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
u929569377
p03478
python
s731442361
s662967413
37
29
3,060
3,060
Accepted
Accepted
21.62
N, A, B = [int(x) for x in input().split()] ans = 0 for i in range(1, N + 1): s = str(i) SUM = 0 for j in range(len(s)): SUM += int(s[j]) if SUM >= A and SUM <= B: ans += i print(ans)
N, A, B = [int(x) for x in input().split()] ans = 0 for i in range(1, N + 1): SUM = 0 n = i while n > 0: SUM += n % 10 n = n // 10 if SUM >= A and SUM <= B: ans += i print(ans)
13
14
206
202
N, A, B = [int(x) for x in input().split()] ans = 0 for i in range(1, N + 1): s = str(i) SUM = 0 for j in range(len(s)): SUM += int(s[j]) if SUM >= A and SUM <= B: ans += i print(ans)
N, A, B = [int(x) for x in input().split()] ans = 0 for i in range(1, N + 1): SUM = 0 n = i while n > 0: SUM += n % 10 n = n // 10 if SUM >= A and SUM <= B: ans += i print(ans)
false
7.142857
[ "- s = str(i)", "- for j in range(len(s)):", "- SUM += int(s[j])", "+ n = i", "+ while n > 0:", "+ SUM += n % 10", "+ n = n // 10" ]
false
0.048215
0.040474
1.191249
[ "s731442361", "s662967413" ]
u645250356
p03151
python
s360659394
s943901783
309
124
75,932
26,308
Accepted
Accepted
59.87
from collections import Counter,defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue sys.setrecursionlimit(10**8) mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) de...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, ...
32
33
838
698
from collections import Counter, defaultdict, deque import sys, heapq, bisect, math, itertools, string, queue sys.setrecursionlimit(10**8) mod = 10**9 + 7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin....
from collections import Counter, defaultdict, deque from heapq import heappop, heappush from bisect import bisect_left, bisect_right import sys, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return ...
false
3.030303
[ "-import sys, heapq, bisect, math, itertools, string, queue", "+from heapq import heappop, heappush", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools, fractions, pprint", "+INF = float(\"inf\")", "-def inpl_str():", "- return list(sys.stdin.readline().split())", "-", ...
false
0.077625
0.076643
1.012808
[ "s360659394", "s943901783" ]
u569457056
p02720
python
s228741931
s018466537
886
34
4,792
4,868
Accepted
Accepted
96.16
def is_valid(num): if 1 <= num < 10: return True ns = list(map(int, str(num))) n = len(ns) for i in range(n - 1): if abs(ns[i] - ns[i + 1]) > 1: return False return True lunluns = [] for i in range(1, 100000): if is_valid(i): lunluns.append(i) ...
# 20/05/10 cost:20min def is_valid(num): if 1 <= num < 10: return True ns = list(map(int, str(num))) n = len(ns) for i in range(n - 1): if abs(ns[i] - ns[i + 1]) > 1: return False return True lunluns = [] for i in range(1, 10): if is_valid(i): ...
76
78
1,692
1,700
def is_valid(num): if 1 <= num < 10: return True ns = list(map(int, str(num))) n = len(ns) for i in range(n - 1): if abs(ns[i] - ns[i + 1]) > 1: return False return True lunluns = [] for i in range(1, 100000): if is_valid(i): lunluns.append(i) d = {} def d...
# 20/05/10 cost:20min def is_valid(num): if 1 <= num < 10: return True ns = list(map(int, str(num))) n = len(ns) for i in range(n - 1): if abs(ns[i] - ns[i + 1]) > 1: return False return True lunluns = [] for i in range(1, 10): if is_valid(i): lunluns.append...
false
2.564103
[ "+# 20/05/10 cost:20min", "-for i in range(1, 100000):", "+for i in range(1, 10):", "-def dfs2(rem, pre):", "+def dfs2(rem, pre, lt):", "- key = (rem, pre)", "+ key = (rem, pre, lt)", "- if pre == -1:", "+ if lt:", "- res += dfs2(rem - 1, -1 if i == 0 else i)", "+ ...
false
0.955968
0.055701
17.162525
[ "s228741931", "s018466537" ]
u600402037
p02881
python
s503525146
s833909356
139
117
2,940
3,268
Accepted
Accepted
15.83
N = int(eval(input())) root = int(N ** (1/2)) + 1 num = 1 for i in range(root, 0, -1): if N % i == 0: num = i break num2 = N // num print((num+num2-2))
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) def make_divisors(n): # nの約数を列挙 divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: d...
9
26
171
564
N = int(eval(input())) root = int(N ** (1 / 2)) + 1 num = 1 for i in range(root, 0, -1): if N % i == 0: num = i break num2 = N // num print((num + num2 - 2))
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) def make_divisors(n): # nの約数を列挙 divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors....
false
65.384615
[ "-N = int(eval(input()))", "-root = int(N ** (1 / 2)) + 1", "-num = 1", "-for i in range(root, 0, -1):", "- if N % i == 0:", "- num = i", "- break", "-num2 = N // num", "-print((num + num2 - 2))", "+import sys", "+", "+sr = lambda: sys.stdin.readline().rstrip()", "+ir = lamb...
false
0.073684
0.045576
1.616737
[ "s503525146", "s833909356" ]
u816587940
p02713
python
s050721066
s991933972
125
65
67,764
68,416
Accepted
Accepted
48
from math import gcd k = int(eval(input())) ans = 0 for a in range(1, k+1): for b in range(1, k+1): t = gcd(a, b) if t == 1: ans += k continue for c in range(1, k+1): ans += gcd(t, c) print(ans)
from math import gcd k = int(eval(input())) ar = [0] * 41000 for i in range(1, 201): for j in range(1, 201): ar[i*200+j] = gcd(i, j) ans = 0 for a in range(1, k+1): for b in range(1, k+1): d = ar[a*200+b] if d == 1: ans += k continue for c in range(1...
11
16
250
355
from math import gcd k = int(eval(input())) ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): t = gcd(a, b) if t == 1: ans += k continue for c in range(1, k + 1): ans += gcd(t, c) print(ans)
from math import gcd k = int(eval(input())) ar = [0] * 41000 for i in range(1, 201): for j in range(1, 201): ar[i * 200 + j] = gcd(i, j) ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): d = ar[a * 200 + b] if d == 1: ans += k continue for c in ...
false
31.25
[ "+ar = [0] * 41000", "+for i in range(1, 201):", "+ for j in range(1, 201):", "+ ar[i * 200 + j] = gcd(i, j)", "- t = gcd(a, b)", "- if t == 1:", "+ d = ar[a * 200 + b]", "+ if d == 1:", "- ans += gcd(t, c)", "+ ans += ar[d * 200 + c]" ]
false
0.090338
0.090618
0.996903
[ "s050721066", "s991933972" ]
u844646164
p03436
python
s480773989
s964765660
200
80
40,816
74,364
Accepted
Accepted
60
from collections import deque h, w = list(map(int, input().split())) s = [list(eval(input())) for _ in range(h)] moves = ((1, 0), (0, 1), (0, -1), (-1, 0)) def bfs(sy, sx): q = deque([[sy, sx]]) dist = [[float('inf')]*w for _ in range(h)] dist[sy][sx] = 0 while q: y, x = q.poplef...
from collections import deque H, W = list(map(int, input().split())) s = [list(eval(input())) for _ in range(H)] moves = ((1, 0), (0, 1), (0, -1), (-1, 0)) def bfs(sy, sx): q = deque([[sy, sx]]) dist = [[float('inf')]*(W) for _ in range(H)] dist[sy][sx] = 0 while q: y, x = q.pople...
32
36
799
811
from collections import deque h, w = list(map(int, input().split())) s = [list(eval(input())) for _ in range(h)] moves = ((1, 0), (0, 1), (0, -1), (-1, 0)) def bfs(sy, sx): q = deque([[sy, sx]]) dist = [[float("inf")] * w for _ in range(h)] dist[sy][sx] = 0 while q: y, x = q.popleft() ...
from collections import deque H, W = list(map(int, input().split())) s = [list(eval(input())) for _ in range(H)] moves = ((1, 0), (0, 1), (0, -1), (-1, 0)) def bfs(sy, sx): q = deque([[sy, sx]]) dist = [[float("inf")] * (W) for _ in range(H)] dist[sy][sx] = 0 while q: y, x = q.popleft() ...
false
11.111111
[ "-h, w = list(map(int, input().split()))", "-s = [list(eval(input())) for _ in range(h)]", "+H, W = list(map(int, input().split()))", "+s = [list(eval(input())) for _ in range(H)]", "- dist = [[float(\"inf\")] * w for _ in range(h)]", "+ dist = [[float(\"inf\")] * (W) for _ in range(H)]", "- ...
false
0.054502
0.035823
1.521424
[ "s480773989", "s964765660" ]
u108650331
p02695
python
s737012424
s043964846
966
668
9,192
23,320
Accepted
Accepted
30.85
#!/usr/bin/env python3 # スペース区切りの整数の入力 from itertools import combinations_with_replacement as comb_rplc # スペース区切りの整数の入力 N, M, Q = list(map(int, input().split())) #配列の入力 data = [list(map(int, input().split())) for _ in range(Q)] ans = -1 for seq in comb_rplc(list(range(1, M+1)), N): score = 0 f...
#!/usr/bin/env python3 # スペース区切りの整数の入力 from collections import deque def calc(seq): score = 0 for a, b, c, d in data: if seq[b-1] - seq[a-1] == c: score += d return score # スペース区切りの整数の入力 N, M, Q = list(map(int, input().split())) #配列の入力 data = [list(map(int, input().spli...
21
37
440
672
#!/usr/bin/env python3 # スペース区切りの整数の入力 from itertools import combinations_with_replacement as comb_rplc # スペース区切りの整数の入力 N, M, Q = list(map(int, input().split())) # 配列の入力 data = [list(map(int, input().split())) for _ in range(Q)] ans = -1 for seq in comb_rplc(list(range(1, M + 1)), N): score = 0 for a, b, c, d ...
#!/usr/bin/env python3 # スペース区切りの整数の入力 from collections import deque def calc(seq): score = 0 for a, b, c, d in data: if seq[b - 1] - seq[a - 1] == c: score += d return score # スペース区切りの整数の入力 N, M, Q = list(map(int, input().split())) # 配列の入力 data = [list(map(int, input().split())) for...
false
43.243243
[ "-from itertools import combinations_with_replacement as comb_rplc", "+from collections import deque", "+", "+", "+def calc(seq):", "+ score = 0", "+ for a, b, c, d in data:", "+ if seq[b - 1] - seq[a - 1] == c:", "+ score += d", "+ return score", "+", "-for seq in c...
false
0.152714
0.102315
1.492591
[ "s737012424", "s043964846" ]
u970197315
p02803
python
s315795535
s237141903
472
300
3,316
9,332
Accepted
Accepted
36.44
from collections import deque def bfs(sy,sx): dist[sy][sx]=0 q=deque([[sy,sx]]) while q: cy,cx=q.popleft() for i,j in ([1,0],[-1,0],[0,1],[0,-1]): ny,nx=cy+i,cx+j if ny<0 or h-1<ny or nx<0 or w-1<nx or path[ny][nx]=='#':continue if path[ny][nx]=...
from collections import deque def bfs(sy,sx): q=deque([[sy,sx]]) visited[sy][sx]=0 while q: y,x=q.popleft() for dy,dx in ([1,0],[-1,0],[0,1],[0,-1]): ny,nx=y+dy,x+dx if ny<0 or ny>h-1 or nx<0 or nx>w-1 or path[ny][nx]=="#":continue if path[ny][nx]=="." and visited[ny][nx]==-1: ...
31
34
869
809
from collections import deque def bfs(sy, sx): dist[sy][sx] = 0 q = deque([[sy, sx]]) while q: cy, cx = q.popleft() for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]): ny, nx = cy + i, cx + j if ny < 0 or h - 1 < ny or nx < 0 or w - 1 < nx or path[ny][nx] == "#": ...
from collections import deque def bfs(sy, sx): q = deque([[sy, sx]]) visited[sy][sx] = 0 while q: y, x = q.popleft() for dy, dx in ([1, 0], [-1, 0], [0, 1], [0, -1]): ny, nx = y + dy, x + dx if ny < 0 or ny > h - 1 or nx < 0 or nx > w - 1 or path[ny][nx] == "#": ...
false
8.823529
[ "- dist[sy][sx] = 0", "+ visited[sy][sx] = 0", "- cy, cx = q.popleft()", "- for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):", "- ny, nx = cy + i, cx + j", "- if ny < 0 or h - 1 < ny or nx < 0 or w - 1 < nx or path[ny][nx] == \"#\":", "+ y, x = q.popleft()...
false
0.142638
0.03774
3.779478
[ "s315795535", "s237141903" ]
u863370423
p03162
python
s453395436
s675608085
817
505
97,620
45,352
Accepted
Accepted
38.19
n = int(eval(input())) h = [] for _ in range(n): a, b, c = [int(x) for x in input().split()] h.append((a, b, c)) vals = {} a, b, c = h[0] vals[(0, 'A')] = a vals[(0, 'B')] = b vals[(0, 'C')] = c for i in range(1, n): a, b, c = h[i] vals[(i, 'A')] = max(vals[(i-1, 'B')], vals[(i-1, 'C')])...
n = int(eval(input())) a=[0] * (n+1) b=[0] * (n+1) c=[0] * (n+1) aux = [ [0] * 5 for _ in range(n+1)] for i in range(1,n+1): a[i],b[i],c[i] = input().split() a = [int(i) for i in a] b = [int(i) for i in b] c = [int(i) for i in c] aux[1][1]=a[1] aux[1][2]=b[1] aux[1][3]=c[1] for i in range(2...
19
25
519
515
n = int(eval(input())) h = [] for _ in range(n): a, b, c = [int(x) for x in input().split()] h.append((a, b, c)) vals = {} a, b, c = h[0] vals[(0, "A")] = a vals[(0, "B")] = b vals[(0, "C")] = c for i in range(1, n): a, b, c = h[i] vals[(i, "A")] = max(vals[(i - 1, "B")], vals[(i - 1, "C")]) + a val...
n = int(eval(input())) a = [0] * (n + 1) b = [0] * (n + 1) c = [0] * (n + 1) aux = [[0] * 5 for _ in range(n + 1)] for i in range(1, n + 1): a[i], b[i], c[i] = input().split() a = [int(i) for i in a] b = [int(i) for i in b] c = [int(i) for i in c] aux[1][1] = a[1] aux[1][2] = b[1] aux[1][3] = c[1] for i in range(2,...
false
24
[ "-h = []", "-for _ in range(n):", "- a, b, c = [int(x) for x in input().split()]", "- h.append((a, b, c))", "-vals = {}", "-a, b, c = h[0]", "-vals[(0, \"A\")] = a", "-vals[(0, \"B\")] = b", "-vals[(0, \"C\")] = c", "-for i in range(1, n):", "- a, b, c = h[i]", "- vals[(i, \"A\")] ...
false
0.046314
0.03697
1.252745
[ "s453395436", "s675608085" ]
u388297793
p02922
python
s791979832
s311643453
30
25
9,000
9,056
Accepted
Accepted
16.67
import math a,b=list(map(int,input().split())) print((math.ceil((b-1)/(a-1))))
a,b=list(map(int,input().split())) ans,num=0,1 while num<b: num-=1 num+=a ans+=1 print(ans)
3
7
74
103
import math a, b = list(map(int, input().split())) print((math.ceil((b - 1) / (a - 1))))
a, b = list(map(int, input().split())) ans, num = 0, 1 while num < b: num -= 1 num += a ans += 1 print(ans)
false
57.142857
[ "-import math", "-", "-print((math.ceil((b - 1) / (a - 1))))", "+ans, num = 0, 1", "+while num < b:", "+ num -= 1", "+ num += a", "+ ans += 1", "+print(ans)" ]
false
0.049393
0.049023
1.007536
[ "s791979832", "s311643453" ]
u790710233
p03339
python
s047706496
s167264396
294
137
27,148
3,700
Accepted
Accepted
53.4
n = int(eval(input())) s = eval(input()) dp_L = [0]*(n+1) dp_R = [0]*(n+1) for i in range(n): dp_L[i+1] = dp_L[i]+[0, 1][s[i] == 'W'] for i in reversed(list(range(n))): dp_R[i] = dp_R[i+1]+[0, 1][s[i] == 'E'] print((min(L+R for L, R in zip(dp_L, dp_R))))
n = int(eval(input())) s = eval(input()) cnt_R = s.count('E') cnt_L = 0 INF = 10**18 ans = INF for x in s: if x == 'W': ans = min(ans, cnt_L+cnt_R) cnt_L += 1 else: cnt_R -= 1 ans = min(ans, cnt_L+cnt_R) print(ans)
12
14
261
256
n = int(eval(input())) s = eval(input()) dp_L = [0] * (n + 1) dp_R = [0] * (n + 1) for i in range(n): dp_L[i + 1] = dp_L[i] + [0, 1][s[i] == "W"] for i in reversed(list(range(n))): dp_R[i] = dp_R[i + 1] + [0, 1][s[i] == "E"] print((min(L + R for L, R in zip(dp_L, dp_R))))
n = int(eval(input())) s = eval(input()) cnt_R = s.count("E") cnt_L = 0 INF = 10**18 ans = INF for x in s: if x == "W": ans = min(ans, cnt_L + cnt_R) cnt_L += 1 else: cnt_R -= 1 ans = min(ans, cnt_L + cnt_R) print(ans)
false
14.285714
[ "-dp_L = [0] * (n + 1)", "-dp_R = [0] * (n + 1)", "-for i in range(n):", "- dp_L[i + 1] = dp_L[i] + [0, 1][s[i] == \"W\"]", "-for i in reversed(list(range(n))):", "- dp_R[i] = dp_R[i + 1] + [0, 1][s[i] == \"E\"]", "-print((min(L + R for L, R in zip(dp_L, dp_R))))", "+cnt_R = s.count(\"E\")", "...
false
0.041484
0.038857
1.067597
[ "s047706496", "s167264396" ]
u086503932
p03476
python
s084451329
s814775179
1,139
558
4,084
13,720
Accepted
Accepted
51.01
#!/usr/bin/env python3 import sys from bisect import bisect_right def cal_prime(N): prime_list = set() ans_list = set() for i in range(2, N): flag = True for j in range(2, int(i**0.5)+1): if i % j == 0: flag = False break if...
def cal_primes(N): candidate = [*list(range(2, N+1))] primes = [] while candidate[0]**2 <= N: primes.append(candidate[0]) candidate = [*[x for x in candidate if x % candidate[0] != 0]] primes.extend(candidate) return primes Q = int(eval(input())) primes = set(cal_p...
32
25
726
630
#!/usr/bin/env python3 import sys from bisect import bisect_right def cal_prime(N): prime_list = set() ans_list = set() for i in range(2, N): flag = True for j in range(2, int(i**0.5) + 1): if i % j == 0: flag = False break if flag: ...
def cal_primes(N): candidate = [*list(range(2, N + 1))] primes = [] while candidate[0] ** 2 <= N: primes.append(candidate[0]) candidate = [*[x for x in candidate if x % candidate[0] != 0]] primes.extend(candidate) return primes Q = int(eval(input())) primes = set(cal_primes(10**5))...
false
21.875
[ "-#!/usr/bin/env python3", "-import sys", "-from bisect import bisect_right", "+def cal_primes(N):", "+ candidate = [*list(range(2, N + 1))]", "+ primes = []", "+ while candidate[0] ** 2 <= N:", "+ primes.append(candidate[0])", "+ candidate = [*[x for x in candidate if x % can...
false
0.860053
0.245602
3.501815
[ "s084451329", "s814775179" ]
u214617707
p03504
python
s176229585
s258895521
821
751
135,556
93,400
Accepted
Accepted
8.53
N, C = list(map(int, input().split())) M = 10 ** 5 * 2 + 5 T = [[0] * M for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) s = 2 * s - 1 t = 2 * t c -= 1 T[c][s] += 1 T[c][t] -= 1 TT = [[0] * (2 * N) for i in range(C)] for i in range(C): for j in ra...
N, C = list(map(int, input().split())) M = 200005 rec = [[0] * M for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) rec[c - 1][2 * s - 1] += 1 rec[c - 1][2 * t] -= 1 for j in range(C): for i in range(1, M): rec[j][i] += rec[j][i - 1] num = 0 for j in r...
25
22
505
445
N, C = list(map(int, input().split())) M = 10**5 * 2 + 5 T = [[0] * M for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) s = 2 * s - 1 t = 2 * t c -= 1 T[c][s] += 1 T[c][t] -= 1 TT = [[0] * (2 * N) for i in range(C)] for i in range(C): for j in range(1, M): ...
N, C = list(map(int, input().split())) M = 200005 rec = [[0] * M for i in range(C)] for i in range(N): s, t, c = list(map(int, input().split())) rec[c - 1][2 * s - 1] += 1 rec[c - 1][2 * t] -= 1 for j in range(C): for i in range(1, M): rec[j][i] += rec[j][i - 1] num = 0 for j in range(M): tm...
false
12
[ "-M = 10**5 * 2 + 5", "-T = [[0] * M for i in range(C)]", "+M = 200005", "+rec = [[0] * M for i in range(C)]", "- s = 2 * s - 1", "- t = 2 * t", "- c -= 1", "- T[c][s] += 1", "- T[c][t] -= 1", "-TT = [[0] * (2 * N) for i in range(C)]", "-for i in range(C):", "- for j in range...
false
1.446836
1.557574
0.928904
[ "s176229585", "s258895521" ]
u408325839
p03169
python
s279419467
s714074014
1,270
965
322,832
318,288
Accepted
Accepted
24.02
import numpy as np from numba import njit @njit('f8(i8,i8,i8,i8,f8[:,:,:])') def get_expv(N, i, j, k, expv): result = 0.0 if expv[i][j][k] != -1: return expv[i][j][k] nonlp = 1.0 - (N-i-j-k) / N result += 1 if i != 0: result += get_expv(N, i-1, j, k, expv) * (i / N) ...
import numpy as np from numba import njit @njit('f8(i8,i8,i8,i8,f8[:,:,:])', cache=True) def get_expv(N, i, j, k, expv): result = 0.0 if expv[i][j][k] != -1: return expv[i][j][k] nonlp = 1.0 - (N-i-j-k) / N result += 1 if i != 0: result += get_expv(N, i-1, j, k, expv)...
36
36
913
932
import numpy as np from numba import njit @njit("f8(i8,i8,i8,i8,f8[:,:,:])") def get_expv(N, i, j, k, expv): result = 0.0 if expv[i][j][k] != -1: return expv[i][j][k] nonlp = 1.0 - (N - i - j - k) / N result += 1 if i != 0: result += get_expv(N, i - 1, j, k, expv) * (i / N) if ...
import numpy as np from numba import njit @njit("f8(i8,i8,i8,i8,f8[:,:,:])", cache=True) def get_expv(N, i, j, k, expv): result = 0.0 if expv[i][j][k] != -1: return expv[i][j][k] nonlp = 1.0 - (N - i - j - k) / N result += 1 if i != 0: result += get_expv(N, i - 1, j, k, expv) * (i ...
false
0
[ "-@njit(\"f8(i8,i8,i8,i8,f8[:,:,:])\")", "+@njit(\"f8(i8,i8,i8,i8,f8[:,:,:])\", cache=True)" ]
false
0.266247
0.291452
0.91352
[ "s279419467", "s714074014" ]
u492779533
p02608
python
s141920146
s143499677
198
137
9,608
9,580
Accepted
Accepted
30.81
num_limit = int(eval(input())) num_list = [0] * num_limit j_limit = int(num_limit ** 0.5) for j in range(1,j_limit+1): for k in range(1,j + 1): for l in range(1,k+1): if num_limit >= j**2 + k**2 + l**2 + j*k + k*l + l*j: if j > k: if k > l: ...
num_limit = int(eval(input())) num_list = [0] * num_limit j_limit = int(num_limit ** 0.5) for j in range(1,j_limit+1): for k in range(1,j + 1): if num_limit < j**2 + k**2 + j*k: break for l in range(1,k+1): if num_limit < j**2 + k**2 + l**2 + j*k + k*l + l*j: ...
18
22
723
876
num_limit = int(eval(input())) num_list = [0] * num_limit j_limit = int(num_limit**0.5) for j in range(1, j_limit + 1): for k in range(1, j + 1): for l in range(1, k + 1): if num_limit >= j**2 + k**2 + l**2 + j * k + k * l + l * j: if j > k: if k > l: ...
num_limit = int(eval(input())) num_list = [0] * num_limit j_limit = int(num_limit**0.5) for j in range(1, j_limit + 1): for k in range(1, j + 1): if num_limit < j**2 + k**2 + j * k: break for l in range(1, k + 1): if num_limit < j**2 + k**2 + l**2 + j * k + k * l + l * j: ...
false
18.181818
[ "+ if num_limit < j**2 + k**2 + j * k:", "+ break", "- if num_limit >= j**2 + k**2 + l**2 + j * k + k * l + l * j:", "+ if num_limit < j**2 + k**2 + l**2 + j * k + k * l + l * j:", "+ break", "+ elif num_limit >= j**2 + k**2 + l**2 + j * k ...
false
0.036595
0.036296
1.008223
[ "s141920146", "s143499677" ]
u255499778
p03062
python
s659812528
s219206516
109
90
14,284
14,412
Accepted
Accepted
17.43
n = int(eval(input())) a = list(map(int, input().split())) box = [] count = 0 zero = 0 for num in range(n): box.append(abs(a[num])) for num in a: if num < 0: count += 1 elif num == 0: zero += 1 box.sort() if count % 2 == 0 or zero > 0: print((sum(box))) else: box[0]...
n = int(eval(input())) a = list(map(int, input().split())) pbox = [] nbox = [] if 0 in a: count = 0 for i in a: count += abs(i) print(count) else: for i in a: if i > 0: pbox.append(i) else: nbox.append(i) if len(nbox) % 2 == 0: ...
19
29
343
598
n = int(eval(input())) a = list(map(int, input().split())) box = [] count = 0 zero = 0 for num in range(n): box.append(abs(a[num])) for num in a: if num < 0: count += 1 elif num == 0: zero += 1 box.sort() if count % 2 == 0 or zero > 0: print((sum(box))) else: box[0] = -box[0] pri...
n = int(eval(input())) a = list(map(int, input().split())) pbox = [] nbox = [] if 0 in a: count = 0 for i in a: count += abs(i) print(count) else: for i in a: if i > 0: pbox.append(i) else: nbox.append(i) if len(nbox) % 2 == 0: count = 0 ...
false
34.482759
[ "-box = []", "-count = 0", "-zero = 0", "-for num in range(n):", "- box.append(abs(a[num]))", "-for num in a:", "- if num < 0:", "- count += 1", "- elif num == 0:", "- zero += 1", "-box.sort()", "-if count % 2 == 0 or zero > 0:", "- print((sum(box)))", "+pbox = []...
false
0.08913
0.044022
2.024643
[ "s659812528", "s219206516" ]
u202619899
p03807
python
s570874762
s887414392
78
69
11,452
14,052
Accepted
Accepted
11.54
N = int(input()) A = list(map(int, input().split(' '))) cnt = 0 for a in A: cnt += 1 if a & 1 == 1 else 0 print(('YES' if cnt % 2 == 0 else 'NO'))
import sys N = int(eval(input())) A = list(map(int, sys.stdin.readline().split(' '))) cnt = 0 for a in A: cnt += 1 if a & 1 == 1 else 0 print(('YES' if cnt % 2 == 0 else 'NO'))
8
9
165
182
N = int(input()) A = list(map(int, input().split(" "))) cnt = 0 for a in A: cnt += 1 if a & 1 == 1 else 0 print(("YES" if cnt % 2 == 0 else "NO"))
import sys N = int(eval(input())) A = list(map(int, sys.stdin.readline().split(" "))) cnt = 0 for a in A: cnt += 1 if a & 1 == 1 else 0 print(("YES" if cnt % 2 == 0 else "NO"))
false
11.111111
[ "-N = int(input())", "-A = list(map(int, input().split(\" \")))", "+import sys", "+", "+N = int(eval(input()))", "+A = list(map(int, sys.stdin.readline().split(\" \")))" ]
false
0.039698
0.035239
1.126536
[ "s570874762", "s887414392" ]
u966695411
p03238
python
s939401669
s616558231
17
10
2,940
2,568
Accepted
Accepted
41.18
i=input;print((eval(i()+'+'+i())if'1'<i()else'Hello World'))
i=input;print(i()+i()if 1<i()else'Hello World')
1
1
58
46
i = input print((eval(i() + "+" + i()) if "1" < i() else "Hello World"))
i = input print(i() + i() if 1 < i() else "Hello World")
false
0
[ "-print((eval(i() + \"+\" + i()) if \"1\" < i() else \"Hello World\"))", "+print(i() + i() if 1 < i() else \"Hello World\")" ]
false
0.041684
0.120707
0.345331
[ "s939401669", "s616558231" ]
u645119489
p03260
python
s232695211
s191651025
19
17
3,060
2,940
Accepted
Accepted
10.53
A, B = list(map(int,input().split())) #偶数×偶数=偶数、偶数×奇数=偶数、奇数×奇数=奇数。 #A*Bが偶数なら、A*B*Cが奇数となるような整数Cは無い。A*Bが奇数なら、A*B*Cが奇数となるような整数Cは無い if A*B %2 == 0: print("No") if A*B %2 == 1: print("Yes")
A, B = list(map(int,input().split())) flg =False #flgを初期化 for C in range(1,4): if A*B*C %2 ==1: flg = True#flgと言う変数にTrueを代入する break #この時点で繰り返しを中断、終了する if flg:#(if文にはじつは、後ろに==trueが省略されているので、これだけで、flg=trueならば、、と言う意味になる) print("Yes") else:#(flg=true では無いならば、) print("No") ...
10
13
198
317
A, B = list(map(int, input().split())) # 偶数×偶数=偶数、偶数×奇数=偶数、奇数×奇数=奇数。 # A*Bが偶数なら、A*B*Cが奇数となるような整数Cは無い。A*Bが奇数なら、A*B*Cが奇数となるような整数Cは無い if A * B % 2 == 0: print("No") if A * B % 2 == 1: print("Yes")
A, B = list(map(int, input().split())) flg = False # flgを初期化 for C in range(1, 4): if A * B * C % 2 == 1: flg = True # flgと言う変数にTrueを代入する break # この時点で繰り返しを中断、終了する if flg: # (if文にはじつは、後ろに==trueが省略されているので、これだけで、flg=trueならば、、と言う意味になる) print("Yes") else: # (flg=true では無いならば、) print("No")
false
23.076923
[ "-# 偶数×偶数=偶数、偶数×奇数=偶数、奇数×奇数=奇数。", "-# A*Bが偶数なら、A*B*Cが奇数となるような整数Cは無い。A*Bが奇数なら、A*B*Cが奇数となるような整数Cは無い", "-if A * B % 2 == 0:", "+flg = False # flgを初期化", "+for C in range(1, 4):", "+ if A * B * C % 2 == 1:", "+ flg = True # flgと言う変数にTrueを代入する", "+ break # この時点で繰り返しを中断、終了する", "+if flg:...
false
0.061348
0.13134
0.467091
[ "s232695211", "s191651025" ]
u461454424
p02860
python
s426081829
s542564318
151
17
12,508
2,940
Accepted
Accepted
88.74
import sys input = sys.stdin.readline #input N = int(eval(input())) S = str(eval(input())) #output import numpy as np if N % 2 == 1: print("No") exit() else: M = int(N/2) T = [0] * M for i in range(M): if S[i] == S[M+i]: T[i] = 1 else: c...
#input N = int(eval(input())) S = str(eval(input())) #output if N % 2 == 1: print("No") else: M = int(N/2) if S[:M] == S[M:]: print("Yes") else: print("No")
26
13
379
190
import sys input = sys.stdin.readline # input N = int(eval(input())) S = str(eval(input())) # output import numpy as np if N % 2 == 1: print("No") exit() else: M = int(N / 2) T = [0] * M for i in range(M): if S[i] == S[M + i]: T[i] = 1 else: continue if np.s...
# input N = int(eval(input())) S = str(eval(input())) # output if N % 2 == 1: print("No") else: M = int(N / 2) if S[:M] == S[M:]: print("Yes") else: print("No")
false
50
[ "-import sys", "-", "-input = sys.stdin.readline", "-import numpy as np", "-", "- exit()", "- T = [0] * M", "- for i in range(M):", "- if S[i] == S[M + i]:", "- T[i] = 1", "- else:", "- continue", "-if np.sum(T) == M:", "- print(\"Yes\")", ...
false
0.076746
0.036015
2.130961
[ "s426081829", "s542564318" ]
u912237403
p00020
python
s056814953
s143285856
20
10
4,176
4,176
Accepted
Accepted
50
a=input().upper() print(a)
a=input() print(a.upper())
2
2
30
30
a = input().upper() print(a)
a = input() print(a.upper())
false
0
[ "-a = input().upper()", "-print(a)", "+a = input()", "+print(a.upper())" ]
false
0.038564
0.039519
0.975838
[ "s056814953", "s143285856" ]
u820351940
p02861
python
s121675160
s337210928
429
22
4,504
3,188
Accepted
Accepted
94.87
import itertools n = int(eval(input())) route = [list(map(int, input().split())) for _ in range(n)] results = [] for v in itertools.permutations(route, r=n): distance = 0 for i in range(n - 1): start, goal = v[i], v[i + 1] distance += ((goal[0] - start[0]) ** 2 + (goal[1] - start[1])...
n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] def distance(i1, i2): p1 = xy[i1] p2 = xy[i2] return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5 dp = [None] * (1 << n) def dfs(state=0): if dp[state] is not None: return dp[state] ans = ...
13
26
394
611
import itertools n = int(eval(input())) route = [list(map(int, input().split())) for _ in range(n)] results = [] for v in itertools.permutations(route, r=n): distance = 0 for i in range(n - 1): start, goal = v[i], v[i + 1] distance += ((goal[0] - start[0]) ** 2 + (goal[1] - start[1]) ** 2) ** 0...
n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] def distance(i1, i2): p1 = xy[i1] p2 = xy[i2] return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5 dp = [None] * (1 << n) def dfs(state=0): if dp[state] is not None: return dp[state] ans = [] s =...
false
50
[ "-import itertools", "+n = int(eval(input()))", "+xy = [list(map(int, input().split())) for _ in range(n)]", "-n = int(eval(input()))", "-route = [list(map(int, input().split())) for _ in range(n)]", "-results = []", "-for v in itertools.permutations(route, r=n):", "- distance = 0", "- for i i...
false
0.041112
0.03901
1.0539
[ "s121675160", "s337210928" ]
u268793453
p03363
python
s988293115
s997025321
238
202
41,568
41,568
Accepted
Accepted
15.13
from collections import Counter n = int(eval(input())) a = [int(i) for i in input().split()] a_ = [0] for i in range(n): a_.append(a_[i] + a[i]) cnt = 0 def sum(i): return int((i + 1) / 2 * i) for i in list(Counter(a_).values()): cnt += sum(i-1) print(cnt)
from collections import Counter n = int(eval(input())) a = [int(i) for i in input().split()] a_ = [0] for i in range(n): a_.append(a_[i] + a[i]) cnt = 0 def sum(i): return i * (i-1) // 2 for i in list(Counter(a_).values()): cnt += sum(i) print(cnt)
19
19
281
273
from collections import Counter n = int(eval(input())) a = [int(i) for i in input().split()] a_ = [0] for i in range(n): a_.append(a_[i] + a[i]) cnt = 0 def sum(i): return int((i + 1) / 2 * i) for i in list(Counter(a_).values()): cnt += sum(i - 1) print(cnt)
from collections import Counter n = int(eval(input())) a = [int(i) for i in input().split()] a_ = [0] for i in range(n): a_.append(a_[i] + a[i]) cnt = 0 def sum(i): return i * (i - 1) // 2 for i in list(Counter(a_).values()): cnt += sum(i) print(cnt)
false
0
[ "- return int((i + 1) / 2 * i)", "+ return i * (i - 1) // 2", "- cnt += sum(i - 1)", "+ cnt += sum(i)" ]
false
0.036366
0.035539
1.023265
[ "s988293115", "s997025321" ]
u724687935
p03241
python
s904700451
s815425175
25
21
3,444
3,060
Accepted
Accepted
16
from collections import Counter import sys sys.setrecursionlimit(10 ** 6) def factorization(n): arr = Counter() temp = n for i in range(2, int(-(-n**0.5 // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //...
from math import sqrt N, M = list(map(int, input().split())) ans = 1 for i in range(1, int(sqrt(M)) + 1): if M % i == 0: j = M // i if M / N >= j: ans = max(ans, j) elif M / N >= i: ans = max(ans, i) print(ans)
48
15
983
275
from collections import Counter import sys sys.setrecursionlimit(10**6) def factorization(n): arr = Counter() temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i ...
from math import sqrt N, M = list(map(int, input().split())) ans = 1 for i in range(1, int(sqrt(M)) + 1): if M % i == 0: j = M // i if M / N >= j: ans = max(ans, j) elif M / N >= i: ans = max(ans, i) print(ans)
false
68.75
[ "-from collections import Counter", "-import sys", "-", "-sys.setrecursionlimit(10**6)", "-", "-", "-def factorization(n):", "- arr = Counter()", "- temp = n", "- for i in range(2, int(-(-(n**0.5) // 1)) + 1):", "- if temp % i == 0:", "- cnt = 0", "- whi...
false
0.089917
0.127134
0.707262
[ "s904700451", "s815425175" ]
u968166680
p04013
python
s426729495
s636131501
90
74
67,220
67,136
Accepted
Accepted
17.78
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) M = sum(X) dp = [[0] * (M + 1) for j in range(N + 1)] dp[0][0] = 1 ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) X = [x - A for x in X] base = 2500 dp = [[0] * 5001 for _ in range(N + 1)]...
32
30
621
604
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) M = sum(X) dp = [[0] * (M + 1) for j in range(N + 1)] dp[0][0] = 1 for i in range(N): ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) X = [x - A for x in X] base = 2500 dp = [[0] * 5001 for _ in range(N + 1)] dp[0][base] =...
false
6.25
[ "- M = sum(X)", "- dp = [[0] * (M + 1) for j in range(N + 1)]", "- dp[0][0] = 1", "+ X = [x - A for x in X]", "+ base = 2500", "+ dp = [[0] * 5001 for _ in range(N + 1)]", "+ dp[0][base] = 1", "- for j in range(N, 0, -1):", "- for k in range(X[i], M + 1):", "...
false
0.04093
0.054148
0.755899
[ "s426729495", "s636131501" ]
u006880673
p03160
python
s617559935
s451231589
236
185
55,400
13,980
Accepted
Accepted
21.61
dp=[] #iまでに要したminコスト #dp[i] = dp[i-1]+abs(l[i]-l[i-1]) or dp[i-2]+abs(l[i+1]-l[i-1]) n = int(eval(input())) l = list(map(int, input().split())) dp.append(0) #dp[0] dp.append(abs(l[1]-l[0])) #dp[1] for i in range(2, n): new = min(dp[i-1]+abs(l[i]-l[i-1]), dp[i-2]+abs(l[i]-l[i-2])) dp.append(new) ...
N = int(eval(input())) h = [0] + list(map(int, input().split())) dp = [10**100] * (N+2) dp[1] = 0 for i in range(1, N): dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i])) if i < N-1: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i])) print((dp[N]))
16
12
400
271
dp = [] # iまでに要したminコスト # dp[i] = dp[i-1]+abs(l[i]-l[i-1]) or dp[i-2]+abs(l[i+1]-l[i-1]) n = int(eval(input())) l = list(map(int, input().split())) dp.append(0) # dp[0] dp.append(abs(l[1] - l[0])) # dp[1] for i in range(2, n): new = min(dp[i - 1] + abs(l[i] - l[i - 1]), dp[i - 2] + abs(l[i] - l[i - 2])) dp.ap...
N = int(eval(input())) h = [0] + list(map(int, input().split())) dp = [10**100] * (N + 2) dp[1] = 0 for i in range(1, N): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i])) if i < N - 1: dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i])) print((dp[N]))
false
25
[ "-dp = []", "-# iまでに要したminコスト", "-# dp[i] = dp[i-1]+abs(l[i]-l[i-1]) or dp[i-2]+abs(l[i+1]-l[i-1])", "-n = int(eval(input()))", "-l = list(map(int, input().split()))", "-dp.append(0) # dp[0]", "-dp.append(abs(l[1] - l[0])) # dp[1]", "-for i in range(2, n):", "- new = min(dp[i - 1] + abs(l[i] - ...
false
0.036044
0.034071
1.05791
[ "s617559935", "s451231589" ]
u384935968
p03962
python
s033179460
s246965165
31
28
9,048
9,068
Accepted
Accepted
9.68
a,b,c = list(map(int,input().split())) if a == b == c: print((1)) elif a == c or a == b or b == c: print((2)) else: print((3))
colors = list(map(int,input().split())) print((len(set(colors))))
8
2
131
64
a, b, c = list(map(int, input().split())) if a == b == c: print((1)) elif a == c or a == b or b == c: print((2)) else: print((3))
colors = list(map(int, input().split())) print((len(set(colors))))
false
75
[ "-a, b, c = list(map(int, input().split()))", "-if a == b == c:", "- print((1))", "-elif a == c or a == b or b == c:", "- print((2))", "-else:", "- print((3))", "+colors = list(map(int, input().split()))", "+print((len(set(colors))))" ]
false
0.047997
0.049044
0.978663
[ "s033179460", "s246965165" ]
u056358163
p02574
python
s243712037
s813638175
918
849
127,756
127,544
Accepted
Accepted
7.52
import math from functools import reduce def getD(num): input_list = [2 if i % 2 == 0 else i for i in range(num+1)] input_list[0] = 0 bool_list = [False if i % 2 == 0 else True for i in range(num+1)] sqrt = int(math.sqrt(num)) for serial in range(3, sqrt + 1, 2): if bool_list...
import math from functools import reduce def getD(num): input_list = [2 if i % 2 == 0 else i for i in range(num+1)] input_list[0] = 0 bool_list = [False if i % 2 == 0 else True for i in range(num+1)] sqrt = int(math.sqrt(num)) for serial in range(3, sqrt + 1, 2): if bool_list...
45
43
1,171
1,090
import math from functools import reduce def getD(num): input_list = [2 if i % 2 == 0 else i for i in range(num + 1)] input_list[0] = 0 bool_list = [False if i % 2 == 0 else True for i in range(num + 1)] sqrt = int(math.sqrt(num)) for serial in range(3, sqrt + 1, 2): if bool_list[serial]: ...
import math from functools import reduce def getD(num): input_list = [2 if i % 2 == 0 else i for i in range(num + 1)] input_list[0] = 0 bool_list = [False if i % 2 == 0 else True for i in range(num + 1)] sqrt = int(math.sqrt(num)) for serial in range(3, sqrt + 1, 2): if bool_list[serial]: ...
false
4.444444
[ "-from math import gcd", "-", "-gcd_of_a = A[0]", "-for i in range(N):", "- gcd_of_a = gcd(gcd_of_a, A[i])", "-if gcd_of_a == 1:", "+if reduce(math.gcd, A) == 1:" ]
false
0.040139
0.041139
0.975694
[ "s243712037", "s813638175" ]
u852690916
p03786
python
s052222070
s222114804
247
107
60,184
83,816
Accepted
Accepted
56.68
import sys from operator import itemgetter from itertools import accumulate def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A.sort() C = list(accumulate(A)) dp = [0] * N for i in range(N-1): if C[i] * 2 >= A[i+1]: ...
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys def main(N, A): A.sort() s = 0 dp = [0] * (N + 1) for i, a in enumerate(A): dp[i + 1] = 1 if a <= s * 2: dp[i + 1] += dp[i] s += a print((dp[N])) if __name__ == '__main__': input = sys.stdin.readline ...
17
17
401
393
import sys from operator import itemgetter from itertools import accumulate def main(): input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A.sort() C = list(accumulate(A)) dp = [0] * N for i in range(N - 1): if C[i] * 2 >= A[i + 1]: dp...
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) import sys def main(N, A): A.sort() s = 0 dp = [0] * (N + 1) for i, a in enumerate(A): dp[i + 1] = 1 if a <= s * 2: dp[i + 1] += dp[i] s += a print((dp[N])) if __name__ == "__main__": input = sys.stdin.readlin...
false
0
[ "+# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)", "-from operator import itemgetter", "-from itertools import accumulate", "-def main():", "- input = sys.stdin.readline", "- N = int(eval(input()))", "- A = list(map(int, input().split()))", "+def main(N, A):", "- C = list(accumulate(A))"...
false
0.062849
0.032251
1.948729
[ "s052222070", "s222114804" ]
u847467233
p02447
python
s042162931
s608562159
660
570
27,616
19,432
Accepted
Accepted
13.64
# AOJ ITP2_5_A: Sorting Pairs # Python3 2018.6.24 bal4u ps = [] n = int(eval(input())) for i in range(n): x, y = list(map(int, input().split())) ps.append((x, y)) a = sorted(ps, key=lambda x:(x[0], x[1])) for i in range(n): print((*a[i]))
# AOJ ITP2_5_A: Sorting Pairs # Python3 2018.6.24 bal4u ps = [] n = int(eval(input())) for i in range(n): x, y = list(map(int, input().split())) ps.append((x, y)) ps.sort() for i in ps: print((*i))
10
10
237
196
# AOJ ITP2_5_A: Sorting Pairs # Python3 2018.6.24 bal4u ps = [] n = int(eval(input())) for i in range(n): x, y = list(map(int, input().split())) ps.append((x, y)) a = sorted(ps, key=lambda x: (x[0], x[1])) for i in range(n): print((*a[i]))
# AOJ ITP2_5_A: Sorting Pairs # Python3 2018.6.24 bal4u ps = [] n = int(eval(input())) for i in range(n): x, y = list(map(int, input().split())) ps.append((x, y)) ps.sort() for i in ps: print((*i))
false
0
[ "-a = sorted(ps, key=lambda x: (x[0], x[1]))", "-for i in range(n):", "- print((*a[i]))", "+ps.sort()", "+for i in ps:", "+ print((*i))" ]
false
0.038103
0.042678
0.892795
[ "s042162931", "s608562159" ]
u252828980
p03043
python
s213989926
s007799318
59
52
6,296
9,184
Accepted
Accepted
11.86
n,k = list(map(int,input().split())) li = [] for i in range(1,n+1): a=0 while i*(2**a)<k: a+=1 li.append((1/n)*(1/2**a)) print((sum(li)))
n,k = list(map(int,input().split())) sum1 = 0 for i in range(1,n+1): p = 0 while True: if (2**p)*i >= k: break p +=1 sum1 += 1/(n*2**p) print(sum1)
10
11
164
192
n, k = list(map(int, input().split())) li = [] for i in range(1, n + 1): a = 0 while i * (2**a) < k: a += 1 li.append((1 / n) * (1 / 2**a)) print((sum(li)))
n, k = list(map(int, input().split())) sum1 = 0 for i in range(1, n + 1): p = 0 while True: if (2**p) * i >= k: break p += 1 sum1 += 1 / (n * 2**p) print(sum1)
false
9.090909
[ "-li = []", "+sum1 = 0", "- a = 0", "- while i * (2**a) < k:", "- a += 1", "- li.append((1 / n) * (1 / 2**a))", "-print((sum(li)))", "+ p = 0", "+ while True:", "+ if (2**p) * i >= k:", "+ break", "+ p += 1", "+ sum1 += 1 / (n * 2**p)", "+p...
false
0.073368
0.074192
0.98889
[ "s213989926", "s007799318" ]
u721316601
p02973
python
s712348275
s688628385
206
92
7,836
7,968
Accepted
Accepted
55.34
from bisect import bisect_right def main(): N = int(eval(input())) A = [int(eval(input())) for i in range(N)] n = [A.pop(-1)] A.reverse() for a in A: if n[-1] <= a: n.append(a) else: n[bisect_right(n, a)] = a print((len(n))) if __name__ == '__main__'...
import sys from bisect import bisect_right input = sys.stdin.readline def main(): N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] n = [A.pop(-1)] A.reverse() for a in A: if n[-1] <= a: n.append(a) else: n[bisect_right(n, a)] = a print(...
16
19
319
357
from bisect import bisect_right def main(): N = int(eval(input())) A = [int(eval(input())) for i in range(N)] n = [A.pop(-1)] A.reverse() for a in A: if n[-1] <= a: n.append(a) else: n[bisect_right(n, a)] = a print((len(n))) if __name__ == "__main__": ...
import sys from bisect import bisect_right input = sys.stdin.readline def main(): N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] n = [A.pop(-1)] A.reverse() for a in A: if n[-1] <= a: n.append(a) else: n[bisect_right(n, a)] = a print(...
false
15.789474
[ "+import sys", "+", "+input = sys.stdin.readline", "- A = [int(eval(input())) for i in range(N)]", "+ A = [int(eval(input())) for _ in range(N)]" ]
false
0.067941
0.066773
1.017497
[ "s712348275", "s688628385" ]
u744920373
p03229
python
s652807130
s775943669
186
115
8,336
8,300
Accepted
Accepted
38.17
import sys def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i for i2 in range(j...
import sys def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [[ini]*i for i2 in range(j...
76
23
2,335
874
import sys def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [...
import sys def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] def dp2(ini, i, j): return [...
false
69.736842
[ "-\"\"\"", "-if N > 2:", "- ans += A[-1] * 2 - A[0] - A[1]", "- l_ind = 2", "- r_ind = N-2", "- while True:", "- if r_ind - 2 >= l_ind:", "-\"\"\"", "-if N == 2:", "- print((A[1] - A[0]))", "-# elif N%2:", "+if N % 2:", "+ ans_1 = sum(A[N // 2 + 1 :]) * 2 - sum(A[: N...
false
0.036575
0.035633
1.02644
[ "s652807130", "s775943669" ]
u903005414
p02684
python
s355098548
s039252715
298
160
42,692
27,796
Accepted
Accepted
46.31
from collections import deque N, K = list(map(int, input().split())) A = list(map(int, input().split())) T = set([0]) # 0-indexed c = 0 # 0-indexed for i in range(N + 1): c = A[c] - 1 # print('c', c) if c not in T: T.add(c) else: break C = deque([c]) T = set([c]) # 0-...
import sys input = sys.stdin.buffer.readline N, K = list(map(int, input().split())) A = [-1] + list(map(int, input().split())) I = [-1] * (N + 1) S = [] idx = 1 while I[idx] == -1: S.append(idx) I[idx] = len(S) idx = A[idx] # print(f'{S=}, {idx=}, {I[idx]=}') start_idx = I[idx] - 1 num_circ...
46
25
883
527
from collections import deque N, K = list(map(int, input().split())) A = list(map(int, input().split())) T = set([0]) # 0-indexed c = 0 # 0-indexed for i in range(N + 1): c = A[c] - 1 # print('c', c) if c not in T: T.add(c) else: break C = deque([c]) T = set([c]) # 0-indexed for i in...
import sys input = sys.stdin.buffer.readline N, K = list(map(int, input().split())) A = [-1] + list(map(int, input().split())) I = [-1] * (N + 1) S = [] idx = 1 while I[idx] == -1: S.append(idx) I[idx] = len(S) idx = A[idx] # print(f'{S=}, {idx=}, {I[idx]=}') start_idx = I[idx] - 1 num_circles = len(S) - s...
false
45.652174
[ "-from collections import deque", "+import sys", "+input = sys.stdin.buffer.readline", "-A = list(map(int, input().split()))", "-T = set([0]) # 0-indexed", "-c = 0 # 0-indexed", "-for i in range(N + 1):", "- c = A[c] - 1", "- # print('c', c)", "- if c not in T:", "- T.add(c)", ...
false
0.087738
0.046044
1.905539
[ "s355098548", "s039252715" ]
u609307781
p02678
python
s906824413
s036647127
859
721
74,520
76,616
Accepted
Accepted
16.07
# D import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import breadth_first_order N, M = list(map(int, input().split())) row = [] col = [] for i in range(M): r, c = list(map(int, input().split())) row.append(c-1) col.append(r-1) data = [1] * (M) csr = csr_...
# D import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import breadth_first_order N, M = list(map(int, input().split())) ABs = np.array([list(map(int, input().split())) for i in range(M)]) row = ABs.T[0]-1 col = ABs.T[1]-1 data = [1] * (M) csr = csr_matrix((data, (row, col...
25
21
526
503
# D import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import breadth_first_order N, M = list(map(int, input().split())) row = [] col = [] for i in range(M): r, c = list(map(int, input().split())) row.append(c - 1) col.append(r - 1) data = [1] * (M) csr = csr_matrix((data, (ro...
# D import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import breadth_first_order N, M = list(map(int, input().split())) ABs = np.array([list(map(int, input().split())) for i in range(M)]) row = ABs.T[0] - 1 col = ABs.T[1] - 1 data = [1] * (M) csr = csr_matrix((data, (row, col)), shape=(N...
false
16
[ "-row = []", "-col = []", "-for i in range(M):", "- r, c = list(map(int, input().split()))", "- row.append(c - 1)", "- col.append(r - 1)", "+ABs = np.array([list(map(int, input().split())) for i in range(M)])", "+row = ABs.T[0] - 1", "+col = ABs.T[1] - 1" ]
false
0.425234
0.677721
0.627447
[ "s906824413", "s036647127" ]
u948524308
p02928
python
s108945566
s562499257
1,299
597
3,316
9,248
Accepted
Accepted
54.04
N,K=list(map(int,input().split())) A=list(map(int,input().split())) L=[0]*N R=[0]*N for i in range(N): for j in range(N): if j<i and A[j]<A[i]: L[i]+=1 if j>i and A[j]<A[i]: R[i]+=1 ans = 0 K1=((1+K)*K//2)%(10**9+7) K2=(K*(K-1)//2)%(10**9+7) for i in range(...
N,K=list(map(int,input().split())) A=list(map(int,input().split())) mod=10**9+7 B=[] for i in range(N): l=0 r=0 for j in range(i): if A[i]>A[j]: l+=1 for k in range(i,N): if A[i]>A[k]: r+=1 B.append([l,r]) ans=0 for i in range(N): a...
23
24
400
379
N, K = list(map(int, input().split())) A = list(map(int, input().split())) L = [0] * N R = [0] * N for i in range(N): for j in range(N): if j < i and A[j] < A[i]: L[i] += 1 if j > i and A[j] < A[i]: R[i] += 1 ans = 0 K1 = ((1 + K) * K // 2) % (10**9 + 7) K2 = (K * (K - 1) // ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) mod = 10**9 + 7 B = [] for i in range(N): l = 0 r = 0 for j in range(i): if A[i] > A[j]: l += 1 for k in range(i, N): if A[i] > A[k]: r += 1 B.append([l, r]) ans = 0 for i in range(N): ...
false
4.166667
[ "-L = [0] * N", "-R = [0] * N", "+mod = 10**9 + 7", "+B = []", "- for j in range(N):", "- if j < i and A[j] < A[i]:", "- L[i] += 1", "- if j > i and A[j] < A[i]:", "- R[i] += 1", "+ l = 0", "+ r = 0", "+ for j in range(i):", "+ if A[i] >...
false
0.037456
0.042433
0.882713
[ "s108945566", "s562499257" ]
u790710233
p03645
python
s046889664
s279485787
833
639
37,532
18,992
Accepted
Accepted
23.29
n, m = list(map(int, input().split())) s = {tuple(map(int, input().split())) for _ in range(m)} for i in range(2, n): route = [1, i, n] if all(edge in s for edge in zip(route, route[1:])): print('POSSIBLE') break else: print('IMPOSSIBLE')
n, m = list(map(int, input().split())) transit_a = set() transit_b = set() for _ in range(m): a, b = list(map(int, input().split())) if a == 1: transit_b |= {b} elif b == n: transit_a |= {a} print(('POSSIBLE' if len(transit_a & transit_b) else 'IMPOSSIBLE'))
11
11
273
283
n, m = list(map(int, input().split())) s = {tuple(map(int, input().split())) for _ in range(m)} for i in range(2, n): route = [1, i, n] if all(edge in s for edge in zip(route, route[1:])): print("POSSIBLE") break else: print("IMPOSSIBLE")
n, m = list(map(int, input().split())) transit_a = set() transit_b = set() for _ in range(m): a, b = list(map(int, input().split())) if a == 1: transit_b |= {b} elif b == n: transit_a |= {a} print(("POSSIBLE" if len(transit_a & transit_b) else "IMPOSSIBLE"))
false
0
[ "-s = {tuple(map(int, input().split())) for _ in range(m)}", "-for i in range(2, n):", "- route = [1, i, n]", "- if all(edge in s for edge in zip(route, route[1:])):", "- print(\"POSSIBLE\")", "- break", "-else:", "- print(\"IMPOSSIBLE\")", "+transit_a = set()", "+transit_b ...
false
0.039455
0.038176
1.033499
[ "s046889664", "s279485787" ]
u576917603
p03425
python
s056642512
s970264991
250
195
20,300
3,064
Accepted
Accepted
22
n=int(eval(input())) a=[list(eval(input()))for i in range(n)] d={'M':0,"A":0,"R":0,'C':0,'H':0} for i in a: if i[0] in d: d[i[0]]+=1 dl=[] for i in list(d.values()): dl.append(i) ans=0 for i in range(3): for j in range(i+1,4): for k in range(j+1,5): ans+=dl[i]*dl[j]*...
n=int(eval(input())) d={} for i in range(n): a=eval(input()) if a[0]=="M" or a[0]=="A" or a[0]=="R" or a[0]=="C" or a[0]=="H": d[a[0]]=d.get(a[0],0)+1 a=list(d.values()) if len(a)<3: print((0)) exit() import itertools c=list(itertools.combinations(a,3)) ans=0 for i,j,k in c: an...
15
16
319
326
n = int(eval(input())) a = [list(eval(input())) for i in range(n)] d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for i in a: if i[0] in d: d[i[0]] += 1 dl = [] for i in list(d.values()): dl.append(i) ans = 0 for i in range(3): for j in range(i + 1, 4): for k in range(j + 1, 5): an...
n = int(eval(input())) d = {} for i in range(n): a = eval(input()) if a[0] == "M" or a[0] == "A" or a[0] == "R" or a[0] == "C" or a[0] == "H": d[a[0]] = d.get(a[0], 0) + 1 a = list(d.values()) if len(a) < 3: print((0)) exit() import itertools c = list(itertools.combinations(a, 3)) ans = 0 for i...
false
6.25
[ "-a = [list(eval(input())) for i in range(n)]", "-d = {\"M\": 0, \"A\": 0, \"R\": 0, \"C\": 0, \"H\": 0}", "-for i in a:", "- if i[0] in d:", "- d[i[0]] += 1", "-dl = []", "-for i in list(d.values()):", "- dl.append(i)", "+d = {}", "+for i in range(n):", "+ a = eval(input())", ...
false
0.042533
0.083632
0.508571
[ "s056642512", "s970264991" ]
u757117214
p02972
python
s926499639
s814763325
361
258
7,132
11,644
Accepted
Accepted
28.53
from collections import Counter N,*a = map(int,open(0).read().split()) ans = [] for i in range(N)[::-1]: part_rem = sum(a[i::i+1]) % 2 if a[i] == 0: if part_rem == 1: a[i] = abs(a[i] - 1) elif a[i] == 1: if part_rem == 0: a[i] = abs(a[i] - 1) ...
N,*a = list(map(int,open(0).read().split())) ans = [] for i in range(N)[::-1]: part_rem = sum(a[i::i+1]) % 2 if a[i] != part_rem: a[i] = abs(a[i] - 1) print((sum(a))) print((*[i+1 for i,v in enumerate(a) if v == 1]))
21
9
460
232
from collections import Counter N, *a = map(int, open(0).read().split()) ans = [] for i in range(N)[::-1]: part_rem = sum(a[i :: i + 1]) % 2 if a[i] == 0: if part_rem == 1: a[i] = abs(a[i] - 1) elif a[i] == 1: if part_rem == 0: a[i] = abs(a[i] - 1) c = Counter(a) pri...
N, *a = list(map(int, open(0).read().split())) ans = [] for i in range(N)[::-1]: part_rem = sum(a[i :: i + 1]) % 2 if a[i] != part_rem: a[i] = abs(a[i] - 1) print((sum(a))) print((*[i + 1 for i, v in enumerate(a) if v == 1]))
false
57.142857
[ "-from collections import Counter", "-", "-N, *a = map(int, open(0).read().split())", "+N, *a = list(map(int, open(0).read().split()))", "- if a[i] == 0:", "- if part_rem == 1:", "- a[i] = abs(a[i] - 1)", "- elif a[i] == 1:", "- if part_rem == 0:", "- a[i]...
false
0.120166
0.049708
2.417454
[ "s926499639", "s814763325" ]
u512212329
p02660
python
s466838138
s454602552
161
92
9,464
9,484
Accepted
Accepted
42.86
from collections import defaultdict from itertools import accumulate def main(): n = int(eval(input())) prime_counter = defaultdict(int) acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39 f = 2 while f * f <= n: if n % f == 0: n //= f prime_co...
from collections import defaultdict from itertools import accumulate def main(): n = int(eval(input())) prime_counter = defaultdict(int) acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39 f = 2 while n % f == 0: n //= f prime_counter[f] += 1 f = 3 wh...
31
34
645
720
from collections import defaultdict from itertools import accumulate def main(): n = int(eval(input())) prime_counter = defaultdict(int) acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39 f = 2 while f * f <= n: if n % f == 0: n //= f prime_counter[f] += 1 ...
from collections import defaultdict from itertools import accumulate def main(): n = int(eval(input())) prime_counter = defaultdict(int) acc = tuple(accumulate(list(range(1, 42)))) # 10^12 < 2^39 f = 2 while n % f == 0: n //= f prime_counter[f] += 1 f = 3 while f * f <= n:...
false
8.823529
[ "+ while n % f == 0:", "+ n //= f", "+ prime_counter[f] += 1", "+ f = 3", "- f += 1", "+ f += 2", "- for i, x in enumerate(acc):", "+ for accum_index, x in enumerate(acc):", "- tmp = i", "- ans += tmp", "+ ans +...
false
0.038778
0.050986
0.760559
[ "s466838138", "s454602552" ]
u592547545
p02660
python
s398209125
s114908405
109
85
9,504
9,324
Accepted
Accepted
22.02
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[...
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[...
47
81
881
1,582
def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if ar...
def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if ar...
false
41.975309
[ "+", "+", "+import math", "+", "+", "+def myFactorization(n):", "+ \"\"\"nを素因数分解する", "+ 戻り値: factList = [[prime1, exp1], [prime2, exp2],...]", "+ n=(prime1)**exp1 * (prime2)**exp2 * ...", "+ \"\"\"", "+ factList = []", "+ temp = n", "+ cnt = 0", "+ while temp...
false
0.060144
0.112141
0.536328
[ "s398209125", "s114908405" ]
u779455925
p03987
python
s304413106
s544011740
325
298
40,900
37,672
Accepted
Accepted
8.31
#import decimal #decimal.getcontext().prec==500 Floatの桁数を500まで増やす #Decimal(c).sqrt() それで平方根を求める #Decimal(1) / Decimal(7) 1/7 from collections import * from itertools import * from bisect import * from heapq import * import copy import math from fractions import gcd import sys #input = sys.stdin.readline ...
#import decimal #decimal.getcontext().prec==500 Floatの桁数を500まで増やす #Decimal(c).sqrt() それで平方根を求める #Decimal(1) / Decimal(7) 1/7 """ from collections import * from itertools import * from bisect import * from heapq import * import copy import math from fractions import gcd import sys""" #input = sys.stdin.read...
35
36
652
660
# import decimal # decimal.getcontext().prec==500 Floatの桁数を500まで増やす # Decimal(c).sqrt() それで平方根を求める # Decimal(1) / Decimal(7) 1/7 from collections import * from itertools import * from bisect import * from heapq import * import copy import math from fractions import gcd import sys # input = sys.stdin.readline # N=int(i...
# import decimal # decimal.getcontext().prec==500 Floatの桁数を500まで増やす # Decimal(c).sqrt() それで平方根を求める # Decimal(1) / Decimal(7) 1/7 """ from collections import * from itertools import * from bisect import * from heapq import * import copy import math from fractions import gcd import sys""" # input = sys.stdin.readline # N...
false
2.777778
[ "+\"\"\"", "-import sys", "-", "+import sys\"\"\"" ]
false
0.035079
0.041807
0.839065
[ "s304413106", "s544011740" ]
u281303342
p03425
python
s636683202
s649256954
154
67
10,112
10,008
Accepted
Accepted
56.49
from collections import defaultdict from itertools import combinations N = int(eval(input())) S = [eval(input()) for _ in range(N)] dic = defaultdict(int) for s in S: dic[s[0]] += 1 comb = combinations("MARCH", 3) ans = 0 for x1,x2,x3 in comb: ans += dic[x1]*dic[x2]*dic[x3] print(ans)
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # --------------------------------------...
17
29
303
646
from collections import defaultdict from itertools import combinations N = int(eval(input())) S = [eval(input()) for _ in range(N)] dic = defaultdict(int) for s in S: dic[s[0]] += 1 comb = combinations("MARCH", 3) ans = 0 for x1, x2, x3 in comb: ans += dic[x1] * dic[x2] * dic[x3] print(ans)
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ---------------------------------------------------...
false
41.37931
[ "+# Python3 (3.4.3)", "+import sys", "+", "+input = sys.stdin.readline", "+# function", "+# main", "+N = int(eval(input()))", "+S = [input().rstrip() for _ in range(N)]", "+", "+d = defaultdict(int)", "+for s in S:", "+ key = s[0]", "+ d[key] += 1", "-N = int(eval(input()))", "-S =...
false
0.038145
0.044585
0.855558
[ "s636683202", "s649256954" ]
u814986259
p03478
python
s760628604
s190159758
35
29
3,060
2,940
Accepted
Accepted
17.14
N,A,B=list(map(int,input().split())) ans=0 for i in range(1,N+1): s=list(map(int,str(i))) s=sum(s) if A<=s and s<=B: ans+=i print(ans)
N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N+1): k = i tmp = 0 while k > 0: tmp += k % 10 k = k // 10 if tmp >= A and tmp <= B: ans += i print(ans)
9
11
149
217
N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N + 1): s = list(map(int, str(i))) s = sum(s) if A <= s and s <= B: ans += i print(ans)
N, A, B = list(map(int, input().split())) ans = 0 for i in range(1, N + 1): k = i tmp = 0 while k > 0: tmp += k % 10 k = k // 10 if tmp >= A and tmp <= B: ans += i print(ans)
false
18.181818
[ "- s = list(map(int, str(i)))", "- s = sum(s)", "- if A <= s and s <= B:", "+ k = i", "+ tmp = 0", "+ while k > 0:", "+ tmp += k % 10", "+ k = k // 10", "+ if tmp >= A and tmp <= B:" ]
false
0.037202
0.038171
0.974629
[ "s760628604", "s190159758" ]
u827202523
p03912
python
s463098485
s316268437
291
225
80,784
58,908
Accepted
Accepted
22.68
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) from collections import deque def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math n, m = getList() nums = getList() n_mods = [0 for i in range(m)] pair_mods = [0 for i in range(...
import sys input = sys.stdin.buffer.readline def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getlist(): return list(map(int, input().split())) import math import heapq from collections import defaultdict, Counter, deque MOD = 10**9 + 7 INF = 10**15 ...
45
52
1,096
1,076
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) from collections import deque def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math n, m = getList() nums = getList() n_mods = [0 for i in range(m)] pair_mods = [0 for i in range(m)] nu...
import sys input = sys.stdin.buffer.readline def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getlist(): return list(map(int, input().split())) import math import heapq from collections import defaultdict, Counter, deque MOD = 10**9 + 7 INF = 10**15 d...
false
13.461538
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(1000000)", "-from collections import deque", "+input = sys.stdin.buffer.readline", "-def getList():", "+def getNM():", "+ return list(map(int, input().split()))", "+", "+", "+def getlist():", "+import heapq", "+from collections import d...
false
0.047665
0.209602
0.227408
[ "s463098485", "s316268437" ]
u163703551
p02803
python
s304699832
s242658011
578
499
3,700
3,608
Accepted
Accepted
13.67
import sys import socket from heapq import heappush, heappop hostname = socket.gethostname() if hostname == 'F451C': sys.stdin = open('d1.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eva...
import sys import socket from heapq import heappush, heappop hostname = socket.gethostname() if hostname == 'F451C': sys.stdin = open('d2.in') def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eva...
97
156
1,841
3,016
import sys import socket from heapq import heappush, heappop hostname = socket.gethostname() if hostname == "F451C": sys.stdin = open("d1.in") def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def re...
import sys import socket from heapq import heappush, heappop hostname = socket.gethostname() if hostname == "F451C": sys.stdin = open("d2.in") def read_int_list(): return list(map(int, input().split())) def read_str_list(): return input().split() def read_int(): return int(eval(input())) def re...
false
37.820513
[ "- sys.stdin = open(\"d1.in\")", "+ sys.stdin = open(\"d2.in\")", "-main()", "+def bfs(a, s):", "+ i0, j0 = s", "+ H = len(a)", "+ W = len(a[0])", "+ inf = 1000", "+ d = [[inf] * W for i in range(H)]", "+ d[i0][j0] = 0", "+ state = [[0] * W for i in range(H)]", "+ ...
false
0.048038
0.054556
0.880532
[ "s304699832", "s242658011" ]
u624475441
p03330
python
s647238054
s654163778
922
831
7,696
3,064
Accepted
Accepted
9.87
from itertools import * N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in [0]*C] c = [list(map(int, input().split())) for _ in [0]*N] tri = [[] for _ in [0]*3] for i in range(1, N+1): for j in range(1, N+1): tri[(i+j) % 3] += [c[i-1][j-1] - 1] incom = [[0]*C for _ ...
from itertools import * N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in [0]*C] tri = [[0]*C for _ in [0]*3] for i in range(N): for j,x in enumerate(map(int, input().split())): tri[(i+j)%3][x-1] += 1 res = 1<<30 for p in permutations(list(range(C)), 3): tt = ...
17
12
567
410
from itertools import * N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in [0] * C] c = [list(map(int, input().split())) for _ in [0] * N] tri = [[] for _ in [0] * 3] for i in range(1, N + 1): for j in range(1, N + 1): tri[(i + j) % 3] += [c[i - 1][j - 1] - 1] incom = [[0]...
from itertools import * N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in [0] * C] tri = [[0] * C for _ in [0] * 3] for i in range(N): for j, x in enumerate(map(int, input().split())): tri[(i + j) % 3][x - 1] += 1 res = 1 << 30 for p in permutations(list(range(C)), 3): ...
false
29.411765
[ "-c = [list(map(int, input().split())) for _ in [0] * N]", "-tri = [[] for _ in [0] * 3]", "-for i in range(1, N + 1):", "- for j in range(1, N + 1):", "- tri[(i + j) % 3] += [c[i - 1][j - 1] - 1]", "-incom = [[0] * C for _ in [0] * 3]", "-for i in range(3):", "- for color in range(C):", ...
false
0.038708
0.037219
1.040006
[ "s647238054", "s654163778" ]
u014333473
p02720
python
s271516686
s520800047
113
86
18,940
18,896
Accepted
Accepted
23.89
from collections import deque k=int(eval(input())) d=deque() for i in range(1,10): d.append(i) for i in range(k): x=d.popleft() if i==k-1: print(x) break if x%10!=0: d.append(10*x+x%10-1) d.append(10*x+x%10) if x%10!=9: d.append(10*x+x%10+1)
from collections import deque d=deque(list(range(1,10))) for i in range(int(eval(input()))): x=d.popleft() r=x%10;c=x*10+r if r!=0:d.append(c-1) d.append(c) if r!=9:d.append(c+1) print(x)
14
9
274
199
from collections import deque k = int(eval(input())) d = deque() for i in range(1, 10): d.append(i) for i in range(k): x = d.popleft() if i == k - 1: print(x) break if x % 10 != 0: d.append(10 * x + x % 10 - 1) d.append(10 * x + x % 10) if x % 10 != 9: d.append(1...
from collections import deque d = deque(list(range(1, 10))) for i in range(int(eval(input()))): x = d.popleft() r = x % 10 c = x * 10 + r if r != 0: d.append(c - 1) d.append(c) if r != 9: d.append(c + 1) print(x)
false
35.714286
[ "-k = int(eval(input()))", "-d = deque()", "-for i in range(1, 10):", "- d.append(i)", "-for i in range(k):", "+d = deque(list(range(1, 10)))", "+for i in range(int(eval(input()))):", "- if i == k - 1:", "- print(x)", "- break", "- if x % 10 != 0:", "- d.append(10...
false
0.050758
0.202978
0.250065
[ "s271516686", "s520800047" ]
u968166680
p02862
python
s776847666
s704472347
201
172
41,328
39,732
Accepted
Accepted
14.43
from sys import stdin, setrecursionlimit setrecursionlimit(10 ** 9) INF = 1 << 60 def input(): return stdin.readline().strip() MOD = 1000000007 X, Y = list(map(int, input().split())) n = (X + Y) // 3 x = (2 * X - Y) // 3 y = (-X + 2 * Y) // 3 if (X + Y) % 3 or x < 0 or y < 0: print((0)) ...
from sys import stdin, setrecursionlimit setrecursionlimit(10 ** 9) INF = 1 << 60 def input(): return stdin.readline().strip() X, Y = list(map(int, input().split())) n = (X + Y) // 3 x = (2 * X - Y) // 3 y = (-X + 2 * Y) // 3 if (X + Y) % 3 or x < 0 or y < 0: print((0)) exit() de...
44
31
783
581
from sys import stdin, setrecursionlimit setrecursionlimit(10**9) INF = 1 << 60 def input(): return stdin.readline().strip() MOD = 1000000007 X, Y = list(map(int, input().split())) n = (X + Y) // 3 x = (2 * X - Y) // 3 y = (-X + 2 * Y) // 3 if (X + Y) % 3 or x < 0 or y < 0: print((0)) exit() def mod_...
from sys import stdin, setrecursionlimit setrecursionlimit(10**9) INF = 1 << 60 def input(): return stdin.readline().strip() X, Y = list(map(int, input().split())) n = (X + Y) // 3 x = (2 * X - Y) // 3 y = (-X + 2 * Y) // 3 if (X + Y) % 3 or x < 0 or y < 0: print((0)) exit() def mod_com(n, r): MO...
false
29.545455
[ "-MOD = 1000000007", "-def mod_com(n, k):", "- if n < k:", "- return 0", "- if n < 0 or k < 0:", "- return 0", "- if k > n - k:", "- k = n - k", "- if k == 0:", "- return 1", "- ans = 1", "- for i in range(n - k + 1, n + 1):", "- ans = ans...
false
0.104123
0.070134
1.484633
[ "s776847666", "s704472347" ]
u119148115
p02625
python
s030486018
s115877637
677
583
68,228
67,920
Accepted
Accepted
13.88
import sys def S(): return sys.stdin.readline().rstrip() N,M = list(map(int,S().split())) mod = 10**9+7 a = M # (M_P_N)**2 for i in range(1,N): a *= M-i a %= mod # 包除原理 # 2つめの条件は常に成り立った状況で考える # {1,…,N}の部分集合Sの元iに対してA_i=B_iが成り立つようなA_1,…,B_1,…の組の個数を考える ans = a**2 % mod r = ans for i in range(...
import sys def S(): return sys.stdin.readline().rstrip() N,M = list(map(int,S().split())) mod = 10**9+7 a = M # (M_P_N)**2 for i in range(1,N): a *= M-i a %= mod # 包除原理 # 2つめの条件は常に成り立った状況で考える # {1,…,N}の部分集合Sの元iに対してA_i=B_iが成り立つようなA_1,…,B_1,…の組の個数を考える ans = a**2 % mod r = ans for i in range(...
24
28
440
488
import sys def S(): return sys.stdin.readline().rstrip() N, M = list(map(int, S().split())) mod = 10**9 + 7 a = M # (M_P_N)**2 for i in range(1, N): a *= M - i a %= mod # 包除原理 # 2つめの条件は常に成り立った状況で考える # {1,…,N}の部分集合Sの元iに対してA_i=B_iが成り立つようなA_1,…,B_1,…の組の個数を考える ans = a**2 % mod r = ans for i in range(1, N +...
import sys def S(): return sys.stdin.readline().rstrip() N, M = list(map(int, S().split())) mod = 10**9 + 7 a = M # (M_P_N)**2 for i in range(1, N): a *= M - i a %= mod # 包除原理 # 2つめの条件は常に成り立った状況で考える # {1,…,N}の部分集合Sの元iに対してA_i=B_iが成り立つようなA_1,…,B_1,…の組の個数を考える ans = a**2 % mod r = ans for i in range(1, N +...
false
14.285714
[ "- r *= (N - i + 1) * pow(i, mod - 2, mod) * pow(M - i + 1, mod - 2, mod) * (-1)", "+ r *= N - i + 1", "+ r %= mod", "+ r *= pow(i, mod - 2, mod)", "+ r %= mod", "+ r *= pow(M - i + 1, mod - 2, mod) * (-1)" ]
false
0.336573
0.672858
0.500214
[ "s030486018", "s115877637" ]
u514401521
p02762
python
s632331606
s090572281
1,574
1,408
62,116
31,192
Accepted
Accepted
10.55
class UnionFind: def __init__(self, n): self.d = [] for _ in range(n): self.d.append(-1) def find(self, x): if self.d[x] < 0: return x else: self.d[x] = self.find(self.d[x]) return self.d[x] def unite(self, x, y):...
class UnionFind: def __init__(self, n): self.d = [-1 for _ in range(n)] def find(self, x): if self.d[x] < 0: return x else: self.d[x] = self.find(self.d[x]) return self.d[x] def union(self, x, y): x = self.find(x) ...
55
56
1,210
1,191
class UnionFind: def __init__(self, n): self.d = [] for _ in range(n): self.d.append(-1) def find(self, x): if self.d[x] < 0: return x else: self.d[x] = self.find(self.d[x]) return self.d[x] def unite(self, x, y): x = ...
class UnionFind: def __init__(self, n): self.d = [-1 for _ in range(n)] def find(self, x): if self.d[x] < 0: return x else: self.d[x] = self.find(self.d[x]) return self.d[x] def union(self, x, y): x = self.find(x) y = self.find(y)...
false
1.785714
[ "- self.d = []", "- for _ in range(n):", "- self.d.append(-1)", "+ self.d = [-1 for _ in range(n)]", "- def unite(self, x, y):", "+ def union(self, x, y):", "- self.d[x] = self.d[x] + self.d[y]", "+ self.d[x] += self.d[y]", "-n, m, k = map(int, inp...
false
0.044823
0.045875
0.977079
[ "s632331606", "s090572281" ]
u892251744
p02728
python
s906533072
s575400919
1,601
1,030
124,748
126,736
Accepted
Accepted
35.67
def main(): import sys from collections import deque input = sys.stdin.readline # comb init mod = 1000000007 nmax = 2*10 ** 5 + 10 # change here fac = [0] * nmax finv = [0] * nmax inv = [0] * nmax fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[...
def main(): import sys input = sys.stdin.readline # comb init mod = 1000000007 nmax = 2 * 10 ** 5 + 10 # change here fac = [0] * nmax finv = [0] * nmax inv = [0] * nmax fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2, nma...
79
98
1,944
2,678
def main(): import sys from collections import deque input = sys.stdin.readline # comb init mod = 1000000007 nmax = 2 * 10**5 + 10 # change here fac = [0] * nmax finv = [0] * nmax inv = [0] * nmax fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for ...
def main(): import sys input = sys.stdin.readline # comb init mod = 1000000007 nmax = 2 * 10**5 + 10 # change here fac = [0] * nmax finv = [0] * nmax inv = [0] * nmax fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2, nmax): fac[i...
false
19.387755
[ "- from collections import deque", "- que = deque()", "- que.append(1)", "- seen = [-1] * (N + 1)", "- seen[1] = 0", "- par = [0] * (N + 1)", "- child = [[] for _ in range(N + 1)]", "- seq = []", "- while que:", "- v = que.popleft()", "- seq.append(v)", ...
false
0.340924
0.502286
0.678746
[ "s906533072", "s575400919" ]
u079022693
p03645
python
s916604554
s400216681
559
388
46,744
43,920
Accepted
Accepted
30.59
from sys import stdin from collections import deque def main(): #入力 readline=stdin.readline n,m=list(map(int,readline().split())) G=[[] for _ in range(n+1)] for _ in range(m): a,b=list(map(int,readline().split())) G[a].append(b) G[b].append(a) #bfs q=deq...
from sys import stdin def main(): #入力 readline=stdin.readline n,m=list(map(int,readline().split())) G=[[] for _ in range(n+1)] for _ in range(m): a,b=list(map(int,readline().split())) G[a].append(b) G[b].append(a) s=set(G[1]) ans=False while len(s)>0...
32
24
754
521
from sys import stdin from collections import deque def main(): # 入力 readline = stdin.readline n, m = list(map(int, readline().split())) G = [[] for _ in range(n + 1)] for _ in range(m): a, b = list(map(int, readline().split())) G[a].append(b) G[b].append(a) # bfs q...
from sys import stdin def main(): # 入力 readline = stdin.readline n, m = list(map(int, readline().split())) G = [[] for _ in range(n + 1)] for _ in range(m): a, b = list(map(int, readline().split())) G[a].append(b) G[b].append(a) s = set(G[1]) ans = False while l...
false
25
[ "-from collections import deque", "- # bfs", "- q = deque([tuple((1, 0))])", "- flags = [False] * (n + 1)", "- flags[1] = True", "+ s = set(G[1])", "- while len(q) > 0:", "- now, d = q.popleft()", "- if now == n:", "- if d == 2:", "+ while len(s) > 0...
false
0.068867
0.038692
1.779881
[ "s916604554", "s400216681" ]
u304050136
p03197
python
s522678948
s815867035
194
52
3,060
7,828
Accepted
Accepted
73.2
print(("second" if all(int(eval(input()))%2 == 0 for i in range(int(eval(input())))) else 'first'))
import sys print(('second' if all(i%2==0 for i in list(map(int,sys.stdin))[1:]) else 'first'))
1
2
86
93
print( ( "second" if all(int(eval(input())) % 2 == 0 for i in range(int(eval(input())))) else "first" ) )
import sys print(("second" if all(i % 2 == 0 for i in list(map(int, sys.stdin))[1:]) else "first"))
false
50
[ "-print(", "- (", "- \"second\"", "- if all(int(eval(input())) % 2 == 0 for i in range(int(eval(input()))))", "- else \"first\"", "- )", "-)", "+import sys", "+", "+print((\"second\" if all(i % 2 == 0 for i in list(map(int, sys.stdin))[1:]) else \"first\"))" ]
false
0.036147
0.036599
0.987668
[ "s522678948", "s815867035" ]
u922449550
p03839
python
s040582086
s187678805
196
159
14,736
14,776
Accepted
Accepted
18.88
N, K = list(map(int, input().split())) A = list(map(int, input().split())) ans = sum([a for a in A if a > 0]) B = [a if a <= 0 else 0 for a in A] s = sum(B[:K]) s_max = s c = sum([1 for a in A[:K] if a <= 0]) c_max = c for i in range(N-K): s += B[i+K] - B[i] s_max = max(s_max, s) c += (A[i+K]<=0) -...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) ans = sum([a for a in A if a > 0]) B = [a if a <= 0 else 0 for a in A] s = sum(B[:K]) s_max = s for i in range(N-K): s += B[i+K] - B[i] s_max = max(s_max, s) B = [a if a > 0 else 0 for a in A] s = sum(B[:K]) s_min = s for i...
28
20
561
412
N, K = list(map(int, input().split())) A = list(map(int, input().split())) ans = sum([a for a in A if a > 0]) B = [a if a <= 0 else 0 for a in A] s = sum(B[:K]) s_max = s c = sum([1 for a in A[:K] if a <= 0]) c_max = c for i in range(N - K): s += B[i + K] - B[i] s_max = max(s_max, s) c += (A[i + K] <= 0) - ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) ans = sum([a for a in A if a > 0]) B = [a if a <= 0 else 0 for a in A] s = sum(B[:K]) s_max = s for i in range(N - K): s += B[i + K] - B[i] s_max = max(s_max, s) B = [a if a > 0 else 0 for a in A] s = sum(B[:K]) s_min = s for i in range(...
false
28.571429
[ "-c = sum([1 for a in A[:K] if a <= 0])", "-c_max = c", "- c += (A[i + K] <= 0) - (A[i] <= 0)", "- c_max = max(c_max, c)", "-if c_max == K:", "- print(ans)", "- quit()" ]
false
0.046259
0.04617
1.001932
[ "s040582086", "s187678805" ]
u607563136
p02573
python
s176725813
s534512289
653
538
41,020
15,824
Accepted
Accepted
17.61
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1]*n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1]*n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union...
39
34
834
817
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = se...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = se...
false
12.820513
[ "-n, m = list(map(int, input().split()))", "-uf = UnionFind(n)", "-ab = [tuple(map(int, input().split())) for _ in range(m)]", "-for a, b in ab:", "- uf.union(a - 1, b - 1)", "-ans = -1", "-for i in uf.parents:", "- ans = min(i, ans)", "-print((-ans))", "+def main():", "+ n, m = list(ma...
false
0.046188
0.04532
1.019151
[ "s176725813", "s534512289" ]
u285681431
p02954
python
s539225914
s525443847
115
96
12,488
79,400
Accepted
Accepted
16.52
s = eval(input()) n = len(s) boundary = [] ans = [0] * n # "LR"を記録、Lの方のindexをboundaryにappend for i in range(n - 1): if s[i] == "L" and s[i + 1] == "R": boundary.append(i) # n-1があると後のfor文で都合が良いので足しておく boundary.append(n - 1) # RR...RLL...L の形に分割されている l = 0 for r in boundary: middle = 0 ...
S = eval(input()) N = len(S) # RR...RLL...L の形に分割したい # 境界は"LR"となっているはず # "LR"の"L"のindexを記録 boundary = [] for i in range(N - 1): if S[i] == "L" and S[i + 1] == "R": boundary.append(i) # boundary は R..RL..Lの左端 として扱いたいので、N-1も追加 boundary.append(N - 1) ans = [0] * N l = 0 for r in boundary...
38
43
854
887
s = eval(input()) n = len(s) boundary = [] ans = [0] * n # "LR"を記録、Lの方のindexをboundaryにappend for i in range(n - 1): if s[i] == "L" and s[i + 1] == "R": boundary.append(i) # n-1があると後のfor文で都合が良いので足しておく boundary.append(n - 1) # RR...RLL...L の形に分割されている l = 0 for r in boundary: middle = 0 cnt = [0, 0] ...
S = eval(input()) N = len(S) # RR...RLL...L の形に分割したい # 境界は"LR"となっているはず # "LR"の"L"のindexを記録 boundary = [] for i in range(N - 1): if S[i] == "L" and S[i + 1] == "R": boundary.append(i) # boundary は R..RL..Lの左端 として扱いたいので、N-1も追加 boundary.append(N - 1) ans = [0] * N l = 0 for r in boundary: mid = 0 # [in...
false
11.627907
[ "-s = eval(input())", "-n = len(s)", "+S = eval(input())", "+N = len(S)", "+# RR...RLL...L の形に分割したい", "+# 境界は\"LR\"となっているはず", "+# \"LR\"の\"L\"のindexを記録", "-ans = [0] * n", "-# \"LR\"を記録、Lの方のindexをboundaryにappend", "-for i in range(n - 1):", "- if s[i] == \"L\" and s[i + 1] == \"R\":", "+for...
false
0.038517
0.037738
1.020641
[ "s539225914", "s525443847" ]
u771917453
p02418
python
s744392528
s921407962
40
30
6,432
6,428
Accepted
Accepted
25
a = input() b = input() a = a+a if 0 < a.count(b): print('Yes') else: print('No')
a = input() b = input() a = a+a if 0 <= a.find(b): print('Yes') else: print('No')
7
7
101
101
a = input() b = input() a = a + a if 0 < a.count(b): print("Yes") else: print("No")
a = input() b = input() a = a + a if 0 <= a.find(b): print("Yes") else: print("No")
false
0
[ "-if 0 < a.count(b):", "+if 0 <= a.find(b):" ]
false
0.185554
0.064963
2.856284
[ "s744392528", "s921407962" ]
u067447457
p02773
python
s148421749
s518526792
809
379
47,240
38,476
Accepted
Accepted
53.15
n = int(eval(input())) s = [eval(input()) for _ in range(n)] d = {} for w in s: if w not in d: d[w] = 0 d[w] += 1 d2 = sorted(list(d.items()), key=lambda x:x[1], reverse=True) maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]] maxcnts.sort() for ans in maxcnts: print(ans)
from collections import Counter stdin = open(0) N = int(stdin.readline()) S = stdin.read().split() counter = Counter(S) max_cnt = max(counter.values()) names = [name for name, cnt in counter.items() if cnt == max_cnt] names.sort() print(*names, sep='\n')
12
14
283
277
n = int(eval(input())) s = [eval(input()) for _ in range(n)] d = {} for w in s: if w not in d: d[w] = 0 d[w] += 1 d2 = sorted(list(d.items()), key=lambda x: x[1], reverse=True) maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]] maxcnts.sort() for ans in maxcnts: print(ans)
from collections import Counter stdin = open(0) N = int(stdin.readline()) S = stdin.read().split() counter = Counter(S) max_cnt = max(counter.values()) names = [name for name, cnt in counter.items() if cnt == max_cnt] names.sort() print(*names, sep="\n")
false
14.285714
[ "-n = int(eval(input()))", "-s = [eval(input()) for _ in range(n)]", "-d = {}", "-for w in s:", "- if w not in d:", "- d[w] = 0", "- d[w] += 1", "-d2 = sorted(list(d.items()), key=lambda x: x[1], reverse=True)", "-maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]]", "-maxcnts.sort()", ...
false
0.038486
0.040202
0.957299
[ "s148421749", "s518526792" ]
u908763441
p02629
python
s872648760
s455663907
83
66
61,752
61,640
Accepted
Accepted
20.48
n = int(eval(input())) s = 'abcdefghijklmnopqrstuvwxyz' def calc(n, ans): n, i = divmod((n - 1), 26) ans = s[i] + ans if (n > 0): return calc(n, ans) else: return ans ans = calc(n, '') print(ans)
n = int(eval(input())) s = 'abcdefghijklmnopqrstuvwxyz' ans = '' while n > 0: n, i = divmod(n - 1, 26) ans = s[i] + ans print(ans)
15
7
223
134
n = int(eval(input())) s = "abcdefghijklmnopqrstuvwxyz" def calc(n, ans): n, i = divmod((n - 1), 26) ans = s[i] + ans if n > 0: return calc(n, ans) else: return ans ans = calc(n, "") print(ans)
n = int(eval(input())) s = "abcdefghijklmnopqrstuvwxyz" ans = "" while n > 0: n, i = divmod(n - 1, 26) ans = s[i] + ans print(ans)
false
53.333333
[ "-", "-", "-def calc(n, ans):", "- n, i = divmod((n - 1), 26)", "+ans = \"\"", "+while n > 0:", "+ n, i = divmod(n - 1, 26)", "- if n > 0:", "- return calc(n, ans)", "- else:", "- return ans", "-", "-", "-ans = calc(n, \"\")" ]
false
0.056251
0.040633
1.384373
[ "s872648760", "s455663907" ]
u761320129
p03644
python
s091085555
s326685025
19
17
2,940
2,940
Accepted
Accepted
10.53
N = int(eval(input())) k = len(bin(N))-3 print((2**k))
N = int(eval(input())) l = len(bin(N))-3 print((2**l))
3
3
48
48
N = int(eval(input())) k = len(bin(N)) - 3 print((2**k))
N = int(eval(input())) l = len(bin(N)) - 3 print((2**l))
false
0
[ "-k = len(bin(N)) - 3", "-print((2**k))", "+l = len(bin(N)) - 3", "+print((2**l))" ]
false
0.046308
0.051685
0.895973
[ "s091085555", "s326685025" ]
u151625340
p03086
python
s401666027
s455859922
169
17
38,256
3,060
Accepted
Accepted
89.94
S = eval(input()) ans = 0 l = 0 for i in range(len(S)): if S[i] in ('A','C','G','T'): l += 1 else: ans = max(ans,l) l = 0 ans = max(ans,l) print(ans)
S = eval(input()) ans = 0 now = 0 for i in range(len(S)): if S[i] in ['A','T','G','C']: now += 1 else: ans = max(ans,now) now = 0 ans = max(ans,now) print(ans)
11
11
186
195
S = eval(input()) ans = 0 l = 0 for i in range(len(S)): if S[i] in ("A", "C", "G", "T"): l += 1 else: ans = max(ans, l) l = 0 ans = max(ans, l) print(ans)
S = eval(input()) ans = 0 now = 0 for i in range(len(S)): if S[i] in ["A", "T", "G", "C"]: now += 1 else: ans = max(ans, now) now = 0 ans = max(ans, now) print(ans)
false
0
[ "-l = 0", "+now = 0", "- if S[i] in (\"A\", \"C\", \"G\", \"T\"):", "- l += 1", "+ if S[i] in [\"A\", \"T\", \"G\", \"C\"]:", "+ now += 1", "- ans = max(ans, l)", "- l = 0", "-ans = max(ans, l)", "+ ans = max(ans, now)", "+ now = 0", "+ans = max(...
false
0.046261
0.084659
0.54644
[ "s401666027", "s455859922" ]
u906501980
p02661
python
s114576519
s739020920
459
373
29,408
99,060
Accepted
Accepted
18.74
def main(): n = int(eval(input())) al = [] bl = [] for _ in range(n): a, b = list(map(int, input().split())) al.append(a) bl.append(b) als = list(sorted(al)) bls = list(sorted(bl)) if n%2: print((bls[n//2]-als[n//2]+1)) else: print((bl...
def main(): n = int(eval(input())) al = [] bl = [] for _ in range(n): a, b = list(map(int, input().split())) al.append(a) bl.append(b) al.sort() bl.sort() if n%2: print((bl[n//2]-al[n//2]+1)) else: print((bl[n//2]+bl[n//2-1]-al[n//2]-a...
17
17
391
359
def main(): n = int(eval(input())) al = [] bl = [] for _ in range(n): a, b = list(map(int, input().split())) al.append(a) bl.append(b) als = list(sorted(al)) bls = list(sorted(bl)) if n % 2: print((bls[n // 2] - als[n // 2] + 1)) else: print((bls[n...
def main(): n = int(eval(input())) al = [] bl = [] for _ in range(n): a, b = list(map(int, input().split())) al.append(a) bl.append(b) al.sort() bl.sort() if n % 2: print((bl[n // 2] - al[n // 2] + 1)) else: print((bl[n // 2] + bl[n // 2 - 1] - al[...
false
0
[ "- als = list(sorted(al))", "- bls = list(sorted(bl))", "+ al.sort()", "+ bl.sort()", "- print((bls[n // 2] - als[n // 2] + 1))", "+ print((bl[n // 2] - al[n // 2] + 1))", "- print((bls[n // 2 - 1] + bls[n // 2] - als[n // 2] - als[n // 2 - 1] + 1))", "+ print((...
false
0.037265
0.037039
1.006089
[ "s114576519", "s739020920" ]
u163783894
p03583
python
s725239204
s989852900
1,602
99
9,208
65,936
Accepted
Accepted
93.82
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().decode('utf-8') ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().decode('utf-8') ...
30
30
749
735
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().decode("utf-8") def main(...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: list(map(int, readline().split())) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: list(map(int, read().split())) in_s = lambda: readline().rstrip().decode("utf-8") def main(...
false
0
[ "- if c.is_integer() and 1 <= c and c <= 3500:", "+ if c.is_integer() and 1 <= c:" ]
false
2.014235
0.47264
4.261666
[ "s725239204", "s989852900" ]
u608241985
p02613
python
s410220792
s823817401
146
31
16,256
9,540
Accepted
Accepted
78.77
n = int(eval(input())) s = [eval(input()) for _ in range(n)] res = ["AC", "WA", "TLE", "RE"] for r in res: print((r, "x", s.count(r)))
s = open(0).read().count for r in "AC", "WA", "TLE", "RE": print((r, "x", s(r)))
6
3
130
84
n = int(eval(input())) s = [eval(input()) for _ in range(n)] res = ["AC", "WA", "TLE", "RE"] for r in res: print((r, "x", s.count(r)))
s = open(0).read().count for r in "AC", "WA", "TLE", "RE": print((r, "x", s(r)))
false
50
[ "-n = int(eval(input()))", "-s = [eval(input()) for _ in range(n)]", "-res = [\"AC\", \"WA\", \"TLE\", \"RE\"]", "-for r in res:", "- print((r, \"x\", s.count(r)))", "+s = open(0).read().count", "+for r in \"AC\", \"WA\", \"TLE\", \"RE\":", "+ print((r, \"x\", s(r)))" ]
false
0.050723
0.038906
1.303716
[ "s410220792", "s823817401" ]
u869790980
p03673
python
s410987866
s340901198
457
409
147,248
130,592
Accepted
Accepted
10.5
import collections n,rev,q = int(input()) ,False,collections.deque() class Node(object): def __init__(self, val): self.val = val self.next = None self.prev = None head = None tail = None for ai in map(int, input().split()): if head is None: node = Node(ai) head = node tail = node else: ...
import collections n,rev = int(input()) ,False class Node(object): def __init__(self, val): self.val = val self.next, self.prev = None, None for i,ai in enumerate(map(int, input().split())): node = Node(ai) if i == 0: head,tail = node,node else: if rev: head.prev, node.next = node, head ...
34
24
629
535
import collections n, rev, q = int(input()), False, collections.deque() class Node(object): def __init__(self, val): self.val = val self.next = None self.prev = None head = None tail = None for ai in map(int, input().split()): if head is None: node = Node(ai) head = ...
import collections n, rev = int(input()), False class Node(object): def __init__(self, val): self.val = val self.next, self.prev = None, None for i, ai in enumerate(map(int, input().split())): node = Node(ai) if i == 0: head, tail = node, node else: if rev: ...
false
29.411765
[ "-n, rev, q = int(input()), False, collections.deque()", "+n, rev = int(input()), False", "- self.next = None", "- self.prev = None", "+ self.next, self.prev = None, None", "-head = None", "-tail = None", "-for ai in map(int, input().split()):", "- if head is None:", "- ...
false
0.082218
0.085166
0.965396
[ "s410987866", "s340901198" ]
u347640436
p02947
python
s232410484
s434579057
359
241
19,764
19,748
Accepted
Accepted
32.87
from collections import Counter n = int(eval(input())) t = Counter([''.join(sorted(eval(input()))) for _ in range(n)]) print((sum(t[k] * (t[k] -1) // 2 for k in t)))
def main(): from collections import Counter from sys import stdin readline = stdin.readline N = int(readline()) t = Counter([''.join(sorted(readline()[:-1])) for _ in range(N)]) print((sum(t[k] * (t[k] - 1) // 2 for k in t))) main()
4
8
155
250
from collections import Counter n = int(eval(input())) t = Counter(["".join(sorted(eval(input()))) for _ in range(n)]) print((sum(t[k] * (t[k] - 1) // 2 for k in t)))
def main(): from collections import Counter from sys import stdin readline = stdin.readline N = int(readline()) t = Counter(["".join(sorted(readline()[:-1])) for _ in range(N)]) print((sum(t[k] * (t[k] - 1) // 2 for k in t))) main()
false
50
[ "-from collections import Counter", "+def main():", "+ from collections import Counter", "+ from sys import stdin", "-n = int(eval(input()))", "-t = Counter([\"\".join(sorted(eval(input()))) for _ in range(n)])", "-print((sum(t[k] * (t[k] - 1) // 2 for k in t)))", "+ readline = stdin.readline...
false
0.036961
0.088872
0.415891
[ "s232410484", "s434579057" ]
u620868411
p03044
python
s282921977
s089690601
1,036
780
38,828
45,976
Accepted
Accepted
24.71
# -*- coding: utf-8 -*- n = int(eval(input())) edge = [[] for _ in range(n)] for _ in range(n-1): u,v,w = list(map(int, input().split())) u -= 1 v -= 1 edge[u].append((v,w)) edge[v].append((u,w)) res = [-1]*n res[0] = 0 q = [0] while len(q)>0: u = q.pop(0) if len(edge[u])==0:...
# -*- coding: utf-8 -*- from collections import defaultdict n = int(eval(input())) e = defaultdict(lambda: []) for _ in range(n-1): v,u,w = list(map(int, input().split())) v -= 1 u -= 1 e[v].append((u,w)) e[u].append((v,w)) col = [-1]*n q = [0] col[0] = 0 while len(q)>0: v = q....
29
26
551
512
# -*- coding: utf-8 -*- n = int(eval(input())) edge = [[] for _ in range(n)] for _ in range(n - 1): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 edge[u].append((v, w)) edge[v].append((u, w)) res = [-1] * n res[0] = 0 q = [0] while len(q) > 0: u = q.pop(0) if len(edge[u]) == 0: ...
# -*- coding: utf-8 -*- from collections import defaultdict n = int(eval(input())) e = defaultdict(lambda: []) for _ in range(n - 1): v, u, w = list(map(int, input().split())) v -= 1 u -= 1 e[v].append((u, w)) e[u].append((v, w)) col = [-1] * n q = [0] col[0] = 0 while len(q) > 0: v = q.pop() ...
false
10.344828
[ "+from collections import defaultdict", "+", "-edge = [[] for _ in range(n)]", "+e = defaultdict(lambda: [])", "- u, v, w = list(map(int, input().split()))", "+ v, u, w = list(map(int, input().split()))", "+ v -= 1", "- v -= 1", "- edge[u].append((v, w))", "- edge[v].append((u, w...
false
0.039168
0.044329
0.883577
[ "s282921977", "s089690601" ]
u729939940
p02911
python
s613298578
s287382425
209
68
11,316
12,624
Accepted
Accepted
67.46
N, K, Q = list(map(int, input().split())) A = [] for q in range(Q): A.append(int(eval(input()))) score = [K - Q] * (N + 1) for a in A: score[a] += 1 ans = "\n".join("No" if s <= 0 else "Yes" for s in score[1:]) print(ans)
import sys N, K, Q = list(map(int, input().split())) A = (int(x) for x in sys.stdin.read().split()) score = [K - Q] * (N + 1) for a in A: score[a] += 1 ans = "\n".join("No" if s <= 0 else "Yes" for s in score[1:]) print(ans)
9
8
225
229
N, K, Q = list(map(int, input().split())) A = [] for q in range(Q): A.append(int(eval(input()))) score = [K - Q] * (N + 1) for a in A: score[a] += 1 ans = "\n".join("No" if s <= 0 else "Yes" for s in score[1:]) print(ans)
import sys N, K, Q = list(map(int, input().split())) A = (int(x) for x in sys.stdin.read().split()) score = [K - Q] * (N + 1) for a in A: score[a] += 1 ans = "\n".join("No" if s <= 0 else "Yes" for s in score[1:]) print(ans)
false
11.111111
[ "+import sys", "+", "-A = []", "-for q in range(Q):", "- A.append(int(eval(input())))", "+A = (int(x) for x in sys.stdin.read().split())" ]
false
0.128352
0.03655
3.511707
[ "s613298578", "s287382425" ]
u644516473
p03575
python
s285267490
s809944377
122
25
3,444
3,316
Accepted
Accepted
79.51
from collections import deque N, M = list(map(int, input().split())) V = [list(map(int, input().split())) for _ in range(M)] class UnionFind(): def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: ...
from collections import deque N, M = list(map(int, input().split())) V = [list(map(int, input().split())) for _ in range(M)] class UnionFind(): def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: ...
46
44
1,110
1,077
from collections import deque N, M = list(map(int, input().split())) V = [list(map(int, input().split())) for _ in range(M)] class UnionFind: def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[...
from collections import deque N, M = list(map(int, input().split())) V = [list(map(int, input().split())) for _ in range(M)] class UnionFind: def __init__(self, n): self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[...
false
4.347826
[ "-for i in range(N):", "- for j in range(i + 1, N):", "- uf = UnionFind(N)", "- for a, b in V:", "- if a - 1 == i and b - 1 == j:", "- continue", "+for i in range(M):", "+ uf = UnionFind(N)", "+ for j, (a, b) in enumerate(V):", "+ if i != j:"...
false
0.084919
0.037192
2.283246
[ "s285267490", "s809944377" ]
u006657459
p03240
python
s354863850
s698195549
38
30
4,324
3,064
Accepted
Accepted
21.05
N = int(eval(input())) x, y, h = [], [], [] x2, y2, h2 = [], [], [] for i in range(N): xi, yi, hi = list(map(int, input().split())) if hi == 0: x2.append(xi) y2.append(yi) h2.append(hi) else: x.append(xi) y.append(yi) h.append(hi) def fn(H, X,...
N = int(eval(input())) x, y, h = [], [], [] x2, y2, h2 = [], [], [] for i in range(N): xi, yi, hi = list(map(int, input().split())) if hi != 0: x.append(xi) y.append(yi) h.append(hi) def fn(H, X, Y, Cx, Cy): return H + abs(Cx - X) + abs(Cy - Y) if len(h) == 1: p...
35
31
810
670
N = int(eval(input())) x, y, h = [], [], [] x2, y2, h2 = [], [], [] for i in range(N): xi, yi, hi = list(map(int, input().split())) if hi == 0: x2.append(xi) y2.append(yi) h2.append(hi) else: x.append(xi) y.append(yi) h.append(hi) def fn(H, X, Y, Cx, Cy): ...
N = int(eval(input())) x, y, h = [], [], [] x2, y2, h2 = [], [], [] for i in range(N): xi, yi, hi = list(map(int, input().split())) if hi != 0: x.append(xi) y.append(yi) h.append(hi) def fn(H, X, Y, Cx, Cy): return H + abs(Cx - X) + abs(Cy - Y) if len(h) == 1: print((x[0], y[...
false
11.428571
[ "- if hi == 0:", "- x2.append(xi)", "- y2.append(yi)", "- h2.append(hi)", "- else:", "+ if hi != 0:", "-heights = []", "+if len(h) == 1:", "+ print((x[0], y[0], h[0]))", "+ exit()", "- heights.append([H, Cx, Cy])", "- if len(h) == 1:", "- ...
false
0.038644
0.042297
0.913629
[ "s354863850", "s698195549" ]
u906501980
p03372
python
s867484021
s432678406
744
675
54,000
71,512
Accepted
Accepted
9.27
from numpy import array as n N, C = list(map(int, input().split())) xy = [list(map(int, input().split())) for _ in range(N)] r1, r2, l1, l2 = [0],[0],[0],[0] sum = 0 for x, cal in xy: sum += cal r1.append(max(r1[-1], sum-x)) r2.append(max(r2[-1], sum-2*x)) sum = 0 for x, cal in xy[::-1]: sum ...
def main(): n, c = list(map(int, input().split())) xv = [list(map(int, input().split())) for _ in range(n)] v, left_max, right_max = 0, 0, 0 gl = [None]*n gr = [None]*n _2oas = [None]*(n+1) _2obs = [None]*(n+1) _2oas[0], _2obs[0] = 0, 0 ans = 0 for i, (xi, vi) in enumer...
16
38
452
1,003
from numpy import array as n N, C = list(map(int, input().split())) xy = [list(map(int, input().split())) for _ in range(N)] r1, r2, l1, l2 = [0], [0], [0], [0] sum = 0 for x, cal in xy: sum += cal r1.append(max(r1[-1], sum - x)) r2.append(max(r2[-1], sum - 2 * x)) sum = 0 for x, cal in xy[::-1]: sum +...
def main(): n, c = list(map(int, input().split())) xv = [list(map(int, input().split())) for _ in range(n)] v, left_max, right_max = 0, 0, 0 gl = [None] * n gr = [None] * n _2oas = [None] * (n + 1) _2obs = [None] * (n + 1) _2oas[0], _2obs[0] = 0, 0 ans = 0 for i, (xi, vi) in enum...
false
57.894737
[ "-from numpy import array as n", "+def main():", "+ n, c = list(map(int, input().split()))", "+ xv = [list(map(int, input().split())) for _ in range(n)]", "+ v, left_max, right_max = 0, 0, 0", "+ gl = [None] * n", "+ gr = [None] * n", "+ _2oas = [None] * (n + 1)", "+ _2obs = [No...
false
0.178889
0.043274
4.133889
[ "s867484021", "s432678406" ]
u222668979
p03031
python
s156530530
s664445382
211
38
42,480
9,204
Accepted
Accepted
81.99
from itertools import product n, m = list(map(int, input().split())) ks = [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) cnt = 0 for pat in product([0, 1], repeat=n): for i in range(m): if sum(pat[ks[i][j + 1] - 1] for j in range(ks[i][0])) % 2 != p[i]: ...
from itertools import product n, m = list(map(int, input().split())) ks = [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) cnt = 0 for pat in product([0, 1], repeat=n): for i in range(m): tmp = sum(pat[ks[i][j + 1] - 1] for j in range(ks[i][0])) if ...
15
15
374
392
from itertools import product n, m = list(map(int, input().split())) ks = [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) cnt = 0 for pat in product([0, 1], repeat=n): for i in range(m): if sum(pat[ks[i][j + 1] - 1] for j in range(ks[i][0])) % 2 != p[i]: ...
from itertools import product n, m = list(map(int, input().split())) ks = [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) cnt = 0 for pat in product([0, 1], repeat=n): for i in range(m): tmp = sum(pat[ks[i][j + 1] - 1] for j in range(ks[i][0])) if tmp % 2 != ...
false
0
[ "- if sum(pat[ks[i][j + 1] - 1] for j in range(ks[i][0])) % 2 != p[i]:", "+ tmp = sum(pat[ks[i][j + 1] - 1] for j in range(ks[i][0]))", "+ if tmp % 2 != p[i]:" ]
false
0.037802
0.165109
0.228953
[ "s156530530", "s664445382" ]
u597622207
p02873
python
s166304556
s112639101
508
246
34,612
12,956
Accepted
Accepted
51.57
S = list(eval(input())) L = len(S) count = 0 count_minus = [0] * L for i in range(L): if S[i] == ">": count = 0 else: count += 1 count_minus[i] = count count = 0 count_plus = [0] * L for i in reversed(list(range(L))): if S[i] == "<": count = 0 else: ...
s = eval(input()) partition = s.replace('><','>|<').split('|') ans=0 for sub in partition: left = sub.count('<') right = sub.count('>') ans += sum(range(1, max(left, right) + 1)) ans += sum(range(1, min(left, right))) print(ans)
26
11
548
250
S = list(eval(input())) L = len(S) count = 0 count_minus = [0] * L for i in range(L): if S[i] == ">": count = 0 else: count += 1 count_minus[i] = count count = 0 count_plus = [0] * L for i in reversed(list(range(L))): if S[i] == "<": count = 0 else: count += 1 cou...
s = eval(input()) partition = s.replace("><", ">|<").split("|") ans = 0 for sub in partition: left = sub.count("<") right = sub.count(">") ans += sum(range(1, max(left, right) + 1)) ans += sum(range(1, min(left, right))) print(ans)
false
57.692308
[ "-S = list(eval(input()))", "-L = len(S)", "-count = 0", "-count_minus = [0] * L", "-for i in range(L):", "- if S[i] == \">\":", "- count = 0", "- else:", "- count += 1", "- count_minus[i] = count", "-count = 0", "-count_plus = [0] * L", "-for i in reversed(list(range(...
false
0.042842
0.150439
0.284781
[ "s166304556", "s112639101" ]
u852690916
p03044
python
s992575731
s220456324
496
392
67,120
67,232
Accepted
Accepted
20.97
import sys def main(): input = sys.stdin.readline N = int(eval(input())) G = [[] for _ in range(N)] for _ in range(N-1): u,v,w = list(map(int, input().split())) u,v = u-1,v-1 G[u].append((v,w)) G[v].append((u,w)) ans = [-1] * N ans[0] = 0 stack =...
def main(): import sys input = sys.stdin.buffer.readline N = int(input()) edge = [[] for _ in range(N)] for i in range(N-1): a, b, c = (int(i) for i in input().split()) edge[a-1].append((c % 2, b-1)) edge[b-1].append((c % 2, a-1)) dist = [-1]*N color = [-1...
25
43
600
1,229
import sys def main(): input = sys.stdin.readline N = int(eval(input())) G = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) u, v = u - 1, v - 1 G[u].append((v, w)) G[v].append((u, w)) ans = [-1] * N ans[0] = 0 stack =...
def main(): import sys input = sys.stdin.buffer.readline N = int(input()) edge = [[] for _ in range(N)] for i in range(N - 1): a, b, c = (int(i) for i in input().split()) edge[a - 1].append((c % 2, b - 1)) edge[b - 1].append((c % 2, a - 1)) dist = [-1] * N color = [-...
false
41.860465
[ "-import sys", "+def main():", "+ import sys", "+ input = sys.stdin.buffer.readline", "+ N = int(input())", "+ edge = [[] for _ in range(N)]", "+ for i in range(N - 1):", "+ a, b, c = (int(i) for i in input().split())", "+ edge[a - 1].append((c % 2, b - 1))", "+ ...
false
0.110053
0.036155
3.043915
[ "s992575731", "s220456324" ]
u780475861
p03613
python
s811000581
s021207953
273
109
25,292
25,572
Accepted
Accepted
60.07
import sys import bisect def main(): n, *a = list(map(int, sys.stdin.read().split())) lr = [[i - 1,i + 1] for i in a] lr.sort(key=lambda x: x[0]) l = [i[0] for i in lr] res = 0 for i in range(n): right = bisect.bisect(l, lr[i][1]) left = bisect.bisect_left(l, l[i]) ...
import sys from itertools import accumulate def main(): n, *A = list(map(int, sys.stdin.read().split())) minA = min(A) - 1 lr = [[i - 1 - minA, i + 1 - minA] for i in A] lst = [0] * (max(A) - minA + 3) for i, j in lr: lst[i] += 1 lst[j + 1] -= 1 lst = list(accumulat...
19
18
411
386
import sys import bisect def main(): n, *a = list(map(int, sys.stdin.read().split())) lr = [[i - 1, i + 1] for i in a] lr.sort(key=lambda x: x[0]) l = [i[0] for i in lr] res = 0 for i in range(n): right = bisect.bisect(l, lr[i][1]) left = bisect.bisect_left(l, l[i]) res...
import sys from itertools import accumulate def main(): n, *A = list(map(int, sys.stdin.read().split())) minA = min(A) - 1 lr = [[i - 1 - minA, i + 1 - minA] for i in A] lst = [0] * (max(A) - minA + 3) for i, j in lr: lst[i] += 1 lst[j + 1] -= 1 lst = list(accumulate(lst)) ...
false
5.263158
[ "-import bisect", "+from itertools import accumulate", "- n, *a = list(map(int, sys.stdin.read().split()))", "- lr = [[i - 1, i + 1] for i in a]", "- lr.sort(key=lambda x: x[0])", "- l = [i[0] for i in lr]", "- res = 0", "- for i in range(n):", "- right = bisect.bisect(l, lr...
false
0.048164
0.083969
0.573601
[ "s811000581", "s021207953" ]
u940139461
p03944
python
s867134626
s528221986
213
167
43,500
38,256
Accepted
Accepted
21.6
# https://atcoder.jp/contests/abc047/tasks/abc047_b w, h, n = list(map(int, input().split())) area = [[0] * w for _ in range(h)] for _ in range(n): x, y, a = list(map(int, input().split())) if a == 1: for i in range(h): for j in range(w): if j < x: ...
w, h, n = list(map(int, input().split())) left_x = 0 right_x = w up_y = h down_y = 0 for _ in range(n): x, y, a = list(map(int, input().split())) if a == 1: left_x = max(left_x, x) elif a == 2: right_x = min(right_x, x) elif a == 3: down_y = max(down_y, y) else: ...
37
21
871
466
# https://atcoder.jp/contests/abc047/tasks/abc047_b w, h, n = list(map(int, input().split())) area = [[0] * w for _ in range(h)] for _ in range(n): x, y, a = list(map(int, input().split())) if a == 1: for i in range(h): for j in range(w): if j < x: area[i]...
w, h, n = list(map(int, input().split())) left_x = 0 right_x = w up_y = h down_y = 0 for _ in range(n): x, y, a = list(map(int, input().split())) if a == 1: left_x = max(left_x, x) elif a == 2: right_x = min(right_x, x) elif a == 3: down_y = max(down_y, y) else: up_y ...
false
43.243243
[ "-# https://atcoder.jp/contests/abc047/tasks/abc047_b", "-area = [[0] * w for _ in range(h)]", "+left_x = 0", "+right_x = w", "+up_y = h", "+down_y = 0", "- for i in range(h):", "- for j in range(w):", "- if j < x:", "- area[i][j] = 1", "- i...
false
0.063936
0.101944
0.627169
[ "s867134626", "s528221986" ]
u036514535
p02744
python
s793815288
s768774317
561
134
4,404
4,412
Accepted
Accepted
76.11
def p(S): str = "" for s in S: str += chr(ord("a")+int(s)) print(str) N = int(eval(input())) S = [0]*N def up(i): if i == 0: return True S[i] += 1 if S[i] == max(S[:i]) + 2: S[i] = 0 return up(i-1) return False while True: p(S) i...
N = int(eval(input())) def dfs(s, mx): if len(s) == N: print(s) else: for c in range(ord("a"),mx+1): if c == mx: dfs(s+chr(c),mx+1) else: dfs(s+chr(c),mx) dfs("",ord("a"))
22
13
340
260
def p(S): str = "" for s in S: str += chr(ord("a") + int(s)) print(str) N = int(eval(input())) S = [0] * N def up(i): if i == 0: return True S[i] += 1 if S[i] == max(S[:i]) + 2: S[i] = 0 return up(i - 1) return False while True: p(S) if up(N - 1)...
N = int(eval(input())) def dfs(s, mx): if len(s) == N: print(s) else: for c in range(ord("a"), mx + 1): if c == mx: dfs(s + chr(c), mx + 1) else: dfs(s + chr(c), mx) dfs("", ord("a"))
false
40.909091
[ "-def p(S):", "- str = \"\"", "- for s in S:", "- str += chr(ord(\"a\") + int(s))", "- print(str)", "+N = int(eval(input()))", "-N = int(eval(input()))", "-S = [0] * N", "+def dfs(s, mx):", "+ if len(s) == N:", "+ print(s)", "+ else:", "+ for c in range(or...
false
0.035851
0.078389
0.457351
[ "s793815288", "s768774317" ]
u777923818
p02934
python
s310559211
s067535465
169
28
38,484
9,168
Accepted
Accepted
83.43
def inpl(): return list(map(int, input().split())) N = int(eval(input())) print((1/sum([1/v for v in inpl()])))
def inpl(): return list(map(int, input().split())) N = int(eval(input())) print((1 / sum([1/a for a in inpl()])))
4
3
107
109
def inpl(): return list(map(int, input().split())) N = int(eval(input())) print((1 / sum([1 / v for v in inpl()])))
def inpl(): return list(map(int, input().split())) N = int(eval(input())) print((1 / sum([1 / a for a in inpl()])))
false
25
[ "-print((1 / sum([1 / v for v in inpl()])))", "+print((1 / sum([1 / a for a in inpl()])))" ]
false
0.046033
0.076253
0.603691
[ "s310559211", "s067535465" ]
u716530146
p03433
python
s537155329
s198506561
166
25
38,384
3,808
Accepted
Accepted
84.94
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.setrecursionlimit(10**8) inf = float('inf') ans = count = 0 n=int(eval(input())) n%=500 a=int(eval(input())) if a>=n: print("Yes") else: print("No...
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect, string input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.setrecursionlimit(10**7) inf = float('inf') mod = 10**9+7 ans = inf ;count = 0 ;pro = 1 n=int(eval(input())) a=int(eval(input())) n%=500 if n<=a: ...
14
15
310
347
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") sys.setrecursionlimit(10**8) inf = float("inf") ans = count = 0 n = int(eval(input())) n %= 500 a = int(eval(input())) if a >= n: print("Yes") else: print("No")
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect, string input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") sys.setrecursionlimit(10**7) inf = float("inf") mod = 10**9 + 7 ans = inf count = 0 pro = 1 n = int(eval(input())) a = int(eval(input())) n %= 500 if n <= a: p...
false
6.666667
[ "-import sys, math, itertools, heapq, collections, bisect", "+import sys, math, itertools, heapq, collections, bisect, string", "-sys.setrecursionlimit(10**8)", "+sys.setrecursionlimit(10**7)", "-ans = count = 0", "+mod = 10**9 + 7", "+ans = inf", "+count = 0", "+pro = 1", "+a = int(eval(input()))...
false
0.12943
0.037513
3.450295
[ "s537155329", "s198506561" ]
u424768586
p02685
python
s186562280
s267375461
227
160
86,784
86,332
Accepted
Accepted
29.52
import sys sys.setrecursionlimit(10**6) #再帰関数の上限 import math from copy import copy, deepcopy from operator import itemgetter from bisect import bisect_left, bisect, bisect_right#2分探索 #bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collections import deque #deque(l), pop(), append(x...
import sys sys.setrecursionlimit(10**6) #再帰関数の上限 import math from copy import copy, deepcopy from operator import itemgetter from bisect import bisect_left, bisect, bisect_right#2分探索 #bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collections import deque #deque(l), pop(), append(x...
106
106
2,879
2,877
import sys sys.setrecursionlimit(10**6) # 再帰関数の上限 import math from copy import copy, deepcopy from operator import itemgetter from bisect import bisect_left, bisect, bisect_right # 2分探索 # bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collections import deque # deque(l), pop(), append(...
import sys sys.setrecursionlimit(10**6) # 再帰関数の上限 import math from copy import copy, deepcopy from operator import itemgetter from bisect import bisect_left, bisect, bisect_right # 2分探索 # bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下 from collections import deque # deque(l), pop(), append(...
false
0
[ "- inv = [1, 1] + [pow(i, mod - 2, mod) for i in range(2, N)]", "+ inv = [1, 1] + [extgcd1(i, mod) for i in range(2, N)]" ]
false
0.131158
0.385514
0.340215
[ "s186562280", "s267375461" ]
u392319141
p03674
python
s011416307
s802018310
815
456
30,996
30,560
Accepted
Accepted
44.05
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 fact = [1 for _ in range(N + 10)] invFact = [0 for _ in range(N + 10)] def modInv(a): b = MOD u = 1 v = 0 while b : t = a // b a -= t * b a, b = b, a u -= t * v u, v = v, ...
from collections import Counter, defaultdict class Combination: def __init__(self, size, mod=10**9 + 7): self.size = size + 2 self.mod = mod self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2,...
49
50
961
1,446
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 fact = [1 for _ in range(N + 10)] invFact = [0 for _ in range(N + 10)] def modInv(a): b = MOD u = 1 v = 0 while b: t = a // b a -= t * b a, b = b, a u -= t * v u, v = v, u u %= MOD ...
from collections import Counter, defaultdict class Combination: def __init__(self, size, mod=10**9 + 7): self.size = size + 2 self.mod = mod self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size...
false
2
[ "+from collections import Counter, defaultdict", "+", "+", "+class Combination:", "+ def __init__(self, size, mod=10**9 + 7):", "+ self.size = size + 2", "+ self.mod = mod", "+ self.fact = [1, 1] + [0] * size", "+ self.factInv = [1, 1] + [0] * size", "+ self.i...
false
0.0081
0.036574
0.221472
[ "s011416307", "s802018310" ]
u627417051
p04002
python
s591710614
s494892509
2,466
2,186
135,976
135,888
Accepted
Accepted
11.35
import sys input = sys.stdin.buffer.readline from collections import defaultdict def getlist(): return list(map(int, input().split())) H, W, N = getlist() D = defaultdict(int) D[0] += (H - 2) * (W - 2) L = [] for i in range(N): a, b = getlist() for j in range(3): for k in range(3): if H - 2 >...
import sys input = sys.stdin.buffer.readline from collections import defaultdict def getlist(): return list(map(int, input().split())) def main(): H, W, N = getlist() D = defaultdict(int) D[0] += (H - 2) * (W - 2) L = [] for i in range(N): a, b = getlist() for j in range(3): for k in r...
39
47
655
745
import sys input = sys.stdin.buffer.readline from collections import defaultdict def getlist(): return list(map(int, input().split())) H, W, N = getlist() D = defaultdict(int) D[0] += (H - 2) * (W - 2) L = [] for i in range(N): a, b = getlist() for j in range(3): for k in range(3): ...
import sys input = sys.stdin.buffer.readline from collections import defaultdict def getlist(): return list(map(int, input().split())) def main(): H, W, N = getlist() D = defaultdict(int) D[0] += (H - 2) * (W - 2) L = [] for i in range(N): a, b = getlist() for j in range(3):...
false
17.021277
[ "-H, W, N = getlist()", "-D = defaultdict(int)", "-D[0] += (H - 2) * (W - 2)", "-L = []", "-for i in range(N):", "- a, b = getlist()", "- for j in range(3):", "- for k in range(3):", "- if H - 2 >= a - j and a - j >= 1 and W - 2 >= b - k and b - k >= 1:", "- ...
false
0.172549
0.045844
3.763794
[ "s591710614", "s494892509" ]
u645250356
p03037
python
s155863071
s529963539
302
228
11,376
9,048
Accepted
Accepted
24.5
import collections n,m = list(map(int,input().split())) r = [] l = [] for i in range(m): ll,rr = list(map(int,input().split())) r.append(rr) l.append(ll) ans = min(r) - max(l) +1 if ans > 0: print(ans) else : print((0))
from collections import Counter,defaultdict import sys,heapq,bisect,math,itertools,string,queue mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) n,m = inpl() cnt = [0]*(n+1) for i...
13
15
237
453
import collections n, m = list(map(int, input().split())) r = [] l = [] for i in range(m): ll, rr = list(map(int, input().split())) r.append(rr) l.append(ll) ans = min(r) - max(l) + 1 if ans > 0: print(ans) else: print((0))
from collections import Counter, defaultdict import sys, heapq, bisect, math, itertools, string, queue mod = 10**9 + 7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) n, m = inpl() ...
false
13.333333
[ "-import collections", "+from collections import Counter, defaultdict", "+import sys, heapq, bisect, math, itertools, string, queue", "-n, m = list(map(int, input().split()))", "-r = []", "-l = []", "+mod = 10**9 + 7", "+", "+", "+def inp():", "+ return int(sys.stdin.readline())", "+", "+...
false
0.072255
0.078821
0.916694
[ "s155863071", "s529963539" ]
u790710233
p04020
python
s069678697
s198854388
282
213
7,028
3,060
Accepted
Accepted
24.47
n = int(eval(input())) cnt = [0]*n for i in range(n): a = int(eval(input())) cnt[i] += a ans = 0 for i, j in zip(list(range(n-1)), list(range(1, n))): x, y = cnt[i], cnt[j] z = x//2 cnt[i] -= 2*z ans += z if cnt[i] == 0: continue if 0 < y: ans += 1 ...
n = int(eval(input())) ans = x = 0 for _ in range(n): a = int(eval(input())) if a == 0: ans += x//2 x = 0 x += a else: ans += x//2 print(ans)
22
13
374
175
n = int(eval(input())) cnt = [0] * n for i in range(n): a = int(eval(input())) cnt[i] += a ans = 0 for i, j in zip(list(range(n - 1)), list(range(1, n))): x, y = cnt[i], cnt[j] z = x // 2 cnt[i] -= 2 * z ans += z if cnt[i] == 0: continue if 0 < y: ans += 1 cnt[i] ...
n = int(eval(input())) ans = x = 0 for _ in range(n): a = int(eval(input())) if a == 0: ans += x // 2 x = 0 x += a else: ans += x // 2 print(ans)
false
40.909091
[ "-cnt = [0] * n", "-for i in range(n):", "+ans = x = 0", "+for _ in range(n):", "- cnt[i] += a", "-ans = 0", "-for i, j in zip(list(range(n - 1)), list(range(1, n))):", "- x, y = cnt[i], cnt[j]", "- z = x // 2", "- cnt[i] -= 2 * z", "- ans += z", "- if cnt[i] == 0:", "- ...
false
0.034512
0.041792
0.825821
[ "s069678697", "s198854388" ]
u012694084
p02983
python
s216809700
s887850709
177
39
39,024
3,060
Accepted
Accepted
77.97
l, r = list(map(int, input().split())) result = None for i in range(l, min(l + 2019 - l % 2019, r - 1) + 1): for j in range(i + 1, min(i + 2019, r) + 1): mod = i * j % 2019 if result is None or result > mod: result = mod if result == 0: break if...
def search(lower, upper, mod): min_remain = mod for i in range(lower, min(lower + mod - lower % mod, upper - 1) + 1): for j in range(i + 1, min(i + mod, upper) + 1): remain = i * j % mod if remain == 0: return 0 if min_remain > remain: ...
13
14
381
436
l, r = list(map(int, input().split())) result = None for i in range(l, min(l + 2019 - l % 2019, r - 1) + 1): for j in range(i + 1, min(i + 2019, r) + 1): mod = i * j % 2019 if result is None or result > mod: result = mod if result == 0: break if result is ...
def search(lower, upper, mod): min_remain = mod for i in range(lower, min(lower + mod - lower % mod, upper - 1) + 1): for j in range(i + 1, min(i + mod, upper) + 1): remain = i * j % mod if remain == 0: return 0 if min_remain > remain: ...
false
7.142857
[ "+def search(lower, upper, mod):", "+ min_remain = mod", "+ for i in range(lower, min(lower + mod - lower % mod, upper - 1) + 1):", "+ for j in range(i + 1, min(i + mod, upper) + 1):", "+ remain = i * j % mod", "+ if remain == 0:", "+ return 0", "+ ...
false
0.079063
0.07922
0.99802
[ "s216809700", "s887850709" ]
u088372268
p02260
python
s843731548
s622568618
30
20
5,600
5,600
Accepted
Accepted
33.33
n, data = int(eval(input())), list(map(int, input().split())) idx, t = 0, 0 for i in range(n-1): for j in range(i, n): if j == i: idx = j elif data[idx] > data[j]: idx = j if data[i] > data[idx]: data[i], data[idx] = data[idx], data[i] t += 1 pr...
n, data = int(eval(input())), list(map(int, input().split())) idx, t = 0, 0 for i in range(n-1): for j in range(i+1, n): if j == i+1: idx = j elif data[idx] > data[j]: idx = j if data[i] > data[idx]: data[i], data[idx] = data[idx], data[i] t += 1...
14
14
356
360
n, data = int(eval(input())), list(map(int, input().split())) idx, t = 0, 0 for i in range(n - 1): for j in range(i, n): if j == i: idx = j elif data[idx] > data[j]: idx = j if data[i] > data[idx]: data[i], data[idx] = data[idx], data[i] t += 1 print((" "....
n, data = int(eval(input())), list(map(int, input().split())) idx, t = 0, 0 for i in range(n - 1): for j in range(i + 1, n): if j == i + 1: idx = j elif data[idx] > data[j]: idx = j if data[i] > data[idx]: data[i], data[idx] = data[idx], data[i] t += 1 pri...
false
0
[ "- for j in range(i, n):", "- if j == i:", "+ for j in range(i + 1, n):", "+ if j == i + 1:" ]
false
0.072472
0.069819
1.038
[ "s843731548", "s622568618" ]
u833543158
p02948
python
s305034121
s141870112
353
270
17,208
26,020
Accepted
Accepted
23.51
import sys import heapq N, M = list(map(int, input().split())) jobs = [] for line in sys.stdin: A, B = list(map(int, line.split())) if A > M: continue jobs.append((A, B)) jobs.sort(reverse=True) q = [] ans = 0 for i in range(1, M + 1): while jobs and jobs[-1][0] <= i: ...
import sys import heapq N, M = list(map(int, input().split())) possiblyValidJobs = {} for line in sys.stdin: A, B = list(map(int, line.split())) if A > M: continue if A in possiblyValidJobs: possiblyValidJobs[A].append(B) else: possiblyValidJobs[A] = [B] validJo...
23
24
423
639
import sys import heapq N, M = list(map(int, input().split())) jobs = [] for line in sys.stdin: A, B = list(map(int, line.split())) if A > M: continue jobs.append((A, B)) jobs.sort(reverse=True) q = [] ans = 0 for i in range(1, M + 1): while jobs and jobs[-1][0] <= i: A, B = jobs.pop() ...
import sys import heapq N, M = list(map(int, input().split())) possiblyValidJobs = {} for line in sys.stdin: A, B = list(map(int, line.split())) if A > M: continue if A in possiblyValidJobs: possiblyValidJobs[A].append(B) else: possiblyValidJobs[A] = [B] validJobsOnThisDay = [] ...
false
4.166667
[ "-jobs = []", "+possiblyValidJobs = {}", "- jobs.append((A, B))", "-jobs.sort(reverse=True)", "-q = []", "+ if A in possiblyValidJobs:", "+ possiblyValidJobs[A].append(B)", "+ else:", "+ possiblyValidJobs[A] = [B]", "+validJobsOnThisDay = []", "-for i in range(1, M + 1):",...
false
0.043376
0.036369
1.192666
[ "s305034121", "s141870112" ]
u370661635
p03317
python
s362783739
s123782105
40
17
13,880
3,064
Accepted
Accepted
57.5
n,k=list(map(int,input().split())) a = list(map(int,input().split())) if (n-1)%(k-1) != 0: cnt = (n-1)//(k-1)+1 else: cnt = (n-1)//(k-1) print(cnt)
import math n,k=list(map(int,input().split())) print((math.ceil((n-k)/(k-1))+1))
9
3
157
74
n, k = list(map(int, input().split())) a = list(map(int, input().split())) if (n - 1) % (k - 1) != 0: cnt = (n - 1) // (k - 1) + 1 else: cnt = (n - 1) // (k - 1) print(cnt)
import math n, k = list(map(int, input().split())) print((math.ceil((n - k) / (k - 1)) + 1))
false
66.666667
[ "+import math", "+", "-a = list(map(int, input().split()))", "-if (n - 1) % (k - 1) != 0:", "- cnt = (n - 1) // (k - 1) + 1", "-else:", "- cnt = (n - 1) // (k - 1)", "-print(cnt)", "+print((math.ceil((n - k) / (k - 1)) + 1))" ]
false
0.142156
0.057424
2.475556
[ "s362783739", "s123782105" ]
u763550415
p02657
python
s045677856
s186395072
26
22
9,156
9,052
Accepted
Accepted
15.38
A, B =list(map(int, input().split())) print((A*B))
a, b = list(map(int, input().split())) print((a*b))
2
2
43
44
A, B = list(map(int, input().split())) print((A * B))
a, b = list(map(int, input().split())) print((a * b))
false
0
[ "-A, B = list(map(int, input().split()))", "-print((A * B))", "+a, b = list(map(int, input().split()))", "+print((a * b))" ]
false
0.040871
0.132233
0.309083
[ "s045677856", "s186395072" ]
u645250356
p02954
python
s310096876
s683507968
190
146
13,752
9,432
Accepted
Accepted
23.16
import sys,fractions a = eval(input()) n = len(a) t = [] ans = [0] * n cnt = 0 tmp = a[0] for i in range(n): if a[i] == tmp: cnt += 1 else: t.append(cnt) tmp = a[i] cnt = 1 t.append(cnt) N = len(t) len = 0 for i in range(N)[::2]: tmp_len = t[i] + t[i+1] ...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 mod2 = 998244353 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.rea...
28
44
556
1,069
import sys, fractions a = eval(input()) n = len(a) t = [] ans = [0] * n cnt = 0 tmp = a[0] for i in range(n): if a[i] == tmp: cnt += 1 else: t.append(cnt) tmp = a[i] cnt = 1 t.append(cnt) N = len(t) len = 0 for i in range(N)[::2]: tmp_len = t[i] + t[i + 1] # R ans[le...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 mod2 = 998244353 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(in...
false
36.363636
[ "-import sys, fractions", "+from collections import Counter, defaultdict, deque", "+from heapq import heappop, heappush, heapify", "+import sys, bisect, math, itertools, fractions, pprint", "-a = eval(input())", "-n = len(a)", "-t = []", "-ans = [0] * n", "+sys.setrecursionlimit(10**8)", "+mod = 1...
false
0.083645
0.038517
2.171606
[ "s310096876", "s683507968" ]
u596505843
p02991
python
s187314072
s535512459
795
276
116,068
124,972
Accepted
Accepted
65.28
import sys, math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline rs = lambda: input().strip() ri = lambda: int...
import sys, math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline rs = lambda: input().strip() ri = lambda: int...
42
36
922
829
import sys, math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline rs = lambda: input().strip() ri = lambda: int(eval(i...
import sys, math from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from itertools import combinations, permutations, product from heapq import heappush, heappop from functools import lru_cache input = sys.stdin.readline rs = lambda: input().strip() ri = lambda: int(eval(i...
false
14.285714
[ "-dp = [[float(\"inf\")] * 3 for i in range(N)]", "-heap = []", "-heappush(heap, (0, S, 0))", "-while heap:", "- d, n, r = heappop(heap)", "+queue = deque()", "+queue.append((S, 0, 0))", "+visited = set()", "+while queue:", "+ n, r, d = queue.popleft()", "- continue", "- # if d...
false
0.107734
0.072849
1.47886
[ "s187314072", "s535512459" ]
u631277801
p03363
python
s837621813
s903571865
231
158
41,672
41,984
Accepted
Accepted
31.6
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) A_sum = [A[0]] for i in range(1,N): A_sum.append(A_sum[i-1]+A[i]) a_cnt = Counter(A_sum) ans = 0 for k,v in list(a_cnt.items()): ans += v*(v-1)//2 if k==0: ans += v print(ans)
from collections import Counter from itertools import accumulate N = int(eval(input())) A = list(map(int, input().split())) B = [0] + list(accumulate(A)) cnt = Counter(B) ans = 0 for v in list(cnt.values()): ans += v*(v-1)//2 print(ans)
20
15
308
251
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) A_sum = [A[0]] for i in range(1, N): A_sum.append(A_sum[i - 1] + A[i]) a_cnt = Counter(A_sum) ans = 0 for k, v in list(a_cnt.items()): ans += v * (v - 1) // 2 if k == 0: ans += v print(ans)
from collections import Counter from itertools import accumulate N = int(eval(input())) A = list(map(int, input().split())) B = [0] + list(accumulate(A)) cnt = Counter(B) ans = 0 for v in list(cnt.values()): ans += v * (v - 1) // 2 print(ans)
false
25
[ "+from itertools import accumulate", "-A_sum = [A[0]]", "-for i in range(1, N):", "- A_sum.append(A_sum[i - 1] + A[i])", "-a_cnt = Counter(A_sum)", "+B = [0] + list(accumulate(A))", "+cnt = Counter(B)", "-for k, v in list(a_cnt.items()):", "+for v in list(cnt.values()):", "- if k == 0:", "...
false
0.110018
0.04139
2.658062
[ "s837621813", "s903571865" ]
u875291233
p03045
python
s210259076
s288756158
602
520
8,564
8,564
Accepted
Accepted
13.62
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n))#親ノード self.size = [1]*n #グループの要素数 def root(self, x): #root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x = s...
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n))#親ノード self.size = [1]*n #グループの要素数 def root(self, x): #root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x = s...
44
43
1,206
1,175
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n)) # 親ノード self.size = [1] * n # グループの要素数 def root(self, x): # root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x = se...
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n)) # 親ノード self.size = [1] * n # グループの要素数 def root(self, x): # root(x): xの根ノードを返す. while self.parent[x] != x: self.parent[x] = self.parent[self.parent[x]] x = se...
false
2.272727
[ "- if not T.issame(x - 1, y - 1):", "- T.merge(x - 1, y - 1)", "+ if T.merge(x - 1, y - 1):" ]
false
0.049058
0.043356
1.131508
[ "s210259076", "s288756158" ]
u440566786
p02925
python
s585844621
s547459645
1,765
1,549
162,304
156,672
Accepted
Accepted
12.24
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() def resolve(): n=int(eval(input())) # id table N=0 id=[[None]*n for _ in range(n)] for i in range(n): for j in range(i+1,n): id[i][j]=N ...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() def resolve(): n=int(eval(input())) # id table N=0 id=[[None]*n for _ in range(n)] from itertools import product for i,j in product(list(range(n)),repeat=2): ...
41
42
958
1,001
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n = int(eval(input())) # id table N = 0 id = [[None] * n for _ in range(n)] for i in range(n): for j in range(i + 1, n): id[i][j] = N ...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n = int(eval(input())) # id table N = 0 id = [[None] * n for _ in range(n)] from itertools import product for i, j in product(list(range(n)), repeat=2)...
false
2.380952
[ "- for i in range(n):", "- for j in range(i + 1, n):", "- id[i][j] = N", "- N += 1", "+ from itertools import product", "+", "+ for i, j in product(list(range(n)), repeat=2):", "+ if i >= j:", "+ continue", "+ id[i][j] = N", "+ ...
false
0.038159
0.00801
4.763763
[ "s585844621", "s547459645" ]
u440566786
p02703
python
s906008758
s787230627
1,798
826
79,860
95,624
Accepted
Accepted
54.06
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # 998244353 input=lambda:sys.stdin.readline().rstrip() def resolve(): n, m, s = list(map(int,input().split())) E = [None] * m S = 0 for i in range(m): u, v, a, b = list(map(int,input().split())) S += a ...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # 998244353 input=lambda:sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m, s = list(map(int,input().split())) S = 0 E = [[] for _ in range(n)] for _ in range(m): u, v, a, b =...
36
41
1,107
1,202
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 # 998244353 input = lambda: sys.stdin.readline().rstrip() def resolve(): n, m, s = list(map(int, input().split())) E = [None] * m S = 0 for i in range(m): u, v, a, b = list(map(int, input().split())) S +=...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 # 998244353 input = lambda: sys.stdin.readline().rstrip() from heapq import heappop, heappush def resolve(): n, m, s = list(map(int, input().split())) S = 0 E = [[] for _ in range(n)] for _ in range(m): u, v, a, ...
false
12.195122
[ "+from heapq import heappop, heappush", "- E = [None] * m", "- for i in range(m):", "- u, v, a, b = list(map(int, input().split()))", "+ E = [[] for _ in range(n)]", "+ for _ in range(m):", "+ u, v, a, b = list(map(int, input().split())) # a : cost silver", "+ u -= 1"...
false
0.091195
0.065312
1.396285
[ "s906008758", "s787230627" ]
u186838327
p03254
python
s502293992
s094030786
169
63
38,512
61,936
Accepted
Accepted
62.72
n, x = list(map(int, input().split())) l = list(map(int, input().split())) l.sort() i = 0 ans = 0 while x > 0 and i<= n-1: if x >= l[i]: x -= l[i] if i == n-1: if x == 0: ans += 1 break else: break else: i += 1 ans += 1 else: x = 0 ...
n, x = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() ans = 0 for i, a in enumerate(A): if i != n-1: if x >= a: ans += 1 x -= a else: break else: if x == a: ans += 1 else: bre...
23
17
341
329
n, x = list(map(int, input().split())) l = list(map(int, input().split())) l.sort() i = 0 ans = 0 while x > 0 and i <= n - 1: if x >= l[i]: x -= l[i] if i == n - 1: if x == 0: ans += 1 break else: break else: ...
n, x = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() ans = 0 for i, a in enumerate(A): if i != n - 1: if x >= a: ans += 1 x -= a else: break else: if x == a: ans += 1 else: break print(ans)...
false
26.086957
[ "-l = list(map(int, input().split()))", "-l.sort()", "-i = 0", "+A = list(map(int, input().split()))", "+A.sort()", "-while x > 0 and i <= n - 1:", "- if x >= l[i]:", "- x -= l[i]", "- if i == n - 1:", "- if x == 0:", "- ans += 1", "- b...
false
0.036618
0.032911
1.112648
[ "s502293992", "s094030786" ]
u864197622
p02604
python
s312441578
s856646686
1,928
1,610
88,628
88,760
Accepted
Accepted
16.49
N = int(input()) X = [] Y = [] P = [] for _ in range(N): x, y, p = map(int, input().split()) X.append(x) Y.append(y) P.append(p) DX = [[0] * N for _ in range(1 << N)] DY = [[0] * N for _ in range(1 << N)] for i, x in enumerate(X): for k in range(1 << N): d = abs(x) ...
N = int(input()) X = [] Y = [] P = [] for _ in range(N): x, y, p = map(int, input().split()) X.append(x) Y.append(y) P.append(p) DX = [[0] * N for _ in range(1 << N)] DY = [[0] * N for _ in range(1 << N)] for i, x in enumerate(X): for k in range(1 << N): d = abs(x) ...
59
61
1,282
1,316
N = int(input()) X = [] Y = [] P = [] for _ in range(N): x, y, p = map(int, input().split()) X.append(x) Y.append(y) P.append(p) DX = [[0] * N for _ in range(1 << N)] DY = [[0] * N for _ in range(1 << N)] for i, x in enumerate(X): for k in range(1 << N): d = abs(x) for j, xx in enume...
N = int(input()) X = [] Y = [] P = [] for _ in range(N): x, y, p = map(int, input().split()) X.append(x) Y.append(y) P.append(p) DX = [[0] * N for _ in range(1 << N)] DY = [[0] * N for _ in range(1 << N)] for i, x in enumerate(X): for k in range(1 << N): d = abs(x) for j, xx in enume...
false
3.278689
[ "+ dxi = DX[i]", "+ dyj = DY[j]", "- ans += min(DX[i][k], DY[j][k])", "+ ans += min(dxi[k], dyj[k])" ]
false
0.062027
0.190931
0.324866
[ "s312441578", "s856646686" ]
u489959379
p03682
python
s856882898
s856509280
1,559
1,325
62,428
65,008
Accepted
Accepted
15.01
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 # Union Find(経路圧縮有) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n # 親が同じか判別 def find(self, x): if self.parents[x] < 0: ...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): """ 親が同じか判別する """ if self.parents[x] < 0: ...
79
84
1,806
1,940
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 # Union Find(経路圧縮有) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n # 親が同じか判別 def find(self, x): if self.parents[x] < 0: return x e...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): """ 親が同じか判別する """ if self.parents[x] < 0: return x...
false
5.952381
[ "-# Union Find(経路圧縮有)", "+", "+", "- # 親が同じか判別", "+ \"\"\"", "+ 親が同じか判別する", "+ \"\"\"", "- # 根を繋ぎ直す", "+ \"\"\"", "+ yをxの根に繋ぐ", "+ \"\"\"", "- # 親が同じか判別", "+ \"\"\"", "+ xとyが同じ連結成分か判別する", "+ \"\"\"", "- # 連結成分の大...
false
0.039044
0.109026
0.35812
[ "s856882898", "s856509280" ]
u414980766
p02919
python
s517151981
s246780522
910
175
14,028
16,212
Accepted
Accepted
80.77
import bisect import array N = int(eval(input())) P = list(map(int, input().split())) P_id = [0]*(N + 1) for i in range(N): P_id[P[i]] = i A = array.array('i', [- 1, P_id[N], N]) res = 0 for i in range(N - 1, 0, - 1): j = bisect.bisect_left(A, P_id[i]) A.insert(j, P_id[i]) l1 = A[j -...
N = int(eval(input())) P_id = [0]*(N + 1) # P_id[i]は順列Pに置けるiのindex, P[0]は無視 for index, p in enumerate(map(int, input().split())): P_id[p] = index left_next_index = list(range(- 1, N - 1)) + ['うんこ', - 1] # + [- 1]ではないことに注意, left_next_index[r1] = l1においてr1 = Nの場合があるから right_next_index = list(range(1, N + 1)) + ...
28
21
526
649
import bisect import array N = int(eval(input())) P = list(map(int, input().split())) P_id = [0] * (N + 1) for i in range(N): P_id[P[i]] = i A = array.array("i", [-1, P_id[N], N]) res = 0 for i in range(N - 1, 0, -1): j = bisect.bisect_left(A, P_id[i]) A.insert(j, P_id[i]) l1 = A[j - 1] r1 = A[j + ...
N = int(eval(input())) P_id = [0] * (N + 1) # P_id[i]は順列Pに置けるiのindex, P[0]は無視 for index, p in enumerate(map(int, input().split())): P_id[p] = index left_next_index = list(range(-1, N - 1)) + [ "うんこ", -1, ] # + [- 1]ではないことに注意, left_next_index[r1] = l1においてr1 = Nの場合があるから right_next_index = list(range(1, N + ...
false
25
[ "-import bisect", "-import array", "-", "-P = list(map(int, input().split()))", "-P_id = [0] * (N + 1)", "-for i in range(N):", "- P_id[P[i]] = i", "-A = array.array(\"i\", [-1, P_id[N], N])", "+P_id = [0] * (N + 1) # P_id[i]は順列Pに置けるiのindex, P[0]は無視", "+for index, p in enumerate(map(int, input...
false
0.03832
0.039359
0.973584
[ "s517151981", "s246780522" ]