Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = list(range(A, B+1))



Fixed submission:
A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = list(range(A, B+1))

o = set()
for i in X[:K]:
    print(i)
    o.add(i)

for i in X[-K:]:
    if i not in o:
        print(i)


Fixed submission:
A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]
X = list(range(A, B+1)))

o = set()
for i in X[:K]:
    print(i)
    o.add(i)

for i in X[-K:]:
    if i not in o:
        print(i)


Fixed submission:
A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]
X = list(range(A, B+1)))
for i in sorted(set(X[:K]) | set(X[-K:])):
    print(i)


Fixed submission:
A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = sorted(range(A, B+1))
for i in sorted(set(X[:K]) | set(X[-K:])):
    print(i)


Fixed submission:
A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)

Buggy python submission (verdict: Runtime Error):
A, B, K = [int(x) for x in input().split()]

X = sorted(range(A, B+1))
for i in sorted(set(X[:K]) | set(X[-K:])):
    print(i)


Fixed submission:
A, B, K = [int(x) for x in input().split()]

u = set(range(A, min(B+1, A+K)))
l = set(range(B, max(A-1, B-K),-1))
for i in sorted(u | l):
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y = [int(x) for x in input().split()]

def solve(X, Y):
    if X == Y:
        return -1
    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
print(solve(X, Y))





Fixed submission:
X, Y = [int(x) for x in input().split()]

def solve(X, Y):
    if X == Y:
        return -1
    if Y < X:
        if X % Y == 0:
            return -1

    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
print(solve(X, Y))

Buggy python submission (verdict: Runtime Error):
X, Y = [int(x) for x in input()]

def solve(X, Y):
    if X == 1:
        return -1
    if X == Y:
        return -1
    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
solve(X, Y)





Fixed submission:
X, Y = [int(x) for x in input().split()]

def solve(X, Y):
    if X == Y:
        return -1
    if Y < X:
        if X % Y == 0:
            return -1

    for x in range(X, 10**18+1, X):
        if x % Y != 0:
            return x
print(solve(X, Y))
Buggy python submission (verdict: Runtime Error):
def main():
    N, A, B = [int(x) for x in input().split()]
    a = 0
	for n in range(N+1):
      s = sum(int(x) for x in n)
      if A <= s <= B:
        a += n
    return a
main()
        
  



Fixed submission:




def main():
    N, A, B = [int(x) for x in input().split()]
    a = 0
    for n in range(N+1):
        s = sum(int(x) for x in str(n))
        if A <= s <= B:
          	a += n
    return a
print(main())
Buggy python submission (verdict: Runtime Error):
A = sorted(input())
B = sorted(input(), revese=True)
print("Yes" if A < B else "No")
  

Fixed submission:
A = "".join((sorted(input())))
B = "".join(sorted(input(), reverse=True))
print("Yes" if A < B else "No")

Buggy python submission (verdict: Runtime Error):
A = sorted(input())
B = sorted(input(), reversed=True)
if A < B:
  print("Yes")
else:
  print("No")

Fixed submission:
A = "".join((sorted(input())))
B = "".join(sorted(input(), reverse=True))
print("Yes" if A < B else "No")
Buggy python submission (verdict: Runtime Error):
A = input().split()

if A[0] == A[1] == A[2]:
  print("Yes"):
else:
  A = A[::-1]
  if A[0] == A[1] == A[2]:
    print("Yes"):
  else:
    print("No")

Fixed submission:
A = input().strip()
if A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from itertools import product as p
A,B,C,D=input();o="+-"
for x in map("".join,p(A,o,B,o,C,o,D)):if eval(x) == 7:print(x+"=7");break

Fixed submission:
from itertools import product

A, B, C, D = [x for x in input().strip()]

for x in ["".join(x) for x in product(A, '+-', B, '+-', C, '+-', D)]:
    if eval(x) == 7:
        print(x+"=7")
        break
Buggy python submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]

print(M * 1900+(N-M)*100)*(2**M)




Fixed submission:
N, M = [int(x) for x in input().split()]

print((M * 1900+(N-M)*100)*(2**M))

Buggy python submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]

if N == M:
    print((1900*M)/(2**N))
else:
    print(M * 1900+(N-M)*100)*(2**M)




Fixed submission:
N, M = [int(x) for x in input().split()]

print((M * 1900+(N-M)*100)*(2**M))
Buggy python submission (verdict: Runtime Error):
N=input()
if any(c=='9'):
  print("Yes")
else:
  print("No")

Fixed submission:
N=input()
if '9' in N:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())

# N < 100
# gcd(a,b) lcd(a,b) = ab

from math import gcd
def lcd(a, b):
    return a*b//gcd(a,b)

l = 1
g = 0
for t in T:
    l = lcd(l, t)
    g = gcd(g, t)
print(l)


Fixed submission:
N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())

# N < 100
# gcd(a,b) lcd(a,b) = ab

from fractions import gcd
def lcd(a, b):
    return a*b//gcd(a,b)

l = 1
g = 0
for t in T:
    l = lcd(l, t)
    g = gcd(g, t)
print(l)
Buggy python submission (verdict: Runtime Error):
N, M = [x for x in input().split()]
E = [[] for x in range(N+1)]
visited = set()

for i in range(M):
    A, B = [x for x in input().split()]
    E[A].append(B)
    E[B].append(A)

if E[1] & E[N]:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Fixed submission:
N, M = [int(x) for x in input().split()]
E = [[] for x in range(N+1)]
visited = set()

for i in range(M):
    A, B = [int(x) for x in input().split()]
    E[A].append(B)
    E[B].append(A)

if set(E[1]) & set(E[N]):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]+[int(input()) for _ in range(N)]

v = {1}
x = 1
a = 0
while True:
  x = A[x]
  a += 1
  if x in v:
    print(-1)
    break
  if x == 2:
	print(a)
    break
  v.add(x)

Fixed submission:
N = int(input())
A = [0]+[int(input()) for _ in range(N)]

v = set()
v.add(1)
x = 1
a = 0
while True:
  x = A[x]
  a += 1
  if x in v:
    print(-1)
    break
  if x == 2:
    print(a)
    break
  v.add(x)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]+[int(input()) for _ in range(N)]

v = {1}
x = 1
a = 0
while True:
  x = A[x]
  a += 1
  if x in v:
    print(-1)
    break
  if x == 2:
	print(a)
    break

Fixed submission:
N = int(input())
A = [0]+[int(input()) for _ in range(N)]

v = set()
v.add(1)
x = 1
a = 0
while True:
  x = A[x]
  a += 1
  if x in v:
    print(-1)
    break
  if x == 2:
    print(a)
    break
  v.add(x)
Buggy python submission (verdict: Runtime Error):
print("YES" if int("".join(list(input()))) % 4 == 0 else "NO")


Fixed submission:
print("YES" if int("".join(x for x in input().split())) % 4 == 0 else "NO")
Buggy python submission (verdict: Runtime Error):
# 2^100

N = int(input())
S = [None] * N
for i in range(N):
    S[i] = int(input())
S.sorted(reverse=True)
total = sum(S)

for i in range(N):
    if total % 10 != 0:
        break
    total -= S[i]
print(total)




Fixed submission:
# 2^100
# WAが残ったので解説見た
def main(N, S):
    total = sum(S)
    if total % 10 != 0:
        return total
    victim = sorted(x for x in S if x % 10 != 0)
    if len(victim) == 0:
        return 0
    else:
        return total - victim[0]

N = int(input())
S = [None] * N
for i in range(N):
    S[i] = int(input())
print(main(N, S))
Buggy python submission (verdict: Runtime Error):
N = int(input())
count = [0]*N
for i in range(N):
	x, y = [int(x) for x in input().split()]
    count[x-1] += 1
    count[y-1] += 1
for c in count:
    print(c)

Fixed submission:
N, M = [int(x) for x in input().split()]
count = [0]*N
for i in range(M):
	x, y = [int(x) for x in input().split()]
	count[x-1] += 1
	count[y-1] += 1
for c in count:
	print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = [0]*N
for i in range(N):
	x, y = [int(x) for x in input().split()]
    count[x-1] += 1
    count[y-1] += 1
for c in N:
    print(c)

Fixed submission:
N, M = [int(x) for x in input().split()]
count = [0]*N
for i in range(M):
	x, y = [int(x) for x in input().split()]
	count[x-1] += 1
	count[y-1] += 1
for c in count:
	print(c)

Buggy python submission (verdict: Runtime Error):
N = int(input())
count = [0]*N
for i in range(N):
	x, y = [int(x) for x in input().split()]
    count[x] += 1
    count[y] += 1
for c in N:
    print(c)

Fixed submission:
N, M = [int(x) for x in input().split()]
count = [0]*N
for i in range(M):
	x, y = [int(x) for x in input().split()]
	count[x-1] += 1
	count[y-1] += 1
for c in count:
	print(c)
Buggy python submission (verdict: Runtime Error):
print("".join(x[0].upper()for x input().split()))

Fixed submission:
print("".join(
  x[0].upper() for x in input().split()))
Buggy python submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():
    for x in range(N-M+1):
        for y in range(N-M+1):
            if all(all(A[r+x][c+y] == B[r][c] for c in range(M)) for r range(M))
                return "Yes"
    return "No"
print(check())



Fixed submission:
N, M = [int(x) for x in input().split()]

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():
    for x in range(N-M+1):
        for y in range(N-M+1):
            match = True
            for r in range(M):
                if not all(A[r+x][c+y] == B[r][c] for c in range(M)):
                    match = False
                    break
            if match:
                return "Yes"

    return "No"
print(check())
Buggy python submission (verdict: Runtime Error):
print(" ".join(input().split(","))

Fixed submission:
print(" ".join(input().split(",")))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [(0 if s == v else INF, v) for v in range(N)]
    heapq.heapify(Q)

    while Q:
        c, u = heapq.heappop(Q)
        if D[u] < c:
            continue
        for v, w in enumerate(m[u]):
            if D[v] > D[u] + w:
                D[v] = D[u] + w
                heapq.heappush(Q, (D[u]+w, v))
    return D[t] 

N, M = map(int, input().split())

# N < 100
m = [[1e10]*N for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1][b-1] = w
    m[b-1][a-1] = w

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    #print((a+1, b+1), d, "w=%d"%w)
    if d < w:
        count += 1

print(count)


Fixed submission:
import heapq

def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [(0 if s == v else INF, v) for v in range(N)]
    heapq.heapify(Q)

    while Q:
        c, u = heapq.heappop(Q)
        if D[u] < c:
            continue
        for v, w in m[u]:
            if D[v] > D[u] + w:
                D[v] = D[u] + w
                heapq.heappush(Q, (D[u]+w, v))
    return D[t] 

N, M = map(int, input().split())

# N < 100
m = [[] for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1].append((b-1,w))
    m[b-1].append((a-1,w))

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    #print((a+1, b+1), d, "w=%d"%w)
    if d < w:
        count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [v for v in range(N)]

    while Q:
        d = INF
        u = None
        for x in Q:
            if D[x] < d:
                d = D[x]
                u = x
        Q.remove(u)
        for v, w in enumerate(m[u]):
            if D[v] > D[u] + w:
                D[v] = D[u] + w
    return D[t] 

N, M = map(int, input().split())

# N < 100
m = [[1e10]*N for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1][b-1] = w
    m[b-1][a-1] = w

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    #print((a+1, b+1), d, "w=%d"%w)
    if d < w:
        count += 1

print(count)


Fixed submission:
import heapq

def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [(0 if s == v else INF, v) for v in range(N)]
    heapq.heapify(Q)

    while Q:
        c, u = heapq.heappop(Q)
        if D[u] < c:
            continue
        for v, w in m[u]:
            if D[v] > D[u] + w:
                D[v] = D[u] + w
                heapq.heappush(Q, (D[u]+w, v))
    return D[t] 

N, M = map(int, input().split())

# N < 100
m = [[] for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1].append((b-1,w))
    m[b-1].append((a-1,w))

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    #print((a+1, b+1), d, "w=%d"%w)
    if d < w:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind:
    def __init__(self, N):
        self.parent = [x for x in range(N+1)]

    def find(self, x):
        p = x
        while self.parent[p] != p:
            p = self.parent[p]
        self.parent[x] = p
        return p

    def union(self, r, l):
        x, y = self.find(r), self.find(l)
        if x == y:
            return
        self.parent[x] = y

def main():
    N, K, L = map(int, input().split())
    
    rails = UnionFind(N)
    for _ in range(K):
        p, q = map(int, input().split())
        rails.union(p, q)

    loads = UnionFind(N)
    for _ in range(L):
        p, q = map(int, input().split())
        loads.union(p,q)
    RL = [(rails.find(u), loads.find(u)) for u in range(1, N+1)]
    from collections import Counter
    c = Counter(RL)

    print(*(c[x] for x in RL))

main()



Fixed submission:
class UnionFind:
    def __init__(self, N):
        self.parent = [x for x in range(N+1)]
        self.rank = [1 for x in range(N+1)]

    def find(self, x):
        p = x
        while self.parent[p] != p:
            p = self.parent[p]
        self.parent[x] = p
        return p

    def union(self, r, l):
        x, y = self.find(r), self.find(l)
        if x == y:
            return
        rx, ry = self.rank[x], self.rank[y]
        if rx > ry:
            self.parent[y] = x
        elif rx == ry:
            self.parent[y] = x
            self.rank[x] += 1
        else:
            self.parent[x] = y

def main():
    N, K, L = map(int, input().split())
    
    rails = UnionFind(N)
    for _ in range(K):
        p, q = map(int, input().split())
        rails.union(p, q)

    loads = UnionFind(N)
    for _ in range(L):
        p, q = map(int, input().split())
        loads.union(p,q)
    RL = [(rails.find(u), loads.find(u)) for u in range(1, N+1)]
    from collections import Counter
    c = Counter(RL)

    print(*(c[x] for x in RL))

main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
TA = [0] * N

vote = 0
t, a = 0, 0
for i in range(N):
    T, A = map(int, input().split())
    if vote == 0:
        t, a = T, A
        vote = t+A
        continue
    t1, a1 = T, A
    while not (t <= t1 and a <= a1):
        t1 += T
        a1 += A
    t, a = t1, a1
print(t+a)




Fixed submission:
N = int(input())
TA = []
for i in range(N):
    T, A = map(int, input().split())
    TA.append((T, A))

T, A = TA[0]
answer = T+A
p = 1
prev = p
pT, pA = T, A
for i in range(1,N):
    # (T+A) * p >= prev
    # p >= prev/(T+A)
    T, A = TA[i]
    s = T+A
    p = (answer+s-1)//s
    p1 = (pT+T-1)//T
    p2 = (pA+A-1)//A
    p = max([p,p1,p2])
    pT, pA = p*T, p*A
    answer =  pT+pA
    #print(T, A, p, answer, sep="\t")
print(answer)
Buggy python submission (verdict: Runtime Error):
N = int(input())
TA = []
for i in range(N):
    T, A = map(int, input().split())
    TA.append((T, A))

T, A = TA[0]
answer = T+A
p = 1
prev = p
pT, pA = T, A
for i in range(1,N):
    # (T+A) * p >= prev
    # p >= prev/(T+A)
    T, A = TA[i]
    s = T+A
    p = (answer+s-1)//s
    p1 = (pT+T-1)//T
    p2 = (pA+A-1)//A
    p = max([p,p1,p2])
    pT, pA = p*T, p*A
    answer =  pT+pA
    #print(T, A, p, answer, sep="\t")
print(answer)

    


Fixed submission:
S = input().strip()

answer = 0

for n in range(2**(len(S)-1)):
    A = [0]
    for d in range(9):
        if n & (1 << d):
            A.append(d+1)
    T = []
    #print("A", A)
    for l, r in zip(A, A[1:]):
        T.append(int("".join(S[l:r])))
    T.append(int("".join(S[A[-1]:])))
    answer += sum(T)

print(answer)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
r = 0
cnt = Counter(input()):
for c in cnt:
    r += cnt[c] % 2
if r == 0:
    print("Yes")
else:
    print("No")



Fixed submission:
from collections import Counter
r = 0
cnt = Counter(input())
for c in cnt:
    r += cnt[c] % 2
if r == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]*N
r = 0
for i in range(N):
    a = int(input())
    A[i] = (a, i)
A.sort()
cnt = 0
for i in range(N, 2):
    a, j = A[i]
    cnt += j & 1
print(cnt)





Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = [0]*N
    r = 0
    for i in range(N):
        a = int(input())
        A[i] = (a, i)
    A.sort()
    cnt = 0
    for i in range(0, N, 2):
        a, j = A[i]
        cnt += j & 1
    print(cnt)

main()
Buggy python submission (verdict: Runtime Error):
def solve(S):
    N = len(S)
    if N == 2:
        if S[0] == S[1]: # oxx
            return i+1,i+2
    for i in range(N-2):
        if S[i] ==  S[i+1]:  # xxo
            return i+1,i+2
        if S[i+1] == S[i+2]: # oxx
            return i+2,i+3
        if S[i] == S[i+2]:   # xox
            return i+1,i+3
    return -1, -1
def solv(s):
    a, b = solve(s)
    print(s[a-1:b])
    return a, b
#solv("oxx")
print(*solve(input()))


Fixed submission:
def solve(S):
    N = len(S)
    # N <= 10**5
    if N == 2:
        if S[0] == S[1]:
            return 1, 2
    for i in range(0, N-2):
        if S[i] == S[i+2]:
            return i+1, i+3
        if S[i] == S[i+1]:
            return i+1, i+3
        if S[i+1] == S[i+2]:
            return i+1, i+3
    return -1, -1
S = input()
print(*solve(S))

Buggy python submission (verdict: Runtime Error):
def solve(S):
    N = len(S)
    if N == 2:
        if S[0] == S[1]: # oxx
            return 1,2
    for i in range(N-2):
        if S[i] ==  S[i+1]:  # xxo
            return i+1,i+2
        if S[i+1] == S[i+2]: # oxx
            return i+2,i+3
        if S[i] == S[i+2]:   # xox
            return i+1,i+3
    return -1, -1
def solv(s)print(*solve(input()))


Fixed submission:
def solve(S):
    N = len(S)
    # N <= 10**5
    if N == 2:
        if S[0] == S[1]:
            return 1, 2
    for i in range(0, N-2):
        if S[i] == S[i+2]:
            return i+1, i+3
        if S[i] == S[i+1]:
            return i+1, i+3
        if S[i+1] == S[i+2]:
            return i+1, i+3
    return -1, -1
S = input()
print(*solve(S))

Buggy python submission (verdict: Runtime Error):
def solve(S):
    N = len(S)
    if N == 2:
        if S[0] == S[1]: # oxx
            return i+1,i+2
    for i in range(N-2):
        if S[i] ==  S[i+1]:  # xxo
            return i+1,i+2
        if S[i+1] == S[i+2]: # oxx
            return i+2,i+3
        if S[i] == S[i+2]:   # xox
            return i+1,i+3
    return -1, -1
def solv(s):
    a, b = solve(s)
    print(s[a-1:b])
    return a, b
#solv("oxx")
print(*solve(input()))


Fixed submission:
def solve(S):
    N = len(S)
    # N <= 10**5
    if N == 2:
        if S[0] == S[1]:
            return 1, 2
    for i in range(0, N-2):
        if S[i] == S[i+2]:
            return i+1, i+3
        if S[i] == S[i+1]:
            return i+1, i+3
        if S[i+1] == S[i+2]:
            return i+1, i+3
    return -1, -1
S = input()
print(*solve(S))
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
N, K = map(int, input().split())
D = input().split()

O = []
for c in "0123456789":
    if c not in D:
        O.append(c)

# N = 523
# D = 2 3

@lru_cache()
def func(s, i, over):
    if i == len(s):
        return ""
    # d < N[0] 
    if over:
        return O[0] + func(s, i+1, over=True)
    for d in O:
        if d < s[i]:
            continue
        if s[i] == d:
            return d + func(s, i+1, over=False)
        return d + func(s, i+1, over=True)

print(func(str(N), 0, over=False))

Fixed submission:
N, K = map(int, input().split())
D = [x for x in input().split()]

while True:
    S = str(N)
    if not any(d in S for d in D):
        break
    N += 1
print(N)

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
N, K = map(int, input().split())
D = input().split()

O = []
for c in "0123456789":
    if c not in D:
        O.append(c)

# N = 523
# D = 2 3

@lru_cache()
def func(s, i, over):
    if i == len(s):
        return ""
    # d < N[0] 
    if over:
        return O[0] + func(s, i+1, over=True)
    for d in O:
        if d < s[i]:
            continue
        if s[i] == d:
            return d + func(s, i+1, over=False)
        return d + func(s, i+1, over=True)

print(func(str(N), 0, over=False))

Fixed submission:
N, K = map(int, input().split())
D = [x for x in input().split()]

while True:
    S = str(N)
    if not any(d in S for d in D):
        break
    N += 1
print(N)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans=0
c=0
for a in range(1,1001):
    for b in range(1,1001):
        c=N-a*b
        if c>=1:
            ans+=1
ans1=0
for a in range(1,1001):
    for b in range(1001,1000001):
        c=N-a*b
        if c>=1:
            ans1+=1
print(ans+ans1*2)

Fixed submission:
N = int(input())
ans=0
c=0
for a in range(1,1001):
    c=N-a*a
    if c>=1:
        ans+=1
ans1=0
for a in range(1,1000001):
    for b in range(a+1,int(N/a)+1):
        c=N-a*b
        if c>=1:
            ans1+=1
print(ans+ans1*2)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
A = list(map(int, input().split()))
#N=3
#A=[1,2,3]
q=deque(A)
#print(q)
ans=0
for i in range(N-1):
    ans+=q.popleft() *sum(q)
print(ans%(10**9+7))

Fixed submission:
from collections import deque
N = int(input())
A = list(map(int, input().split()))
#N=3
#A=[1,2,3]
q=deque(A)
#print(q)
ans=0
sums=sum(q)
#print(sums)
for i in range(N-1):
    qwe=q.popleft()
    ans+=qwe *(sums-qwe)
    sums-=qwe
print(ans%(10**9+7))