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 = [x for x in input().split()]
D = [x for x in input().split()]

M = N
if len(D) == 9:
  ans = 0
else:
  while True:
    N_ = 0
    for i,n in enumerate(N):
      if n in D:
        N_ += (int(n) + 1) * 10 ** (len(N) - 1 - i)
        break
      else:
        N_ += int(n) * 10 ** (len(N) - 1 - i)
    else:
      break
    N = str(N_)
          
print(N)

Submission status: Wrong Answer

Solution code:
n, k = (int(x) for x in input().split())
dislike_numbers = input().split()

for i in range(n, 10000):
    if all(dn not in str(i) for dn in dislike_numbers):
        print(i)
        break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    D = inputList()
    
    base = list(range(10))
    for vol in D:
        base.remove(vol)
        
    ans = ""
    NN = str(N)
    flg = False
    for i,val in enumerate(NN):
        isInp = False
        for j,vol in enumerate(base):
            if flg == True:
                ans += str(vol)
                isInp = True
                break
            tmp = int(val)
            if tmp == vol:
                ans += val
                isInp = True
                break
            elif tmp < vol:
                flg = True
                ans += str(vol)
                isInp = True
                break
            else:
                continue
        
        if isInp == False:
            ans += "*"
    
    ans = list(ans)
    ans_T = ""
    if ans[0] == "*":
        if base[0] != 0:
            ans_T += str(base[0])
            for i in range(len(str(N))):
                ans_T += str(base[0])
        else:
            ans_T += str(base[1])
            for i in range(len(str(N))):
                ans_T += str(base[0])
                
        print(ans_T)
        sys.exit()
            
    print("".join(ans))
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    D = inputList()
    
    base = list(range(10))
    for vol in D:
        base.remove(vol)
        
    ans = ""
    NN = str(N)
    flg = False
    for i,val in enumerate(NN):
        for j,vol in enumerate(base):
            if flg == True:
                ans += str(vol)
                break
            tmp = int(val)
            if tmp == vol:
                ans += val
                break
            elif tmp < vol:
                flg = True
                ans += str(vol)
                break
            else:
                continue
    
    print(ans)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
d = list(map(str, input().split()))
num = [0 for _ in range(10)]

for v in d:
    num[int(v)] = 1

for j in range(1, 100000):
    v = j * n
    v_l = list(str(v))
    flag = True
    for i in v_l:
        if num[int(i)] == 1:
            flag = False
            break
    if flag:
        print(v)
        exit()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
d = list(map(str, input().split()))
num = [0 for _ in range(10)]

for v in d:
    num[int(v)] = 1

for j in range(1, 1000):
    v = j * n
    v_l = list(str(v))
    flag = True
    for i in v_l:
        if num[int(i)] == 1:
            flag = False
            break
    if flag:
        print(v)
        exit()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
d = list(map(str, input().split()))
num = [0 for _ in range(10)]

for v in d:
    num[int(v)] = 1

for j in range(1, 11):
    v = j * n
    v_l = list(str(v))
    flag = True
    for i in v_l:
        if num[int(i)]:
            flag = False
            break
    if flag:
        print(v)
        exit()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
d = list(map(str, input().split()))
num = [0 for _ in range(10)]

for v in d:
    num[int(v)] = 1

v = n
while True:
    v_l = list(str(v))
    flag = True
    for i in v_l:
        if num[int(i)]:
            flag = False
            break
    if flag:
        print(v)
        exit()
    else:
        v += n

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
d = list(map(str, input().split()))
v = n
while True:
    v_l = list(str(v))
    flag = True
    for i in v_l:
        if i in d:
            flag = False
            break
    if flag:
        print(v)
        exit()
    else:
        v += n

Submission status: Wrong Answer

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


dislike_number = set(map(int, input().split()))
num = set([i for i in range(10)])
ok_num = list(num - dislike_number)
ok_num = sorted(ok_num)



import math
import copy
max_len = len(str(N))
ok_num_len=len(ok_num)
visited = {}
widths=[0]*(max_len+1)

def dfs(num, depth, widths):
    check=""
    for i in widths[depth:]:
        check += str(ok_num[i])
    check = int(check)
    
#     if check in visited:
#         return num
    visited[check]=1
    
    if N <= check  < num:
        num=check
    if depth-1>=0:
        num =dfs(num, depth-1,widths)
    
    if widths[depth]+1<ok_num_len:
        temp=copy.deepcopy(widths)
        temp[depth]+=1
        num = dfs(num, depth,temp)
    return num

print(dfs(10**max_len, max_len, widths))

Submission status: Wrong Answer

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


dislike_number = set(map(int, input().split()))
num = set([i for i in range(10)])
ok_num = list(num - dislike_number)
ok_num = sorted(ok_num)



import math
import copy
max_len = len(str(N))
ok_num_len=len(ok_num)
visited = {}
widths=[0]*(max_len+1)

def dfs(num, depth, widths):
    check=""
    for i in widths[depth:]:
        check += str(ok_num[i])
    check = int(check)
    if check in visited:
        return num
    visited[check]=1
    
    if N <= check  < num:
        num=check
    if depth-1>=0:
        num =dfs(num, depth-1,widths)
    
    if widths[depth]+1<ok_num_len:
        temp=copy.deepcopy(widths)
        temp[depth]+=1
        num = dfs(num, depth,temp)
    return num

print(dfs(10**max_len, max_len, widths))

Submission status: Wrong Answer

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


dislike_number = set(map(int, input().split()))
num = set([i for i in range(10)])
ok_num = list(num - dislike_number)
ok_num = sorted(ok_num)



import math
import copy
max_len = len(str(N))
ok_num_len=len(ok_num)
visited = {}
widths=[0]*(max_len+1)

def dfs(num, depth, widths):
    check=""
    for i in widths:
        check += str(ok_num[i])
    check = int(check)
    if N <= check  < num:
        num=check
    if depth+1<=max_len:
        num =dfs(num, depth+1,widths)
    
    if widths[depth]+1<ok_num_len:
        temp=copy.deepcopy(widths)
        temp[depth]+=1
        num = dfs(num, depth,temp)
    return num

print(dfs(10**max_len, 0, widths))

Submission status: Wrong Answer

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

carry = 0
ans = ""
for i in reversed(range(len(N))):
    N_i = int(N[i])
    N_i += carry
    while(True):
        if N_i%10 in d:
            N_i += 1
        else:
            break
    ans = str(N_i%10) + ans
    carry = N_i//10

while(carry != 0):
    while(True):
        if carry%10 in d:
            carry += 1
        else:
            break
    ans = str(carry%10) + ans
    carry = carry//10

print(ans)

Submission status: Wrong Answer

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

carry = 0
ans = ""
for i in reversed(range(len(N))):
    N_i = int(N[i])
    N_i += carry
    while(True):
        if N_i%10 in d:
            N_i += 1
        else:
            break
    ans = str(N_i%10) + ans
    carry = N_i//10

if(carry > 0):
    ans = str(carry) + ans
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(str,input().split())
d = list(map(int,input().split()))
not_d = [i for i in range(10) if i not in d]

carry = 0
ans = ""
for i in reversed(range(len(N))):
    N_i = int(N[i])
    N_i += carry
    while(True):
        if N_i%10 in d:
            N_i += 1
        else:
            break
    ans = str(N_i%10) + ans
    carry = N_i//10

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
s=input().split()
money,num=int(s[0]),int(s[1])
no_list=input().split()
if len(no_list)!=num:
    sys.exit()
for i in range(money,10000):
    origin=i
    flag=0
    while i!=0:
        if str(i%10) in no_list:
            flag=1
            break
        i//=10
    if flag==0:
        print(origin)
        break

Submission status: Wrong Answer

Solution code:
s=input().split()
money,num=int(s[0]),int(s[1])
no_list=input().split()
for i in range(money,10000):
    origin=i
    flag=0
    while i!=0:
        if str(i%10) in no_list:
            flag=1
            break
        i=i//10
    if flag==0:
        print(origin)
        break

Submission status: Wrong Answer

Solution code:
s=input().split()
money,num=int(s[0]),int(s[1])
no_list=input().split()
for i in range(money,10000):
    origin=i
    flag=0
    while i!=0:
        if str(i%10) in no_list:
            flag=1
            break
        i//=10
    if flag==0:
        print(origin)
        break

Submission status: Wrong Answer

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

for i in range(n,10001):
    ans=list(str(i))
    flag=0
    for x in ans:
        if x  in d:
            flag=1
    if flag==0:
        print(''.join(ans))
        sys.exit()

Submission status: Wrong Answer

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

for i in range(n,10001):
    ans=list(str(i))
    for x in ans:
        if x  in lista:
            break
        print(''.join(ans))
        sys.exit()

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
l = list(map(int, input().split()))
num = [i for i in range(10) if i not in l]

print(l)
while True:    
    N_str = str(N)
    frag = 0
    for i in range(len(N_str)):
        if int(N_str[i]) in l:
            #print("yes")
            frag = 1
            break
    if frag == 0:
        break
    else:
        N += 1
print(N)

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
d = set(map(int,input().split()))
num = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
usable = num - d
ans = []

n_list = [int(x) for x in list(str(n))]
for i in n_list:
    if i in usable:
        ans.append(i)
    else:
        for j in usable:
            if i < j:
                ans.append(j)
for i in ans:
    print(i, end='')

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=set(map(int,input().split()))
i=n
a=[]
for j in range(len(str(n))):
	a.append(str(n)[j])
a=set(a)
while i<10**5+1:
	if len(a&d)==0:
		print(i)
		exit()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
m=len(str(n))
a=[0]
for i in range(m):
	a.append(int(str(n)[i]))
for i in range(1,m+2):
	if i==m+1 and a[0]==0:
		break
	j=a[-i]
	if j==10:
		j=0
		a[-i-1]+=1
	while j<=10:
		if j in d:
			j+=1
		else:
			break
		if j==10:
			j=0
			a[-i-1]+=1
	a[-i]=j
ans=0
for i in range(m+1):
	ans+=10**i*a[-i-1]
print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
l = list(map(int, input().split()))
num = [i for i in range(10) if i not in l]
digit = []
while N>0:
    digit.append(N%10)
    N = N//10
digit.reverse()
retval = []
print(digit)
print(num)
if digit[0] > num[-1]:
    if num[0] == 0:
        retval.append(str(num[1]))
        for i in range(len(digit)):
            retval.append(str(num[0]))
    else:
        for i in range(len(digit)+1):
            retval.append(str(num[0]))
else:
    for i in range(len(digit)):
        m = 10000000
        for j in num:
            if j < m and j >= digit[i]:
                m = j
                break
        retval.append(str(m))
        print(digit[i])
        print(m)
        if digit[i] == m:
            #print("yes")
            for k in range(len(digit)-i-1):
                retval.append(str(num[0]))
            break
        else: continue

#print(retval)
print("".join(retval))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=[int(i) for i in input().split()]

num=[0,1,2,3,4,5,6,7,8,9]
ok=[]
for tmp in num:
  if tmp not in d:
    ok.append(tmp)
    
ans=[]
for tmp in str(n):
  for k in ok:
    if int(tmp)<=k:
      ans.append(k)
      break
print(*ans,sep='')

Submission status: Wrong Answer

Solution code:
#入力
n, k = map(int, input().split())
d = input().split()
stop = min(10000, int(n) * 10)

for l in range(n, stop + 1):
  a = str(n)
  flag = 0
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % k) != 0 or flag == 0:
      break
  if flag == len(a) * k:
    break
print(n)

Submission status: Wrong Answer

Solution code:
#入力
n, k = map(int, input().split())
d = input().split()
stop = min(10000, int(n) * 10)

for l in range(n, stop):
  a = str(n)
  flag = 0
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % k) != 0 or flag == 0:
      break
  if flag == len(a) * k:
    break
print(n)

Submission status: Wrong Answer

Solution code:
#入力
n, k = map(int, input().split())
d = input().split()
stop = min(10000, n * 10)

for l in range(n, stop):
  a = str(n)
  flag = 0
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % k) != 0 and flag != 0:
      break
  if flag == len(a) * k:
    break
print(n)

Submission status: Wrong Answer

Solution code:
inputted = input().split(" ")
N=int(inputted[0])
K=int(inputted[1])
s = [i for i in input() if i != ' ']

num=0
while True:
  num+=1
  match=[i for i in str(num) if i not in s]
  if num>=N and len(match)>=len(str(N)):
    print(num)
    break

Submission status: Wrong Answer

Solution code:
inputted = input().split(" ")
N=int(inputted[0])
K=int(inputted[1])
s = [i for i in input() if i != ' ']

num=0
while True:
  num+=1
  match=[i for i in str(num) if i not in s]
  if num>=N and len(match)==len(str(N)):
    print(num)
    break

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
N = str(N)
D = list(map(int, input().split()))
elD = []
ans = ""
for i in range(10):
    if i not in D:
        elD.append(str(i))
    
for i in range(len(N)):
    for j in range(len(elD)):
        if N[i] <= elD[j]:
            ans += elD[j]
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
d = list(map(int,input().split()))
use = [x for x in range(10) if x not in d]
ans = []
n = list(str(n))
for i in range(len(n)):
  for j in range(len(use)):
    if int(n[i]) == use[j]:
      ans.append(str(use[j]))
      break
    elif int(n[i]) < use[j]:
      ans.append(str(use[j]))
      break
print("".join(ans))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
d = list(map(int,input().split()))
use = [i for i in range(11) if i not in d]
q = 0
ans = []
n = list(str(n))
for i in range(len(n)):
  for j in range(len(use)):
    if int(n[i]) == use[j]:
      ans.append(str(use[j]))
      break
    elif int(n[i]) < use[j]:
      ans.append(str(use[j]))
      break
print("".join(ans))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
d = list(map(int,input().split()))
use = [i for i in range(11) if i not in d]
q = 0
ans = []
n = list(str(n))
for i in range(len(n)):
  for j in range(len(use)):
    if int(n[i]) == use[j] and q != len(n):
      ans.append(str(use[j]))
      q += 1
      break
    elif int(n[i]) < use[j] or (n[i] == use[j] and q == len(n)):
      ans.append(str(use[j]))
      break
print("".join(ans))

Submission status: Wrong Answer

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

bad = [int(i) for i in input().split()]

j = 1
allowzero = True
for i in bad:
    if i == 0:
        allowzero = False
    if j == i:
        j += 1

bad.sort(reverse = True)

okay = list(range(10))
for i in bad:
    if i == 9:
        okay[i] = (j * 10) if allowzero else (j * 10 + j)
    else:
        okay[i] = okay[i+1]

ans = [okay[i] for i in n_digits]
print(int(''.join(map(str,ans))))

Submission status: Wrong Answer

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

bad = [int(i) for i in input().split()]
bad.sort(reverse = True)

okay = list(range(10))
for i in bad:
    if i == 9:
        okay[i] = 10
    else:
        okay[i] = okay[i+1]

ans = [okay[i] for i in n_digits]
print(int(''.join(map(str,ans))))

Submission status: Wrong Answer

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

bad = [int(i) for i in input().split()]
bad.reverse()
okay = list(range(10))
for i in bad:
    if i == 9:
        okay[i] = 10
    else:
        okay[i] = okay[i+1]

ans = [okay[i] for i in n_digits]
print(int(''.join(map(str,ans))))

Submission status: Wrong Answer

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

for i in range(n, 10000):
    flg = 0
    for s in str(i):
        if int(s) in dlist:
            flg = 1
            break
    if flg == 0:
        print(i)
        break

Submission status: Wrong Answer

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

for i in range(n, 10000):
    flg = True
    for s in str(i):
        if int(s) in dlist:
            flg = False
            break
    if flg:
        print(i)
        break

Submission status: Wrong Answer

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

for i in range(n, 10000):
    flg = True
    for s in str(i):
        if s in dlist:
            flg = False
            break
    if flg:
        print(i)
        break

Submission status: Wrong Answer

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

for i in range(n, 10000):
    flg = True
    for j in dlist:
        if str(j) in str(i):
            flg = False
            break
    if flg:
        print(i)
        break

Submission status: Wrong Answer

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

for i in range(n, 9999):
    s = str(i)
    flg = True
    for j in dlist:
        if j in s:
            flg = False
            break
    if flg:
        print(i)
        break

Submission status: Wrong Answer

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

for i in range(n, 10000):
    s = str(i)
    flg = True
    for j in dlist:
        if j in s:
            flg = False
            continue
    if flg:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
first = raw_input().split()
n, k = int(first[0]), int(first[1])
ds = raw_input().split()
cand = [int(i) for i in range(0, 10)]
for i in range(len(ds)):
    if int(ds[i]) in cand:
        cand.pop(cand.index(int(ds[i])))
cand.sort()  # the rest of candidates
length = len(str(n))


def dfs(cand, output, now):
    if len(now) == length:
        output.append(now)
        return
    for i in range(len(cand)):
        dfs(cand, output, now + str(cand[i]))
    return output


o = dfs(cand, [], '')
for i in range(len(o)):
    if int(o[i]) >= n:
        print int(o[i])
        exit(0)

Submission status: Wrong Answer

Solution code:
def C_IrohasObsession():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    ans = 0
    for x in range(N, 10000):
        for y in str(x):
            if int(y) in D:
                break
        else:
            ans = int(x)
            break
    if N > ans:
        for x in range(1,10):
            if x not in D:
                ans = x * 10000
                break
    print(ans)

if __name__ == "__main__":
    C_IrohasObsession()

Submission status: Wrong Answer

Solution code:
def C_IrohasObsession():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    ans = 0
    for x in range(N, 10000):
        for y in str(x):
            if int(y) in D:
                break
        else:
            ans = int(x)
            break
    if N > ans:
        for x in range(10):
            if x not in D:
                ans = x * 10000
                break
    print(ans)

if __name__ == "__main__":
    C_IrohasObsession()

Submission status: Wrong Answer

Solution code:
def C_IrohasObsession():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    ans = 0
    for x in range(N, 10000):
        for y in str(x):
            if int(y) in D:
                break
        else:
            ans = int(x)
            break
    if N > ans:
        for x in range(10):
            if x not in D:
                ans = x ** 10000
                break
    print(ans)

if __name__ == "__main__":
    C_IrohasObsession()

Submission status: Wrong Answer

Solution code:
def C_IrohasObsession():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    ans = 0
    for x in range(N, 10000):
        for y in str(x):
            if int(y) in D:
                break
        else:
            ans = int(x)
            break
    print(ans)

if __name__ == "__main__":
    C_IrohasObsession()

Submission status: Wrong Answer

Solution code:
N_str, K=input().split()
N_digit=list(map(int,list(N_str)))
D=sorted(list(map(int,input().split())))
l_digit=[n>D[-1] for n in N_digit]

if any(l_digit):
  N_n=l_digit.index(True)
  if not any([n<D[-1] for n in N_digit[0:N_n]]):
    out=[str(D[0]) for i in range(len(N_digit)+1)]
  else:
    out=[str(D[[n<=D[j] for j in range(int(K))].index(True)]) for n in N_digit[0:N_n]] + [str(D[0]) for n in N_digit[N_n:]]
    for k in range(N_n-1,-1,-1):
      if N_digit[k]<D[-1]:
        out[k]=str(D[[N_digit[k]<D[j] for j in range(int(K))].index(True)])
        break
    
else:
  out=[str(D[[n<=D[j] for j in range(int(K))].index(True)]) for n in N_digit]

print(int("".join(out)))

Submission status: Wrong Answer

Solution code:
#入力
n, k = map(int, input().split())
d = input().split()
stop = min(10000, n * 10)

for l in range(n, stop):
  a = str(n)
  flag = 0
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % k) != 0 and flag == 0:
      break
  if flag == len(a) * k:
    break
print(n)

Submission status: Wrong Answer

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

def okane():
    for i in range(n, 10001):
        for s in str(i):
            if s in d:
                break
        else:
            print(i)
            return 
    return

okane()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
ok=[str(i) for i in range(1,11) if not i in d]

def okane():
    for i in range(n, 10001):
        for s in str(i):
            if not s in ok:
                break
            print(i)
            return 
    return

okane()

Submission status: Wrong Answer

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

def okane():
    for i in range(n, 10001):
        for s in str(i):
            if s in d:
                break
        else:
            print(i)
            return
    return

okane()

Submission status: Wrong Answer

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

for l in range(n, 10000):
  a = str(n)
  flag = 1
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % (k+1)) != 0:
      break
  if flag == len(a) * (k+1):
    #m = l
    break
print(n)

Submission status: Wrong Answer

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

for l in range(n, 10000):
  a = str(l)
  flag = 1
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        #n += 1
        break
    if (flag % (k+1)) != 0:
      break
  if flag == len(a) * (k+1):
    m = l
    break
print(l)

Submission status: Wrong Answer

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

for l in range(n, 10000):
  a = str(n)
  flag = 1
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        #n += 1
        break
    if (flag % (k+1)) != 0:
      break
  if flag == len(a) * (k+1):
    m = l
    break
print(l)

Submission status: Wrong Answer

Solution code:
#入力
n, k = map(int, input().split())
d = input().split()
m = n
for l in range(m, 10000):
  a = str(n)
  flag = 1
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % (k+1)) != 0:
      break
  if flag == len(a) * (k+1):
    break
print(n)

Submission status: Wrong Answer

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

for l in range(n, 10000):
  a = str(n)
  flag = 1
  for i in range(len(a)):
    for j in range(k):
      if a[i] != d[j]:
        flag += 1
      else:
        n += 1
        break
    if (flag % (k+1)) != 0:
      break
  if flag == len(a) * (k+1):
    break
print(n)

Submission status: Wrong Answer

Solution code:
n,K = map(int,input().split())
use = [0,1,2,3,4,5,6,7,8,9]
useless = list(map(int,input().split()))
for i in range(K):
  use.remove(useless[i])
k = 10 - K
time = [0]
def suc(time):
  now = 0
  while True:
    if now >= len(time):
      time.append(0)
      break
    elif time[now] != k-1:
      time[now] += 1
      break
    else:
      time[now] = 0
      now += 1
  return time
#print(suc([0]))
#print(suc([1,1,1,1]))
#print(suc([1,0,1,1]))
while True:
  pay = 0
  for j in range(len(time)):
    pay += use[time[j]] * 10 ** j
  if pay >= n:
    print(pay,time)
    break
  time = suc(time)

Submission status: Wrong Answer

Solution code:
import itertools
n, k = map(int, input().split())
d = list(map(int, input().split()))
ls = []
for i in range(10):
    if i not in d:
        ls.append(i)
mp = 10 ** 9
for i in itertools.product(ls, repeat=len(str(n))):
    m = int("".join(map(str, i)))
    if m >= n:
        mp = min(mp, m)
print(mp)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
d = list(map(str,input().split()))
a = 0 #フラグ
for i in range(n,10000):
    for j in d:
        if j in str(i): # もしも嫌いな文字dが含まれていたらこの文字iはだめ
            a = 1 #フラグをダメにする　次の値段にアップ
            break
        elif j == d[-1]: a=0 #最後までまわった⇨全て含まれない⇨フラグ０に
    if a==0:  
        print(i)
        break

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
d = list(map(int,input().split()))
a = 0
for i in range(n,10001):
    for j in d:
        if str(j) in str(i): # もしも嫌いな文字dが含まれていたらこの文字iはだめ
            a = 1
            break
        elif j == d[-1]: a=0
    if a==0: 
        print(i)
        break

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
d = list(map(int,input().split()))
a = 0
for i in range(n,10000):
    for j in d:
        if str(j) in str(i): # もしも嫌いな文字dが含まれていたらこの文字iはだめ
            a = 1
            break
        elif j == d[-1]: a=0
    if a==0: 
        print(i)
        break

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import numpy as np

if __name__ == "__main__":
    
    raw = input("")
    N, _ = raw.split(" ")
    
    raw = input("")
    unlike_number = [int(f) for f in raw.split(" ")]
    
    like_number = np.delete(np.arange(10), unlike_number)
    
    payment = list(N)
    for i in range(len(N)):
        for j in range(len(like_number)):
            _payment = payment.copy()
            _payment[i] = str(like_number[j])
            if int("".join(_payment)) >= int(N):                    
                payment[i] = str(like_number[j])
                break

    print("".join(payment))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import numpy as np

if __name__ == "__main__":
    
    raw = input(">>> ")
    N, _ = raw.split(" ")
    
    raw = input(">>> ")
    unlike_number = [int(f) for f in raw.split(" ")]
    
    like_number = np.delete(np.arange(10), unlike_number)
    
    payment = list(N)
    for i in range(len(N)):
        for j in range(len(like_number)):
            _payment = payment.copy()
            _payment[i] = str(like_number[j])
            if int("".join(_payment)) >= int(N):                    
                payment[i] = str(like_number[j])
                break

    print("".join(payment))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

import numpy as np

if __name__ == "__main__":
    
    raw = input()
    N, _ = raw.split(" ")
    
    raw = input()
    unlike_number = [int(f) for f in raw.split(" ")]
    
    like_number = np.delete(np.arange(10), unlike_number)
    
    payment = list(N)
    for i in range(len(N)):
        for j in range(len(like_number)):
            _payment = payment.copy()
            _payment[i] = str(like_number[j])
            if int("".join(_payment)) >= int(N):                    
                payment[i] = str(like_number[j])
                break

    print("".join(payment))