Buggy python submission (verdict: Runtime Error):
s = input()
s = s.split(" ")
N = s[0]
K = int(s[1])

s = input()
s = s.split(" ")
ds = [int(digit) for digit in s]

minNum = min([digit for digit in range(0, 10) if digit not in ds])
maxNum = max([digit for digit in range(0, 10) if digit not in ds])

digits = [int(digit) for digit in N]

result = N
for index in range(0, len(digits)):
  digit = digits[index]
  if digit in ds:
    i = index
    if digit > maxNum:
      i = index - 1
      while i >= 0 and digits[i] == maxNum:
        i -= 1
    
    if i < 0:
      result = str(minNum) * (len(N) + 1)
    else:
      biggerDigit = min([d for d in range(0, 10) if d not in ds and d > digits[i]])
      digits[i] = biggerDigit
      for j in range(i+1, len(digits)):
        digits[j] = minNum
      result = "".join([str(digit) for digit in digits])

print(result)


Fixed submission:
s = input()
s = s.split(" ")
N = s[0]
K = int(s[1])

s = input()
s = s.split(" ")
ds = [int(digit) for digit in s]

minNum = min([digit for digit in range(0, 10) if digit not in ds])
nonZerominNum = min([digit for digit in range(1, 10) if digit not in ds])
maxNum = max([digit for digit in range(0, 10) if digit not in ds])

digits = [int(digit) for digit in N]

result = N
for index in range(0, len(digits)):
  digit = digits[index]
  if digit in ds:
    i = index
    if digit > maxNum:
      i = index - 1
      while i >= 0 and digits[i] == maxNum:
        i -= 1
    
    if i < 0:
      result = str(nonZerominNum) + (str(minNum) * len(N))
    else:
      biggerDigit = min([d for d in range(0, 10) if d not in ds and d > digits[i]])
      digits[i] = biggerDigit
      for j in range(i+1, len(digits)):
        digits[j] = minNum
      result = "".join([str(digit) for digit in digits])
    break

print(result)

Buggy python submission (verdict: Runtime Error):
s = input()
s = s.split(" ")
N = s[0]
K = int(s[1])

s = input()
s = s.split(" ")
ds = [int(digit) for digit in s]

minNum = min([digit for digit in range(0, 10) if digit not in ds])
maxNum = max([digit for digit in range(0, 10) if digit not in ds])

digits = [int(digit) for digit in N]

result = N
for index in range(0, len(digits)):
  digit = digits[index]
  if digit in ds:
    i = index
    if digit > maxNum:
      i = index - 1
      while i >= 0 and digits[i] == maxNum:
        i -= 1
    
    if i < 0:
      result = str(minNum) * (len(N) + 1)
    else:
      biggerDigit = min([d for d in range(0, 10) if d not in ds and d > digits[i]])
      result = N[:i] + str(biggerDigit) + (str(minNum) * (len(N) - i - 1))

print(result)


Fixed submission:
s = input()
s = s.split(" ")
N = s[0]
K = int(s[1])

s = input()
s = s.split(" ")
ds = [int(digit) for digit in s]

minNum = min([digit for digit in range(0, 10) if digit not in ds])
nonZerominNum = min([digit for digit in range(1, 10) if digit not in ds])
maxNum = max([digit for digit in range(0, 10) if digit not in ds])

digits = [int(digit) for digit in N]

result = N
for index in range(0, len(digits)):
  digit = digits[index]
  if digit in ds:
    i = index
    if digit > maxNum:
      i = index - 1
      while i >= 0 and digits[i] == maxNum:
        i -= 1
    
    if i < 0:
      result = str(nonZerominNum) + (str(minNum) * len(N))
    else:
      biggerDigit = min([d for d in range(0, 10) if d not in ds and d > digits[i]])
      digits[i] = biggerDigit
      for j in range(i+1, len(digits)):
        digits[j] = minNum
      result = "".join([str(digit) for digit in digits])
    break

print(result)

Buggy python submission (verdict: Runtime Error):
import random

numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
count = random.randint(1, 9)
dk, i = [], 0
while i < count:
    m = random.choice(numbers)
    if m not in dk:
        dk.append(m)
        i += 1
    else:
        continue

number_input = random.randint(10, 10000)
number_result = number_input
while True:
    string_middle = str(number_result)
    judge = 0
    for each in string_middle:
        if each in numbers:
            judge = 1
            break
        else:
             continue
    if judge == 1:
        number_result += 1
    else:
        break
print('%d %d'%(number_input, count)
print(dk)
print('%d'%number_result)

Fixed submission:
n,k=map(int,input().split())
d=list(map(int,input().split()))
while True:
    m=n
    f=False
    while m>0:
        if m%10 in d:
            f=True
            break
        m=int(m/10)
    if f:
        n+=1
    else:
        print(n)
        break