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 = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []
for i in a:
    like.remove(i)

for i in str(n):
    while int(i)%10 in a:
            i = int(i) + 1
    pay.append(str(int(i) % 10))
    
total = ''

for i in pay:
    total += i
    
if total[0] == '0':
    if like[0] == '0':
        total[0] = like[1]
    else:
        total[0] = like[0]
        
if n > int(total):
    total += str(like[0])
print(int(total))

Submission status: Wrong Answer

Solution code:
n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []
    
for i in str(n):
    while int(i)%10 in a:
            i = int(i) + 1
    pay.append(str(int(i) % 10))
    
total = ''

for i in pay:
    total += i
    
if total[0] == '0':
    if like[0] == '0':
        total[0] = like[1]
    else:
        total[0] = like[0]
        
if n > int(total):
    total += str(like[0])
print(int(total))

Submission status: Wrong Answer

Solution code:
n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []
    
for i in str(n):
    while int(i)%10 in a:
            i = int(i) + 1
    pay.append(str(int(i) % 10))
 
total = ''
for i in pay:
    total += i
 
if n > int(total):
    total += str(like[0])
print(int(total))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
D=list(map(int,input().split()))
for i in range(N+1,10*N+1):
    I=list(map(int,str(i)))
    match=list(set(I)&set(D))
    if len(match)==0:
        print(i)
        break
    else:
        pass

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
D=list(map(int,input().split()))
for i in range(N+1,10*N+1):
    I=list(map(int,str(i)))
    match=list(set(I)&set(D))
    if len(match)==0:
        print(i)
        break
    else:
        continue

Submission status: Wrong Answer

Solution code:
n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]

pay = []
for i in str(n):
    while int(i) in a:
        i = int(i) + 1
    pay.append(str(i))

total = ''
for i in pay:
    total += i
    
print(int(total))

Submission status: Wrong Answer

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

while True:
    f = False

    for a in map(int, list(str(n))):
        if a in dl:
            break
        f = True

    if f:
        break
    n += 1

print(n)

Submission status: Wrong Answer

Solution code:
import collections
import math
N,K = map(int,input().split())
Ds = list(map(int,input().split()))
for n in range(N,10001):
    check = True
    for d in Ds:
        if str(d) in str(n):
            check = False
            break
    if check ==True:
        print(n)
        break

Submission status: Wrong Answer

Solution code:
import collections
import math
N,K = map(int,input().split())
Ds = list(map(int,input().split()))
for n in range(N-1,10000):
    check = True
    for d in Ds:
        if str(d) in str(n):
            check = False
            break
    if check ==True:
        print(n)
        break

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
Ds = list(map(int,input().split()))
for n in range(N,10000):
    check = True
    for d in Ds:
        if str(d) in str(n):
            check = False
            break
    if check ==True:
        print(n)
        break

Submission status: Wrong Answer

Solution code:
def f(n, d):
    while True:
        for x in d:
            try:
                str(n).index(str(x))
            except ValueError:
                return n
            else:
                break
        n = n + 1


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

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

print(f(n, d))

Submission status: Wrong Answer

Solution code:
def f(n, d):
    y = n
    while True:
        for x in d:
            try:
                str(y).index(str(x))
            except ValueError:
                return y
            else:
                break
        y = y + n


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

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

print(f(n, d))

Submission status: Wrong Answer

Solution code:
import itertools

n, _ = map(int, input().split(' '))
no_likes = list(map(int, input().split(' ')))

numbers = sorted([i for i in range(10) if i not in no_likes])

for i in itertools.product(numbers, numbers, numbers, numbers, numbers):
    num = int(''.join(map(str, i)))
    # print(num)
    if num >= n:
        print(num)
        break

Submission status: Wrong Answer

Solution code:
n, _ = map(int, input().split(' '))
no_likes = list(map(int, input().split(' ')))

numbers = sorted([i for i in range(10) if i not in no_likes])

for i in range(n, 10000):
    for b in str(i):
        if int(b) not in numbers:
            break
    else:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import itertools

# 組み合わせ
n, _ = map(int, input().split(' '))
no_likes = list(map(int, input().split(' ')))
# print(n, no_likes)

numbers = sorted([i for i in range(10) if i not in no_likes])

for i in itertools.product(numbers, numbers, numbers, numbers):
  num = int(''.join(map(str, i)))
  # print(num)
  if num >= n:
      print(int(num))
      break

Submission status: Wrong Answer

Solution code:
import itertools

# 組み合わせ
Num = [int(n) for n in input().rstrip().split()]
D = [int(n) for n in input().rstrip().split()]

numbers = [i for i in range(10) if i not in D]
for i in itertools.product(numbers, numbers, numbers, numbers):
  n = int(''.join(map(str, i)))
  if n >= Num[0]:
      print(n)
      break

Submission status: Wrong Answer

Solution code:
Num = [int(n) for n in input().rstrip().split()]

D = [int(n) for n in input().rstrip().split()]

for i in range(Num[0],10000):
    if len(set([str(n) for n in D]) & set(str(i))) != 0:
        continue
    else:
        print(int(i))
        break

Submission status: Wrong Answer

Solution code:
Num = [int(n) for n in input().rstrip().split()]

D = [int(n) for n in input().rstrip().split()]

for i in range(Num[0],10000):
    if len(set([str(n) for n in D]) & set(str(i))) == 0:
        print(int(i))
        break

Submission status: Wrong Answer

Solution code:
Num = [int(n) for n in input().rstrip().split()]

D = [int(n) for n in input().rstrip().split()]

for i in range(Num[0]+1,10000):
    if len(set([str(n) for n in D]) & set(str(i))) == 0:
        print(int(i))
        break

Submission status: Wrong Answer

Solution code:

Num = [int(n) for n in input().rstrip().split()]

D = [int(n) for n in input().rstrip().split()]

for i in range(Num[0],10000):
    if len(set([str(n) for n in D]) & set(str(i))) == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
d_li = [int(i) for i in input().split()]
n_li = reversed([int(i) for i in str(N)])
all_digits = set(range(10))
dis_digits = set(d_li)
like_digits = all_digits - dis_digits
like_li = sorted(list(like_digits))
result = []
is_increase = False
for ne in n_li:
    if is_increase:
        ne += 1
        is_increase = False

    if ne >= 10:
        ne = ne % 10
        is_increase = True

    if ne in d_li:
        if ne > max(like_li):
            result.append(min(like_li))
            is_increase = True
        else:
            for lle in like_li:
                if ne < lle:
                    result.append(lle)
                    break
    else:
        result.append(ne)

if is_increase:
    result.append(min(like_digits))

result.reverse()
print("".join([str(r) for r in result]))

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
d_li = [int(i) for i in input().split()]
n_li = reversed([int(i) for i in str(N)])
all_digits = set(range(10))
dis_digits = set(d_li)
like_digits = all_digits - dis_digits
like_li = sorted(list(like_digits))
result = []
is_increase = False
for ne in n_li:
    if is_increase:
        ne += 1
        is_increase = False
    if ne in d_li:
        if ne > max(like_li):
            result.append(min(like_li))
            is_increase = True
        else:
            for lle in like_li:
                if ne < lle:
                    result.append(lle)
                    break
    else:
        result.append(ne)

if is_increase:
    result.append(min(like_digits))

result.reverse()
print("".join([str(r) for r in result]))

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
d_li = [int(i) for i in input().split()]
n_li = reversed([int(i) for i in str(N)])
all_digits = set(range(10))
dis_digits = set(d_li)
like_digits = all_digits - dis_digits
like_li = sorted(list(like_digits))
result = []
is_increase = False
for ne in n_li:
    if is_increase:
        ne += 1
        is_increase = False
    if ne in d_li:
        if ne > max(like_li):
            result.append(min(like_li))
            is_increase = True
        else:
            for lle in like_li:
                if ne < lle:
                    result.append(lle)
    else:
        result.append(ne)

if is_increase:
    result.append(min(like_digits))

result.reverse()
print("".join([str(r) for r in result]))

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
d_li = [int(i) for i in input().split()]
n_li = reversed([int(i) for i in str(N)])
all_digits = set(range(10))
dis_digits = set(d_li)
like_digits = all_digits - dis_digits
like_li = sorted(list(like_digits))
result = []
is_increase = False
for ne in n_li:
    if is_increase:
        ne += 1
        is_increase = False
    if ne in d_li:
        if ne > max(like_li):
            result.append(min(like_li))
            is_increase = True
        else:
            for lle in like_li:
                if ne < lle:
                    result.append(lle)
    else:
        result.append(ne)

result.reverse()
print("".join([str(r) for r in result]))

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
d_li = [int(i) for i in input().split()]
n_li = [int(i) for i in str(N)]

result = ""
for ne in n_li:
    if ne in d_li:
        result += str(ne+1)
    else:
        result += str(ne)
print(result)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
D = set(list(map(int, input().split())))
D.add(0)
for i in range(N, 10000):
    int_i = [int(s) for s in list(str(i))]
    set_i = set(int_i)
    if not D & set_i:
        print(i)
        break
    i += 1

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
D = set(list(map(int, input().split())))
for i in range(N, 10000):
    int_i = [int(s) for s in list(str(i))]
    set_i = set(int_i)
    if not D & set_i:
        print(i)
        break
    i += 1

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
l1=map(int,input().split())
l2=[0,1,2,3,4,5,6,7,8,9]
l3=set(l1)^set(l2)
m=str(n)
l4=map(int,set(m))
l4=set(l4)
def check(a,b):
    if (a|b)==a:
        return True
    else:
        return False
while check(l3,l4) is False:
    n=n+1
    m=str(n)
    l4=map(int,set(m))
    l4=set(l4)
print(n+1)

Submission status: Wrong Answer

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

#使用可能数字の取り出し
Num1 = []
for i in range(10):
  if(i in D): continue
  else: Num1.append(i)
 
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n):
  Comb.append(Num1)
Comb = list(itertools.product(*Comb))

ans = -1
for i in range(len(Comb)):
  tmp = Comb[i]
  tmp_num = ''
  for j in range(n): tmp_num += str(tmp[j])
  tmp_num = int(tmp_num)
  if(N <= tmp_num):
    ans = tmp_num
    break

if(ans == -1): 
  ans = int(str(Num1[0])*(n+1)) 
print(ans)

Submission status: Wrong Answer

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

#使用可能数字の取り出し
Num = [1]*10 #index = num, 使用可能: 1,使用不可: 0
Num1 = [] #使用可能数字格納
for i in range(K):
  Num[D[i]] = 0
for i in range(10):
  if(Num[i] == 1):Num1.append(i)
    
#ケタの数の決定
N = list(str(N))
min_num = str(Num1[0])
judge = 0 #1:ケタの数はmin使う
ans = ''
for i in range(len(N)):
  n = int(N[i])
  for j in range(len(Num1)):
    if(judge == 0):
     if(n == Num1[j]): 
      ans += str(Num1[j])
      break
     elif(n < Num1[j]): 
      ans += str(Num1[j])
      judge = 1
      break
    elif(judge == 1):
      ans += min_num
      break

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
D = list(map(int,input().split()))
Num = [1]*10 #index = num, 使用可能: 1,使用不可: 0
Num1 = [] #使用可能数字格納
for i in range(K):
  Num[D[i]] = 0
for i in range(10):
  if(Num[i] == 1):Num1.append(i)
    
N = list(str(N))
min_num = str(Num1[0])
judge = 0 #1:ケタの数はmin使う
ans = ''
#ケタの数の決定
for i in range(len(N)):
  n = int(N[i])
  for j in range(len(Num1)):
    if((n == Num1[j])and(judge == 0)): 
      ans += str(Num1[j])
      break
    elif((n < Num1[j])and(judge == 0)): 
      ans += str(Num1[j])
      judge = 1
      break
    elif(judge == 1):
      ans += min_num
      break

print(ans)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
D = list(map(int,input().split()))
Num = [1]*10 #index = num, 使用可能: 1,使用不可: 0
for i in range(K):
  Num[D[i]] = 0

N1 = list(str(N))
n = len(N1)
ans = ''
#ケタの数の決定
for i in range(n):
  n1 = int(N1[i])
  for j in range(n1,10):
   if(Num[j] == 1): 
    ans += str(j)
    break
  
print(ans)

Submission status: Wrong Answer

Solution code:
def irohas_obsession(N: int, K: int, D: list) -> int:
    ret = 0
    digit = 1
    while N > 0:
        # 1 の位から順番に変換していく。
        n = N % 10

        for d in range(n, 10):
            # n 以上 9 以下の値で変換可能な値があれば
            # 変換する。このとき繰り上がりは起きない。
            if d in D:
                continue
            ret += digit * d
            break
        else:
            # n 未満の値で変換可能な値を探す。
            # このときは繰り上がりが起きる。
            for d in range(0, n):
                if d in D:
                    continue
                ret += digit * d
                # 繰り上がりを考える。
                N += 10
                break

        digit *= 10
        N //= 10

    return ret


if __name__ == "__main__":
    N, K = map(int, input().split())
    D = [int(s) for s in input().split()]
    ans = irohas_obsession(N, K, D)
    print(ans)

Submission status: Wrong Answer

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

can_use = []
for i in range(10):
    if i not in D:
        can_use.append(i)

ans = []

for dig in list(str(N))[::-1]:
    m = 999
    for cu in can_use:
        sa = cu - int(dig)
        if sa <= m and sa >= 0:
            m = sa
            ans.append(cu)

if len(ans) < len(list(str(N))):
    min_not0 = can_use[1] if can_use[0] == 0 else can_use[0]
    print(str(min_not0)+str(can_use[0])*len(list(str(N))))
    exit()


print(''.join(map(str, ans[::-1])))

Submission status: Wrong Answer

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

can_use = []
for i in range(10):
    if i not in D:
        can_use.append(i)

ans = []

for dig in list(str(N))[::-1]:
    m = 999
    for cu in can_use:
        sa = cu - int(dig)
        if sa <= m and sa >= 0:
            m = sa
            ans.append(cu)

if len(ans) == 0:
    min_not0 = can_use[1] if can_use[0] == 0 else can_use[0]
    print(str(min_not0)+str(can_use[0])*len(list(str(N))))
    exit()


print(''.join(map(str, ans[::-1])))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(n,10**6):
  flag=True
  for j in str(i):
    if int(j) in d:
      flag=False
      break
  print(i)
  exit()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
number=[]
for i in range(10):
  number.append(i)
likenumber=[i for i in number if i not in d]
likenumber.sort()
n=list(str(n))
n=list(map(int,n))
i=len(n)
while i!=0:
  i-=1
  if n[i]>9:
    n[i]-=10
    if i==0:
      n.insert(0,1)
      i=1
    else:
      n[i-1]+=1
  if n[i] in d:
    for j in likenumber:
      if j>n[i]:
        n[i]=j
        break
  if n[i] in d:
    n[i]=likenumber[0]
    if i==0:
      n.insert(0,1)
      i=1
    else:
      n[i-1]+=1
if n[0]==0:
  while 1:
    x=1
print(int("".join(map(str,n))))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
number=[]
for i in range(10):
  number.append(i)
likenumber=[i for i in number if i not in d]
likenumber.sort()
n=list(str(n))
n=list(map(int,n))
i=len(n)
while i!=0:
  i-=1
  if n[i]>9:
    n[i]-=10
    if i==0:
      n.insert(0,1)
      i=1
    else:
      n[i-1]+=1
  if n[i] in d:
    for j in likenumber:
      if j>n[i]:
        n[i]=j
        break
  if n[i] in d:
    n[i]=likenumber[0]
    if i==0:
      n.insert(0,1)
      i=1
    else:
      n[i-1]+=1
if n[0]==0:
  n[0]=likenumber[1]
print(int("".join(map(str,n))))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
number=[]
for i in range(10):
  number.append(i)
likenumber=[i for i in number if i not in d]
likenumber.sort()
n=list(str(n))
n=list(map(int,n))
i=len(n)
while i!=0:
  i-=1
  if n[i]>9:
    n[i]-=10
    if i==0:
      n.insert(0,1)
      i=1
    else:
      n[i-1]+=1
  if n[i] in d:
    for j in likenumber:
      if j>n[i]:
        n[i]=j
        break
  if n[i] in d:
    n[i]=likenumber[0]
    if i==0:
      n.insert(0,1)
      i=1
    else:
      n[i-1]+=1
print("".join(map(str,n)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
number=[]
for i in range(10):
  number.append(i)
likenumber=[i for i in number if i not in d]
likenumber.sort()
n=list(str(n))
n=list(map(int,n))
i=len(n)
while i!=0:
  i-=1
  if n[i]>9:
    n[i]-=10
    if i==0:
      n.insert(0,0)
      n[0]+=1
      i=1
    else:
      n[i-1]+=1
  if n[i] in d:
    for j in likenumber:
      if j>n[i]:
        n[i]=j
        break
  if n[i] in d:
    n[i]=min(likenumber)
    if i==0:
      n.insert(0,1)
      i=1
    else:
      n[i-1]+=1
print("".join(map(str,n)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
number=[]
for i in range(10):
  number.append(i)
likenumber=[i for i in number if i not in d]
likenumber.sort()
n=list(str(n))
n=list(map(int,n))
for i in range(len(n)-1,-1,-1):
  if n[i]>9:
    n[i]-=10
    if i==0:
      n.insert(0,0)
      n[0]+=1
    else:
      n[i-1]+=1
  if n[i] in d:
    for j in likenumber:
      if j>n[i]:
        n[i]=j
        break
  if n[i] in d:
    n[i]=min(likenumber)
    if i==0:
      n.insert(0,1)
    else:
      n[i-1]+=1
print("".join(map(str,n)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d=list(map(int,input().split()))
number=[]
for i in range(10):
  number.append(i)
likenumber=[i for i in number if i not in d]
n=list(str(n))
n=list(map(int,n))
for i in range(len(n)-1,-1,-1):
  if n[i]>9:
    if i==len(n)-1:
      n.insert(0,0)
    n[i]-=10
    n[i-1]+=1
  if n[i] in d:
    for j in likenumber:
      if j<n[i]:
        n[i]=j
        continue
  n[i]=min(likenumber)
  n[i-1]+=1
print("".join(map(str,n)))

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
result = N
d = list(map(int,input().split()))
flag = True
while flag:
    for i in sorted(range(len(str(N))), reverse=True):
        a = math.floor(N / 10**i)
        if a in d:
            N += 10**i
            
            break
        elif i == 0:flag = False
print(N)

Submission status: Wrong Answer

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

D=set(map(int,input().split()))

X={0,1,2,3,4,5,6,7,8,9}-D

for i in range(n,10000):
    if set([int(a) for a in str(i)])|X==X:
        print(i)
        break

Submission status: Wrong Answer

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

D=set(map(int,input().split()))

X={0,1,2,3,4,5,6,7,8,9}-D

for i in range(n,10000):
    if set([int(a) for a in str(i)])==X:
        print(i)
        break

Submission status: Wrong Answer

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

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

n_list = list(str(n))

num = {1,2,3,4,5,6,7,8,9,0}

avairable_number = num - set(d)


ans = ""
for i in range(len(n_list)):
  flag = 0
  for  p in avairable_number:
    if int(n_list[i]) <= p and flag == 0:
      ans += str(p)
      flag = 1
      
print(ans)

Submission status: Wrong Answer

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

a = [0,1,2,3,4,5,6,7,8,9]

c = set(a) - set(b)
c = list(c)

lst = []

while i >0:
    lst.append(i%10)
    i //= 10
lst.reverse()

N = len(lst)
M = len(c)
X = []
for n in range(N):
    for m in range(M):
        if c[m] >= lst[n]:
            x = c[m]
            X.append(x)
            break
            
X = [str(l) for l in X]
print(''.join(X))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
d=0
e=0
for i in range(100000):
  d=str(n+i)
  for j in range(k):
    e=e+d.count(str(a[j]))
  if e==0:
    print(d)
    break
  d=0

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc042/submissions/3930271
import sys
n, k = map(int, input().split())
aset =set(input())
i = n
while True:
    k = list(str(i))
    klen = len(k)
    for j in range(klen):
        if k[j] in aset:
            print(1,i)
            i += 10 ** (klen - j - 1)
            print(2,i)
            i -= i % (10 ** (klen - j - 1))
            print(3,i)
            break
    else:
        print(i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n, k = map(int, input().split())
aset =set(input())
i = n
while True:
    k = list(str(i))
    klen = len(k)
    for j in range(klen):
        if k[j] in aset:
            print(1,i)
            i += 10 ** (klen - j - 1)
            print(2,i)
            i -= i % (10 ** (klen - j - 1))
            print(3,i)
            break
        else:
            print(i)
            sys.exit()

Submission status: Wrong Answer

Solution code:
#C 042

N,K= map(int,input().split())
D = [int(j) for j in input().split()]
use =list(set([i for i in range(0,10)]) -set(D))
use.sort()
ans =''
for i,n in enumerate(str(N)):
    for j in use:
        if j >= int(n):
            ans+=str(j)
            break
print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    slist = input().rstrip().split(' ')
    N = int(slist[0])
    K = int(slist[1])
    D = input().rstrip().split(' ')
    # print(D)
    for n in range(N,10001):
        # 各桁にDの配列にある数値がいるか
        d_flag = False
        tmp_n = list(str(n))
        # print(tmp_n)
        for tmp_char in tmp_n:
            # print(tmp_char)
            if (str(tmp_char) in D):
                d_flag = True
                break
                # continue
        if(d_flag == False):
            print(n)
            break
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce

def main():
    # 一文字のみを読み込み
    # s = input().rstrip().split(' ')
    
    # スペース区切りで標準入力を配列として読み込み
    # s = input().rstrip().split(' ')

    # 位置文字ずつ標準入力を配列として読み込み
    # s = list(input().rstrip())
    slist = input().rstrip().split(' ')
    N = int(slist[0])
    K = int(slist[1])
    D = input().rstrip().split(' ')
    for n in range(N,10001):
        # 各桁にDの配列にある数値がいるか
        d_flag = False
        tmp_n = list(str(n))
        # print(tmp_n)
        for tmp_char in tmp_n:
            if (str(tmp_char) in D):
                d_flag = True
                continue
        if(d_flag == False):
            print(n)
            break
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
D = input().split()
for n in range(N, 10001):
	if all(d not in str(n) for d in D):
		print(n)
		exit()

Submission status: Wrong Answer

Solution code:
# coding: UTF-8


N, _ = input().split()
Nint = int(N)

dislike_nums = list(map(int, input().split()))
nums = [i for i in range(10) if i not in dislike_nums]

i = 0
j = len(N)-1
s = 0
while Nint > 0:
    if j >= 0:
        Ni = int(N[j])
    else:
        Ni = 0

    larger_num = [n for n in nums if n >= Ni]
    if larger_num == []:
        n = min(nums)
    else:
        n = min(larger_num)
    Nint -= n*(10**i)
    s += n*(10**i)
    i += 1
    j -= 1

print(s)

Submission status: Wrong Answer

Solution code:
# coding: UTF-8


N, _ = input().split()
N = int(N)

dislike_nums = list(map(int, input().split()))
nums = [i for i in range(10) if i not in dislike_nums]

i = 0
s = 0
while N > 0:
    Ni = (N % (10**(i+1))) // (10**i)
    larger_num = [n for n in nums if n >= Ni]
    if larger_num == []:
        n = min(nums)
    else:
        n = min(larger_num)
    N -= n*(10**i)
    s += n*(10**i)
    i += 1

print(s)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-
# arc058_a

# input
N, K = map(int, input().split())
D = input().split()
# getans
def getans():
	for i in range(100000):
		ans = str(N+i)
		for d in D:
			if d in ans:
				break
			return ans
	raise
ans = getans()
# output
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-
# arc058_a

# input
N, K = map(int, input().split())
D = input().split()
# getans
def getans():
	for i in range(10000):
		ans = str(N+i)
		for d in D:
			if d in ans:
				break
			return ans
	raise
ans = getans()
# output
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
D=list(map(int,input().split()))
for i in range(N,10000):
	Ai=str(i)
	if all((str(j) not in Ai)for j in D):
			print(i)
			break

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
D = set([int(d) for d in input().split()])
num = set([0,1,2,3,4,5,6,7,8,9])
D = list(num - D)
D.sort(reverse=True)
_ = 10**7
def abcC(x, ans):
    if len(x) == len(str(n))+2:
        return ans
    if n <= int(x) < ans:
        ans = int(x)
    elif n > int(x):
        for i in D:
            ans = abcC(x+str(i),ans)
    return ans
        
print(abcC('0',_))

Submission status: Wrong Answer

Solution code:
#ABC042C
N,K=map(str,input().split())
N=list('0'+N)
D=list(map(int,input().split()))+[10]
E=[]
for i in [0,1,2,3,4,5,6,7,8,9,10,10]:
    if i not in D:
        E.append(i)
    else:
        E.append(10)


for i in range(1,len(N))[::-1]:
    if int(N[i]) in D:
        if min(E[int(N[i])+1:])==10:
            N[i]=str(min(E))
            N[i-1]=str(int(N[i-1])+1)
        else:
            N[i]=str(min(E[int(N[i])+1:]))

if N[0]=='1' and int(N[i]) in D: 
    N[0]=str(min(E[int(N[0])+1:]))
print(int(''.join(N)))

Submission status: Wrong Answer

Solution code:
import sys
N, K = map(int, input().split())
D = list(input().split())
for i in range(N, 100 * N):
    for d in D:
        if d not in str(i):
            print(i)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N,K = [int(n) for n in input().split()]
D = set([str(n) for n in input().split()])
# OK = sorted(list(set([0,1,2,3,4,5,6,7,8,9]) - D))
for i in range(N,10001):
    stri = set(list(str(i)))
    find = True
    for d in D:
        if d in stri:
            find = False
            break
    if find:
        print(i)
        sys.exit()

# a =
# S = str(input())
# L = len(S)
# T = str(input())

Submission status: Wrong Answer

Solution code:
import sys
N,K = [int(n) for n in input().split()]
D = set([str(n) for n in input().split()])
# OK = sorted(list(set([0,1,2,3,4,5,6,7,8,9]) - D))
for i in range(N,10000):
    stri = set(list(str(i)))
    find = True
    for d in D:
        if d in stri:
            find = False
            break
    if find:
        print(i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = set([int(i) for i in input().split()])
num = set([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) - A

for i in range(n, 10001):
    for j in list(str(i)):
        if int(j) not in num:
            break
    else:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
l=[str(x) for x in range(100000)]
n,k=map(int,input().split())
if n==9999 and k==1:
  exit()
l2=list(map(str,input().split()))
ind=l.index(str(n))
while True:
  a=l[ind]
  f=False
  for x in l2:
    if x in a:
      f=True
  if not f:
    break
  ind+=1
print(a)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split(" "))
Ds = set(map(str, input().split(" ")))
for i in range(N, 10000):
    if (set(str(i)) & set(Ds)) == set():
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, _ = map(int, input().split())
D = list(map(int, input().split()))
E = [str(i) for i in [0,1,2,3,4,5,6,7,8,9] if i not in D]
k=len(str(N))
while (not str(N)[0] in E):
        N+=pow(10,k-1)
if len(str(N))!=k:
    for i in range(1,k+1):
        while (not str(N)[i] in E):
            N+=pow(10,k-i)            
else:
    for i in range(1,k):
        while (not str(N)[i] in E):
            N+=pow(10,k-i-1)
print(N)

Submission status: Wrong Answer

Solution code:
import sys
N, _ = input().split()
D = list(map(int, input().split()))
E = [str(i) for i in [0,1,2,3,4,5,6,7,8,9] if i not in D]
for n in N:
    if not n in E:
        for e in E:
            if e>n:
                n=e
                sys.stdout.write(n)
                break;
    else:
        sys.stdout.write(n)

Submission status: Wrong Answer

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

while True:
  for n in str(N):
    if(n in D):
      break
  else:
    break
  N += 1
print(N)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
D=list(map(int,input().split()))
nums=[i for i in range(10) if i not in D]
ans=""

def str_check(string):
  string=str(string)
  for i in string:
    if int(i) not in nums:
      return False
  return True

for i in range(1,10001):
  if str_check(i)==True and n<=i:
    print(i)
    exit()