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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u450956662 | p03699 | python | s251225930 | s103003357 | 58 | 29 | 10,412 | 9,188 | Accepted | Accepted | 50 | N = int(eval(input()))
res = set([0])
for _ in range(N):
s = int(eval(input()))
res |= set([r + s for r in res])
res = list(res)
res.sort()
n = len(res)
for i in range(n-1, -1, -1):
if res[i] % 10 == 0:
continue
print((res[i]))
break
else:
print((0)) | N = int(eval(input()))
S = [int(eval(input())) for _ in range(N)]
S.sort()
total = sum(S)
T = [s for s in S if s % 10 != 0]
if total % 10 != 0:
print(total)
elif len(T) > 0:
print((total - T[0]))
else:
print((0)) | 15 | 11 | 280 | 218 | N = int(eval(input()))
res = set([0])
for _ in range(N):
s = int(eval(input()))
res |= set([r + s for r in res])
res = list(res)
res.sort()
n = len(res)
for i in range(n - 1, -1, -1):
if res[i] % 10 == 0:
continue
print((res[i]))
break
else:
print((0))
| N = int(eval(input()))
S = [int(eval(input())) for _ in range(N)]
S.sort()
total = sum(S)
T = [s for s in S if s % 10 != 0]
if total % 10 != 0:
print(total)
elif len(T) > 0:
print((total - T[0]))
else:
print((0))
| false | 26.666667 | [
"-res = set([0])",
"-for _ in range(N):",
"- s = int(eval(input()))",
"- res |= set([r + s for r in res])",
"-res = list(res)",
"-res.sort()",
"-n = len(res)",
"-for i in range(n - 1, -1, -1):",
"- if res[i] % 10 == 0:",
"- continue",
"- print((res[i]))",
"- break",
"+S... | false | 0.035894 | 0.085913 | 0.417791 | [
"s251225930",
"s103003357"
] |
u186838327 | p02917 | python | s885525620 | s672334867 | 168 | 66 | 38,256 | 61,748 | Accepted | Accepted | 60.71 | n = int(eval(input()))
b = list(map(int, input().split()))
ans = [0]*n
ans[n-1] = b[-1]
for j in reversed(list(range(n-1))):
b_ = b[j]
if ans[j+1] > b_:
ans[j+1] = b_
ans[j] = b_
#print(ans)
print((sum(ans)))
| n = int(eval(input()))
B = list(map(int, input().split()))
A = [B[0]]
for i in range(n-1):
if i != n-2:
a = min(B[i], B[i+1])
else:
a = B[i]
A.append(a)
print((sum(A)))
| 15 | 10 | 233 | 198 | n = int(eval(input()))
b = list(map(int, input().split()))
ans = [0] * n
ans[n - 1] = b[-1]
for j in reversed(list(range(n - 1))):
b_ = b[j]
if ans[j + 1] > b_:
ans[j + 1] = b_
ans[j] = b_
# print(ans)
print((sum(ans)))
| n = int(eval(input()))
B = list(map(int, input().split()))
A = [B[0]]
for i in range(n - 1):
if i != n - 2:
a = min(B[i], B[i + 1])
else:
a = B[i]
A.append(a)
print((sum(A)))
| false | 33.333333 | [
"-b = list(map(int, input().split()))",
"-ans = [0] * n",
"-ans[n - 1] = b[-1]",
"-for j in reversed(list(range(n - 1))):",
"- b_ = b[j]",
"- if ans[j + 1] > b_:",
"- ans[j + 1] = b_",
"- ans[j] = b_",
"-# print(ans)",
"-print((sum(ans)))",
"+B = list(map(int, input().split()))",... | false | 0.036918 | 0.043603 | 0.846687 | [
"s885525620",
"s672334867"
] |
u379959788 | p03569 | python | s062210076 | s019585646 | 135 | 81 | 16,604 | 3,316 | Accepted | Accepted | 40 | # C
S = eval(input())
N = len(S)
# 回分判定
ss = ""
for s in S:
if s == 'x':
pass
else:
ss += s
if ss != ss[::-1]:
print((-1))
exit()
if ss == "":
print((0))
exit()
# 真ん中を決める
# x の位置と個数を求める
n = len(ss)
if n % 2 == 0:
cnt = 0
for i in range(n//2+1):
... | S = eval(input())
N = len(S)
r = 0
l = 0
ans = 0
while l+r < N:
if S[l] == S[N-1 - r]:
l += 1
r += 1
else:
if S[l] == 'x':
l += 1
ans += 1
elif S[N-1 - r] == 'x':
r += 1
ans += 1
else:
print((-1)... | 98 | 21 | 2,290 | 347 | # C
S = eval(input())
N = len(S)
# 回分判定
ss = ""
for s in S:
if s == "x":
pass
else:
ss += s
if ss != ss[::-1]:
print((-1))
exit()
if ss == "":
print((0))
exit()
# 真ん中を決める
# x の位置と個数を求める
n = len(ss)
if n % 2 == 0:
cnt = 0
for i in range(n // 2 + 1):
for j in range(... | S = eval(input())
N = len(S)
r = 0
l = 0
ans = 0
while l + r < N:
if S[l] == S[N - 1 - r]:
l += 1
r += 1
else:
if S[l] == "x":
l += 1
ans += 1
elif S[N - 1 - r] == "x":
r += 1
ans += 1
else:
print((-1))
... | false | 78.571429 | [
"-# C",
"-# 回分判定",
"-ss = \"\"",
"-for s in S:",
"- if s == \"x\":",
"- pass",
"+r = 0",
"+l = 0",
"+ans = 0",
"+while l + r < N:",
"+ if S[l] == S[N - 1 - r]:",
"+ l += 1",
"+ r += 1",
"- ss += s",
"-if ss != ss[::-1]:",
"- print((-1))",
"- ex... | false | 0.08628 | 0.039417 | 2.188932 | [
"s062210076",
"s019585646"
] |
u017415492 | p02995 | python | s250668254 | s004100980 | 36 | 25 | 5,048 | 9,120 | Accepted | Accepted | 30.56 | import fractions
a,b,c,d=list(map(int,input().split()))
x=b//c
y=b//d
xy=b//(c*d//fractions.gcd(c,d))
b=b-x-y+xy
x=(a-1)//c
y=(a-1)//d
xy=(a-1)//(c*d//fractions.gcd(c,d))
a=(a-1)-x-y+xy
print((b-a)) | import math
a,b,c,d=list(map(int,input().split()))
lcm=(c*d)//math.gcd(c,d)
print(((b-(b//c+b//d-b//lcm))-(a-1-((a-1)//d+(a-1)//c-(a-1)//lcm)))) | 12 | 4 | 202 | 139 | import fractions
a, b, c, d = list(map(int, input().split()))
x = b // c
y = b // d
xy = b // (c * d // fractions.gcd(c, d))
b = b - x - y + xy
x = (a - 1) // c
y = (a - 1) // d
xy = (a - 1) // (c * d // fractions.gcd(c, d))
a = (a - 1) - x - y + xy
print((b - a))
| import math
a, b, c, d = list(map(int, input().split()))
lcm = (c * d) // math.gcd(c, d)
print(
(
(b - (b // c + b // d - b // lcm))
- (a - 1 - ((a - 1) // d + (a - 1) // c - (a - 1) // lcm))
)
)
| false | 66.666667 | [
"-import fractions",
"+import math",
"-x = b // c",
"-y = b // d",
"-xy = b // (c * d // fractions.gcd(c, d))",
"-b = b - x - y + xy",
"-x = (a - 1) // c",
"-y = (a - 1) // d",
"-xy = (a - 1) // (c * d // fractions.gcd(c, d))",
"-a = (a - 1) - x - y + xy",
"-print((b - a))",
"+lcm = (c * d) //... | false | 0.050322 | 0.03888 | 1.294288 | [
"s250668254",
"s004100980"
] |
u950708010 | p02972 | python | s817045960 | s521638136 | 892 | 177 | 63,720 | 12,688 | Accepted | Accepted | 80.16 | def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
return divisors
def solve():
n = int(input())
a = list(int(i) for i in input().split())
ans = [0]... | ##https://atcoder.jp/contests/abc134/submissions/6482430
import sys
input = sys.stdin.readline
def main():
n = int(eval(input()))
A = [0] + list(int(i) for i in input().split())
for i in range(n//2,0,-1):
A[i] = sum(A[i::i]) % 2
ans = [i for i, j in enumerate(A) if j]
print((len(ans... | 29 | 15 | 649 | 378 | def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
def solve():
n = int(input())
a = list(int(i) for i in input().split())
ans = [0] * ... | ##https://atcoder.jp/contests/abc134/submissions/6482430
import sys
input = sys.stdin.readline
def main():
n = int(eval(input()))
A = [0] + list(int(i) for i in input().split())
for i in range(n // 2, 0, -1):
A[i] = sum(A[i::i]) % 2
ans = [i for i, j in enumerate(A) if j]
print((len(ans))... | false | 48.275862 | [
"-def make_divisors(n):",
"- divisors = []",
"- for i in range(1, int(n**0.5) + 1):",
"- if n % i == 0:",
"- divisors.append(i)",
"- if i != n // i:",
"- divisors.append(n // i)",
"- return divisors",
"+##https://atcoder.jp/contests/abc134/submiss... | false | 0.157123 | 0.036971 | 4.249932 | [
"s817045960",
"s521638136"
] |
u380524497 | p02804 | python | s163776275 | s697787003 | 384 | 263 | 89,356 | 22,544 | Accepted | Accepted | 31.51 | P = 10**9 + 7
N = 1000000
inv_t = [0]+[1]
for i in range(2,N):
inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
A.sort()
mini_count = 0
maxim_count = 0
pattern = 1
for i in range(n-k, -1, -1):
mini ... | P = 10**9 + 7
N = 200000
inv_t = [0]+[1] # 逆元
for i in range(2, N):
inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
A.sort()
mini_count = 0
maxim_count = 0
pattern = 1
"""
minX, maxXとして選ばれるのはそれぞれ
minX:so... | 35 | 41 | 686 | 951 | P = 10**9 + 7
N = 1000000
inv_t = [0] + [1]
for i in range(2, N):
inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 10**9 + 7
A.sort()
mini_count = 0
maxim_count = 0
pattern = 1
for i in range(n - k, -1, -1):
mini = A[i]
mini_coun... | P = 10**9 + 7
N = 200000
inv_t = [0] + [1] # 逆元
for i in range(2, N):
inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
mod = 10**9 + 7
A.sort()
mini_count = 0
maxim_count = 0
pattern = 1
"""
minX, maxXとして選ばれるのはそれぞれ
minX:sortAの右からk番目(大きい数値からk個... | false | 14.634146 | [
"-N = 1000000",
"-inv_t = [0] + [1]",
"+N = 200000",
"+inv_t = [0] + [1] # 逆元",
"-for i in range(n - k, -1, -1):",
"- mini = A[i]",
"+\"\"\"",
"+minX, maxXとして選ばれるのはそれぞれ",
"+minX:sortAの右からk番目(大きい数値からk個取った時の最小値)とそれより左の要素",
"+maxX:sortAの左からk番目(小さい数値からk個取った時の最大値)とそれより右の要素",
"+選ばれるパターンはminXの場合自分の... | false | 1.473085 | 0.234718 | 6.27599 | [
"s163776275",
"s697787003"
] |
u036104576 | p02781 | python | s945344368 | s108709276 | 34 | 31 | 9,604 | 9,640 | Accepted | Accepted | 8.82 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, ... | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, ... | 61 | 57 | 1,437 | 1,256 | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split())
S = e... | import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# map(int, input().split())
S = e... | false | 6.557377 | [
"-dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(102)]",
"+import functools",
"+@functools.lru_cache(None)",
"- if dp[i][k][is_same] != 0:",
"- return dp[i][k][is_same]",
"- dp[i][k][is_same] = int(S[len(S) - i - 1])",
"+ return int(S[len(S) - i - 1])",
... | false | 0.035389 | 0.07352 | 0.481356 | [
"s945344368",
"s108709276"
] |
u773265208 | p02971 | python | s720878100 | s240865017 | 1,290 | 627 | 124,632 | 14,112 | Accepted | Accepted | 51.4 | import sys
import heapq
import copy
n = int(eval(input()))
a = []
for _ in range(n):
a.append(-1 * int(eval(input())))
b = copy.deepcopy(a)
heapq.heapify(b)
for i in range(n):
maximum = heapq.heappop(b)
if maximum == a[i]:
tmp = maximum
maximum = heapq.heappop(b)
print((maximum * (-1)))
... | import bisect
n = int(eval(input()))
a = []
for _ in range(n):
a.append(int(eval(input())))
a2 = sorted(a)
max_a = a2[-1]
index = bisect.bisect_left(a2,max_a)
num = n-index
if num > 1:
for _ in range(n):
print((a2[-1]))
else:
for i in range(n):
if a[i] == a2[-1]:
print((a2[-... | 23 | 23 | 391 | 341 | import sys
import heapq
import copy
n = int(eval(input()))
a = []
for _ in range(n):
a.append(-1 * int(eval(input())))
b = copy.deepcopy(a)
heapq.heapify(b)
for i in range(n):
maximum = heapq.heappop(b)
if maximum == a[i]:
tmp = maximum
maximum = heapq.heappop(b)
print((maximum * (-... | import bisect
n = int(eval(input()))
a = []
for _ in range(n):
a.append(int(eval(input())))
a2 = sorted(a)
max_a = a2[-1]
index = bisect.bisect_left(a2, max_a)
num = n - index
if num > 1:
for _ in range(n):
print((a2[-1]))
else:
for i in range(n):
if a[i] == a2[-1]:
print((a2[-2... | false | 0 | [
"-import sys",
"-import heapq",
"-import copy",
"+import bisect",
"- a.append(-1 * int(eval(input())))",
"-b = copy.deepcopy(a)",
"-heapq.heapify(b)",
"-for i in range(n):",
"- maximum = heapq.heappop(b)",
"- if maximum == a[i]:",
"- tmp = maximum",
"- maximum = heapq.he... | false | 0.049498 | 0.039171 | 1.263623 | [
"s720878100",
"s240865017"
] |
u674052742 | p03160 | python | s850171840 | s615467950 | 170 | 134 | 51,328 | 13,928 | Accepted | Accepted | 21.18 | # -*- coding: utf-8 -*-
"""
Created on Sat May 2 00:21:08 2020
@author: Kanaru Sato
"""
import sys
sys.setrecursionlimit(10 ** 6)
N = int(eval(input()))
h = list(map(int, input().split()))
memo = [-1]*N
memo[0] = 0
memo[1] = abs(h[1]-h[0])
#topdown
def cost(n):
if n <= 1 or memo[n] >= 0:
... | # -*- coding: utf-8 -*-
"""
Created on Sat May 2 18:45:39 2020
@author: Kanaru Sato
"""
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [-1]*n
for i in range(n):
if i == 0:
dp[i] = 0
elif i == 1:
dp[i] = abs(h[1]-h[0])
else:
dp[i] = min(dp[i-1]+... | 24 | 21 | 464 | 375 | # -*- coding: utf-8 -*-
"""
Created on Sat May 2 00:21:08 2020
@author: Kanaru Sato
"""
import sys
sys.setrecursionlimit(10**6)
N = int(eval(input()))
h = list(map(int, input().split()))
memo = [-1] * N
memo[0] = 0
memo[1] = abs(h[1] - h[0])
# topdown
def cost(n):
if n <= 1 or memo[n] >= 0:
return memo[n]... | # -*- coding: utf-8 -*-
"""
Created on Sat May 2 18:45:39 2020
@author: Kanaru Sato
"""
n = int(eval(input()))
h = list(map(int, input().split()))
dp = [-1] * n
for i in range(n):
if i == 0:
dp[i] = 0
elif i == 1:
dp[i] = abs(h[1] - h[0])
else:
dp[i] = min(dp[i - 1] + abs(h[i] - h[i... | false | 12.5 | [
"-Created on Sat May 2 00:21:08 2020",
"+Created on Sat May 2 18:45:39 2020",
"-import sys",
"-",
"-sys.setrecursionlimit(10**6)",
"-N = int(eval(input()))",
"+n = int(eval(input()))",
"-memo = [-1] * N",
"-memo[0] = 0",
"-memo[1] = abs(h[1] - h[0])",
"-# topdown",
"-def cost(n):",
"- i... | false | 0.045151 | 0.046337 | 0.974396 | [
"s850171840",
"s615467950"
] |
u197615397 | p02345 | python | s071831384 | s708508914 | 2,510 | 1,350 | 15,132 | 15,092 | Accepted | Accepted | 46.22 | import math
class SegmentTree:
__slots__ = ["elem_size", "tree_size", "tree"]
def __init__(self, a: list, default: int):
real_size = len(a)
self.elem_size = 1 << math.ceil(math.log2(real_size))
self.tree_size = 2 * self.elem_size
self.tree = [default]*self.elem_size ... | import math
class SegmentTree:
__slots__ = ["elem_size", "tree_size", "tree"]
def __init__(self, a: list, default: int):
real_size = len(a)
self.elem_size = 1 << math.ceil(math.log2(real_size))
self.tree_size = 2 * self.elem_size
self.tree = [default]*self.elem_size ... | 71 | 71 | 2,296 | 2,125 | import math
class SegmentTree:
__slots__ = ["elem_size", "tree_size", "tree"]
def __init__(self, a: list, default: int):
real_size = len(a)
self.elem_size = 1 << math.ceil(math.log2(real_size))
self.tree_size = 2 * self.elem_size
self.tree = (
[default] * self.elem... | import math
class SegmentTree:
__slots__ = ["elem_size", "tree_size", "tree"]
def __init__(self, a: list, default: int):
real_size = len(a)
self.elem_size = 1 << math.ceil(math.log2(real_size))
self.tree_size = 2 * self.elem_size
self.tree = (
[default] * self.elem... | false | 0 | [
"- def get_range_index(",
"- self, x: int, y: int, k: int = 1, l_end: int = 0, r_end: int = None",
"- ):",
"+ def get_range_indexes(self, x: int, y: int):",
"- if r_end is None:",
"- r_end = self.elem_size",
"- if l_end == x and y == r_end:",
"- retu... | false | 0.040178 | 0.088705 | 0.452934 | [
"s071831384",
"s708508914"
] |
u894114233 | p02316 | python | s166799169 | s563860373 | 660 | 470 | 15,868 | 6,644 | Accepted | Accepted | 28.79 | N,W=list(map(int,input().split()))
vw=[list(map(int,input().split())) for i in range(N)]
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(N):
for j in range(W+1):
if vw[i][1]>j:
dp[i+1][j]=dp[i][j]
else:
dp[i+1][j]=max(dp[i][j],dp[i+1][j-vw[i][1]]+vw[i][0])
print((d... | n,w=list(map(int,input().split()))
vw=[list(map(int,input().split())) for _ in range(n)]
dp=[0]*(w+1)
for i in range(n):
for j in range(vw[i][1],w+1):
dp[j]=max(dp[j],dp[j-vw[i][1]]+vw[i][0])
print((dp[w])) | 10 | 7 | 327 | 226 | N, W = list(map(int, input().split()))
vw = [list(map(int, input().split())) for i in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
for j in range(W + 1):
if vw[i][1] > j:
dp[i + 1][j] = dp[i][j]
else:
dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - vw[i]... | n, w = list(map(int, input().split()))
vw = [list(map(int, input().split())) for _ in range(n)]
dp = [0] * (w + 1)
for i in range(n):
for j in range(vw[i][1], w + 1):
dp[j] = max(dp[j], dp[j - vw[i][1]] + vw[i][0])
print((dp[w]))
| false | 30 | [
"-N, W = list(map(int, input().split()))",
"-vw = [list(map(int, input().split())) for i in range(N)]",
"-dp = [[0] * (W + 1) for _ in range(N + 1)]",
"-for i in range(N):",
"- for j in range(W + 1):",
"- if vw[i][1] > j:",
"- dp[i + 1][j] = dp[i][j]",
"- else:",
"- ... | false | 0.039719 | 0.041619 | 0.95435 | [
"s166799169",
"s563860373"
] |
u014333473 | p02953 | python | s914942137 | s570754483 | 76 | 64 | 14,396 | 20,636 | Accepted | Accepted | 15.79 | N = int(eval(input()))
H = list(map(int, input().split()))
judge = False
for i in range(1, len(H)):
if H[i] - H[i-1] >= 1:
H[i] -= 1
elif H[i] - H[i-1] < 0:
judge = True
break
print(('No' if judge else 'Yes')) | eval(input());a=list(map(int,input().split()));b=sorted(a)
for i,j in zip(a,b):
if abs(i-j)>1: print('No');break
else:
print('Yes') | 10 | 5 | 226 | 133 | N = int(eval(input()))
H = list(map(int, input().split()))
judge = False
for i in range(1, len(H)):
if H[i] - H[i - 1] >= 1:
H[i] -= 1
elif H[i] - H[i - 1] < 0:
judge = True
break
print(("No" if judge else "Yes"))
| eval(input())
a = list(map(int, input().split()))
b = sorted(a)
for i, j in zip(a, b):
if abs(i - j) > 1:
print("No")
break
else:
print("Yes")
| false | 50 | [
"-N = int(eval(input()))",
"-H = list(map(int, input().split()))",
"-judge = False",
"-for i in range(1, len(H)):",
"- if H[i] - H[i - 1] >= 1:",
"- H[i] -= 1",
"- elif H[i] - H[i - 1] < 0:",
"- judge = True",
"+eval(input())",
"+a = list(map(int, input().split()))",
"+b = so... | false | 0.035576 | 0.0354 | 1.004987 | [
"s914942137",
"s570754483"
] |
u469281291 | p02689 | python | s902198414 | s535017765 | 317 | 226 | 20,120 | 85,152 | Accepted | Accepted | 28.71 | import sys
import math
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ma = [0] * n
for i in range(m):
a, b = list(map(int, input().split()))
ma[a - 1] = max(ma[a-1],h[b - 1])
ma[b - 1] = max(ma[b-1] ,h[a - 1])
cnt = 0
for i in range(n):
if h[i] > ma[i]:
... | import sys
import math
import itertools
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
a, b = list(map(int, input().split()))
lis[a - 1] = max(lis[a - 1], h[b - 1])
lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
for ... | 15 | 17 | 329 | 377 | import sys
import math
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ma = [0] * n
for i in range(m):
a, b = list(map(int, input().split()))
ma[a - 1] = max(ma[a - 1], h[b - 1])
ma[b - 1] = max(ma[b - 1], h[a - 1])
cnt = 0
for i in range(n):
if h[i] > ma[i]:
cnt += 1... | import sys
import math
import itertools
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ans = [True] * n
lis = [0] * n
for i in range(m):
a, b = list(map(int, input().split()))
lis[a - 1] = max(lis[a - 1], h[b - 1])
lis[b - 1] = max(lis[b - 1], h[a - 1])
ans = 0
for i in range(n)... | false | 11.764706 | [
"+import itertools",
"-ma = [0] * n",
"+ans = [True] * n",
"+lis = [0] * n",
"- ma[a - 1] = max(ma[a - 1], h[b - 1])",
"- ma[b - 1] = max(ma[b - 1], h[a - 1])",
"-cnt = 0",
"+ lis[a - 1] = max(lis[a - 1], h[b - 1])",
"+ lis[b - 1] = max(lis[b - 1], h[a - 1])",
"+ans = 0",
"- if h[... | false | 0.040954 | 0.040818 | 1.003329 | [
"s902198414",
"s535017765"
] |
u930705402 | p03162 | python | s758009704 | s144260534 | 667 | 517 | 74,328 | 22,816 | Accepted | Accepted | 22.49 | N=int(eval(input()))
act=[]
for i in range(N):
act.append(list(map(int,input().split())))
dp=[[0]*3 for i in range(N+1)]
for i in range(1,N+1):
for j in range(3):
for k in range(3):
if(j!=k):
dp[i][j]=max(dp[i][j],dp[i-1][k]+act[i-1][j])
print((m... | N=int(eval(input()))
dp=[[0,0,0] for i in range(N+1)]
for i in range(1,N+1):
a,b,c=list(map(int,input().split()))
dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a)
dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b)
dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c)
print((max(dp[N]))) | 13 | 8 | 346 | 262 | N = int(eval(input()))
act = []
for i in range(N):
act.append(list(map(int, input().split())))
dp = [[0] * 3 for i in range(N + 1)]
for i in range(1, N + 1):
for j in range(3):
for k in range(3):
if j != k:
dp[i][j] = max(dp[i][j], dp[i - 1][k] + act[i - 1][j])
print((max([dp... | N = int(eval(input()))
dp = [[0, 0, 0] for i in range(N + 1)]
for i in range(1, N + 1):
a, b, c = list(map(int, input().split()))
dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a)
dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b)
dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c)
print((max(dp[N])))
| false | 38.461538 | [
"-act = []",
"-for i in range(N):",
"- act.append(list(map(int, input().split())))",
"-dp = [[0] * 3 for i in range(N + 1)]",
"+dp = [[0, 0, 0] for i in range(N + 1)]",
"- for j in range(3):",
"- for k in range(3):",
"- if j != k:",
"- dp[i][j] = max(dp[i][j], ... | false | 0.03203 | 0.036719 | 0.872315 | [
"s758009704",
"s144260534"
] |
u779455925 | p03734 | python | s351443881 | s826448473 | 966 | 309 | 123,480 | 66,924 | Accepted | Accepted | 68.01 | from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,W=list(map(int,input().split()))
WV=[list(map(int,input().split())) for i in range(N)]
lst=[]
for ... | from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,W=list(map(int,input().split()))
WV=[list(map(int,input().split())) for i in range(N)]
lst=deque([]... | 34 | 83 | 800 | 2,170 | from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input = lambda: sys.stdin.readline().rstrip()
N, W = list(map(int, input().split()))
WV = [list(map(int, input().split())) for i in range(N)]
lst = []
for w,... | from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input = lambda: sys.stdin.readline().rstrip()
N, W = list(map(int, input().split()))
WV = [list(map(int, input().split())) for i in range(N)]
lst = deque([])... | false | 59.036145 | [
"-lst = []",
"+lst = deque([])",
"+ nlst = deque([[w, v]])",
"- if w1:",
"- lst.append([w1 + w, v1 + v])",
"- lst.append([w, v])",
"- lst = sorted(lst, key=lambda x: x[0], reverse=True)",
"- while lst and lst[-1][0] == 0:",
"- lst.pop()",
"- w, v = lst[-1]",... | false | 0.054255 | 0.054728 | 0.991358 | [
"s351443881",
"s826448473"
] |
u186838327 | p02900 | python | s401534779 | s805319488 | 996 | 290 | 3,064 | 64,236 | Accepted | Accepted | 70.88 | a, b = list(map(int, input().split()))
import math
def prime(n):
if n == 1:
return False
i = 1
while i < int(math.sqrt(n)):
i += 1
if n%i == 0:
return False
else:
return True
#print(prime(1))
if prime(a) and prime(b) and a==b:
print((2))
exit()
if a-b == 1 o... | a, b = list(map(int, input().split()))
import fractions
g = fractions.gcd(a, b)
import math
def div(m):
d = {}
temp = int(math.sqrt(m))+1
for i in range(2, temp):
while m%i== 0:
m //= i
if i in d:
d[i] += 1
else:
... | 43 | 33 | 746 | 562 | a, b = list(map(int, input().split()))
import math
def prime(n):
if n == 1:
return False
i = 1
while i < int(math.sqrt(n)):
i += 1
if n % i == 0:
return False
else:
return True
# print(prime(1))
if prime(a) and prime(b) and a == b:
print((2))
exit(... | a, b = list(map(int, input().split()))
import fractions
g = fractions.gcd(a, b)
import math
def div(m):
d = {}
temp = int(math.sqrt(m)) + 1
for i in range(2, temp):
while m % i == 0:
m //= i
if i in d:
d[i] += 1
else:
d[i] = 1
... | false | 23.255814 | [
"+import fractions",
"+",
"+g = fractions.gcd(a, b)",
"-def prime(n):",
"- if n == 1:",
"- return False",
"- i = 1",
"- while i < int(math.sqrt(n)):",
"- i += 1",
"- if n % i == 0:",
"- return False",
"+def div(m):",
"+ d = {}",
"+ temp = int(... | false | 0.035993 | 0.053354 | 0.674598 | [
"s401534779",
"s805319488"
] |
u488401358 | p02728 | python | s569067291 | s128928249 | 2,761 | 1,427 | 178,864 | 169,136 | Accepted | Accepted | 48.32 | import sys,heapq
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 = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( (... | import sys
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 = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
g1.append( ( g1[-1... | 115 | 108 | 2,818 | 2,587 | import sys, heapq
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 = 2 * 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
g1.append(... | import sys
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 = 2 * 10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
g1.append((g1[-1]... | false | 6.086957 | [
"-import sys, heapq",
"+import sys",
"+write = sys.stdout.write",
"-heapq.heapify(q)",
"-heapq.heapify(sub)",
"- x = heapq.heappop(q)",
"+ x = q.pop()",
"- heapq.heappush(sub, p)",
"+ sub.append(p)",
"- heapq.heapify(sub)",
"-heapq.heapify(q... | false | 0.493342 | 0.387209 | 1.274097 | [
"s569067291",
"s128928249"
] |
u222668979 | p02702 | python | s437412731 | s544634254 | 450 | 127 | 79,356 | 76,412 | Accepted | Accepted | 71.78 | s = str(eval(input()))
num = [int(s[-1])]
for i in range(1, len(s)):
tmp = num[-1] + pow(10, i, 2019) * int(s[-i - 1])
num.append(tmp % 2019)
mod = [1] + [0] * 2018
ans = 0
for i in num:
m = i % 2019
ans += mod[m]
mod[m] += 1
print(ans)
| s = str(eval(input()))
num = [int(s[-1])]
for i in range(1, len(s)):
tmp = num[-1] + pow(10, i, 2019) * int(s[-i - 1])
num.append(tmp % 2019)
mod = [1] + [0] * 2018
ans = 0
for i in num:
ans += mod[i]
mod[i] += 1
print(ans)
| 14 | 13 | 266 | 248 | s = str(eval(input()))
num = [int(s[-1])]
for i in range(1, len(s)):
tmp = num[-1] + pow(10, i, 2019) * int(s[-i - 1])
num.append(tmp % 2019)
mod = [1] + [0] * 2018
ans = 0
for i in num:
m = i % 2019
ans += mod[m]
mod[m] += 1
print(ans)
| s = str(eval(input()))
num = [int(s[-1])]
for i in range(1, len(s)):
tmp = num[-1] + pow(10, i, 2019) * int(s[-i - 1])
num.append(tmp % 2019)
mod = [1] + [0] * 2018
ans = 0
for i in num:
ans += mod[i]
mod[i] += 1
print(ans)
| false | 7.142857 | [
"- m = i % 2019",
"- ans += mod[m]",
"- mod[m] += 1",
"+ ans += mod[i]",
"+ mod[i] += 1"
] | false | 0.079941 | 0.037263 | 2.145353 | [
"s437412731",
"s544634254"
] |
u902641880 | p02911 | python | s676368111 | s343590588 | 565 | 266 | 50,648 | 6,596 | Accepted | Accepted | 52.92 | N, Q, K = list(map(int, input().split()))
score = [Q-K] * N
for i in range(K):
score[int(eval(input()))-1] += 1
for i in score:
if i > 0:
print("Yes")
else:
print("No") | n, k, q = list(map(int, input().split()))
score = [k-q]*n
for i in range(q):
cor = int(eval(input()))
score[cor-1] += 1
for i in score:
if i <= 0:
print("No")
else:
print("Yes")
| 11 | 11 | 182 | 210 | N, Q, K = list(map(int, input().split()))
score = [Q - K] * N
for i in range(K):
score[int(eval(input())) - 1] += 1
for i in score:
if i > 0:
print("Yes")
else:
print("No")
| n, k, q = list(map(int, input().split()))
score = [k - q] * n
for i in range(q):
cor = int(eval(input()))
score[cor - 1] += 1
for i in score:
if i <= 0:
print("No")
else:
print("Yes")
| false | 0 | [
"-N, Q, K = list(map(int, input().split()))",
"-score = [Q - K] * N",
"-for i in range(K):",
"- score[int(eval(input())) - 1] += 1",
"+n, k, q = list(map(int, input().split()))",
"+score = [k - q] * n",
"+for i in range(q):",
"+ cor = int(eval(input()))",
"+ score[cor - 1] += 1",
"- if... | false | 0.198541 | 0.097531 | 2.035674 | [
"s676368111",
"s343590588"
] |
u286955577 | p03088 | python | s698864205 | s092906268 | 122 | 42 | 3,872 | 3,312 | Accepted | Accepted | 65.57 | 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 memo[cur]:
return memo[cur][last3]... | N, MOD = int(eval(input())), 10 ** 9 + 7
dp = [[[[0 for k in range(4)] for k in range(4)] for j in range(4)] for i in range(101)]
dp[0][3][3][3] = 1
for length in range(N):
for i in range(4):
for j in range(4):
for k in range(4):
if dp[length][i][j][k] == 0: continue
for a in range... | 25 | 27 | 505 | 824 | 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, MOD = int(eval(input())), 10**9 + 7
dp = [[[[0 for k in range(4)] for k in range(4)] for j in range(4)] for i in range(101)]
dp[0][3][3][3] = 1
for length in range(N):
for i in range(4):
for j in range(4):
for k in range(4):
if dp[length][i][j][k] == 0:
con... | false | 7.407407 | [
"-memo = [{} for i in range(N + 1)]",
"-",
"-",
"-def ok(last4):",
"+dp = [[[[0 for k in range(4)] for k in range(4)] for j in range(4)] for i in range(101)]",
"+dp[0][3][3][3] = 1",
"+for length in range(N):",
"- t = list(last4)",
"- if i >= 1:",
"- t[i - 1], t[i] = t[i],... | false | 0.077833 | 0.12342 | 0.630636 | [
"s698864205",
"s092906268"
] |
u545368057 | p03212 | python | s291024606 | s619991606 | 84 | 49 | 5,236 | 3,060 | Accepted | Accepted | 41.67 | from collections import deque
X = int(eval(input()))
# その時の数字と、3,5,7が今までに含まれていたか
q = deque([""])
q_is3 = deque([0])
q_is5 = deque([0])
q_is7 = deque([0])
N = "357"
ans = 0
while q:
num = q.popleft()
is3 = q_is3.popleft()
is5 = q_is5.popleft()
is7 = q_is7.popleft()
for n in N:
... | """
753の数
"""
import sys
sys.setrecursionlimit(100000)
N = int(eval(input()))
# seen = [False] * N
"""
1. Gを予め作って探索するパターン
2. Gを作りながら探索するパターン
"""
cnt = 0
def dfs(v):
global cnt
# vを訪問済みにする
# seen[v] = True
num = "753"
#グラフ中の次のVについて
for n in num:
next_v = v + n
... | 28 | 31 | 732 | 560 | from collections import deque
X = int(eval(input()))
# その時の数字と、3,5,7が今までに含まれていたか
q = deque([""])
q_is3 = deque([0])
q_is5 = deque([0])
q_is7 = deque([0])
N = "357"
ans = 0
while q:
num = q.popleft()
is3 = q_is3.popleft()
is5 = q_is5.popleft()
is7 = q_is7.popleft()
for n in N:
next_v = num +... | """
753の数
"""
import sys
sys.setrecursionlimit(100000)
N = int(eval(input()))
# seen = [False] * N
"""
1. Gを予め作って探索するパターン
2. Gを作りながら探索するパターン
"""
cnt = 0
def dfs(v):
global cnt
# vを訪問済みにする
# seen[v] = True
num = "753"
# グラフ中の次のVについて
for n in num:
next_v = v + n
# 探索打ち切り条件->
... | false | 9.677419 | [
"-from collections import deque",
"+\"\"\"",
"+753の数",
"+\"\"\"",
"+import sys",
"-X = int(eval(input()))",
"-# その時の数字と、3,5,7が今までに含まれていたか",
"-q = deque([\"\"])",
"-q_is3 = deque([0])",
"-q_is5 = deque([0])",
"-q_is7 = deque([0])",
"-N = \"357\"",
"-ans = 0",
"-while q:",
"- num = q.po... | false | 0.239556 | 0.146922 | 1.630502 | [
"s291024606",
"s619991606"
] |
u217627525 | p03835 | python | s243016551 | s881606139 | 1,735 | 23 | 2,940 | 3,572 | Accepted | Accepted | 98.67 | k,s=list(map(int,input().split()))
ans=0
for i in range(k+1):
for j in range(k+1):
z=s-i-j
if z>=0 and z<=k:
ans+=1
print(ans) | from operator import mul
from functools import reduce
def cmb(n,r):
r = min(n-r,r)
if r == 0: return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1,r + 1)))
return over // under
k,s=list(map(int,input().split()))
if s<=k:
print((cmb(s+2,2)))
elif ... | 8 | 23 | 159 | 480 | k, s = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
for j in range(k + 1):
z = s - i - j
if z >= 0 and z <= k:
ans += 1
print(ans)
| from operator import mul
from functools import reduce
def cmb(n, r):
r = min(n - r, r)
if r == 0:
return 1
over = reduce(mul, list(range(n, n - r, -1)))
under = reduce(mul, list(range(1, r + 1)))
return over // under
k, s = list(map(int, input().split()))
if s <= k:
print((cmb(s + 2,... | false | 65.217391 | [
"+from operator import mul",
"+from functools import reduce",
"+",
"+",
"+def cmb(n, r):",
"+ r = min(n - r, r)",
"+ if r == 0:",
"+ return 1",
"+ over = reduce(mul, list(range(n, n - r, -1)))",
"+ under = reduce(mul, list(range(1, r + 1)))",
"+ return over // under",
"+"... | false | 0.084095 | 0.043803 | 1.919839 | [
"s243016551",
"s881606139"
] |
u977661421 | p03107 | python | s894338948 | s433612596 | 76 | 22 | 4,652 | 3,956 | Accepted | Accepted | 71.05 | # -*- coding: utf-8 -*-
s = list(eval(input()))
tmp = []
ans = 0
for i in range(len(s)):
if len(tmp) > 0 and tmp[-1] == '0' and s[i] == '1':
tmp.pop()
ans += 2
elif len(tmp) > 0 and tmp[-1] == '1' and s[i] == '0':
tmp.pop()
ans += 2
else:
tmp.append(s[i]... | # -*- coding: utf-8 -*-
s = list(eval(input()))
ans = min(s.count('0'), s.count('1'))
print((ans * 2))
| 15 | 5 | 328 | 100 | # -*- coding: utf-8 -*-
s = list(eval(input()))
tmp = []
ans = 0
for i in range(len(s)):
if len(tmp) > 0 and tmp[-1] == "0" and s[i] == "1":
tmp.pop()
ans += 2
elif len(tmp) > 0 and tmp[-1] == "1" and s[i] == "0":
tmp.pop()
ans += 2
else:
tmp.append(s[i])
print(ans)
| # -*- coding: utf-8 -*-
s = list(eval(input()))
ans = min(s.count("0"), s.count("1"))
print((ans * 2))
| false | 66.666667 | [
"-tmp = []",
"-ans = 0",
"-for i in range(len(s)):",
"- if len(tmp) > 0 and tmp[-1] == \"0\" and s[i] == \"1\":",
"- tmp.pop()",
"- ans += 2",
"- elif len(tmp) > 0 and tmp[-1] == \"1\" and s[i] == \"0\":",
"- tmp.pop()",
"- ans += 2",
"- else:",
"- tmp... | false | 0.196636 | 0.042872 | 4.586528 | [
"s894338948",
"s433612596"
] |
u811512248 | p02974 | python | s935812871 | s728631170 | 1,800 | 1,486 | 80,504 | 58,620 | Accepted | Accepted | 17.44 | n, k = list(map(int, input().split()))
MOD =10**9+7
memo = [[{} for j in range(n+1)] for i in range(n+1)]
def fdp(cur_N, remain, min_k, MOD=10**9+7):
if cur_N <= 1:
if remain == 0 and min_k == 0:
return 1
if remain == 1 and min_k == 2:
return 1
else:
... | n, k = list(map(int, input().split()))
MOD =10**9+7
memo = [[{} for j in range(n+1)] for i in range(n+1)]
def fdp(cur_N, remain, min_k, MOD=10**9+7):
if cur_N <= 1:
if remain == 0 and min_k == 0:
return 1
if remain == 1 and min_k == 2:
return 1
else:
... | 26 | 30 | 805 | 886 | n, k = list(map(int, input().split()))
MOD = 10**9 + 7
memo = [[{} for j in range(n + 1)] for i in range(n + 1)]
def fdp(cur_N, remain, min_k, MOD=10**9 + 7):
if cur_N <= 1:
if remain == 0 and min_k == 0:
return 1
if remain == 1 and min_k == 2:
return 1
else:
... | n, k = list(map(int, input().split()))
MOD = 10**9 + 7
memo = [[{} for j in range(n + 1)] for i in range(n + 1)]
def fdp(cur_N, remain, min_k, MOD=10**9 + 7):
if cur_N <= 1:
if remain == 0 and min_k == 0:
return 1
if remain == 1 and min_k == 2:
return 1
else:
... | false | 13.333333 | [
"+ if cur_N < remain:",
"+ return 0",
"+ if min_k < 0:",
"+ return 0"
] | false | 0.65907 | 0.257139 | 2.563087 | [
"s935812871",
"s728631170"
] |
u119148115 | p03636 | python | s030574299 | s280648562 | 391 | 64 | 79,820 | 61,808 | Accepted | Accepted | 83.63 | import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.st... | import sys
def LS2():
return list(sys.stdin.readline().rstrip()) #空白なし
s = LS2()
print((s[0]+str(len(s)-2)+s[-1])) | 13 | 7 | 469 | 126 | import sys
sys.setrecursionlimit(10**7)
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり
def LI2():
return list(map(int, sys.stdin.readline().rstrip())) # 空白なし
def S():
return sys.stdin.readline().rstrip()
def L... | import sys
def LS2():
return list(sys.stdin.readline().rstrip()) # 空白なし
s = LS2()
print((s[0] + str(len(s) - 2) + s[-1]))
| false | 46.153846 | [
"-",
"-sys.setrecursionlimit(10**7)",
"-",
"-",
"-def I():",
"- return int(sys.stdin.readline().rstrip())",
"-",
"-",
"-def LI():",
"- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり",
"-",
"-",
"-def LI2():",
"- return list(map(int, sys.stdin.readline().rstri... | false | 0.134177 | 0.036158 | 3.710879 | [
"s030574299",
"s280648562"
] |
u367701763 | p02936 | python | s601234011 | s976580782 | 1,149 | 865 | 282,640 | 264,992 | Accepted | Accepted | 24.72 | # https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
input = sys.stdin.readline
from copy import deepcopy
class Graph:
def __init__(self, n, dictated=False, decrement=True, edge=[]):
self.n = n
self.dictated = dictated
self.decrement = decrement
self.edge = [... | # https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
input = sys.stdin.readline
import marshal
class Graph:
def __init__(self, n, dictated=False, decrement=True, edge=[]):
self.n = n
self.dictated = dictated
self.decrement = decrement
self.edge = [set() for _... | 102 | 102 | 2,905 | 2,901 | # https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
input = sys.stdin.readline
from copy import deepcopy
class Graph:
def __init__(self, n, dictated=False, decrement=True, edge=[]):
self.n = n
self.dictated = dictated
self.decrement = decrement
self.edge = [set() for _ ... | # https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
input = sys.stdin.readline
import marshal
class Graph:
def __init__(self, n, dictated=False, decrement=True, edge=[]):
self.n = n
self.dictated = dictated
self.decrement = decrement
self.edge = [set() for _ in range(se... | false | 0 | [
"-from copy import deepcopy",
"+import marshal",
"- # if not save:",
"- # self.parent = [-1] * self.n",
"- #",
"- edge2 = deepcopy(self.edge)",
"+ if not save:",
"+ self.parent = [-1] * self.n",
"+ edge2 = marshal.loads(marshal.dumps(self.edge... | false | 0.139417 | 0.046925 | 2.971053 | [
"s601234011",
"s976580782"
] |
u561231954 | p02796 | python | s112844568 | s542631776 | 533 | 423 | 40,996 | 21,692 | Accepted | Accepted | 20.64 | n=int(eval(input()))
rob=[list(map(int,input().split())) for i in range(n)]
rob=[[sum(rob[i]), rob[i][0]-rob[i][1]] for i in range(n)]
rob.sort(key=lambda i:i[0])
robp=[rob[i][0] for i in range(n)]
robm=[rob[i][1] for i in range(n)]
#print(robp)
#print(robm)
ans=0
x=-10**9
for i in range(n):
if x<=robm[i... | INF = 10 ** 9
MOD = 10 **9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from math import factorial
def main():
n = int(eval(input()))
Robot = [tuple(map(int,input().split())) for _ in range(n)]
Robot.sort(key = lambda x: sum(x))
... | 16 | 24 | 355 | 539 | n = int(eval(input()))
rob = [list(map(int, input().split())) for i in range(n)]
rob = [[sum(rob[i]), rob[i][0] - rob[i][1]] for i in range(n)]
rob.sort(key=lambda i: i[0])
robp = [rob[i][0] for i in range(n)]
robm = [rob[i][1] for i in range(n)]
# print(robp)
# print(robm)
ans = 0
x = -(10**9)
for i in range(n):
i... | INF = 10**9
MOD = 10**9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1, 0, 1, 0)
dx = (0, 1, 0, -1)
from collections import deque
from math import factorial
def main():
n = int(eval(input()))
Robot = [tuple(map(int, input().split())) for _ in range(n)]
Robot.sort(key=lambda x: sum(x))
ans =... | false | 33.333333 | [
"-n = int(eval(input()))",
"-rob = [list(map(int, input().split())) for i in range(n)]",
"-rob = [[sum(rob[i]), rob[i][0] - rob[i][1]] for i in range(n)]",
"-rob.sort(key=lambda i: i[0])",
"-robp = [rob[i][0] for i in range(n)]",
"-robm = [rob[i][1] for i in range(n)]",
"-# print(robp)",
"-# print(rob... | false | 0.116444 | 0.099707 | 1.167852 | [
"s112844568",
"s542631776"
] |
u583619578 | p02695 | python | s279581159 | s994502515 | 940 | 719 | 9,192 | 9,144 | Accepted | Accepted | 23.51 | import itertools
n,m,q = list(map(int,input().split()))
target = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(list(range(1,m+1)),n):
count = 0
for abcd in target:
if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]:
count += abcd[3]
ans... | import itertools
n,m,q = list(map(int,input().split()))
target = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(list(range(1,m+1)),n):
count = sum([abcd[3] for abcd in target if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]])
ans = max(ans,count)
print(an... | 14 | 8 | 339 | 310 | import itertools
n, m, q = list(map(int, input().split()))
target = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(list(range(1, m + 1)), n):
count = 0
for abcd in target:
if A[abcd[1] - 1] - A[abcd[0] - 1] == abcd[2]:
count += a... | import itertools
n, m, q = list(map(int, input().split()))
target = [list(map(int, input().split())) for _ in range(q)]
ans = 0
for A in itertools.combinations_with_replacement(list(range(1, m + 1)), n):
count = sum(
[abcd[3] for abcd in target if A[abcd[1] - 1] - A[abcd[0] - 1] == abcd[2]]
)
ans =... | false | 42.857143 | [
"- count = 0",
"- for abcd in target:",
"- if A[abcd[1] - 1] - A[abcd[0] - 1] == abcd[2]:",
"- count += abcd[3]",
"+ count = sum(",
"+ [abcd[3] for abcd in target if A[abcd[1] - 1] - A[abcd[0] - 1] == abcd[2]]",
"+ )"
] | false | 0.055787 | 0.085487 | 0.652585 | [
"s279581159",
"s994502515"
] |
u844789719 | p03295 | python | s710383151 | s781250079 | 592 | 202 | 24,176 | 31,692 | Accepted | Accepted | 65.88 | N, M = [int(_) for _ in input().split()]
AB = sorted([[int(_) for _ in input().split()] for _ in range(M)])
l = 0
r = N + 1
ans = 1
for i in range(M):
if AB[i][0] < r:
r = min(r, AB[i][1])
else:
ans += 1
r = AB[i][1]
l = AB[i][0]
print(ans) | import bisect
N, M, *AB = [int(_) for _ in open(0).read().split()]
AB = sorted(zip(AB[::2], AB[1::2]))
l, r = AB[0]
ans = 1
for a, b in AB[1:]:
if r <= a:
l, r = a, b
ans += 1
else:
r = min(r, b)
print(ans)
| 14 | 12 | 290 | 250 | N, M = [int(_) for _ in input().split()]
AB = sorted([[int(_) for _ in input().split()] for _ in range(M)])
l = 0
r = N + 1
ans = 1
for i in range(M):
if AB[i][0] < r:
r = min(r, AB[i][1])
else:
ans += 1
r = AB[i][1]
l = AB[i][0]
print(ans)
| import bisect
N, M, *AB = [int(_) for _ in open(0).read().split()]
AB = sorted(zip(AB[::2], AB[1::2]))
l, r = AB[0]
ans = 1
for a, b in AB[1:]:
if r <= a:
l, r = a, b
ans += 1
else:
r = min(r, b)
print(ans)
| false | 14.285714 | [
"-N, M = [int(_) for _ in input().split()]",
"-AB = sorted([[int(_) for _ in input().split()] for _ in range(M)])",
"-l = 0",
"-r = N + 1",
"+import bisect",
"+",
"+N, M, *AB = [int(_) for _ in open(0).read().split()]",
"+AB = sorted(zip(AB[::2], AB[1::2]))",
"+l, r = AB[0]",
"-for i in range(M):"... | false | 0.03579 | 0.035791 | 0.99997 | [
"s710383151",
"s781250079"
] |
u911449886 | p02787 | python | s713082872 | s261718447 | 639 | 237 | 111,736 | 68,612 | Accepted | Accepted | 62.91 | from sys import stdin
import numpy as np
from numba import njit
H,N = list(map(int, input().split()))
M = [list(map(int, stdin.readline().split())) for i in [0]*N]
M = np.array(M)
@njit
def main(h,n,m):
dp = [10**8+1]*(10**4+1)
dp = np.array(dp)
dp[0] = 0
for i in range(1,10**4+1):
... | def getval():
h,n = list(map(int,input().split()))
m = [list(map(int,input().split())) for i in range(n)]
return h,n,m
def main(h,n,m):
#DP for minimal mp needed to do h damage
dp = [0]
for i in range(h):
update = 2**60
for j in m:
if j[0]>=(i+1):
... | 27 | 21 | 576 | 555 | from sys import stdin
import numpy as np
from numba import njit
H, N = list(map(int, input().split()))
M = [list(map(int, stdin.readline().split())) for i in [0] * N]
M = np.array(M)
@njit
def main(h, n, m):
dp = [10**8 + 1] * (10**4 + 1)
dp = np.array(dp)
dp[0] = 0
for i in range(1, 10**4 + 1):
... | def getval():
h, n = list(map(int, input().split()))
m = [list(map(int, input().split())) for i in range(n)]
return h, n, m
def main(h, n, m):
# DP for minimal mp needed to do h damage
dp = [0]
for i in range(h):
update = 2**60
for j in m:
if j[0] >= (i + 1):
... | false | 22.222222 | [
"-from sys import stdin",
"-import numpy as np",
"-from numba import njit",
"-",
"-H, N = list(map(int, input().split()))",
"-M = [list(map(int, stdin.readline().split())) for i in [0] * N]",
"-M = np.array(M)",
"+def getval():",
"+ h, n = list(map(int, input().split()))",
"+ m = [list(map(i... | false | 0.233043 | 0.076395 | 3.050489 | [
"s713082872",
"s261718447"
] |
u959519702 | p03030 | python | s116050079 | s304004141 | 56 | 35 | 32,620 | 27,756 | Accepted | Accepted | 37.5 |
def comp_rest(a,b):
if a[0] > b[0]:
return True
elif a[0] < b[0]:
return False
elif a[0] == b[0]:
return a[1] < b[1]
def solve():
N = int(input())
SP = []
for i in range(N):
SiPi = input().split()
Si = SiPi[0]
Pi = int(SiPi[1])
... | def solve():
N = int(input())
SP = []
for i in range(N):
SiPi = input().split()
Si = SiPi[0]
Pi = int(SiPi[1])
SP.append([Si, - Pi, i+1])
SP.sort()
for i in range(N):
print(SP[i][2])
if __name__ == '__main__':
solve()
| 26 | 14 | 593 | 303 | def comp_rest(a, b):
if a[0] > b[0]:
return True
elif a[0] < b[0]:
return False
elif a[0] == b[0]:
return a[1] < b[1]
def solve():
N = int(input())
SP = []
for i in range(N):
SiPi = input().split()
Si = SiPi[0]
Pi = int(SiPi[1])
SP.append... | def solve():
N = int(input())
SP = []
for i in range(N):
SiPi = input().split()
Si = SiPi[0]
Pi = int(SiPi[1])
SP.append([Si, -Pi, i + 1])
SP.sort()
for i in range(N):
print(SP[i][2])
if __name__ == "__main__":
solve()
| false | 46.153846 | [
"-def comp_rest(a, b):",
"- if a[0] > b[0]:",
"- return True",
"- elif a[0] < b[0]:",
"- return False",
"- elif a[0] == b[0]:",
"- return a[1] < b[1]",
"-",
"-",
"- SP.append([Si, Pi, i + 1])",
"- for i in range(N):",
"- for j in range(i + 1, N):"... | false | 0.041105 | 0.03675 | 1.1185 | [
"s116050079",
"s304004141"
] |
u721407235 | p02695 | python | s871603772 | s081651667 | 1,107 | 698 | 39,416 | 9,172 | Accepted | Accepted | 36.95 | import numpy as np
import itertools
N,M,Q=list(map(int,input().split()))
abcd=[]
for q in range(Q):
array=list(map(int,input().split()))
abcd.append(array)
all = list(itertools.combinations_with_replacement(list(range(1,M+1)), N))
MAX=0
for al in all:
sum=0
for a,b,c,d in abcd:
if al[b... | N,M,Q=list(map(int,input().split()))
a=[];b=[];c=[];d=[]
for q in range(Q):
a_,b_,c_,d_ =list(map(int,input().split()))
a.append(a_-1)
b.append(b_-1)
c.append(c_)
d.append(d_)
def score(A):
tmp=0
for q in range(Q):
if A[b[q]]-A[a[q]]==c[q]:
tmp += d[q]
return tmp
def ... | 22 | 39 | 379 | 572 | import numpy as np
import itertools
N, M, Q = list(map(int, input().split()))
abcd = []
for q in range(Q):
array = list(map(int, input().split()))
abcd.append(array)
all = list(itertools.combinations_with_replacement(list(range(1, M + 1)), N))
MAX = 0
for al in all:
sum = 0
for a, b, c, d in abcd:
... | N, M, Q = list(map(int, input().split()))
a = []
b = []
c = []
d = []
for q in range(Q):
a_, b_, c_, d_ = list(map(int, input().split()))
a.append(a_ - 1)
b.append(b_ - 1)
c.append(c_)
d.append(d_)
def score(A):
tmp = 0
for q in range(Q):
if A[b[q]] - A[a[q]] == c[q]:
t... | false | 43.589744 | [
"-import numpy as np",
"-import itertools",
"+N, M, Q = list(map(int, input().split()))",
"+a = []",
"+b = []",
"+c = []",
"+d = []",
"+for q in range(Q):",
"+ a_, b_, c_, d_ = list(map(int, input().split()))",
"+ a.append(a_ - 1)",
"+ b.append(b_ - 1)",
"+ c.append(c_)",
"+ d... | false | 0.048247 | 0.101458 | 0.47554 | [
"s871603772",
"s081651667"
] |
u729133443 | p03305 | python | s676684500 | s609425025 | 1,999 | 1,031 | 109,928 | 131,976 | Accepted | Accepted | 48.42 | from heapq import*
def dijkstra(s,e):
g=10**6
d=[10**18]*n
f=[1]*n
d[s]=f[s]=0
q=[]
for a,b in e[s]:heappush(q,a*g+b)
while q:
m=heappop(q)
if f[m%g]<1:continue
v=m%g
x=d[v]=m//g
f[v]=0
for y,w in e[v]:
if f[w]:heappush(q,(x+y)*g+w)
return d
(n,m,s,t),*z=[l... | from heapq import*
def dijkstra(s,e):
g=10**6;d=[10**18]*n;f=[1]*n;d[s]=f[s]=0;q=[]
for a,b in e[s]:heappush(q,a*g+b)
while q:
m=heappop(q)
if f[m%g]:
v=m%g;x=d[v]=m//g;f[v]=0
for y,w in e[v]:
if f[w]:heappush(q,(x+y)*g+w)
return d
(n,m,s,t),*z=[list(map(int,t.split()))for t in open(0)]
e,... | 32 | 17 | 609 | 538 | from heapq import *
def dijkstra(s, e):
g = 10**6
d = [10**18] * n
f = [1] * n
d[s] = f[s] = 0
q = []
for a, b in e[s]:
heappush(q, a * g + b)
while q:
m = heappop(q)
if f[m % g] < 1:
continue
v = m % g
x = d[v] = m // g
f[v] = 0
... | from heapq import *
def dijkstra(s, e):
g = 10**6
d = [10**18] * n
f = [1] * n
d[s] = f[s] = 0
q = []
for a, b in e[s]:
heappush(q, a * g + b)
while q:
m = heappop(q)
if f[m % g]:
v = m % g
x = d[v] = m // g
f[v] = 0
f... | false | 46.875 | [
"- if f[m % g] < 1:",
"- continue",
"- v = m % g",
"- x = d[v] = m // g",
"- f[v] = 0",
"- for y, w in e[v]:",
"- if f[w]:",
"- heappush(q, (x + y) * g + w)",
"+ if f[m % g]:",
"+ v = m % g",
"+ ... | false | 0.086048 | 0.086045 | 1.00004 | [
"s676684500",
"s609425025"
] |
u714300041 | p03160 | python | s854600815 | s021731197 | 156 | 132 | 13,924 | 13,980 | Accepted | Accepted | 15.38 | N = int(eval(input()))
*T, = list(map(int, input().split()))
INF = float("inf") # pythonでの無限大の作り方
DP = [INF for i in range(N)]
def chmin(a, b):
if a > b:
return b
return a
DP[0] = 0
for i in range(1, N):
DP[i] = chmin(DP[i], DP[i-1] + abs(T[i-1] - T[i]))
DP[i] = chmin(DP[... | """
dp[i] := 足場iまでにかかるコストの最小値
"""
N = int(eval(input()))
*h, = list(map(int, input().split()))
dp = [0 for _ in range(N)]
dp[1] = abs(h[0] - h[1]) # initialize dp
for i in range(2, N):
case1 = dp[i-1] + abs(h[i-1] - h[i])
case2 = dp[i-2] + abs(h[i-2] - h[i])
dp[i] = min(case1, case2)
print((... | 17 | 14 | 363 | 314 | N = int(eval(input()))
(*T,) = list(map(int, input().split()))
INF = float("inf") # pythonでの無限大の作り方
DP = [INF for i in range(N)]
def chmin(a, b):
if a > b:
return b
return a
DP[0] = 0
for i in range(1, N):
DP[i] = chmin(DP[i], DP[i - 1] + abs(T[i - 1] - T[i]))
DP[i] = chmin(DP[i], DP[i - 2]... | """
dp[i] := 足場iまでにかかるコストの最小値
"""
N = int(eval(input()))
(*h,) = list(map(int, input().split()))
dp = [0 for _ in range(N)]
dp[1] = abs(h[0] - h[1]) # initialize dp
for i in range(2, N):
case1 = dp[i - 1] + abs(h[i - 1] - h[i])
case2 = dp[i - 2] + abs(h[i - 2] - h[i])
dp[i] = min(case1, case2)
print((dp[-1... | false | 17.647059 | [
"+\"\"\"",
"+dp[i] := 足場iまでにかかるコストの最小値",
"+\"\"\"",
"-(*T,) = list(map(int, input().split()))",
"-INF = float(\"inf\") # pythonでの無限大の作り方",
"-DP = [INF for i in range(N)]",
"-",
"-",
"-def chmin(a, b):",
"- if a > b:",
"- return b",
"- return a",
"-",
"-",
"-DP[0] = 0",
"-... | false | 0.148218 | 0.115806 | 1.279876 | [
"s854600815",
"s021731197"
] |
u597374218 | p02916 | python | s967578147 | s750960105 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | N=int(eval(input()))
A,B,C=[list(map(int,input().split())) for i in range(3)]
print((sum(B)+sum(C[A[i]-1] for i in range(N-1) if A[i]==(A[i+1]-1)))) | N=int(eval(input()))
A,B,C=[list(map(int,input().split())) for i in range(3)]
satisfaction=0
for i in range(N):
satisfaction+=B[A[i]-1]
if i!=0 and A[i]==A[i-1]+1:
satisfaction+=C[A[i-1]-1]
print(satisfaction) | 3 | 8 | 142 | 226 | N = int(eval(input()))
A, B, C = [list(map(int, input().split())) for i in range(3)]
print((sum(B) + sum(C[A[i] - 1] for i in range(N - 1) if A[i] == (A[i + 1] - 1))))
| N = int(eval(input()))
A, B, C = [list(map(int, input().split())) for i in range(3)]
satisfaction = 0
for i in range(N):
satisfaction += B[A[i] - 1]
if i != 0 and A[i] == A[i - 1] + 1:
satisfaction += C[A[i - 1] - 1]
print(satisfaction)
| false | 62.5 | [
"-print((sum(B) + sum(C[A[i] - 1] for i in range(N - 1) if A[i] == (A[i + 1] - 1))))",
"+satisfaction = 0",
"+for i in range(N):",
"+ satisfaction += B[A[i] - 1]",
"+ if i != 0 and A[i] == A[i - 1] + 1:",
"+ satisfaction += C[A[i - 1] - 1]",
"+print(satisfaction)"
] | false | 0.039832 | 0.039767 | 1.001627 | [
"s967578147",
"s750960105"
] |
u644907318 | p03282 | python | s070403354 | s845134656 | 168 | 63 | 38,384 | 61,752 | Accepted | Accepted | 62.5 | S = input().strip()
K = int(eval(input()))
N = len(S)
ind = N
for i in range(N):
if S[i]!="1":
ind = i
break
if K<=ind:
print((1))
else:
print((S[ind])) | S = input().strip()
K = int(eval(input()))
a = "1"
ind = len(S)
for i in range(len(S)):
if S[i]!="1":
a = S[i]
ind = i
break
if K<=ind:
print((1))
else:
print(a) | 12 | 13 | 181 | 201 | S = input().strip()
K = int(eval(input()))
N = len(S)
ind = N
for i in range(N):
if S[i] != "1":
ind = i
break
if K <= ind:
print((1))
else:
print((S[ind]))
| S = input().strip()
K = int(eval(input()))
a = "1"
ind = len(S)
for i in range(len(S)):
if S[i] != "1":
a = S[i]
ind = i
break
if K <= ind:
print((1))
else:
print(a)
| false | 7.692308 | [
"-N = len(S)",
"-ind = N",
"-for i in range(N):",
"+a = \"1\"",
"+ind = len(S)",
"+for i in range(len(S)):",
"+ a = S[i]",
"- print((S[ind]))",
"+ print(a)"
] | false | 0.038825 | 0.06936 | 0.559764 | [
"s070403354",
"s845134656"
] |
u867824281 | p02411 | python | s410136446 | s457915716 | 30 | 20 | 7,688 | 7,608 | Accepted | Accepted | 33.33 | while True:
try:
m,f,r = list(map(int,input().split(" ")))
if m == -1:
if f == -1:
if r == -1:
break
if m == -1 or f == -1:
print("F")
continue
if m+f >= 80:
print("A")
if m+f >= 6... | while True:
try:
m,f,r = list(map(int,input().split(" ")))
if m == -1 and f == -1 and r == -1:
break
if m == -1 or f == -1:
print("F")
continue
if m+f >= 80:
print("A")
if m+f >= 65 and m+f < 80:
print("B"... | 25 | 23 | 632 | 594 | while True:
try:
m, f, r = list(map(int, input().split(" ")))
if m == -1:
if f == -1:
if r == -1:
break
if m == -1 or f == -1:
print("F")
continue
if m + f >= 80:
print("A")
if m + f >= 65 and... | while True:
try:
m, f, r = list(map(int, input().split(" ")))
if m == -1 and f == -1 and r == -1:
break
if m == -1 or f == -1:
print("F")
continue
if m + f >= 80:
print("A")
if m + f >= 65 and m + f < 80:
print("B")
... | false | 8 | [
"- if m == -1:",
"- if f == -1:",
"- if r == -1:",
"- break",
"+ if m == -1 and f == -1 and r == -1:",
"+ break"
] | false | 0.045152 | 0.043005 | 1.049922 | [
"s410136446",
"s457915716"
] |
u102278909 | p02695 | python | s287786929 | s460821646 | 292 | 227 | 73,816 | 68,836 | Accepted | Accepted | 22.26 | # coding: utf-8
import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return... | # coding: utf-8
import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return... | 49 | 52 | 1,091 | 1,203 | # coding: utf-8
import sys
import math
import collections
import itertools
INF = 10**13
MOD = 10**9 + 7
def input():
return sys.stdin.readline().strip()
def lcm(x, y):
return (x * y) // math.gcd(x, y)
def I():
return int(input())
def LI():
return [int(x) for x in input().split()]
def RI(N):
... | # coding: utf-8
import sys
import math
import collections
import itertools
INF = 10**13
MOD = 10**9 + 7
def input():
return sys.stdin.readline().strip()
def lcm(x, y):
return (x * y) // math.gcd(x, y)
def I():
return int(input())
def LI():
return [int(x) for x in input().split()]
def RI(N):
... | false | 5.769231 | [
"-ans = 0",
"+def dfs(A):",
"+ ans = 0",
"+ stack = A",
"+ while stack:",
"+ s = stack.pop()",
"+ if len(s) < N + 1:",
"+ back = s[-1]",
"+ while back <= M:",
"+ stack.append(s + [back])",
"+ back += 1",
"+ else:... | false | 0.050033 | 0.051372 | 0.973942 | [
"s287786929",
"s460821646"
] |
u263261672 | p02675 | python | s136103527 | s714225129 | 23 | 19 | 9,036 | 9,140 | Accepted | Accepted | 17.39 | import sys
n = int(eval(input()))
num = n % 10
if num == 3:
print('bon')
elif num==0 or num==1 or num==6 or num==8:
print('pon')
else:
print('hon')
| n = int(eval(input()))
num = n % 10
if num == 3:
print('bon')
elif num==0 or num==1 or num==6 or num==8:
print('pon')
else:
print('hon')
| 12 | 10 | 164 | 150 | import sys
n = int(eval(input()))
num = n % 10
if num == 3:
print("bon")
elif num == 0 or num == 1 or num == 6 or num == 8:
print("pon")
else:
print("hon")
| n = int(eval(input()))
num = n % 10
if num == 3:
print("bon")
elif num == 0 or num == 1 or num == 6 or num == 8:
print("pon")
else:
print("hon")
| false | 16.666667 | [
"-import sys",
"-"
] | false | 0.038985 | 0.047086 | 0.827961 | [
"s136103527",
"s714225129"
] |
u526094365 | p02786 | python | s447064644 | s909497942 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | import math
H = int(eval(input()))
i = 1
if H == 1:
print((1))
else:
while H > 1:
i = i + 1
H = math.floor(H / 2)
print((2 ** i - 1))
| H = int(eval(input()))
def f(X):
if X < 2:
return X
return f(int(X / 2)) * 2 + 1
print((f(H)))
| 10 | 10 | 161 | 116 | import math
H = int(eval(input()))
i = 1
if H == 1:
print((1))
else:
while H > 1:
i = i + 1
H = math.floor(H / 2)
print((2**i - 1))
| H = int(eval(input()))
def f(X):
if X < 2:
return X
return f(int(X / 2)) * 2 + 1
print((f(H)))
| false | 0 | [
"-import math",
"+H = int(eval(input()))",
"-H = int(eval(input()))",
"-i = 1",
"-if H == 1:",
"- print((1))",
"-else:",
"- while H > 1:",
"- i = i + 1",
"- H = math.floor(H / 2)",
"- print((2**i - 1))",
"+",
"+def f(X):",
"+ if X < 2:",
"+ return X",
"... | false | 0.042405 | 0.069672 | 0.608648 | [
"s447064644",
"s909497942"
] |
u940139461 | p02888 | python | s179459681 | s886593289 | 915 | 748 | 133,976 | 43,740 | Accepted | Accepted | 18.25 | # https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(eval(input())) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
pairs = []
for i in range(n):
for j in range(i + 1, n):
... | # https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(eval(input())) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
... | 18 | 14 | 450 | 394 | # https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(eval(input())) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
pairs = []
for i in range(n):
for j in range(i + 1, n):
p... | # https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(eval(input())) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
a, b... | false | 22.222222 | [
"-pairs = []",
"+ans = 0",
"- pairs.append((i, j))",
"-ans = 0",
"-for i, j in pairs:",
"- a, b = L[i], L[j]",
"- ans += bisect_left(L, a + b) - 1 - j",
"+ a, b = L[i], L[j]",
"+ ans += bisect_left(L, a + b) - 1 - j"
] | false | 0.037092 | 0.041647 | 0.890625 | [
"s179459681",
"s886593289"
] |
u970197315 | p03673 | python | s372346277 | s362127468 | 291 | 166 | 26,044 | 30,824 | Accepted | Accepted | 42.96 | # ABC069 C - PushPush
from collections import deque
N = int(eval(input()))
A = list(map(int,input().split()))
B1 = deque()
B2 = deque()
for i in range(N):
if i == 0:
B1.appendleft(A[0])
B2.appendleft(A[0])
if i > 0 and i%2 == 1:
B1.append(A[i])
B2.appendleft... | n=int(eval(input()))
a=list(map(int,input().split()))
mode=0
from collections import deque
b=deque([])
for i in range(n):
if i%2==0:
b.append(a[i])
mode+=1
mode%=2
else:
b.appendleft(a[i])
mode+=1
mode%=2
if mode==1:
b=list(b)
b=b[::-1]
print((*b))
| 26 | 18 | 506 | 290 | # ABC069 C - PushPush
from collections import deque
N = int(eval(input()))
A = list(map(int, input().split()))
B1 = deque()
B2 = deque()
for i in range(N):
if i == 0:
B1.appendleft(A[0])
B2.appendleft(A[0])
if i > 0 and i % 2 == 1:
B1.append(A[i])
B2.appendleft(A[i])
elif i ... | n = int(eval(input()))
a = list(map(int, input().split()))
mode = 0
from collections import deque
b = deque([])
for i in range(n):
if i % 2 == 0:
b.append(a[i])
mode += 1
mode %= 2
else:
b.appendleft(a[i])
mode += 1
mode %= 2
if mode == 1:
b = list(b)
b =... | false | 30.769231 | [
"-# ABC069 C - PushPush",
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"+mode = 0",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-B1 = deque()",
"-B2 = deque()",
"-for i in range(N):",
"- if i == 0:",
"- B1.appendleft(A[0])",
"- B2.... | false | 0.039294 | 0.040436 | 0.971755 | [
"s372346277",
"s362127468"
] |
u935984175 | p02990 | python | s331798732 | s390421316 | 880 | 219 | 15,160 | 42,224 | Accepted | Accepted | 75.11 | from scipy.misc import comb
def solve():
N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7
for i in range(1, K+1):
ans = comb(N-K+1, i, exact=True) * comb(K-1, i-1, exact=True)
ans %= MOD
print(ans)
if __name__ == '__main__':
solve()
| import sys
sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline
class Combination:
def __init__(self, n: int, mod: int):
self.mod = mod
self.fact = [0] * (n + 1)
self.factinv = [0] * (n + 1)
self.inv = [0] * (n + 1)
self.fact[0] = self.fact[1] = 1
... | 15 | 50 | 294 | 1,380 | from scipy.misc import comb
def solve():
N, K = list(map(int, input().split()))
MOD = 10**9 + 7
for i in range(1, K + 1):
ans = comb(N - K + 1, i, exact=True) * comb(K - 1, i - 1, exact=True)
ans %= MOD
print(ans)
if __name__ == "__main__":
solve()
| import sys
sys.setrecursionlimit(10**7)
rl = sys.stdin.readline
class Combination:
def __init__(self, n: int, mod: int):
self.mod = mod
self.fact = [0] * (n + 1)
self.factinv = [0] * (n + 1)
self.inv = [0] * (n + 1)
self.fact[0] = self.fact[1] = 1
self.factinv[0] =... | false | 70 | [
"-from scipy.misc import comb",
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"+rl = sys.stdin.readline",
"+",
"+",
"+class Combination:",
"+ def __init__(self, n: int, mod: int):",
"+ self.mod = mod",
"+ self.fact = [0] * (n + 1)",
"+ self.factinv = [0] * (n + 1... | false | 0.279409 | 0.07767 | 3.597373 | [
"s331798732",
"s390421316"
] |
u270681687 | p03328 | python | s372588809 | s036612440 | 104 | 18 | 2,940 | 2,940 | Accepted | Accepted | 82.69 | a, b = list(map(int, input().split()))
c = b - a
count = 0
for i in range(c+1):
count += i
count -= b
print(count) | a, b = list(map(int, input().split()))
n = b - a
print((((n+1)*n)//2 - b))
| 10 | 4 | 124 | 71 | a, b = list(map(int, input().split()))
c = b - a
count = 0
for i in range(c + 1):
count += i
count -= b
print(count)
| a, b = list(map(int, input().split()))
n = b - a
print((((n + 1) * n) // 2 - b))
| false | 60 | [
"-c = b - a",
"-count = 0",
"-for i in range(c + 1):",
"- count += i",
"-count -= b",
"-print(count)",
"+n = b - a",
"+print((((n + 1) * n) // 2 - b))"
] | false | 0.040007 | 0.039705 | 1.007601 | [
"s372588809",
"s036612440"
] |
u983918956 | p03660 | python | s543668745 | s544867674 | 1,202 | 449 | 180,368 | 29,336 | Accepted | Accepted | 62.65 | import sys,copy
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
inf = float('inf')
N = int(eval(input()))
ad = [{} for _ in range(N)]
dis = [inf]*N
near = [-1]*N
player = ["Fennec","Snuke"]
for i in range(N-1):
a,b = list(map(int,input().split()))
a -= 1; b -= 1
ad[a][i] = b
ad[... | import sys
input = sys.stdin.readline
from collections import deque
N = int(eval(input()))
ad = [[] for _ in range(N)]
dis = [[-1]*N,[-1]*N]
for _ in range(N-1):
a,b = list(map(int,input().split()))
a -= 1; b -= 1
ad[a].append(b); ad[b].append(a)
def bfs(s):
index = 0 if s == 0 else 1
... | 37 | 31 | 733 | 680 | import sys, copy
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
inf = float("inf")
N = int(eval(input()))
ad = [{} for _ in range(N)]
dis = [inf] * N
near = [-1] * N
player = ["Fennec", "Snuke"]
for i in range(N - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ad[a][i] = b
ad[b][... | import sys
input = sys.stdin.readline
from collections import deque
N = int(eval(input()))
ad = [[] for _ in range(N)]
dis = [[-1] * N, [-1] * N]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
ad[a].append(b)
ad[b].append(a)
def bfs(s):
index = 0 if s == 0 else 1... | false | 16.216216 | [
"-import sys, copy",
"+import sys",
"-sys.setrecursionlimit(10**6)",
"-inf = float(\"inf\")",
"+from collections import deque",
"+",
"-ad = [{} for _ in range(N)]",
"-dis = [inf] * N",
"-near = [-1] * N",
"-player = [\"Fennec\", \"Snuke\"]",
"-for i in range(N - 1):",
"+ad = [[] for _ in range... | false | 0.042402 | 0.060628 | 0.699383 | [
"s543668745",
"s544867674"
] |
u998771223 | p03831 | python | s156898836 | s779658396 | 150 | 112 | 11,100 | 11,100 | Accepted | Accepted | 25.33 | S1=eval(input())
S1=S1.split()
S2=eval(input())
S2=S2.split()
move=0
N=int(S1[0])
A=int(S1[1])
B=int(S1[2])
for i in range(N-1):
if (int(S2[i+1])-int(S2[i]))*A>=B:
move+=B
else:
move+=A*(int(S2[i+1])-int(S2[i]))
print(move) | S1=eval(input())
S1=S1.split()
S2=eval(input())
S2=S2.split()
move=0
N=int(S1[0])
A=int(S1[1])
B=int(S1[2])
for i in range(N-1):
div=int(S2[i+1])-int(S2[i])
if (div)*A>=B:
move+=B
else:
move+=A*(div)
print(move) | 14 | 15 | 248 | 241 | S1 = eval(input())
S1 = S1.split()
S2 = eval(input())
S2 = S2.split()
move = 0
N = int(S1[0])
A = int(S1[1])
B = int(S1[2])
for i in range(N - 1):
if (int(S2[i + 1]) - int(S2[i])) * A >= B:
move += B
else:
move += A * (int(S2[i + 1]) - int(S2[i]))
print(move)
| S1 = eval(input())
S1 = S1.split()
S2 = eval(input())
S2 = S2.split()
move = 0
N = int(S1[0])
A = int(S1[1])
B = int(S1[2])
for i in range(N - 1):
div = int(S2[i + 1]) - int(S2[i])
if (div) * A >= B:
move += B
else:
move += A * (div)
print(move)
| false | 6.666667 | [
"- if (int(S2[i + 1]) - int(S2[i])) * A >= B:",
"+ div = int(S2[i + 1]) - int(S2[i])",
"+ if (div) * A >= B:",
"- move += A * (int(S2[i + 1]) - int(S2[i]))",
"+ move += A * (div)"
] | false | 0.043739 | 0.118138 | 0.370231 | [
"s156898836",
"s779658396"
] |
u297574184 | p03168 | python | s284454439 | s187060807 | 1,818 | 1,355 | 3,316 | 3,316 | Accepted | Accepted | 25.47 | def solve():
N = int(eval(input()))
Ps = list(map(float, input().split()))
Qs = [1-P for P in Ps]
dp = [0.0] * (N+2)
dp[0] = 1.0
for P, Q in zip(Ps, Qs):
dp2 = [0.0] * (N+2)
for j in range(N+1):
if dp[j] == 0.0: continue
dp2[j] += dp[j] * Q
... | def solve():
N = int(eval(input()))
Ps = list(map(float, input().split()))
Qs = [1-P for P in Ps]
dp = [0.0] * (N+2)
dp[0] = 1.0
for i, (P, Q) in enumerate(zip(Ps, Qs)):
dp2 = [0.0] * (N+2)
for j in range(i+1):
dp2[j] += dp[j] * Q
dp2[j+1] +=... | 20 | 19 | 412 | 389 | def solve():
N = int(eval(input()))
Ps = list(map(float, input().split()))
Qs = [1 - P for P in Ps]
dp = [0.0] * (N + 2)
dp[0] = 1.0
for P, Q in zip(Ps, Qs):
dp2 = [0.0] * (N + 2)
for j in range(N + 1):
if dp[j] == 0.0:
continue
dp2[j] += d... | def solve():
N = int(eval(input()))
Ps = list(map(float, input().split()))
Qs = [1 - P for P in Ps]
dp = [0.0] * (N + 2)
dp[0] = 1.0
for i, (P, Q) in enumerate(zip(Ps, Qs)):
dp2 = [0.0] * (N + 2)
for j in range(i + 1):
dp2[j] += dp[j] * Q
dp2[j + 1] += dp[... | false | 5 | [
"- for P, Q in zip(Ps, Qs):",
"+ for i, (P, Q) in enumerate(zip(Ps, Qs)):",
"- for j in range(N + 1):",
"- if dp[j] == 0.0:",
"- continue",
"+ for j in range(i + 1):"
] | false | 0.034051 | 0.039475 | 0.862598 | [
"s284454439",
"s187060807"
] |
u117348081 | p03252 | python | s761646643 | s514594133 | 89 | 82 | 3,632 | 3,632 | Accepted | Accepted | 7.87 | s = eval(input())
t = eval(input())
dict_st = {}
dict_ts = {}
for x, y in zip(s, t):
if x not in dict_st:
dict_st[x] = y
else:
if dict_st[x] != y:
print("No")
break
if y not in dict_ts:
dict_ts[y]=x
else:
if dict_ts[y]!=x:
... | s = eval(input())
t = eval(input())
dict_st = {}
dict_ts = {}
for x, y in zip(s, t):
if x not in dict_st:
dict_st[x] = y
else:
if dict_st[x] != y:
print("No")
exit()
if y not in dict_ts:
dict_ts[y]=x
else:
if dict_ts[y]!=x:
... | 22 | 22 | 372 | 365 | s = eval(input())
t = eval(input())
dict_st = {}
dict_ts = {}
for x, y in zip(s, t):
if x not in dict_st:
dict_st[x] = y
else:
if dict_st[x] != y:
print("No")
break
if y not in dict_ts:
dict_ts[y] = x
else:
if dict_ts[y] != x:
print("No... | s = eval(input())
t = eval(input())
dict_st = {}
dict_ts = {}
for x, y in zip(s, t):
if x not in dict_st:
dict_st[x] = y
else:
if dict_st[x] != y:
print("No")
exit()
if y not in dict_ts:
dict_ts[y] = x
else:
if dict_ts[y] != x:
print("N... | false | 0 | [
"- break",
"+ exit()",
"- break",
"-else:",
"- print(\"Yes\")",
"+ exit()",
"+print(\"Yes\")"
] | false | 0.042295 | 0.085263 | 0.496055 | [
"s761646643",
"s514594133"
] |
u896741788 | p03298 | python | s830654882 | s835319875 | 1,409 | 1,254 | 150,056 | 129,300 | Accepted | Accepted | 11 | def f():
n,s=int(eval(input())),eval(input())
a,b=s[n-1::-1],s[n:]
from collections import defaultdict
ad=defaultdict(int)
bd=defaultdict(int)
for i in range(2**n):
sa,ta,sb,tb="","","",""
for j in range(n):
if i%2:
sa+=a[j]
... | def f():
n,s=int(eval(input())),eval(input())
a,b=s[n-1::-1],s[n:]
ad={}
bd={}
for i in range(2**n):
sa,ta,sb,tb="","","",""
for j in range(n):
if i%2:
sa+=a[j]
sb+=b[j]
else:
ta+=a[j]
... | 24 | 23 | 563 | 586 | def f():
n, s = int(eval(input())), eval(input())
a, b = s[n - 1 :: -1], s[n:]
from collections import defaultdict
ad = defaultdict(int)
bd = defaultdict(int)
for i in range(2**n):
sa, ta, sb, tb = "", "", "", ""
for j in range(n):
if i % 2:
sa += a[j... | def f():
n, s = int(eval(input())), eval(input())
a, b = s[n - 1 :: -1], s[n:]
ad = {}
bd = {}
for i in range(2**n):
sa, ta, sb, tb = "", "", "", ""
for j in range(n):
if i % 2:
sa += a[j]
sb += b[j]
else:
ta += ... | false | 4.166667 | [
"- from collections import defaultdict",
"-",
"- ad = defaultdict(int)",
"- bd = defaultdict(int)",
"+ ad = {}",
"+ bd = {}",
"- ad[(sa, ta)] += 1",
"- bd[(sb, tb)] += 1",
"+ ad[(sa, ta)] = 1 if (sa, ta) not in ad else ad[(sa, ta)] + 1",
"+ bd[(sb, tb)] =... | false | 0.06346 | 0.043583 | 1.45606 | [
"s830654882",
"s835319875"
] |
u384124931 | p02630 | python | s043274332 | s746005760 | 193 | 163 | 20,832 | 20,280 | Accepted | Accepted | 15.54 | import sys
N = int(eval(input()))
A = list(map(int, input().split()))
total = sum(A)
num = [0] * (10 ** 5 + 1)
for a in A:
num[a] += 1
Q = int(eval(input()))
for _ in range(Q):
b, c = list(map(int, sys.stdin.readline().split()))
total -= b * num[b]
total += c * num[b]
num[c] += num[b]
... | def Replacing():
import sys
input = sys.stdin.readline
n = int(eval(input()))
A = list(map(int,input().split()))
q = int(eval(input()))
total = sum(A) # これを基に各queryに対応(加算、減算)する
l = [0 for i in range(10**5+1)] # 配列のインデックスを各valueとみなす
for _ in A: # 各インデックスに各keyを加算
... | 16 | 23 | 336 | 560 | import sys
N = int(eval(input()))
A = list(map(int, input().split()))
total = sum(A)
num = [0] * (10**5 + 1)
for a in A:
num[a] += 1
Q = int(eval(input()))
for _ in range(Q):
b, c = list(map(int, sys.stdin.readline().split()))
total -= b * num[b]
total += c * num[b]
num[c] += num[b]
num[b] = 0
... | def Replacing():
import sys
input = sys.stdin.readline
n = int(eval(input()))
A = list(map(int, input().split()))
q = int(eval(input()))
total = sum(A) # これを基に各queryに対応(加算、減算)する
l = [0 for i in range(10**5 + 1)] # 配列のインデックスを各valueとみなす
for _ in A: # 各インデックスに各keyを加算
l[_] += 1
... | false | 30.434783 | [
"-import sys",
"+def Replacing():",
"+ import sys",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-total = sum(A)",
"-num = [0] * (10**5 + 1)",
"-for a in A:",
"- num[a] += 1",
"-Q = int(eval(input()))",
"-for _ in range(Q):",
"- b, c = list(map(int, sys.stdin.re... | false | 0.0909 | 0.086676 | 1.048734 | [
"s043274332",
"s746005760"
] |
u089032001 | p03031 | python | s873213398 | s236455616 | 27 | 23 | 3,064 | 3,064 | Accepted | Accepted | 14.81 | def inpl():
return list(map(int, input().split()))
def isAllOn(pattern):
for i, s in enumerate(S):
on = 0
for k in s[1:]:
if (pattern >> (k - 1)) % 2 == 1:
on += 1
# print(pattern, i, on)
if on % 2 != P[i]:
return False
r... | def inpl():
return tuple(map(int, input().split()))
def getPattern(i):
return {j for j in range(N) if (i >> j) % 2}
def isOn(pattern):
return all(P[i] == len(pattern & S[i]) % 2 for i in range(M))
N, M = inpl()
S = []
for _ in range(M):
tmp = inpl()
tmp = [t - 1 for t in tmp[1:... | 27 | 25 | 502 | 465 | def inpl():
return list(map(int, input().split()))
def isAllOn(pattern):
for i, s in enumerate(S):
on = 0
for k in s[1:]:
if (pattern >> (k - 1)) % 2 == 1:
on += 1
# print(pattern, i, on)
if on % 2 != P[i]:
return False
return True
... | def inpl():
return tuple(map(int, input().split()))
def getPattern(i):
return {j for j in range(N) if (i >> j) % 2}
def isOn(pattern):
return all(P[i] == len(pattern & S[i]) % 2 for i in range(M))
N, M = inpl()
S = []
for _ in range(M):
tmp = inpl()
tmp = [t - 1 for t in tmp[1:]]
S.append(... | false | 7.407407 | [
"- return list(map(int, input().split()))",
"+ return tuple(map(int, input().split()))",
"-def isAllOn(pattern):",
"- for i, s in enumerate(S):",
"- on = 0",
"- for k in s[1:]:",
"- if (pattern >> (k - 1)) % 2 == 1:",
"- on += 1",
"- # print(pa... | false | 0.069904 | 0.071531 | 0.977247 | [
"s873213398",
"s236455616"
] |
u089376182 | p02887 | python | s105437996 | s953092832 | 1,522 | 61 | 4,264 | 15,860 | Accepted | Accepted | 95.99 | n = int(eval(input()))
d = list(eval(input()))
ans = list(d.pop(0))
while d:
target = d.pop(0)
if ans[-1] != target:
ans.append(target)
print((len(ans))) | from itertools import groupby
_ = eval(input())
s = list(groupby(eval(input())))
print((len(s))) | 11 | 5 | 160 | 88 | n = int(eval(input()))
d = list(eval(input()))
ans = list(d.pop(0))
while d:
target = d.pop(0)
if ans[-1] != target:
ans.append(target)
print((len(ans)))
| from itertools import groupby
_ = eval(input())
s = list(groupby(eval(input())))
print((len(s)))
| false | 54.545455 | [
"-n = int(eval(input()))",
"-d = list(eval(input()))",
"-ans = list(d.pop(0))",
"-while d:",
"- target = d.pop(0)",
"- if ans[-1] != target:",
"- ans.append(target)",
"-print((len(ans)))",
"+from itertools import groupby",
"+",
"+_ = eval(input())",
"+s = list(groupby(eval(input()... | false | 0.045564 | 0.038918 | 1.170775 | [
"s105437996",
"s953092832"
] |
u150984829 | p00479 | python | s000034325 | s443604400 | 30 | 20 | 5,612 | 5,724 | Accepted | Accepted | 33.33 | N=int(eval(input()))
for _ in[0]*int(eval(input())):
a,b=list(map(int,input().split()))
print((min(a-1,N-a,b-1,N-b)%3+1))
| import sys
N=int(eval(input()))
eval(input())
for e in sys.stdin:
a,b=list(map(int,e.split()))
print((min(a-1,N-a,b-1,N-b)%3+1))
| 4 | 6 | 107 | 116 | N = int(eval(input()))
for _ in [0] * int(eval(input())):
a, b = list(map(int, input().split()))
print((min(a - 1, N - a, b - 1, N - b) % 3 + 1))
| import sys
N = int(eval(input()))
eval(input())
for e in sys.stdin:
a, b = list(map(int, e.split()))
print((min(a - 1, N - a, b - 1, N - b) % 3 + 1))
| false | 33.333333 | [
"+import sys",
"+",
"-for _ in [0] * int(eval(input())):",
"- a, b = list(map(int, input().split()))",
"+eval(input())",
"+for e in sys.stdin:",
"+ a, b = list(map(int, e.split()))"
] | false | 0.043389 | 0.038975 | 1.11325 | [
"s000034325",
"s443604400"
] |
u439396449 | p03291 | python | s423253369 | s667321213 | 747 | 484 | 27,628 | 27,580 | Accepted | Accepted | 35.21 | S = eval(input())
N = len(S)
mod = 10 ** 9 + 7
# dp[i][j]: i番目までの文字までで、状態jになる組み合わせ数
dp = [[0 for _ in range(4)] for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
if S[i] in ['A', '?']:
for j in range(4):
dp[i + 1][j] += dp[i][j]
dp[i + 1][1] += dp[i][0]
if S[i] in... | S = eval(input())
N = len(S)
mod = 10 ** 9 + 7
dp = [[0 for _ in range(4)] for _ in range(N + 1)]
dp [0][0] = 1
for i in range(N):
if S[i] == 'A':
for j in range(4):
dp[i + 1][j] += dp[i][j]
dp[i + 1][1] += dp[i][0]
elif S[i] == 'B':
for j in range(4):
... | 26 | 31 | 628 | 757 | S = eval(input())
N = len(S)
mod = 10**9 + 7
# dp[i][j]: i番目までの文字までで、状態jになる組み合わせ数
dp = [[0 for _ in range(4)] for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
if S[i] in ["A", "?"]:
for j in range(4):
dp[i + 1][j] += dp[i][j]
dp[i + 1][1] += dp[i][0]
if S[i] in ["B", "?"]:
... | S = eval(input())
N = len(S)
mod = 10**9 + 7
dp = [[0 for _ in range(4)] for _ in range(N + 1)]
dp[0][0] = 1
for i in range(N):
if S[i] == "A":
for j in range(4):
dp[i + 1][j] += dp[i][j]
dp[i + 1][1] += dp[i][0]
elif S[i] == "B":
for j in range(4):
dp[i + 1][j] +... | false | 16.129032 | [
"-# dp[i][j]: i番目までの文字までで、状態jになる組み合わせ数",
"- if S[i] in [\"A\", \"?\"]:",
"+ if S[i] == \"A\":",
"- if S[i] in [\"B\", \"?\"]:",
"+ elif S[i] == \"B\":",
"- if S[i] in [\"C\", \"?\"]:",
"+ elif S[i] == \"C\":",
"+ dp[i + 1][3] += dp[i][2]",
"+ else:",
"+ for j in ... | false | 0.144173 | 0.116698 | 1.235435 | [
"s423253369",
"s667321213"
] |
u150984829 | p02269 | python | s238296140 | s951001410 | 1,110 | 980 | 118,108 | 117,988 | Accepted | Accepted | 11.71 | import sys
d={}
for e in sys.stdin.readlines()[1:]:
c,g=e.split()
if'i'==c[0]:d[g]=0
else:print((['no','yes'][g in d]))
| import sys
d={}
for e in sys.stdin.readlines()[1:]:
if'i'==e[0]:d[e[7:]]=0
else:print((['no','yes'][e[5:]in d]))
| 6 | 5 | 126 | 117 | import sys
d = {}
for e in sys.stdin.readlines()[1:]:
c, g = e.split()
if "i" == c[0]:
d[g] = 0
else:
print((["no", "yes"][g in d]))
| import sys
d = {}
for e in sys.stdin.readlines()[1:]:
if "i" == e[0]:
d[e[7:]] = 0
else:
print((["no", "yes"][e[5:] in d]))
| false | 16.666667 | [
"- c, g = e.split()",
"- if \"i\" == c[0]:",
"- d[g] = 0",
"+ if \"i\" == e[0]:",
"+ d[e[7:]] = 0",
"- print(([\"no\", \"yes\"][g in d]))",
"+ print(([\"no\", \"yes\"][e[5:] in d]))"
] | false | 0.034773 | 0.053683 | 0.647736 | [
"s238296140",
"s951001410"
] |
u476604182 | p03142 | python | s429550680 | s528265438 | 281 | 252 | 37,220 | 37,228 | Accepted | Accepted | 10.32 | from collections import defaultdict
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [None]*N
cnt = [0]*(N+1)
for a,b in zip(*[iter(L)]*2):
dic[a] += [b]
cnt[b] += 1
for i in range(1,N+1):
if cnt[i]==0:
q = [i]
par[i-1] = '0'
... | from collections import defaultdict, deque
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [None]*N
cnt = [0]*(N+1)
for a,b in zip(*[iter(L)]*2):
dic[a] += [b]
cnt[b] += 1
for i in range(1,N+1):
if cnt[i]==0:
q = deque([i])
p... | 29 | 29 | 548 | 569 | from collections import defaultdict
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [None] * N
cnt = [0] * (N + 1)
for a, b in zip(*[iter(L)] * 2):
dic[a] += [b]
cnt[b] += 1
for i in range(1, N + 1):
if cnt[i] == 0:
... | from collections import defaultdict, deque
def main():
N, M, *L = list(map(int, open(0).read().split()))
dic = defaultdict(list)
par = [None] * N
cnt = [0] * (N + 1)
for a, b in zip(*[iter(L)] * 2):
dic[a] += [b]
cnt[b] += 1
for i in range(1, N + 1):
if cnt[i] == 0:
... | false | 0 | [
"-from collections import defaultdict",
"+from collections import defaultdict, deque",
"- q = [i]",
"+ q = deque([i])",
"- m = q.pop()",
"+ m = q.popleft()",
"- q += [c]",
"+ q.append(c)"
] | false | 0.041166 | 0.048356 | 0.851313 | [
"s429550680",
"s528265438"
] |
u972591645 | p02838 | python | s962152991 | s579799251 | 301 | 261 | 124,320 | 68,892 | Accepted | Accepted | 13.29 | n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
one = 0
for j in range(n):
if (a[j] >> i) & 1:
one += 1
ans = (ans + (one*(n-one))*two) % mod
two = (two * 2) % mod
print(ans) | import numpy as np
n = int(eval(input()))
a = np.array(list((list(map(int, input().split())))))
mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
one = np.count_nonzero(a & 1)
a = a >> 1
ans = (ans + (one*(n-one))*two) % mod
two = (two * 2) % mod
print(ans) | 14 | 14 | 281 | 278 | n = int(eval(input()))
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
one = 0
for j in range(n):
if (a[j] >> i) & 1:
one += 1
ans = (ans + (one * (n - one)) * two) % mod
two = (two * 2) % mod
print(ans)
| import numpy as np
n = int(eval(input()))
a = np.array(list((list(map(int, input().split())))))
mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
one = np.count_nonzero(a & 1)
a = a >> 1
ans = (ans + (one * (n - one)) * two) % mod
two = (two * 2) % mod
print(ans)
| false | 0 | [
"+import numpy as np",
"+",
"-a = list(map(int, input().split()))",
"+a = np.array(list((list(map(int, input().split())))))",
"- one = 0",
"- for j in range(n):",
"- if (a[j] >> i) & 1:",
"- one += 1",
"+ one = np.count_nonzero(a & 1)",
"+ a = a >> 1"
] | false | 0.043264 | 0.236406 | 0.18301 | [
"s962152991",
"s579799251"
] |
u548464743 | p03775 | python | s239715222 | s371023344 | 145 | 40 | 9,188 | 9,356 | Accepted | Accepted | 72.41 | num = int(eval(input()))
digits = len(str(num))
ans = digits
for i in range(1,10 ** (digits // 2 + 1)):
if num % i == 0:
target = max(len(str(i)), len(str(num//i)))
if ans >= target:
ans = target
else:
print(ans)
exit()
print(ans) | n=int(eval(input()))
x=int(n**0.5)
for i in range(x):
if n%(x-i)==0:
print((len(str(n//(x-i)))))
break | 15 | 6 | 305 | 119 | num = int(eval(input()))
digits = len(str(num))
ans = digits
for i in range(1, 10 ** (digits // 2 + 1)):
if num % i == 0:
target = max(len(str(i)), len(str(num // i)))
if ans >= target:
ans = target
else:
print(ans)
exit()
print(ans)
| n = int(eval(input()))
x = int(n**0.5)
for i in range(x):
if n % (x - i) == 0:
print((len(str(n // (x - i)))))
break
| false | 60 | [
"-num = int(eval(input()))",
"-digits = len(str(num))",
"-ans = digits",
"-for i in range(1, 10 ** (digits // 2 + 1)):",
"- if num % i == 0:",
"- target = max(len(str(i)), len(str(num // i)))",
"- if ans >= target:",
"- ans = target",
"- else:",
"- pri... | false | 0.108043 | 0.039415 | 2.741162 | [
"s239715222",
"s371023344"
] |
u761320129 | p02862 | python | s322314792 | s665996067 | 928 | 304 | 87,324 | 16,200 | Accepted | Accepted | 67.24 | X,Y = list(map(int,input().split()))
if X>Y:
X,Y = Y,X
if(X+Y)%3:
print((0))
exit()
n = (X+Y)//3
if X < n:
print((0))
exit()
MOD = 10**9+7
r = X-n
maxn = n+5
fac = [1,1] + [0]*maxn
finv = [1,1] + [0]*maxn
inv = [0,1] + [0]*maxn
for i in range(2,maxn+2):
fac[i] = fac[i-1] * i... | X,Y = list(map(int,input().split()))
MOD = 10**9+7
if (X+Y)%3:
print((0))
exit()
n = (X+Y)//3
r = X-n
if not 0 <= r <= n:
print((0))
exit()
MAXN = r
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
inv[i] = -inv[MOD%i] * (MOD // i) % MOD
def comb(n,r):
ret = 1
for i in ra... | 29 | 25 | 549 | 418 | X, Y = list(map(int, input().split()))
if X > Y:
X, Y = Y, X
if (X + Y) % 3:
print((0))
exit()
n = (X + Y) // 3
if X < n:
print((0))
exit()
MOD = 10**9 + 7
r = X - n
maxn = n + 5
fac = [1, 1] + [0] * maxn
finv = [1, 1] + [0] * maxn
inv = [0, 1] + [0] * maxn
for i in range(2, maxn + 2):
fac[i] = ... | X, Y = list(map(int, input().split()))
MOD = 10**9 + 7
if (X + Y) % 3:
print((0))
exit()
n = (X + Y) // 3
r = X - n
if not 0 <= r <= n:
print((0))
exit()
MAXN = r
inv = [0, 1] + [0] * MAXN
for i in range(2, MAXN + 2):
inv[i] = -inv[MOD % i] * (MOD // i) % MOD
def comb(n, r):
ret = 1
for i ... | false | 13.793103 | [
"-if X > Y:",
"- X, Y = Y, X",
"+MOD = 10**9 + 7",
"-if X < n:",
"+r = X - n",
"+if not 0 <= r <= n:",
"-MOD = 10**9 + 7",
"-r = X - n",
"-maxn = n + 5",
"-fac = [1, 1] + [0] * maxn",
"-finv = [1, 1] + [0] * maxn",
"-inv = [0, 1] + [0] * maxn",
"-for i in range(2, maxn + 2):",
"- fac... | false | 0.212165 | 0.152036 | 1.395495 | [
"s322314792",
"s665996067"
] |
u191874006 | p03062 | python | s523288263 | s089783000 | 1,165 | 86 | 23,264 | 14,412 | Accepted | Accepted | 92.62 | #!/usr/bin/env python3
#D
import numpy as np
import math
import re
n = int(eval(input()))
a = eval(input())
a = re.split(" ",a)
a = list(map(int,a))
count = 0
sum = 0
for i in range(n):
if(a[i] < 0):
count += 1
if(count %2 == 0):
for j in a:
sum += abs(j)
print(sum)
else:... | #!/usr/bin/env python3
#ABC125 D
n = int(eval(input()))
a = list(map(int,input().split()))
cnt = 0
mi = float('inf')
tmp = 0
for i in range(n):
if a[i] < 0:
cnt += 1
if mi > abs(a[i]):
mi = abs(a[i])
tmp = i
s = list([abs(x) for x in a])
if cnt % 2:
print((sum(s)-2*s... | 33 | 19 | 579 | 349 | #!/usr/bin/env python3
# D
import numpy as np
import math
import re
n = int(eval(input()))
a = eval(input())
a = re.split(" ", a)
a = list(map(int, a))
count = 0
sum = 0
for i in range(n):
if a[i] < 0:
count += 1
if count % 2 == 0:
for j in a:
sum += abs(j)
print(sum)
else:
min = 10**9
... | #!/usr/bin/env python3
# ABC125 D
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
mi = float("inf")
tmp = 0
for i in range(n):
if a[i] < 0:
cnt += 1
if mi > abs(a[i]):
mi = abs(a[i])
tmp = i
s = list([abs(x) for x in a])
if cnt % 2:
print((sum(s) - 2 * s[tmp]))
els... | false | 42.424242 | [
"-# D",
"-import numpy as np",
"-import math",
"-import re",
"-",
"+# ABC125 D",
"-a = eval(input())",
"-a = re.split(\" \", a)",
"-a = list(map(int, a))",
"-count = 0",
"-sum = 0",
"+a = list(map(int, input().split()))",
"+cnt = 0",
"+mi = float(\"inf\")",
"+tmp = 0",
"- count ... | false | 0.108283 | 0.035346 | 3.063521 | [
"s523288263",
"s089783000"
] |
u543954314 | p03033 | python | s471665869 | s738302151 | 1,584 | 1,210 | 80,580 | 88,904 | Accepted | Accepted | 23.61 | import sys, heapq
input = sys.stdin.buffer.readline # 入出力高速化
def main():
N, Q = list(map(int, input().split()))
tl = [] # イベントタイムライン
for _ in range(N):
S, T, X = list(map(int, input().split()))
tl.append((S-X, 1, X)) # insert
tl.append((T-X, 0, X)) # erase
for _ in ran... | import sys
input = sys.stdin.buffer.readline # 入出力高速化
def main():
N, Q = list(map(int, input().split()))
tl = [] # イベントタイムライン
for _ in range(N):
S, T, X = list(map(int, input().split()))
tl.append((S-X, 1, X)) # insert
tl.append((T-X, 0, X)) # erase
for _ in range(Q):
... | 30 | 43 | 886 | 1,131 | import sys, heapq
input = sys.stdin.buffer.readline # 入出力高速化
def main():
N, Q = list(map(int, input().split()))
tl = [] # イベントタイムライン
for _ in range(N):
S, T, X = list(map(int, input().split()))
tl.append((S - X, 1, X)) # insert
tl.append((T - X, 0, X)) # erase
for _ in ran... | import sys
input = sys.stdin.buffer.readline # 入出力高速化
def main():
N, Q = list(map(int, input().split()))
tl = [] # イベントタイムライン
for _ in range(N):
S, T, X = list(map(int, input().split()))
tl.append((S - X, 1, X)) # insert
tl.append((T - X, 0, X)) # erase
for _ in range(Q):
... | false | 30.232558 | [
"-import sys, heapq",
"+import sys",
"- working = list() # 工事中",
"- todelete = list() # 削除用",
"+ working = set() # 工事中",
"+ wcur = 0 # 工事中の区域の数",
"+ curmin = -1",
"+ flag = False",
"- heapq.heappush(todelete, x)",
"+ wcur -= 1",
"+ working.r... | false | 0.035688 | 0.143524 | 0.248656 | [
"s471665869",
"s738302151"
] |
u314050667 | p03308 | python | s203690417 | s385598523 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
for j in range(i+1,len(a)):
ans = max(ans,abs(a[i]-a[j]))
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
ans = max(a)-min(a)
print(ans) | 7 | 4 | 171 | 86 | n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
for j in range(i + 1, len(a)):
ans = max(ans, abs(a[i] - a[j]))
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
ans = max(a) - min(a)
print(ans)
| false | 42.857143 | [
"-ans = 0",
"-for i in range(len(a)):",
"- for j in range(i + 1, len(a)):",
"- ans = max(ans, abs(a[i] - a[j]))",
"+ans = max(a) - min(a)"
] | false | 0.079764 | 0.081536 | 0.978257 | [
"s203690417",
"s385598523"
] |
u210718367 | p03607 | python | s998778586 | s646596544 | 871 | 713 | 17,084 | 17,084 | Accepted | Accepted | 18.14 | d = {}
for i in range(eval(input())):
a = eval(input())
try:
d[a] += 1
except KeyError:
d[a] = 1
print(len([x for x in [d[x] for x in d] if x % 2]))
| d = {}
for i in range(eval(input())):
a = eval(input())
d[a] = d.get(a, 0) + 1
print(len([x for x in [d[x] for x in d] if x % 2]))
| 9 | 6 | 167 | 136 | d = {}
for i in range(eval(input())):
a = eval(input())
try:
d[a] += 1
except KeyError:
d[a] = 1
print(len([x for x in [d[x] for x in d] if x % 2]))
| d = {}
for i in range(eval(input())):
a = eval(input())
d[a] = d.get(a, 0) + 1
print(len([x for x in [d[x] for x in d] if x % 2]))
| false | 33.333333 | [
"- try:",
"- d[a] += 1",
"- except KeyError:",
"- d[a] = 1",
"+ d[a] = d.get(a, 0) + 1"
] | false | 0.034921 | 0.032505 | 1.074321 | [
"s998778586",
"s646596544"
] |
u608088992 | p02722 | python | s415997245 | s572238326 | 522 | 402 | 3,064 | 9,236 | Accepted | Accepted | 22.99 | import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
if N == 2: print((1))
else:
K = {N, N-1}
for i in range(2, N + 1):
if i ** 2 > N: break
if N % i == 0:
k = N
while k % i == 0:
... | import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
ans = {N}
if N > 2: ans |= {N-1}
for i in range(2, N): #N-1の約数ならばsubtractした後1になる。もしくはpow(k, x) == Nの場合
if i ** 2 > N: break
if (N - 1) % i == 0:
ans |= {i}
if i ** 2 < N - 1:... | 24 | 31 | 591 | 748 | import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
if N == 2:
print((1))
else:
K = {N, N - 1}
for i in range(2, N + 1):
if i**2 > N:
break
if N % i == 0:
k = N
while k % i == 0:
... | import sys
def solve():
input = sys.stdin.readline
N = int(eval(input()))
ans = {N}
if N > 2:
ans |= {N - 1}
for i in range(2, N): # N-1の約数ならばsubtractした後1になる。もしくはpow(k, x) == Nの場合
if i**2 > N:
break
if (N - 1) % i == 0:
ans |= {i}
if i**... | false | 22.580645 | [
"- if N == 2:",
"- print((1))",
"- else:",
"- K = {N, N - 1}",
"- for i in range(2, N + 1):",
"- if i**2 > N:",
"- break",
"- if N % i == 0:",
"+ ans = {N}",
"+ if N > 2:",
"+ ans |= {N - 1}",
"+ for i in range(2, ... | false | 0.094837 | 0.118974 | 0.797125 | [
"s415997245",
"s572238326"
] |
u156037302 | p02258 | python | s003115940 | s522020997 | 1,320 | 570 | 17,276 | 15,088 | Accepted | Accepted | 56.82 | data = list()
for i in range(int(eval(input()))):
data.append(int(eval(input())))
max_diff = -1000000000
min_data = data[0]
for value in data[1:] :
max_diff = max(max_diff, value - min_data)
min_data = min(min_data, value)
print(max_diff)
| data = []
for _ in range(int(eval(input()))) :
data.append(int(eval(input())))
max_diff = -1000000000
min_data = data[0]
for value in data[1:] :
max_diff = max(max_diff, value - min_data)
min_data = min(min_data, value)
print(max_diff)
| 11 | 12 | 252 | 254 | data = list()
for i in range(int(eval(input()))):
data.append(int(eval(input())))
max_diff = -1000000000
min_data = data[0]
for value in data[1:]:
max_diff = max(max_diff, value - min_data)
min_data = min(min_data, value)
print(max_diff)
| data = []
for _ in range(int(eval(input()))):
data.append(int(eval(input())))
max_diff = -1000000000
min_data = data[0]
for value in data[1:]:
max_diff = max(max_diff, value - min_data)
min_data = min(min_data, value)
print(max_diff)
| false | 8.333333 | [
"-data = list()",
"-for i in range(int(eval(input()))):",
"+data = []",
"+for _ in range(int(eval(input()))):"
] | false | 0.007335 | 0.040243 | 0.182265 | [
"s003115940",
"s522020997"
] |
u186838327 | p03062 | python | s684904044 | s810538368 | 264 | 105 | 65,440 | 99,240 | Accepted | Accepted | 60.23 | n = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for a in A:
if a < 0:
cnt += 1
C = [abs(a) for a in A]
C.sort(reverse=True)
if cnt%2 == 0:
print((sum(C)))
else:
C[-1] *= (-1)
print((sum(C))) | n = int(eval(input()))
A =list(map(int, input().split()))
dp = [[0]*2 for _ in range(n)]
# dp[i][0]:*1
# dp[i][1]:*(-1)
for i in range(n-1):
if i == 0:
dp[i+1][0] += A[i]
dp[i+1][1] += -A[i]
else:
dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]+(-1)*A[i])
dp[i+1][1] = max(d... | 15 | 15 | 239 | 414 | n = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
for a in A:
if a < 0:
cnt += 1
C = [abs(a) for a in A]
C.sort(reverse=True)
if cnt % 2 == 0:
print((sum(C)))
else:
C[-1] *= -1
print((sum(C)))
| n = int(eval(input()))
A = list(map(int, input().split()))
dp = [[0] * 2 for _ in range(n)]
# dp[i][0]:*1
# dp[i][1]:*(-1)
for i in range(n - 1):
if i == 0:
dp[i + 1][0] += A[i]
dp[i + 1][1] += -A[i]
else:
dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] + (-1) * A[i])
dp[i + 1][1] =... | false | 0 | [
"-cnt = 0",
"-for a in A:",
"- if a < 0:",
"- cnt += 1",
"-C = [abs(a) for a in A]",
"-C.sort(reverse=True)",
"-if cnt % 2 == 0:",
"- print((sum(C)))",
"-else:",
"- C[-1] *= -1",
"- print((sum(C)))",
"+dp = [[0] * 2 for _ in range(n)]",
"+# dp[i][0]:*1",
"+# dp[i][1]:*(-... | false | 0.037229 | 0.044561 | 0.835448 | [
"s684904044",
"s810538368"
] |
u627803856 | p03160 | python | s306114809 | s701211769 | 238 | 103 | 52,208 | 85,620 | Accepted | Accepted | 56.72 | n = int(eval(input()))
h = [0] + list(map(int, input().split()))
dp = [0] * (n + 1)
dp[1] = 0
dp[2] = dp[1] + abs(h[2] - h[1])
for i in range(3, n + 1):
dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
dp[i - 1] + abs(h[i] - h[i - 1]))
print((dp[n])) | n = int(eval(input()))
h = list(map(int, input().split()))
def chmin(a, b):
if a > b: return b
else: return a
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
if i > 1:
dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2... | 12 | 14 | 258 | 333 | n = int(eval(input()))
h = [0] + list(map(int, input().split()))
dp = [0] * (n + 1)
dp[1] = 0
dp[2] = dp[1] + abs(h[2] - h[1])
for i in range(3, n + 1):
dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))
print((dp[n]))
| n = int(eval(input()))
h = list(map(int, input().split()))
def chmin(a, b):
if a > b:
return b
else:
return a
dp = [float("inf")] * n
dp[0] = 0
for i in range(1, n):
dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
if i > 1:
dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h... | false | 14.285714 | [
"-h = [0] + list(map(int, input().split()))",
"-dp = [0] * (n + 1)",
"-dp[1] = 0",
"-dp[2] = dp[1] + abs(h[2] - h[1])",
"-for i in range(3, n + 1):",
"- dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))",
"-print((dp[n]))",
"+h = list(map(int, input().split()))",
"+"... | false | 0.048208 | 0.049197 | 0.979902 | [
"s306114809",
"s701211769"
] |
u716530146 | p02995 | python | s239890626 | s307185419 | 328 | 165 | 63,852 | 38,256 | Accepted | Accepted | 49.7 | from fractions import gcd
a,b,c,d=list(map(int,input().split()))
lenth=b-a+1
def lcm(m,n):
return (m*n)//gcd(m,n)
def divnumber(c):
ans=lenth//c
rem1=a%c
if rem1==0:rem1+=c
rem2=lenth%c-1
if rem1+rem2>=c:
ans+=1
return ans
print((lenth-divnumber(c)-divnumber(d)+divnumber(lcm(c,d))))
| import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
a,b,c,d = list(map(int,input().split()))
C = b//c-(a-1)//c
D = b//d - (a-1)//d
def gcd(a, b):
while(b != 0):
... | 18 | 19 | 306 | 473 | from fractions import gcd
a, b, c, d = list(map(int, input().split()))
lenth = b - a + 1
def lcm(m, n):
return (m * n) // gcd(m, n)
def divnumber(c):
ans = lenth // c
rem1 = a % c
if rem1 == 0:
rem1 += c
rem2 = lenth % c - 1
if rem1 + rem2 >= c:
ans += 1
return ans
pri... | import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
a, b, c, d = list(map(int, input().split()))
C = b // c - (a - 1) // c
D = b // d - (a - 1) // d
def gcd(a, b):
while b != ... | false | 5.263158 | [
"-from fractions import gcd",
"+import sys, math, itertools, collections, bisect",
"+input = lambda: sys.stdin.buffer.readline().rstrip().decode(\"utf-8\")",
"+inf = float(\"inf\")",
"+mod = 10**9 + 7",
"+mans = inf",
"+ans = 0",
"+count = 0",
"+pro = 1",
"-lenth = b - a + 1",
"+C = b // c - (a ... | false | 0.007673 | 0.037766 | 0.203184 | [
"s239890626",
"s307185419"
] |
u524534026 | p02729 | python | s524003228 | s274414911 | 175 | 19 | 13,500 | 2,940 | Accepted | Accepted | 89.14 | from scipy.misc import comb
n, m = list(map(int,input().split()))
ans = comb(n,2,exact=True) + comb(m,2,exact=True) #exact=Trueで整数値が返される
print(ans) | n, m = list(map(int,input().split()))
if n <= 1:
N =0
else:
N = n*(n-1)/2
if m <= 1:
M = 0
else:
M = m*(m-1)/2
print((int(N+M))) | 5 | 11 | 146 | 147 | from scipy.misc import comb
n, m = list(map(int, input().split()))
ans = comb(n, 2, exact=True) + comb(m, 2, exact=True) # exact=Trueで整数値が返される
print(ans)
| n, m = list(map(int, input().split()))
if n <= 1:
N = 0
else:
N = n * (n - 1) / 2
if m <= 1:
M = 0
else:
M = m * (m - 1) / 2
print((int(N + M)))
| false | 54.545455 | [
"-from scipy.misc import comb",
"-",
"-ans = comb(n, 2, exact=True) + comb(m, 2, exact=True) # exact=Trueで整数値が返される",
"-print(ans)",
"+if n <= 1:",
"+ N = 0",
"+else:",
"+ N = n * (n - 1) / 2",
"+if m <= 1:",
"+ M = 0",
"+else:",
"+ M = m * (m - 1) / 2",
"+print((int(N + M)))"
] | false | 0.335326 | 0.044372 | 7.557117 | [
"s524003228",
"s274414911"
] |
u133936772 | p03418 | python | s351515614 | s631265271 | 75 | 62 | 9,168 | 9,168 | Accepted | Accepted | 17.33 | n,k=list(map(int,input().split()))
c=0
for b in range(k+1,n+1):
c+=n//b*(b-k)+max(n%b-k+1,0)-(k<1)
print(c) | n,k=list(map(int,input().split()))
print((sum(n//b*(b-k)+max(n%b-k+1,0)-(k<1) for b in range(k+1,n+1)))) | 5 | 2 | 107 | 97 | n, k = list(map(int, input().split()))
c = 0
for b in range(k + 1, n + 1):
c += n // b * (b - k) + max(n % b - k + 1, 0) - (k < 1)
print(c)
| n, k = list(map(int, input().split()))
print(
(
sum(
n // b * (b - k) + max(n % b - k + 1, 0) - (k < 1)
for b in range(k + 1, n + 1)
)
)
)
| false | 60 | [
"-c = 0",
"-for b in range(k + 1, n + 1):",
"- c += n // b * (b - k) + max(n % b - k + 1, 0) - (k < 1)",
"-print(c)",
"+print(",
"+ (",
"+ sum(",
"+ n // b * (b - k) + max(n % b - k + 1, 0) - (k < 1)",
"+ for b in range(k + 1, n + 1)",
"+ )",
"+ )",
... | false | 0.04265 | 0.10219 | 0.417361 | [
"s351515614",
"s631265271"
] |
u075595666 | p02626 | python | s203325990 | s919749353 | 64 | 28 | 62,256 | 9,224 | Accepted | Accepted | 56.25 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
a = list(map(int,readline().split()))
s = a[0]+a[1]
if n == 2:
if a[0] < a[1] or s%2 == 1:
print((-1))
else:
print((a[0]-s//2))
exit()
c = 0
for i in ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
a = list(map(int,readline().split()))
s = a[0]+a[1]
if n == 2:
if a[0] < a[1] or s%2 == 1:
print((-1))
else:
print((a[0]-s//2))
exit()
c = 0
for i in ... | 49 | 43 | 830 | 769 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
a = list(map(int, readline().split()))
s = a[0] + a[1]
if n == 2:
if a[0] < a[1] or s % 2 == 1:
print((-1))
else:
print((a[0] - s // 2))
exit()
c = 0
for i... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
a = list(map(int, readline().split()))
s = a[0] + a[1]
if n == 2:
if a[0] < a[1] or s % 2 == 1:
print((-1))
else:
print((a[0] - s // 2))
exit()
c = 0
for i... | false | 12.244898 | [
"-if s < c or (s - c) % 2 == 1 or c & sc != 0:",
"+if s < c or (s - c) % 2 == 1 or c & sc:",
"- if (c >> i & 1) | (sc >> i & 1) == 0:",
"+ if not (c >> i & 1) | (sc >> i & 1):",
"- elif c >> i & 1 == 0 and sc >> i & 1 == 1:",
"+ elif not c >> i & 1 and sc >> i & 1:",
"- x += \"p\"",
... | false | 0.037016 | 0.03777 | 0.980041 | [
"s203325990",
"s919749353"
] |
u635277286 | p03675 | python | s318896232 | s532165383 | 153 | 113 | 30,404 | 28,100 | Accepted | Accepted | 26.14 | n = int(eval(input()))
a = list(map(int,input().split()))
even = []
odd = []
for i in range(0,n):
if i % 2 == 0:
odd.append(a[i])
else:
even.append(a[i])
res = []
if n % 2 == 0:
even = reversed(even)
res.extend(even)
res.extend(odd)
else:
odd = reversed(odd)
res.extend(odd)
res.extend(e... | n = int(eval(input()))
a = list(map(int,input().split()))
if n == 1:
print((a[0]))
elif n % 2 == 0:
print((" ".join(map(str, a[1::2][::-1] + a[0::2]))))
else:
print((" ".join(map(str, a[0::2][::-1] + a[1::2])))) | 22 | 9 | 351 | 211 | n = int(eval(input()))
a = list(map(int, input().split()))
even = []
odd = []
for i in range(0, n):
if i % 2 == 0:
odd.append(a[i])
else:
even.append(a[i])
res = []
if n % 2 == 0:
even = reversed(even)
res.extend(even)
res.extend(odd)
else:
odd = reversed(odd)
res.extend(odd)... | n = int(eval(input()))
a = list(map(int, input().split()))
if n == 1:
print((a[0]))
elif n % 2 == 0:
print((" ".join(map(str, a[1::2][::-1] + a[0::2]))))
else:
print((" ".join(map(str, a[0::2][::-1] + a[1::2]))))
| false | 59.090909 | [
"-even = []",
"-odd = []",
"-for i in range(0, n):",
"- if i % 2 == 0:",
"- odd.append(a[i])",
"- else:",
"- even.append(a[i])",
"-res = []",
"-if n % 2 == 0:",
"- even = reversed(even)",
"- res.extend(even)",
"- res.extend(odd)",
"+if n == 1:",
"+ print((a[... | false | 0.037342 | 0.037356 | 0.999638 | [
"s318896232",
"s532165383"
] |
u637175065 | p03181 | python | s787632054 | s301687902 | 1,994 | 1,689 | 176,276 | 215,292 | Accepted | Accepted | 15.3 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return list(map(int, sys.stdin.readli... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in s... | 70 | 105 | 1,772 | 2,533 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return... | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI... | false | 33.333333 | [
"-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools",
"+import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools",
"- return list(map(int, sys.stdin.readline().split()))",
"-",
"-",
"-def LL... | false | 0.084641 | 0.049567 | 1.707608 | [
"s787632054",
"s301687902"
] |
u761320129 | p02953 | python | s216368542 | s009690386 | 76 | 66 | 14,396 | 20,580 | Accepted | Accepted | 13.16 | N = int(eval(input()))
H = list(map(int,input().split()))
minh = H[0]-1
for h in H[1:]:
if minh > h:
print('No')
exit()
minh = max(minh, h-1)
print('Yes') | N = int(eval(input()))
H = list(map(int,input().split()))
down = False
p = -1
for h in H:
if p - h >= 2:
print('No')
exit()
if down and p - h >= 1:
print('No')
exit()
if p < h:
down = False
elif p > h:
down = True
p = h
print('Yes') | 10 | 18 | 182 | 312 | N = int(eval(input()))
H = list(map(int, input().split()))
minh = H[0] - 1
for h in H[1:]:
if minh > h:
print("No")
exit()
minh = max(minh, h - 1)
print("Yes")
| N = int(eval(input()))
H = list(map(int, input().split()))
down = False
p = -1
for h in H:
if p - h >= 2:
print("No")
exit()
if down and p - h >= 1:
print("No")
exit()
if p < h:
down = False
elif p > h:
down = True
p = h
print("Yes")
| false | 44.444444 | [
"-minh = H[0] - 1",
"-for h in H[1:]:",
"- if minh > h:",
"+down = False",
"+p = -1",
"+for h in H:",
"+ if p - h >= 2:",
"- minh = max(minh, h - 1)",
"+ if down and p - h >= 1:",
"+ print(\"No\")",
"+ exit()",
"+ if p < h:",
"+ down = False",
"+ elif... | false | 0.032286 | 0.032716 | 0.986878 | [
"s216368542",
"s009690386"
] |
u353797797 | p03287 | python | s546617252 | s724142981 | 131 | 104 | 13,904 | 14,424 | Accepted | Accepted | 20.61 | n, m = list(map(int, input().split()))
aa = [int(ak) % m for ak in input().split()]
mod = {}
ans = 0
zi = 0
for a in aa:
zi = (zi - a) % m
ai = (zi + a) % m
mod.setdefault(ai,0)
mod[ai] += 1
ans += mod.get(zi,0)
print(ans)
| def f(n, m):
aa = [int(ak) % m for ak in input().split()]
mod = {}
ans = 0
zi = 0
for a in aa:
zi = (zi - a) % m
ai = (zi + a) % m
mod.setdefault(ai, 0)
mod[ai] += 1
ans += mod.get(zi, 0)
print(ans)
n, m = list(map(int, input().split()))
f... | 12 | 16 | 248 | 321 | n, m = list(map(int, input().split()))
aa = [int(ak) % m for ak in input().split()]
mod = {}
ans = 0
zi = 0
for a in aa:
zi = (zi - a) % m
ai = (zi + a) % m
mod.setdefault(ai, 0)
mod[ai] += 1
ans += mod.get(zi, 0)
print(ans)
| def f(n, m):
aa = [int(ak) % m for ak in input().split()]
mod = {}
ans = 0
zi = 0
for a in aa:
zi = (zi - a) % m
ai = (zi + a) % m
mod.setdefault(ai, 0)
mod[ai] += 1
ans += mod.get(zi, 0)
print(ans)
n, m = list(map(int, input().split()))
f(n, m)
| false | 25 | [
"+def f(n, m):",
"+ aa = [int(ak) % m for ak in input().split()]",
"+ mod = {}",
"+ ans = 0",
"+ zi = 0",
"+ for a in aa:",
"+ zi = (zi - a) % m",
"+ ai = (zi + a) % m",
"+ mod.setdefault(ai, 0)",
"+ mod[ai] += 1",
"+ ans += mod.get(zi, 0)",
"+... | false | 0.035779 | 0.032622 | 1.096775 | [
"s546617252",
"s724142981"
] |
u189023301 | p02837 | python | s806329577 | s036613188 | 702 | 97 | 3,064 | 8,820 | Accepted | Accepted | 86.18 | n = int(eval(input()))
t = [[] for _ in range(n)]
s = [[] for _ in range(n)]
for i in range(n):
a = int(eval(input()))
for j in range(a):
x, y = list(map(int, input().split()))
if y == 1:
t[i].append(x - 1)
else:
s[i].append(x - 1)
res = 0
for k in r... | import itertools as it
n = int(eval(input()))
lis = [[] for _ in range(n)]
val = list(it.product([0, 1], repeat=n))
for i in range(n):
for j in range(int(eval(input()))):
x, y = list(map(int, input().split()))
x = x - 1
lis[i].append((x, y))
def honesty(k, lis, n):
for ... | 29 | 27 | 688 | 555 | n = int(eval(input()))
t = [[] for _ in range(n)]
s = [[] for _ in range(n)]
for i in range(n):
a = int(eval(input()))
for j in range(a):
x, y = list(map(int, input().split()))
if y == 1:
t[i].append(x - 1)
else:
s[i].append(x - 1)
res = 0
for k in range(pow(2, n)... | import itertools as it
n = int(eval(input()))
lis = [[] for _ in range(n)]
val = list(it.product([0, 1], repeat=n))
for i in range(n):
for j in range(int(eval(input()))):
x, y = list(map(int, input().split()))
x = x - 1
lis[i].append((x, y))
def honesty(k, lis, n):
for i in range(n):
... | false | 6.896552 | [
"+import itertools as it",
"+",
"-t = [[] for _ in range(n)]",
"-s = [[] for _ in range(n)]",
"+lis = [[] for _ in range(n)]",
"+val = list(it.product([0, 1], repeat=n))",
"- a = int(eval(input()))",
"- for j in range(a):",
"+ for j in range(int(eval(input()))):",
"- if y == 1:",
... | false | 0.040193 | 0.075354 | 0.533392 | [
"s806329577",
"s036613188"
] |
u827554201 | p02720 | python | s831720719 | s625725859 | 251 | 172 | 8,880 | 9,072 | Accepted | Accepted | 31.47 | k = int(eval(input()))
nums = []
def inc(num):
if num > 3234566667:
return None
if num <= 3234566667:
nums.append(num)
num_str = str(num)
end = num_str[-1:]
end_num = int(end)
if end_num < 9:
inc(int(num_str + str(end_num + 1)))
inc(int(num_str + ... | k = int(eval(input()))
nums = []
def inc(num):
if num > 3234566667:
return None
if num <= 3234566667:
nums.append(num)
end = str(num)[-1:]
end_num = int(end)
if end_num < 9:
inc(num * 10 + end_num + 1)
inc(num * 10 + end_num)
if end_num > 0:
... | 26 | 25 | 486 | 438 | k = int(eval(input()))
nums = []
def inc(num):
if num > 3234566667:
return None
if num <= 3234566667:
nums.append(num)
num_str = str(num)
end = num_str[-1:]
end_num = int(end)
if end_num < 9:
inc(int(num_str + str(end_num + 1)))
inc(int(num_str + end))
if end_nu... | k = int(eval(input()))
nums = []
def inc(num):
if num > 3234566667:
return None
if num <= 3234566667:
nums.append(num)
end = str(num)[-1:]
end_num = int(end)
if end_num < 9:
inc(num * 10 + end_num + 1)
inc(num * 10 + end_num)
if end_num > 0:
inc(num * 10 + e... | false | 3.846154 | [
"- num_str = str(num)",
"- end = num_str[-1:]",
"+ end = str(num)[-1:]",
"- inc(int(num_str + str(end_num + 1)))",
"- inc(int(num_str + end))",
"+ inc(num * 10 + end_num + 1)",
"+ inc(num * 10 + end_num)",
"- inc(int(num_str + str(end_num - 1)))",
"+ inc(nu... | false | 1.17581 | 0.747257 | 1.573501 | [
"s831720719",
"s625725859"
] |
u595375942 | p03031 | python | s249672970 | s309940636 | 31 | 20 | 3,064 | 3,064 | Accepted | Accepted | 35.48 | n,m=list(map(int,input().split()))
S=[list(map(int,input().split()))[1:] for _ in range(m)]
P=list(map(int,input().split()))
cnt=0
for i in range(2**n):
Q=0
switch=set([i+1 for i,j in enumerate(format(i,"b").zfill(n)[::-1]) if j == '1'])
for k,j in enumerate(S):
if len(switch&set(j))%2==P[... | import sys
n, m = list(map(int, input().split()))
swi = []
for _ in range(m):
k, *sss = list(map(int, input().split()))
t = 0
for s in sss:
t += 1 << (s - 1)
swi.append(t)
ppp = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
for s, p in zip(swi, ppp):
... | 15 | 22 | 379 | 446 | n, m = list(map(int, input().split()))
S = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
cnt = 0
for i in range(2**n):
Q = 0
switch = set(
[i + 1 for i, j in enumerate(format(i, "b").zfill(n)[::-1]) if j == "1"]
)
for k, j in enumerate(S):
if... | import sys
n, m = list(map(int, input().split()))
swi = []
for _ in range(m):
k, *sss = list(map(int, input().split()))
t = 0
for s in sss:
t += 1 << (s - 1)
swi.append(t)
ppp = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
for s, p in zip(swi, ppp):
t = i & s
... | false | 31.818182 | [
"+import sys",
"+",
"-S = [list(map(int, input().split()))[1:] for _ in range(m)]",
"-P = list(map(int, input().split()))",
"-cnt = 0",
"-for i in range(2**n):",
"- Q = 0",
"- switch = set(",
"- [i + 1 for i, j in enumerate(format(i, \"b\").zfill(n)[::-1]) if j == \"1\"]",
"- )",
... | false | 0.036653 | 0.037546 | 0.976224 | [
"s249672970",
"s309940636"
] |
u512212329 | p02660 | python | s742169626 | s559766176 | 103 | 81 | 9,684 | 9,652 | Accepted | Accepted | 21.36 | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int) # key ^ value
acc = tuple(accumulate(list(range(1, 42)))) # because 10^12 < 2^39
def facs(n):
yield 2
max_x = int((n ** 0.5 - 3) / 2 + ... | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int) # key ^ value
acc = tuple(accumulate(list(range(1, 42)))) # because 10^12 < 2^39
def facs(n):
yield 2
max_x = int(n ** 0.5)
fo... | 36 | 36 | 869 | 855 | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int) # key ^ value
acc = tuple(accumulate(list(range(1, 42)))) # because 10^12 < 2^39
def facs(n):
yield 2
max_x = int((n**0.5 - 3) / 2 + 1)
fo... | from itertools import accumulate
from collections import defaultdict
def main():
n = int(eval(input()))
prime_counter = defaultdict(int) # key ^ value
acc = tuple(accumulate(list(range(1, 42)))) # because 10^12 < 2^39
def facs(n):
yield 2
max_x = int(n**0.5)
for x in range(3... | false | 0 | [
"- max_x = int((n**0.5 - 3) / 2 + 1)",
"- for x in range(max_x):",
"- yield x * 2 + 3",
"+ max_x = int(n**0.5)",
"+ for x in range(3, max_x + 1, 2):",
"+ yield x"
] | false | 0.055334 | 0.058743 | 0.941963 | [
"s742169626",
"s559766176"
] |
u579832365 | p02712 | python | s368693854 | s305144926 | 188 | 145 | 9,100 | 9,548 | Accepted | Accepted | 22.87 | 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 = ans + i
print(ans)
| from functools import lru_cache
N = int(eval(input()))
@lru_cache(maxsize=1000)
def main(K):
ans = 0
for i in range(1, N+1):
if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:
ans = ans + i
return(ans)
print((main(N))) | 9 | 13 | 137 | 254 | 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 = ans + i
print(ans)
| from functools import lru_cache
N = int(eval(input()))
@lru_cache(maxsize=1000)
def main(K):
ans = 0
for i in range(1, N + 1):
if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:
ans = ans + i
return ans
print((main(N)))
| false | 30.769231 | [
"+from functools import lru_cache",
"+",
"-ans = 0",
"-for i in range(1, N + 1):",
"- if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:",
"- ans = ans + i",
"-print(ans)",
"+",
"+",
"+@lru_cache(maxsize=1000)",
"+def main(K):",
"+ ans = 0",
"+ for i in range(1, N + 1):",
"+ ... | false | 0.787334 | 0.219214 | 3.591629 | [
"s368693854",
"s305144926"
] |
u649558044 | p03240 | python | s917240020 | s348223600 | 489 | 35 | 3,700 | 3,700 | Accepted | Accepted | 92.84 | import itertools
n = int(input())
x, y, h = [], [], []
for _ in range(n):
xi, yi, hi = map(int, input().split())
if hi != 0:
x.append(xi)
y.append(yi)
h.append(hi)
candidate_cx = list(range(min(x), max(x) + 1))
candidate_cy = list(range(min(y), max(y) + 1))
for cx, cy in l... | import itertools
n = int(input())
x, y, h = [], [], []
for _ in range(n):
xi, yi, hi = map(int, input().split())
if hi != 0:
x.append(xi)
y.append(yi)
h.append(hi)
candidate_cx = list(range(min(x), max(x) + 1))
candidate_cy = list(range(min(y), max(y) + 1))
for cx, cy in l... | 26 | 24 | 724 | 668 | import itertools
n = int(input())
x, y, h = [], [], []
for _ in range(n):
xi, yi, hi = map(int, input().split())
if hi != 0:
x.append(xi)
y.append(yi)
h.append(hi)
candidate_cx = list(range(min(x), max(x) + 1))
candidate_cy = list(range(min(y), max(y) + 1))
for cx, cy in list(itertools.... | import itertools
n = int(input())
x, y, h = [], [], []
for _ in range(n):
xi, yi, hi = map(int, input().split())
if hi != 0:
x.append(xi)
y.append(yi)
h.append(hi)
candidate_cx = list(range(min(x), max(x) + 1))
candidate_cy = list(range(min(y), max(y) + 1))
for cx, cy in list(itertools.... | false | 7.692308 | [
"- ch = 0",
"- for xi, yi, hi in zip(x, y, h):",
"- ch = max(ch, hi + abs(xi - cx) + abs(yi - cy))",
"+ ch = h[0] + abs(x[0] - cx) + abs(y[0] - cy)"
] | false | 0.036401 | 0.006345 | 5.737343 | [
"s917240020",
"s348223600"
] |
u226108478 | p03231 | python | s547127796 | s184474604 | 108 | 86 | 5,844 | 5,716 | Accepted | Accepted | 20.37 | # -*- coding: utf-8 -*-
def lcm(x: int, y: int):
'''
See:
https://note.nkmk.me/python-gcd-lcm/
'''
from fractions import gcd
return (x * y) // gcd(x, y)
def main():
n, m = list(map(int, input().split()))
s = eval(input())
t = eval(input())
size = lcm(n, m)
... | # -*- coding: utf-8 -*-
def lcm(x: int, y: int):
'''
See:
https://note.nkmk.me/python-gcd-lcm/
'''
from fractions import gcd
return (x * y) // gcd(x, y)
def main():
n, m = list(map(int, input().split()))
s = eval(input())
t = eval(input())
size = lcm(n, m)
... | 42 | 38 | 707 | 675 | # -*- coding: utf-8 -*-
def lcm(x: int, y: int):
"""
See:
https://note.nkmk.me/python-gcd-lcm/
"""
from fractions import gcd
return (x * y) // gcd(x, y)
def main():
n, m = list(map(int, input().split()))
s = eval(input())
t = eval(input())
size = lcm(n, m)
dn = size // n
... | # -*- coding: utf-8 -*-
def lcm(x: int, y: int):
"""
See:
https://note.nkmk.me/python-gcd-lcm/
"""
from fractions import gcd
return (x * y) // gcd(x, y)
def main():
n, m = list(map(int, input().split()))
s = eval(input())
t = eval(input())
size = lcm(n, m)
dn = size // n
... | false | 9.52381 | [
"- part_s = [s[0]]",
"- part_t = [t[0]]",
"- i = dm",
"- j = dn",
"- while i < n:",
"+ part_s = list()",
"+ part_t = list()",
"+ for i in range(0, n, dm):",
"- i += dm",
"- while j < m:",
"- part_t.append(t[j])",
"- j += dn",
"+ for i in ran... | false | 0.058087 | 0.00737 | 7.882094 | [
"s547127796",
"s184474604"
] |
u991567869 | p02837 | python | s264855773 | s657094457 | 1,094 | 210 | 3,064 | 3,316 | Accepted | Accepted | 80.8 | n = int(eval(input()))
l = [[] for _ in range(n)]
ans = 0
for i in range(n):
a = int(eval(input()))
for j in range(a):
xy = input().split()
l[i].append(list(map(int, xy)))
for i in range(2**n):
judge = True
for j in range(n):
if i & (1 << j): #証言者が正直者設定なら進む。
... | n = int(eval(input()))
l = [[] for _ in range(n)]
ans = 0
for i in range(n):
a = int(eval(input()))
for j in range(a):
xy = input().split()
l[i].append(list(map(int, xy)))
for i in range(2**n):
judge = True
for j in range(n):
if judge == False:
break
... | 24 | 26 | 632 | 679 | n = int(eval(input()))
l = [[] for _ in range(n)]
ans = 0
for i in range(n):
a = int(eval(input()))
for j in range(a):
xy = input().split()
l[i].append(list(map(int, xy)))
for i in range(2**n):
judge = True
for j in range(n):
if i & (1 << j): # 証言者が正直者設定なら進む。
for x, ... | n = int(eval(input()))
l = [[] for _ in range(n)]
ans = 0
for i in range(n):
a = int(eval(input()))
for j in range(a):
xy = input().split()
l[i].append(list(map(int, xy)))
for i in range(2**n):
judge = True
for j in range(n):
if judge == False:
break
if i & (1... | false | 7.692308 | [
"+ if judge == False:",
"+ break"
] | false | 0.088496 | 0.052603 | 1.682342 | [
"s264855773",
"s657094457"
] |
u268554510 | p02597 | python | s729988338 | s086445764 | 113 | 86 | 73,112 | 68,044 | Accepted | Accepted | 23.89 | N = int(eval(input()))
c = eval(input())
right = N - 1
left = 0
ans = 0
flag = False
while True:
if c[right]=='W':
if (right>=1)and(right>left+1):
right -= 1
continue
else:
break
else:
while True:
if c[left]=='R':
if (left<N)and(left<right-1):
... | N = int(eval(input()))
c = eval(input())
W = 0
R = 0
for x in c:
if x=='R':
R += 1
ans = R
for x in c:
if x=='W':
W += 1
else:
R -= 1
ans = min(ans,max(R,W))
print(ans) | 35 | 19 | 543 | 204 | N = int(eval(input()))
c = eval(input())
right = N - 1
left = 0
ans = 0
flag = False
while True:
if c[right] == "W":
if (right >= 1) and (right > left + 1):
right -= 1
continue
else:
break
else:
while True:
if c[left] == "R":
... | N = int(eval(input()))
c = eval(input())
W = 0
R = 0
for x in c:
if x == "R":
R += 1
ans = R
for x in c:
if x == "W":
W += 1
else:
R -= 1
ans = min(ans, max(R, W))
print(ans)
| false | 45.714286 | [
"-right = N - 1",
"-left = 0",
"-ans = 0",
"-flag = False",
"-while True:",
"- if c[right] == \"W\":",
"- if (right >= 1) and (right > left + 1):",
"- right -= 1",
"- continue",
"- else:",
"- break",
"+W = 0",
"+R = 0",
"+for x in c:",
"+... | false | 0.03691 | 0.041136 | 0.897269 | [
"s729988338",
"s086445764"
] |
u729133443 | p03440 | python | s028659189 | s271803130 | 686 | 628 | 138,788 | 138,604 | Accepted | Accepted | 8.45 | (n,m),a,*q=[map(int,t.split())for t in open(0)]
t=[-1]*n
def r(x):
while-1<t[x]:x=t[x]
return x
def u(x):
x,y=map(r,x)
if x!=y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
[*map(u,q)]
i=c=0
k,*b=n+~m<<1,
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
print(k<1and'0'or(k>n)*'Impossible'or exec('for p in... | (n,m,*b),a,*q=[list(map(int,t.split()))for t in open(0)]
t=[-1]*n
def r(x):
while-1<t[x]:x=t[x]
return x
def u(x):
x,y=list(map(r,x))
if x!=y:
if t[x]>t[y]:x,y=y,x
t[x]+=t[y];t[y]=x
[*list(map(u,q))]
i=c=0
k=j=n+~m<<1
*d,=eval('[],'*n)
for v in a:d[r(i)]+=v,;i+=1
for p in d:x,*y=sorted(p)+[0];c+=... | 16 | 17 | 390 | 382 | (n, m), a, *q = [map(int, t.split()) for t in open(0)]
t = [-1] * n
def r(x):
while -1 < t[x]:
x = t[x]
return x
def u(x):
x, y = map(r, x)
if x != y:
if t[x] > t[y]:
x, y = y, x
t[x] += t[y]
t[y] = x
[*map(u, q)]
i = c = 0
k, *b = (n + ~m << 1,)
(*d,) =... | (n, m, *b), a, *q = [list(map(int, t.split())) for t in open(0)]
t = [-1] * n
def r(x):
while -1 < t[x]:
x = t[x]
return x
def u(x):
x, y = list(map(r, x))
if x != y:
if t[x] > t[y]:
x, y = y, x
t[x] += t[y]
t[y] = x
[*list(map(u, q))]
i = c = 0
k = j = ... | false | 5.882353 | [
"-(n, m), a, *q = [map(int, t.split()) for t in open(0)]",
"+(n, m, *b), a, *q = [list(map(int, t.split())) for t in open(0)]",
"- x, y = map(r, x)",
"+ x, y = list(map(r, x))",
"-[*map(u, q)]",
"+[*list(map(u, q))]",
"-k, *b = (n + ~m << 1,)",
"+k = j = n + ~m << 1",
"-print(",
"- k < 1"... | false | 0.035141 | 0.035625 | 0.986419 | [
"s028659189",
"s271803130"
] |
u894258749 | p03000 | python | s214696195 | s961774059 | 171 | 17 | 38,740 | 3,060 | Accepted | Accepted | 90.06 | inpl = lambda: list(map(int,input().split()))
N, X = inpl()
L = inpl()
q = 0
for i in range(N):
q += L[i]
if q > X:
break
else:
i += 1
print((i+1)) | inpl = lambda: list(map(int,input().split()))
N, X = inpl()
L = inpl()
P = 0
for i in range(N):
P += L[i]
if P > X:
print((i+1))
break
else:
print((N+1)) | 11 | 11 | 175 | 187 | inpl = lambda: list(map(int, input().split()))
N, X = inpl()
L = inpl()
q = 0
for i in range(N):
q += L[i]
if q > X:
break
else:
i += 1
print((i + 1))
| inpl = lambda: list(map(int, input().split()))
N, X = inpl()
L = inpl()
P = 0
for i in range(N):
P += L[i]
if P > X:
print((i + 1))
break
else:
print((N + 1))
| false | 0 | [
"-q = 0",
"+P = 0",
"- q += L[i]",
"- if q > X:",
"+ P += L[i]",
"+ if P > X:",
"+ print((i + 1))",
"- i += 1",
"-print((i + 1))",
"+ print((N + 1))"
] | false | 0.036461 | 0.03683 | 0.989999 | [
"s214696195",
"s961774059"
] |
u327466606 | p02936 | python | s896220016 | s420079883 | 1,870 | 727 | 95,744 | 136,804 | Accepted | Accepted | 61.12 | N,Q = list(map(int,input().split()))
adj = [list() for _ in range(N)]
for _ in range(N-1):
a,b = list(map(int,input().split()))
adj[a-1].append(b-1)
memo = [0]*N
for _ in range(Q):
p,x = list(map(int,input().split()))
memo[p-1] += x
result = [None]*N
stack = [(0,0)]
while stack:
v,... | N,Q = list(map(int,input().split()))
adj = [list() for _ in range(N)]
for _ in range(N-1):
a,b = list(map(int,input().split()))
adj[a-1].append(b-1)
adj[b-1].append(a-1)
memo = [0]*N
for _ in range(Q):
p,x = list(map(int,input().split()))
memo[p-1] += x
result = [0]*N
stack = [(None... | 22 | 25 | 423 | 512 | N, Q = list(map(int, input().split()))
adj = [list() for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
adj[a - 1].append(b - 1)
memo = [0] * N
for _ in range(Q):
p, x = list(map(int, input().split()))
memo[p - 1] += x
result = [None] * N
stack = [(0, 0)]
while stack:
v... | N, Q = list(map(int, input().split()))
adj = [list() for _ in range(N)]
for _ in range(N - 1):
a, b = list(map(int, input().split()))
adj[a - 1].append(b - 1)
adj[b - 1].append(a - 1)
memo = [0] * N
for _ in range(Q):
p, x = list(map(int, input().split()))
memo[p - 1] += x
result = [0] * N
stack = [... | false | 12 | [
"+ adj[b - 1].append(a - 1)",
"-result = [None] * N",
"-stack = [(0, 0)]",
"+result = [0] * N",
"+stack = [(None, 0)]",
"- v, a = stack.pop()",
"- a += memo[v]",
"- result[v] = a",
"+ p, v = stack.pop()",
"+ result[v] += memo[v]",
"- stack.append((u, a))",
"+ if... | false | 0.036589 | 0.036754 | 0.995508 | [
"s896220016",
"s420079883"
] |
u604839890 | p03644 | python | s767867305 | s844075392 | 32 | 27 | 9,132 | 9,096 | Accepted | Accepted | 15.62 | n = int(eval(input()))
cnt = 1
while cnt <= n:
cnt *= 2
print((cnt//2)) | n = int(eval(input()))
t = 1
while t <= n:
t*=2
print((t//2)) | 5 | 5 | 71 | 61 | n = int(eval(input()))
cnt = 1
while cnt <= n:
cnt *= 2
print((cnt // 2))
| n = int(eval(input()))
t = 1
while t <= n:
t *= 2
print((t // 2))
| false | 0 | [
"-cnt = 1",
"-while cnt <= n:",
"- cnt *= 2",
"-print((cnt // 2))",
"+t = 1",
"+while t <= n:",
"+ t *= 2",
"+print((t // 2))"
] | false | 0.040169 | 0.044542 | 0.901822 | [
"s767867305",
"s844075392"
] |
u638795007 | p03464 | python | s831646122 | s097832120 | 227 | 92 | 59,628 | 15,016 | Accepted | Accepted | 59.47 | def examA():
N, A, B = LI()
if (A-B)%2==0:
ans = "Alice"
else:
ans = "Borys"
print(ans)
return
def examB():
K = I()
A = LI()
cur = 2
for i in range(K-1,-1,-1):
a = A[i]
if A[i]>cur:
print((-1))
exit()
... | def examA():
N = I()
A = LI()
if A[-1]!=2:
print((-1))
return
l = 2; r = 2
for a in A[::-1]:
ner = (r//a+1)*a-1
nel = ((l-1)//a+1)*a
r = ner; l = nel
if r<l:
print((-1))
return
print((l,r))
return
def e... | 47 | 58 | 1,115 | 1,168 | def examA():
N, A, B = LI()
if (A - B) % 2 == 0:
ans = "Alice"
else:
ans = "Borys"
print(ans)
return
def examB():
K = I()
A = LI()
cur = 2
for i in range(K - 1, -1, -1):
a = A[i]
if A[i] > cur:
print((-1))
exit()
cur =... | def examA():
N = I()
A = LI()
if A[-1] != 2:
print((-1))
return
l = 2
r = 2
for a in A[::-1]:
ner = (r // a + 1) * a - 1
nel = ((l - 1) // a + 1) * a
r = ner
l = nel
if r < l:
print((-1))
return
print((l, r))
... | false | 18.965517 | [
"- N, A, B = LI()",
"- if (A - B) % 2 == 0:",
"- ans = \"Alice\"",
"- else:",
"- ans = \"Borys\"",
"+ N = I()",
"+ A = LI()",
"+ if A[-1] != 2:",
"+ print((-1))",
"+ return",
"+ l = 2",
"+ r = 2",
"+ for a in A[::-1]:",
"+ ner =... | false | 0.081171 | 0.037503 | 2.164408 | [
"s831646122",
"s097832120"
] |
u072053884 | p02467 | python | s213883341 | s669862116 | 30 | 20 | 7,764 | 7,760 | Accepted | Accepted | 33.33 | def is_prime(x):
if x == 1:
return False
elif x == 2:
return True
elif x % 2 == 0:
return False
l = x ** 0.5
n = 3
while n <= l:
if x % n == 0:
return False
n += 2
return True
def solve():
n = int(input())
print("... | def is_prime(x):
# Perform prime number discrimination for odd numbers of 3 or more.
return pow(2, x - 1, x) == 1
def solve():
n = int(input())
print("{}: ".format(n), end='')
if is_prime(n):
print(n)
else:
ans = []
while n % 2 == 0:
n //= 2
... | 38 | 26 | 692 | 618 | def is_prime(x):
if x == 1:
return False
elif x == 2:
return True
elif x % 2 == 0:
return False
l = x**0.5
n = 3
while n <= l:
if x % n == 0:
return False
n += 2
return True
def solve():
n = int(input())
print("{}: ".format(n), en... | def is_prime(x):
# Perform prime number discrimination for odd numbers of 3 or more.
return pow(2, x - 1, x) == 1
def solve():
n = int(input())
print("{}: ".format(n), end="")
if is_prime(n):
print(n)
else:
ans = []
while n % 2 == 0:
n //= 2
ans.... | false | 31.578947 | [
"- if x == 1:",
"- return False",
"- elif x == 2:",
"- return True",
"- elif x % 2 == 0:",
"- return False",
"- l = x**0.5",
"- n = 3",
"- while n <= l:",
"- if x % n == 0:",
"- return False",
"- n += 2",
"- return True",
"... | false | 0.051745 | 0.046516 | 1.112403 | [
"s213883341",
"s669862116"
] |
u102461423 | p02624 | python | s496416858 | s819915157 | 604 | 531 | 109,164 | 106,264 | Accepted | Accepted | 12.09 | import sys
import numba
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@numba.njit
def main(N):
x = 0
for a in range(1, N+1):
for b in range(1, N//a+1):
x += a*b
return x
N = int(read())
print((main(N)))
| import sys
import numba
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@numba.njit('(i8,)', cache=True)
def main(N):
x = 0
for a in range(1, N+1):
for b in range(1, N//a+1):
x += a*b
return x
N = int(read())
pri... | 17 | 17 | 311 | 332 | import sys
import numba
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@numba.njit
def main(N):
x = 0
for a in range(1, N + 1):
for b in range(1, N // a + 1):
x += a * b
return x
N = int(read())
print((main(N)))
| import sys
import numba
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@numba.njit("(i8,)", cache=True)
def main(N):
x = 0
for a in range(1, N + 1):
for b in range(1, N // a + 1):
x += a * b
return x
N = int(read())
print((ma... | false | 0 | [
"-@numba.njit",
"+@numba.njit(\"(i8,)\", cache=True)"
] | false | 0.042051 | 0.040625 | 1.035105 | [
"s496416858",
"s819915157"
] |
u947883560 | p03108 | python | s675354105 | s178237569 | 772 | 611 | 29,364 | 29,336 | Accepted | Accepted | 20.85 | N, M = [int(x) for x in input().split()]
bridge = [[int(x) for x in input().split()] for x in range(M)]
par = [int(x) for x in range(N+1)] # 所属グループ
gn = [1 for _ in range(N+1)]
def group(i):
if par[i] == i:
return i
else:
return group(par[i])
def group_num(i): #... | N, M = [int(x) for x in input().split()]
bridge = [[int(x) for x in input().split()] for x in range(M)]
par = [int(x) for x in range(N+1)] # 所属グループ
gn = [1 for _ in range(N+1)] # 各グループサイズ
def group(i):
if par[i] == i:
return i
else:
par[i] = group(par[i])
return pa... | 46 | 35 | 1,010 | 798 | N, M = [int(x) for x in input().split()]
bridge = [[int(x) for x in input().split()] for x in range(M)]
par = [int(x) for x in range(N + 1)] # 所属グループ
gn = [1 for _ in range(N + 1)]
def group(i):
if par[i] == i:
return i
else:
return group(par[i])
def group_num(i): # order(NlogN)?
count... | N, M = [int(x) for x in input().split()]
bridge = [[int(x) for x in input().split()] for x in range(M)]
par = [int(x) for x in range(N + 1)] # 所属グループ
gn = [1 for _ in range(N + 1)] # 各グループサイズ
def group(i):
if par[i] == i:
return i
else:
par[i] = group(par[i])
return par[i]
ans = [i... | false | 23.913043 | [
"-gn = [1 for _ in range(N + 1)]",
"+gn = [1 for _ in range(N + 1)] # 各グループサイズ",
"- return group(par[i])",
"-",
"-",
"-def group_num(i): # order(NlogN)?",
"- counter = 0",
"- for j in range(N + 1):",
"- if group(j) == i:",
"- counter += 1",
"- return counter",... | false | 0.046751 | 0.037652 | 1.241659 | [
"s675354105",
"s178237569"
] |
u037430802 | p03329 | python | s542040330 | s280930574 | 1,888 | 844 | 3,188 | 3,188 | Accepted | Accepted | 55.3 | l9 = []
l9.append(1)
tmp = 1
while tmp <= 10**5:
tmp *= 9
l9.append(tmp)
l6 = []
l6.append(1)
tmp = 1
while tmp <= 10**5:
tmp *= 6
l6.append(tmp)
import bisect
n = int(eval(input()))
ans = 10**6
for i in range(0, n+1):
a = i
b = n - i
p = 0
while a > 0:
idx = bisect.bi... | import bisect
N = int(eval(input()))
ans = N
sixs = [1]
i = 6
while i <= N:
sixs.append(i)
i *= 6
nines = [1]
i = 9
while i <= N:
nines.append(i)
i *= 9
for i in range(N+1):
#iの分だけ6**xで構成
cnt = 0
a = i
b = N-i
while a > 0:
idx = bisect.bisect_right(sixs... | 43 | 33 | 615 | 587 | l9 = []
l9.append(1)
tmp = 1
while tmp <= 10**5:
tmp *= 9
l9.append(tmp)
l6 = []
l6.append(1)
tmp = 1
while tmp <= 10**5:
tmp *= 6
l6.append(tmp)
import bisect
n = int(eval(input()))
ans = 10**6
for i in range(0, n + 1):
a = i
b = n - i
p = 0
while a > 0:
idx = bisect.bisect_lef... | import bisect
N = int(eval(input()))
ans = N
sixs = [1]
i = 6
while i <= N:
sixs.append(i)
i *= 6
nines = [1]
i = 9
while i <= N:
nines.append(i)
i *= 9
for i in range(N + 1):
# iの分だけ6**xで構成
cnt = 0
a = i
b = N - i
while a > 0:
idx = bisect.bisect_right(sixs, a)
cnt ... | false | 23.255814 | [
"-l9 = []",
"-l9.append(1)",
"-tmp = 1",
"-while tmp <= 10**5:",
"- tmp *= 9",
"- l9.append(tmp)",
"-l6 = []",
"-l6.append(1)",
"-tmp = 1",
"-while tmp <= 10**5:",
"- tmp *= 6",
"- l6.append(tmp)",
"-n = int(eval(input()))",
"-ans = 10**6",
"-for i in range(0, n + 1):",
"+N... | false | 0.261943 | 0.302807 | 0.865048 | [
"s542040330",
"s280930574"
] |
u067975558 | p02412 | python | s833691454 | s772141597 | 620 | 560 | 6,724 | 6,720 | Accepted | Accepted | 9.68 | while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0: break
count = 0
for i in range(1,n - 1):
for j in range(i + 1 ,n):
for k in range(j + 1 ,n + 1):
if i + j + k == x: count += 1
print(count) | while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0: break
count = 0
for i in range(1,n - 1):
for j in range(i + 1 ,n):
for k in range(j + 1 ,n + 1):
if i + j + k == x:
count += 1
break
print(co... | 9 | 11 | 274 | 324 | while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0:
break
count = 0
for i in range(1, n - 1):
for j in range(i + 1, n):
for k in range(j + 1, n + 1):
if i + j + k == x:
count += 1
print(count)
| while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0:
break
count = 0
for i in range(1, n - 1):
for j in range(i + 1, n):
for k in range(j + 1, n + 1):
if i + j + k == x:
count += 1
break
print(count... | false | 18.181818 | [
"+ break"
] | false | 0.050883 | 0.049654 | 1.024745 | [
"s833691454",
"s772141597"
] |
u757117214 | p02983 | python | s035510975 | s464232774 | 1,221 | 880 | 2,940 | 3,060 | Accepted | Accepted | 27.93 | L,R=list(map(int,input().split()))
_min=2018
if L==0:
_min=0
else:
for l in range(L,L+2019):
if l>R:
break
for r in range(l+1,l+2020):
if r>R:
break
m=(l*r)%2019
if _min>m:
_min=m
print(_min)
| L,R=list(map(int,input().split()))
_min=2018
if L==0:
_min=0
elif R-L>=2019:
_min=0
else:
for l in range(L,R):
for r in range(L+1,R+1):
mm=(l*r)%2019
if mm==0:
_min=0
break
elif _min>mm:
_min=mm
print(_min)
| 16 | 17 | 260 | 274 | L, R = list(map(int, input().split()))
_min = 2018
if L == 0:
_min = 0
else:
for l in range(L, L + 2019):
if l > R:
break
for r in range(l + 1, l + 2020):
if r > R:
break
m = (l * r) % 2019
if _min > m:
_min = m
prin... | L, R = list(map(int, input().split()))
_min = 2018
if L == 0:
_min = 0
elif R - L >= 2019:
_min = 0
else:
for l in range(L, R):
for r in range(L + 1, R + 1):
mm = (l * r) % 2019
if mm == 0:
_min = 0
break
elif _min > mm:
... | false | 5.882353 | [
"+elif R - L >= 2019:",
"+ _min = 0",
"- for l in range(L, L + 2019):",
"- if l > R:",
"- break",
"- for r in range(l + 1, l + 2020):",
"- if r > R:",
"+ for l in range(L, R):",
"+ for r in range(L + 1, R + 1):",
"+ mm = (l * r) % 2019... | false | 0.111357 | 0.053075 | 2.098107 | [
"s035510975",
"s464232774"
] |
u912237403 | p02412 | python | s937383748 | s488068792 | 270 | 210 | 4,228 | 4,228 | Accepted | Accepted | 22.22 | while True:
n,x = list(map(int, input().split()))
if n == 0 and x == 0: break
c = 0
for i in range(1, min(n-1,x/3)):
for j in range(i+1, min(n,x/2)):
for k in range(j+1, n+1):
ijk = i + j + k
if ijk == x:
c += 1
... | def count(n, x):
c = 0
for i in range(1, n-1):
for j in range(i+1, n,):
for k in range(j+1, n+1):
s = i + j + k
if s == x:
c += 1
break
elif s > x: break
return c
while True:
p = lis... | 13 | 16 | 387 | 394 | while True:
n, x = list(map(int, input().split()))
if n == 0 and x == 0:
break
c = 0
for i in range(1, min(n - 1, x / 3)):
for j in range(i + 1, min(n, x / 2)):
for k in range(j + 1, n + 1):
ijk = i + j + k
if ijk == x:
c +=... | def count(n, x):
c = 0
for i in range(1, n - 1):
for j in range(
i + 1,
n,
):
for k in range(j + 1, n + 1):
s = i + j + k
if s == x:
c += 1
break
elif s > x:
... | false | 18.75 | [
"-while True:",
"- n, x = list(map(int, input().split()))",
"- if n == 0 and x == 0:",
"- break",
"+def count(n, x):",
"- for i in range(1, min(n - 1, x / 3)):",
"- for j in range(i + 1, min(n, x / 2)):",
"+ for i in range(1, n - 1):",
"+ for j in range(",
"+ ... | false | 0.078776 | 0.103287 | 0.762687 | [
"s937383748",
"s488068792"
] |
u852690916 | p03634 | python | s408971132 | s952112398 | 968 | 568 | 62,824 | 72,660 | Accepted | Accepted | 41.32 | N=int(eval(input()))
E=[[] for _ in range(N+1)]
for _ in range(N-1):
a,b,c=list(map(int,input().split()))
E[a].append((b,c))
E[b].append((a,c))
Q,K=list(map(int,input().split()))
qs=[tuple(map(int,input().split())) for _ in range(Q)]
#DFS
stack=[(K,0)]
dist=[0]*(N+1)
dist[K]=0
while stack:... | import sys
def main():
input = sys.stdin.readline
N = int(eval(input()))
G=[[] for _ in range(N)]
for _ in range(N-1):
a,b,c=list(map(int, input().split()))
a,b=a-1,b-1
G[a].append((b,c))
G[b].append((a,c))
Q,K=list(map(int, input().split()))
K-=1
... | 25 | 30 | 499 | 698 | N = int(eval(input()))
E = [[] for _ in range(N + 1)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
E[a].append((b, c))
E[b].append((a, c))
Q, K = list(map(int, input().split()))
qs = [tuple(map(int, input().split())) for _ in range(Q)]
# DFS
stack = [(K, 0)]
dist = [0] * (N + 1)
dist[K] ... | import sys
def main():
input = sys.stdin.readline
N = int(eval(input()))
G = [[] for _ in range(N)]
for _ in range(N - 1):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
G[a].append((b, c))
G[b].append((a, c))
Q, K = list(map(int, input().split()))
... | false | 16.666667 | [
"-N = int(eval(input()))",
"-E = [[] for _ in range(N + 1)]",
"-for _ in range(N - 1):",
"- a, b, c = list(map(int, input().split()))",
"- E[a].append((b, c))",
"- E[b].append((a, c))",
"-Q, K = list(map(int, input().split()))",
"-qs = [tuple(map(int, input().split())) for _ in range(Q)]",
... | false | 0.041893 | 0.046444 | 0.902 | [
"s408971132",
"s952112398"
] |
u055941944 | p02947 | python | s459588414 | s164746240 | 918 | 795 | 20,588 | 19,808 | Accepted | Accepted | 13.4 | import collections
from math import ceil
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(eval(input()))
x = []
for i in range(n):
s = list(eval(input()))
s.sort()
z = (' '.join(map(str, s)))
x.append(z)
c = collections.C... | import collections
from math import factorial
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n =int(eval(input()))
s_lis = []
for i in range(n):
x = list(eval(input()))
x.sort()
n = ''.join(x)
s_lis.append(n)
z = collections.Co... | 22 | 22 | 408 | 410 | import collections
from math import ceil
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(eval(input()))
x = []
for i in range(n):
s = list(eval(input()))
s.sort()
z = " ".join(map(str, s))
x.append(z)
c = collections.Count... | import collections
from math import factorial
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(eval(input()))
s_lis = []
for i in range(n):
x = list(eval(input()))
x.sort()
n = "".join(x)
s_lis.append(n)
z = collections.Cou... | false | 0 | [
"-from math import ceil",
"+from math import factorial",
"-x = []",
"+s_lis = []",
"- s = list(eval(input()))",
"- s.sort()",
"- z = \" \".join(map(str, s))",
"- x.append(z)",
"-c = collections.Counter(x)",
"+ x = list(eval(input()))",
"+ x.sort()",
"+ n = \"\".join(x)",
... | false | 0.038172 | 0.054685 | 0.698033 | [
"s459588414",
"s164746240"
] |
u912237403 | p00040 | python | s933588050 | s231996323 | 40 | 30 | 4,420 | 4,424 | Accepted | Accepted | 25 | import string
A2Z="abcdefghijklmnopqrstuvwxyz"
def decode(msg,L):
t = string.maketrans(A2Z,L)
s = string.translate(msg,t)
return s
def affine(msg, a, b):
L = "".join([A2Z[(i*a+b)%26]for i in range(26)])
return decode(msg,L)
def rot(msg, a):
a = a % 26
L = "".join(A2Z[a:]+A2Z... | import string
A2Z="abcdefghijklmnopqrstuvwxyz"
R=list(range(26))
def decode(msg,L):
x=""
for c in msg: x+=(L[A2Z.index(c)] if "a"<=c<="z" else c)
return x
def affine(msg, a, b):
L="".join([A2Z[(i*a+b)%26]for i in R])
s = decode(msg,L)
return s
def rot(msg, a):
a = a % 26
... | 36 | 40 | 789 | 814 | import string
A2Z = "abcdefghijklmnopqrstuvwxyz"
def decode(msg, L):
t = string.maketrans(A2Z, L)
s = string.translate(msg, t)
return s
def affine(msg, a, b):
L = "".join([A2Z[(i * a + b) % 26] for i in range(26)])
return decode(msg, L)
def rot(msg, a):
a = a % 26
L = "".join(A2Z[a:] ... | import string
A2Z = "abcdefghijklmnopqrstuvwxyz"
R = list(range(26))
def decode(msg, L):
x = ""
for c in msg:
x += L[A2Z.index(c)] if "a" <= c <= "z" else c
return x
def affine(msg, a, b):
L = "".join([A2Z[(i * a + b) % 26] for i in R])
s = decode(msg, L)
return s
def rot(msg, a):... | false | 10 | [
"+R = list(range(26))",
"- t = string.maketrans(A2Z, L)",
"- s = string.translate(msg, t)",
"- return s",
"+ x = \"\"",
"+ for c in msg:",
"+ x += L[A2Z.index(c)] if \"a\" <= c <= \"z\" else c",
"+ return x",
"- L = \"\".join([A2Z[(i * a + b) % 26] for i in range(26)])",
... | false | 0.00863 | 0.051603 | 0.167238 | [
"s933588050",
"s231996323"
] |
u391589398 | p02862 | python | s025492264 | s169367094 | 705 | 136 | 43,760 | 29,300 | Accepted | Accepted | 80.71 | X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
print((0))
else:
n2x = (2*X - Y) // 3
n1x = (2*Y - X) // 3
n = n2x + n1x
# nCn2xを求める
def combs(n,n2x):
invs = [1] * (n+1)
nfac = 1
for i in range(1, n+1):
... | X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0 or X > 2*Y or Y > 2*X:
print((0))
else:
n2x = (2*X - Y) // 3
n1x = (2*Y - X) // 3
n = n2x + n1x
# nCn2xを求める
def combs(n,n2x,mod):
facs = [1] * (n+1)
# invs = [1] * (n+1)
nfac = 1
... | 20 | 22 | 470 | 574 | X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0 or X > 2 * Y or Y > 2 * X:
print((0))
else:
n2x = (2 * X - Y) // 3
n1x = (2 * Y - X) // 3
n = n2x + n1x
# nCn2xを求める
def combs(n, n2x):
invs = [1] * (n + 1)
nfac = 1
for i in range(1, n + 1):
... | X, Y = list(map(int, input().split()))
mod = 10**9 + 7
if (X + Y) % 3 != 0 or X > 2 * Y or Y > 2 * X:
print((0))
else:
n2x = (2 * X - Y) // 3
n1x = (2 * Y - X) // 3
n = n2x + n1x
# nCn2xを求める
def combs(n, n2x, mod):
facs = [1] * (n + 1)
# invs = [1] * (n+1)
nfac = 1
... | false | 9.090909 | [
"- def combs(n, n2x):",
"- invs = [1] * (n + 1)",
"+ def combs(n, n2x, mod):",
"+ facs = [1] * (n + 1)",
"+ # invs = [1] * (n+1)",
"- invs[i] = pow(nfac, mod - 2, mod)",
"- return nfac * invs[n2x] * invs[n - n2x] % mod",
"+ facs[i] = nfac",
"+ ... | false | 0.857725 | 0.065999 | 12.99594 | [
"s025492264",
"s169367094"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.