user_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 1
value | submission_id_v0
stringlengths 10
10
| submission_id_v1
stringlengths 10
10
| cpu_time_v0
int64 10
38.3k
| cpu_time_v1
int64 0
24.7k
| memory_v0
int64 2.57k
1.02M
| memory_v1
int64 2.57k
869k
| status_v0
stringclasses 1
value | status_v1
stringclasses 1
value | improvement_frac
float64 7.51
100
| input
stringlengths 20
4.55k
| target
stringlengths 17
3.34k
| code_v0_loc
int64 1
148
| code_v1_loc
int64 1
184
| code_v0_num_chars
int64 13
4.55k
| code_v1_num_chars
int64 14
3.34k
| code_v0_no_empty_lines
stringlengths 21
6.88k
| code_v1_no_empty_lines
stringlengths 20
4.93k
| code_same
bool 1
class | relative_loc_diff_percent
float64 0
79.8
| diff
list | diff_only_import_comment
bool 1
class | measured_runtime_v0
float64 0.01
4.45
| measured_runtime_v1
float64 0.01
4.31
| runtime_lift
float64 0
359
| key
list |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u604774382
|
p02264
|
python
|
s852215548
|
s890949716
| 1,610 | 300 | 21,536 | 16,160 |
Accepted
|
Accepted
| 81.37 |
from queue import Queue
n, q = [ int( val ) for val in input( ).split( " " ) ]
processes = Queue( )
for i in range( n ):
name, time = input( ).split( " " )
processes.put( ( name, int( time ) ) )
qsum = 0
output = []
while not processes.empty( ):
process = processes.get( )
if process[1] <= q:
qsum += process[1]
output.append( "{:s} {:d}".format( process[0], qsum ) )
else:
processes.put( ( process[0], process[1]- q ) )
qsum += q
print(( "\n".join( output ) ))
|
from collections import deque
n, q = [ int( val ) for val in input( ).split( " " ) ]
processes = deque( )
for i in range( n ):
name, time = input( ).split( " " )
processes.append( ( name, int( time ) ) )
qsum = 0
output = []
while len( processes ):
process = processes.popleft( )
if process[1] <= q:
qsum += process[1]
output.append( "{:s} {:d}".format( process[0], qsum ) )
else:
processes.append( ( process[0], process[1]- q ) )
qsum += q
print(( "\n".join( output ) ))
| 20 | 20 | 537 | 554 |
from queue import Queue
n, q = [int(val) for val in input().split(" ")]
processes = Queue()
for i in range(n):
name, time = input().split(" ")
processes.put((name, int(time)))
qsum = 0
output = []
while not processes.empty():
process = processes.get()
if process[1] <= q:
qsum += process[1]
output.append("{:s} {:d}".format(process[0], qsum))
else:
processes.put((process[0], process[1] - q))
qsum += q
print(("\n".join(output)))
|
from collections import deque
n, q = [int(val) for val in input().split(" ")]
processes = deque()
for i in range(n):
name, time = input().split(" ")
processes.append((name, int(time)))
qsum = 0
output = []
while len(processes):
process = processes.popleft()
if process[1] <= q:
qsum += process[1]
output.append("{:s} {:d}".format(process[0], qsum))
else:
processes.append((process[0], process[1] - q))
qsum += q
print(("\n".join(output)))
| false | 0 |
[
"-from queue import Queue",
"+from collections import deque",
"-processes = Queue()",
"+processes = deque()",
"- processes.put((name, int(time)))",
"+ processes.append((name, int(time)))",
"-while not processes.empty():",
"- process = processes.get()",
"+while len(processes):",
"+ process = processes.popleft()",
"- processes.put((process[0], process[1] - q))",
"+ processes.append((process[0], process[1] - q))"
] | false | 0.038095 | 0.040871 | 0.932078 |
[
"s852215548",
"s890949716"
] |
u488401358
|
p03182
|
python
|
s566170724
|
s859633165
| 1,273 | 713 | 176,796 | 176,228 |
Accepted
|
Accepted
| 43.99 |
class LazySegmentTree():
def __init__(self,n,init,merge_func,ide_ele):
self.n=(n-1).bit_length()
self.merge_func=merge_func
self.ide_ele=ide_ele
self.data=[0 for i in range(1<<(self.n+1))]
self.lazy=[0 for i in range(1<<(self.n+1))]
for i in range(n):
self.data[2**self.n+i]=init[i]
for i in range(2**self.n-1,0,-1):
self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])
def propagate_above(self,i):
ids=[]
while i:
i>>=1
ids.append(i)
for v in ids[::-1]:
self.data[v]+=self.lazy[v]
self.lazy[2*v]+=self.lazy[v]
self.lazy[2*v+1]+=self.lazy[v]
self.lazy[v]=0
def remerge_above(self,i):
ids=[]
while i:
i>>=1
self.data[i]=self.merge_func(self.data[2*i]+self.lazy[2*i],self.data[2*i+1]+self.lazy[2*i+1])
def update(self,l,r,x):
l+=1<<self.n
r+=1<<self.n
l0=l//(l&-l)
r0=r//(r&-r)-1
self.propagate_above(l0)
self.propagate_above(r0)
while l<r:
if l&1:
self.lazy[l]+=x
l+=1
if r&1:
self.lazy[r-1]+=x
l>>=1
r>>=1
self.remerge_above(l0)
self.remerge_above(r0)
def query(self,l,r):
l+=1<<self.n
r+=1<<self.n
l0=l//(l&-l)
r0=r//(r&-r)-1
self.propagate_above(l0)
self.propagate_above(r0)
res=self.ide_ele
while l<r:
if l&1:
res=self.merge_func(res,self.data[l]+self.lazy[l])
l+=1
if r&1:
res=self.merge_func(res,self.data[r-1]+self.lazy[r-1])
l>>=1
r>>=1
return res
import sys
input=sys.stdin.readline
N,M=list(map(int,input().split()))
interval=[[] for i in range(N)]
for i in range(M):
l,r,a=list(map(int,input().split()))
interval[l-1].append((r-1,a))
init=[0]*N
LST=LazySegmentTree(N,init,merge_func=min,ide_ele=10**18)
Max=[0]*N
for i in range(N-1,-1,-1):
for r,a in interval[i]:
LST.update(i,r+1,-a)
Max[i]=max(-LST.query(0,N),0)
if i:
LST.update(i-1,i,-Max[i])
print((Max[0]))
|
class LazySegmentTree():
def __init__(self,n,init,merge_func=min,ide_ele=10**18):
self.n=(n-1).bit_length()
self.merge_func=merge_func
self.ide_ele=ide_ele
self.data=[0 for i in range(1<<(self.n+1))]
self.lazy=[0 for i in range(1<<(self.n+1))]
for i in range(n):
self.data[2**self.n+i]=init[i]
for i in range(2**self.n-1,0,-1):
self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])
def propagate_above(self,i):
m=i.bit_length()-1
for bit in range(m,0,-1):
v=i>>bit
add=self.lazy[v]
self.lazy[v]=0
self.data[2*v]+=add
self.data[2*v+1]+=add
self.lazy[2*v]+=add
self.lazy[2*v+1]+=add
def remerge_above(self,i):
while i:
i>>=1
self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])+self.lazy[i]
def update(self,l,r,x):
l+=1<<self.n
r+=1<<self.n
l0=l//(l&-l)
r0=r//(r&-r)-1
while l<r:
self.data[l]+=x*(l&1)
self.lazy[l]+=x*(l&1)
l+=(l&1)
self.data[r-1]+=x*(r&1)
self.lazy[r-1]+=x*(r&1)
l>>=1
r>>=1
self.remerge_above(l0)
self.remerge_above(r0)
def query(self,l,r):
l+=1<<self.n
r+=1<<self.n
l0=l//(l&-l)
r0=r//(r&-r)-1
self.propagate_above(l0)
self.propagate_above(r0)
res=self.ide_ele
while l<r:
if l&1:
res=self.merge_func(res,self.data[l])
l+=1
if r&1:
res=self.merge_func(res,self.data[r-1])
l>>=1
r>>=1
return res
import sys
input=sys.stdin.readline
N,M=list(map(int,input().split()))
interval=[[] for i in range(N)]
for i in range(M):
l,r,a=list(map(int,input().split()))
interval[l-1].append((r-1,a))
init=[0]*N
LST=LazySegmentTree(N,init,merge_func=min,ide_ele=10**18)
Max=[0]*N
for i in range(N-1,-1,-1):
for r,a in interval[i]:
LST.update(i,r+1,-a)
Max[i]=max(-LST.query(0,N),0)
if i:
LST.update(i-1,i,-Max[i])
print((Max[0]))
| 88 | 84 | 2,373 | 2,302 |
class LazySegmentTree:
def __init__(self, n, init, merge_func, ide_ele):
self.n = (n - 1).bit_length()
self.merge_func = merge_func
self.ide_ele = ide_ele
self.data = [0 for i in range(1 << (self.n + 1))]
self.lazy = [0 for i in range(1 << (self.n + 1))]
for i in range(n):
self.data[2**self.n + i] = init[i]
for i in range(2**self.n - 1, 0, -1):
self.data[i] = self.merge_func(self.data[2 * i], self.data[2 * i + 1])
def propagate_above(self, i):
ids = []
while i:
i >>= 1
ids.append(i)
for v in ids[::-1]:
self.data[v] += self.lazy[v]
self.lazy[2 * v] += self.lazy[v]
self.lazy[2 * v + 1] += self.lazy[v]
self.lazy[v] = 0
def remerge_above(self, i):
ids = []
while i:
i >>= 1
self.data[i] = self.merge_func(
self.data[2 * i] + self.lazy[2 * i],
self.data[2 * i + 1] + self.lazy[2 * i + 1],
)
def update(self, l, r, x):
l += 1 << self.n
r += 1 << self.n
l0 = l // (l & -l)
r0 = r // (r & -r) - 1
self.propagate_above(l0)
self.propagate_above(r0)
while l < r:
if l & 1:
self.lazy[l] += x
l += 1
if r & 1:
self.lazy[r - 1] += x
l >>= 1
r >>= 1
self.remerge_above(l0)
self.remerge_above(r0)
def query(self, l, r):
l += 1 << self.n
r += 1 << self.n
l0 = l // (l & -l)
r0 = r // (r & -r) - 1
self.propagate_above(l0)
self.propagate_above(r0)
res = self.ide_ele
while l < r:
if l & 1:
res = self.merge_func(res, self.data[l] + self.lazy[l])
l += 1
if r & 1:
res = self.merge_func(res, self.data[r - 1] + self.lazy[r - 1])
l >>= 1
r >>= 1
return res
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
interval = [[] for i in range(N)]
for i in range(M):
l, r, a = list(map(int, input().split()))
interval[l - 1].append((r - 1, a))
init = [0] * N
LST = LazySegmentTree(N, init, merge_func=min, ide_ele=10**18)
Max = [0] * N
for i in range(N - 1, -1, -1):
for r, a in interval[i]:
LST.update(i, r + 1, -a)
Max[i] = max(-LST.query(0, N), 0)
if i:
LST.update(i - 1, i, -Max[i])
print((Max[0]))
|
class LazySegmentTree:
def __init__(self, n, init, merge_func=min, ide_ele=10**18):
self.n = (n - 1).bit_length()
self.merge_func = merge_func
self.ide_ele = ide_ele
self.data = [0 for i in range(1 << (self.n + 1))]
self.lazy = [0 for i in range(1 << (self.n + 1))]
for i in range(n):
self.data[2**self.n + i] = init[i]
for i in range(2**self.n - 1, 0, -1):
self.data[i] = self.merge_func(self.data[2 * i], self.data[2 * i + 1])
def propagate_above(self, i):
m = i.bit_length() - 1
for bit in range(m, 0, -1):
v = i >> bit
add = self.lazy[v]
self.lazy[v] = 0
self.data[2 * v] += add
self.data[2 * v + 1] += add
self.lazy[2 * v] += add
self.lazy[2 * v + 1] += add
def remerge_above(self, i):
while i:
i >>= 1
self.data[i] = (
self.merge_func(self.data[2 * i], self.data[2 * i + 1]) + self.lazy[i]
)
def update(self, l, r, x):
l += 1 << self.n
r += 1 << self.n
l0 = l // (l & -l)
r0 = r // (r & -r) - 1
while l < r:
self.data[l] += x * (l & 1)
self.lazy[l] += x * (l & 1)
l += l & 1
self.data[r - 1] += x * (r & 1)
self.lazy[r - 1] += x * (r & 1)
l >>= 1
r >>= 1
self.remerge_above(l0)
self.remerge_above(r0)
def query(self, l, r):
l += 1 << self.n
r += 1 << self.n
l0 = l // (l & -l)
r0 = r // (r & -r) - 1
self.propagate_above(l0)
self.propagate_above(r0)
res = self.ide_ele
while l < r:
if l & 1:
res = self.merge_func(res, self.data[l])
l += 1
if r & 1:
res = self.merge_func(res, self.data[r - 1])
l >>= 1
r >>= 1
return res
import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))
interval = [[] for i in range(N)]
for i in range(M):
l, r, a = list(map(int, input().split()))
interval[l - 1].append((r - 1, a))
init = [0] * N
LST = LazySegmentTree(N, init, merge_func=min, ide_ele=10**18)
Max = [0] * N
for i in range(N - 1, -1, -1):
for r, a in interval[i]:
LST.update(i, r + 1, -a)
Max[i] = max(-LST.query(0, N), 0)
if i:
LST.update(i - 1, i, -Max[i])
print((Max[0]))
| false | 4.545455 |
[
"- def __init__(self, n, init, merge_func, ide_ele):",
"+ def __init__(self, n, init, merge_func=min, ide_ele=10**18):",
"- ids = []",
"+ m = i.bit_length() - 1",
"+ for bit in range(m, 0, -1):",
"+ v = i >> bit",
"+ add = self.lazy[v]",
"+ self.lazy[v] = 0",
"+ self.data[2 * v] += add",
"+ self.data[2 * v + 1] += add",
"+ self.lazy[2 * v] += add",
"+ self.lazy[2 * v + 1] += add",
"+",
"+ def remerge_above(self, i):",
"- ids.append(i)",
"- for v in ids[::-1]:",
"- self.data[v] += self.lazy[v]",
"- self.lazy[2 * v] += self.lazy[v]",
"- self.lazy[2 * v + 1] += self.lazy[v]",
"- self.lazy[v] = 0",
"-",
"- def remerge_above(self, i):",
"- ids = []",
"- while i:",
"- i >>= 1",
"- self.data[i] = self.merge_func(",
"- self.data[2 * i] + self.lazy[2 * i],",
"- self.data[2 * i + 1] + self.lazy[2 * i + 1],",
"+ self.data[i] = (",
"+ self.merge_func(self.data[2 * i], self.data[2 * i + 1]) + self.lazy[i]",
"- self.propagate_above(l0)",
"- self.propagate_above(r0)",
"- if l & 1:",
"- self.lazy[l] += x",
"- l += 1",
"- if r & 1:",
"- self.lazy[r - 1] += x",
"+ self.data[l] += x * (l & 1)",
"+ self.lazy[l] += x * (l & 1)",
"+ l += l & 1",
"+ self.data[r - 1] += x * (r & 1)",
"+ self.lazy[r - 1] += x * (r & 1)",
"- res = self.merge_func(res, self.data[l] + self.lazy[l])",
"+ res = self.merge_func(res, self.data[l])",
"- res = self.merge_func(res, self.data[r - 1] + self.lazy[r - 1])",
"+ res = self.merge_func(res, self.data[r - 1])"
] | false | 0.036962 | 0.04654 | 0.794184 |
[
"s566170724",
"s859633165"
] |
u808427016
|
p03287
|
python
|
s645339484
|
s751000261
| 226 | 108 | 62,576 | 14,252 |
Accepted
|
Accepted
| 52.21 |
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
from itertools import accumulate
from collections import defaultdict
ts = defaultdict(int)
ts[0] = 1
t = 0
for a in A:
t = (t + a) % M
ts[t] += 1
result = 0
for t in ts:
result += ts[t] * (ts[t] - 1) // 2
print(result)
|
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
from collections import defaultdict
ts = defaultdict(int)
ts[0] = 1
t = 0
for a in A:
t = (t + a) % M
ts[t] += 1
result = 0
for k, v in list(ts.items()):
result += v * (v - 1) // 2
print(result)
| 23 | 20 | 341 | 306 |
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
from itertools import accumulate
from collections import defaultdict
ts = defaultdict(int)
ts[0] = 1
t = 0
for a in A:
t = (t + a) % M
ts[t] += 1
result = 0
for t in ts:
result += ts[t] * (ts[t] - 1) // 2
print(result)
|
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
from collections import defaultdict
ts = defaultdict(int)
ts[0] = 1
t = 0
for a in A:
t = (t + a) % M
ts[t] += 1
result = 0
for k, v in list(ts.items()):
result += v * (v - 1) // 2
print(result)
| false | 13.043478 |
[
"-from itertools import accumulate",
"-for t in ts:",
"- result += ts[t] * (ts[t] - 1) // 2",
"+for k, v in list(ts.items()):",
"+ result += v * (v - 1) // 2"
] | false | 0.126481 | 0.037474 | 3.375177 |
[
"s645339484",
"s751000261"
] |
u112629957
|
p02767
|
python
|
s468649910
|
s029707087
| 22 | 18 | 3,060 | 3,060 |
Accepted
|
Accepted
| 18.18 |
N=int(eval(input()))
ls=list(map(int,input().split()))
ans=10**9+7
for i in range(1,101):
a=0
for j in range(N):
a+=(i-ls[j])**2
ans=min([ans,a])
print(ans)
|
import math
N=int(eval(input()))
ls=list(map(int,input().split()))
av=math.floor(sum(ls)/N)
A=B=0
for i in range(N):
A+=(ls[i]-av)**2
B+=(ls[i]-av-1)**2
print((min([A,B])))
| 9 | 9 | 170 | 177 |
N = int(eval(input()))
ls = list(map(int, input().split()))
ans = 10**9 + 7
for i in range(1, 101):
a = 0
for j in range(N):
a += (i - ls[j]) ** 2
ans = min([ans, a])
print(ans)
|
import math
N = int(eval(input()))
ls = list(map(int, input().split()))
av = math.floor(sum(ls) / N)
A = B = 0
for i in range(N):
A += (ls[i] - av) ** 2
B += (ls[i] - av - 1) ** 2
print((min([A, B])))
| false | 0 |
[
"+import math",
"+",
"-ans = 10**9 + 7",
"-for i in range(1, 101):",
"- a = 0",
"- for j in range(N):",
"- a += (i - ls[j]) ** 2",
"- ans = min([ans, a])",
"-print(ans)",
"+av = math.floor(sum(ls) / N)",
"+A = B = 0",
"+for i in range(N):",
"+ A += (ls[i] - av) ** 2",
"+ B += (ls[i] - av - 1) ** 2",
"+print((min([A, B])))"
] | false | 0.045059 | 0.045831 | 0.983164 |
[
"s468649910",
"s029707087"
] |
u260980560
|
p00425
|
python
|
s786108324
|
s134610452
| 30 | 20 | 4,252 | 4,244 |
Accepted
|
Accepted
| 33.33 |
rot = {
"North": (1,5,2,3,0,4),
"East" : (3,1,0,5,4,2),
"West" : (2,1,5,0,4,3),
"South": (4,0,2,3,5,1),
"Right": (0,2,4,1,3,5),
"Left" : (0,3,1,4,2,5)
}
while 1:
n = eval(input())
if not n:
break
dice = [1,2,3,4,5,6]
nxt = [0]*6
ans = 0
for i in range(n):
r = rot[input()]
for i in range(6):
nxt[i] = dice[r[i]]
dice, nxt = nxt, dice
ans += dice[0]
print(ans+1)
|
rot = {
"North": (1,5,2,3,0,4),
"East" : (3,1,0,5,4,2),
"West" : (2,1,5,0,4,3),
"South": (4,0,2,3,5,1),
"Right": (0,2,4,1,3,5),
"Left" : (0,3,1,4,2,5)
}
while 1:
n = eval(input())
if not n:
break
dice = [1,2,3,4,5,6]
nxt = [0]*6
ans = 0
for i in range(n):
r = rot[input()]
dice = [dice[r[i]] for i in range(6)]
ans += dice[0]
print(ans+1)
| 22 | 20 | 485 | 440 |
rot = {
"North": (1, 5, 2, 3, 0, 4),
"East": (3, 1, 0, 5, 4, 2),
"West": (2, 1, 5, 0, 4, 3),
"South": (4, 0, 2, 3, 5, 1),
"Right": (0, 2, 4, 1, 3, 5),
"Left": (0, 3, 1, 4, 2, 5),
}
while 1:
n = eval(input())
if not n:
break
dice = [1, 2, 3, 4, 5, 6]
nxt = [0] * 6
ans = 0
for i in range(n):
r = rot[input()]
for i in range(6):
nxt[i] = dice[r[i]]
dice, nxt = nxt, dice
ans += dice[0]
print(ans + 1)
|
rot = {
"North": (1, 5, 2, 3, 0, 4),
"East": (3, 1, 0, 5, 4, 2),
"West": (2, 1, 5, 0, 4, 3),
"South": (4, 0, 2, 3, 5, 1),
"Right": (0, 2, 4, 1, 3, 5),
"Left": (0, 3, 1, 4, 2, 5),
}
while 1:
n = eval(input())
if not n:
break
dice = [1, 2, 3, 4, 5, 6]
nxt = [0] * 6
ans = 0
for i in range(n):
r = rot[input()]
dice = [dice[r[i]] for i in range(6)]
ans += dice[0]
print(ans + 1)
| false | 9.090909 |
[
"- for i in range(6):",
"- nxt[i] = dice[r[i]]",
"- dice, nxt = nxt, dice",
"+ dice = [dice[r[i]] for i in range(6)]"
] | false | 0.042908 | 0.04132 | 1.038428 |
[
"s786108324",
"s134610452"
] |
u889914341
|
p03127
|
python
|
s215525232
|
s510256486
| 145 | 88 | 14,180 | 16,280 |
Accepted
|
Accepted
| 39.31 |
from heapq import heapify, heappush, heappop
n = int(eval(input()))
A = list(map(int, input().split()))
heapify(A)
while len(A) != 1:
t = heappop(A)
A = [a % t for a in A if a % t != 0]
if A is None:
A = [t]
break
heappush(A, t)
print((A[0]))
|
from fractions import gcd
n = int(eval(input()))
A = list(map(int, input().split()))
ans = A[0]
for a in A[1:]:
ans = gcd(ans, a)
print(ans)
| 12 | 7 | 278 | 145 |
from heapq import heapify, heappush, heappop
n = int(eval(input()))
A = list(map(int, input().split()))
heapify(A)
while len(A) != 1:
t = heappop(A)
A = [a % t for a in A if a % t != 0]
if A is None:
A = [t]
break
heappush(A, t)
print((A[0]))
|
from fractions import gcd
n = int(eval(input()))
A = list(map(int, input().split()))
ans = A[0]
for a in A[1:]:
ans = gcd(ans, a)
print(ans)
| false | 41.666667 |
[
"-from heapq import heapify, heappush, heappop",
"+from fractions import gcd",
"-heapify(A)",
"-while len(A) != 1:",
"- t = heappop(A)",
"- A = [a % t for a in A if a % t != 0]",
"- if A is None:",
"- A = [t]",
"- break",
"- heappush(A, t)",
"-print((A[0]))",
"+ans = A[0]",
"+for a in A[1:]:",
"+ ans = gcd(ans, a)",
"+print(ans)"
] | false | 0.044186 | 0.055767 | 0.792328 |
[
"s215525232",
"s510256486"
] |
u252828980
|
p02683
|
python
|
s745806924
|
s007825637
| 185 | 91 | 27,340 | 9,268 |
Accepted
|
Accepted
| 50.81 |
n,m,k = list(map(int,input().split()))
import numpy as np
pr = []
score = []
for i in range(n):
li = list(map(int,input().split()))
pr.append(li[0])
score.append(li[1:])
cnt =0
ans = 10**10
for i in range(1<<n):
tot = np.array([0]*m)
pr_all = 0
for j in range(n):
if i>>j&1:
score[j] = np.array(score[j])
tot +=np.array(score[j])
pr_all +=pr[j]
if np.all(tot >=k):
ans = min(ans,pr_all)
print((ans if ans <10**10 else -1))
|
n,m,x = list(map(int,input().split()))
pr = []
score = []
for i in range(n):
L = list(map(int,input().split()))
pr.append(L[0])
score.append(L[1:])
ans = 10**10
for i in range(1<<n):
li = []
cost = 0
for j in range(n):
if (i>>j)&1:
li.append(score[j])
cost +=pr[j]
score_all = [0 for l in range(m)]
for k in range(len(li)):
for j in range(m):
score_all[j] +=li[k][j]
if all([y>=x for y in score_all]):
ans = min(ans,cost)
if ans != 10**10:
print(ans)
else:
print((-1))
| 25 | 29 | 530 | 600 |
n, m, k = list(map(int, input().split()))
import numpy as np
pr = []
score = []
for i in range(n):
li = list(map(int, input().split()))
pr.append(li[0])
score.append(li[1:])
cnt = 0
ans = 10**10
for i in range(1 << n):
tot = np.array([0] * m)
pr_all = 0
for j in range(n):
if i >> j & 1:
score[j] = np.array(score[j])
tot += np.array(score[j])
pr_all += pr[j]
if np.all(tot >= k):
ans = min(ans, pr_all)
print((ans if ans < 10**10 else -1))
|
n, m, x = list(map(int, input().split()))
pr = []
score = []
for i in range(n):
L = list(map(int, input().split()))
pr.append(L[0])
score.append(L[1:])
ans = 10**10
for i in range(1 << n):
li = []
cost = 0
for j in range(n):
if (i >> j) & 1:
li.append(score[j])
cost += pr[j]
score_all = [0 for l in range(m)]
for k in range(len(li)):
for j in range(m):
score_all[j] += li[k][j]
if all([y >= x for y in score_all]):
ans = min(ans, cost)
if ans != 10**10:
print(ans)
else:
print((-1))
| false | 13.793103 |
[
"-n, m, k = list(map(int, input().split()))",
"-import numpy as np",
"-",
"+n, m, x = list(map(int, input().split()))",
"- li = list(map(int, input().split()))",
"- pr.append(li[0])",
"- score.append(li[1:])",
"-cnt = 0",
"+ L = list(map(int, input().split()))",
"+ pr.append(L[0])",
"+ score.append(L[1:])",
"- tot = np.array([0] * m)",
"- pr_all = 0",
"+ li = []",
"+ cost = 0",
"- if i >> j & 1:",
"- score[j] = np.array(score[j])",
"- tot += np.array(score[j])",
"- pr_all += pr[j]",
"- if np.all(tot >= k):",
"- ans = min(ans, pr_all)",
"-print((ans if ans < 10**10 else -1))",
"+ if (i >> j) & 1:",
"+ li.append(score[j])",
"+ cost += pr[j]",
"+ score_all = [0 for l in range(m)]",
"+ for k in range(len(li)):",
"+ for j in range(m):",
"+ score_all[j] += li[k][j]",
"+ if all([y >= x for y in score_all]):",
"+ ans = min(ans, cost)",
"+if ans != 10**10:",
"+ print(ans)",
"+else:",
"+ print((-1))"
] | false | 0.318584 | 0.048312 | 6.594305 |
[
"s745806924",
"s007825637"
] |
u539367121
|
p02678
|
python
|
s143810968
|
s996819547
| 1,339 | 637 | 33,580 | 34,132 |
Accepted
|
Accepted
| 52.43 |
N,M=list(map(int,input().split()))
G=[[] for _ in range(N+1)]
for i in range(M):
a,b=list(map(int,input().split()))
G[a].append(b)
G[b].append(a)
ans=[0]*(N+1)
d=[1]
while d:
c=d.pop(0)
for g in G[c]:
if not ans[g]:
d.append(g)
ans[g]=c
print('Yes')
for i in range(2, N+1):
print((ans[i]))
|
from collections import deque
N,M=list(map(int,input().split()))
G=[[] for _ in range(N+1)]
for i in range(M):
a,b=list(map(int,input().split()))
G[a].append(b)
G[b].append(a)
ans=[0]*(N+1)
d=deque([1])
while d:
c=d.popleft()
for g in G[c]:
if not ans[g]:
d.append(g)
ans[g]=c
print('Yes')
for i in range(2, N+1):
print((ans[i]))
| 19 | 21 | 323 | 366 |
N, M = list(map(int, input().split()))
G = [[] for _ in range(N + 1)]
for i in range(M):
a, b = list(map(int, input().split()))
G[a].append(b)
G[b].append(a)
ans = [0] * (N + 1)
d = [1]
while d:
c = d.pop(0)
for g in G[c]:
if not ans[g]:
d.append(g)
ans[g] = c
print("Yes")
for i in range(2, N + 1):
print((ans[i]))
|
from collections import deque
N, M = list(map(int, input().split()))
G = [[] for _ in range(N + 1)]
for i in range(M):
a, b = list(map(int, input().split()))
G[a].append(b)
G[b].append(a)
ans = [0] * (N + 1)
d = deque([1])
while d:
c = d.popleft()
for g in G[c]:
if not ans[g]:
d.append(g)
ans[g] = c
print("Yes")
for i in range(2, N + 1):
print((ans[i]))
| false | 9.52381 |
[
"+from collections import deque",
"+",
"-d = [1]",
"+d = deque([1])",
"- c = d.pop(0)",
"+ c = d.popleft()"
] | false | 0.035565 | 0.035746 | 0.994937 |
[
"s143810968",
"s996819547"
] |
u970197315
|
p02850
|
python
|
s281108229
|
s133003432
| 332 | 288 | 23,152 | 91,212 |
Accepted
|
Accepted
| 13.25 |
n=int(eval(input()))
G=[[] for i in range(n+1)]
G_order=[]
for i in range(n-1):
a,b=list(map(int,input().split()))
G[a].append(b)
G_order.append(b)
from collections import deque
q=deque([1])
color=[0]*(n+1)
while q:
cur=q.popleft()
c=1
for nx in G[cur]:
if c==color[cur]:
c+=1
color[nx]=c
c+=1
q.append(nx)
print((max(color)))
for i in G_order:
print((color[i]))
|
n = int(eval(input()))
G = [[] for _ in range(n)]
edge = []
for _ in range(n-1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].append(b)
edge.append(b)
from collections import deque
q = deque()
color = [0]*n
q.append(0)
while q:
cur = q.popleft()
c = 1
for nx in G[cur]:
if color[cur] == c:
c += 1
color[nx] = c
c += 1
q.append(nx)
print((max(color)))
for e in edge:
print((color[e]))
| 24 | 28 | 408 | 491 |
n = int(eval(input()))
G = [[] for i in range(n + 1)]
G_order = []
for i in range(n - 1):
a, b = list(map(int, input().split()))
G[a].append(b)
G_order.append(b)
from collections import deque
q = deque([1])
color = [0] * (n + 1)
while q:
cur = q.popleft()
c = 1
for nx in G[cur]:
if c == color[cur]:
c += 1
color[nx] = c
c += 1
q.append(nx)
print((max(color)))
for i in G_order:
print((color[i]))
|
n = int(eval(input()))
G = [[] for _ in range(n)]
edge = []
for _ in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].append(b)
edge.append(b)
from collections import deque
q = deque()
color = [0] * n
q.append(0)
while q:
cur = q.popleft()
c = 1
for nx in G[cur]:
if color[cur] == c:
c += 1
color[nx] = c
c += 1
q.append(nx)
print((max(color)))
for e in edge:
print((color[e]))
| false | 14.285714 |
[
"-G = [[] for i in range(n + 1)]",
"-G_order = []",
"-for i in range(n - 1):",
"+G = [[] for _ in range(n)]",
"+edge = []",
"+for _ in range(n - 1):",
"+ a -= 1",
"+ b -= 1",
"- G_order.append(b)",
"+ edge.append(b)",
"-q = deque([1])",
"-color = [0] * (n + 1)",
"+q = deque()",
"+color = [0] * n",
"+q.append(0)",
"- if c == color[cur]:",
"+ if color[cur] == c:",
"-for i in G_order:",
"- print((color[i]))",
"+for e in edge:",
"+ print((color[e]))"
] | false | 0.035051 | 0.047111 | 0.744007 |
[
"s281108229",
"s133003432"
] |
u823044869
|
p03448
|
python
|
s433435524
|
s783293247
| 60 | 49 | 3,064 | 3,060 |
Accepted
|
Accepted
| 18.33 |
cn500 = int(eval(input()))
cn100 = int(eval(input()))
cn50 = int(eval(input()))
g_amount = int(eval(input()))
counter = 0
for i in range(cn500+1):
for j in range(cn100+1):
for n in range(cn50+1):
if g_amount == (500 * i + 100 * j + 50 * n):
counter += 1
break
elif g_amount < (500 * i + 100 * j + 50 * n):
break
print(counter)
|
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
count = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if i*500+ j*100+ k*50 == x:
count += 1
print(count)
| 17 | 13 | 405 | 227 |
cn500 = int(eval(input()))
cn100 = int(eval(input()))
cn50 = int(eval(input()))
g_amount = int(eval(input()))
counter = 0
for i in range(cn500 + 1):
for j in range(cn100 + 1):
for n in range(cn50 + 1):
if g_amount == (500 * i + 100 * j + 50 * n):
counter += 1
break
elif g_amount < (500 * i + 100 * j + 50 * n):
break
print(counter)
|
a = int(eval(input()))
b = int(eval(input()))
c = int(eval(input()))
x = int(eval(input()))
count = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
if i * 500 + j * 100 + k * 50 == x:
count += 1
print(count)
| false | 23.529412 |
[
"-cn500 = int(eval(input()))",
"-cn100 = int(eval(input()))",
"-cn50 = int(eval(input()))",
"-g_amount = int(eval(input()))",
"-counter = 0",
"-for i in range(cn500 + 1):",
"- for j in range(cn100 + 1):",
"- for n in range(cn50 + 1):",
"- if g_amount == (500 * i + 100 * j + 50 * n):",
"- counter += 1",
"- break",
"- elif g_amount < (500 * i + 100 * j + 50 * n):",
"- break",
"-print(counter)",
"+a = int(eval(input()))",
"+b = int(eval(input()))",
"+c = int(eval(input()))",
"+x = int(eval(input()))",
"+count = 0",
"+for i in range(a + 1):",
"+ for j in range(b + 1):",
"+ for k in range(c + 1):",
"+ if i * 500 + j * 100 + k * 50 == x:",
"+ count += 1",
"+print(count)"
] | false | 0.055754 | 0.084194 | 0.662212 |
[
"s433435524",
"s783293247"
] |
u597455618
|
p02536
|
python
|
s851236906
|
s997421969
| 216 | 175 | 23,116 | 16,368 |
Accepted
|
Accepted
| 18.98 |
import sys
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def main():
n, m = list(map(int, sys.stdin.buffer.readline().split()))
U = UnionFind(n)
for x in sys.stdin.buffer.readlines():
a, b = list(map(int, x.split()))
U.union(a-1, b-1)
ans = {}
for i in range(n):
ans.setdefault(U._root(i), []).append(i)
print((len(ans) - 1))
if __name__ == "__main__":
main()
|
import sys
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def roots(self):
return [i for i, x in enumerate(self.table) if x < 0]
def group_count(self):
return len(self.roots())
def main():
n, m = list(map(int, sys.stdin.buffer.readline().split()))
U = UnionFind(n)
for x in sys.stdin.buffer.readlines():
a, b = list(map(int, x.split()))
U.union(a-1, b-1)
print((U.group_count() - 1))
if __name__ == "__main__":
main()
| 49 | 52 | 1,107 | 1,177 |
import sys
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def main():
n, m = list(map(int, sys.stdin.buffer.readline().split()))
U = UnionFind(n)
for x in sys.stdin.buffer.readlines():
a, b = list(map(int, x.split()))
U.union(a - 1, b - 1)
ans = {}
for i in range(n):
ans.setdefault(U._root(i), []).append(i)
print((len(ans) - 1))
if __name__ == "__main__":
main()
|
import sys
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
stack = []
tbl = self.table
while tbl[x] >= 0:
stack.append(x)
x = tbl[x]
for y in stack:
tbl[y] = x
return x
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
self.table[r1] += d2
else:
self.table[r1] = r2
self.table[r2] += d1
def roots(self):
return [i for i, x in enumerate(self.table) if x < 0]
def group_count(self):
return len(self.roots())
def main():
n, m = list(map(int, sys.stdin.buffer.readline().split()))
U = UnionFind(n)
for x in sys.stdin.buffer.readlines():
a, b = list(map(int, x.split()))
U.union(a - 1, b - 1)
print((U.group_count() - 1))
if __name__ == "__main__":
main()
| false | 5.769231 |
[
"+ def roots(self):",
"+ return [i for i, x in enumerate(self.table) if x < 0]",
"+",
"+ def group_count(self):",
"+ return len(self.roots())",
"+",
"- ans = {}",
"- for i in range(n):",
"- ans.setdefault(U._root(i), []).append(i)",
"- print((len(ans) - 1))",
"+ print((U.group_count() - 1))"
] | false | 0.048535 | 0.048158 | 1.007832 |
[
"s851236906",
"s997421969"
] |
u631277801
|
p02913
|
python
|
s119692201
|
s853449401
| 62 | 57 | 4,264 | 4,152 |
Accepted
|
Accepted
| 8.06 |
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
class RollingHash(object):
def __init__(self, source: str, base=10**9+7, mod=(1<<64)-1):
self.source = source
self.base = base
self.mod = mod
self.hash_from_zero_to = self._get_hash_from_zero_to()
self.base_pow = self._get_base_pow()
# 文字列sourceの区間 [0, right) のハッシュ値を前計算する
def _get_hash_from_zero_to(self):
hash_from_zero_to = [0]
for si in self.source:
hash_from_zero_to.append((hash_from_zero_to[-1] * self.base + ord(si)) % self.mod)
return hash_from_zero_to
# base値をi回掛けてmodをとった値を前計算する
def _get_base_pow(self):
base_pow = [1]
for i in range(len(self.source)):
base_pow.append(base_pow[-1] * self.base % self.mod)
return base_pow
# 文字列sourceの区間 [left, right) のハッシュを取得する
def get_hash(self, left: int, right: int):
return (self.hash_from_zero_to[right]
- self.hash_from_zero_to[left] * self.base_pow[right - left]) % self.mod
def binsearch(func, rh: RollingHash, ok: int, ng: int):
source_length = len(rh.source)
while ng - ok > 1:
mid = (ok + ng) // 2
if func(rh, mid, source_length):
ok = mid
else:
ng = mid
return ok
# 題意を満たす長さtarget_lengthの文字列があるか判定
def judge(rh: RollingHash, target_length: int, source_length: int):
memo = {}
for start_idx in range(source_length - target_length + 1):
cur_hash = rh.get_hash(start_idx, start_idx + target_length)
if cur_hash in memo:
if start_idx - memo[cur_hash] >= target_length:
return True
else:
memo[cur_hash] = start_idx
return False
n = ni()
s = ns()
rh = RollingHash(s)
print((binsearch(judge, rh, 0, n//2 + 2)))
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x) - 1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
class RollingHash(object):
def __init__(self, source: str, base=1000000007, mod=9007199254740997):
self.source = source
self.base = base
self.mod = mod
self.hash_from_zero_to = self._get_hash_from_zero_to()
self.base_pow = self._get_base_pow()
# 文字列sourceの区間 [0, right) のハッシュ値を前計算する
def _get_hash_from_zero_to(self):
hash_from_zero_to = [0]
for si in self.source:
hash_from_zero_to.append((hash_from_zero_to[-1] * self.base + ord(si)) % self.mod)
return hash_from_zero_to
# base値をi回掛けてmodをとった値を前計算する
def _get_base_pow(self):
base_pow = [1]
for i in range(len(self.source)):
base_pow.append(base_pow[-1] * self.base % self.mod)
return base_pow
# 文字列sourceの区間 [left, right) のハッシュを取得する
def get_hash(self, left: int, right: int):
return (self.hash_from_zero_to[right]
- self.hash_from_zero_to[left] * self.base_pow[right - left]) % self.mod
# 題意を満たす文字列の最大長を二分探索する
def binsearch(func, rh: RollingHash, ok: int, ng: int):
source_length = len(rh.source)
while ng - ok > 1:
mid = (ok + ng) // 2
if func(rh, mid, source_length):
ok = mid
else:
ng = mid
return ok
# 題意を満たす長さtarget_lengthの文字列があるか判定する
def judge(rh: RollingHash, target_length: int, source_length: int):
memo = {}
for start_idx in range(source_length - target_length + 1):
cur_hash = rh.get_hash(start_idx, start_idx + target_length)
if cur_hash in memo:
if start_idx - memo[cur_hash] >= target_length:
return True
else:
memo[cur_hash] = start_idx
return False
n = ni()
s = ns()
rh = RollingHash(s)
print((binsearch(judge, rh, 0, n//2 + 2)))
| 76 | 77 | 2,280 | 2,316 |
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
class RollingHash(object):
def __init__(self, source: str, base=10**9 + 7, mod=(1 << 64) - 1):
self.source = source
self.base = base
self.mod = mod
self.hash_from_zero_to = self._get_hash_from_zero_to()
self.base_pow = self._get_base_pow()
# 文字列sourceの区間 [0, right) のハッシュ値を前計算する
def _get_hash_from_zero_to(self):
hash_from_zero_to = [0]
for si in self.source:
hash_from_zero_to.append(
(hash_from_zero_to[-1] * self.base + ord(si)) % self.mod
)
return hash_from_zero_to
# base値をi回掛けてmodをとった値を前計算する
def _get_base_pow(self):
base_pow = [1]
for i in range(len(self.source)):
base_pow.append(base_pow[-1] * self.base % self.mod)
return base_pow
# 文字列sourceの区間 [left, right) のハッシュを取得する
def get_hash(self, left: int, right: int):
return (
self.hash_from_zero_to[right]
- self.hash_from_zero_to[left] * self.base_pow[right - left]
) % self.mod
def binsearch(func, rh: RollingHash, ok: int, ng: int):
source_length = len(rh.source)
while ng - ok > 1:
mid = (ok + ng) // 2
if func(rh, mid, source_length):
ok = mid
else:
ng = mid
return ok
# 題意を満たす長さtarget_lengthの文字列があるか判定
def judge(rh: RollingHash, target_length: int, source_length: int):
memo = {}
for start_idx in range(source_length - target_length + 1):
cur_hash = rh.get_hash(start_idx, start_idx + target_length)
if cur_hash in memo:
if start_idx - memo[cur_hash] >= target_length:
return True
else:
memo[cur_hash] = start_idx
return False
n = ni()
s = ns()
rh = RollingHash(s)
print((binsearch(judge, rh, 0, n // 2 + 2)))
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)
def li():
return list(map(int, stdin.readline().split()))
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return list(map(float, stdin.readline().split()))
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(stdin.readline())
def nf():
return float(stdin.readline())
class RollingHash(object):
def __init__(self, source: str, base=1000000007, mod=9007199254740997):
self.source = source
self.base = base
self.mod = mod
self.hash_from_zero_to = self._get_hash_from_zero_to()
self.base_pow = self._get_base_pow()
# 文字列sourceの区間 [0, right) のハッシュ値を前計算する
def _get_hash_from_zero_to(self):
hash_from_zero_to = [0]
for si in self.source:
hash_from_zero_to.append(
(hash_from_zero_to[-1] * self.base + ord(si)) % self.mod
)
return hash_from_zero_to
# base値をi回掛けてmodをとった値を前計算する
def _get_base_pow(self):
base_pow = [1]
for i in range(len(self.source)):
base_pow.append(base_pow[-1] * self.base % self.mod)
return base_pow
# 文字列sourceの区間 [left, right) のハッシュを取得する
def get_hash(self, left: int, right: int):
return (
self.hash_from_zero_to[right]
- self.hash_from_zero_to[left] * self.base_pow[right - left]
) % self.mod
# 題意を満たす文字列の最大長を二分探索する
def binsearch(func, rh: RollingHash, ok: int, ng: int):
source_length = len(rh.source)
while ng - ok > 1:
mid = (ok + ng) // 2
if func(rh, mid, source_length):
ok = mid
else:
ng = mid
return ok
# 題意を満たす長さtarget_lengthの文字列があるか判定する
def judge(rh: RollingHash, target_length: int, source_length: int):
memo = {}
for start_idx in range(source_length - target_length + 1):
cur_hash = rh.get_hash(start_idx, start_idx + target_length)
if cur_hash in memo:
if start_idx - memo[cur_hash] >= target_length:
return True
else:
memo[cur_hash] = start_idx
return False
n = ni()
s = ns()
rh = RollingHash(s)
print((binsearch(judge, rh, 0, n // 2 + 2)))
| false | 1.298701 |
[
"- def __init__(self, source: str, base=10**9 + 7, mod=(1 << 64) - 1):",
"+ def __init__(self, source: str, base=1000000007, mod=9007199254740997):",
"+# 題意を満たす文字列の最大長を二分探索する",
"-# 題意を満たす長さtarget_lengthの文字列があるか判定",
"+# 題意を満たす長さtarget_lengthの文字列があるか判定する"
] | false | 0.033266 | 0.035081 | 0.948255 |
[
"s119692201",
"s853449401"
] |
u434103236
|
p04043
|
python
|
s116081207
|
s626161795
| 28 | 22 | 8,816 | 9,024 |
Accepted
|
Accepted
| 21.43 |
x = eval(input())
mode = 0
count = 0
for num in x.split(" "):
if num == '5':
mode+=1
elif num =='7':
mode+=4
count+=1
if mode == 6 and count == 3:
print("YES")
else:
print("NO")
|
x = eval(input())
str_a = x.split(" ")
array=[0]*10
for s in str_a:
array[int(s)]+=1
if array[5]==2 and array[7]==1:
print("YES")
else:
print("NO")
| 14 | 9 | 203 | 156 |
x = eval(input())
mode = 0
count = 0
for num in x.split(" "):
if num == "5":
mode += 1
elif num == "7":
mode += 4
count += 1
if mode == 6 and count == 3:
print("YES")
else:
print("NO")
|
x = eval(input())
str_a = x.split(" ")
array = [0] * 10
for s in str_a:
array[int(s)] += 1
if array[5] == 2 and array[7] == 1:
print("YES")
else:
print("NO")
| false | 35.714286 |
[
"-mode = 0",
"-count = 0",
"-for num in x.split(\" \"):",
"- if num == \"5\":",
"- mode += 1",
"- elif num == \"7\":",
"- mode += 4",
"- count += 1",
"-if mode == 6 and count == 3:",
"+str_a = x.split(\" \")",
"+array = [0] * 10",
"+for s in str_a:",
"+ array[int(s)] += 1",
"+if array[5] == 2 and array[7] == 1:"
] | false | 0.047728 | 0.091096 | 0.523933 |
[
"s116081207",
"s626161795"
] |
u440566786
|
p03231
|
python
|
s964017952
|
s219355883
| 311 | 89 | 66,284 | 92,232 |
Accepted
|
Accepted
| 71.38 |
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
from fractions import gcd
n,m=list(map(int,input().split()))
s,t=[eval(input()) for _ in range(2)]
gcd=gcd(n,m)
lcm=n*m//gcd
n//=gcd
m//=gcd
print((lcm if all(s[n*i]==t[m*i] for i in range(gcd)) else -1))
resolve()
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from math import gcd
def resolve():
fixed = {}
n, m = list(map(int, input().split()))
S = eval(input())
T = eval(input())
l = n // gcd(n, m) * m
for i in range(n):
fixed[i * l // n] = S[i]
for j in range(m):
if not j * l // m in fixed:
continue
if fixed[j * l // m] != T[j]:
print((-1))
return
print(l)
resolve()
| 15 | 22 | 379 | 537 |
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
def resolve():
from fractions import gcd
n, m = list(map(int, input().split()))
s, t = [eval(input()) for _ in range(2)]
gcd = gcd(n, m)
lcm = n * m // gcd
n //= gcd
m //= gcd
print((lcm if all(s[n * i] == t[m * i] for i in range(gcd)) else -1))
resolve()
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()
from math import gcd
def resolve():
fixed = {}
n, m = list(map(int, input().split()))
S = eval(input())
T = eval(input())
l = n // gcd(n, m) * m
for i in range(n):
fixed[i * l // n] = S[i]
for j in range(m):
if not j * l // m in fixed:
continue
if fixed[j * l // m] != T[j]:
print((-1))
return
print(l)
resolve()
| false | 31.818182 |
[
"+INF = 1 << 60",
"+MOD = 10**9 + 7 # 998244353",
"-INF = float(\"inf\")",
"-MOD = 10**9 + 7",
"+from math import gcd",
"- from fractions import gcd",
"-",
"+ fixed = {}",
"- s, t = [eval(input()) for _ in range(2)]",
"- gcd = gcd(n, m)",
"- lcm = n * m // gcd",
"- n //= gcd",
"- m //= gcd",
"- print((lcm if all(s[n * i] == t[m * i] for i in range(gcd)) else -1))",
"+ S = eval(input())",
"+ T = eval(input())",
"+ l = n // gcd(n, m) * m",
"+ for i in range(n):",
"+ fixed[i * l // n] = S[i]",
"+ for j in range(m):",
"+ if not j * l // m in fixed:",
"+ continue",
"+ if fixed[j * l // m] != T[j]:",
"+ print((-1))",
"+ return",
"+ print(l)"
] | false | 0.143253 | 0.037558 | 3.814157 |
[
"s964017952",
"s219355883"
] |
u952708174
|
p03643
|
python
|
s357251071
|
s247016030
| 166 | 17 | 38,256 | 2,940 |
Accepted
|
Accepted
| 89.76 |
x=eval(input(""))
print(("ABC{}".format(x)))
|
print(('ABC'+eval(input())))
| 2 | 1 | 37 | 20 |
x = eval(input(""))
print(("ABC{}".format(x)))
|
print(("ABC" + eval(input())))
| false | 50 |
[
"-x = eval(input(\"\"))",
"-print((\"ABC{}\".format(x)))",
"+print((\"ABC\" + eval(input())))"
] | false | 0.043562 | 0.04482 | 0.971935 |
[
"s357251071",
"s247016030"
] |
u271934630
|
p03371
|
python
|
s577471756
|
s267454570
| 19 | 17 | 3,316 | 3,064 |
Accepted
|
Accepted
| 10.53 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
A, B, C, X, Y = list(map(int, input().split()))
ans = 0
if X >= Y:
ans = min(A*X+B*Y, C*(Y)*2+A*(X-Y))
else:
ans = min(A*X+B*Y, C*(X)*2+B*(Y-X))
ans = min(ans, C*max(X, Y)*2)
print(ans)
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()
A, B, C, X, Y = i_l()
if X < Y:
X * C + (Y - X) * B
print((min((X * A + Y * B), (X * C * 2 + (Y - X) * B), C * max(X, Y) * 2)))
else:
print((min((X * A + Y * B), (Y * C * 2 + (X - Y) * A), C * max(X, Y) * 2)))
| 15 | 16 | 275 | 420 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
A, B, C, X, Y = list(map(int, input().split()))
ans = 0
if X >= Y:
ans = min(A * X + B * Y, C * (Y) * 2 + A * (X - Y))
else:
ans = min(A * X + B * Y, C * (X) * 2 + B * (Y - X))
ans = min(ans, C * max(X, Y) * 2)
print(ans)
|
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**7)
i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()
A, B, C, X, Y = i_l()
if X < Y:
X * C + (Y - X) * B
print((min((X * A + Y * B), (X * C * 2 + (Y - X) * B), C * max(X, Y) * 2)))
else:
print((min((X * A + Y * B), (Y * C * 2 + (X - Y) * A), C * max(X, Y) * 2)))
| false | 6.25 |
[
"-input = sys.stdin.readline",
"+stdin = sys.stdin",
"-A, B, C, X, Y = list(map(int, input().split()))",
"-ans = 0",
"-if X >= Y:",
"- ans = min(A * X + B * Y, C * (Y) * 2 + A * (X - Y))",
"+i_i = lambda: int(i_s())",
"+i_l = lambda: list(map(int, stdin.readline().split()))",
"+i_s = lambda: stdin.readline().rstrip()",
"+A, B, C, X, Y = i_l()",
"+if X < Y:",
"+ X * C + (Y - X) * B",
"+ print((min((X * A + Y * B), (X * C * 2 + (Y - X) * B), C * max(X, Y) * 2)))",
"- ans = min(A * X + B * Y, C * (X) * 2 + B * (Y - X))",
"-ans = min(ans, C * max(X, Y) * 2)",
"-print(ans)",
"+ print((min((X * A + Y * B), (Y * C * 2 + (X - Y) * A), C * max(X, Y) * 2)))"
] | false | 0.067438 | 0.064858 | 1.039776 |
[
"s577471756",
"s267454570"
] |
u562935282
|
p03273
|
python
|
s563058364
|
s065541047
| 23 | 20 | 3,064 | 3,064 |
Accepted
|
Accepted
| 13.04 |
h , w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
good_r = [False for _ in range(h)]
good_c = [False for _ in range(w)]
for i in range(h):
for j in range(w):
if a[i][j] == '#':
good_r[i] = True
good_c[j] = True
for i in range(h):
if good_r[i]:
string = ''
for j in range(w):
if good_c[j]:
string += a[i][j]
if len(string) > 0:
print(string)
|
def main():
H, W = map(int, input().split())
a = [input() for _ in range(H)]
show_r = []
show_c = []
for r, row in enumerate(a):
show_r.append(any(c == '#' for c in row))
for c, col in enumerate(zip(*a)):
show_c.append(any(c == '#' for c in col))
ans = []
for r in range(H):
t = ''
for c in range(W):
if show_r[r] and show_c[c]:
t += a[r][c]
if t:
ans.append(t)
print(*ans, sep='\n')
if __name__ == '__main__':
main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
| 19 | 36 | 486 | 714 |
h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
good_r = [False for _ in range(h)]
good_c = [False for _ in range(w)]
for i in range(h):
for j in range(w):
if a[i][j] == "#":
good_r[i] = True
good_c[j] = True
for i in range(h):
if good_r[i]:
string = ""
for j in range(w):
if good_c[j]:
string += a[i][j]
if len(string) > 0:
print(string)
|
def main():
H, W = map(int, input().split())
a = [input() for _ in range(H)]
show_r = []
show_c = []
for r, row in enumerate(a):
show_r.append(any(c == "#" for c in row))
for c, col in enumerate(zip(*a)):
show_c.append(any(c == "#" for c in col))
ans = []
for r in range(H):
t = ""
for c in range(W):
if show_r[r] and show_c[c]:
t += a[r][c]
if t:
ans.append(t)
print(*ans, sep="\n")
if __name__ == "__main__":
main()
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
| false | 47.222222 |
[
"-h, w = list(map(int, input().split()))",
"-a = [list(eval(input())) for _ in range(h)]",
"-good_r = [False for _ in range(h)]",
"-good_c = [False for _ in range(w)]",
"-for i in range(h):",
"- for j in range(w):",
"- if a[i][j] == \"#\":",
"- good_r[i] = True",
"- good_c[j] = True",
"-for i in range(h):",
"- if good_r[i]:",
"- string = \"\"",
"- for j in range(w):",
"- if good_c[j]:",
"- string += a[i][j]",
"- if len(string) > 0:",
"- print(string)",
"+def main():",
"+ H, W = map(int, input().split())",
"+ a = [input() for _ in range(H)]",
"+ show_r = []",
"+ show_c = []",
"+ for r, row in enumerate(a):",
"+ show_r.append(any(c == \"#\" for c in row))",
"+ for c, col in enumerate(zip(*a)):",
"+ show_c.append(any(c == \"#\" for c in col))",
"+ ans = []",
"+ for r in range(H):",
"+ t = \"\"",
"+ for c in range(W):",
"+ if show_r[r] and show_c[c]:",
"+ t += a[r][c]",
"+ if t:",
"+ ans.append(t)",
"+ print(*ans, sep=\"\\n\")",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()",
"+# import sys",
"+#",
"+# sys.setrecursionlimit(10 ** 7)",
"+#",
"+# input = sys.stdin.readline",
"+# rstrip()",
"+# int(input())",
"+# map(int, input().split())"
] | false | 0.115264 | 0.038377 | 3.003441 |
[
"s563058364",
"s065541047"
] |
u802963389
|
p02881
|
python
|
s508470158
|
s916813221
| 164 | 139 | 2,940 | 2,940 |
Accepted
|
Accepted
| 15.24 |
N = int(eval(input()))
ans = 10 ** 19
for i in range(1, int(N**.5) + 1):
if N % i == 0:
ans = min(ans, i + N // i -2)
print(ans)
|
n = int(eval(input()))
for i in range(int(n**.5) + 1, 0, -1):
if n % i == 0:
ans = n // i + i - 2
print(ans)
exit()
| 6 | 6 | 133 | 128 |
N = int(eval(input()))
ans = 10**19
for i in range(1, int(N**0.5) + 1):
if N % i == 0:
ans = min(ans, i + N // i - 2)
print(ans)
|
n = int(eval(input()))
for i in range(int(n**0.5) + 1, 0, -1):
if n % i == 0:
ans = n // i + i - 2
print(ans)
exit()
| false | 0 |
[
"-N = int(eval(input()))",
"-ans = 10**19",
"-for i in range(1, int(N**0.5) + 1):",
"- if N % i == 0:",
"- ans = min(ans, i + N // i - 2)",
"-print(ans)",
"+n = int(eval(input()))",
"+for i in range(int(n**0.5) + 1, 0, -1):",
"+ if n % i == 0:",
"+ ans = n // i + i - 2",
"+ print(ans)",
"+ exit()"
] | false | 0.047587 | 0.087772 | 0.542166 |
[
"s508470158",
"s916813221"
] |
u339199690
|
p03645
|
python
|
s180149938
|
s727254595
| 941 | 862 | 67,740 | 67,740 |
Accepted
|
Accepted
| 8.4 |
N, M = list(map(int, input().split()))
G = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].add(b)
G[b].add(a)
for g in G[N - 1]:
if g in G[0]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
N, M = list(map(int, input().split()))
G = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].add(b)
G[b].add(a)
if len(G[N - 1] & G[0]) > 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| 16 | 14 | 289 | 269 |
N, M = list(map(int, input().split()))
G = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].add(b)
G[b].add(a)
for g in G[N - 1]:
if g in G[0]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
N, M = list(map(int, input().split()))
G = [set() for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
G[a].add(b)
G[b].add(a)
if len(G[N - 1] & G[0]) > 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| false | 12.5 |
[
"-for g in G[N - 1]:",
"- if g in G[0]:",
"- print(\"POSSIBLE\")",
"- exit()",
"-print(\"IMPOSSIBLE\")",
"+if len(G[N - 1] & G[0]) > 0:",
"+ print(\"POSSIBLE\")",
"+else:",
"+ print(\"IMPOSSIBLE\")"
] | false | 0.046447 | 0.048398 | 0.959686 |
[
"s180149938",
"s727254595"
] |
u021387650
|
p02659
|
python
|
s646031943
|
s758387460
| 28 | 20 | 10,004 | 9,144 |
Accepted
|
Accepted
| 28.57 |
from decimal import Decimal
A,B = list(map(str,input().split()))
A = Decimal(A)
B = Decimal(B)
print((int(A*B)))
|
a, b = input().split()
a = int(a)
b = int(b.replace('.',''))
print((a*b//100))
| 5 | 4 | 108 | 79 |
from decimal import Decimal
A, B = list(map(str, input().split()))
A = Decimal(A)
B = Decimal(B)
print((int(A * B)))
|
a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
print((a * b // 100))
| false | 20 |
[
"-from decimal import Decimal",
"-",
"-A, B = list(map(str, input().split()))",
"-A = Decimal(A)",
"-B = Decimal(B)",
"-print((int(A * B)))",
"+a, b = input().split()",
"+a = int(a)",
"+b = int(b.replace(\".\", \"\"))",
"+print((a * b // 100))"
] | false | 0.044159 | 0.040399 | 1.093081 |
[
"s646031943",
"s758387460"
] |
u573754721
|
p02767
|
python
|
s950138856
|
s500725347
| 186 | 168 | 38,768 | 38,512 |
Accepted
|
Accepted
| 9.68 |
def calc(s,t):
return (t-s)**2
n=int(eval(input()))
X=sorted(list(map(int,input().split())))
inf=float("inf")
ans=inf
for i in range(X[0],X[-1]+1):
u=0
for j in X:
u+=calc(i,j)
ans=min(ans,u)
print(ans)
|
n=int(eval(input()))
X=list(map(int,input().split()))
s=float("inf")
for i in range(min(X),max(X)+1):
d=0
for j in X:
d+=(j-i)**2
s=min(s,d)
print(s)
| 14 | 11 | 253 | 173 |
def calc(s, t):
return (t - s) ** 2
n = int(eval(input()))
X = sorted(list(map(int, input().split())))
inf = float("inf")
ans = inf
for i in range(X[0], X[-1] + 1):
u = 0
for j in X:
u += calc(i, j)
ans = min(ans, u)
print(ans)
|
n = int(eval(input()))
X = list(map(int, input().split()))
s = float("inf")
for i in range(min(X), max(X) + 1):
d = 0
for j in X:
d += (j - i) ** 2
s = min(s, d)
print(s)
| false | 21.428571 |
[
"-def calc(s, t):",
"- return (t - s) ** 2",
"-",
"-",
"-X = sorted(list(map(int, input().split())))",
"-inf = float(\"inf\")",
"-ans = inf",
"-for i in range(X[0], X[-1] + 1):",
"- u = 0",
"+X = list(map(int, input().split()))",
"+s = float(\"inf\")",
"+for i in range(min(X), max(X) + 1):",
"+ d = 0",
"- u += calc(i, j)",
"- ans = min(ans, u)",
"-print(ans)",
"+ d += (j - i) ** 2",
"+ s = min(s, d)",
"+print(s)"
] | false | 0.145947 | 0.106845 | 1.365969 |
[
"s950138856",
"s500725347"
] |
u814781830
|
p03013
|
python
|
s879864160
|
s069092508
| 497 | 457 | 460,020 | 460,020 |
Accepted
|
Accepted
| 8.05 |
N, M = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(M)]
mod = 1000000007
ret = [-1] * (N+1)
ret[0] = 1
for i in a:
ret[i] = 0
for i in range(1,N+1):
if ret[i] == 0:
continue
elif i == 1:
ret[1] = 1
else:
ret[i] = ret[i-2] + ret[i-1]
print((ret[len(ret)-1]%mod))
|
N, M = list(map(int, input().split()))
a = set([int(eval(input())) for _ in range(M)])
mod = 1000000007
ret = [0] * (N+1)
ret[0] = 1
for i in range(1,N+1):
if i in a:
continue
elif i == 1:
ret[1] = 1
else:
ret[i] = ret[i-2] + ret[i-1]
print((ret[len(ret)-1]%mod))
| 17 | 14 | 333 | 301 |
N, M = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(M)]
mod = 1000000007
ret = [-1] * (N + 1)
ret[0] = 1
for i in a:
ret[i] = 0
for i in range(1, N + 1):
if ret[i] == 0:
continue
elif i == 1:
ret[1] = 1
else:
ret[i] = ret[i - 2] + ret[i - 1]
print((ret[len(ret) - 1] % mod))
|
N, M = list(map(int, input().split()))
a = set([int(eval(input())) for _ in range(M)])
mod = 1000000007
ret = [0] * (N + 1)
ret[0] = 1
for i in range(1, N + 1):
if i in a:
continue
elif i == 1:
ret[1] = 1
else:
ret[i] = ret[i - 2] + ret[i - 1]
print((ret[len(ret) - 1] % mod))
| false | 17.647059 |
[
"-a = [int(eval(input())) for _ in range(M)]",
"+a = set([int(eval(input())) for _ in range(M)])",
"-ret = [-1] * (N + 1)",
"+ret = [0] * (N + 1)",
"-for i in a:",
"- ret[i] = 0",
"- if ret[i] == 0:",
"+ if i in a:"
] | false | 0.036407 | 0.03792 | 0.960094 |
[
"s879864160",
"s069092508"
] |
u252828980
|
p03575
|
python
|
s552306288
|
s798450510
| 220 | 31 | 44,524 | 9,388 |
Accepted
|
Accepted
| 85.91 |
n,m = list(map(int,input().split()))
d = []
for i in range(m):
a,b = list(map(int,input().split()))
a,b = a-1, b-1
d.append((a,b))
#print(d)
pa = None
def root(a):
if pa[a] == a:
return a
else:
pa[a] = root(pa[a])
return pa[a]
def is_same(a,b):
return root(a) == root(b)
def unite(a,b):
aa = root(a)
bb = root(b)
if aa == bb:
return
pa[aa] = bb
ans = 0
for i in range(m):
pa = [x for x in range(n)]
for j,v in enumerate(d):
#(i,j,v)
if i == j:continue
a,b = v
unite(a,b)
a,b = d[i]
if not is_same(a,b):
ans +=1
print(ans)
|
from collections import deque
n,m = list(map(int,input().split()))
L =[list(map(int, input().split())) for _ in range(m)]
#print(L)
cnt = 0
for i in range(m):
G = [[] for _ in range(n)]
for j in range(m):
if i == j:
continue
a,b = L[j][0],L[j][1]
#print(a-1,b-1)
G[a-1].append(b-1)
G[b-1].append(a-1)
#print(G)
Q = deque()
Q.append(0)
visited = [0]*n
visited[0] = 1
while Q:
q = Q.pop()
for g in G[q]:
if visited[g] == 0:
visited[g] = 1
#print(visited)
Q.append(g)
if 0 in visited:
cnt +=1
print(cnt)
| 36 | 31 | 674 | 702 |
n, m = list(map(int, input().split()))
d = []
for i in range(m):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
d.append((a, b))
# print(d)
pa = None
def root(a):
if pa[a] == a:
return a
else:
pa[a] = root(pa[a])
return pa[a]
def is_same(a, b):
return root(a) == root(b)
def unite(a, b):
aa = root(a)
bb = root(b)
if aa == bb:
return
pa[aa] = bb
ans = 0
for i in range(m):
pa = [x for x in range(n)]
for j, v in enumerate(d):
# (i,j,v)
if i == j:
continue
a, b = v
unite(a, b)
a, b = d[i]
if not is_same(a, b):
ans += 1
print(ans)
|
from collections import deque
n, m = list(map(int, input().split()))
L = [list(map(int, input().split())) for _ in range(m)]
# print(L)
cnt = 0
for i in range(m):
G = [[] for _ in range(n)]
for j in range(m):
if i == j:
continue
a, b = L[j][0], L[j][1]
# print(a-1,b-1)
G[a - 1].append(b - 1)
G[b - 1].append(a - 1)
# print(G)
Q = deque()
Q.append(0)
visited = [0] * n
visited[0] = 1
while Q:
q = Q.pop()
for g in G[q]:
if visited[g] == 0:
visited[g] = 1
# print(visited)
Q.append(g)
if 0 in visited:
cnt += 1
print(cnt)
| false | 13.888889 |
[
"+from collections import deque",
"+",
"-d = []",
"+L = [list(map(int, input().split())) for _ in range(m)]",
"+# print(L)",
"+cnt = 0",
"- a, b = list(map(int, input().split()))",
"- a, b = a - 1, b - 1",
"- d.append((a, b))",
"-# print(d)",
"-pa = None",
"-",
"-",
"-def root(a):",
"- if pa[a] == a:",
"- return a",
"- else:",
"- pa[a] = root(pa[a])",
"- return pa[a]",
"-",
"-",
"-def is_same(a, b):",
"- return root(a) == root(b)",
"-",
"-",
"-def unite(a, b):",
"- aa = root(a)",
"- bb = root(b)",
"- if aa == bb:",
"- return",
"- pa[aa] = bb",
"-",
"-",
"-ans = 0",
"-for i in range(m):",
"- pa = [x for x in range(n)]",
"- for j, v in enumerate(d):",
"- # (i,j,v)",
"+ G = [[] for _ in range(n)]",
"+ for j in range(m):",
"- a, b = v",
"- unite(a, b)",
"- a, b = d[i]",
"- if not is_same(a, b):",
"- ans += 1",
"-print(ans)",
"+ a, b = L[j][0], L[j][1]",
"+ # print(a-1,b-1)",
"+ G[a - 1].append(b - 1)",
"+ G[b - 1].append(a - 1)",
"+ # print(G)",
"+ Q = deque()",
"+ Q.append(0)",
"+ visited = [0] * n",
"+ visited[0] = 1",
"+ while Q:",
"+ q = Q.pop()",
"+ for g in G[q]:",
"+ if visited[g] == 0:",
"+ visited[g] = 1",
"+ # print(visited)",
"+ Q.append(g)",
"+ if 0 in visited:",
"+ cnt += 1",
"+print(cnt)"
] | false | 0.04404 | 0.045371 | 0.970668 |
[
"s552306288",
"s798450510"
] |
u491656579
|
p03574
|
python
|
s404902880
|
s503228700
| 28 | 25 | 3,444 | 3,444 |
Accepted
|
Accepted
| 10.71 |
import sys
from collections import Counter
h, w = list(map(int, input().split()))
s_list = [list(eval(input())) for i in range(h)]
def check_mine(v):
if v == '#':
return 1
else:
return 0
for i in range(h):
for j in range(w):
if s_list[i][j] == '.':
tmp = 0
if i != 0:
if j != 0:
tmp += check_mine(s_list[i-1][j-1])
if j != w-1:
tmp += check_mine(s_list[i-1][j+1])
tmp += check_mine(s_list[i-1][j])
if i != h-1:
if j != 0:
tmp += check_mine(s_list[i+1][j-1])
if j != w-1:
tmp += check_mine(s_list[i+1][j+1])
tmp += check_mine(s_list[i+1][j])
if j != 0:
tmp += check_mine(s_list[i][j-1])
if j != w-1:
tmp += check_mine(s_list[i][j+1])
s_list[i][j] = str(tmp)
for i in s_list:
print((''.join(i)))
|
import sys
from collections import Counter
h, w = list(map(int, input().split()))
s_list = [list('.' * (w + 2))]
s_list.extend([list('.' + eval(input()) + '.') for i in range(h)])
s_list.append(list('.' * (w + 2)))
def check_mine(v):
if v == '#':
return 1
else:
return 0
for i in range(1, h+1):
for j in range(1, w+1):
if s_list[i][j] == '.':
cnt = 0
cnt += s_list[i-1][j-1:j+2].count('#')
cnt += s_list[i][j-1:j+2].count('#')
cnt += s_list[i+1][j-1:j+2].count('#')
s_list[i][j] = str(cnt)
for i in s_list[1:-1]:
print((''.join(i[1:-1])))
| 40 | 25 | 1,059 | 652 |
import sys
from collections import Counter
h, w = list(map(int, input().split()))
s_list = [list(eval(input())) for i in range(h)]
def check_mine(v):
if v == "#":
return 1
else:
return 0
for i in range(h):
for j in range(w):
if s_list[i][j] == ".":
tmp = 0
if i != 0:
if j != 0:
tmp += check_mine(s_list[i - 1][j - 1])
if j != w - 1:
tmp += check_mine(s_list[i - 1][j + 1])
tmp += check_mine(s_list[i - 1][j])
if i != h - 1:
if j != 0:
tmp += check_mine(s_list[i + 1][j - 1])
if j != w - 1:
tmp += check_mine(s_list[i + 1][j + 1])
tmp += check_mine(s_list[i + 1][j])
if j != 0:
tmp += check_mine(s_list[i][j - 1])
if j != w - 1:
tmp += check_mine(s_list[i][j + 1])
s_list[i][j] = str(tmp)
for i in s_list:
print(("".join(i)))
|
import sys
from collections import Counter
h, w = list(map(int, input().split()))
s_list = [list("." * (w + 2))]
s_list.extend([list("." + eval(input()) + ".") for i in range(h)])
s_list.append(list("." * (w + 2)))
def check_mine(v):
if v == "#":
return 1
else:
return 0
for i in range(1, h + 1):
for j in range(1, w + 1):
if s_list[i][j] == ".":
cnt = 0
cnt += s_list[i - 1][j - 1 : j + 2].count("#")
cnt += s_list[i][j - 1 : j + 2].count("#")
cnt += s_list[i + 1][j - 1 : j + 2].count("#")
s_list[i][j] = str(cnt)
for i in s_list[1:-1]:
print(("".join(i[1:-1])))
| false | 37.5 |
[
"-s_list = [list(eval(input())) for i in range(h)]",
"+s_list = [list(\".\" * (w + 2))]",
"+s_list.extend([list(\".\" + eval(input()) + \".\") for i in range(h)])",
"+s_list.append(list(\".\" * (w + 2)))",
"-for i in range(h):",
"- for j in range(w):",
"+for i in range(1, h + 1):",
"+ for j in range(1, w + 1):",
"- tmp = 0",
"- if i != 0:",
"- if j != 0:",
"- tmp += check_mine(s_list[i - 1][j - 1])",
"- if j != w - 1:",
"- tmp += check_mine(s_list[i - 1][j + 1])",
"- tmp += check_mine(s_list[i - 1][j])",
"- if i != h - 1:",
"- if j != 0:",
"- tmp += check_mine(s_list[i + 1][j - 1])",
"- if j != w - 1:",
"- tmp += check_mine(s_list[i + 1][j + 1])",
"- tmp += check_mine(s_list[i + 1][j])",
"- if j != 0:",
"- tmp += check_mine(s_list[i][j - 1])",
"- if j != w - 1:",
"- tmp += check_mine(s_list[i][j + 1])",
"- s_list[i][j] = str(tmp)",
"-for i in s_list:",
"- print((\"\".join(i)))",
"+ cnt = 0",
"+ cnt += s_list[i - 1][j - 1 : j + 2].count(\"#\")",
"+ cnt += s_list[i][j - 1 : j + 2].count(\"#\")",
"+ cnt += s_list[i + 1][j - 1 : j + 2].count(\"#\")",
"+ s_list[i][j] = str(cnt)",
"+for i in s_list[1:-1]:",
"+ print((\"\".join(i[1:-1])))"
] | false | 0.038991 | 0.100548 | 0.387785 |
[
"s404902880",
"s503228700"
] |
u606045429
|
p02775
|
python
|
s675876666
|
s787320430
| 901 | 815 | 5,492 | 5,492 |
Accepted
|
Accepted
| 9.54 |
S = list(map(int, eval(input())))
a, b = 0, 1
for s in S:
a, b = min(a + s, b + 10 - s), min(a + (s + 1), b + 10 - (s + 1))
print(a)
|
def main():
S = list(map(int, eval(input())))
a, b = 0, 1
for s in S:
a, b = min(a + s, b + 10 - s), min(a + (s + 1), b + 10 - (s + 1))
print(a)
main()
| 7 | 11 | 132 | 177 |
S = list(map(int, eval(input())))
a, b = 0, 1
for s in S:
a, b = min(a + s, b + 10 - s), min(a + (s + 1), b + 10 - (s + 1))
print(a)
|
def main():
S = list(map(int, eval(input())))
a, b = 0, 1
for s in S:
a, b = min(a + s, b + 10 - s), min(a + (s + 1), b + 10 - (s + 1))
print(a)
main()
| false | 36.363636 |
[
"-S = list(map(int, eval(input())))",
"-a, b = 0, 1",
"-for s in S:",
"- a, b = min(a + s, b + 10 - s), min(a + (s + 1), b + 10 - (s + 1))",
"-print(a)",
"+def main():",
"+ S = list(map(int, eval(input())))",
"+ a, b = 0, 1",
"+ for s in S:",
"+ a, b = min(a + s, b + 10 - s), min(a + (s + 1), b + 10 - (s + 1))",
"+ print(a)",
"+",
"+",
"+main()"
] | false | 0.038534 | 0.115975 | 0.332258 |
[
"s675876666",
"s787320430"
] |
u124498235
|
p02534
|
python
|
s696677631
|
s947125830
| 32 | 24 | 9,148 | 9,144 |
Accepted
|
Accepted
| 25 |
n = int(eval(input()))
ans = n*('ACL')
print (ans)
|
print((int(eval(input()))*'ACL'))
| 3 | 1 | 46 | 25 |
n = int(eval(input()))
ans = n * ("ACL")
print(ans)
|
print((int(eval(input())) * "ACL"))
| false | 66.666667 |
[
"-n = int(eval(input()))",
"-ans = n * (\"ACL\")",
"-print(ans)",
"+print((int(eval(input())) * \"ACL\"))"
] | false | 0.036847 | 0.03545 | 1.039415 |
[
"s696677631",
"s947125830"
] |
u256256172
|
p00433
|
python
|
s979263284
|
s188809065
| 30 | 20 | 7,688 | 7,692 |
Accepted
|
Accepted
| 33.33 |
a = list(map(int, input().split()))
b = list(map(int, input().split()))
def sum(x):
sum = 0
for i in range(4):
sum += x[i]
return sum
A = sum(a)
B = sum(b)
print((A if A > B else B))
|
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print((max(sum(a),sum(b))))
| 13 | 3 | 215 | 87 |
a = list(map(int, input().split()))
b = list(map(int, input().split()))
def sum(x):
sum = 0
for i in range(4):
sum += x[i]
return sum
A = sum(a)
B = sum(b)
print((A if A > B else B))
|
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print((max(sum(a), sum(b))))
| false | 76.923077 |
[
"-",
"-",
"-def sum(x):",
"- sum = 0",
"- for i in range(4):",
"- sum += x[i]",
"- return sum",
"-",
"-",
"-A = sum(a)",
"-B = sum(b)",
"-print((A if A > B else B))",
"+print((max(sum(a), sum(b))))"
] | false | 0.046834 | 0.244249 | 0.191748 |
[
"s979263284",
"s188809065"
] |
u623814058
|
p03013
|
python
|
s735287476
|
s884429168
| 481 | 148 | 465,932 | 17,556 |
Accepted
|
Accepted
| 69.23 |
N,M=list(map(int, input().split()))
A=set(int(eval(input())) for _ in range(M))
D=[0]*(N+1)
D[0]=1
for i in range(1,N+1):
if i in A: continue
D[i]=D[i-1]+D[i-2]
print((D[-1] % (10**9+7)))
|
N,M=list(map(int, input().split()))
A=set(int(eval(input())) for _ in range(M))
D=[0]*(N+1)
D[0]=1
for i in range(1,N+1):
if i in A: continue
D[i]=(D[i-1]+D[i-2])%(10**9+7)
print((D[-1]))
| 9 | 9 | 184 | 184 |
N, M = list(map(int, input().split()))
A = set(int(eval(input())) for _ in range(M))
D = [0] * (N + 1)
D[0] = 1
for i in range(1, N + 1):
if i in A:
continue
D[i] = D[i - 1] + D[i - 2]
print((D[-1] % (10**9 + 7)))
|
N, M = list(map(int, input().split()))
A = set(int(eval(input())) for _ in range(M))
D = [0] * (N + 1)
D[0] = 1
for i in range(1, N + 1):
if i in A:
continue
D[i] = (D[i - 1] + D[i - 2]) % (10**9 + 7)
print((D[-1]))
| false | 0 |
[
"- D[i] = D[i - 1] + D[i - 2]",
"-print((D[-1] % (10**9 + 7)))",
"+ D[i] = (D[i - 1] + D[i - 2]) % (10**9 + 7)",
"+print((D[-1]))"
] | false | 0.037396 | 0.044711 | 0.836385 |
[
"s735287476",
"s884429168"
] |
u098223184
|
p02554
|
python
|
s661172940
|
s179173806
| 389 | 29 | 11,020 | 9,076 |
Accepted
|
Accepted
| 92.54 |
n=int(eval(input()))
mod=1000000007
print(((10**n-2*9**n+8**n)%mod))
|
n=int(eval(input()))
mod=1000000007
print(((pow(10,n,mod)-2*pow(9,n,mod)+pow(8,n,mod))%mod))
| 3 | 3 | 63 | 86 |
n = int(eval(input()))
mod = 1000000007
print(((10**n - 2 * 9**n + 8**n) % mod))
|
n = int(eval(input()))
mod = 1000000007
print(((pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)) % mod))
| false | 0 |
[
"-print(((10**n - 2 * 9**n + 8**n) % mod))",
"+print(((pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)) % mod))"
] | false | 0.135998 | 0.033777 | 4.026318 |
[
"s661172940",
"s179173806"
] |
u562935282
|
p03359
|
python
|
s719423402
|
s350115433
| 21 | 18 | 3,316 | 2,940 |
Accepted
|
Accepted
| 14.29 |
a, b = list(map(int, input().split()))
if a <= b:
print(a)
else:
print((a-1))
|
a, b = list(map(int, input().split()))
ans = -1
if (a <= b):
ans = a
else:
ans = a - 1
print(ans)
| 5 | 7 | 81 | 105 |
a, b = list(map(int, input().split()))
if a <= b:
print(a)
else:
print((a - 1))
|
a, b = list(map(int, input().split()))
ans = -1
if a <= b:
ans = a
else:
ans = a - 1
print(ans)
| false | 28.571429 |
[
"+ans = -1",
"- print(a)",
"+ ans = a",
"- print((a - 1))",
"+ ans = a - 1",
"+print(ans)"
] | false | 0.049968 | 0.086253 | 0.579324 |
[
"s719423402",
"s350115433"
] |
u706167597
|
p04043
|
python
|
s477528031
|
s102610920
| 19 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 10.53 |
a = eval(input())
if (a.count("5") == 2 and a.count("7") == 1):
print("YES")
else:
print("NO")
|
l=list(map(int,input().split()))
if l.count(5)==2 and l.count(7)==1:
print('YES')
else:
print('NO')
| 7 | 5 | 102 | 107 |
a = eval(input())
if a.count("5") == 2 and a.count("7") == 1:
print("YES")
else:
print("NO")
|
l = list(map(int, input().split()))
if l.count(5) == 2 and l.count(7) == 1:
print("YES")
else:
print("NO")
| false | 28.571429 |
[
"-a = eval(input())",
"-if a.count(\"5\") == 2 and a.count(\"7\") == 1:",
"+l = list(map(int, input().split()))",
"+if l.count(5) == 2 and l.count(7) == 1:"
] | false | 0.075749 | 0.072267 | 1.048182 |
[
"s477528031",
"s102610920"
] |
u332906195
|
p03599
|
python
|
s872368087
|
s115524498
| 2,139 | 241 | 3,064 | 43,116 |
Accepted
|
Accepted
| 88.73 |
# -*- coding: utf-8 -*-
def calcCons(nA, nB, nC, nD):
W = nA*a*100 + nB*b*100
S = nC*c + nD*d
if W+S == 0:
return -1
return 100*S/(W+S)
a, b, c, d, e, f = list(map(int, input().split()))
maxCons = 0
answer_W, answer_S = 0, 0
nA, nB, nC, nD = 0, 0, 0, 0
while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
# Operation A
while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
# Operation B
while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
# Operation C
while nA*a*100 + nB*b*100 + nC*c + nD*d <= f:
# Operation D
cons = calcCons(nA, nB, nC, nD)
# print("{} {} {} {} {}".format(cons, nA, nB, nC, nD))
if cons > maxCons and cons <= 100*e/(100+e):
maxCons = cons
answer_W, answer_S = nA*a*100 + nB*b*100, nC*c + nD*d
nD += 1
nD = 0
nC += 1
nC = 0
nB += 1
nB = 0
nA += 1
if maxCons == 0:
answer_W = a*100
print(("{} {}".format(int(answer_W+answer_S), int(answer_S))))
|
def calcCons(nA, nB, nC, nD):
W = (nA * a + nB * b) * 100
S = nC * c + nD * d
if W + S == 0:
return -1
return S / (W + S)
a, b, c, d, e, f = list(map(int, input().split()))
nA, nB, nC, nD, W, S, M = 0, 0, 0, 0, 0, 0, 0
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
cons = calcCons(nA, nB, nC, nD)
if cons > M and cons <= e / (100 + e):
M = cons
W, S = nA * a * 100 + nB * b * 100, nC * c + nD * d
nD += 1
nD = 0
nC += 1
nC = 0
nB += 1
nB = 0
nA += 1
if M == 0:
W = a * 100
print((W + S, S))
| 41 | 29 | 1,127 | 888 |
# -*- coding: utf-8 -*-
def calcCons(nA, nB, nC, nD):
W = nA * a * 100 + nB * b * 100
S = nC * c + nD * d
if W + S == 0:
return -1
return 100 * S / (W + S)
a, b, c, d, e, f = list(map(int, input().split()))
maxCons = 0
answer_W, answer_S = 0, 0
nA, nB, nC, nD = 0, 0, 0, 0
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
# Operation A
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
# Operation B
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
# Operation C
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
# Operation D
cons = calcCons(nA, nB, nC, nD)
# print("{} {} {} {} {}".format(cons, nA, nB, nC, nD))
if cons > maxCons and cons <= 100 * e / (100 + e):
maxCons = cons
answer_W, answer_S = nA * a * 100 + nB * b * 100, nC * c + nD * d
nD += 1
nD = 0
nC += 1
nC = 0
nB += 1
nB = 0
nA += 1
if maxCons == 0:
answer_W = a * 100
print(("{} {}".format(int(answer_W + answer_S), int(answer_S))))
|
def calcCons(nA, nB, nC, nD):
W = (nA * a + nB * b) * 100
S = nC * c + nD * d
if W + S == 0:
return -1
return S / (W + S)
a, b, c, d, e, f = list(map(int, input().split()))
nA, nB, nC, nD, W, S, M = 0, 0, 0, 0, 0, 0, 0
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
while nA * a * 100 + nB * b * 100 + nC * c + nD * d <= f:
cons = calcCons(nA, nB, nC, nD)
if cons > M and cons <= e / (100 + e):
M = cons
W, S = nA * a * 100 + nB * b * 100, nC * c + nD * d
nD += 1
nD = 0
nC += 1
nC = 0
nB += 1
nB = 0
nA += 1
if M == 0:
W = a * 100
print((W + S, S))
| false | 29.268293 |
[
"-# -*- coding: utf-8 -*-",
"- W = nA * a * 100 + nB * b * 100",
"+ W = (nA * a + nB * b) * 100",
"- return 100 * S / (W + S)",
"+ return S / (W + S)",
"-maxCons = 0",
"-answer_W, answer_S = 0, 0",
"-nA, nB, nC, nD = 0, 0, 0, 0",
"+nA, nB, nC, nD, W, S, M = 0, 0, 0, 0, 0, 0, 0",
"- # Operation A",
"- # Operation B",
"- # Operation C",
"- # Operation D",
"- # print(\"{} {} {} {} {}\".format(cons, nA, nB, nC, nD))",
"- if cons > maxCons and cons <= 100 * e / (100 + e):",
"- maxCons = cons",
"- answer_W, answer_S = nA * a * 100 + nB * b * 100, nC * c + nD * d",
"+ if cons > M and cons <= e / (100 + e):",
"+ M = cons",
"+ W, S = nA * a * 100 + nB * b * 100, nC * c + nD * d",
"-if maxCons == 0:",
"- answer_W = a * 100",
"-print((\"{} {}\".format(int(answer_W + answer_S), int(answer_S))))",
"+if M == 0:",
"+ W = a * 100",
"+print((W + S, S))"
] | false | 0.92834 | 0.789926 | 1.175225 |
[
"s872368087",
"s115524498"
] |
u600402037
|
p02703
|
python
|
s361146551
|
s009891415
| 1,732 | 987 | 120,964 | 95,268 |
Accepted
|
Accepted
| 43.01 |
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 同じ地点で銀貨の枚数によって別の状態として扱う(最大max(A)*(N-1))
N, M, S = lr()
UVAB = [lr() for _ in range(M)]
CD = [lr() for _ in range(N)] # 0-indexed
Amax = 0
for i in range(M):
a = UVAB[i][2]
if a > Amax:
Amax = a
limit = Amax*(N-1)
S = min(S, limit)
graph = [[] for _ in range(N+1)] # 1-indexed
for u, v, a, b in UVAB:
graph[u].append((v, a, b))
graph[v].append((u, a, b))
def dijkstra(start):
# 時間、銀貨の枚数、現在地をqueへ
INF = 10 ** 15
dist = [[INF for _ in range(limit+1)] for _ in range(N+1)]
dist[1][S] = 0
que = [(0, S, 1)]
while que:
time, silver, prev = heappop(que)
if dist[prev][silver] < time:
continue
for next, a, b in graph[prev]:
t = time + b
si = silver - a
if si < 0:
continue
if dist[next][si] > t:
dist[next][si] = t
heappush(que, (t, si, next))
c, d = CD[prev-1]
si = min(limit, silver+c)
while dist[prev][si] > time + d:
dist[prev][si] = time + d
heappush(que, (time+d, si, prev))
si += c; si = min(limit, si)
time += d
return dist
dist = dijkstra(1)
for i in range(2, N+1):
d = dist[i]
answer = min(d)
print(answer)
# 前解いたものをPyPyで
|
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 銀貨を何枚持っているかの状態数、N*2501の都市, dijkstra
N, M, S = lr()
limit = 2500
S = min(S, limit)
graph = [[] for _ in range((N+1) * (limit+1))] # 1-indexed
for _ in range(M):
u, v, a, b = lr()
for x in range(a, limit+1):
graph[u*(limit+1) + x].append(((v*(limit+1)+x-a), b))
graph[v*(limit+1) + x].append(((u*(limit+1)+x-a), b))
for i in range(N):
i += 1
c, d = lr()
for x in range(limit-c+1):
graph[i*(limit+1) + x].append((i*(limit+1) + x + c, d))
def dijkstra(start):
INF = 10 ** 15
dist = [INF] * ((N+1) * (limit+1))
dist[start] = 0
que = [(0, start)]
while que:
d, prev = heappop(que)
if dist[prev] < d:
continue
for next, time in graph[prev]:
d1 = d + time
if dist[next] > d1:
dist[next] = d1
heappush(que, (d1, next))
return dist
dist = dijkstra(1*(limit+1)+S)
for i in range(2, N+1):
answer = min(dist[i*(limit+1):(i+1)*(limit+1)])
print(answer)
| 60 | 45 | 1,553 | 1,239 |
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 同じ地点で銀貨の枚数によって別の状態として扱う(最大max(A)*(N-1))
N, M, S = lr()
UVAB = [lr() for _ in range(M)]
CD = [lr() for _ in range(N)] # 0-indexed
Amax = 0
for i in range(M):
a = UVAB[i][2]
if a > Amax:
Amax = a
limit = Amax * (N - 1)
S = min(S, limit)
graph = [[] for _ in range(N + 1)] # 1-indexed
for u, v, a, b in UVAB:
graph[u].append((v, a, b))
graph[v].append((u, a, b))
def dijkstra(start):
# 時間、銀貨の枚数、現在地をqueへ
INF = 10**15
dist = [[INF for _ in range(limit + 1)] for _ in range(N + 1)]
dist[1][S] = 0
que = [(0, S, 1)]
while que:
time, silver, prev = heappop(que)
if dist[prev][silver] < time:
continue
for next, a, b in graph[prev]:
t = time + b
si = silver - a
if si < 0:
continue
if dist[next][si] > t:
dist[next][si] = t
heappush(que, (t, si, next))
c, d = CD[prev - 1]
si = min(limit, silver + c)
while dist[prev][si] > time + d:
dist[prev][si] = time + d
heappush(que, (time + d, si, prev))
si += c
si = min(limit, si)
time += d
return dist
dist = dijkstra(1)
for i in range(2, N + 1):
d = dist[i]
answer = min(d)
print(answer)
# 前解いたものをPyPyで
|
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
# 銀貨を何枚持っているかの状態数、N*2501の都市, dijkstra
N, M, S = lr()
limit = 2500
S = min(S, limit)
graph = [[] for _ in range((N + 1) * (limit + 1))] # 1-indexed
for _ in range(M):
u, v, a, b = lr()
for x in range(a, limit + 1):
graph[u * (limit + 1) + x].append(((v * (limit + 1) + x - a), b))
graph[v * (limit + 1) + x].append(((u * (limit + 1) + x - a), b))
for i in range(N):
i += 1
c, d = lr()
for x in range(limit - c + 1):
graph[i * (limit + 1) + x].append((i * (limit + 1) + x + c, d))
def dijkstra(start):
INF = 10**15
dist = [INF] * ((N + 1) * (limit + 1))
dist[start] = 0
que = [(0, start)]
while que:
d, prev = heappop(que)
if dist[prev] < d:
continue
for next, time in graph[prev]:
d1 = d + time
if dist[next] > d1:
dist[next] = d1
heappush(que, (d1, next))
return dist
dist = dijkstra(1 * (limit + 1) + S)
for i in range(2, N + 1):
answer = min(dist[i * (limit + 1) : (i + 1) * (limit + 1)])
print(answer)
| false | 25 |
[
"-# 同じ地点で銀貨の枚数によって別の状態として扱う(最大max(A)*(N-1))",
"+# 銀貨を何枚持っているかの状態数、N*2501の都市, dijkstra",
"-UVAB = [lr() for _ in range(M)]",
"-CD = [lr() for _ in range(N)] # 0-indexed",
"-Amax = 0",
"-for i in range(M):",
"- a = UVAB[i][2]",
"- if a > Amax:",
"- Amax = a",
"-limit = Amax * (N - 1)",
"+limit = 2500",
"-graph = [[] for _ in range(N + 1)] # 1-indexed",
"-for u, v, a, b in UVAB:",
"- graph[u].append((v, a, b))",
"- graph[v].append((u, a, b))",
"+graph = [[] for _ in range((N + 1) * (limit + 1))] # 1-indexed",
"+for _ in range(M):",
"+ u, v, a, b = lr()",
"+ for x in range(a, limit + 1):",
"+ graph[u * (limit + 1) + x].append(((v * (limit + 1) + x - a), b))",
"+ graph[v * (limit + 1) + x].append(((u * (limit + 1) + x - a), b))",
"+for i in range(N):",
"+ i += 1",
"+ c, d = lr()",
"+ for x in range(limit - c + 1):",
"+ graph[i * (limit + 1) + x].append((i * (limit + 1) + x + c, d))",
"- # 時間、銀貨の枚数、現在地をqueへ",
"- dist = [[INF for _ in range(limit + 1)] for _ in range(N + 1)]",
"- dist[1][S] = 0",
"- que = [(0, S, 1)]",
"+ dist = [INF] * ((N + 1) * (limit + 1))",
"+ dist[start] = 0",
"+ que = [(0, start)]",
"- time, silver, prev = heappop(que)",
"- if dist[prev][silver] < time:",
"+ d, prev = heappop(que)",
"+ if dist[prev] < d:",
"- for next, a, b in graph[prev]:",
"- t = time + b",
"- si = silver - a",
"- if si < 0:",
"- continue",
"- if dist[next][si] > t:",
"- dist[next][si] = t",
"- heappush(que, (t, si, next))",
"- c, d = CD[prev - 1]",
"- si = min(limit, silver + c)",
"- while dist[prev][si] > time + d:",
"- dist[prev][si] = time + d",
"- heappush(que, (time + d, si, prev))",
"- si += c",
"- si = min(limit, si)",
"- time += d",
"+ for next, time in graph[prev]:",
"+ d1 = d + time",
"+ if dist[next] > d1:",
"+ dist[next] = d1",
"+ heappush(que, (d1, next))",
"-dist = dijkstra(1)",
"+dist = dijkstra(1 * (limit + 1) + S)",
"- d = dist[i]",
"- answer = min(d)",
"+ answer = min(dist[i * (limit + 1) : (i + 1) * (limit + 1)])",
"-# 前解いたものをPyPyで"
] | false | 0.105135 | 0.086944 | 1.209231 |
[
"s361146551",
"s009891415"
] |
u997641430
|
p02714
|
python
|
s225902271
|
s001491600
| 918 | 150 | 71,696 | 68,600 |
Accepted
|
Accepted
| 83.66 |
import bisect
n = int(eval(input()))
S = list(eval(input()))
R, G, B = [], [], []
for i in range(n):
if S[i] == 'R':
R.append(i)
if S[i] == 'G':
G.append(i)
if S[i] == 'B':
B.append(i)
r = len(R)
g = len(G)
b = len(B)
cnt = 0
Rset, Gset, Bset = set(R), set(G), set(B)
# RGB
for i in range(r):
g0 = bisect.bisect_right(G, R[i])
for j in range(g0, g):
b0 = bisect.bisect_right(B, G[j])
cnt += b - b0
x = 2*G[j]-R[i]
if x in Bset:
cnt -= 1
# RBG
for i in range(r):
b0 = bisect.bisect_right(B, R[i])
for j in range(b0, b):
g0 = bisect.bisect_right(G, B[j])
cnt += g - g0
x = 2*B[j]-R[i]
if x in Gset:
cnt -= 1
# GBR
for i in range(g):
b0 = bisect.bisect_right(B, G[i])
for j in range(b0, b):
r0 = bisect.bisect_right(R, B[j])
cnt += r - r0
x = 2*B[j]-G[i]
if x in Rset:
cnt -= 1
# GRB
for i in range(g):
r0 = bisect.bisect_right(R, G[i])
for j in range(r0, r):
b0 = bisect.bisect_right(B, R[j])
cnt += b - b0
x = 2*R[j]-G[i]
if x in Bset:
cnt -= 1
# BRG
for i in range(b):
r0 = bisect.bisect_right(R, B[i])
for j in range(r0, r):
g0 = bisect.bisect_right(G, R[j])
cnt += g - g0
x = 2*R[j]-B[i]
if x in Gset:
cnt -= 1
# BGR
for i in range(b):
g0 = bisect.bisect_right(G, B[i])
for j in range(g0, g):
r0 = bisect.bisect_right(R, G[j])
cnt += r - r0
x = 2*G[j]-B[i]
if x in Rset:
cnt -= 1
print(cnt)
|
n = int(eval(input()))
S = list(eval(input()))
R, G, B = set(), set(), set()
for i in range(n):
if S[i] == 'R':
R.add(i)
if S[i] == 'G':
G.add(i)
if S[i] == 'B':
B.add(i)
cnt = len(R)*len(G)*len(B)
for r in R:
for g in G:
if 2*g-r in B:
cnt -= 1
if 2*r-g in B:
cnt -= 1
if (r+g) % 2 == 0 and (r+g)//2 in B:
cnt -= 1
print(cnt)
| 71 | 20 | 1,699 | 434 |
import bisect
n = int(eval(input()))
S = list(eval(input()))
R, G, B = [], [], []
for i in range(n):
if S[i] == "R":
R.append(i)
if S[i] == "G":
G.append(i)
if S[i] == "B":
B.append(i)
r = len(R)
g = len(G)
b = len(B)
cnt = 0
Rset, Gset, Bset = set(R), set(G), set(B)
# RGB
for i in range(r):
g0 = bisect.bisect_right(G, R[i])
for j in range(g0, g):
b0 = bisect.bisect_right(B, G[j])
cnt += b - b0
x = 2 * G[j] - R[i]
if x in Bset:
cnt -= 1
# RBG
for i in range(r):
b0 = bisect.bisect_right(B, R[i])
for j in range(b0, b):
g0 = bisect.bisect_right(G, B[j])
cnt += g - g0
x = 2 * B[j] - R[i]
if x in Gset:
cnt -= 1
# GBR
for i in range(g):
b0 = bisect.bisect_right(B, G[i])
for j in range(b0, b):
r0 = bisect.bisect_right(R, B[j])
cnt += r - r0
x = 2 * B[j] - G[i]
if x in Rset:
cnt -= 1
# GRB
for i in range(g):
r0 = bisect.bisect_right(R, G[i])
for j in range(r0, r):
b0 = bisect.bisect_right(B, R[j])
cnt += b - b0
x = 2 * R[j] - G[i]
if x in Bset:
cnt -= 1
# BRG
for i in range(b):
r0 = bisect.bisect_right(R, B[i])
for j in range(r0, r):
g0 = bisect.bisect_right(G, R[j])
cnt += g - g0
x = 2 * R[j] - B[i]
if x in Gset:
cnt -= 1
# BGR
for i in range(b):
g0 = bisect.bisect_right(G, B[i])
for j in range(g0, g):
r0 = bisect.bisect_right(R, G[j])
cnt += r - r0
x = 2 * G[j] - B[i]
if x in Rset:
cnt -= 1
print(cnt)
|
n = int(eval(input()))
S = list(eval(input()))
R, G, B = set(), set(), set()
for i in range(n):
if S[i] == "R":
R.add(i)
if S[i] == "G":
G.add(i)
if S[i] == "B":
B.add(i)
cnt = len(R) * len(G) * len(B)
for r in R:
for g in G:
if 2 * g - r in B:
cnt -= 1
if 2 * r - g in B:
cnt -= 1
if (r + g) % 2 == 0 and (r + g) // 2 in B:
cnt -= 1
print(cnt)
| false | 71.830986 |
[
"-import bisect",
"-",
"-R, G, B = [], [], []",
"+R, G, B = set(), set(), set()",
"- R.append(i)",
"+ R.add(i)",
"- G.append(i)",
"+ G.add(i)",
"- B.append(i)",
"-r = len(R)",
"-g = len(G)",
"-b = len(B)",
"-cnt = 0",
"-Rset, Gset, Bset = set(R), set(G), set(B)",
"-# RGB",
"-for i in range(r):",
"- g0 = bisect.bisect_right(G, R[i])",
"- for j in range(g0, g):",
"- b0 = bisect.bisect_right(B, G[j])",
"- cnt += b - b0",
"- x = 2 * G[j] - R[i]",
"- if x in Bset:",
"+ B.add(i)",
"+cnt = len(R) * len(G) * len(B)",
"+for r in R:",
"+ for g in G:",
"+ if 2 * g - r in B:",
"-# RBG",
"-for i in range(r):",
"- b0 = bisect.bisect_right(B, R[i])",
"- for j in range(b0, b):",
"- g0 = bisect.bisect_right(G, B[j])",
"- cnt += g - g0",
"- x = 2 * B[j] - R[i]",
"- if x in Gset:",
"+ if 2 * r - g in B:",
"-# GBR",
"-for i in range(g):",
"- b0 = bisect.bisect_right(B, G[i])",
"- for j in range(b0, b):",
"- r0 = bisect.bisect_right(R, B[j])",
"- cnt += r - r0",
"- x = 2 * B[j] - G[i]",
"- if x in Rset:",
"- cnt -= 1",
"-# GRB",
"-for i in range(g):",
"- r0 = bisect.bisect_right(R, G[i])",
"- for j in range(r0, r):",
"- b0 = bisect.bisect_right(B, R[j])",
"- cnt += b - b0",
"- x = 2 * R[j] - G[i]",
"- if x in Bset:",
"- cnt -= 1",
"-# BRG",
"-for i in range(b):",
"- r0 = bisect.bisect_right(R, B[i])",
"- for j in range(r0, r):",
"- g0 = bisect.bisect_right(G, R[j])",
"- cnt += g - g0",
"- x = 2 * R[j] - B[i]",
"- if x in Gset:",
"- cnt -= 1",
"-# BGR",
"-for i in range(b):",
"- g0 = bisect.bisect_right(G, B[i])",
"- for j in range(g0, g):",
"- r0 = bisect.bisect_right(R, G[j])",
"- cnt += r - r0",
"- x = 2 * G[j] - B[i]",
"- if x in Rset:",
"+ if (r + g) % 2 == 0 and (r + g) // 2 in B:"
] | false | 0.046132 | 0.037677 | 1.224426 |
[
"s225902271",
"s001491600"
] |
u570706399
|
p02898
|
python
|
s695793350
|
s096041610
| 50 | 43 | 9,984 | 11,580 |
Accepted
|
Accepted
| 14 |
# coding: utf-8
# Your code here!
N,K = list(map(int, input().split()))
h = list(map(int, input().split()))
cou = 0
for i in h:
if K<=i:
cou+=1
print(cou)
|
N,K = list(map(int, input().split()))
h = list(map(int, input().split()))
cou = len([i for i in h if i>=K])
print(cou)
| 11 | 5 | 166 | 111 |
# coding: utf-8
# Your code here!
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
cou = 0
for i in h:
if K <= i:
cou += 1
print(cou)
|
N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
cou = len([i for i in h if i >= K])
print(cou)
| false | 54.545455 |
[
"-# coding: utf-8",
"-# Your code here!",
"-cou = 0",
"-for i in h:",
"- if K <= i:",
"- cou += 1",
"+cou = len([i for i in h if i >= K])"
] | false | 0.045948 | 0.035502 | 1.294225 |
[
"s695793350",
"s096041610"
] |
u972591645
|
p02630
|
python
|
s916070316
|
s053867320
| 592 | 391 | 24,144 | 40,412 |
Accepted
|
Accepted
| 33.95 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
counter = Counter(a)
sum_res = sum(a) # はじめの合計、名前がsumだとsum関数とかぶってよくないので
# q回操作します。ループ変数は使わないので_とします(Pythonの慣習)
for _ in range(q):
before, after = list(map(int, input().split()))
# 合計を変更します
sum_res -= before * counter[before]
sum_res += after * counter[before]
# 個数を変更します
counter[after] += counter[before]
counter[before] = 0
print(sum_res)
|
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
bc = [list(map(int, input().split())) for _ in range(q)]
cou = Counter(a)
s = sum(a)
for b, c in bc:
s = s + cou[b]*(c-b)
cou[c] += cou[b]
cou[b] = 0
print(s)
| 22 | 15 | 495 | 293 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
counter = Counter(a)
sum_res = sum(a) # はじめの合計、名前がsumだとsum関数とかぶってよくないので
# q回操作します。ループ変数は使わないので_とします(Pythonの慣習)
for _ in range(q):
before, after = list(map(int, input().split()))
# 合計を変更します
sum_res -= before * counter[before]
sum_res += after * counter[before]
# 個数を変更します
counter[after] += counter[before]
counter[before] = 0
print(sum_res)
|
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
bc = [list(map(int, input().split())) for _ in range(q)]
cou = Counter(a)
s = sum(a)
for b, c in bc:
s = s + cou[b] * (c - b)
cou[c] += cou[b]
cou[b] = 0
print(s)
| false | 31.818182 |
[
"-counter = Counter(a)",
"-sum_res = sum(a) # はじめの合計、名前がsumだとsum関数とかぶってよくないので",
"-# q回操作します。ループ変数は使わないので_とします(Pythonの慣習)",
"-for _ in range(q):",
"- before, after = list(map(int, input().split()))",
"- # 合計を変更します",
"- sum_res -= before * counter[before]",
"- sum_res += after * counter[before]",
"- # 個数を変更します",
"- counter[after] += counter[before]",
"- counter[before] = 0",
"- print(sum_res)",
"+bc = [list(map(int, input().split())) for _ in range(q)]",
"+cou = Counter(a)",
"+s = sum(a)",
"+for b, c in bc:",
"+ s = s + cou[b] * (c - b)",
"+ cou[c] += cou[b]",
"+ cou[b] = 0",
"+ print(s)"
] | false | 0.036011 | 0.055104 | 0.653518 |
[
"s916070316",
"s053867320"
] |
u883040023
|
p03325
|
python
|
s741916430
|
s496599077
| 121 | 80 | 4,148 | 4,148 |
Accepted
|
Accepted
| 33.88 |
n = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in A:
while i % 2 == 0:
i /= 2
ans += 1
print(ans)
|
n = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in A:
while i % 2 == 0:
i //= 2
ans += 1
print(ans)
| 10 | 10 | 159 | 160 |
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in A:
while i % 2 == 0:
i /= 2
ans += 1
print(ans)
|
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in A:
while i % 2 == 0:
i //= 2
ans += 1
print(ans)
| false | 0 |
[
"- i /= 2",
"+ i //= 2"
] | false | 0.036582 | 0.03643 | 1.004168 |
[
"s741916430",
"s496599077"
] |
u576432509
|
p02887
|
python
|
s736344902
|
s719946207
| 407 | 42 | 4,084 | 3,316 |
Accepted
|
Accepted
| 89.68 |
n=int(eval(input()))
s=eval(input())
if n==1:
print((1))
else:
slist=[]
for i in range(len(s)):
slist.append(s[i])
for i in range(len(s)-1,0,-1):
if slist[i-1]==slist[i]:
del slist[i]
print((len(slist)))
|
n=int(eval(input()))
s=eval(input())
icnt=1
for i in range(len(s)-1):
if s[i]!=s[i+1]:
icnt+=1
print(icnt)
| 14 | 8 | 254 | 114 |
n = int(eval(input()))
s = eval(input())
if n == 1:
print((1))
else:
slist = []
for i in range(len(s)):
slist.append(s[i])
for i in range(len(s) - 1, 0, -1):
if slist[i - 1] == slist[i]:
del slist[i]
print((len(slist)))
|
n = int(eval(input()))
s = eval(input())
icnt = 1
for i in range(len(s) - 1):
if s[i] != s[i + 1]:
icnt += 1
print(icnt)
| false | 42.857143 |
[
"-if n == 1:",
"- print((1))",
"-else:",
"- slist = []",
"- for i in range(len(s)):",
"- slist.append(s[i])",
"- for i in range(len(s) - 1, 0, -1):",
"- if slist[i - 1] == slist[i]:",
"- del slist[i]",
"- print((len(slist)))",
"+icnt = 1",
"+for i in range(len(s) - 1):",
"+ if s[i] != s[i + 1]:",
"+ icnt += 1",
"+print(icnt)"
] | false | 0.128647 | 0.043139 | 2.98218 |
[
"s736344902",
"s719946207"
] |
u790710233
|
p03031
|
python
|
s260818051
|
s325501540
| 40 | 36 | 3,064 | 3,064 |
Accepted
|
Accepted
| 10 |
n, m = list(map(int, input().split()))
ls = []
for _ in range(m):
k, *s, = [int(x)-1 for x in input().split()]
ls.append(s)
p = list(map(int, input().split()))
def base_n(x, n, zero_padding=8):
retval = [[], ['0']][x == 0]
while x > 0:
x, r = divmod(x, n)
retval.append(str(r))
cnt = zero_padding - len(retval)
pad = ['', '0'*cnt][cnt > 0]
return pad+''.join(retval[::-1])
ans = 0
for i in range(2**n):
base_2 = base_n(i, 2, n)
for j in range(m):
switchs = ls[j]
cond = p[j]
on_cnt = 0
for switch in switchs:
if int(base_2[switch]):
on_cnt += 1
if on_cnt % 2 != cond:
break
else:
ans += 1
print(ans)
|
from itertools import product
n, m = list(map(int, input().split()))
ls = []
for _ in range(m):
k, *s, = [int(x)-1 for x in input().split()]
ls.append(s)
p = list(map(int, input().split()))
it = ["01"]*n
ans = 0
for b in product(*it):
base_2 = "".join(b)
for j in range(m):
switchs = ls[j]
cond = p[j]
on_cnt = 0
for switch in switchs:
if int(base_2[switch]):
on_cnt += 1
if on_cnt % 2 != cond:
break
else:
ans += 1
print(ans)
| 35 | 24 | 782 | 557 |
n, m = list(map(int, input().split()))
ls = []
for _ in range(m):
(
k,
*s,
) = [int(x) - 1 for x in input().split()]
ls.append(s)
p = list(map(int, input().split()))
def base_n(x, n, zero_padding=8):
retval = [[], ["0"]][x == 0]
while x > 0:
x, r = divmod(x, n)
retval.append(str(r))
cnt = zero_padding - len(retval)
pad = ["", "0" * cnt][cnt > 0]
return pad + "".join(retval[::-1])
ans = 0
for i in range(2**n):
base_2 = base_n(i, 2, n)
for j in range(m):
switchs = ls[j]
cond = p[j]
on_cnt = 0
for switch in switchs:
if int(base_2[switch]):
on_cnt += 1
if on_cnt % 2 != cond:
break
else:
ans += 1
print(ans)
|
from itertools import product
n, m = list(map(int, input().split()))
ls = []
for _ in range(m):
(
k,
*s,
) = [int(x) - 1 for x in input().split()]
ls.append(s)
p = list(map(int, input().split()))
it = ["01"] * n
ans = 0
for b in product(*it):
base_2 = "".join(b)
for j in range(m):
switchs = ls[j]
cond = p[j]
on_cnt = 0
for switch in switchs:
if int(base_2[switch]):
on_cnt += 1
if on_cnt % 2 != cond:
break
else:
ans += 1
print(ans)
| false | 31.428571 |
[
"+from itertools import product",
"+",
"-",
"-",
"-def base_n(x, n, zero_padding=8):",
"- retval = [[], [\"0\"]][x == 0]",
"- while x > 0:",
"- x, r = divmod(x, n)",
"- retval.append(str(r))",
"- cnt = zero_padding - len(retval)",
"- pad = [\"\", \"0\" * cnt][cnt > 0]",
"- return pad + \"\".join(retval[::-1])",
"-",
"-",
"+it = [\"01\"] * n",
"-for i in range(2**n):",
"- base_2 = base_n(i, 2, n)",
"+for b in product(*it):",
"+ base_2 = \"\".join(b)"
] | false | 0.091209 | 0.047775 | 1.909136 |
[
"s260818051",
"s325501540"
] |
u465699806
|
p03665
|
python
|
s500365992
|
s314887975
| 465 | 166 | 100,776 | 81,496 |
Accepted
|
Accepted
| 64.3 |
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
def dump_impl(*objects):
print(*objects, file=sys.stderr)
def dump_dummy(*objects):
pass
dump = dump_impl if "DEBUG" in sys.argv else dump_dummy
def odd(n): return n & 1
def even(n): return not odd(n)
def comb(n, m):
r = 1
for i in range(1, n+1):
r *= i
for i in range(1, m+1):
r //= i
for i in range(1, n-m+1):
r //= i
return r
N, P = map(int, input().split())
A = [int(n) % 2 for n in input().split()]
cnt0 = len([a for a in A if a == 0])
cnt1 = len([a for a in A if a == 1])
ans = 0
if odd(P):
for i in range(cnt1 + 1):
if odd(i):
ans += comb(cnt1, i)
else:
for i in range(cnt1 + 1):
if even(i):
ans += comb(cnt1, i)
ans *= pow(2, cnt0)
print(ans)
|
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
def dump_impl(*objects):
print(*objects, file=sys.stderr)
def dump_dummy(*objects):
pass
dump = dump_impl if "DEBUG" in sys.argv else dump_dummy
def odd(n): return n & 1
def even(n): return not odd(n)
def comb(n, m):
r = 1
for i in range(1, n+1):
r *= i
for i in range(1, m+1):
r //= i
for i in range(1, n-m+1):
r //= i
return r
N, P = map(int, input().split())
A = [int(n) % 2 for n in input().split()]
cnt0 = len([a for a in A if a == 0])
cnt1 = len([a for a in A if a == 1])
ans = 0
if odd(P):
for i in range(cnt1 + 1):
if odd(i):
ans += comb(cnt1, i)
else:
for i in range(cnt1 + 1):
if even(i):
ans += comb(cnt1, i)
ans *= pow(2, cnt0)
print(ans)
| 52 | 53 | 963 | 991 |
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
def dump_impl(*objects):
print(*objects, file=sys.stderr)
def dump_dummy(*objects):
pass
dump = dump_impl if "DEBUG" in sys.argv else dump_dummy
def odd(n):
return n & 1
def even(n):
return not odd(n)
def comb(n, m):
r = 1
for i in range(1, n + 1):
r *= i
for i in range(1, m + 1):
r //= i
for i in range(1, n - m + 1):
r //= i
return r
N, P = map(int, input().split())
A = [int(n) % 2 for n in input().split()]
cnt0 = len([a for a in A if a == 0])
cnt1 = len([a for a in A if a == 1])
ans = 0
if odd(P):
for i in range(cnt1 + 1):
if odd(i):
ans += comb(cnt1, i)
else:
for i in range(cnt1 + 1):
if even(i):
ans += comb(cnt1, i)
ans *= pow(2, cnt0)
print(ans)
|
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
def dump_impl(*objects):
print(*objects, file=sys.stderr)
def dump_dummy(*objects):
pass
dump = dump_impl if "DEBUG" in sys.argv else dump_dummy
def odd(n):
return n & 1
def even(n):
return not odd(n)
def comb(n, m):
r = 1
for i in range(1, n + 1):
r *= i
for i in range(1, m + 1):
r //= i
for i in range(1, n - m + 1):
r //= i
return r
N, P = map(int, input().split())
A = [int(n) % 2 for n in input().split()]
cnt0 = len([a for a in A if a == 0])
cnt1 = len([a for a in A if a == 1])
ans = 0
if odd(P):
for i in range(cnt1 + 1):
if odd(i):
ans += comb(cnt1, i)
else:
for i in range(cnt1 + 1):
if even(i):
ans += comb(cnt1, i)
ans *= pow(2, cnt0)
print(ans)
| false | 1.886792 |
[
"+input = sys.stdin.readline"
] | false | 0.111602 | 0.03701 | 3.015443 |
[
"s500365992",
"s314887975"
] |
u624475441
|
p03265
|
python
|
s145611040
|
s876276351
| 21 | 17 | 3,316 | 2,940 |
Accepted
|
Accepted
| 19.05 |
import math
a,b,c,d=list(map(int,input().split()))
x=a+b*1j
y=c+d*1j
z=y-x
ans3=y+z*1j
ans4=ans3-z
print((*list(map(int,[ans3.real,ans3.imag,ans4.real,ans4.imag]))))
|
a,b,c,d=list(map(int,input().split()))
x,y=c-a,d-b
print((c-y,d+x,a-y,b+x))
| 8 | 3 | 158 | 69 |
import math
a, b, c, d = list(map(int, input().split()))
x = a + b * 1j
y = c + d * 1j
z = y - x
ans3 = y + z * 1j
ans4 = ans3 - z
print((*list(map(int, [ans3.real, ans3.imag, ans4.real, ans4.imag]))))
|
a, b, c, d = list(map(int, input().split()))
x, y = c - a, d - b
print((c - y, d + x, a - y, b + x))
| false | 62.5 |
[
"-import math",
"-",
"-x = a + b * 1j",
"-y = c + d * 1j",
"-z = y - x",
"-ans3 = y + z * 1j",
"-ans4 = ans3 - z",
"-print((*list(map(int, [ans3.real, ans3.imag, ans4.real, ans4.imag]))))",
"+x, y = c - a, d - b",
"+print((c - y, d + x, a - y, b + x))"
] | false | 0.051026 | 0.13249 | 0.385131 |
[
"s145611040",
"s876276351"
] |
u391589398
|
p03212
|
python
|
s804140806
|
s400598712
| 89 | 80 | 68,420 | 73,872 |
Accepted
|
Accepted
| 10.11 |
n = int(eval(input()))
keta = len(str(n))
if keta <= 2:
print((0))
else:
# keta-1までのパターン
ans = 0
# for k in range(3, keta):
# ans = pow(3, k) - 3 - (3*(pow(2, k) + 2))
from itertools import product
for k in range(3, keta+1):
for l in product(['3', '5', '7'], repeat=k):
if not '3' in l or not '5' in l or not '7' in l:
continue
nn = int(''.join(l))
if nn <= n:
ans += 1
print(ans)
|
n = int(eval(input()))
keta = len(str(n))
if keta <= 2:
print((0))
else:
# keta-1までのパターン
ans = 0
for k in range(3, keta):
ans += pow(3, k) - 3 - (3*(pow(2, k) - 2))
from itertools import product
for l in product(['3', '5', '7'], repeat=keta):
if not '3' in l or not '5' in l or not '7' in l:
continue
nn = int(''.join(l))
if nn <= n:
ans += 1
print(ans)
| 21 | 20 | 507 | 452 |
n = int(eval(input()))
keta = len(str(n))
if keta <= 2:
print((0))
else:
# keta-1までのパターン
ans = 0
# for k in range(3, keta):
# ans = pow(3, k) - 3 - (3*(pow(2, k) + 2))
from itertools import product
for k in range(3, keta + 1):
for l in product(["3", "5", "7"], repeat=k):
if not "3" in l or not "5" in l or not "7" in l:
continue
nn = int("".join(l))
if nn <= n:
ans += 1
print(ans)
|
n = int(eval(input()))
keta = len(str(n))
if keta <= 2:
print((0))
else:
# keta-1までのパターン
ans = 0
for k in range(3, keta):
ans += pow(3, k) - 3 - (3 * (pow(2, k) - 2))
from itertools import product
for l in product(["3", "5", "7"], repeat=keta):
if not "3" in l or not "5" in l or not "7" in l:
continue
nn = int("".join(l))
if nn <= n:
ans += 1
print(ans)
| false | 4.761905 |
[
"- # for k in range(3, keta):",
"- # ans = pow(3, k) - 3 - (3*(pow(2, k) + 2))",
"+ for k in range(3, keta):",
"+ ans += pow(3, k) - 3 - (3 * (pow(2, k) - 2))",
"- for k in range(3, keta + 1):",
"- for l in product([\"3\", \"5\", \"7\"], repeat=k):",
"- if not \"3\" in l or not \"5\" in l or not \"7\" in l:",
"- continue",
"- nn = int(\"\".join(l))",
"- if nn <= n:",
"- ans += 1",
"+ for l in product([\"3\", \"5\", \"7\"], repeat=keta):",
"+ if not \"3\" in l or not \"5\" in l or not \"7\" in l:",
"+ continue",
"+ nn = int(\"\".join(l))",
"+ if nn <= n:",
"+ ans += 1"
] | false | 0.093871 | 0.07776 | 1.207197 |
[
"s804140806",
"s400598712"
] |
u902577051
|
p03014
|
python
|
s410819774
|
s020382859
| 1,164 | 978 | 184,708 | 266,576 |
Accepted
|
Accepted
| 15.98 |
# -*- coding: utf-8 -*-
h, w = list(map(int, input().split()))
s = [eval(input()) for i in range(h)]
l = [[0 for j in range(w)] for i in range(h)]
r = [[0 for j in range(w)] for i in range(h)]
u = [[0 for j in range(w)] for i in range(h)]
d = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
for j in range(w):
l[i][j] = 0 if s[i][j] == '#' else 1 + (0 if j == 0 else l[i][j - 1])
for j in range(w - 1, -1, -1):
r[i][j] = 0 if s[i][j] == '#' else 1 + (0 if j == w - 1 else r[i][j + 1])
for j in range(w):
for i in range(h):
u[i][j] = 0 if s[i][j] == '#' else 1 + (0 if i == 0 else u[i - 1][j])
for i in range(h - 1, -1, -1):
d[i][j] = 0 if s[i][j] == '#' else 1 + (0 if i == h - 1 else d[i + 1][j])
ans = 0
for i in range(h):
for j in range(w):
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
print(ans)
|
# -*- coding: utf-8 -*-
import numpy as np
h, w = list(map(int, input().split()))
s = [list(eval(input())) for i in range(h)]
b = np.array(s)
b = np.where(b == '.', 1, 0)
u = np.zeros((h, w), dtype=np.int)
for i in range(1, h):
u[i] += (u[i - 1] + 1) * b[i - 1]
d = np.zeros((h, w), dtype=np.int)
for i in range(h - 2, -1, -1):
d[i] += (d[i + 1] + 1) * b[i + 1]
l = np.zeros((h, w), dtype=np.int)
for j in range(1, w):
l[:, j] += (l[:, j - 1] + 1) * b[:, j - 1]
r = np.zeros((h, w), dtype=np.int)
for j in range(w - 2, -1, -1):
r[:, j] += (r[:, j + 1] + 1) * b[:, j + 1]
print((((u + d + l + r) * b).max() + 1))
| 26 | 26 | 902 | 645 |
# -*- coding: utf-8 -*-
h, w = list(map(int, input().split()))
s = [eval(input()) for i in range(h)]
l = [[0 for j in range(w)] for i in range(h)]
r = [[0 for j in range(w)] for i in range(h)]
u = [[0 for j in range(w)] for i in range(h)]
d = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
for j in range(w):
l[i][j] = 0 if s[i][j] == "#" else 1 + (0 if j == 0 else l[i][j - 1])
for j in range(w - 1, -1, -1):
r[i][j] = 0 if s[i][j] == "#" else 1 + (0 if j == w - 1 else r[i][j + 1])
for j in range(w):
for i in range(h):
u[i][j] = 0 if s[i][j] == "#" else 1 + (0 if i == 0 else u[i - 1][j])
for i in range(h - 1, -1, -1):
d[i][j] = 0 if s[i][j] == "#" else 1 + (0 if i == h - 1 else d[i + 1][j])
ans = 0
for i in range(h):
for j in range(w):
ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
print(ans)
|
# -*- coding: utf-8 -*-
import numpy as np
h, w = list(map(int, input().split()))
s = [list(eval(input())) for i in range(h)]
b = np.array(s)
b = np.where(b == ".", 1, 0)
u = np.zeros((h, w), dtype=np.int)
for i in range(1, h):
u[i] += (u[i - 1] + 1) * b[i - 1]
d = np.zeros((h, w), dtype=np.int)
for i in range(h - 2, -1, -1):
d[i] += (d[i + 1] + 1) * b[i + 1]
l = np.zeros((h, w), dtype=np.int)
for j in range(1, w):
l[:, j] += (l[:, j - 1] + 1) * b[:, j - 1]
r = np.zeros((h, w), dtype=np.int)
for j in range(w - 2, -1, -1):
r[:, j] += (r[:, j + 1] + 1) * b[:, j + 1]
print((((u + d + l + r) * b).max() + 1))
| false | 0 |
[
"+import numpy as np",
"+",
"-s = [eval(input()) for i in range(h)]",
"-l = [[0 for j in range(w)] for i in range(h)]",
"-r = [[0 for j in range(w)] for i in range(h)]",
"-u = [[0 for j in range(w)] for i in range(h)]",
"-d = [[0 for j in range(w)] for i in range(h)]",
"-for i in range(h):",
"- for j in range(w):",
"- l[i][j] = 0 if s[i][j] == \"#\" else 1 + (0 if j == 0 else l[i][j - 1])",
"- for j in range(w - 1, -1, -1):",
"- r[i][j] = 0 if s[i][j] == \"#\" else 1 + (0 if j == w - 1 else r[i][j + 1])",
"-for j in range(w):",
"- for i in range(h):",
"- u[i][j] = 0 if s[i][j] == \"#\" else 1 + (0 if i == 0 else u[i - 1][j])",
"- for i in range(h - 1, -1, -1):",
"- d[i][j] = 0 if s[i][j] == \"#\" else 1 + (0 if i == h - 1 else d[i + 1][j])",
"-ans = 0",
"-for i in range(h):",
"- for j in range(w):",
"- ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)",
"-print(ans)",
"+s = [list(eval(input())) for i in range(h)]",
"+b = np.array(s)",
"+b = np.where(b == \".\", 1, 0)",
"+u = np.zeros((h, w), dtype=np.int)",
"+for i in range(1, h):",
"+ u[i] += (u[i - 1] + 1) * b[i - 1]",
"+d = np.zeros((h, w), dtype=np.int)",
"+for i in range(h - 2, -1, -1):",
"+ d[i] += (d[i + 1] + 1) * b[i + 1]",
"+l = np.zeros((h, w), dtype=np.int)",
"+for j in range(1, w):",
"+ l[:, j] += (l[:, j - 1] + 1) * b[:, j - 1]",
"+r = np.zeros((h, w), dtype=np.int)",
"+for j in range(w - 2, -1, -1):",
"+ r[:, j] += (r[:, j + 1] + 1) * b[:, j + 1]",
"+print((((u + d + l + r) * b).max() + 1))"
] | false | 0.046922 | 0.779647 | 0.060183 |
[
"s410819774",
"s020382859"
] |
u279460955
|
p03297
|
python
|
s074445189
|
s800025807
| 72 | 66 | 68,224 | 67,988 |
Accepted
|
Accepted
| 8.33 |
from math import gcd
t = int(eval(input()))
queries = [tuple(int(x) for x in input().split()) for _ in range(t)]
for a, b, c, d in queries:
if a < b:
print("No")
continue
if b > d:
print("No")
continue
if b - c <= 1:
print("Yes")
continue
g = gcd(-b, d)
if g == 1 or b - c > g:
print("No")
else:
m = a - ((a - c) // g) * g
if c < m < b:
print("No")
else:
print("Yes")
|
from math import gcd
t = int(eval(input()))
queries = [tuple(int(x) for x in input().split()) for _ in range(t)]
for a, b, c, d in queries:
if a < b:
print("No")
continue
if b > d:
print("No")
continue
if b - c <= 1:
print("Yes")
continue
g = gcd(b, d)
m = a + ((b - a) // g) * g
if m >= b:
m -= g
if c < m:
print("No")
else:
print("Yes")
| 24 | 23 | 515 | 461 |
from math import gcd
t = int(eval(input()))
queries = [tuple(int(x) for x in input().split()) for _ in range(t)]
for a, b, c, d in queries:
if a < b:
print("No")
continue
if b > d:
print("No")
continue
if b - c <= 1:
print("Yes")
continue
g = gcd(-b, d)
if g == 1 or b - c > g:
print("No")
else:
m = a - ((a - c) // g) * g
if c < m < b:
print("No")
else:
print("Yes")
|
from math import gcd
t = int(eval(input()))
queries = [tuple(int(x) for x in input().split()) for _ in range(t)]
for a, b, c, d in queries:
if a < b:
print("No")
continue
if b > d:
print("No")
continue
if b - c <= 1:
print("Yes")
continue
g = gcd(b, d)
m = a + ((b - a) // g) * g
if m >= b:
m -= g
if c < m:
print("No")
else:
print("Yes")
| false | 4.166667 |
[
"- g = gcd(-b, d)",
"- if g == 1 or b - c > g:",
"+ g = gcd(b, d)",
"+ m = a + ((b - a) // g) * g",
"+ if m >= b:",
"+ m -= g",
"+ if c < m:",
"- m = a - ((a - c) // g) * g",
"- if c < m < b:",
"- print(\"No\")",
"- else:",
"- print(\"Yes\")",
"+ print(\"Yes\")"
] | false | 0.107174 | 0.050434 | 2.125062 |
[
"s074445189",
"s800025807"
] |
u038021590
|
p03286
|
python
|
s093037400
|
s370585807
| 175 | 62 | 38,384 | 61,992 |
Accepted
|
Accepted
| 64.57 |
N = int(eval(input()))
if N == 0:
print((0))
exit()
elif N == 1:
print((1))
exit()
DP = [(0,1)]
num = 0
start = 0
end = 1
while True:
num += 1
a = end - start + 1
if num % 2 == 0:
start_ = end + 1
end_ = start_ + a - 1
end = end_
else:
end_ = start - 1
start_ = end_ - a + 1
start = start_
DP.append((start_, end_))
if start <= N <= end:
break
Ans = ''
DP[0] = (1, 1)
for i, (start, end) in enumerate(DP[::-1]):
if start <= N <= end:
Ans += '1'
N -= (-2) ** (num-i)
else:
Ans += '0'
print(Ans)
|
N = int(eval(input()))
start = 0
end = 1
Judge = [(1, 1)]
for i in range(1, abs(N)):
start_ = start + (-2) ** i
end_ = end + (-2) ** i
Judge.append((start_, end_))
start = min(start, start_)
end = max(end, end_)
if start <= N <= end:
break
n = len(Judge)
A = ['0'] * n
for i in range(n)[::-1]:
start, end = Judge[i]
if start <= N <= end:
A[i] = '1'
N -= (-2) ** i
print((''.join(A[::-1])))
| 37 | 22 | 651 | 461 |
N = int(eval(input()))
if N == 0:
print((0))
exit()
elif N == 1:
print((1))
exit()
DP = [(0, 1)]
num = 0
start = 0
end = 1
while True:
num += 1
a = end - start + 1
if num % 2 == 0:
start_ = end + 1
end_ = start_ + a - 1
end = end_
else:
end_ = start - 1
start_ = end_ - a + 1
start = start_
DP.append((start_, end_))
if start <= N <= end:
break
Ans = ""
DP[0] = (1, 1)
for i, (start, end) in enumerate(DP[::-1]):
if start <= N <= end:
Ans += "1"
N -= (-2) ** (num - i)
else:
Ans += "0"
print(Ans)
|
N = int(eval(input()))
start = 0
end = 1
Judge = [(1, 1)]
for i in range(1, abs(N)):
start_ = start + (-2) ** i
end_ = end + (-2) ** i
Judge.append((start_, end_))
start = min(start, start_)
end = max(end, end_)
if start <= N <= end:
break
n = len(Judge)
A = ["0"] * n
for i in range(n)[::-1]:
start, end = Judge[i]
if start <= N <= end:
A[i] = "1"
N -= (-2) ** i
print(("".join(A[::-1])))
| false | 40.540541 |
[
"-if N == 0:",
"- print((0))",
"- exit()",
"-elif N == 1:",
"- print((1))",
"- exit()",
"-DP = [(0, 1)]",
"-num = 0",
"-while True:",
"- num += 1",
"- a = end - start + 1",
"- if num % 2 == 0:",
"- start_ = end + 1",
"- end_ = start_ + a - 1",
"- end = end_",
"- else:",
"- end_ = start - 1",
"- start_ = end_ - a + 1",
"- start = start_",
"- DP.append((start_, end_))",
"+Judge = [(1, 1)]",
"+for i in range(1, abs(N)):",
"+ start_ = start + (-2) ** i",
"+ end_ = end + (-2) ** i",
"+ Judge.append((start_, end_))",
"+ start = min(start, start_)",
"+ end = max(end, end_)",
"-Ans = \"\"",
"-DP[0] = (1, 1)",
"-for i, (start, end) in enumerate(DP[::-1]):",
"+n = len(Judge)",
"+A = [\"0\"] * n",
"+for i in range(n)[::-1]:",
"+ start, end = Judge[i]",
"- Ans += \"1\"",
"- N -= (-2) ** (num - i)",
"- else:",
"- Ans += \"0\"",
"-print(Ans)",
"+ A[i] = \"1\"",
"+ N -= (-2) ** i",
"+print((\"\".join(A[::-1])))"
] | false | 0.03647 | 0.085599 | 0.426056 |
[
"s093037400",
"s370585807"
] |
u803647747
|
p03487
|
python
|
s314331214
|
s940855423
| 180 | 77 | 24,188 | 18,676 |
Accepted
|
Accepted
| 57.22 |
N = int(eval(input()))
sort_a_list = sorted(list(map(int, input().split())))
sort_dict = {}
for i in sort_a_list:
if i not in list(sort_dict.keys()):
sort_dict[i] = [i]
else:
sort_dict[i].append(i)
remove_counter = 0
for key, value in list(sort_dict.items()):
if len(value) < key:
remove_counter += len(value)
elif len(value) == key:
pass
else:
remove_counter +=(len(value) - key)
print(remove_counter)
|
import collections
N = int(eval(input()))
a_list = list(map(int, input().split()))
sort_dict = collections.Counter(a_list)
remove_counter = 0
for key, value in list(sort_dict.items()):
if value < key:
remove_counter += value
else:
remove_counter += (value - key)
print(remove_counter)
| 20 | 12 | 482 | 313 |
N = int(eval(input()))
sort_a_list = sorted(list(map(int, input().split())))
sort_dict = {}
for i in sort_a_list:
if i not in list(sort_dict.keys()):
sort_dict[i] = [i]
else:
sort_dict[i].append(i)
remove_counter = 0
for key, value in list(sort_dict.items()):
if len(value) < key:
remove_counter += len(value)
elif len(value) == key:
pass
else:
remove_counter += len(value) - key
print(remove_counter)
|
import collections
N = int(eval(input()))
a_list = list(map(int, input().split()))
sort_dict = collections.Counter(a_list)
remove_counter = 0
for key, value in list(sort_dict.items()):
if value < key:
remove_counter += value
else:
remove_counter += value - key
print(remove_counter)
| false | 40 |
[
"+import collections",
"+",
"-sort_a_list = sorted(list(map(int, input().split())))",
"-sort_dict = {}",
"-for i in sort_a_list:",
"- if i not in list(sort_dict.keys()):",
"- sort_dict[i] = [i]",
"- else:",
"- sort_dict[i].append(i)",
"+a_list = list(map(int, input().split()))",
"+sort_dict = collections.Counter(a_list)",
"- if len(value) < key:",
"- remove_counter += len(value)",
"- elif len(value) == key:",
"- pass",
"+ if value < key:",
"+ remove_counter += value",
"- remove_counter += len(value) - key",
"+ remove_counter += value - key"
] | false | 0.052484 | 0.054046 | 0.97109 |
[
"s314331214",
"s940855423"
] |
u185896732
|
p03219
|
python
|
s386952099
|
s899374689
| 172 | 17 | 38,256 | 2,940 |
Accepted
|
Accepted
| 90.12 |
x,y=list(map(int,input().split()))
print((x+y//2))
|
import sys
input=sys.stdin.readline
x,y=list(map(int,input().split()))
print((x+y//2))
| 2 | 5 | 43 | 83 |
x, y = list(map(int, input().split()))
print((x + y // 2))
|
import sys
input = sys.stdin.readline
x, y = list(map(int, input().split()))
print((x + y // 2))
| false | 60 |
[
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.047123 | 0.082105 | 0.573937 |
[
"s386952099",
"s899374689"
] |
u150984829
|
p02239
|
python
|
s095516121
|
s803889574
| 40 | 20 | 6,884 | 5,624 |
Accepted
|
Accepted
| 50 |
import queue
def s():
N=int(eval(input()))
M=[input().split()[2:]for _ in[0]*N]
q=queue.Queue();q.put(0)
d=[-1]*N;d[0]=0
while not q.empty():
u=q.get()
for v in M[u]:
v=int(v)-1
if d[v]<0:d[v]=d[u]+1;q.put(v)
for i in range(N):print((i+1,d[i]))
if'__main__'==__name__:s()
|
N=int(eval(input()))
M=[input().split()[2:]for _ in[0]*N]
q=[0]
d=[-1]*N;d[0]=0
while q:
u=q.pop(0)
for v in M[u]:
v=int(v)-1
if d[v]<0:d[v]=d[u]+1;q+=[v]
for i in range(N):print((i+1,d[i]))
| 13 | 10 | 292 | 198 |
import queue
def s():
N = int(eval(input()))
M = [input().split()[2:] for _ in [0] * N]
q = queue.Queue()
q.put(0)
d = [-1] * N
d[0] = 0
while not q.empty():
u = q.get()
for v in M[u]:
v = int(v) - 1
if d[v] < 0:
d[v] = d[u] + 1
q.put(v)
for i in range(N):
print((i + 1, d[i]))
if "__main__" == __name__:
s()
|
N = int(eval(input()))
M = [input().split()[2:] for _ in [0] * N]
q = [0]
d = [-1] * N
d[0] = 0
while q:
u = q.pop(0)
for v in M[u]:
v = int(v) - 1
if d[v] < 0:
d[v] = d[u] + 1
q += [v]
for i in range(N):
print((i + 1, d[i]))
| false | 23.076923 |
[
"-import queue",
"-",
"-",
"-def s():",
"- N = int(eval(input()))",
"- M = [input().split()[2:] for _ in [0] * N]",
"- q = queue.Queue()",
"- q.put(0)",
"- d = [-1] * N",
"- d[0] = 0",
"- while not q.empty():",
"- u = q.get()",
"- for v in M[u]:",
"- v = int(v) - 1",
"- if d[v] < 0:",
"- d[v] = d[u] + 1",
"- q.put(v)",
"- for i in range(N):",
"- print((i + 1, d[i]))",
"-",
"-",
"-if \"__main__\" == __name__:",
"- s()",
"+N = int(eval(input()))",
"+M = [input().split()[2:] for _ in [0] * N]",
"+q = [0]",
"+d = [-1] * N",
"+d[0] = 0",
"+while q:",
"+ u = q.pop(0)",
"+ for v in M[u]:",
"+ v = int(v) - 1",
"+ if d[v] < 0:",
"+ d[v] = d[u] + 1",
"+ q += [v]",
"+for i in range(N):",
"+ print((i + 1, d[i]))"
] | false | 0.045843 | 0.042228 | 1.08562 |
[
"s095516121",
"s803889574"
] |
u301523983
|
p02819
|
python
|
s471107329
|
s512243505
| 39 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 56.41 |
# -*- Coding: utf-8 -*-
x = int(eval(input()))
min_sosu = x
flg_found = False
for i in range(x, 1000000):
for j in range(2, i*i):
if i%j == 0 and j < x:
break
if i%j == 0 and j >= x and i == j:
min_sosu = i
flg_found = True
print(min_sosu)
break
if flg_found:
break
|
# -*- Coding: utf-8 -*-
import math
def is_prime(x):
if x <=1:
return False
for i in range(2, int(math.sqrt(x)+1)):
if x%i == 0:
return False
return True
x = int(eval(input()))
while(not is_prime(x)): x+=1
print(x)
| 17 | 18 | 370 | 275 |
# -*- Coding: utf-8 -*-
x = int(eval(input()))
min_sosu = x
flg_found = False
for i in range(x, 1000000):
for j in range(2, i * i):
if i % j == 0 and j < x:
break
if i % j == 0 and j >= x and i == j:
min_sosu = i
flg_found = True
print(min_sosu)
break
if flg_found:
break
|
# -*- Coding: utf-8 -*-
import math
def is_prime(x):
if x <= 1:
return False
for i in range(2, int(math.sqrt(x) + 1)):
if x % i == 0:
return False
return True
x = int(eval(input()))
while not is_prime(x):
x += 1
print(x)
| false | 5.555556 |
[
"+import math",
"+",
"+",
"+def is_prime(x):",
"+ if x <= 1:",
"+ return False",
"+ for i in range(2, int(math.sqrt(x) + 1)):",
"+ if x % i == 0:",
"+ return False",
"+ return True",
"+",
"+",
"-min_sosu = x",
"-flg_found = False",
"-for i in range(x, 1000000):",
"- for j in range(2, i * i):",
"- if i % j == 0 and j < x:",
"- break",
"- if i % j == 0 and j >= x and i == j:",
"- min_sosu = i",
"- flg_found = True",
"- print(min_sosu)",
"- break",
"- if flg_found:",
"- break",
"+while not is_prime(x):",
"+ x += 1",
"+print(x)"
] | false | 0.122699 | 0.007287 | 16.838699 |
[
"s471107329",
"s512243505"
] |
u597455618
|
p02720
|
python
|
s343187785
|
s117883938
| 102 | 74 | 18,868 | 11,912 |
Accepted
|
Accepted
| 27.45 |
import collections
k = int(eval(input()))
Q = collections.deque([int(i) for i in range(1, 10)])
for _ in range(k):
x = Q.popleft()
if x%10:
Q.append(10*x + x%10 - 1)
Q.append(10*x + x%10)
if x%10 != 9:
Q.append(10*x + x%10 + 1)
print(x)
|
import collections
k = int(eval(input()))
Q = collections.deque([int(i) for i in range(1, 10)])
chk = False
for i in range(k):
x = Q.popleft()
if i + len(Q) > k:
chk = True
if chk:
continue
else:
if x%10:
Q.append(10*x + x%10 - 1)
Q.append(10*x + x%10)
if x%10 != 9:
Q.append(10*x + x%10 + 1)
print(x)
| 12 | 18 | 275 | 394 |
import collections
k = int(eval(input()))
Q = collections.deque([int(i) for i in range(1, 10)])
for _ in range(k):
x = Q.popleft()
if x % 10:
Q.append(10 * x + x % 10 - 1)
Q.append(10 * x + x % 10)
if x % 10 != 9:
Q.append(10 * x + x % 10 + 1)
print(x)
|
import collections
k = int(eval(input()))
Q = collections.deque([int(i) for i in range(1, 10)])
chk = False
for i in range(k):
x = Q.popleft()
if i + len(Q) > k:
chk = True
if chk:
continue
else:
if x % 10:
Q.append(10 * x + x % 10 - 1)
Q.append(10 * x + x % 10)
if x % 10 != 9:
Q.append(10 * x + x % 10 + 1)
print(x)
| false | 33.333333 |
[
"-for _ in range(k):",
"+chk = False",
"+for i in range(k):",
"- if x % 10:",
"- Q.append(10 * x + x % 10 - 1)",
"- Q.append(10 * x + x % 10)",
"- if x % 10 != 9:",
"- Q.append(10 * x + x % 10 + 1)",
"+ if i + len(Q) > k:",
"+ chk = True",
"+ if chk:",
"+ continue",
"+ else:",
"+ if x % 10:",
"+ Q.append(10 * x + x % 10 - 1)",
"+ Q.append(10 * x + x % 10)",
"+ if x % 10 != 9:",
"+ Q.append(10 * x + x % 10 + 1)"
] | false | 0.082452 | 0.058953 | 1.398618 |
[
"s343187785",
"s117883938"
] |
u480138356
|
p03329
|
python
|
s146209939
|
s566202185
| 432 | 205 | 3,828 | 3,064 |
Accepted
|
Accepted
| 52.55 |
import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
ind = [1]
tmp = 6
while tmp <= N:
ind.append(tmp)
tmp *= 6
tmp = 9
while tmp <= N:
ind.append(tmp)
tmp *= 9
ind = sorted(ind)
INF = int(1e9)
dp = [INF] * (N+1)
dp[0] = 0
for i in range(1, N+1):
for t in ind:
if i - t >= 0:
dp[i] = min(dp[i], dp[i-t]+1)
else:
break
# print(dp[:20])
print((dp[N]))
if __name__ == "__main__":
main()
|
import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
ans = N
for i in range(N+1):# 6^pで何円引き出すか
count = 0
tmp = i
while tmp > 0:
count += tmp % 6
tmp //= 6
tmp = N - i
while tmp > 0:
count += tmp % 9
tmp //= 9
ans = min(ans, count)
print(ans)
if __name__ == "__main__":
main()
| 31 | 21 | 585 | 427 |
import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
ind = [1]
tmp = 6
while tmp <= N:
ind.append(tmp)
tmp *= 6
tmp = 9
while tmp <= N:
ind.append(tmp)
tmp *= 9
ind = sorted(ind)
INF = int(1e9)
dp = [INF] * (N + 1)
dp[0] = 0
for i in range(1, N + 1):
for t in ind:
if i - t >= 0:
dp[i] = min(dp[i], dp[i - t] + 1)
else:
break
# print(dp[:20])
print((dp[N]))
if __name__ == "__main__":
main()
|
import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
ans = N
for i in range(N + 1): # 6^pで何円引き出すか
count = 0
tmp = i
while tmp > 0:
count += tmp % 6
tmp //= 6
tmp = N - i
while tmp > 0:
count += tmp % 9
tmp //= 9
ans = min(ans, count)
print(ans)
if __name__ == "__main__":
main()
| false | 32.258065 |
[
"- ind = [1]",
"- tmp = 6",
"- while tmp <= N:",
"- ind.append(tmp)",
"- tmp *= 6",
"- tmp = 9",
"- while tmp <= N:",
"- ind.append(tmp)",
"- tmp *= 9",
"- ind = sorted(ind)",
"- INF = int(1e9)",
"- dp = [INF] * (N + 1)",
"- dp[0] = 0",
"- for i in range(1, N + 1):",
"- for t in ind:",
"- if i - t >= 0:",
"- dp[i] = min(dp[i], dp[i - t] + 1)",
"- else:",
"- break",
"- # print(dp[:20])",
"- print((dp[N]))",
"+ ans = N",
"+ for i in range(N + 1): # 6^pで何円引き出すか",
"+ count = 0",
"+ tmp = i",
"+ while tmp > 0:",
"+ count += tmp % 6",
"+ tmp //= 6",
"+ tmp = N - i",
"+ while tmp > 0:",
"+ count += tmp % 9",
"+ tmp //= 9",
"+ ans = min(ans, count)",
"+ print(ans)"
] | false | 0.080439 | 0.132506 | 0.607062 |
[
"s146209939",
"s566202185"
] |
u075012704
|
p03946
|
python
|
s516085755
|
s847661415
| 87 | 75 | 14,244 | 15,060 |
Accepted
|
Accepted
| 13.79 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
maxp = 0
minv = float('inf')
ans = 0
for a in A:
p = a - minv
if p > maxp:
maxp = p
ans = 1
elif p == maxp:
ans += 1
minv = min(minv, a)
print(ans)
|
from itertools import accumulate
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
MIN_Acc = list(accumulate(A, func=min))
Profits = [A[i] - MIN_Acc[i] for i in range(N)]
MAX_Profit = max(Profits)
ans = Profits.count(MAX_Profit)
print(ans)
| 17 | 10 | 275 | 270 |
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
maxp = 0
minv = float("inf")
ans = 0
for a in A:
p = a - minv
if p > maxp:
maxp = p
ans = 1
elif p == maxp:
ans += 1
minv = min(minv, a)
print(ans)
|
from itertools import accumulate
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))
MIN_Acc = list(accumulate(A, func=min))
Profits = [A[i] - MIN_Acc[i] for i in range(N)]
MAX_Profit = max(Profits)
ans = Profits.count(MAX_Profit)
print(ans)
| false | 41.176471 |
[
"+from itertools import accumulate",
"+",
"-maxp = 0",
"-minv = float(\"inf\")",
"-ans = 0",
"-for a in A:",
"- p = a - minv",
"- if p > maxp:",
"- maxp = p",
"- ans = 1",
"- elif p == maxp:",
"- ans += 1",
"- minv = min(minv, a)",
"+MIN_Acc = list(accumulate(A, func=min))",
"+Profits = [A[i] - MIN_Acc[i] for i in range(N)]",
"+MAX_Profit = max(Profits)",
"+ans = Profits.count(MAX_Profit)"
] | false | 0.042721 | 0.039696 | 1.076218 |
[
"s516085755",
"s847661415"
] |
u310381103
|
p03493
|
python
|
s122062033
|
s453255674
| 173 | 32 | 38,256 | 9,064 |
Accepted
|
Accepted
| 81.5 |
test=list(eval(input()))
sum=0
for i in range(3):
if test[i]=='1':
sum += 1
print(sum)
|
s=list(eval(input()))
print((s.count("1")))
| 6 | 2 | 89 | 36 |
test = list(eval(input()))
sum = 0
for i in range(3):
if test[i] == "1":
sum += 1
print(sum)
|
s = list(eval(input()))
print((s.count("1")))
| false | 66.666667 |
[
"-test = list(eval(input()))",
"-sum = 0",
"-for i in range(3):",
"- if test[i] == \"1\":",
"- sum += 1",
"-print(sum)",
"+s = list(eval(input()))",
"+print((s.count(\"1\")))"
] | false | 0.050638 | 0.070937 | 0.713847 |
[
"s122062033",
"s453255674"
] |
u864197622
|
p02734
|
python
|
s214420160
|
s284204419
| 245 | 122 | 3,512 | 3,316 |
Accepted
|
Accepted
| 50.2 |
def setM():
k = K2 // 2
while k:
m = int(("1" * (K2 - k) + "0" * (K2 + k)) * 3001, 2)
M.append((k, m, ~m, (1 << K2 + k) % P))
k //= 2
break
def modp(n):
for k, m, tm, a in M:
n = (n & tm) + ((n & m) >> K2 + k) * a
return n
K = 64
K2 = K // 2
P = 998244353
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
M = []
setM()
N, S = list(map(int, input().split()))
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
s += 1
s += s << a * K
s &= mm
s = modp(s)
ans += (s >> S * K) & mmm
print((ans % P))
|
K = 32
P = 998244353
m = int(("1" * 2 + "0" * 30) * 3001, 2)
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
pa = (1 << 30) - ((1 << 30) % P)
M = []
N, S = list(map(int, input().split()))
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
s += 1
s += s << a * K
s &= mm
s -= ((s & m) >> 30) * pa
ans += (s >> S * K) & mmm
print((ans % P))
| 32 | 20 | 604 | 380 |
def setM():
k = K2 // 2
while k:
m = int(("1" * (K2 - k) + "0" * (K2 + k)) * 3001, 2)
M.append((k, m, ~m, (1 << K2 + k) % P))
k //= 2
break
def modp(n):
for k, m, tm, a in M:
n = (n & tm) + ((n & m) >> K2 + k) * a
return n
K = 64
K2 = K // 2
P = 998244353
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
M = []
setM()
N, S = list(map(int, input().split()))
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
s += 1
s += s << a * K
s &= mm
s = modp(s)
ans += (s >> S * K) & mmm
print((ans % P))
|
K = 32
P = 998244353
m = int(("1" * 2 + "0" * 30) * 3001, 2)
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
pa = (1 << 30) - ((1 << 30) % P)
M = []
N, S = list(map(int, input().split()))
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
s += 1
s += s << a * K
s &= mm
s -= ((s & m) >> 30) * pa
ans += (s >> S * K) & mmm
print((ans % P))
| false | 37.5 |
[
"-def setM():",
"- k = K2 // 2",
"- while k:",
"- m = int((\"1\" * (K2 - k) + \"0\" * (K2 + k)) * 3001, 2)",
"- M.append((k, m, ~m, (1 << K2 + k) % P))",
"- k //= 2",
"- break",
"-",
"-",
"-def modp(n):",
"- for k, m, tm, a in M:",
"- n = (n & tm) + ((n & m) >> K2 + k) * a",
"- return n",
"-",
"-",
"-K = 64",
"-K2 = K // 2",
"+K = 32",
"+m = int((\"1\" * 2 + \"0\" * 30) * 3001, 2)",
"+pa = (1 << 30) - ((1 << 30) % P)",
"-setM()",
"- s = modp(s)",
"+ s -= ((s & m) >> 30) * pa"
] | false | 0.037011 | 0.037891 | 0.976767 |
[
"s214420160",
"s284204419"
] |
u347640436
|
p03599
|
python
|
s220151860
|
s998254048
| 1,354 | 531 | 3,064 | 3,064 |
Accepted
|
Accepted
| 60.78 |
A, B, C, D, E, F = list(map(int, input().split()))
w = []
for i in range(F // (100 * A) + 1):
for j in range(F // (100 * B) + 1):
a = (A * i + B * j) * 100
if a < F:
w.append(a)
best_concentration = -1
best_a = -1
best_b = -1
for a in w:
for i in range((F - a) // C + 1):
for j in range((F - a) // D + 1):
b = C * i + D * j
if a + b > F:
continue
if b > E * a // 100:
continue
if a + b == 0:
continue
concentration = 100 * b / (a + b)
if concentration > best_concentration:
best_concentration = concentration
best_a = a
best_b = b
print((best_a + best_b, best_b))
|
A, B, C, D, E, F = list(map(int, input().split()))
w = set()
for i in range(F // (100 * A) + 1):
for j in range(F // (100 * B) + 1):
a = (A * i + B * j) * 100
if a < F:
w.add(a)
w.remove(0)
best_concentration = -1
best_a = -1
best_b = -1
for a in w:
for i in range((F - a) // C + 1):
for j in range((F - a) // D + 1):
b = C * i + D * j
if a + b > F:
continue
if b > E * a // 100:
continue
concentration = 100 * b / (a + b)
if concentration > best_concentration:
best_concentration = concentration
best_a = a
best_b = b
print((best_a + best_b, best_b))
| 28 | 27 | 797 | 756 |
A, B, C, D, E, F = list(map(int, input().split()))
w = []
for i in range(F // (100 * A) + 1):
for j in range(F // (100 * B) + 1):
a = (A * i + B * j) * 100
if a < F:
w.append(a)
best_concentration = -1
best_a = -1
best_b = -1
for a in w:
for i in range((F - a) // C + 1):
for j in range((F - a) // D + 1):
b = C * i + D * j
if a + b > F:
continue
if b > E * a // 100:
continue
if a + b == 0:
continue
concentration = 100 * b / (a + b)
if concentration > best_concentration:
best_concentration = concentration
best_a = a
best_b = b
print((best_a + best_b, best_b))
|
A, B, C, D, E, F = list(map(int, input().split()))
w = set()
for i in range(F // (100 * A) + 1):
for j in range(F // (100 * B) + 1):
a = (A * i + B * j) * 100
if a < F:
w.add(a)
w.remove(0)
best_concentration = -1
best_a = -1
best_b = -1
for a in w:
for i in range((F - a) // C + 1):
for j in range((F - a) // D + 1):
b = C * i + D * j
if a + b > F:
continue
if b > E * a // 100:
continue
concentration = 100 * b / (a + b)
if concentration > best_concentration:
best_concentration = concentration
best_a = a
best_b = b
print((best_a + best_b, best_b))
| false | 3.571429 |
[
"-w = []",
"+w = set()",
"- w.append(a)",
"+ w.add(a)",
"+w.remove(0)",
"- if a + b == 0:",
"- continue"
] | false | 0.006073 | 0.00731 | 0.830827 |
[
"s220151860",
"s998254048"
] |
u945181840
|
p03283
|
python
|
s630777695
|
s730290901
| 600 | 371 | 98,192 | 45,732 |
Accepted
|
Accepted
| 38.17 |
import numpy as np
import sys
line = sys.stdin.readlines()
N, M, Q = list(map(int, line[0].split()))
city = np.zeros((N + 1, N + 1), dtype='int32')
L, R = np.array(list(map(str.split, line[1:M + 1])), np.int32).T
p, q = np.array(list(map(str.split, line[M + 1:])), np.int32).T
np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)
p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print(('\n'.join(answer.astype(str))))
|
import numpy as np
import sys
buf = sys.stdin.buffer
N, M, Q = list(map(int, buf.readline().split()))
city = np.zeros((N + 1, N + 1), np.int32)
LRpq = np.array(buf.read().split(), np.int32)
LR = LRpq[:2 * M]
L = LR[::2]
R = LR[1::2]
pq = LRpq[2 * M:]
p = pq[::2]
q = pq[1::2]
np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)
p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print(('\n'.join(answer.astype(str))))
| 16 | 23 | 486 | 494 |
import numpy as np
import sys
line = sys.stdin.readlines()
N, M, Q = list(map(int, line[0].split()))
city = np.zeros((N + 1, N + 1), dtype="int32")
L, R = np.array(list(map(str.split, line[1 : M + 1])), np.int32).T
p, q = np.array(list(map(str.split, line[M + 1 :])), np.int32).T
np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)
p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print(("\n".join(answer.astype(str))))
|
import numpy as np
import sys
buf = sys.stdin.buffer
N, M, Q = list(map(int, buf.readline().split()))
city = np.zeros((N + 1, N + 1), np.int32)
LRpq = np.array(buf.read().split(), np.int32)
LR = LRpq[: 2 * M]
L = LR[::2]
R = LR[1::2]
pq = LRpq[2 * M :]
p = pq[::2]
q = pq[1::2]
np.add.at(city, (L, R), 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)
p -= 1
answer = city[q, q] - city[p, q] - city[q, p] + city[p, p]
print(("\n".join(answer.astype(str))))
| false | 30.434783 |
[
"-line = sys.stdin.readlines()",
"-N, M, Q = list(map(int, line[0].split()))",
"-city = np.zeros((N + 1, N + 1), dtype=\"int32\")",
"-L, R = np.array(list(map(str.split, line[1 : M + 1])), np.int32).T",
"-p, q = np.array(list(map(str.split, line[M + 1 :])), np.int32).T",
"+buf = sys.stdin.buffer",
"+N, M, Q = list(map(int, buf.readline().split()))",
"+city = np.zeros((N + 1, N + 1), np.int32)",
"+LRpq = np.array(buf.read().split(), np.int32)",
"+LR = LRpq[: 2 * M]",
"+L = LR[::2]",
"+R = LR[1::2]",
"+pq = LRpq[2 * M :]",
"+p = pq[::2]",
"+q = pq[1::2]"
] | false | 0.687327 | 0.303474 | 2.26486 |
[
"s630777695",
"s730290901"
] |
u738622346
|
p03457
|
python
|
s077800584
|
s635807773
| 507 | 402 | 27,324 | 11,816 |
Accepted
|
Accepted
| 20.71 |
n = int(eval(input()))
points = []
for i in range(n):
points.append(list(map(int, input().split(" "))))
t_pre, x_pre, y_pre = 0, 0, 0
reachable = True
for point in points:
t, x, y = list(map(int, point))
diff_t = t - t_pre
p = x + y
p_pre = x_pre + y_pre
move = 0
for _ in range(diff_t):
move += 1 if p > (p_pre + move) else -1
if p - p_pre != move:
reachable = False
break
t_pre, x_pre, y_pre = t, x, y
print(("Yes" if reachable == True else "No"))
|
n = int(eval(input()))
t = [0]
x = [0]
y = [0]
for _ in range(n):
t_tmp, x_tmp, y_tmp = list(map(int, input().split(" ")))
t.append(t_tmp)
x.append(x_tmp)
y.append(y_tmp)
reachable = True
for j in range(1, n + 1):
dt = t[j] - t[j - 1]
dist = abs(x[j] - x[j - 1]) + abs(y[j] - y[j - 1])
if dt < dist or dist % 2 != dt % 2:
reachable = False
print(("Yes" if reachable == True else "No"))
| 23 | 18 | 521 | 427 |
n = int(eval(input()))
points = []
for i in range(n):
points.append(list(map(int, input().split(" "))))
t_pre, x_pre, y_pre = 0, 0, 0
reachable = True
for point in points:
t, x, y = list(map(int, point))
diff_t = t - t_pre
p = x + y
p_pre = x_pre + y_pre
move = 0
for _ in range(diff_t):
move += 1 if p > (p_pre + move) else -1
if p - p_pre != move:
reachable = False
break
t_pre, x_pre, y_pre = t, x, y
print(("Yes" if reachable == True else "No"))
|
n = int(eval(input()))
t = [0]
x = [0]
y = [0]
for _ in range(n):
t_tmp, x_tmp, y_tmp = list(map(int, input().split(" ")))
t.append(t_tmp)
x.append(x_tmp)
y.append(y_tmp)
reachable = True
for j in range(1, n + 1):
dt = t[j] - t[j - 1]
dist = abs(x[j] - x[j - 1]) + abs(y[j] - y[j - 1])
if dt < dist or dist % 2 != dt % 2:
reachable = False
print(("Yes" if reachable == True else "No"))
| false | 21.73913 |
[
"-points = []",
"-for i in range(n):",
"- points.append(list(map(int, input().split(\" \"))))",
"-t_pre, x_pre, y_pre = 0, 0, 0",
"+t = [0]",
"+x = [0]",
"+y = [0]",
"+for _ in range(n):",
"+ t_tmp, x_tmp, y_tmp = list(map(int, input().split(\" \")))",
"+ t.append(t_tmp)",
"+ x.append(x_tmp)",
"+ y.append(y_tmp)",
"-for point in points:",
"- t, x, y = list(map(int, point))",
"- diff_t = t - t_pre",
"- p = x + y",
"- p_pre = x_pre + y_pre",
"- move = 0",
"- for _ in range(diff_t):",
"- move += 1 if p > (p_pre + move) else -1",
"- if p - p_pre != move:",
"+for j in range(1, n + 1):",
"+ dt = t[j] - t[j - 1]",
"+ dist = abs(x[j] - x[j - 1]) + abs(y[j] - y[j - 1])",
"+ if dt < dist or dist % 2 != dt % 2:",
"- break",
"- t_pre, x_pre, y_pre = t, x, y"
] | false | 0.037127 | 0.080909 | 0.458875 |
[
"s077800584",
"s635807773"
] |
u513081876
|
p03673
|
python
|
s734587739
|
s005832491
| 347 | 129 | 26,020 | 31,428 |
Accepted
|
Accepted
| 62.82 |
N = int(input())
A = [int(i) for i in input().split()]
if N % 2 == 0:
ans = A[::-2]+A[::2]
else:
ans = A[::-2]+A[1::2]
for i in ans:
print(str(i)+' ', end='')
|
n = int(eval(input()))
a = [int(i) for i in input().split()]
if n % 2 == 0:
a1 = a[::2]
a2 = a[1::2]
a2 = a2[::-1]
ans = a2 + a1
else:
a1 = a[::2]
a1 = a1[::-1]
a2 = a[1::2]
ans = a1 + a2
ans = list(map(str, ans))
print((' '.join(ans)))
| 9 | 18 | 183 | 275 |
N = int(input())
A = [int(i) for i in input().split()]
if N % 2 == 0:
ans = A[::-2] + A[::2]
else:
ans = A[::-2] + A[1::2]
for i in ans:
print(str(i) + " ", end="")
|
n = int(eval(input()))
a = [int(i) for i in input().split()]
if n % 2 == 0:
a1 = a[::2]
a2 = a[1::2]
a2 = a2[::-1]
ans = a2 + a1
else:
a1 = a[::2]
a1 = a1[::-1]
a2 = a[1::2]
ans = a1 + a2
ans = list(map(str, ans))
print((" ".join(ans)))
| false | 50 |
[
"-N = int(input())",
"-A = [int(i) for i in input().split()]",
"-if N % 2 == 0:",
"- ans = A[::-2] + A[::2]",
"+n = int(eval(input()))",
"+a = [int(i) for i in input().split()]",
"+if n % 2 == 0:",
"+ a1 = a[::2]",
"+ a2 = a[1::2]",
"+ a2 = a2[::-1]",
"+ ans = a2 + a1",
"- ans = A[::-2] + A[1::2]",
"-for i in ans:",
"- print(str(i) + \" \", end=\"\")",
"+ a1 = a[::2]",
"+ a1 = a1[::-1]",
"+ a2 = a[1::2]",
"+ ans = a1 + a2",
"+ans = list(map(str, ans))",
"+print((\" \".join(ans)))"
] | false | 0.078377 | 0.075239 | 1.041703 |
[
"s734587739",
"s005832491"
] |
u256464928
|
p02881
|
python
|
s133209879
|
s923511299
| 269 | 168 | 3,060 | 29,028 |
Accepted
|
Accepted
| 37.55 |
N = int(eval(input()))
i = 1
ans = float("inf")
while i * i <= N:
if N % i == 0:
a = i
b = int(N / i)
ans = min(ans,(a-1) + (b-1))
i += 1
print(ans)
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N = int(read())
U = 10**6 + 100
x = np.arange(1,U,dtype=np.int64)
div = x[N%x==0]
ans = (div + (N//div)).min() - 2
print(ans)
| 10 | 12 | 167 | 272 |
N = int(eval(input()))
i = 1
ans = float("inf")
while i * i <= N:
if N % i == 0:
a = i
b = int(N / i)
ans = min(ans, (a - 1) + (b - 1))
i += 1
print(ans)
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N = int(read())
U = 10**6 + 100
x = np.arange(1, U, dtype=np.int64)
div = x[N % x == 0]
ans = (div + (N // div)).min() - 2
print(ans)
| false | 16.666667 |
[
"-N = int(eval(input()))",
"-i = 1",
"-ans = float(\"inf\")",
"-while i * i <= N:",
"- if N % i == 0:",
"- a = i",
"- b = int(N / i)",
"- ans = min(ans, (a - 1) + (b - 1))",
"- i += 1",
"+import sys",
"+",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"+import numpy as np",
"+",
"+N = int(read())",
"+U = 10**6 + 100",
"+x = np.arange(1, U, dtype=np.int64)",
"+div = x[N % x == 0]",
"+ans = (div + (N // div)).min() - 2"
] | false | 0.044049 | 0.626397 | 0.070322 |
[
"s133209879",
"s923511299"
] |
u952708174
|
p02659
|
python
|
s827157667
|
s476576046
| 27 | 24 | 9,872 | 9,940 |
Accepted
|
Accepted
| 11.11 |
def c_multiplication_3():
from decimal import Decimal
I = input().split()
A = Decimal(I[0])
B = Decimal(I[1])
return A * B // 1
print((c_multiplication_3()))
|
def c_multiplication_3():
from decimal import Decimal
A, B = [Decimal(i) for i in input().split()]
return A * B // 1
print((c_multiplication_3()))
| 8 | 6 | 183 | 162 |
def c_multiplication_3():
from decimal import Decimal
I = input().split()
A = Decimal(I[0])
B = Decimal(I[1])
return A * B // 1
print((c_multiplication_3()))
|
def c_multiplication_3():
from decimal import Decimal
A, B = [Decimal(i) for i in input().split()]
return A * B // 1
print((c_multiplication_3()))
| false | 25 |
[
"- I = input().split()",
"- A = Decimal(I[0])",
"- B = Decimal(I[1])",
"+ A, B = [Decimal(i) for i in input().split()]"
] | false | 0.033795 | 0.038748 | 0.872173 |
[
"s827157667",
"s476576046"
] |
u063596417
|
p02580
|
python
|
s399059977
|
s200614222
| 1,070 | 878 | 238,792 | 311,928 |
Accepted
|
Accepted
| 17.94 |
from collections import defaultdict
h, w, m = list(map(int, input().split()))
row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
row, col = list(map(int, input().split()))
row_dict[row] += 1
col_dict[col] += 1
row_col_dict[row].add(col)
max_row = max(row_dict.values())
max_col = max(col_dict.values())
max_rows = [k for k, v in list(row_dict.items()) if v == max_row]
max_cols = [k for k, v in list(col_dict.items()) if v == max_col]
ans = max_row + max_col - 1
flg = False
if ans < m:
for row in max_rows:
for col in max_cols:
if not col in row_col_dict[row]:
ans += 1
flg = True
break
if flg:
break
print(ans)
|
from collections import defaultdict
h, w, m = list(map(int, input().split()))
row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
row, col = list(map(int, input().split()))
row_dict[row] += 1
col_dict[col] += 1
row_col_dict[row].add(col)
max_row = max(row_dict.values())
max_col = max(col_dict.values())
max_rows = {k for k, v in list(row_dict.items()) if v == max_row}
max_cols = {k for k, v in list(col_dict.items()) if v == max_col}
ans = max_row + max_col - 1
flg = False
if ans < m:
for row in max_rows:
for col in max_cols:
if not col in row_col_dict[row]:
ans += 1
flg = True
break
if flg:
break
print(ans)
| 31 | 31 | 788 | 788 |
from collections import defaultdict
h, w, m = list(map(int, input().split()))
row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
row, col = list(map(int, input().split()))
row_dict[row] += 1
col_dict[col] += 1
row_col_dict[row].add(col)
max_row = max(row_dict.values())
max_col = max(col_dict.values())
max_rows = [k for k, v in list(row_dict.items()) if v == max_row]
max_cols = [k for k, v in list(col_dict.items()) if v == max_col]
ans = max_row + max_col - 1
flg = False
if ans < m:
for row in max_rows:
for col in max_cols:
if not col in row_col_dict[row]:
ans += 1
flg = True
break
if flg:
break
print(ans)
|
from collections import defaultdict
h, w, m = list(map(int, input().split()))
row_dict = defaultdict(int)
col_dict = defaultdict(int)
row_col_dict = defaultdict(set)
for _ in range(m):
row, col = list(map(int, input().split()))
row_dict[row] += 1
col_dict[col] += 1
row_col_dict[row].add(col)
max_row = max(row_dict.values())
max_col = max(col_dict.values())
max_rows = {k for k, v in list(row_dict.items()) if v == max_row}
max_cols = {k for k, v in list(col_dict.items()) if v == max_col}
ans = max_row + max_col - 1
flg = False
if ans < m:
for row in max_rows:
for col in max_cols:
if not col in row_col_dict[row]:
ans += 1
flg = True
break
if flg:
break
print(ans)
| false | 0 |
[
"-max_rows = [k for k, v in list(row_dict.items()) if v == max_row]",
"-max_cols = [k for k, v in list(col_dict.items()) if v == max_col]",
"+max_rows = {k for k, v in list(row_dict.items()) if v == max_row}",
"+max_cols = {k for k, v in list(col_dict.items()) if v == max_col}"
] | false | 0.03728 | 0.038102 | 0.978448 |
[
"s399059977",
"s200614222"
] |
u078349616
|
p02917
|
python
|
s171594945
|
s953851852
| 19 | 17 | 3,064 | 3,060 |
Accepted
|
Accepted
| 10.53 |
N = int(eval(input()))
b = list(map(int, input().split()))
a = []
for i in range(N-1):
if(i == 0):
a.append(b[i])
else:
if(b[i] > b[i-1]):
a.append(b[i-1])
else:
a.append(b[i])
if(i == N-2):
a.append(b[i])
print((sum(a)))
|
N = int(eval(input()))
b = list(map(int, input().split()))
a = []
a.append(b[0])
for i in range(1, N-1):
a.append(min(b[i], b[i-1]))
a.append(b[N-2])
print((sum(a)))
| 14 | 8 | 266 | 166 |
N = int(eval(input()))
b = list(map(int, input().split()))
a = []
for i in range(N - 1):
if i == 0:
a.append(b[i])
else:
if b[i] > b[i - 1]:
a.append(b[i - 1])
else:
a.append(b[i])
if i == N - 2:
a.append(b[i])
print((sum(a)))
|
N = int(eval(input()))
b = list(map(int, input().split()))
a = []
a.append(b[0])
for i in range(1, N - 1):
a.append(min(b[i], b[i - 1]))
a.append(b[N - 2])
print((sum(a)))
| false | 42.857143 |
[
"-for i in range(N - 1):",
"- if i == 0:",
"- a.append(b[i])",
"- else:",
"- if b[i] > b[i - 1]:",
"- a.append(b[i - 1])",
"- else:",
"- a.append(b[i])",
"- if i == N - 2:",
"- a.append(b[i])",
"+a.append(b[0])",
"+for i in range(1, N - 1):",
"+ a.append(min(b[i], b[i - 1]))",
"+a.append(b[N - 2])"
] | false | 0.050088 | 0.048339 | 1.036173 |
[
"s171594945",
"s953851852"
] |
u630566146
|
p02263
|
python
|
s663020439
|
s310998801
| 30 | 20 | 7,648 | 5,612 |
Accepted
|
Accepted
| 33.33 |
line = input().split()
stack = []
for i in range(len(line)):
obj = line[i]
if obj.isnumeric():
stack.append(obj)
else:
b = int(stack.pop(-1))
a = int(stack.pop(-1))
if obj == '+':
stack.append(a+b)
elif obj == '-':
stack.append(a-b)
else:
stack.append(a*b)
print((stack[0]))
|
class Stack:
def __init__(self, n):
self.n = n
self._l = [None for _ in range(self.n + 1)]
self._top = 0
def push(self, x):
if self.isFull():
raise IndexError("stack is full")
else:
self._top += 1
self._l[self._top] = x
def pop(self):
if self.isEmpty():
raise IndexError("pop from empty stack")
else:
e = self._l[self._top]
self._l[self._top] = None
self._top -= 1
return e
def isEmpty(self):
return self._top == 0
def isFull(self):
return self._top == self.n
def poland_calculator(s):
n = len(s)
stack = Stack(n)
i = 0
while i < n:
if s[i] == ' ':
i += 1
continue
elif s[i].isdigit():
sn = ''
while s[i].isdigit():
sn += s[i]
i += 1
stack.push(int(sn))
else:
b = stack.pop()
a = stack.pop()
if s[i] == '+':
e = a + b
elif s[i] == '-':
e = a - b
else:
e = a * b
stack.push(e)
i +=1
return stack.pop()
if __name__ == '__main__':
s = eval(input())
res = poland_calculator(s)
print(res)
| 16 | 62 | 383 | 1,416 |
line = input().split()
stack = []
for i in range(len(line)):
obj = line[i]
if obj.isnumeric():
stack.append(obj)
else:
b = int(stack.pop(-1))
a = int(stack.pop(-1))
if obj == "+":
stack.append(a + b)
elif obj == "-":
stack.append(a - b)
else:
stack.append(a * b)
print((stack[0]))
|
class Stack:
def __init__(self, n):
self.n = n
self._l = [None for _ in range(self.n + 1)]
self._top = 0
def push(self, x):
if self.isFull():
raise IndexError("stack is full")
else:
self._top += 1
self._l[self._top] = x
def pop(self):
if self.isEmpty():
raise IndexError("pop from empty stack")
else:
e = self._l[self._top]
self._l[self._top] = None
self._top -= 1
return e
def isEmpty(self):
return self._top == 0
def isFull(self):
return self._top == self.n
def poland_calculator(s):
n = len(s)
stack = Stack(n)
i = 0
while i < n:
if s[i] == " ":
i += 1
continue
elif s[i].isdigit():
sn = ""
while s[i].isdigit():
sn += s[i]
i += 1
stack.push(int(sn))
else:
b = stack.pop()
a = stack.pop()
if s[i] == "+":
e = a + b
elif s[i] == "-":
e = a - b
else:
e = a * b
stack.push(e)
i += 1
return stack.pop()
if __name__ == "__main__":
s = eval(input())
res = poland_calculator(s)
print(res)
| false | 74.193548 |
[
"-line = input().split()",
"-stack = []",
"-for i in range(len(line)):",
"- obj = line[i]",
"- if obj.isnumeric():",
"- stack.append(obj)",
"- else:",
"- b = int(stack.pop(-1))",
"- a = int(stack.pop(-1))",
"- if obj == \"+\":",
"- stack.append(a + b)",
"- elif obj == \"-\":",
"- stack.append(a - b)",
"+class Stack:",
"+ def __init__(self, n):",
"+ self.n = n",
"+ self._l = [None for _ in range(self.n + 1)]",
"+ self._top = 0",
"+",
"+ def push(self, x):",
"+ if self.isFull():",
"+ raise IndexError(\"stack is full\")",
"- stack.append(a * b)",
"-print((stack[0]))",
"+ self._top += 1",
"+ self._l[self._top] = x",
"+",
"+ def pop(self):",
"+ if self.isEmpty():",
"+ raise IndexError(\"pop from empty stack\")",
"+ else:",
"+ e = self._l[self._top]",
"+ self._l[self._top] = None",
"+ self._top -= 1",
"+ return e",
"+",
"+ def isEmpty(self):",
"+ return self._top == 0",
"+",
"+ def isFull(self):",
"+ return self._top == self.n",
"+",
"+",
"+def poland_calculator(s):",
"+ n = len(s)",
"+ stack = Stack(n)",
"+ i = 0",
"+ while i < n:",
"+ if s[i] == \" \":",
"+ i += 1",
"+ continue",
"+ elif s[i].isdigit():",
"+ sn = \"\"",
"+ while s[i].isdigit():",
"+ sn += s[i]",
"+ i += 1",
"+ stack.push(int(sn))",
"+ else:",
"+ b = stack.pop()",
"+ a = stack.pop()",
"+ if s[i] == \"+\":",
"+ e = a + b",
"+ elif s[i] == \"-\":",
"+ e = a - b",
"+ else:",
"+ e = a * b",
"+ stack.push(e)",
"+ i += 1",
"+ return stack.pop()",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ s = eval(input())",
"+ res = poland_calculator(s)",
"+ print(res)"
] | false | 0.05732 | 0.042809 | 1.33895 |
[
"s663020439",
"s310998801"
] |
u463775490
|
p03611
|
python
|
s741005759
|
s594708340
| 164 | 136 | 20,688 | 14,008 |
Accepted
|
Accepted
| 17.07 |
n = int(eval(input()))
a = sorted([int(i) for i in input().split()])
ans = 1
dic = {}
for i in range(10**5):
dic[i] = 0
for i in a:
dic[i] += 1
for i in range(1,10**5-1):
ans = max(ans, dic[i-1] + dic[i] + dic[i+1])
print(ans)
|
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = [0] * 10**5
ans = 1
if n == 2:
if abs(a[0] - a[1]) <= 2:
ans = 2
for i in range(n):
b[a[i]] += 1
for i in range(n-2):
ans = max(ans, b[i]+b[i+1]+b[i+2])
print(ans)
| 11 | 13 | 242 | 261 |
n = int(eval(input()))
a = sorted([int(i) for i in input().split()])
ans = 1
dic = {}
for i in range(10**5):
dic[i] = 0
for i in a:
dic[i] += 1
for i in range(1, 10**5 - 1):
ans = max(ans, dic[i - 1] + dic[i] + dic[i + 1])
print(ans)
|
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = [0] * 10**5
ans = 1
if n == 2:
if abs(a[0] - a[1]) <= 2:
ans = 2
for i in range(n):
b[a[i]] += 1
for i in range(n - 2):
ans = max(ans, b[i] + b[i + 1] + b[i + 2])
print(ans)
| false | 15.384615 |
[
"-a = sorted([int(i) for i in input().split()])",
"+a = sorted(list(map(int, input().split())))",
"+b = [0] * 10**5",
"-dic = {}",
"-for i in range(10**5):",
"- dic[i] = 0",
"-for i in a:",
"- dic[i] += 1",
"-for i in range(1, 10**5 - 1):",
"- ans = max(ans, dic[i - 1] + dic[i] + dic[i + 1])",
"+if n == 2:",
"+ if abs(a[0] - a[1]) <= 2:",
"+ ans = 2",
"+for i in range(n):",
"+ b[a[i]] += 1",
"+for i in range(n - 2):",
"+ ans = max(ans, b[i] + b[i + 1] + b[i + 2])"
] | false | 0.175107 | 0.046139 | 3.795216 |
[
"s741005759",
"s594708340"
] |
u133936772
|
p03739
|
python
|
s487282049
|
s551569883
| 93 | 84 | 14,332 | 14,084 |
Accepted
|
Accepted
| 9.68 |
eval(input())
l=list(map(int,input().split()))
def f(s):
c=t=0
for i in l:
t+=i
if s*t<=0: c+=abs(t-s); t=s
s*=-1
return c
print((min(f(1),f(-1))))
|
_,*l=list(map(int,open(0).read().split()))
def f(s):
c=t=0
for i in l:
t+=i
if s*t<=0: c+=abs(t-s); t=s
s*=-1
return c
print((min(f(1),f(-1))))
| 10 | 9 | 166 | 161 |
eval(input())
l = list(map(int, input().split()))
def f(s):
c = t = 0
for i in l:
t += i
if s * t <= 0:
c += abs(t - s)
t = s
s *= -1
return c
print((min(f(1), f(-1))))
|
_, *l = list(map(int, open(0).read().split()))
def f(s):
c = t = 0
for i in l:
t += i
if s * t <= 0:
c += abs(t - s)
t = s
s *= -1
return c
print((min(f(1), f(-1))))
| false | 10 |
[
"-eval(input())",
"-l = list(map(int, input().split()))",
"+_, *l = list(map(int, open(0).read().split()))"
] | false | 0.038667 | 0.039227 | 0.985721 |
[
"s487282049",
"s551569883"
] |
u790905630
|
p02946
|
python
|
s110040348
|
s638688251
| 19 | 17 | 3,060 | 3,060 |
Accepted
|
Accepted
| 10.53 |
K, X = map(int, input().split())
for i in range(X - (K - 1), X + K):
print(i, end=' ')
|
K, X = list(map(int, input().split()))
for i in range(X - (K - 1), X + K):
print(i)
| 3 | 3 | 92 | 83 |
K, X = map(int, input().split())
for i in range(X - (K - 1), X + K):
print(i, end=" ")
|
K, X = list(map(int, input().split()))
for i in range(X - (K - 1), X + K):
print(i)
| false | 0 |
[
"-K, X = map(int, input().split())",
"+K, X = list(map(int, input().split()))",
"- print(i, end=\" \")",
"+ print(i)"
] | false | 0.047602 | 0.0457 | 1.041614 |
[
"s110040348",
"s638688251"
] |
u079022693
|
p02883
|
python
|
s452082038
|
s536158112
| 597 | 541 | 121,036 | 119,500 |
Accepted
|
Accepted
| 9.38 |
N,K=input().split()
N,K=[int(N),int(K)]
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A=sorted(A)
F=sorted(F,reverse=True)
goal_max=10**12+1
goal_min=0-1
while(goal_max-goal_min!=1):
goal=(goal_max+goal_min)//2
counter=0
for i in range(N):
counter+=max(0,A[i]-goal//F[i])
if(counter<=K):
goal_max=goal
else:
goal_min=goal
print(goal_max)
|
def main():
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort(reverse=True)
F.sort()
l_score=-1
r_score=10**12
while l_score<r_score-1:
t_score=(l_score+r_score)//2
count=0
for i in range(N):
count+=max(0,A[i]-t_score//F[i])
if count<=K:
r_score=t_score
else:
l_score=t_score
print(r_score)
if __name__=="__main__":
main()
| 25 | 21 | 427 | 511 |
N, K = input().split()
N, K = [int(N), int(K)]
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A = sorted(A)
F = sorted(F, reverse=True)
goal_max = 10**12 + 1
goal_min = 0 - 1
while goal_max - goal_min != 1:
goal = (goal_max + goal_min) // 2
counter = 0
for i in range(N):
counter += max(0, A[i] - goal // F[i])
if counter <= K:
goal_max = goal
else:
goal_min = goal
print(goal_max)
|
def main():
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort(reverse=True)
F.sort()
l_score = -1
r_score = 10**12
while l_score < r_score - 1:
t_score = (l_score + r_score) // 2
count = 0
for i in range(N):
count += max(0, A[i] - t_score // F[i])
if count <= K:
r_score = t_score
else:
l_score = t_score
print(r_score)
if __name__ == "__main__":
main()
| false | 16 |
[
"-N, K = input().split()",
"-N, K = [int(N), int(K)]",
"-A = list(map(int, input().split()))",
"-F = list(map(int, input().split()))",
"-A = sorted(A)",
"-F = sorted(F, reverse=True)",
"-goal_max = 10**12 + 1",
"-goal_min = 0 - 1",
"-while goal_max - goal_min != 1:",
"- goal = (goal_max + goal_min) // 2",
"- counter = 0",
"- for i in range(N):",
"- counter += max(0, A[i] - goal // F[i])",
"- if counter <= K:",
"- goal_max = goal",
"- else:",
"- goal_min = goal",
"-print(goal_max)",
"+def main():",
"+ N, K = list(map(int, input().split()))",
"+ A = list(map(int, input().split()))",
"+ F = list(map(int, input().split()))",
"+ A.sort(reverse=True)",
"+ F.sort()",
"+ l_score = -1",
"+ r_score = 10**12",
"+ while l_score < r_score - 1:",
"+ t_score = (l_score + r_score) // 2",
"+ count = 0",
"+ for i in range(N):",
"+ count += max(0, A[i] - t_score // F[i])",
"+ if count <= K:",
"+ r_score = t_score",
"+ else:",
"+ l_score = t_score",
"+ print(r_score)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.036843 | 0.138358 | 0.266285 |
[
"s452082038",
"s536158112"
] |
u729133443
|
p03472
|
python
|
s671272905
|
s663933543
| 297 | 136 | 102,024 | 25,124 |
Accepted
|
Accepted
| 54.21 |
n,h,*t=list(map(int,open(0).read().split()))
b=sorted(t[1::2])
a=max(t[::2])
c=0
while h>0and b and b[-1]>a:
h-=b.pop()
c+=1
if h>0:c-=-h//a
print(c)
|
n,h,*d=list(map(int,open(0).read().split()))
a=max(d[::2])
b=sorted(d[1::2])
c=0
while b and b[-1]>a>0<h:h-=b.pop();c+=1
print((c--h*(h>0)//a))
| 9 | 6 | 159 | 140 |
n, h, *t = list(map(int, open(0).read().split()))
b = sorted(t[1::2])
a = max(t[::2])
c = 0
while h > 0 and b and b[-1] > a:
h -= b.pop()
c += 1
if h > 0:
c -= -h // a
print(c)
|
n, h, *d = list(map(int, open(0).read().split()))
a = max(d[::2])
b = sorted(d[1::2])
c = 0
while b and b[-1] > a > 0 < h:
h -= b.pop()
c += 1
print((c - -h * (h > 0) // a))
| false | 33.333333 |
[
"-n, h, *t = list(map(int, open(0).read().split()))",
"-b = sorted(t[1::2])",
"-a = max(t[::2])",
"+n, h, *d = list(map(int, open(0).read().split()))",
"+a = max(d[::2])",
"+b = sorted(d[1::2])",
"-while h > 0 and b and b[-1] > a:",
"+while b and b[-1] > a > 0 < h:",
"-if h > 0:",
"- c -= -h // a",
"-print(c)",
"+print((c - -h * (h > 0) // a))"
] | false | 0.035465 | 0.038353 | 0.924721 |
[
"s671272905",
"s663933543"
] |
u179169725
|
p02573
|
python
|
s248641765
|
s915532606
| 629 | 291 | 14,840 | 44,232 |
Accepted
|
Accepted
| 53.74 |
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline # 文字列読み込む時はこっち
ra = range
enu = enumerate
def exit(*argv, **kwarg):
print(*argv, **kwarg)
sys.exit()
def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def a_int(): return int(readline())
def ints(): return list(map(int, readline().split()))
def read_col(H):
'''H is number of rows
A列、B列が与えられるようなとき
ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合'''
ret = []
for _ in range(H):
ret.append(list(map(int, readline().split())))
return tuple(map(list, zip(*ret)))
def read_tuple(H):
'''H is number of rows'''
ret = []
for _ in range(H):
ret.append(tuple(map(int, readline().split())))
return ret
def read_matrix(H):
'''H is number of rows'''
ret = []
for _ in range(H):
ret.append(list(map(int, readline().split())))
return ret
# return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため
class UnionFind:
def __init__(self, N):
self.N = N # ノード数
self.n_groups = N # グループ数
# 親ノードをしめす。負は自身が親ということ。
self.parent = [-1] * N # idxが各ノードに対応。
def root(self, A):
# print(A)
# ノード番号を受け取って一番上の親ノードの番号を帰す
if (self.parent[A] < 0):
return A
self.parent[A] = self.root(self.parent[A]) # 経由したノードすべての親を上書き
return self.parent[A]
def size(self, A):
# ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
return -self.parent[self.root(A)]
def unite(self, A, B):
# ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
# 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
A = self.root(A)
B = self.root(B)
# すでにくっついている場合
if (A == B):
return False
# 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
if (self.size(A) < self.size(B)):
A, B = B, A
# くっつける
self.parent[A] += self.parent[B] # sizeの更新
self.parent[B] = A # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる
self.n_groups -= 1
return True
def is_in_same(self, A, B):
return self.root(A) == self.root(B)
MOD = 10**9 + 7
INF = 2**31 # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right # , insort_left, insort_right
from functools import reduce
from math import gcd
def lcm(a, b):
# 最小公倍数
g = gcd(a, b)
return a // g * b
N, M = ints()
uf = UnionFind(N)
for _ in range(M):
a, b = mina(*ints())
uf.unite(a, b)
# あとはなるべく別々になるように
# →サイズを1ずつ引いて1グループ
# いやmaxのsizeか
print(-min(uf.parent))
|
mycode = r'''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。
ctypedef long long LL
import numpy as np
from functools import partial
array=partial(np.array, dtype=np.int64)
zeros=partial(np.zeros, dtype=np.int64)
full=partial(np.full, dtype=np.int64)
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち
cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)
cdef read_matrix(LL H,LL W):
#return np.ndarray shape=(H,W) matrix
lines=[]
cdef LL _
for _ in range(H):
lines.append(read())
lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)
cdef class UnionFind:
cdef:
public LL N,n_groups
public LL[::1] parent
def __init__(self, LL N):
self.N = N # ノード数
self.n_groups = N # グループ数
# 親ノードをしめす。負は自身が親ということ。
self.parent = full(N,-1) # idxが各ノードに対応。
cdef LL root(self, LL A):
# print(A)
# ノード番号を受け取って一番上の親ノードの番号を帰す
if (self.parent[A] < 0):
return A
self.parent[A] = self.root(self.parent[A]) # 経由したノードすべての親を上書き
return self.parent[A]
cdef LL size(self, LL A):
# ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
return -self.parent[self.root(A)]
cdef bint unite(self,LL A,LL B):
# ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
# 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
A = self.root(A)
B = self.root(B)
# すでにくっついている場合
if (A == B):
return False
# 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
if (self.size(A) < self.size(B)):
A, B = B, A
# くっつける
self.parent[A] += self.parent[B] # sizeの更新
self.parent[B] = A # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる
self.n_groups -= 1
return True
cdef bint is_in_same(self,LL A,LL B):
return self.root(A) == self.root(B)
cdef LL N,M
N, M = ints()
AB=read_matrix(M,2)-1
cdef UnionFind uf = UnionFind(N)
cdef LL a,b
for a,b in AB:
uf.unite(a, b)
print(-np.min(uf.parent))
'''
import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE': # コンパイル時
with open('mycode.pyx', 'w') as f:
f.write(mycode)
os.system('cythonize -i -3 -b mycode.pyx')
import mycode
| 122 | 96 | 2,923 | 2,631 |
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline # 文字列読み込む時はこっち
ra = range
enu = enumerate
def exit(*argv, **kwarg):
print(*argv, **kwarg)
sys.exit()
def mina(*argv, sub=1):
return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def a_int():
return int(readline())
def ints():
return list(map(int, readline().split()))
def read_col(H):
"""H is number of rows
A列、B列が与えられるようなとき
ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合"""
ret = []
for _ in range(H):
ret.append(list(map(int, readline().split())))
return tuple(map(list, zip(*ret)))
def read_tuple(H):
"""H is number of rows"""
ret = []
for _ in range(H):
ret.append(tuple(map(int, readline().split())))
return ret
def read_matrix(H):
"""H is number of rows"""
ret = []
for _ in range(H):
ret.append(list(map(int, readline().split())))
return ret
# return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため
class UnionFind:
def __init__(self, N):
self.N = N # ノード数
self.n_groups = N # グループ数
# 親ノードをしめす。負は自身が親ということ。
self.parent = [-1] * N # idxが各ノードに対応。
def root(self, A):
# print(A)
# ノード番号を受け取って一番上の親ノードの番号を帰す
if self.parent[A] < 0:
return A
self.parent[A] = self.root(self.parent[A]) # 経由したノードすべての親を上書き
return self.parent[A]
def size(self, A):
# ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
return -self.parent[self.root(A)]
def unite(self, A, B):
# ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
# 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
A = self.root(A)
B = self.root(B)
# すでにくっついている場合
if A == B:
return False
# 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
if self.size(A) < self.size(B):
A, B = B, A
# くっつける
self.parent[A] += self.parent[B] # sizeの更新
self.parent[B] = A # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる
self.n_groups -= 1
return True
def is_in_same(self, A, B):
return self.root(A) == self.root(B)
MOD = 10**9 + 7
INF = 2**31 # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right # , insort_left, insort_right
from functools import reduce
from math import gcd
def lcm(a, b):
# 最小公倍数
g = gcd(a, b)
return a // g * b
N, M = ints()
uf = UnionFind(N)
for _ in range(M):
a, b = mina(*ints())
uf.unite(a, b)
# あとはなるべく別々になるように
# →サイズを1ずつ引いて1グループ
# いやmaxのsizeか
print(-min(uf.parent))
|
mycode = r"""
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。
ctypedef long long LL
import numpy as np
from functools import partial
array=partial(np.array, dtype=np.int64)
zeros=partial(np.zeros, dtype=np.int64)
full=partial(np.full, dtype=np.int64)
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち
cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)
cdef read_matrix(LL H,LL W):
#return np.ndarray shape=(H,W) matrix
lines=[]
cdef LL _
for _ in range(H):
lines.append(read())
lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)
cdef class UnionFind:
cdef:
public LL N,n_groups
public LL[::1] parent
def __init__(self, LL N):
self.N = N # ノード数
self.n_groups = N # グループ数
# 親ノードをしめす。負は自身が親ということ。
self.parent = full(N,-1) # idxが各ノードに対応。
cdef LL root(self, LL A):
# print(A)
# ノード番号を受け取って一番上の親ノードの番号を帰す
if (self.parent[A] < 0):
return A
self.parent[A] = self.root(self.parent[A]) # 経由したノードすべての親を上書き
return self.parent[A]
cdef LL size(self, LL A):
# ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
return -self.parent[self.root(A)]
cdef bint unite(self,LL A,LL B):
# ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
# 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
A = self.root(A)
B = self.root(B)
# すでにくっついている場合
if (A == B):
return False
# 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
if (self.size(A) < self.size(B)):
A, B = B, A
# くっつける
self.parent[A] += self.parent[B] # sizeの更新
self.parent[B] = A # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる
self.n_groups -= 1
return True
cdef bint is_in_same(self,LL A,LL B):
return self.root(A) == self.root(B)
cdef LL N,M
N, M = ints()
AB=read_matrix(M,2)-1
cdef UnionFind uf = UnionFind(N)
cdef LL a,b
for a,b in AB:
uf.unite(a, b)
print(-np.min(uf.parent))
"""
import sys
import os
if sys.argv[-1] == "ONLINE_JUDGE": # コンパイル時
with open("mycode.pyx", "w") as f:
f.write(mycode)
os.system("cythonize -i -3 -b mycode.pyx")
import mycode
| false | 21.311475 |
[
"+mycode = r\"\"\"",
"+# distutils: language=c++",
"+# cython: language_level=3, boundscheck=False, wraparound=False",
"+# cython: cdivision=True",
"+# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。",
"+ctypedef long long LL",
"+import numpy as np",
"+from functools import partial",
"+array=partial(np.array, dtype=np.int64)",
"+zeros=partial(np.zeros, dtype=np.int64)",
"+full=partial(np.full, dtype=np.int64)",
"-",
"-sys.setrecursionlimit(1 << 25)",
"-read = sys.stdin.readline # 文字列読み込む時はこっち",
"-ra = range",
"-enu = enumerate",
"-",
"-",
"-def exit(*argv, **kwarg):",
"- print(*argv, **kwarg)",
"- sys.exit()",
"-",
"-",
"-def mina(*argv, sub=1):",
"- return list(map(lambda x: x - sub, argv))",
"-",
"-",
"-# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと",
"-def a_int():",
"- return int(readline())",
"-",
"-",
"-def ints():",
"- return list(map(int, readline().split()))",
"-",
"-",
"-def read_col(H):",
"- \"\"\"H is number of rows",
"- A列、B列が与えられるようなとき",
"- ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合\"\"\"",
"- ret = []",
"- for _ in range(H):",
"- ret.append(list(map(int, readline().split())))",
"- return tuple(map(list, zip(*ret)))",
"-",
"-",
"-def read_tuple(H):",
"- \"\"\"H is number of rows\"\"\"",
"- ret = []",
"- for _ in range(H):",
"- ret.append(tuple(map(int, readline().split())))",
"- return ret",
"-",
"-",
"-def read_matrix(H):",
"- \"\"\"H is number of rows\"\"\"",
"- ret = []",
"- for _ in range(H):",
"- ret.append(list(map(int, readline().split())))",
"- return ret",
"- # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため",
"-",
"-",
"-class UnionFind:",
"- def __init__(self, N):",
"+read = sys.stdin.readline #文字列読み込む時はこっち",
"+cdef ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)",
"+cdef read_matrix(LL H,LL W):",
"+ #return np.ndarray shape=(H,W) matrix",
"+ lines=[]",
"+ cdef LL _",
"+ for _ in range(H):",
"+ lines.append(read())",
"+ lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで",
"+ return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)",
"+cdef class UnionFind:",
"+ cdef:",
"+ public LL N,n_groups",
"+ public LL[::1] parent",
"+ def __init__(self, LL N):",
"- self.parent = [-1] * N # idxが各ノードに対応。",
"-",
"- def root(self, A):",
"+ self.parent = full(N,-1) # idxが各ノードに対応。",
"+ cdef LL root(self, LL A):",
"- if self.parent[A] < 0:",
"+ if (self.parent[A] < 0):",
"-",
"- def size(self, A):",
"+ cdef LL size(self, LL A):",
"-",
"- def unite(self, A, B):",
"+ cdef bint unite(self,LL A,LL B):",
"- if A == B:",
"+ if (A == B):",
"- if self.size(A) < self.size(B):",
"+ if (self.size(A) < self.size(B)):",
"+ cdef bint is_in_same(self,LL A,LL B):",
"+ return self.root(A) == self.root(B)",
"+cdef LL N,M",
"+N, M = ints()",
"+AB=read_matrix(M,2)-1",
"+cdef UnionFind uf = UnionFind(N)",
"+cdef LL a,b",
"+for a,b in AB:",
"+ uf.unite(a, b)",
"+print(-np.min(uf.parent))",
"+\"\"\"",
"+import sys",
"+import os",
"- def is_in_same(self, A, B):",
"- return self.root(A) == self.root(B)",
"-",
"-",
"-MOD = 10**9 + 7",
"-INF = 2**31 # 2147483648 > 10**9",
"-# default import",
"-from collections import defaultdict, Counter, deque",
"-from operator import itemgetter, xor, add",
"-from itertools import product, permutations, combinations",
"-from bisect import bisect_left, bisect_right # , insort_left, insort_right",
"-from functools import reduce",
"-from math import gcd",
"-",
"-",
"-def lcm(a, b):",
"- # 最小公倍数",
"- g = gcd(a, b)",
"- return a // g * b",
"-",
"-",
"-N, M = ints()",
"-uf = UnionFind(N)",
"-for _ in range(M):",
"- a, b = mina(*ints())",
"- uf.unite(a, b)",
"-# あとはなるべく別々になるように",
"-# →サイズを1ずつ引いて1グループ",
"-# いやmaxのsizeか",
"-print(-min(uf.parent))",
"+if sys.argv[-1] == \"ONLINE_JUDGE\": # コンパイル時",
"+ with open(\"mycode.pyx\", \"w\") as f:",
"+ f.write(mycode)",
"+ os.system(\"cythonize -i -3 -b mycode.pyx\")",
"+import mycode"
] | false | 0.036959 | 0.075986 | 0.486389 |
[
"s248641765",
"s915532606"
] |
u168578024
|
p03061
|
python
|
s093797437
|
s889070034
| 952 | 587 | 105,504 | 81,852 |
Accepted
|
Accepted
| 38.34 |
from fractions import gcd
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
import copy
class SegmentTree:
def __init__(self, N, func, I):
self.sz = N
self.func = func
self.I = copy.deepcopy(I)
self.seg = [copy.deepcopy(I) for i in range(N * 2)]
def assign(self, k, x):
self.seg[k + self.sz] = copy.deepcopy(x)
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = copy.deepcopy(x)
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = copy.deepcopy(self.I)
R = copy.deepcopy(self.I)
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def main():
N = int(readline())
m = list(map(int, read().split()))
seg = SegmentTree(N, gcd, 0)
for i in range(N):
seg.assign(i, next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
print(ans)
main()
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd
class SegmentTree:
def __init__(self, N, func, I):
self.func = func
self.I = I
self.sz = 2**(N-1).bit_length()
self.seg = [I] * (self.sz * 2)
def assign(self, k, x):
self.seg[k + self.sz] = x
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = x
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = self.I
R = self.I
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def main():
N = int(readline())
m = list(map(int,read().split()))
seg = SegmentTree(N , gcd , 0)
for i in range(N):
seg.assign(i , next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
print(ans)
main()
| 56 | 55 | 1,493 | 1,408 |
from fractions import gcd
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
import copy
class SegmentTree:
def __init__(self, N, func, I):
self.sz = N
self.func = func
self.I = copy.deepcopy(I)
self.seg = [copy.deepcopy(I) for i in range(N * 2)]
def assign(self, k, x):
self.seg[k + self.sz] = copy.deepcopy(x)
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = copy.deepcopy(x)
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = copy.deepcopy(self.I)
R = copy.deepcopy(self.I)
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def main():
N = int(readline())
m = list(map(int, read().split()))
seg = SegmentTree(N, gcd, 0)
for i in range(N):
seg.assign(i, next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
print(ans)
main()
|
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd
class SegmentTree:
def __init__(self, N, func, I):
self.func = func
self.I = I
self.sz = 2 ** (N - 1).bit_length()
self.seg = [I] * (self.sz * 2)
def assign(self, k, x):
self.seg[k + self.sz] = x
def build(self):
for i in range(self.sz - 1, 0, -1):
self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
def update(self, k, x):
k += self.sz
self.seg[k] = x
while k > 1:
k >>= 1
self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
def query(self, a, b):
L = self.I
R = self.I
a += self.sz
b += self.sz
while a < b:
if a & 1:
L = self.func(L, self.seg[a])
a += 1
if b & 1:
b -= 1
R = self.func(self.seg[b], R)
a >>= 1
b >>= 1
return self.func(L, R)
def main():
N = int(readline())
m = list(map(int, read().split()))
seg = SegmentTree(N, gcd, 0)
for i in range(N):
seg.assign(i, next(m))
seg.build()
ans = 1
for i in range(N):
ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, N)))
print(ans)
main()
| false | 1.785714 |
[
"-from fractions import gcd",
"-import copy",
"+from fractions import gcd",
"- self.sz = N",
"- self.I = copy.deepcopy(I)",
"- self.seg = [copy.deepcopy(I) for i in range(N * 2)]",
"+ self.I = I",
"+ self.sz = 2 ** (N - 1).bit_length()",
"+ self.seg = [I] * (self.sz * 2)",
"- self.seg[k + self.sz] = copy.deepcopy(x)",
"+ self.seg[k + self.sz] = x",
"- self.seg[k] = copy.deepcopy(x)",
"+ self.seg[k] = x",
"- L = copy.deepcopy(self.I)",
"- R = copy.deepcopy(self.I)",
"+ L = self.I",
"+ R = self.I"
] | false | 0.046148 | 0.075567 | 0.610693 |
[
"s093797437",
"s889070034"
] |
u863442865
|
p03339
|
python
|
s091866195
|
s500602066
| 178 | 127 | 3,700 | 3,700 |
Accepted
|
Accepted
| 28.65 |
n = int(eval(input()))
s = eval(input())
total = s[1:].count('E')
ans = total
for i in range(n-1):
if s[i]=='W':
total += 1
if s[i+1]=='E':
total -= 1
ans = min(ans, total)
print(ans)
|
n = int(eval(input()))
s = eval(input())
total = s[1:].count('E')
ans = total
for i in range(n-1):
if s[i]=='W':
total += 1
if s[i+1]=='E':
total -= 1
if ans>total:
ans = total
print(ans)
| 11 | 12 | 210 | 221 |
n = int(eval(input()))
s = eval(input())
total = s[1:].count("E")
ans = total
for i in range(n - 1):
if s[i] == "W":
total += 1
if s[i + 1] == "E":
total -= 1
ans = min(ans, total)
print(ans)
|
n = int(eval(input()))
s = eval(input())
total = s[1:].count("E")
ans = total
for i in range(n - 1):
if s[i] == "W":
total += 1
if s[i + 1] == "E":
total -= 1
if ans > total:
ans = total
print(ans)
| false | 8.333333 |
[
"- ans = min(ans, total)",
"+ if ans > total:",
"+ ans = total"
] | false | 0.051162 | 0.051479 | 0.993842 |
[
"s091866195",
"s500602066"
] |
u130900604
|
p03387
|
python
|
s565272273
|
s257274046
| 148 | 17 | 12,488 | 3,060 |
Accepted
|
Accepted
| 88.51 |
import numpy as np
a,b,c=list(map(int,input().split()))
l=[a,b,c]
arr=np.array(l)
m=max(arr)
t=m-arr
#print(t)
s=sum(t)
if s%2==0:
ans=s//2
else:
ans=(s+3)//2
print(ans)
|
a,b,c=list(map(int,input().split()))
m=max(a,b,c)
r=m-a+m-b+m-c
if r%2==0:
ans=r//2
else:
ans=(r+3)//2
print(ans)
| 13 | 8 | 179 | 118 |
import numpy as np
a, b, c = list(map(int, input().split()))
l = [a, b, c]
arr = np.array(l)
m = max(arr)
t = m - arr
# print(t)
s = sum(t)
if s % 2 == 0:
ans = s // 2
else:
ans = (s + 3) // 2
print(ans)
|
a, b, c = list(map(int, input().split()))
m = max(a, b, c)
r = m - a + m - b + m - c
if r % 2 == 0:
ans = r // 2
else:
ans = (r + 3) // 2
print(ans)
| false | 38.461538 |
[
"-import numpy as np",
"-",
"-l = [a, b, c]",
"-arr = np.array(l)",
"-m = max(arr)",
"-t = m - arr",
"-# print(t)",
"-s = sum(t)",
"-if s % 2 == 0:",
"- ans = s // 2",
"+m = max(a, b, c)",
"+r = m - a + m - b + m - c",
"+if r % 2 == 0:",
"+ ans = r // 2",
"- ans = (s + 3) // 2",
"+ ans = (r + 3) // 2"
] | false | 0.212022 | 0.03906 | 5.42812 |
[
"s565272273",
"s257274046"
] |
u436982376
|
p02720
|
python
|
s086296697
|
s259712541
| 164 | 59 | 19,544 | 12,328 |
Accepted
|
Accepted
| 64.02 |
import heapq
k = int(eval(input()))
num_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
mae = 0
if k <= 9:
print(k)
else:
k -= 9
q = []
heapq.heapify(q)
for i in range(1, 10):
heapq.heappush(q, i)
temp = 0
while temp < 9:
temp += 1
num = heapq.heappop(q)
if temp == 9:
heapq.heappush(q, num*10 + num_list[(num%10)-1])
heapq.heappush(q, num*10 + num_list[(num%10)])
else:
heapq.heappush(q, num*10 + num_list[(num%10)-1])
heapq.heappush(q, num*10 + num_list[(num%10)])
heapq.heappush(q, num*10 + num_list[(num%10)+1])
while k > 0:
k -= 1
num = heapq.heappop(q)
if num == mae:
k += 1
continue
elif num%10 == 0:
heapq.heappush(q, num*10 + num_list[(num%10)])
heapq.heappush(q, num*10 + num_list[(num%10)+1])
elif num%10 == 9:
heapq.heappush(q, num*10 + num_list[(num%10)-1])
heapq.heappush(q, num*10 + num_list[(num%10)])
else:
heapq.heappush(q, num*10 + num_list[(num%10)-1])
heapq.heappush(q, num*10 + num_list[(num%10)])
heapq.heappush(q, num*10 + num_list[(num%10)+1])
mae = num
print(num)
|
from collections import deque
k = int(eval(input()))
cnt = 9
q = deque([])
for i in range(1,10):
q.append(i)
ans = 0
if k < 10:
print(k)
else:
while cnt != k:
n = q.popleft()
if n%10 == 0:
tmp = n*10
q.append(n*10)
cnt += 1
if cnt == k:
print(tmp)
break
q.append(1+tmp)
cnt += 1
if cnt == k:
print((tmp+1))
break
elif n%10 == 9:
tmp = n*10
q.append(tmp+8)
cnt+=1
if cnt == k:
print((tmp+8))
break
q.append(tmp+9)
cnt += 1
if cnt == k:
print((tmp+9))
break
else:
tmp = n%10
q.append(tmp-1+(n*10))
cnt += 1
if cnt ==k:
print((tmp-1+(n*10)))
break
q.append(tmp+(n*10))
cnt +=1
if cnt == k:
print((tmp+(n*10)))
break
q.append(tmp+1+(n*10))
cnt += 1
if cnt == k:
print((tmp+1+(n*10)))
break
| 44 | 55 | 1,320 | 1,280 |
import heapq
k = int(eval(input()))
num_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
mae = 0
if k <= 9:
print(k)
else:
k -= 9
q = []
heapq.heapify(q)
for i in range(1, 10):
heapq.heappush(q, i)
temp = 0
while temp < 9:
temp += 1
num = heapq.heappop(q)
if temp == 9:
heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])
heapq.heappush(q, num * 10 + num_list[(num % 10)])
else:
heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])
heapq.heappush(q, num * 10 + num_list[(num % 10)])
heapq.heappush(q, num * 10 + num_list[(num % 10) + 1])
while k > 0:
k -= 1
num = heapq.heappop(q)
if num == mae:
k += 1
continue
elif num % 10 == 0:
heapq.heappush(q, num * 10 + num_list[(num % 10)])
heapq.heappush(q, num * 10 + num_list[(num % 10) + 1])
elif num % 10 == 9:
heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])
heapq.heappush(q, num * 10 + num_list[(num % 10)])
else:
heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])
heapq.heappush(q, num * 10 + num_list[(num % 10)])
heapq.heappush(q, num * 10 + num_list[(num % 10) + 1])
mae = num
print(num)
|
from collections import deque
k = int(eval(input()))
cnt = 9
q = deque([])
for i in range(1, 10):
q.append(i)
ans = 0
if k < 10:
print(k)
else:
while cnt != k:
n = q.popleft()
if n % 10 == 0:
tmp = n * 10
q.append(n * 10)
cnt += 1
if cnt == k:
print(tmp)
break
q.append(1 + tmp)
cnt += 1
if cnt == k:
print((tmp + 1))
break
elif n % 10 == 9:
tmp = n * 10
q.append(tmp + 8)
cnt += 1
if cnt == k:
print((tmp + 8))
break
q.append(tmp + 9)
cnt += 1
if cnt == k:
print((tmp + 9))
break
else:
tmp = n % 10
q.append(tmp - 1 + (n * 10))
cnt += 1
if cnt == k:
print((tmp - 1 + (n * 10)))
break
q.append(tmp + (n * 10))
cnt += 1
if cnt == k:
print((tmp + (n * 10)))
break
q.append(tmp + 1 + (n * 10))
cnt += 1
if cnt == k:
print((tmp + 1 + (n * 10)))
break
| false | 20 |
[
"-import heapq",
"+from collections import deque",
"-num_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"-mae = 0",
"-if k <= 9:",
"+cnt = 9",
"+q = deque([])",
"+for i in range(1, 10):",
"+ q.append(i)",
"+ans = 0",
"+if k < 10:",
"- k -= 9",
"- q = []",
"- heapq.heapify(q)",
"- for i in range(1, 10):",
"- heapq.heappush(q, i)",
"- temp = 0",
"- while temp < 9:",
"- temp += 1",
"- num = heapq.heappop(q)",
"- if temp == 9:",
"- heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])",
"- heapq.heappush(q, num * 10 + num_list[(num % 10)])",
"+ while cnt != k:",
"+ n = q.popleft()",
"+ if n % 10 == 0:",
"+ tmp = n * 10",
"+ q.append(n * 10)",
"+ cnt += 1",
"+ if cnt == k:",
"+ print(tmp)",
"+ break",
"+ q.append(1 + tmp)",
"+ cnt += 1",
"+ if cnt == k:",
"+ print((tmp + 1))",
"+ break",
"+ elif n % 10 == 9:",
"+ tmp = n * 10",
"+ q.append(tmp + 8)",
"+ cnt += 1",
"+ if cnt == k:",
"+ print((tmp + 8))",
"+ break",
"+ q.append(tmp + 9)",
"+ cnt += 1",
"+ if cnt == k:",
"+ print((tmp + 9))",
"+ break",
"- heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])",
"- heapq.heappush(q, num * 10 + num_list[(num % 10)])",
"- heapq.heappush(q, num * 10 + num_list[(num % 10) + 1])",
"- while k > 0:",
"- k -= 1",
"- num = heapq.heappop(q)",
"- if num == mae:",
"- k += 1",
"- continue",
"- elif num % 10 == 0:",
"- heapq.heappush(q, num * 10 + num_list[(num % 10)])",
"- heapq.heappush(q, num * 10 + num_list[(num % 10) + 1])",
"- elif num % 10 == 9:",
"- heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])",
"- heapq.heappush(q, num * 10 + num_list[(num % 10)])",
"- else:",
"- heapq.heappush(q, num * 10 + num_list[(num % 10) - 1])",
"- heapq.heappush(q, num * 10 + num_list[(num % 10)])",
"- heapq.heappush(q, num * 10 + num_list[(num % 10) + 1])",
"- mae = num",
"- print(num)",
"+ tmp = n % 10",
"+ q.append(tmp - 1 + (n * 10))",
"+ cnt += 1",
"+ if cnt == k:",
"+ print((tmp - 1 + (n * 10)))",
"+ break",
"+ q.append(tmp + (n * 10))",
"+ cnt += 1",
"+ if cnt == k:",
"+ print((tmp + (n * 10)))",
"+ break",
"+ q.append(tmp + 1 + (n * 10))",
"+ cnt += 1",
"+ if cnt == k:",
"+ print((tmp + 1 + (n * 10)))",
"+ break"
] | false | 0.163805 | 0.132093 | 1.240072 |
[
"s086296697",
"s259712541"
] |
u746419473
|
p02772
|
python
|
s520100556
|
s893674764
| 22 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 22.73 |
n = int(eval(input()))
*a, = list(map(int, input().split()))
ans = "APPROVED"
for _a in a:
if _a%2 == 0 and _a%3 != 0 and _a%5 != 0:
ans = "DENIED"
break
print(ans)
|
n = int(eval(input()))
*a, = list(map(int, input().split()))
*_a, = [x for x in a if x%2 == 0]
*_a, = [x%3 == 0 or x%5 == 0 for x in _a]
print(("APPROVED" if all(_a) else "DENIED"))
| 9 | 7 | 182 | 184 |
n = int(eval(input()))
(*a,) = list(map(int, input().split()))
ans = "APPROVED"
for _a in a:
if _a % 2 == 0 and _a % 3 != 0 and _a % 5 != 0:
ans = "DENIED"
break
print(ans)
|
n = int(eval(input()))
(*a,) = list(map(int, input().split()))
(*_a,) = [x for x in a if x % 2 == 0]
(*_a,) = [x % 3 == 0 or x % 5 == 0 for x in _a]
print(("APPROVED" if all(_a) else "DENIED"))
| false | 22.222222 |
[
"-ans = \"APPROVED\"",
"-for _a in a:",
"- if _a % 2 == 0 and _a % 3 != 0 and _a % 5 != 0:",
"- ans = \"DENIED\"",
"- break",
"-print(ans)",
"+(*_a,) = [x for x in a if x % 2 == 0]",
"+(*_a,) = [x % 3 == 0 or x % 5 == 0 for x in _a]",
"+print((\"APPROVED\" if all(_a) else \"DENIED\"))"
] | false | 0.066139 | 0.045158 | 1.464605 |
[
"s520100556",
"s893674764"
] |
u888092736
|
p02594
|
python
|
s480060953
|
s955540509
| 35 | 27 | 9,140 | 9,052 |
Accepted
|
Accepted
| 22.86 |
X = int(input())
print("Yes") if X >= 30 else print("No")
|
X = int(eval(input()))
if X >= 30:
print("Yes")
else:
print("No")
| 2 | 5 | 58 | 72 |
X = int(input())
print("Yes") if X >= 30 else print("No")
|
X = int(eval(input()))
if X >= 30:
print("Yes")
else:
print("No")
| false | 60 |
[
"-X = int(input())",
"-print(\"Yes\") if X >= 30 else print(\"No\")",
"+X = int(eval(input()))",
"+if X >= 30:",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")"
] | false | 0.117226 | 0.037129 | 3.157278 |
[
"s480060953",
"s955540509"
] |
u390727364
|
p02767
|
python
|
s386163174
|
s436488056
| 180 | 165 | 38,256 | 38,256 |
Accepted
|
Accepted
| 8.33 |
from sys import stdin
def main():
n = int(stdin.readline())
x = list(map(int, stdin.readline().split()))
p = sum(x) / n
p1 = int(p)
p2 = int(p + 1)
s1 = 0
s2 = 0
for xi in x:
s1 += (xi - p1) ** 2
s2 += (xi - p2) ** 2
print((min(s1, s2)))
if __name__ == "__main__":
main()
|
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n = int(eval(input()))
x = list(map(int, input().split()))
sum = 0
for xi in x:
sum += xi
ans_1 = sum // n
ans_2 = sum // n + 1
score_1 = 0
score_2 = 0
for xi in x:
score_1 += (xi - ans_1) ** 2
score_2 += (xi - ans_2) ** 2
print((min(score_1, score_2)))
if __name__ == "__main__":
setrecursionlimit(10000)
main()
| 24 | 23 | 357 | 490 |
from sys import stdin
def main():
n = int(stdin.readline())
x = list(map(int, stdin.readline().split()))
p = sum(x) / n
p1 = int(p)
p2 = int(p + 1)
s1 = 0
s2 = 0
for xi in x:
s1 += (xi - p1) ** 2
s2 += (xi - p2) ** 2
print((min(s1, s2)))
if __name__ == "__main__":
main()
|
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
n = int(eval(input()))
x = list(map(int, input().split()))
sum = 0
for xi in x:
sum += xi
ans_1 = sum // n
ans_2 = sum // n + 1
score_1 = 0
score_2 = 0
for xi in x:
score_1 += (xi - ans_1) ** 2
score_2 += (xi - ans_2) ** 2
print((min(score_1, score_2)))
if __name__ == "__main__":
setrecursionlimit(10000)
main()
| false | 4.166667 |
[
"-from sys import stdin",
"+from sys import stdin, setrecursionlimit",
"- n = int(stdin.readline())",
"- x = list(map(int, stdin.readline().split()))",
"- p = sum(x) / n",
"- p1 = int(p)",
"- p2 = int(p + 1)",
"- s1 = 0",
"- s2 = 0",
"+ input = stdin.buffer.readline",
"+ n = int(eval(input()))",
"+ x = list(map(int, input().split()))",
"+ sum = 0",
"- s1 += (xi - p1) ** 2",
"- s2 += (xi - p2) ** 2",
"- print((min(s1, s2)))",
"+ sum += xi",
"+ ans_1 = sum // n",
"+ ans_2 = sum // n + 1",
"+ score_1 = 0",
"+ score_2 = 0",
"+ for xi in x:",
"+ score_1 += (xi - ans_1) ** 2",
"+ score_2 += (xi - ans_2) ** 2",
"+ print((min(score_1, score_2)))",
"+ setrecursionlimit(10000)"
] | false | 0.038185 | 0.039363 | 0.970065 |
[
"s386163174",
"s436488056"
] |
u678167152
|
p02787
|
python
|
s716628659
|
s029993199
| 1,416 | 322 | 12,520 | 74,608 |
Accepted
|
Accepted
| 77.26 |
#動的計画法
import numpy as np
H, N = list(map(int, input().split()))
A=np.empty(N,dtype=int)
B=np.empty(N,dtype=int)
for i in range(N):
A[i],B[i]=list(map(int,list(input().split(" "))))
DP=np.empty(H+1,dtype=int)
def battle(hp,magic=0):
#print(hp,magic)
if hp==0:
return magic
t = hp-A
t[t<0] = 0
min_power = min(DP[t]+B)
return magic+min_power
#DP = [0]*(H+1)
for i in range(H+1):
DP[i] = battle(i)
#print(DP[i])
ans = DP[H]
print(ans)
#print(*ans, sep='\n')
|
def solve():
H, N = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
dp = [float('inf')]*(H+10**4)
dp[0] = 0
for h in range(1,H+10**4):
for i in range(N):
if A[i][0]<=h:
dp[h] = min(dp[h],dp[h-A[i][0]]+A[i][1])
ans = min(dp[H:])
return ans
print((solve()))
| 28 | 12 | 499 | 362 |
# 動的計画法
import numpy as np
H, N = list(map(int, input().split()))
A = np.empty(N, dtype=int)
B = np.empty(N, dtype=int)
for i in range(N):
A[i], B[i] = list(map(int, list(input().split(" "))))
DP = np.empty(H + 1, dtype=int)
def battle(hp, magic=0):
# print(hp,magic)
if hp == 0:
return magic
t = hp - A
t[t < 0] = 0
min_power = min(DP[t] + B)
return magic + min_power
# DP = [0]*(H+1)
for i in range(H + 1):
DP[i] = battle(i)
# print(DP[i])
ans = DP[H]
print(ans)
# print(*ans, sep='\n')
|
def solve():
H, N = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
dp = [float("inf")] * (H + 10**4)
dp[0] = 0
for h in range(1, H + 10**4):
for i in range(N):
if A[i][0] <= h:
dp[h] = min(dp[h], dp[h - A[i][0]] + A[i][1])
ans = min(dp[H:])
return ans
print((solve()))
| false | 57.142857 |
[
"-# 動的計画法",
"-import numpy as np",
"-",
"-H, N = list(map(int, input().split()))",
"-A = np.empty(N, dtype=int)",
"-B = np.empty(N, dtype=int)",
"-for i in range(N):",
"- A[i], B[i] = list(map(int, list(input().split(\" \"))))",
"-DP = np.empty(H + 1, dtype=int)",
"+def solve():",
"+ H, N = list(map(int, input().split()))",
"+ A = [list(map(int, input().split())) for _ in range(N)]",
"+ dp = [float(\"inf\")] * (H + 10**4)",
"+ dp[0] = 0",
"+ for h in range(1, H + 10**4):",
"+ for i in range(N):",
"+ if A[i][0] <= h:",
"+ dp[h] = min(dp[h], dp[h - A[i][0]] + A[i][1])",
"+ ans = min(dp[H:])",
"+ return ans",
"-def battle(hp, magic=0):",
"- # print(hp,magic)",
"- if hp == 0:",
"- return magic",
"- t = hp - A",
"- t[t < 0] = 0",
"- min_power = min(DP[t] + B)",
"- return magic + min_power",
"-",
"-",
"-# DP = [0]*(H+1)",
"-for i in range(H + 1):",
"- DP[i] = battle(i)",
"- # print(DP[i])",
"-ans = DP[H]",
"-print(ans)",
"-# print(*ans, sep='\\n')",
"+print((solve()))"
] | false | 0.548455 | 0.119683 | 4.582586 |
[
"s716628659",
"s029993199"
] |
u941644149
|
p02658
|
python
|
s510261653
|
s222168114
| 91 | 56 | 95,896 | 21,776 |
Accepted
|
Accepted
| 38.46 |
N = int(eval(input()))
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
print((0))
exit()
upp = 10**18
flag = 1
ans = 1
#print(A)
for a in A:
ans *= a
if ans > upp:
ans = -1
break
print(ans)
|
N = int(eval(input()))
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
print((0))
exit()
upp = 10**18
ans = 1
#print(A)
for a in A:
ans *= a
if ans > upp:
ans = -1
break
print(ans)
| 19 | 18 | 231 | 221 |
N = int(eval(input()))
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
print((0))
exit()
upp = 10**18
flag = 1
ans = 1
# print(A)
for a in A:
ans *= a
if ans > upp:
ans = -1
break
print(ans)
|
N = int(eval(input()))
A = list(map(int, input().split()))
S = set(A)
if 0 in S:
print((0))
exit()
upp = 10**18
ans = 1
# print(A)
for a in A:
ans *= a
if ans > upp:
ans = -1
break
print(ans)
| false | 5.263158 |
[
"-flag = 1"
] | false | 0.033069 | 0.034115 | 0.969344 |
[
"s510261653",
"s222168114"
] |
u525065967
|
p02684
|
python
|
s701461027
|
s075628890
| 243 | 220 | 32,372 | 32,376 |
Accepted
|
Accepted
| 9.47 |
N,K = list(map(int, input().split()))
A = [*[int(x)-1 for x in input().split()]]
cnt = [0]*N
pre = 0
for _ in range(N*2):
cnt[pre] += 1
now = A[pre]
pre = now
one = 0
loops = 0
for c in cnt:
if c == 1: one += 1
elif c > 1: loops += 1
k = max(0, K-one) % loops + min(K, one)
pre = 0
for _ in range(k):
now = A[pre]
pre = now
ans = pre + 1
print(ans)
|
N,K = list(map(int, input().split()))
A = [*[int(x)-1 for x in input().split()]]
cnt, pre = [0]*N, 0
for _ in range(N*2):
cnt[pre] += 1
pre = A[pre]
one, loops = 0, 0
for c in cnt:
if c == 1: one += 1
elif c > 1: loops += 1
k = max(0, K-one) % loops + min(K, one)
pre = 0
for _ in range(k): pre = A[pre]
print((pre + 1))
| 25 | 18 | 404 | 354 |
N, K = list(map(int, input().split()))
A = [*[int(x) - 1 for x in input().split()]]
cnt = [0] * N
pre = 0
for _ in range(N * 2):
cnt[pre] += 1
now = A[pre]
pre = now
one = 0
loops = 0
for c in cnt:
if c == 1:
one += 1
elif c > 1:
loops += 1
k = max(0, K - one) % loops + min(K, one)
pre = 0
for _ in range(k):
now = A[pre]
pre = now
ans = pre + 1
print(ans)
|
N, K = list(map(int, input().split()))
A = [*[int(x) - 1 for x in input().split()]]
cnt, pre = [0] * N, 0
for _ in range(N * 2):
cnt[pre] += 1
pre = A[pre]
one, loops = 0, 0
for c in cnt:
if c == 1:
one += 1
elif c > 1:
loops += 1
k = max(0, K - one) % loops + min(K, one)
pre = 0
for _ in range(k):
pre = A[pre]
print((pre + 1))
| false | 28 |
[
"-cnt = [0] * N",
"-pre = 0",
"+cnt, pre = [0] * N, 0",
"- now = A[pre]",
"- pre = now",
"-one = 0",
"-loops = 0",
"+ pre = A[pre]",
"+one, loops = 0, 0",
"- now = A[pre]",
"- pre = now",
"-ans = pre + 1",
"-print(ans)",
"+ pre = A[pre]",
"+print((pre + 1))"
] | false | 0.10715 | 0.053105 | 2.01771 |
[
"s701461027",
"s075628890"
] |
u867848444
|
p02881
|
python
|
s222077826
|
s752920317
| 258 | 160 | 2,940 | 2,940 |
Accepted
|
Accepted
| 37.98 |
n=int(eval(input()))
num=int(n**0.5)+1
mini=float('inf')
for k in range(1,num+1):
i=k
j=0
if n%i==0:
j=n//i
if j!=0 and mini>=i+j-2:
mini=i+j-2
print(mini)
|
n=int(eval(input()))
ans=10**12
for i in range(1,int(n**0.5)+1):
if n%i==0:
ans=min(ans,i+n//i-2)
print(ans)
| 13 | 7 | 196 | 121 |
n = int(eval(input()))
num = int(n**0.5) + 1
mini = float("inf")
for k in range(1, num + 1):
i = k
j = 0
if n % i == 0:
j = n // i
if j != 0 and mini >= i + j - 2:
mini = i + j - 2
print(mini)
|
n = int(eval(input()))
ans = 10**12
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
ans = min(ans, i + n // i - 2)
print(ans)
| false | 46.153846 |
[
"-num = int(n**0.5) + 1",
"-mini = float(\"inf\")",
"-for k in range(1, num + 1):",
"- i = k",
"- j = 0",
"+ans = 10**12",
"+for i in range(1, int(n**0.5) + 1):",
"- j = n // i",
"- if j != 0 and mini >= i + j - 2:",
"- mini = i + j - 2",
"-print(mini)",
"+ ans = min(ans, i + n // i - 2)",
"+print(ans)"
] | false | 0.039206 | 0.064534 | 0.607516 |
[
"s222077826",
"s752920317"
] |
u551901148
|
p02993
|
python
|
s331280533
|
s087226627
| 20 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 15 |
param = eval(input())
s = list(map(int, list(str(param))))
pre = None
check = True
for i in s:
if pre != None:
if pre == i:
print("Bad")
check = False
break
pre = i
if check:
print("Good")
|
s = list(str(eval(input())))
flag = True
pre = None
for i, value in enumerate(s):
if i != 0:
if pre == value:
flag = False
break
pre = value
if flag:
print("Good")
else:
print("Bad")
| 16 | 16 | 231 | 222 |
param = eval(input())
s = list(map(int, list(str(param))))
pre = None
check = True
for i in s:
if pre != None:
if pre == i:
print("Bad")
check = False
break
pre = i
if check:
print("Good")
|
s = list(str(eval(input())))
flag = True
pre = None
for i, value in enumerate(s):
if i != 0:
if pre == value:
flag = False
break
pre = value
if flag:
print("Good")
else:
print("Bad")
| false | 0 |
[
"-param = eval(input())",
"-s = list(map(int, list(str(param))))",
"+s = list(str(eval(input())))",
"+flag = True",
"-check = True",
"-for i in s:",
"- if pre != None:",
"- if pre == i:",
"- print(\"Bad\")",
"- check = False",
"+for i, value in enumerate(s):",
"+ if i != 0:",
"+ if pre == value:",
"+ flag = False",
"- pre = i",
"-if check:",
"+ pre = value",
"+if flag:",
"+else:",
"+ print(\"Bad\")"
] | false | 0.039417 | 0.04063 | 0.970123 |
[
"s331280533",
"s087226627"
] |
u120691615
|
p03556
|
python
|
s832482776
|
s784398966
| 64 | 17 | 3,188 | 2,940 |
Accepted
|
Accepted
| 73.44 |
N = int(eval(input()))
for i in range(N + 1)[::-1]:
sqrt = int(i ** (1 / 2))
if sqrt ** 2 == i:
print(i)
break
|
N = int(eval(input()))
N = int(N ** 0.5)
print((N*N))
| 6 | 3 | 133 | 47 |
N = int(eval(input()))
for i in range(N + 1)[::-1]:
sqrt = int(i ** (1 / 2))
if sqrt**2 == i:
print(i)
break
|
N = int(eval(input()))
N = int(N**0.5)
print((N * N))
| false | 50 |
[
"-for i in range(N + 1)[::-1]:",
"- sqrt = int(i ** (1 / 2))",
"- if sqrt**2 == i:",
"- print(i)",
"- break",
"+N = int(N**0.5)",
"+print((N * N))"
] | false | 0.047027 | 0.062369 | 0.754018 |
[
"s832482776",
"s784398966"
] |
u941047297
|
p03632
|
python
|
s420294501
|
s584200438
| 177 | 17 | 38,384 | 3,064 |
Accepted
|
Accepted
| 90.4 |
A, B, C, D = list(map(int, input().split()))
if A <= C:
x = [A, B]
y = [C, D]
else:
y = [A, B]
x = [C, D]
if x[1] <= y[1]:
d = x[1] - y[0]
else:
d = y[1] - y[0]
if d < 0:
d = 0
print(d)
|
a, b, c, d = list(map(int, input().split()))
def overlap(a, b):
if max(a[0], b[0]) > min(a[1], b[1]):
return [0, 0]
return [max(a[0], b[0]), min(a[1], b[1])]
ans = overlap([a, b], [c, d])
print((ans[1] - ans[0]))
| 14 | 7 | 226 | 232 |
A, B, C, D = list(map(int, input().split()))
if A <= C:
x = [A, B]
y = [C, D]
else:
y = [A, B]
x = [C, D]
if x[1] <= y[1]:
d = x[1] - y[0]
else:
d = y[1] - y[0]
if d < 0:
d = 0
print(d)
|
a, b, c, d = list(map(int, input().split()))
def overlap(a, b):
if max(a[0], b[0]) > min(a[1], b[1]):
return [0, 0]
return [max(a[0], b[0]), min(a[1], b[1])]
ans = overlap([a, b], [c, d])
print((ans[1] - ans[0]))
| false | 50 |
[
"-A, B, C, D = list(map(int, input().split()))",
"-if A <= C:",
"- x = [A, B]",
"- y = [C, D]",
"-else:",
"- y = [A, B]",
"- x = [C, D]",
"-if x[1] <= y[1]:",
"- d = x[1] - y[0]",
"-else:",
"- d = y[1] - y[0]",
"-if d < 0:",
"- d = 0",
"-print(d)",
"+a, b, c, d = list(map(int, input().split()))",
"+",
"+",
"+def overlap(a, b):",
"+ if max(a[0], b[0]) > min(a[1], b[1]):",
"+ return [0, 0]",
"+ return [max(a[0], b[0]), min(a[1], b[1])]",
"+",
"+",
"+ans = overlap([a, b], [c, d])",
"+print((ans[1] - ans[0]))"
] | false | 0.106817 | 0.035558 | 3.003976 |
[
"s420294501",
"s584200438"
] |
u426534722
|
p02238
|
python
|
s265807929
|
s210645852
| 30 | 20 | 7,792 | 7,788 |
Accepted
|
Accepted
| 33.33 |
from sys import stdin
n = int(stdin.readline())
M = [None]
M += [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [None]
sndf += [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
global tt
sndf[u][0] = True
tt += 1
sndf[u].append(tt)
for v in M[u]:
if not sndf[v][0]:
dfs(v)
tt += 1
sndf[u].append(tt)
for i in range(1, n + 1):
if not sndf[i][0]:
dfs(i)
for x in sndf[1:]:
print((*x[1:]))
|
from sys import stdin
n = int(stdin.readline())
M = [None] + [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [None] + [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
global tt
sndf[u][0] = True
tt += 1
sndf[u].append(tt)
for v in M[u]:
if not sndf[v][0]:
dfs(v)
tt += 1
sndf[u].append(tt)
for i in range(1, n + 1):
if not sndf[i][0]:
dfs(i)
for x in sndf[1:]:
print((*x[1:]))
| 22 | 20 | 500 | 489 |
from sys import stdin
n = int(stdin.readline())
M = [None]
M += [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [None]
sndf += [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
global tt
sndf[u][0] = True
tt += 1
sndf[u].append(tt)
for v in M[u]:
if not sndf[v][0]:
dfs(v)
tt += 1
sndf[u].append(tt)
for i in range(1, n + 1):
if not sndf[i][0]:
dfs(i)
for x in sndf[1:]:
print((*x[1:]))
|
from sys import stdin
n = int(stdin.readline())
M = [None] + [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [None] + [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
global tt
sndf[u][0] = True
tt += 1
sndf[u].append(tt)
for v in M[u]:
if not sndf[v][0]:
dfs(v)
tt += 1
sndf[u].append(tt)
for i in range(1, n + 1):
if not sndf[i][0]:
dfs(i)
for x in sndf[1:]:
print((*x[1:]))
| false | 9.090909 |
[
"-M = [None]",
"-M += [list(map(int, stdin.readline().split()[2:])) for i in range(n)]",
"-sndf = [None]",
"-sndf += [[False, i] for i in range(1, n + 1)]",
"+M = [None] + [list(map(int, stdin.readline().split()[2:])) for i in range(n)]",
"+sndf = [None] + [[False, i] for i in range(1, n + 1)]"
] | false | 0.041386 | 0.041104 | 1.006879 |
[
"s265807929",
"s210645852"
] |
u606033239
|
p03338
|
python
|
s803603950
|
s186418402
| 20 | 18 | 3,060 | 2,940 |
Accepted
|
Accepted
| 10 |
n = int(eval(input()))
s = eval(input())
f = []
for i in range(n):
a = []
for j in range(i):
if s[j] in s[i:]:
a.append(s[j])
f.append(len(set(a)))
print((max(f)))
|
n = int(eval(input()))
s = eval(input())
a = 0
for i in range(1,n+1):
a = max(a,len(set(s[:i]) & set(s[i:])))
print(a)
| 10 | 7 | 190 | 117 |
n = int(eval(input()))
s = eval(input())
f = []
for i in range(n):
a = []
for j in range(i):
if s[j] in s[i:]:
a.append(s[j])
f.append(len(set(a)))
print((max(f)))
|
n = int(eval(input()))
s = eval(input())
a = 0
for i in range(1, n + 1):
a = max(a, len(set(s[:i]) & set(s[i:])))
print(a)
| false | 30 |
[
"-f = []",
"-for i in range(n):",
"- a = []",
"- for j in range(i):",
"- if s[j] in s[i:]:",
"- a.append(s[j])",
"- f.append(len(set(a)))",
"-print((max(f)))",
"+a = 0",
"+for i in range(1, n + 1):",
"+ a = max(a, len(set(s[:i]) & set(s[i:])))",
"+print(a)"
] | false | 0.03945 | 0.034487 | 1.143893 |
[
"s803603950",
"s186418402"
] |
u227082700
|
p02971
|
python
|
s444732041
|
s215630291
| 976 | 516 | 37,820 | 14,112 |
Accepted
|
Accepted
| 47.13 |
n=int(eval(input()))
a=[[int(eval(input())),i]for i in range(n)]
a.sort()
c=a[-1][0]
d=a[-2][0]
e=a[-1][1]
for i in range(n):
if i==e:print(d)
else:print(c)
|
n=int(eval(input()))
a=[int(eval(input()))for _ in range(n)]
b=sorted(a)
m=b[-1]
mm=b[-2]
for i in a:
if i==m:print(mm)
else:print(m)
| 9 | 8 | 156 | 132 |
n = int(eval(input()))
a = [[int(eval(input())), i] for i in range(n)]
a.sort()
c = a[-1][0]
d = a[-2][0]
e = a[-1][1]
for i in range(n):
if i == e:
print(d)
else:
print(c)
|
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
b = sorted(a)
m = b[-1]
mm = b[-2]
for i in a:
if i == m:
print(mm)
else:
print(m)
| false | 11.111111 |
[
"-a = [[int(eval(input())), i] for i in range(n)]",
"-a.sort()",
"-c = a[-1][0]",
"-d = a[-2][0]",
"-e = a[-1][1]",
"-for i in range(n):",
"- if i == e:",
"- print(d)",
"+a = [int(eval(input())) for _ in range(n)]",
"+b = sorted(a)",
"+m = b[-1]",
"+mm = b[-2]",
"+for i in a:",
"+ if i == m:",
"+ print(mm)",
"- print(c)",
"+ print(m)"
] | false | 0.040675 | 0.035882 | 1.133577 |
[
"s444732041",
"s215630291"
] |
u968166680
|
p02856
|
python
|
s855746115
|
s745447763
| 319 | 124 | 112,172 | 28,240 |
Accepted
|
Accepted
| 61.13 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
def main():
M, *DC = list(map(int, read().split()))
D = DC[::2]
C = DC[1::2]
total = sum(d * c for d, c in zip(D, C))
ans = sum(C) - 1 + (total - 1) // 9
print(ans)
return
if __name__ == '__main__':
main()
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
def main():
M, *DC = list(map(int, read().split()))
total = digits = 0
for d, c in zip(DC[::2], DC[1::2]):
total += d * c
digits += c
ans = digits - 1 + (total - 1) // 9
print(ans)
return
if __name__ == '__main__':
main()
| 22 | 25 | 399 | 432 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
def main():
M, *DC = list(map(int, read().split()))
D = DC[::2]
C = DC[1::2]
total = sum(d * c for d, c in zip(D, C))
ans = sum(C) - 1 + (total - 1) // 9
print(ans)
return
if __name__ == "__main__":
main()
|
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
def main():
M, *DC = list(map(int, read().split()))
total = digits = 0
for d, c in zip(DC[::2], DC[1::2]):
total += d * c
digits += c
ans = digits - 1 + (total - 1) // 9
print(ans)
return
if __name__ == "__main__":
main()
| false | 12 |
[
"- D = DC[::2]",
"- C = DC[1::2]",
"- total = sum(d * c for d, c in zip(D, C))",
"- ans = sum(C) - 1 + (total - 1) // 9",
"+ total = digits = 0",
"+ for d, c in zip(DC[::2], DC[1::2]):",
"+ total += d * c",
"+ digits += c",
"+ ans = digits - 1 + (total - 1) // 9"
] | false | 0.037248 | 0.036694 | 1.015114 |
[
"s855746115",
"s745447763"
] |
u239342230
|
p02706
|
python
|
s817860026
|
s498885677
| 24 | 21 | 9,984 | 9,644 |
Accepted
|
Accepted
| 12.5 |
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
print((max(-1,N-sum(A))))
|
N,M=list(map(int,input().split()))
print((max(-1,N-sum(map(int,input().split())))))
| 3 | 2 | 87 | 76 |
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
print((max(-1, N - sum(A))))
|
N, M = list(map(int, input().split()))
print((max(-1, N - sum(map(int, input().split())))))
| false | 33.333333 |
[
"-A = list(map(int, input().split()))",
"-print((max(-1, N - sum(A))))",
"+print((max(-1, N - sum(map(int, input().split())))))"
] | false | 0.03603 | 0.038229 | 0.942485 |
[
"s817860026",
"s498885677"
] |
u073852194
|
p03739
|
python
|
s321831154
|
s179607129
| 244 | 136 | 63,216 | 14,468 |
Accepted
|
Accepted
| 44.26 |
n = int(eval(input()))
A = list(map(int,input().split()))
count1 = 0
accum1 = 0
for i in range(n):
if i % 2 == 0:
if accum1 + A[i] <= 0:
count1 += 1 - accum1 - A[i]
accum1 = 1
else:
accum1 += A[i]
else:
if accum1 + A[i] >= 0:
count1 += 1 + accum1 + A[i]
accum1 = -1
else:
accum1 += A[i]
count2 = 0
accum2 = 0
for i in range(n):
if i % 2 != 0:
if accum2 + A[i] <= 0:
count2 += 1 - accum2 - A[i]
accum2 = 1
else:
accum2 += A[i]
else:
if accum2 + A[i] >= 0:
count2 += 1 + accum2 + A[i]
accum2 = -1
else:
accum2 += A[i]
print((min(count1,count2)))
|
N = int(eval(input()))
A = list(map(int, input().split()))
res1 = 0
cum1 = 0
for i in range(N):
cum1 += A[i]
if i % 2 == 0 and cum1 <= 0:
res1 += - cum1 + 1
cum1 = 1
if i % 2 != 0 and cum1 >= 0:
res1 += cum1 + 1
cum1 = -1
res2 = 0
cum2 = 0
for i in range(N):
cum2 += A[i]
if i % 2 != 0 and cum2 <= 0:
res2 += - cum2 + 1
cum2 = 1
if i % 2 == 0 and cum2 >= 0:
res2 += cum2 + 1
cum2 = -1
print((min(res1, res2)))
| 36 | 28 | 821 | 521 |
n = int(eval(input()))
A = list(map(int, input().split()))
count1 = 0
accum1 = 0
for i in range(n):
if i % 2 == 0:
if accum1 + A[i] <= 0:
count1 += 1 - accum1 - A[i]
accum1 = 1
else:
accum1 += A[i]
else:
if accum1 + A[i] >= 0:
count1 += 1 + accum1 + A[i]
accum1 = -1
else:
accum1 += A[i]
count2 = 0
accum2 = 0
for i in range(n):
if i % 2 != 0:
if accum2 + A[i] <= 0:
count2 += 1 - accum2 - A[i]
accum2 = 1
else:
accum2 += A[i]
else:
if accum2 + A[i] >= 0:
count2 += 1 + accum2 + A[i]
accum2 = -1
else:
accum2 += A[i]
print((min(count1, count2)))
|
N = int(eval(input()))
A = list(map(int, input().split()))
res1 = 0
cum1 = 0
for i in range(N):
cum1 += A[i]
if i % 2 == 0 and cum1 <= 0:
res1 += -cum1 + 1
cum1 = 1
if i % 2 != 0 and cum1 >= 0:
res1 += cum1 + 1
cum1 = -1
res2 = 0
cum2 = 0
for i in range(N):
cum2 += A[i]
if i % 2 != 0 and cum2 <= 0:
res2 += -cum2 + 1
cum2 = 1
if i % 2 == 0 and cum2 >= 0:
res2 += cum2 + 1
cum2 = -1
print((min(res1, res2)))
| false | 22.222222 |
[
"-n = int(eval(input()))",
"+N = int(eval(input()))",
"-count1 = 0",
"-accum1 = 0",
"-for i in range(n):",
"- if i % 2 == 0:",
"- if accum1 + A[i] <= 0:",
"- count1 += 1 - accum1 - A[i]",
"- accum1 = 1",
"- else:",
"- accum1 += A[i]",
"- else:",
"- if accum1 + A[i] >= 0:",
"- count1 += 1 + accum1 + A[i]",
"- accum1 = -1",
"- else:",
"- accum1 += A[i]",
"-count2 = 0",
"-accum2 = 0",
"-for i in range(n):",
"- if i % 2 != 0:",
"- if accum2 + A[i] <= 0:",
"- count2 += 1 - accum2 - A[i]",
"- accum2 = 1",
"- else:",
"- accum2 += A[i]",
"- else:",
"- if accum2 + A[i] >= 0:",
"- count2 += 1 + accum2 + A[i]",
"- accum2 = -1",
"- else:",
"- accum2 += A[i]",
"-print((min(count1, count2)))",
"+res1 = 0",
"+cum1 = 0",
"+for i in range(N):",
"+ cum1 += A[i]",
"+ if i % 2 == 0 and cum1 <= 0:",
"+ res1 += -cum1 + 1",
"+ cum1 = 1",
"+ if i % 2 != 0 and cum1 >= 0:",
"+ res1 += cum1 + 1",
"+ cum1 = -1",
"+res2 = 0",
"+cum2 = 0",
"+for i in range(N):",
"+ cum2 += A[i]",
"+ if i % 2 != 0 and cum2 <= 0:",
"+ res2 += -cum2 + 1",
"+ cum2 = 1",
"+ if i % 2 == 0 and cum2 >= 0:",
"+ res2 += cum2 + 1",
"+ cum2 = -1",
"+print((min(res1, res2)))"
] | false | 0.049201 | 0.049232 | 0.999376 |
[
"s321831154",
"s179607129"
] |
u525065967
|
p02606
|
python
|
s024894509
|
s281908815
| 35 | 29 | 9,016 | 9,068 |
Accepted
|
Accepted
| 17.14 |
l, r, d = list(map(int, input().split()))
c = 0
for i in range(l, r+1):
if i%d == 0: c += 1
print(c)
|
l, r, d = list(map(int, input().split()))
print((r//d - l//d + (l%d==0)))
| 5 | 2 | 103 | 67 |
l, r, d = list(map(int, input().split()))
c = 0
for i in range(l, r + 1):
if i % d == 0:
c += 1
print(c)
|
l, r, d = list(map(int, input().split()))
print((r // d - l // d + (l % d == 0)))
| false | 60 |
[
"-c = 0",
"-for i in range(l, r + 1):",
"- if i % d == 0:",
"- c += 1",
"-print(c)",
"+print((r // d - l // d + (l % d == 0)))"
] | false | 0.036489 | 0.034937 | 1.044418 |
[
"s024894509",
"s281908815"
] |
u968166680
|
p02814
|
python
|
s374057642
|
s309175957
| 508 | 43 | 15,316 | 11,356 |
Accepted
|
Accepted
| 91.54 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
def main():
N, M, *A = list(map(int, read().split()))
B = A.copy()
while not any(b % 2 for b in B):
B = [b // 2 for b in B]
if not all(b % 2 for b in B):
print((0))
return
semi_lcm = 1
for a in A:
semi_lcm = lcm(semi_lcm, a // 2)
print(((M // semi_lcm + 1) // 2))
return
if __name__ == '__main__':
main()
|
N, M = list(map(int, input().split()))
A = list(set(map(int, input().split(" "))))
G = A.copy()
while not any(x % 2 for x in G):
G = [i // 2 for i in G]
if not all(x % 2 for x in G):
print((0))
exit(0)
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
total = 1
for x in A:
total = lcm(total, x // 2)
print(((M // total + 1) // 2))
| 40 | 26 | 665 | 445 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
def main():
N, M, *A = list(map(int, read().split()))
B = A.copy()
while not any(b % 2 for b in B):
B = [b // 2 for b in B]
if not all(b % 2 for b in B):
print((0))
return
semi_lcm = 1
for a in A:
semi_lcm = lcm(semi_lcm, a // 2)
print(((M // semi_lcm + 1) // 2))
return
if __name__ == "__main__":
main()
|
N, M = list(map(int, input().split()))
A = list(set(map(int, input().split(" "))))
G = A.copy()
while not any(x % 2 for x in G):
G = [i // 2 for i in G]
if not all(x % 2 for x in G):
print((0))
exit(0)
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
total = 1
for x in A:
total = lcm(total, x // 2)
print(((M // total + 1) // 2))
| false | 35 |
[
"-import sys",
"-",
"-read = sys.stdin.read",
"-readline = sys.stdin.readline",
"-readlines = sys.stdin.readlines",
"-sys.setrecursionlimit(10**9)",
"-INF = 1 << 60",
"+N, M = list(map(int, input().split()))",
"+A = list(set(map(int, input().split(\" \"))))",
"+G = A.copy()",
"+while not any(x % 2 for x in G):",
"+ G = [i // 2 for i in G]",
"+if not all(x % 2 for x in G):",
"+ print((0))",
"+ exit(0)",
"-def main():",
"- N, M, *A = list(map(int, read().split()))",
"- B = A.copy()",
"- while not any(b % 2 for b in B):",
"- B = [b // 2 for b in B]",
"- if not all(b % 2 for b in B):",
"- print((0))",
"- return",
"- semi_lcm = 1",
"- for a in A:",
"- semi_lcm = lcm(semi_lcm, a // 2)",
"- print(((M // semi_lcm + 1) // 2))",
"- return",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+total = 1",
"+for x in A:",
"+ total = lcm(total, x // 2)",
"+print(((M // total + 1) // 2))"
] | false | 0.122405 | 0.036132 | 3.387695 |
[
"s374057642",
"s309175957"
] |
u057993957
|
p03449
|
python
|
s929373460
|
s986107202
| 153 | 18 | 12,404 | 3,060 |
Accepted
|
Accepted
| 88.24 |
import numpy as np
n = int(eval(input()))
a = np.array([list(map(int,input().split())) for i in range(2)])
cnt = [0] * (n)
for i in range(0, n):
cnt[i] = sum(a[0, :i+1]) + sum(a[1, i:])
print((max(cnt)))
|
n = int(eval(input()))
a = [list(map(int,input().split())) for i in range(2)]
cnt = [sum(a[0][:i+1]) + sum(a[1][i:]) for i in range(n)]
print((max(cnt)))
| 10 | 4 | 224 | 148 |
import numpy as np
n = int(eval(input()))
a = np.array([list(map(int, input().split())) for i in range(2)])
cnt = [0] * (n)
for i in range(0, n):
cnt[i] = sum(a[0, : i + 1]) + sum(a[1, i:])
print((max(cnt)))
|
n = int(eval(input()))
a = [list(map(int, input().split())) for i in range(2)]
cnt = [sum(a[0][: i + 1]) + sum(a[1][i:]) for i in range(n)]
print((max(cnt)))
| false | 60 |
[
"-import numpy as np",
"-",
"-a = np.array([list(map(int, input().split())) for i in range(2)])",
"-cnt = [0] * (n)",
"-for i in range(0, n):",
"- cnt[i] = sum(a[0, : i + 1]) + sum(a[1, i:])",
"+a = [list(map(int, input().split())) for i in range(2)]",
"+cnt = [sum(a[0][: i + 1]) + sum(a[1][i:]) for i in range(n)]"
] | false | 0.299233 | 0.037518 | 7.975634 |
[
"s929373460",
"s986107202"
] |
u525065967
|
p03290
|
python
|
s344540332
|
s889454565
| 254 | 28 | 3,064 | 3,064 |
Accepted
|
Accepted
| 88.98 |
d,g = list(map(int,input().split()))
P,C = [0]*d,[0]*d
for i in range(d): P[i],C[i] = list(map(int,input().split()))
ans = 10**9
for bin in range(1, 1<<d):
cnt = tot = 0
for i in range(d):
if bin & 1<<i:
cnt += P[i]
tot += P[i]*(i+1)*100 + C[i]
if tot < g: continue
ans = min(ans, cnt)
for i in range(d):
if bin & 1<<i:
now_cnt = cnt
now_tot = tot - C[i]
for k in range(P[i]-1):
now_cnt -= 1
now_tot -= (i+1)*100
if now_tot >= g: ans = min(ans, now_cnt)
print(ans)
|
d,g = list(map(int,input().split()))
g //= 100
P,C = [0]*d,[0]*d
for i in range(d):
P[i],C[i] = list(map(int,input().split()))
C[i] //= 100
ans = 10**9
for bin in range(1, 1<<d):
cnt = tot = 0
for i in range(d):
if bin & 1<<i:
cnt += P[i]
tot += P[i]*(i+1) + C[i]
if tot < g: continue
ans = min(ans, cnt)
for i in range(d):
if bin & 1<<i:
rest_g = g - (tot - P[i]*(i+1) - C[i])
p = max(0, (rest_g+i)//(i+1)) # round up
ans = min(ans, cnt - (P[i] - p))
print(ans)
| 21 | 21 | 617 | 575 |
d, g = list(map(int, input().split()))
P, C = [0] * d, [0] * d
for i in range(d):
P[i], C[i] = list(map(int, input().split()))
ans = 10**9
for bin in range(1, 1 << d):
cnt = tot = 0
for i in range(d):
if bin & 1 << i:
cnt += P[i]
tot += P[i] * (i + 1) * 100 + C[i]
if tot < g:
continue
ans = min(ans, cnt)
for i in range(d):
if bin & 1 << i:
now_cnt = cnt
now_tot = tot - C[i]
for k in range(P[i] - 1):
now_cnt -= 1
now_tot -= (i + 1) * 100
if now_tot >= g:
ans = min(ans, now_cnt)
print(ans)
|
d, g = list(map(int, input().split()))
g //= 100
P, C = [0] * d, [0] * d
for i in range(d):
P[i], C[i] = list(map(int, input().split()))
C[i] //= 100
ans = 10**9
for bin in range(1, 1 << d):
cnt = tot = 0
for i in range(d):
if bin & 1 << i:
cnt += P[i]
tot += P[i] * (i + 1) + C[i]
if tot < g:
continue
ans = min(ans, cnt)
for i in range(d):
if bin & 1 << i:
rest_g = g - (tot - P[i] * (i + 1) - C[i])
p = max(0, (rest_g + i) // (i + 1)) # round up
ans = min(ans, cnt - (P[i] - p))
print(ans)
| false | 0 |
[
"+g //= 100",
"+ C[i] //= 100",
"- tot += P[i] * (i + 1) * 100 + C[i]",
"+ tot += P[i] * (i + 1) + C[i]",
"- now_cnt = cnt",
"- now_tot = tot - C[i]",
"- for k in range(P[i] - 1):",
"- now_cnt -= 1",
"- now_tot -= (i + 1) * 100",
"- if now_tot >= g:",
"- ans = min(ans, now_cnt)",
"+ rest_g = g - (tot - P[i] * (i + 1) - C[i])",
"+ p = max(0, (rest_g + i) // (i + 1)) # round up",
"+ ans = min(ans, cnt - (P[i] - p))"
] | false | 0.046467 | 0.037923 | 1.225294 |
[
"s344540332",
"s889454565"
] |
u886112691
|
p03370
|
python
|
s823562934
|
s380492864
| 41 | 27 | 3,060 | 9,156 |
Accepted
|
Accepted
| 34.15 |
n,x=list(map(int,input().split()))
m=[]
for i in range(n):
m.append(int(eval(input())))
x-=sum(m)
count=n
minm=min(m)
while minm<=x:
count+=1
x-=minm
print(count)
|
n,x=list(map(int,input().split()))
m=[0]*n
for i in range(n):
m[i]=int(eval(input()))
x-=m[i]
print((n+x//min(m)))
| 15 | 9 | 180 | 119 |
n, x = list(map(int, input().split()))
m = []
for i in range(n):
m.append(int(eval(input())))
x -= sum(m)
count = n
minm = min(m)
while minm <= x:
count += 1
x -= minm
print(count)
|
n, x = list(map(int, input().split()))
m = [0] * n
for i in range(n):
m[i] = int(eval(input()))
x -= m[i]
print((n + x // min(m)))
| false | 40 |
[
"-m = []",
"+m = [0] * n",
"- m.append(int(eval(input())))",
"-x -= sum(m)",
"-count = n",
"-minm = min(m)",
"-while minm <= x:",
"- count += 1",
"- x -= minm",
"-print(count)",
"+ m[i] = int(eval(input()))",
"+ x -= m[i]",
"+print((n + x // min(m)))"
] | false | 0.083616 | 0.037108 | 2.253319 |
[
"s823562934",
"s380492864"
] |
u413165887
|
p03347
|
python
|
s173419449
|
s780645013
| 766 | 407 | 61,016 | 12,588 |
Accepted
|
Accepted
| 46.87 |
n = int(eval(input()))
a = [int(eval(input())) for _i in range(n)] + [-1]
result = -1
for i in range(n):
if a[i-1] >= a[i]:
result += a[i]
elif a[i-1] + 1 == a[i]:
result += 1
else:
result = -1
break
print(result)
|
n,r=int(eval(input())),-1
a = [int(eval(input())) for _i in range(n)]+[-1]
for i in range(n):
if a[i-1] >= a[i]:r+=a[i]
elif a[i-1]+1==a[i]:r+=1
else:r=-1;break
print(r)
| 13 | 7 | 258 | 175 |
n = int(eval(input()))
a = [int(eval(input())) for _i in range(n)] + [-1]
result = -1
for i in range(n):
if a[i - 1] >= a[i]:
result += a[i]
elif a[i - 1] + 1 == a[i]:
result += 1
else:
result = -1
break
print(result)
|
n, r = int(eval(input())), -1
a = [int(eval(input())) for _i in range(n)] + [-1]
for i in range(n):
if a[i - 1] >= a[i]:
r += a[i]
elif a[i - 1] + 1 == a[i]:
r += 1
else:
r = -1
break
print(r)
| false | 46.153846 |
[
"-n = int(eval(input()))",
"+n, r = int(eval(input())), -1",
"-result = -1",
"- result += a[i]",
"+ r += a[i]",
"- result += 1",
"+ r += 1",
"- result = -1",
"+ r = -1",
"-print(result)",
"+print(r)"
] | false | 0.225908 | 0.06326 | 3.571107 |
[
"s173419449",
"s780645013"
] |
u994988729
|
p02769
|
python
|
s080661384
|
s295263632
| 1,969 | 476 | 27,460 | 18,804 |
Accepted
|
Accepted
| 75.83 |
from itertools import accumulate
import numpy as np
MOD = 10 ** 9 + 7
def cumprod(A, mod=MOD):
L = len(A)
Lsq = int(L ** 0.5 + 1)
A = np.resize(A, Lsq ** 2).reshape((Lsq, Lsq))
for i in range(1, Lsq):
A[:, i] *= A[:, i - 1]
A[:, i] %= mod
for i in range(1, Lsq):
A[i] *= A[i - 1][-1]
A[i] %= mod
return A.ravel()[:L]
def make_fact_and_inv(U, mod=MOD):
"""
0~Nまでのサイズ(N+1)の階乗およびその逆元の配列を返す
"""
tmp = np.arange(U, dtype=np.int64)
tmp[0] = 1
fact = cumprod(tmp, mod)
tmp = np.arange(U, 0, -1, dtype=np.int64)
tmp[0] = pow(int(fact[-1]), mod - 2, mod)
inv = cumprod(tmp, mod)[::-1]
return fact, inv
fact, inv = make_fact_and_inv(2 * 10 ** 5 + 10)
def nCr(n, r, mod=MOD):
if r < 0 or r > n or n < 0:
return 0
return fact[n] * inv[r] % mod * inv[n - r] % mod
if __name__ == "__main__":
N, K = list(map(int, input().split()))
ans = []
for i in range(min(N - 1, K) + 1):
val = nCr(N, i) * nCr(N - 1, i) % MOD
ans.append(val)
answer = 0
while ans:
answer = (answer + ans.pop()) % MOD
print(answer)
|
U = 2 * 10 ** 5
mod = 10 ** 9 + 7
class Combination:
"""
SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
使い方:
comb = Combination(SIZE, MOD)
comb(10, 3) => 120
"""
def __init__(self, N, MOD=10 ** 9 + 7):
self.MOD = MOD
self.fact, self.inv = self._make_factorial_list(N)
def __call__(self, n, k):
if k < 0 or k > n:
return 0
res = self.fact[n] * self.inv[k] % self.MOD
res = res * self.inv[n - k] % self.MOD
return res
def _make_factorial_list(self, N):
fact = [1] * (N + 1)
inv = [1] * (N + 1)
MOD = self.MOD
for i in range(1, N + 1):
fact[i] = (fact[i - 1] * i) % MOD
inv[N] = pow(fact[N], MOD - 2, MOD)
for i in range(N, 0, -1):
inv[i - 1] = (inv[i] * i) % MOD
return fact, inv
if __name__ == "__main__":
N, K = list(map(int, input().split()))
comb = Combination(U + 5, mod)
ans = 1
for i in range(1, min(K + 1, N)):
vacant = comb(N, i)
person = comb(N - 1, i)
ans = (ans + vacant * person % mod) % mod
print(ans)
| 52 | 45 | 1,204 | 1,166 |
from itertools import accumulate
import numpy as np
MOD = 10**9 + 7
def cumprod(A, mod=MOD):
L = len(A)
Lsq = int(L**0.5 + 1)
A = np.resize(A, Lsq**2).reshape((Lsq, Lsq))
for i in range(1, Lsq):
A[:, i] *= A[:, i - 1]
A[:, i] %= mod
for i in range(1, Lsq):
A[i] *= A[i - 1][-1]
A[i] %= mod
return A.ravel()[:L]
def make_fact_and_inv(U, mod=MOD):
"""
0~Nまでのサイズ(N+1)の階乗およびその逆元の配列を返す
"""
tmp = np.arange(U, dtype=np.int64)
tmp[0] = 1
fact = cumprod(tmp, mod)
tmp = np.arange(U, 0, -1, dtype=np.int64)
tmp[0] = pow(int(fact[-1]), mod - 2, mod)
inv = cumprod(tmp, mod)[::-1]
return fact, inv
fact, inv = make_fact_and_inv(2 * 10**5 + 10)
def nCr(n, r, mod=MOD):
if r < 0 or r > n or n < 0:
return 0
return fact[n] * inv[r] % mod * inv[n - r] % mod
if __name__ == "__main__":
N, K = list(map(int, input().split()))
ans = []
for i in range(min(N - 1, K) + 1):
val = nCr(N, i) * nCr(N - 1, i) % MOD
ans.append(val)
answer = 0
while ans:
answer = (answer + ans.pop()) % MOD
print(answer)
|
U = 2 * 10**5
mod = 10**9 + 7
class Combination:
"""
SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
使い方:
comb = Combination(SIZE, MOD)
comb(10, 3) => 120
"""
def __init__(self, N, MOD=10**9 + 7):
self.MOD = MOD
self.fact, self.inv = self._make_factorial_list(N)
def __call__(self, n, k):
if k < 0 or k > n:
return 0
res = self.fact[n] * self.inv[k] % self.MOD
res = res * self.inv[n - k] % self.MOD
return res
def _make_factorial_list(self, N):
fact = [1] * (N + 1)
inv = [1] * (N + 1)
MOD = self.MOD
for i in range(1, N + 1):
fact[i] = (fact[i - 1] * i) % MOD
inv[N] = pow(fact[N], MOD - 2, MOD)
for i in range(N, 0, -1):
inv[i - 1] = (inv[i] * i) % MOD
return fact, inv
if __name__ == "__main__":
N, K = list(map(int, input().split()))
comb = Combination(U + 5, mod)
ans = 1
for i in range(1, min(K + 1, N)):
vacant = comb(N, i)
person = comb(N - 1, i)
ans = (ans + vacant * person % mod) % mod
print(ans)
| false | 13.461538 |
[
"-from itertools import accumulate",
"-import numpy as np",
"-",
"-MOD = 10**9 + 7",
"+U = 2 * 10**5",
"+mod = 10**9 + 7",
"-def cumprod(A, mod=MOD):",
"- L = len(A)",
"- Lsq = int(L**0.5 + 1)",
"- A = np.resize(A, Lsq**2).reshape((Lsq, Lsq))",
"- for i in range(1, Lsq):",
"- A[:, i] *= A[:, i - 1]",
"- A[:, i] %= mod",
"- for i in range(1, Lsq):",
"- A[i] *= A[i - 1][-1]",
"- A[i] %= mod",
"- return A.ravel()[:L]",
"+class Combination:",
"+ \"\"\"",
"+ SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う",
"+ 使い方:",
"+ comb = Combination(SIZE, MOD)",
"+ comb(10, 3) => 120",
"+ \"\"\"",
"+ def __init__(self, N, MOD=10**9 + 7):",
"+ self.MOD = MOD",
"+ self.fact, self.inv = self._make_factorial_list(N)",
"-def make_fact_and_inv(U, mod=MOD):",
"- \"\"\"",
"- 0~Nまでのサイズ(N+1)の階乗およびその逆元の配列を返す",
"- \"\"\"",
"- tmp = np.arange(U, dtype=np.int64)",
"- tmp[0] = 1",
"- fact = cumprod(tmp, mod)",
"- tmp = np.arange(U, 0, -1, dtype=np.int64)",
"- tmp[0] = pow(int(fact[-1]), mod - 2, mod)",
"- inv = cumprod(tmp, mod)[::-1]",
"- return fact, inv",
"+ def __call__(self, n, k):",
"+ if k < 0 or k > n:",
"+ return 0",
"+ res = self.fact[n] * self.inv[k] % self.MOD",
"+ res = res * self.inv[n - k] % self.MOD",
"+ return res",
"-",
"-fact, inv = make_fact_and_inv(2 * 10**5 + 10)",
"-",
"-",
"-def nCr(n, r, mod=MOD):",
"- if r < 0 or r > n or n < 0:",
"- return 0",
"- return fact[n] * inv[r] % mod * inv[n - r] % mod",
"+ def _make_factorial_list(self, N):",
"+ fact = [1] * (N + 1)",
"+ inv = [1] * (N + 1)",
"+ MOD = self.MOD",
"+ for i in range(1, N + 1):",
"+ fact[i] = (fact[i - 1] * i) % MOD",
"+ inv[N] = pow(fact[N], MOD - 2, MOD)",
"+ for i in range(N, 0, -1):",
"+ inv[i - 1] = (inv[i] * i) % MOD",
"+ return fact, inv",
"- ans = []",
"- for i in range(min(N - 1, K) + 1):",
"- val = nCr(N, i) * nCr(N - 1, i) % MOD",
"- ans.append(val)",
"- answer = 0",
"- while ans:",
"- answer = (answer + ans.pop()) % MOD",
"- print(answer)",
"+ comb = Combination(U + 5, mod)",
"+ ans = 1",
"+ for i in range(1, min(K + 1, N)):",
"+ vacant = comb(N, i)",
"+ person = comb(N - 1, i)",
"+ ans = (ans + vacant * person % mod) % mod",
"+ print(ans)"
] | false | 0.965675 | 1.002039 | 0.96371 |
[
"s080661384",
"s295263632"
] |
u724687935
|
p02838
|
python
|
s495022878
|
s783274579
| 852 | 467 | 122,968 | 122,808 |
Accepted
|
Accepted
| 45.19 |
N = int(eval(input()))
A = list(map(int, input().split()))
ones = [0] * 60
m = 10 ** 9 + 7
for Ai in A:
for digit in range(len(bin(Ai)) - 2):
ones[digit] += ((Ai >> digit) & 1)
res = 0
for i, num in enumerate(ones):
res += (1 << i) * num * (N - num)
print((res % m))
|
N = int(eval(input()))
A = list(map(int, input().split()))
ones = [0] * 60
m = 10 ** 9 + 7
for Ai in A:
for digit in range(60):
ones[digit] += ((Ai >> digit) & 1)
res = 0
for i, num in enumerate(ones):
res += (1 << i) * num * (N - num)
print((res % m))
| 16 | 16 | 289 | 275 |
N = int(eval(input()))
A = list(map(int, input().split()))
ones = [0] * 60
m = 10**9 + 7
for Ai in A:
for digit in range(len(bin(Ai)) - 2):
ones[digit] += (Ai >> digit) & 1
res = 0
for i, num in enumerate(ones):
res += (1 << i) * num * (N - num)
print((res % m))
|
N = int(eval(input()))
A = list(map(int, input().split()))
ones = [0] * 60
m = 10**9 + 7
for Ai in A:
for digit in range(60):
ones[digit] += (Ai >> digit) & 1
res = 0
for i, num in enumerate(ones):
res += (1 << i) * num * (N - num)
print((res % m))
| false | 0 |
[
"- for digit in range(len(bin(Ai)) - 2):",
"+ for digit in range(60):"
] | false | 0.085622 | 0.087348 | 0.980247 |
[
"s495022878",
"s783274579"
] |
u442030035
|
p03102
|
python
|
s336505566
|
s267822805
| 21 | 18 | 3,316 | 2,940 |
Accepted
|
Accepted
| 14.29 |
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
ct = 0
for i in A:
if sum([j * k for j, k in zip(i, B)]) + C > 0:
ct += 1
print(ct)
|
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
ct = 0
for i in range(N):
if sum([j * k for j, k in zip(list(map(int, input().split())), B)]) + C > 0:
ct += 1
print(ct)
| 10 | 9 | 235 | 215 |
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
ct = 0
for i in A:
if sum([j * k for j, k in zip(i, B)]) + C > 0:
ct += 1
print(ct)
|
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
ct = 0
for i in range(N):
if sum([j * k for j, k in zip(list(map(int, input().split())), B)]) + C > 0:
ct += 1
print(ct)
| false | 10 |
[
"-A = [list(map(int, input().split())) for i in range(N)]",
"-for i in A:",
"- if sum([j * k for j, k in zip(i, B)]) + C > 0:",
"+for i in range(N):",
"+ if sum([j * k for j, k in zip(list(map(int, input().split())), B)]) + C > 0:"
] | false | 0.035104 | 0.036278 | 0.967647 |
[
"s336505566",
"s267822805"
] |
u241159583
|
p03611
|
python
|
s041467721
|
s087287598
| 138 | 113 | 14,548 | 14,564 |
Accepted
|
Accepted
| 18.12 |
from collections import Counter
n = int(eval(input()))
a = Counter(sorted(list(map(int, input().split()))))
ans = 0
p = 0
for x, y in list(a.items()):
p = y
if x-1 in a: p += a[x-1]
if x+1 in a: p += a[x+1]
if p > ans: ans = p
print(ans)
|
from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
ans = 0
for x,y in list(a.items()):
cnt = y
if x-1 in a: cnt += a[x-1]
if x+1 in a: cnt += a[x+1]
if cnt > ans: ans = cnt
print(ans)
| 12 | 11 | 253 | 239 |
from collections import Counter
n = int(eval(input()))
a = Counter(sorted(list(map(int, input().split()))))
ans = 0
p = 0
for x, y in list(a.items()):
p = y
if x - 1 in a:
p += a[x - 1]
if x + 1 in a:
p += a[x + 1]
if p > ans:
ans = p
print(ans)
|
from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))
ans = 0
for x, y in list(a.items()):
cnt = y
if x - 1 in a:
cnt += a[x - 1]
if x + 1 in a:
cnt += a[x + 1]
if cnt > ans:
ans = cnt
print(ans)
| false | 8.333333 |
[
"-a = Counter(sorted(list(map(int, input().split()))))",
"+a = Counter(list(map(int, input().split())))",
"-p = 0",
"- p = y",
"+ cnt = y",
"- p += a[x - 1]",
"+ cnt += a[x - 1]",
"- p += a[x + 1]",
"- if p > ans:",
"- ans = p",
"+ cnt += a[x + 1]",
"+ if cnt > ans:",
"+ ans = cnt"
] | false | 0.110952 | 0.040017 | 2.772599 |
[
"s041467721",
"s087287598"
] |
u729133443
|
p03423
|
python
|
s852144185
|
s143209657
| 38 | 17 | 27,884 | 2,940 |
Accepted
|
Accepted
| 55.26 |
print(eval(input())/3)
|
print((int(eval(input()))//3))
| 1 | 1 | 15 | 22 |
print(eval(input()) / 3)
|
print((int(eval(input())) // 3))
| false | 0 |
[
"-print(eval(input()) / 3)",
"+print((int(eval(input())) // 3))"
] | false | 0.007632 | 0.040715 | 0.187437 |
[
"s852144185",
"s143209657"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.