s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1 value | original_language stringclasses 11 values | filename_ext stringclasses 1 value | status stringclasses 1 value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s223654371 | p04045 | u577504524 | 1593355499 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9184 | 666 | #C
n,k = map(int,input().split())
d = list(map(int,input().split()))
x = [i for i in range(10)]
num = list(set(x)-set(d))
price = str(n)
w = []
for i in range(len(price)):
for j in range(len(num)):
if num[j]>= int(price[i]):
w.append(j)
break
if num[len(num)-1] < int(price[i]):
k = 1
while True:
y = len(w) - k
if w[y]!=0:
w[y] = w[y]-1
break
else:
k +=1
w.append(num[0])
break
p = 0
for i in range(len(w)):
p += num[w[i]]*10**(len(w)-i-1)
print(p) |
s385224259 | p04045 | u577504524 | 1593355187 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9204 | 484 | #C
n,k = map(int,input().split())
d = list(map(int,input().split()))
x = [i for i in range(10)]
num = list(set(x)-set(d))
price = str(n)
w = []
for i in range(len(price)):
for j in range(len(num)):
if num[j]>= int(price[i]):
w.append(j)
break
if num[len(num)-1] < int(price[i]):
w[len(w)-1] = w[len(w)-1]-1
w.append(num[0])
break
p = 0
for i in range(len(w)):
p += num[w[i]]*10**(len(w)-i-1)
print(p) |
s876982084 | p04045 | u577504524 | 1593355113 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9220 | 484 | #C
n,k = map(int,input().split())
d = list(map(int,input().split()))
x = [i for i in range(10)]
num = list(set(x)-set(d))
price = str(n)
w = []
for i in range(len(price)):
for j in range(len(num)):
if num[j]>= int(price[i]):
w.append(j)
break
if num[len(num)-1] < int(price[i]):
w[len(w)-1] = w[len(w)-1]-1
w.append(num[0])
break
p = 0
for i in range(len(w)):
p += num[w[i]]*10**(len(w)-i-1)
print(p) |
s223359281 | p04045 | u643679148 | 1593343251 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9212 | 420 | n, k = input().split()
ds = list(map(int, input().split()))
p_num = list(set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - set(ds))
p_num.sort()
ans = []
if max(p_num) < int(n[0]):
n = n[1:]
if (min(p_num) != 0):
ans.append(p_num[0])
else:
ans.append(p_num[1])
for s in n:
for p in p_num:
if int(s) <= p:
ans.append(str(p))
break
ans = int(''.join(ans))
print(ans)
|
s184862450 | p04045 | u643679148 | 1593343121 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9212 | 406 | n, k = input().split()
ds = list(map(int, input().split()))
p_num = list(set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - set(ds))
p_num.sort()
ans = []
if max(p_num) < int(n[0]):
if (min(p_num) != 0):
ans.append(p_num[0])
else:
ans.append(p_num[1])
for s in n:
for p in p_num:
if int(s) <= p:
ans.append(str(p))
break
ans = int(''.join(ans))
print(ans)
|
s521491683 | p04045 | u643679148 | 1593342758 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9160 | 284 | n, k = input().split()
ds = list(map(int, input().split()))
p_num = list(set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - set(ds))
p_num.sort()
ans = []
for s in n:
for p in p_num:
if int(s) <= p:
ans.append(str(p))
break
ans = int(''.join(ans))
print(ans)
|
s090104311 | p04045 | u896004073 | 1593311425 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9208 | 886 | N, K = input().split()
dislike = set(list(map(int, input().split())))
next_map = {}
for i in range(10):
for j in range(i,10):
if j not in dislike:
if i == 0:
min_digit = j
next_map.update({ i : j })
break
next_map.update({ i : min_digit })
max_digit = max(next_map.values())
num = len(list(N))
count = num
cand = []
for n in list(N):
n = int(n)
if n in dislike:
n_ = next_map[n]
cand.append(n_)
count -= 1
cand.extend(count*[min_digit])
break
else:
cand.append(n)
cand = int("".join(list(map(str, cand))))
if int(N) <= cand:
print(cand)
else:
if min_digit == 0:
next_min = next_map[1]
cand = [next_min] + num * [0]
else:
cand = (num + 1) * [min_digit]
cand = int("".join(list(map(str, cand))))
print(cand) |
s309097272 | p04045 | u699522269 | 1593309172 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9040 | 256 | a = input().split()
tg = a[0]
ok_nums = set("1","2","3","4","5","6","7","8","9","0")
ng_nums = set(input().split())
ok_nums = ok_nums - ng_nums
rt = 0
i = int(tg)
while True:
if ok_nums >= set(d for d in str(i)):
print(i)
break
else:
i+=1
|
s236534621 | p04045 | u820195841 | 1592939447 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9368 | 395 | N, K = map(int, input().split())
P = list(map(int, input().split()))
numbers = [0,1,2,3,4,5,6,7,8,9]
use = []
for i in numbers:
if not i in P:
use.append(i)
ul = []
for u5 in [0, use[1]]:
for u4 in use:
for u3 in use:
for u2 in use:
for u1 in use:
ul.append(u5*10000 + u4*1000 + u3*100 + u2*10 + u1)
ul.sort()
for r in ul:
if N <= r:
print(r)
break |
s820063456 | p04045 | u793430793 | 1592842801 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9036 | 230 | #ABC042C
N,K=map(int,input().split())
N=str(N)
N_len=len(N)
a=[]
out=N
for i in range(K):
a.append(input())
for i2 in range(N_len):
for i3 in range(K):
if N[i2]==a[i3]:
out += 1
print(out)
|
s312386682 | p04045 | u804954217 | 1592832387 | Python | Python (3.8.2) | py | Runtime Error | 22 | 9016 | 555 | #include <iostream>
using namespace std;
int main(void)
{
int n, k;
cin >> n >> k;
bool dislikes[10] = {false};
for (int i = 0, x; i < k; i++)
{
cin >> x;
dislikes[x] = true;
}
auto valid = [&](int x) {
while (x)
{
int d = x % 10;
if (dislikes[d])
return false;
x /= 10;
}
return true;
};
for (int p = n; p < 80001; p++)
if (valid(p))
{
cout << p << endl;
break;
}
}
|
s457009253 | p04045 | u653883313 | 1592675414 | Python | Python (3.8.2) | py | Runtime Error | 39 | 9116 | 250 | n, k = map(int, input().split())
d = set(map(int, input().split()))
l = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
a = d ^ l
for i in range(n, 10000):
g = set(str(i))
i_int ={int(m) for m in g}
if i_int<=a:
ans = i
break
print(ans) |
s660408754 | p04045 | u653883313 | 1592674868 | Python | Python (3.8.2) | py | Runtime Error | 36 | 9144 | 250 | n, k = map(int, input().split())
d = set(map(int, input().split()))
l = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
a = d ^ l
for i in range(n, 10000):
g = set(str(i))
i_int ={int(m) for m in g}
if i_int==a:
ans = i
break
print(ans) |
s330242895 | p04045 | u951684192 | 1592536592 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9040 | 146 | N,K = map(int, input().split())
D = set(map(int, input().split()))
D2 = {1,2,3,4,5,6,7,8,9}
if 0 in D:
print(N)
else:
print(int(*D2-D)*N) |
s542533856 | p04045 | u372102441 | 1592442434 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3700 | 736 | import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
a=[]
b=[]
for i in range():
A, B = map(int, input().split())
a.append(A)
b.append(B)'''
a=list(map(str, [0,1,2,3,4,5,6,7,8,9]))
n,k=map(int, input().split())
d=list(map(str, input().split()))
for item in d:
a.remove(item)
#print(a)
from collections import deque
q=deque()
q.extend(a)
if n<10:
if a[0]!=0:
print(a[1])
sys.exit()
else:
print(a[0])
sys.exit()
while True:
qq=q.popleft()
#print(q)
for item in a:
qqq=qq+item
#print(qqq[::-1])
if int(qqq[::-1])>=n:
print(qqq[::-1])
sys.exit()
q.append(qqq[::-1])
|
s135017278 | p04045 | u841856382 | 1592229765 | Python | Python (3.4.3) | py | Runtime Error | 70 | 3060 | 354 | N, K = map(int, input().split())
d = list(map(str, input().split()))
ans = N
while True:
sra = str(ans)
if sra[0] not in d and sra[1] not in d and sra[2] not in d and sra[3] not in d:
if len(sra) == 5:
if sra[4] not in d:
print(sra)
break
print(sra)
break
ans = int(sra) + 1 |
s388756447 | p04045 | u811436126 | 1591508417 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 582 | n, k = map(int, input().split())
d = list(map(int, input().split()))
keta = int(len(str(n)))
ok = sorted(list(set(d) ^ {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))
ans = ''
for i in reversed(range(keta)):
val = int(str(n)[i])
candidate = [j for j in ok if j >= val]
if candidate:
ans += str(min(candidate))
else:
ans = str(min(ok))
ans = ''.join(reversed(list(ans)))
if int(ans) < n:
idx = ok.index(ans[0])
if idx == len(ok) - 1:
ans = str(min(ok)) * (keta + 1)
else:
ans = str(ok[idx + 1]) + str(min(ok)) * (keta - 1)
print(ans)
|
s558763832 | p04045 | u811436126 | 1591507719 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 435 | n, k = map(int, input().split())
d = list(map(int, input().split()))
ok = sorted(list(set(d) ^ {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))
ans = ''
for i in range(len(str(n))):
flag = False
num = int(str(n)[i])
candidate = [j for j in ok if j >= num]
if candidate:
ans += str(min(candidate))
else:
ans += min(ok)
flag = True
if flag:
ans[0] = str(min([i for i in ok if i > ans[0]]))
print(ans)
|
s979033622 | p04045 | u811436126 | 1591506877 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 254 | n, k = map(int, input().split())
d = list(map(int, input().split()))
ok = sorted(list(set(d) ^ {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))
ans = ''
for i in range(len(str(n))):
num = int(str(n)[i])
ans += str(min([j for j in ok if j >= num]))
print(ans)
|
s857317350 | p04045 | u757274384 | 1591333813 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 254 | # -*- coding : utf-8 -*-
n,k = map(int, input().split())
D = list(map(str, input().split()))
curr_num = N
while True :
n_str = str(curr_num)
for d in D:
if d in n_str:
curr_num += 1
break
else:
print(curr_num)
break
|
s080804357 | p04045 | u757274384 | 1591333730 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 219 | # -*- coding : utf-8 -*-
n,k = map(int, input().split())
D = list(map(str, input().split()))
while True :
n_str = str(N)
for d in D:
if d in n_str:
N += 1
break
else:
print(N)
break |
s067811569 | p04045 | u583276018 | 1591105485 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 269 | n, k = map(int, input().split())
d = list(map(int, input().split()))
other = [i for i in range(10)] - d
m = 0
def dfs(m, now):
m = int(m)
if(m >= n):
print(int(now))
else:
if(m == 0):
m = ""
m = str(m)
for(o in other):
dfs(m, m + o)
|
s925235212 | p04045 | u581142892 | 1591054714 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 932 | class A:
def solve(self):
[a, b, c] = sorted([int(x) for x in input().split(" ")])
if a == 5 and b == 5 and c == 7:
print("YES")
else:
print("NO")
class B:
def solve(self):
[n, l] = [int(x) for x in input().split(" ")]
strings = []
for r in range(n):
strings.append(input())
sorted_strings = sorted(strings)
print("".join(sorted_strings))
class C:
def solve(self):
[n, k] = [int(x) for x in input().split(" ")]
dislikes = [int(x) for x in input().split(" ")]
likes = []
for r in range(10):
if r not in dislikes:
likes.append(r)
import bisect as b
final_amount = []
for c in str(n):
i = b.bisect_left(likes, int(c))
final_amount.append(str(likes[i]))
print("".join(final_amount))
C().solve()
|
s303559524 | p04045 | u924845460 | 1590645231 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 117 | n,k=map(int, input().split())
ds=list(map(str, input().split()))
while i in str(n) for i in ds:
n+=1
print(str(n))
|
s213518475 | p04045 | u924845460 | 1590641747 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38384 | 131 | n,k=map(int, input().split())
ds=[]
for i in range(len(k)):
ds.append(input())
ans=n
while ds in ans:
ans+=1
print(str(ans))
|
s927887613 | p04045 | u306950978 | 1590433608 | Python | Python (3.4.3) | py | Runtime Error | 74 | 3924 | 236 | n , k = map(int,input().split())
d = set(list(map(int,input().split())))
kouho =list({0,1,2,3,4,5,6,7,8,9} - d)
kouho.sort()
def f(now):
if now >= n:
print(now)
exit()
for i in kouho:
f(now*10 + i)
f(0) |
s978087471 | p04045 | u822179469 | 1589947539 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 348 | n,k = map(int,input().split()) #入力
a = list(map(int,input().split())) #使用不可の数字
b = {0,1,2,3,4,5,6,7,8,9}-set(a) #使用可能な数字の集合
n = [int(i) for i in list(str(n))] #価格(int)をリストに分解
while set([int(i) for i in list(str(n))])-b !={} : # 使用可能な数字のみでなければ
n += 1
print(n) |
s423622729 | p04045 | u822179469 | 1589945990 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 307 | n,k = map(int,input().split()) #入力
a = list(map(int,input().split())) #使用不可の数字
n2 = [int(i) for i in list(str(n))] #価格を分解
for i in n2:
while n2[i] in a :#使用不可ならば
n2[i] += 1
if n2[i]>=10:
n2[i] =1
print("".join([str(i) for i in n2])) |
s208962859 | p04045 | u822179469 | 1589945873 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 339 | n,k = map(int,input().split()) #入力
a = list(map(int,input().split())) #使用不可の数字
b = list({0,1,2,3,4,5,6,7,8,9}-set(a)) #使用可能な数字のリスト
n2 = [int(i) for i in list(str(n))] #価格を分解
for i in n2:
while n2[i] in a :#使用不可ならば
n2[i] += 1
print("".join([str(i) for i in n2])) |
s818556852 | p04045 | u488178971 | 1589679813 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 411 | N,K= map(int,input().split())
D = [int(j) for j in input().split()]
D2 = list(set([i for i in range(0,10)])-set(D))
D1 = list(set([i for i in range(1,10)])-set(D))
ans =''
for i in reversed(range(-len(str(N)),0)):
if int(str(N)[i]) not in D:
ans+=str(N)[i]
elif i==-len(str(N)):
ans+=str(min(D1))
else:
ans+=str(min([d for d in D2 if d>int(str(N)[i])]))
print(int(ans[::-1])) |
s411723615 | p04045 | u818308350 | 1589659209 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 680 | #input
#n=3519,k=5,d=0,2,5,7,9
d0=[0,1,2,3,4,5,6,7,8,9]
n,k=map(int,input().split())
d=list(map(int,input().split()))
for i in range(k):d0.remove(d[i])
n=str(n)
n=n[::-1]
ans0=0
for i in range(len(n)):
for j in range(len(d0)):
if int(n[i])==9 and i<(len(n)-1) and d0[len(d0)-1]!=9:
ans=10**i * d0[0]
break
elif int(n[i])==9 and i==(len(n)-1) and d0[len(d0)-1]!=9:
ans=10**(i+1) * d0[0] + 10**i * d0[0]
break
elif int(n[i])==d0[j]:
ans=10**(i) * d0[j]
break
elif int(n[i])<d0[j]:
ans=10**(i) * d0[j]
break
ans0=ans0+ans
print(ans0) |
s568847651 | p04045 | u729535891 | 1589653812 | Python | Python (3.4.3) | py | Runtime Error | 34 | 3316 | 950 | from collections import deque
n, k = map(int, input().split())
D = list(map(int, input().split()))
# 1. 初期化
ok_lst = [x for x in range(0, 10) if x not in D]
ok_lst.sort(reverse = True)
stack = deque([x for x in ok_lst if x != 0])
while len(stack) > 0:
# 2. 現在の情報の取得
# 今回は現在の数字
now_num = stack.pop()
# 3. 処理
# もしnow_numの桁数がnの桁数と同じかつ条件の値以上の場合,ansに記録しwhileを終了.
# もしnow_numの桁数がnの桁数と同じかつ条件の値未満の場合,次は数値を足すとまずいのでcontinueで防ぐ
if len(str(now_num)) == len(str(n)) and now_num >= n:
ans = now_num
break
if len(str(now_num)) == len(str(n)) and now_num < n:
continue
# 4. 更新
for x in ok_lst:
next_num = str(now_num) + str(x)
next_num = int(next_num)
stack.append(next_num)
print(ans) |
s187741334 | p04045 | u285891772 | 1589498047 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3572 | 1300 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
"""
lim = 2*10**5 #必要そうな階乗の限界を入力
#階乗#
fact = [1] * (lim+1)
for n in range(1, lim+1):
fact[n] = n * fact[n-1] % mod
#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
fact_inv[n-1] = n*fact_inv[n]%mod
def C(n, r):
return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod
"""
N, K = MAP()
D = LIST()
while 1:
if set(list(str(N))) & set(D) == set():
print(N)
break
N += 1 |
s120190106 | p04045 | u379142263 | 1589351049 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3440 | 672 | import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18
n,k= map(int,input().split())
d = list(map(int,input().split()))
able = [True]*10
for i in range(k):
able[d[i]] = False
use = []
for i in range(len(able)):
if able[i] == True:
use.append(i)
while True:
ans = ""
s = str(n)
for i in range(len(s)):
c = int(s[i])
for j in range(len(use)):
if c<=use[j]:
ans += str(use[j])
break
if int(ans)>=n:
break
else:
n += 1
print(ans) |
s074580474 | p04045 | u317916383 | 1589114458 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 321 | inputNK = input()
N = int(inputNK[0])
K = int(inputNK[1])
dislike = input.split(" ")
judge = true
answer = 0
for i in range(N,INF):
for number in dislike:
if str(i).count(number) != 0
judge = false
break
if judge == true:
answer = i
break
else:
judge = true
print(i) |
s831259203 | p04045 | u446451725 | 1589087375 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 454 | import itertools
NK = input().split()
N = NK[0]
K = int(NK[1])
d = input().split()
D = [int[s] for s in d]
Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in D:
Da.remove(i)
Da_str = [str(j) for j in Da]
a_1 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N))]
a_2 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N)+1)]
a = a_1 + a_2
nu = [int(k) for k in a]
for i in nu:
if i >= int(N):
print(i)
break |
s683703784 | p04045 | u446451725 | 1589087199 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 456 | import itertools
NK = input().split()
N = NK[0]
K = int(NK[1])
d = input().split()
D = [int[s] for s in d]
Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in D:
Da.remove(i)
Da_str = [str(j) for j in Da]
a_1 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N))]
a_2 = [''.join(j) for j in itertools.product(Da_str, repeat=len(N)+1)]
a = a_1 + a_2
nu = [int(k) for k in a]
for i in nu:
if i >= int(N):
print(i)
break |
s407099380 | p04045 | u446451725 | 1589087017 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 467 | import itertools
NK = input().split()
N = NK[0]
K = int(NK[1])
d = input().split()
D = [int[s] for s in d]
Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(len(D)):
Da.remove(D[i])
Da_str = [str(j) for j in Da]
a_1 = [''.join(j) for j in itertools.product(b_st, repeat=len(N))]
a_2 = [''.join(j) for j in itertools.product(b_st, repeat=len(N)+1)]
a = a_1 + a_2
nu = [int(k) for k in a]
for i in nu:
if i >= int(N):
print(i)
break |
s681043206 | p04045 | u446451725 | 1589086802 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 460 | import itertools
NK = input().split()
N = NK[0]
K = int(NK[1])
d = input().split()
D = [int[s] for s in d]
Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(len(D)):
Da.remove(D[i])
Da_str = [str(j) for j in Da]
a_1 = [''.join(j) for j in itertools.product(b_st, repeat=len(N))]
a_2 = [''.join(j) for j in itertools.product(b_st, repeat=len(N)+1)]
a = a_1 + a_2
nu = [int(k) for k in a]
for i in nu:
if i >= N:
print(i)
break |
s060859799 | p04045 | u446451725 | 1589085336 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 401 | import itertools
NK = input().split()
N = NK[0]
K = int(NK[1])
d = input().split()
D = [int[s] for s in d]
Da = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(len(D)):
Da.remove(D[i])
nu = []
for j in itertools.combinations_with_replacement(Da, len(N)+1):
b = ''.join([str(j[i]) for i in range(len(N)+1)])
nu.append(int(b))
for i in nu:
if i >= N:
print(i)
break
|
s656527362 | p04045 | u586206420 | 1588999597 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3444 | 1546 | import copy
def make1d(n, m):
return [copy.deepcopy(m) for i in range(0,n)]
s = list(map(int, input().split()))
t = list(map(int, input().split()))
#支払う金額s[0]を桁ごとに分解する
#支払う金額の桁数:n
n = 0
while (s[0] // (10 ** n)) >= 10:
n = n + 1
l = make1d(n + 1, 1)
m = s[0]
for i in range(0, n + 1):
l[n - i] = m % 10
m = m // 10
#使えない数字->tを使える数字->numに変換
num = make1d(10, 1)
for i in range(0, len(t)):
num[t[i]] = 0
#支払う金額からスタートしてダメな数字を含む場合は1増やしていく
#払うべき金額->l,使える数字->num(使える->1,使えない->0),支払う金額(答え)->a
a = l
limit = 10 ** len(a) - 1
a_int = int(''.join(map(str, a)))
#桁数が一致しているときは
tmp = 1
for i in range(0, n + 1):
tmp = tmp * num[a[i]]
if tmp == 1:
ans = a_int
while tmp == 0:
if(a_int <= limit - 1):
a_int = a_int + 1
a_tmp = a_int
for i in range(0, n + 1):
a[n - i] = a_tmp % 10
a_tmp = a_tmp // 10
tmp = 1
for i in range(0, n + 1):
tmp = tmp * num[a[i]]
ans = a_int
else:#桁が一つ増える場合
count = 0
count_n = 1#0以外の最小の数
while count == 0:
count = count + num[count_n]
if num[0] == 1:
a = make1d[n + 2, 0]
a[0] = count_n
else:
a = make1d[n + 2, count_n]
ans = int(''.join(map(str, a)))
print(ans) |
s026985626 | p04045 | u646445992 | 1588828842 | Python | PyPy3 (2.4.0) | py | Runtime Error | 176 | 38256 | 672 | N, K = map(int, input().split())
D = list(map(int, input().split()))
OK = list({1, 2, 3, 4, 5, 6, 7, 8, 9} - set(D))
S = str(N)
ans = []
def find_next(x):
while True:
x += 1
if x in OK:
return str(x)
for i in range(len(S)):
if int(S[i]) in OK:
ans += S[i]
elif max(OK) > int(S[0]):
ans += find_next(int(S[0]))
for _ in range(len(S) - len(ans)):
ans += "0"
break
else:
if i == 0:
ans += str(min(OK))
else:
ans[-1] = find_next(ans[-1])
for _ in range(len(S) - len(ans) + 1):
ans += "0"
break
print("".join(ans)) |
s101671575 | p04045 | u730257868 | 1588826608 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3192 | 746 | n, k = map(int,input().split())
d = list(map(int,input().split()))
s = 0
while s == d[s]:
s += 1
x = 0
y = 0
while x <4:
if n // (10**x) >0:
y = x
x += 1
i = 0
a = [0]
m = 0
while i <= y:
a.append(((n//(10**(y-i)))%10))
i +=1
i = 0
t = 0
while i <= y + t:
j = 0
while j < k:
if a[y-i+1] == d[j]:
a[y-i+1] += 1
if y-i+1 < y+1:
a[y-i+2] = s
if a[y-i+1] == 10:
a[y-i+1] = 0
a[y-i] +=1
j+=1
i+=1
if a[0] == 1 and t == 0:
i = 1
while i<=y+1:
a[i] = 0
i += 1
i = 0
t = 1
continue
i = 0
while i <= y + t:
m += a[y-i+1]*(10**(i))
i+=1
print(m) |
s519971500 | p04045 | u730257868 | 1588825705 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 646 | n, k = map(int,input().split())
d = list(map(int,input().split()))
x = 0
y = 0
while x <4:
if n // (10**x) >0:
y = x
x += 1
i = 0
a = [0]
m = 0
while i <= y:
a.append(((n//(10**(y-i)))%10))
i +=1
i = 0
t = 0
while i <= y + t:
j = 0
while j < k:
if a[y-i+1] == d[j]:
a[y-i+1] += 1
if a[y-i+1] == 10:
a[y-i+1] = 0
a[y-i] +=1
j+=1
i+=1
if a[0] == 1 and t == 0:
a[1] = 0
a[2] = 0
a[3] = 0
a[4] = 0
i = 0
t = 1
continue
i = 0
while i <= y + t:
m += a[y-i+1]*(10**(i))
i+=1
print(m) |
s399996043 | p04045 | u730257868 | 1588805043 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 646 | n, k = map(int,input().split())
d = list(map(int,input().split()))
x = 0
y = 0
while x <4:
if n // (10**x) >0:
y = x
x += 1
i = 0
a = [0]
m = 0
while i <= y:
a.append(((n//(10**(y-i)))%10))
i +=1
i = 0
t = 0
while i <= y + t:
j = 0
while j < k:
if a[y-i+1] == d[j]:
a[y-i+1] += 1
if a[y-i+1] == 10:
a[y-i+1] = 0
a[y-i] +=1
j+=1
i+=1
if a[0] == 1 and t == 0:
a[1] = 0
a[2] = 0
a[3] = 0
a[4] = 0
i = 0
t = 1
continue
i = 0
while i <= y + 1:
m += a[y-i+1]*(10**(i))
i+=1
print(m) |
s336074556 | p04045 | u730257868 | 1588804898 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 643 | n, k = map(int,input().split())
d = list(map(int,input().split()))
x = 0
y = 0
while x <4:
if n // (10**x) >0:
y = x
x += 1
i = 0
a = [0]
m = 0
while i <= y:
a.append(((n//(10**(y-i)))%10))
i +=1
i = 0
t = 0
while i <= y:
j = 0
while j < k:
if a[y-i+1] == d[j]:
a[y-i+1] += 1
if a[y-i+1] == 10:
a[y-i+1] = 0
a[y-i] +=1
j+=1
i+=1
if a[0] == 1 and t == 0:
a[1] = 0
a[2] = 0
a[3] = 0
a[4] = 0
i = 0
t = 1
continue
i = 0
while i <= y + 1:
m += a[y-i+1]*(10**(i))
i+=1
print(m)
|
s621917806 | p04045 | u730257868 | 1588804420 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 591 | n, k = map(int,input().split())
d = list(map(int,input().split()))
x = 0
y = 0
while x <4:
if n // (10**x) >0:
y = x
x += 1
i = 0
a = [0]
m = 0
while i <= y:
a.append(((n//(10**(y-i)))%10))
i +=1
i = 0
t = 0
while i <= y:
j = 0
while j < k:
if a[y-i+1] == d[j]:
a[y-i+1] += 1
if a[y-i+1] == 10:
a[y-i+1] = 0
a[y-i] +=1
j+=1
i+=1
if a[0] == 1 and t == 0:
a[1] = a[2] = a[3] = a[4] = i = 0
t = 1
continue
i = 0
while i <= y + 1:
m += a[y-i+1]*(10**(i))
i+=1 |
s154583960 | p04045 | u730257868 | 1588804340 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3064 | 571 | n, k = map(int,input().split())
d = list(map(int,input().split()))
x = 0
y = 0
while x <4:
if n // (10**x) >0:
y = x
x += 1
i = 0
a = [0]
m = 0
while i <= y:
a.append(((n//(10**(y-i)))%10))
i +=1
i = 0
while i <= y:
j = 0
while j < k:
if a[y-i+1] == d[j]:
a[y-i+1] += 1
if a[y-i+1] == 10:
a[y-i+1] = 0
a[y-i] +=1
j+=1
i+=1
if a[0] == 1:
a[1] = a[2] = a[3] = a[4] = i = 0
continue
i = 0
while i <= y + 1:
m += a[y-i+1]*(10**(i))
i+=1
print(m) |
s659250155 | p04045 | u927870520 | 1588804030 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 638 | n,k=list(map(int,input().split()))
D=list(map(int,input().split()))
like=[]
for i in range(10):
if not i in D:
like.append(i)
N=str(n)
ans=[]
for i in range(len(N)):
for j in range(len(like)):
if like[j]>=int(N[i]):
ans.append(like[j])
break
else:
if not like[0]==0:
ans.append(like[1])
else:
ans.append(like[0])
for i in range(len(N)):
ans.append(like[0])
break
if ans[i]>int(N[i]):
for i in range(i+1,len(N)):
ans.append(like[0])
break
answer=''.join(map(str,ans))
print(int(answer)) |
s031267728 | p04045 | u230717961 | 1588529583 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3060 | 415 | import itertools
def solve(n, k, xs):
tmp = [str(i) for i in range(10) if i not in xs]
str_len = len(str(n))
hoge = [i for i in map(lambda x: int("".join(x)),
itertools.product(tmp, repeat=str_len)) if i >= n]
return hoge[0]
if __name__ == "__main__":
n, k = [int(i) for i in input().split()]
xs = [int(i) for i in input().split()]
print(solve(n, k, xs))
|
s775029378 | p04045 | u366541443 | 1588494357 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38256 | 340 | import math
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
for ii in range(n*10):
i = ii+1
ar = ValueToArray10(i, int(1+(math.log(i)+0.00001)/math.log(10)))
ok=1
for j in ar:
for k in a:
if(j==k):
ok=0
if(ok==1 and i>=n):
print(i)
exit()
|
s817785256 | p04045 | u486814557 | 1588060923 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 527 | l=list(map(int,input().split()))
d=list(map(int,input().split()))
d_bar=[]
for m in range(10):
if m not in d:
d_bar.append(m)
d_bar.sort()
n=[int(k) for k in str(l[0])
for i in range(len(n))
dig1=0
dig2=0
for j in range(l[1]):
p=dig1+d_bar[j]*10**(range(l[0])-i)
if p>l[0]:
break
dig1=p
dig2=dig2+d_bar[j]*l[1]**(range(l[0])-i)
dig2=dig2+1
r=dig
R=[]
while q!=0 or q!=1:
q=q/l[1]
r=q%l[1]
R.append(r)
s=int(sum[str(-t-1) for t in R])
print(s)
|
s669673608 | p04045 | u486814557 | 1588053190 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 656 | l=list(map(int,input().split()))
d=list(map(int,input().split()))
d_bar=[]
for m in range(10):
if m not in d:
d_bar.append(m)
d_bar.sort()
a=[]
p=0
n_int=[int(k) for k in str(l[0])]
for i in range(len(n_int)):
a.append(10)
for j in range(len(d_bar)):
if n_int[-i-1]==d_bar[j]:
a.pop(i)
a.append(d_bar[j+p])
p=0
break
elif n_int[-i-1]<d_bar[j]:
a.pop(i)
a.append(d_bar[j])
p=0
break
if a[i]==10:
a.pop(i)
a.append(d_bar[0])
p=1
b=''
for q in range(len(n_int)):
b=b+str(a[-q-1])
print(int(b)) |
s895417764 | p04045 | u486814557 | 1588049018 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 439 | l=list(map(int,input().split()))
d=list(map(int,input().split()))
d_bar=[]
for m in range(10):
if m not in d:
d_bar.append(m)
d_bar.sort()
a=[]
n_str=str(l[0])
n_int=[int(k) for k in n_str]
for i in n_int:
a.append('na')
for j in d_bar:
if i<=j:
a[i-1]=j
break
else:
pass
if a[i-1]='na':
a[i-1]=d_bar[0]
if a[0]=0:
a.insert(0,d_bar[0])
print(int(a)) |
s209511472 | p04045 | u486814557 | 1588047349 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 312 | l=list(map(int,input().split()))
d=list(map(int,input().split()))
d_bar=[]
for m in range(10):
if m not in d:
d_bar.append(m)
d_bar.sort()
a=''
for i in str(l[0]):
for j in d_bar:
if int(i)<=j:
k=str(j)
break
else:
pass
a=a+k
print(int(a)) |
s523848461 | p04045 | u306033313 | 1587916475 | Python | Python (3.4.3) | py | Runtime Error | 32 | 3700 | 1259 | n, k = map( int, input().split())
hate = set( input().split())
usable = sorted( list( {str(i) for i in range(10)} - hate))
l = len(str(n))
def check(l):
num = []
if l == 1:
for i in usable:
num.append(i)
if l == 2:
for ii in usable:
for i in usable:
num.append(int( str(ii) + str(i)))
elif l == 3:
for iii in usable:
for ii in usable:
for i in usable:
num.append(int( str(iii) + str(ii) + str(i)))
elif l == 4:
for iv in usable:
for iii in usable:
for ii in usable:
for i in usable:
num.append(int( str(iv) + str(iii) + str(ii) + str(i)))
else:
for v in usable:
for iv in usable:
for iii in usable:
for ii in usable:
for i in usable:
num.append(int( str(v) + str(iv) + str(iii) + str(ii) + str(i)))
return num
truf = False
num = check(l)
for i in num:
if n <= i:
print(i)
truf = True
break
if not truf:
num = check(l+1)
for i in num:
if n <= i:
print(i)
break |
s771393223 | p04045 | u306033313 | 1587916385 | Python | Python (3.4.3) | py | Runtime Error | 32 | 3700 | 1241 | n, k = map( int, input().split())
hate = set( input().split())
usable = sorted( list( {str(i) for i in range(10)} - hate))
l = len(str(n))
def check(l):
num = []
if l == 1:
for i in usable:
num.append(i)
if l == 2:
for ii in usable:
for i in usable:
num.append(int( str(ii) + str(i)))
elif l == 3:
for iii in usable:
for ii in usable:
for i in usable:
num.append(int( str(iii) + str(ii) + str(i)))
elif l == 4:
for iv in usable:
for iii in usable:
for ii in usable:
for i in usable:
num.append(int( str(iv) + str(iii) + str(ii) + str(i)))
else:
for v in usable:
for iv in usable:
for iii in usable:
for ii in usable:
for i in usable:
num.append(int( str(v) + str(iv) + str(iii) + str(ii) + str(i)))
return num
truf = False
num = check(l)
for i in num:
if n <= i:
print(i)
truf = True
break
if not truf:
num = check(l+1)
for i in num:
if n <= i:
print(i) |
s472313769 | p04045 | u308918401 | 1587782991 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 282 | a,n=map(int,input())
b=[]
for i in range(n):
b.append(int(input())
flag="F"
which flag=="F":
k=a
fflag="T"
which k>=1 and fflag=="T":
l=int(k%10)
for i in range(n):
if a[i]==l:
fflag="F"
break
if fflag=="T":
flag="T"
else:
a+=1
print(a) |
s305178661 | p04045 | u655622461 | 1587674249 | Python | Python (3.4.3) | py | Runtime Error | 39 | 3408 | 190 | N, L = map(int, input().split())
hates = [input() for _ in range(N)]
for i in range(N, 9999):
nums = list(str(i))
com = set(nums) & set(hates)
if len(com) == 0:
print(i) |
s203917040 | p04045 | u492447501 | 1587331615 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3060 | 262 | import sys
N,K = map(int, input().split())
*D, = input().split()
for n in range(N, 10000, 1):
L = list(str(n))
flg = 0
for l in L:
if (l in D) or n<N:
flg = 1
break
if flg==0:
print(n)
sys.exit(9) |
s553242666 | p04045 | u434872492 | 1587158516 | Python | Python (3.4.3) | py | Runtime Error | 37 | 3060 | 261 | N,K=map(int,input().split())
D=list(map(int,input().split()))
for price in range(N,10**4+1):
s=str(price)
flag=True
for i in range(len(s)):
if int(s[i]) in D:
flag=False
if flag:
ans=price
break
print(ans) |
s618811671 | p04045 | u145600939 | 1586917992 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2106 | 40556 | 304 | n,k = map(int,input().split())
d = list(input().split())
ans = n
while True:
flag = False
for i in d:
if flag :break
if i in str(ans):
x = len(str(n)) - str(n).index(i) - 1
ans += 10**x
flag = True
if flag:continue
print(ans)
break
|
s151171527 | p04045 | u145600939 | 1586917766 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3060 | 306 | n,k = map(int,input().split())
d = list(input().split())
ans = n
while True:
flag = False
for i in d:
if flag :break
if i in str(ans):
x = len(str(n)) - str(n).index(i) - 1
ans += 10**x
flag = True
if flag:continue
print(ans)
exit(0)
|
s568916532 | p04045 | u975644365 | 1586912171 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 347 | N, K = map(str, input().split())
N = ''.join(list(reversed(N)))
num_ls = [i for i in range(10)]
ls = map(int, input().split())
dif = list(set(num_ls) - set(ls))
dif.sort()
ans = ''
for i in N:
tmp = min(filter(lambda x: int(i) <= x, dif))
if tmp == None:
tmp=min(dif)
ans = ans + str(tmp)
print(''.join(list(reversed(ans)))) |
s140604602 | p04045 | u515647766 | 1586892302 | Python | Python (3.4.3) | py | Runtime Error | 72 | 3904 | 362 | def function(m, set1):
set2 = set(str(m))
if len(set1 & set2) > 0:
return False
else:
return True
def function(n, set1):
m = n
while not function(m, set1):
m += 1
return m
line1 = input().split()
n = int(line1[0])
k = int(line1[1])
list1 = []
for i in range(k):
list1.append(int(input()))
set1 = set(list1)
print(function(n, set1))
|
s503285288 | p04045 | u449863068 | 1586823049 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 221 | N, K = map(int, input().split())
D = list(map(int, input(split())))
i = N
while True:
flg = True
for j in str(i):
if int(j) in D:
flg = False
break
if flg == True:
print(i)
exit()
i += 1 |
s980819994 | p04045 | u687135117 | 1586804452 | Python | Python (3.4.3) | py | Runtime Error | 149 | 12488 | 1218 | import numpy as np
import sys
import math
readline = sys.stdin.buffer.readline
#N,K = map(int, readline().split())
N = list(input())
#print(N)
K=int(N[len(N)-1])
N.remove(' ')
N.remove(N[len(N)-1])
#print(N)
A = list(input().split())
#print(N,K)
#print(A)
Number=['1','2' ,'3', '4', '5', '6', '7', '8', '9','0']
#'''
for i in range(0,K):
if A[i]== '1':
Number.remove('1')
elif A[i]== '2':
Number.remove('2')
elif A[i]== '3':
Number.remove('3')
elif A[i]== '4':
Number.remove('4')
elif A[i]== '5':
Number.remove('5')
elif A[i]== '6':
Number.remove('6')
elif A[i]== '7':
Number.remove('7')
elif A[i]== '8':
Number.remove('8')
elif A[i]== '9':
Number.remove('9')
elif A[i]== '0':
Number.remove('0')
#'''
#print(N,K)
#print(A)
#print(Number,'Number')
Answer=[]
#print(N,'N')
for i in range(0,len(Number)):
for j in range (0,len(N)):
if int(Number[i])>=int(N[j]):
Answer.append(Number[i])
#print(min(Number[i]))
Answer1=[]
for i in range (0,len(N)):
Answer1.append(Answer[i])
#Answer1.reverse()
Answer1 = ''.join(Answer1)
print(Answer1) |
s775708733 | p04045 | u687135117 | 1586804386 | Python | Python (3.4.3) | py | Runtime Error | 150 | 12516 | 1217 | import numpy as np
import sys
import math
readline = sys.stdin.buffer.readline
#N,K = map(int, readline().split())
N = list(input())
#print(N)
K=int(N[len(N)-1])
N.remove(' ')
N.remove(N[len(N)-1])
#print(N)
A = list(input().split())
#print(N,K)
#print(A)
Number=['1','2' ,'3', '4', '5', '6', '7', '8', '9','0']
#'''
for i in range(0,K):
if A[i]== '1':
Number.remove('1')
elif A[i]== '2':
Number.remove('2')
elif A[i]== '3':
Number.remove('3')
elif A[i]== '4':
Number.remove('4')
elif A[i]== '5':
Number.remove('5')
elif A[i]== '6':
Number.remove('6')
elif A[i]== '7':
Number.remove('7')
elif A[i]== '8':
Number.remove('8')
elif A[i]== '9':
Number.remove('9')
elif A[i]== '0':
Number.remove('0')
#'''
#print(N,K)
#print(A)
#print(Number,'Number')
Answer=[]
print(N,'N')
for i in range(0,len(Number)):
for j in range (0,len(N)):
if int(Number[i])>=int(N[j]):
Answer.append(Number[i])
#print(min(Number[i]))
Answer1=[]
for i in range (0,len(N)):
Answer1.append(Answer[i])
#Answer1.reverse()
Answer1 = ''.join(Answer1)
print(Answer1) |
s236855492 | p04045 | u687135117 | 1586803452 | Python | Python (3.4.3) | py | Runtime Error | 152 | 12484 | 1199 | import numpy as np
import sys
import math
readline = sys.stdin.buffer.readline
#N,K = map(int, readline().split())
N = list(input())
#print(N)
K=int(N[len(N)-1])
N.remove(' ')
N.remove(N[len(N)-1])
#print(N)
A = list(input().split())
#print(N,K)
#print(A)
Number=['1','2' ,'3', '4', '5', '6', '7', '8', '9','0']
#'''
for i in range(0,K):
if A[i]== '1':
Number.remove('1')
elif A[i]== '2':
Number.remove('2')
elif A[i]== '3':
Number.remove('3')
elif A[i]== '4':
Number.remove('4')
elif A[i]== '5':
Number.remove('5')
elif A[i]== '6':
Number.remove('6')
elif A[i]== '7':
Number.remove('7')
elif A[i]== '8':
Number.remove('8')
elif A[i]== '9':
Number.remove('9')
elif A[i]== '0':
Number.remove('0')
#'''
#print(N,K)
#print(A)
#print(Number,'Number')
Answer=[]
for i in range(0,len(Number)):
for j in range (0,len(N)):
if int(Number[i])>=int(N[j]):
Answer.append(min(Number[i]))
#print(min(Number[i]))
#print(N,'N')
Answer1=[]
for i in range (-len(N),0):
Answer1.append(Answer[i])
Answer1 = ''.join(Answer1)
print(Answer1) |
s589137447 | p04045 | u870518235 | 1586406520 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 555 | N, K = map(int, input().split())
num = ["0","1","2","3","4","5","6","7","8","9"]
dis = input().split()
can_use = sorted(list(set(num)-set(dis)))
sN = str(N)
L = len(sN)
ans = ""
for i in range(1,L):
if sN[i] in can_use:
ans += sN[i]
else:
ans += min(can_use)
if sN[0] in can_use:
ans += sN[0]
else:
if can_use[0] == "0":
ans = can_use[1] + ans
else:
ans = can_use[0] + ans
if int(ans) < N:
if can_use[0] != "0":
ans = ans + can_use[1]
else:
ans = ans + can_use[0]
print(ans) |
s475720564 | p04045 | u870518235 | 1586398779 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 546 | N, K = map(int, input().split())
num = ["0","1","2","3","4","5","6","7","8","9"]
dis = input().split()
can_use = sorted(list(set(num)-set(dis)))
sN = str(N)
L = len(sN)
ans = ""
if sN[0] in can_use:
ans += sN[0]
else:
if can_use[0] == "0":
ans += can_use[1]
else:
ans += can_use[0]
for i in range(1,L):
if sN[i] in can_use:
ans += sN[i]
else:
ans += min(can_use)
if int(ans) < N:
if can_use[0] != "0":
ans = ans + can_use[1]
else:
ans = ans + can_use[0]
print(ans)
|
s988366733 | p04045 | u312784236 | 1586316837 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 651 | n,k=map(int, input().split())
d=list(map(int, input().split()))
l=list()
for i in range(10):
l.append(i)
l=list(set(d) ^ set(l))
lFirst=list(set(l) ^ set([0]))
nList=list(map(int, list(str(n))))
answer=list()
flag=False
for i in lFirst:
if nList[0]<i:
answer.append(i)
for i in range(1,len(nList)):
answer.append(l[0])
flag=True
elif nList[0]==i:
answer.append(i)
break
if False==flag:
for i in range(1,len(nList)):
for j in l:
if nList[i]<=j:
answer.append(j)
break
ans=''
for i in answer:
ans+=str(i)
print(int(ans)) |
s013239175 | p04045 | u684906944 | 1586229063 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 573 | n, k = map(int, input().split())
d = list(map(int, input().split()))
n_str = str(n)
# print(n_str)
l = list(({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(d)))
# print(l)
ans_list = []
for i in range(len(n_str)):
if int(n_str[i]) in l:
ans_list.append(n_str[i])
elif int(n_str[i]) < l[-1]:
for j in range(len(l)):
if l[j] > int(n_str[i]):
ans_list.append(l[j])
break
for k in range(i+1, len(n_str)):
ans_list.append(l[0])
break
# print(ans_list)
ans = ''
for i in range(len(ans_list)):
ans += str(ans_list[i])
print(int(ans)) |
s675907851 | p04045 | u133936772 | 1586031380 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 77 | n,_=map(int,input().split())
s=set(input())
while s&set(str(n)): n+=1
print(n |
s774757704 | p04045 | u870297120 | 1585943626 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 116 | N = int(input().split(' ')[0])
D = set(input())
while len(set(str(N))&D)!=0:
N += 1
print(N) |
s687729149 | p04045 | u870297120 | 1585943529 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 116 | N = int(input().split(' ')[0])
D = set(input())
while len(set(str(N))&D)!=0:
N += 1
print(N) |
s816462613 | p04045 | u449863068 | 1585744669 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 253 | N, K = map(int, input().split())
D = list(map(int, input().split()))
for
ans = ""
for n in str(N):
a = 0
while True:
if int(n) in D:
n = int(n) + 1
a = int(n)+1
else:
a = int(n)
ans += str(a)
break
print(ans)
|
s333019644 | p04045 | u443872523 | 1585713567 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 612 | N, K = map(int, input().split())
L = set(map(int, input().split()))
A = set(i for i in range(10))
B = sorted(list(A - L))
N_digit = len(str(N))
pay = ""
for i in str(N):
for b in B:
if b >= int(i):
pay += str(b)
break
else:
continue
if int(pay):
print(int(pay))
else:
if int(min(B)) == 0:
C = B - set(0)
pay = str(min(C))
for i in range(digit_N):
pay += "0"
print(int(pay))
else:
pay = str(min(C))
for i in range(digt_N):
pay += str(min(C))
print(int(pay))
|
s720973416 | p04045 | u443872523 | 1585608920 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 308 | N, K = map(int, input().split())
L = set(map(int, input().split()))
A = set(i for i in range(10))
B = sorted(list(A - L))
N_digit = len(str(N))
pay = ""
for i in str(N):
for b in B:
if b >= int(i):
pay += str(b)
break
else:
continue
print(int(pay)) |
s405076939 | p04045 | u443872523 | 1585608816 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 363 | N, K = map(int, input().split())
# L = set(input() for i in range(K))
L = set(map(int, input().split()))
# 差集合→list
A = set(i for i in range(10))
B = sorted(list(A - L))
N_digit = len(str(N))
pay = ""
for i in str(N):
for b in B:
if b >= int(i):
pay += str(b)
break
else:
continue
print(int(pay)) |
s538710672 | p04045 | u547167033 | 1585072772 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 193 | n,k=map(int,input().split())
d=list(map(int,input().split()))
N=list(str(n))
for i in range(len(N)):
N[i]=int(N[i])
for i in range(n,n*10+1):
if not N.isdisjoint(d):
print(i)
exit() |
s663589511 | p04045 | u545368057 | 1584963680 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1003 | N,K = map(int, input().split())
Ds = list(map(int, input().split()))
able = []
for i in range(10):
if i in Ds:continue
able.append(i)
# print(able)
sN = str(N)
n = len(sN)
m = able[0] #最小
if int(sN[0]) > max(able):
if m == 0:
ans = str(able[1]) + str(able[0]) * n
else:
ans = str(able[0]) * (n+1)
print(ans)
exit()
prev = -1
flg = True #確定していない
ans = ""
for i,s in enumerate(sN):
flg2 = False
if flg:
for j,a in enumerate(able):
if int(s) < a:
ans += str(a)
flg = False
flg2 = True
break
if int(s) == a:
ans += str(a)
flg = True
flg2 = True
break
if not flg2:
ans = ans[:-1]
ans += str(able[prev+1]) + str(m)
flg = False
else:
ans += str(m)
prev = j
# print(ans)
print(ans)
"""
1333 8
0 3 4 5 6 7 8 9
""" |
s127683617 | p04045 | u545368057 | 1584963542 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38384 | 955 | N,K = map(int, input().split())
Ds = list(map(int, input().split()))
able = []
for i in range(10):
if i in Ds:continue
able.append(i)
# print(able)
sN = str(N)
n = len(sN)
m = able[0] #最小
if int(sN[0]) > max(able):
if m == 0:
ans = str(able[1]) + str(able[0]) * n
else:
ans = str(able[0]) * (n+1)
print(ans)
exit()
prev = -1
flg = True #確定していない
ans = ""
for i,s in enumerate(sN):
flg2 = False
if flg:
for j,a in enumerate(able):
if int(s) < a:
ans += str(a)
flg = False
flg2 = True
break
if int(s) == a:
ans += str(a)
flg = True
flg2 = True
break
if not flg2:
ans = ans[:-1]
ans += str(able[prev+1]) + str(m)
flg = True
else:
ans += str(m)
prev = j
print(ans)
|
s705312520 | p04045 | u519835472 | 1584821670 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 282 | N,K = list(map(str, input().split()))
D = sorted(input().split())
W = []
P = ""
for i in range(10):
if str(i) not in D:
W.append(str(i))
for i in range(len(N)):
for j in range(len(W)):
if N[i] <= W[j]:
P += W[j]
break
print(int(P)) |
s923943146 | p04045 | u759518460 | 1584761393 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 508 | n, k = input().split()
d = input().split()
valid = [i for i in range(10) if str(i) not in d]
ans = ''
if valid[-1] < int(n[0]):
if valid[0] == 0:
ans += str(valid[1])
else:
ans += str(valid[0])
ans += str(valid[0]) * len(n)
else:
for i, s in enumerate(n):
if i > 0 and ans[i-1] > n[i-1]:
ans += str(valid[0]) * (len(n)-i)
break
for k in valid:
if k >= int(s):
ans += str(k)
break
print(ans) |
s929763507 | p04045 | u096616343 | 1584445092 | Python | Python (3.4.3) | py | Runtime Error | 19 | 2940 | 1 | a |
s325231315 | p04045 | u788703383 | 1584414675 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 677 | import sys
sys.setrecursionlimit(10**6)
n_price,k = map(str,input().split())
k = int(k)
n_length = len(n_price)
d_ng_list = list(input())
restrict = True
answer = ""
for s in range(10):
if str(s) not in d_ng_list:
min_number = str(s)
break
def find_number(i):
global restrict
if not restrict:
return min_number
for s in range(10):
if (str(s) not in d_ng_list) and str(s) >= n_price[i]:
if s > int(n_price[i]):
restrict = False
return str(s)
def rec_cal_pay(answer, i, restrict):
if i == n_length-1:
answer += find_number(i)
print(answer)
return
else:
c = find_number(i)
rec_cal_pay(answer+c, i+1, restrict)
rec_cal_pay(answer, 0, restrict)
|
s330217009 | p04045 | u788703383 | 1584412672 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 684 | import sys
sys.setrecursionlimit(10**6)
n_price,k = map(str,input().split())
k = int(k)
n_length = len(n_price)
d_ng_list = list(map(str,input().split()))
restricted = True
answer = ""
for s in range(10):
if str(s) not in d_ng_list:
min_number = str(s)
break
def find_number(i,restricted):
if not restricted:
return min_number
for s in range(10):
if str(s) not in d_ng_list and str(s) >= n_price[i]:
if str(s) > n_price[i]:
restricted = False
return str(s)
def rec_cal_pay(answer, i):
if i == n_length-1:
answer += find_number(i,restricted)
print(answer)
return
else:
c = find_number(i,restricted)
rec_cal_pay(answer+c,i+1)
rec_cal_pay(answer, 0)
|
s415705379 | p04045 | u788703383 | 1584412574 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 643 | n_price,k = map(str,input().split())
k = int(k)
n_length = len(n_price)
d_ng_list = list(map(str,input().split()))
restricted = True
answer = ""
for s in range(10):
if str(s) not in d_ng_list:
min_number = str(s)
break
def find_number(i,restricted):
if not restricted:
return min_number
for s in range(10):
if str(s) not in d_ng_list and str(s) >= n_price[i]:
if str(s) > n_price[i]:
restricted = False
return str(s)
def rec_cal_pay(answer, i):
if i == n_length-1:
answer += find_number(i,restricted)
print(answer)
return
else:
c = find_number(i,restricted)
rec_cal_pay(answer+c,i+1)
rec_cal_pay(answer, 0)
|
s074367606 | p04045 | u934868410 | 1584065431 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 196 | n,k = map(int,input().split())
D = list(map(int,input().split()))
while True:
dis = False
for d in D:
if d in str(n):
dis = True
break
if not dis:
break
n += 1
print(n) |
s731247956 | p04045 | u152638361 | 1584029918 | Python | Python (3.4.3) | py | Runtime Error | 36 | 3060 | 203 | N, K = map(int,input().split())
D = list(input())
for i in range(N, 10000):
M = list(str(i))
if all([M[j] not in D for j in range(len(M))]):
ans = int("".join(M))
break
print(ans) |
s080285038 | p04045 | u771538568 | 1583784824 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 244 | N,K=map(int,(input().split()))
li=[]
for i in range(K):
li.append(int(input()))
for j in range(N,10000):
k=0
for t in str(j):
if int(t) in li:
k=1
break
else:
if k==0:
print(j) |
s096594883 | p04045 | u572425901 | 1583726568 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38512 | 258 | N, K = map(int, input().split())
D = list(map(str, input().split()))
for i in range(n, 100000):
s = list(str(i))
flg = 0
for j in s:
if j in d:
flg = 1
break
if flg == 0:
print("".join(s))
break |
s256043756 | p04045 | u723583932 | 1583566205 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 398 | #abc 042 c
def dfs(i,s):
if i==n_keta:
if s>=n:
kouho.append(s)
return 0
for j in range(len(like)):
dfs(i+1,s+like[j])
return 0
n,k=input().split()
d=list(map(int,input().split()))
like=[]
for i in range(10):
if i not in d:
like.append(str(i))
kouho=[]
n_keta=len(n)
dfs(0,"")
if not kouho:
n_keta+=1
dfs(0,"")
print(min(kouho))
|
s743844544 | p04045 | u723583932 | 1583564688 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 358 | #abc 042 c
def dfs(i,s):
if i==n_keta:
if s>=n:
kouho.append(s)
return 0
for j in range(len(like)):
dfs(i+1,s+like[j])
return 0
n,k=input().split()
d=list(map(int,input().split()))
like=[]
for i in range(10):
if i not in d:
like.append(str(i))
kouho=[]
n_keta=len(n)
dfs(0,"")
print(min(kouho)) |
s952691506 | p04045 | u126887629 | 1583380043 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 257 | n,k = map(int, input().strip().split())
d = list(input().split())
n,k = map(int,input().strip().split())
d = list(input().split())
for x in range(n,100000):
for y in d:
if y in str(x):
break
else:
print(x)
break |
s211528341 | p04045 | u000123984 | 1583283298 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 158 | n,k = map(int, input().split())
li = list(map(int, input().split()))
Li = list(n)
while len(set(Li)&set(li)):
n += 1
Li = list(n)
else: print("".join(Li)) |
s842587910 | p04045 | u000123984 | 1583283253 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 153 | n,k = map(int, input().split())
li = list(map(int, input().split()))
Li = list(n)
while set(Li)&set(li):
n += 1
Li = list(n)
else: print("".join(Li)) |
s354621139 | p04045 | u000123984 | 1583283059 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 199 | n,k = map(int, input().split())
li = []
for i in range(k):
li.append(int(input()))
else:
Li = list(n)
while not len(set(li)&set(Li)) == 0:
n += 1
Li = list(n)
else: print("".join(Li)) |
s116218906 | p04045 | u000123984 | 1583283003 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 194 | n,k = map(int, input().split())
li = []
for i in range(k):
li.append(int(input()))
else:
Li = list(n)
while not len(set(li)&set(Li)):
n += 1
Li = list(n)
else: print("".join(Li)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.