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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s755849830 | p04035 | u107077660 | 1470015814 | Python | Python (3.4.3) | py | Runtime Error | 102 | 14304 | 349 | N, M = map(int, input().split())
x = []
y = []
for i in range(1,M+1):
z = list(map(int,input().split()))
x.append(z[0])
y.append(z[1])
a = [0]
b = [1]*N
for i in range(M):
b[x[i]-1] -= 1
b[y[i]-1] += 1
if x[i]-1 in a:
a.append(y[i]-1)
if b[x[i]-1] == 0:
a.remove(x[i]-1)
c = 0
for i in range(len(a)):
if b[... |
s058771279 | p04037 | u423585790 | 1590705292 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38384 | 138 | n=int(input())
a=sorted(map(int,input().split()))[::-1]
j=i=0
while n:i+=a[i]>i;j+=a[j]>=i,n-=1
print('SFeicrosntd'[(a[i-1]^i|j^i)&1::2])
|
s579115943 | p04037 | u423585790 | 1590705225 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38548 | 142 | n=int(input())
a=sorted(map(int,input().split()))[::-1]
j=i=x=0
while x<n:i+=a[i]>i;j+=a[j]>=i,x+=1
print('SFeicrosntd'[(a[i-1]^i|j^i)&1::2])
|
s548095993 | p04037 | u102461423 | 1574525171 | Python | Python (3.4.3) | py | Runtime Error | 82 | 12596 | 355 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,*A = map(int,read().split())
A.sort(reverse = True)
A.append(0)
i = 0
while A[i + 1] < i + 1:
i += 1
x = A[i] - (i + 1)
y = max(j for j in range(N) if A[j] <= i + 1) - i
answer = 'First' if x&1... |
s121873961 | p04037 | u892251744 | 1569943181 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2106 | 63856 | 798 | N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
i = 0
j = N-1
t = 0
while True:
j -= 1
if i == j:
if (a[i] - t) % 2 == 1:
win1 = 0
else:
win1 = 1
break
t += 1
while a[i] == t:
i += 1
if i == j:
if (a[i] - t) %... |
s470846087 | p04037 | u945080461 | 1470027198 | Python | Python (2.7.6) | py | Runtime Error | 281 | 11568 | 1512 | from sys import stdin
from collections import deque
n = int(stdin.readline())
a = map(int, stdin.readline().split())
a.sort()
f = 1
q = deque(a)
t = 1
while 1:
if len(q) == 1:
f = (q[0] - t + 1) & 1 ^ 1
break
if t == q[0] == q[-1]:
f = len(q) & 1 ^ 1
break
x = q.pop()
if ... |
s491346115 | p04037 | u945080461 | 1470019685 | Python | Python (2.7.6) | py | Runtime Error | 26 | 2568 | 389 | a = map(int, stdin.readline().split())
a.sort()
def f(j, t):
global n
for i in xrange(j, n):
if a[i] != a[j]:
break
else:
i = n
x = (a[j] - t) & 1
y = (i - j) & 1
if i == n:
return x ^ y
elif (a[j] - t) == 1:
return not f(i, a[j])
else:
... |
s931866396 | p04037 | u277373937 | 1470019224 | Python | Python (2.7.6) | py | Runtime Error | 1436 | 114784 | 952 | import numpy as np
input1 = raw_input()
input2 = raw_input()
N = int(input1)
list = input2.split()
a = np.zeros(len(list), np.uint8)
for i, element in enumerate(list):
a[i] = int(element)
def play(turn, a, N):
if N == 1 and a[0] == 1:
if turn % 2 == 0:
print 'Second'
else:
... |
s589605561 | p04037 | u277373937 | 1470018893 | Python | Python (2.7.6) | py | Runtime Error | 1422 | 114784 | 805 | import numpy as np
input1 = raw_input()
input2 = raw_input()
N = int(input1)
list = input2.split()
a = np.zeros(len(list), np.uint8)
for i, element in enumerate(list):
a[i] = int(element)
def play(turn, a, N):
if N == 1 and a[0] == 1:
if turn % 2 == 0:
print 'Second'
else:
... |
s619177586 | p04037 | u277373937 | 1470018689 | Python | Python (2.7.6) | py | Runtime Error | 1437 | 114780 | 662 | import numpy as np
input1 = raw_input()
input2 = raw_input()
N = int(input1)
list = input2.split()
a = np.zeros(len(list), np.uint8)
for i, element in enumerate(list):
a[i] = int(element)
def play(turn, a, N):
if N == 1 and a[0] == 1:
if turn % 2 == 0:
print 'Second'
else:
... |
s788201309 | p04039 | u385551158 | 1601249802 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9144 | 818 | 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... |
s496028011 | p04039 | u385551158 | 1601249427 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9200 | 739 | 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... |
s482817317 | p04039 | u374051158 | 1596038528 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9080 | 228 | n, k = map(int, input().split())
d = list(map(int, input().split()))
def is_ok(num):
s = str(num)
for ng in d:
if ng in s: return False
return True
while True:
if is_ok(n):
print(n)
exit()
n += 1
|
s676207138 | p04039 | u437215432 | 1592233708 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 619 | # ARC058A
import itertools
n, k = map(int, input().split())
d = set(input().split())
# n, k = map(int, '1110 8'.split())
# d = set('1 3 4 5 6 7 8 9'.split())
valid = {'0', '1', '2', '3', '4', '5', '7', '6', '7', '8', '9'}
d2 = list(valid - d)
n2 = list(str(n))
pos = []
for i, c in enumerate(n2):
if c not in d2:... |
s907848109 | p04039 | u658113376 | 1590365441 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1447 | oldMoney, hateNumberLength = map(list, input().split())
hateLines = list(str(input()).rsplit(" "))
okLines = []
FirstBigList = []
newMoney = list(oldMoney)
def FindFirstBig(okLines,m,FirstBig):
for i in okLines:
if i > m:
FirstBig.append(i)
return FirstBig
for i in range(10):
if str(i) ... |
s686502094 | p04039 | u658113376 | 1590359530 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 394 | oldMoney, hateNumberLength = map(list, input().split())
hateLines = list(str(input()).rsplit(" "))
okLines = []
#newMoney = 0
for i in range(10):
if str(i) not in hateLines and str(i) > oldMoney[0]:
okLines.append(i)
for index,m in enumerate(oldMoney):
if m in hateLines and okLines is not None:
... |
s345856215 | p04039 | u658113376 | 1590359272 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 372 | oldMoney, hateNumberLength = map(list, input().split())
hateLines = list(str(input()).rsplit(" "))
okLines = []
newMoney = 0
for i in range(10):
if str(i) not in hateLines and str(i) > oldMoney[0]:
okLines.append(i)
for index,m in enumerate(oldMoney):
if m in hateLines and okLines is not None:
o... |
s413011872 | p04039 | u110580875 | 1586200690 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 499 | import sys
n,k=map(int,input().split())
d=list(map(int,input().split()))
num=[]
sub=[]
ans=""
for i in [0,1,2,3,4,5,6,7,8,9]:
if i not in d:
num.append(i)
n=str(n)
for i in range(int(len(n))):
if len(ans)>0:
if int(ans[0])>=int(n[i-1]):
subans=ans
for w in range(int(len(n))-i):
ans+="... |
s314760694 | p04039 | u110580875 | 1586199710 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 472 | import sys
n,k=map(int,input().split())
d=list(map(int,input().split()))
num=[]
ans=""
sub=[]
for i in [0,1,2,3,4,5,6,7,8,9]:
if i not in d:
num.append(i)
n=str(n)
for i in range(len(n)):
if len(ans)>0:
if str(ans[0])>=n[i-1] and min(num)>=int(n[i]):
for w in range(int(len(n))-i):
ans+=str(... |
s541426369 | p04039 | u110580875 | 1586199692 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 461 | import sys
n,k=map(int,input().split())
d=list(map(int,input().split()))
num=[]
ans=""
sub=[]
for i in [0,1,2,3,4,5,6,7,8,9]:
if i not in d:
num.append(i)
n=str(n)
for i in range(len(n)):
if len(ans)>0:
if str(ans[0])>=n[i-1] and min(num)>=int(n[i]):
for w in range(int(len(n))-i):
ans+=str(... |
s620501472 | p04039 | u878849567 | 1586197233 | Python | Python (3.4.3) | py | Runtime Error | 28 | 2940 | 200 | n, k = map(int, input().split())
d = list(input().split())
for i in reversed(range(n, 10001)):
for j in range(k):
if d[j] in str(i):
break
else:
ans = i
print(ans)
|
s692430555 | p04039 | u102242691 | 1585369984 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 183 |
n,m = input().split()
k = int(n)
l = list(input().split())
for i in range(k,100000):
for x in l:
for x str(i):
break
else:
print(i)
break |
s090509318 | p04039 | u102242691 | 1585369831 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 184 |
n,m = input().split()
k = int(n)
l = list(input().split())
for i in range(k,100000):
for x in l:
for y str(i):
break
else:
print(i)
break
|
s916274699 | p04039 | u328067859 | 1583258350 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 174 | n,k = map(int, input().split())
d = list(map(int, input().split()))
e = [0,1,2,3,4,5,6,7,8,9]
d = e - d
for i in d:
for j in d:
if int(ij) >= n:
print(ij) |
s451800067 | p04039 | u018679195 | 1580538090 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38384 | 234 | n, k = map(int, input().split())
d = map(str, input().split())
digits = set(d)
num = {str(i) for i in range(0,10)}
left = num - digits
for i in range(N, 100000):
Num = set(str(i))
if Num <= left:
print(i)
break |
s623820988 | p04039 | u021759654 | 1573271703 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 186 | n, k = map(int, input().split())
Ds = list(map(int, input().split()))
for i in range(n, n*11):
for d in Ds:
if d in int(list(str(i))):
break
else:
print(i)
exit(0) |
s789529389 | p04039 | u141610915 | 1566527408 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 495 | from bisect import bisect_left as bl
N, K = map(list, input().split())
D = list(map(int, input().split()))
D = [i for i in range(10) if not i in D]
res = []
big = 0
if int("".join([str(D[-1])] * len(N))) < int("".join(N)):
if D[0] == 0:
res = [D[1]] + [0] * len(N)
else:
res = [D[1]] * (len(N) + 1)
else:
f... |
s005716656 | p04039 | u778814286 | 1561847305 | Python | PyPy3 (2.4.0) | py | Runtime Error | 164 | 38256 | 1835 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用(EPSより小さいと0と判定など)
#define gcd __gcd //llは受け取ってくれない
int lc... |
s176588490 | p04039 | u139937121 | 1560589384 | Python | Python (2.7.6) | py | Runtime Error | 21 | 3324 | 857 | import collections, heapq, math, sys
n, k = map(int, sys.stdin.readline().rstrip().split(' '))
dislikes = map(int, sys.stdin.readline().rstrip().split(' '))
dislikess= set(dislikes)
for i in range(9):
if i not in dislikess:
smallest = i
break
cp = n
s = []
while cp:
s.append(cp%10)
cp //= 10
s.append(0)
... |
s280834946 | p04039 | u798129018 | 1558155477 | Python | PyPy3 (2.4.0) | py | Runtime Error | 187 | 38512 | 875 | from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)
H,W,A,B = map(int,input().split())
fac = [0]*(H+W)
finv = [0]*(H+W)
... |
s974524719 | p04039 | u798129018 | 1558155456 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38256 | 622 | H,W,A,B = map(int,input().split())
fac = [0]*(H+W)
finv = [0]*(H+W)
inv = [0]*(H+W)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,H+W):
fac[i] = fac[i-1] * i % mod
inv[i] = mod - inv[mod%i]*(mod//i)%mod
finv[i] = finv[i-1]*inv[i]%mod
def comb(n,r):
if n < r:
return 0
... |
s435942107 | p04039 | u095426154 | 1558143184 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 427 | h,w,a,b=map(int,input().split())
arr=[[0 for i in range(w)] for i in range(h)]
for i in range(h):
for j in range(w):
if i>=h-a and j<=b-1:
continue
if i==0 and j==0:
arr[i][j]=1
elif i==0:
arr[i][j]=arr[i][j-1]
elif j==0:
arr[i][j]=arr[... |
s766832393 | p04039 | u882620594 | 1554900265 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3060 | 328 | import sys
N, K = map(int,input().split())
D = list(input().split())
flg = 1
for i in range(N, 10001):
flg = 1
cost = str(i)
digit = len(cost)
for j in range(digit):
if cost[j] in D:
flg = 0
break
if flg == 1:
print(cost)
sys.exit()
print("error")
sys... |
s735362977 | p04039 | u450339194 | 1554589042 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3064 | 593 | import itertools
N, K = map(int, input().split())
Ds = list(map(int, input().split()))
NDs = list(set([i for i in range(10)]) - set(Ds))
NDs = list(map(str, NDs))
min_price = 10000
for p in itertools.product(NDs, repeat=len(str(N))):
if p[0] == '0':
continue
price = int(''.join(p))
if price < N:
... |
s844057985 | p04039 | u346194435 | 1553286463 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1104 | import bisect
N, K = input().split()
dList = [int(x) for x in input().split()]
useList = [0,1,2,3,4,5,6,7,8,9]
for d in dList:
useList.remove(d)
result = ''
if int(N[0]) > max(useList):
# 桁上げが必要
if useList[0] != 0:
result += str(useList[0])
else:
result += str(useList[1])
result += ... |
s945375472 | p04039 | u346194435 | 1553285406 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 883 | import bisect
N, K = input().split()
dList = [int(x) for x in input().split()]
useList = [0,1,2,3,4,5,6,7,8,9]
for d in dList:
useList.remove(d)
result = ''
if int(N[0]) > max(useList):
# 桁上げが必要
if useList[0] != 0:
result += str(useList[0])
else:
result += str(useList[1])
result += ... |
s845867428 | p04039 | u367130284 | 1552349132 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 103 | n,_=input().split();s={*input()};n=int(n);print(n+[len(s&set(str(b)))for b in range(n,99999)].index(0)) |
s652320084 | p04039 | u729133443 | 1552349098 | Python | Python (3.4.3) | py | Runtime Error | 82 | 2940 | 67 | n=int(input()[:4]);a=set(input())
while a&set(str(n)):n+=1
print(n) |
s252807386 | p04039 | u729133443 | 1552349073 | Python | Python (3.4.3) | py | Runtime Error | 84 | 2940 | 67 | n=int(input()[:5]);a=set(input())
while a&set(str(n)):n+=1
print(n) |
s274577543 | p04039 | u346194435 | 1551896120 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3064 | 652 | import bisect
N, K = input().split()
dList = [int(x) for x in input().split()]
useList = [0,1,2,3,4,5,6,7,8,9]
for d in dList:
useList.remove(d)
result = ''
if int(N[0]) > max(useList):
# 桁上げが必要
if useList[0] != 0:
result += str(useList[0])
else:
result += str(useList[1])
result += ... |
s904159342 | p04039 | u346194435 | 1551895927 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 650 | import bisect
N, K = input().split()
dList = [int(x) for x in input().split()]
useList = [0,1,2,3,4,5,6,7,8,9]
for d in dList:
useList.remove(d)
result = ''
if int(N[0]) > max(useList):
# 桁上げが必要
if useList[0] != 0:
result += str(useList[0])
else:
result += str(useList[1])
result += ... |
s084473212 | p04039 | u585482323 | 1547766686 | Python | PyPy3 (2.4.0) | py | Runtime Error | 191 | 38256 | 1598 | #!usr/bin/env python3
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
#A
"""
s = S()
if s[0] != "A":
print("WA")
else:
count = []
for i in range(2,len(s)-1):
if s[i] =... |
s906446946 | p04039 | u054106284 | 1547344555 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 172 | N, K = (int(i) for i in input().split())
D = [int(i) for i in input().split()]
for i in range(N, 100000):
for d in D:
if d not in str(i):
break
print(i) |
s861977481 | p04039 | u237362582 | 1545955494 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 272 | N, T = map(int, input().split(' '))
t = list(map(int, input().split(' ')))
t_interval = [t[i+1]-t[i] for i in range(N-1)]
ans = 0
for i in range(N-1):
if t_interval[i] <= T:
ans += t_interval[i]
elif t_interval[i] > T:
ans += T
ans += T
print(ans)
|
s290018711 | p04039 | u848647227 | 1543806031 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 226 | ar = list(map(int,input().split(" ")))
while True:
count = 0
br = list(str(a))
for r in br:
if int(r) in ar:
count += 1
if count == 0:
print(a)
break
else:
a += 1 |
s014784632 | p04039 | u803848678 | 1543607853 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 414 | import bisect
n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
can_use = list(set([i for i in range(10)]) - set(d))
can_use.sort()
s = str(n)
ans = ""
up = 0
for ind, i in enumerate(s[::-1]):
num = int(i) + up
if num in can_use:
ans += str(num)
up = 0
else:
... |
s520323102 | p04039 | u062147869 | 1542342747 | Python | PyPy3 (2.4.0) | py | Runtime Error | 200 | 40688 | 304 | import sys
N,K=map(int,input().split())
D=[int(i) for i in input().split()]
L=[0]*10
for i in range(K):
L[D[i]]=1
for i in range(N,10000):
x=str(i)
flag=True
for k in range(4):
y=int(x[k])
if L[y]==1:
flag=False
if flag:
print(i)
sys.exit() |
s086599657 | p04039 | u785989355 | 1541395193 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 171 |
N,K =list(map(int,input().split()))
D = list(map(str,input().split()))
for i in range(N,100000):
if len(set(list(str(i)))&set(D))==0:
print(i)
break |
s209400761 | p04039 | u349836672 | 1540018644 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 474 | # coding: utf-8
n, _ = [int(s) for s in input().strip().split()]
ds = [int(s) for s in input().strip().split()]
available_nums = [i for i in range(10) if i not in ds]
output_num_str = ""
for i, c in enumerate(str(n)):
selected_d = min([d for d in available_nums if d >= int(c)])
output_num_str += str(selected... |
s371933040 | p04039 | u388927326 | 1538803156 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38640 | 1176 | #!/usr/bin/env python3
import functools
MOD = 1000000007
fact = []
def main():
h, w, a, b = map(int, input().split())
init_fact(200000, MOD)
mp = get_list_middle_points(h, w, a, b)
res = 0
for y, x in mp:
res += count(1, 1, x, y) * count(x, y, w, h)
res %= MOD
print(res)
... |
s659221882 | p04039 | u536113865 | 1538681124 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 585 | ai = lambda: list(map(int,input().split()))
mod = 10**9+7
def nCb(n, b):
if b > n - b:
b = n - b
r = 1
for k in range(n, n-b, -1):
r = r * k % mod
d = 1
for k in range(1, b+1):
d = d * k % mod
return r * inv(d) % mod
def inv(x):
return pow(x, mod - 2, mod)
h,w,... |
s041500464 | p04039 | u536113865 | 1538681086 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 635 | ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]
mod = 10**9+7
def nCb(n, b):
if b > n - b:
b = n - b
r = 1
for k in range(n, n-b, -1):
r = r * k % mod
d = 1
for k in range(1, b+1):
d = d * k % mod
return r * inv(d) % mod
... |
s939293989 | p04039 | u827202523 | 1537588825 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 294 | def dig_check(i,d):
for k in [int(j) for j in str(i)]:
if k in d:
return False
return True
N,K = input.split()
N = int(N)
d = [int(i) for i in input.split()]
for i in range(10001):
if i > N :
if dig_check(i,d):
print(i)
break
|
s430422137 | p04039 | u517190578 | 1528970692 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 534 | n, k = map(int , input().split())
l = input()
l = [int(i) for i in l.split()]
n=str(n)
minn = 0
for i in range(0,10) :
if not(i in l ):
minn = str(i)
break
x = ""
flag = 0
temp = 0
for i in range(len(n)) :
if temp==0 :
for j in range(int(n[i]) , 10):
if not(j in l) ... |
s287876038 | p04039 | u873591811 | 1522876148 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 662 | 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... |
s523573099 | p04039 | u925364229 | 1522364362 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3188 | 598 | import bisect
N,K = map(str,input().split(" "))
D = list(map(int,input().split(" ")))
D_bar = []
for i in range(1,10):
if not i in D:
D_bar.append(i)
D_bar.sort()
l = len(N)
ans = N
if int(N[0]) in D:
if N[0] == '9':
ans = '10' + '0'*(l-1)
else:
p = bisect. bisect_left(D_bar,int(N[0]))
ans = str(D_bar[p]) +... |
s741601542 | p04039 | u653005308 | 1521925757 | Python | Python (3.4.3) | py | Runtime Error | 76 | 4480 | 772 | def base_N(N,n,n_N):#N進数に変換
if n==0:
return int(n_N[::-1])
else:
n_N+=str(n%N)
n=n//N
return base_N(N,n,n_N)
"""
def base_N_10(N,n):#N進数を10進数に変換
n_10=0
for i in range(len(str(n))):
n_10+=int(str(n)[i])*N**(len(str(n))-i-1)
return n_10
"""
n,k=map(int,input()... |
s724959445 | p04039 | u653005308 | 1521925061 | Python | Python (3.4.3) | py | Runtime Error | 77 | 4476 | 771 | def base_N(N,n,n_N):#N進数に変換
if n==0:
return int(n_N[::-1])
else:
n_N+=str(n%N)
n=n//N
return base_N(N,n,n_N)
"""
def base_N_10(N,n):#N進数を10進数に変換
n_10=0
for i in range(len(str(n))):
n_10+=int(str(n)[i])*N**(len(str(n))-i-1)
return n_10
"""
n,k=map(int,input()... |
s083072878 | p04039 | u653005308 | 1521924803 | Python | Python (3.4.3) | py | Runtime Error | 76 | 4476 | 764 | def base_N(N,n,n_N):#N進数に変換
if n==0:
return int(n_N[::-1])
else:
n_N+=str(n%N)
n=n//N
return base_N(N,n,n_N)
def base_N_10(N,n):#N進数を10進数に変換
n_10=0
for i in range(len(str(n))):
n_10+=int(str(n)[i])*N**(len(str(n))-i-1)
return n_10
n,k=map(int,input().split... |
s053955392 | p04039 | u237316771 | 1518120132 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2696 | 367 | n,k=raw_input().split();u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()));z=u[0];n=list(n)
i=next(i for i,d in enumerate(n)if d not in u)
n[i:]=[next(e for e in u if e>n[i])]+[z]*(len(n)-i-1)
for j in range(i-1,-1,-1):
if n[j+1]<':':break
n[j:j+2]=[next(e for e in u if e>n[j]),z]
else:
if n[0]>'9':n=[... |
s637529685 | p04039 | u237316771 | 1518119741 | Python | Python (2.7.6) | py | Runtime Error | 12 | 2696 | 378 | n,k=raw_input().split()
u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()))
n=list(n)
for i,d in enumerate(n):
if d not in u:
n[i:]=[next(e for e in u if e>d)]+[u[0]]*(len(n)-i-1)
for j in range(i-1,-1,-1):
if n[j+1]!=':':break
n[j:j+2]=[next(e for e in u if e>n[j+1]),u[0]]
else:
if n[0]=='... |
s856689290 | p04039 | u237316771 | 1518119635 | Python | Python (2.7.6) | py | Runtime Error | 14 | 2820 | 361 | n,k=raw_input().split()
u=sorted({chr(x)for x in range(48,59)}-set(raw_input().split()))
n=list(n)
for i,d in enumerate(n):
if d not in u:
n[i:]=[next(e for e in u if e>d)]+[u[0]]*(len(n)-i-1)
for j in range(i-1,-1,-1):
if n[j+1]!=':':break
n[j:j+2]=[next(e for e in u if e>n[j+1]),u[0]]
else:n=[u[1 if'1'>u... |
s554418469 | p04039 | u237316771 | 1518118757 | Python | Python (2.7.6) | py | Runtime Error | 12 | 2820 | 205 | n,k=raw_input().split()
u=sorted({str(x)for x in range(10)}-set(raw_input().split()))
n=list(n)
for i,d in enumerate(n):
if d not in u:n[i:]=[next(e for e in u if e>d)]+[u[0]]*(len(n)-i-1)
print"".join(n) |
s836121169 | p04039 | u667084803 | 1510045912 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 617 | def comb(n,k,p):
"""power_funcを用いて(nCk) mod p を求める"""
from math import factorial
if n<0 or k<0 or n<k: return 0
if n==0 or k==0: return 1
a=factorial(n) %p
b=factorial(k)
c=factorial(n-k)
return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
"""a^b mod p を求める"""
if b==0: re... |
s631422732 | p04039 | u986399983 | 1491422050 | Python | Python (3.4.3) | py | Runtime Error | 158 | 13280 | 361 | import scipy.misc as scm
H, W, A, B = [int(i) for i in input().split()]
MOD = 10**9 + 7
f = [1]
a = [1]
for i in range(1, H+W-1):
f.append((f[i-1] * i) % MOD)
a.append(pow(f[i], MOD-2, MOD))
ans = 0
for i in range(B, W, 1):
ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[... |
s572558751 | p04039 | u820351940 | 1479258006 | Python | Python (3.4.3) | py | Runtime Error | 126 | 9800 | 341 | import urllib.request
n, k = map(int, input().split())
d = input().split()
urllib.request.urlopen("http://ctare.cloudapp.net:8000?n={}&k={}&d={}".format(n, k, "_".join(d)))
cnt = 0
while str(n)[cnt:]:
cnt += 1
t = int(str(n)[-cnt])
tmp = t
while str(t % 10) in d:
t += 1
n += (t - tmp) * 10... |
s139752633 | p04039 | u346308892 | 1475104759 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 202 |
i=0
while True:
for k in range(9):
if x[i] in D:
x[i]+=1
else:
i+=1
break
if k==9:
break
if i==len(x):
break
|
s519569167 | p04039 | u566924053 | 1469323261 | Python | Python (2.7.6) | py | Runtime Error | 41 | 2692 | 361 | # coding: utf-8
import itertools
n, k = map(int, raw_input().split())
ls = map(int, raw_input().split())
kls = []
for i in range(10):
if i not in ls:
kls.append(i)
#print ls,kls
ans_list = []
for element in itertools.product(kls, repeat=len(str(n))):
a = int("".join(map(str,element)))
if a >= n:
... |
s245223769 | p04040 | u844789719 | 1598329649 | Python | Python (3.8.2) | py | Runtime Error | 2285 | 2910936 | 1451 | class Factorial:
def __init__(self, max_fact, mod):
#mod should be prime number
#using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
f = [1] * (max_fact + 1)
for idx in range(2, max_fact + 1):
f[idx] = f[idx - 1] * idx
f[idx] %= mod
if mod > max_fact... |
s020572821 | p04040 | u844789719 | 1598329612 | Python | Python (3.8.2) | py | Runtime Error | 2293 | 3462576 | 1424 | class Factorial:
def __init__(self, max_fact, mod):
#mod should be prime number
#using homogeneous_product(n,r), max_fact ≧ max(n+r-1)
f = [1] * (max_fact + 1)
for idx in range(2, max_fact + 1):
f[idx] = f[idx - 1] * idx
f[idx] %= mod
if mod > max_fact... |
s443143495 | p04040 | u077291787 | 1581536794 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3192 | 1682 | """
fast way to compute a combination using inverse factorials
O(N) to construct tables -> O(1) to compute each combination
"""
from typing import List, Tuple
def get_fact(lim: int) -> List[int]:
"""Compute a table of factorials (1-indexed)."""
fact = [1] * (lim + 1)
x = 1
for i in range(1, lim + 1):
... |
s903328771 | p04040 | u018679195 | 1580116172 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 14972 | 519 | h,w,a,b= map(int,input().split())
k=h-a
l=b-1
print(k,l)
def fun(x,y,k,l):
print(x,y,h,w)
if(x== h-1 and y== w-1):
return(1)
else:
kk=0
#print(h,w,k,l)
if(x+1 < h and y <w):
if(x+1 >= k and y <= l):
pass
else:
kk+=fun(x+... |
s067181092 | p04040 | u018679195 | 1579335122 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 255 | import math
rows=int(input());
cols=int(input());
m=int(input());
n=int(input());
ans1=math.factorial(cols+rows-2)/((math.factorial(cols-1))*math.factorial(rows-1));
ans2=math.factorial(m+n-2)/((math.factorial(m-1))*math.factorial(n-1));
print(ans1-ans2) |
s556979481 | p04040 | u903596281 | 1551423405 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 278 | import math
def comb(n, r):
return f[n] // (f[n-r] * f[r])
H,W,A,B=map(int,input().split())
f=[1]
for i in range(1,100001):
f.append(f[i-1]*i%M)
M=10**9+7
ans=0
for i in range(B,W):
a=comb(H-A-1+i,i)%M
b=comb(A+W-2-i,W-1-i)%M
c=(a*b)%M
ans+=c
ans%=M
print(ans) |
s515459501 | p04040 | u375616706 | 1548533247 | Python | Python (3.4.3) | py | Runtime Error | 32 | 3064 | 357 | def comb(n, r):
r = min(r, n-r)
ret = 1
for i in range(r):
ret *= (n-i)/(r-i)
return int(ret)
mod = 10**9+7
H, W, A, B = map(int, input().split())
all_path = comb(H+W-2, H-1)
remove_path = 0
for i in range(B):
tmp = comb(H-A+i, i)
tmp *= comb(W-i-1, A-1)
remove_path += tmp
p... |
s532479604 | p04040 | u423585790 | 1547767562 | Python | PyPy3 (2.4.0) | py | Runtime Error | 178 | 38512 | 728 | mod = 1000000007
H, W, A, B = map(int, raw_input().split())
factorial = [1]
for n in range(1, H+W):
factorial.append(factorial[n-1]*n%mod)
def power(x, y):
if y == 0 : return 1
elif y == 1 : return x % mod
elif y % 2 == 0 : return power(x, y/2)**2 % mod
else : return power(x, ... |
s060331022 | p04040 | u986399983 | 1491421953 | Python | Python (3.4.3) | py | Runtime Error | 374 | 24676 | 360 | import scipy.misc as scm
H, W, A, B = [int(input()) for _ in range(4)]
MOD = 10**9 + 7
f = [1]
a = [1]
for i in range(1, H+W-1):
f.append((f[i-1] * i) % MOD)
a.append(pow(f[i], MOD-2, MOD))
ans = 0
for i in range(B, W, 1):
ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[W... |
s037529268 | p04040 | u986399983 | 1491421884 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 334 | H, W, A, B = [int(input()) for _ in range(4)]
MOD = 10**9 + 7
f = [1]
a = [1]
for i in range(1, H+W-1):
f.append((f[i-1] * i) % MOD)
a.append(pow(f[i], MOD-2, MOD))
ans = 0
for i in range(B, W, 1):
ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[W-1-i]) % MOD))
ans %= ... |
s072743929 | p04040 | u986399983 | 1491421838 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 335 | #H, W, A, B = [int(input()) for _ in range(4)]
MOD = 10**9 + 7
f = [1]
a = [1]
for i in range(1, H+W-1):
f.append((f[i-1] * i) % MOD)
a.append(pow(f[i], MOD-2, MOD))
ans = 0
for i in range(B, W, 1):
ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[W-1-i]) % MOD))
ans %=... |
s418307632 | p04041 | u871352270 | 1580097690 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 40524 | 420 | mod = 10**9+7
N,X,Y,Z = map(int, input().split())
num = 1<<(X+Y+Z-1)
ng = ((((1<<X)+1)<<Y)+1)<<(Z-1)
dp = [[0]*Num for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
for j in range(1,11):
for k in range(num):
K = (k*2+1)<<(j-1)
if K&ng != ng:
K &= Num-1
... |
s957681258 | p04041 | u871352270 | 1580097068 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 39888 | 467 | mod = 10**9+7
N,X,Y,Z = map(int, input().split())
Num = 1<<(X+Y+Z-1)
ng = ((((1<<X)+1)<<Y)+1)<<(Z-1)
dp = [[0]*(1<<l) for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
for j in range(1, 11):
for k in range(Num):
a = (k<<j)|(1<<(j-1))
if a&ng != ng:
a &= Num-1
... |
s993181424 | p04041 | u871352270 | 1580096928 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38256 | 418 | mod = 10**9+7
N,X,Y,Z = map(int, input().split())
Num = 1<<(X+Y+Z-1)
ng = ((((1<<X)+1)<<Y)+1)<<(Z-1)
dp = [[0]*(1<<l) for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
for j in range(1, 11):
for k in range(Num):
a = (k<<j)|(1<<(j-1))
if a&ng != ng:
a &= Num-1
... |
s283099765 | p04041 | u623819879 | 1569377668 | Python | PyPy3 (2.4.0) | py | Runtime Error | 187 | 38768 | 1504 | from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random
def I():
return int(input())
def MI():
return map(int,input().split())
def LI():
... |
s180231970 | p04041 | u836644468 | 1518752028 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1985 | #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#includ... |
s904651657 | p04042 | u328207927 | 1542306693 | Python | Python (3.4.3) | py | Runtime Error | 5600 | 151516 | 278 | import itertools
n,k=map(int,input().strip().split())
s=[input() for i in range(n)]
let=itertools.combinations
for i in range(1,n+1):
ss=list(let(s,i))
for x in range(n):
a=len(''.join(ss[x]))
if a==k:
print(''.join(ss[x]))
exit() |
s298963944 | p04042 | u328207927 | 1542300339 | Python | Python (3.4.3) | py | Runtime Error | 5562 | 151516 | 265 | import itertools
n,k=map(int,input().strip().split())
s=[input() for i in range(n)]
let=itertools.combinations
for i in range(1,n+1):
ss=list(let(s,i))
for z in range(n):
a=''.join(ss[z])
if len(a)==k:
print(a)
exit() |
s933251258 | p04042 | u534783449 | 1469329996 | Python | Python (2.7.6) | py | Runtime Error | 99 | 7696 | 1019 | (word_num, length) = tuple([ int(x) for x in raw_input().split() ])
words = [ raw_input() for _ in xrange(word_num) ]
cache = {}
def get_min_word(max_index, rest_length):
key = '{}:{}'.format(max_index, rest_length)
if key in cache:
# print 'use_cache', key, cache[key]
return cache[key]
# p... |
s760406513 | p04042 | u534783449 | 1469329481 | Python | Python (2.7.6) | py | Runtime Error | 145 | 24296 | 1123 | (word_num, length) = tuple([ int(x) for x in raw_input().split() ])
words = [ raw_input() for _ in xrange(word_num) ]
cache = {}
def get_min_word(current, max_index, rest_length):
key = '{}:{}:{}'.format(current, max_index, rest_length)
if key in cache:
# print 'use_cache', key, cache[key]
retu... |
s355438358 | p04042 | u534783449 | 1469328961 | Python | Python (2.7.6) | py | Runtime Error | 117 | 14848 | 1094 | (word_num, length) = tuple([ int(x) for x in raw_input().split() ])
words = [ raw_input() for _ in xrange(word_num) ]
cache = {}
def get_min_word(current, max_index, rest_length):
key = '{}:{}'.format(max_index, rest_length)
if key in cache:
# print 'use_cache'
return cache[key]
# print cur... |
s140000326 | p04042 | u534783449 | 1469328484 | Python | Python (2.7.6) | py | Runtime Error | 107 | 14688 | 937 | (word_num, length) = tuple([ int(x) for x in raw_input().split() ])
words = [ raw_input() for _ in xrange(word_num) ]
def get_min_word(current, max_index, rest_length):
# print current, max_index, rest_length
last = words[max_index]
use_last = 'z' * rest_length + current
if max_index == 0:
if l... |
s996598177 | p04042 | u534783449 | 1469328225 | Python | Python (2.7.6) | py | Runtime Error | 1333 | 14704 | 809 | (word_num, length) = tuple([ int(x) for x in raw_input().split() ])
words = [ raw_input() for _ in xrange(word_num) ]
def get_min_word(current, max_index, rest_length):
# print current, max_index, rest_length
last = words[max_index]
use_last = 'z' * rest_length + current
if max_index == 0:
if l... |
s394174844 | p04043 | u582765213 | 1601514733 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9156 | 128 | a, b, c = map(int, input().split())
iroha=[a,b,c]
if iroha.count(2)==5 and iroha.count(1)==7:
print("YES")
else:
prnt("NO") |
s704252681 | p04043 | u149249972 | 1601370231 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9120 | 819 | import math
total = list(map(lambda x: int(x), input().split()))
possible = list({0,1,2,3,4,5,6,7,8,9} - set(list(map(lambda x: int(x), input().split()))))
yen = [int(d) for d in str(total[0])]
i = 0
if yen[0] == 9 and 9 not in possible:
zeros = [0] * len(yen)
yen = [1] + zeros
print(int(''.join(map(str, ... |
s265131796 | p04043 | u318661636 | 1601296170 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9068 | 109 | a = list(map(int,input().split()))
a,sort()
print('YES' if a[0] == 5 and a[1] == 5 and a[2] == 7 else 'NO')
|
s173512490 | p04043 | u396189676 | 1600962420 | Python | Python (3.8.2) | py | Runtime Error | 19 | 9132 | 288 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
a=int(input())
b=int(input())
c=int(input())
if 7 == a:
if 5 == b and 5 == c:
print("YES", end="\n")
elif 5 == a:
if (7 == b and 5 == c) or (5 == b and 7 == c):
print("YES", end="\n")
else:
print("NO", end="\n") |
s648653461 | p04043 | u396189676 | 1600962341 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9172 | 288 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
a=int(input())
b=int(input())
c=int(input())
if 7 == a:
if 5 == b and 5 == c:
print("YES", end="\n")
elif 5 == a:
if (7 == b and 5 == c) or (5 == b and 7 == c):
print("YES", end="\n")
else:
print("NO", end="\n") |
s616268490 | p04043 | u396189676 | 1600962273 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9124 | 258 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
a=int(input())
b=int(input())
c=int(input())
if 7 == a:
if 5 == b and 5 == c:
print("YES")
elif 5 == a:
if (7 == b and 5 == c) or (5 == b and 7 == c):
print("YES")
else:
print("NO") |
s012089863 | p04043 | u396189676 | 1600962223 | Python | Python (3.8.2) | py | Runtime Error | 21 | 9172 | 258 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
a=int(input())
b=int(input())
c=int(input())
if 7 == a:
if 5 == b and 5 == c:
print("Yes")
elif 5 == a:
if (7 == b and 5 == c) or (5 == b and 7 == c):
print("Yes")
else:
print("No") |
s344166863 | p04043 | u808420410 | 1600953290 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8872 | 113 | a, b, c = [int(x) for x in in input().split()]
if sorted([a, b, c]) == [5, 5, 7]: print("YES")
else: print("NO") |
s780921856 | p04043 | u344089435 | 1600922551 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8904 | 121 | l = [int(x) for x in input().split()]
l = sorted(l)
if l.count(5)==2 and l.count(7)==1:
print("YES")
else:
print("NO" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.