Problem p04045 (python)

Fixed submission:
import sys
 
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
D=list(map(int,input().rstrip().split()))
sys.setrecursionlimit(10**6)

def dfs(N):
    for i in range(K):
        if(str(N).find(str(D[i]))!=-1):
            dfs(N+1)
            return
    else:
        print(N)
    
    

dfs(N)

Buggy submission (verdict: Runtime Error):
import sys

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

def dfs(N):
    for i in range(K):
        if(str(N).find(str(D[i]))!=-1):
            dfs(N+1)
            return
    else:
        print(N)
        return
    return
    


dfs(N)

Buggy submission (verdict: Runtime Error):
import sys

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

def dfs(N):
    for i in range(K):
        if(str(N).find(str(D[i]))!=-1):
            dfs(N+1)
            return
    else:
        print(N)
        return
    return
    


def resolve():
    dfs(N)


from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1000 8
1 3 4 5 6 7 8 9"""
        output = """2000"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """9999 1
0"""
        output = """9999"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Buggy submission (verdict: Runtime Error):
import sys

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

def dfs(N):
    for i in range(K):
        if(str(N).find(str(D[i]))!=-1):
            dfs(N+1)
            return
    else:
        print(N)
    
    


def resolve():
    dfs(N)


from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1000 8
1 3 4 5 6 7 8 9"""
        output = """2000"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """9999 1
0"""
        output = """9999"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Buggy submission (verdict: Runtime Error):
import sys

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

def dfs(N):
    for i in range(K):
        if(str(N).find(str(D[i]))!=-1):
            dfs(N+1)
            return
    else:
        print(N)
    
    


def resolve():
    dfs(N)


from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1000 8
1 3 4 5 6 7 8 9"""
        output = """2000"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """9999 1
0"""
        output = """9999"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()