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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u827202523 | p03044 | python | s388174922 | s468866350 | 777 | 496 | 46,784 | 68,528 | Accepted | Accepted | 36.16 | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
from collections import deque
n = getN()
paths = [[] for i in range(n)]
for i in range(n-1):
a,b,c = getList()
paths[a-1].append((b-1,c))
... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
return int(eval(input()))
def getList():
return list(map(int, input().split()))
import math
from collections import deque
n = getN()
tree = [[] for i in range(n)]
visited = [0 for i in ra... | 43 | 42 | 914 | 867 | def getN():
return int(eval(input()))
def getNM():
return list(map(int, input().split()))
def getList():
return list(map(int, input().split()))
from collections import deque
n = getN()
paths = [[] for i in range(n)]
for i in range(n - 1):
a, b, c = getList()
paths[a - 1].append((b - 1, c))
... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
return int(eval(input()))
def getList():
return list(map(int, input().split()))
import math
from collections import deque
n = getN()
tree = [[] for i in range(n)]
visited = [0 for i in range(n)... | false | 2.325581 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"+sys.setrecursionlimit(1000000)",
"+from collections import deque",
"+",
"+",
"-",
"-",
"-def getNM():",
"- return list(map(int, input().split()))",
"+import math",
"-paths = [[] for i in range(n)]",
"+tree = [[] for i in range(n)]",
... | false | 0.045432 | 0.069243 | 0.656129 | [
"s388174922",
"s468866350"
] |
u633068244 | p00222 | python | s654754950 | s532864054 | 4,360 | 3,620 | 280,936 | 280,952 | Accepted | Accepted | 16.97 | r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2*i::i] = [0 for j in range(2*i,r,i)]
while 1:
try:
n = eval(input())
if n == 0: break
n -= 1-n%2
while any(not p[n-i] for i in [0,2,6,8]):
n -= 2 + (2 + 4*(1-p[n-6]))*(1-p[n-2])
print(n)
except:
pass | ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2*i::i] = [0 for j in range(2*i,r,i)]
while 1:
try:
n = eval(input())
if n == 0: break
n -= 1-n%2
while any(not p[n-i] for i in [0,2,6,8]):
n -= ref[p[n-2]][p[n-6]][p[n-8]]
... | 17 | 18 | 309 | 342 | r = 10000001
p = [1] * r
p[0] = p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2 * i :: i] = [0 for j in range(2 * i, r, i)]
while 1:
try:
n = eval(input())
if n == 0:
break
n -= 1 - n % 2
while any(not p[n - i] for i in [0, 2, 6, 8]):
n -= 2 + (... | ref = [[[10, 8], [4, 4]], [[10, 2], [4, 2]]]
r = 10000001
p = [1] * r
p[0] = p[1] = 0
for i in range(int(r**0.5)):
if p[i]:
p[2 * i :: i] = [0 for j in range(2 * i, r, i)]
while 1:
try:
n = eval(input())
if n == 0:
break
n -= 1 - n % 2
while any(not p[n - i] f... | false | 5.555556 | [
"+ref = [[[10, 8], [4, 4]], [[10, 2], [4, 2]]]",
"- n -= 2 + (2 + 4 * (1 - p[n - 6])) * (1 - p[n - 2])",
"+ n -= ref[p[n - 2]][p[n - 6]][p[n - 8]]"
] | false | 1.370202 | 2.661862 | 0.514753 | [
"s654754950",
"s532864054"
] |
u611509859 | p03304 | python | s923017149 | s061409095 | 78 | 17 | 5,588 | 2,940 | Accepted | Accepted | 78.21 | import math
from decimal import Decimal
n, m, d = list(map(int, input().split()))
if d == 0:
t = math.exp(float(Decimal.from_float(math.log(n)+math.log(m-1)-2*math.log(n))))
print(t)
else:
t = 2.0 * (n - d)*(m-1) / n ** 2
print(t) | n, m, d = list(map(int, input().split()))
if d == 0:
print((n * (m - 1) / n ** 2))
else:
print((2*(n - d) * (m - 1) / n ** 2)) | 9 | 5 | 248 | 128 | import math
from decimal import Decimal
n, m, d = list(map(int, input().split()))
if d == 0:
t = math.exp(
float(Decimal.from_float(math.log(n) + math.log(m - 1) - 2 * math.log(n)))
)
print(t)
else:
t = 2.0 * (n - d) * (m - 1) / n**2
print(t)
| n, m, d = list(map(int, input().split()))
if d == 0:
print((n * (m - 1) / n**2))
else:
print((2 * (n - d) * (m - 1) / n**2))
| false | 44.444444 | [
"-import math",
"-from decimal import Decimal",
"-",
"- t = math.exp(",
"- float(Decimal.from_float(math.log(n) + math.log(m - 1) - 2 * math.log(n)))",
"- )",
"- print(t)",
"+ print((n * (m - 1) / n**2))",
"- t = 2.0 * (n - d) * (m - 1) / n**2",
"- print(t)",
"+ print... | false | 0.110783 | 0.04422 | 2.505275 | [
"s923017149",
"s061409095"
] |
u102461423 | p03619 | python | s284023082 | s614157832 | 866 | 220 | 57,104 | 52,904 | Accepted | Accepted | 74.6 | import sys
input = sys.stdin.readline
from bisect import bisect_left
from math import pi
sx,sy,gx,gy = list(map(int,input().split()))
N = int(eval(input()))
XY = [tuple(int(x) for x in input().split()) for _ in range(N)]
if sx > gx:
sx,gx = gx,sx
sy,gy = gy,sy
gx -= sx
gy -= sy
XY = [(x-sx,y... | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def longest_increasing_subsequence(seq):
side = 'left'
N = len(seq)
INF = 10**18
dp = np.full_like(seq, INF)
for x in seq:
i = np.searchsorted... | 42 | 64 | 827 | 1,345 | import sys
input = sys.stdin.readline
from bisect import bisect_left
from math import pi
sx, sy, gx, gy = list(map(int, input().split()))
N = int(eval(input()))
XY = [tuple(int(x) for x in input().split()) for _ in range(N)]
if sx > gx:
sx, gx = gx, sx
sy, gy = gy, sy
gx -= sx
gy -= sy
XY = [(x - sx, y - sy) ... | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def longest_increasing_subsequence(seq):
side = "left"
N = len(seq)
INF = 10**18
dp = np.full_like(seq, INF)
for x in seq:
i = np.searchsorted(dp, x, side... | false | 34.375 | [
"+import numpy as np",
"-input = sys.stdin.readline",
"-from bisect import bisect_left",
"-from math import pi",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"-sx, sy, gx, gy = list(map(int, input().split()))",
"-N = int(eval(in... | false | 0.059159 | 0.356275 | 0.166048 | [
"s284023082",
"s614157832"
] |
u767797498 | p02597 | python | s410170707 | s051041610 | 59 | 27 | 9,344 | 9,392 | Accepted | Accepted | 54.24 | n=int(eval(input()))
s=eval(input())
li=0
ri=len(s)
cnt=0
while li<ri:
if s[li] == "W":
while li<ri:
ri-=1
if s[ri] == "R":
cnt+=1
break
li+=1
print(cnt)
| n=int(eval(input()))
s=eval(input())
rcnt=s.count("R")
# "R"をすべて左に寄せるならば、(0 ~ "R"個数-1)分の配列範囲はすべて"R"となる。
r_expected_arr=s[:rcnt]
# "R"期待範囲に"W"が存在する場合、"R"との交換が要求される。
# その場合、文字列中に"R"個数分の"R"が存在するため、交換対象の"R"は必ず存在する。
w_exchange_needed=r_expected_arr.count("W")
print(w_exchange_needed)
| 16 | 9 | 202 | 276 | n = int(eval(input()))
s = eval(input())
li = 0
ri = len(s)
cnt = 0
while li < ri:
if s[li] == "W":
while li < ri:
ri -= 1
if s[ri] == "R":
cnt += 1
break
li += 1
print(cnt)
| n = int(eval(input()))
s = eval(input())
rcnt = s.count("R")
# "R"をすべて左に寄せるならば、(0 ~ "R"個数-1)分の配列範囲はすべて"R"となる。
r_expected_arr = s[:rcnt]
# "R"期待範囲に"W"が存在する場合、"R"との交換が要求される。
# その場合、文字列中に"R"個数分の"R"が存在するため、交換対象の"R"は必ず存在する。
w_exchange_needed = r_expected_arr.count("W")
print(w_exchange_needed)
| false | 43.75 | [
"-li = 0",
"-ri = len(s)",
"-cnt = 0",
"-while li < ri:",
"- if s[li] == \"W\":",
"- while li < ri:",
"- ri -= 1",
"- if s[ri] == \"R\":",
"- cnt += 1",
"- break",
"- li += 1",
"-print(cnt)",
"+rcnt = s.count(\"R\")",
"+# \"R... | false | 0.036507 | 0.035103 | 1.040012 | [
"s410170707",
"s051041610"
] |
u461454424 | p02911 | python | s033521056 | s676221679 | 573 | 265 | 51,032 | 13,932 | Accepted | Accepted | 53.75 | N, K, Q = list(map(int, input().split()))
A = [0] * Q
for i in range(Q):
A[i] = int(eval(input()))
initial_point = [(K-Q)]*N
for i in range(Q):
initial_point[(A[i]-1)] += 1
for i in range(N):
if initial_point[i] > 0 :
print("Yes")
else:
print("No") | #input
N, K, Q = list(map(int, input().split()))
A = [0] * Q
for i in range(Q):
A[i] = int(eval(input()))
#output
from collections import Counter
point = [(K-Q)] * N
C = Counter(A)
for i, j in list(C.items()):
point[(i-1)] += j
for i in range(N):
if point[i] > 0:
print("Yes")
... | 15 | 19 | 288 | 329 | N, K, Q = list(map(int, input().split()))
A = [0] * Q
for i in range(Q):
A[i] = int(eval(input()))
initial_point = [(K - Q)] * N
for i in range(Q):
initial_point[(A[i] - 1)] += 1
for i in range(N):
if initial_point[i] > 0:
print("Yes")
else:
print("No")
| # input
N, K, Q = list(map(int, input().split()))
A = [0] * Q
for i in range(Q):
A[i] = int(eval(input()))
# output
from collections import Counter
point = [(K - Q)] * N
C = Counter(A)
for i, j in list(C.items()):
point[(i - 1)] += j
for i in range(N):
if point[i] > 0:
print("Yes")
else:
... | false | 21.052632 | [
"+# input",
"-initial_point = [(K - Q)] * N",
"-for i in range(Q):",
"- initial_point[(A[i] - 1)] += 1",
"+# output",
"+from collections import Counter",
"+",
"+point = [(K - Q)] * N",
"+C = Counter(A)",
"+for i, j in list(C.items()):",
"+ point[(i - 1)] += j",
"- if initial_point[i] ... | false | 0.075499 | 0.036338 | 2.077692 | [
"s033521056",
"s676221679"
] |
u011062360 | p03212 | python | s931866571 | s254207272 | 88 | 45 | 9,212 | 11,180 | Accepted | Accepted | 48.86 | n = int(eval(input()))
ans, q = 0, ["3", "5", "7"]
while q:
p = q.pop()
for s in ["3", "5", "7"]:
t = p + s
if int(t) <= n:
q.append(str(t))
if len(list(set(list(str(t))))) == 3:
ans += 1
print(ans) | n = int(eval(input()))
ans = 0
list_N = [["3", "5", "7"]]
for i in range(2, 10):
d = []
for a in list_N[-1]:
for b in ["3", "5", "7"]:
k = b + a
if n >= int(k) and "3" in k and "5" in k and "7" in k:
ans += 1
d.append(k)
list_N.append(... | 13 | 15 | 270 | 330 | n = int(eval(input()))
ans, q = 0, ["3", "5", "7"]
while q:
p = q.pop()
for s in ["3", "5", "7"]:
t = p + s
if int(t) <= n:
q.append(str(t))
if len(list(set(list(str(t))))) == 3:
ans += 1
print(ans)
| n = int(eval(input()))
ans = 0
list_N = [["3", "5", "7"]]
for i in range(2, 10):
d = []
for a in list_N[-1]:
for b in ["3", "5", "7"]:
k = b + a
if n >= int(k) and "3" in k and "5" in k and "7" in k:
ans += 1
d.append(k)
list_N.append(d)
print(ans)... | false | 13.333333 | [
"-ans, q = 0, [\"3\", \"5\", \"7\"]",
"-while q:",
"- p = q.pop()",
"- for s in [\"3\", \"5\", \"7\"]:",
"- t = p + s",
"- if int(t) <= n:",
"- q.append(str(t))",
"- if len(list(set(list(str(t))))) == 3:",
"+ans = 0",
"+list_N = [[\"3\", \"5\", \"7\"]]",
... | false | 0.048464 | 0.045733 | 1.059717 | [
"s931866571",
"s254207272"
] |
u511824539 | p02756 | python | s393364281 | s993323244 | 431 | 311 | 4,340 | 10,036 | Accepted | Accepted | 27.84 | S = eval(input())
Q = int(eval(input()))
bgn = ''
end = ''
is_inversion = False
for _ in range(Q):
query = input().split()
if query[0] == '1':
if is_inversion:
is_inversion = False
else:
is_inversion = True
elif query[0] == '2':
if query[1] == '... | inversion = 1 #1 は反転していない、 -1 は反転している。
s = eval(input())
s1 = ""
s2 = ""
n_query = int(eval(input()))
for i in range(n_query):
q = input().split()
if q[0] == '1':
inversion *= -1
elif q[0] == '2':
if inversion == 1:
if q[1] == '1':
s1 = s1 + q[2]... | 33 | 28 | 689 | 643 | S = eval(input())
Q = int(eval(input()))
bgn = ""
end = ""
is_inversion = False
for _ in range(Q):
query = input().split()
if query[0] == "1":
if is_inversion:
is_inversion = False
else:
is_inversion = True
elif query[0] == "2":
if query[1] == "1":
... | inversion = 1 # 1 は反転していない、 -1 は反転している。
s = eval(input())
s1 = ""
s2 = ""
n_query = int(eval(input()))
for i in range(n_query):
q = input().split()
if q[0] == "1":
inversion *= -1
elif q[0] == "2":
if inversion == 1:
if q[1] == "1":
s1 = s1 + q[2]
eli... | false | 15.151515 | [
"-S = eval(input())",
"-Q = int(eval(input()))",
"-bgn = \"\"",
"-end = \"\"",
"-is_inversion = False",
"-for _ in range(Q):",
"- query = input().split()",
"- if query[0] == \"1\":",
"- if is_inversion:",
"- is_inversion = False",
"- else:",
"- is_inve... | false | 0.048632 | 0.044094 | 1.102921 | [
"s393364281",
"s993323244"
] |
u638456847 | p02720 | python | s870023584 | s688201452 | 92 | 19 | 11,948 | 3,188 | Accepted | Accepted | 79.35 | from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
K = int(readline())
queue = deque([])
for i in range(1,10):
queue.append(i)
for i in range(K):
x = queue.popleft()
r = ... | # 桁dp + 二分探索
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def lunlun_num(N):
N = str(N)
L = len(N)
dp = [[0]*10 for j in range(L)]
for j in range(1,int(N[0])):
dp[0][j] = 1
flag = True
for i in range(L-1):
d = i... | 28 | 59 | 548 | 1,312 | from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
K = int(readline())
queue = deque([])
for i in range(1, 10):
queue.append(i)
for i in range(K):
x = queue.popleft()
r = x % 10
if r ... | # 桁dp + 二分探索
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def lunlun_num(N):
N = str(N)
L = len(N)
dp = [[0] * 10 for j in range(L)]
for j in range(1, int(N[0])):
dp[0][j] = 1
flag = True
for i in range(L - 1):
d = int(N[i + 1]... | false | 52.542373 | [
"-from collections import deque",
"+# 桁dp + 二分探索",
"+def lunlun_num(N):",
"+ N = str(N)",
"+ L = len(N)",
"+ dp = [[0] * 10 for j in range(L)]",
"+ for j in range(1, int(N[0])):",
"+ dp[0][j] = 1",
"+ flag = True",
"+ for i in range(L - 1):",
"+ d = int(N[i + 1])"... | false | 0.050642 | 0.036481 | 1.388172 | [
"s870023584",
"s688201452"
] |
u254871849 | p02891 | python | s004842323 | s103861025 | 20 | 17 | 3,316 | 3,064 | Accepted | Accepted | 15 | # 2019-11-25 06:26:24(JST)
import sys
def main():
s, k = sys.stdin.read().split()
k = int(k)
if len(s) == 1:
print((k // 2))
sys.exit()
if s.count(s[0]) == len(s):
if len(s) % 2 == 0:
ans = len(s) // 2 * k
else:
if k % 2 == 0:... | # 2019-11-25 06:26:24(JST)
import sys
def main():
s, k = sys.stdin.read().split()
k = int(k)
if len(s) == 1:
print((k // 2))
sys.exit()
if s.count(s[0]) == len(s):
if len(s) % 2 == 0:
ans = len(s) // 2 * k
else:
if k % 2 == 0:... | 51 | 56 | 1,073 | 1,235 | # 2019-11-25 06:26:24(JST)
import sys
def main():
s, k = sys.stdin.read().split()
k = int(k)
if len(s) == 1:
print((k // 2))
sys.exit()
if s.count(s[0]) == len(s):
if len(s) % 2 == 0:
ans = len(s) // 2 * k
else:
if k % 2 == 0:
ans... | # 2019-11-25 06:26:24(JST)
import sys
def main():
s, k = sys.stdin.read().split()
k = int(k)
if len(s) == 1:
print((k // 2))
sys.exit()
if s.count(s[0]) == len(s):
if len(s) % 2 == 0:
ans = len(s) // 2 * k
else:
if k % 2 == 0:
ans... | false | 8.928571 | [
"+ flag = False",
"- if count == 0:",
"+ if not flag:",
"+ flag = True",
"+ # 最初に何文字連続するかだけ記録しておく",
"+ # ここでのsameは一番最後に連続した文字数",
"+ # この場合は最後だけ調整が必要なので記録しておく"
] | false | 0.065872 | 0.052526 | 1.254083 | [
"s004842323",
"s103861025"
] |
u077291787 | p03800 | python | s133360014 | s600263369 | 128 | 116 | 4,852 | 4,852 | Accepted | Accepted | 9.38 | # ARC069D - Menagerie (ABC055D)
def check(a: int, b: int, S: str) -> list:
ret, cur, prev = [], a, b
for i in S:
ret += [cur]
if cur ^ (i == "o"): # oSo or oWx
prev, cur = cur, prev ^ 1 # both neighbors are different
else: # oSx or oWo
prev, cur = cur, ... | # ARC069D - Menagerie (ABC055D)
def check(a: int, b: int) -> list:
ret, cur, prev = [], a, b
for i in S:
ret += [cur]
if cur ^ (i == "o"): # oSo or oWx
prev, cur = cur, prev ^ 1 # both neighbors are different
else: # oSx or oWo
prev, cur = cur, prev # ... | 27 | 28 | 782 | 777 | # ARC069D - Menagerie (ABC055D)
def check(a: int, b: int, S: str) -> list:
ret, cur, prev = [], a, b
for i in S:
ret += [cur]
if cur ^ (i == "o"): # oSo or oWx
prev, cur = cur, prev ^ 1 # both neighbors are different
else: # oSx or oWo
prev, cur = cur, prev # ... | # ARC069D - Menagerie (ABC055D)
def check(a: int, b: int) -> list:
ret, cur, prev = [], a, b
for i in S:
ret += [cur]
if cur ^ (i == "o"): # oSo or oWx
prev, cur = cur, prev ^ 1 # both neighbors are different
else: # oSx or oWo
prev, cur = cur, prev # both are... | false | 3.571429 | [
"-def check(a: int, b: int, S: str) -> list:",
"+def check(a: int, b: int) -> list:",
"- N = int(input())",
"+ global S",
"+ N = int(eval(input()))",
"- ans = check(a, b, S)",
"+ ans = check(a, b)",
"- print(\"\".join(\"S\" if i else \"W\" for i in ans), s... | false | 0.034412 | 0.041065 | 0.837999 | [
"s133360014",
"s600263369"
] |
u633068244 | p00219 | python | s448258980 | s017445389 | 50 | 40 | 4,516 | 4,512 | Accepted | Accepted | 20 | while 1:
n=eval(input())
if n==0:break
h=[0]*10
for i in range(n):
h[int(input())]+=1
for i in range(10):
print("*"*h[i] if h[i] else "-") | while 1:
n=eval(input())
if n==0:break
h=[0]*10
for i in range(n):
h[int(input())]+=1
for i in h:
print("*"*i if i else "-") | 8 | 8 | 151 | 137 | while 1:
n = eval(input())
if n == 0:
break
h = [0] * 10
for i in range(n):
h[int(input())] += 1
for i in range(10):
print("*" * h[i] if h[i] else "-")
| while 1:
n = eval(input())
if n == 0:
break
h = [0] * 10
for i in range(n):
h[int(input())] += 1
for i in h:
print("*" * i if i else "-")
| false | 0 | [
"- for i in range(10):",
"- print(\"*\" * h[i] if h[i] else \"-\")",
"+ for i in h:",
"+ print(\"*\" * i if i else \"-\")"
] | false | 0.08435 | 0.040993 | 2.057662 | [
"s448258980",
"s017445389"
] |
u971091945 | p02720 | python | s363319514 | s287166152 | 159 | 106 | 9,844 | 10,868 | Accepted | Accepted | 33.33 | import collections
k = int(eval(input()))
n = 10**10
li = list(range(1,10))
num_li = li[:]
q = collections.deque(li)
count = 0
for i in range(1,n):
num = str(q.popleft())
go = int(num[-1])
if go != 0:
numa = num + str(go - 1)
num_li.append(int(numa))
q.append(int(num... | import collections
k = int(eval(input()))
li = [str(i) for i in range(1,10)]
st_li = li[:]
q = collections.deque(li)
count = 0
n = 10 ** 10
for i in range(1, n):
a = q.popleft()
num = int(a[-1])
if num != 0:
aa = a + str(num-1)
st_li.append(aa)
q.append(aa)
... | 31 | 30 | 628 | 587 | import collections
k = int(eval(input()))
n = 10**10
li = list(range(1, 10))
num_li = li[:]
q = collections.deque(li)
count = 0
for i in range(1, n):
num = str(q.popleft())
go = int(num[-1])
if go != 0:
numa = num + str(go - 1)
num_li.append(int(numa))
q.append(int(numa))
co... | import collections
k = int(eval(input()))
li = [str(i) for i in range(1, 10)]
st_li = li[:]
q = collections.deque(li)
count = 0
n = 10**10
for i in range(1, n):
a = q.popleft()
num = int(a[-1])
if num != 0:
aa = a + str(num - 1)
st_li.append(aa)
q.append(aa)
count += 1
a... | false | 3.225806 | [
"-n = 10**10",
"-li = list(range(1, 10))",
"-num_li = li[:]",
"+li = [str(i) for i in range(1, 10)]",
"+st_li = li[:]",
"+n = 10**10",
"- num = str(q.popleft())",
"- go = int(num[-1])",
"- if go != 0:",
"- numa = num + str(go - 1)",
"- num_li.append(int(numa))",
"- ... | false | 0.061663 | 0.125981 | 0.489463 | [
"s363319514",
"s287166152"
] |
u464113929 | p03162 | python | s734261771 | s524623739 | 1,375 | 445 | 14,844 | 3,064 | Accepted | Accepted | 67.64 | N = int(eval(input()))
dp = [[0 for _ in range(3)] for i in range(N)]
a,b,c = list(map(int,input().split()))
dpa = a
dpb = b
dpc = c
for i in range(1,N):
dpap = dpa
dpbp = dpb
dpcp = dpc
a,b,c = list(map(int,input().split()))
dpa = max(dpbp + a, dpcp + a)
dpb = max(dpap + b, dpcp + b... | N = int(eval(input()))
a,b,c = list(map(int,input().split()))
dpa = a
dpb = b
dpc = c
for i in range(1,N):
dpap = dpa
dpbp = dpb
dpcp = dpc
a,b,c = list(map(int,input().split()))
dpa = max(dpbp + a, dpcp + a)
dpb = max(dpap + b, dpcp + b)
dpc = max(dpap + c, dpbp + c)
print((max... | 16 | 15 | 378 | 330 | N = int(eval(input()))
dp = [[0 for _ in range(3)] for i in range(N)]
a, b, c = list(map(int, input().split()))
dpa = a
dpb = b
dpc = c
for i in range(1, N):
dpap = dpa
dpbp = dpb
dpcp = dpc
a, b, c = list(map(int, input().split()))
dpa = max(dpbp + a, dpcp + a)
dpb = max(dpap + b, dpcp + b)
... | N = int(eval(input()))
a, b, c = list(map(int, input().split()))
dpa = a
dpb = b
dpc = c
for i in range(1, N):
dpap = dpa
dpbp = dpb
dpcp = dpc
a, b, c = list(map(int, input().split()))
dpa = max(dpbp + a, dpcp + a)
dpb = max(dpap + b, dpcp + b)
dpc = max(dpap + c, dpbp + c)
print((max(dpa, ... | false | 6.25 | [
"-dp = [[0 for _ in range(3)] for i in range(N)]"
] | false | 0.061495 | 0.040926 | 1.502598 | [
"s734261771",
"s524623739"
] |
u191874006 | p02586 | python | s219784559 | s929558677 | 837 | 736 | 359,408 | 358,840 | Accepted | Accepted | 12.07 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from... | 36 | 37 | 1,163 | 1,142 | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collectio... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collectio... | false | 2.702703 | [
"+ v = maze[i][j]",
"- dp1[i][j - 1],",
"- dp1[i - 1][j] + maze[i][j],",
"- dp2[i - 1][j] + maze[i][j],",
"- dp3[i - 1][j] + maze[i][j],",
"+ dp1[i][j - 1], dp1[i - 1][j] + v, dp2[i - 1][j] + v, dp3[i - 1][j] + v",
"- dp2[i][j] = max(d... | false | 0.038359 | 0.048377 | 0.792932 | [
"s219784559",
"s929558677"
] |
u780698286 | p02833 | python | s805487875 | s472966275 | 30 | 26 | 9,072 | 8,868 | Accepted | Accepted | 13.33 | import sys
n = int(eval(input()))
if n % 2 == 1:
print((0))
sys.exit()
ans = 0
x = 2
while n >= x:
x *= 5
ans += n // x
print(ans) | n = int(eval(input()))
if n%2 == 1:
print((0))
else:
x = 10
ans = 0
while n >= x:
ans += n // x
x *= 5
print(ans) | 12 | 10 | 142 | 150 | import sys
n = int(eval(input()))
if n % 2 == 1:
print((0))
sys.exit()
ans = 0
x = 2
while n >= x:
x *= 5
ans += n // x
print(ans)
| n = int(eval(input()))
if n % 2 == 1:
print((0))
else:
x = 10
ans = 0
while n >= x:
ans += n // x
x *= 5
print(ans)
| false | 16.666667 | [
"-import sys",
"-",
"- sys.exit()",
"-ans = 0",
"-x = 2",
"-while n >= x:",
"- x *= 5",
"- ans += n // x",
"-print(ans)",
"+else:",
"+ x = 10",
"+ ans = 0",
"+ while n >= x:",
"+ ans += n // x",
"+ x *= 5",
"+ print(ans)"
] | false | 0.031238 | 0.03615 | 0.864114 | [
"s805487875",
"s472966275"
] |
u108808596 | p03107 | python | s836815951 | s832861458 | 33 | 26 | 2,936 | 3,444 | Accepted | Accepted | 21.21 | from collections import Counter
cnt=Counter(input())
print(2*min(cnt['0'],cnt['1'])) | from collections import Counter
cnt=Counter(eval(input()))
print((2*min(cnt['0'],cnt['1']))) | 3 | 3 | 89 | 86 | from collections import Counter
cnt = Counter(input())
print(2 * min(cnt["0"], cnt["1"]))
| from collections import Counter
cnt = Counter(eval(input()))
print((2 * min(cnt["0"], cnt["1"])))
| false | 0 | [
"-cnt = Counter(input())",
"-print(2 * min(cnt[\"0\"], cnt[\"1\"]))",
"+cnt = Counter(eval(input()))",
"+print((2 * min(cnt[\"0\"], cnt[\"1\"])))"
] | false | 0.044003 | 0.044424 | 0.990533 | [
"s836815951",
"s832861458"
] |
u025501820 | p03476 | python | s712781687 | s761125725 | 1,242 | 946 | 3,860 | 8,092 | Accepted | Accepted | 23.83 | d = [0]
ans = 0
def prime(n):
if n == 1:
return False
i = 2
while i * i <= n:
if n % i == 0:
return False
else:
i += 1
return True
for i in range(10 ** 5 // 2):
if prime(2 * i + 1) and prime(i + 1):
ans += 1
d.append(... | #!/usr/bin/env python3
Q = int(eval(input()))
my_max = 10 ** 5
nums = [i for i in range(2, my_max + 1)]
p = 2
idx = 0
while p * p <= my_max and idx < len(nums):
nums = [n for n in nums if n % p != 0 or n == p]
idx += 1
p = nums[idx]
primes = set(nums)
ruiseki = [0]
total = 0
for i in rang... | 24 | 24 | 450 | 545 | d = [0]
ans = 0
def prime(n):
if n == 1:
return False
i = 2
while i * i <= n:
if n % i == 0:
return False
else:
i += 1
return True
for i in range(10**5 // 2):
if prime(2 * i + 1) and prime(i + 1):
ans += 1
d.append(ans)
Q = int(eval(inp... | #!/usr/bin/env python3
Q = int(eval(input()))
my_max = 10**5
nums = [i for i in range(2, my_max + 1)]
p = 2
idx = 0
while p * p <= my_max and idx < len(nums):
nums = [n for n in nums if n % p != 0 or n == p]
idx += 1
p = nums[idx]
primes = set(nums)
ruiseki = [0]
total = 0
for i in range(1, my_max + 1):
... | false | 0 | [
"-d = [0]",
"-ans = 0",
"-",
"-",
"-def prime(n):",
"- if n == 1:",
"- return False",
"- i = 2",
"- while i * i <= n:",
"- if n % i == 0:",
"- return False",
"- else:",
"- i += 1",
"- return True",
"-",
"-",
"-for i in range(10**... | false | 0.627555 | 0.186235 | 3.369696 | [
"s712781687",
"s761125725"
] |
u994988729 | p02755 | python | s419969929 | s772394064 | 73 | 24 | 2,940 | 2,940 | Accepted | Accepted | 67.12 | A, B = list(map(int, input().split()))
ans = -1
for x in range(100000):
a = int(x * 0.08)
b = int(x * 0.1)
if a == A and b == B:
ans = x
break
print(ans)
| A, B = list(map(int, input().split()))
for x in range(10000):
a = int(x * 0.08)
b = int(x * 0.1)
if a == A and b == B:
print(x)
exit()
print((-1)) | 12 | 8 | 190 | 173 | A, B = list(map(int, input().split()))
ans = -1
for x in range(100000):
a = int(x * 0.08)
b = int(x * 0.1)
if a == A and b == B:
ans = x
break
print(ans)
| A, B = list(map(int, input().split()))
for x in range(10000):
a = int(x * 0.08)
b = int(x * 0.1)
if a == A and b == B:
print(x)
exit()
print((-1))
| false | 33.333333 | [
"-ans = -1",
"-for x in range(100000):",
"+for x in range(10000):",
"- ans = x",
"- break",
"-print(ans)",
"+ print(x)",
"+ exit()",
"+print((-1))"
] | false | 0.181752 | 0.043493 | 4.178827 | [
"s419969929",
"s772394064"
] |
u803617136 | p02959 | python | s383743178 | s936134326 | 251 | 213 | 18,624 | 18,348 | Accepted | Accepted | 15.14 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = a[::-1]
b = b[::-1]
ans = 0
for i, bi in enumerate(b):
ans += min(a[i], b[i])
remain = max(0, b[i] - a[i])
ans += min(a[i + 1], remain)
a[i + 1] = max(0, a[i + 1] - remain)
print(ans) | n = int(eval(input()))
A = list(map(int, input().split()))[::-1]
B = list(map(int, input().split()))[::-1]
ans = 0
for i, b in enumerate(B):
ans += min(A[i], b)
remain = max(0, b - A[i])
ans += min(A[i + 1], remain)
A[i + 1] = max(0, A[i + 1] - remain)
print(ans) | 13 | 12 | 305 | 286 | n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = a[::-1]
b = b[::-1]
ans = 0
for i, bi in enumerate(b):
ans += min(a[i], b[i])
remain = max(0, b[i] - a[i])
ans += min(a[i + 1], remain)
a[i + 1] = max(0, a[i + 1] - remain)
print(ans)
| n = int(eval(input()))
A = list(map(int, input().split()))[::-1]
B = list(map(int, input().split()))[::-1]
ans = 0
for i, b in enumerate(B):
ans += min(A[i], b)
remain = max(0, b - A[i])
ans += min(A[i + 1], remain)
A[i + 1] = max(0, A[i + 1] - remain)
print(ans)
| false | 7.692308 | [
"-a = list(map(int, input().split()))",
"-b = list(map(int, input().split()))",
"-a = a[::-1]",
"-b = b[::-1]",
"+A = list(map(int, input().split()))[::-1]",
"+B = list(map(int, input().split()))[::-1]",
"-for i, bi in enumerate(b):",
"- ans += min(a[i], b[i])",
"- remain = max(0, b[i] - a[i])... | false | 0.056139 | 0.054331 | 1.033276 | [
"s383743178",
"s936134326"
] |
u186838327 | p03273 | python | s985144141 | s243597648 | 31 | 20 | 4,468 | 3,064 | Accepted | Accepted | 35.48 | h, w = map(int, input().split())
a = ['']*h
for i in range(h):
a[i] = input()
row = [False] * h
col = [False] * w
for i in range(h):
for j in range(w):
if a[i][j] == '#':
row[i] = True
col[j] = True
for i in range(h):
if row[i]:
for j in range(w... | h, w = list(map(int, input().split()))
l = []
for i in range(h):
a = str(eval(input()))
if a == '.'*w:
continue
l.append(a)
skip = []
for i in range(w):
for j in range(len(l)):
if l[j][i] == '#':
break
else:
skip.append(i)
skip = set(skip)
l_ = [0]*len(l)
for i in range(l... | 20 | 27 | 405 | 458 | h, w = map(int, input().split())
a = [""] * h
for i in range(h):
a[i] = input()
row = [False] * h
col = [False] * w
for i in range(h):
for j in range(w):
if a[i][j] == "#":
row[i] = True
col[j] = True
for i in range(h):
if row[i]:
for j in range(w):
if col... | h, w = list(map(int, input().split()))
l = []
for i in range(h):
a = str(eval(input()))
if a == "." * w:
continue
l.append(a)
skip = []
for i in range(w):
for j in range(len(l)):
if l[j][i] == "#":
break
else:
skip.append(i)
skip = set(skip)
l_ = [0] * len(l)
for ... | false | 25.925926 | [
"-h, w = map(int, input().split())",
"-a = [\"\"] * h",
"+h, w = list(map(int, input().split()))",
"+l = []",
"- a[i] = input()",
"-row = [False] * h",
"-col = [False] * w",
"-for i in range(h):",
"+ a = str(eval(input()))",
"+ if a == \".\" * w:",
"+ continue",
"+ l.append(... | false | 0.066678 | 0.067831 | 0.983004 | [
"s985144141",
"s243597648"
] |
u296518383 | p02928 | python | s558337683 | s510157625 | 1,243 | 274 | 3,188 | 41,964 | Accepted | Accepted | 77.96 | mod=10**9+7
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
s=[0]*N
t=[0]*N
for i in range(N):
for j in range(i+1,N):
if A[i]>A[j]:
s[i]+=1
#print(s)
for i in range(N):
for j in range(N):
if A[i]>A[j]:
t[i]+=1
#print(t)
for i in range(N):
s[i]=(s[i... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
in_A, out_A = 0, 0
for i in range(N):
for j in range(i + 1, N):
if A[i] > A[j]:
in_A += 1
for j in range(N):
if A[i] > A[j]:
out_A += 1
print(((in_A * K + out_A * K * (K - 1) // 2) % MOD... | 27 | 16 | 404 | 317 | mod = 10**9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
s = [0] * N
t = [0] * N
for i in range(N):
for j in range(i + 1, N):
if A[i] > A[j]:
s[i] += 1
# print(s)
for i in range(N):
for j in range(N):
if A[i] > A[j]:
t[i] += 1
# print(t)
... | N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10**9 + 7
in_A, out_A = 0, 0
for i in range(N):
for j in range(i + 1, N):
if A[i] > A[j]:
in_A += 1
for j in range(N):
if A[i] > A[j]:
out_A += 1
print(((in_A * K + out_A * K * (K - 1) // 2) ... | false | 40.740741 | [
"-mod = 10**9 + 7",
"-s = [0] * N",
"-t = [0] * N",
"+MOD = 10**9 + 7",
"+in_A, out_A = 0, 0",
"- s[i] += 1",
"-# print(s)",
"-for i in range(N):",
"+ in_A += 1",
"- t[i] += 1",
"-# print(t)",
"-for i in range(N):",
"- s[i] = (s[i] * K) % mod",
"- t[i... | false | 0.077382 | 0.03911 | 1.978543 | [
"s558337683",
"s510157625"
] |
u455034505 | p02713 | python | s935146273 | s981987201 | 696 | 470 | 9,176 | 9,160 | Accepted | Accepted | 32.47 | import math
K = int(eval(input()))
sum = 0
for a in range(K):
sum += a + 1
#print(a + 1, a + 1)
for b in range(K):
if a < b:
gcd2_sum = math.gcd(a + 1, b + 1) * 3 * 2
sum += gcd2_sum
#print(a + 1, b + 1, gcd2_sum)
for c in range(K):
... | import math
K = int(eval(input()))
sum = 0
for a in range(1,K + 1):
sum += a
#print(a, a)
for b in range(a + 1,K + 1):
gcd2_sum = math.gcd(a, b) * 3 * 2
sum += gcd2_sum
#print(a, b, gcd2_sum)
for c in range(b + 1, K + 1):
gcd3_sum = math.gcd(math.... | 20 | 18 | 524 | 413 | import math
K = int(eval(input()))
sum = 0
for a in range(K):
sum += a + 1
# print(a + 1, a + 1)
for b in range(K):
if a < b:
gcd2_sum = math.gcd(a + 1, b + 1) * 3 * 2
sum += gcd2_sum
# print(a + 1, b + 1, gcd2_sum)
for c in range(K):
... | import math
K = int(eval(input()))
sum = 0
for a in range(1, K + 1):
sum += a
# print(a, a)
for b in range(a + 1, K + 1):
gcd2_sum = math.gcd(a, b) * 3 * 2
sum += gcd2_sum
# print(a, b, gcd2_sum)
for c in range(b + 1, K + 1):
gcd3_sum = math.gcd(math.gcd(a, b), c... | false | 10 | [
"-for a in range(K):",
"- sum += a + 1",
"- # print(a + 1, a + 1)",
"- for b in range(K):",
"- if a < b:",
"- gcd2_sum = math.gcd(a + 1, b + 1) * 3 * 2",
"- sum += gcd2_sum",
"- # print(a + 1, b + 1, gcd2_sum)",
"- for c in range(K):",
"-... | false | 0.071154 | 0.072204 | 0.985465 | [
"s935146273",
"s981987201"
] |
u968166680 | p03607 | python | s238146592 | s716362474 | 73 | 67 | 22,436 | 22,140 | Accepted | Accepted | 8.22 | import sys
from collections import defaultdict
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *A = list(map(int, read().split()))
d = defaultdict(bool)
for a in A:
if... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *A = list(map(int, read().split()))
d = dict()
for a in A:
if a in d and d[a]:
d[a] = False
... | 29 | 28 | 510 | 475 | import sys
from collections import defaultdict
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *A = list(map(int, read().split()))
d = defaultdict(bool)
for a in A:
if d[a]:
... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
N, *A = list(map(int, read().split()))
d = dict()
for a in A:
if a in d and d[a]:
d[a] = False
else:
... | false | 3.448276 | [
"-from collections import defaultdict",
"- d = defaultdict(bool)",
"+ d = dict()",
"- if d[a]:",
"+ if a in d and d[a]:",
"- ans = sum(1 for f in list(d.values()) if f)",
"+ ans = sum(1 for flag in list(d.values()) if flag)"
] | false | 0.068575 | 0.035976 | 1.906109 | [
"s238146592",
"s716362474"
] |
u257162238 | p02579 | python | s454323463 | s885965596 | 1,907 | 395 | 235,676 | 90,816 | Accepted | Accepted | 79.29 | import sys
input = sys.stdin.readline
from collections import deque
from itertools import product
import heapq
def read():
H, W = list(map(int, input().strip().split()))
CH, CW = list(map(int, input().strip().split()))
DH, DW = list(map(int, input().strip().split()))
S = [[0 for j in range(... | import sys
input = sys.stdin.readline
from collections import deque
from itertools import product
import heapq
def read():
H, W = list(map(int, input().strip().split()))
CH, CW = list(map(int, input().strip().split()))
DH, DW = list(map(int, input().strip().split()))
S = [[0 for j in range(... | 57 | 58 | 1,687 | 1,746 | import sys
input = sys.stdin.readline
from collections import deque
from itertools import product
import heapq
def read():
H, W = list(map(int, input().strip().split()))
CH, CW = list(map(int, input().strip().split()))
DH, DW = list(map(int, input().strip().split()))
S = [[0 for j in range(W)] for i ... | import sys
input = sys.stdin.readline
from collections import deque
from itertools import product
import heapq
def read():
H, W = list(map(int, input().strip().split()))
CH, CW = list(map(int, input().strip().split()))
DH, DW = list(map(int, input().strip().split()))
S = [[0 for j in range(W)] for i ... | false | 1.724138 | [
"+ S[CH - 1][CW - 1] = 0",
"- q.appendleft((CH - 1, CW - 1, 0))",
"+ q.appendleft((CH - 1, CW - 1))",
"- y0, x0, d0 = q.popleft()",
"- if 0 <= S[y0][x0] < d0:",
"- continue",
"- S[y0][x0] = d0",
"+ y0, x0 = q.popleft()",
"+ d0 = S[y0][x0]",
"-... | false | 0.121198 | 0.157103 | 0.771456 | [
"s454323463",
"s885965596"
] |
u283719735 | p03371 | python | s881709263 | s289120098 | 131 | 17 | 3,064 | 3,064 | Accepted | Accepted | 87.02 | A, B, C, X, Y = list(map(int, input().split()))
# xn, yn = 0, 0
# price = 0
#
# if (A+B) >= 2*C and A >= 1 and B >= 1:
# ammount = min(X, Y)
# price += C * ammount * 2
# xn += ammount
# yn += ammount
#
# if A >= 2*C and X > xn:
# ammount = X - xn
# price += C * X * 2
# xn +=... | A, B, C, X, Y = list(map(int, input().split()))
xn, yn = 0, 0
price = 0
if A >= 2*C and X > xn:
ammount = X - xn
price += C * X * 2
xn += X
yn += X
if B >= 2*C and Y > yn:
ammount = Y - yn
price += C * ammount * 2
xn += ammount
yn += ammount
if (A+B) >= 2*C and (X - ... | 38 | 42 | 763 | 789 | A, B, C, X, Y = list(map(int, input().split()))
# xn, yn = 0, 0
# price = 0
#
# if (A+B) >= 2*C and A >= 1 and B >= 1:
# ammount = min(X, Y)
# price += C * ammount * 2
# xn += ammount
# yn += ammount
#
# if A >= 2*C and X > xn:
# ammount = X - xn
# price += C * X * 2
# xn += X
# yn += X
... | A, B, C, X, Y = list(map(int, input().split()))
xn, yn = 0, 0
price = 0
if A >= 2 * C and X > xn:
ammount = X - xn
price += C * X * 2
xn += X
yn += X
if B >= 2 * C and Y > yn:
ammount = Y - yn
price += C * ammount * 2
xn += ammount
yn += ammount
if (A + B) >= 2 * C and (X - xn) >= 1 and ... | false | 9.52381 | [
"-# xn, yn = 0, 0",
"-# price = 0",
"+xn, yn = 0, 0",
"+price = 0",
"+if A >= 2 * C and X > xn:",
"+ ammount = X - xn",
"+ price += C * X * 2",
"+ xn += X",
"+ yn += X",
"+if B >= 2 * C and Y > yn:",
"+ ammount = Y - yn",
"+ price += C * ammount * 2",
"+ xn += ammount",
... | false | 0.153337 | 0.035465 | 4.323642 | [
"s881709263",
"s289120098"
] |
u181719868 | p03433 | python | s731405172 | s820918558 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | # coding: utf-8
# Your code here!
N = int(eval(input()))
S = int(eval(input()))
if N%500<=S:
print("Yes")
else:
print("No") | # coding: utf-8
# Your code here!
N = int(eval(input()))
A = int(eval(input()))
if N%500 <= A:
print("Yes")
else:
print("No")
| 10 | 9 | 130 | 132 | # coding: utf-8
# Your code here!
N = int(eval(input()))
S = int(eval(input()))
if N % 500 <= S:
print("Yes")
else:
print("No")
| # coding: utf-8
# Your code here!
N = int(eval(input()))
A = int(eval(input()))
if N % 500 <= A:
print("Yes")
else:
print("No")
| false | 10 | [
"-S = int(eval(input()))",
"-if N % 500 <= S:",
"+A = int(eval(input()))",
"+if N % 500 <= A:"
] | false | 0.008927 | 0.043924 | 0.203237 | [
"s731405172",
"s820918558"
] |
u856364553 | p02862 | python | s998398197 | s909714097 | 1,330 | 123 | 121,968 | 3,064 | Accepted | Accepted | 90.75 | import math
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, N + 1 ):
g1.append( ( g1[-1] * i ) % mod )
inverse.append( ( -inverse[mo... | import math
def cmb(n, r, mod):
r = min(r, n-r)
a = 1
b = 1
for i in range(r):
a = (a * (n-i)) % mod
b = (b * (i+1)) % mod
return a * pow(b, mod-2, mod) % mod
X, Y = [int(i) for i in input().split()]
mod = 10**9+7
x_tmp = 2*X - Y
y_tmp = 2*Y - X
if x_tmp <... | 29 | 28 | 604 | 493 | import math
def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod // i)) ... | import math
def cmb(n, r, mod):
r = min(r, n - r)
a = 1
b = 1
for i in range(r):
a = (a * (n - i)) % mod
b = (b * (i + 1)) % mod
return a * pow(b, mod - 2, mod) % mod
X, Y = [int(i) for i in input().split()]
mod = 10**9 + 7
x_tmp = 2 * X - Y
y_tmp = 2 * Y - X
if x_tmp < 0 or y_tm... | false | 3.448276 | [
"- if r < 0 or r > n:",
"- return 0",
"- return g1[n] * g2[r] * g2[n - r] % mod",
"+ a = 1",
"+ b = 1",
"+ for i in range(r):",
"+ a = (a * (n - i)) % mod",
"+ b = (b * (i + 1)) % mod",
"+ return a * pow(b, mod - 2, mod) % mod",
"+X, Y = [int(i) for i in inpu... | false | 1.500773 | 0.051891 | 28.921852 | [
"s998398197",
"s909714097"
] |
u273010357 | p03775 | python | s763299199 | s919170474 | 47 | 30 | 2,940 | 3,060 | Accepted | Accepted | 36.17 | n = int(eval(input()))
tmp = n
for x in range(1, n+1):
y = n//x
if x > y:
break
if n % x == 0:
tmp = y
ans = len(str(tmp))
print(ans) | N = int(eval(input()))
answer = 10**10
M = int(N**0.5)+1
for a in range(1,M):
if N%a==0:
b = N//a
F = max(len(str(a)),len(str(b)))
answer = min(answer,F)
print(answer) | 10 | 10 | 164 | 199 | n = int(eval(input()))
tmp = n
for x in range(1, n + 1):
y = n // x
if x > y:
break
if n % x == 0:
tmp = y
ans = len(str(tmp))
print(ans)
| N = int(eval(input()))
answer = 10**10
M = int(N**0.5) + 1
for a in range(1, M):
if N % a == 0:
b = N // a
F = max(len(str(a)), len(str(b)))
answer = min(answer, F)
print(answer)
| false | 0 | [
"-n = int(eval(input()))",
"-tmp = n",
"-for x in range(1, n + 1):",
"- y = n // x",
"- if x > y:",
"- break",
"- if n % x == 0:",
"- tmp = y",
"-ans = len(str(tmp))",
"-print(ans)",
"+N = int(eval(input()))",
"+answer = 10**10",
"+M = int(N**0.5) + 1",
"+for a in ra... | false | 0.051801 | 0.06151 | 0.842155 | [
"s763299199",
"s919170474"
] |
u580697892 | p02954 | python | s880760941 | s695368232 | 181 | 158 | 6,408 | 6,408 | Accepted | Accepted | 12.71 | # coding: utf-8
S = eval(input())
ans = [1 for i in range(len(S))]
tmp = []
lr = []
l, r = 0, 0
tl = 0
cnt = 0
for i in range(len(S) - 1):
if S[i] + S[i+1] == "RL":
r, l = i, i + 1
if S[i] + S[i+1] == "LR":
if cnt != 0:
tl += 1
for j in range(tl, i + 1):
... | # coding: utf-8
from math import ceil
from bisect import bisect_left
S = eval(input())
L = []
r, l = 0, 0
cnt = 0
tl = 0
ans = [1 for _ in range(len(S))]
for i in range(len(S)-1):
if S[i] == "R" and S[i+1] == "L":
r, l = i, i+1
if S[i] == "L" and S[i+1] == "R":
if cnt != 0:
... | 38 | 37 | 915 | 901 | # coding: utf-8
S = eval(input())
ans = [1 for i in range(len(S))]
tmp = []
lr = []
l, r = 0, 0
tl = 0
cnt = 0
for i in range(len(S) - 1):
if S[i] + S[i + 1] == "RL":
r, l = i, i + 1
if S[i] + S[i + 1] == "LR":
if cnt != 0:
tl += 1
for j in range(tl, i + 1):
if j ... | # coding: utf-8
from math import ceil
from bisect import bisect_left
S = eval(input())
L = []
r, l = 0, 0
cnt = 0
tl = 0
ans = [1 for _ in range(len(S))]
for i in range(len(S) - 1):
if S[i] == "R" and S[i + 1] == "L":
r, l = i, i + 1
if S[i] == "L" and S[i + 1] == "R":
if cnt != 0:
... | false | 2.631579 | [
"+from math import ceil",
"+from bisect import bisect_left",
"+",
"-ans = [1 for i in range(len(S))]",
"-tmp = []",
"-lr = []",
"-l, r = 0, 0",
"+L = []",
"+r, l = 0, 0",
"+cnt = 0",
"-cnt = 0",
"+ans = [1 for _ in range(len(S))]",
"- if S[i] + S[i + 1] == \"RL\":",
"+ if S[i] == \"R... | false | 0.045024 | 0.0452 | 0.996099 | [
"s880760941",
"s695368232"
] |
u919730120 | p02624 | python | s009650621 | s920640796 | 2,515 | 722 | 9,164 | 110,876 | Accepted | Accepted | 71.29 | n=int(eval(input()))
ans=0
for i in range(1,n+1):
x=n//i
ans+=i*(x+1)*x//2
print(ans) | from numba import jit
@jit(cache = True)
def main():
n=int(eval(input()))
ans=0
for i in range(1,n+1):
x=n//i
ans+=i*(x+1)*x//2
print(ans)
if __name__ == '__main__':
main() | 6 | 12 | 92 | 214 | n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
x = n // i
ans += i * (x + 1) * x // 2
print(ans)
| from numba import jit
@jit(cache=True)
def main():
n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
x = n // i
ans += i * (x + 1) * x // 2
print(ans)
if __name__ == "__main__":
main()
| false | 50 | [
"-n = int(eval(input()))",
"-ans = 0",
"-for i in range(1, n + 1):",
"- x = n // i",
"- ans += i * (x + 1) * x // 2",
"-print(ans)",
"+from numba import jit",
"+",
"+",
"+@jit(cache=True)",
"+def main():",
"+ n = int(eval(input()))",
"+ ans = 0",
"+ for i in range(1, n + 1):... | false | 0.830774 | 0.036555 | 22.72684 | [
"s009650621",
"s920640796"
] |
u504836877 | p02791 | python | s177102940 | s907827331 | 253 | 97 | 76,880 | 32,328 | Accepted | Accepted | 61.66 | N = int(eval(input()))
P = [int(p) for p in input().split()]
ans = 0
m = P[0]
for i in range(N):
if P[i] <= m:
ans += 1
m = P[i]
print(ans) | N = int(eval(input()))
P = [int(p) for p in input().split()]
M = N+1
cnt = 0
for p in P:
if p < M:
cnt += 1
M = p
print(cnt) | 11 | 11 | 165 | 150 | N = int(eval(input()))
P = [int(p) for p in input().split()]
ans = 0
m = P[0]
for i in range(N):
if P[i] <= m:
ans += 1
m = P[i]
print(ans)
| N = int(eval(input()))
P = [int(p) for p in input().split()]
M = N + 1
cnt = 0
for p in P:
if p < M:
cnt += 1
M = p
print(cnt)
| false | 0 | [
"-ans = 0",
"-m = P[0]",
"-for i in range(N):",
"- if P[i] <= m:",
"- ans += 1",
"- m = P[i]",
"-print(ans)",
"+M = N + 1",
"+cnt = 0",
"+for p in P:",
"+ if p < M:",
"+ cnt += 1",
"+ M = p",
"+print(cnt)"
] | false | 0.079825 | 0.037721 | 2.116213 | [
"s177102940",
"s907827331"
] |
u903948194 | p03146 | python | s606387625 | s108571798 | 61 | 41 | 3,064 | 3,064 | Accepted | Accepted | 32.79 | s = int(eval(input()))
def func(n):
if n%2 == 0:
return int(n / 2)
else:
return 3 * n + 1
a = [s]
i = 0
flg = 1
while(flg):
a.append(func(a[i]))
#print(a)
for k in range(len(a)):
for l in range(1, len(a)-k):
if a[k] == a[k+l]:
... | s = int(eval(input()))
def func(n):
if n%2 == 0:
return int(n / 2)
else:
return 3 * n + 1
def check(a, k):
for l in range(1, len(a)-k):
if a[k] == a[k+l]:
print((k+l+1))
return False
return True
a = [s]
i = 0
flg = 1
while(flg):... | 27 | 27 | 458 | 463 | s = int(eval(input()))
def func(n):
if n % 2 == 0:
return int(n / 2)
else:
return 3 * n + 1
a = [s]
i = 0
flg = 1
while flg:
a.append(func(a[i]))
# print(a)
for k in range(len(a)):
for l in range(1, len(a) - k):
if a[k] == a[k + l]:
print((k + ... | s = int(eval(input()))
def func(n):
if n % 2 == 0:
return int(n / 2)
else:
return 3 * n + 1
def check(a, k):
for l in range(1, len(a) - k):
if a[k] == a[k + l]:
print((k + l + 1))
return False
return True
a = [s]
i = 0
flg = 1
while flg:
a.append... | false | 0 | [
"+def check(a, k):",
"+ for l in range(1, len(a) - k):",
"+ if a[k] == a[k + l]:",
"+ print((k + l + 1))",
"+ return False",
"+ return True",
"+",
"+",
"- for l in range(1, len(a) - k):",
"- if a[k] == a[k + l]:",
"- print((k + ... | false | 0.066476 | 0.138993 | 0.478269 | [
"s606387625",
"s108571798"
] |
u353797797 | p03078 | python | s525810164 | s322499826 | 860 | 37 | 4,980 | 5,232 | Accepted | Accepted | 95.7 | from heapq import *
an, bn, cn, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
la = len(a)
lb = len(b)
lc = len(c)
ans = []
hp = [[-(a[0] + b[0] + c[0... | from heapq import *
an, bn, cn, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
la = len(a)
lb = len(b)
lc = len(c)
ans = []
hp = [[-(a[0] + b[0] + c[0... | 35 | 35 | 983 | 983 | from heapq import *
an, bn, cn, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
la = len(a)
lb = len(b)
lc = len(c)
ans = []
hp = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
h... | from heapq import *
an, bn, cn, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
la = len(a)
lb = len(b)
lc = len(c)
ans = []
hp = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
h... | false | 0 | [
"-sumi = [[0, 0, 0]]",
"+sumi = {(0, 0, 0)}",
"- if ai + 1 < la and [ai + 1, bi, ci] not in sumi:",
"+ if ai + 1 < la and (ai + 1, bi, ci) not in sumi:",
"- sumi += [[ai + 1, bi, ci]]",
"- if bi + 1 < lb and [ai, bi + 1, ci] not in sumi:",
"+ sumi.add((ai + 1, bi, ci))",
"+ i... | false | 0.080249 | 0.037973 | 2.113307 | [
"s525810164",
"s322499826"
] |
u877470159 | p03045 | python | s853152706 | s799347591 | 1,090 | 924 | 86,944 | 73,432 | Accepted | Accepted | 15.23 | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
# 検索
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
... | class UnionFind:
def __init__(self, n):
self.par = [-1]*(n+1)
self.sizes=[1]*(n+1)
# 検索
def find(self, x):
if self.par[x]<0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def union(self,... | 39 | 52 | 954 | 1,209 | class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n + 1)]
self.rank = [0] * (n + 1)
# 検索
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def un... | class UnionFind:
def __init__(self, n):
self.par = [-1] * (n + 1)
self.sizes = [1] * (n + 1)
# 検索
def find(self, x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合
def union(self, x... | false | 25 | [
"- self.par = [i for i in range(n + 1)]",
"- self.rank = [0] * (n + 1)",
"+ self.par = [-1] * (n + 1)",
"+ self.sizes = [1] * (n + 1)",
"- if self.par[x] == x:",
"+ if self.par[x] < 0:",
"- if self.rank[x] < self.rank[y]:",
"+ if x == y:",
"+ ... | false | 0.081164 | 0.044762 | 1.813245 | [
"s853152706",
"s799347591"
] |
u634461820 | p03417 | python | s359408084 | s105651768 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | N,M = list(map(int,input().split()))
if N ==1 and M == 1:
print((1))
elif min(N,M) == 1 and max(N,M) >= 3:
print((N*M-2))
elif N == 2 or M == 2:
print((0))
else:
print(((N-2)*(M-2))) | N,M = list(map(int,input().split()))
if N == 1 and M == 1:
print((1))
elif min(N, M) == 1:
print((max(N, M) - 2))
else:
print(((N-2)*(M-2))) | 10 | 8 | 192 | 148 | N, M = list(map(int, input().split()))
if N == 1 and M == 1:
print((1))
elif min(N, M) == 1 and max(N, M) >= 3:
print((N * M - 2))
elif N == 2 or M == 2:
print((0))
else:
print(((N - 2) * (M - 2)))
| N, M = list(map(int, input().split()))
if N == 1 and M == 1:
print((1))
elif min(N, M) == 1:
print((max(N, M) - 2))
else:
print(((N - 2) * (M - 2)))
| false | 20 | [
"-elif min(N, M) == 1 and max(N, M) >= 3:",
"- print((N * M - 2))",
"-elif N == 2 or M == 2:",
"- print((0))",
"+elif min(N, M) == 1:",
"+ print((max(N, M) - 2))"
] | false | 0.046453 | 0.075138 | 0.618236 | [
"s359408084",
"s105651768"
] |
u285891772 | p03611 | python | s887718448 | s172092728 | 186 | 121 | 24,328 | 15,956 | Accepted | Accepted | 34.95 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy... | 29 | 35 | 986 | 1,066 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mu... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mu... | false | 17.142857 | [
"-import numpy as np",
"-",
"+# import numpy as np",
"+# from decimal import *",
"-a = np.array(LIST())",
"-a = np.bincount(a)",
"-b = a.copy()",
"-b[1:] += a[:-1]",
"-b[:-1] += a[1:]",
"-print((b.max()))",
"+a = LIST()",
"+lim = 10**5 + 3",
"+cnt = [0] * lim",
"+for n in a:",
"+ cnt[... | false | 0.174314 | 0.151526 | 1.150391 | [
"s887718448",
"s172092728"
] |
u389910364 | p03146 | python | s375355685 | s202559817 | 157 | 26 | 13,560 | 10,868 | Accepted | Accepted | 83.44 | import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", ... | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
S = int(sys.stdin.buffer.readline())
seen = [0] * 1000001
a = S
i = 0
while not seen[a]:
seen[a] = 1
if ... | 33 | 26 | 599 | 409 | import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrec... | import os
import sys
if os.getenv("LOCAL"):
sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(10**9)
INF = float("inf")
IINF = 10**18
MOD = 10**9 + 7
# MOD = 998244353
S = int(sys.stdin.buffer.readline())
seen = [0] * 1000001
a = S
i = 0
while not seen[a]:
seen[a] = 1
if a % 2 == 0:
a //= 2
... | false | 21.212121 | [
"-import bisect",
"-from collections import Counter, deque",
"-from fractions import gcd",
"-from functools import lru_cache",
"-from functools import reduce",
"-import functools",
"-import heapq",
"-import itertools",
"-import math",
"-import numpy as np",
"-import re",
"-sys.setrecursionlimi... | false | 0.036498 | 0.05115 | 0.713557 | [
"s375355685",
"s202559817"
] |
u912650255 | p03624 | python | s692753572 | s093115089 | 30 | 26 | 9,144 | 9,092 | Accepted | Accepted | 13.33 | arb = 'abcdefghijklmnopqrstuvwxyz'
S = eval(input())
ans =''
for i in arb:
if i not in S:
ans += i
sort_ans = sorted(ans)
if len(ans)==0:
print('None')
else:
print((sort_ans[0])) | arb = 'abcdefghijklmnopqrstuvwxyz'
S = eval(input())
s_S =sorted(set(arb)^set(S))
print(('None' if len(s_S) == 0 else s_S[0]))
| 13 | 4 | 204 | 122 | arb = "abcdefghijklmnopqrstuvwxyz"
S = eval(input())
ans = ""
for i in arb:
if i not in S:
ans += i
sort_ans = sorted(ans)
if len(ans) == 0:
print("None")
else:
print((sort_ans[0]))
| arb = "abcdefghijklmnopqrstuvwxyz"
S = eval(input())
s_S = sorted(set(arb) ^ set(S))
print(("None" if len(s_S) == 0 else s_S[0]))
| false | 69.230769 | [
"-ans = \"\"",
"-for i in arb:",
"- if i not in S:",
"- ans += i",
"-sort_ans = sorted(ans)",
"-if len(ans) == 0:",
"- print(\"None\")",
"-else:",
"- print((sort_ans[0]))",
"+s_S = sorted(set(arb) ^ set(S))",
"+print((\"None\" if len(s_S) == 0 else s_S[0]))"
] | false | 0.040596 | 0.039582 | 1.02561 | [
"s692753572",
"s093115089"
] |
u922449550 | p02698 | python | s365653259 | s694248529 | 1,448 | 1,240 | 237,396 | 232,924 | Accepted | Accepted | 14.36 | import bisect
import sys
sys.setrecursionlimit(10**9)
N = int(input())
A = list(map(int, input().split()))
tree = [[] for i in range(N)]
for i in range(N-1):
u, v = map(int, input().split())
tree[u-1].append(v-1); tree[v-1].append(u-1)
ans = [0] * N
ans[0] = 1
INF = 10**10
dp = [INF] * N
dp[0] ... | import bisect
import sys
sys.setrecursionlimit(10**9)
N = int(input())
A = list(map(int, input().split()))
tree = [[] for i in range(N)]
for i in range(N-1):
u, v = map(int, input().split())
tree[u-1].append(v-1); tree[v-1].append(u-1)
ans = [0] * N
ans[0] = 1
INF = 10**10
dp = [INF] * N
dp[0] ... | 43 | 37 | 835 | 732 | import bisect
import sys
sys.setrecursionlimit(10**9)
N = int(input())
A = list(map(int, input().split()))
tree = [[] for i in range(N)]
for i in range(N - 1):
u, v = map(int, input().split())
tree[u - 1].append(v - 1)
tree[v - 1].append(u - 1)
ans = [0] * N
ans[0] = 1
INF = 10**10
dp = [INF] * N
dp[0] = A... | import bisect
import sys
sys.setrecursionlimit(10**9)
N = int(input())
A = list(map(int, input().split()))
tree = [[] for i in range(N)]
for i in range(N - 1):
u, v = map(int, input().split())
tree[u - 1].append(v - 1)
tree[v - 1].append(u - 1)
ans = [0] * N
ans[0] = 1
INF = 10**10
dp = [INF] * N
dp[0] = A... | false | 13.953488 | [
"-stack = []",
"-n_stack = []",
"- global stack",
"- stack.append([idx, dp[idx]])",
"- n_stack.append(n)",
"+ _idx, _num = idx, dp[idx] # 巻き戻し用に退避",
"- n = max(n, idx + 1)",
"- ans[child] = n",
"- dfs(child, node, n)",
"+ _n = max(n, idx + 1)",
... | false | 0.036433 | 0.036355 | 1.002138 | [
"s365653259",
"s694248529"
] |
u576917603 | p03575 | python | s704293376 | s823424588 | 91 | 22 | 3,064 | 3,188 | Accepted | Accepted | 75.82 | def dijkstra(s,n,w,cost):
#始点sから各頂点への最短距離
#n:頂点数, w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
d=[float("inf")]*n #各頂点への距離
used=[False]*n
d[s]=0
while True:
v=-1
#まだ使われてない頂点の中から最小の距離のものを探す
for i in range(n):
if (not used[i]) and (v==-1): #その頂点が使われた... | class UnionFind():
def __init__(self, n):
self.n=n
self.parents=[-1]*n #各要素の親要素の番号を格納するリスト
def find(self, x): #要素xが属するグループの根を返す
if self.parents[x]<0:
return x
else:
self.parents[x]=self.find(self.parents[x])
return self.parents[x]
... | 41 | 72 | 1,086 | 1,895 | def dijkstra(s, n, w, cost):
# 始点sから各頂点への最短距離
# n:頂点数, w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
d = [float("inf")] * n # 各頂点への距離
used = [False] * n
d[s] = 0
while True:
v = -1
# まだ使われてない頂点の中から最小の距離のものを探す
for i in range(n):
if (not used[i]) and (v == -1): # そ... | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n # 各要素の親要素の番号を格納するリスト
def find(self, x): # 要素xが属するグループの根を返す
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
... | false | 43.055556 | [
"-def dijkstra(s, n, w, cost):",
"- # 始点sから各頂点への最短距離",
"- # n:頂点数, w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)",
"- d = [float(\"inf\")] * n # 各頂点への距離",
"- used = [False] * n",
"- d[s] = 0",
"- while True:",
"- v = -1",
"- # まだ使われてない頂点の中から最小の距離のものを探す",
"- for i... | false | 0.045518 | 0.037943 | 1.199648 | [
"s704293376",
"s823424588"
] |
u020390084 | p03111 | python | s446187441 | s875173836 | 621 | 178 | 3,188 | 10,996 | Accepted | Accepted | 71.34 | n,a,b,c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
answer = a+b+c
def Base_10_to_n(X, n):
if (int(X/n)):
return Base_10_to_n(int(X/n), n)+str(X%n)
return str(X%n)
for i in range(1, 4**n):
aa = []
bb = []
cc = []
four = list(str(Base_10_to_n(i,4).z... | #!/usr/bin/env python3
import sys
import itertools
def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
# 0: 使わない 1:A 2:B 3:C
all = list(itertools.product([0,1,2,3], repeat=N))
answer = 10**9
for a in all:
a_sum = 0
a_count = 0
b_sum = 0
b_count = 0
... | 35 | 54 | 808 | 1,437 | n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
answer = a + b + c
def Base_10_to_n(X, n):
if int(X / n):
return Base_10_to_n(int(X / n), n) + str(X % n)
return str(X % n)
for i in range(1, 4**n):
aa = []
bb = []
cc = []
four = list(str(Base_10... | #!/usr/bin/env python3
import sys
import itertools
def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
# 0: 使わない 1:A 2:B 3:C
all = list(itertools.product([0, 1, 2, 3], repeat=N))
answer = 10**9
for a in all:
a_sum = 0
a_count = 0
b_sum = 0
b_count = 0
c_s... | false | 35.185185 | [
"-n, a, b, c = list(map(int, input().split()))",
"-l = [int(eval(input())) for _ in range(n)]",
"-answer = a + b + c",
"+#!/usr/bin/env python3",
"+import sys",
"+import itertools",
"-def Base_10_to_n(X, n):",
"- if int(X / n):",
"- return Base_10_to_n(int(X / n), n) + str(X % n)",
"- ... | false | 0.343489 | 0.177289 | 1.937456 | [
"s446187441",
"s875173836"
] |
u392319141 | p03600 | python | s924299879 | s197220093 | 836 | 601 | 45,148 | 43,356 | Accepted | Accepted | 28.11 | N = int(eval(input()))
A = [list(map(int, input().split())) for _ in range(N)]
def sol():
for k in range(N):
for i in range(N):
for j in range(N):
d = A[i][k] + A[k][j]
if d < A[i][j]:
return - 1
INF = 10**18
for k in ra... | N = int(eval(input()))
A = [list(map(int, input().split())) for _ in range(N)]
def sol():
for k in range(N):
for i in range(N):
for j in range(N):
d = A[i][k] + A[k][j]
if d < A[i][j]:
return - 1
ret = 0
for i in range(N):... | 31 | 25 | 708 | 612 | N = int(eval(input()))
A = [list(map(int, input().split())) for _ in range(N)]
def sol():
for k in range(N):
for i in range(N):
for j in range(N):
d = A[i][k] + A[k][j]
if d < A[i][j]:
return -1
INF = 10**18
for k in range(N):
... | N = int(eval(input()))
A = [list(map(int, input().split())) for _ in range(N)]
def sol():
for k in range(N):
for i in range(N):
for j in range(N):
d = A[i][k] + A[k][j]
if d < A[i][j]:
return -1
ret = 0
for i in range(N):
for ... | false | 19.354839 | [
"- INF = 10**18",
"- for k in range(N):",
"- for i in range(N):",
"- for j in range(N):",
"+ ret = 0",
"+ for i in range(N):",
"+ for j in range(i + 1, N):",
"+ for k in range(N):",
"- A[i][j] = INF",
"- ans = 0",
"- for i ... | false | 0.098531 | 0.097797 | 1.007505 | [
"s924299879",
"s197220093"
] |
u057964173 | p03695 | python | s831447477 | s374373337 | 182 | 17 | 38,256 | 3,064 | Accepted | Accepted | 90.66 | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
n = int(eval(input()))
l = list(map(int, input().split()))
check=[False]*8
jiyu=0
for i in l:
if i<3200:
check[i//400]=True
else:
jiyu+=1
cnt=0
for j in check:
... |
import sys
def input(): return sys.stdin.readline().strip()
def resolve():
n=int(eval(input()))
l=list(map(int,input().split()))
check=[0]*8
tuyo=0
for i in l:
x=i//400
if x>=8:
tuyo+=1
else:
check[x]+=1
if tuyo==n:
print(... | 25 | 24 | 438 | 457 | import sys
def input():
return sys.stdin.readline().strip()
def resolve():
n = int(eval(input()))
l = list(map(int, input().split()))
check = [False] * 8
jiyu = 0
for i in l:
if i < 3200:
check[i // 400] = True
else:
jiyu += 1
cnt = 0
for j in ... | import sys
def input():
return sys.stdin.readline().strip()
def resolve():
n = int(eval(input()))
l = list(map(int, input().split()))
check = [0] * 8
tuyo = 0
for i in l:
x = i // 400
if x >= 8:
tuyo += 1
else:
check[x] += 1
if tuyo == n:
... | false | 4 | [
"- check = [False] * 8",
"- jiyu = 0",
"+ check = [0] * 8",
"+ tuyo = 0",
"- if i < 3200:",
"- check[i // 400] = True",
"+ x = i // 400",
"+ if x >= 8:",
"+ tuyo += 1",
"- jiyu += 1",
"- cnt = 0",
"- for j in check:",
"-... | false | 0.043593 | 0.045945 | 0.9488 | [
"s831447477",
"s374373337"
] |
u521323621 | p03739 | python | s827910644 | s112791843 | 116 | 89 | 20,048 | 19,836 | Accepted | Accepted | 23.28 | from itertools import accumulate
n, *A = list(map(int, open(0).read().split()))
B = list(accumulate(A))
p0 = n0 = p1 = n1 = 0
for i, b in enumerate(B):
if i % 2 == 0:
if b+p0-n0 <= 0:
p0 += abs(b+p0-n0)+1
if b+p1-n1 >= 0:
n1 += abs(b+p1-n1)+1
else:
if b... | n = int(eval(input()))
a = list(map(int,input().split()))
def calc(t):
ans = su = 0
for i in range(n):
su += a[i]
if i % 2 == t:
if su > 0:
pass
else:
x = 1 - su
ans += abs(x)
su = 1
else:
if su < 0:
pass
else:
x ... | 16 | 23 | 447 | 408 | from itertools import accumulate
n, *A = list(map(int, open(0).read().split()))
B = list(accumulate(A))
p0 = n0 = p1 = n1 = 0
for i, b in enumerate(B):
if i % 2 == 0:
if b + p0 - n0 <= 0:
p0 += abs(b + p0 - n0) + 1
if b + p1 - n1 >= 0:
n1 += abs(b + p1 - n1) + 1
else:
... | n = int(eval(input()))
a = list(map(int, input().split()))
def calc(t):
ans = su = 0
for i in range(n):
su += a[i]
if i % 2 == t:
if su > 0:
pass
else:
x = 1 - su
ans += abs(x)
su = 1
else:
... | false | 30.434783 | [
"-from itertools import accumulate",
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"-n, *A = list(map(int, open(0).read().split()))",
"-B = list(accumulate(A))",
"-p0 = n0 = p1 = n1 = 0",
"-for i, b in enumerate(B):",
"- if i % 2 == 0:",
"- if b + p0 - n0 <= 0:",
"- ... | false | 0.038098 | 0.007361 | 5.175417 | [
"s827910644",
"s112791843"
] |
u994988729 | p02722 | python | s603351626 | s298354851 | 571 | 209 | 3,952 | 3,828 | Accepted | Accepted | 63.4 | N = int(eval(input()))
def divisor(M):
div = set()
for i in range(1, int(N ** 0.5 + 0.5) + 1):
if M % i == 0:
div.add(i)
div.add(M // i)
return div
def simu(M, X):
cnt = 0
while M >= X:
if M % X == 0:
M //= X
elif M % X... | N = int(eval(input()))
def divisor(M):
div = set()
for i in range(1, int(N ** 0.5 + 0.5) + 1):
if M % i == 0:
div.add(i)
div.add(M // i)
return div
def simu(M, X):
while M % X == 0:
M //= X
return M % X == 1
B = divisor(N - 1)
ans = le... | 38 | 28 | 616 | 415 | N = int(eval(input()))
def divisor(M):
div = set()
for i in range(1, int(N**0.5 + 0.5) + 1):
if M % i == 0:
div.add(i)
div.add(M // i)
return div
def simu(M, X):
cnt = 0
while M >= X:
if M % X == 0:
M //= X
elif M % X == 1:
... | N = int(eval(input()))
def divisor(M):
div = set()
for i in range(1, int(N**0.5 + 0.5) + 1):
if M % i == 0:
div.add(i)
div.add(M // i)
return div
def simu(M, X):
while M % X == 0:
M //= X
return M % X == 1
B = divisor(N - 1)
ans = len(B) - 1
A = divisor(... | false | 26.315789 | [
"- cnt = 0",
"- while M >= X:",
"- if M % X == 0:",
"- M //= X",
"- elif M % X == 1:",
"- return True",
"- else:",
"- M -= X",
"- cnt += 1",
"- if cnt > 1000:",
"- return False",
"- return M == 1",
"+ ... | false | 0.061491 | 0.060975 | 1.008453 | [
"s603351626",
"s298354851"
] |
u537782349 | p03127 | python | s382527038 | s313215387 | 161 | 97 | 14,252 | 14,252 | Accepted | Accepted | 39.75 | a = int(eval(input()))
b = list(map(int, input().split()))
b.sort()
while True:
c = []
c.append(b[0])
for i in range(1, len(b)):
if b[i] % b[0] != 0:
c.append(b[i] % b[0])
if len(b) == 1:
print((b[0]))
exit()
else:
b = c
b.sort()
| def g_c_d(x, y):
if x == 0:
return y
elif y == 0:
return x
else:
return g_c_d(y, x % y)
a = int(eval(input()))
b = list(map(int, input().split()))
c = 0
for i in range(a):
c = g_c_d(c, b[i])
print(c)
| 15 | 15 | 308 | 250 | a = int(eval(input()))
b = list(map(int, input().split()))
b.sort()
while True:
c = []
c.append(b[0])
for i in range(1, len(b)):
if b[i] % b[0] != 0:
c.append(b[i] % b[0])
if len(b) == 1:
print((b[0]))
exit()
else:
b = c
b.sort()
| def g_c_d(x, y):
if x == 0:
return y
elif y == 0:
return x
else:
return g_c_d(y, x % y)
a = int(eval(input()))
b = list(map(int, input().split()))
c = 0
for i in range(a):
c = g_c_d(c, b[i])
print(c)
| false | 0 | [
"+def g_c_d(x, y):",
"+ if x == 0:",
"+ return y",
"+ elif y == 0:",
"+ return x",
"+ else:",
"+ return g_c_d(y, x % y)",
"+",
"+",
"-b.sort()",
"-while True:",
"- c = []",
"- c.append(b[0])",
"- for i in range(1, len(b)):",
"- if b[i] % b[0]... | false | 0.041775 | 0.086201 | 0.484619 | [
"s382527038",
"s313215387"
] |
u893826665 | p02712 | python | s499781931 | s648510533 | 190 | 154 | 9,104 | 9,136 | Accepted | Accepted | 18.95 | n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:
ans += i
print(ans) | n = int(eval(input()))
ans = 0
for i in range(n + 1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans) | 7 | 7 | 135 | 116 | n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:
ans += i
print(ans)
| n = int(eval(input()))
ans = 0
for i in range(n + 1):
if i % 3 != 0 and i % 5 != 0:
ans += i
print(ans)
| false | 0 | [
"-for i in range(1, n + 1):",
"- if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:",
"+for i in range(n + 1):",
"+ if i % 3 != 0 and i % 5 != 0:"
] | false | 0.451805 | 0.501785 | 0.900397 | [
"s499781931",
"s648510533"
] |
u608088992 | p03959 | python | s803899992 | s783426988 | 203 | 132 | 18,624 | 18,624 | Accepted | Accepted | 34.98 | N = int(eval(input()))
T = [int(t) for t in input().split()]
A = [int(a) for a in input().split()]
mod = 7 + 10**9
TS, AS = [None for i in range(N)], [None for j in range(N)] #山の高さが一意に決まるならTrue
TS[0], AS[-1] = True, True
for i in range(1, N):
if T[i] > T[i-1]: TS[i] = True
else: TS[i] = False
if ... | import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
T = [int(t) for t in input().split()]
A = [int(a) for a in input().split()]
mod = 7 + 10 ** 9
Ans = 1
H = [-1] * N
H[0] = T[0]
for i in range(1, N):
if T[i] > T[i-1]: H[i] = T[i]
if H[... | 32 | 30 | 743 | 764 | N = int(eval(input()))
T = [int(t) for t in input().split()]
A = [int(a) for a in input().split()]
mod = 7 + 10**9
TS, AS = [None for i in range(N)], [None for j in range(N)] # 山の高さが一意に決まるならTrue
TS[0], AS[-1] = True, True
for i in range(1, N):
if T[i] > T[i - 1]:
TS[i] = True
else:
TS[i] = Fals... | import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
T = [int(t) for t in input().split()]
A = [int(a) for a in input().split()]
mod = 7 + 10**9
Ans = 1
H = [-1] * N
H[0] = T[0]
for i in range(1, N):
if T[i] > T[i - 1]:
H[i] = T[i]
if H[... | false | 6.25 | [
"-N = int(eval(input()))",
"-T = [int(t) for t in input().split()]",
"-A = [int(a) for a in input().split()]",
"-mod = 7 + 10**9",
"-TS, AS = [None for i in range(N)], [None for j in range(N)] # 山の高さが一意に決まるならTrue",
"-TS[0], AS[-1] = True, True",
"-for i in range(1, N):",
"- if T[i] > T[i - 1]:",
... | false | 0.037158 | 0.098777 | 0.376183 | [
"s803899992",
"s783426988"
] |
u887207211 | p03220 | python | s062621010 | s306493477 | 25 | 20 | 3,064 | 3,188 | Accepted | Accepted | 20 | N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))
dist = 1
tmp = abs(T - H[0]*0.006 - A)
for i in range(1,N):
tempra = abs(T - H[i]*0.006 - A)
if(tempra < tmp):
tmp = tempra
dist = i + 1
print(dist) | N = int(eval(input()))
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))
tempra = [abs((T - h * 0.006) - A) for h in H]
print((tempra.index(min(tempra)) + 1)) | 12 | 6 | 256 | 173 | N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
dist = 1
tmp = abs(T - H[0] * 0.006 - A)
for i in range(1, N):
tempra = abs(T - H[i] * 0.006 - A)
if tempra < tmp:
tmp = tempra
dist = i + 1
print(dist)
| N = int(eval(input()))
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
tempra = [abs((T - h * 0.006) - A) for h in H]
print((tempra.index(min(tempra)) + 1))
| false | 50 | [
"-dist = 1",
"-tmp = abs(T - H[0] * 0.006 - A)",
"-for i in range(1, N):",
"- tempra = abs(T - H[i] * 0.006 - A)",
"- if tempra < tmp:",
"- tmp = tempra",
"- dist = i + 1",
"-print(dist)",
"+tempra = [abs((T - h * 0.006) - A) for h in H]",
"+print((tempra.index(min(tempra)) + 1... | false | 0.118177 | 0.043937 | 2.68971 | [
"s062621010",
"s306493477"
] |
u046158516 | p02769 | python | s389691613 | s741741591 | 1,122 | 408 | 26,820 | 69,488 | Accepted | Accepted | 63.64 | n,k=list(map(int,input().split()))
fact=[1]
for i in range(1,2*n):
fact.append((fact[i-1]*(i+1))%(10**9+7))
factinv=[]
for i in range(n):
factinv.append(pow(fact[i],10**9+5,10**9+7))
if k==1:
print(((n*(n-1))%(10**9+7)))
elif k>=n-1:
print(((fact[2*n-2]*factinv[n-1]*factinv[n-2])%(10**9+7)))
else:
... | n,k=list(map(int,input().split()))
factorial=[1]
for i in range(1,2*n):
factorial.append((factorial[i-1]*(i+1))%(10**9+7))
inv=[]
for i in range(n):
inv.append(pow(factorial[i],10**9+5,10**9+7))
if k>=n-1:
print(((factorial[2*n-2]*inv[n-1]*inv[n-2])%(10**9+7)))
else:
ans=1
for i in range (k):
... | 16 | 16 | 450 | 436 | n, k = list(map(int, input().split()))
fact = [1]
for i in range(1, 2 * n):
fact.append((fact[i - 1] * (i + 1)) % (10**9 + 7))
factinv = []
for i in range(n):
factinv.append(pow(fact[i], 10**9 + 5, 10**9 + 7))
if k == 1:
print(((n * (n - 1)) % (10**9 + 7)))
elif k >= n - 1:
print(((fact[2 * n - 2] * fac... | n, k = list(map(int, input().split()))
factorial = [1]
for i in range(1, 2 * n):
factorial.append((factorial[i - 1] * (i + 1)) % (10**9 + 7))
inv = []
for i in range(n):
inv.append(pow(factorial[i], 10**9 + 5, 10**9 + 7))
if k >= n - 1:
print(((factorial[2 * n - 2] * inv[n - 1] * inv[n - 2]) % (10**9 + 7)))... | false | 0 | [
"-fact = [1]",
"+factorial = [1]",
"- fact.append((fact[i - 1] * (i + 1)) % (10**9 + 7))",
"-factinv = []",
"+ factorial.append((factorial[i - 1] * (i + 1)) % (10**9 + 7))",
"+inv = []",
"- factinv.append(pow(fact[i], 10**9 + 5, 10**9 + 7))",
"-if k == 1:",
"- print(((n * (n - 1)) % (10*... | false | 0.370479 | 0.54142 | 0.684274 | [
"s389691613",
"s741741591"
] |
u997521090 | p03111 | python | s562840788 | s756141004 | 275 | 148 | 4,856 | 3,064 | Accepted | Accepted | 46.18 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math
sys.setrecursionlimit(1000000)
INF = 10 ** 18
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
ans = 10 ** 12
for i in range(4 ** N):
S = [0, 0, 0, 0]
hoge... | INF = 10 ** 18
N, A, B, C = list(map(int,input().split()))
ls = [int(eval(input())) for i in range(N)]
def func(pos, a, b, c):return abs(a - A) + abs(b - B) + abs(c - C) - 30 + INF * max(0, 1 - a * b * c) if pos == N else min(func(pos + 1, a + ls[pos] * (i == 0), b + ls[pos] * (i == 1), c + ls[pos] * (i == 2)) +... | 30 | 7 | 562 | 365 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
import math
sys.setrecursionlimit(1000000)
INF = 10**18
N, A, B, C = list(map(int, input().split()))
l = [int(eval(input())) for i in range(N)]
ans = 10**12
for i in range(4**N):
S = [0, 0, 0, 0]
hoge = i
cost = -30
f... | INF = 10**18
N, A, B, C = list(map(int, input().split()))
ls = [int(eval(input())) for i in range(N)]
def func(pos, a, b, c):
return (
abs(a - A) + abs(b - B) + abs(c - C) - 30 + INF * max(0, 1 - a * b * c)
if pos == N
else min(
func(
pos + 1,
a ... | false | 76.666667 | [
"-#!/usr/bin/env python",
"-from collections import deque",
"-import itertools as it",
"-import sys",
"-import math",
"-",
"-sys.setrecursionlimit(1000000)",
"-l = [int(eval(input())) for i in range(N)]",
"-ans = 10**12",
"-for i in range(4**N):",
"- S = [0, 0, 0, 0]",
"- hoge = i",
"-... | false | 0.058688 | 0.158502 | 0.37027 | [
"s562840788",
"s756141004"
] |
u014333473 | p03486 | python | s778767272 | s901982666 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | print(('Yes'if ''.join(sorted(eval(input())))<''.join(sorted(eval(input()),reverse=True)) else'No')) | print(('Yes'if sorted(eval(input()))<sorted(eval(input()),reverse=True) else'No')) | 1 | 1 | 86 | 68 | print(
(
"Yes"
if "".join(sorted(eval(input()))) < "".join(sorted(eval(input()), reverse=True))
else "No"
)
)
| print(("Yes" if sorted(eval(input())) < sorted(eval(input()), reverse=True) else "No"))
| false | 0 | [
"-print(",
"- (",
"- \"Yes\"",
"- if \"\".join(sorted(eval(input()))) < \"\".join(sorted(eval(input()), reverse=True))",
"- else \"No\"",
"- )",
"-)",
"+print((\"Yes\" if sorted(eval(input())) < sorted(eval(input()), reverse=True) else \"No\"))"
] | false | 0.04295 | 0.04346 | 0.988248 | [
"s778767272",
"s901982666"
] |
u123518636 | p03560 | python | s876538058 | s158037547 | 343 | 93 | 10,008 | 6,556 | Accepted | Accepted | 72.89 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq
# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7
def solve(f):
n = f.read_int()
d = [float('inf')] * n
d[1] = 1
que = [(1, 1)] ... | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq
# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7
def solve(f):
k = f.read_int()
depth = [float('inf')] * k
depth[1] = 1
que = ... | 69 | 65 | 2,105 | 2,031 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, collections, itertools, re, math, fractions, decimal, random, array, bisect, heapq
# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7
def solve(f):
n = f.read_int()
d = [float("inf")] * n
d[1] = 1
que = [(1, 1)] # (mi... | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, collections, itertools, re, math, fractions, decimal, random, array, bisect, heapq
# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7
def solve(f):
k = f.read_int()
depth = [float("inf")] * k
depth[1] = 1
que = collect... | false | 5.797101 | [
"- n = f.read_int()",
"- d = [float(\"inf\")] * n",
"- d[1] = 1",
"- que = [(1, 1)] # (min_dist, vertex)",
"- heapq.heapify(que)",
"+ k = f.read_int()",
"+ depth = [float(\"inf\")] * k",
"+ depth[1] = 1",
"+ que = collections.deque([1])",
"- dist, v0 = heapq.heap... | false | 0.047855 | 0.041406 | 1.155744 | [
"s876538058",
"s158037547"
] |
u588341295 | p03634 | python | s197439012 | s988369983 | 1,449 | 841 | 131,632 | 46,268 | Accepted | Accepted | 41.96 | # -*- coding: utf-8 -*-
"""
参考:https://img.atcoder.jp/abc070/editorial.pdf
・公式解が再帰だったのでやってみる
"""
import sys
# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)
N = int(eval(input()))
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
a, b, c = list(map(int, input().split()))
# nodes[出... | # -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
from heapq import heappop, heappush
# 今回はダイクストラするので、データの持ち方は隣接リスト
N = int(eval(input()))
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
a, b, c = list(map(int, input().split()))
# nodes[出発ノード](到着ノード, コス... | 36 | 45 | 773 | 1,199 | # -*- coding: utf-8 -*-
"""
参考:https://img.atcoder.jp/abc070/editorial.pdf
・公式解が再帰だったのでやってみる
"""
import sys
# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10**9)
N = int(eval(input()))
nodes = [[] for _ in range(N + 1)]
for i in range(N - 1):
a, b, c = list(map(int, input().split()))
# nodes[出発ノード](到着ノード, コスト)... | # -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
from heapq import heappop, heappush
# 今回はダイクストラするので、データの持ち方は隣接リスト
N = int(eval(input()))
nodes = [[] for _ in range(N + 1)]
for i in range(N - 1):
a, b, c = list(map(int, input().split()))
# nodes[出発ノード](到着ノード, コスト))
... | false | 20 | [
"-\"\"\"",
"-参考:https://img.atcoder.jp/abc070/editorial.pdf",
"-・公式解が再帰だったのでやってみる",
"-\"\"\"",
"-# 再帰呼び出しの回数制限(デフォルト1000)",
"-sys.setrecursionlimit(10**9)",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"+",
"+from heapq import heappop, heappush",
"+",
"+# 今回はダイクスト... | false | 0.074325 | 0.036321 | 2.046364 | [
"s197439012",
"s988369983"
] |
u735763891 | p03338 | python | s252631390 | s807121767 | 150 | 21 | 12,508 | 3,064 | Accepted | Accepted | 86 | def abc098_b():
import numpy as np
n = int(eval(input()))
s = eval(input())
counts = []
if len(s) == 2:
return [0,1][s[0] == s[1]]
for i in range(1, n - 1):
x = s[:i]
y = s[i:]
count = 0
for let in set(x):
if let in set(y):
... | def abc098_b():
n = int(eval(input()))
s = eval(input())
count_max = 0
if len(s) == 2:
return [0, 1][s[0] == s[1]]
for i in range(1, n - 1):
x = s[:i]
y = s[i:]
count = 0
for let in set(x):
if let in set(y):
count += 1
... | 19 | 17 | 407 | 391 | def abc098_b():
import numpy as np
n = int(eval(input()))
s = eval(input())
counts = []
if len(s) == 2:
return [0, 1][s[0] == s[1]]
for i in range(1, n - 1):
x = s[:i]
y = s[i:]
count = 0
for let in set(x):
if let in set(y):
co... | def abc098_b():
n = int(eval(input()))
s = eval(input())
count_max = 0
if len(s) == 2:
return [0, 1][s[0] == s[1]]
for i in range(1, n - 1):
x = s[:i]
y = s[i:]
count = 0
for let in set(x):
if let in set(y):
count += 1
count... | false | 10.526316 | [
"- import numpy as np",
"-",
"- counts = []",
"+ count_max = 0",
"- counts.append(count)",
"- return np.max(counts)",
"+ count_max = max(count, count_max)",
"+ return count_max"
] | false | 0.330317 | 0.086401 | 3.823085 | [
"s252631390",
"s807121767"
] |
u479719434 | p03168 | python | s370216629 | s519077575 | 1,223 | 903 | 396,680 | 272,136 | Accepted | Accepted | 26.17 | def main():
N = int(input())
p = list(map(float, input().split()))
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
p_mul = 1
dp[0][0] = 1
for i in range(1, N + 1):
p_mul *= (1-p[i-1])
dp[i][0] = p_mul
for i in range(1, N+1):
for j in range(1, N+1):
... | # python3だとTLE,pypy3だとAC
def main():
N = int(input())
p = list(map(float, input().split()))
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N+1):
for j in range(0, N+1):
dp[i][j] = dp[i - 1][j] * \
(1 - p[i - 1]) + ... | 18 | 16 | 497 | 424 | def main():
N = int(input())
p = list(map(float, input().split()))
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
p_mul = 1
dp[0][0] = 1
for i in range(1, N + 1):
p_mul *= 1 - p[i - 1]
dp[i][0] = p_mul
for i in range(1, N + 1):
for j in range(1, N + 1):
... | # python3だとTLE,pypy3だとAC
def main():
N = int(input())
p = list(map(float, input().split()))
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
dp[0][0] = 1
for i in range(1, N + 1):
for j in range(0, N + 1):
dp[i][j] = dp[i - 1][j] * (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - ... | false | 11.111111 | [
"+# python3だとTLE,pypy3だとAC",
"- p_mul = 1",
"- p_mul *= 1 - p[i - 1]",
"- dp[i][0] = p_mul",
"- for i in range(1, N + 1):",
"- for j in range(1, N + 1):",
"+ for j in range(0, N + 1):"
] | false | 0.035548 | 0.036959 | 0.961814 | [
"s370216629",
"s519077575"
] |
u997641430 | p02768 | python | s365364536 | s138910006 | 1,510 | 853 | 3,060 | 18,920 | Accepted | Accepted | 43.51 | n, a, b = list(map(int, input().split()))
p = 10**9+7
def comb(n, a):
ans = 1
for i in range(1, a + 1):
ans = ans * (n - i + 1) * pow(i, p - 2, p) % p
return ans
ans = (pow(2, n, p)-1-comb(n, a)-comb(n, b)) % p
print(ans)
| class Comb0():
# あらかじめO(k)の前計算をしておいてr<=kに対してnCrを高速に計算する
def __init__(self, n, k=10**6, p=10**9+7):
# num[i]=nPi
# den[i]=(i!)^(-1)
num, den = [1], [1]
a, b = 1, 1
for i in range(1, k+1):
a = (a*(n-i+1)) % p
b = (b*pow(i, p-2, p)) % p
... | 13 | 28 | 252 | 756 | n, a, b = list(map(int, input().split()))
p = 10**9 + 7
def comb(n, a):
ans = 1
for i in range(1, a + 1):
ans = ans * (n - i + 1) * pow(i, p - 2, p) % p
return ans
ans = (pow(2, n, p) - 1 - comb(n, a) - comb(n, b)) % p
print(ans)
| class Comb0:
# あらかじめO(k)の前計算をしておいてr<=kに対してnCrを高速に計算する
def __init__(self, n, k=10**6, p=10**9 + 7):
# num[i]=nPi
# den[i]=(i!)^(-1)
num, den = [1], [1]
a, b = 1, 1
for i in range(1, k + 1):
a = (a * (n - i + 1)) % p
b = (b * pow(i, p - 2, p)) % p
... | false | 53.571429 | [
"+class Comb0:",
"+ # あらかじめO(k)の前計算をしておいてr<=kに対してnCrを高速に計算する",
"+ def __init__(self, n, k=10**6, p=10**9 + 7):",
"+ # num[i]=nPi",
"+ # den[i]=(i!)^(-1)",
"+ num, den = [1], [1]",
"+ a, b = 1, 1",
"+ for i in range(1, k + 1):",
"+ a = (a * (n - i +... | false | 0.561731 | 0.918603 | 0.611505 | [
"s365364536",
"s138910006"
] |
u716530146 | p03290 | python | s090105271 | s276273675 | 549 | 483 | 114,484 | 84,644 | Accepted | Accepted | 12.02 | #!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = inf
count = 0; pro = 1
d, g = list(map(int, input().split()))
g //= 100
dp=[[i... | #!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = inf
count = 0; pro = 1
d, g = list(map(int, input().split()))
g //= 100
dp=[[i... | 46 | 46 | 1,373 | 1,385 | #!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
sys.setrecursionlimit(10**8)
inf = float("inf")
mod = 10**9 + 7
ans = inf
count = 0
pro = 1
d, g = list(map(int, input().split()))
g //= 100
dp = [[inf] * (1... | #!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
sys.setrecursionlimit(10**8)
inf = float("inf")
mod = 10**9 + 7
ans = inf
count = 0
pro = 1
d, g = list(map(int, input().split()))
g //= 100
dp = [[inf] * (1... | false | 0 | [
"-dp = [[inf] * (10**5 * 2) for i in range(11)]",
"+dp = [[inf] * (10**5 + 10000) for i in range(11)]",
"- for j in range(10**5 * 2):",
"+ for j in range(10**5 + 10000):",
"-for i in range(g, 10**5 * 2):",
"+for i in range(g, 10**5 + 10000):"
] | false | 0.877267 | 0.32652 | 2.686718 | [
"s090105271",
"s276273675"
] |
u863442865 | p03780 | python | s442534230 | s850567972 | 1,750 | 537 | 36,884 | 13,580 | Accepted | Accepted | 69.31 | '''
1枚抜いてDPをN枚についてやれば良い, がこれでは間に合わない
そこで必要不要の境界を二分探索で探す
するとO(N^2K)→O(NKlogN)となって間に合う
もう1つの方法は分からない
'''
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools impo... | import numpy as np
import itertools
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
def check(i): #i番目のカードを使わなかった時
dp = np.zeros(K, dtype = np.bool)
#dp[k]はkが作れる時True
#保持する情報はTrue/Falseのみで良いので1次元DPを上書きしていく(1回でまとめて)
dp[0] = True
for j in itertools.cha... | 70 | 26 | 1,804 | 677 | """
1枚抜いてDPをN枚についてやれば良い, がこれでは間に合わない
そこで必要不要の境界を二分探索で探す
するとO(N^2K)→O(NKlogN)となって間に合う
もう1つの方法は分からない
"""
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
# from collections import defaultdict
from itertools import combinat... | import numpy as np
import itertools
N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
def check(i): # i番目のカードを使わなかった時
dp = np.zeros(K, dtype=np.bool)
# dp[k]はkが作れる時True
# 保持する情報はTrue/Falseのみで良いので1次元DPを上書きしていく(1回でまとめて)
dp[0] = True
for j in itertools.chain(a[:i],... | false | 62.857143 | [
"-\"\"\"",
"-1枚抜いてDPをN枚についてやれば良い, がこれでは間に合わない",
"-そこで必要不要の境界を二分探索で探す",
"-するとO(N^2K)→O(NKlogN)となって間に合う",
"-もう1つの方法は分からない",
"-\"\"\"",
"+import numpy as np",
"+import itertools",
"+",
"+N, K = list(map(int, input().split()))",
"+a = list(map(int, input().split()))",
"+a.sort()",
"-def main():"... | false | 0.360161 | 0.570118 | 0.63173 | [
"s442534230",
"s850567972"
] |
u620238824 | p02771 | python | s981532331 | s396490837 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | A = list(map(int, input().split()))#リスト
if len(set(A)) == 2:
print("Yes")
else:
print("No") | A= list(map(int, input().split())) #数字
if len(set(A)) == 2:
print("Yes")
else:
print("No") | 6 | 5 | 105 | 97 | A = list(map(int, input().split())) # リスト
if len(set(A)) == 2:
print("Yes")
else:
print("No")
| A = list(map(int, input().split())) # 数字
if len(set(A)) == 2:
print("Yes")
else:
print("No")
| false | 16.666667 | [
"-A = list(map(int, input().split())) # リスト",
"+A = list(map(int, input().split())) # 数字"
] | false | 0.043429 | 0.04335 | 1.001804 | [
"s981532331",
"s396490837"
] |
u390694622 | p02955 | python | s960916892 | s255861449 | 222 | 161 | 6,424 | 3,064 | Accepted | Accepted | 27.48 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
def distance(x,d):
r = x%d
return(min(r,d-r))
def cost(d,numList):
r = list([x%d for x in ... | import math
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
def cost(d,numList):
r = [x%d for x in numList]
r.sort(reverse=True)
p = sum(r)//d
c = 0
for i in range(p):
c += d - r[i]
return(c)
def divisors(n):
sq = math.ceil(math.sqrt(n))
... | 37 | 30 | 770 | 572 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10**7)
inf = 10**20
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
def distance(x, d):
r = x % d
return min(r, d - r)
def cost(d, numList):
r = list([x %... | import math
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
def cost(d, numList):
r = [x % d for x in numList]
r.sort(reverse=True)
p = sum(r) // d
c = 0
for i in range(p):
c += d - r[i]
return c
def divisors(n):
sq = math.ceil(math.sqrt(n))
ans = ... | false | 18.918919 | [
"-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time",
"+import math",
"-sys.setrecursionlimit(10**7)",
"-inf = 10**20",
"-def distance(x, d):",
"- r = x % d",
"- return min(r, d - r)",
"-",
"-",
"- r = list([x % d for x in numList])",
"+... | false | 0.036364 | 0.038983 | 0.932827 | [
"s960916892",
"s255861449"
] |
u133936772 | p02947 | python | s569041114 | s326192689 | 541 | 345 | 21,988 | 21,980 | Accepted | Accepted | 36.23 | d,a={},0
for i in range(int(eval(input()))):
k=str(sorted(eval(input())))
d[k]=d.get(k,-1)+1; a+=d[k]
print(a) | d,a={},0
for s in open(0):k=str(sorted(s));d[k]=d.get(k,-1)+1;a+=d[k]
print(a) | 5 | 3 | 106 | 80 | d, a = {}, 0
for i in range(int(eval(input()))):
k = str(sorted(eval(input())))
d[k] = d.get(k, -1) + 1
a += d[k]
print(a)
| d, a = {}, 0
for s in open(0):
k = str(sorted(s))
d[k] = d.get(k, -1) + 1
a += d[k]
print(a)
| false | 40 | [
"-for i in range(int(eval(input()))):",
"- k = str(sorted(eval(input())))",
"+for s in open(0):",
"+ k = str(sorted(s))"
] | false | 0.115963 | 0.037754 | 3.071513 | [
"s569041114",
"s326192689"
] |
u787456042 | p03401 | python | s189800639 | s307617245 | 184 | 135 | 13,804 | 14,232 | Accepted | Accepted | 26.63 | N,*A=list(map(int,open(0).read().split()))
A=[0]+A+[0]
f=lambda i:abs(A[i]-A[i+1])
s=sum(f(i)for i in range(N+1))
print((*[s-f(i)-f(i+1)+abs(A[i]-A[i+2])for i in range(N)])) | N,*A=list(map(int,open(0).read().split()))
A=[0]+A+[0]
f=abs
s=sum(f(i-j)for i,j in zip(A,A[1:]))
print((*[s-f(i-j)-f(j-k)+f(i-k)for i,j,k in zip(A,A[1:],A[2:])])) | 5 | 5 | 169 | 159 | N, *A = list(map(int, open(0).read().split()))
A = [0] + A + [0]
f = lambda i: abs(A[i] - A[i + 1])
s = sum(f(i) for i in range(N + 1))
print((*[s - f(i) - f(i + 1) + abs(A[i] - A[i + 2]) for i in range(N)]))
| N, *A = list(map(int, open(0).read().split()))
A = [0] + A + [0]
f = abs
s = sum(f(i - j) for i, j in zip(A, A[1:]))
print((*[s - f(i - j) - f(j - k) + f(i - k) for i, j, k in zip(A, A[1:], A[2:])]))
| false | 0 | [
"-f = lambda i: abs(A[i] - A[i + 1])",
"-s = sum(f(i) for i in range(N + 1))",
"-print((*[s - f(i) - f(i + 1) + abs(A[i] - A[i + 2]) for i in range(N)]))",
"+f = abs",
"+s = sum(f(i - j) for i, j in zip(A, A[1:]))",
"+print((*[s - f(i - j) - f(j - k) + f(i - k) for i, j, k in zip(A, A[1:], A[2:])]))"
] | false | 0.04073 | 0.044744 | 0.910298 | [
"s189800639",
"s307617245"
] |
u411923565 | p02888 | python | s821998839 | s283989363 | 1,001 | 357 | 9,288 | 68,504 | Accepted | Accepted | 64.34 | import bisect
N = eval(input())
N = int(N)
L = list(map(int,input().split()))
L_sorted = sorted(L, reverse = False)#昇順
count = 0
for i in range(N):#aの選び方
for j in range(i+1,N):#bの選び方
a = L_sorted[i]
b = L_sorted[j]#b <= c < a+b
count += bisect.bisect_left(L_sorted, a+b) - j -... | import bisect
N = int(eval(input()))
L = list(map(int,input().split()))
L = sorted(L,reverse = False)
cnt = 0
# a の index
for a in range(len(L)):
# b の index
for b in range(a+1,len(L)):
# c が取りうる最大の index
c_idx = bisect.bisect_left(L,L[a]+L[b]) - 1
cnt += c_idx - b
print(cn... | 15 | 14 | 329 | 316 | import bisect
N = eval(input())
N = int(N)
L = list(map(int, input().split()))
L_sorted = sorted(L, reverse=False) # 昇順
count = 0
for i in range(N): # aの選び方
for j in range(i + 1, N): # bの選び方
a = L_sorted[i]
b = L_sorted[j] # b <= c < a+b
count += bisect.bisect_left(L_sorted, a + b) - j ... | import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
L = sorted(L, reverse=False)
cnt = 0
# a の index
for a in range(len(L)):
# b の index
for b in range(a + 1, len(L)):
# c が取りうる最大の index
c_idx = bisect.bisect_left(L, L[a] + L[b]) - 1
cnt += c_idx - b
print(cnt)
| false | 6.666667 | [
"-N = eval(input())",
"-N = int(N)",
"+N = int(eval(input()))",
"-L_sorted = sorted(L, reverse=False) # 昇順",
"-count = 0",
"-for i in range(N): # aの選び方",
"- for j in range(i + 1, N): # bの選び方",
"- a = L_sorted[i]",
"- b = L_sorted[j] # b <= c < a+b",
"- count += bisect.b... | false | 0.062531 | 0.036898 | 1.6947 | [
"s821998839",
"s283989363"
] |
u707124227 | p02834 | python | s713509879 | s536150931 | 711 | 353 | 68,128 | 95,796 | Accepted | Accepted | 50.35 | n,u,v=list(map(int,input().split()))
u-=1
v-=1
ki=[[]for _ in range(n)]
for _ in range(n-1):
a,b=[int(x)-1 for x in input().split()]
ki[a].append(b)
ki[b].append(a)
du=[0]*n
dv=[0]*n
from collections import deque
def distance(i):
seen=[-1]*n
seen[i]=0
todo=deque([i])
while todo:
t=todo... | n,u,v=list(map(int,input().split()))
ki=[[] for _ in range(n)]
for _ in range(n-1):
a,b=list(map(int,input().split()))
a,b=a-1,b-1
ki[a].append(b)
ki[b].append(a)
# 次数
dn=[len(ki[i]) for i in range(n)]
inf=float('inf')
dt=[inf]*n
da=[inf]*n
u,v=u-1,v-1
from collections import deque
todo=deque([u])... | 31 | 38 | 575 | 717 | n, u, v = list(map(int, input().split()))
u -= 1
v -= 1
ki = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = [int(x) - 1 for x in input().split()]
ki[a].append(b)
ki[b].append(a)
du = [0] * n
dv = [0] * n
from collections import deque
def distance(i):
seen = [-1] * n
seen[i] = 0
todo = de... | n, u, v = list(map(int, input().split()))
ki = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
a, b = a - 1, b - 1
ki[a].append(b)
ki[b].append(a)
# 次数
dn = [len(ki[i]) for i in range(n)]
inf = float("inf")
dt = [inf] * n
da = [inf] * n
u, v = u - 1, v - 1
from colle... | false | 18.421053 | [
"-u -= 1",
"-v -= 1",
"- a, b = [int(x) - 1 for x in input().split()]",
"+ a, b = list(map(int, input().split()))",
"+ a, b = a - 1, b - 1",
"-du = [0] * n",
"-dv = [0] * n",
"+# 次数",
"+dn = [len(ki[i]) for i in range(n)]",
"+inf = float(\"inf\")",
"+dt = [inf] * n",
"+da = [inf] * n"... | false | 0.10871 | 0.098804 | 1.100257 | [
"s713509879",
"s536150931"
] |
u644907318 | p03137 | python | s960964553 | s861063262 | 104 | 96 | 92,604 | 20,244 | Accepted | Accepted | 7.69 | N,M = list(map(int,input().split()))
X = sorted(list(map(int,input().split())))
if N>=M:
print((0))
else:
L = []
for i in range(1,M):
L.append(X[i]-X[i-1])
L = sorted(L,reverse=True)
tot = sum(L[N-1:])
print(tot) | N,M = list(map(int,input().split()))
X = sorted(list(map(int,input().split())))
L = []
for i in range(1,M):
L.append(X[i]-X[i-1])
L = sorted(L,reverse=True)
if N>=M:
print((0))
else:
print((sum(L[N-1:]))) | 11 | 10 | 246 | 215 | N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))
if N >= M:
print((0))
else:
L = []
for i in range(1, M):
L.append(X[i] - X[i - 1])
L = sorted(L, reverse=True)
tot = sum(L[N - 1 :])
print(tot)
| N, M = list(map(int, input().split()))
X = sorted(list(map(int, input().split())))
L = []
for i in range(1, M):
L.append(X[i] - X[i - 1])
L = sorted(L, reverse=True)
if N >= M:
print((0))
else:
print((sum(L[N - 1 :])))
| false | 9.090909 | [
"+L = []",
"+for i in range(1, M):",
"+ L.append(X[i] - X[i - 1])",
"+L = sorted(L, reverse=True)",
"- L = []",
"- for i in range(1, M):",
"- L.append(X[i] - X[i - 1])",
"- L = sorted(L, reverse=True)",
"- tot = sum(L[N - 1 :])",
"- print(tot)",
"+ print((sum(L[N - 1 ... | false | 0.048231 | 0.152036 | 0.317232 | [
"s960964553",
"s861063262"
] |
u537142137 | p02619 | python | s812787842 | s322946673 | 142 | 128 | 27,636 | 27,336 | Accepted | Accepted | 9.86 | import numpy as np
D = int(eval(input()))
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365+1)]
for i in range(D):
s[i] = list(map(int, input().split()))
#
last = np.array( [-1]*26 )
v = 0
for d in range(D):
t = int(eval(input()))
t -= 1
last[t] = d
v += s[d][t]
v... | import numpy as np
D = int(eval(input()))
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365+1)]
for i in range(D):
s[i] = np.array( list(map(int, input().split())) )
#
last = np.array( [-1]*26 )
av = np.array( [0]*26 )
id = np.identity(4,dtype=int)
v = 0
for d in range(D):
a... | 19 | 21 | 345 | 434 | import numpy as np
D = int(eval(input()))
c = np.array(list(map(int, input().split())))
s = [[] for i in range(365 + 1)]
for i in range(D):
s[i] = list(map(int, input().split()))
#
last = np.array([-1] * 26)
v = 0
for d in range(D):
t = int(eval(input()))
t -= 1
last[t] = d
v += s[d][t]
v -= su... | import numpy as np
D = int(eval(input()))
c = np.array(list(map(int, input().split())))
s = [[] for i in range(365 + 1)]
for i in range(D):
s[i] = np.array(list(map(int, input().split())))
#
last = np.array([-1] * 26)
av = np.array([0] * 26)
id = np.identity(4, dtype=int)
v = 0
for d in range(D):
av = s[d] - s... | false | 9.52381 | [
"- s[i] = list(map(int, input().split()))",
"+ s[i] = np.array(list(map(int, input().split())))",
"+av = np.array([0] * 26)",
"+id = np.identity(4, dtype=int)",
"+ av = s[d] - sum(c * (d - last)) + c * (d - last)",
"- v += s[d][t]",
"- v -= sum((d - last) * c)",
"+ v += av[t]"
] | false | 0.197245 | 0.192574 | 1.024259 | [
"s812787842",
"s322946673"
] |
u826549974 | p02240 | python | s715003049 | s308025978 | 830 | 680 | 132,540 | 122,208 | Accepted | Accepted | 18.07 | import sys
sys.setrecursionlimit(200000)
def dfs(v):
global node_chk
global edge_chk
global B
global connect
global value
node_chk[v] = 1
connect[v] = value
for x in B[v]:
if(node_chk[x] == 0):
dfs(x)
n,m = list(map(int,input().split()))
B ... | import sys
sys.setrecursionlimit(200000)
def dfs(v):
global node_chk
global B
global connect
global value
node_chk[v] = 1
connect[v] = value
for x in B[v]:
if(node_chk[x] == 0):
dfs(x)
n,m = list(map(int,input().split()))
B = [[]for i in range(n... | 46 | 42 | 912 | 797 | import sys
sys.setrecursionlimit(200000)
def dfs(v):
global node_chk
global edge_chk
global B
global connect
global value
node_chk[v] = 1
connect[v] = value
for x in B[v]:
if node_chk[x] == 0:
dfs(x)
n, m = list(map(int, input().split()))
B = [[] for i in range(n... | import sys
sys.setrecursionlimit(200000)
def dfs(v):
global node_chk
global B
global connect
global value
node_chk[v] = 1
connect[v] = value
for x in B[v]:
if node_chk[x] == 0:
dfs(x)
n, m = list(map(int, input().split()))
B = [[] for i in range(n)] # 隣接リスト
node_chk... | false | 8.695652 | [
"- global edge_chk",
"-edge_chk = [[] for i in range(n)]",
"- edge_chk[A[0]].append(0)",
"- edge_chk[A[1]].append(0)"
] | false | 0.036924 | 0.036327 | 1.016435 | [
"s715003049",
"s308025978"
] |
u408071652 | p02583 | python | s313168424 | s135199229 | 83 | 71 | 73,492 | 67,956 | Accepted | Accepted | 14.46 | import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
t = L[i... | 28 | 30 | 517 | 588 | import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
a = bisect.... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
t = L[i] + L[j]
... | false | 6.666667 | [
"-import bisect",
"- a = bisect.bisect_right(L[j + 1 :], L[j])",
"- b = bisect.bisect_left(L[j + 1 :], L[i] + L[j])",
"- count += b - a",
"+ t = L[i] + L[j]",
"+ for k in range(j + 1, N):",
"+ if L[j] != L[k]:",
"+ ... | false | 0.033156 | 0.036145 | 0.917313 | [
"s313168424",
"s135199229"
] |
u291628833 | p02923 | python | s644599149 | s970089033 | 306 | 237 | 90,348 | 63,856 | Accepted | Accepted | 22.55 | import copy
n = int(eval(input()))
r_L = list(map(int,input().split()))
l_L = copy.deepcopy(r_L)
l_L.reverse()
r_ans,l_ans = 0,0
r_ans_L,l_ans_L = [],[]
for val in range(n-1):
if r_L[val] >= r_L[val+1]:
r_ans += 1
else:
r_ans_L.append(r_ans)
r_ans = 0
l_ans... | n = int(eval(input()))
h_L = list(map(int,input().split()))
s = h_L[0]
tmp = 0
result_L = []
for i in range(0,n-1):
if s >= h_L[i+1]:
tmp += 1
else:
result_L.append(tmp)
tmp = 0
s = h_L[i+1]
result_L.append(tmp)
print((max(result_L))) | 24 | 19 | 395 | 285 | import copy
n = int(eval(input()))
r_L = list(map(int, input().split()))
l_L = copy.deepcopy(r_L)
l_L.reverse()
r_ans, l_ans = 0, 0
r_ans_L, l_ans_L = [], []
for val in range(n - 1):
if r_L[val] >= r_L[val + 1]:
r_ans += 1
else:
r_ans_L.append(r_ans)
r_ans = 0
l_ans_L.append(l_ans)
r_an... | n = int(eval(input()))
h_L = list(map(int, input().split()))
s = h_L[0]
tmp = 0
result_L = []
for i in range(0, n - 1):
if s >= h_L[i + 1]:
tmp += 1
else:
result_L.append(tmp)
tmp = 0
s = h_L[i + 1]
result_L.append(tmp)
print((max(result_L)))
| false | 20.833333 | [
"-import copy",
"-",
"-r_L = list(map(int, input().split()))",
"-l_L = copy.deepcopy(r_L)",
"-l_L.reverse()",
"-r_ans, l_ans = 0, 0",
"-r_ans_L, l_ans_L = [], []",
"-for val in range(n - 1):",
"- if r_L[val] >= r_L[val + 1]:",
"- r_ans += 1",
"+h_L = list(map(int, input().split()))",
... | false | 0.03733 | 0.051991 | 0.718016 | [
"s644599149",
"s970089033"
] |
u606878291 | p02720 | python | s367642359 | s300789137 | 154 | 103 | 9,212 | 18,832 | Accepted | Accepted | 33.12 | K = int(eval(input()))
k = K - 1
numbers = {
0: 1
}
while k > 0:
k -= 1
for i in range(len(numbers)):
n = numbers[i]
if n == 9:
continue
if abs(numbers.get(i - 1, n) - (n + 1)) <= 1 and abs(numbers.get(i + 1, n) - (n + 1)) <= 1:
numbers[i] ... | from collections import deque
K = int(eval(input()))
queue = deque(list(range(1, 10)))
for _ in range(K):
x = queue.popleft()
if x % 10 != 0:
queue.append(10 * x + x % 10 - 1)
queue.append(10 * x + x % 10)
if x % 10 != 9:
queue.append(10 * x + x % 10 + 1)
print(x)
| 28 | 15 | 653 | 303 | K = int(eval(input()))
k = K - 1
numbers = {0: 1}
while k > 0:
k -= 1
for i in range(len(numbers)):
n = numbers[i]
if n == 9:
continue
if (
abs(numbers.get(i - 1, n) - (n + 1)) <= 1
and abs(numbers.get(i + 1, n) - (n + 1)) <= 1
):
n... | from collections import deque
K = int(eval(input()))
queue = deque(list(range(1, 10)))
for _ in range(K):
x = queue.popleft()
if x % 10 != 0:
queue.append(10 * x + x % 10 - 1)
queue.append(10 * x + x % 10)
if x % 10 != 9:
queue.append(10 * x + x % 10 + 1)
print(x)
| false | 46.428571 | [
"+from collections import deque",
"+",
"-k = K - 1",
"-numbers = {0: 1}",
"-while k > 0:",
"- k -= 1",
"- for i in range(len(numbers)):",
"- n = numbers[i]",
"- if n == 9:",
"- continue",
"- if (",
"- abs(numbers.get(i - 1, n) - (n + 1)) <= 1",
... | false | 0.067905 | 0.057958 | 1.171618 | [
"s367642359",
"s300789137"
] |
u707124227 | p02690 | python | s824277713 | s133648739 | 80 | 34 | 9,200 | 9,180 | Accepted | Accepted | 57.5 | x=int(eval(input()))
i=0
while True:
for j in range(0,i+1):
a=j
b=i-j
if a**5-b**5==x:
print((a,b))
exit()
a*=-1
if a**5-b**5==x:
print((a,b))
exit()
b*=-1
if a**5-b**5==x:
print((a,b))
exit()
a*=-1
if a**5-b**5==x:
print... | x=int(eval(input()))
j=0
while True:
j+=1
for i in range(j+1):
a=j
b=j-i
if pow(a,5)-pow(b,5)==x:
print((a,b))
exit(0)
b*=-1
if pow(a,5)-pow(b,5)==x:
print((a,b))
exit(0)
b*=-1
a*=-1
if pow(a,5)-pow(b,5)==x:
print((a,b))
exit(0)
... | 22 | 22 | 336 | 313 | x = int(eval(input()))
i = 0
while True:
for j in range(0, i + 1):
a = j
b = i - j
if a**5 - b**5 == x:
print((a, b))
exit()
a *= -1
if a**5 - b**5 == x:
print((a, b))
exit()
b *= -1
if a**5 - b**5 == x:
... | x = int(eval(input()))
j = 0
while True:
j += 1
for i in range(j + 1):
a = j
b = j - i
if pow(a, 5) - pow(b, 5) == x:
print((a, b))
exit(0)
b *= -1
if pow(a, 5) - pow(b, 5) == x:
print((a, b))
exit(0)
b *= -1
... | false | 0 | [
"-i = 0",
"+j = 0",
"- for j in range(0, i + 1):",
"+ j += 1",
"+ for i in range(j + 1):",
"- b = i - j",
"- if a**5 - b**5 == x:",
"+ b = j - i",
"+ if pow(a, 5) - pow(b, 5) == x:",
"- exit()",
"+ exit(0)",
"+ b *= -1",
"+ ... | false | 0.067204 | 0.03284 | 2.046416 | [
"s824277713",
"s133648739"
] |
u431047462 | p02862 | python | s292672649 | s200002939 | 158 | 131 | 3,064 | 3,064 | Accepted | Accepted | 17.09 | mod = 10**9+7
def pow(n, x):
if x == 0:
return 1
elif x % 2 == 0:
return pow(n * n % mod, x // 2)
else:
return n * pow(n * n % mod, x // 2) % mod
def comb(n, r):
p, q = 1, 1
for i in range(r):
p = p * (n-i) % mod
q = q * (i+1) % mod
return p * pow(q, mod-2) % mod
x, y... | mod = 10**9+7
def comb(n, r):
p, q = 1, 1
for i in range(r):
p = p * (n-i) % mod
q = q * (i+1) % mod
return p * pow(q, mod-2, mod) % mod
x, y = list(map(int, input().split()))
m = abs(x - y)
n = (x + y) // 3
if (x + y) % 3 == 0 and n >= m:
print((comb(n, (n - m) // 2)))
else:
print((0... | 24 | 16 | 466 | 312 | mod = 10**9 + 7
def pow(n, x):
if x == 0:
return 1
elif x % 2 == 0:
return pow(n * n % mod, x // 2)
else:
return n * pow(n * n % mod, x // 2) % mod
def comb(n, r):
p, q = 1, 1
for i in range(r):
p = p * (n - i) % mod
q = q * (i + 1) % mod
return p * po... | mod = 10**9 + 7
def comb(n, r):
p, q = 1, 1
for i in range(r):
p = p * (n - i) % mod
q = q * (i + 1) % mod
return p * pow(q, mod - 2, mod) % mod
x, y = list(map(int, input().split()))
m = abs(x - y)
n = (x + y) // 3
if (x + y) % 3 == 0 and n >= m:
print((comb(n, (n - m) // 2)))
else:... | false | 33.333333 | [
"-",
"-",
"-def pow(n, x):",
"- if x == 0:",
"- return 1",
"- elif x % 2 == 0:",
"- return pow(n * n % mod, x // 2)",
"- else:",
"- return n * pow(n * n % mod, x // 2) % mod",
"- return p * pow(q, mod - 2) % mod",
"+ return p * pow(q, mod - 2, mod) % mod",
"... | false | 0.330508 | 0.21076 | 1.568175 | [
"s292672649",
"s200002939"
] |
u475503988 | p03088 | python | s143921246 | s528080066 | 128 | 103 | 3,872 | 3,872 | Accepted | Accepted | 19.53 | N, MOD = int(eval(input())), 10 ** 9 + 7
memo = [{} for i in range(N+1)]
def ok(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i-1], t[i] = t[i], t[i-1]
if ''.join(t).count('AGC') >= 1:
return False
return True
def dfs(cur, last3):
if last3... | N = int(eval(input()))
MOD = 10 ** 9 + 7
memo = [{} for _ in range(N)]
def ok(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i-1], t[i] = t[i], t[i-1]
if 'AGC' in ''.join(t):
return False
return True
def dfs(cur, last3):
if cur == N:
... | 22 | 25 | 586 | 625 | N, MOD = int(eval(input())), 10**9 + 7
memo = [{} for i in range(N + 1)]
def ok(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i - 1], t[i] = t[i], t[i - 1]
if "".join(t).count("AGC") >= 1:
return False
return True
def dfs(cur, last3):
if last3 in... | N = int(eval(input()))
MOD = 10**9 + 7
memo = [{} for _ in range(N)]
def ok(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i - 1], t[i] = t[i], t[i - 1]
if "AGC" in "".join(t):
return False
return True
def dfs(cur, last3):
if cur == N:
ret... | false | 12 | [
"-N, MOD = int(eval(input())), 10**9 + 7",
"-memo = [{} for i in range(N + 1)]",
"+N = int(eval(input()))",
"+MOD = 10**9 + 7",
"+memo = [{} for _ in range(N)]",
"- if \"\".join(t).count(\"AGC\") >= 1:",
"+ if \"AGC\" in \"\".join(t):",
"- if last3 in memo[cur]:",
"- return m... | false | 0.074297 | 0.067065 | 1.107836 | [
"s143921246",
"s528080066"
] |
u143509139 | p03044 | python | s731006890 | s002541357 | 774 | 633 | 80,100 | 38,828 | Accepted | Accepted | 18.22 | def dfs(graph, start):
stack = [(start, 0)]
visited = set()
li = [0] * N
while stack:
d = stack.pop()
li[d[0] - 1] = d[1] % 2
for node, w in graph[d[0]]:
if node not in visited:
visited.add(node)
stack.append((node, d[1] + w))... | N=int(eval(input()))
p=[[]for _ in range(N+1)]
for _ in range(N-1):
u,v,w=list(map(int,input().split()))
p[u].append((v,w))
p[v].append((u,w))
s=[(1,0)]
l=[-1]*N
while s:
a,w=s.pop()
l[a-1]=w%2
for b,c in p[a]:
if l[b-1]==-1:
s.append((b,w+c))
for i in l:
print(i) | 23 | 16 | 556 | 290 | def dfs(graph, start):
stack = [(start, 0)]
visited = set()
li = [0] * N
while stack:
d = stack.pop()
li[d[0] - 1] = d[1] % 2
for node, w in graph[d[0]]:
if node not in visited:
visited.add(node)
stack.append((node, d[1] + w))
retur... | N = int(eval(input()))
p = [[] for _ in range(N + 1)]
for _ in range(N - 1):
u, v, w = list(map(int, input().split()))
p[u].append((v, w))
p[v].append((u, w))
s = [(1, 0)]
l = [-1] * N
while s:
a, w = s.pop()
l[a - 1] = w % 2
for b, c in p[a]:
if l[b - 1] == -1:
s.append((b, ... | false | 30.434783 | [
"-def dfs(graph, start):",
"- stack = [(start, 0)]",
"- visited = set()",
"- li = [0] * N",
"- while stack:",
"- d = stack.pop()",
"- li[d[0] - 1] = d[1] % 2",
"- for node, w in graph[d[0]]:",
"- if node not in visited:",
"- visited.add(no... | false | 0.041344 | 0.067615 | 0.611468 | [
"s731006890",
"s002541357"
] |
u716530146 | p02936 | python | s382110083 | s400201698 | 1,394 | 999 | 95,924 | 130,856 | Accepted | Accepted | 28.34 | import sys
sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n,q=list(map(int,input().split()))
ab=[tuple(map(int,input().split())) for i in range(n-1)]
px=[tuple(map(int,input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
visited=[0]*(n+1)
cnt=[0]*(n+1)
data=[[]... | import sys
sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n,q=list(map(int,input().split()))
ab=[tuple(map(int,input().split())) for i in range(n-1)]
px=[tuple(map(int,input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
cnt=[0]*(n+1)
data=[[] for i in range(n... | 31 | 30 | 625 | 595 | import sys
sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n, q = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for i in range(n - 1)]
px = [tuple(map(int, input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
visited = [0] * (n + 1)
cnt = [0] * ... | import sys
sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n, q = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for i in range(n - 1)]
px = [tuple(map(int, input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
cnt = [0] * (n + 1)
data = [[] for i... | false | 3.225806 | [
"-visited = [0] * (n + 1)",
"-visited[1] = 1",
"-stack = [1]",
"+stack = [(1, 0)]",
"- v = stack.pop()",
"+ v, parent = stack.pop()",
"- if visited[to]:",
"+ if to == parent:",
"- visited[to] = 1",
"- stack.append(to)",
"+ stack.append((to, v))"
] | false | 0.080867 | 0.041764 | 1.936298 | [
"s382110083",
"s400201698"
] |
u377989038 | p02678 | python | s787995264 | s125979198 | 757 | 681 | 39,192 | 38,464 | Accepted | Accepted | 10.04 | from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
x = q.popleft()
for i in g[x]:
if b[i] != 0:
... | from collections import deque
print("Yes")
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
x = q.popleft()
for i in g[x]:
if b[... | 24 | 22 | 466 | 420 | from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
x = q.popleft()
for i in g[x]:
if b[i] != 0:
continue
... | from collections import deque
print("Yes")
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
x = q.popleft()
for i in g[x]:
if b[i] != 0:
... | false | 8.333333 | [
"+print(\"Yes\")",
"-if 0 in b[1:]:",
"- print(\"No\")",
"-else:",
"- print(\"Yes\")",
"- print(*b[1:], sep=\"\\n\")",
"+print(*b[1:], sep=\"\\n\")"
] | false | 0.034122 | 0.037404 | 0.912266 | [
"s787995264",
"s125979198"
] |
u241159583 | p03062 | python | s770553086 | s748132788 | 89 | 70 | 14,332 | 14,412 | Accepted | Accepted | 21.35 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
m = 10 ** 9 #絶対値の最小
c = 0 #マイナスの数
for i in range(N):
ans += abs(A[i])
if m > abs(A[i]):
m = abs(A[i])
if A[i] < 0: c += 1
print((ans if c % 2 == 0 else ans - 2 * m)) | N = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
if A[i] < 0:cnt += 1
if cnt % 2 == 0:
print((sum([abs(x) for x in A])))
else:
a = [abs(x) for x in A]
print((sum(a) - min(a)*2)) | 11 | 11 | 244 | 231 | N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
m = 10**9 # 絶対値の最小
c = 0 # マイナスの数
for i in range(N):
ans += abs(A[i])
if m > abs(A[i]):
m = abs(A[i])
if A[i] < 0:
c += 1
print((ans if c % 2 == 0 else ans - 2 * m))
| N = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
if A[i] < 0:
cnt += 1
if cnt % 2 == 0:
print((sum([abs(x) for x in A])))
else:
a = [abs(x) for x in A]
print((sum(a) - min(a) * 2))
| false | 0 | [
"-ans = 0",
"-m = 10**9 # 絶対値の最小",
"-c = 0 # マイナスの数",
"+cnt = 0",
"- ans += abs(A[i])",
"- if m > abs(A[i]):",
"- m = abs(A[i])",
"- c += 1",
"-print((ans if c % 2 == 0 else ans - 2 * m))",
"+ cnt += 1",
"+if cnt % 2 == 0:",
"+ print((sum([abs(x) for x in A])))"... | false | 0.03197 | 0.041073 | 0.778365 | [
"s770553086",
"s748132788"
] |
u277314812 | p02711 | python | s690996927 | s411706229 | 23 | 20 | 9,008 | 9,092 | Accepted | Accepted | 13.04 | S = eval(input())
print(("Yes" if(S.count('7') > 0) else "No")) | print((["No","Yes"]["7" in eval(input())])) | 2 | 1 | 56 | 35 | S = eval(input())
print(("Yes" if (S.count("7") > 0) else "No"))
| print((["No", "Yes"]["7" in eval(input())]))
| false | 50 | [
"-S = eval(input())",
"-print((\"Yes\" if (S.count(\"7\") > 0) else \"No\"))",
"+print(([\"No\", \"Yes\"][\"7\" in eval(input())]))"
] | false | 0.080881 | 0.109238 | 0.74041 | [
"s690996927",
"s411706229"
] |
u016128476 | p02624 | python | s813132152 | s400429144 | 1,604 | 489 | 9,096 | 339,360 | Accepted | Accepted | 69.51 | N = int(eval(input()))
def solve():
ans = 0
for k in range(1,N+1):
d = N//k
ans += k*d*(d+1)//2
return ans
if __name__ == "__main__":
print((solve()))
| import numpy as np
n = int(eval(input()))
k = np.arange(1,n+1)
d = n // k
print(((k*d*(d+1)//2).sum())) | 11 | 5 | 187 | 99 | N = int(eval(input()))
def solve():
ans = 0
for k in range(1, N + 1):
d = N // k
ans += k * d * (d + 1) // 2
return ans
if __name__ == "__main__":
print((solve()))
| import numpy as np
n = int(eval(input()))
k = np.arange(1, n + 1)
d = n // k
print(((k * d * (d + 1) // 2).sum()))
| false | 54.545455 | [
"-N = int(eval(input()))",
"+import numpy as np",
"-",
"-def solve():",
"- ans = 0",
"- for k in range(1, N + 1):",
"- d = N // k",
"- ans += k * d * (d + 1) // 2",
"- return ans",
"-",
"-",
"-if __name__ == \"__main__\":",
"- print((solve()))",
"+n = int(eval(inp... | false | 1.266395 | 0.572917 | 2.210435 | [
"s813132152",
"s400429144"
] |
u663767599 | p02803 | python | s472247391 | s412199738 | 547 | 500 | 3,064 | 3,316 | Accepted | Accepted | 8.59 |
from itertools import chain
H, W = list(map(int, input().split()))
M = [list(eval(input())) for _ in range(H)]
inf = float('inf')
def flatten(list_of_lists):
"Flatten one level of nesting"
return chain.from_iterable(list_of_lists)
def bfs(start, end):
distance = [[inf for i in range(W)] fo... | from collections import deque
from itertools import chain
H, W = list(map(int, input().split()))
M = [list(eval(input())) for _ in range(H)]
inf = float('inf')
def flatten(list_of_lists):
return chain.from_iterable(list_of_lists)
def bfs(start, end):
distance = [[inf for i in range(W)] for j i... | 37 | 37 | 972 | 975 | from itertools import chain
H, W = list(map(int, input().split()))
M = [list(eval(input())) for _ in range(H)]
inf = float("inf")
def flatten(list_of_lists):
"Flatten one level of nesting"
return chain.from_iterable(list_of_lists)
def bfs(start, end):
distance = [[inf for i in range(W)] for j in range(... | from collections import deque
from itertools import chain
H, W = list(map(int, input().split()))
M = [list(eval(input())) for _ in range(H)]
inf = float("inf")
def flatten(list_of_lists):
return chain.from_iterable(list_of_lists)
def bfs(start, end):
distance = [[inf for i in range(W)] for j in range(H)]
... | false | 0 | [
"+from collections import deque",
"- \"Flatten one level of nesting\"",
"- queue = [(end, start)]",
"+ queue = deque([(end, start)])",
"- queue.insert(0, (ny, nx))",
"+ queue.appendleft((ny, nx))"
] | false | 0.081271 | 0.037116 | 2.189657 | [
"s472247391",
"s412199738"
] |
u865741247 | p03455 | python | s985438256 | s066641495 | 19 | 17 | 3,316 | 2,940 | Accepted | Accepted | 10.53 | def ketanowa(p):
ans=0
p=str(p)
for i in p:
ans+=int(i)
return ans
def main():
temp=input().split(" ")
n=int(temp[0])
a=int(temp[1])
if n*a%2==0:
print("Even")
else:
print("Odd")
if __name__ == '__main__':
main()
| a,b=input().split()
c=int(a)*int(b)
if c%2==0:
print("Even")
else:
print("Odd") | 20 | 6 | 304 | 88 | def ketanowa(p):
ans = 0
p = str(p)
for i in p:
ans += int(i)
return ans
def main():
temp = input().split(" ")
n = int(temp[0])
a = int(temp[1])
if n * a % 2 == 0:
print("Even")
else:
print("Odd")
if __name__ == "__main__":
main()
| a, b = input().split()
c = int(a) * int(b)
if c % 2 == 0:
print("Even")
else:
print("Odd")
| false | 70 | [
"-def ketanowa(p):",
"- ans = 0",
"- p = str(p)",
"- for i in p:",
"- ans += int(i)",
"- return ans",
"-",
"-",
"-def main():",
"- temp = input().split(\" \")",
"- n = int(temp[0])",
"- a = int(temp[1])",
"- if n * a % 2 == 0:",
"- print(\"Even\")",
... | false | 0.071349 | 0.069399 | 1.028086 | [
"s985438256",
"s066641495"
] |
u396495667 | p02993 | python | s896775509 | s067135409 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | s = list(eval(input()))
ans =0
for i in range(len(s)-1):
if s[i] ==s[i+1]:
ans = 1
if ans == 1:
print('Bad')
else:
print('Good') | s = eval(input())
print(('Bad' if s[0]==s[1] or s[1]==s[2] or s[2]==s[3] else 'Good')) | 9 | 2 | 140 | 79 | s = list(eval(input()))
ans = 0
for i in range(len(s) - 1):
if s[i] == s[i + 1]:
ans = 1
if ans == 1:
print("Bad")
else:
print("Good")
| s = eval(input())
print(("Bad" if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else "Good"))
| false | 77.777778 | [
"-s = list(eval(input()))",
"-ans = 0",
"-for i in range(len(s) - 1):",
"- if s[i] == s[i + 1]:",
"- ans = 1",
"-if ans == 1:",
"- print(\"Bad\")",
"-else:",
"- print(\"Good\")",
"+s = eval(input())",
"+print((\"Bad\" if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else \"Good\")... | false | 0.075048 | 0.069342 | 1.082285 | [
"s896775509",
"s067135409"
] |
u208633734 | p02570 | python | s465281084 | s725936493 | 29 | 24 | 9,140 | 9,144 | Accepted | Accepted | 17.24 | D,T,S = list(map(int,input().split()))
if D/S>T:
print("No")
else:
print("Yes") | d,t,s = list(map(int,input().split()))
if d/s>t:
print("No")
else:
print("Yes") | 5 | 5 | 81 | 81 | D, T, S = list(map(int, input().split()))
if D / S > T:
print("No")
else:
print("Yes")
| d, t, s = list(map(int, input().split()))
if d / s > t:
print("No")
else:
print("Yes")
| false | 0 | [
"-D, T, S = list(map(int, input().split()))",
"-if D / S > T:",
"+d, t, s = list(map(int, input().split()))",
"+if d / s > t:"
] | false | 0.036875 | 0.085641 | 0.430579 | [
"s465281084",
"s725936493"
] |
u328364772 | p03050 | python | s105317954 | s371924863 | 458 | 175 | 2,940 | 3,828 | Accepted | Accepted | 61.79 | n = int(eval(input()))
ans = 0
i = 1
while i*(i+1)+i <= n:
if (n-i) % i == 0:
ans += (n-i)//i
i += 1
print(ans)
| n = int(eval(input()))
divisors = set()
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.add(i)
divisors.add(n//i)
ans = 0
for d in divisors:
m = d-1
if m != 0 and n//m == n % m:
ans += m
print(ans)
| 11 | 17 | 135 | 259 | n = int(eval(input()))
ans = 0
i = 1
while i * (i + 1) + i <= n:
if (n - i) % i == 0:
ans += (n - i) // i
i += 1
print(ans)
| n = int(eval(input()))
divisors = set()
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.add(i)
divisors.add(n // i)
ans = 0
for d in divisors:
m = d - 1
if m != 0 and n // m == n % m:
ans += m
print(ans)
| false | 35.294118 | [
"+divisors = set()",
"+for i in range(1, int(n**0.5) + 1):",
"+ if n % i == 0:",
"+ divisors.add(i)",
"+ divisors.add(n // i)",
"-i = 1",
"-while i * (i + 1) + i <= n:",
"- if (n - i) % i == 0:",
"- ans += (n - i) // i",
"- i += 1",
"+for d in divisors:",
"+ m ... | false | 1.539266 | 0.194917 | 7.897039 | [
"s105317954",
"s371924863"
] |
u270681687 | p03309 | python | s409680648 | s504019075 | 690 | 225 | 99,924 | 25,196 | Accepted | Accepted | 67.39 | n = int(eval(input()))
a = list(map(int, input().split()))
c = []
for i in range(n):
c.append(a[i] - (i + 1))
c.sort()
ave = c[n//2]
ans = 10**9*n
for b in range(ave-100, ave+100):
t = 0
for i in range(n):
t += abs(c[i]-b)
ans = min(ans, t)
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
a[i] = a[i] - (i + 1)
a.sort()
if n % 2 == 1:
median = a[n // 2]
else:
median = (a[n//2 - 1] + a[n//2]) // 2
ans = 0
for i in range(n):
ans += abs(a[i] - median)
print(ans) | 20 | 18 | 294 | 282 | n = int(eval(input()))
a = list(map(int, input().split()))
c = []
for i in range(n):
c.append(a[i] - (i + 1))
c.sort()
ave = c[n // 2]
ans = 10**9 * n
for b in range(ave - 100, ave + 100):
t = 0
for i in range(n):
t += abs(c[i] - b)
ans = min(ans, t)
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
a[i] = a[i] - (i + 1)
a.sort()
if n % 2 == 1:
median = a[n // 2]
else:
median = (a[n // 2 - 1] + a[n // 2]) // 2
ans = 0
for i in range(n):
ans += abs(a[i] - median)
print(ans)
| false | 10 | [
"-c = []",
"- c.append(a[i] - (i + 1))",
"-c.sort()",
"-ave = c[n // 2]",
"-ans = 10**9 * n",
"-for b in range(ave - 100, ave + 100):",
"- t = 0",
"- for i in range(n):",
"- t += abs(c[i] - b)",
"- ans = min(ans, t)",
"+ a[i] = a[i] - (i + 1)",
"+a.sort()",
"+if n % 2 =... | false | 0.037619 | 0.036612 | 1.027491 | [
"s409680648",
"s504019075"
] |
u325119213 | p03835 | python | s856246998 | s811871986 | 1,546 | 664 | 9,040 | 9,180 | Accepted | Accepted | 57.05 | def actual(K, S):
count = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - (x + y)
cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
cond2 = (x + y + z) == S
if cond1 and cond2:
count += 1
return count
... | def actual(K, S):
count = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - (x + y)
if 0 <= z <= K:
count += 1
return count
K, S = list(map(int, input().split()))
print((actual(K, S))) | 17 | 14 | 374 | 259 | def actual(K, S):
count = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - (x + y)
cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)
cond2 = (x + y + z) == S
if cond1 and cond2:
count += 1
return count
K, S = list(map(i... | def actual(K, S):
count = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - (x + y)
if 0 <= z <= K:
count += 1
return count
K, S = list(map(int, input().split()))
print((actual(K, S)))
| false | 17.647059 | [
"- cond1 = (0 <= x <= K) and (0 <= y <= K) and (0 <= z <= K)",
"- cond2 = (x + y + z) == S",
"- if cond1 and cond2:",
"+ if 0 <= z <= K:"
] | false | 0.037801 | 0.057895 | 0.652931 | [
"s856246998",
"s811871986"
] |
u319725914 | p00210 | python | s248953891 | s993469510 | 140 | 100 | 5,744 | 5,636 | Accepted | Accepted | 28.57 | from sys import stdin
from itertools import chain
head = [[8,1,2,4],[1,2,4,8],[2,4,8,1],[4,8,1,2]]
while(True):
W,H = list(map(int, stdin.readline().split()))
m = [[0]*W for _ in range(H)]
ps = []
if not (W or H): break
flag = True
for h in range(H):
s = stdin.readline()
... | from sys import stdin
# from line_profiler import LineProfiler
def main():
head = [[8,1,2,4],[1,2,4,8],[2,4,8,1],[4,8,1,2]]
while(True):
W,H = list(map(int, stdin.readline().split()))
m = [[0]*W for _ in range(H)]
ps = []
if not (W or H): break
for h in ran... | 88 | 57 | 2,970 | 2,348 | from sys import stdin
from itertools import chain
head = [[8, 1, 2, 4], [1, 2, 4, 8], [2, 4, 8, 1], [4, 8, 1, 2]]
while True:
W, H = list(map(int, stdin.readline().split()))
m = [[0] * W for _ in range(H)]
ps = []
if not (W or H):
break
flag = True
for h in range(H):
s = stdin.r... | from sys import stdin
# from line_profiler import LineProfiler
def main():
head = [[8, 1, 2, 4], [1, 2, 4, 8], [2, 4, 8, 1], [4, 8, 1, 2]]
while True:
W, H = list(map(int, stdin.readline().split()))
m = [[0] * W for _ in range(H)]
ps = []
if not (W or H):
break
... | false | 35.227273 | [
"-from itertools import chain",
"-head = [[8, 1, 2, 4], [1, 2, 4, 8], [2, 4, 8, 1], [4, 8, 1, 2]]",
"-while True:",
"- W, H = list(map(int, stdin.readline().split()))",
"- m = [[0] * W for _ in range(H)]",
"- ps = []",
"- if not (W or H):",
"- break",
"- flag = True",
"- f... | false | 0.121605 | 0.095867 | 1.268478 | [
"s248953891",
"s993469510"
] |
u130900604 | p02787 | python | s097030728 | s502047735 | 1,110 | 204 | 289,544 | 73,984 | Accepted | Accepted | 81.62 |
h,n=list(map(int,input().split()))
a=[]
b=[]
for i in range(n):
x,y=list(map(int,input().split()))
a.append(x)
b.append(y)
INF=float("inf")
dp=([[INF]*(1+h) for i in range(1+n)])
dp[0][0]=0
for i in range(n):
# print(dp)
for j in range(h+1):
# print("i+1=",i+1,"j... | def LI():
return list(map(int,input().split()))
h,n=LI()
a=[]
b=[]
for _ in range(n):
x,y=LI()
a.append(x)
b.append(y)
INF=10**15
dp=[INF]*(h+max(a)+10)
dp[0]=0
for i in range(0,h+1):
for j,k in zip(a,b):
dp[i+j]=min(dp[i+j],dp[i]+k)
ans=INF
for i in dp[h:]:
ans=min(ans,i)
prin... | 27 | 22 | 548 | 326 | h, n = list(map(int, input().split()))
a = []
b = []
for i in range(n):
x, y = list(map(int, input().split()))
a.append(x)
b.append(y)
INF = float("inf")
dp = [[INF] * (1 + h) for i in range(1 + n)]
dp[0][0] = 0
for i in range(n):
# print(dp)
for j in range(h + 1):
# print("i+1=",i+1,"j=",j)... | def LI():
return list(map(int, input().split()))
h, n = LI()
a = []
b = []
for _ in range(n):
x, y = LI()
a.append(x)
b.append(y)
INF = 10**15
dp = [INF] * (h + max(a) + 10)
dp[0] = 0
for i in range(0, h + 1):
for j, k in zip(a, b):
dp[i + j] = min(dp[i + j], dp[i] + k)
ans = INF
for i in ... | false | 18.518519 | [
"-h, n = list(map(int, input().split()))",
"+def LI():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+h, n = LI()",
"-for i in range(n):",
"- x, y = list(map(int, input().split()))",
"+for _ in range(n):",
"+ x, y = LI()",
"-INF = float(\"inf\")",
"-dp = [[INF] * (1 + h) fo... | false | 0.299886 | 0.245833 | 1.219879 | [
"s097030728",
"s502047735"
] |
u028973125 | p03436 | python | s936952462 | s722119027 | 188 | 31 | 40,176 | 3,700 | Accepted | Accepted | 83.51 | import sys
from pprint import pprint
from collections import deque
h, w = list(map(int, sys.stdin.readline().strip().split(" ")))
field = []
for _ in range(h):
field.append(list(sys.stdin.readline().strip()))
black = 0
for i in range(h):
for j in range(w):
if field[i][j] == "#":
... | import sys
from collections import deque
H, W = list(map(int, sys.stdin.readline().strip().split()))
grid = [[]] * H
movable = 0
for i in range(H):
grid[i] = list(sys.stdin.readline().strip())
for j in grid[i]:
if j == ".":
movable += 1
# print(movable)
q = deque()
q.append((... | 42 | 37 | 1,089 | 877 | import sys
from pprint import pprint
from collections import deque
h, w = list(map(int, sys.stdin.readline().strip().split(" ")))
field = []
for _ in range(h):
field.append(list(sys.stdin.readline().strip()))
black = 0
for i in range(h):
for j in range(w):
if field[i][j] == "#":
black += 1
... | import sys
from collections import deque
H, W = list(map(int, sys.stdin.readline().strip().split()))
grid = [[]] * H
movable = 0
for i in range(H):
grid[i] = list(sys.stdin.readline().strip())
for j in grid[i]:
if j == ".":
movable += 1
# print(movable)
q = deque()
q.append((0, 0, 0))
visit... | false | 11.904762 | [
"-from pprint import pprint",
"-h, w = list(map(int, sys.stdin.readline().strip().split(\" \")))",
"-field = []",
"-for _ in range(h):",
"- field.append(list(sys.stdin.readline().strip()))",
"-black = 0",
"-for i in range(h):",
"- for j in range(w):",
"- if field[i][j] == \"#\":",
"- ... | false | 0.065664 | 0.037072 | 1.771252 | [
"s936952462",
"s722119027"
] |
u256678932 | p02392 | python | s469533092 | s570370812 | 30 | 20 | 7,548 | 5,588 | Accepted | Accepted | 33.33 | a, b, c = list(map(int, input().split(' ')))
if a < b < c:
print('Yes')
else:
print('No') | a, b, c = list(map(int, input().split()))
if a < b < c:
print("Yes")
else:
print("No")
| 6 | 7 | 97 | 97 | a, b, c = list(map(int, input().split(" ")))
if a < b < c:
print("Yes")
else:
print("No")
| a, b, c = list(map(int, input().split()))
if a < b < c:
print("Yes")
else:
print("No")
| false | 14.285714 | [
"-a, b, c = list(map(int, input().split(\" \")))",
"+a, b, c = list(map(int, input().split()))"
] | false | 0.042556 | 0.042571 | 0.999632 | [
"s469533092",
"s570370812"
] |
u886747123 | p03241 | python | s634280222 | s374473340 | 478 | 23 | 40,044 | 3,060 | Accepted | Accepted | 95.19 | # D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す
N, M = list(map(int, input().split()))
if N == 1:
print(M)
exit()
x = M//N
while 1:
if M % x == 0:
ans = x
break
x -= 1
print(ans) | # D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す
N, M = list(map(int, input().split()))
x = min(M//N, int(M**0.5))
ans_list = []
while x > 0:
if M % x == 0:
ans_list.append(x)
if (M//x) * N <= M:
ans_list.append(M//x)
x -= 1
print((max(ans_list))) | 18 | 16 | 235 | 302 | # D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す
N, M = list(map(int, input().split()))
if N == 1:
print(M)
exit()
x = M // N
while 1:
if M % x == 0:
ans = x
break
x -= 1
print(ans)
| # D - Partition
# Mの約数で、しかもN倍してもMを超えないもののうち、最大のものを探す
N, M = list(map(int, input().split()))
x = min(M // N, int(M**0.5))
ans_list = []
while x > 0:
if M % x == 0:
ans_list.append(x)
if (M // x) * N <= M:
ans_list.append(M // x)
x -= 1
print((max(ans_list)))
| false | 11.111111 | [
"-if N == 1:",
"- print(M)",
"- exit()",
"-x = M // N",
"-while 1:",
"+x = min(M // N, int(M**0.5))",
"+ans_list = []",
"+while x > 0:",
"- ans = x",
"- break",
"+ ans_list.append(x)",
"+ if (M // x) * N <= M:",
"+ ans_list.append(M // x)",
"-pr... | false | 0.062381 | 0.059898 | 1.041454 | [
"s634280222",
"s374473340"
] |
u777923818 | p03716 | python | s628760075 | s735291469 | 455 | 319 | 37,596 | 37,212 | Accepted | Accepted | 29.89 | # -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from heapq import heapify, heappop, heappush
from copy import deepcopy
N = int(eval(input()))
A = inpl()
before = deepcopy(A[:N])
heapify(before)
middle = A[N:-N]
after = [-a for a in A[-N:]]
heapify(after)
sb = sum(A[:N])
sa =... | # -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from heapq import heapify, heapreplace
N = int(eval(input()))
A = inpl()
L = A[:N]
M = A[N:2*N]
R = [-a for a in A[2*N:]]
ans = sum(L) + sum(R)
heapify(L)
heapify(R)
i = 0
j = N+1
S = [0]*(N+1)
s = 0
for i, m in enumera... | 41 | 33 | 766 | 537 | # -*- coding: utf-8 -*-
def inpl():
return list(map(int, input().split()))
from heapq import heapify, heappop, heappush
from copy import deepcopy
N = int(eval(input()))
A = inpl()
before = deepcopy(A[:N])
heapify(before)
middle = A[N:-N]
after = [-a for a in A[-N:]]
heapify(after)
sb = sum(A[:N])
sa = -sum(A[-N:... | # -*- coding: utf-8 -*-
def inpl():
return list(map(int, input().split()))
from heapq import heapify, heapreplace
N = int(eval(input()))
A = inpl()
L = A[:N]
M = A[N : 2 * N]
R = [-a for a in A[2 * N :]]
ans = sum(L) + sum(R)
heapify(L)
heapify(R)
i = 0
j = N + 1
S = [0] * (N + 1)
s = 0
for i, m in enumerate(M):... | false | 19.512195 | [
"-from heapq import heapify, heappop, heappush",
"-from copy import deepcopy",
"+from heapq import heapify, heapreplace",
"-before = deepcopy(A[:N])",
"-heapify(before)",
"-middle = A[N:-N]",
"-after = [-a for a in A[-N:]]",
"-heapify(after)",
"-sb = sum(A[:N])",
"-sa = -sum(A[-N:])",
"-SB = [sb... | false | 0.041671 | 0.036366 | 1.145879 | [
"s628760075",
"s735291469"
] |
u696273805 | p02257 | python | s497783881 | s658208760 | 370 | 70 | 5,756 | 5,632 | Accepted | Accepted | 81.08 | import math
def is_prime(n):
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return n != 1
n = int(eval(input()))
answer = 0
for _ in range(0, n):
m = int(eval(input()))
if is_prime(m):
answer = answer + 1
print(answer)
| def is_prime(n):
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return n != 1
def witness(a, n, t, u):
x = pow(a, u, n) # x0 = a^u mod nを計算
y = x
for _ in range(0, t):
y = (x * x) % n
# 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
... | 15 | 46 | 284 | 1,055 | import math
def is_prime(n):
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return n != 1
n = int(eval(input()))
answer = 0
for _ in range(0, n):
m = int(eval(input()))
if is_prime(m):
answer = answer + 1
print(answer)
| def is_prime(n):
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return n != 1
def witness(a, n, t, u):
x = pow(a, u, n) # x0 = a^u mod nを計算
y = x
for _ in range(0, t):
y = (x * x) % n
# 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
if y == 1 and ... | false | 67.391304 | [
"-import math",
"-",
"-",
"+def witness(a, n, t, u):",
"+ x = pow(a, u, n) # x0 = a^u mod nを計算",
"+ y = x",
"+ for _ in range(0, t):",
"+ y = (x * x) % n",
"+ # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る",
"+ if y == 1 and x != 1 and x != (n - 1):",
"+ return T... | false | 0.041925 | 0.06811 | 0.615543 | [
"s497783881",
"s658208760"
] |
u227082700 | p02883 | python | s877331663 | s187642320 | 790 | 579 | 127,200 | 120,268 | Accepted | Accepted | 26.71 | n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=1)
su=ok=ng=0
for i in range(n):
ok=max(ok,a[i]*f[i])
su+=a[i]
if su<=k:print((0));exit()
while ng+1!=ok:
mid=(ok+ng)//2
b=[mid//i for i in f]
b.sort()
h=0
for i in r... | n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=1)
su=ok=ng=0
for i in range(n):
ok=max(ok,a[i]*f[i])
su+=a[i]
if su<=k:print((0));exit()
while ng+1<ok:
mid=(ok+ng)//2
h=0
for i in range(n):
h+=max(a[i]-(mid//f[i]),... | 19 | 18 | 383 | 358 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=1)
su = ok = ng = 0
for i in range(n):
ok = max(ok, a[i] * f[i])
su += a[i]
if su <= k:
print((0))
exit()
while ng + 1 != ok:
mid = (ok + ng) // 2
b = [mid // i ... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=1)
su = ok = ng = 0
for i in range(n):
ok = max(ok, a[i] * f[i])
su += a[i]
if su <= k:
print((0))
exit()
while ng + 1 < ok:
mid = (ok + ng) // 2
h = 0
for i... | false | 5.263158 | [
"-while ng + 1 != ok:",
"+while ng + 1 < ok:",
"- b = [mid // i for i in f]",
"- b.sort()",
"- h += max(0, a[i] - b[i])",
"+ h += max(a[i] - (mid // f[i]), 0)"
] | false | 0.046556 | 0.232513 | 0.200229 | [
"s877331663",
"s187642320"
] |
u466917094 | p03291 | python | s218629112 | s724806701 | 1,349 | 993 | 21,672 | 21,500 | Accepted | Accepted | 26.39 | import numpy as np
s=eval(input())
n=len(s)
MOD=1000000007
wayA=np.array([0,0,0,0])
wayB=np.array([0,0,0,0])
wayC=np.array([0,0,0,0])
hatena=0
for c in s:
if c=="A":
wayA[0]+=1
if c=="B":
wayB+=wayA
if c=='C':
wayC+=wayB
if c=='?':
wayC[1]=wayC[1]+wayB[0]
wayC[2]=wayC[2]+wayB[1]
wayC[3... | import numpy as np
s=eval(input())
n=len(s)
MOD=1000000007
wayA=np.array([0,0,0,0])
wayB=np.array([0,0,0,0])
wayC=np.array([0,0,0,0])
hatena=0
for c in s:
if c=="A":
wayA[0]+=1
if c=="B":
wayB+=wayA
if c=='C':
wayC+=wayB
if c=='?':
wayC[1]=wayC[1]+wayB[0]
wayC[2]=wayC[2]+wayB[1]
wayC[3... | 28 | 27 | 513 | 500 | import numpy as np
s = eval(input())
n = len(s)
MOD = 1000000007
wayA = np.array([0, 0, 0, 0])
wayB = np.array([0, 0, 0, 0])
wayC = np.array([0, 0, 0, 0])
hatena = 0
for c in s:
if c == "A":
wayA[0] += 1
if c == "B":
wayB += wayA
if c == "C":
wayC += wayB
if c == "?":
wa... | import numpy as np
s = eval(input())
n = len(s)
MOD = 1000000007
wayA = np.array([0, 0, 0, 0])
wayB = np.array([0, 0, 0, 0])
wayC = np.array([0, 0, 0, 0])
hatena = 0
for c in s:
if c == "A":
wayA[0] += 1
if c == "B":
wayB += wayA
if c == "C":
wayC += wayB
if c == "?":
wa... | false | 3.571429 | [
"- ans = ans + pow(3, hatena - i) * wayC[i]",
"- ans = ans % MOD",
"-print((int(ans)))",
"+ ans += pow(3, hatena - i) * wayC[i]",
"+print((int(ans % MOD)))"
] | false | 0.635918 | 0.472914 | 1.344679 | [
"s218629112",
"s724806701"
] |
u754022296 | p03083 | python | s161661718 | s164465561 | 618 | 378 | 36,768 | 58,584 | Accepted | Accepted | 38.83 | def main():
U = 2*10**5
MOD = 10**9+7
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
two = [1]*(U+1)
two_inv = [1]*(U+1)
for i in range(1,U+1):
fact[i] = (fact[i-1]*i)%MOD
two[i] = (two[i-1]*2)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
two_inv[U] = pow(two[U], MOD-2, MOD)
for... | U = 2*10**5
MOD = 10**9+7
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
two = [1]*(U+1)
two_inv = [1]*(U+1)
for i in range(1,U+1):
fact[i] = (fact[i-1]*i)%MOD
two[i] = (two[i-1]*2)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
two_inv[U] = pow(two[U], MOD-2, MOD)
for i in range(U,0,-1):
fact_inv[i... | 46 | 41 | 945 | 819 | def main():
U = 2 * 10**5
MOD = 10**9 + 7
fact = [1] * (U + 1)
fact_inv = [1] * (U + 1)
two = [1] * (U + 1)
two_inv = [1] * (U + 1)
for i in range(1, U + 1):
fact[i] = (fact[i - 1] * i) % MOD
two[i] = (two[i - 1] * 2) % MOD
fact_inv[U] = pow(fact[U], MOD - 2, MOD)
two... | U = 2 * 10**5
MOD = 10**9 + 7
fact = [1] * (U + 1)
fact_inv = [1] * (U + 1)
two = [1] * (U + 1)
two_inv = [1] * (U + 1)
for i in range(1, U + 1):
fact[i] = (fact[i - 1] * i) % MOD
two[i] = (two[i - 1] * 2) % MOD
fact_inv[U] = pow(fact[U], MOD - 2, MOD)
two_inv[U] = pow(two[U], MOD - 2, MOD)
for i in range(U, 0,... | false | 10.869565 | [
"-def main():",
"- U = 2 * 10**5",
"- MOD = 10**9 + 7",
"- fact = [1] * (U + 1)",
"- fact_inv = [1] * (U + 1)",
"- two = [1] * (U + 1)",
"- two_inv = [1] * (U + 1)",
"- for i in range(1, U + 1):",
"- fact[i] = (fact[i - 1] * i) % MOD",
"- two[i] = (two[i - 1] * 2... | false | 0.84646 | 0.801035 | 1.056708 | [
"s161661718",
"s164465561"
] |
u197457087 | p03476 | python | s938979250 | s343596292 | 1,396 | 505 | 15,396 | 12,780 | Accepted | Accepted | 63.83 | N = int(eval(input()))
MAX=110000
S = [_+2 for _ in range(MAX)]
old = S
i = 0
while True:
new = set([])
t = old[i]
for j in range(len(old)):
if old[j] == t or old[j]%t != 0:
new.add(old[j])
if len(old) == len(new):
break
old = list(new)
old.sort()
i += 1
#print(old)
A = ... | def get_sieve_of_eratosthenes(n):
if not isinstance(n, int):
raise TypeError('n is int type.')
if n < 2:
raise ValueError('n is more than 2')
prime = [2]
limit = int(n**0.5) #ルートn以上で割れることはない
data = [i + 1 for i in range(2, n, 2)] #最初から3スタートの奇数にしておく
while True:
p ... | 34 | 30 | 632 | 862 | N = int(eval(input()))
MAX = 110000
S = [_ + 2 for _ in range(MAX)]
old = S
i = 0
while True:
new = set([])
t = old[i]
for j in range(len(old)):
if old[j] == t or old[j] % t != 0:
new.add(old[j])
if len(old) == len(new):
break
old = list(new)
old.sort()
i += 1
# p... | def get_sieve_of_eratosthenes(n):
if not isinstance(n, int):
raise TypeError("n is int type.")
if n < 2:
raise ValueError("n is more than 2")
prime = [2]
limit = int(n**0.5) # ルートn以上で割れることはない
data = [i + 1 for i in range(2, n, 2)] # 最初から3スタートの奇数にしておく
while True:
p = dat... | false | 11.764706 | [
"-N = int(eval(input()))",
"-MAX = 110000",
"-S = [_ + 2 for _ in range(MAX)]",
"-old = S",
"-i = 0",
"-while True:",
"- new = set([])",
"- t = old[i]",
"- for j in range(len(old)):",
"- if old[j] == t or old[j] % t != 0:",
"- new.add(old[j])",
"- if len(old) == l... | false | 1.131765 | 0.189661 | 5.967303 | [
"s938979250",
"s343596292"
] |
u533039576 | p02991 | python | s317204930 | s289542992 | 1,197 | 940 | 102,896 | 105,328 | Accepted | Accepted | 21.47 | n, m = list(map(int, input().split()))
graph1 = [[] for _ in range(n*3)]
for _ in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
graph1[u*3+0].append(v*3+1)
graph1[u*3+1].append(v*3+2)
graph1[u*3+2].append(v*3+0)
s, t = list(map(int, input().split()))
s -= 1
t -=... | n, m = list(map(int, input().split()))
graph1 = [[] for _ in range(n * 3)]
for _ in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
graph1[u * 3 + 0].append(v * 3 + 1)
graph1[u * 3 + 1].append(v * 3 + 2)
graph1[u * 3 + 2].append(v * 3 + 0)
s, t = list(map(int, input... | 43 | 45 | 1,025 | 1,036 | n, m = list(map(int, input().split()))
graph1 = [[] for _ in range(n * 3)]
for _ in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
graph1[u * 3 + 0].append(v * 3 + 1)
graph1[u * 3 + 1].append(v * 3 + 2)
graph1[u * 3 + 2].append(v * 3 + 0)
s, t = list(map(int, input().split()))
s ... | n, m = list(map(int, input().split()))
graph1 = [[] for _ in range(n * 3)]
for _ in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
graph1[u * 3 + 0].append(v * 3 + 1)
graph1[u * 3 + 1].append(v * 3 + 2)
graph1[u * 3 + 2].append(v * 3 + 0)
s, t = list(map(int, input().split()))
s ... | false | 4.444444 | [
"-def dijkstra(graph: list, node: int, start: int) -> list:",
"+def dijkstra(graph: list, n: int, start: int, INF: int = float(\"inf\")) -> list:",
"- inf = float(\"inf\")",
"- dist = [inf] * node",
"+ dist = [INF] * n",
"+ num = [0] * n",
"- NextCost = 1",
"- cost, thisNode = he... | false | 0.045161 | 0.109348 | 0.413003 | [
"s317204930",
"s289542992"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.