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
u352394527
p00097
python
s677046026
s249586043
420
300
5,732
5,716
Accepted
Accepted
28.57
""" now...今注目する値 used...使った数字の数 sum...それまでの合計 dp[now][used][sum]...nowまででused個の数字を使って合計sumの場合の数 dp[now][used][sum] = dp[now - 1][used - 1][sum - now] + dp[now - 1][used][sum] (used >= 1 and sum >= now) dp[now - 1][used][sum] (used == 0 or sum < now) ...
dp = [[0 for _ in range(1001)] for _ in range(10)] dp[1][0] = dp[0][0] = 1 for now in range(1, 101): for used in range(9, 0, -1): dpu = dp[used] dpu_1 = dp[used - 1] for s in range(now, 1001): dpu[s] = dpu_1[s - now] + dpu[s] while True: n, s = list(map(int, input().split())) if no...
34
15
819
349
""" now...今注目する値 used...使った数字の数 sum...それまでの合計 dp[now][used][sum]...nowまででused個の数字を使って合計sumの場合の数 dp[now][used][sum] = dp[now - 1][used - 1][sum - now] + dp[now - 1][used][sum] (used >= 1 and sum >= now) dp[now - 1][used][sum] (used == 0 or sum < now) 2次元化 dp[used...
dp = [[0 for _ in range(1001)] for _ in range(10)] dp[1][0] = dp[0][0] = 1 for now in range(1, 101): for used in range(9, 0, -1): dpu = dp[used] dpu_1 = dp[used - 1] for s in range(now, 1001): dpu[s] = dpu_1[s - now] + dpu[s] while True: n, s = list(map(int, input().split()))...
false
55.882353
[ "-\"\"\"", "-now...今注目する値", "-used...使った数字の数", "-sum...それまでの合計", "-dp[now][used][sum]...nowまででused個の数字を使って合計sumの場合の数", "-dp[now][used][sum] = dp[now - 1][used - 1][sum - now] + dp[now - 1][used][sum] (used >= 1 and sum >= now)", "- dp[now - 1][used][sum] ...
false
0.828647
0.400733
2.067829
[ "s677046026", "s249586043" ]
u796942881
p03290
python
s183573916
s545505613
20
18
3,188
3,064
Accepted
Accepted
10
def main(): D, G, *pc = list(map(int, open(0).read().split())) p = pc[::2] c = pc[1::2] # コンプリート comp = [c[i] + 100 * (i + 1) * p[i] for i in range(D)] def dfs(G, i): # G 総合スコア # i 問題 1-based indexing if i <= 0: # 目標の 総合スコア に到達しなかった re...
def main(): D, G, *pc = list(map(int, open(0).read().split())) p = pc[::2] c = pc[1::2] # コンプリート comp = [c[i] + 100 * (i + 1) * p[i] for i in range(D)] def dfs(G, i): # G 総合スコア # i 問題 1-based indexing if i <= 0: # 目標の 総合スコア に到達しなかった re...
30
28
735
691
def main(): D, G, *pc = list(map(int, open(0).read().split())) p = pc[::2] c = pc[1::2] # コンプリート comp = [c[i] + 100 * (i + 1) * p[i] for i in range(D)] def dfs(G, i): # G 総合スコア # i 問題 1-based indexing if i <= 0: # 目標の 総合スコア に到達しなかった return 1e9 + 7...
def main(): D, G, *pc = list(map(int, open(0).read().split())) p = pc[::2] c = pc[1::2] # コンプリート comp = [c[i] + 100 * (i + 1) * p[i] for i in range(D)] def dfs(G, i): # G 総合スコア # i 問題 1-based indexing if i <= 0: # 目標の 総合スコア に到達しなかった return 1e9 + 7...
false
6.666667
[ "- num = 0", "- if G // (100 * i) < p[i - 1]:", "+ num = min(G // (100 * i), p[i - 1])", "+ if num == p[i - 1]:", "+ # コンプリートする", "+ score = comp[i - 1]", "+ else:", "- num = G // (100 * i)", "- else:", "- # コンプリ...
false
0.088256
0.09051
0.975099
[ "s183573916", "s545505613" ]
u312025627
p03221
python
s396881077
s328281714
1,037
622
69,608
129,752
Accepted
Accepted
40.02
n, m = (int(i) for i in input().split()) py = [[int(i) for i in input().split()] for j in range(m)] pre = {} for i in range(m): cur_p = py[i][0] cur_p_cities = pre.get(cur_p,[]) cur_p_cities.append(i) pre[cur_p] = cur_p_cities for i in list(pre.keys()): pre[i].sort(key=lambda x:py[x][1]) ...
def main(): N, M = (int(i) for i in input().split()) PY = [([int(i) for i in input().split()], j) for j in range(M)] dic = {i: [] for i in range(N)} # 県iの市を生まれた順に持つ A = sorted(PY, key=lambda p: p[0][1]) for py, i in A: dic[py[0]-1].append(i) ans = [] for p in range(N): # ...
23
22
609
670
n, m = (int(i) for i in input().split()) py = [[int(i) for i in input().split()] for j in range(m)] pre = {} for i in range(m): cur_p = py[i][0] cur_p_cities = pre.get(cur_p, []) cur_p_cities.append(i) pre[cur_p] = cur_p_cities for i in list(pre.keys()): pre[i].sort(key=lambda x: py[x][1]) city_...
def main(): N, M = (int(i) for i in input().split()) PY = [([int(i) for i in input().split()], j) for j in range(M)] dic = {i: [] for i in range(N)} # 県iの市を生まれた順に持つ A = sorted(PY, key=lambda p: p[0][1]) for py, i in A: dic[py[0] - 1].append(i) ans = [] for p in range(N): # 県ごとに番号を振...
false
4.347826
[ "-n, m = (int(i) for i in input().split())", "-py = [[int(i) for i in input().split()] for j in range(m)]", "-pre = {}", "-for i in range(m):", "- cur_p = py[i][0]", "- cur_p_cities = pre.get(cur_p, [])", "- cur_p_cities.append(i)", "- pre[cur_p] = cur_p_cities", "-for i in list(pre.keys...
false
0.046917
0.038921
1.205449
[ "s396881077", "s328281714" ]
u324314500
p03031
python
s196830917
s011702454
373
212
44,636
43,228
Accepted
Accepted
43.16
import sys #import numpy as np s2nn = lambda s: [int(c) for c in s.split(' ')] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for ...
import sys from collections import deque # 双方向キュー from collections import defaultdict # 初期化済み辞書 from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー from bisect import bisect_left, bisect_right # 二分探索 #import numpy as np # 1.8.2 #import scipy # 0.13.3 #sys.setrecursionlimit(int(1e+6)) s2...
76
48
1,928
1,349
import sys # import numpy as np s2nn = lambda s: [int(c) for c in s.split(" ")] ss2nn = lambda ss: [int(s) for s in ss] ss2nnn = lambda ss: [s2nn(s) for s in ss] i2s = lambda: sys.stdin.readline().rstrip() i2n = lambda: int(i2s()) i2nn = lambda: s2nn(i2s()) ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in ran...
import sys from collections import deque # 双方向キュー from collections import defaultdict # 初期化済み辞書 from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー from bisect import bisect_left, bisect_right # 二分探索 # import numpy as np # 1.8.2 # import scipy # 0.13.3 # sys.setrecursionlimit(int(1e+6)) s2nn =...
false
36.842105
[ "+from collections import deque # 双方向キュー", "+from collections import defaultdict # 初期化済み辞書", "+from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー", "+from bisect import bisect_left, bisect_right # 二分探索", "-# import numpy as np", "+# import numpy as np # 1.8.2", "+# import scipy ...
false
0.080685
0.038246
2.109609
[ "s196830917", "s011702454" ]
u195054737
p03160
python
s323365117
s776824873
337
196
23,996
13,800
Accepted
Accepted
41.84
import sys import itertools from operator import itemgetter #sortedの対象を決めたい from fractions import gcd #最大公約数 from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根 from copy import deepcopy #参照で影響されないコピー from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型 import heapq import numpy as np from f...
n = int(eval(input())) h = [int(i) for i in input().split()] dp = [1e9] * n dp[0] = 0 for i in range(1,n): dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1])) if i > 1: dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2])) print((dp[-1]))
30
13
717
254
import sys import itertools from operator import itemgetter # sortedの対象を決めたい from fractions import gcd # 最大公約数 from math import ceil, floor, sqrt, isinf # 小数点切り上げ、切り捨て、平方根 from copy import deepcopy # 参照で影響されないコピー from collections import Counter, deque # 要素ごとの出現回数、双方向アクセス可能データ型 import heapq import numpy as np from ...
n = int(eval(input())) h = [int(i) for i in input().split()] dp = [1e9] * n dp[0] = 0 for i in range(1, n): dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) if i > 1: dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[-1]))
false
56.666667
[ "-import sys", "-import itertools", "-from operator import itemgetter # sortedの対象を決めたい", "-from fractions import gcd # 最大公約数", "-from math import ceil, floor, sqrt, isinf # 小数点切り上げ、切り捨て、平方根", "-from copy import deepcopy # 参照で影響されないコピー", "-from collections import Counter, deque # 要素ごとの出現回数、双方向アクセス可能...
false
0.046695
0.036803
1.268765
[ "s323365117", "s776824873" ]
u077291787
p02579
python
s498106478
s004106897
560
434
219,780
220,656
Accepted
Accepted
22.5
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"] def __init__( self, height: int, width: int, start: Tuple[int, int], ...
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"] def __init__( self, height: int, width: int, start: Tuple[int, int], ...
90
93
2,878
3,049
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"] def __init__( self, height: int, width: int, start: Tuple[int, int], goal: Tuple[in...
# D - Wizard in Maze import sys from collections import deque from typing import List, Tuple class WarpableMaze: __slots__ = ["height", "width", "start", "goal", "road", "wall", "grid"] def __init__( self, height: int, width: int, start: Tuple[int, int], goal: Tuple[in...
false
3.225806
[ "+ def _flatten_dxy(self, x: int, y: int) -> int:", "+ return self.width * x + y", "+", "- return self.width * (h + 2) + w + 2", "+ return self._flatten_dxy(h + 2, w + 2)", "- move = (-w, w, -1, 1)", "- warp = [-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -2 * w + 2]...
false
0.056875
0.059895
0.949575
[ "s498106478", "s004106897" ]
u021019433
p02939
python
s987202351
s261728571
54
48
3,624
3,500
Accepted
Accepted
11.11
r = 0 p = None f = False for c in eval(input()): if f: f = False r += 1 elif c == p: f, p = True, None else: r += 1 p = c print(r)
r = 0 f, p = False, None for c in eval(input()): if f: f, p = False, None r += 1 elif c == p: f = True else: r += 1 p = c print(r)
13
12
189
188
r = 0 p = None f = False for c in eval(input()): if f: f = False r += 1 elif c == p: f, p = True, None else: r += 1 p = c print(r)
r = 0 f, p = False, None for c in eval(input()): if f: f, p = False, None r += 1 elif c == p: f = True else: r += 1 p = c print(r)
false
7.692308
[ "-p = None", "-f = False", "+f, p = False, None", "- f = False", "+ f, p = False, None", "- f, p = True, None", "+ f = True" ]
false
0.039736
0.048789
0.814442
[ "s987202351", "s261728571" ]
u111365362
p03739
python
s263167562
s646304238
146
120
14,468
14,468
Accepted
Accepted
17.81
n = int(eval(input())) a = list(map(int,input().split())) sun = 0 ans1 = 0 for i in range(n): if i == 0: SUN = 1 else: SUN = sun now = a[i] if SUN * (sun+now) >= 0: ans1 += abs(sun+now) + 1 if SUN > 0: sun = -1 else: sun = 1 else: sun += now sun = 0 ans2 ...
n = int(eval(input())) a = list(map(int,input().split())) can = [] ans = 0 now = 0 for i in range(n): now += a[i] if i % 2 == 0: if now <= 0: ans += 1 - now now = 1 else: if now >= 0: ans += 1 + now now = -1 can.append(ans) ans = 0 now = 0 for i in range(n): no...
36
30
587
495
n = int(eval(input())) a = list(map(int, input().split())) sun = 0 ans1 = 0 for i in range(n): if i == 0: SUN = 1 else: SUN = sun now = a[i] if SUN * (sun + now) >= 0: ans1 += abs(sun + now) + 1 if SUN > 0: sun = -1 else: sun = 1 else: ...
n = int(eval(input())) a = list(map(int, input().split())) can = [] ans = 0 now = 0 for i in range(n): now += a[i] if i % 2 == 0: if now <= 0: ans += 1 - now now = 1 else: if now >= 0: ans += 1 + now now = -1 can.append(ans) ans = 0 now = 0 for...
false
16.666667
[ "-sun = 0", "-ans1 = 0", "+can = []", "+ans = 0", "+now = 0", "- if i == 0:", "- SUN = 1", "+ now += a[i]", "+ if i % 2 == 0:", "+ if now <= 0:", "+ ans += 1 - now", "+ now = 1", "- SUN = sun", "- now = a[i]", "- if SUN * (sun + n...
false
0.039087
0.121659
0.321286
[ "s263167562", "s646304238" ]
u285681431
p02837
python
s077521718
s951752868
933
120
9,236
80,688
Accepted
Accepted
87.14
N = int(eval(input())) # [[1番の人の証言], [2番の人の証言], ..., [N番の人の証言]] l = [[-1 for i in range(N)] for j in range(N)] # N人についてそれぞれ証言をまとめる for i in range(N): # 証言の数 a = int(eval(input())) # 各証言をlに格納 for _ in range(a): x, y = list(map(int, input().split())) l[i][x - 1] = y ans = 0 ...
import itertools N = int(eval(input())) # [[1番の人の証言], [2番の人の証言], ..., [N番の人の証言]] l = [[-1 for _ in range(N)] for _ in range(N)] # N人についてそれぞれ証言をまとめる for i in range(N): # 証言の数 a = int(eval(input())) # 各証言をlに格納 for _ in range(a): x, y = list(map(int, input().split())) l[i][x - ...
52
42
1,243
1,015
N = int(eval(input())) # [[1番の人の証言], [2番の人の証言], ..., [N番の人の証言]] l = [[-1 for i in range(N)] for j in range(N)] # N人についてそれぞれ証言をまとめる for i in range(N): # 証言の数 a = int(eval(input())) # 各証言をlに格納 for _ in range(a): x, y = list(map(int, input().split())) l[i][x - 1] = y ans = 0 # bit全探索 # N人につ...
import itertools N = int(eval(input())) # [[1番の人の証言], [2番の人の証言], ..., [N番の人の証言]] l = [[-1 for _ in range(N)] for _ in range(N)] # N人についてそれぞれ証言をまとめる for i in range(N): # 証言の数 a = int(eval(input())) # 各証言をlに格納 for _ in range(a): x, y = list(map(int, input().split())) l[i][x - 1] = y ans =...
false
19.230769
[ "+import itertools", "+", "-l = [[-1 for i in range(N)] for j in range(N)]", "+l = [[-1 for _ in range(N)] for _ in range(N)]", "-# bit全探索", "-# N人について聖人/狂人の計2**N通り", "-for i in range(2**N):", "- # iをN桁2bitに変換, 1が聖人に対応", "- d = [0 for _ in range(N)]", "- # 下からj桁目のbitが立っているか否か", "+# 全通りを...
false
0.096374
0.037101
2.59762
[ "s077521718", "s951752868" ]
u312025627
p03137
python
s040128132
s350591212
399
226
72,616
56,488
Accepted
Accepted
43.36
def main(): N, M = (int(i) for i in input().split()) X = [int(i) for i in input().split()] if N >= M: print((0)) elif N < M: X.sort() diff = [[0,0] for _ in range(M-1)] for i in range(M-1): diff[i] = [X[i+1] - X[i],i] diff.sort(reverse=True...
def main(): N, M = (int(i) for i in input().split()) X = [int(i) for i in input().split()] if N >= M: print((0)) elif N < M: X.sort() diff = [0 for _ in range(M-1)] for i in range(M-1): diff[i] = X[i+1] - X[i] diff.sort(reverse=True) ...
23
18
618
467
def main(): N, M = (int(i) for i in input().split()) X = [int(i) for i in input().split()] if N >= M: print((0)) elif N < M: X.sort() diff = [[0, 0] for _ in range(M - 1)] for i in range(M - 1): diff[i] = [X[i + 1] - X[i], i] diff.sort(reverse=True) ...
def main(): N, M = (int(i) for i in input().split()) X = [int(i) for i in input().split()] if N >= M: print((0)) elif N < M: X.sort() diff = [0 for _ in range(M - 1)] for i in range(M - 1): diff[i] = X[i + 1] - X[i] diff.sort(reverse=True) ans ...
false
21.73913
[ "- diff = [[0, 0] for _ in range(M - 1)]", "+ diff = [0 for _ in range(M - 1)]", "- diff[i] = [X[i + 1] - X[i], i]", "+ diff[i] = X[i + 1] - X[i]", "- diff = diff[: N - 1]", "- diff.sort(key=lambda p: p[1])", "- ans = 0", "- cnt = 0", "...
false
0.043476
0.043278
1.004561
[ "s040128132", "s350591212" ]
u945181840
p03215
python
s069087925
s141550790
1,604
299
25,140
23,848
Accepted
Accepted
81.36
import sys from itertools import accumulate, combinations read = sys.stdin.read N, K, *a = list(map(int, read().split())) a = accumulate([0] + a) seq = [] for i, j in combinations(a, 2): seq.append(j - i) m = (10 ** 9 * 1000).bit_length() answer = 0 bit = 1 << (m - 1) for _ in range(m): tmp ...
import sys from itertools import accumulate, combinations read = sys.stdin.read N, K, *a = list(map(int, read().split())) a = accumulate([0] + a) seq = [] for i, j in combinations(a, 2): seq.append(j - i) m = (10 ** 9 * 1000).bit_length() answer = 0 bit = 1 << (m - 1) for _ in range(m): tmp ...
22
23
437
448
import sys from itertools import accumulate, combinations read = sys.stdin.read N, K, *a = list(map(int, read().split())) a = accumulate([0] + a) seq = [] for i, j in combinations(a, 2): seq.append(j - i) m = (10**9 * 1000).bit_length() answer = 0 bit = 1 << (m - 1) for _ in range(m): tmp = bit + answer if...
import sys from itertools import accumulate, combinations read = sys.stdin.read N, K, *a = list(map(int, read().split())) a = accumulate([0] + a) seq = [] for i, j in combinations(a, 2): seq.append(j - i) m = (10**9 * 1000).bit_length() answer = 0 bit = 1 << (m - 1) for _ in range(m): tmp = [i for i in seq if ...
false
4.347826
[ "- tmp = bit + answer", "- if len([i for i in seq if i & tmp == tmp]) >= K:", "- answer = tmp", "+ tmp = [i for i in seq if i & bit == bit]", "+ if len(tmp) >= K:", "+ answer += bit", "+ seq = tmp" ]
false
0.037062
0.03912
0.947407
[ "s069087925", "s141550790" ]
u010110540
p03813
python
s889352160
s835449629
24
17
3,064
2,940
Accepted
Accepted
29.17
x = int(eval(input())) if x < 1200: print('ABC') else: print('ARC')
x = int(eval(input())) print(('ABC' if x < 1200 else 'ARC'))
5
2
73
53
x = int(eval(input())) if x < 1200: print("ABC") else: print("ARC")
x = int(eval(input())) print(("ABC" if x < 1200 else "ARC"))
false
60
[ "-if x < 1200:", "- print(\"ABC\")", "-else:", "- print(\"ARC\")", "+print((\"ABC\" if x < 1200 else \"ARC\"))" ]
false
0.079499
0.053904
1.47483
[ "s889352160", "s835449629" ]
u837677955
p02768
python
s769511054
s299643760
834
143
12,588
3,064
Accepted
Accepted
82.85
n,a,b = list(map(int,input().split())) M = 10**9+7 # 2**n twon = pow(2,n,M) # nCr+1 = nCr * (n-r)/(r+1) # nCr = A(r)とおくと ※nは固定 # A(r+1) = A(r) * (n-r)/(r+1) # ここでmod M では、フェルマーの小定理より # 1/(r+1) === (r+1)**(M-2) ※===は合同記号の意味 # よって A(r+1) = A(r) * (n-r) * (r+1)**(M-2) L = [0] * (2*(10**5) + 1) L[0] = 1 f...
import time n,a,b = list(map(int,input().split())) start = time.time() # 時間計測開始 M = 10**9+7 # 2**n twon = pow(2,n,M) # nCr+1 = nCr * (n-r)/(r+1) # nCr = A(r)とおくと ※nは固定 # A(r+1) = A(r) * (n-r)/(r+1) # ここでmod M では、フェルマーの小定理より # 1/(r+1) === (r+1)**(M-2) ※===は合同記号の意味 # よって A(r+1) = A(r) * (n-r) * (r+...
26
45
478
823
n, a, b = list(map(int, input().split())) M = 10**9 + 7 # 2**n twon = pow(2, n, M) # nCr+1 = nCr * (n-r)/(r+1) # nCr = A(r)とおくと ※nは固定 # A(r+1) = A(r) * (n-r)/(r+1) # ここでmod M では、フェルマーの小定理より # 1/(r+1) === (r+1)**(M-2) ※===は合同記号の意味 # よって A(r+1) = A(r) * (n-r) * (r+1)**(M-2) L = [0] * (2 * (10**5) + 1) L[0] = 1 for i in r...
import time n, a, b = list(map(int, input().split())) start = time.time() # 時間計測開始 M = 10**9 + 7 # 2**n twon = pow(2, n, M) # nCr+1 = nCr * (n-r)/(r+1) # nCr = A(r)とおくと ※nは固定 # A(r+1) = A(r) * (n-r)/(r+1) # ここでmod M では、フェルマーの小定理より # 1/(r+1) === (r+1)**(M-2) ※===は合同記号の意味 # よって A(r+1) = A(r) * (n-r) * (r+1)**(M-2) # L ...
false
42.222222
[ "+import time", "+", "+start = time.time() # 時間計測開始", "-L = [0] * (2 * (10**5) + 1)", "-L[0] = 1", "-for i in range(len(L) - 1):", "- L[i + 1] = (L[i] * (n - i) * pow(i + 1, M - 2, M)) % M", "+# L = [0] * (2*(10**5) + 1)", "+# L[0] = 1", "+# for i in range(len(L)-1):", "+# L[i+1] = ( L[i...
false
3.508686
0.115297
30.431629
[ "s769511054", "s299643760" ]
u225388820
p02558
python
s047525832
s524691774
695
309
76,696
75,708
Accepted
Accepted
55.54
def main(): class UnionFind: def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. rank:ランク """ self.N = N self.root = [-1] * N self.rank =...
def main(): class UnionFind: def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. rank:ランク """ self.N = N self.root = [-1] * N self.rank =...
57
57
1,601
1,621
def main(): class UnionFind: def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. rank:ランク """ self.N = N self.root = [-1] * N self.rank = [0] * N ...
def main(): class UnionFind: def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. rank:ランク """ self.N = N self.root = [-1] * N self.rank = [0] * N ...
false
0
[ "- t, u, v = list(map(int, input().split()))", "+ t, u, v = list(map(int, sys.stdin.buffer.readline().split()))" ]
false
0.038616
0.064318
0.600391
[ "s047525832", "s524691774" ]
u375616706
p03212
python
s133498280
s721237591
82
56
3,060
3,060
Accepted
Accepted
31.71
n = (int)(eval(input())) def f(s): ans = 0 if (int)(s) > n: return 0 for c in '753': num = (str)(s+c) if (int)(num) <= n: if num.count('3')and num.count('5') and num.count('7'): ans += 1 ans += f(num) return ans print((f('0'))...
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N = int(eval(input())) ans = 0 def check(s: str)->bool: return '3' in s and '5' in s and '7' in s def dfs(s: str)->int: ret = 0 if int(s) > N: return 0 else: if ch...
14
31
314
483
n = (int)(eval(input())) def f(s): ans = 0 if (int)(s) > n: return 0 for c in "753": num = (str)(s + c) if (int)(num) <= n: if num.count("3") and num.count("5") and num.count("7"): ans += 1 ans += f(num) return ans print((f("0")))
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N = int(eval(input())) ans = 0 def check(s: str) -> bool: return "3" in s and "5" in s and "7" in s def dfs(s: str) -> int: ret = 0 if int(s) > N: return 0 else: if check(s): ...
false
54.83871
[ "-n = (int)(eval(input()))", "+# python template for atcoder1", "+import sys", "+", "+sys.setrecursionlimit(10**9)", "+input = sys.stdin.readline", "+N = int(eval(input()))", "+ans = 0", "-def f(s):", "- ans = 0", "- if (int)(s) > n:", "- return 0", "- for c in \"753\":", "...
false
0.114864
0.050759
2.262926
[ "s133498280", "s721237591" ]
u498487134
p02949
python
s688023475
s063781167
724
647
81,584
80,628
Accepted
Accepted
10.64
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 #0から他の頂点へ def BellmanFord(N, M, edges): #N頂点,M辺,edgesのリスト inf=10**20 ...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 #0から他の頂点へ def BellmanFord(N, M, edges): #N頂点,M辺,edgesのリスト inf=10**20 ...
86
95
1,814
2,018
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 # 0から他の頂点へ def BellmanFord(N, M, edges): # N頂点,M辺,edgesのリスト inf = 10**20...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 # 0から他の頂点へ def BellmanFord(N, M, edges): # N頂点,M辺,edgesのリスト inf = 10**20...
false
9.473684
[ "+ can = [0] * N", "+ for i in range(N):", "+ can[i] = to[i] and rto[i]", "+ newE = []", "+ for (a, b, c) in edges:", "+ if can[a] and can[b]:", "+ newE.append((a, b, c))", "- ans = BellmanFord(N, M, edges)", "+ ans = BellmanFord(N, M, newE)" ]
false
0.160526
0.045944
3.493925
[ "s688023475", "s063781167" ]
u310431893
p03229
python
s003863270
s553756188
1,929
246
11,100
9,312
Accepted
Accepted
87.25
N = int(eval(input())) A = [int(eval(input())) for i in range(N)] A_ = sorted(A) A_r = list(reversed(A_)) l = [] for i, (x, y) in enumerate(zip(A_[:N//2], A_r[:N//2])): if i % 2 == 0: l.append(x) l.insert(0, y) else: l.append(y) l.insert(0, x) if N % 2 != 0: ...
N = int(eval(input())) A = [int(eval(input())) for i in range(N)] A_ = sorted(A) A_r = list(reversed(A_)) n = (A_[0], A_r[0]) sum = abs(n[0] - n[1]) for i, (x, y) in enumerate(zip(A_[1:N//2], A_r[1:N//2])): sum += abs(n[0] - y) + abs(n[1] - x) n = (x, y) if N%2 != 0: m = A_[N//2] sum +=...
27
17
515
357
N = int(eval(input())) A = [int(eval(input())) for i in range(N)] A_ = sorted(A) A_r = list(reversed(A_)) l = [] for i, (x, y) in enumerate(zip(A_[: N // 2], A_r[: N // 2])): if i % 2 == 0: l.append(x) l.insert(0, y) else: l.append(y) l.insert(0, x) if N % 2 != 0: m = A_[N //...
N = int(eval(input())) A = [int(eval(input())) for i in range(N)] A_ = sorted(A) A_r = list(reversed(A_)) n = (A_[0], A_r[0]) sum = abs(n[0] - n[1]) for i, (x, y) in enumerate(zip(A_[1 : N // 2], A_r[1 : N // 2])): sum += abs(n[0] - y) + abs(n[1] - x) n = (x, y) if N % 2 != 0: m = A_[N // 2] sum += max(...
false
37.037037
[ "-l = []", "-for i, (x, y) in enumerate(zip(A_[: N // 2], A_r[: N // 2])):", "- if i % 2 == 0:", "- l.append(x)", "- l.insert(0, y)", "- else:", "- l.append(y)", "- l.insert(0, x)", "+n = (A_[0], A_r[0])", "+sum = abs(n[0] - n[1])", "+for i, (x, y) in enumerate(...
false
0.083725
0.044182
1.894974
[ "s003863270", "s553756188" ]
u159117533
p02792
python
s122529322
s153185574
521
253
3,064
3,060
Accepted
Accepted
51.44
N = int(eval(input())) mat = list() for i in range(10): mat.append([0] * 10) for i in range(N): A = int(str(i + 1)[0]) B = int(str(i + 1)[-1]) mat[A][B] += 1 ans = 0 for i in range(N): A = int(str(i + 1)[0]) B = int(str(i + 1)[-1]) ans += mat[B][A] print(ans)
N = int(eval(input())) mat = list() for i in range(10): mat.append([0] * 10) for i in range(N): A = int(str(i + 1)[0]) B = int(str(i + 1)[-1]) mat[A][B] += 1 ans = 0 for i in range(10): for j in range(10): ans += mat[i][j] * mat[j][i] print(ans)
15
14
297
282
N = int(eval(input())) mat = list() for i in range(10): mat.append([0] * 10) for i in range(N): A = int(str(i + 1)[0]) B = int(str(i + 1)[-1]) mat[A][B] += 1 ans = 0 for i in range(N): A = int(str(i + 1)[0]) B = int(str(i + 1)[-1]) ans += mat[B][A] print(ans)
N = int(eval(input())) mat = list() for i in range(10): mat.append([0] * 10) for i in range(N): A = int(str(i + 1)[0]) B = int(str(i + 1)[-1]) mat[A][B] += 1 ans = 0 for i in range(10): for j in range(10): ans += mat[i][j] * mat[j][i] print(ans)
false
6.666667
[ "-for i in range(N):", "- A = int(str(i + 1)[0])", "- B = int(str(i + 1)[-1])", "- ans += mat[B][A]", "+for i in range(10):", "+ for j in range(10):", "+ ans += mat[i][j] * mat[j][i]" ]
false
0.274304
0.07706
3.559616
[ "s122529322", "s153185574" ]
u775681539
p02936
python
s368011813
s418711873
1,809
1,655
53,040
135,444
Accepted
Accepted
8.51
#python3 from collections import deque def main(): n, q = map(int, input().split()) to = [[] for _ in range(n)] for _ in range(n-1): a, b = map(lambda x: int(x)-1, input().split()) to[a].append(b) to[b].append(a) node = [0 for _ in range(n)] for _ in range(q): ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from copy import deepcopy from collections import deque def main(): N, Q = map(int, readline().split()) m = map(int, read().split()) n = deepcopy(m) to = [[] for _ in range(N)] ...
32
34
790
949
# python3 from collections import deque def main(): n, q = map(int, input().split()) to = [[] for _ in range(n)] for _ in range(n - 1): a, b = map(lambda x: int(x) - 1, input().split()) to[a].append(b) to[b].append(a) node = [0 for _ in range(n)] for _ in range(q): ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from copy import deepcopy from collections import deque def main(): N, Q = map(int, readline().split()) m = map(int, read().split()) n = deepcopy(m) to = [[] for _ in range(N)] for ...
false
5.882353
[ "-# python3", "+import sys", "+", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+from copy import deepcopy", "- n, q = map(int, input().split())", "- to = [[] for _ in range(n)]", "- for _ in range(n - 1):", "- ...
false
0.070812
0.085293
0.83022
[ "s368011813", "s418711873" ]
u254871849
p03283
python
s078388111
s648105384
723
415
66,932
57,632
Accepted
Accepted
42.6
import sys import numpy as np I = np.array(sys.stdin.read().split(), dtype=np.int64) n, m, q = I[:3] l, r = I[3:3+m*2].reshape(-1, 2).T p, q = I[3+m*2:].reshape(-1, 2).T def main(): res = np.zeros((n+2, n+2), dtype=np.int64) np.add.at(res, (1, r), 1) res[1, n+1] += -1 * m np.add.at(res, ...
import sys *I, = map(int, sys.stdin.read().split()) n, m, Q = I[:3] lr = zip(*[iter(I[3:3+m*2])] * 2) pq = zip(*[iter(I[3+m*2:])] * 2) def main(): res = [[0] * (n + 2) for _ in range(n+2)] for l, r in lr: res[1][r] += 1 res[1][n+1] -= 1 res[l+1][r] -= 1 res[l...
24
30
550
656
import sys import numpy as np I = np.array(sys.stdin.read().split(), dtype=np.int64) n, m, q = I[:3] l, r = I[3 : 3 + m * 2].reshape(-1, 2).T p, q = I[3 + m * 2 :].reshape(-1, 2).T def main(): res = np.zeros((n + 2, n + 2), dtype=np.int64) np.add.at(res, (1, r), 1) res[1, n + 1] += -1 * m np.add.at(r...
import sys (*I,) = map(int, sys.stdin.read().split()) n, m, Q = I[:3] lr = zip(*[iter(I[3 : 3 + m * 2])] * 2) pq = zip(*[iter(I[3 + m * 2 :])] * 2) def main(): res = [[0] * (n + 2) for _ in range(n + 2)] for l, r in lr: res[1][r] += 1 res[1][n + 1] -= 1 res[l + 1][r] -= 1 res[...
false
20
[ "-import numpy as np", "-I = np.array(sys.stdin.read().split(), dtype=np.int64)", "-n, m, q = I[:3]", "-l, r = I[3 : 3 + m * 2].reshape(-1, 2).T", "-p, q = I[3 + m * 2 :].reshape(-1, 2).T", "+(*I,) = map(int, sys.stdin.read().split())", "+n, m, Q = I[:3]", "+lr = zip(*[iter(I[3 : 3 + m * 2])] * 2)", ...
false
0.284502
0.037927
7.501264
[ "s078388111", "s648105384" ]
u340781749
p03054
python
s567025957
s042271836
114
78
3,768
4,020
Accepted
Accepted
31.58
def check(dist, tak, aok, lim): for s, t in zip(ss, ts): if s == tak: if dist == 0: return True dist -= 1 if t == aok: if dist < lim: dist += 1 return False def solve(): if check(sr - 1, 'U', 'D', h - 1): ...
def solve(): lim_u = 0 lim_b = h lim_l = 0 lim_r = w for s, t in zip(ss[::-1], ts[::-1]): if t == 'U': if lim_b < h: lim_b += 1 elif t == 'D': if lim_u > 0: lim_u -= 1 elif t == 'L': if lim_r < w...
29
38
684
879
def check(dist, tak, aok, lim): for s, t in zip(ss, ts): if s == tak: if dist == 0: return True dist -= 1 if t == aok: if dist < lim: dist += 1 return False def solve(): if check(sr - 1, "U", "D", h - 1): return Tr...
def solve(): lim_u = 0 lim_b = h lim_l = 0 lim_r = w for s, t in zip(ss[::-1], ts[::-1]): if t == "U": if lim_b < h: lim_b += 1 elif t == "D": if lim_u > 0: lim_u -= 1 elif t == "L": if lim_r < w: ...
false
23.684211
[ "-def check(dist, tak, aok, lim):", "- for s, t in zip(ss, ts):", "- if s == tak:", "- if dist == 0:", "- return True", "- dist -= 1", "- if t == aok:", "- if dist < lim:", "- dist += 1", "- return False", "-", ...
false
0.03717
0.036952
1.005876
[ "s567025957", "s042271836" ]
u172748267
p02742
python
s387515231
s481071867
29
25
9,156
9,012
Accepted
Accepted
13.79
from math import ceil h,w=list(map(int,input().split())) ans=0 if h==1 or w==1: ans=1 elif (h*w)%2==0: ans=int(h*w//2) else: ans=ceil(h*w/2) print(ans)
from math import ceil h,w=list(map(int,input().split())) ans=0 if h==1 or w==1: ans=1 else: ans=ceil(h*w/2) print(ans)
10
8
166
127
from math import ceil h, w = list(map(int, input().split())) ans = 0 if h == 1 or w == 1: ans = 1 elif (h * w) % 2 == 0: ans = int(h * w // 2) else: ans = ceil(h * w / 2) print(ans)
from math import ceil h, w = list(map(int, input().split())) ans = 0 if h == 1 or w == 1: ans = 1 else: ans = ceil(h * w / 2) print(ans)
false
20
[ "-elif (h * w) % 2 == 0:", "- ans = int(h * w // 2)" ]
false
0.035897
0.037926
0.946506
[ "s387515231", "s481071867" ]
u413165887
p03427
python
s479123060
s416929393
65
26
61,260
8,948
Accepted
Accepted
60
a = list(eval(input())) if all(i=='9' for i in a[1:]): print((9*len(a)-9+int(a[0]))) elif len(a)==1: print((a[0])) else: print((max(int(a[0])-1, 0)+9*(len(a)-1)))
a = list(eval(input())) if all(i=='9' for i in a[1:]): print((9*len(a)-9+int(a[0]))) else: print((max(int(a[0])-1, 0)+9*(len(a)-1)))
7
5
168
134
a = list(eval(input())) if all(i == "9" for i in a[1:]): print((9 * len(a) - 9 + int(a[0]))) elif len(a) == 1: print((a[0])) else: print((max(int(a[0]) - 1, 0) + 9 * (len(a) - 1)))
a = list(eval(input())) if all(i == "9" for i in a[1:]): print((9 * len(a) - 9 + int(a[0]))) else: print((max(int(a[0]) - 1, 0) + 9 * (len(a) - 1)))
false
28.571429
[ "-elif len(a) == 1:", "- print((a[0]))" ]
false
0.047593
0.0473
1.006202
[ "s479123060", "s416929393" ]
u745561510
p03632
python
s423723611
s297082008
167
17
38,384
2,940
Accepted
Accepted
89.82
A, B, C, D = list(map(int, input().split())) Alice = set([]) Bob = set([]) for i in range(A, B + 1): Alice.add(i) for i in range(C, D + 1): Bob.add(i) ans = Alice & Bob ans = list(ans) if len(ans) == 0: print((0)) exit() print((ans[-1] - ans[0]))
A, B, C, D = list(map(int, input().split())) ans = min(D, B) - max(A, C) print((max(ans, 0)))
16
5
262
91
A, B, C, D = list(map(int, input().split())) Alice = set([]) Bob = set([]) for i in range(A, B + 1): Alice.add(i) for i in range(C, D + 1): Bob.add(i) ans = Alice & Bob ans = list(ans) if len(ans) == 0: print((0)) exit() print((ans[-1] - ans[0]))
A, B, C, D = list(map(int, input().split())) ans = min(D, B) - max(A, C) print((max(ans, 0)))
false
68.75
[ "-Alice = set([])", "-Bob = set([])", "-for i in range(A, B + 1):", "- Alice.add(i)", "-for i in range(C, D + 1):", "- Bob.add(i)", "-ans = Alice & Bob", "-ans = list(ans)", "-if len(ans) == 0:", "- print((0))", "- exit()", "-print((ans[-1] - ans[0]))", "+ans = min(D, B) - max(A,...
false
0.043779
0.044858
0.975926
[ "s423723611", "s297082008" ]
u416011173
p02608
python
s184933940
s062121466
892
782
9,220
9,492
Accepted
Accepted
12.33
# -*- coding: utf-8 -*- # モジュールのインポート import math import itertools # 標準入力を取得 N = int(eval(input())) # メイン処理 def g(x: int, y: int, z: int) -> int: return x**2 + y**2 + z**2 + x*y + y*z + z*x l = [0 for n in range(N)] for x, y, z in itertools.product(list(range(1, int(math.sqrt(N)) + 1)), repeat...
# -*- coding: utf-8 -*- # モジュールのインポート import math import itertools def get_input() -> int: """ 標準入力を取得する. Returns:\n int: 標準入力 """ N = int(eval(input())) return N # メイン処理 def g(x: int, y: int, z: int) -> int: """ 関数. Args:\n x (int): 整...
24
61
413
931
# -*- coding: utf-8 -*- # モジュールのインポート import math import itertools # 標準入力を取得 N = int(eval(input())) # メイン処理 def g(x: int, y: int, z: int) -> int: return x**2 + y**2 + z**2 + x * y + y * z + z * x l = [0 for n in range(N)] for x, y, z in itertools.product(list(range(1, int(math.sqrt(N)) + 1)), repeat=3): v = ...
# -*- coding: utf-8 -*- # モジュールのインポート import math import itertools def get_input() -> int: """ 標準入力を取得する. Returns:\n int: 標準入力 """ N = int(eval(input())) return N # メイン処理 def g(x: int, y: int, z: int) -> int: """ 関数. Args:\n x (int): 整数(1 <= x) y (int): 整数...
false
60.655738
[ "-# 標準入力を取得", "-N = int(eval(input()))", "+", "+def get_input() -> int:", "+ \"\"\"", "+ 標準入力を取得する.", "+ Returns:\\n", "+ int: 標準入力", "+ \"\"\"", "+ N = int(eval(input()))", "+ return N", "+", "+", "+ \"\"\"", "+ 関数.", "+ Args:\\n", "+ x (int)...
false
0.038173
0.115254
0.331206
[ "s184933940", "s062121466" ]
u476124554
p03221
python
s084481376
s714454907
979
867
45,764
44,972
Accepted
Accepted
11.44
n,m = list(map(int,input().split())) p,y = [],[] for i in range(m): v1,v2 = list(map(int,input().split())) p.append(v1) y.append(v2) py = list(zip(p,y,list(range(m)))) py = sorted(py) p,y,index = list(zip(*py)) ans = [] start = p[0] count = 1 for i in range(m): if start == p[i]: ...
n,m = list(map(int,input().split())) p,y = [],[] for i in range(m): v1,v2 = list(map(int,input().split())) p.append(v1) y.append(v2) py = list(zip(p,y,list(range(m)))) py = sorted(py) p,y,index = list(zip(*py)) ans = [] start = p[0] count = 1 for i in range(m): if start == p[i]: ...
29
29
601
599
n, m = list(map(int, input().split())) p, y = [], [] for i in range(m): v1, v2 = list(map(int, input().split())) p.append(v1) y.append(v2) py = list(zip(p, y, list(range(m)))) py = sorted(py) p, y, index = list(zip(*py)) ans = [] start = p[0] count = 1 for i in range(m): if start == p[i]: ans.ap...
n, m = list(map(int, input().split())) p, y = [], [] for i in range(m): v1, v2 = list(map(int, input().split())) p.append(v1) y.append(v2) py = list(zip(p, y, list(range(m)))) py = sorted(py) p, y, index = list(zip(*py)) ans = [] start = p[0] count = 1 for i in range(m): if start == p[i]: ans.ap...
false
0
[ "-ans1 = list(zip(index, ans))", "-ans1 = sorted(ans1)", "-index, ans = list(zip(*ans1))", "+ans = list(zip(index, ans))", "+ans = sorted(ans)", "+index, ans = list(zip(*ans))" ]
false
0.035228
0.035489
0.992656
[ "s084481376", "s714454907" ]
u078042885
p00066
python
s714749318
s114575045
30
20
7,420
7,492
Accepted
Accepted
33.33
def f(a): for x in ['o','x']: if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x for i in range(3): if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x return 'd' while 1: try:a=list(eval(input())) except:break print((f(a)))
def f(a): for x in ['o','x']: if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x for i in range(3): if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x return 'd' while 1: try:print((f(list(eval(input()))))) except:break
11
10
288
279
def f(a): for x in ["o", "x"]: if a[0::4].count(x) == 3 or a[2:7:2].count(x) == 3: return x for i in range(3): if a[i * 3 : i * 3 + 3].count(x) == 3 or a[i::3].count(x) == 3: return x return "d" while 1: try: a = list(eval(input())) excep...
def f(a): for x in ["o", "x"]: if a[0::4].count(x) == 3 or a[2:7:2].count(x) == 3: return x for i in range(3): if a[i * 3 : i * 3 + 3].count(x) == 3 or a[i::3].count(x) == 3: return x return "d" while 1: try: print((f(list(eval(input()))))) ...
false
9.090909
[ "- a = list(eval(input()))", "+ print((f(list(eval(input())))))", "- print((f(a)))" ]
false
0.044285
0.044575
0.993488
[ "s714749318", "s114575045" ]
u435226340
p02389
python
s420253527
s302280840
30
20
5,580
5,584
Accepted
Accepted
33.33
p = input().split() a = int(p[0]) b = int(p[1]) print((a*b, 2*(a+b)))
a,b = list(map(int, input().split())) print((a*b, 2*(a+b)))
4
3
71
55
p = input().split() a = int(p[0]) b = int(p[1]) print((a * b, 2 * (a + b)))
a, b = list(map(int, input().split())) print((a * b, 2 * (a + b)))
false
25
[ "-p = input().split()", "-a = int(p[0])", "-b = int(p[1])", "+a, b = list(map(int, input().split()))" ]
false
0.039803
0.044091
0.902756
[ "s420253527", "s302280840" ]
u775681539
p02695
python
s687158813
s515623618
620
303
9,372
75,788
Accepted
Accepted
51.13
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque ans = 0 def main(): N, M, Q = list(map(int, readline().split())) query = [] for _ in range(Q): a, b, c, d = list(map(int, readline().split()))...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(1000000) ans = 0 def main(): N, M, Q = list(map(int, readline().split())) query = [] for _ in range(Q): a, b, c, d = list(map(int, readline().split()))...
41
46
942
1,091
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque ans = 0 def main(): N, M, Q = list(map(int, readline().split())) query = [] for _ in range(Q): a, b, c, d = list(map(int, readline().split())) ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(1000000) ans = 0 def main(): N, M, Q = list(map(int, readline().split())) query = [] for _ in range(Q): a, b, c, d = list(map(int, readline().split())) ...
false
10.869565
[ "-from collections import deque", "-", "+sys.setrecursionlimit(1000000)", "+ a -= 1", "+ b -= 1", "- def getScore(A):", "- res = 0", "+ def slv(A):", "+ s = 0", "- if A[b - 1] - A[a - 1] == c:", "- res += d", "- return res", ...
false
0.080104
0.079068
1.013115
[ "s687158813", "s515623618" ]
u936985471
p03075
python
s860517118
s294848693
19
17
2,940
2,940
Accepted
Accepted
10.53
a=int(eval(input())) eval(input());eval(input());eval(input()); e=int(eval(input())) k=int(eval(input())) print(("Yay!" if k>=e-a else ":("))
a,b,c,d,e,k=list(map(int,open(0))) print(((":(","Yay!")[e-a<=k]))
5
2
107
58
a = int(eval(input())) eval(input()) eval(input()) eval(input()) e = int(eval(input())) k = int(eval(input())) print(("Yay!" if k >= e - a else ":("))
a, b, c, d, e, k = list(map(int, open(0))) print(((":(", "Yay!")[e - a <= k]))
false
60
[ "-a = int(eval(input()))", "-eval(input())", "-eval(input())", "-eval(input())", "-e = int(eval(input()))", "-k = int(eval(input()))", "-print((\"Yay!\" if k >= e - a else \":(\"))", "+a, b, c, d, e, k = list(map(int, open(0)))", "+print(((\":(\", \"Yay!\")[e - a <= k]))" ]
false
0.066938
0.053946
1.240841
[ "s860517118", "s294848693" ]
u332385682
p03837
python
s581373039
s709128227
576
225
3,444
3,316
Accepted
Accepted
60.94
# D - Candidates of No Shortest Paths MAXI = 999999999 # 入力 N, M = list(map(int, input().split())) cost = [[-1 for i in range(N)] for j in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) cost[a - 1][b - 1] = c cost[b - 1][a - 1] = c # iからjへの最短距離を表すテーブルの初期化 dist = [...
import sys inf = 1<<60 def solve(): N, M = list(map(int, sys.stdin.readline().split())) cost = [[inf]*N for i in range(N)] for mi in range(M): a, b, c = list(map(int, sys.stdin.readline().split())) a, b = a-1, b-1 cost[a][b] = cost[b][a] = c dist = [[0]*N for i...
41
36
967
835
# D - Candidates of No Shortest Paths MAXI = 999999999 # 入力 N, M = list(map(int, input().split())) cost = [[-1 for i in range(N)] for j in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) cost[a - 1][b - 1] = c cost[b - 1][a - 1] = c # iからjへの最短距離を表すテーブルの初期化 dist = [[MAXI for i in range...
import sys inf = 1 << 60 def solve(): N, M = list(map(int, sys.stdin.readline().split())) cost = [[inf] * N for i in range(N)] for mi in range(M): a, b, c = list(map(int, sys.stdin.readline().split())) a, b = a - 1, b - 1 cost[a][b] = cost[b][a] = c dist = [[0] * N for i in ra...
false
12.195122
[ "-# D - Candidates of No Shortest Paths", "-MAXI = 999999999", "-# 入力", "-N, M = list(map(int, input().split()))", "-cost = [[-1 for i in range(N)] for j in range(N)]", "-for i in range(M):", "- a, b, c = list(map(int, input().split()))", "- cost[a - 1][b - 1] = c", "- cost[b - 1][a - 1] = ...
false
0.038171
0.036426
1.047913
[ "s581373039", "s709128227" ]
u888092736
p02802
python
s628584404
s683469359
376
290
51,388
4,596
Accepted
Accepted
22.87
from collections import defaultdict n, m = list(map(int, input().split())) ps = [] for _ in range(m): ps.append(input().split()) sub_st = defaultdict(list) for p, s in ps: sub_st[p].append(s) solved = 0 error = 0 for k, v in list(sub_st.items()): temp_error = 0 for history in v: ...
N, M = list(map(int, input().split())) did_ac = [False] * N pn_cnt = [0] * N for _ in range(M): p, s = input().split() p = int(p) - 1 if did_ac[p]: continue s = s == 'AC' if s: did_ac[p] = True else: pn_cnt[p] += 1 print((sum(did_ac), sum(pn_cnt[i] for i in r...
23
14
457
336
from collections import defaultdict n, m = list(map(int, input().split())) ps = [] for _ in range(m): ps.append(input().split()) sub_st = defaultdict(list) for p, s in ps: sub_st[p].append(s) solved = 0 error = 0 for k, v in list(sub_st.items()): temp_error = 0 for history in v: if "AC" in hist...
N, M = list(map(int, input().split())) did_ac = [False] * N pn_cnt = [0] * N for _ in range(M): p, s = input().split() p = int(p) - 1 if did_ac[p]: continue s = s == "AC" if s: did_ac[p] = True else: pn_cnt[p] += 1 print((sum(did_ac), sum(pn_cnt[i] for i in range(N) if di...
false
39.130435
[ "-from collections import defaultdict", "-", "-n, m = list(map(int, input().split()))", "-ps = []", "-for _ in range(m):", "- ps.append(input().split())", "-sub_st = defaultdict(list)", "-for p, s in ps:", "- sub_st[p].append(s)", "-solved = 0", "-error = 0", "-for k, v in list(sub_st.it...
false
0.048468
0.049111
0.986907
[ "s628584404", "s683469359" ]
u754022296
p03660
python
s022329110
s455163436
752
419
137,652
28,976
Accepted
Accepted
44.28
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) def main(): n = int(eval(input())) F = [[] for _ in range(n)] for _ in range(n-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 F[a].append(b) F[b].append(a) seenB = [False]*n seenW = [False]*n dis...
import sys input = sys.stdin.readline n = int(eval(input())) T = [[] for _ in range(n)] for _ in range(n-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 T[a].append(b) T[b].append(a) def dfs(v): dist = [-1]*n dist[v] = 0 stack = [v] while stack: nv = stack.pop() for ...
39
34
763
607
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) def main(): n = int(eval(input())) F = [[] for _ in range(n)] for _ in range(n - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 F[a].append(b) F[b].append(a) seenB = [False] * n se...
import sys input = sys.stdin.readline n = int(eval(input())) T = [[] for _ in range(n)] for _ in range(n - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 T[a].append(b) T[b].append(a) def dfs(v): dist = [-1] * n dist[v] = 0 stack = [v] while stack: nv = stack.pop...
false
12.820513
[ "-sys.setrecursionlimit(10**7)", "+n = int(eval(input()))", "+T = [[] for _ in range(n)]", "+for _ in range(n - 1):", "+ a, b = list(map(int, input().split()))", "+ a -= 1", "+ b -= 1", "+ T[a].append(b)", "+ T[b].append(a)", "-def main():", "- n = int(eval(input()))", "- ...
false
0.07821
0.041996
1.862311
[ "s022329110", "s455163436" ]
u508732591
p00009
python
s493384460
s663263161
280
170
28,884
16,924
Accepted
Accepted
39.29
import sys import math N = 1000000 primes = [1] * (N//2+1) primes[0] = 1 for i in range(3,int(math.sqrt(N))+1,2): if primes[i//2]: primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::i]) primes[i//2] += primes[i//2-1] for i in range(int(math.sqrt(N))+1,N+1,2): primes[i//2] += primes[i//...
import sys N = 1000000 primes = [1] * (N//2) primes[0] = 0 for i in range(3,int(N**0.5),2): if primes[i//2]: primes[(i*i)//2::i] = [0] * len(primes[(i*i)//2::i]) for i in sys.stdin: n = int(i) if n < 3: print((n-1)) else: print((sum(primes[:(n+1)//2])+1))
24
16
479
315
import sys import math N = 1000000 primes = [1] * (N // 2 + 1) primes[0] = 1 for i in range(3, int(math.sqrt(N)) + 1, 2): if primes[i // 2]: primes[(i * i) // 2 :: i] = [0] * len(primes[(i * i) // 2 :: i]) primes[i // 2] += primes[i // 2 - 1] for i in range(int(math.sqrt(N)) + 1, N + 1, 2): primes[...
import sys N = 1000000 primes = [1] * (N // 2) primes[0] = 0 for i in range(3, int(N**0.5), 2): if primes[i // 2]: primes[(i * i) // 2 :: i] = [0] * len(primes[(i * i) // 2 :: i]) for i in sys.stdin: n = int(i) if n < 3: print((n - 1)) else: print((sum(primes[: (n + 1) // 2]) + ...
false
33.333333
[ "-import math", "-primes = [1] * (N // 2 + 1)", "-primes[0] = 1", "-for i in range(3, int(math.sqrt(N)) + 1, 2):", "+primes = [1] * (N // 2)", "+primes[0] = 0", "+for i in range(3, int(N**0.5), 2):", "- primes[i // 2] += primes[i // 2 - 1]", "-for i in range(int(math.sqrt(N)) + 1, N + 1, 2):", ...
false
0.469915
0.155811
3.015935
[ "s493384460", "s663263161" ]
u380524497
p02914
python
s403745356
s799297134
1,974
1,800
16,116
16,116
Accepted
Accepted
8.81
n = int(eval(input())) A = list(map(int, input().split())) not_important = 0 for a in A: not_important ^= a for i in range(n): A[i] &= ~not_important A.sort() rank = 0 for digit in range(60, -1, -1): check_bit = 1 << digit for i in range(rank, n): if A[i] & check_bit: ...
n = int(eval(input())) A = list(map(int, input().split())) not_important = 0 for a in A: not_important ^= a for i in range(n): A[i] &= ~not_important A.sort(reverse=True) rank = 0 for digit in range(60, -1, -1): check_bit = 1 << digit for i in range(rank, n): if A[i] & check_...
34
34
614
627
n = int(eval(input())) A = list(map(int, input().split())) not_important = 0 for a in A: not_important ^= a for i in range(n): A[i] &= ~not_important A.sort() rank = 0 for digit in range(60, -1, -1): check_bit = 1 << digit for i in range(rank, n): if A[i] & check_bit: A[rank], A[i] =...
n = int(eval(input())) A = list(map(int, input().split())) not_important = 0 for a in A: not_important ^= a for i in range(n): A[i] &= ~not_important A.sort(reverse=True) rank = 0 for digit in range(60, -1, -1): check_bit = 1 << digit for i in range(rank, n): if A[i] & check_bit: A[r...
false
0
[ "-A.sort()", "+A.sort(reverse=True)" ]
false
0.046552
0.04656
0.999835
[ "s403745356", "s799297134" ]
u775681539
p02614
python
s486985792
s988653418
112
80
75,376
73,828
Accepted
Accepted
28.57
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines ans = 0 def main(): H, W, K = list(map(int, readline().split())) grid = [] for _ in range(H): grid.append(list(eval(input()))) #再帰関数で二組の全bit探索を組む #リストをコピーしない方法 ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): H, W, K = list(map(int, readline().split())) grid = [] for _ in range(H): grid.append(list(readline().rstrip().decode())) #gridの状態をシミュレーションしない ans = 0 ...
54
28
1,299
777
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines ans = 0 def main(): H, W, K = list(map(int, readline().split())) grid = [] for _ in range(H): grid.append(list(eval(input()))) # 再帰関数で二組の全bit探索を組む # リストをコピーしない方法 bitr = ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): H, W, K = list(map(int, readline().split())) grid = [] for _ in range(H): grid.append(list(readline().rstrip().decode())) # gridの状態をシミュレーションしない ans = 0 for i...
false
48.148148
[ "-ans = 0", "- grid.append(list(eval(input())))", "- # 再帰関数で二組の全bit探索を組む", "- # リストをコピーしない方法", "- bitr = [0 for _ in range(H)]", "- bitc = [0 for _ in range(W)]", "-", "- def dfsr(i):", "- if i == H:", "- dfsc(0)", "- return", "- dfsr(i...
false
0.039223
0.039647
0.989316
[ "s486985792", "s988653418" ]
u314050667
p03835
python
s906045966
s431402049
1,773
1,219
3,060
2,940
Accepted
Accepted
31.25
k,s=list(map(int,input().split())) cnt = 0 for x in range(k+1): for y in range(k+1): z = s-(x+y) if 0 <= z and z <= k: cnt+=1 print(cnt)
k,s = list(map(int,input().split())) cnt = 0 for x in range(k+1): for y in range(k+1): if 0 <= s-x-y <= k: cnt += 1 print(cnt)
8
10
169
138
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): z = s - (x + y) if 0 <= z and z <= k: cnt += 1 print(cnt)
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): if 0 <= s - x - y <= k: cnt += 1 print(cnt)
false
20
[ "- z = s - (x + y)", "- if 0 <= z and z <= k:", "+ if 0 <= s - x - y <= k:" ]
false
0.035106
0.065211
0.538349
[ "s906045966", "s431402049" ]
u540761833
p03592
python
s289581935
s685518230
294
17
3,060
3,060
Accepted
Accepted
94.22
N,M,K = list(map(int,input().split())) ans = 'No' flag = False for x in range(M+1): if flag: break for y in range(N+1): if (N-y)*x+(M-x)*y == K: ans = 'Yes' flag = True break print(ans)
N,M,K = list(map(int,input().split())) ans = 'No' for x in range(M+1): if M-2*x == 0: if K%N == 0: ans = 'Yes' break else: continue else: if (K-N*x)%(M-2*x) == 0 and 0 <= (K-N*x)/(M-2*x) <= N: ans = 'Yes' break ...
12
16
250
357
N, M, K = list(map(int, input().split())) ans = "No" flag = False for x in range(M + 1): if flag: break for y in range(N + 1): if (N - y) * x + (M - x) * y == K: ans = "Yes" flag = True break print(ans)
N, M, K = list(map(int, input().split())) ans = "No" for x in range(M + 1): if M - 2 * x == 0: if K % N == 0: ans = "Yes" break else: continue else: if (K - N * x) % (M - 2 * x) == 0 and 0 <= (K - N * x) / (M - 2 * x) <= N: ans = "Yes" ...
false
25
[ "-flag = False", "- if flag:", "- break", "- for y in range(N + 1):", "- if (N - y) * x + (M - x) * y == K:", "+ if M - 2 * x == 0:", "+ if K % N == 0:", "- flag = True", "+ else:", "+ continue", "+ else:", "+ if (K - N * x) ...
false
0.040196
0.037246
1.079185
[ "s289581935", "s685518230" ]
u765758367
p02641
python
s301264457
s218200950
23
21
9,128
9,184
Accepted
Accepted
8.7
X,N= list(map(int,input().split())) p = list(map(int, input().split())) p = sorted(p) ans_tmp = 10**9+7 ans = 0 if N==0: print(X) else: if X not in p: print(X) exit() else: tmp1,tmp2 = X-1,X+1 while True: if tmp1 not in p: print(tmp1...
X,N= list(map(int,input().split())) p = list(map(int, input().split())) ans_tmp = 10**9 ans = X for i in range(0,102): if i not in p and ans_tmp>abs(X-i): ans_tmp=abs(X-i) ans = i print(ans)
22
9
469
213
X, N = list(map(int, input().split())) p = list(map(int, input().split())) p = sorted(p) ans_tmp = 10**9 + 7 ans = 0 if N == 0: print(X) else: if X not in p: print(X) exit() else: tmp1, tmp2 = X - 1, X + 1 while True: if tmp1 not in p: print(tmp1) ...
X, N = list(map(int, input().split())) p = list(map(int, input().split())) ans_tmp = 10**9 ans = X for i in range(0, 102): if i not in p and ans_tmp > abs(X - i): ans_tmp = abs(X - i) ans = i print(ans)
false
59.090909
[ "-p = sorted(p)", "-ans_tmp = 10**9 + 7", "-ans = 0", "-if N == 0:", "- print(X)", "-else:", "- if X not in p:", "- print(X)", "- exit()", "- else:", "- tmp1, tmp2 = X - 1, X + 1", "- while True:", "- if tmp1 not in p:", "- pri...
false
0.037025
0.045687
0.810412
[ "s301264457", "s218200950" ]
u725993280
p02659
python
s415721357
s373626018
28
22
10,040
9,164
Accepted
Accepted
21.43
from decimal import Decimal a,b = list(map(Decimal,input().split())) ans = a*b print((int(ans)))
a,b = input().split() a = int(a) b = int(b[0]+b[2]+b[3]) ans = a*b ans = ans//100 print(ans)
7
6
97
97
from decimal import Decimal a, b = list(map(Decimal, input().split())) ans = a * b print((int(ans)))
a, b = input().split() a = int(a) b = int(b[0] + b[2] + b[3]) ans = a * b ans = ans // 100 print(ans)
false
14.285714
[ "-from decimal import Decimal", "-", "-a, b = list(map(Decimal, input().split()))", "+a, b = input().split()", "+a = int(a)", "+b = int(b[0] + b[2] + b[3])", "-print((int(ans)))", "+ans = ans // 100", "+print(ans)" ]
false
0.047638
0.044462
1.071443
[ "s415721357", "s373626018" ]
u794173881
p02998
python
s896886012
s175267552
793
715
104,908
81,956
Accepted
Accepted
9.84
import sys input = sys.stdin.readline sys.setrecursionlimit(200010) n = int(eval(input())) info = [list(map(int, input().split())) for i in range(n)] v = 100000 graph = [[] for i in range(v*2)] for i in range(n): x = info[i][0] - 1 y = (info[i][1] - 1) + v graph[x].append(y) graph[y].appe...
def dfs(v): cnt = [0, 0] if v < OFFSET: cnt[0] += 1 else: cnt[1] += 1 visited[v] = True stack = [v] while stack: v = stack.pop() for nxt_v in graph[v]: if visited[nxt_v]: continue if nxt_v < OFFSET: ...
33
43
635
895
import sys input = sys.stdin.readline sys.setrecursionlimit(200010) n = int(eval(input())) info = [list(map(int, input().split())) for i in range(n)] v = 100000 graph = [[] for i in range(v * 2)] for i in range(n): x = info[i][0] - 1 y = (info[i][1] - 1) + v graph[x].append(y) graph[y].append(x) def ...
def dfs(v): cnt = [0, 0] if v < OFFSET: cnt[0] += 1 else: cnt[1] += 1 visited[v] = True stack = [v] while stack: v = stack.pop() for nxt_v in graph[v]: if visited[nxt_v]: continue if nxt_v < OFFSET: cnt[0] +=...
false
23.255814
[ "-import sys", "+def dfs(v):", "+ cnt = [0, 0]", "+ if v < OFFSET:", "+ cnt[0] += 1", "+ else:", "+ cnt[1] += 1", "+ visited[v] = True", "+ stack = [v]", "+ while stack:", "+ v = stack.pop()", "+ for nxt_v in graph[v]:", "+ if visited[...
false
0.595929
0.627603
0.949532
[ "s896886012", "s175267552" ]
u580093517
p03408
python
s713002042
s425874497
19
17
3,060
2,940
Accepted
Accepted
10.53
n = [eval(input()) for _ in range(int(eval(input())))] m = [eval(input()) for _ in range(int(eval(input())))] l = list(set(n)) print((max(0,max([n.count(l[i]) - m.count(l[i]) for i in range(len(l))]))))
n = [eval(input()) for _ in range(int(eval(input())))] m = [eval(input()) for _ in range(int(eval(input())))] l = set(n) print((max(0,max([n.count(i) - m.count(i) for i in l]))))
5
4
181
155
n = [eval(input()) for _ in range(int(eval(input())))] m = [eval(input()) for _ in range(int(eval(input())))] l = list(set(n)) print((max(0, max([n.count(l[i]) - m.count(l[i]) for i in range(len(l))]))))
n = [eval(input()) for _ in range(int(eval(input())))] m = [eval(input()) for _ in range(int(eval(input())))] l = set(n) print((max(0, max([n.count(i) - m.count(i) for i in l]))))
false
20
[ "-l = list(set(n))", "-print((max(0, max([n.count(l[i]) - m.count(l[i]) for i in range(len(l))]))))", "+l = set(n)", "+print((max(0, max([n.count(i) - m.count(i) for i in l]))))" ]
false
0.044741
0.044312
1.0097
[ "s713002042", "s425874497" ]
u667084803
p03132
python
s333819629
s699718867
1,373
1,003
3,064
3,064
Accepted
Accepted
26.95
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d #2019-02-11 #DP L = int(eval(input())) DP = [0 for i in range(5)] def cost(a): if a: return [a, a%2, (a+1)%2, a%2, a] else: return [0, 2, 1, 2, 0] def list_add(in1, in2): return [a + b for a...
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d #2019-02-11 #DP L = int(eval(input())) DP = [0 for i in range(5)] def cost(a): if a: return [a, a%2, (a+1)%2, a%2, a] else: return [0, 2, 1, 2, 0] def list_add(in1, in2): return [a + b for a...
27
30
490
590
# https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d # 2019-02-11 # DP L = int(eval(input())) DP = [0 for i in range(5)] def cost(a): if a: return [a, a % 2, (a + 1) % 2, a % 2, a] else: return [0, 2, 1, 2, 0] def list_add(in1, in2): return [a + b for a, b in...
# https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d # 2019-02-11 # DP L = int(eval(input())) DP = [0 for i in range(5)] def cost(a): if a: return [a, a % 2, (a + 1) % 2, a % 2, a] else: return [0, 2, 1, 2, 0] def list_add(in1, in2): return [a + b for a, b in...
false
10
[ "- n = [min(DP[: i + 1]) for i in range(5)]", "- DP = list_add(n, cos)", "+ DP[4] = min(DP[:5]) + cos[4]", "+ DP[3] = min(DP[:4]) + cos[3]", "+ DP[2] = min(DP[:3]) + cos[2]", "+ DP[1] = min(DP[:2]) + cos[1]", "+ DP[0] = min(DP[:1]) + cos[0]" ]
false
0.034715
0.056113
0.618667
[ "s333819629", "s699718867" ]
u513081876
p03574
python
s413015513
s692195527
156
30
14,552
3,188
Accepted
Accepted
80.77
import numpy as np ans = [] H, W = list(map(int, input().split())) S = [] S.append('.'*(W+2)) for i in range(H): S.append('.'+eval(input()) + '.') S.append('.'*(W+2)) for y in range(1, H+1): for x in range(1, W+1): if S[y][x] == '.': cnt = S[y][x-1].count('#')+S[y][x+1].count('#...
H, W = list(map(int, input().split())) S = [eval(input()) for i in range(H)] ans = [['#' for i in range(W)] for i in range(H)] for x in range(W): for y in range(H): num = 0 if S[y][x] == '.': for dx, dy in [1, 0], [-1, 0], [0, 1], [0, -1], [1, 1], [-1, -1], [1, -1], [-1, 1]: ...
20
15
544
527
import numpy as np ans = [] H, W = list(map(int, input().split())) S = [] S.append("." * (W + 2)) for i in range(H): S.append("." + eval(input()) + ".") S.append("." * (W + 2)) for y in range(1, H + 1): for x in range(1, W + 1): if S[y][x] == ".": cnt = ( S[y][x - 1].count("...
H, W = list(map(int, input().split())) S = [eval(input()) for i in range(H)] ans = [["#" for i in range(W)] for i in range(H)] for x in range(W): for y in range(H): num = 0 if S[y][x] == ".": for dx, dy in ( [1, 0], [-1, 0], [0, 1], ...
false
25
[ "-import numpy as np", "-", "-ans = []", "-S = []", "-S.append(\".\" * (W + 2))", "-for i in range(H):", "- S.append(\".\" + eval(input()) + \".\")", "-S.append(\".\" * (W + 2))", "-for y in range(1, H + 1):", "- for x in range(1, W + 1):", "+S = [eval(input()) for i in range(H)]", "+ans...
false
0.162588
0.038811
4.189232
[ "s413015513", "s692195527" ]
u347640436
p02837
python
s131546973
s821714369
321
149
3,064
3,064
Accepted
Accepted
53.58
N = int(eval(input())) s = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) s[i].append((x - 1, y)) result = 0 for i in range(1, 2 ** N): t = [-1] * N for j in range(N): t[j] = (i >> j) & 1 m = False for j...
N = int(eval(input())) s = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) s[i].append((x - 1, y)) result = 0 for i in range(1, 2 ** N): consistent = True for j in range(N): if (i >> j) & 1 ...
25
24
513
586
N = int(eval(input())) s = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) s[i].append((x - 1, y)) result = 0 for i in range(1, 2**N): t = [-1] * N for j in range(N): t[j] = (i >> j) & 1 m = False ...
N = int(eval(input())) s = [[] for _ in range(N)] for i in range(N): A = int(eval(input())) for _ in range(A): x, y = list(map(int, input().split())) s[i].append((x - 1, y)) result = 0 for i in range(1, 2**N): consistent = True for j in range(N): if (i >> j) & 1 == 0: ...
false
4
[ "- t = [-1] * N", "- for j in range(N):", "- t[j] = (i >> j) & 1", "- m = False", "+ consistent = True", "- if t[x] != y:", "- m = True", "+ if (i >> x) & 1 != y:", "+ consistent = False", "- if not m:", "+ if not c...
false
0.065629
0.034637
1.89475
[ "s131546973", "s821714369" ]
u539367121
p02832
python
s210978782
s740128015
129
95
32,160
32,324
Accepted
Accepted
26.36
N=int(eval(input())) A=list(map(int,input().split())) ans=[0] cnt=0 hit=0 while cnt<N: if ans[hit]+1==A[cnt]: hit+=1 ans.append(hit) cnt+=1 print((N-len(ans[1:]) if len(ans)>1 else -1))
N=int(eval(input())) A=list(map(int,input().split())) cnt=0 for a in A: cnt+=1 if cnt+1==a else 0 print((N-cnt if cnt>0 else -1))
12
7
201
130
N = int(eval(input())) A = list(map(int, input().split())) ans = [0] cnt = 0 hit = 0 while cnt < N: if ans[hit] + 1 == A[cnt]: hit += 1 ans.append(hit) cnt += 1 print((N - len(ans[1:]) if len(ans) > 1 else -1))
N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 for a in A: cnt += 1 if cnt + 1 == a else 0 print((N - cnt if cnt > 0 else -1))
false
41.666667
[ "-ans = [0]", "-hit = 0", "-while cnt < N:", "- if ans[hit] + 1 == A[cnt]:", "- hit += 1", "- ans.append(hit)", "- cnt += 1", "-print((N - len(ans[1:]) if len(ans) > 1 else -1))", "+for a in A:", "+ cnt += 1 if cnt + 1 == a else 0", "+print((N - cnt if cnt > 0 else -1))" ]
false
0.038253
0.041906
0.912815
[ "s210978782", "s740128015" ]
u620084012
p02881
python
s554005555
s901639085
190
150
40,556
3,064
Accepted
Accepted
21.05
import math N = int(eval(input())) ans = 10**12 + 1 for k in range(1,math.floor(math.sqrt(N))+1): if N % k == 0: ans = min(ans,k+N//k-2) print(ans)
import math N = int(eval(input())) ans = 10**13 for k in range(1,math.floor(math.sqrt(N))+1): if N % k == 0: ans = min(ans,k+N//k-2) print(ans)
8
7
162
156
import math N = int(eval(input())) ans = 10**12 + 1 for k in range(1, math.floor(math.sqrt(N)) + 1): if N % k == 0: ans = min(ans, k + N // k - 2) print(ans)
import math N = int(eval(input())) ans = 10**13 for k in range(1, math.floor(math.sqrt(N)) + 1): if N % k == 0: ans = min(ans, k + N // k - 2) print(ans)
false
12.5
[ "-ans = 10**12 + 1", "+ans = 10**13" ]
false
0.047409
0.048911
0.969303
[ "s554005555", "s901639085" ]
u533885955
p03854
python
s018175320
s804843173
66
23
4,724
6,516
Accepted
Accepted
65.15
#C問題 S=str(eval(input())) Slist=list(S) Slen=len(Slist) Srev=Slist[::-1] kari="" for i in range(Slen): if len(kari) == 5: if kari == "maerd": kari=Srev[i] elif kari == "esare": kari=Srev[i] else: kari+=Srev[i] elif len(kari) == 6: ...
#C問題 import re S = str(eval(input())) p = re.match('(dream|dreamer|erase|eraser)+$',S) if p: print("YES") else: print("NO")
30
8
678
132
# C問題 S = str(eval(input())) Slist = list(S) Slen = len(Slist) Srev = Slist[::-1] kari = "" for i in range(Slen): if len(kari) == 5: if kari == "maerd": kari = Srev[i] elif kari == "esare": kari = Srev[i] else: kari += Srev[i] elif len(kari) == 6: ...
# C問題 import re S = str(eval(input())) p = re.match("(dream|dreamer|erase|eraser)+$", S) if p: print("YES") else: print("NO")
false
73.333333
[ "+import re", "+", "-Slist = list(S)", "-Slen = len(Slist)", "-Srev = Slist[::-1]", "-kari = \"\"", "-for i in range(Slen):", "- if len(kari) == 5:", "- if kari == \"maerd\":", "- kari = Srev[i]", "- elif kari == \"esare\":", "- kari = Srev[i]", "- ...
false
0.062985
0.040616
1.55076
[ "s018175320", "s804843173" ]
u334712262
p03175
python
s497102238
s824869477
951
835
123,684
129,136
Accepted
Accepted
12.2
from collections import defaultdict import sys sys.setrecursionlimit(10**6) N = int(eval(input())) g = [set() for _ in range(N+1)] for x, y in [list(map(int, input().split())) for _ in range(N-1)]: g[x].add(y) g[y].add(x) M = 10**9 + 7 def dfs(u, p): w = 1 b = 1 for v in ...
from collections import defaultdict import sys sys.setrecursionlimit(10**6) N = int(eval(input())) g = defaultdict(set) for x, y in [list(map(int, input().split())) for _ in range(N-1)]: g[x].add(y) g[y].add(x) M = 10**9 + 7 def dfs(u, p): w = 1 b = 1 for v in g[u]: ...
30
30
498
487
from collections import defaultdict import sys sys.setrecursionlimit(10**6) N = int(eval(input())) g = [set() for _ in range(N + 1)] for x, y in [list(map(int, input().split())) for _ in range(N - 1)]: g[x].add(y) g[y].add(x) M = 10**9 + 7 def dfs(u, p): w = 1 b = 1 for v in g[u]: if p ==...
from collections import defaultdict import sys sys.setrecursionlimit(10**6) N = int(eval(input())) g = defaultdict(set) for x, y in [list(map(int, input().split())) for _ in range(N - 1)]: g[x].add(y) g[y].add(x) M = 10**9 + 7 def dfs(u, p): w = 1 b = 1 for v in g[u]: if p == v: ...
false
0
[ "-g = [set() for _ in range(N + 1)]", "+g = defaultdict(set)" ]
false
0.057543
0.038666
1.488198
[ "s497102238", "s824869477" ]
u075012704
p03166
python
s987121459
s523581242
1,175
715
147,912
67,288
Accepted
Accepted
39.15
import sys sys.setrecursionlimit(10 ** 9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y) def topological_sort(g): topological_list = [] visited = set() def dfs(n): ...
import sys sys.setrecursionlimit(10 ** 9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y) def topological_sort(g): topological_list = [] visited = set() def dfs(n): ...
36
36
710
735
import sys sys.setrecursionlimit(10**9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y) def topological_sort(g): topological_list = [] visited = set() def dfs(n): for e in g...
import sys sys.setrecursionlimit(10**9) N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(M): x, y = list(map(int, input().split())) x, y = x - 1, y - 1 G[x].append(y) def topological_sort(g): topological_list = [] visited = set() def dfs(n): for e in g...
false
0
[ "-T = topological_sort(G)", "-dist = [0] * N", "-for n in T:", "- for v in G[n]:", "- dist[v] = max(dist[v], dist[n] + 1)", "-print((max(dist)))", "+topological_order = topological_sort(G)", "+dp = [0] * N", "+for t in topological_order:", "+ for to in G[t]:", "+ dp[to] = max...
false
0.035304
0.034539
1.022152
[ "s987121459", "s523581242" ]
u863370423
p03632
python
s671539660
s005523851
17
10
3,060
2,568
Accepted
Accepted
41.18
a,b,c,d=list(map(int,input().split())) print((max(0,min(b,d)-max(a,c))))
a, b, c, d = input().split(' ');time= int(min(int(b), int(d))) - int(max(int(a), int(c)));print((time if time>0 else 0))
2
1
65
122
a, b, c, d = list(map(int, input().split())) print((max(0, min(b, d) - max(a, c))))
a, b, c, d = input().split(" ") time = int(min(int(b), int(d))) - int(max(int(a), int(c))) print((time if time > 0 else 0))
false
50
[ "-a, b, c, d = list(map(int, input().split()))", "-print((max(0, min(b, d) - max(a, c))))", "+a, b, c, d = input().split(\" \")", "+time = int(min(int(b), int(d))) - int(max(int(a), int(c)))", "+print((time if time > 0 else 0))" ]
false
0.080845
0.0372
2.173233
[ "s671539660", "s005523851" ]
u648881683
p03627
python
s550163316
s174316984
96
80
23,324
23,184
Accepted
Accepted
16.67
import bisect, collections, copy, heapq, itertools, math, string, sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = float('inf') def I(): return int(eval(input())) def F(): return float(eval(input())) def SS(): return eval(input()) def LI(): return [int(x) for x in input().spl...
import bisect, collections, copy, heapq, itertools, math, string, sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = float('inf') def I(): return int(eval(input())) def F(): return float(eval(input())) def SS(): return eval(input()) def LI(): return [int(x) for x in input().spl...
31
32
850
840
import bisect, collections, copy, heapq, itertools, math, string, sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = float("inf") def I(): return int(eval(input())) def F(): return float(eval(input())) def SS(): return eval(input()) def LI(): return [int(x) for...
import bisect, collections, copy, heapq, itertools, math, string, sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = float("inf") def I(): return int(eval(input())) def F(): return float(eval(input())) def SS(): return eval(input()) def LI(): return [int(x) for...
false
3.125
[ "- edge = [(k, v) for k, v in list(cnt.items()) if v >= 2]", "+ edge = [k for k, v in list(cnt.items()) if v >= 2]", "- if len(edge) >= 1 and edge[0][1] >= 4:", "- ans = edge[0][0] ** 2", "+ if len(edge) >= 1 and cnt[edge[0]] >= 4:", "+ ans = edge[0] ** 2", "- ans = edge...
false
0.125548
0.172742
0.726794
[ "s550163316", "s174316984" ]
u312025627
p02994
python
s561959495
s247565576
210
184
39,152
38,384
Accepted
Accepted
12.38
n, l = list(map(int,input().split())) pies = [l+i-1 for i in range(1,n+1)] pie_plan = sum(pies) pie_real = 0 diff_plan_real = float("inf") for i in range(1,n+1): pie_provisonal = sum([l+j-1 for j in range(1,n+1) if j != i]) if abs(pie_plan - pie_provisonal) < diff_plan_real: diff_plan_real = a...
def main(): N, L = (int(i) for i in input().split()) s = 0 li = [] for i in range(1, N+1): s += L + i - 1 li.append((abs(L + i - 1), i)) li.sort() print((s - (L + li[0][1] - 1))) if __name__ == '__main__': main()
13
14
401
271
n, l = list(map(int, input().split())) pies = [l + i - 1 for i in range(1, n + 1)] pie_plan = sum(pies) pie_real = 0 diff_plan_real = float("inf") for i in range(1, n + 1): pie_provisonal = sum([l + j - 1 for j in range(1, n + 1) if j != i]) if abs(pie_plan - pie_provisonal) < diff_plan_real: diff_plan_...
def main(): N, L = (int(i) for i in input().split()) s = 0 li = [] for i in range(1, N + 1): s += L + i - 1 li.append((abs(L + i - 1), i)) li.sort() print((s - (L + li[0][1] - 1))) if __name__ == "__main__": main()
false
7.142857
[ "-n, l = list(map(int, input().split()))", "-pies = [l + i - 1 for i in range(1, n + 1)]", "-pie_plan = sum(pies)", "-pie_real = 0", "-diff_plan_real = float(\"inf\")", "-for i in range(1, n + 1):", "- pie_provisonal = sum([l + j - 1 for j in range(1, n + 1) if j != i])", "- if abs(pie_plan - pi...
false
0.041975
0.036551
1.148389
[ "s561959495", "s247565576" ]
u156815136
p03238
python
s624706286
s260972583
35
17
5,048
2,940
Accepted
Accepted
51.43
import itertools import fractions def main(): n = int(eval(input())) if n == 1: print('Hello World') else: a = int(eval(input())) b = int(eval(input())) print((a+b)) if __name__ == '__main__': main()
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] #from itertools import combinations # (string,3) 3回 #from collections import deque #import collections.defaultdict #import bisect # # d = m - k[i] - k[j] # if kk[bisect.bi...
12
32
214
706
import itertools import fractions def main(): n = int(eval(input())) if n == 1: print("Hello World") else: a = int(eval(input())) b = int(eval(input())) print((a + b)) if __name__ == "__main__": main()
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] # from itertools import combinations # (string,3) 3回 # from collections import deque # import collections.defaultdict # import bisect # # d = m - k[i] - k[j] # if kk[bisect.bise...
false
62.5
[ "-import itertools", "-import fractions", "+# from statistics import median", "+# import collections", "+# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]", "+# from itertools import combinations # (string,3) 3回", "+# from collections import deque", "+# import collect...
false
0.036596
0.04572
0.800425
[ "s624706286", "s260972583" ]
u173148629
p02819
python
s028820360
s488070003
36
18
2,940
3,060
Accepted
Accepted
50
X=int(eval(input())) f=False a=X if X==2: print("2") exit() while f==False: for i in range(2,a+1): if a%i==0: break if i==a-1: f=True a+=1 print((a-1))
X=int(eval(input())) f=False a=X if X==2 or X==3: print(X) exit() while f==False: for i in range(2,int(a**0.5)+1): if a%i==0: break if i==int(a**0.5): f=True a+=1 print((a-1))
17
15
219
238
X = int(eval(input())) f = False a = X if X == 2: print("2") exit() while f == False: for i in range(2, a + 1): if a % i == 0: break if i == a - 1: f = True a += 1 print((a - 1))
X = int(eval(input())) f = False a = X if X == 2 or X == 3: print(X) exit() while f == False: for i in range(2, int(a**0.5) + 1): if a % i == 0: break if i == int(a**0.5): f = True a += 1 print((a - 1))
false
11.764706
[ "-if X == 2:", "- print(\"2\")", "+if X == 2 or X == 3:", "+ print(X)", "- for i in range(2, a + 1):", "+ for i in range(2, int(a**0.5) + 1):", "- if i == a - 1:", "+ if i == int(a**0.5):" ]
false
0.042157
0.047948
0.879206
[ "s028820360", "s488070003" ]
u413165887
p02844
python
s532724034
s911100579
470
21
42,608
3,060
Accepted
Accepted
95.53
n = int(eval(input())) s = list(eval(input()))[::-1] result = 0 for i in range(1000): x = format(i, "03") j = 0 p = 0 while p < n: if s[p]==x[j]: j += 1 if j == 3: result += 1 break p += 1 print(result)
n = int(eval(input())) s = eval(input()) result = 0 for i in range(1000): x = format(i, "03") indx = s.find(x[0],0) indx1 = s.find(x[1], indx+1) indx2 = s.find(x[2], indx1+1) if indx>=0 and indx1>0 and indx2>0: result += 1 print(result)
16
12
294
264
n = int(eval(input())) s = list(eval(input()))[::-1] result = 0 for i in range(1000): x = format(i, "03") j = 0 p = 0 while p < n: if s[p] == x[j]: j += 1 if j == 3: result += 1 break p += 1 print(result)
n = int(eval(input())) s = eval(input()) result = 0 for i in range(1000): x = format(i, "03") indx = s.find(x[0], 0) indx1 = s.find(x[1], indx + 1) indx2 = s.find(x[2], indx1 + 1) if indx >= 0 and indx1 > 0 and indx2 > 0: result += 1 print(result)
false
25
[ "-s = list(eval(input()))[::-1]", "+s = eval(input())", "- j = 0", "- p = 0", "- while p < n:", "- if s[p] == x[j]:", "- j += 1", "- if j == 3:", "- result += 1", "- break", "- p += 1", "+ indx = s.find(x[0], 0)", ...
false
0.100818
0.036424
2.767932
[ "s532724034", "s911100579" ]
u218834617
p02583
python
s394817045
s788853231
90
69
9,100
9,064
Accepted
Accepted
23.33
N=int(eval(input())) L=list(map(int,input().split())) L.sort() ans=0 for i in range(N-2): for j in range(i+1,N-1): for k in range(j+1,N): a,b,c=L[i],L[j],L[k] if a!=b and b!=c and a+b>c: ans+=1 print(ans)
N=int(eval(input())) L=list(map(int,input().split())) L.sort() ans=0 for i in range(N-2): a=L[i] for j in range(i+1,N-1): b=L[j] if a==b: continue for k in range(j+1,N): c=L[k] if b==c: continue ans+=a+b>c ...
13
18
265
326
N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): for k in range(j + 1, N): a, b, c = L[i], L[j], L[k] if a != b and b != c and a + b > c: ans += 1 print(ans)
N = int(eval(input())) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N - 2): a = L[i] for j in range(i + 1, N - 1): b = L[j] if a == b: continue for k in range(j + 1, N): c = L[k] if b == c: continue an...
false
27.777778
[ "+ a = L[i]", "+ b = L[j]", "+ if a == b:", "+ continue", "- a, b, c = L[i], L[j], L[k]", "- if a != b and b != c and a + b > c:", "- ans += 1", "+ c = L[k]", "+ if b == c:", "+ continue", "+ ...
false
0.038083
0.038318
0.993872
[ "s394817045", "s788853231" ]
u037430802
p03805
python
s795015870
s541934082
138
24
3,444
3,064
Accepted
Accepted
82.61
import copy n,m = list(map(int, input().split())) paths = [[] for _ in range(n)] for i in range(m): a,b = list(map(int, input().split())) paths[a-1].append(b-1) paths[b-1].append(a-1) ans = 0 checked = [False for _ in range(n)] def solve(i, c): c[i] = True global ans if c.count(F...
N, M = list(map(int, input().split())) if M == 0: print((0)) exit() es = [[] for i in range(M+1)] for i in range(M): a, b = list(map(int, input().split())) a,b = a-1, b-1 es[a].append(b) es[b].append(a) def dfs(v, visited, es, cnt): #print("--------------") #print((v,...
34
36
540
652
import copy n, m = list(map(int, input().split())) paths = [[] for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) paths[a - 1].append(b - 1) paths[b - 1].append(a - 1) ans = 0 checked = [False for _ in range(n)] def solve(i, c): c[i] = True global ans if c.count(Fals...
N, M = list(map(int, input().split())) if M == 0: print((0)) exit() es = [[] for i in range(M + 1)] for i in range(M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 es[a].append(b) es[b].append(a) def dfs(v, visited, es, cnt): # print("--------------") # print((v, visited,...
false
5.555556
[ "-import copy", "-", "-n, m = list(map(int, input().split()))", "-paths = [[] for _ in range(n)]", "-for i in range(m):", "+N, M = list(map(int, input().split()))", "+if M == 0:", "+ print((0))", "+ exit()", "+es = [[] for i in range(M + 1)]", "+for i in range(M):", "- paths[a - 1].ap...
false
0.034331
0.030281
1.133729
[ "s795015870", "s541934082" ]
u852690916
p03503
python
s090373240
s057593639
141
75
3,064
3,064
Accepted
Accepted
46.81
N=int(eval(input())) F=[tuple(map(int,input().split())) for _ in range(N)] P=[tuple(map(int,input().split())) for _ in range(N)] ans=-(10**7*N) #営業パターンを10bitの整数であらわす(0はない) for o in range(1,1<<10): #同時に営業する時間帯数のリスト C=[0]*N for t in range(10): #時間帯tに営業するか if o&1: for i...
N=int(eval(input())) F=[int(input().replace(' ',''),2) for _ in range(N)] P=[tuple(map(int,input().split())) for _ in range(N)] ans=-(10**7*N) for o in range(1,1<<10): p=0 for i in range(N): p+=P[i][bin(F[i]&o).count('1')] ans=max(ans,p) print(ans)
23
11
505
273
N = int(eval(input())) F = [tuple(map(int, input().split())) for _ in range(N)] P = [tuple(map(int, input().split())) for _ in range(N)] ans = -(10**7 * N) # 営業パターンを10bitの整数であらわす(0はない) for o in range(1, 1 << 10): # 同時に営業する時間帯数のリスト C = [0] * N for t in range(10): # 時間帯tに営業するか if o & 1: ...
N = int(eval(input())) F = [int(input().replace(" ", ""), 2) for _ in range(N)] P = [tuple(map(int, input().split())) for _ in range(N)] ans = -(10**7 * N) for o in range(1, 1 << 10): p = 0 for i in range(N): p += P[i][bin(F[i] & o).count("1")] ans = max(ans, p) print(ans)
false
52.173913
[ "-F = [tuple(map(int, input().split())) for _ in range(N)]", "+F = [int(input().replace(\" \", \"\"), 2) for _ in range(N)]", "-# 営業パターンを10bitの整数であらわす(0はない)", "- # 同時に営業する時間帯数のリスト", "- C = [0] * N", "- for t in range(10):", "- # 時間帯tに営業するか", "- if o & 1:", "- for i ...
false
0.098989
0.125935
0.786028
[ "s090373240", "s057593639" ]
u282228874
p03111
python
s023059247
s237745940
75
62
3,064
3,064
Accepted
Accepted
17.33
n,a,b,c = list(map(int,input().split())) l = [int(eval(input())) for i in range(n)] def dfs(cnt,A,B,C): if cnt == n: if min(A,B,C) == 0: return float('inf') else: return abs(a-A)+abs(b-B)+abs(c-C)-30 else: ret1 = dfs(cnt+1,A+l[cnt],B,C)+10 ret2 =...
N,A,B,C = list(map(int,input().split())) L = [int(eval(input())) for i in range(N)] def dfs(i,la,lb,lc,cost): if i == N: if la*lb*lc == 0: return 10**20 else: return abs(A-la)+abs(B-lb)+abs(C-lc)-30+cost ret1 = dfs(i+1,la+L[i],lb,lc,cost+10) ret2 = dfs(i+1,la...
15
14
473
466
n, a, b, c = list(map(int, input().split())) l = [int(eval(input())) for i in range(n)] def dfs(cnt, A, B, C): if cnt == n: if min(A, B, C) == 0: return float("inf") else: return abs(a - A) + abs(b - B) + abs(c - C) - 30 else: ret1 = dfs(cnt + 1, A + l[cnt], B, ...
N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for i in range(N)] def dfs(i, la, lb, lc, cost): if i == N: if la * lb * lc == 0: return 10**20 else: return abs(A - la) + abs(B - lb) + abs(C - lc) - 30 + cost ret1 = dfs(i + 1, la + L[i], lb, lc, cos...
false
6.666667
[ "-n, a, b, c = list(map(int, input().split()))", "-l = [int(eval(input())) for i in range(n)]", "+N, A, B, C = list(map(int, input().split()))", "+L = [int(eval(input())) for i in range(N)]", "-def dfs(cnt, A, B, C):", "- if cnt == n:", "- if min(A, B, C) == 0:", "- return float(\...
false
0.077128
0.071348
1.081007
[ "s023059247", "s237745940" ]
u912237403
p00162
python
s510809748
s072227708
120
20
34,428
4,244
Accepted
Accepted
83.33
def hum(n): x = [0]*(n+1) x[1] = 1 for e in [2, 3, 5]: for i in range(n/e+1): if x[i]: x[i*e] = 1 return x M = [] N = [] while 1: try: m,n = list(map(int, input().split())) except: break M.append(m) N.append(n) H = hum(max(N)) for m, n in zip(M,N): print(sum(H[m:n+1]))
def f(x, I, n): while x[-1]<=n: a = [x[I[0]]*2, x[I[1]]*3, x[I[2]]*5] b = min(a) c = a.index(b) if b > x[-1]: x += [b] I[c] += 1 return while 1: try: m,n = list(map(int, input().split())) except: break x = [1] I = [0, 0, 0] f(x, I, m-1) a = len(x) f(x, I, n) pri...
18
18
312
329
def hum(n): x = [0] * (n + 1) x[1] = 1 for e in [2, 3, 5]: for i in range(n / e + 1): if x[i]: x[i * e] = 1 return x M = [] N = [] while 1: try: m, n = list(map(int, input().split())) except: break M.append(m) N.append(n) H = hum(max(...
def f(x, I, n): while x[-1] <= n: a = [x[I[0]] * 2, x[I[1]] * 3, x[I[2]] * 5] b = min(a) c = a.index(b) if b > x[-1]: x += [b] I[c] += 1 return while 1: try: m, n = list(map(int, input().split())) except: break x = [1] I = [0,...
false
0
[ "-def hum(n):", "- x = [0] * (n + 1)", "- x[1] = 1", "- for e in [2, 3, 5]:", "- for i in range(n / e + 1):", "- if x[i]:", "- x[i * e] = 1", "- return x", "+def f(x, I, n):", "+ while x[-1] <= n:", "+ a = [x[I[0]] * 2, x[I[1]] * 3, x[I[2]] ...
false
0.045465
0.045172
1.006474
[ "s510809748", "s072227708" ]
u562935282
p03026
python
s283264297
s591326132
578
79
51,672
17,264
Accepted
Accepted
86.33
N = int(input()) es = [[] for idx in range(N)] # es[idx]:=[隣接リスト] for _ in range(N - 1): a, b = map(int, input().split()) a -= 1 b -= 1 es[a].append(b) es[b].append(a) h = [len(es[i]) for i in range(N)] # 次数 c = list(map(int, input().split())) c.sort() # スコアが小さい順にソート v = [-1] *...
def main(): import sys sys.setrecursionlimit(10 ** 7) def dfs(v): nonlocal curr num[v] = 0 # 0: visited, but not written yet for u in g[v]: if num[u] >= 0: continue dfs(u) num[v] = c[curr] curr += 1 n = ...
37
37
759
723
N = int(input()) es = [[] for idx in range(N)] # es[idx]:=[隣接リスト] for _ in range(N - 1): a, b = map(int, input().split()) a -= 1 b -= 1 es[a].append(b) es[b].append(a) h = [len(es[i]) for i in range(N)] # 次数 c = list(map(int, input().split())) c.sort() # スコアが小さい順にソート v = [-1] * N cur = 0 ans = 0 for...
def main(): import sys sys.setrecursionlimit(10**7) def dfs(v): nonlocal curr num[v] = 0 # 0: visited, but not written yet for u in g[v]: if num[u] >= 0: continue dfs(u) num[v] = c[curr] curr += 1 n = int(eval(input())) ...
false
0
[ "-N = int(input())", "-es = [[] for idx in range(N)]", "-# es[idx]:=[隣接リスト]", "-for _ in range(N - 1):", "- a, b = map(int, input().split())", "- a -= 1", "- b -= 1", "- es[a].append(b)", "- es[b].append(a)", "-h = [len(es[i]) for i in range(N)]", "-# 次数", "-c = list(map(int, in...
false
0.045637
0.052923
0.862325
[ "s283264297", "s591326132" ]
u875291233
p03546
python
s744194371
s143854510
231
38
41,584
3,444
Accepted
Accepted
83.55
# coding: utf-8 # Your code here! H,W = [int(i) for i in input().split()] c=[[int(i) for i in input().split()] for _ in range(10)] A=[[int(i) for i in input().split()] for _ in range(H)] dist = c n=10 #n: 頂点数 for k in range(n): for i in range(n): for j in range(n): dist[i][j] = m...
# coding: utf-8 # Your code here! H,W = [int(i) for i in input().split()] c=[[int(i) for i in input().split()] for _ in range(10)] A=[[int(i) for i in input().split()] for _ in range(H)] dist = c n=10 #n: 頂点数 for k,dk in enumerate(dist): for di in dist: for j in range(n): if di[j...
23
24
499
516
# coding: utf-8 # Your code here! H, W = [int(i) for i in input().split()] c = [[int(i) for i in input().split()] for _ in range(10)] A = [[int(i) for i in input().split()] for _ in range(H)] dist = c n = 10 # n: 頂点数 for k in range(n): for i in range(n): for j in range(n): dist[i][j] = min(dist[...
# coding: utf-8 # Your code here! H, W = [int(i) for i in input().split()] c = [[int(i) for i in input().split()] for _ in range(10)] A = [[int(i) for i in input().split()] for _ in range(H)] dist = c n = 10 # n: 頂点数 for k, dk in enumerate(dist): for di in dist: for j in range(n): if di[j] > di[...
false
4.166667
[ "-for k in range(n):", "- for i in range(n):", "+for k, dk in enumerate(dist):", "+ for di in dist:", "- dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])", "+ if di[j] > di[k] + dk[j]:", "+ di[j] = di[k] + dk[j]" ]
false
0.041257
0.035399
1.16549
[ "s744194371", "s143854510" ]
u849151695
p02720
python
s742307448
s853481667
107
98
11,948
11,880
Accepted
Accepted
8.41
from collections import deque k = int(eval(input())) Q = deque(list(range(1, 10))) #るんるん数を格納するキュー # Q: 1 2 3 4 5 6 7 8 9 for i in range(k): x = Q.popleft() #x = 1 <-- Q: 2 3 4 5 6 7 8 9 last_digit = x % 10 # 1 一番目の桁の値 if last_digit == 0: Q.append(10*x + 0) Q.append(10*x + 1) ...
from collections import deque k = int(eval(input())) Q = deque(list(range(1, 10))) #るんるん数を格納するキュー # Q: 1 2 3 4 5 6 7 8 9 for i in range(k): x = Q.popleft() #x = 1 <-- Q: 2 3 4 5 6 7 8 9 last_digit = x % 10 # 1 一番目の桁の値 z = 10*x + last_digit #11 if last_digit != 0: Q.append(z-1) # Q: 2...
23
21
545
466
from collections import deque k = int(eval(input())) Q = deque(list(range(1, 10))) # るんるん数を格納するキュー # Q: 1 2 3 4 5 6 7 8 9 for i in range(k): x = Q.popleft() # x = 1 <-- Q: 2 3 4 5 6 7 8 9 last_digit = x % 10 # 1 一番目の桁の値 if last_digit == 0: Q.append(10 * x + 0) Q.append(10 * x + 1) ...
from collections import deque k = int(eval(input())) Q = deque(list(range(1, 10))) # るんるん数を格納するキュー # Q: 1 2 3 4 5 6 7 8 9 for i in range(k): x = Q.popleft() # x = 1 <-- Q: 2 3 4 5 6 7 8 9 last_digit = x % 10 # 1 一番目の桁の値 z = 10 * x + last_digit # 11 if last_digit != 0: Q.append(z - 1) ...
false
8.695652
[ "- if last_digit == 0:", "- Q.append(10 * x + 0)", "- Q.append(10 * x + 1)", "- elif last_digit == 9:", "- Q.append(10 * x + 8)", "- Q.append(10 * x + 9)", "- else: # 1<=last_digit <=8", "- Q.append(10 * x + last_digit - 1)", "- Q.append(10 * x + l...
false
0.050125
0.042036
1.192441
[ "s742307448", "s853481667" ]
u687766076
p03141
python
s319659403
s790597826
334
289
25,244
25,640
Accepted
Accepted
13.47
import sys n=int(sys.stdin.readline()) M = [] for i in range(n): a,b = list(map(int,sys.stdin.readline().split())) M.append([a,b]) M = sorted(M,key=lambda x:sum(x), reverse=True) cnt = 0 for i in range(n): if i%2==0: cnt += M[i][0] else: cnt -= M[i][1] print(cnt)
import sys from collections import deque n=int(sys.stdin.readline()) M = deque(maxlen=n) for i in range(n): a,b = list(map(int,sys.stdin.readline().split())) M.append([a,b]) M = sorted(M,key=lambda x:sum(x)) cnt = 0 for i in range(n): if i%2==0: cnt += M.pop()[0] else: ...
16
18
307
345
import sys n = int(sys.stdin.readline()) M = [] for i in range(n): a, b = list(map(int, sys.stdin.readline().split())) M.append([a, b]) M = sorted(M, key=lambda x: sum(x), reverse=True) cnt = 0 for i in range(n): if i % 2 == 0: cnt += M[i][0] else: cnt -= M[i][1] print(cnt)
import sys from collections import deque n = int(sys.stdin.readline()) M = deque(maxlen=n) for i in range(n): a, b = list(map(int, sys.stdin.readline().split())) M.append([a, b]) M = sorted(M, key=lambda x: sum(x)) cnt = 0 for i in range(n): if i % 2 == 0: cnt += M.pop()[0] else: cnt -=...
false
11.111111
[ "+from collections import deque", "-M = []", "+M = deque(maxlen=n)", "-M = sorted(M, key=lambda x: sum(x), reverse=True)", "+M = sorted(M, key=lambda x: sum(x))", "- cnt += M[i][0]", "+ cnt += M.pop()[0]", "- cnt -= M[i][1]", "+ cnt -= M.pop()[1]" ]
false
0.10887
0.039476
2.757847
[ "s319659403", "s790597826" ]
u980655160
p03059
python
s768065102
s022543143
1,205
17
21,284
2,940
Accepted
Accepted
98.59
import numpy as np if __name__ == "__main__": a, b, t = list(map(int, input().split())) print((b * (t // a)))
if __name__ == "__main__": a, b, t = list(map(int, input().split())) print((b * (t // a)))
5
3
114
92
import numpy as np if __name__ == "__main__": a, b, t = list(map(int, input().split())) print((b * (t // a)))
if __name__ == "__main__": a, b, t = list(map(int, input().split())) print((b * (t // a)))
false
40
[ "-import numpy as np", "-" ]
false
0.043866
0.041986
1.044776
[ "s768065102", "s022543143" ]
u394721319
p03136
python
s560022522
s985459096
168
28
38,384
9,064
Accepted
Accepted
83.33
n = int(eval(input())) li = list(map(int,input().split())) li.sort() if li[-1]*2 >= sum(li): print('No') else: print('Yes')
N = int(eval(input())) L = [int(i) for i in input().split()] if 2*max(L)-sum(L) < 0: print('Yes') else: print('No')
8
7
134
125
n = int(eval(input())) li = list(map(int, input().split())) li.sort() if li[-1] * 2 >= sum(li): print("No") else: print("Yes")
N = int(eval(input())) L = [int(i) for i in input().split()] if 2 * max(L) - sum(L) < 0: print("Yes") else: print("No")
false
12.5
[ "-n = int(eval(input()))", "-li = list(map(int, input().split()))", "-li.sort()", "-if li[-1] * 2 >= sum(li):", "+N = int(eval(input()))", "+L = [int(i) for i in input().split()]", "+if 2 * max(L) - sum(L) < 0:", "+ print(\"Yes\")", "+else:", "-else:", "- print(\"Yes\")" ]
false
0.060411
0.03733
1.618308
[ "s560022522", "s985459096" ]
u119148115
p03222
python
s762210228
s458670862
173
71
38,256
62,800
Accepted
Accepted
58.96
import sys def S(): return sys.stdin.readline().rstrip() H,W,K = list(map(int,S().split())) mod = 10**9+7 if W == 1: print((1)) exit() fib = [1,1,2,3,5,8,13,21] # fib[i] = i本の縦線に横線を引く方法の数(同じ高さ) dp = [[0]*(W+1) for _ in range(H+1)] # dp[i][j] = i行目にjに達する横線の引き方 for i in range(H+1): for...
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
32
43
894
1,406
import sys def S(): return sys.stdin.readline().rstrip() H, W, K = list(map(int, S().split())) mod = 10**9 + 7 if W == 1: print((1)) exit() fib = [1, 1, 2, 3, 5, 8, 13, 21] # fib[i] = i本の縦線に横線を引く方法の数(同じ高さ) dp = [[0] * (W + 1) for _ in range(H + 1)] # dp[i][j] = i行目にjに達する横線の引き方 for i in range(H + 1): ...
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
false
25.581395
[ "+", "+sys.setrecursionlimit(10**7)", "+", "+", "+def I():", "+ return int(sys.stdin.readline().rstrip())", "+", "+", "+def MI():", "+ return list(map(int, sys.stdin.readline().rstrip().split()))", "+", "+", "+def LI():", "+ return list(map(int, sys.stdin.readline().rstrip().split...
false
0.039222
0.047799
0.820546
[ "s762210228", "s458670862" ]
u261103969
p02802
python
s163150165
s342513107
323
181
14,836
75,968
Accepted
Accepted
43.96
n, m = [int(i) for i in input().split()] p = [0] * m s = [0] * m ac = 0 wc = 0 wan = [0] * (n+1) qj = [False] * (n+1) for i in range(m): p[i], s[i] = input().split() p[i] = int(p[i]) if not qj[p[i]]: if s[i] == 'AC': qj[p[i]] = 'True' ac += 1 wc...
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): N, M = list(map(int, readline().split())) AC = [False] * N cnt = [0] * N for _ in range(M): p, s = input().split() p = int(p) p -= 1 ...
21
35
393
627
n, m = [int(i) for i in input().split()] p = [0] * m s = [0] * m ac = 0 wc = 0 wan = [0] * (n + 1) qj = [False] * (n + 1) for i in range(m): p[i], s[i] = input().split() p[i] = int(p[i]) if not qj[p[i]]: if s[i] == "AC": qj[p[i]] = "True" ac += 1 wc += wan[p[i]] ...
import sys readline = sys.stdin.readline MOD = 10**9 + 7 INF = float("INF") sys.setrecursionlimit(10**5) def main(): N, M = list(map(int, readline().split())) AC = [False] * N cnt = [0] * N for _ in range(M): p, s = input().split() p = int(p) p -= 1 if s == "AC": ...
false
40
[ "-n, m = [int(i) for i in input().split()]", "-p = [0] * m", "-s = [0] * m", "-ac = 0", "-wc = 0", "-wan = [0] * (n + 1)", "-qj = [False] * (n + 1)", "-for i in range(m):", "- p[i], s[i] = input().split()", "- p[i] = int(p[i])", "- if not qj[p[i]]:", "- if s[i] == \"AC\":", "...
false
0.041914
0.042889
0.977247
[ "s163150165", "s342513107" ]
u585482323
p02714
python
s803169418
s880666992
1,494
944
74,552
78,736
Accepted
Accepted
36.81
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) def LS...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) def LS...
67
65
1,650
1,615
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) d...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) d...
false
2.985075
[ "- right = len(b) - bisect.bisect_left(b, j)", "- res = left * right", "- for i in range(len(g)):", "- li = g[i]", "- k = bisect.bisect_left(b, j2 - li)", "- if k < len(b) and b[k] + li == j2 and b[k] > li:", "+ right = bisect.bisect_left(b, j...
false
0.048619
0.048688
0.998592
[ "s803169418", "s880666992" ]
u682755774
p02392
python
s494645360
s375480282
20
10
4,260
4,192
Accepted
Accepted
50
#coding:UTF-8 import copy n = list(map(int,input().split())) if n[0]<n[1]<n[2]: print("Yes") else: print("No")
#coding:UTF-8 n = list(map(int,input().split())) if n[0]<n[1]<n[2]: print("Yes") else: print("No")
9
8
124
111
# coding:UTF-8 import copy n = list(map(int, input().split())) if n[0] < n[1] < n[2]: print("Yes") else: print("No")
# coding:UTF-8 n = list(map(int, input().split())) if n[0] < n[1] < n[2]: print("Yes") else: print("No")
false
11.111111
[ "-import copy", "-" ]
false
0.041365
0.035754
1.156928
[ "s494645360", "s375480282" ]
u634461820
p03213
python
s334427120
s831921752
82
18
3,188
3,064
Accepted
Accepted
78.05
import itertools import math N = int(input()) pn = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] ans = [] for ar in itertools.permutations(pn,3): if math.factorial(N) > (ar[0]**2*ar[1]**4*ar[2]**4) and\ math.factorial(N) % (ar[0]**2*ar[1]**4*ar[2]**4) == 0: ans.app...
import math N = int(eval(input())) pn = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] C3 = 0 C5 = 0 C15 = 0 C25 = 0 C75 = 0 for i in pn: if math.factorial(N) % pow(i,2) == 0: C3 += 1 if math.factorial(N) % pow(i,4) == 0: C5 += 1 if math.factorial...
29
25
887
551
import itertools import math N = int(input()) pn = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, ] ans = [] for ar in itertools.permutations(pn, 3): if ( m...
import math N = int(eval(input())) pn = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, ] C3 = 0 C5 = 0 C15 = 0 C25 = 0 C75 = 0 for i in pn: if math.factorial(N) % p...
false
13.793103
[ "-import itertools", "-N = int(input())", "+N = int(eval(input()))", "-ans = []", "-for ar in itertools.permutations(pn, 3):", "- if (", "- math.factorial(N) > (ar[0] ** 2 * ar[1] ** 4 * ar[2] ** 4)", "- and math.factorial(N) % (ar[0] ** 2 * ar[1] ** 4 * ar[2] ** 4) == 0", "- ):"...
false
0.077087
0.057892
1.331576
[ "s334427120", "s831921752" ]
u227020436
p03262
python
s775613302
s278904989
97
88
13,208
16,280
Accepted
Accepted
9.28
from fractions import gcd from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) dist = [abs(y - X) for y in x] print((reduce(gcd, dist)))
from fractions import gcd # math.gcd in Python 3.5 from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) dist = [abs(y - X) for y in x] print((reduce(gcd, dist)))
9
9
192
215
from fractions import gcd from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) dist = [abs(y - X) for y in x] print((reduce(gcd, dist)))
from fractions import gcd # math.gcd in Python 3.5 from functools import reduce N, X = list(map(int, input().split())) x = list(map(int, input().split())) dist = [abs(y - X) for y in x] print((reduce(gcd, dist)))
false
0
[ "-from fractions import gcd", "+from fractions import gcd # math.gcd in Python 3.5" ]
false
0.0443
0.044623
0.992765
[ "s775613302", "s278904989" ]
u779455925
p03775
python
s856534678
s095503538
79
28
3,060
2,940
Accepted
Accepted
64.56
N=int(eval(input())) M=int((N**(1/2))) mult=0 while 1: for i in [-1,1]: x=M+i*mult if not N%x: print((max([len(str(x)),len(str(int(N/x)))]))) exit() mult+=1
N=int(eval(input())) M=int((N**(1/2))) print((min([max([len(str(i)),len(str(int(N/i)))]) for i in range(1,M+1) if N%i==0])))
10
3
206
119
N = int(eval(input())) M = int((N ** (1 / 2))) mult = 0 while 1: for i in [-1, 1]: x = M + i * mult if not N % x: print((max([len(str(x)), len(str(int(N / x)))]))) exit() mult += 1
N = int(eval(input())) M = int((N ** (1 / 2))) print( ( min( [ max([len(str(i)), len(str(int(N / i)))]) for i in range(1, M + 1) if N % i == 0 ] ) ) )
false
70
[ "-mult = 0", "-while 1:", "- for i in [-1, 1]:", "- x = M + i * mult", "- if not N % x:", "- print((max([len(str(x)), len(str(int(N / x)))])))", "- exit()", "- mult += 1", "+print(", "+ (", "+ min(", "+ [", "+ max(...
false
0.08985
0.038156
2.354836
[ "s856534678", "s095503538" ]
u723345499
p02791
python
s675713700
s973692167
146
112
26,580
24,744
Accepted
Accepted
23.29
n = int(eval(input())) p = list(map(int, input().split())) cnt = 1 tmp_min = p[0] for i in range(1, n): tmp_min = min(tmp_min, p[i]) if tmp_min == p[i]: cnt += 1 print(cnt)
n = int(eval(input())) p = list(map(int, input().split())) cnt = 1 tmp_min = p[0] for i in range(1, n): if tmp_min >= p[i]: tmp_min = p[i] cnt += 1 print(cnt)
10
11
193
192
n = int(eval(input())) p = list(map(int, input().split())) cnt = 1 tmp_min = p[0] for i in range(1, n): tmp_min = min(tmp_min, p[i]) if tmp_min == p[i]: cnt += 1 print(cnt)
n = int(eval(input())) p = list(map(int, input().split())) cnt = 1 tmp_min = p[0] for i in range(1, n): if tmp_min >= p[i]: tmp_min = p[i] cnt += 1 print(cnt)
false
9.090909
[ "- tmp_min = min(tmp_min, p[i])", "- if tmp_min == p[i]:", "+ if tmp_min >= p[i]:", "+ tmp_min = p[i]" ]
false
0.035889
0.032726
1.096656
[ "s675713700", "s973692167" ]
u650918644
p03244
python
s386906132
s140544097
106
84
17,500
17,500
Accepted
Accepted
20.75
import collections as coll n = int(eval(input())) v = list(map(int,input().split())) even = [] odd = [] for i in range(n): if i % 2 == 0: even.append(v[i]) else: odd.append(v[i]) oddc = coll.Counter(odd).most_common()[:2] evenc = coll.Counter(even).most_common()[:2] if(len(oddc) == 1): oddc....
import collections as coll n = int(eval(input())) v = list(map(int,input().split())) even = v[0::2] odd = v[1::2] oddc = coll.Counter(odd).most_common()[:2] evenc = coll.Counter(even).most_common()[:2] if(len(oddc) == 1): oddc.append((0,0)) if(len(evenc) == 1): evenc.append((0,0)) if(oddc[0][0] !...
26
20
516
438
import collections as coll n = int(eval(input())) v = list(map(int, input().split())) even = [] odd = [] for i in range(n): if i % 2 == 0: even.append(v[i]) else: odd.append(v[i]) oddc = coll.Counter(odd).most_common()[:2] evenc = coll.Counter(even).most_common()[:2] if len(oddc) == 1: oddc...
import collections as coll n = int(eval(input())) v = list(map(int, input().split())) even = v[0::2] odd = v[1::2] oddc = coll.Counter(odd).most_common()[:2] evenc = coll.Counter(even).most_common()[:2] if len(oddc) == 1: oddc.append((0, 0)) if len(evenc) == 1: evenc.append((0, 0)) if oddc[0][0] != evenc[0][0]...
false
23.076923
[ "-even = []", "-odd = []", "-for i in range(n):", "- if i % 2 == 0:", "- even.append(v[i])", "- else:", "- odd.append(v[i])", "+even = v[0::2]", "+odd = v[1::2]" ]
false
0.032971
0.036118
0.912869
[ "s386906132", "s140544097" ]
u534308356
p02696
python
s780636896
s366003472
23
21
9,116
8,940
Accepted
Accepted
8.7
A, B, N = list(map(int, input().split())) ans = 0 x = min(N, B-1) A_x = A * x left_ = int(A_x / B) right_ = A * int(x / B) fnc_ = left_ - right_ ans = fnc_ print(ans)
A, B, N = list(map(int, input().split())) ans = 0 x = min(N, B-1) A_x = A * x ans = int(A_x / B) - A * int(x / B) print(ans)
13
10
177
132
A, B, N = list(map(int, input().split())) ans = 0 x = min(N, B - 1) A_x = A * x left_ = int(A_x / B) right_ = A * int(x / B) fnc_ = left_ - right_ ans = fnc_ print(ans)
A, B, N = list(map(int, input().split())) ans = 0 x = min(N, B - 1) A_x = A * x ans = int(A_x / B) - A * int(x / B) print(ans)
false
23.076923
[ "-left_ = int(A_x / B)", "-right_ = A * int(x / B)", "-fnc_ = left_ - right_", "-ans = fnc_", "+ans = int(A_x / B) - A * int(x / B)" ]
false
0.179143
0.106752
1.678121
[ "s780636896", "s366003472" ]
u709079466
p02831
python
s128274808
s416885036
42
17
5,304
2,940
Accepted
Accepted
59.52
A, B = list(map(int, input().split())) import fractions print((int(A*B/fractions.gcd(A,B))))
def gcd(a, b): while True: a, b = b, a%b if b == 0: return a def lcm(a, b): return int((a*b) // gcd(a, b)) a, b = list(map(int, input().split())) print((lcm(a, b)))
4
12
89
206
A, B = list(map(int, input().split())) import fractions print((int(A * B / fractions.gcd(A, B))))
def gcd(a, b): while True: a, b = b, a % b if b == 0: return a def lcm(a, b): return int((a * b) // gcd(a, b)) a, b = list(map(int, input().split())) print((lcm(a, b)))
false
66.666667
[ "-A, B = list(map(int, input().split()))", "-import fractions", "+def gcd(a, b):", "+ while True:", "+ a, b = b, a % b", "+ if b == 0:", "+ return a", "-print((int(A * B / fractions.gcd(A, B))))", "+", "+def lcm(a, b):", "+ return int((a * b) // gcd(a, b))", "+",...
false
0.044225
0.033595
1.316404
[ "s128274808", "s416885036" ]
u744920373
p03252
python
s103435485
s819426360
257
174
49,200
3,760
Accepted
Accepted
32.3
def ad_list_gen(S): l = len(S) ad_list = [[] for i in range(l)] al_dict = {} for i, moji in enumerate(S): if moji not in al_dict: al_dict[moji] = i else: ad_list[al_dict[moji]].append(i) return ad_list S = eval(input()) T = eval(input()) ...
S = eval(input()) T = eval(input()) #ad_list = [[] for i in range(26)] #ad_list2 = [[] for i in range(26)] num = 97 al_dict = {} al_dict2 = {} new = '' new2 = '' for i, moji in enumerate(S): if moji not in al_dict: al_dict[moji] = i new += chr(num) num += 1 else: ...
22
32
426
588
def ad_list_gen(S): l = len(S) ad_list = [[] for i in range(l)] al_dict = {} for i, moji in enumerate(S): if moji not in al_dict: al_dict[moji] = i else: ad_list[al_dict[moji]].append(i) return ad_list S = eval(input()) T = eval(input()) ad_list = ad_list_ge...
S = eval(input()) T = eval(input()) # ad_list = [[] for i in range(26)] # ad_list2 = [[] for i in range(26)] num = 97 al_dict = {} al_dict2 = {} new = "" new2 = "" for i, moji in enumerate(S): if moji not in al_dict: al_dict[moji] = i new += chr(num) num += 1 else: new += new[al_...
false
31.25
[ "-def ad_list_gen(S):", "- l = len(S)", "- ad_list = [[] for i in range(l)]", "- al_dict = {}", "- for i, moji in enumerate(S):", "- if moji not in al_dict:", "- al_dict[moji] = i", "- else:", "- ad_list[al_dict[moji]].append(i)", "- return ad_lis...
false
0.075173
0.055489
1.35473
[ "s103435485", "s819426360" ]
u049182844
p02675
python
s601207619
s193385447
24
20
9,072
9,116
Accepted
Accepted
16.67
digit_1 = int(eval(input())) % 10 if digit_1 in [2 , 4 , 5 ,7 ,9]: print('hon') elif digit_1 in [0 , 1 , 6 , 8]: print('pon') elif digit_1 == 3: print("bon")
N = int(input()[-1]) if N in [2,4,5,7,9]: print('hon') elif N in [0,1,6,8]: print('pon') elif N in [3]: print('bon')
10
7
176
129
digit_1 = int(eval(input())) % 10 if digit_1 in [2, 4, 5, 7, 9]: print("hon") elif digit_1 in [0, 1, 6, 8]: print("pon") elif digit_1 == 3: print("bon")
N = int(input()[-1]) if N in [2, 4, 5, 7, 9]: print("hon") elif N in [0, 1, 6, 8]: print("pon") elif N in [3]: print("bon")
false
30
[ "-digit_1 = int(eval(input())) % 10", "-if digit_1 in [2, 4, 5, 7, 9]:", "+N = int(input()[-1])", "+if N in [2, 4, 5, 7, 9]:", "-elif digit_1 in [0, 1, 6, 8]:", "+elif N in [0, 1, 6, 8]:", "-elif digit_1 == 3:", "+elif N in [3]:" ]
false
0.045898
0.047171
0.973028
[ "s601207619", "s193385447" ]
u610192658
p03317
python
s677503577
s268733497
42
18
13,812
3,060
Accepted
Accepted
57.14
import math N, K = list(map(int, input().split())) A_list = [int(i) for i in input().split()] print((math.ceil((N-1)/(K-1))))
import math N, K = list(map(int, input().split())) print((math.ceil((N-1)/(K-1))))
5
3
122
76
import math N, K = list(map(int, input().split())) A_list = [int(i) for i in input().split()] print((math.ceil((N - 1) / (K - 1))))
import math N, K = list(map(int, input().split())) print((math.ceil((N - 1) / (K - 1))))
false
40
[ "-A_list = [int(i) for i in input().split()]" ]
false
0.038379
0.037321
1.028363
[ "s677503577", "s268733497" ]
u369094007
p02880
python
s356791483
s289136517
21
17
3,316
2,940
Accepted
Accepted
19.05
N = int(eval(input())) for i in range(1, 10): if N % i == 0 and N // i <= 9: print('Yes') exit() print('No')
N = int(eval(input())) for i in range(1, 10): for j in range(1, 10): if N == i * j: print('Yes') exit() print('No')
6
7
117
133
N = int(eval(input())) for i in range(1, 10): if N % i == 0 and N // i <= 9: print("Yes") exit() print("No")
N = int(eval(input())) for i in range(1, 10): for j in range(1, 10): if N == i * j: print("Yes") exit() print("No")
false
14.285714
[ "- if N % i == 0 and N // i <= 9:", "- print(\"Yes\")", "- exit()", "+ for j in range(1, 10):", "+ if N == i * j:", "+ print(\"Yes\")", "+ exit()" ]
false
0.008478
0.042697
0.198568
[ "s356791483", "s289136517" ]
u644907318
p02726
python
s601940968
s439710547
1,141
677
73,948
111,244
Accepted
Accepted
40.67
import heapq INFTY = 10**4 N,X,Y = list(map(int,input().split())) C = {k:0 for k in range(N)} G = {i:[] for i in range(1,N+1)} G[1].append(2) G[N].append(N-1) for i in range(2,N): G[i].append(i-1) G[i].append(i+1) G[X].append(Y) G[Y].append(X) for i in range(1,N+1): heap = [(0,i)] dist = [...
import heapq INFTY = 10**4 N,X,Y = list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} for i in range(1,N): G[i].append(i+1) G[i+1].append(i) G[X].append(Y) G[Y].append(X) dist = [[INFTY for _ in range(N+1)] for _ in range(N+1)] for i in range(N+1): dist[i][i] = 0 for i in range(1,N+...
29
31
739
823
import heapq INFTY = 10**4 N, X, Y = list(map(int, input().split())) C = {k: 0 for k in range(N)} G = {i: [] for i in range(1, N + 1)} G[1].append(2) G[N].append(N - 1) for i in range(2, N): G[i].append(i - 1) G[i].append(i + 1) G[X].append(Y) G[Y].append(X) for i in range(1, N + 1): heap = [(0, i)] di...
import heapq INFTY = 10**4 N, X, Y = list(map(int, input().split())) G = {i: [] for i in range(1, N + 1)} for i in range(1, N): G[i].append(i + 1) G[i + 1].append(i) G[X].append(Y) G[Y].append(X) dist = [[INFTY for _ in range(N + 1)] for _ in range(N + 1)] for i in range(N + 1): dist[i][i] = 0 for i in ran...
false
6.451613
[ "-C = {k: 0 for k in range(N)}", "-G[1].append(2)", "-G[N].append(N - 1)", "-for i in range(2, N):", "- G[i].append(i - 1)", "+for i in range(1, N):", "+ G[i + 1].append(i)", "+dist = [[INFTY for _ in range(N + 1)] for _ in range(N + 1)]", "+for i in range(N + 1):", "+ dist[i][i] = 0", ...
false
0.037817
0.03664
1.032129
[ "s601940968", "s439710547" ]
u298297089
p03078
python
s912883355
s501884494
1,072
64
5,900
5,164
Accepted
Accepted
94.03
*xyz,k = list(map(int, input().split())) xyz_list = [] xyz_list.append(list(map(int, input().split()))) xyz_list.append(list(map(int, input().split()))) xyz_list.append(list(map(int, input().split()))) xyz_list[0].sort(reverse=True) xyz_list[1].sort(reverse=True) xyz_list[2].sort(reverse=True) print((xyz_lis...
from itertools import product from heapq import heappop, heappush x,y,z,k = map(int,input().split()) a = sorted(map(int, input().split()), reverse=True) b = sorted(map(int, input().split()), reverse=True) c = sorted(map(int, input().split()), reverse=True) if x * y * z <= 3000: lst = sorted([sum(i) for i i...
37
38
1,249
1,334
*xyz, k = list(map(int, input().split())) xyz_list = [] xyz_list.append(list(map(int, input().split()))) xyz_list.append(list(map(int, input().split()))) xyz_list.append(list(map(int, input().split()))) xyz_list[0].sort(reverse=True) xyz_list[1].sort(reverse=True) xyz_list[2].sort(reverse=True) print((xyz_list[0][0] + ...
from itertools import product from heapq import heappop, heappush x, y, z, k = map(int, input().split()) a = sorted(map(int, input().split()), reverse=True) b = sorted(map(int, input().split()), reverse=True) c = sorted(map(int, input().split()), reverse=True) if x * y * z <= 3000: lst = sorted([sum(i) for i in pr...
false
2.631579
[ "-*xyz, k = list(map(int, input().split()))", "-xyz_list = []", "-xyz_list.append(list(map(int, input().split())))", "-xyz_list.append(list(map(int, input().split())))", "-xyz_list.append(list(map(int, input().split())))", "-xyz_list[0].sort(reverse=True)", "-xyz_list[1].sort(reverse=True)", "-xyz_lis...
false
0.04223
0.036545
1.155561
[ "s912883355", "s501884494" ]
u802963389
p03408
python
s851562007
s316781768
23
20
3,316
3,316
Accepted
Accepted
13.04
import collections N = int(eval(input())) s = [eval(input()) for i in range(N)] M = int(eval(input())) t = [eval(input()) for i in range(M)] cs = collections.Counter(s) ct = collections.Counter(t) ans = 0 for k in list(cs.keys()): # print(k, cs[k], ct[k]) c = cs[k] - ct[k] if c > ans: ans = c pr...
N = int(eval(input())) s = [eval(input()) for _ in range(N)] M = int(eval(input())) t = [eval(input()) for _ in range(M)] from collections import Counter sc = Counter(s) tc = Counter(t) print((max(0, max([sc[i] - tc[i] for i in sc]))))
15
11
306
225
import collections N = int(eval(input())) s = [eval(input()) for i in range(N)] M = int(eval(input())) t = [eval(input()) for i in range(M)] cs = collections.Counter(s) ct = collections.Counter(t) ans = 0 for k in list(cs.keys()): # print(k, cs[k], ct[k]) c = cs[k] - ct[k] if c > ans: ans = c prin...
N = int(eval(input())) s = [eval(input()) for _ in range(N)] M = int(eval(input())) t = [eval(input()) for _ in range(M)] from collections import Counter sc = Counter(s) tc = Counter(t) print((max(0, max([sc[i] - tc[i] for i in sc]))))
false
26.666667
[ "-import collections", "+N = int(eval(input()))", "+s = [eval(input()) for _ in range(N)]", "+M = int(eval(input()))", "+t = [eval(input()) for _ in range(M)]", "+from collections import Counter", "-N = int(eval(input()))", "-s = [eval(input()) for i in range(N)]", "-M = int(eval(input()))", "-t =...
false
0.047912
0.047867
1.000943
[ "s851562007", "s316781768" ]
u264972437
p02386
python
s733024142
s707743752
1,420
80
7,824
7,828
Accepted
Accepted
94.37
class dice: def __init__(self,data): self.faces = data def turn(self,direction): if direction == 'N': idx = [1,5,2,3,0,4] self.faces = [self.faces[i] for i in idx] elif direction == 'S': [self.turn('N') for i in range(3)] elif direction == 'E': idx = [3,1,0,5,4,2] self.faces = [se...
class dice: def __init__(self,data): self.faces = data def turn(self,direction): if direction == 'N': idx = [1,5,2,3,0,4] self.faces = [self.faces[i] for i in idx] elif direction == 'S': [self.turn('N') for i in range(3)] elif direction == 'E': idx = [3,1,0,5,4,2] self.faces = [se...
43
40
992
1,025
class dice: def __init__(self, data): self.faces = data def turn(self, direction): if direction == "N": idx = [1, 5, 2, 3, 0, 4] self.faces = [self.faces[i] for i in idx] elif direction == "S": [self.turn("N") for i in range(3)] elif direction...
class dice: def __init__(self, data): self.faces = data def turn(self, direction): if direction == "N": idx = [1, 5, 2, 3, 0, 4] self.faces = [self.faces[i] for i in idx] elif direction == "S": [self.turn("N") for i in range(3)] elif direction...
false
6.976744
[ "-def isunique(d1, d2):", "+def min_side(dice):", "+ num = [int(\"\".join([str(i) for i in dice.faces]))]", "- if d1.faces == d2.faces:", "- break", "- else:", "- d2.turn(o)", "- if d1.faces == d2.faces:", "- return False", "- else:", "- ...
false
0.067108
0.037753
1.777558
[ "s733024142", "s707743752" ]
u736729525
p03557
python
s898534616
s132075686
374
328
24,180
24,052
Accepted
Accepted
12.3
from bisect import bisect_right N = int(eval(input())) A = sorted(int(x) for x in input().split()) B = sorted(int(x) for x in input().split()) C = sorted(int(x) for x in input().split()) b2c = [0] * (N+1) for i in range(N): b = B[i] j = bisect_right(C, b) b2c[i] = N - j #print("B[%d]=%5d"%...
def main(): from bisect import bisect_right N = int(eval(input())) A = sorted(int(x) for x in input().split()) B = sorted(int(x) for x in input().split()) C = sorted(int(x) for x in input().split()) b2c = [0] * (N+1) for i in range(N): b = B[i] j = bisect_right(C...
30
31
603
718
from bisect import bisect_right N = int(eval(input())) A = sorted(int(x) for x in input().split()) B = sorted(int(x) for x in input().split()) C = sorted(int(x) for x in input().split()) b2c = [0] * (N + 1) for i in range(N): b = B[i] j = bisect_right(C, b) b2c[i] = N - j # print("B[%d]=%5d"%(i,b), "C[...
def main(): from bisect import bisect_right N = int(eval(input())) A = sorted(int(x) for x in input().split()) B = sorted(int(x) for x in input().split()) C = sorted(int(x) for x in input().split()) b2c = [0] * (N + 1) for i in range(N): b = B[i] j = bisect_right(C, b) ...
false
3.225806
[ "-from bisect import bisect_right", "+def main():", "+ from bisect import bisect_right", "-N = int(eval(input()))", "-A = sorted(int(x) for x in input().split())", "-B = sorted(int(x) for x in input().split())", "-C = sorted(int(x) for x in input().split())", "-b2c = [0] * (N + 1)", "-for i in ra...
false
0.041112
0.038447
1.069324
[ "s898534616", "s132075686" ]
u936985471
p03946
python
s342361988
s403000805
104
68
15,020
14,628
Accepted
Accepted
34.62
# ans = 売る可能性がある場所の数 = 売って利益が最大値になる可能性がある場所 # Tは関係ない N,T=list(map(int,input().split())) A=list(map(int,input().split())) # 売る場所を一つず右にずらす # それより前の場所の最安値を持っておく # 差分のmaxvalを満たす回数をカウント、maxvalが更新されたら回数は1に戻す INF=10**9+1 maxval=0 minval=INF ans=0 for i in range(1,len(A)): minval=min(A[i-1],minval) diff=...
import sys readline = sys.stdin.readline # そこまでの最小値を記録する # 最小値との差が最大になった時点で、その値を記録し、1を計上 # 最小値との差がこれまでの最大値と同じ場合は+1を計上 # 最小値との差の最大値が更新された場合はまた1から計上 # Tは関係ない N,T = list(map(int,readline().split())) A = list(map(int,readline().split())) minval = 10 ** 9 + 1 # そこまでの最小値 maxdiff = 0 # そこまでの差の最大値 ans = 0 for...
24
27
421
499
# ans = 売る可能性がある場所の数 = 売って利益が最大値になる可能性がある場所 # Tは関係ない N, T = list(map(int, input().split())) A = list(map(int, input().split())) # 売る場所を一つず右にずらす # それより前の場所の最安値を持っておく # 差分のmaxvalを満たす回数をカウント、maxvalが更新されたら回数は1に戻す INF = 10**9 + 1 maxval = 0 minval = INF ans = 0 for i in range(1, len(A)): minval = min(A[i - 1], minval) ...
import sys readline = sys.stdin.readline # そこまでの最小値を記録する # 最小値との差が最大になった時点で、その値を記録し、1を計上 # 最小値との差がこれまでの最大値と同じ場合は+1を計上 # 最小値との差の最大値が更新された場合はまた1から計上 # Tは関係ない N, T = list(map(int, readline().split())) A = list(map(int, readline().split())) minval = 10**9 + 1 # そこまでの最小値 maxdiff = 0 # そこまでの差の最大値 ans = 0 for a in A: i...
false
11.111111
[ "-# ans = 売る可能性がある場所の数 = 売って利益が最大値になる可能性がある場所", "+import sys", "+", "+readline = sys.stdin.readline", "+# そこまでの最小値を記録する", "+# 最小値との差が最大になった時点で、その値を記録し、1を計上", "+# 最小値との差がこれまでの最大値と同じ場合は+1を計上", "+# 最小値との差の最大値が更新された場合はまた1から計上", "-N, T = list(map(int, input().split()))", "-A = list(map(int, input().spl...
false
0.078612
0.052645
1.493255
[ "s342361988", "s403000805" ]
u813174766
p03196
python
s863580349
s551743739
518
389
9,180
9,160
Accepted
Accepted
24.9
n, p = list(map(int,input().split())) if n == 1: print(p) elif n > 40: print((1)) else: ans = 1 i = 1 while(True): if i ** n > p: break if p % (i ** n) == 0: ans = i i += 1 print(ans)
n, p = list(map(int,input().split())) ans = 1 if n == 1: ans = p elif n > 40: pass else: i = 1 while(True): t = i ** n if t > p: break if p % t == 0: ans = i i += 1 print(ans)
15
16
225
220
n, p = list(map(int, input().split())) if n == 1: print(p) elif n > 40: print((1)) else: ans = 1 i = 1 while True: if i**n > p: break if p % (i**n) == 0: ans = i i += 1 print(ans)
n, p = list(map(int, input().split())) ans = 1 if n == 1: ans = p elif n > 40: pass else: i = 1 while True: t = i**n if t > p: break if p % t == 0: ans = i i += 1 print(ans)
false
6.25
[ "+ans = 1", "- print(p)", "+ ans = p", "- print((1))", "+ pass", "- ans = 1", "- if i**n > p:", "+ t = i**n", "+ if t > p:", "- if p % (i**n) == 0:", "+ if p % t == 0:", "- print(ans)", "+print(ans)" ]
false
0.043409
0.045613
0.95167
[ "s863580349", "s551743739" ]
u225388820
p02708
python
s277729949
s650376000
153
126
19,364
9,120
Accepted
Accepted
17.65
n,k=list(map(int,input().split())) ans=0 mod=10**9+7 b=[0]+[i for i in range(n+1)] for i in range(1,n+2): b[i]+=b[i-1] for i in range(k,n+2): ans+=b[n+1]-b[n-i+1]-b[i]+1 ans%=mod print(ans)
n,k=list(map(int,input().split())) ans=0 mod=10**9+7 for i in range(k,n+2): ans+=(2*n-i+1)*i//2-i*(i-1)//2+1 ans%=mod print(ans)
11
7
206
136
n, k = list(map(int, input().split())) ans = 0 mod = 10**9 + 7 b = [0] + [i for i in range(n + 1)] for i in range(1, n + 2): b[i] += b[i - 1] for i in range(k, n + 2): ans += b[n + 1] - b[n - i + 1] - b[i] + 1 ans %= mod print(ans)
n, k = list(map(int, input().split())) ans = 0 mod = 10**9 + 7 for i in range(k, n + 2): ans += (2 * n - i + 1) * i // 2 - i * (i - 1) // 2 + 1 ans %= mod print(ans)
false
36.363636
[ "-b = [0] + [i for i in range(n + 1)]", "-for i in range(1, n + 2):", "- b[i] += b[i - 1]", "- ans += b[n + 1] - b[n - i + 1] - b[i] + 1", "+ ans += (2 * n - i + 1) * i // 2 - i * (i - 1) // 2 + 1" ]
false
0.228963
0.10997
2.08205
[ "s277729949", "s650376000" ]
u117348081
p03252
python
s344436351
s761646643
200
89
41,712
3,632
Accepted
Accepted
55.5
import collections s = eval(input()) t = eval(input()) s = collections.Counter(s) t = collections.Counter(t) if sorted(s.values()) == sorted(t.values()): print("Yes") else: 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") break if y not in dict_ts: dict_ts[y]=x else: if dict_ts[y]!=x: ...
9
22
185
372
import collections s = eval(input()) t = eval(input()) s = collections.Counter(s) t = collections.Counter(t) if sorted(s.values()) == sorted(t.values()): print("Yes") else: 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") break if y not in dict_ts: dict_ts[y] = x else: if dict_ts[y] != x: print("No...
false
59.090909
[ "-import collections", "-", "-s = collections.Counter(s)", "-t = collections.Counter(t)", "-if sorted(s.values()) == sorted(t.values()):", "+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] ...
false
0.036442
0.042295
0.861613
[ "s344436351", "s761646643" ]
u796942881
p03557
python
s946389125
s659710261
783
316
23,328
22,720
Accepted
Accepted
59.64
def main(): N = int(eval(input())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) def lowerBound(a, v): # 以上 return lb(a, 0, len(a), v) def upperBound(a, v): # より大きい # 値をプラス1 ...
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) An = sorted(map(int, input().split())) Bn = sorted(map(int, input().split())) Cn = sorted(map(int, input().split())) ans = 0 lx = 0 ux = 0 for Bi in Bn: # ...
35
28
711
493
def main(): N = int(eval(input())) A = sorted(map(int, input().split())) B = sorted(map(int, input().split())) C = sorted(map(int, input().split())) def lowerBound(a, v): # 以上 return lb(a, 0, len(a), v) def upperBound(a, v): # より大きい # 値をプラス1 return lb(a,...
def main(): from bisect import bisect_left from bisect import bisect_right N = int(eval(input())) An = sorted(map(int, input().split())) Bn = sorted(map(int, input().split())) Cn = sorted(map(int, input().split())) ans = 0 lx = 0 ux = 0 for Bi in Bn: # 以上 lx = bi...
false
20
[ "+ from bisect import bisect_left", "+ from bisect import bisect_right", "+", "- A = sorted(map(int, input().split()))", "- B = sorted(map(int, input().split()))", "- C = sorted(map(int, input().split()))", "-", "- def lowerBound(a, v):", "+ An = sorted(map(int, input().split())...
false
0.045458
0.040302
1.127939
[ "s946389125", "s659710261" ]
u691018832
p02699
python
s465055373
s996452971
60
25
61,564
9,168
Accepted
Accepted
58.33
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) s, w = list(map(int, readline().split())) if w >= s: print('unsafe') else: print('safe')
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) s, w = list(map(int, read().split())) if w >= s: print('unsafe') else: print('safe')
11
11
249
245
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) s, w = list(map(int, readline().split())) if w >= s: print("unsafe") else: print("safe")
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) s, w = list(map(int, read().split())) if w >= s: print("unsafe") else: print("safe")
false
0
[ "-s, w = list(map(int, readline().split()))", "+s, w = list(map(int, read().split()))" ]
false
0.034916
0.040234
0.86784
[ "s465055373", "s996452971" ]
u644907318
p03393
python
s728541451
s632525535
170
74
38,256
61,728
Accepted
Accepted
56.47
S = input().strip() C = {chr(i):0 for i in range(97,123)} n = len(S) for a in S: C[a] += 1 flag = 0 for i in range(97,123): if C[chr(i)]==0: x = S+chr(i) flag = 1 break if flag==0: cnt = -2 while cnt>=-n: b = S[cnt] A = [] for i in range(n+...
S = input().strip() if len(S)<26: for i in range(97,123): if chr(i) not in S: print((S+chr(i))) break else: flag = 0 for i in range(24,-1,-1): if S[i]<S[i+1]: a = S[i] for j in range(25,i,-1): if S[j]>a: ...
29
19
584
467
S = input().strip() C = {chr(i): 0 for i in range(97, 123)} n = len(S) for a in S: C[a] += 1 flag = 0 for i in range(97, 123): if C[chr(i)] == 0: x = S + chr(i) flag = 1 break if flag == 0: cnt = -2 while cnt >= -n: b = S[cnt] A = [] for i in range(n + cnt...
S = input().strip() if len(S) < 26: for i in range(97, 123): if chr(i) not in S: print((S + chr(i))) break else: flag = 0 for i in range(24, -1, -1): if S[i] < S[i + 1]: a = S[i] for j in range(25, i, -1): if S[j] > a: ...
false
34.482759
[ "-C = {chr(i): 0 for i in range(97, 123)}", "-n = len(S)", "-for a in S:", "- C[a] += 1", "-flag = 0", "-for i in range(97, 123):", "- if C[chr(i)] == 0:", "- x = S + chr(i)", "- flag = 1", "- break", "-if flag == 0:", "- cnt = -2", "- while cnt >= -n:", "-...
false
0.036876
0.038456
0.958912
[ "s728541451", "s632525535" ]
u270144704
p03162
python
s459501151
s659246642
737
618
75,096
66,776
Accepted
Accepted
16.15
def main(): n = int(eval(input())) x = [] for _ in range(n): a, b, c = list(map(int, input().split())) x.append([a, b, c]) dp = [[0] * 3 for _ in range(n)] # i日目の幸福度dp[i-1] # まず1日目の幸福度を設定 dp[0] = [x[0][l] for l in range(3)] for i in range(1,n): for j in...
def main(): n = int(eval(input())) x = [] for _ in range(n): a, b, c = list(map(int, input().split())) x.append((a, b, c)) dp0 = [0]*(n+1) dp1 = [0]*(n+1) dp2 = [0]*(n+1) for i in range(1,n+1): a, b, c = x[i-1] dp0[i] = max(dp1[i-1]+a, dp2[i-1]+a) ...
17
18
474
480
def main(): n = int(eval(input())) x = [] for _ in range(n): a, b, c = list(map(int, input().split())) x.append([a, b, c]) dp = [[0] * 3 for _ in range(n)] # i日目の幸福度dp[i-1] # まず1日目の幸福度を設定 dp[0] = [x[0][l] for l in range(3)] for i in range(1, n): for j in range(3):...
def main(): n = int(eval(input())) x = [] for _ in range(n): a, b, c = list(map(int, input().split())) x.append((a, b, c)) dp0 = [0] * (n + 1) dp1 = [0] * (n + 1) dp2 = [0] * (n + 1) for i in range(1, n + 1): a, b, c = x[i - 1] dp0[i] = max(dp1[i - 1] + a, dp2...
false
5.555556
[ "- x.append([a, b, c])", "- dp = [[0] * 3 for _ in range(n)]", "- # i日目の幸福度dp[i-1]", "- # まず1日目の幸福度を設定", "- dp[0] = [x[0][l] for l in range(3)]", "- for i in range(1, n):", "- for j in range(3):", "- dp[i][j] = max(", "- [dp[i - 1][k] + x[i][j] ...
false
0.083666
0.045146
1.853247
[ "s459501151", "s659246642" ]
u543954314
p02881
python
s939863775
s168232940
181
115
3,060
3,296
Accepted
Accepted
36.46
n = int(eval(input())) ans = n for i in range(1,int(n**.5)+2): if n%i == 0: ans = min(ans, i + n//i - 2) print(ans)
def divisor(n): ass = [] for i in range(1, int(n**0.5)+1): if n%i == 0: ass.append(i) ass.append(n//i) return sorted(ass) n = int(eval(input())) p = divisor(n) ans = n + 10 for x in p: if x*x > n: break y = n//x if ans > y+x: ans = y+x print((a...
6
18
120
320
n = int(eval(input())) ans = n for i in range(1, int(n**0.5) + 2): if n % i == 0: ans = min(ans, i + n // i - 2) print(ans)
def divisor(n): ass = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: ass.append(i) ass.append(n // i) return sorted(ass) n = int(eval(input())) p = divisor(n) ans = n + 10 for x in p: if x * x > n: break y = n // x if ans > y + x: ans = y ...
false
66.666667
[ "+def divisor(n):", "+ ass = []", "+ for i in range(1, int(n**0.5) + 1):", "+ if n % i == 0:", "+ ass.append(i)", "+ ass.append(n // i)", "+ return sorted(ass)", "+", "+", "-ans = n", "-for i in range(1, int(n**0.5) + 2):", "- if n % i == 0:", "- ...
false
0.082398
0.047936
1.718918
[ "s939863775", "s168232940" ]
u862417957
p02792
python
s773157870
s220292434
1,007
899
9,244
9,168
Accepted
Accepted
10.72
# !/usr/bin/python3 """ https://atcoder.jp/contests/abc152/tasks/abc152_d Low Elements. """ def solve(n): res = 0 for num in range(n+1): start = int(str(num)[0]) end = int(str(num)[-1]) for i in range(10): for j in range(10): if i == start ...
# !/usr/bin/python3 """ https://atcoder.jp/contests/abc152/tasks/abc152_d Low Elements. """ def solve(n): res = 0 for num in range(n+1): start = int(str(num)[0]) end = int(str(num)[-1]) for i in range(1, 10): for j in range(1, 10): if i == ...
31
31
632
638
# !/usr/bin/python3 """ https://atcoder.jp/contests/abc152/tasks/abc152_d Low Elements. """ def solve(n): res = 0 for num in range(n + 1): start = int(str(num)[0]) end = int(str(num)[-1]) for i in range(10): for j in range(10): if i == start and j == end: ...
# !/usr/bin/python3 """ https://atcoder.jp/contests/abc152/tasks/abc152_d Low Elements. """ def solve(n): res = 0 for num in range(n + 1): start = int(str(num)[0]) end = int(str(num)[-1]) for i in range(1, 10): for j in range(1, 10): if i == start and j == e...
false
0
[ "- for i in range(10):", "- for j in range(10):", "+ for i in range(1, 10):", "+ for j in range(1, 10):" ]
false
0.273877
0.236529
1.157901
[ "s773157870", "s220292434" ]
u410269178
p02684
python
s835735350
s771098799
242
162
34,104
32,216
Accepted
Accepted
33.06
from collections import deque n, k = list(map(int, input().split())) a = list(map(int, input().split())) g = [i for i in range(n)] for i in range(n): g[i] = a[i]-1 dist =[-1]*n dist[0] = 0 q = deque([0]) hajimari = -1 loopnum = -1 while q: v = q.popleft() u = g[v] if dist[u] == -1: ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) dist = [-1] * n dist[0] = 0 now = 0 while True: next = a[now] - 1 if dist[next] == -1: dist[next] = dist[now] + 1 else: hajimari = next loopnum = dist[now] + 1 - dist[hajimari] town = 0 ...
33
23
702
609
from collections import deque n, k = list(map(int, input().split())) a = list(map(int, input().split())) g = [i for i in range(n)] for i in range(n): g[i] = a[i] - 1 dist = [-1] * n dist[0] = 0 q = deque([0]) hajimari = -1 loopnum = -1 while q: v = q.popleft() u = g[v] if dist[u] == -1: dist[u]...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) dist = [-1] * n dist[0] = 0 now = 0 while True: next = a[now] - 1 if dist[next] == -1: dist[next] = dist[now] + 1 else: hajimari = next loopnum = dist[now] + 1 - dist[hajimari] town = 0 if k <=...
false
30.30303
[ "-from collections import deque", "-", "-g = [i for i in range(n)]", "-for i in range(n):", "- g[i] = a[i] - 1", "-q = deque([0])", "-hajimari = -1", "-loopnum = -1", "-while q:", "- v = q.popleft()", "- u = g[v]", "- if dist[u] == -1:", "- dist[u] = dist[v] + 1", "- ...
false
0.04293
0.045
0.953992
[ "s835735350", "s771098799" ]
u796942881
p03361
python
s032252915
s019595375
20
18
3,064
3,064
Accepted
Accepted
10
def main(): # 下、右、上、左 dy = [1, 0, -1, 0] dx = [0, 1, 0, -1] H, W = map(int, input().split()) s = [input() for i in range(H)] for y in range(H): for x in range(W): if s[y][x] == '.': continue cnt = 0 for i, j in zip(dy, dx): ...
def main(): # 下、右、上、左 dy = [1, 0, -1, 0] dx = [0, 1, 0, -1] H, W = map(int, input().split()) s = [["."] * (W + 2)] s.extend([["."] + list(input()) + ["."] for i in range(H)]) s.append(["."] * (W + 2)) for y in range(1, H + 1): for x in range(1, W + 1): if s[...
27
21
684
635
def main(): # 下、右、上、左 dy = [1, 0, -1, 0] dx = [0, 1, 0, -1] H, W = map(int, input().split()) s = [input() for i in range(H)] for y in range(H): for x in range(W): if s[y][x] == ".": continue cnt = 0 for i, j in zip(dy, dx): ...
def main(): # 下、右、上、左 dy = [1, 0, -1, 0] dx = [0, 1, 0, -1] H, W = map(int, input().split()) s = [["."] * (W + 2)] s.extend([["."] + list(input()) + ["."] for i in range(H)]) s.append(["."] * (W + 2)) for y in range(1, H + 1): for x in range(1, W + 1): if ( ...
false
22.222222
[ "- s = [input() for i in range(H)]", "- for y in range(H):", "- for x in range(W):", "- if s[y][x] == \".\":", "- continue", "- cnt = 0", "- for i, j in zip(dy, dx):", "- ny = y + i", "- nx = x + j", "- ...
false
0.042024
0.042853
0.98065
[ "s032252915", "s019595375" ]
u297574184
p03290
python
s339171861
s928732529
303
22
3,188
3,064
Accepted
Accepted
92.74
INF = float('inf') D, G = list(map(int, input().split())) pcs = [tuple(map(int, input().split())) for i in range(D)] sumP = sum([p for p, c in pcs]) def max2(a, b): return a if a >= b else b # 【配るDP】 # dp[i+1][j]: pcs[i]まで考慮したとき、j問で達成できるスコアの最大値 dp = [[-INF] * (sumP + 1) for i in range(D + 1)] dp[...
from math import ceil D, G = list(map(int, input().split())) ps, cs = [], [] for _ in range(D): p, c = list(map(int, input().split())) ps.append(p) cs.append(c) ans = 1000 for pat in range(2 ** D): score = 0 num = 0 for i in range(D): if pat & (1 << i): score...
26
28
714
576
INF = float("inf") D, G = list(map(int, input().split())) pcs = [tuple(map(int, input().split())) for i in range(D)] sumP = sum([p for p, c in pcs]) def max2(a, b): return a if a >= b else b # 【配るDP】 # dp[i+1][j]: pcs[i]まで考慮したとき、j問で達成できるスコアの最大値 dp = [[-INF] * (sumP + 1) for i in range(D + 1)] dp[0][0] = 0 for i...
from math import ceil D, G = list(map(int, input().split())) ps, cs = [], [] for _ in range(D): p, c = list(map(int, input().split())) ps.append(p) cs.append(c) ans = 1000 for pat in range(2**D): score = 0 num = 0 for i in range(D): if pat & (1 << i): score += 100 * (i + 1) ...
false
7.142857
[ "-INF = float(\"inf\")", "+from math import ceil", "+", "-pcs = [tuple(map(int, input().split())) for i in range(D)]", "-sumP = sum([p for p, c in pcs])", "-", "-", "-def max2(a, b):", "- return a if a >= b else b", "-", "-", "-# 【配るDP】", "-# dp[i+1][j]: pcs[i]まで考慮したとき、j問で達成できるスコアの最大値", ...
false
0.037748
0.049344
0.764999
[ "s339171861", "s928732529" ]