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
u970899068
p02803
python
s676607767
s128595561
278
256
44,140
44,268
Accepted
Accepted
7.91
def clear_maze(sx, sy, maze): INF=-10**9 global cnt cnt=0 distance = [[INF for i in range(w+1)] for j in range(h+1)] # distance = [[None]*field_x_length]*field_y_length def bfs(): global cnt queue = [] queue.insert(0, (sx, sy)) distance[sx][sy...
import collections from collections import deque h,w = list(map(int, input().split())) maze=[list(eval(input())) for i in range(h)] # 枠を囲う for i in range(h): maze[i]=['#']+maze[i]+['#'] maze=[['#' for i in range(w+2)]]+maze+[['#' for i in range(w+2)]] def clear_maze(sx, sy): INF=-10**9 dis...
51
45
1,274
1,144
def clear_maze(sx, sy, maze): INF = -(10**9) global cnt cnt = 0 distance = [[INF for i in range(w + 1)] for j in range(h + 1)] # distance = [[None]*field_x_length]*field_y_length def bfs(): global cnt queue = [] queue.insert(0, (sx, sy)) distance[sx][sy] = 0 ...
import collections from collections import deque h, w = list(map(int, input().split())) maze = [list(eval(input())) for i in range(h)] # 枠を囲う for i in range(h): maze[i] = ["#"] + maze[i] + ["#"] maze = [["#" for i in range(w + 2)]] + maze + [["#" for i in range(w + 2)]] def clear_maze(sx, sy): INF = -(10**9)...
false
11.764706
[ "-def clear_maze(sx, sy, maze):", "+import collections", "+from collections import deque", "+", "+h, w = list(map(int, input().split()))", "+maze = [list(eval(input())) for i in range(h)]", "+# 枠を囲う", "+for i in range(h):", "+ maze[i] = [\"#\"] + maze[i] + [\"#\"]", "+maze = [[\"#\" for i in ra...
false
0.039761
0.047883
0.830377
[ "s676607767", "s128595561" ]
u735891571
p02678
python
s680034685
s470840275
821
619
64,068
64,064
Accepted
Accepted
24.6
from scipy.sparse.csgraph import breadth_first_tree, breadth_first_order from scipy.sparse import csr_matrix, coo_matrix N, M = list(map(int,input().split())) A = [] B = [] for i in range(M): a, b = list(map(int,input().split())) a -= 1 b -= 1 A.append(a) B.append(b) D = [1] * M csr = co...
from scipy.sparse.csgraph import breadth_first_tree, breadth_first_order from scipy.sparse import csr_matrix, coo_matrix import sys input = sys.stdin.readline N, M = list(map(int,input().split())) A = [] B = [] for i in range(M): a, b = list(map(int,input().split())) a -= 1 b -= 1 A.append(a)...
23
25
548
588
from scipy.sparse.csgraph import breadth_first_tree, breadth_first_order from scipy.sparse import csr_matrix, coo_matrix N, M = list(map(int, input().split())) A = [] B = [] for i in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 A.append(a) B.append(b) D = [1] * M csr = coo_matrix(...
from scipy.sparse.csgraph import breadth_first_tree, breadth_first_order from scipy.sparse import csr_matrix, coo_matrix import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = [] B = [] for i in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 A.append(a) B.a...
false
8
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.304092
0.974879
0.311928
[ "s680034685", "s470840275" ]
u923668099
p02255
python
s665886881
s444530804
30
20
8,084
8,100
Accepted
Accepted
33.33
# coding: utf-8 n = int(eval(input())) data = [int(i) for i in input().split()] for i in range(n): v = data[i] j = i - 1 while j >= 0 and data[j] > v: data[j+1] = data[j] j -= 1 data[j+1] = v print((*data))
def InsertionSort(A, N): print((*A)) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print((*A)) N = int(eval(input())) A = [int(a) for a in input().split()] Insert...
12
21
246
323
# coding: utf-8 n = int(eval(input())) data = [int(i) for i in input().split()] for i in range(n): v = data[i] j = i - 1 while j >= 0 and data[j] > v: data[j + 1] = data[j] j -= 1 data[j + 1] = v print((*data))
def InsertionSort(A, N): print((*A)) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print((*A)) N = int(eval(input())) A = [int(a) for a in input().split()] InsertionSort(A, N)
false
42.857143
[ "-# coding: utf-8", "-n = int(eval(input()))", "-data = [int(i) for i in input().split()]", "-for i in range(n):", "- v = data[i]", "- j = i - 1", "- while j >= 0 and data[j] > v:", "- data[j + 1] = data[j]", "- j -= 1", "- data[j + 1] = v", "- print((*data))", "+d...
false
0.043569
0.042932
1.01482
[ "s665886881", "s444530804" ]
u476604182
p03108
python
s273804015
s773007234
882
411
25,984
26,128
Accepted
Accepted
53.4
from functools import reduce from operator import mul def cmb(n,r): r = min(r, n-r) if r==0: return 1 if r<0: return 0 over = reduce(mul, list(range(n, n-r, -1))) under = reduce(mul, list(range(1,r+1))) return over//under class UnionFind: def __init__(self, n): self.par = [i for i in ra...
class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.size = [1]*n self.rank = [0]*n def find(self, x): if self.par[x]==x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def unit(self, x, y): x = self.find(x) ...
69
49
1,457
1,097
from functools import reduce from operator import mul def cmb(n, r): r = min(r, n - r) if r == 0: return 1 if r < 0: return 0 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return over // under class UnionFind: def __init__(self, ...
class UnionFind: def __init__(self, n): self.par = [i for i in range(n)] self.size = [1] * n self.rank = [0] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def un...
false
28.985507
[ "-from functools import reduce", "-from operator import mul", "-", "-", "-def cmb(n, r):", "- r = min(r, n - r)", "- if r == 0:", "- return 1", "- if r < 0:", "- return 0", "- over = reduce(mul, list(range(n, n - r, -1)))", "- under = reduce(mul, list(range(1, r + ...
false
0.039977
0.039483
1.012517
[ "s273804015", "s773007234" ]
u731368968
p02755
python
s033983375
s475376594
24
18
2,940
2,940
Accepted
Accepted
25
A, B = list(map(int, input().split())) for i in range(20000): if int(i*0.08) == A and int(i * 0.1) == B: print(i) exit() print((-1))
A,B=list(map(int,input().split())) for i in range(2000): if A==i*8//100 and B==i*10//100: print(i) break else: print((-1))
6
7
150
135
A, B = list(map(int, input().split())) for i in range(20000): if int(i * 0.08) == A and int(i * 0.1) == B: print(i) exit() print((-1))
A, B = list(map(int, input().split())) for i in range(2000): if A == i * 8 // 100 and B == i * 10 // 100: print(i) break else: print((-1))
false
14.285714
[ "-for i in range(20000):", "- if int(i * 0.08) == A and int(i * 0.1) == B:", "+for i in range(2000):", "+ if A == i * 8 // 100 and B == i * 10 // 100:", "- exit()", "-print((-1))", "+ break", "+else:", "+ print((-1))" ]
false
0.09027
0.040267
2.241793
[ "s033983375", "s475376594" ]
u107077660
p04043
python
s816091617
s524856998
41
22
3,064
3,064
Accepted
Accepted
46.34
L = sorted(list(map(int, input().split()))) if L == [5,5,7]: print("YES") else: print("NO")
S = [int(i) for i in input().split()] S.sort() if S == [5,5,7]: print("YES") else: print("NO")
5
6
97
102
L = sorted(list(map(int, input().split()))) if L == [5, 5, 7]: print("YES") else: print("NO")
S = [int(i) for i in input().split()] S.sort() if S == [5, 5, 7]: print("YES") else: print("NO")
false
16.666667
[ "-L = sorted(list(map(int, input().split())))", "-if L == [5, 5, 7]:", "+S = [int(i) for i in input().split()]", "+S.sort()", "+if S == [5, 5, 7]:" ]
false
0.036075
0.074153
0.486498
[ "s816091617", "s524856998" ]
u934442292
p03319
python
s592851637
s068618685
40
17
13,876
2,940
Accepted
Accepted
57.5
import sys input = sys.stdin.readline def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) q, r, = divmod(N - 1, K - 1) ans = q + int(r > 0) print(ans) if __name__ == "__main__": main()
import sys input = sys.stdin.readline def main(): N, K = list(map(int, input().split())) # A = list(map(int, input().split())) q, r, = divmod(N - 1, K - 1) ans = q + int(r > 0) print(ans) if __name__ == "__main__": main()
17
17
261
263
import sys input = sys.stdin.readline def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) ( q, r, ) = divmod(N - 1, K - 1) ans = q + int(r > 0) print(ans) if __name__ == "__main__": main()
import sys input = sys.stdin.readline def main(): N, K = list(map(int, input().split())) # A = list(map(int, input().split())) ( q, r, ) = divmod(N - 1, K - 1) ans = q + int(r > 0) print(ans) if __name__ == "__main__": main()
false
0
[ "- A = list(map(int, input().split()))", "+ # A = list(map(int, input().split()))" ]
false
0.042752
0.038757
1.103081
[ "s592851637", "s068618685" ]
u263830634
p03721
python
s925672350
s917006454
909
220
61,144
18,220
Accepted
Accepted
75.8
N, K = list(map(int, input().split())) lst = [] for i in range(N): lst += [list(map(int, input().split()))] lst.sort() for i in range(N): if K <= lst[i][1]: print((lst[i][0])) exit() else: K -= lst[i][1]
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort(key = lambda x: x[0]) for a, b in AB: K -= b if K <= 0: print (a) exit()
15
15
250
252
N, K = list(map(int, input().split())) lst = [] for i in range(N): lst += [list(map(int, input().split()))] lst.sort() for i in range(N): if K <= lst[i][1]: print((lst[i][0])) exit() else: K -= lst[i][1]
import sys input = sys.stdin.readline N, K = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort(key=lambda x: x[0]) for a, b in AB: K -= b if K <= 0: print(a) exit()
false
0
[ "+import sys", "+", "+input = sys.stdin.readline", "-lst = []", "-for i in range(N):", "- lst += [list(map(int, input().split()))]", "-lst.sort()", "-for i in range(N):", "- if K <= lst[i][1]:", "- print((lst[i][0]))", "+AB = [tuple(map(int, input().split())) for _ in range(N)]", ...
false
0.035408
0.0425
0.833125
[ "s925672350", "s917006454" ]
u489959379
p02901
python
s958087866
s867364368
1,410
959
3,316
9,372
Accepted
Accepted
31.99
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, m = list(map(int, input().split())) ABC = [] for _ in range(m): a, b = list(map(int, input().split())) C = list(map(int, input().split())) bit = ["0"] * n for c...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, m = list(map(int, input().split())) keys = [] for _ in range(m): bit = ["0"] * n a, b = list(map(int, input().split())) C = list(map(int, inp...
35
32
731
710
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): n, m = list(map(int, input().split())) ABC = [] for _ in range(m): a, b = list(map(int, input().split())) C = list(map(int, input().split())) bit = ["0"] * n for c in C: ...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n, m = list(map(int, input().split())) keys = [] for _ in range(m): bit = ["0"] * n a, b = list(map(int, input().split())) C = list(map(int, input().split())) ...
false
8.571429
[ "+input = sys.stdin.readline", "- ABC = []", "+ keys = []", "+ bit = [\"0\"] * n", "- bit = [\"0\"] * n", "- bit = \"\".join(bit)", "- ABC.append([a, b, int(bit, 2)])", "- dp = [f_inf for _ in range(1 << n)]", "+ bit = int(\"\".join(bit), 2)", "+ ...
false
0.036485
0.03599
1.013738
[ "s958087866", "s867364368" ]
u136395536
p03416
python
s496821008
s077755592
56
50
2,940
2,940
Accepted
Accepted
10.71
A,B = (int(i) for i in input().split()) count = 0 for i in range(B-A+1): number = A+i charnum = str(number) if(charnum[0]==charnum[4] and charnum[1]==charnum[3]): count = count + 1 print(count)
A,B = (int(i) for i in input().split()) count = 0 for i in range(A,B+1): s = str(i) if s[0]==s[4] and s[1]==s[3]: count += 1 print(count)
10
9
226
163
A, B = (int(i) for i in input().split()) count = 0 for i in range(B - A + 1): number = A + i charnum = str(number) if charnum[0] == charnum[4] and charnum[1] == charnum[3]: count = count + 1 print(count)
A, B = (int(i) for i in input().split()) count = 0 for i in range(A, B + 1): s = str(i) if s[0] == s[4] and s[1] == s[3]: count += 1 print(count)
false
10
[ "-for i in range(B - A + 1):", "- number = A + i", "- charnum = str(number)", "- if charnum[0] == charnum[4] and charnum[1] == charnum[3]:", "- count = count + 1", "+for i in range(A, B + 1):", "+ s = str(i)", "+ if s[0] == s[4] and s[1] == s[3]:", "+ count += 1" ]
false
0.062012
0.046076
1.345883
[ "s496821008", "s077755592" ]
u678167152
p03745
python
s013412573
s274790788
85
74
14,224
14,252
Accepted
Accepted
12.94
N = int(eval(input())) A = list(map(int, input().split())) def solve(N,A): liss = [] lis = [] lis.append(A[0]) a = A[0] for i in range(1,N): if len(lis)==1 or prev==0: prev = A[i]-a elif (A[i]-a)*prev<0: liss.append(lis) lis = [] ...
N = int(eval(input())) A = list(map(int, input().split())) def solve(N,A): ans = 1 lis = [] lis.append(A[0]) a = A[0] for i in range(1,N): if len(lis)==1 or prev==0: prev = A[i]-a elif (A[i]-a)*prev<0: ans += 1 lis = [] lis.app...
19
17
429
376
N = int(eval(input())) A = list(map(int, input().split())) def solve(N, A): liss = [] lis = [] lis.append(A[0]) a = A[0] for i in range(1, N): if len(lis) == 1 or prev == 0: prev = A[i] - a elif (A[i] - a) * prev < 0: liss.append(lis) lis = [] ...
N = int(eval(input())) A = list(map(int, input().split())) def solve(N, A): ans = 1 lis = [] lis.append(A[0]) a = A[0] for i in range(1, N): if len(lis) == 1 or prev == 0: prev = A[i] - a elif (A[i] - a) * prev < 0: ans += 1 lis = [] lis....
false
10.526316
[ "- liss = []", "+ ans = 1", "- liss.append(lis)", "+ ans += 1", "- liss.append(lis)", "- ans = len(liss)" ]
false
0.157449
0.04619
3.40876
[ "s013412573", "s274790788" ]
u796942881
p02959
python
s045898968
s104158243
117
87
20,324
18,624
Accepted
Accepted
25.64
from sys import stdin def main(): lines = stdin.readlines() A = tuple(map(int, lines[1].split())) B = tuple(map(int, lines[2].split())) pre = A[0] ans = 0 for a, b in zip(A[1:], B): tmp1 = min(pre, b) b -= tmp1 tmp2 = min(a, b) ans += tmp1 + tmp2 ...
from sys import stdin def main(): eval(input()) A = tuple(map(int, stdin.readline().split())) B = tuple(map(int, stdin.readline().split())) pre = A[0] ans = 0 for a, b in zip(A[1:], B): tmp1 = pre if pre < b else b b -= tmp1 tmp2 = a if a < b else b ...
20
20
382
398
from sys import stdin def main(): lines = stdin.readlines() A = tuple(map(int, lines[1].split())) B = tuple(map(int, lines[2].split())) pre = A[0] ans = 0 for a, b in zip(A[1:], B): tmp1 = min(pre, b) b -= tmp1 tmp2 = min(a, b) ans += tmp1 + tmp2 pre = a...
from sys import stdin def main(): eval(input()) A = tuple(map(int, stdin.readline().split())) B = tuple(map(int, stdin.readline().split())) pre = A[0] ans = 0 for a, b in zip(A[1:], B): tmp1 = pre if pre < b else b b -= tmp1 tmp2 = a if a < b else b ans += tmp1 ...
false
0
[ "- lines = stdin.readlines()", "- A = tuple(map(int, lines[1].split()))", "- B = tuple(map(int, lines[2].split()))", "+ eval(input())", "+ A = tuple(map(int, stdin.readline().split()))", "+ B = tuple(map(int, stdin.readline().split()))", "- tmp1 = min(pre, b)", "+ tmp1 ...
false
0.036547
0.058045
0.629636
[ "s045898968", "s104158243" ]
u145600939
p02913
python
s788687126
s468392048
498
202
229,768
4,208
Accepted
Accepted
59.44
def main(): n = int(eval(input())) s = eval(input()) dp = [[0]*(n+1) for i in range(n+1)] ans = 0 for i in range(n-1)[::-1]: for j in range(i+1,n)[::-1]: if s[i] == s[j]: dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1) ans = max(ans, min(dp[i][...
n = int(eval(input())) s = eval(input()) mod = 10**20 + 7 base = 12345 def ok(l): array = {} rolling_hash = 0 for i in range(n): rolling_hash *= base rolling_hash += ord(s[i]) if i - l >= 0: rolling_hash -= ord(s[i-l]) * pow(base, l, mod) rolling_h...
12
35
341
778
def main(): n = int(eval(input())) s = eval(input()) dp = [[0] * (n + 1) for i in range(n + 1)] ans = 0 for i in range(n - 1)[::-1]: for j in range(i + 1, n)[::-1]: if s[i] == s[j]: dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1) ans = max(ans, min(...
n = int(eval(input())) s = eval(input()) mod = 10**20 + 7 base = 12345 def ok(l): array = {} rolling_hash = 0 for i in range(n): rolling_hash *= base rolling_hash += ord(s[i]) if i - l >= 0: rolling_hash -= ord(s[i - l]) * pow(base, l, mod) rolling_hash %= mod ...
false
65.714286
[ "-def main():", "- n = int(eval(input()))", "- s = eval(input())", "- dp = [[0] * (n + 1) for i in range(n + 1)]", "- ans = 0", "- for i in range(n - 1)[::-1]:", "- for j in range(i + 1, n)[::-1]:", "- if s[i] == s[j]:", "- dp[i][j] = max(dp[i][j], dp[...
false
0.048025
0.043492
1.10422
[ "s788687126", "s468392048" ]
u888092736
p02598
python
s287876772
s007245376
1,941
1,149
31,412
31,496
Accepted
Accepted
40.8
def is_good(mid, key): return sum(count_cuts(a, mid) for a in A) <= key def binary_search(key): bad, good = 0, 2 * 10 ** 14 + 1 while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = mid else: bad = mid return good de...
def count_cuts(a, unit): return (a + unit - 1) // unit - 1 def is_good(mid, key): return sum(count_cuts(a, mid) for a in A) <= key def binary_search(key): bad, good = 0, 1_000_000_000 while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = ...
21
21
456
453
def is_good(mid, key): return sum(count_cuts(a, mid) for a in A) <= key def binary_search(key): bad, good = 0, 2 * 10**14 + 1 while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = mid else: bad = mid return good def count_cuts(a, u...
def count_cuts(a, unit): return (a + unit - 1) // unit - 1 def is_good(mid, key): return sum(count_cuts(a, mid) for a in A) <= key def binary_search(key): bad, good = 0, 1_000_000_000 while good - bad > 1: mid = (bad + good) // 2 if is_good(mid, key): good = mid e...
false
0
[ "+def count_cuts(a, unit):", "+ return (a + unit - 1) // unit - 1", "+", "+", "- bad, good = 0, 2 * 10**14 + 1", "+ bad, good = 0, 1_000_000_000", "-def count_cuts(a, unit):", "- return (a + unit - 1) // unit - 1", "-", "-" ]
false
0.038337
0.038191
1.003814
[ "s287876772", "s007245376" ]
u358919705
p00022
python
s849639573
s474073786
1,250
60
7,828
7,712
Accepted
Accepted
95.2
import itertools while True: n = int(eval(input())) if n == 0: break a = [int(eval(input())) for _ in range(n)] a[:0] = [0] for i in range(1, len(a)): a[i] += a[i - 1] print((max([x[1] - x[0] for x in itertools.combinations(a, 2)])))
while True: n = int(eval(input())) if not n: break a = [int(eval(input())) for _ in range(n)] for i in range(1, n): if a[i - 1] > 0: a[i] += a[i - 1] print((max(a)))
10
9
272
207
import itertools while True: n = int(eval(input())) if n == 0: break a = [int(eval(input())) for _ in range(n)] a[:0] = [0] for i in range(1, len(a)): a[i] += a[i - 1] print((max([x[1] - x[0] for x in itertools.combinations(a, 2)])))
while True: n = int(eval(input())) if not n: break a = [int(eval(input())) for _ in range(n)] for i in range(1, n): if a[i - 1] > 0: a[i] += a[i - 1] print((max(a)))
false
10
[ "-import itertools", "-", "- if n == 0:", "+ if not n:", "- a[:0] = [0]", "- for i in range(1, len(a)):", "- a[i] += a[i - 1]", "- print((max([x[1] - x[0] for x in itertools.combinations(a, 2)])))", "+ for i in range(1, n):", "+ if a[i - 1] > 0:", "+ a[...
false
0.060372
0.035523
1.699496
[ "s849639573", "s474073786" ]
u297574184
p03035
python
s436524960
s321517546
20
18
2,940
2,940
Accepted
Accepted
10
A, B = list(map(int, input().split())) if A <= 5: print((0)) elif A <= 12: print((B//2)) else: print(B)
A, B = list(map(int, input().split())) if A <= 5: B = 0 elif A <= 12: B //= 2 print(B)
8
8
114
98
A, B = list(map(int, input().split())) if A <= 5: print((0)) elif A <= 12: print((B // 2)) else: print(B)
A, B = list(map(int, input().split())) if A <= 5: B = 0 elif A <= 12: B //= 2 print(B)
false
0
[ "- print((0))", "+ B = 0", "- print((B // 2))", "-else:", "- print(B)", "+ B //= 2", "+print(B)" ]
false
0.040966
0.077186
0.530745
[ "s436524960", "s321517546" ]
u606045429
p02716
python
s615185385
s049743227
1,320
1,022
291,152
291,132
Accepted
Accepted
22.58
from collections import defaultdict INF = float("inf") N, *A = list(map(int, open(0).read().split())) dp_in = defaultdict(lambda: -INF) dp_out = defaultdict(lambda: -INF) dp_out[(0, 0)] = 0 for i, a in enumerate(A, 1): p = i // 2 for j in [p - 1, p, p + 1]: dp_in[(i, j)] = a + dp_out[...
from collections import defaultdict def main(): INF = float("inf") N, *A = list(map(int, open(0).read().split())) dp_in = defaultdict(lambda: -INF) dp_out = defaultdict(lambda: -INF) dp_out[(0, 0)] = 0 for i, a in enumerate(A, 1): p = i // 2 for j in [p - 1, p,...
18
21
453
520
from collections import defaultdict INF = float("inf") N, *A = list(map(int, open(0).read().split())) dp_in = defaultdict(lambda: -INF) dp_out = defaultdict(lambda: -INF) dp_out[(0, 0)] = 0 for i, a in enumerate(A, 1): p = i // 2 for j in [p - 1, p, p + 1]: dp_in[(i, j)] = a + dp_out[(i - 1, j - 1)] ...
from collections import defaultdict def main(): INF = float("inf") N, *A = list(map(int, open(0).read().split())) dp_in = defaultdict(lambda: -INF) dp_out = defaultdict(lambda: -INF) dp_out[(0, 0)] = 0 for i, a in enumerate(A, 1): p = i // 2 for j in [p - 1, p, p + 1]: ...
false
14.285714
[ "-INF = float(\"inf\")", "-N, *A = list(map(int, open(0).read().split()))", "-dp_in = defaultdict(lambda: -INF)", "-dp_out = defaultdict(lambda: -INF)", "-dp_out[(0, 0)] = 0", "-for i, a in enumerate(A, 1):", "- p = i // 2", "- for j in [p - 1, p, p + 1]:", "- dp_in[(i, j)] = a + dp_out...
false
0.047576
0.047204
1.007867
[ "s615185385", "s049743227" ]
u645250356
p03557
python
s021929667
s683569770
375
325
23,360
23,328
Accepted
Accepted
13.33
import bisect n = int(eval(input())) bb = [0] * (n+1) ans = 0 a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] a.sort() b.sort() c.sort() for i in range(1,n+1): bb[i] = bisect.bisect_left(a,b[i-1]) + bb[i-1] for i in range(n): ans...
import bisect n = int(eval(input())) ans = 0 a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort() b.sort() c.sort() for i in range(n): ans += bisect.bisect_left(a,b[i]) * (n-bisect.bisect_right(c,b[i])) print(ans)
17
12
360
283
import bisect n = int(eval(input())) bb = [0] * (n + 1) ans = 0 a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] a.sort() b.sort() c.sort() for i in range(1, n + 1): bb[i] = bisect.bisect_left(a, b[i - 1]) + bb[i - 1] for i in range(n): ans += bb...
import bisect n = int(eval(input())) ans = 0 a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort() b.sort() c.sort() for i in range(n): ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i])) print(ans)
false
29.411765
[ "-bb = [0] * (n + 1)", "-a = [int(i) for i in input().split()]", "-b = [int(i) for i in input().split()]", "-c = [int(i) for i in input().split()]", "+a = list(map(int, input().split()))", "+b = list(map(int, input().split()))", "+c = list(map(int, input().split()))", "-for i in range(1, n + 1):", "...
false
0.038809
0.039467
0.983317
[ "s021929667", "s683569770" ]
u561083515
p03651
python
s430034835
s393391825
168
93
14,224
16,280
Accepted
Accepted
44.64
N,K = list(map(int, input().split())) A = [int(i) for i in input().split()] A.sort() if A[-1] < K: print("IMPOSSIBLE") exit() from bisect import bisect_left flag = False for i in range(N): if A[i] == K: flag = True idx = bisect_left(A, K - A[i]) if idx < N and i != id...
from fractions import gcd N,K = list(map(int, input().split())) A = [int(i) for i in input().split()] M = max(A) G = 0 for a in A: G = gcd(G, a) if K % G == 0 and K <= M: print("POSSIBLE") else: print("IMPOSSIBLE")
23
15
427
238
N, K = list(map(int, input().split())) A = [int(i) for i in input().split()] A.sort() if A[-1] < K: print("IMPOSSIBLE") exit() from bisect import bisect_left flag = False for i in range(N): if A[i] == K: flag = True idx = bisect_left(A, K - A[i]) if idx < N and i != idx and A[idx] == K - A[...
from fractions import gcd N, K = list(map(int, input().split())) A = [int(i) for i in input().split()] M = max(A) G = 0 for a in A: G = gcd(G, a) if K % G == 0 and K <= M: print("POSSIBLE") else: print("IMPOSSIBLE")
false
34.782609
[ "+from fractions import gcd", "+", "-A.sort()", "-if A[-1] < K:", "- print(\"IMPOSSIBLE\")", "- exit()", "-from bisect import bisect_left", "-", "-flag = False", "-for i in range(N):", "- if A[i] == K:", "- flag = True", "- idx = bisect_left(A, K - A[i])", "- if idx <...
false
0.036112
0.046053
0.784144
[ "s430034835", "s393391825" ]
u740284863
p02813
python
s743609440
s980231339
39
34
14,180
13,932
Accepted
Accepted
12.82
import itertools,math n = int(eval(input())) a = sorted(list(itertools.permutations([ i for i in range(1,n+1)]))) p = tuple(map(int,input().split())) q = tuple(map(int,input().split())) print((abs(a.index(p) - a.index(q))))
import itertools n = int(eval(input())) P = tuple(map(int,input().split())) Q = tuple(map(int,input().split())) L = list(itertools.permutations([i for i in range(1,n+1)])) print(( abs((L.index(P)+1)-((L.index(Q)+1))) ))
6
8
220
227
import itertools, math n = int(eval(input())) a = sorted(list(itertools.permutations([i for i in range(1, n + 1)]))) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) print((abs(a.index(p) - a.index(q))))
import itertools n = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) L = list(itertools.permutations([i for i in range(1, n + 1)])) print((abs((L.index(P) + 1) - ((L.index(Q) + 1)))))
false
25
[ "-import itertools, math", "+import itertools", "-a = sorted(list(itertools.permutations([i for i in range(1, n + 1)])))", "-p = tuple(map(int, input().split()))", "-q = tuple(map(int, input().split()))", "-print((abs(a.index(p) - a.index(q))))", "+P = tuple(map(int, input().split()))", "+Q = tuple(ma...
false
0.040686
0.03944
1.031592
[ "s743609440", "s980231339" ]
u627234757
p03037
python
s661584276
s274754900
353
191
10,996
9,208
Accepted
Accepted
45.89
N, M = list(map(int, input().split())) L = [] R = [] for _ in range(M): tmp1,tmp2 = list(map(int,input().split())) L.append(tmp1) R.append(tmp2) max_L = L[0] min_R = R[0] for i in range(1,M): max_L = max(max_L, L[i]) min_R = min(min_R, R[i]) if min_R >= max_L: res = min_R - max_...
n, m = list(map(int, input().split())) max_l = 0 min_r = 10**5 for i in range(m): l, r = list(map(int, input().split())) if l > max_l: max_l = l if r < min_r: min_r = r max_l = min(n+1, max_l) min_r = min(n+1, min_r) res = min_r - max_l + 1 if res<0: res = 0 print(res)
19
15
345
287
N, M = list(map(int, input().split())) L = [] R = [] for _ in range(M): tmp1, tmp2 = list(map(int, input().split())) L.append(tmp1) R.append(tmp2) max_L = L[0] min_R = R[0] for i in range(1, M): max_L = max(max_L, L[i]) min_R = min(min_R, R[i]) if min_R >= max_L: res = min_R - max_L + 1 else: ...
n, m = list(map(int, input().split())) max_l = 0 min_r = 10**5 for i in range(m): l, r = list(map(int, input().split())) if l > max_l: max_l = l if r < min_r: min_r = r max_l = min(n + 1, max_l) min_r = min(n + 1, min_r) res = min_r - max_l + 1 if res < 0: res = 0 print(res)
false
21.052632
[ "-N, M = list(map(int, input().split()))", "-L = []", "-R = []", "-for _ in range(M):", "- tmp1, tmp2 = list(map(int, input().split()))", "- L.append(tmp1)", "- R.append(tmp2)", "-max_L = L[0]", "-min_R = R[0]", "-for i in range(1, M):", "- max_L = max(max_L, L[i])", "- min_R = ...
false
0.04147
0.121408
0.341581
[ "s661584276", "s274754900" ]
u296518383
p02862
python
s782629493
s107812686
409
315
127,612
118,928
Accepted
Accepted
22.98
def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = 10**6 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.ap...
X, Y = list(map(int, input().split())) MOD = 10 ** 9 + 7 if (X + Y) % 3 != 0: print((0)) exit() if abs(X - Y) > (X + Y) // 3: print((0)) exit() n = (X + Y) // 3 + 1 k = ((X - Y) + n + 1) // 2 SIZE = max(n, k) g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] ...
32
32
598
661
def cmb(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod mod = 10**9 + 7 # 出力の制限 N = 10**6 g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] # 逆元テーブル計算用テーブル for i in range(2, N + 1): g1.append((g1[-1] * i) % mod) inverse.append((-...
X, Y = list(map(int, input().split())) MOD = 10**9 + 7 if (X + Y) % 3 != 0: print((0)) exit() if abs(X - Y) > (X + Y) // 3: print((0)) exit() n = (X + Y) // 3 + 1 k = ((X - Y) + n + 1) // 2 SIZE = max(n, k) g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] # 逆元テーブル計算用テーブル def comb(n, r, mod...
false
0
[ "-def cmb(n, r, mod):", "+X, Y = list(map(int, input().split()))", "+MOD = 10**9 + 7", "+if (X + Y) % 3 != 0:", "+ print((0))", "+ exit()", "+if abs(X - Y) > (X + Y) // 3:", "+ print((0))", "+ exit()", "+n = (X + Y) // 3 + 1", "+k = ((X - Y) + n + 1) // 2", "+SIZE = max(n, k)", "...
false
3.260735
0.340239
9.583656
[ "s782629493", "s107812686" ]
u421502518
p03470
python
s689270111
s950580047
47
17
3,060
3,060
Accepted
Accepted
63.83
n = int(eval(input())) d = [] for i in range(n): d.append(int(eval(input()))) d = sorted(d) answer = 1 for i in range(1, n): if d[i-1] != d[i]: answer += 1 print(answer)
n = int(eval(input())) d = [] for i in range(n): d.append(int(eval(input()))) d.sort() answer = 1 for i in range(1, n): if d[i-1] != d[i]: answer += 1 print(answer)
10
10
170
165
n = int(eval(input())) d = [] for i in range(n): d.append(int(eval(input()))) d = sorted(d) answer = 1 for i in range(1, n): if d[i - 1] != d[i]: answer += 1 print(answer)
n = int(eval(input())) d = [] for i in range(n): d.append(int(eval(input()))) d.sort() answer = 1 for i in range(1, n): if d[i - 1] != d[i]: answer += 1 print(answer)
false
0
[ "-d = sorted(d)", "+d.sort()" ]
false
0.049598
0.036697
1.351547
[ "s689270111", "s950580047" ]
u943057856
p02813
python
s099504170
s424441793
52
40
14,152
14,196
Accepted
Accepted
23.08
from itertools import permutations n=int(eval(input())) p=list(map(int,input().split())) q=list(map(int,input().split())) c=sorted(list(permutations(list(range(1,n+1))))) a,b,=0,0 for i,c in enumerate(c): if p==list(c): a=i if q==list(c): b=i print((abs(a-b)))
from itertools import permutations n=int(eval(input())) p=tuple(map(int,input().split())) q=tuple(map(int,input().split())) P=sorted(list(permutations(list(range(1,n+1)),n))) print((abs(P.index(p)-P.index(q))))
12
6
281
201
from itertools import permutations n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) c = sorted(list(permutations(list(range(1, n + 1))))) a, b, = ( 0, 0, ) for i, c in enumerate(c): if p == list(c): a = i if q == list(c): b = i print((abs(a ...
from itertools import permutations n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) P = sorted(list(permutations(list(range(1, n + 1)), n))) print((abs(P.index(p) - P.index(q))))
false
50
[ "-p = list(map(int, input().split()))", "-q = list(map(int, input().split()))", "-c = sorted(list(permutations(list(range(1, n + 1)))))", "-a, b, = (", "- 0,", "- 0,", "-)", "-for i, c in enumerate(c):", "- if p == list(c):", "- a = i", "- if q == list(c):", "- b = i"...
false
0.043878
0.04178
1.050206
[ "s099504170", "s424441793" ]
u118211443
p02912
python
s867730665
s223743904
186
163
15,300
14,536
Accepted
Accepted
12.37
import heapq import math n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list([x * (-1) for x in a]) heapq.heapify(b) for i in range(m): h = heapq.heappop(b) heapq.heappush(b, math.ceil(h / 2)) c = list([x * (-1) for x in b]) print((sum(c)))
import heapq import math n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list([x * (-1) for x in a]) heapq.heapify(b) for i in range(m): h = heapq.heappop(b) heapq.heappush(b, math.ceil(h / 2)) print((sum(b)*(-1)))
15
12
301
263
import heapq import math n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list([x * (-1) for x in a]) heapq.heapify(b) for i in range(m): h = heapq.heappop(b) heapq.heappush(b, math.ceil(h / 2)) c = list([x * (-1) for x in b]) print((sum(c)))
import heapq import math n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list([x * (-1) for x in a]) heapq.heapify(b) for i in range(m): h = heapq.heappop(b) heapq.heappush(b, math.ceil(h / 2)) print((sum(b) * (-1)))
false
20
[ "-c = list([x * (-1) for x in b])", "-print((sum(c)))", "+print((sum(b) * (-1)))" ]
false
0.051561
0.052006
0.991438
[ "s867730665", "s223743904" ]
u309289733
p04000
python
s635261947
s967274611
1,955
1,759
152,092
152,100
Accepted
Accepted
10.03
from collections import Counter, defaultdict h, w, n = list(map(int, input().split())) hs, ws = h - 2, w - 2 dd = defaultdict(int) for a, b in (list(map(int, input().split())) for _ in range(n)): for y in range(max(0, a - 3), min(a, hs)): for x in range(max(0, b - 3), min(b, ws)): dd[...
from collections import Counter, defaultdict h, w, n = list(map(int, input().split())) blacks = defaultdict(int) for a, b in (list(map(int, input().split())) for _ in range(n)): for y in range(max(0, a - 3), min(a, (h - 2))): for x in range(max(0, b - 3), min(b, (w - 2))): blacks[(y, x...
16
15
435
448
from collections import Counter, defaultdict h, w, n = list(map(int, input().split())) hs, ws = h - 2, w - 2 dd = defaultdict(int) for a, b in (list(map(int, input().split())) for _ in range(n)): for y in range(max(0, a - 3), min(a, hs)): for x in range(max(0, b - 3), min(b, ws)): dd[(y, x)] +=...
from collections import Counter, defaultdict h, w, n = list(map(int, input().split())) blacks = defaultdict(int) for a, b in (list(map(int, input().split())) for _ in range(n)): for y in range(max(0, a - 3), min(a, (h - 2))): for x in range(max(0, b - 3), min(b, (w - 2))): blacks[(y, x)] += 1 p...
false
6.25
[ "-hs, ws = h - 2, w - 2", "-dd = defaultdict(int)", "+blacks = defaultdict(int)", "- for y in range(max(0, a - 3), min(a, hs)):", "- for x in range(max(0, b - 3), min(b, ws)):", "- dd[(y, x)] += 1", "-print((hs * ws - len(dd)))", "-c = Counter(list(dd.values()))", "+ for y in...
false
0.04162
0.036806
1.130788
[ "s635261947", "s967274611" ]
u585482323
p03493
python
s647650804
s292402140
195
166
39,408
38,512
Accepted
Accepted
14.87
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, ...
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in...
78
35
1,237
834
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(m...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(...
false
55.128205
[ "-from collections import defaultdict", "-from collections import deque", "+from collections import defaultdict, deque", "+from itertools import permutations", "-import random", "- return list(map(int, sys.stdin.readline().split()))", "+ return [int(x) for x in sys.stdin.readline().split()]", "-...
false
0.127574
0.008423
15.14591
[ "s647650804", "s292402140" ]
u426108351
p03161
python
s822386966
s854316844
386
351
56,544
52,448
Accepted
Accepted
9.07
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [1000000001 for i in range(N)] dp[0] = 0 for i in range(N): for j in range(1, K+1): if i+j <= N-1: dp[i+j] = min(dp[i] + abs(h[i+j] - h[i]), dp[i+j]) print((dp[N-1]))
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [10000000000]*(N+100) dp[0] = 0 for i in range(N): for j in range(1, K+1): if i + j <= N-1: dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i])) print((dp[N-1]))
10
10
273
266
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [1000000001 for i in range(N)] dp[0] = 0 for i in range(N): for j in range(1, K + 1): if i + j <= N - 1: dp[i + j] = min(dp[i] + abs(h[i + j] - h[i]), dp[i + j]) print((dp[N - 1]))
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [10000000000] * (N + 100) dp[0] = 0 for i in range(N): for j in range(1, K + 1): if i + j <= N - 1: dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i])) print((dp[N - 1]))
false
0
[ "-dp = [1000000001 for i in range(N)]", "+dp = [10000000000] * (N + 100)", "- dp[i + j] = min(dp[i] + abs(h[i + j] - h[i]), dp[i + j])", "+ dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))" ]
false
0.041554
0.09762
0.425671
[ "s822386966", "s854316844" ]
u543954314
p02722
python
s147413768
s326890080
647
211
43,996
3,316
Accepted
Accepted
67.39
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: list(map(int, stdin.readline().split())) nl = lambda: list(map(int, stdin.readline().split())) def divisor(n): ass = [] for i in range(1, int(n**0.5)+1): if n%i == ...
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: list(map(int, stdin.readline().split())) nl = lambda: list(map(int, stdin.readline().split())) def divisor(n): ass = [] for i in range(1, int(n**0.5)+1): if n%i == ...
34
30
656
585
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: list(map(int, stdin.readline().split())) nl = lambda: list(map(int, stdin.readline().split())) def divisor(n): ass = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: ...
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: list(map(int, stdin.readline().split())) nl = lambda: list(map(int, stdin.readline().split())) def divisor(n): ass = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: ...
false
11.764706
[ "+q = divisor(n - 1)", "-for k in p:", "- nk = n // k", "- for t in divisor(nk - 1):", "- s.add(t * k)", "-s.remove(1)", "-s.add(n)", "-for t in s:", "+for x in p + q:", "- while m % t == 0:", "- m //= t", "- if m % t == 1:", "- ans += 1", "-print(ans)", ...
false
0.167427
0.058772
2.848736
[ "s147413768", "s326890080" ]
u785578220
p03045
python
s008525897
s118944329
621
472
16,784
12,780
Accepted
Accepted
23.99
class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, ...
def main(): #Union Find #locate x def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] #merge x y def unite(x,y): x = find(x) y = find(y) if x == y: return False ...
37
46
886
991
class UnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] self.rank = [0] * (n + 1) def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def union(self, x, y): ...
def main(): # Union Find # locate x def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] # merge x y def unite(x, y): x = find(x) y = find(y) if x == y: return False else: ...
false
19.565217
[ "-class UnionFind:", "- def __init__(self, n):", "- self.par = [i for i in range(n + 1)]", "- self.rank = [0] * (n + 1)", "-", "- def find(self, x):", "- if self.par[x] == x:", "+def main():", "+ # Union Find", "+ # locate x", "+ def find(x):", "+ if ...
false
0.047038
0.05348
0.87955
[ "s008525897", "s118944329" ]
u015593272
p02583
python
s025090587
s430462499
842
465
108,204
91,748
Accepted
Accepted
44.77
import numpy as np from numba import * N = int(eval(input())) length = np.array(input().split(), np.int64) length = np.sort(length) @njit def calc(length): cnt = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): l1, l2, l3 = l...
import numpy as np from numba import * N = int(eval(input())) length = np.array(input().split(), np.int64) length = np.sort(length) def calc(length): cnt = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): l1, l2, l3 = length...
26
26
535
530
import numpy as np from numba import * N = int(eval(input())) length = np.array(input().split(), np.int64) length = np.sort(length) @njit def calc(length): cnt = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): l1, l2, l3 = length[i], length[j], len...
import numpy as np from numba import * N = int(eval(input())) length = np.array(input().split(), np.int64) length = np.sort(length) def calc(length): cnt = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): l1, l2, l3 = length[i], length[j], length[k]...
false
0
[ "-@njit" ]
false
0.228535
0.303041
0.754137
[ "s025090587", "s430462499" ]
u458530128
p02315
python
s586321153
s765436866
990
630
25,944
5,932
Accepted
Accepted
36.36
N, W = list(map(int, input().split())) items = [[0, 0]] for _ in range(N): v, w = list(map(int, input().split())) items.append([v, w]) DP = [[0 for _ in range(W + 1)] for _ in range(N + 1)] for i in range(1, N + 1): for j in range(W + 1): if items[i][1] > j: DP[i][j] = DP[i - 1]...
N, W = list(map(int, input().split())) items = [[0, 0]] for _ in range(N): v, w = list(map(int, input().split())) items.append([v, w]) ''' DP = [[0 for _ in range(W + 1)] for _ in range(N + 1)] for i in range(1, N + 1): for j in range(W + 1): if items[i][1] > j: DP[i][j] = DP[i...
14
21
442
642
N, W = list(map(int, input().split())) items = [[0, 0]] for _ in range(N): v, w = list(map(int, input().split())) items.append([v, w]) DP = [[0 for _ in range(W + 1)] for _ in range(N + 1)] for i in range(1, N + 1): for j in range(W + 1): if items[i][1] > j: DP[i][j] = DP[i - 1][j] ...
N, W = list(map(int, input().split())) items = [[0, 0]] for _ in range(N): v, w = list(map(int, input().split())) items.append([v, w]) """ DP = [[0 for _ in range(W + 1)] for _ in range(N + 1)] for i in range(1, N + 1): for j in range(W + 1): if items[i][1] > j: DP[i][j] = DP[i - 1][j] ...
false
33.333333
[ "+\"\"\"", "-print((DP[N][W]))", "+print(DP[N][W])", "+\"\"\"", "+DP2 = [0 for _ in range(W + 1)]", "+for i in range(1, N + 1):", "+ for j in range(W, items[i][1] - 1, -1):", "+ DP2[j] = max(DP2[j], DP2[j - items[i][1]] + items[i][0])", "+print((DP2[W]))" ]
false
0.045741
0.106579
0.429177
[ "s586321153", "s765436866" ]
u294485299
p02689
python
s679874537
s498362433
486
339
31,952
98,148
Accepted
Accepted
30.25
n, m = list(map(int, input().split())) ans= 0 rs = [] hs = list(map(int, input().split())) ds = {} ok = True for i in range(m): a,b = list(map(int, input().split())) if(a in ds): ds[a].append(b) if(b in ds): ds[b].append(a) if(a not in ds): ds[a] = [b] if(b not ...
n, m = list(map(int, input().split())) ans= 0 hs = list(map(int, input().split())) ds = {} ok = True for i in range(m): a,b = list(map(int, input().split())) if(a in ds): ds[a].append(b) if(b in ds): ds[b].append(a) if(a not in ds): ds[a] = [b] if(b not in ds): ...
27
26
570
562
n, m = list(map(int, input().split())) ans = 0 rs = [] hs = list(map(int, input().split())) ds = {} ok = True for i in range(m): a, b = list(map(int, input().split())) if a in ds: ds[a].append(b) if b in ds: ds[b].append(a) if a not in ds: ds[a] = [b] if b not in ds: ...
n, m = list(map(int, input().split())) ans = 0 hs = list(map(int, input().split())) ds = {} ok = True for i in range(m): a, b = list(map(int, input().split())) if a in ds: ds[a].append(b) if b in ds: ds[b].append(a) if a not in ds: ds[a] = [b] if b not in ds: ds[b] = ...
false
3.703704
[ "-rs = []" ]
false
0.041806
0.075408
0.554396
[ "s679874537", "s498362433" ]
u604774382
p02398
python
s024484955
s677850684
40
30
6,728
6,724
Accepted
Accepted
25
import sys a, b, c = [ int( val ) for val in sys.stdin.readline().split( ' ' ) ] cnt = 0 i = a while i <= b: if ( c % i ) == 0: cnt += 1 i += 1 print(( "{}".format( cnt ) ))
import sys a, b, c = [ int( val ) for val in sys.stdin.readline().split( ' ' ) ] cnt = 0 for divisor in range( a, b+1 ): if ( c % divisor ) == 0: cnt += 1 print(( "{}".format( cnt ) ))
10
8
185
202
import sys a, b, c = [int(val) for val in sys.stdin.readline().split(" ")] cnt = 0 i = a while i <= b: if (c % i) == 0: cnt += 1 i += 1 print(("{}".format(cnt)))
import sys a, b, c = [int(val) for val in sys.stdin.readline().split(" ")] cnt = 0 for divisor in range(a, b + 1): if (c % divisor) == 0: cnt += 1 print(("{}".format(cnt)))
false
20
[ "-i = a", "-while i <= b:", "- if (c % i) == 0:", "+for divisor in range(a, b + 1):", "+ if (c % divisor) == 0:", "- i += 1" ]
false
0.046242
0.037575
1.230642
[ "s024484955", "s677850684" ]
u254871849
p03401
python
s768854517
s838491662
487
203
22,976
14,188
Accepted
Accepted
58.32
import sys import numpy as np n, *a = map(int, sys.stdin.read().split()) a = np.array([0] + a + [0]) def main(): res1 = np.absolute(a[2:] - a[1:-1]) + np.absolute(a[1:-1] - a[:-2]) res2 = np.absolute(a[2:] - a[:-2]) default = np.absolute(a[1:] - a[:-1]).sum() ans = default - (res1 - r...
import sys n, *a = list(map(int, sys.stdin.read().split())) a = [0] + a + [0] def main(): s = sum([abs(a[i+1] - a[i]) for i in range(n + 1)]) for i in range(1, n + 1): if a[i-1] <= a[i] <= a[i+1]: res = s elif a[i-1] >= a[i] >= a[i+1]: res = s else: res = s - 2 * min(abs(a[i]...
17
15
415
420
import sys import numpy as np n, *a = map(int, sys.stdin.read().split()) a = np.array([0] + a + [0]) def main(): res1 = np.absolute(a[2:] - a[1:-1]) + np.absolute(a[1:-1] - a[:-2]) res2 = np.absolute(a[2:] - a[:-2]) default = np.absolute(a[1:] - a[:-1]).sum() ans = default - (res1 - res2) return ...
import sys n, *a = list(map(int, sys.stdin.read().split())) a = [0] + a + [0] def main(): s = sum([abs(a[i + 1] - a[i]) for i in range(n + 1)]) for i in range(1, n + 1): if a[i - 1] <= a[i] <= a[i + 1]: res = s elif a[i - 1] >= a[i] >= a[i + 1]: res = s else: ...
false
11.764706
[ "-import numpy as np", "-n, *a = map(int, sys.stdin.read().split())", "-a = np.array([0] + a + [0])", "+n, *a = list(map(int, sys.stdin.read().split()))", "+a = [0] + a + [0]", "- res1 = np.absolute(a[2:] - a[1:-1]) + np.absolute(a[1:-1] - a[:-2])", "- res2 = np.absolute(a[2:] - a[:-2])", "- ...
false
0.734914
0.03828
19.198259
[ "s768854517", "s838491662" ]
u086503932
p02678
python
s942677697
s803536275
535
486
35,764
98,372
Accepted
Accepted
9.16
#!/usr/bin/env python3 from collections import deque def main(): N, M = map(int, input().split()) adj = [[] for _ in range(N)] for i in range(M): a, b = map(int, input().split()) adj[a-1].append(b-1) adj[b-1].append(a-1) queue = deque([0]) visit = [-1] * N ...
N, M = list(map(int, input().split())) adj = [[] for _ in range(N)] for _ in range(M): A, B = [int(x)-1 for x in input().split()] adj[A].append(B) adj[B].append(A) from collections import deque queue = deque([0]) visit = [-1] * N visit[0] = 1 while queue: now = queue.popleft() for ...
29
26
677
566
#!/usr/bin/env python3 from collections import deque def main(): N, M = map(int, input().split()) adj = [[] for _ in range(N)] for i in range(M): a, b = map(int, input().split()) adj[a - 1].append(b - 1) adj[b - 1].append(a - 1) queue = deque([0]) visit = [-1] * N visit...
N, M = list(map(int, input().split())) adj = [[] for _ in range(N)] for _ in range(M): A, B = [int(x) - 1 for x in input().split()] adj[A].append(B) adj[B].append(A) from collections import deque queue = deque([0]) visit = [-1] * N visit[0] = 1 while queue: now = queue.popleft() for u in adj[now]: ...
false
10.344828
[ "-#!/usr/bin/env python3", "+N, M = list(map(int, input().split()))", "+adj = [[] for _ in range(N)]", "+for _ in range(M):", "+ A, B = [int(x) - 1 for x in input().split()]", "+ adj[A].append(B)", "+ adj[B].append(A)", "-", "-def main():", "- N, M = map(int, input().split())", "- ...
false
0.0071
0.039102
0.181571
[ "s942677697", "s803536275" ]
u620084012
p03330
python
s113322422
s994551560
660
519
5,492
11,592
Accepted
Accepted
21.36
N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for k in range(C)] G = [list(map(int, input().split())) for k in range(N)] M = [[0,0,0] for k in range(C)] for x in range(N): for y in range(N): M[G[x][y]-1][(x+y)%3] += 1 ans = 10**9 for p in range(C): for q in ran...
N, C = list(map(int,input().split())) D = [list(map(int,input().split())) for _ in range(C)] G = [list(map(int,input().split())) for _ in range(N)] Z = [0]*C O = [0]*C T = [0]*C for x in range(N): for y in range(N): if (x+y)%3 == 0: Z[G[x][y]-1] += 1 elif (x+y)%3 == 1: ...
20
31
572
831
N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for k in range(C)] G = [list(map(int, input().split())) for k in range(N)] M = [[0, 0, 0] for k in range(C)] for x in range(N): for y in range(N): M[G[x][y] - 1][(x + y) % 3] += 1 ans = 10**9 for p in range(C): for q in range(C)...
N, C = list(map(int, input().split())) D = [list(map(int, input().split())) for _ in range(C)] G = [list(map(int, input().split())) for _ in range(N)] Z = [0] * C O = [0] * C T = [0] * C for x in range(N): for y in range(N): if (x + y) % 3 == 0: Z[G[x][y] - 1] += 1 elif (x + y) % 3 == 1:...
false
35.483871
[ "-D = [list(map(int, input().split())) for k in range(C)]", "-G = [list(map(int, input().split())) for k in range(N)]", "-M = [[0, 0, 0] for k in range(C)]", "+D = [list(map(int, input().split())) for _ in range(C)]", "+G = [list(map(int, input().split())) for _ in range(N)]", "+Z = [0] * C", "+O = [0] ...
false
0.046183
0.129093
0.357748
[ "s113322422", "s994551560" ]
u562935282
p03157
python
s071466057
s702703757
1,819
573
9,108
148,212
Accepted
Accepted
68.5
class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed) self.bk = [1 if s[r][c] == '#' else 0 for r in range(H) for c in range(W)] self.wt = [1 if s[r][c] == '.' else 0 for r in range(H) for c in range(W)] def find(se...
# https://atcoder.jp/contests/aising2019/submissions/3986315 import sys sys.setrecursionlimit(2 * 10 ** 5) H, W = list(map(int, input().split())) s = [eval(input()) for _ in range(H)] ans = 0 dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] un_reached = [[True for i in range(W)] for j in range(H)] def dfs...
80
37
2,712
806
class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed) self.bk = [1 if s[r][c] == "#" else 0 for r in range(H) for c in range(W)] self.wt = [1 if s[r][c] == "." else 0 for r in range(H) for c in range(W)] def find(self, x)...
# https://atcoder.jp/contests/aising2019/submissions/3986315 import sys sys.setrecursionlimit(2 * 10**5) H, W = list(map(int, input().split())) s = [eval(input()) for _ in range(H)] ans = 0 dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] un_reached = [[True for i in range(W)] for j in range(H)] def dfs(x, y): un_reached[x...
false
53.75
[ "-class UnionFind:", "- def __init__(self, n):", "- self.v = [-1 for _ in range(n)] # 根(負): 連結頂点数 * (-1) / 子(正): 根の頂点番号(0-indexed)", "- self.bk = [1 if s[r][c] == \"#\" else 0 for r in range(H) for c in range(W)]", "- self.wt = [1 if s[r][c] == \".\" else 0 for r in range(H) for c i...
false
0.038374
0.08569
0.447822
[ "s071466057", "s702703757" ]
u608297208
p03702
python
s185061480
s286752458
1,589
1,345
19,260
15,232
Accepted
Accepted
15.36
import math N,A,B = list(map(int,input().split())) H = [int(eval(input())) for i in range(N)] Hs = sum(H) c = A - B M = math.ceil(Hs / B) m = 0 while M - m > 1: n = (M + m) // 2 H2 = [H[i] - n * B for i in range(N) if H[i] - n * B > 0] cnts = [math.ceil(H2[i] / c) for i in range(len(H2))] cnt = sum(c...
import math N,A,B = list(map(int,input().split())) H = [int(eval(input())) for i in range(N)] Hs = sum(H) c = A - B M = math.ceil(max(H) / B) m = max(H) // A while M - m > 1: n = (M + m) // 2 H2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H[i] - n * B > 0] cnt = sum(H2) if cnt > n: m = n...
22
21
397
370
import math N, A, B = list(map(int, input().split())) H = [int(eval(input())) for i in range(N)] Hs = sum(H) c = A - B M = math.ceil(Hs / B) m = 0 while M - m > 1: n = (M + m) // 2 H2 = [H[i] - n * B for i in range(N) if H[i] - n * B > 0] cnts = [math.ceil(H2[i] / c) for i in range(len(H2))] cnt = sum(...
import math N, A, B = list(map(int, input().split())) H = [int(eval(input())) for i in range(N)] Hs = sum(H) c = A - B M = math.ceil(max(H) / B) m = max(H) // A while M - m > 1: n = (M + m) // 2 H2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H[i] - n * B > 0] cnt = sum(H2) if cnt > n: ...
false
4.545455
[ "-M = math.ceil(Hs / B)", "-m = 0", "+M = math.ceil(max(H) / B)", "+m = max(H) // A", "- H2 = [H[i] - n * B for i in range(N) if H[i] - n * B > 0]", "- cnts = [math.ceil(H2[i] / c) for i in range(len(H2))]", "- cnt = sum(cnts)", "+ H2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H...
false
0.033471
0.037096
0.902281
[ "s185061480", "s286752458" ]
u754022296
p03168
python
s582345168
s115742008
857
245
259,720
84,788
Accepted
Accepted
71.41
n = int(eval(input())) P = list(map(float, input().split())) dp = [[0]*(n+1) for _ in range(n+1)] dp[0][0] = 1 for i in range(n): for j in range(n+1): if j==0: dp[i+1][j] = dp[i][j]*(1-P[i]) else: dp[i+1][j] = dp[i][j-1]*P[i] + dp[i][j]*(1-P[i]) print((sum(dp[n][1+n//2:])))
import numpy as np n = int(eval(input())) P = list(map(float, input().split())) dp = np.zeros((n+1, n+1)) dp[0, 0] = 1 for i in range(n): dp[i+1, 0] = dp[i, 0] * (1-P[i]) dp[i+1, 1:] = dp[i, :-1]*P[i] + dp[i, 1:]*(1-P[i]) print((dp[n, 1+n//2:].sum()))
11
10
298
257
n = int(eval(input())) P = list(map(float, input().split())) dp = [[0] * (n + 1) for _ in range(n + 1)] dp[0][0] = 1 for i in range(n): for j in range(n + 1): if j == 0: dp[i + 1][j] = dp[i][j] * (1 - P[i]) else: dp[i + 1][j] = dp[i][j - 1] * P[i] + dp[i][j] * (1 - P[i]) prin...
import numpy as np n = int(eval(input())) P = list(map(float, input().split())) dp = np.zeros((n + 1, n + 1)) dp[0, 0] = 1 for i in range(n): dp[i + 1, 0] = dp[i, 0] * (1 - P[i]) dp[i + 1, 1:] = dp[i, :-1] * P[i] + dp[i, 1:] * (1 - P[i]) print((dp[n, 1 + n // 2 :].sum()))
false
9.090909
[ "+import numpy as np", "+", "-dp = [[0] * (n + 1) for _ in range(n + 1)]", "-dp[0][0] = 1", "+dp = np.zeros((n + 1, n + 1))", "+dp[0, 0] = 1", "- for j in range(n + 1):", "- if j == 0:", "- dp[i + 1][j] = dp[i][j] * (1 - P[i])", "- else:", "- dp[i + 1][j] =...
false
0.042155
0.57431
0.0734
[ "s582345168", "s115742008" ]
u493130708
p02949
python
s774750828
s229797415
1,211
1,012
75,648
75,856
Accepted
Accepted
16.43
import bisect import collections import copy import functools import heapq import math import sys from collections import deque from collections import defaultdict input = sys.stdin.readline MOD = 10**9+7 N,M,P = list(map(int,(input().split()))) line = [] for i in range(M): a,b,c = list(map(int,(inp...
import bisect import collections import copy import functools import heapq import math import sys from collections import deque from collections import defaultdict input = sys.stdin.readline MOD = 10**9+7 N,M,P = list(map(int,(input().split()))) line = [] for i in range(M): a,b,c = list(map(int,(inp...
58
52
1,590
1,502
import bisect import collections import copy import functools import heapq import math import sys from collections import deque from collections import defaultdict input = sys.stdin.readline MOD = 10**9 + 7 N, M, P = list(map(int, (input().split()))) line = [] for i in range(M): a, b, c = list(map(int, (input().sp...
import bisect import collections import copy import functools import heapq import math import sys from collections import deque from collections import defaultdict input = sys.stdin.readline MOD = 10**9 + 7 N, M, P = list(map(int, (input().split()))) line = [] for i in range(M): a, b, c = list(map(int, (input().sp...
false
10.344828
[ "-", "-", "-def Bellman_Ford():", "- for _ in range(N):", "- update = False", "- for s, g, d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る", "- if (", "- min_distance[s] != float(\"inf\")", "- and min_distance[s] + d < min_distance...
false
0.038135
0.03725
1.023766
[ "s774750828", "s229797415" ]
u406138190
p02683
python
s947510508
s173763740
156
98
9,236
9,244
Accepted
Accepted
37.18
n,m,x=list(map(int,input().split())) arr=[[0 for i in range(m+1)] for j in range(n)] b=[0]*18 ans=-1 flag=1 for i in range(n): arr[i]=list(map(int,input().split())) for i in range(2**n): b=[0]*18 for j in range(n): flag=1 if (1& i>>j): for s in range(m+1): ...
n,m,x=list(map(int,input().split())) a=[[0]*(m+1)]*n for i in range(n): a[i]=list(map(int,input().split())) b=[0]*(m+1) flag=True ans=-1 for i in range(2**n): flag=True b=[0]*(m+1) for j in range(n): if(i>>j & 1): for y in range(m+1): b[y]=b[y]+a[j][y] ...
22
22
534
483
n, m, x = list(map(int, input().split())) arr = [[0 for i in range(m + 1)] for j in range(n)] b = [0] * 18 ans = -1 flag = 1 for i in range(n): arr[i] = list(map(int, input().split())) for i in range(2**n): b = [0] * 18 for j in range(n): flag = 1 if 1 & i >> j: for s in range(m ...
n, m, x = list(map(int, input().split())) a = [[0] * (m + 1)] * n for i in range(n): a[i] = list(map(int, input().split())) b = [0] * (m + 1) flag = True ans = -1 for i in range(2**n): flag = True b = [0] * (m + 1) for j in range(n): if i >> j & 1: for y in range(m + 1): ...
false
0
[ "-arr = [[0 for i in range(m + 1)] for j in range(n)]", "-b = [0] * 18", "+a = [[0] * (m + 1)] * n", "+for i in range(n):", "+ a[i] = list(map(int, input().split()))", "+b = [0] * (m + 1)", "+flag = True", "-flag = 1", "-for i in range(n):", "- arr[i] = list(map(int, input().split()))", "-...
false
0.08452
0.044336
1.906345
[ "s947510508", "s173763740" ]
u729133443
p03201
python
s609883013
s044644120
454
415
33,712
55,140
Accepted
Accepted
8.59
from collections import* from bisect import* p=[1] for _ in range(30):p+=p[-1]*2, n,*a=list(map(int,open(0).read().split())) d=Counter(a) c=0 for b in sorted(a)[::-1]: if d[b]<1:continue d[b]-=1 x=p[bisect(p,b)]-b if d[x]: d[x]-=1 c+=1 print(c)
from collections import* C=Counter(a:=sorted(map(int,[*open(r:=0)][1].split()))) for x in a[::-1]: if C[x]>0:y=2**x.bit_length()-x;C[x]-=1;r+=C[y]>0;C[y]-=1 print(r)
15
5
268
170
from collections import * from bisect import * p = [1] for _ in range(30): p += (p[-1] * 2,) n, *a = list(map(int, open(0).read().split())) d = Counter(a) c = 0 for b in sorted(a)[::-1]: if d[b] < 1: continue d[b] -= 1 x = p[bisect(p, b)] - b if d[x]: d[x] -= 1 c += 1 print(...
from collections import * C = Counter(a := sorted(map(int, [*open(r := 0)][1].split()))) for x in a[::-1]: if C[x] > 0: y = 2 ** x.bit_length() - x C[x] -= 1 r += C[y] > 0 C[y] -= 1 print(r)
false
66.666667
[ "-from bisect import *", "-p = [1]", "-for _ in range(30):", "- p += (p[-1] * 2,)", "-n, *a = list(map(int, open(0).read().split()))", "-d = Counter(a)", "-c = 0", "-for b in sorted(a)[::-1]:", "- if d[b] < 1:", "- continue", "- d[b] -= 1", "- x = p[bisect(p, b)] - b", "- ...
false
0.038597
0.047391
0.814444
[ "s609883013", "s044644120" ]
u935184340
p00008
python
s607291156
s175978156
30
20
7,704
7,796
Accepted
Accepted
33.33
import sys from itertools import product sum = [0] * 51 for k,l in product([i+j for i,j in product(list(range(10)),repeat=2)],repeat=2): sum[k+l] += 1 for i in sys.stdin: print((sum[int(i)]))
import sys import math def nCr(n, k): if 0 <= k <= n: nk,kk = 1,1 for t in range(1, min(k, n - k) + 1): nk = nk*n kk = kk*t n -= 1 return nk // kk else: return 0 p = [0] * 51 v = 0 for i in range(19): t = nCr(i+3, i) ...
9
24
201
429
import sys from itertools import product sum = [0] * 51 for k, l in product([i + j for i, j in product(list(range(10)), repeat=2)], repeat=2): sum[k + l] += 1 for i in sys.stdin: print((sum[int(i)]))
import sys import math def nCr(n, k): if 0 <= k <= n: nk, kk = 1, 1 for t in range(1, min(k, n - k) + 1): nk = nk * n kk = kk * t n -= 1 return nk // kk else: return 0 p = [0] * 51 v = 0 for i in range(19): t = nCr(i + 3, i) v = v +...
false
62.5
[ "-from itertools import product", "+import math", "-sum = [0] * 51", "-for k, l in product([i + j for i, j in product(list(range(10)), repeat=2)], repeat=2):", "- sum[k + l] += 1", "+", "+def nCr(n, k):", "+ if 0 <= k <= n:", "+ nk, kk = 1, 1", "+ for t in range(1, min(k, n - k...
false
0.042956
0.042475
1.011325
[ "s607291156", "s175978156" ]
u193927973
p02888
python
s803556165
s690718547
1,272
1,034
74,604
74,844
Accepted
Accepted
18.71
import bisect as bs N=int(eval(input())) y=list(map(int, input().split())) y.sort() ans=0 for i in range(N-2): for j in range(i+1, N-1): tmp=y[i]+y[j] ans+=bs.bisect_left(y[(j+1):],tmp) print(ans)
from bisect import bisect_left N=int(eval(input())) y=list(map(int, input().split())) y.sort() ans=0 for i in range(N-2): for j in range(i+1, N-1): tmp=y[i]+y[j] ans+=bisect_left(y[(j+1):],tmp) print(ans)
12
10
218
217
import bisect as bs N = int(eval(input())) y = list(map(int, input().split())) y.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): tmp = y[i] + y[j] ans += bs.bisect_left(y[(j + 1) :], tmp) print(ans)
from bisect import bisect_left N = int(eval(input())) y = list(map(int, input().split())) y.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): tmp = y[i] + y[j] ans += bisect_left(y[(j + 1) :], tmp) print(ans)
false
16.666667
[ "-import bisect as bs", "+from bisect import bisect_left", "- ans += bs.bisect_left(y[(j + 1) :], tmp)", "+ ans += bisect_left(y[(j + 1) :], tmp)" ]
false
0.126168
0.038485
3.278344
[ "s803556165", "s690718547" ]
u033524082
p02707
python
s804136391
s474952623
237
150
121,972
32,228
Accepted
Accepted
36.71
import collections n=int(eval(input())) a=list(map(int,input().split())) m=max(a) c=collections.Counter(a) c=c.most_common() l=[0]*n for i in range(len(c)): l[c[i][0]-1]=c[i][1] print((l[0])) for j in range(1,n): print((l[j]))
n=int(eval(input())) a=list(map(int,input().split())) l=[0]*(n+1) check=[False]*(n+1) for i in a: l[i]+=1 for i in range(1,n+1): print((l[i]))
12
9
236
147
import collections n = int(eval(input())) a = list(map(int, input().split())) m = max(a) c = collections.Counter(a) c = c.most_common() l = [0] * n for i in range(len(c)): l[c[i][0] - 1] = c[i][1] print((l[0])) for j in range(1, n): print((l[j]))
n = int(eval(input())) a = list(map(int, input().split())) l = [0] * (n + 1) check = [False] * (n + 1) for i in a: l[i] += 1 for i in range(1, n + 1): print((l[i]))
false
25
[ "-import collections", "-", "-m = max(a)", "-c = collections.Counter(a)", "-c = c.most_common()", "-l = [0] * n", "-for i in range(len(c)):", "- l[c[i][0] - 1] = c[i][1]", "-print((l[0]))", "-for j in range(1, n):", "- print((l[j]))", "+l = [0] * (n + 1)", "+check = [False] * (n + 1)",...
false
0.147562
0.036033
4.095249
[ "s804136391", "s474952623" ]
u869790980
p03266
python
s471509801
s586840013
443
75
84,960
64,016
Accepted
Accepted
83.07
n,k = list(map(int, input().split(' '))) a = n / k b = n/k + (1 if 0 < k / 2 <= n % k else 0) print(a ** 3 + (b ** 3 if k % 2 == 0 else 0))
n,k = list(map(int, input().split(' '))) a,b = n / k, n / k + (1 if 0 < k / 2 <= n % k else 0) print(a ** 3 + (b ** 3 if k % 2 == 0 else 0))
4
3
139
140
n, k = list(map(int, input().split(" "))) a = n / k b = n / k + (1 if 0 < k / 2 <= n % k else 0) print(a**3 + (b**3 if k % 2 == 0 else 0))
n, k = list(map(int, input().split(" "))) a, b = n / k, n / k + (1 if 0 < k / 2 <= n % k else 0) print(a**3 + (b**3 if k % 2 == 0 else 0))
false
25
[ "-a = n / k", "-b = n / k + (1 if 0 < k / 2 <= n % k else 0)", "+a, b = n / k, n / k + (1 if 0 < k / 2 <= n % k else 0)" ]
false
0.095832
0.053964
1.775867
[ "s471509801", "s586840013" ]
u920103253
p02681
python
s123670022
s720016947
24
20
9,132
9,020
Accepted
Accepted
16.67
def s0():return input() def s1():return input().split() def s2(n):return [input() for x in range(n)] def s3(n):return [[input().split()] for _ in range(n)] def n0():return int(input()) def n1():return [int(x) for x in input().split()] def n2(n):return [int(input()) for _ in range(n)] def n3(n):return [[int(x) ...
def s0():return input() def s1():return input().split() def s2(n):return [input() for x in range(n)] def s3(n):return [[input().split()] for _ in range(n)] def n0():return int(input()) def n1():return [int(x) for x in input().split()] def n2(n):return [int(input()) for _ in range(n)] def n3(n):return [[int(x) ...
21
20
695
689
def s0(): return input() def s1(): return input().split() def s2(n): return [input() for x in range(n)] def s3(n): return [[input().split()] for _ in range(n)] def n0(): return int(input()) def n1(): return [int(x) for x in input().split()] def n2(n): return [int(input()) for _ i...
def s0(): return input() def s1(): return input().split() def s2(n): return [input() for x in range(n)] def s3(n): return [[input().split()] for _ in range(n)] def n0(): return int(input()) def n1(): return [int(x) for x in input().split()] def n2(n): return [int(input()) for _ i...
false
4.761905
[ "-def p0(b, yes, no):", "+def p0(b, yes=\"Yes\", no=\"No\"):", "-p0(s == t[:-1], \"Yes\", \"No\")", "+p0(s == t[:-1])" ]
false
0.04055
0.233167
0.173908
[ "s123670022", "s720016947" ]
u490642448
p03095
python
s326671355
s676112389
265
183
42,604
39,024
Accepted
Accepted
30.94
n = int(eval(input())) s = eval(input()) mod = 10**9 + 7 ans = 0 cnt = [1] * 26 for i,ch in enumerate(s): tmp = 1 for j in range(26): if(j==(ord(ch) - 97)): continue tmp *= cnt[j] tmp %= mod ans += tmp ans %= mod cnt[ord(ch) - 97] += 1 print(ans...
n = int(eval(input())) s = eval(input()) mod = 10**9 + 7 cnt = [0] * 26 for i in range(26): cnt[i] = s.count(chr(i+97)) + 1 ans = 1 for i in cnt: ans *= i ans %= mod ans -= 1 ans %= mod print(ans)
18
16
309
214
n = int(eval(input())) s = eval(input()) mod = 10**9 + 7 ans = 0 cnt = [1] * 26 for i, ch in enumerate(s): tmp = 1 for j in range(26): if j == (ord(ch) - 97): continue tmp *= cnt[j] tmp %= mod ans += tmp ans %= mod cnt[ord(ch) - 97] += 1 print(ans)
n = int(eval(input())) s = eval(input()) mod = 10**9 + 7 cnt = [0] * 26 for i in range(26): cnt[i] = s.count(chr(i + 97)) + 1 ans = 1 for i in cnt: ans *= i ans %= mod ans -= 1 ans %= mod print(ans)
false
11.111111
[ "-ans = 0", "-cnt = [1] * 26", "-for i, ch in enumerate(s):", "- tmp = 1", "- for j in range(26):", "- if j == (ord(ch) - 97):", "- continue", "- tmp *= cnt[j]", "- tmp %= mod", "- ans += tmp", "+cnt = [0] * 26", "+for i in range(26):", "+ cnt[i] =...
false
0.047903
0.047055
1.018018
[ "s326671355", "s676112389" ]
u968166680
p03330
python
s897825226
s178795490
794
114
11,588
11,816
Accepted
Accepted
85.64
import sys from itertools import permutations read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, C = list(map(int, readline().split())) D = [0] * C for i in range(C): D[i] ...
import sys from collections import Counter from itertools import permutations read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, C = list(map(int, readline().split())) D = [0] * C ...
39
43
957
1,099
import sys from itertools import permutations read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, C = list(map(int, readline().split())) D = [0] * C for i in range(C): D[i] = list(map(int, r...
import sys from collections import Counter from itertools import permutations read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, C = list(map(int, readline().split())) D = [0] * C for i in range(C)...
false
9.302326
[ "+from collections import Counter", "+ counter = [[0] * C for _ in range(3)]", "- color = G[x][y]", "- cost_current = cost[(x + y) % 3]", "- for i in range(C):", "- cost_current[i] += D[color][i]", "+ counter[(x + y) % 3][G[x][y]] += 1", "+...
false
0.060479
0.038571
1.567973
[ "s897825226", "s178795490" ]
u898967808
p02726
python
s266495345
s041557358
1,888
1,482
3,444
3,572
Accepted
Accepted
21.5
n,x,y = list(map(int,input().split())) x,y = x-1,y-1 ans = [0]*(n) for i in range(n): for j in range(i+1,n): sp = min(abs(j-i), abs(x-i)+abs(j-y)+1, abs(y-i)+1+abs(j-x)) ans[sp]+=1 for a in ans[1:]: print(a)
n,x,y = list(map(int,input().split())) x,y = x-1,y-1 ans = [0]*(n) for i in range(n): for j in range(i+1,n): sp = min(abs(j-i), abs(x-i)+abs(j-y)+1) ans[sp]+=1 for a in ans[1:]: print(a)
11
11
233
212
n, x, y = list(map(int, input().split())) x, y = x - 1, y - 1 ans = [0] * (n) for i in range(n): for j in range(i + 1, n): sp = min(abs(j - i), abs(x - i) + abs(j - y) + 1, abs(y - i) + 1 + abs(j - x)) ans[sp] += 1 for a in ans[1:]: print(a)
n, x, y = list(map(int, input().split())) x, y = x - 1, y - 1 ans = [0] * (n) for i in range(n): for j in range(i + 1, n): sp = min(abs(j - i), abs(x - i) + abs(j - y) + 1) ans[sp] += 1 for a in ans[1:]: print(a)
false
0
[ "- sp = min(abs(j - i), abs(x - i) + abs(j - y) + 1, abs(y - i) + 1 + abs(j - x))", "+ sp = min(abs(j - i), abs(x - i) + abs(j - y) + 1)" ]
false
0.034547
0.036683
0.94178
[ "s266495345", "s041557358" ]
u724687935
p02548
python
s823696459
s031682437
340
179
148,076
9,140
Accepted
Accepted
47.35
from bisect import bisect_right N = int(eval(input())) num = [i for i in range(1, N)] cnt = 0 for a in range(1, N): n = (N - 1) // a b = bisect_right(num, n) cnt += b print(cnt)
N = int(eval(input())) cnt = 0 for a in range(1, N): n = (N - 1) // a cnt += n print(cnt)
11
7
196
99
from bisect import bisect_right N = int(eval(input())) num = [i for i in range(1, N)] cnt = 0 for a in range(1, N): n = (N - 1) // a b = bisect_right(num, n) cnt += b print(cnt)
N = int(eval(input())) cnt = 0 for a in range(1, N): n = (N - 1) // a cnt += n print(cnt)
false
36.363636
[ "-from bisect import bisect_right", "-", "-num = [i for i in range(1, N)]", "- b = bisect_right(num, n)", "- cnt += b", "+ cnt += n" ]
false
0.228035
0.079758
2.859078
[ "s823696459", "s031682437" ]
u693378622
p02726
python
s374457752
s495775300
1,250
233
3,188
43,244
Accepted
Accepted
81.36
n, x, y = list(map(int, input().split())) x -= 1 y -= 1 ans = [0] * n for j in range(n): for i in range(j): d = min(j-i, abs(x-i)+1+abs(j-y)) ans[d] += 1 print(( "\n".join( [str(d) for d in ans[1:]] )))
n,x,y = list(map(int, input().split())) x -= 1 y -= 1 ans = [0] * (n-1) for j in range(n): for i in range(j): ans[min(j-i, abs(x-i)+1+abs(j-y)) - 1] += 1 print(("\n".join([str(d) for d in ans])))
12
11
219
206
n, x, y = list(map(int, input().split())) x -= 1 y -= 1 ans = [0] * n for j in range(n): for i in range(j): d = min(j - i, abs(x - i) + 1 + abs(j - y)) ans[d] += 1 print(("\n".join([str(d) for d in ans[1:]])))
n, x, y = list(map(int, input().split())) x -= 1 y -= 1 ans = [0] * (n - 1) for j in range(n): for i in range(j): ans[min(j - i, abs(x - i) + 1 + abs(j - y)) - 1] += 1 print(("\n".join([str(d) for d in ans])))
false
8.333333
[ "-ans = [0] * n", "+ans = [0] * (n - 1)", "- d = min(j - i, abs(x - i) + 1 + abs(j - y))", "- ans[d] += 1", "-print((\"\\n\".join([str(d) for d in ans[1:]])))", "+ ans[min(j - i, abs(x - i) + 1 + abs(j - y)) - 1] += 1", "+print((\"\\n\".join([str(d) for d in ans])))" ]
false
0.037734
0.038782
0.972964
[ "s374457752", "s495775300" ]
u693378622
p02803
python
s394480862
s496566622
501
248
32,352
18,760
Accepted
Accepted
50.5
H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] N = W * H E = [[0] * N for _ in range(N)] dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] for i in range(H): for j in range(W): if S[i][j] == ".": for di, dj in dij: ni, nj = i + di, j + dj ...
INF = float("inf") H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] N = W * H E = [[INF] * N for _ in range(N)] dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] for i in range(H): for j in range(W): if S[i][j] == ".": for di, dj in dij: ni, ...
21
23
586
611
H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] N = W * H E = [[0] * N for _ in range(N)] dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] for i in range(H): for j in range(W): if S[i][j] == ".": for di, dj in dij: ni, nj = i + di, j + dj if 0...
INF = float("inf") H, W = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] N = W * H E = [[INF] * N for _ in range(N)] dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] for i in range(H): for j in range(W): if S[i][j] == ".": for di, dj in dij: ni, nj = i + di, j + dj...
false
8.695652
[ "+INF = float(\"inf\")", "-E = [[0] * N for _ in range(N)]", "+E = [[INF] * N for _ in range(N)]" ]
false
0.243995
0.159948
1.525461
[ "s394480862", "s496566622" ]
u844646164
p02883
python
s121789705
s545716729
604
332
121,164
113,648
Accepted
Accepted
45.03
N, K = list(map(int, input().split())) A = list(map(int, input().split())) F = list(map(int, input().split())) A = sorted(A) F = sorted(F, reverse=True) l = -1 # 絶対にfalse r = 10**12+5 while (l+1<r): c = (l+r)//2 s = 0 for i in range(N): s += max(0, A[i]-(c//F[i])) if s <= K: r = c el...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) F = list(map(int, input().split())) A = sorted(A) F = sorted(F, reverse=True) l = -1 r = 10**12+5 while (l+1<r): c = (l+r)//2 tmp = 0 for i in range(N): tmp += max(0, A[i]-(c//F[i])) if tmp <= K: r = c e...
20
22
340
341
N, K = list(map(int, input().split())) A = list(map(int, input().split())) F = list(map(int, input().split())) A = sorted(A) F = sorted(F, reverse=True) l = -1 # 絶対にfalse r = 10**12 + 5 while l + 1 < r: c = (l + r) // 2 s = 0 for i in range(N): s += max(0, A[i] - (c // F[i])) if s <= K: ...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) F = list(map(int, input().split())) A = sorted(A) F = sorted(F, reverse=True) l = -1 r = 10**12 + 5 while l + 1 < r: c = (l + r) // 2 tmp = 0 for i in range(N): tmp += max(0, A[i] - (c // F[i])) if tmp <= K: r = c...
false
9.090909
[ "-l = -1 # 絶対にfalse", "+l = -1", "- s = 0", "+ tmp = 0", "- s += max(0, A[i] - (c // F[i]))", "- if s <= K:", "+ tmp += max(0, A[i] - (c // F[i]))", "+ if tmp <= K:" ]
false
0.078708
0.065988
1.192762
[ "s121789705", "s545716729" ]
u074220993
p03456
python
s950582769
s085117699
116
29
27,012
8,988
Accepted
Accepted
75
import numpy as np n = np.sqrt(int(''.join(input().split()))) print(('Yes' if n == int(n) else 'No'))
from math import sqrt a, b = input().split() n = int(a+b) print(('Yes' if sqrt(n) == int(sqrt(n)) else 'No'))
3
4
101
111
import numpy as np n = np.sqrt(int("".join(input().split()))) print(("Yes" if n == int(n) else "No"))
from math import sqrt a, b = input().split() n = int(a + b) print(("Yes" if sqrt(n) == int(sqrt(n)) else "No"))
false
25
[ "-import numpy as np", "+from math import sqrt", "-n = np.sqrt(int(\"\".join(input().split())))", "-print((\"Yes\" if n == int(n) else \"No\"))", "+a, b = input().split()", "+n = int(a + b)", "+print((\"Yes\" if sqrt(n) == int(sqrt(n)) else \"No\"))" ]
false
0.66042
0.035094
18.818747
[ "s950582769", "s085117699" ]
u440566786
p02574
python
s344771380
s479739018
439
359
191,040
191,508
Accepted
Accepted
18.22
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() # https://qiita.com/Kiri8128/items/eca965fe86ea5f4cbb98 def isPrimeMR(n): d = n - 1 d = d // (d & -d) L = [2] for a in L: t = d y = pow(a, t, ...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() from functools import reduce from math import gcd def resolve(): n = int(eval(input())) A = list(map(int, input().split())) if reduce(gcd, A) != 1: print("...
95
39
2,460
932
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda: sys.stdin.readline().rstrip() # https://qiita.com/Kiri8128/items/eca965fe86ea5f4cbb98 def isPrimeMR(n): d = n - 1 d = d // (d & -d) L = [2] for a in L: t = d y = pow(a, t, n) ...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda: sys.stdin.readline().rstrip() from functools import reduce from math import gcd def resolve(): n = int(eval(input())) A = list(map(int, input().split())) if reduce(gcd, A) != 1: print("not copr...
false
58.947368
[ "-# https://qiita.com/Kiri8128/items/eca965fe86ea5f4cbb98", "-def isPrimeMR(n):", "- d = n - 1", "- d = d // (d & -d)", "- L = [2]", "- for a in L:", "- t = d", "- y = pow(a, t, n)", "- if y == 1:", "- continue", "- while y != n - 1:", "- ...
false
0.14932
0.047699
3.130435
[ "s344771380", "s479739018" ]
u475077336
p03338
python
s682132143
s237685655
32
19
3,444
3,316
Accepted
Accepted
40.62
from collections import OrderedDict # Function to remove all duplicates from string # and order does not matter def removeDupWithoutOrder(str): # set() --> A Set is an unordered collection # data type that is iterable, mutable, # and has no duplicate elements. ...
n = int(eval(input())) s = eval(input()) answer = 0 for i in range(1,n): a = s[:i] b = s[i:] oset = set() oset = set(a) & set(b) answer = max(answer, len(oset)) print(answer)
39
10
1,152
191
from collections import OrderedDict # Function to remove all duplicates from string # and order does not matter def removeDupWithoutOrder(str): # set() --> A Set is an unordered collection # data type that is iterable, mutable, # and has no duplicate elements. # "".join() --> It j...
n = int(eval(input())) s = eval(input()) answer = 0 for i in range(1, n): a = s[:i] b = s[i:] oset = set() oset = set(a) & set(b) answer = max(answer, len(oset)) print(answer)
false
74.358974
[ "-from collections import OrderedDict", "-", "-# Function to remove all duplicates from string", "-# and order does not matter", "-def removeDupWithoutOrder(str):", "- # set() --> A Set is an unordered collection", "- # data type that is iterable, mutable,", "- # and has...
false
0.038239
0.043843
0.872178
[ "s682132143", "s237685655" ]
u729133443
p03723
python
s455905707
s389282429
169
30
39,888
9,068
Accepted
Accepted
82.25
a,b,c=list(map(int,input().split())) if a==b==c: print((-(a%2<1))) else: s=0 while a%2<1and b%2<1and c%2<1: a,b,c=(b+c)//2,(c+a)//2,(a+b)//2 s+=1 print(s)
a,b,c=list(map(int,input().split())) e=a-b|b-c print(((e!=b%2)*(e^e-1).bit_length()-1))
9
3
170
81
a, b, c = list(map(int, input().split())) if a == b == c: print((-(a % 2 < 1))) else: s = 0 while a % 2 < 1 and b % 2 < 1 and c % 2 < 1: a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2 s += 1 print(s)
a, b, c = list(map(int, input().split())) e = a - b | b - c print(((e != b % 2) * (e ^ e - 1).bit_length() - 1))
false
66.666667
[ "-if a == b == c:", "- print((-(a % 2 < 1)))", "-else:", "- s = 0", "- while a % 2 < 1 and b % 2 < 1 and c % 2 < 1:", "- a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2", "- s += 1", "- print(s)", "+e = a - b | b - c", "+print(((e != b % 2) * (e ^ e - 1).bit_length() -...
false
0.041985
0.044238
0.949067
[ "s455905707", "s389282429" ]
u941438707
p03031
python
s794392677
s020498956
41
30
3,064
3,060
Accepted
Accepted
26.83
n,m=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(m)] p=list(map(int,input().split())) ans=0 for i in range(2**n): b=0 for j in range(m): a=0 for k in s[j][1:]: if (i>>(k-1))&1: a+=1 if a%2==p[j]: a+=1...
n,m=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(m)] *p,=list(map(int,input().split())) a=0 for i in range(2**n): a+=all(sum((i>>(k-1))&1 for k in s[j][1:])%2==p[j] for j in range(m)) print(a)
17
7
382
225
n, m = list(map(int, input().split())) s = [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) ans = 0 for i in range(2**n): b = 0 for j in range(m): a = 0 for k in s[j][1:]: if (i >> (k - 1)) & 1: a += 1 if a % 2 == p[j]: ...
n, m = list(map(int, input().split())) s = [list(map(int, input().split())) for _ in range(m)] (*p,) = list(map(int, input().split())) a = 0 for i in range(2**n): a += all(sum((i >> (k - 1)) & 1 for k in s[j][1:]) % 2 == p[j] for j in range(m)) print(a)
false
58.823529
[ "-p = list(map(int, input().split()))", "-ans = 0", "+(*p,) = list(map(int, input().split()))", "+a = 0", "- b = 0", "- for j in range(m):", "- a = 0", "- for k in s[j][1:]:", "- if (i >> (k - 1)) & 1:", "- a += 1", "- if a % 2 == p[j]:", "-...
false
0.036135
0.036428
0.991977
[ "s794392677", "s020498956" ]
u389910364
p02991
python
s866103901
s477533319
851
712
87,468
76,408
Accepted
Accepted
16.33
import heapq import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10 ** 18 N, M = list(map(int, sys.stdin.readline().split())) UV = [list(map(int, sys.stdin.readline().split())) for _ in range(M)] S, T = list(map(int...
import heapq import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10 ** 18 N, M = list(map(int, sys.stdin.readline().split())) VU = [list(map(int, sys.stdin.readline().split())) for _ in range(M)] S, T = list(map(int...
46
35
1,088
856
import heapq import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10**18 N, M = list(map(int, sys.stdin.readline().split())) UV = [list(map(int, sys.stdin.readline().split())) for _ in range(M)] S, T = list(map(int, sys.stdin.readl...
import heapq import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10**18 N, M = list(map(int, sys.stdin.readline().split())) VU = [list(map(int, sys.stdin.readline().split())) for _ in range(M)] S, T = list(map(int, sys.stdin.readl...
false
23.913043
[ "-UV = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]", "+VU = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]", "-U = []", "-V = []", "-for u, v in UV:", "- U.extend([u, u + N, u + N * 2])", "- V.extend([v + N, v + N * 2, v])", "-# graph = csr_matrix(([1] * (M...
false
0.038935
0.083748
0.464904
[ "s866103901", "s477533319" ]
u573754721
p03073
python
s105223544
s342856259
50
18
3,188
3,188
Accepted
Accepted
64
s=eval(input()) a=0 for i in range(len(s)): if i%2==0: if s[i]=="0": a+=1 elif s[i]=="1": a+=1 print((min(a,len(s)-a)))
s=eval(input()) a=s[::2].count("0") b=s[1::2].count("1") a=a+b print((min(a,len(s)-a)))
9
5
173
83
s = eval(input()) a = 0 for i in range(len(s)): if i % 2 == 0: if s[i] == "0": a += 1 elif s[i] == "1": a += 1 print((min(a, len(s) - a)))
s = eval(input()) a = s[::2].count("0") b = s[1::2].count("1") a = a + b print((min(a, len(s) - a)))
false
44.444444
[ "-a = 0", "-for i in range(len(s)):", "- if i % 2 == 0:", "- if s[i] == \"0\":", "- a += 1", "- elif s[i] == \"1\":", "- a += 1", "+a = s[::2].count(\"0\")", "+b = s[1::2].count(\"1\")", "+a = a + b" ]
false
0.038627
0.008077
4.782312
[ "s105223544", "s342856259" ]
u119148115
p02552
python
s685530510
s727549752
75
68
61,692
61,776
Accepted
Accepted
9.33
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
import sys def I(): return int(sys.stdin.readline().rstrip()) print((1-I()))
13
5
505
81
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
import sys def I(): return int(sys.stdin.readline().rstrip()) print((1 - I()))
false
61.538462
[ "-", "-sys.setrecursionlimit(10**7)", "-def MI():", "- return list(map(int, sys.stdin.readline().rstrip().split()))", "-", "-", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-def LI2():", "- return list(map(int, sys.stdin.readline()...
false
0.049075
0.047308
1.037352
[ "s685530510", "s727549752" ]
u767995501
p02952
python
s927225320
s434683117
55
43
2,940
2,940
Accepted
Accepted
21.82
n = int(eval(input())) ans = 0 for i in range(1,n+1): if len(str(i)) & 1: ans += 1 print(ans)
N = int(eval(input())) answer = sum(len(str(i))&1 for i in range(1,N+1)) print(answer)
7
4
106
84
n = int(eval(input())) ans = 0 for i in range(1, n + 1): if len(str(i)) & 1: ans += 1 print(ans)
N = int(eval(input())) answer = sum(len(str(i)) & 1 for i in range(1, N + 1)) print(answer)
false
42.857143
[ "-n = int(eval(input()))", "-ans = 0", "-for i in range(1, n + 1):", "- if len(str(i)) & 1:", "- ans += 1", "-print(ans)", "+N = int(eval(input()))", "+answer = sum(len(str(i)) & 1 for i in range(1, N + 1))", "+print(answer)" ]
false
0.055339
0.183433
0.301687
[ "s927225320", "s434683117" ]
u780475861
p03276
python
s485437576
s102200757
64
57
14,052
14,052
Accepted
Accepted
10.94
import bisect def main(): n, k, *lst = list(map(int, open(0).read().split())) z = bisect.bisect_left(lst, 0) if not z: print((lst[k - 1])) elif z >= n - 1: print((-lst[-k])) else: res = float('inf') for i in range(max(z - k + 1, 0), min(z, n - k) + 1): tmp = lst[i + k - 1] -...
import bisect def main(): n, k, *lst = list(map(int, open(0).read().split())) z = bisect.bisect_left(lst, 0) if not z: print((lst[k - 1])) elif z >= n - 1: print((-lst[-k])) else: idx = max(z - k + 1, 0) print((min(min(abs(i), j) + j - i for i, j in zip(lst[idx:], lst[idx + k - 1:]...
19
15
448
352
import bisect def main(): n, k, *lst = list(map(int, open(0).read().split())) z = bisect.bisect_left(lst, 0) if not z: print((lst[k - 1])) elif z >= n - 1: print((-lst[-k])) else: res = float("inf") for i in range(max(z - k + 1, 0), min(z, n - k) + 1): t...
import bisect def main(): n, k, *lst = list(map(int, open(0).read().split())) z = bisect.bisect_left(lst, 0) if not z: print((lst[k - 1])) elif z >= n - 1: print((-lst[-k])) else: idx = max(z - k + 1, 0) print( (min(min(abs(i), j) + j - i for i, j in zip...
false
21.052632
[ "- res = float(\"inf\")", "- for i in range(max(z - k + 1, 0), min(z, n - k) + 1):", "- tmp = lst[i + k - 1] - lst[i] + min(abs(lst[i]), lst[i + k - 1])", "- if tmp < res:", "- res = tmp", "- print(res)", "+ idx = max(z - k + 1, 0)", "+ ...
false
0.040522
0.042786
0.947076
[ "s485437576", "s102200757" ]
u646412443
p02725
python
s537542978
s136262957
170
150
26,444
26,444
Accepted
Accepted
11.76
# -*- coding: utf-8 -*- k, n = list(map(int,input().split())) a = [int(i) for i in input().split()] a.append(k + a[0]) l = 0 for i in range(n): l = max(l, a[i + 1] - a[i]) ans = k - l print(ans)
k, n = list(map(int, input().split())) a = list(map(int, input().split())) a.append(k + a[0]) dist = 0 for i in range(n): dist = max(dist, a[i + 1] - a[i]) print((k - dist))
9
7
201
176
# -*- coding: utf-8 -*- k, n = list(map(int, input().split())) a = [int(i) for i in input().split()] a.append(k + a[0]) l = 0 for i in range(n): l = max(l, a[i + 1] - a[i]) ans = k - l print(ans)
k, n = list(map(int, input().split())) a = list(map(int, input().split())) a.append(k + a[0]) dist = 0 for i in range(n): dist = max(dist, a[i + 1] - a[i]) print((k - dist))
false
22.222222
[ "-# -*- coding: utf-8 -*-", "-a = [int(i) for i in input().split()]", "+a = list(map(int, input().split()))", "-l = 0", "+dist = 0", "- l = max(l, a[i + 1] - a[i])", "-ans = k - l", "-print(ans)", "+ dist = max(dist, a[i + 1] - a[i])", "+print((k - dist))" ]
false
0.046849
0.070543
0.664122
[ "s537542978", "s136262957" ]
u279493135
p02925
python
s579927429
s633166690
1,940
946
207,024
133,720
Accepted
Accepted
51.24
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upp...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upp...
79
64
1,973
1,611
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase...
false
18.987342
[ "- graph_out = defaultdict(list)", "- graph_in = defaultdict(list)", "- gin = [[] for _ in range(V)]", "- gin[toid(i, A[i][j + 1] - 1)].append(toid(i, A[i][j] - 1))", "- # トポロジカルソート", "- ans = [v for v in range(V) if deg[v] == 0]", "- deq = deque(ans)", "- used = [0] * ...
false
0.045528
0.049041
0.928363
[ "s579927429", "s633166690" ]
u600402037
p02888
python
s136582700
s533517672
883
213
3,188
41,452
Accepted
Accepted
75.88
N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N-1, 1, -1): # iは辺の最大値 s = 0 # aは1番短い辺 l = i-1 while l > s: if L[s] + L[l] > L[i]: answer += l - s l -= 1 else: s += 1 print(answer)
N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N-1, 1, -1): # iは辺の最大値 s = 0 # sは1番短い辺 l = i-1 while l > s: if L[s] + L[l] > L[i]: answer += l - s l -= 1 else: s += 1 print(answer)
14
14
298
298
N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N - 1, 1, -1): # iは辺の最大値 s = 0 # aは1番短い辺 l = i - 1 while l > s: if L[s] + L[l] > L[i]: answer += l - s l -= 1 else: s += 1 print(answer)
N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N - 1, 1, -1): # iは辺の最大値 s = 0 # sは1番短い辺 l = i - 1 while l > s: if L[s] + L[l] > L[i]: answer += l - s l -= 1 else: s += 1 print(answer)
false
0
[ "- s = 0 # aは1番短い辺", "+ s = 0 # sは1番短い辺" ]
false
0.035156
0.038048
0.923976
[ "s136582700", "s533517672" ]
u279605379
p02242
python
s204881959
s139255315
40
30
6,228
5,952
Accepted
Accepted
25
from collections import deque import sys import heapq n = int(eval(input())) V = [[int(i) for i in input().split()] for _ in range(n)] dis = [sys.maxsize for _ in range(n)] dis[0] = 0 h = [] for i in range(n): heapq.heappush(h,(dis[i],i)) while(len(h)>0): node = heapq.heappop(h) tmp = node[1] ...
import sys import heapq n = int(eval(input())) V = [[int(i) for i in input().split()] for _ in range(n)] dis = [sys.maxsize for _ in range(n)] dis[0] = 0 h = [] for i in range(n): heapq.heappush(h,(dis[i],i)) while(len(h)>0): node = heapq.heappop(h) tmp = node[1] for i in range(V[tmp][1]): ...
21
20
570
539
from collections import deque import sys import heapq n = int(eval(input())) V = [[int(i) for i in input().split()] for _ in range(n)] dis = [sys.maxsize for _ in range(n)] dis[0] = 0 h = [] for i in range(n): heapq.heappush(h, (dis[i], i)) while len(h) > 0: node = heapq.heappop(h) tmp = node[1] for i ...
import sys import heapq n = int(eval(input())) V = [[int(i) for i in input().split()] for _ in range(n)] dis = [sys.maxsize for _ in range(n)] dis[0] = 0 h = [] for i in range(n): heapq.heappush(h, (dis[i], i)) while len(h) > 0: node = heapq.heappop(h) tmp = node[1] for i in range(V[tmp][1]): i...
false
4.761905
[ "-from collections import deque" ]
false
0.11503
0.039953
2.879128
[ "s204881959", "s139255315" ]
u994988729
p03724
python
s575129437
s525931194
639
343
15,176
5,620
Accepted
Accepted
46.32
import numpy as np import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, m = list(map(int, readline().split())) edge = np.zeros(n, dtype=int) for _ in range(m): a, b = list(map(int, readline().split())) ...
N, M = list(map(int, input().split())) # 木だったらなんでもOK? # いもす法 edge = [0] * (N + 1) for _ in range(M): a, b = list(map(int, input().split())) edge[a] += 1 edge[b] -= 1 ans = "YES" for i in range(N): edge[i + 1] += edge[i] if edge[i + 1] % 2 == 1: ans = "NO" break pr...
22
18
463
317
import numpy as np import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) n, m = list(map(int, readline().split())) edge = np.zeros(n, dtype=int) for _ in range(m): a, b = list(map(int, readline().split())) edge[a - 1] +=...
N, M = list(map(int, input().split())) # 木だったらなんでもOK? # いもす法 edge = [0] * (N + 1) for _ in range(M): a, b = list(map(int, input().split())) edge[a] += 1 edge[b] -= 1 ans = "YES" for i in range(N): edge[i + 1] += edge[i] if edge[i + 1] % 2 == 1: ans = "NO" break print(ans)
false
18.181818
[ "-import numpy as np", "-import sys", "-", "-read = sys.stdin.buffer.read", "-readline = sys.stdin.buffer.readline", "-readlines = sys.stdin.buffer.readlines", "-sys.setrecursionlimit(10**7)", "-n, m = list(map(int, readline().split()))", "-edge = np.zeros(n, dtype=int)", "-for _ in range(m):", ...
false
0.303747
0.042182
7.200886
[ "s575129437", "s525931194" ]
u869154953
p03631
python
s219003120
s648194273
29
25
8,908
8,960
Accepted
Accepted
13.79
N=eval(input()) if N==N[::-1]: print("Yes") else: print("No")
N=eval(input()) if N[0]==N[2]: print("Yes") else: print("No")
6
6
63
64
N = eval(input()) if N == N[::-1]: print("Yes") else: print("No")
N = eval(input()) if N[0] == N[2]: print("Yes") else: print("No")
false
0
[ "-if N == N[::-1]:", "+if N[0] == N[2]:" ]
false
0.043184
0.046358
0.931526
[ "s219003120", "s648194273" ]
u666415539
p02928
python
s351688322
s508695738
1,082
760
3,188
3,188
Accepted
Accepted
29.76
N,K=list(map(int,input().split())) a=list(map(int,input().split())) tentou1=0 for i in range(N): for j in range(i+1,N): if(a[i]>a[j]): tentou1+=1 stentou=0 for i in range(N): for j in range(N): if(a[i]>a[j]): stentou+=1 answer=int(tentou1*K + stentou*K*(K-1)//int(2)) print((answe...
N,K=list(map(int,input().split())) a=list(map(int,input().split())) tentou1=0 for i in range(len(a)): for j in range(i+1,len(a)): if(a[i]>a[j]): tentou1+=1 a.sort() a.reverse() stentou=0 for i in range(len(a)): for j in range(i+1,len(a)): if(a[i]>a[j]): stentou+=1 answer=int(tent...
15
17
327
373
N, K = list(map(int, input().split())) a = list(map(int, input().split())) tentou1 = 0 for i in range(N): for j in range(i + 1, N): if a[i] > a[j]: tentou1 += 1 stentou = 0 for i in range(N): for j in range(N): if a[i] > a[j]: stentou += 1 answer = int(tentou1 * K + stent...
N, K = list(map(int, input().split())) a = list(map(int, input().split())) tentou1 = 0 for i in range(len(a)): for j in range(i + 1, len(a)): if a[i] > a[j]: tentou1 += 1 a.sort() a.reverse() stentou = 0 for i in range(len(a)): for j in range(i + 1, len(a)): if a[i] > a[j]: ...
false
11.764706
[ "-for i in range(N):", "- for j in range(i + 1, N):", "+for i in range(len(a)):", "+ for j in range(i + 1, len(a)):", "+a.sort()", "+a.reverse()", "-for i in range(N):", "- for j in range(N):", "+for i in range(len(a)):", "+ for j in range(i + 1, len(a)):", "-answer = int(tentou1 * K...
false
0.044065
0.044548
0.989169
[ "s351688322", "s508695738" ]
u553987207
p02701
python
s609094646
s857094398
295
113
31,072
30,972
Accepted
Accepted
61.69
N = int(eval(input())) x = set() for _ in range(N): s = eval(input()) x.add(s) print((len(x)))
import sys N = int(eval(input())) x = set() for _ in range(N): s = sys.stdin.readline() x.add(s) print((len(x)))
6
7
93
118
N = int(eval(input())) x = set() for _ in range(N): s = eval(input()) x.add(s) print((len(x)))
import sys N = int(eval(input())) x = set() for _ in range(N): s = sys.stdin.readline() x.add(s) print((len(x)))
false
14.285714
[ "+import sys", "+", "- s = eval(input())", "+ s = sys.stdin.readline()" ]
false
0.036189
0.036428
0.993454
[ "s609094646", "s857094398" ]
u230621983
p03993
python
s677642415
s891281979
144
69
21,940
14,068
Accepted
Accepted
52.08
n, *a_l= list(map(int, open(0).read().split())) lovedBy = [[] for _ in range(n)] for i, a in enumerate(a_l): lovedBy[a-1].append(i) cnt = 0 for i, a in enumerate(a_l): if a-1 in lovedBy[i]: cnt += 1 print((cnt//2))
n, *a_l= list(map(int, open(0).read().split())) cnt = 0 for i, a in enumerate(a_l): if a_l[a-1] == i+1: cnt += 1 print((cnt//2))
9
6
230
137
n, *a_l = list(map(int, open(0).read().split())) lovedBy = [[] for _ in range(n)] for i, a in enumerate(a_l): lovedBy[a - 1].append(i) cnt = 0 for i, a in enumerate(a_l): if a - 1 in lovedBy[i]: cnt += 1 print((cnt // 2))
n, *a_l = list(map(int, open(0).read().split())) cnt = 0 for i, a in enumerate(a_l): if a_l[a - 1] == i + 1: cnt += 1 print((cnt // 2))
false
33.333333
[ "-lovedBy = [[] for _ in range(n)]", "-for i, a in enumerate(a_l):", "- lovedBy[a - 1].append(i)", "- if a - 1 in lovedBy[i]:", "+ if a_l[a - 1] == i + 1:" ]
false
0.037197
0.035089
1.060068
[ "s677642415", "s891281979" ]
u638902622
p03127
python
s503728291
s541302811
139
65
14,224
14,596
Accepted
Accepted
53.24
import sys IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) def main(): n = II() a_lst = sorted(MII(), reverse=True) while True: minv = a_lst[-1] a_lst = [a%minv for a in a_lst[:-1] if a%minv != 0] a_lst.append(m...
""" keywords: 最大公約数、ユークリッドの互除法 """ import sys IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) from functools import reduce def gcd(a, b): while b: a, b = b, a%b return a def main(): n = II() a_lst = MII() print((...
18
21
457
381
import sys IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) def main(): n = II() a_lst = sorted(MII(), reverse=True) while True: minv = a_lst[-1] a_lst = [a % minv for a in a_lst[:-1] if a % minv != 0] a_lst.append(minv) ...
""" keywords: 最大公約数、ユークリッドの互除法 """ import sys IS = lambda: sys.stdin.readline().rstrip() II = lambda: int(IS()) MII = lambda: list(map(int, IS().split())) from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def main(): n = II() a_lst = MII() print((reduce(gcd, ...
false
14.285714
[ "+\"\"\"", "+keywords: 最大公約数、ユークリッドの互除法", "+\"\"\"", "+from functools import reduce", "+", "+", "+def gcd(a, b):", "+ while b:", "+ a, b = b, a % b", "+ return a", "- a_lst = sorted(MII(), reverse=True)", "- while True:", "- minv = a_lst[-1]", "- a_lst = [a...
false
0.093621
0.068245
1.371836
[ "s503728291", "s541302811" ]
u812576525
p03379
python
s864621927
s094781138
349
315
25,472
25,220
Accepted
Accepted
9.74
N = int(eval(input())) A = list(map(int,input().split())) X = sorted(A,reverse=False) for i in range(N): if A[i] < X[N//2 ]: print((X[N//2 ])) else: print((X[N//2 - 1]))
N = int(eval(input())) A = list(map(int,input().split())) B = sorted(A) X = B[N//2-1] Y = B[N//2] for i in range(N): if A[i] <= X: print(Y) else: print(X)
9
12
193
186
N = int(eval(input())) A = list(map(int, input().split())) X = sorted(A, reverse=False) for i in range(N): if A[i] < X[N // 2]: print((X[N // 2])) else: print((X[N // 2 - 1]))
N = int(eval(input())) A = list(map(int, input().split())) B = sorted(A) X = B[N // 2 - 1] Y = B[N // 2] for i in range(N): if A[i] <= X: print(Y) else: print(X)
false
25
[ "-X = sorted(A, reverse=False)", "+B = sorted(A)", "+X = B[N // 2 - 1]", "+Y = B[N // 2]", "- if A[i] < X[N // 2]:", "- print((X[N // 2]))", "+ if A[i] <= X:", "+ print(Y)", "- print((X[N // 2 - 1]))", "+ print(X)" ]
false
0.046469
0.048813
0.951985
[ "s864621927", "s094781138" ]
u200887663
p02899
python
s129168209
s133465836
157
86
24,796
15,588
Accepted
Accepted
45.22
n=int(input()) al=list(map(int,input().split())) d={} for i in range(n): d[al[i]]=i+1 l=[] for k,v in sorted(d.items()): l.append(v) print(*l,sep=" ")
n=int(eval(input())) al=list(map(int,input().split())) l=[0 for i in range(n)] for i in range(n): l[al[i]-1]=str(i+1) print((" ".join(l)))
12
6
171
140
n = int(input()) al = list(map(int, input().split())) d = {} for i in range(n): d[al[i]] = i + 1 l = [] for k, v in sorted(d.items()): l.append(v) print(*l, sep=" ")
n = int(eval(input())) al = list(map(int, input().split())) l = [0 for i in range(n)] for i in range(n): l[al[i] - 1] = str(i + 1) print((" ".join(l)))
false
50
[ "-n = int(input())", "+n = int(eval(input()))", "-d = {}", "+l = [0 for i in range(n)]", "- d[al[i]] = i + 1", "-l = []", "-for k, v in sorted(d.items()):", "- l.append(v)", "-print(*l, sep=\" \")", "+ l[al[i] - 1] = str(i + 1)", "+print((\" \".join(l)))" ]
false
0.031265
0.053631
0.582959
[ "s129168209", "s133465836" ]
u683406607
p02854
python
s949062536
s599804162
447
182
36,252
26,060
Accepted
Accepted
59.28
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) cum = np.cumsum(a) mid = cum[-1]/2 diff = 10**10 for each in cum: diff = min(diff, abs(mid-each)) print((int(diff/0.5)))
n = int(eval(input())) a = list(map(int, input().split())) mid = sum(a)/2 cum = 0 diff = 10**10 for each in a: cum += each diff = min(diff, abs(mid-cum)) print((int(diff/0.5)))
12
11
208
186
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) cum = np.cumsum(a) mid = cum[-1] / 2 diff = 10**10 for each in cum: diff = min(diff, abs(mid - each)) print((int(diff / 0.5)))
n = int(eval(input())) a = list(map(int, input().split())) mid = sum(a) / 2 cum = 0 diff = 10**10 for each in a: cum += each diff = min(diff, abs(mid - cum)) print((int(diff / 0.5)))
false
8.333333
[ "-import numpy as np", "-", "-cum = np.cumsum(a)", "-mid = cum[-1] / 2", "+mid = sum(a) / 2", "+cum = 0", "-for each in cum:", "- diff = min(diff, abs(mid - each))", "+for each in a:", "+ cum += each", "+ diff = min(diff, abs(mid - cum))" ]
false
0.496349
0.048635
10.20559
[ "s949062536", "s599804162" ]
u633068244
p00631
python
s059795119
s265165843
2,210
70
25,716
4,248
Accepted
Accepted
96.83
while 1: n = eval(input()) if n == 0: break a = sorted(map(int,input().split()))[::-1] s = sum(a) L = [0] for i in a: L += [i+j for j in L if j < s/2] print(min(abs(s-2*i) for i in L))
def S(a,i,x,y): if 2*x >= A: return 2*x-A if 2*y >= A: return 2*y-A return min(S(a,i+1,x+a[i],y),S(a,i+1,x,y+a[i])) while 1: n = eval(input()) if n == 0: break a = sorted(map(int,input().split()))[::-1] A = sum(a) print(S(a,1,a[0],0))
9
10
198
248
while 1: n = eval(input()) if n == 0: break a = sorted(map(int, input().split()))[::-1] s = sum(a) L = [0] for i in a: L += [i + j for j in L if j < s / 2] print(min(abs(s - 2 * i) for i in L))
def S(a, i, x, y): if 2 * x >= A: return 2 * x - A if 2 * y >= A: return 2 * y - A return min(S(a, i + 1, x + a[i], y), S(a, i + 1, x, y + a[i])) while 1: n = eval(input()) if n == 0: break a = sorted(map(int, input().split()))[::-1] A = sum(a) print(S(a, 1, a[0...
false
10
[ "+def S(a, i, x, y):", "+ if 2 * x >= A:", "+ return 2 * x - A", "+ if 2 * y >= A:", "+ return 2 * y - A", "+ return min(S(a, i + 1, x + a[i], y), S(a, i + 1, x, y + a[i]))", "+", "+", "- s = sum(a)", "- L = [0]", "- for i in a:", "- L += [i + j for j in ...
false
0.073715
0.034143
2.159032
[ "s059795119", "s265165843" ]
u372144784
p03164
python
s488755514
s586435190
1,046
435
311,176
120,044
Accepted
Accepted
58.41
n,w = list(map(int,input().split())) dp = [[float("inf")]*(10**5+1) for _ in range(n+1)] dp[0][0] = 0 for i in range(1,n+1): weight,value = list(map(int,input().split())) for j in range(10**5+1): if j < value: dp[i][j] = dp[i-1][j] else: dp[i][j] = min(dp[i-1][...
import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 n,w = list(map(int,readline().split())) WV = [] for i in range(n): WV.append(list(map(int,readline().split()))) dp = [[10**12]*(10**5+1) for _ in range(n+1)] dp[0][0] = 0 #価値j以上で重さがwを満たすようなものの最大値 for i in range(n): ...
19
26
429
540
n, w = list(map(int, input().split())) dp = [[float("inf")] * (10**5 + 1) for _ in range(n + 1)] dp[0][0] = 0 for i in range(1, n + 1): weight, value = list(map(int, input().split())) for j in range(10**5 + 1): if j < value: dp[i][j] = dp[i - 1][j] else: dp[i][j] = min(dp...
import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n % 2 == 0 else 0 n, w = list(map(int, readline().split())) WV = [] for i in range(n): WV.append(list(map(int, readline().split()))) dp = [[10**12] * (10**5 + 1) for _ in range(n + 1)] dp[0][0] = 0 # 価値j以上で重さがwを満たすようなものの最大値 for i in r...
false
26.923077
[ "-n, w = list(map(int, input().split()))", "-dp = [[float(\"inf\")] * (10**5 + 1) for _ in range(n + 1)]", "+import sys", "+", "+readline = sys.stdin.buffer.readline", "+", "+", "+def even(n):", "+ return 1 if n % 2 == 0 else 0", "+", "+", "+n, w = list(map(int, readline().split()))", "+W...
false
0.360491
0.493024
0.731183
[ "s488755514", "s586435190" ]
u588341295
p03354
python
s731071811
s243050034
599
554
14,008
15,968
Accepted
Accepted
7.51
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ...
105
102
2,791
2,845
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in rang...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in rang...
false
2.857143
[ "-INF = float(\"inf\")", "+INF = 10**18", "- def same(self, x, y):", "+ def is_same(self, x, y):", "- def get_size(self, x):", "- \"\"\"あるノードの属する集合のノード数\"\"\"", "- return self.size[self.find(x)]", "+ def get_size(self, x=None):", "+ if x is not None:", "+ ...
false
0.038707
0.04188
0.924242
[ "s731071811", "s243050034" ]
u098012509
p02627
python
s500379755
s620252613
31
25
9,092
9,020
Accepted
Accepted
19.35
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): S = input().strip() if ord('A') <= ord(S[0]) <= ord('Z'): print("A") else: print("a") if __name__ == '__main__': main()
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): S = input().strip() if S.islower(): print("a") else: print("A") if __name__ == '__main__': main()
19
20
259
239
import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline def main(): S = input().strip() if ord("A") <= ord(S[0]) <= ord("Z"): print("A") else: print("a") if __name__ == "__main__": main()
import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline def main(): S = input().strip() if S.islower(): print("a") else: print("A") if __name__ == "__main__": main()
false
5
[ "- if ord(\"A\") <= ord(S[0]) <= ord(\"Z\"):", "+ if S.islower():", "+ print(\"a\")", "+ else:", "- else:", "- print(\"a\")" ]
false
0.042399
0.03554
1.192964
[ "s500379755", "s620252613" ]
u582415761
p03127
python
s141689659
s575667729
213
75
25,008
14,252
Accepted
Accepted
64.79
from sys import stdin import numpy as np #import math as math import fractions as math N = int(stdin.readline()) A = list(map(int,stdin.readline().strip().split())) ans = A[0] for i in range(1,N): ans = math.gcd(ans,A[i]) print(ans)
from sys import stdin def gcd(a, b): while b: a, b = b, a % b return a N = int(stdin.readline()) A = list(map(int,stdin.readline().strip().split())) ans = A[0] for i in range(1,N): ans = gcd(ans,A[i]) print(ans)
14
15
253
250
from sys import stdin import numpy as np # import math as math import fractions as math N = int(stdin.readline()) A = list(map(int, stdin.readline().strip().split())) ans = A[0] for i in range(1, N): ans = math.gcd(ans, A[i]) print(ans)
from sys import stdin def gcd(a, b): while b: a, b = b, a % b return a N = int(stdin.readline()) A = list(map(int, stdin.readline().strip().split())) ans = A[0] for i in range(1, N): ans = gcd(ans, A[i]) print(ans)
false
6.666667
[ "-import numpy as np", "-# import math as math", "-import fractions as math", "+", "+def gcd(a, b):", "+ while b:", "+ a, b = b, a % b", "+ return a", "+", "- ans = math.gcd(ans, A[i])", "+ ans = gcd(ans, A[i])" ]
false
0.045997
0.036166
1.271836
[ "s141689659", "s575667729" ]
u657361950
p02273
python
s416737462
s573586253
40
30
5,724
5,736
Accepted
Accepted
25
import math class Pos: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return str(self.x) + ' ' + str(self.y) def koch_curve(i, n, start, end): if i < n: f = get_pos(start, end, 1/3) t = get_pos(start, end, 2/3) s = get_sec_pos(start, end, f, t) koch_curve(i + 1, n, s...
import math class Point: def __init__(self,x,y): self.x=x self.y=y def __str__(self): return str(self.x)+' '+str(self.y) def koch(n,a,b): if n==0: return s=Point(0,0) t=Point(0,0) u=Point(0,0) th=math.pi*60/180 s.x=(2*a.x+1*b.x)/3 s.y=(2*a.y+1*b.y)/3 t.x=(1*a.x+2*b.x)/3 t.y=(1*a.y+2*...
57
36
1,161
622
import math class Pos: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return str(self.x) + " " + str(self.y) def koch_curve(i, n, start, end): if i < n: f = get_pos(start, end, 1 / 3) t = get_pos(start, end, 2 / 3) s = get_sec_pos(star...
import math class Point: def __init__(self, x, y): self.x = x self.y = y def __str__(self): return str(self.x) + " " + str(self.y) def koch(n, a, b): if n == 0: return s = Point(0, 0) t = Point(0, 0) u = Point(0, 0) th = math.pi * 60 / 180 s.x = (2 * ...
false
36.842105
[ "-class Pos:", "+class Point:", "-def koch_curve(i, n, start, end):", "- if i < n:", "- f = get_pos(start, end, 1 / 3)", "- t = get_pos(start, end, 2 / 3)", "- s = get_sec_pos(start, end, f, t)", "- koch_curve(i + 1, n, start, f)", "- print(f)", "- koch...
false
0.051263
0.05163
0.992896
[ "s416737462", "s573586253" ]
u102461423
p03821
python
s975943061
s802331666
201
150
21,876
27,688
Accepted
Accepted
25.37
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) # 右から N = int(eval(input())) AB = [[int(x) for x in input().split()] for _ in range(N)] push = 0 for a,b in AB[::-1]: a += push push += (-a)%b print(push)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int,read().split())) A,B = list(zip(*list(zip(m,m)))) # 末尾から add = 0 for a,b in zip(A[::-1],B[::-1]): a += add add += (-a) % b print(add)
13
17
239
296
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) # 右から N = int(eval(input())) AB = [[int(x) for x in input().split()] for _ in range(N)] push = 0 for a, b in AB[::-1]: a += push push += (-a) % b print(push)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int, read().split())) A, B = list(zip(*list(zip(m, m)))) # 末尾から add = 0 for a, b in zip(A[::-1], B[::-1]): a += add add += (-a) % b print(add)
false
23.529412
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-# 右から", "-N = int(eval(input()))", "-AB = [[int(x) for x in input().split()] for _ in range(N)]", "-push = 0", "-for a, b in AB[::-1]:", "- a += push", "- push += (-a) % b", "-print(push)", "+read = sys.stdin.buffer.read", ...
false
0.042698
0.041688
1.024206
[ "s975943061", "s802331666" ]
u317779196
p03998
python
s591171523
s168332729
31
25
9,312
8,984
Accepted
Accepted
19.35
from collections import deque a = deque(eval(input())) b = deque(eval(input())) c = deque(eval(input())) i = 0 turn = 'a' while True: if turn == 'a': if len(a) == 0: ans = 'A' break a0 = a.popleft() if a0 == 'a': turn = 'a' elif a0 ...
S = dict() S['a'] = list(eval(input()))[::-1] S['b'] = list(eval(input()))[::-1] S['c'] = list(eval(input()))[::-1] p = 'a' while S[p]: p = S[p].pop() print((p.upper()))
42
9
916
162
from collections import deque a = deque(eval(input())) b = deque(eval(input())) c = deque(eval(input())) i = 0 turn = "a" while True: if turn == "a": if len(a) == 0: ans = "A" break a0 = a.popleft() if a0 == "a": turn = "a" elif a0 == "b": ...
S = dict() S["a"] = list(eval(input()))[::-1] S["b"] = list(eval(input()))[::-1] S["c"] = list(eval(input()))[::-1] p = "a" while S[p]: p = S[p].pop() print((p.upper()))
false
78.571429
[ "-from collections import deque", "-", "-a = deque(eval(input()))", "-b = deque(eval(input()))", "-c = deque(eval(input()))", "-i = 0", "-turn = \"a\"", "-while True:", "- if turn == \"a\":", "- if len(a) == 0:", "- ans = \"A\"", "- break", "- a0 = a.po...
false
0.043386
0.043788
0.990822
[ "s591171523", "s168332729" ]
u954858867
p02412
python
s457428846
s070252348
290
30
6,392
6,444
Accepted
Accepted
89.66
ret = [] while True: n, x = list(map(int, input().split())) num_arr = [i for i in range(1, n+1)] if (n, x) == (0, 0): break cnt = 0 for i in range(n, 0, -1): if x - i <= 2: continue #print "i : %d" % i for j in range(i -1, 0, -1): if x-i-j <=...
ret = [] while True: n, x = list(map(int, input().split())) num_arr = [i for i in range(1, n+1)] if (n, x) == (0, 0): break cnt = 0 for i in range(n, 0, -1): for j in range(i -1, 0, -1): if 0 < x - i - j < j: cnt += 1 ret += [cnt] for i...
26
16
647
339
ret = [] while True: n, x = list(map(int, input().split())) num_arr = [i for i in range(1, n + 1)] if (n, x) == (0, 0): break cnt = 0 for i in range(n, 0, -1): if x - i <= 2: continue # print "i : %d" % i for j in range(i - 1, 0, -1): if x - i ...
ret = [] while True: n, x = list(map(int, input().split())) num_arr = [i for i in range(1, n + 1)] if (n, x) == (0, 0): break cnt = 0 for i in range(n, 0, -1): for j in range(i - 1, 0, -1): if 0 < x - i - j < j: cnt += 1 ret += [cnt] for i in ret: ...
false
38.461538
[ "- if x - i <= 2:", "- continue", "- # print \"i : %d\" % i", "- if x - i - j <= 0:", "- continue", "- # print \"j : %d\" % j", "- for k in range(j - 1, 0, -1):", "- if x - i - j - k < 0:", "- ...
false
0.163171
0.043401
3.759593
[ "s457428846", "s070252348" ]
u046187684
p02660
python
s171142448
s657288702
230
101
20,224
9,424
Accepted
Accepted
56.09
def find_primes(n): ps = [] t = [True] * n t[0] = t[1] = False for i in range(2, n): if not t[i]: continue ps.append(i) for j in range(i, n, i): t[j] = False return ps def solve(string): n = int(string) if n == 1: retu...
import collections n = int(eval(input())) def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n)...
32
41
648
661
def find_primes(n): ps = [] t = [True] * n t[0] = t[1] = False for i in range(2, n): if not t[i]: continue ps.append(i) for j in range(i, n, i): t[j] = False return ps def solve(string): n = int(string) if n == 1: return "0" rn = ...
import collections n = int(eval(input())) def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a ...
false
21.95122
[ "-def find_primes(n):", "- ps = []", "- t = [True] * n", "- t[0] = t[1] = False", "- for i in range(2, n):", "- if not t[i]:", "- continue", "- ps.append(i)", "- for j in range(i, n, i):", "- t[j] = False", "- return ps", "+import colle...
false
0.085063
0.037713
2.255505
[ "s171142448", "s657288702" ]
u440161695
p03107
python
s380665176
s703980325
64
26
4,212
3,444
Accepted
Accepted
59.38
from collections import deque s=deque(eval(input())) N=len(s) A=[] for i in range(N): a=s.popleft() if len(A)!=0: if A[-1]!=a: A.pop() else: A.append(a) else: A.append(a) print((N-len(A)))
from collections import Counter d={chr(i):0 for i in range(2)} s=Counter(eval(input())) d=d.update(s) print((min(s["0"],s["1"])*2))
14
5
223
127
from collections import deque s = deque(eval(input())) N = len(s) A = [] for i in range(N): a = s.popleft() if len(A) != 0: if A[-1] != a: A.pop() else: A.append(a) else: A.append(a) print((N - len(A)))
from collections import Counter d = {chr(i): 0 for i in range(2)} s = Counter(eval(input())) d = d.update(s) print((min(s["0"], s["1"]) * 2))
false
64.285714
[ "-from collections import deque", "+from collections import Counter", "-s = deque(eval(input()))", "-N = len(s)", "-A = []", "-for i in range(N):", "- a = s.popleft()", "- if len(A) != 0:", "- if A[-1] != a:", "- A.pop()", "- else:", "- A.append(a)", ...
false
0.008688
0.033695
0.257854
[ "s380665176", "s703980325" ]
u597374218
p02952
python
s476795169
s350706070
62
49
2,940
2,940
Accepted
Accepted
20.97
N=int(eval(input())) count=0 for i in range(1,N+1): if len(str(i))%2==1:count+=1 print(count)
N=int(eval(input())) print((sum(len(str(i))%2==1 for i in range(1,N+1))))
5
2
95
66
N = int(eval(input())) count = 0 for i in range(1, N + 1): if len(str(i)) % 2 == 1: count += 1 print(count)
N = int(eval(input())) print((sum(len(str(i)) % 2 == 1 for i in range(1, N + 1))))
false
60
[ "-count = 0", "-for i in range(1, N + 1):", "- if len(str(i)) % 2 == 1:", "- count += 1", "-print(count)", "+print((sum(len(str(i)) % 2 == 1 for i in range(1, N + 1))))" ]
false
0.043423
0.047544
0.913324
[ "s476795169", "s350706070" ]
u426764965
p03295
python
s653020369
s906171964
859
250
24,676
24,740
Accepted
Accepted
70.9
N, M = list(map(int, input().split())) Q = [tuple(map(int, input().split())) for _ in range(M)] # 右側が小さい順にソート、制約a<bなのでそのまま使ってよい Q = sorted(Q, key=lambda x: x[1]) # 境界、右側の区間の始まり border = [] for a, b in Q: flag = True for x in border: # 既存の境界で分けられるか if a < x and x <= b: ...
N, M = list(map(int, input().split())) Q = [tuple(map(int, input().split())) for _ in range(M)] # 右側が小さい順にソート、制約a<bなのでそのまま使ってよい Q = sorted(Q, key=lambda x: x[1]) # 境界、右側の区間の始まり border = -1 ans = 0 for a, b in Q: # 既存の境界で分けられないときは右にずらす if border <= a: ans += 1 border = b print(a...
20
16
418
317
N, M = list(map(int, input().split())) Q = [tuple(map(int, input().split())) for _ in range(M)] # 右側が小さい順にソート、制約a<bなのでそのまま使ってよい Q = sorted(Q, key=lambda x: x[1]) # 境界、右側の区間の始まり border = [] for a, b in Q: flag = True for x in border: # 既存の境界で分けられるか if a < x and x <= b: flag = False ...
N, M = list(map(int, input().split())) Q = [tuple(map(int, input().split())) for _ in range(M)] # 右側が小さい順にソート、制約a<bなのでそのまま使ってよい Q = sorted(Q, key=lambda x: x[1]) # 境界、右側の区間の始まり border = -1 ans = 0 for a, b in Q: # 既存の境界で分けられないときは右にずらす if border <= a: ans += 1 border = b print(ans)
false
20
[ "-border = []", "+border = -1", "+ans = 0", "- flag = True", "- for x in border:", "- # 既存の境界で分けられるか", "- if a < x and x <= b:", "- flag = False", "- break", "- if flag:", "- border.append(b)", "-ans = len(border)", "+ # 既存の境界で分けられないときは右...
false
0.038042
0.096982
0.392254
[ "s653020369", "s906171964" ]
u422104747
p03295
python
s455153972
s360143579
446
401
17,008
16,996
Accepted
Accepted
10.09
n,m=input().split() n=int(n) m=int(m) l=[] for i in range(m): t=input().split() l.append((int(t[0]),int(t[1]))) l.sort() i=0 res=0 flag=False while True: ra=l[i][1] while l[i][0]<ra: if i==m-1: flag=True break ra=min(ra,l[i][1]) i+=1 ...
s=input().split() n=int(s[0]) m=int(s[1]) l=[] for i in range(m): s=input().split() l.append((int(s[1]),int(s[0]))) l.sort() o=[] for p in l: if len(o)>0 and p[0]>=o[-1]>p[1]: continue else: o.append(p[0]) print((len(o)))
23
15
369
266
n, m = input().split() n = int(n) m = int(m) l = [] for i in range(m): t = input().split() l.append((int(t[0]), int(t[1]))) l.sort() i = 0 res = 0 flag = False while True: ra = l[i][1] while l[i][0] < ra: if i == m - 1: flag = True break ra = min(ra, l[i][1]) ...
s = input().split() n = int(s[0]) m = int(s[1]) l = [] for i in range(m): s = input().split() l.append((int(s[1]), int(s[0]))) l.sort() o = [] for p in l: if len(o) > 0 and p[0] >= o[-1] > p[1]: continue else: o.append(p[0]) print((len(o)))
false
34.782609
[ "-n, m = input().split()", "-n = int(n)", "-m = int(m)", "+s = input().split()", "+n = int(s[0])", "+m = int(s[1])", "- t = input().split()", "- l.append((int(t[0]), int(t[1])))", "+ s = input().split()", "+ l.append((int(s[1]), int(s[0])))", "-i = 0", "-res = 0", "-flag = False"...
false
0.036862
0.037635
0.97946
[ "s455153972", "s360143579" ]
u631277801
p03032
python
s644247512
s319378177
210
36
42,984
3,064
Accepted
Accepted
82.86
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.r...
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.r...
47
46
1,065
976
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
false
2.12766
[ "-from heapq import heappop", "-", "+# 入力", "+# 個数m決め打ち", "-for x in range(-(-k // 2)):", "- if 2 * x > k:", "+for m in range(n + 1):", "+ rest = k", "+ rest -= m", "+ if rest < 0:", "- get = k - x", "- if get >= n:", "- cnt = 0", "- heap = sorted(v)", "- ...
false
0.042532
0.067063
0.634213
[ "s644247512", "s319378177" ]
u504836877
p03659
python
s721470362
s791719584
245
221
24,824
24,832
Accepted
Accepted
9.8
N = int(eval(input())) A = [int(a) for a in input().split()] S = [0]*(N+1) for i in range(N): S[i+1] += S[i] + A[i] ans = 10**12 for i in range(N-1): ans = min(ans, abs(S[i+1]-(S[N]-S[i+1]))) print(ans)
N = int(eval(input())) A = [int(a) for a in input().split()] for i in range(N-1): A[i+1] += A[i] ans = 10**15 for i in range(N-1): ans = min(ans, abs(A[N-1]-2*A[i])) print(ans)
12
10
226
189
N = int(eval(input())) A = [int(a) for a in input().split()] S = [0] * (N + 1) for i in range(N): S[i + 1] += S[i] + A[i] ans = 10**12 for i in range(N - 1): ans = min(ans, abs(S[i + 1] - (S[N] - S[i + 1]))) print(ans)
N = int(eval(input())) A = [int(a) for a in input().split()] for i in range(N - 1): A[i + 1] += A[i] ans = 10**15 for i in range(N - 1): ans = min(ans, abs(A[N - 1] - 2 * A[i])) print(ans)
false
16.666667
[ "-S = [0] * (N + 1)", "-for i in range(N):", "- S[i + 1] += S[i] + A[i]", "-ans = 10**12", "- ans = min(ans, abs(S[i + 1] - (S[N] - S[i + 1])))", "+ A[i + 1] += A[i]", "+ans = 10**15", "+for i in range(N - 1):", "+ ans = min(ans, abs(A[N - 1] - 2 * A[i]))" ]
false
0.101284
0.103217
0.981282
[ "s721470362", "s791719584" ]
u172035535
p03074
python
s653719033
s152365433
61
48
7,156
7,156
Accepted
Accepted
21.31
N,K = list(map(int,input().split())) S = eval(input()) L = [0] ans = 0 res = '1' i = 0 for s in S: if s != res: L.append(i) i += 1 else: i += 1 res = s L.append(i) L.append(i) if len(L)<=2*K+1: ans = N for i in range(0,len(L)-K*2-1,2): ans = max(ans,L[i+K*2+...
def func(): N,K = list(map(int,input().split())) S = eval(input()) L = [] L.append(0) if S[0] == '0' else 0 num = '2' for i in range(N): if num != S[i]: L.append(i) num = S[i] L.append(N) L.append(N) ans = 0 for i in range(0,len(L)-K*2...
20
17
328
419
N, K = list(map(int, input().split())) S = eval(input()) L = [0] ans = 0 res = "1" i = 0 for s in S: if s != res: L.append(i) i += 1 else: i += 1 res = s L.append(i) L.append(i) if len(L) <= 2 * K + 1: ans = N for i in range(0, len(L) - K * 2 - 1, 2): ans = max(ans, L[i + K *...
def func(): N, K = list(map(int, input().split())) S = eval(input()) L = [] L.append(0) if S[0] == "0" else 0 num = "2" for i in range(N): if num != S[i]: L.append(i) num = S[i] L.append(N) L.append(N) ans = 0 for i in range(0, len(L) - K * 2 - 1, ...
false
15
[ "-N, K = list(map(int, input().split()))", "-S = eval(input())", "-L = [0]", "-ans = 0", "-res = \"1\"", "-i = 0", "-for s in S:", "- if s != res:", "- L.append(i)", "- i += 1", "- else:", "- i += 1", "- res = s", "-L.append(i)", "-L.append(i)", "-if len(L...
false
0.10565
0.038738
2.727308
[ "s653719033", "s152365433" ]
u023515228
p03163
python
s910403634
s162277652
310
231
15,928
15,648
Accepted
Accepted
25.48
from numpy import* f=lambda:list(map(int,input().split())) N,W=f() J=arange(0,W+1,1,'i8') T=J*0 exec('w,v=f();T=maximum(T,(T[J-w]+v)*(J>=w));'*N) print((T[-1]))
from numpy import* f=lambda:list(map(int,input().split())) N,W=f() T=zeros(W+1,'i8') exec('w,v=f();T[w:]=maximum(T[w:],T[:-w]+v);'*N) print((T[-1]))
7
6
158
145
from numpy import * f = lambda: list(map(int, input().split())) N, W = f() J = arange(0, W + 1, 1, "i8") T = J * 0 exec("w,v=f();T=maximum(T,(T[J-w]+v)*(J>=w));" * N) print((T[-1]))
from numpy import * f = lambda: list(map(int, input().split())) N, W = f() T = zeros(W + 1, "i8") exec("w,v=f();T[w:]=maximum(T[w:],T[:-w]+v);" * N) print((T[-1]))
false
14.285714
[ "-J = arange(0, W + 1, 1, \"i8\")", "-T = J * 0", "-exec(\"w,v=f();T=maximum(T,(T[J-w]+v)*(J>=w));\" * N)", "+T = zeros(W + 1, \"i8\")", "+exec(\"w,v=f();T[w:]=maximum(T[w:],T[:-w]+v);\" * N)" ]
false
0.230401
0.185042
1.245132
[ "s910403634", "s162277652" ]
u144913062
p02990
python
s528512431
s049524096
1,745
26
356,084
3,316
Accepted
Accepted
98.51
N, K = list(map(int, input().split())) mod = 10**9+7 dp = [[0] * (K+1) for i in range(K+1)] # the number of ways to split j into i parts dp[0][0] = 1 for i in range(1, K+1): for j in range(1, K+1): dp[i][j] = dp[i][j-1] + dp[i-1][j-1] combination = 1 for i in range(1, K+1): combination = (co...
N, K = list(map(int, input().split())) mod = 10**9+7 ans = N-K+1 print(ans) for i in range(2, K+1): ans = (ans * (N-K-i+2) * (K-i+1) * pow(i * (i-1), mod-2, mod)) % mod print(ans)
12
8
407
190
N, K = list(map(int, input().split())) mod = 10**9 + 7 dp = [[0] * (K + 1) for i in range(K + 1)] # the number of ways to split j into i parts dp[0][0] = 1 for i in range(1, K + 1): for j in range(1, K + 1): dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1] combination = 1 for i in range(1, K + 1): combinatio...
N, K = list(map(int, input().split())) mod = 10**9 + 7 ans = N - K + 1 print(ans) for i in range(2, K + 1): ans = (ans * (N - K - i + 2) * (K - i + 1) * pow(i * (i - 1), mod - 2, mod)) % mod print(ans)
false
33.333333
[ "-dp = [[0] * (K + 1) for i in range(K + 1)] # the number of ways to split j into i parts", "-dp[0][0] = 1", "-for i in range(1, K + 1):", "- for j in range(1, K + 1):", "- dp[i][j] = dp[i][j - 1] + dp[i - 1][j - 1]", "-combination = 1", "-for i in range(1, K + 1):", "- combination = (co...
false
0.101142
0.050084
2.019464
[ "s528512431", "s049524096" ]
u077898957
p03211
python
s355791828
s506272410
149
17
12,468
2,940
Accepted
Accepted
88.59
import numpy as np import sys s = eval(input()) ans = 753 for i in range(len(s)-2): value = abs(753 - int(s[i:i+3])) ans = min(ans,value) print(ans)
s=eval(input()) ans=1000 for i in range(len(s)-2): if abs(753-int(s[i:i+3]))<=ans: ans=abs(753-int(s[i:i+3])) print(ans)
8
6
158
132
import numpy as np import sys s = eval(input()) ans = 753 for i in range(len(s) - 2): value = abs(753 - int(s[i : i + 3])) ans = min(ans, value) print(ans)
s = eval(input()) ans = 1000 for i in range(len(s) - 2): if abs(753 - int(s[i : i + 3])) <= ans: ans = abs(753 - int(s[i : i + 3])) print(ans)
false
25
[ "-import numpy as np", "-import sys", "-", "-ans = 753", "+ans = 1000", "- value = abs(753 - int(s[i : i + 3]))", "- ans = min(ans, value)", "+ if abs(753 - int(s[i : i + 3])) <= ans:", "+ ans = abs(753 - int(s[i : i + 3]))" ]
false
0.036523
0.037015
0.986726
[ "s355791828", "s506272410" ]
u606878291
p03221
python
s601503385
s583816223
727
637
44,128
35,260
Accepted
Accepted
12.38
from collections import Counter N, M = list(map(int, input().split(' '))) records = [tuple(map(int, input().split(' '))) for _ in range(M)] s_records = sorted(records) counter = Counter() d = {} for p, y in s_records: counter[p] += 1 d[(p, y)] = '{:06}{:06}'.format(p, counter[p]) for p, y in re...
import bisect from collections import defaultdict N, M = list(map(int, input().split(' '))) cities = [] years = defaultdict(list) for _ in range(M): p, y = list(map(int, input().split(' '))) cities.append((p, y)) years[p].append(y) for p in list(years.keys()): years[p].sort() for p, y i...
15
16
343
381
from collections import Counter N, M = list(map(int, input().split(" "))) records = [tuple(map(int, input().split(" "))) for _ in range(M)] s_records = sorted(records) counter = Counter() d = {} for p, y in s_records: counter[p] += 1 d[(p, y)] = "{:06}{:06}".format(p, counter[p]) for p, y in records: print...
import bisect from collections import defaultdict N, M = list(map(int, input().split(" "))) cities = [] years = defaultdict(list) for _ in range(M): p, y = list(map(int, input().split(" "))) cities.append((p, y)) years[p].append(y) for p in list(years.keys()): years[p].sort() for p, y in cities: pr...
false
6.25
[ "-from collections import Counter", "+import bisect", "+from collections import defaultdict", "-records = [tuple(map(int, input().split(\" \"))) for _ in range(M)]", "-s_records = sorted(records)", "-counter = Counter()", "-d = {}", "-for p, y in s_records:", "- counter[p] += 1", "- d[(p, y)...
false
0.044433
0.046126
0.963303
[ "s601503385", "s583816223" ]
u020390084
p03274
python
s904562490
s356273165
121
110
14,128
19,884
Accepted
Accepted
9.09
n,k=list(map(int,input().split())) x = list(map(int,input().split())) import bisect zero_index = bisect.bisect_left(x,0) start_index = max(0,zero_index-k) x = x[start_index:zero_index+k] answer = (x[-1]-x[0])*k for i in range(len(x)-k+1): if x[i+k-1]*x[i]>0: answer = min(answer,max(abs(x[i+k-1]),ab...
#!/usr/bin/env python3 import sys from itertools import accumulate def solve(N: int, K: int, x: "List[int]"): minus = [] plus = [] answer = 10**9 for i in range(N): if x[i] >= 0: plus.append(x[i]) else: minus.append(abs(x[i])) minus = minus[::-1]...
17
44
436
1,231
n, k = list(map(int, input().split())) x = list(map(int, input().split())) import bisect zero_index = bisect.bisect_left(x, 0) start_index = max(0, zero_index - k) x = x[start_index : zero_index + k] answer = (x[-1] - x[0]) * k for i in range(len(x) - k + 1): if x[i + k - 1] * x[i] > 0: answer = min(answer...
#!/usr/bin/env python3 import sys from itertools import accumulate def solve(N: int, K: int, x: "List[int]"): minus = [] plus = [] answer = 10**9 for i in range(N): if x[i] >= 0: plus.append(x[i]) else: minus.append(abs(x[i])) minus = minus[::-1] for plu...
false
61.363636
[ "-n, k = list(map(int, input().split()))", "-x = list(map(int, input().split()))", "-import bisect", "+#!/usr/bin/env python3", "+import sys", "+from itertools import accumulate", "-zero_index = bisect.bisect_left(x, 0)", "-start_index = max(0, zero_index - k)", "-x = x[start_index : zero_index + k]...
false
0.039386
0.040118
0.981775
[ "s904562490", "s356273165" ]