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 = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
a = []
for j in range(len(N)):
    for i in range(len(num)):
        if int(N[j]) <= int(num[i]):
            ans += num[i]
            break
    if int(ans.ljust(len(N), min(num))) > int(N):
        ans = int(ans.ljust(len(N), min(num)))
        break
# a.append(int(ans))
# ans = ''
# for j in range(len(N)):
#     if j == 0:
#         for i in range(len(num)):
#             print(N[j], num[i])
#             if int(N[j]) <= int(num[i]):
#                 ans += num[i]
#                 break
#     else:
#         ans += min(num)
# a.append(int(ans))
# print(a)
# print(min(a) if min(a) >= int(N) else max(a))
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
a = []
print(num)
for j in range(len(N)):
    for i in range(len(num)):
        if int(N[j]) <= int(num[i]):
            ans += num[i]
            break
    if int(ans.ljust(len(N), min(num))) > int(N):
        ans = int(ans.ljust(len(N), min(num)))
        break
# a.append(int(ans))
# ans = ''
# for j in range(len(N)):
#     if j == 0:
#         for i in range(len(num)):
#             print(N[j], num[i])
#             if int(N[j]) <= int(num[i]):
#                 ans += num[i]
#                 break
#     else:
#         ans += min(num)
# a.append(int(ans))
# print(a)
# print(min(a) if min(a) >= int(N) else max(a))
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = input().split()
D = [i for i in input().split()]
NUM = '0123456789'
num = [i for i in NUM if i not in D]
ans = ''
for j in range(len(N)):
    for i in range(len(num)):
        if int(N[j]) <= int(num[i]):
            ans += num[i]
            break
print(ans)

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
e = []

# print("繰り返す数", len(str(a[0])))
for i in range(len(str(a[0]))):
    while (a[0] % 10) in b:
        # print("no(a[0] % 10):", a[0] % 10, " b:", b)
        a[0] += 1

    # print("ok(a[0] % 10):", a[0] % 10, " b:", b)
    e.append(a[0] % 10)
    a[0] = int(a[0] / 10)
    # print(a[0])
e.reverse()
e_str = map(str, e)
f = "".join(e_str)
print(int(f))

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
e = []

# print("繰り返す数", len(str(a[0])))
for i in range(len(str(a[0]))):
    while (a[0] % 10) in b:
        # print("bada[0]=", a[0])
        a[0] += 1

    # print("gooda[0]=", a[0], "→")
    e.append(a[0] % 10)
    a[0] = int(a[0] / 10)
    # print(a[0])
e.reverse()
e_str = map(str, e)
f = "".join(e_str)
print(int(f))

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
e = []

# print("繰り返す数", len(str(a[0])))
for i in range(len(str(a[0]))):
    while (a[0] % 10) in b:
        # print("bada[0]=", a[0])
        a[0] += 1

    # print("gooda[0]=", a[0], "→")
    e.append(a[0] % 10)
    a[0] = int(a[0] / 10)
    print(a[0])
e.reverse()
e_str = map(str, e)
f = "".join(e_str)
print(int(f))

Submission status: Wrong Answer

Solution code:
import itertools as it
price, hate = input().split()
price = int(price)
hate = int(hate)
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

number_of_hate = [x for x in input().split()]
number_of_like = []

# print(number_of_hate)

flag1 = False
flag2 = False
flag3 = False
f4 = False
for c in range(0, 10):
    if str(c) not in number_of_hate:
        number_of_like.append(str(c))
# number_of_like.sort()
if price >= 1000:
    ans = ['0', '0', '0', '0']
    value_of_thou = int(str(price // 1000))
    value_of_hun = int(str((price // 100) % 10))
    value_of_ten = int(str((price // 10) % 10))
    value_of_one = int(str(price % 10))
    for c in range(len(number_of_like)):
        if value_of_thou <= int(number_of_like[c]):
            ans[0] = number_of_like[c]
            ans[1] = number_of_like[0]
            ans[2] = number_of_like[0]
            ans[3] = number_of_like[0]
            #flag1 = True
            break
            """"
            if value_of_hun <= int(number_of_like[c]) and flag2 is False:
                ans[1] = number_of_like[c]
                flag2 = True
            if value_of_ten <= int(number_of_like[c]) and flag3 is False:
                ans[2] = number_of_like[c]
                flag3 = True
            if value_of_one <= int(number_of_like[c]) and f4 is False:
                ans[3] = number_of_like[c]
                f4 = True
            if flag1 is True and flag2 is True and flag3 is True and f4 is True:
                break
            """
    for i in ans:
        print(i, end="")
elif price >= 100:
    ans = ['0', '0', '0']
    value_of_hun = int(str(price // 100))
    value_of_ten = int(str((price % 100) // 10))
    value_of_one = int(str(price % 10))
    for c in range(len(number_of_like)):
        if value_of_hun <= int(number_of_like[c]) and flag1 is False:
            ans[0] = number_of_like[c]
            ans[1] = number_of_like[0]
            ans[2] = number_of_like[0]
            flag1 = True
            break
            """
            if value_of_ten <= int(number_of_like[c]) and flag2 is False:
                ans[1] = number_of_like[c]
                flag2 = True
            if value_of_one <= int(number_of_like[c]) and flag3 is False:
                ans[2] = number_of_like[c]
                flag3 = True
        if flag1 is True and flag2 is True and flag3 is True:
            break
        """
    for i in ans:
        print(i, end="")
elif price >= 10:
    ans = ['0', '0']
    value_of_ten = int(str(price // 10))
    value_of_one = int(str(price % 10))
    for c in range(len(number_of_like)):
        if value_of_ten <= int(number_of_like[c]):
            ans[0] = number_of_like[c]
            ans[1] = number_of_hate[0]
            break
            """"
            if value_of_one <= int(number_of_like[c]) and flag2 is False:
                ans[1] = number_of_like[c]
                flag2 = True
            if flag1 is True and flag2 is True:
                break
                """
    for i in ans:
        print(i, end="")
else:
    value_of_one = int(str(price))
    for c in range(len(number_of_like)):
        if value_of_one <= int(number_of_like[c]):
            print(number_of_like[c], end="")
            break
print()

Submission status: Wrong Answer

Solution code:
import itertools as it
price, hate = input().split()
price = int(price)
hate = int(hate)
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

number_of_hate = [x for x in input().split()]
number_of_like = []

# print(number_of_hate)

flag1 = False
flag2 = False
flag3 = False
f4 = False
for c in range(0, 10):
    if str(c) not in number_of_hate:
        number_of_like.append(str(c))
# number_of_like.sort()
if price >= 1000:
    ans = ['0', '0', '0', '0']
    value_of_thou = int(str(price // 1000))
    value_of_hun = int(str((price // 100) % 10))
    value_of_ten = int(str((price // 10) % 10))
    value_of_one = int(str(price % 10))
    for c in range(len(number_of_like)):
        if value_of_thou <= int(number_of_like[c]) and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 = True
        if value_of_hun <= int(number_of_like[c]) and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 = True
        if value_of_ten <= int(number_of_like[c]) and flag3 is False:
            ans[2] = number_of_like[c]
            flag3 = True
        if value_of_one <= int(number_of_like[c]) and f4 is False:
            ans[3] = number_of_like[c]
            f4 = True
        if flag1 is True and flag2 is True and flag3 is True and f4 is True:
            break
    for i in ans:
        print(i, end="")
elif price >= 100:
    ans = ['0', '0', '0']
    value_of_hun = int(str(price // 100))
    value_of_ten = int(str((price % 100) // 10))
    value_of_one = int(str(price % 10))
    for c in range(len(number_of_like)):
        if value_of_hun <= int(number_of_like[c]) and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 = True
        if value_of_ten <= int(number_of_like[c]) and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 = True
        if value_of_one <= int(number_of_like[c]) and flag3 is False:
            ans[2] = number_of_like[c]
            flag3 = True
        if flag1 is True and flag2 is True and flag3 is True:
            break
    for i in ans:
        print(i, end="")
elif price >= 10:
    ans = ['0', '0']
    value_of_ten = int(str(price // 10))
    value_of_one = int(str(price % 10))
    for c in range(len(number_of_like)):
        if value_of_ten <= int(number_of_like[c]) and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 = True
        if value_of_one <= int(number_of_like[c]) and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 = True
        if flag1 is True and flag2 is True:
            break
    for i in ans:
        print(i, end="")
else:
    value_of_one = int(str(price))
    for c in range(len(number_of_like)):
        if value_of_one <= int(number_of_like[c]):
            print(number_of_like[c], end="")
            break
print()

Submission status: Wrong Answer

Solution code:
import itertools as it
price, hate = input().split()
price = int(price)
hate = int(hate)
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

number_of_hate = [x for x in input().split()]
number_of_like = []

# print(number_of_hate)

flag1 = False
flag2 = False
flag3 = False
f4 = False
for c in range(0, 10):
    if str(c) not in number_of_hate:
        number_of_like.append(str(c))
# number_of_like.sort()
# print(number_of_like)
if price >= 1000:
    ans = ['0', '0', '0', '0']
    value_of_thou = int(str(price // 1000))
    value_of_hun = int(str((price // 100) % 10))
    value_of_ten = int(str((price // 10) % 10))
    value_of_one = int(str(price % 10))
    # print(value_of_thou)
    # print(value_of_hun)
    # print(value_of_ten)
    # print(value_of_one)
    for c in range(len(number_of_like)):
        # print(number_of_like[c])

        if value_of_thou <= int(number_of_like[c]) and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 = True
        if value_of_hun <= int(number_of_like[c]) and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 = True
        if value_of_ten <= int(number_of_like[c]) and flag3 is False:
            ans[2] = number_of_like[c]
            flag3 = True
        if value_of_one <= int(number_of_like[c]) and f4 is False:
            ans[3] = number_of_like[c]
            f4 = True
        if flag1 is True and flag2 is True and flag3 is True and f4 is True:
            break
    for i in ans:
        print(i, end="")
elif price >= 100:
    ans = ['0', '0', '0']
    value_of_hun = str(price // 100)
    value_of_ten = str((price % 100) // 10)
    value_of_one = str(price % 10)
    for c in range(len(number_of_like)):
        if value_of_hun <= number_of_like[c] and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 = True
        if value_of_ten <= number_of_like[c] and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 = True
        if value_of_one <= number_of_like[c] and flag3 is False:
            ans[2] = number_of_like[c]
            flag3 = True
        if flag1 is True and flag2 is True and flag3 is True:
            break
    for i in ans:
        print(i, end="")
elif price >= 10:
    ans = ['0', '0']
    value_of_ten = str(price // 10)
    value_of_one = str(price % 10)
    for c in range(len(number_of_like)):
        if value_of_ten <= number_of_like[c] and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 is True
        if value_of_one <= number_of_like[c] and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 is True
        if flag1 is True and flag2:
            break
    for i in ans:
        print(i, end=" ")
else:
    value_of_one = str(price)
    for c in range(len(number_of_like)):
        if value_of_one <= number_of_like[c]:
            print(number_of_like[c], end="")
            break
print()

Submission status: Wrong Answer

Solution code:
import itertools as it
price, hate = input().split()
price = int(price)
hate = int(hate)
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

number_of_hate = [x for x in input().split()]
number_of_like = []

# print(number_of_hate)

flag1 = False
flag2 = False
flag3 = False
f4 = False
for c in range(0, 10):
    if str(c) not in number_of_hate:
        number_of_like.append(str(c))
# number_of_like.sort()
# print(number_of_like)
if price >= 1000:
    ans = ['0', '0', '0', '0']
    value_of_thou = int(str(price // 1000))
    value_of_hun = int(str((price // 100) % 10))
    value_of_ten = int(str((price // 10) % 10))
    value_of_one = int(str(price % 10))
    # print(value_of_thou)
    # print(value_of_hun)
    # print(value_of_ten)
    # print(value_of_one)
    for c in range(len(number_of_like)):
        # print(number_of_like[c])

        if value_of_thou <= int(number_of_like[c]) and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 = True
        if value_of_hun <= int(number_of_like[c]) and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 = True
        if value_of_ten <= int(number_of_like[c]) and flag3 is False:
            ans[2] = number_of_like[c]
            flag3 = True
        if value_of_one <= int(number_of_like[c]) and f4 is False:
            ans[3] = number_of_like[c]
            f4 = True
        if flag1 is True and flag2 is True and flag3 is True and f4 is True:
            break
    for i in ans:
        print(i, end="")
elif price >= 100:
    ans = ['0', '0', '0']
    value_of_hun = str(price // 100)
    value_of_ten = str((price % 100) // 10)
    value_of_one = str(price % 10)
    for c in range(len(number_of_like)):
        if value_of_hun <= number_of_like[c] and flag1 is False:
            ans[0] = number_of_like[c]
            flag1 = True
        if value_of_ten <= number_of_like[c] and flag2 is False:
            ans[1] = number_of_like[c]
            flag2 = True
        if value_of_one <= number_of_like[c] and flag3 is False:
            ans[2] = number_of_like[c]
            flag1 = True
        for i in ans:
            print(i, end="")
else:
    ans = ['0', '0']
    value_of_ten = str(price // 10)
    value_of_one = str(price % 10)
    for c in range(len(number_of_like)):
        if value_of_ten <= number_of_like[c]:
            ans[0] = number_of_like[c]
        if value_of_one <= number_of_like[c]:
            ans[1] = number_of_like[c]
    for i in ans:
        print(i, end=" ")
print()

Submission status: Wrong Answer

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

number = {0,1,2,3,4,5,6,7,8,9}
dislike = set(li)
like = number - dislike
price = [int(i) for i in str(ints[0])]
length = len(price)
for i in range(length)[::-1]:
    if price[i] not in like:
        for j in like:
            if j > price[i]:
                price[i] = j
                break
        else:
            price[i-1] = price[i-1]+1
            price[i] = 0
            for j in like:
                if j > price[i]:
                    price[i] = j
for i in range(length):
    print(price[i], end="")

Submission status: Wrong Answer

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

number = {0,1,2,3,4,5,6,7,8,9}
dislike = set(li)
like = number - dislike
price = [int(i) for i in str(ints[0])]
length = len(price)
for i in range(length)[::-1]:
    if price[i] not in like:
        for j in like:
            if j > price[i]:
                price[i] = j
        else:
            price[i-1] = price[i-1]+1
            for j in like:
                price[i] = 0
                if j > price[i]:
                    price[i] = j
for i in range(length):
    print(price[i], end="")

Submission status: Wrong Answer

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

number = {0,1,2,3,4,5,6,7,8,9}
dislike = set(li)
like = number - dislike
price = [int(i) for i in str(ints[0])]
length = len(price)
for i in range(length)[::-1]:
    if price[i] not in like:
        for j in like:
            if j > price[i]:
                price[i] = j
        else:
            price[i-1] = price[i-1]+1
            for j in like:
                if j >= 0:
                    price[i] = j
for i in range(length):
    print(price[i], end="")

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
d_n = [i for i in range(10) if i not in d]
n_c = [int(c) for c in n]
re = []
for i in n_c:
    for j in d_n:
        if i <= j:
            re.append(j)
            break
re_s = map(str, re)
moji = ",".join(re_s).replace(",", "")
print(moji)
"""
print(d)
print(d_n)
print(n_c)
print(re)
"""

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
nlist = list(map(int, n))
tmp = -10
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            if (0 not in d) and tmp == (i - 1):
                nlist[i] = 0
            else:
                if tmp== (i - 1):
                    l = 0
                    while l < 10:
                        if l not in d:
                            nlist[i] = l
                            l = 10
                            tmp = i
                        l += 1
                else:
                    nlist[i] += 1
                tmp = i
        else:
            if tmp == (i - 1):
                l = 0
                while l < 10:
                    if l not in d:
                        #print(l,i,nlist[i])
                        nlist[i] = l
                        l = 10
                        #print(l,  i,nlist[i])
                        tmp = i
                    l += 1
            j = 10
#print(nlist)
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
nlist = list(map(int, n))
tmp = -10
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            if (0 not in d) and tmp == (i - 1):
                nlist[i] = 0
            else:
                nlist[i] += 1
                tmp = i
        else:
            if tmp == (i - 1):
                nlist[i] = 0
                tmp = i
            j = 10
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
nlist = list(map(int, n))
tmp = 0
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            if (0 not in d) and tmp == (i - 1):
                nlist[i] = 0
            else:
                nlist[i] += 1
                tmp = i
        else:
            j = 10
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
nlist = list(map(int, n))
tmp = 0
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            if (0 not in d) and tmp == 1:
                nlist[i] = 0
            else:
                nlist[i] += 1
                tmp = 1
        else:
            j = 10
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
nlist = list(map(int, n))
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            if 0 in d:
                nlist[i] = 0
            else:
                nlist[i] += 1
        else:
            j = 10
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
nlist = list(map(int, n))
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            nlist[i] += 1
        else:
            j = 10
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = list(map(int, input().split()))
nlist = list(map(int, n))
print(len(nlist),d)
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            nlist[i] += 1
        else:
            j = 10
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
d = map(int, input().split())
nlist = list(map(int, n))
for i in range(len(nlist)):
    for j in range(10):
        if nlist[i] in d:
            nlist[i] += 1
        else:
            j = 10
print("".join(map(str, nlist)))

Submission status: Wrong Answer

Solution code:
N,K = map(str, input().split())
D = set(map(int,input().split()))
E = {0,1,2,3,4,5,6,7,8,9}
F = E - D
f = max(F)
swith = 0
if 0 in F:
    g =str(list(F)[1])
else:
    g = str(min(F))
list = ["1"]*len(N)
length = len(N)
for n in range(length):
    if int(N[n]) in D:
        swith = 1
        for l in range(n+1,length):
             list[l] = str(min(F)) 
        if int(N[n]) >= f:
              list[n] = str(min(F))
              if n == 0:
                     list.insert(0,str(g))
        else:
              H = {}
              H = set(range(int(N[n]) + 1))
              list[n] =  str(min(F - H))
    if swith == 1:
        break
print(''.join(list))

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
D_rest = list(i for i in range(10))

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

for i in range(len(D)):
    D_rest.remove(D[i])

flag = False
for i in range(len(N_split)):
    if flag:
        N_split[i] = min(D_rest)
    if N_split[i] in D:
        flag = True
        for j in range(len(D_rest)):
            temp = D_rest[j]
            if temp > N_split[i]:
                N_split[i] = temp
                break

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

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
D_rest = list(i for i in range(10))

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

for i in range(len(D)):
    D_rest.remove(D[i])

flag = False
for i in range(len(N_split)):
    if flag:
        N_split[i] = min(D_rest)
    if N_split[i] in D:
        flag = True
        for j in range(len(D_rest)):
            temp = D_rest[j]
            if temp > N_split[i]:
                N_split[i] = temp
                break



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

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = list(map(int, input().split()))
D_rest = list(i for i in range(10))

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

for i in range(len(D)):
    D_rest.remove(D[i])

for i in range(len(N_split)):
    if N_split[i] in D:
        for j in range(len(D_rest)):
            temp = D_rest[j]
            if temp > N_split[i]:
                N_split[i] = temp
                break

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

Submission status: Wrong Answer

Solution code:
import sys
N, K = map(int, input().split())
D = list(map(int, input().split()))
like = set(range(10)) - set(D)
while True:
    for i in str(N):
        if int(i) not in like:
            N += 1
            break
        else:
            print(N)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N, K = map(int, input().split())
D = list(map(int, input().split()))
like = set(range(10)) - set(D)
cost = N
while True:
    for i in str(cost):
        if int(i) not in like:
            cost += 1
            break
        else:
            print(cost)
            sys.exit()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
D = set(map(int,input().split()))
N = set(range(10))
N -= D
Ans = list(N)
mini = 10**10
length = 1

while length <= len(str(n)) or mini == 10**10:
    temp = []
    for ans in Ans:
        for num in N:
            temp.append(ans*10 + num)
            if mini >= ans*10 + num and ans*10 + num >= n:
                mini = ans * 10 + num
    Ans = temp
    length += 1
print(mini)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
D = set(map(int,input().split()))
N = set(range(10))
N -= D
Ans = list(N)
mini = 10**10
length = 1

while length <= len(str(n)):
    temp = []
    for ans in Ans:
        for num in N:
            temp.append(ans*10 + num)
            if mini >= ans*10 + num and ans*10 + num >= n:
                mini = ans * 10 + num
    Ans = temp
    length += 1
print(mini)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=input().split()
stopcode=False
while stopcode==False:
  for i in range(len(str(n))):
    if str(n)[i] in d:
      n+=1
      break
    else:
      stopcode=True
      break
print(n)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
L = [int(v) for v in input().split()]
no = [v for v in range(10) if v not in L]

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

for i in range(len(s)):
    if i == 0:
        if s[i] in L:
            s[i] = min([v for v in no if v != 0])
    else:
        if s[i] in L:
            s[i] = min(no)
            
print("".join(map(str, s)))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
l = list(input().split())
l1 = []
for j in range(10):
  if str(j) not in l:
    l1.append(j)
a = ""
b = n
c = ""
for i in n:
  if i not in l:
    a += i
if a == n:
  print(a)
else:
  for j in range(len(b)):
    if j == 0:
      for i in range(10):
        if i > int(n[0]):
          c += str(i)
          break
    else:
      c += str(min(l1))
  print(c)

Submission status: Wrong Answer

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

kouho = list(map(str, range(0, 9)))

for i in d:
  for j in kouho:
    if i == j:
      kouho.remove(j)
      break

# print(kouho)

while(1):
  strcount = 0
  
  for j in kouho:
    # print(j, n, str(n), len(str(n)), str(n).count(j))
    if(str(n).count(j) != 0):
      strcount += str(n).count(j)
      
  # print(strcount)
  
  if(strcount == len(str(n))):
    print(n)
    exit()
    
  n += 1

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
*D, = map(int,input().split())
for i in range(N,10000):
    for n in str(i):
        if int(n) in D:
            break
    else:
        break
print(i)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(n,10000+1):
  s=set(str(i))
  for j in range(k):
    if str(d[j]) in s:
      break
  else:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#mathをインポート
import math
#n円が金額、嫌いな数がk個。入力
n,k=map(int,input().split(" "))
#嫌いな文字リスト
klist=input().split(" ")
def hantei(n,kl):
    if len(str(n))==4:
        while math.floor(n/1000)==kl or \
        math.floor(n/100)-10*math.floor(n/1000)==kl or \
        math.floor(n/10)-10*math.floor(n/100)==kl or \
        n-10*math.floor(n/10)==kl:
            n=n+1
    elif len(str(n))==3:
        while math.floor(n/100)==kl or \
        math.floor(n/10)-10*math.floor(n/100)==kl or \
        n-10*math.floor(n/10)==kl:
            n=n+1
    elif len(str(n))==2:
        while math.floor(n/10)==kl or \
        n-10*math.floor(n/10)==kl:
            n=n+1
    elif len(str(n))==1:
        while n==kl:
            n=n+1
    return int(n)
n2=n
for kl in klist:
    kl=int(kl)
    n=hantei(n,kl)
while n!=n2:
    n2=n
    for kl in klist:
        kl=int(kl)
        n=hantei(n,kl)
print(n)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#mathをインポート
import math
#n円が金額、嫌いな数がk個。入力
n,k=map(int,input().split(" "))
#嫌いな文字リスト
klist=input().split(" ")
for kl in klist:
        kl=int(kl)
        if len(str(n))==4:
            while math.floor(n/1000)==kl or \
            math.floor(n/100)-10*math.floor(n/1000)==kl or \
            math.floor(n/10)-10*math.floor(n/100)==kl or \
            n-10*math.floor(n/10)==kl:
                n=n+1
        elif len(str(n))==3:
            while \
            math.floor(n/100)==kl or \
            math.floor(n/10)-10*math.floor(n/100)==kl or \
            n-10*math.floor(n/10)==kl:
                n=n+1
        elif len(str(n))==2:
            while \
            math.floor(n/10)==kl or \
            n-10*math.floor(n/10)==kl:
                n=n+1
        elif len(str(n))==1:
            while n==kl:
                n=n+1
print(n)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#mathをインポート
import math
#n円が金額、嫌いな数がk個。入力
n,k=map(int,input().split(" "))
#嫌いな文字リスト
klist=input().split(" ")
end=0
for kl in klist:
        kl=int(kl)
        while math.floor(n/1000)==kl or math.floor(n/100)-10*math.floor(n/1000)==kl or \
        math.floor(n/10)-10*math.floor(n/100)==kl or \
        n-10*math.floor(n/10)==kl:
            n=n+1
print(n)

Submission status: Wrong Answer

Solution code:
#n=int(input())
ans=10**6
n,k=map(int,input().split())
p=[int(i) for i in input().split()]
s=[]
for i in range(10):
    if i not in p:
        s.append(str(i))
        
for a in s+['0']:
    for b in s:
        for c in s:
            for d in s:
                for e in s:
                    x=int(a+b+c+d+e)
                    if x>=n:
                        ans=min(x,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
#n=int(input())
ans=10**6
n,k=map(int,input().split())
p=[int(i) for i in input().split()]
s=[]
for i in range(10):
    if i not in p:
        s.append(str(i))
        
for a in s:
    for b in s:
        for c in s:
            for d in s:
                for e in s:
                    x=int(a+b+c+d+e)
                    if x>=n:
                        ans=min(x,ans)
print(ans)