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
u254871849
p02834
python
s353844913
s318582453
446
304
36,284
31,960
Accepted
Accepted
31.84
import sys n, u, v, *ab = list(map(int, sys.stdin.read().split())) ab = list(zip(*[iter(ab)] * 2)) graph = [[] for _ in range(n+1)] for a, b in ab: graph[a].append(b) graph[b].append(a) def dfs(v): dist = [None] * (n + 1) dist[v] = 0 stack = [v] while stack: x = stack.pop...
import sys n, u, v, *ab = list(map(int, sys.stdin.read().split())) graph = [[] for _ in range(n+1)] for a, b in zip(*[iter(ab)] * 2): graph[a].append(b) graph[b].append(a) def dfs(v): dist = [None] * (n + 1) dist[v] = 0 stack = [v] while stack: x = stack.pop() for...
35
34
733
718
import sys n, u, v, *ab = list(map(int, sys.stdin.read().split())) ab = list(zip(*[iter(ab)] * 2)) graph = [[] for _ in range(n + 1)] for a, b in ab: graph[a].append(b) graph[b].append(a) def dfs(v): dist = [None] * (n + 1) dist[v] = 0 stack = [v] while stack: x = stack.pop() ...
import sys n, u, v, *ab = list(map(int, sys.stdin.read().split())) graph = [[] for _ in range(n + 1)] for a, b in zip(*[iter(ab)] * 2): graph[a].append(b) graph[b].append(a) def dfs(v): dist = [None] * (n + 1) dist[v] = 0 stack = [v] while stack: x = stack.pop() for y in graph...
false
2.857143
[ "-ab = list(zip(*[iter(ab)] * 2))", "-for a, b in ab:", "+for a, b in zip(*[iter(ab)] * 2):" ]
false
0.130503
0.065496
1.992543
[ "s353844913", "s318582453" ]
u760802228
p02573
python
s825125623
s829385262
1,012
477
115,452
79,544
Accepted
Accepted
52.87
import queue N, M = list(map(int, input().split())) l = [[] for i in range(N)] for i in range(M): a, b = list(map(int, input().split())) l[a - 1].append(b - 1) l[b - 1].append(a - 1) c = [0] * N ans = 1 q = queue.Queue() for j in range(N): q.put(l[j]) u = 0 ...
N, M = list(map(int, input().split())) r = [-1] * (N + 1) def root(x): if r[x] < 0: return x return root(r[x]) for i in range(M): x, y = list(map(int, input().split())) x = root(x) y = root(y) if x == y: continue if ...
23
20
613
408
import queue N, M = list(map(int, input().split())) l = [[] for i in range(N)] for i in range(M): a, b = list(map(int, input().split())) l[a - 1].append(b - 1) l[b - 1].append(a - 1) c = [0] * N ans = 1 q = queue.Queue() for j in range(N): q.put(l[j]) u = 0 while not q.empty(): temp = q...
N, M = list(map(int, input().split())) r = [-1] * (N + 1) def root(x): if r[x] < 0: return x return root(r[x]) for i in range(M): x, y = list(map(int, input().split())) x = root(x) y = root(y) if x == y: continue if r[x] > r[y]: x, y = y, x r[x] += r[y] r[...
false
13.043478
[ "-import queue", "+N, M = list(map(int, input().split()))", "+r = [-1] * (N + 1)", "-N, M = list(map(int, input().split()))", "-l = [[] for i in range(N)]", "+", "+def root(x):", "+ if r[x] < 0:", "+ return x", "+ return root(r[x])", "+", "+", "- a, b = list(map(int, input()....
false
0.04143
0.037665
1.099973
[ "s825125623", "s829385262" ]
u143492911
p03339
python
s732691661
s249005774
331
280
29,328
19,948
Accepted
Accepted
15.41
n=int(eval(input())) s=list(eval(input())) cnt=s[1:].count("E") e_cnt=[0]*(n+1) w_cnt=[0]*(n+1) e_cnt[0]=cnt for i in range(n): w_cnt[i+1]=w_cnt[i]+(s[i]=="W")#Wの数を累積和でとる for i in range(1,n): e_cnt[i]=e_cnt[i-1]-(s[i]=="E")#Eの数を累積和でとる ans=float("inf") for i in range(n): ans=min(ans,w_cnt[i]+e_cn...
n=int(eval(input())) s=list(eval(input())) w_cnt=[0]*(n+1) e_cnt=[0]*(n+1) s.insert(0,"G") for i in range(1,n+1): if s[i]=="W": w_cnt[i]=w_cnt[i-1]+1 else: w_cnt[i]=w_cnt[i-1] s.reverse() s.pop(n) s.insert(0,"G") for i in range(1,n+1): if s[i]=="E": e_cnt[i]=e_cnt[i-1]...
14
24
326
470
n = int(eval(input())) s = list(eval(input())) cnt = s[1:].count("E") e_cnt = [0] * (n + 1) w_cnt = [0] * (n + 1) e_cnt[0] = cnt for i in range(n): w_cnt[i + 1] = w_cnt[i] + (s[i] == "W") # Wの数を累積和でとる for i in range(1, n): e_cnt[i] = e_cnt[i - 1] - (s[i] == "E") # Eの数を累積和でとる ans = float("inf") for i in range(...
n = int(eval(input())) s = list(eval(input())) w_cnt = [0] * (n + 1) e_cnt = [0] * (n + 1) s.insert(0, "G") for i in range(1, n + 1): if s[i] == "W": w_cnt[i] = w_cnt[i - 1] + 1 else: w_cnt[i] = w_cnt[i - 1] s.reverse() s.pop(n) s.insert(0, "G") for i in range(1, n + 1): if s[i] == "E": ...
false
41.666667
[ "-cnt = s[1:].count(\"E\")", "+w_cnt = [0] * (n + 1)", "-w_cnt = [0] * (n + 1)", "-e_cnt[0] = cnt", "-for i in range(n):", "- w_cnt[i + 1] = w_cnt[i] + (s[i] == \"W\") # Wの数を累積和でとる", "-for i in range(1, n):", "- e_cnt[i] = e_cnt[i - 1] - (s[i] == \"E\") # Eの数を累積和でとる", "+s.insert(0, \"G\")", ...
false
0.03779
0.03962
0.953807
[ "s732691661", "s249005774" ]
u989345508
p02720
python
s091215385
s236306768
415
174
33,640
23,388
Accepted
Accepted
58.07
k=int(eval(input())) ans=[[i for i in range(1,10)]] d=9 while d<k: ans.append([]) for i in ans[-2]: x=str(i) y=int(x[0]) if y==1: ans[-1].append(str(y)+x) ans[-1].append(str(y+1)+x) elif 2<=y<=8: ans[-1].append(str(y-1)+x) ...
k=int(eval(input())) ans=[[i for i in range(1,10)]] d=9 while d<k: ans.append([]) for i in ans[-2]: x=str(i) z=int(x[-1]) if z==0: ans[-1].append(x+str(z)) ans[-1].append(x+str(z+1)) elif 1<=z<=8: ans[-1].append(x+str(z-1)) ...
35
23
956
573
k = int(eval(input())) ans = [[i for i in range(1, 10)]] d = 9 while d < k: ans.append([]) for i in ans[-2]: x = str(i) y = int(x[0]) if y == 1: ans[-1].append(str(y) + x) ans[-1].append(str(y + 1) + x) elif 2 <= y <= 8: ans[-1].append(str(y - ...
k = int(eval(input())) ans = [[i for i in range(1, 10)]] d = 9 while d < k: ans.append([]) for i in ans[-2]: x = str(i) z = int(x[-1]) if z == 0: ans[-1].append(x + str(z)) ans[-1].append(x + str(z + 1)) elif 1 <= z <= 8: ans[-1].append(x + str...
false
34.285714
[ "- y = int(x[0])", "- if y == 1:", "- ans[-1].append(str(y) + x)", "- ans[-1].append(str(y + 1) + x)", "- elif 2 <= y <= 8:", "- ans[-1].append(str(y - 1) + x)", "- ans[-1].append(str(y) + x)", "- ans[-1].append(str(y + 1) + x...
false
0.466594
0.269561
1.730943
[ "s091215385", "s236306768" ]
u271934630
p03998
python
s169843918
s083936237
198
21
38,256
3,316
Accepted
Accepted
89.39
A = list(eval(input())) B = list(eval(input())) C = list(eval(input())) card = A.pop(0) while True: if card == 'a': if A: card = A.pop(0) else: print('A') exit() elif card == 'b': if B: card = B.pop(0) else: ...
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) from collections import deque i_i = lambda: int(i_s()) i_l = lambda: list(map(int, stdin.readline().split())) i_s = lambda: stdin.readline().rstrip() a = deque(list(i_s())) b = deque(list(i_s())) c = deque(list(i_s())) x = a.popleft() while Tr...
24
30
451
673
A = list(eval(input())) B = list(eval(input())) C = list(eval(input())) card = A.pop(0) while True: if card == "a": if A: card = A.pop(0) else: print("A") exit() elif card == "b": if B: card = B.pop(0) else: print("B") ...
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) from collections import deque i_i = lambda: int(i_s()) i_l = lambda: list(map(int, stdin.readline().split())) i_s = lambda: stdin.readline().rstrip() a = deque(list(i_s())) b = deque(list(i_s())) c = deque(list(i_s())) x = a.popleft() while True: if a and ...
false
20
[ "-A = list(eval(input()))", "-B = list(eval(input()))", "-C = list(eval(input()))", "-card = A.pop(0)", "+import sys", "+", "+stdin = sys.stdin", "+sys.setrecursionlimit(10**7)", "+from collections import deque", "+", "+i_i = lambda: int(i_s())", "+i_l = lambda: list(map(int, stdin.readline()....
false
0.035279
0.035869
0.983552
[ "s169843918", "s083936237" ]
u957167787
p02899
python
s341041572
s287508631
382
101
21,420
13,880
Accepted
Accepted
73.56
N = int(input()) A = list(map(int, input().split())) B = [] for i in range(1, N+1): B.append([A[i-1], i]) B.sort() for i in range(N): print(B[i][1] ,end=' ') print()
N = int(eval(input())) A = list(map(int, input().split())) ans = [0] * N # enumerate関数 # enumerate(イテラブル) # 前の変数には0, 1, 2, ...のように0から開始して1ずつ増える数が入る # 後ろの変数にはイテラブルの要素が入る # enumerate関数は(番号, イテラブルの要素)というtupleを作るので # それをアンパックして前の変数と後ろの変数に代入している for i, a in enumerate(A): ans[a-1] = i+1 # アスタリスクをつけると中身だけ...
11
18
185
372
N = int(input()) A = list(map(int, input().split())) B = [] for i in range(1, N + 1): B.append([A[i - 1], i]) B.sort() for i in range(N): print(B[i][1], end=" ") print()
N = int(eval(input())) A = list(map(int, input().split())) ans = [0] * N # enumerate関数 # enumerate(イテラブル) # 前の変数には0, 1, 2, ...のように0から開始して1ずつ増える数が入る # 後ろの変数にはイテラブルの要素が入る # enumerate関数は(番号, イテラブルの要素)というtupleを作るので # それをアンパックして前の変数と後ろの変数に代入している for i, a in enumerate(A): ans[a - 1] = i + 1 # アスタリスクをつけると中身だけを出力できる # 細かい原...
false
38.888889
[ "-N = int(input())", "+N = int(eval(input()))", "-B = []", "-for i in range(1, N + 1):", "- B.append([A[i - 1], i])", "-B.sort()", "-for i in range(N):", "- print(B[i][1], end=\" \")", "-print()", "+ans = [0] * N", "+# enumerate関数", "+# enumerate(イテラブル)", "+# 前の変数には0, 1, 2, ...のように0から開...
false
0.054844
0.03687
1.487502
[ "s341041572", "s287508631" ]
u057109575
p02733
python
s073607656
s898746276
1,242
524
44,764
75,524
Accepted
Accepted
57.81
H, W, K = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] ans = 10 ** 5 for bit in range(2 ** (H - 1)): group = [0] * H gnum = 0 # Group each row for i in range(H - 1): if not bit >> i & 1: group[i + 1] = group[i] else: gro...
H, W, K = list(map(int, input().split())) X = [list(eval(input())) for _ in range(H)] MOD = 10 ** 9 + 7 ans = MOD for bit in range(2 ** (H - 1)): n = bin(bit).count("1") ctr = [0] * (n + 1) # Accumulation res = 0 for j in range(W): k = 0 tmp = [0] * (n + 1) # One column ...
39
34
981
811
H, W, K = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] ans = 10**5 for bit in range(2 ** (H - 1)): group = [0] * H gnum = 0 # Group each row for i in range(H - 1): if not bit >> i & 1: group[i + 1] = group[i] else: group[i + 1] = group[i] ...
H, W, K = list(map(int, input().split())) X = [list(eval(input())) for _ in range(H)] MOD = 10**9 + 7 ans = MOD for bit in range(2 ** (H - 1)): n = bin(bit).count("1") ctr = [0] * (n + 1) # Accumulation res = 0 for j in range(W): k = 0 tmp = [0] * (n + 1) # One column for i in ...
false
12.820513
[ "-S = [eval(input()) for _ in range(H)]", "-ans = 10**5", "+X = [list(eval(input())) for _ in range(H)]", "+MOD = 10**9 + 7", "+ans = MOD", "- group = [0] * H", "- gnum = 0", "- # Group each row", "- for i in range(H - 1):", "- if not bit >> i & 1:", "- group[i + 1]...
false
0.042385
0.042452
0.998408
[ "s073607656", "s898746276" ]
u729133443
p03987
python
s545888976
s791410263
177
125
33,392
22,192
Accepted
Accepted
29.38
code = r""" # distutils: language=c++ from libcpp.set cimport set from libcpp.vector cimport vector from cython.operator cimport dereference as deref, predecrement as dec cdef int n = int(input()), i cdef long c cdef vector[long] a = [*map(int, input().split())] cdef vector[long] l = [0] * n for i in range(n):...
import sys if sys.argv[-1] == 'ONLINE_JUDGE': import os, zlib, base64 open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rg?P`QD5d7~`ER<5McXC316zM&QJxYwLw=|bXvi9iPcVn!*mIj3E%<Q-yxr3ep&rBvXV3ZwaHR4g1Wj1(s0YjahrYazVrpx3!gWP{{AE?>+jZWc@q6*xT+vpKlpOxRi<jL}obo!Ie&Q@+huWr41^f<_8HG&E$jG5S@_IN?d3D%kJ...
23
6
706
642
code = r""" # distutils: language=c++ from libcpp.set cimport set from libcpp.vector cimport vector from cython.operator cimport dereference as deref, predecrement as dec cdef int n = int(input()), i cdef long c cdef vector[long] a = [*map(int, input().split())] cdef vector[long] l = [0] * n for i in range(n): l[a[i] -...
import sys if sys.argv[-1] == "ONLINE_JUDGE": import os, zlib, base64 open("solve.pyx", "wb").write( zlib.decompress( base64.b85decode( "c${rg?P`QD5d7~`ER<5McXC316zM&QJxYwLw=|bXvi9iPcVn!*mIj3E%<Q-yxr3ep&rBvXV3ZwaHR4g1Wj1(s0YjahrYazVrpx3!gWP{{AE?>+jZWc@q6*xT+vpKlpOxRi<jL}obo...
false
73.913043
[ "-code = r\"\"\"", "-# distutils: language=c++", "-from libcpp.set cimport set", "-from libcpp.vector cimport vector", "-from cython.operator cimport dereference as deref, predecrement as dec", "-cdef int n = int(input()), i", "-cdef long c", "-cdef vector[long] a = [*map(int, input().split())]", "-...
false
0.03811
0.055982
0.680747
[ "s545888976", "s791410263" ]
u832039789
p02847
python
s691237343
s125248911
19
17
2,940
2,940
Accepted
Accepted
10.53
print(("SATFRITHUWEDTUEMONSUN".index(eval(input()))//3+1))
s = eval(input()) l = ["SUN","MON","TUE","WED","THU","FRI","SAT","SUN"] print((7 - l.index(s)))
1
3
50
90
print(("SATFRITHUWEDTUEMONSUN".index(eval(input())) // 3 + 1))
s = eval(input()) l = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"] print((7 - l.index(s)))
false
66.666667
[ "-print((\"SATFRITHUWEDTUEMONSUN\".index(eval(input())) // 3 + 1))", "+s = eval(input())", "+l = [\"SUN\", \"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\", \"SUN\"]", "+print((7 - l.index(s)))" ]
false
0.052995
0.086794
0.610585
[ "s691237343", "s125248911" ]
u045830275
p02257
python
s869603713
s769043018
840
70
8,196
8,184
Accepted
Accepted
91.67
import math def isPrime(x) : if x == 2 : return True if x < 2 or x % 2 == 0 : return False i = 3 while i <= math.sqrt(x) : if x % i == 0 : return False i += 2 return True def main() : n = int(eval(input())) nums = [] ...
def is_prime(x) : if x == 2 : return True if x < 2 or x % 2 == 0 : return False return pow(2, x-1, x) == 1 def main() : n = int(eval(input())) nums = [] for _ in range(n) : x = int(eval(input())) nums.append(x) count = 0 for num in nums ...
35
24
539
424
import math def isPrime(x): if x == 2: return True if x < 2 or x % 2 == 0: return False i = 3 while i <= math.sqrt(x): if x % i == 0: return False i += 2 return True def main(): n = int(eval(input())) nums = [] for i in range(n): x ...
def is_prime(x): if x == 2: return True if x < 2 or x % 2 == 0: return False return pow(2, x - 1, x) == 1 def main(): n = int(eval(input())) nums = [] for _ in range(n): x = int(eval(input())) nums.append(x) count = 0 for num in nums: if is_prime...
false
31.428571
[ "-import math", "-", "-", "-def isPrime(x):", "+def is_prime(x):", "- i = 3", "- while i <= math.sqrt(x):", "- if x % i == 0:", "- return False", "- i += 2", "- return True", "+ return pow(2, x - 1, x) == 1", "- for i in range(n):", "+ for _ in ra...
false
0.060072
0.040208
1.494027
[ "s869603713", "s769043018" ]
u225388820
p03659
python
s800678855
s482032701
203
162
24,832
24,800
Accepted
Accepted
20.2
n=int(eval(input())) a=list(map(int,input().split())) for i in range(1,n): a[i]+=a[i-1] ABS=10**15 for i in range(n-1): ABS=min(abs(a[-1]-2*a[i]),ABS) print(ABS)
n=int(eval(input())) a=list(map(int,input().split())) s=sum(a) now=0 ans=10**14 for i in a[:n-1]: now+=i ans=min(abs(2*now-s),ans) print(ans)
8
9
170
151
n = int(eval(input())) a = list(map(int, input().split())) for i in range(1, n): a[i] += a[i - 1] ABS = 10**15 for i in range(n - 1): ABS = min(abs(a[-1] - 2 * a[i]), ABS) print(ABS)
n = int(eval(input())) a = list(map(int, input().split())) s = sum(a) now = 0 ans = 10**14 for i in a[: n - 1]: now += i ans = min(abs(2 * now - s), ans) print(ans)
false
11.111111
[ "-for i in range(1, n):", "- a[i] += a[i - 1]", "-ABS = 10**15", "-for i in range(n - 1):", "- ABS = min(abs(a[-1] - 2 * a[i]), ABS)", "-print(ABS)", "+s = sum(a)", "+now = 0", "+ans = 10**14", "+for i in a[: n - 1]:", "+ now += i", "+ ans = min(abs(2 * now - s), ans)", "+print(a...
false
0.04162
0.043331
0.960511
[ "s800678855", "s482032701" ]
u433375322
p02582
python
s399134722
s520938477
34
28
8,984
9,052
Accepted
Accepted
17.65
a=list(eval(input())) if a[0]=="R": if a[1]=="S": print((1)) else: if a[2]=="R": print((3)) else: print((2)) else: if a[1]=="R" and a[2]=="R": print((2)) elif a[1]=="S" and a[2]=="S": print((0)) else: print((1))
s=list(eval(input())) c=0 l=[] for i in range(3): if s[i]=="R": c+=1 else: c=0 l.append(c) print((max(l)))
16
11
254
145
a = list(eval(input())) if a[0] == "R": if a[1] == "S": print((1)) else: if a[2] == "R": print((3)) else: print((2)) else: if a[1] == "R" and a[2] == "R": print((2)) elif a[1] == "S" and a[2] == "S": print((0)) else: print((1))
s = list(eval(input())) c = 0 l = [] for i in range(3): if s[i] == "R": c += 1 else: c = 0 l.append(c) print((max(l)))
false
31.25
[ "-a = list(eval(input()))", "-if a[0] == \"R\":", "- if a[1] == \"S\":", "- print((1))", "+s = list(eval(input()))", "+c = 0", "+l = []", "+for i in range(3):", "+ if s[i] == \"R\":", "+ c += 1", "- if a[2] == \"R\":", "- print((3))", "- else:", ...
false
0.039564
0.064702
0.61149
[ "s399134722", "s520938477" ]
u952467214
p03164
python
s379939222
s787658246
959
383
308,168
119,788
Accepted
Accepted
60.06
N, W = [int(i) for i in input().split()] w, v = [0]*N, [0]*N for i in range(N): w[i], v[i] = [int(_) for _ in input().split()] V = sum(v) dp = [[float('inf')] * (V+1) for _ in range(N+1)] # dp[i][j] i番目までの荷物で価値がj以上になるように選んだときの重さの最小値 dp[0][0] = 0 for i in range(N): for j in range(V+1): if v[i] <=...
N, W = list(map(int, input().split())) w, v = [0]*(N+1),[0]*(N+1) for i in range(N): w[i+1], v[i+1] = [int(_) for _ in input().split()] V = sum(v) dp = [[10**12]*(V+1) for _ in range(N+1)] dp[0][0] = 0 # dp[i][j]:i番目以前の商品を見たときの価値総和jとしたときの重さの最小値 ans = 0 for i in range(1,N+1): for j in range(V+1): #...
23
25
557
669
N, W = [int(i) for i in input().split()] w, v = [0] * N, [0] * N for i in range(N): w[i], v[i] = [int(_) for _ in input().split()] V = sum(v) dp = [[float("inf")] * (V + 1) for _ in range(N + 1)] # dp[i][j] i番目までの荷物で価値がj以上になるように選んだときの重さの最小値 dp[0][0] = 0 for i in range(N): for j in range(V + 1): if v[i] ...
N, W = list(map(int, input().split())) w, v = [0] * (N + 1), [0] * (N + 1) for i in range(N): w[i + 1], v[i + 1] = [int(_) for _ in input().split()] V = sum(v) dp = [[10**12] * (V + 1) for _ in range(N + 1)] dp[0][0] = 0 # dp[i][j]:i番目以前の商品を見たときの価値総和jとしたときの重さの最小値 ans = 0 for i in range(1, N + 1): for j in range...
false
8
[ "-N, W = [int(i) for i in input().split()]", "-w, v = [0] * N, [0] * N", "+N, W = list(map(int, input().split()))", "+w, v = [0] * (N + 1), [0] * (N + 1)", "- w[i], v[i] = [int(_) for _ in input().split()]", "+ w[i + 1], v[i + 1] = [int(_) for _ in input().split()]", "-dp = [[float(\"inf\")] * (V ...
false
0.045473
0.046688
0.973982
[ "s379939222", "s787658246" ]
u345966487
p03724
python
s567180571
s832128170
633
252
51,672
82,800
Accepted
Accepted
60.19
from collections import Counter N, M = list(map(int, input().split())) counter = Counter() for i in range(M): a, b = list(map(int, input().split())) counter[a] += 1 counter[b] += 1 if all(x % 2 == 0 for x in list(counter.values())): print("YES") else: print("NO")
n,m,*p=list(map(int,open(0).read().split()));c=[0]*n for x in p:c[x-1]+=1 print(("YNEOS"[any(x%2for x in c)::2]))
13
3
280
107
from collections import Counter N, M = list(map(int, input().split())) counter = Counter() for i in range(M): a, b = list(map(int, input().split())) counter[a] += 1 counter[b] += 1 if all(x % 2 == 0 for x in list(counter.values())): print("YES") else: print("NO")
n, m, *p = list(map(int, open(0).read().split())) c = [0] * n for x in p: c[x - 1] += 1 print(("YNEOS"[any(x % 2 for x in c) :: 2]))
false
76.923077
[ "-from collections import Counter", "-", "-N, M = list(map(int, input().split()))", "-counter = Counter()", "-for i in range(M):", "- a, b = list(map(int, input().split()))", "- counter[a] += 1", "- counter[b] += 1", "-if all(x % 2 == 0 for x in list(counter.values())):", "- print(\"YE...
false
0.036025
0.035394
1.017835
[ "s567180571", "s832128170" ]
u738622346
p03361
python
s057928861
s421511816
28
25
3,064
3,064
Accepted
Accepted
10.71
h, w = list(map(int, input().split(" "))) s = [] for row in range(h): line = eval(input()) tmp = [] for column in range(w): tmp.append(line[column]) s.append(tmp) sx = [-1, 0, 0, 1] sy = [0, 1, -1, 0] res = True for row in range(h): for column in range(w): if s[row][...
h, w = list(map(int, input().split(" "))) s = [] for row in range(h): line = eval(input()) tmp = [] for column in range(w): tmp.append(line[column]) s.append(tmp) sx = [-1, 0, 0, 1] sy = [0, 1, -1, 0] res = True for row in range(h): for column in range(w): if s[row][...
28
31
769
855
h, w = list(map(int, input().split(" "))) s = [] for row in range(h): line = eval(input()) tmp = [] for column in range(w): tmp.append(line[column]) s.append(tmp) sx = [-1, 0, 0, 1] sy = [0, 1, -1, 0] res = True for row in range(h): for column in range(w): if s[row][column] == "#": ...
h, w = list(map(int, input().split(" "))) s = [] for row in range(h): line = eval(input()) tmp = [] for column in range(w): tmp.append(line[column]) s.append(tmp) sx = [-1, 0, 0, 1] sy = [0, 1, -1, 0] res = True for row in range(h): for column in range(w): if s[row][column] == "#": ...
false
9.677419
[ "- if row + sx[i] < 0 or len(s) <= row + sx[i]:", "+ row_target = row + sx[i]", "+ column_target = column + sy[i]", "+ if row_target < 0 or len(s) <= row_target:", "- if column + sy[i] < 0 or len(s[row]) <= column + sy[i]:", "+ ...
false
0.08043
0.043984
1.828604
[ "s057928861", "s421511816" ]
u852690916
p03013
python
s501793787
s324497975
489
246
50,008
57,180
Accepted
Accepted
49.69
N,M=list(map(int,input().split())) a=[int(eval(input())) for _ in range(M)] MOD=10**9+7 dp=[0]*(N+1) dp[0]=1 dp[1]=1 for i in a: dp[i]=-1 for i in range(2,N+1): if dp[i]==-1: continue if dp[i-1]!=-1: dp[i] = (dp[i]+dp[i-1])%MOD if dp[i-2]!=-1: dp[i] = (dp[i]+dp[i-...
import sys def main(): input = sys.stdin.readline N, M = list(map(int, input().split())) A = [int(eval(input())) for _ in range(M)] + [-1] dp = [Mint() for _ in range(N+1)] dp[0] = Mint(1) j = 0 for i in range(1,N+1): if i == A[j]: j += 1 continue ...
18
85
332
2,555
N, M = list(map(int, input().split())) a = [int(eval(input())) for _ in range(M)] MOD = 10**9 + 7 dp = [0] * (N + 1) dp[0] = 1 dp[1] = 1 for i in a: dp[i] = -1 for i in range(2, N + 1): if dp[i] == -1: continue if dp[i - 1] != -1: dp[i] = (dp[i] + dp[i - 1]) % MOD if dp[i - 2] != -1: ...
import sys def main(): input = sys.stdin.readline N, M = list(map(int, input().split())) A = [int(eval(input())) for _ in range(M)] + [-1] dp = [Mint() for _ in range(N + 1)] dp[0] = Mint(1) j = 0 for i in range(1, N + 1): if i == A[j]: j += 1 continue ...
false
78.823529
[ "-N, M = list(map(int, input().split()))", "-a = [int(eval(input())) for _ in range(M)]", "-MOD = 10**9 + 7", "-dp = [0] * (N + 1)", "-dp[0] = 1", "-dp[1] = 1", "-for i in a:", "- dp[i] = -1", "-for i in range(2, N + 1):", "- if dp[i] == -1:", "- continue", "- if dp[i - 1] != -...
false
0.068818
0.035162
1.957199
[ "s501793787", "s324497975" ]
u670567845
p03331
python
s070183021
s357649648
146
132
9,048
74,240
Accepted
Accepted
9.59
N = int(eval(input())) ans = float('inf') for i in range(N//2): A = i+1 B = N-A ans = min(ans, sum(list(map(int,str(A)))) + sum(list(map(int,str(B))) )) print(ans)
N = int(eval(input())) ans = 10**9+7 for i in range(1,N): A = i B = N-i ans = min(ans, sum(list(map(int,str(A))))+sum(list(map(int,str(B))))) print(ans)
8
7
171
158
N = int(eval(input())) ans = float("inf") for i in range(N // 2): A = i + 1 B = N - A ans = min(ans, sum(list(map(int, str(A)))) + sum(list(map(int, str(B))))) print(ans)
N = int(eval(input())) ans = 10**9 + 7 for i in range(1, N): A = i B = N - i ans = min(ans, sum(list(map(int, str(A)))) + sum(list(map(int, str(B))))) print(ans)
false
12.5
[ "-ans = float(\"inf\")", "-for i in range(N // 2):", "- A = i + 1", "- B = N - A", "+ans = 10**9 + 7", "+for i in range(1, N):", "+ A = i", "+ B = N - i" ]
false
0.250604
0.100811
2.485884
[ "s070183021", "s357649648" ]
u392319141
p02814
python
s083058620
s198355055
511
158
63,984
14,244
Accepted
Accepted
69.08
N, M = list(map(int, input().split())) A = list(set(map(int, input().split()))) def gcd(m, n): if n == 0: return m return gcd(n, m % n) LCM = A[0] for a in A: LCM = LCM * a // gcd(LCM, a) K = max(A) for X in range(K // 2, M + 1, K): for a in A: if (X - a // 2) % a != 0:...
N, M = list(map(int, input().split())) A = list(map(int, input().split())) B = set([a & (-a) for a in A]) if len(B) > 1: print((0)) exit() def gcd(n, m): if m == 0: return n return gcd(m, n % m) def lcm(x, y): return x * y // gcd(x, y) A = [a // 2 for a in A] LCM = A[0] ...
21
23
406
391
N, M = list(map(int, input().split())) A = list(set(map(int, input().split()))) def gcd(m, n): if n == 0: return m return gcd(n, m % n) LCM = A[0] for a in A: LCM = LCM * a // gcd(LCM, a) K = max(A) for X in range(K // 2, M + 1, K): for a in A: if (X - a // 2) % a != 0: b...
N, M = list(map(int, input().split())) A = list(map(int, input().split())) B = set([a & (-a) for a in A]) if len(B) > 1: print((0)) exit() def gcd(n, m): if m == 0: return n return gcd(m, n % m) def lcm(x, y): return x * y // gcd(x, y) A = [a // 2 for a in A] LCM = A[0] for a in A: ...
false
8.695652
[ "-A = list(set(map(int, input().split())))", "+A = list(map(int, input().split()))", "+B = set([a & (-a) for a in A])", "+if len(B) > 1:", "+ print((0))", "+ exit()", "-def gcd(m, n):", "- if n == 0:", "- return m", "- return gcd(n, m % n)", "+def gcd(n, m):", "+ if m == ...
false
0.075867
0.076469
0.992128
[ "s083058620", "s198355055" ]
u667024514
p03795
python
s615203565
s969830995
19
17
2,940
2,940
Accepted
Accepted
10.53
a = int(eval(input())) b = int(a/15) print((800*a-200*b))
n = int(eval(input())) print((n * 800 - (n // 15) * 200))
3
2
51
50
a = int(eval(input())) b = int(a / 15) print((800 * a - 200 * b))
n = int(eval(input())) print((n * 800 - (n // 15) * 200))
false
33.333333
[ "-a = int(eval(input()))", "-b = int(a / 15)", "-print((800 * a - 200 * b))", "+n = int(eval(input()))", "+print((n * 800 - (n // 15) * 200))" ]
false
0.075351
0.078521
0.959627
[ "s615203565", "s969830995" ]
u070201429
p03283
python
s511542875
s517463046
956
307
50,596
22,400
Accepted
Accepted
67.89
# Reference: https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree # Fenwick Tree class BinaryIndexedTree: # a = [0] * n # O(n) def __init__(self, n): self.size = n self.data = [0] * (n+1) # return sum(a[0:i]) # O(log(n)) def cumulative_sum...
from sys import stdin input = stdin.buffer.readline def main(): n, m, q = list(map(int, input().split())) # Two-dimensional Cumulative Sum cs = [[0] * (n+1) for _ in range(n+1)] for _ in range(m): l, r = list(map(int, input().split())) cs[l][r] += 1 for l in range(1,...
60
28
1,421
633
# Reference: https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree # Fenwick Tree class BinaryIndexedTree: # a = [0] * n # O(n) def __init__(self, n): self.size = n self.data = [0] * (n + 1) # return sum(a[0:i]) # O(log(n)) def cumulative_sum(self, i)...
from sys import stdin input = stdin.buffer.readline def main(): n, m, q = list(map(int, input().split())) # Two-dimensional Cumulative Sum cs = [[0] * (n + 1) for _ in range(n + 1)] for _ in range(m): l, r = list(map(int, input().split())) cs[l][r] += 1 for l in range(1, n + 1): ...
false
53.333333
[ "-# Reference: https://ikatakos.com/pot/programming_algorithm/data_structure/binary_indexed_tree", "-# Fenwick Tree", "-class BinaryIndexedTree:", "- # a = [0] * n", "- # O(n)", "- def __init__(self, n):", "- self.size = n", "- self.data = [0] * (n + 1)", "-", "- # return...
false
0.042563
0.042964
0.990648
[ "s511542875", "s517463046" ]
u523087093
p03281
python
s776990114
s996757594
120
28
27,220
9,180
Accepted
Accepted
76.67
import itertools import numpy as np def check_eight(n): div_list = [] for i in range(3, n + 1, 2): if n % i == 0: while n % i == 0: n = n // i div_list.append(i) if n == 1: break answer_list = [] for i in range(1, ...
N = int(eval(input())) ans = 0 for n in range(3, N+1, 2): count = 1 for i in range(3, n+1, 2): if n % i == 0: count += 1 if n == 1: break if count == 8: ans += 1 print(ans)
32
15
710
244
import itertools import numpy as np def check_eight(n): div_list = [] for i in range(3, n + 1, 2): if n % i == 0: while n % i == 0: n = n // i div_list.append(i) if n == 1: break answer_list = [] for i in range(1, len(div_list) + ...
N = int(eval(input())) ans = 0 for n in range(3, N + 1, 2): count = 1 for i in range(3, n + 1, 2): if n % i == 0: count += 1 if n == 1: break if count == 8: ans += 1 print(ans)
false
53.125
[ "-import itertools", "-import numpy as np", "-", "-", "-def check_eight(n):", "- div_list = []", "+N = int(eval(input()))", "+ans = 0", "+for n in range(3, N + 1, 2):", "+ count = 1", "- while n % i == 0:", "- n = n // i", "- div_list.append(i)"...
false
0.292536
0.035396
8.26478
[ "s776990114", "s996757594" ]
u157020659
p02947
python
s477367465
s440954614
287
240
37,080
23,816
Accepted
Accepted
16.38
n = int(eval(input())) s = [list(eval(input())) for _ in range(n)] s_dict = dict([]) for i in s: key = ''.join(sorted(i)) s_dict.setdefault(key, 0) s_dict[key] += 1 ans = 0 for v in list(s_dict.values()): ans += v * (v - 1) // 2 print(ans)
import collections n = int(eval(input())) s = [''.join(sorted(list(eval(input())))) for _ in range(n)] s = collections.Counter(s) ans = 0 for v in list(s.values()): ans += v * (v - 1) // 2 print(ans)
14
10
253
196
n = int(eval(input())) s = [list(eval(input())) for _ in range(n)] s_dict = dict([]) for i in s: key = "".join(sorted(i)) s_dict.setdefault(key, 0) s_dict[key] += 1 ans = 0 for v in list(s_dict.values()): ans += v * (v - 1) // 2 print(ans)
import collections n = int(eval(input())) s = ["".join(sorted(list(eval(input())))) for _ in range(n)] s = collections.Counter(s) ans = 0 for v in list(s.values()): ans += v * (v - 1) // 2 print(ans)
false
28.571429
[ "+import collections", "+", "-s = [list(eval(input())) for _ in range(n)]", "-s_dict = dict([])", "-for i in s:", "- key = \"\".join(sorted(i))", "- s_dict.setdefault(key, 0)", "- s_dict[key] += 1", "+s = [\"\".join(sorted(list(eval(input())))) for _ in range(n)]", "+s = collections.Count...
false
0.036148
0.036099
1.001359
[ "s477367465", "s440954614" ]
u564589929
p02989
python
s069770345
s634808833
93
75
14,812
14,396
Accepted
Accepted
19.35
import sys sys.setrecursionlimit(10 ** 9) int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LLI(rows_number): return [LI() for _ in range(rows...
# import sys # sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LLI(rows_number): return [LI() for _ in range(...
37
23
791
470
import sys sys.setrecursionlimit(10**9) int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LLI(rows_number): return [LI() f...
# import sys # sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LLI(rows_number): return [L...
false
37.837838
[ "-import sys", "-", "-sys.setrecursionlimit(10**9)", "+# import sys", "+# sys.setrecursionlimit(10 ** 6)", "-from collections import deque", "-", "-", "- D = deque(sorted(LI()))", "- for i in range(n):", "- l = D.popleft()", "- # print('l', l)", "- if len(D) == 0:"...
false
0.09126
0.097789
0.933236
[ "s069770345", "s634808833" ]
u347640436
p03504
python
s219858103
s108691231
1,110
585
29,428
35,460
Accepted
Accepted
47.3
N, C = list(map(int, input().split())) tt = [[0] * (10 ** 5 + 1) for _ in range(30)] for _ in range(N): s, t, c = list(map(int, input().split())) ttc = tt[c - 1] for i in range(s - 1, t): ttc[i] = 1 ct = [0] * (10 ** 5 + 1) for i in range(30): tti = tt[i] for j in range(10 ** 5...
# imos 法 from operator import itemgetter N, C = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(N)] stc.sort(key=itemgetter(2, 0)) cs = [0] * (10 ** 5 + 1) pc = -1 for s, t, c in stc: if pc != c: pt = -1 pc = c if pt == s: cs[s] += 1 ...
16
24
358
454
N, C = list(map(int, input().split())) tt = [[0] * (10**5 + 1) for _ in range(30)] for _ in range(N): s, t, c = list(map(int, input().split())) ttc = tt[c - 1] for i in range(s - 1, t): ttc[i] = 1 ct = [0] * (10**5 + 1) for i in range(30): tti = tt[i] for j in range(10**5 + 1): ct[j]...
# imos 法 from operator import itemgetter N, C = list(map(int, input().split())) stc = [list(map(int, input().split())) for _ in range(N)] stc.sort(key=itemgetter(2, 0)) cs = [0] * (10**5 + 1) pc = -1 for s, t, c in stc: if pc != c: pt = -1 pc = c if pt == s: cs[s] += 1 else: ...
false
33.333333
[ "+# imos 法", "+from operator import itemgetter", "+", "-tt = [[0] * (10**5 + 1) for _ in range(30)]", "-for _ in range(N):", "- s, t, c = list(map(int, input().split()))", "- ttc = tt[c - 1]", "- for i in range(s - 1, t):", "- ttc[i] = 1", "-ct = [0] * (10**5 + 1)", "-for i in ra...
false
1.213267
0.064444
18.826729
[ "s219858103", "s108691231" ]
u905582793
p02775
python
s110945367
s606798305
730
673
5,492
5,492
Accepted
Accepted
7.81
n = eval(input()) n = n[::-1] l = len(n) ans = 0 flg = 0 x = [] for j in range(l): i = n[j] i = int(i) if i+flg>=6: i += flg ans += (10-i) flg = 1 elif i+flg == 5: if j == l-1: ans += i+flg flg = 0 elif int(n[j+1]) >= 5: i += flg ans += (10-i) ...
n = eval(input()) n = n[::-1] l = len(n) ans = 0 flg = 0 x = [] for j in range(l): i = n[j] i = int(i) i += flg if i >= 6: ans += (10-i) flg = 1 elif i == 5: if j == l-1: ans += i flg = 0 elif int(n[j+1]) >= 5: ans += (10-i) flg = 1 else: ...
31
29
452
406
n = eval(input()) n = n[::-1] l = len(n) ans = 0 flg = 0 x = [] for j in range(l): i = n[j] i = int(i) if i + flg >= 6: i += flg ans += 10 - i flg = 1 elif i + flg == 5: if j == l - 1: ans += i + flg flg = 0 elif int(n[j + 1]) >= 5: ...
n = eval(input()) n = n[::-1] l = len(n) ans = 0 flg = 0 x = [] for j in range(l): i = n[j] i = int(i) i += flg if i >= 6: ans += 10 - i flg = 1 elif i == 5: if j == l - 1: ans += i flg = 0 elif int(n[j + 1]) >= 5: ans += 10 - i ...
false
6.451613
[ "- if i + flg >= 6:", "- i += flg", "+ i += flg", "+ if i >= 6:", "- elif i + flg == 5:", "+ elif i == 5:", "- ans += i + flg", "+ ans += i", "- i += flg", "- ans += i + flg", "+ ans += i", "- i += flg" ]
false
0.031397
0.03823
0.821256
[ "s110945367", "s606798305" ]
u546285759
p00590
python
s894421349
s470697839
950
490
7,800
7,752
Accepted
Accepted
48.42
primes = [0, 0] + [1] * 9999 for i in range(2, 101): if primes[i]: for j in range(i*i, 10001, i): primes[j] = 0 while True: try: N = int(eval(input())) except: break print((sum(primes[i] & primes[N-i+1] for i in range(1, N+1))))
primes = [0, 0] + [1] * 9999 for i in range(2, 101): if primes[i]: for j in range(i*i, 10001, i): primes[j] = 0 while True: try: N = int(eval(input())) except: break print((sum(primes[i] and primes[N-i+1] for i in range(1, N+1))))
12
12
284
286
primes = [0, 0] + [1] * 9999 for i in range(2, 101): if primes[i]: for j in range(i * i, 10001, i): primes[j] = 0 while True: try: N = int(eval(input())) except: break print((sum(primes[i] & primes[N - i + 1] for i in range(1, N + 1))))
primes = [0, 0] + [1] * 9999 for i in range(2, 101): if primes[i]: for j in range(i * i, 10001, i): primes[j] = 0 while True: try: N = int(eval(input())) except: break print((sum(primes[i] and primes[N - i + 1] for i in range(1, N + 1))))
false
0
[ "- print((sum(primes[i] & primes[N - i + 1] for i in range(1, N + 1))))", "+ print((sum(primes[i] and primes[N - i + 1] for i in range(1, N + 1))))" ]
false
0.08304
0.045185
1.837781
[ "s894421349", "s470697839" ]
u761529120
p03634
python
s083939253
s961032358
754
388
94,752
112,352
Accepted
Accepted
48.54
import heapq import sys input = sys.stdin.readline def dijkstra(s, edge, N): d = [float('inf')] * N used = [True] * N d[s] = 0 used[s] = False edgelist = [] for a, b in edge[s]: heapq.heappush(edgelist, a * (10 ** 6) + b) while len(edgelist): minedge = heapq.h...
import heapq import sys input = sys.stdin.readline def dijkstra_heap(s,edge,n): #始点sから各頂点への最短距離 d = [10**20] * n used = [True] * n #True:未確定 d[s] = 0 used[s] = False edgelist = [] for a,b in edge[s]: heapq.heappush(edgelist,a*(10**6)+b) while len(edgelist): ...
48
50
1,130
1,171
import heapq import sys input = sys.stdin.readline def dijkstra(s, edge, N): d = [float("inf")] * N used = [True] * N d[s] = 0 used[s] = False edgelist = [] for a, b in edge[s]: heapq.heappush(edgelist, a * (10**6) + b) while len(edgelist): minedge = heapq.heappop(edgelist...
import heapq import sys input = sys.stdin.readline def dijkstra_heap(s, edge, n): # 始点sから各頂点への最短距離 d = [10**20] * n used = [True] * n # True:未確定 d[s] = 0 used[s] = False edgelist = [] for a, b in edge[s]: heapq.heappush(edgelist, a * (10**6) + b) while len(edgelist): ...
false
4
[ "-def dijkstra(s, edge, N):", "- d = [float(\"inf\")] * N", "- used = [True] * N", "+def dijkstra_heap(s, edge, n):", "+ # 始点sから各頂点への最短距離", "+ d = [10**20] * n", "+ used = [True] * n # True:未確定", "+ # まだ使われてない頂点の中から最小の距離のものを探す", "- edge = [[] for _ in range(N)]", "+ ed...
false
0.088581
0.085382
1.037462
[ "s083939253", "s961032358" ]
u254871849
p03681
python
s192739059
s863149610
442
45
4,084
6,900
Accepted
Accepted
89.82
import sys input = sys.stdin.readline from math import factorial mod = 10 ** 9 + 7 N, M = [int(x) for x in input().split()] if abs(N - M) >= 2: ans = 0 else: ans = (factorial(N) % mod * factorial(M) % mod) % mod if N == M: ans *= 2 print((ans % mod))
import sys MOD = 10 ** 9 + 7 def make_factorial_mod(n, mod): fac = [None] * (n + 1) fac[0] = 1 for i in range(n): fac[i+1] = fac[i] * (i + 1) % mod return fac fac = make_factorial_mod(10**5, MOD) n, m = list(map(int, sys.stdin.readline().split())) if n < m: n, m = m, n ...
10
29
259
538
import sys input = sys.stdin.readline from math import factorial mod = 10**9 + 7 N, M = [int(x) for x in input().split()] if abs(N - M) >= 2: ans = 0 else: ans = (factorial(N) % mod * factorial(M) % mod) % mod if N == M: ans *= 2 print((ans % mod))
import sys MOD = 10**9 + 7 def make_factorial_mod(n, mod): fac = [None] * (n + 1) fac[0] = 1 for i in range(n): fac[i + 1] = fac[i] * (i + 1) % mod return fac fac = make_factorial_mod(10**5, MOD) n, m = list(map(int, sys.stdin.readline().split())) if n < m: n, m = m, n def main(): ...
false
65.517241
[ "-input = sys.stdin.readline", "-from math import factorial", "+MOD = 10**9 + 7", "-mod = 10**9 + 7", "-N, M = [int(x) for x in input().split()]", "-if abs(N - M) >= 2:", "- ans = 0", "-else:", "- ans = (factorial(N) % mod * factorial(M) % mod) % mod", "-if N == M:", "- ans *= 2", "-p...
false
0.082556
0.091445
0.902797
[ "s192739059", "s863149610" ]
u588341295
p03450
python
s104695241
s396198608
1,458
1,234
11,536
12,140
Accepted
Accepted
15.36
# -*- coding: utf-8 -*- """ 参考:http://hamko.hatenadiary.jp/entry/2018/01/30/210057    http://at274.hatenablog.com/entry/2018/02/03/140504 ・重み付きUnion-Find木 """ class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 根への距離を管理 ...
# -*- coding: utf-8 -*- """ 参考:http://hamko.hatenadiary.jp/entry/2018/01/30/210057    http://at274.hatenablog.com/entry/2018/02/03/140504 ・重み付きUnion-Find木 """ import sys def input(): return sys.stdin.readline().strip() class WeightedUnionFind: def __init__(self, n): self.par = [i for i in ra...
64
67
1,684
1,747
# -*- coding: utf-8 -*- """ 参考:http://hamko.hatenadiary.jp/entry/2018/01/30/210057    http://at274.hatenablog.com/entry/2018/02/03/140504 ・重み付きUnion-Find木 """ class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] self.rank = [0] * (n + 1) # 根への距離を管理 s...
# -*- coding: utf-8 -*- """ 参考:http://hamko.hatenadiary.jp/entry/2018/01/30/210057    http://at274.hatenablog.com/entry/2018/02/03/140504 ・重み付きUnion-Find木 """ import sys def input(): return sys.stdin.readline().strip() class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n + ...
false
4.477612
[ "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "- # 同じ集合に属する場合は", "+ # 同じ集合に属する場合" ]
false
0.043005
0.040229
1.069003
[ "s104695241", "s396198608" ]
u716530146
p02753
python
s904424661
s869738989
181
167
38,256
38,256
Accepted
Accepted
7.73
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 s = eval(input()) S = {"A","B"} s1 = {s[0],s[1]} s2 = {s[2],s[1]} if s1 == S or s2 == S: pr...
import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 s = eval(input()) for i in range(2): if s[i] != s[i+1]: count += 1 print(("Yes" if count >= 1 else "No"))
14
10
347
305
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") inf = float("inf") mod = 10**9 + 7 mans = inf ans = 0 count = 0 pro = 1 s = eval(input()) S = {"A", "B"} s1 = {s[0], s[1]} s2 = {s[2], s[1]} if s1 == S or s2 == S: print("Yes...
import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") inf = float("inf") mod = 10**9 + 7 mans = inf ans = 0 count = 0 pro = 1 s = eval(input()) for i in range(2): if s[i] != s[i + 1]: count += 1 print(("Yes" if count >= 1 else "No"))
false
28.571429
[ "-#!/usr/bin/env python3", "-S = {\"A\", \"B\"}", "-s1 = {s[0], s[1]}", "-s2 = {s[2], s[1]}", "-if s1 == S or s2 == S:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+for i in range(2):", "+ if s[i] != s[i + 1]:", "+ count += 1", "+print((\"Yes\" if count >= 1 else \"No\")...
false
0.040028
0.039515
1.012976
[ "s904424661", "s869738989" ]
u761320129
p03296
python
s745001197
s210749859
20
17
3,316
3,060
Accepted
Accepted
15
N = int(eval(input())) src = list(map(int,input().split())) prev = -1 seq = 1 ans = 0 for a in src: if prev == a: seq += 1 else: ans += seq//2 seq = 1 prev = a if seq > 1: ans += seq//2 print(ans)
N = int(eval(input())) A = list(map(int,input().split())) ans = 0 changed = False for a,b in zip(A,A[1:]): if changed: changed = False continue if a == b: ans += 1 changed = True print(ans)
17
13
248
236
N = int(eval(input())) src = list(map(int, input().split())) prev = -1 seq = 1 ans = 0 for a in src: if prev == a: seq += 1 else: ans += seq // 2 seq = 1 prev = a if seq > 1: ans += seq // 2 print(ans)
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 changed = False for a, b in zip(A, A[1:]): if changed: changed = False continue if a == b: ans += 1 changed = True print(ans)
false
23.529412
[ "-src = list(map(int, input().split()))", "-prev = -1", "-seq = 1", "+A = list(map(int, input().split()))", "-for a in src:", "- if prev == a:", "- seq += 1", "- else:", "- ans += seq // 2", "- seq = 1", "- prev = a", "-if seq > 1:", "- ans += seq // 2", "+...
false
0.008618
0.039044
0.220734
[ "s745001197", "s210749859" ]
u268822556
p02657
python
s064652758
s134524285
23
20
9,152
9,024
Accepted
Accepted
13.04
A, B = list(map(int, input().split())) print((A*B))
A, B = list(map(float, input().split())) i = (int(A)*int(B*100))//100 print(i)
2
3
44
75
A, B = list(map(int, input().split())) print((A * B))
A, B = list(map(float, input().split())) i = (int(A) * int(B * 100)) // 100 print(i)
false
33.333333
[ "-A, B = list(map(int, input().split()))", "-print((A * B))", "+A, B = list(map(float, input().split()))", "+i = (int(A) * int(B * 100)) // 100", "+print(i)" ]
false
0.07459
0.042846
1.74087
[ "s064652758", "s134524285" ]
u670180528
p03781
python
s547493995
s888395414
30
17
2,940
2,940
Accepted
Accepted
43.33
x=int(eval(input())) n=1 while n*(n+1)//2<x:n+=1 print(n)
print((int((8*int(eval(input())))**.5+1)//2))
4
1
54
37
x = int(eval(input())) n = 1 while n * (n + 1) // 2 < x: n += 1 print(n)
print((int((8 * int(eval(input()))) ** 0.5 + 1) // 2))
false
75
[ "-x = int(eval(input()))", "-n = 1", "-while n * (n + 1) // 2 < x:", "- n += 1", "-print(n)", "+print((int((8 * int(eval(input()))) ** 0.5 + 1) // 2))" ]
false
0.076383
0.087588
0.872068
[ "s547493995", "s888395414" ]
u330661451
p03013
python
s428107599
s879023289
179
72
7,064
6,900
Accepted
Accepted
59.78
MOD = 1000000007 n , m = list(map(int,input().split())) count = [-1 for i in range(n+1)] for i in range(m): count[int(eval(input()))] = 0 for i in range(1,n+1): if count[i] == 0: continue if i == 1: count[i] = 1 elif i == 2: count[i] = count[i-1] + 1 ...
import sys input = sys.stdin.readline MOD = 1000000007 n , m = list(map(int,input().split())) count = [-1] * (n+1) for i in range(m): count[int(eval(input()))] = 0 for i in range(1,n+1): if count[i] == 0: continue if i == 1: count[i] = 1 elif i == 2: c...
20
23
385
415
MOD = 1000000007 n, m = list(map(int, input().split())) count = [-1 for i in range(n + 1)] for i in range(m): count[int(eval(input()))] = 0 for i in range(1, n + 1): if count[i] == 0: continue if i == 1: count[i] = 1 elif i == 2: count[i] = count[i - 1] + 1 else: coun...
import sys input = sys.stdin.readline MOD = 1000000007 n, m = list(map(int, input().split())) count = [-1] * (n + 1) for i in range(m): count[int(eval(input()))] = 0 for i in range(1, n + 1): if count[i] == 0: continue if i == 1: count[i] = 1 elif i == 2: count[i] = count[i - 1]...
false
13.043478
[ "+import sys", "+", "+input = sys.stdin.readline", "-count = [-1 for i in range(n + 1)]", "+count = [-1] * (n + 1)" ]
false
0.127889
0.042078
3.039334
[ "s428107599", "s879023289" ]
u948524308
p02947
python
s391277155
s941220571
956
771
61,696
11,428
Accepted
Accepted
19.35
import math N = int(eval(input())) s = [[""]*10 for i in range(N)] a =[[0]*26 for i in range(N)] b =[""]*N cn =ord("a") for i in range(N): s[i] = list(eval(input())) s[i].sort() b[i] ="".join(s[i]) b.sort() c = 0 ans =0 for i in range(N-1): if b[i]==b[i+1]: c +=1 el...
import math N = int(eval(input())) b =[""]*N cn =ord("a") for i in range(N): s = list(eval(input())) s.sort() b[i] ="".join(s) b.sort() c = 0 ans =0 for i in range(N-1): if b[i]==b[i+1]: c +=1 else: if c !=0: ans=ans + math.factorial(c+1)/...
32
31
554
491
import math N = int(eval(input())) s = [[""] * 10 for i in range(N)] a = [[0] * 26 for i in range(N)] b = [""] * N cn = ord("a") for i in range(N): s[i] = list(eval(input())) s[i].sort() b[i] = "".join(s[i]) b.sort() c = 0 ans = 0 for i in range(N - 1): if b[i] == b[i + 1]: c += 1 else: ...
import math N = int(eval(input())) b = [""] * N cn = ord("a") for i in range(N): s = list(eval(input())) s.sort() b[i] = "".join(s) b.sort() c = 0 ans = 0 for i in range(N - 1): if b[i] == b[i + 1]: c += 1 else: if c != 0: ans = ans + math.factorial(c + 1) / ( ...
false
3.125
[ "-s = [[\"\"] * 10 for i in range(N)]", "-a = [[0] * 26 for i in range(N)]", "- s[i] = list(eval(input()))", "- s[i].sort()", "- b[i] = \"\".join(s[i])", "+ s = list(eval(input()))", "+ s.sort()", "+ b[i] = \"\".join(s)" ]
false
0.038048
0.061061
0.623107
[ "s391277155", "s941220571" ]
u175034939
p02609
python
s150079668
s124096300
690
451
12,912
15,932
Accepted
Accepted
34.64
n = int(eval(input())) s = eval(input()) x = [int(i) for i in s] pc = s.count('1') def popcnt(x): x = x - ((x >> 1) & 0x5555555555555555) x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333) x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f x = x + (x >> 8) x = x + (x >> 16) x = x + ...
n = int(input()) s = input() int_s = [int(i) for i in s] pc = s.count('1') def f(x): bi = bin(x) pc = bi.count('1') cnt = 1 while True: if x == 0: break x = x % pc bi = bin(x) pc = bi.count('1') cnt += 1 return cnt num_pl = 0 f...
48
50
957
962
n = int(eval(input())) s = eval(input()) x = [int(i) for i in s] pc = s.count("1") def popcnt(x): x = x - ((x >> 1) & 0x5555555555555555) x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333) x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0F x = x + (x >> 8) x = x + (x >> 16) x = x + (x >> 32) ...
n = int(input()) s = input() int_s = [int(i) for i in s] pc = s.count("1") def f(x): bi = bin(x) pc = bi.count("1") cnt = 1 while True: if x == 0: break x = x % pc bi = bin(x) pc = bi.count("1") cnt += 1 return cnt num_pl = 0 for i in range(n):...
false
4
[ "-n = int(eval(input()))", "-s = eval(input())", "-x = [int(i) for i in s]", "+n = int(input())", "+s = input()", "+int_s = [int(i) for i in s]", "-def popcnt(x):", "- x = x - ((x >> 1) & 0x5555555555555555)", "- x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)", "- x = (x +...
false
0.038219
0.037427
1.021152
[ "s150079668", "s124096300" ]
u604774382
p02422
python
s254369768
s151643364
40
20
6,724
4,236
Accepted
Accepted
50
s = list( eval(input( )) ) n = int( eval(input( )) ) for i in range( n ): cmd = input( ).split( " " ) a = int( cmd[1] ) b = int( cmd[2] ) + 1 if "print" == cmd[0]: print(( "".join( s[ a:b ] ) )) elif "reverse" == cmd[0]: for i in reversed( s[ a:b ] ): s[ a ] = i a += 1 elif "replace" == cmd[...
s = list( input( ) ) n = int( input( ) ) for i in range( n ): cmd = input( ).split( " " ) a = int( cmd[1] ) b = int( cmd[2] ) + 1 if "print" == cmd[0]: print(( "".join( s[ a:b ] ) )) elif "reverse" == cmd[0]: for i, ss in enumerate( reversed( s[ a:b ] ) ): s[ a+i ] = ss elif "replace" == cmd[0]:...
16
14
355
385
s = list(eval(input())) n = int(eval(input())) for i in range(n): cmd = input().split(" ") a = int(cmd[1]) b = int(cmd[2]) + 1 if "print" == cmd[0]: print(("".join(s[a:b]))) elif "reverse" == cmd[0]: for i in reversed(s[a:b]): s[a] = i a += 1 elif "replace...
s = list(input()) n = int(input()) for i in range(n): cmd = input().split(" ") a = int(cmd[1]) b = int(cmd[2]) + 1 if "print" == cmd[0]: print(("".join(s[a:b]))) elif "reverse" == cmd[0]: for i, ss in enumerate(reversed(s[a:b])): s[a + i] = ss elif "replace" == cmd[0]...
false
12.5
[ "-s = list(eval(input()))", "-n = int(eval(input()))", "+s = list(input())", "+n = int(input())", "- for i in reversed(s[a:b]):", "- s[a] = i", "- a += 1", "+ for i, ss in enumerate(reversed(s[a:b])):", "+ s[a + i] = ss", "- for i in cmd[3]:", ...
false
0.035819
0.037479
0.955708
[ "s254369768", "s151643364" ]
u597374218
p03834
python
s235016294
s383875907
31
25
8,884
9,000
Accepted
Accepted
19.35
s=eval(input()) print((*s.split(",")))
s=input().split(",") print((*s))
2
2
31
31
s = eval(input()) print((*s.split(",")))
s = input().split(",") print((*s))
false
0
[ "-s = eval(input())", "-print((*s.split(\",\")))", "+s = input().split(\",\")", "+print((*s))" ]
false
0.040308
0.037305
1.080503
[ "s235016294", "s383875907" ]
u374103100
p02925
python
s680954867
s040026085
1,665
563
53,592
57,692
Accepted
Accepted
66.19
# import sys import time def input(): return sys.stdin.readline().strip() def main(): n = int(eval(input())) agrid = [] agrid_pointer = [0] * n start = time.time() for i in range(n): al = list(map(int, input().split())) agrid.append(al) ans = 0 while ...
# import sys from collections import deque def input(): return sys.stdin.readline().strip() def main(): n = int(eval(input())) agrid = [] agrid_pointer = [0] * n for i in range(n): al = list(map(int, input().split())) for j in range(len(al)): al[j] -= 1 ...
64
69
1,466
1,522
# import sys import time def input(): return sys.stdin.readline().strip() def main(): n = int(eval(input())) agrid = [] agrid_pointer = [0] * n start = time.time() for i in range(n): al = list(map(int, input().split())) agrid.append(al) ans = 0 while True: mat...
# import sys from collections import deque def input(): return sys.stdin.readline().strip() def main(): n = int(eval(input())) agrid = [] agrid_pointer = [0] * n for i in range(n): al = list(map(int, input().split())) for j in range(len(al)): al[j] -= 1 agrid....
false
7.246377
[ "-import time", "+from collections import deque", "- start = time.time()", "+ for j in range(len(al)):", "+ al[j] -= 1", "- while True:", "+", "+ def find_next(idx, q, m):", "+ if agrid_pointer[idx] == n - 1 or i in m: # もう全部対戦済み or この日対戦済み", "+ return...
false
0.064552
0.111715
0.577826
[ "s680954867", "s040026085" ]
u565204025
p03478
python
s386986623
s610024048
237
39
42,972
3,060
Accepted
Accepted
83.54
# -*- coding: utf-8 -*- n,a,b = list(map(int,input().split())) answer = 0 for i in range(n+1): nc = list(str(i)) nc = list(map(int,nc)) ncsum = sum(nc) nc = list(map(str,nc)) nc = int("".join(nc)) if a <= ncsum and b >= ncsum: answer += nc print(answer)
# -*- coding: utf-8 -*- n,a,b = list(map(int,input().split())) def digit_list(num): num = str(num) num = list(num) num = list(map(int,num)) return num cnt = 0 for i in range(1,n+1): temp = sum(digit_list(i)) if a <= temp <= b: cnt += i print(cnt)
16
18
299
295
# -*- coding: utf-8 -*- n, a, b = list(map(int, input().split())) answer = 0 for i in range(n + 1): nc = list(str(i)) nc = list(map(int, nc)) ncsum = sum(nc) nc = list(map(str, nc)) nc = int("".join(nc)) if a <= ncsum and b >= ncsum: answer += nc print(answer)
# -*- coding: utf-8 -*- n, a, b = list(map(int, input().split())) def digit_list(num): num = str(num) num = list(num) num = list(map(int, num)) return num cnt = 0 for i in range(1, n + 1): temp = sum(digit_list(i)) if a <= temp <= b: cnt += i print(cnt)
false
11.111111
[ "-answer = 0", "-for i in range(n + 1):", "- nc = list(str(i))", "- nc = list(map(int, nc))", "- ncsum = sum(nc)", "- nc = list(map(str, nc))", "- nc = int(\"\".join(nc))", "- if a <= ncsum and b >= ncsum:", "- answer += nc", "-print(answer)", "+", "+", "+def digit_l...
false
0.039149
0.034983
1.11909
[ "s386986623", "s610024048" ]
u832039789
p03076
python
s996997765
s812054997
263
188
64,364
38,256
Accepted
Accepted
28.52
import sys from fractions import gcd from itertools import groupby as gb from itertools import permutations as perm from itertools import combinations as comb from collections import Counter as C from collections import defaultdict as dd sys.setrecursionlimit(10**5) def y(f): if f: print('Yes') ...
from itertools import permutations as perm l = [int(eval(input())) for _ in range(5)] res = 10 ** 100 for p in perm(l): tmp = 0 for i in p: tmp = (tmp + 9) // 10 * 10 tmp += i res = min(res, tmp) print(res)
38
11
798
239
import sys from fractions import gcd from itertools import groupby as gb from itertools import permutations as perm from itertools import combinations as comb from collections import Counter as C from collections import defaultdict as dd sys.setrecursionlimit(10**5) def y(f): if f: print("Yes") else:...
from itertools import permutations as perm l = [int(eval(input())) for _ in range(5)] res = 10**100 for p in perm(l): tmp = 0 for i in p: tmp = (tmp + 9) // 10 * 10 tmp += i res = min(res, tmp) print(res)
false
71.052632
[ "-import sys", "-from fractions import gcd", "-from itertools import groupby as gb", "-from itertools import combinations as comb", "-from collections import Counter as C", "-from collections import defaultdict as dd", "-", "-sys.setrecursionlimit(10**5)", "-", "-", "-def y(f):", "- if f:",...
false
0.049394
0.046216
1.068778
[ "s996997765", "s812054997" ]
u886633618
p03044
python
s918025750
s628494182
823
701
108,960
81,300
Accepted
Accepted
14.82
N = int(eval(input())) node_array = [list(map(int, input().split())) for i in range(N - 1)] # print(node_array) tree_num_array = [-1] * N # print(tree_num_array) tree_num_max = -1 tree = {} last_tree_num = -1 for node in node_array: # print(tree) i, j, w = node i = i - 1 j = j - 1 if ...
from sys import setrecursionlimit setrecursionlimit(10**8) def dfs(i, d): # print(i, d) for j, w in node_array[i]: if color_array[j] == -1: color_array[j] = (d + w) % 2 dfs(j, d + w) N = int(eval(input())) node_array = [[] for i in range(N)] color_array = [-1] *...
59
26
2,124
550
N = int(eval(input())) node_array = [list(map(int, input().split())) for i in range(N - 1)] # print(node_array) tree_num_array = [-1] * N # print(tree_num_array) tree_num_max = -1 tree = {} last_tree_num = -1 for node in node_array: # print(tree) i, j, w = node i = i - 1 j = j - 1 if tree_num_array[...
from sys import setrecursionlimit setrecursionlimit(10**8) def dfs(i, d): # print(i, d) for j, w in node_array[i]: if color_array[j] == -1: color_array[j] = (d + w) % 2 dfs(j, d + w) N = int(eval(input())) node_array = [[] for i in range(N)] color_array = [-1] * N for _ in r...
false
55.932203
[ "+from sys import setrecursionlimit", "+", "+setrecursionlimit(10**8)", "+", "+", "+def dfs(i, d):", "+ # print(i, d)", "+ for j, w in node_array[i]:", "+ if color_array[j] == -1:", "+ color_array[j] = (d + w) % 2", "+ dfs(j, d + w)", "+", "+", "-node_arr...
false
0.043258
0.044594
0.970032
[ "s918025750", "s628494182" ]
u203843959
p03964
python
s248103195
s295946496
39
20
5,052
3,064
Accepted
Accepted
48.72
import fractions N=int(eval(input())) vt=va=0 for _ in range(N): T,A=list(map(int,input().split())) kt=-(-vt//T) ka=-(-va//A) if kt==0 and ka==0: vt=T va=A else: k=max(kt,ka) vt=k*T va=k*A #print(vt,va) print((vt+va))
N=int(eval(input())) vt=va=0 for _ in range(N): T,A=list(map(int,input().split())) kt=-(-vt//T) ka=-(-va//A) k=max(kt,ka,1) vt=k*T va=k*A #print(vt,va) print((vt+va))
19
14
260
188
import fractions N = int(eval(input())) vt = va = 0 for _ in range(N): T, A = list(map(int, input().split())) kt = -(-vt // T) ka = -(-va // A) if kt == 0 and ka == 0: vt = T va = A else: k = max(kt, ka) vt = k * T va = k * A # print(vt,va) print((vt + va...
N = int(eval(input())) vt = va = 0 for _ in range(N): T, A = list(map(int, input().split())) kt = -(-vt // T) ka = -(-va // A) k = max(kt, ka, 1) vt = k * T va = k * A # print(vt,va) print((vt + va))
false
26.315789
[ "-import fractions", "-", "- if kt == 0 and ka == 0:", "- vt = T", "- va = A", "- else:", "- k = max(kt, ka)", "- vt = k * T", "- va = k * A", "+ k = max(kt, ka, 1)", "+ vt = k * T", "+ va = k * A" ]
false
0.088578
0.063172
1.402168
[ "s248103195", "s295946496" ]
u587821863
p00491
python
s623849898
s965715061
40
30
6,760
6,752
Accepted
Accepted
25
#f = open("input.txt") #N, K = [int(x) for x in f.readline().split(' ')] #lines = f.readlines() #f.close() import sys N, K = [int(x) for x in sys.stdin.readline().split(' ')] lines = sys.stdin.readlines() schedule = [0]*N for line in lines: strs = line.split(' ') schedule[int(strs[0])-1] = int(str...
#f = open("input.txt") #N, K = [int(x) for x in f.readline().split(' ')] #lines = f.readlines() #f.close() from sys import stdin N, K = [int(x) for x in stdin.readline().split(' ')] lines = stdin.readlines() schedule = [0]*N for line in lines: strs = line.split(' ') schedule[int(strs[0])-1] = int(st...
39
32
948
846
# f = open("input.txt") # N, K = [int(x) for x in f.readline().split(' ')] # lines = f.readlines() # f.close() import sys N, K = [int(x) for x in sys.stdin.readline().split(" ")] lines = sys.stdin.readlines() schedule = [0] * N for line in lines: strs = line.split(" ") schedule[int(strs[0]) - 1] = int(strs[1])...
# f = open("input.txt") # N, K = [int(x) for x in f.readline().split(' ')] # lines = f.readlines() # f.close() from sys import stdin N, K = [int(x) for x in stdin.readline().split(" ")] lines = stdin.readlines() schedule = [0] * N for line in lines: strs = line.split(" ") schedule[int(strs[0]) - 1] = int(strs[...
false
17.948718
[ "-import sys", "+from sys import stdin", "-N, K = [int(x) for x in sys.stdin.readline().split(\" \")]", "-lines = sys.stdin.readlines()", "+N, K = [int(x) for x in stdin.readline().split(\" \")]", "+lines = stdin.readlines()", "-number = [0] * 9", "+number = [1] * 9", "- else:", "- numbe...
false
0.037957
0.036973
1.026619
[ "s623849898", "s965715061" ]
u729133443
p03062
python
s801341909
s354026353
277
185
74,016
26,192
Accepted
Accepted
33.21
_,a=open(0);b,c=list(zip(*[(abs(i),i<0)for i in map(int,a.split())]));print((sum(b)-sum(c)%2*min(b)*2))
from numpy import*;_,a=open(0);a=int64(a.split());b=abs(a);print((sum(b)-sum(a<0)%2*min(b)*2))
1
1
95
92
_, a = open(0) b, c = list(zip(*[(abs(i), i < 0) for i in map(int, a.split())])) print((sum(b) - sum(c) % 2 * min(b) * 2))
from numpy import * _, a = open(0) a = int64(a.split()) b = abs(a) print((sum(b) - sum(a < 0) % 2 * min(b) * 2))
false
0
[ "+from numpy import *", "+", "-b, c = list(zip(*[(abs(i), i < 0) for i in map(int, a.split())]))", "-print((sum(b) - sum(c) % 2 * min(b) * 2))", "+a = int64(a.split())", "+b = abs(a)", "+print((sum(b) - sum(a < 0) % 2 * min(b) * 2))" ]
false
0.036573
0.512492
0.071363
[ "s801341909", "s354026353" ]
u241159583
p03331
python
s376445321
s947338773
212
156
3,060
9,212
Accepted
Accepted
26.42
n = int(eval(input())) N = n//2 ans = float("INF") for i in range(1,N+1): a,b = list(str(i)), list(str(n-i)) A,B = sum(list(map(int, a))), sum(list(map(int, b))) if ans > A+B: ans = A+B print(ans)
n = int(eval(input())) ans = 10**5+1 for a in range(1, n//2+1): a,b = list(str(a)), list(str(n-a)) ans = min(ans, sum(list(map(int, a)))+sum(list(map(int, b)))) print(ans)
8
6
203
178
n = int(eval(input())) N = n // 2 ans = float("INF") for i in range(1, N + 1): a, b = list(str(i)), list(str(n - i)) A, B = sum(list(map(int, a))), sum(list(map(int, b))) if ans > A + B: ans = A + B print(ans)
n = int(eval(input())) ans = 10**5 + 1 for a in range(1, n // 2 + 1): a, b = list(str(a)), list(str(n - a)) ans = min(ans, sum(list(map(int, a))) + sum(list(map(int, b)))) print(ans)
false
25
[ "-N = n // 2", "-ans = float(\"INF\")", "-for i in range(1, N + 1):", "- a, b = list(str(i)), list(str(n - i))", "- A, B = sum(list(map(int, a))), sum(list(map(int, b)))", "- if ans > A + B:", "- ans = A + B", "+ans = 10**5 + 1", "+for a in range(1, n // 2 + 1):", "+ a, b = list...
false
0.088012
0.086559
1.01679
[ "s376445321", "s947338773" ]
u753803401
p03645
python
s646431710
s613820090
512
388
80,604
78,172
Accepted
Accepted
24.22
import sys import collections def solve(): sys.setrecursionlimit(2000) input = sys.stdin.readline mod = 10 ** 9 + 7 n, m = list(map(int, input().rstrip('\n').split())) d = collections.defaultdict(list) for i in range(m): a, b = list(map(int, input().rstrip('\n').split())) ...
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 n, m = list(map(int, readline().split())) d = collections.defaultdict(list) for _ in range(m): a, b = list(map(int, readline().split())) if a == 1 or a == n: if...
29
27
672
674
import sys import collections def solve(): sys.setrecursionlimit(2000) input = sys.stdin.readline mod = 10**9 + 7 n, m = list(map(int, input().rstrip("\n").split())) d = collections.defaultdict(list) for i in range(m): a, b = list(map(int, input().rstrip("\n").split())) if a ==...
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 n, m = list(map(int, readline().split())) d = collections.defaultdict(list) for _ in range(m): a, b = list(map(int, readline().split())) if a == 1 or a == n: if a not in d[b]...
false
6.896552
[ "- sys.setrecursionlimit(2000)", "- input = sys.stdin.readline", "+ readline = sys.stdin.buffer.readline", "- n, m = list(map(int, input().rstrip(\"\\n\").split()))", "+ n, m = list(map(int, readline().split()))", "- for i in range(m):", "- a, b = list(map(int, input().rstrip(\"...
false
0.120293
0.038027
3.163323
[ "s646431710", "s613820090" ]
u448994613
p02615
python
s087636238
s260336087
1,162
478
117,752
117,552
Accepted
Accepted
58.86
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right from collections import defaultdict from heapq import heappop, heappush import itertools import random from collections import deque from decimal import * import queue input = sys.stdin.readline ...
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right from collections import defaultdict from heapq import heappop, heappush import itertools import random from collections import deque from decimal import * import queue input = sys.stdin.readline ...
61
55
1,222
1,153
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right from collections import defaultdict from heapq import heappop, heappush import itertools import random from collections import deque from decimal import * import queue input = sys.stdin.readline def inputInt...
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right from collections import defaultdict from heapq import heappop, heappush import itertools import random from collections import deque from decimal import * import queue input = sys.stdin.readline def inputInt...
false
9.836066
[ "- if tmp == val:", "- pgt.put(val)", "- else:", "- pgt.put(val)", "- # print(ansans)", "+ pgt.put(val)" ]
false
0.039367
0.046753
0.842019
[ "s087636238", "s260336087" ]
u796060588
p03479
python
s697093939
s736924068
949
17
2,568
3,192
Accepted
Accepted
98.21
# vim: set fileencoding=utf-8: """ X,Yの区間は[1, pow(10,18)]であり、全探索すると日が暮れる。 厳密には、区間[X, Y]のすべてを検証する必要はないはずで、 [X, 2*X]でいいはずである。たぶん。 """ def main(): X, Y = list(map(int, input().split())) ans = 0 temp = 0 X2 = 2 * X ct = 0 for i, _ in enumerate(range(X2), X): ct += 1 ...
#!/usr/bin/python3 # vim: set fileencoding=utf-8: import sys input = sys.stdin.readline """ H = int(input()) h = [int(ele) for ele in input().split()] h = [0] + h """ def main(): A = [] X, Y = list(map(int, input().split())) n = X A.append(n) while n * 2 <= Y: n = n*2 ...
34
140
555
2,724
# vim: set fileencoding=utf-8: """ X,Yの区間は[1, pow(10,18)]であり、全探索すると日が暮れる。 厳密には、区間[X, Y]のすべてを検証する必要はないはずで、 [X, 2*X]でいいはずである。たぶん。 """ def main(): X, Y = list(map(int, input().split())) ans = 0 temp = 0 X2 = 2 * X ct = 0 for i, _ in enumerate(range(X2), X): ct += 1 n = i w...
#!/usr/bin/python3 # vim: set fileencoding=utf-8: import sys input = sys.stdin.readline """ H = int(input()) h = [int(ele) for ele in input().split()] h = [0] + h """ def main(): A = [] X, Y = list(map(int, input().split())) n = X A.append(n) while n * 2 <= Y: n = n * 2 A.append(n...
false
75.714286
[ "+#!/usr/bin/python3", "+import sys", "+", "+input = sys.stdin.readline", "-X,Yの区間は[1, pow(10,18)]であり、全探索すると日が暮れる。", "-厳密には、区間[X, Y]のすべてを検証する必要はないはずで、", "-[X, 2*X]でいいはずである。たぶん。", "+H = int(input())", "+h = [int(ele) for ele in input().split()]", "+h = [0] + h", "+ A = []", "- ans = 0", ...
false
0.798234
0.050019
15.958771
[ "s697093939", "s736924068" ]
u077291787
p03878
python
s194622809
s932362420
417
345
28,328
28,536
Accepted
Accepted
17.27
# cf16-exhibition-final-openA - 1D Matching import sys input = sys.stdin.readline def calc(x, y, total): MOD = 10 ** 9 + 7 if y: total = (total * y) % MOD y -= 1 else: x += 1 return x, y, total def main(): N = int(eval(input())) A = tuple(map(int, [eval(i...
# cf16-exhibition-final-openA - 1D Matching def calc(x, y, total): if y: total = (total * y) % MOD y -= 1 else: x += 1 return x, y, total def main(): global MOD # sort A, B and the lines between A, B shouldn't cross # cross <-> not min distance N, *AB ...
29
28
693
675
# cf16-exhibition-final-openA - 1D Matching import sys input = sys.stdin.readline def calc(x, y, total): MOD = 10**9 + 7 if y: total = (total * y) % MOD y -= 1 else: x += 1 return x, y, total def main(): N = int(eval(input())) A = tuple(map(int, [eval(input()) for _ ...
# cf16-exhibition-final-openA - 1D Matching def calc(x, y, total): if y: total = (total * y) % MOD y -= 1 else: x += 1 return x, y, total def main(): global MOD # sort A, B and the lines between A, B shouldn't cross # cross <-> not min distance N, *AB = list(map(int...
false
3.448276
[ "-import sys", "-", "-input = sys.stdin.readline", "-", "-", "- MOD = 10**9 + 7", "- N = int(eval(input()))", "- A = tuple(map(int, [eval(input()) for _ in range(N)]))", "- B = tuple(map(int, [eval(input()) for _ in range(N)]))", "- C = sorted([(i, 1) for i in A] + [(i, 0) for i in ...
false
0.178321
0.007498
23.782554
[ "s194622809", "s932362420" ]
u888337853
p02924
python
s206154455
s059409139
157
17
13,664
2,940
Accepted
Accepted
89.17
import math import copy import sys import fractions import numpy as np from functools import reduce # ===FUNCTION=== def getInputInt(): inputNum = int(eval(input())) return inputNum def getInputListInt(): outputoData = [] inputData = input().split() outputData = [int(n) for n in i...
import sys # import math # import bisect # import copy # import heapq # from collections import deque # import decimal # sys.setrecursionlimit(100001) # INF = sys.maxsize # MOD = 10 ** 9 + 7 ni = lambda: int(sys.stdin.readline()) ns = lambda: list(map(int, sys.stdin.readline().split())) na = lambda:...
52
29
1,023
491
import math import copy import sys import fractions import numpy as np from functools import reduce # ===FUNCTION=== def getInputInt(): inputNum = int(eval(input())) return inputNum def getInputListInt(): outputoData = [] inputData = input().split() outputData = [int(n) for n in inputData] re...
import sys # import math # import bisect # import copy # import heapq # from collections import deque # import decimal # sys.setrecursionlimit(100001) # INF = sys.maxsize # MOD = 10 ** 9 + 7 ni = lambda: int(sys.stdin.readline()) ns = lambda: list(map(int, sys.stdin.readline().split())) na = lambda: list(map(int, sys....
false
44.230769
[ "-import math", "-import copy", "-import fractions", "-import numpy as np", "-from functools import reduce", "-# ===FUNCTION===", "-def getInputInt():", "- inputNum = int(eval(input()))", "- return inputNum", "+# import math", "+# import bisect", "+# import copy", "+# import heapq", ...
false
0.047527
0.043029
1.104519
[ "s206154455", "s059409139" ]
u475675023
p02702
python
s085564926
s938886246
324
92
9,196
9,340
Accepted
Accepted
71.6
s=eval(input()) ans=0 u=0 l=[0]*2019 l[0]=1 for i,n in enumerate(map(int,s)): u=(u+n*pow(10,len(s)-i,2019))%2019 l[u]+=1 for i in l: ans+=i*(i-1)//2 print(ans)
s=input()[::-1] ans=0 u=0 d=1 l=[0]*2019 l[0]=1 for i in map(int,s): u=(u+i*d)%2019 l[u]+=1 d=d*10%2019 for i in l: ans+=i*(i-1)//2 print(ans)
11
13
169
162
s = eval(input()) ans = 0 u = 0 l = [0] * 2019 l[0] = 1 for i, n in enumerate(map(int, s)): u = (u + n * pow(10, len(s) - i, 2019)) % 2019 l[u] += 1 for i in l: ans += i * (i - 1) // 2 print(ans)
s = input()[::-1] ans = 0 u = 0 d = 1 l = [0] * 2019 l[0] = 1 for i in map(int, s): u = (u + i * d) % 2019 l[u] += 1 d = d * 10 % 2019 for i in l: ans += i * (i - 1) // 2 print(ans)
false
15.384615
[ "-s = eval(input())", "+s = input()[::-1]", "+d = 1", "-for i, n in enumerate(map(int, s)):", "- u = (u + n * pow(10, len(s) - i, 2019)) % 2019", "+for i in map(int, s):", "+ u = (u + i * d) % 2019", "+ d = d * 10 % 2019" ]
false
0.044013
0.043729
1.006488
[ "s085564926", "s938886246" ]
u585482323
p03329
python
s638002148
s114043965
233
208
41,200
39,280
Accepted
Accepted
10.73
#!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 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, ...
77
89
1,337
1,456
#!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 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...
false
13.483146
[ "- l[i] = SR()", "+ l[i] = LS()", "+sys.setrecursionlimit(1000000)", "- return", "-", "-", "-# B", "-def B():", "- return", "-", "-", "-# C", "-def C():", "- ans = min(ans, m)", "+ if m < ans:", "+ ans = m", "+ return", "+", "+", ...
false
0.122852
0.070229
1.74931
[ "s638002148", "s114043965" ]
u392319141
p02930
python
s895069891
s705655176
552
139
63,192
3,952
Accepted
Accepted
74.82
import sys import heapq from operator import itemgetter from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 10**9 + 7 def sol(): N = int(input()) for i in range(1, N): for j in ran...
N = int(eval(input())) for i in range(N - 1): row = [] for j in range(i + 1, N): d = 0 while (i & (1 << d)) == (j & (1 << d)): d += 1 row.append(d + 1) print((*row))
21
10
529
216
import sys import heapq from operator import itemgetter from collections import deque, defaultdict, Counter from bisect import bisect_left, bisect_right input = sys.stdin.readline sys.setrecursionlimit(10**7) MOD = 10**9 + 7 def sol(): N = int(input()) for i in range(1, N): for j in range(i + 1, N + ...
N = int(eval(input())) for i in range(N - 1): row = [] for j in range(i + 1, N): d = 0 while (i & (1 << d)) == (j & (1 << d)): d += 1 row.append(d + 1) print((*row))
false
52.380952
[ "-import sys", "-import heapq", "-from operator import itemgetter", "-from collections import deque, defaultdict, Counter", "-from bisect import bisect_left, bisect_right", "-", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-MOD = 10**9 + 7", "-", "-", "-def sol():", "- ...
false
0.054619
0.125916
0.433773
[ "s895069891", "s705655176" ]
u009348313
p02720
python
s384329287
s259829574
323
266
91,440
52,048
Accepted
Accepted
17.65
K = int(eval(input())) ans = [] R = [[] for _ in range(11)] for i in range(1,10): R[0].append(i) for i in range(1,11): R[i] = [10**i] if i > 1: for j in range(i-1): for r in R[i-2-j]: d = r//(10**(i-2-j)) if d <= 1: R[i].append(10**i+r) for r in R[i-1]: d = ...
from heapq import heappush, heappop K = int(eval(input())) hq = [] for i in range(1,10): heappush(hq,i) cnt = 0 while(cnt < K): x = heappop(hq) cnt += 1 for i in [-1,0,1]: d = (x%10)+i if 0 <= d <= 9: heappush(hq,x*10+d) print(x)
34
15
690
261
K = int(eval(input())) ans = [] R = [[] for _ in range(11)] for i in range(1, 10): R[0].append(i) for i in range(1, 11): R[i] = [10**i] if i > 1: for j in range(i - 1): for r in R[i - 2 - j]: d = r // (10 ** (i - 2 - j)) if d <= 1: R[i]...
from heapq import heappush, heappop K = int(eval(input())) hq = [] for i in range(1, 10): heappush(hq, i) cnt = 0 while cnt < K: x = heappop(hq) cnt += 1 for i in [-1, 0, 1]: d = (x % 10) + i if 0 <= d <= 9: heappush(hq, x * 10 + d) print(x)
false
55.882353
[ "+from heapq import heappush, heappop", "+", "-ans = []", "-R = [[] for _ in range(11)]", "+hq = []", "- R[0].append(i)", "-for i in range(1, 11):", "- R[i] = [10**i]", "- if i > 1:", "- for j in range(i - 1):", "- for r in R[i - 2 - j]:", "- d = r // ...
false
1.155127
0.078409
14.732078
[ "s384329287", "s259829574" ]
u887207211
p03219
python
s932857076
s951276477
19
17
2,940
2,940
Accepted
Accepted
10.53
def ans(): X, Y = list(map(int,input().split())) print((X+Y//2)) ans()
X, Y = list(map(int,input().split())) print((X+Y//2))
4
2
69
46
def ans(): X, Y = list(map(int, input().split())) print((X + Y // 2)) ans()
X, Y = list(map(int, input().split())) print((X + Y // 2))
false
50
[ "-def ans():", "- X, Y = list(map(int, input().split()))", "- print((X + Y // 2))", "-", "-", "-ans()", "+X, Y = list(map(int, input().split()))", "+print((X + Y // 2))" ]
false
0.073349
0.071303
1.028693
[ "s932857076", "s951276477" ]
u564902833
p03049
python
s532921963
s312688908
285
36
48,216
3,700
Accepted
Accepted
87.37
N = int(eval(input())) s = [eval(input()) for _ in range(N)] k = sum(t.count('AB') for t in s) ab = sum(t[-1] == 'A' and t[0] == 'B' for t in s) a = sum(t[-1] == 'A' and t[0] != 'B' for t in s) b = sum(t[-1] != 'A' and t[0] == 'B' for t in s) ans = k isA = False if a > 0: a -= 1 isA = True if ab > ...
# 入力 N = int(eval(input())) s = [eval(input()) for _ in range(N)] # 先頭がBである/ではない、末尾がAである/ではない文字列の個数を数え上げる a = sum(t[0] != 'B' and t[-1] == 'A' for t in s) b = sum(t[0] == 'B' and t[-1] != 'A' for t in s) ba = sum(t[0] == 'B' and t[-1] == 'A' for t in s) # 最初に、先頭文字がBではない、かつ、末尾文字がAの文字列を先頭におく(そのような文字列が存在すれば) #...
26
27
514
646
N = int(eval(input())) s = [eval(input()) for _ in range(N)] k = sum(t.count("AB") for t in s) ab = sum(t[-1] == "A" and t[0] == "B" for t in s) a = sum(t[-1] == "A" and t[0] != "B" for t in s) b = sum(t[-1] != "A" and t[0] == "B" for t in s) ans = k isA = False if a > 0: a -= 1 isA = True if ab > 0: if isA...
# 入力 N = int(eval(input())) s = [eval(input()) for _ in range(N)] # 先頭がBである/ではない、末尾がAである/ではない文字列の個数を数え上げる a = sum(t[0] != "B" and t[-1] == "A" for t in s) b = sum(t[0] == "B" and t[-1] != "A" for t in s) ba = sum(t[0] == "B" and t[-1] == "A" for t in s) # 最初に、先頭文字がBではない、かつ、末尾文字がAの文字列を先頭におく(そのような文字列が存在すれば) # 次に、先頭文字がB、か...
false
3.703704
[ "+# 入力", "-k = sum(t.count(\"AB\") for t in s)", "-ab = sum(t[-1] == \"A\" and t[0] == \"B\" for t in s)", "-a = sum(t[-1] == \"A\" and t[0] != \"B\" for t in s)", "-b = sum(t[-1] != \"A\" and t[0] == \"B\" for t in s)", "-ans = k", "-isA = False", "-if a > 0:", "- a -= 1", "- isA = True", ...
false
0.084321
0.046263
1.822645
[ "s532921963", "s312688908" ]
u411203878
p03700
python
s207263631
s258911541
743
186
52,460
81,596
Accepted
Accepted
74.97
n, a, b = list(map(int, input().split())) h = [int(eval(input())) for _ in range(n)] import math def ok(x): t = 0 for i in range(n): r = h[i] - b*x if r < 0: continue else: t += math.ceil(r/(a-b)) if t <= x: return True else: ...
N,A,B = list(map(int,input().split())) H = [] for _ in range(N): h = int(eval(input())) H.append(h) ok = 1000000000 ng = 0 while ok != ng+1: mid = (ok+ng)//2 range_damage = mid*B attack_count = 0 for value in H: if range_damage < value: if (value - range_dama...
26
25
447
557
n, a, b = list(map(int, input().split())) h = [int(eval(input())) for _ in range(n)] import math def ok(x): t = 0 for i in range(n): r = h[i] - b * x if r < 0: continue else: t += math.ceil(r / (a - b)) if t <= x: return True else: return...
N, A, B = list(map(int, input().split())) H = [] for _ in range(N): h = int(eval(input())) H.append(h) ok = 1000000000 ng = 0 while ok != ng + 1: mid = (ok + ng) // 2 range_damage = mid * B attack_count = 0 for value in H: if range_damage < value: if (value - range_damage) % ...
false
3.846154
[ "-n, a, b = list(map(int, input().split()))", "-h = [int(eval(input())) for _ in range(n)]", "-import math", "-", "-", "-def ok(x):", "- t = 0", "- for i in range(n):", "- r = h[i] - b * x", "- if r < 0:", "- continue", "- else:", "- t += math...
false
0.044773
0.043412
1.031365
[ "s207263631", "s258911541" ]
u600402037
p03401
python
s381258078
s836679300
231
211
14,048
14,048
Accepted
Accepted
8.66
N = int(eval(input())) A = [0] + [int(x) for x in input().split()] + [0] cnt = 0 for i in range(N+1): cnt += abs(A[i+1]-A[i]) for j in range(1, N+1): print((cnt - (abs(A[j]-A[j-1]) + abs(A[j+1]-A[j])) + abs(A[j+1]-A[j-1])))
N = int(eval(input())) A = [0] + [int(x) for x in input().split()] + [0] cnt = sum(abs(A[i+1] - A[i]) for i in range(N+1)) for j in range(1, N+1): print((cnt - (abs(A[j]-A[j-1]) + abs(A[j+1]-A[j])) + abs(A[j+1]-A[j-1])))
9
7
237
225
N = int(eval(input())) A = [0] + [int(x) for x in input().split()] + [0] cnt = 0 for i in range(N + 1): cnt += abs(A[i + 1] - A[i]) for j in range(1, N + 1): print( (cnt - (abs(A[j] - A[j - 1]) + abs(A[j + 1] - A[j])) + abs(A[j + 1] - A[j - 1])) )
N = int(eval(input())) A = [0] + [int(x) for x in input().split()] + [0] cnt = sum(abs(A[i + 1] - A[i]) for i in range(N + 1)) for j in range(1, N + 1): print( (cnt - (abs(A[j] - A[j - 1]) + abs(A[j + 1] - A[j])) + abs(A[j + 1] - A[j - 1])) )
false
22.222222
[ "-cnt = 0", "-for i in range(N + 1):", "- cnt += abs(A[i + 1] - A[i])", "+cnt = sum(abs(A[i + 1] - A[i]) for i in range(N + 1))" ]
false
0.119239
0.037837
3.151386
[ "s381258078", "s836679300" ]
u017810624
p02936
python
s905786032
s811657771
1,946
967
157,320
148,956
Accepted
Accepted
50.31
n,q=list(map(int,input().split())) l=[] for i in range(n-1): l.append(list(map(int,input().split()))) l2=[] for i in range(q): l2.append(list(map(int,input().split()))) connection=[[] for i in range(n)] for i in range(n-1): connection[l[i][0]-1].append(l[i][1]-1) L4=[] for i in range(n): L4.appen...
import sys input=sys.stdin.readline n,q=list(map(int,input().split())) l=[] for i in range(n-1): l.append(list(map(int,input().split()))) l2=[] for i in range(q): l2.append(list(map(int,input().split()))) connection=[[] for i in range(n)] for i in range(n-1): connection[l[i][0]-1].append(l[i][1]-1) ...
34
36
826
864
n, q = list(map(int, input().split())) l = [] for i in range(n - 1): l.append(list(map(int, input().split()))) l2 = [] for i in range(q): l2.append(list(map(int, input().split()))) connection = [[] for i in range(n)] for i in range(n - 1): connection[l[i][0] - 1].append(l[i][1] - 1) L4 = [] for i in range(n...
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) l = [] for i in range(n - 1): l.append(list(map(int, input().split()))) l2 = [] for i in range(q): l2.append(list(map(int, input().split()))) connection = [[] for i in range(n)] for i in range(n - 1): connection[l[i][0] - 1].appen...
false
5.555556
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.033658
0.037328
0.901682
[ "s905786032", "s811657771" ]
u375616706
p02863
python
s431227213
s192732932
857
460
120,920
47,976
Accepted
Accepted
46.32
N,T = list(map(int,input().split())) item=[list(map(int,input().split())) for _ in range(N)] item = sorted(item,key=lambda x:x[0]) dp=[[0]*(T+1) for _ in range(N+1)] for i,(a,b) in enumerate(item,1): for t in reversed(list(range(T))): dist=min(T,t+a) dp[i][dist] = max(dp[i-1][t]+b,dp[i...
N,T = list(map(int,input().split())) item=[list(map(int,input().split())) for _ in range(N)] item = sorted(item,key=lambda x:x[0]) dp=[0]*(T+1) for a,b in item: for t in reversed(list(range(T))): dist=min(T,t+a) dp[dist] = max(dp[t]+b,dp[dist]) print((max(dp)))
16
12
420
282
N, T = list(map(int, input().split())) item = [list(map(int, input().split())) for _ in range(N)] item = sorted(item, key=lambda x: x[0]) dp = [[0] * (T + 1) for _ in range(N + 1)] for i, (a, b) in enumerate(item, 1): for t in reversed(list(range(T))): dist = min(T, t + a) dp[i][dist] = max(dp[i - 1...
N, T = list(map(int, input().split())) item = [list(map(int, input().split())) for _ in range(N)] item = sorted(item, key=lambda x: x[0]) dp = [0] * (T + 1) for a, b in item: for t in reversed(list(range(T))): dist = min(T, t + a) dp[dist] = max(dp[t] + b, dp[dist]) print((max(dp)))
false
25
[ "-dp = [[0] * (T + 1) for _ in range(N + 1)]", "-for i, (a, b) in enumerate(item, 1):", "+dp = [0] * (T + 1)", "+for a, b in item:", "- dp[i][dist] = max(dp[i - 1][t] + b, dp[i][dist])", "- dp[i][t] = max(dp[i - 1][t], dp[i - 1][t])", "-ans = 0", "-for l in dp:", "- ans = max(ans, m...
false
0.173244
0.08594
2.015878
[ "s431227213", "s192732932" ]
u935558307
p02787
python
s632587506
s344823168
1,148
378
21,528
42,348
Accepted
Accepted
67.07
#モンスターの体力は H #トキはN種類の魔法が使え、 #i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、 #トキの魔力を Bi消耗します。 #dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値 #dp[i+1] = min(dp[i-Ai]+Bi,dp[i]) #dp[0]=0 import numpy as np h, n = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab = np.array(ab) a = ...
h, n = list(map(int, input().split())) a = [] b = [] for i in range(n): a_, b_ = list(map(int, input().split())) a.append(a_) b.append(b_) dp = [10**9] * (h+1) dp[0] = 0 for i in range(1, h+1): for j in range(n): dp[i] = min(dp[i], dp[max(i-a[j], 0)] + b[j]) print((dp[-1]))
22
16
447
303
# モンスターの体力は H # トキはN種類の魔法が使え、 # i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、 # トキの魔力を Bi消耗します。 # dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値 # dp[i+1] = min(dp[i-Ai]+Bi,dp[i]) # dp[0]=0 import numpy as np h, n = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab = np.array(ab) a = ab[:, 0] b = ...
h, n = list(map(int, input().split())) a = [] b = [] for i in range(n): a_, b_ = list(map(int, input().split())) a.append(a_) b.append(b_) dp = [10**9] * (h + 1) dp[0] = 0 for i in range(1, h + 1): for j in range(n): dp[i] = min(dp[i], dp[max(i - a[j], 0)] + b[j]) print((dp[-1]))
false
27.272727
[ "-# モンスターの体力は H", "-# トキはN種類の魔法が使え、", "-# i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、", "-# トキの魔力を Bi消耗します。", "-# dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値", "-# dp[i+1] = min(dp[i-Ai]+Bi,dp[i])", "-# dp[0]=0", "-import numpy as np", "-", "-ab = [list(map(int, input().split())) for _ in range(n)]", "-ab = np....
false
0.220151
0.089762
2.452608
[ "s632587506", "s344823168" ]
u197300773
p02845
python
s776834819
s946006475
178
69
14,396
13,964
Accepted
Accepted
61.24
def main(): import sys N=int(eval(input())) MOD=1000000007 a=list(map(int,input().split())) c=[0,0,0] ans=1 for i in range(N): if a[i]!=c[0] and a[i]!=c[1] and a[i]!=c[2]: print((0)) sys.exit() if c[1]==c[0] and c[2]==c[0]: ...
def main(): import sys N=int(eval(input())) MOD=1000000007 a=list(map(int,input().split())) c=[3]+[0]*N ans=1 for i in range(N): p=a[i] ans=ans*c[p]%MOD c[p]-=1 c[p+1]+=1 print(ans) if __name__ == '__main__': main()
44
20
924
307
def main(): import sys N = int(eval(input())) MOD = 1000000007 a = list(map(int, input().split())) c = [0, 0, 0] ans = 1 for i in range(N): if a[i] != c[0] and a[i] != c[1] and a[i] != c[2]: print((0)) sys.exit() if c[1] == c[0] and c[2] == c[0]: ...
def main(): import sys N = int(eval(input())) MOD = 1000000007 a = list(map(int, input().split())) c = [3] + [0] * N ans = 1 for i in range(N): p = a[i] ans = ans * c[p] % MOD c[p] -= 1 c[p + 1] += 1 print(ans) if __name__ == "__main__": main()
false
54.545455
[ "- c = [0, 0, 0]", "+ c = [3] + [0] * N", "- if a[i] != c[0] and a[i] != c[1] and a[i] != c[2]:", "- print((0))", "- sys.exit()", "- if c[1] == c[0] and c[2] == c[0]:", "- ans = (ans * 3) % MOD", "- c[0] += 1", "- elif c[0] == c[...
false
0.123238
0.134913
0.913458
[ "s776834819", "s946006475" ]
u232852711
p03999
python
s189864172
s972622902
38
29
3,572
3,444
Accepted
Accepted
23.68
from copy import deepcopy s = eval(input()) length = len(s) ans = 0 def solve(s_split, s, i): if i == length: # print(s_split) global ans ans += sum(list(map(int, s_split))) else: tmp1 = deepcopy(s_split) tmp1[-1] += s[0] solve(tmp1, s[1:], i+1) ...
from copy import deepcopy s = eval(input()) length = len(s) ans = 0 def solve(s_split, s, i): if i == length: # print(s_split) global ans ans += sum(list(map(int, s_split))) else: tmp1 = deepcopy(s_split) tmp1[-1] += s[0] solve(tmp1, s[1:], i+1) ...
21
21
454
452
from copy import deepcopy s = eval(input()) length = len(s) ans = 0 def solve(s_split, s, i): if i == length: # print(s_split) global ans ans += sum(list(map(int, s_split))) else: tmp1 = deepcopy(s_split) tmp1[-1] += s[0] solve(tmp1, s[1:], i + 1) tmp2 ...
from copy import deepcopy s = eval(input()) length = len(s) ans = 0 def solve(s_split, s, i): if i == length: # print(s_split) global ans ans += sum(list(map(int, s_split))) else: tmp1 = deepcopy(s_split) tmp1[-1] += s[0] solve(tmp1, s[1:], i + 1) tmp2 ...
false
0
[ "-solve([\"0\"], s, 0)", "-print((int(ans / 2)))", "+solve([s[0]], s[1:], 1)", "+print(ans)" ]
false
0.037935
0.038082
0.996153
[ "s189864172", "s972622902" ]
u325264482
p03363
python
s972325738
s267898053
395
198
48,488
48,144
Accepted
Accepted
49.87
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) S = [0] for i, a in enumerate(A): S.append(S[i] + a) S = sorted(S) a = Counter(S).most_common() cnt = 0 for i in range(len(a)): cnt += ((a[i][1]-1)*a[i][1])//2 print(cnt)
from itertools import accumulate import collections N = int(eval(input())) A = list(map(int, input().split())) def main(): # 累積和 B = [0] + A B = list(accumulate(B)) c = collections.Counter(B) cm = c.most_common() cnt = 0 for v in cm: if v[1] > 1: cn...
18
23
287
373
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) S = [0] for i, a in enumerate(A): S.append(S[i] + a) S = sorted(S) a = Counter(S).most_common() cnt = 0 for i in range(len(a)): cnt += ((a[i][1] - 1) * a[i][1]) // 2 print(cnt)
from itertools import accumulate import collections N = int(eval(input())) A = list(map(int, input().split())) def main(): # 累積和 B = [0] + A B = list(accumulate(B)) c = collections.Counter(B) cm = c.most_common() cnt = 0 for v in cm: if v[1] > 1: cnt += v[1] * (v[1] - ...
false
21.73913
[ "-from collections import Counter", "+from itertools import accumulate", "+import collections", "-S = [0]", "-for i, a in enumerate(A):", "- S.append(S[i] + a)", "-S = sorted(S)", "-a = Counter(S).most_common()", "-cnt = 0", "-for i in range(len(a)):", "- cnt += ((a[i][1] - 1) * a[i][1]) /...
false
0.089547
0.093511
0.957614
[ "s972325738", "s267898053" ]
u699296734
p03448
python
s727071207
s643729542
58
26
9,088
9,180
Accepted
Accepted
55.17
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) res = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if 500 * i + 100 * j + 50 * k == x: res += 1 print(res)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) c_nums = set(50 * i for i in range(c + 1)) res = 0 for i in range(a + 1): for j in range(b + 1): tmp = x - 500 * i - 100 * j if tmp in c_nums: res += 1 print(res)
13
14
255
278
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) res = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): if 500 * i + 100 * j + 50 * k == x: res += 1 print(res)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) c_nums = set(50 * i for i in range(c + 1)) res = 0 for i in range(a + 1): for j in range(b + 1): tmp = x - 500 * i - 100 * j if tmp in c_nums: res += 1 print(res)
false
7.142857
[ "+c_nums = set(50 * i for i in range(c + 1))", "- for k in range(c + 1):", "- if 500 * i + 100 * j + 50 * k == x:", "- res += 1", "+ tmp = x - 500 * i - 100 * j", "+ if tmp in c_nums:", "+ res += 1" ]
false
0.227559
0.084703
2.686544
[ "s727071207", "s643729542" ]
u895515293
p03504
python
s451884108
s951365799
1,124
967
63,448
62,736
Accepted
Accepted
13.97
N,C=list(map(int, input().split())) inl = [tuple(map(int, input().split())) for i in range(N)] inl.sort() res = 0 st = set() for s,t,c in inl: nx = set() for t1, c1 in st: if not (t1 == s and c == c1) and t1 >= s: nx.add((t1,c1)) nx.add((t,c)) st = nx res = max(len(...
N,C=list(map(int, input().split())) inl = [tuple(map(int, input().split())) for i in range(N)] inl.sort() res = 0 st = [(0,0)]*30 for s,t,c in inl: nx = (t,c) cnt = 0 for i, (t1, c1) in enumerate(st): if not (t1 == s and c == c1) and t1 >= s: st[i] = (t1,c1) else: ...
16
21
338
451
N, C = list(map(int, input().split())) inl = [tuple(map(int, input().split())) for i in range(N)] inl.sort() res = 0 st = set() for s, t, c in inl: nx = set() for t1, c1 in st: if not (t1 == s and c == c1) and t1 >= s: nx.add((t1, c1)) nx.add((t, c)) st = nx res = max(len(nx), re...
N, C = list(map(int, input().split())) inl = [tuple(map(int, input().split())) for i in range(N)] inl.sort() res = 0 st = [(0, 0)] * 30 for s, t, c in inl: nx = (t, c) cnt = 0 for i, (t1, c1) in enumerate(st): if not (t1 == s and c == c1) and t1 >= s: st[i] = (t1, c1) else: ...
false
23.809524
[ "-st = set()", "+st = [(0, 0)] * 30", "- nx = set()", "- for t1, c1 in st:", "+ nx = (t, c)", "+ cnt = 0", "+ for i, (t1, c1) in enumerate(st):", "- nx.add((t1, c1))", "- nx.add((t, c))", "- st = nx", "- res = max(len(nx), res)", "+ st[i] = (t1, c1...
false
0.038234
0.064434
0.593387
[ "s451884108", "s951365799" ]
u133936772
p03673
python
s254408564
s321725190
135
108
23,492
23,968
Accepted
Accepted
20
n=int(eval(input()));l=list(input().split());print((*l[n-n%2::-2]+l[n%2::2]))
n=int(eval(input()));l=input().split();print((*l[::-2]+l[n%2::2]))
1
1
69
58
n = int(eval(input())) l = list(input().split()) print((*l[n - n % 2 :: -2] + l[n % 2 :: 2]))
n = int(eval(input())) l = input().split() print((*l[::-2] + l[n % 2 :: 2]))
false
0
[ "-l = list(input().split())", "-print((*l[n - n % 2 :: -2] + l[n % 2 :: 2]))", "+l = input().split()", "+print((*l[::-2] + l[n % 2 :: 2]))" ]
false
0.072943
0.040118
1.818208
[ "s254408564", "s321725190" ]
u839857256
p03565
python
s464936016
s922580394
19
17
3,064
3,064
Accepted
Accepted
10.53
s = eval(input()) t = eval(input()) flag = 0 count = 0 new = '' l = [] for i in range(len(s)): if s[i] == '?' or s[i] in t: if count == 0: start = i count += 1 else: if count >= len(t): for j in range(count-len(t)+1): check = 0 ...
s = eval(input()) t = eval(input()) ans = '' if len(s) >= len(t): for i in range(len(s)-len(t), -1, -1): s_tmp = s[i:i+len(t)] flag = 0 for j in range(len(t)): if s_tmp[j] == '?': s_tmp = t[:j+1] + s_tmp[j+1:] elif s_tmp[j] != t[j]: ...
48
26
1,251
625
s = eval(input()) t = eval(input()) flag = 0 count = 0 new = "" l = [] for i in range(len(s)): if s[i] == "?" or s[i] in t: if count == 0: start = i count += 1 else: if count >= len(t): for j in range(count - len(t) + 1): check = 0 ...
s = eval(input()) t = eval(input()) ans = "" if len(s) >= len(t): for i in range(len(s) - len(t), -1, -1): s_tmp = s[i : i + len(t)] flag = 0 for j in range(len(t)): if s_tmp[j] == "?": s_tmp = t[: j + 1] + s_tmp[j + 1 :] elif s_tmp[j] != t[j]: ...
false
45.833333
[ "-flag = 0", "-count = 0", "-new = \"\"", "-l = []", "-for i in range(len(s)):", "- if s[i] == \"?\" or s[i] in t:", "- if count == 0:", "- start = i", "- count += 1", "- else:", "- if count >= len(t):", "- for j in range(count - len(t) + 1):", ...
false
0.04211
0.038602
1.090872
[ "s464936016", "s922580394" ]
u187620552
p03103
python
s077753972
s711429899
632
458
21,544
21,604
Accepted
Accepted
27.53
n, m = list(map(int, input().split())) stores = [] for i in range(n): store = input().split() stores.append([int(store[i]) for i in range(2)]) stores.sort() drinks = 0 cost = 0 for store in stores: if drinks + store[1] <= m: drinks += store[1] cost += store[0]*store[1] elif...
n, m = list(map(int, input().split())) stores = [[int(j) for j in input().split()]for i in range(n)] stores.sort() drinks = 0 cost = 0 for store in stores: if drinks + store[1] <= m: drinks += store[1] cost += store[0]*store[1] elif drinks + store[1] > m: cost += (m - drinks)...
17
14
404
351
n, m = list(map(int, input().split())) stores = [] for i in range(n): store = input().split() stores.append([int(store[i]) for i in range(2)]) stores.sort() drinks = 0 cost = 0 for store in stores: if drinks + store[1] <= m: drinks += store[1] cost += store[0] * store[1] elif drinks + st...
n, m = list(map(int, input().split())) stores = [[int(j) for j in input().split()] for i in range(n)] stores.sort() drinks = 0 cost = 0 for store in stores: if drinks + store[1] <= m: drinks += store[1] cost += store[0] * store[1] elif drinks + store[1] > m: cost += (m - drinks) * store[...
false
17.647059
[ "-stores = []", "-for i in range(n):", "- store = input().split()", "- stores.append([int(store[i]) for i in range(2)])", "+stores = [[int(j) for j in input().split()] for i in range(n)]" ]
false
0.06884
0.051973
1.32453
[ "s077753972", "s711429899" ]
u941407962
p03968
python
s211173480
s214941447
3,358
2,988
51,160
50,548
Accepted
Accepted
11.02
from collections import defaultdict N, = list(map(int, input().split())) def normal(xs): return tuple(min((xs[j:] + xs[:j] for j in range(1, 5)))) dd = defaultdict(int) cc = dict() norm = dict() ss = [] for _ in range(N): xs = list(map(int, input().split())) cnd = [tuple(xs[j:] + xs[:j]) for j...
from collections import defaultdict N, = list(map(int, input().split())) dd = defaultdict(int) cc = dict() norm = dict() ss = [] for _ in range(N): xs = list(map(int, input().split())) cnd = [tuple(xs[j:] + xs[:j]) for j in range(1, 5)] x = min(cnd) for item in cnd: norm[item] = x ...
57
47
1,217
1,080
from collections import defaultdict (N,) = list(map(int, input().split())) def normal(xs): return tuple(min((xs[j:] + xs[:j] for j in range(1, 5)))) dd = defaultdict(int) cc = dict() norm = dict() ss = [] for _ in range(N): xs = list(map(int, input().split())) cnd = [tuple(xs[j:] + xs[:j]) for j in ran...
from collections import defaultdict (N,) = list(map(int, input().split())) dd = defaultdict(int) cc = dict() norm = dict() ss = [] for _ in range(N): xs = list(map(int, input().split())) cnd = [tuple(xs[j:] + xs[:j]) for j in range(1, 5)] x = min(cnd) for item in cnd: norm[item] = x dd[x] +...
false
17.54386
[ "-", "-", "-def normal(xs):", "- return tuple(min((xs[j:] + xs[:j] for j in range(1, 5))))", "-", "-", "-def icr(x):", "- dd[x] += 1", "-", "-", "-def dcr(x):", "- dd[x] -= 1", "-", "-", "- for cp in tl:", "- if cp not in norm:", "+ for i in range(4):", "+ ...
false
0.040599
0.039635
1.024314
[ "s211173480", "s214941447" ]
u150984829
p00106
python
s743051847
s678066602
70
20
5,596
5,612
Accepted
Accepted
71.43
while True: N = int(eval(input())) if N==0: break ans = float('inf') for c200 in range(N//200+1): for c300 in range(N//300+1): for c500 in range(N//500+1): if 200 * c200 + c300 * 300 + c500 * 500 == N: ans = min(ans, 1520*(c200//5)+380*(c200%5)+1870*(c300//4)+550*(c300%4)+2244*(c500//3)+850*(c...
a=[1e4]*51 for i,j in[(2,380),(3,550),(5,850),(10,1520),(12,1870),(15,2244)]: a[i]=j for k in range(51-i): if a[k+i]>a[k]+j:a[k+i]=a[k]+j for n in iter(input,'0'):print((a[int(n)//100]))
10
6
335
194
while True: N = int(eval(input())) if N == 0: break ans = float("inf") for c200 in range(N // 200 + 1): for c300 in range(N // 300 + 1): for c500 in range(N // 500 + 1): if 200 * c200 + c300 * 300 + c500 * 500 == N: ans = min( ...
a = [1e4] * 51 for i, j in [(2, 380), (3, 550), (5, 850), (10, 1520), (12, 1870), (15, 2244)]: a[i] = j for k in range(51 - i): if a[k + i] > a[k] + j: a[k + i] = a[k] + j for n in iter(input, "0"): print((a[int(n) // 100]))
false
40
[ "-while True:", "- N = int(eval(input()))", "- if N == 0:", "- break", "- ans = float(\"inf\")", "- for c200 in range(N // 200 + 1):", "- for c300 in range(N // 300 + 1):", "- for c500 in range(N // 500 + 1):", "- if 200 * c200 + c300 * 300 + c500 ...
false
0.036693
0.035503
1.033515
[ "s743051847", "s678066602" ]
u644907318
p03837
python
s712741229
s972409418
393
98
56,796
68,168
Accepted
Accepted
75.06
import heapq INFTY = 10**6 N,M = list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} Arc = {} for _ in range(M): a,b,c = list(map(int,input().split())) G[a].append((b,c)) G[b].append((a,c)) Arc[(a,b)]=0 Arc[(b,a)]=0 for s in range(1,N+1): dist = [INFTY for _ in range(N+1)...
INFTY = 10**5+10 N,M = list(map(int,input().split())) L = [list(map(int,input().split())) for _ in range(M)] G = {i:[] for i in range(1,N+1)} dist = [[INFTY for _ in range(N+1)] for _ in range(N+1)] for j in range(M): a,b,c = L[j] G[a].append(b) G[b].append(a) dist[a][b] = c dist[b][a] = c...
40
21
958
561
import heapq INFTY = 10**6 N, M = list(map(int, input().split())) G = {i: [] for i in range(1, N + 1)} Arc = {} for _ in range(M): a, b, c = list(map(int, input().split())) G[a].append((b, c)) G[b].append((a, c)) Arc[(a, b)] = 0 Arc[(b, a)] = 0 for s in range(1, N + 1): dist = [INFTY for _ in r...
INFTY = 10**5 + 10 N, M = list(map(int, input().split())) L = [list(map(int, input().split())) for _ in range(M)] G = {i: [] for i in range(1, N + 1)} dist = [[INFTY for _ in range(N + 1)] for _ in range(N + 1)] for j in range(M): a, b, c = L[j] G[a].append(b) G[b].append(a) dist[a][b] = c dist[b][a...
false
47.5
[ "-import heapq", "-", "-INFTY = 10**6", "+INFTY = 10**5 + 10", "+L = [list(map(int, input().split())) for _ in range(M)]", "-Arc = {}", "-for _ in range(M):", "- a, b, c = list(map(int, input().split()))", "- G[a].append((b, c))", "- G[b].append((a, c))", "- Arc[(a, b)] = 0", "- ...
false
0.040685
0.036295
1.120937
[ "s712741229", "s972409418" ]
u934740772
p03575
python
s355467940
s117797648
23
20
3,064
3,064
Accepted
Accepted
13.04
n, m = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(m)] def bfs(i, edges, r): if all(r): return True if r[i]: return False r[i] = True if any([bfs(e, edges, r) for e in edges[i]]): return True return False ans = 0 for i ...
def dfs(i,edge): if vis[i]==True: return vis[i]=True for j in edge[i]: dfs(j,edge) N,M=list(map(int,input().split())) ab=[[0,0] for _ in range(M)] for i in range(M): a,b=list(map(int,input().split())) ab[i][0],ab[i][1]=a,b ans=0 for i in range(M): edge=[[] for _ in...
24
25
613
559
n, m = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(m)] def bfs(i, edges, r): if all(r): return True if r[i]: return False r[i] = True if any([bfs(e, edges, r) for e in edges[i]]): return True return False ans = 0 for i in range(m):...
def dfs(i, edge): if vis[i] == True: return vis[i] = True for j in edge[i]: dfs(j, edge) N, M = list(map(int, input().split())) ab = [[0, 0] for _ in range(M)] for i in range(M): a, b = list(map(int, input().split())) ab[i][0], ab[i][1] = a, b ans = 0 for i in range(M): edge = ...
false
4
[ "-n, m = list(map(int, input().split()))", "-ab = [list(map(int, input().split())) for _ in range(m)]", "+def dfs(i, edge):", "+ if vis[i] == True:", "+ return", "+ vis[i] = True", "+ for j in edge[i]:", "+ dfs(j, edge)", "-def bfs(i, edges, r):", "- if all(r):", "- ...
false
0.079254
0.037934
2.089263
[ "s355467940", "s117797648" ]
u347600233
p02688
python
s429927942
s960775871
29
26
9,124
9,172
Accepted
Accepted
10.34
n, k = list(map(int, input().split())) a = set() for i in range(k): d = int(eval(input())) a |= set(map(int, input().split())) print((len(set(range(1, n + 1)) - a)))
n, k = list(map(int, input().split())) a = set() for i in range(k): d = int(eval(input())) a |= set(map(int, input().split())) print((n - len(a)))
6
6
164
145
n, k = list(map(int, input().split())) a = set() for i in range(k): d = int(eval(input())) a |= set(map(int, input().split())) print((len(set(range(1, n + 1)) - a)))
n, k = list(map(int, input().split())) a = set() for i in range(k): d = int(eval(input())) a |= set(map(int, input().split())) print((n - len(a)))
false
0
[ "-print((len(set(range(1, n + 1)) - a)))", "+print((n - len(a)))" ]
false
0.047134
0.043134
1.092738
[ "s429927942", "s960775871" ]
u257162238
p03044
python
s663648391
s597690596
1,037
905
47,176
59,336
Accepted
Accepted
12.73
import numpy as np def read(): N = int(input().strip()) # N <= 10**5 to = [[] for _ in range(N)] cost = [[] for _ in range(N)] for i in range(N-1): # u[i] < v[i] は保証されている u, v, w = list(map(int, input().strip().split())) to[u-1].append(v-1) to[v-1].append(u-...
import numpy as np def read(): N = int(input().strip()) # N <= 10**5 edges = dict() for i in range(N-1): # u[i] < v[i] は保証されている u, v, w = list(map(int, input().strip().split())) if u - 1 in list(edges.keys()): edges[u - 1].update({v - 1: w % 2}) else...
39
42
952
1,095
import numpy as np def read(): N = int(input().strip()) # N <= 10**5 to = [[] for _ in range(N)] cost = [[] for _ in range(N)] for i in range(N - 1): # u[i] < v[i] は保証されている u, v, w = list(map(int, input().strip().split())) to[u - 1].append(v - 1) to[v - 1].append(u - 1...
import numpy as np def read(): N = int(input().strip()) # N <= 10**5 edges = dict() for i in range(N - 1): # u[i] < v[i] は保証されている u, v, w = list(map(int, input().strip().split())) if u - 1 in list(edges.keys()): edges[u - 1].update({v - 1: w % 2}) else: ...
false
7.142857
[ "- to = [[] for _ in range(N)]", "- cost = [[] for _ in range(N)]", "+ edges = dict()", "- to[u - 1].append(v - 1)", "- to[v - 1].append(u - 1)", "- cost[u - 1].append(w % 2)", "- cost[v - 1].append(w % 2)", "- return N, to, cost", "+ if u - 1 in list(e...
false
0.105054
0.105271
0.997933
[ "s663648391", "s597690596" ]
u496744988
p03645
python
s747438425
s352010181
634
344
62,228
21,360
Accepted
Accepted
45.74
from collections import Counter from functools import reduce # import statistics import bisect import copy import fractions import math import pprint import random import sys import time sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().sp...
from collections import Counter from functools import reduce # import statistics import bisect import copy import fractions import math import pprint import random import sys import time sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().sp...
68
63
1,643
1,515
from collections import Counter from functools import reduce # import statistics import bisect import copy import fractions import math import pprint import random import sys import time sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] d...
from collections import Counter from functools import reduce # import statistics import bisect import copy import fractions import math import pprint import random import sys import time sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] d...
false
7.352941
[ "-sides = [LI() for _ in range(m)]", "-islands = [[0] * 2 for _ in range(n)]", "-for a, b in sides:", "- if a - 1 == 0:", "- islands[b - 1][0] = 1", "- if b - 1 == n - 1:", "- islands[a - 1][1] = 1", "-for a, b in islands:", "- if a == b == 1:", "- print(\"POSSIBLE\")...
false
0.048377
0.049074
0.98581
[ "s747438425", "s352010181" ]
u921518222
p03031
python
s999727449
s274500052
294
201
12,504
41,948
Accepted
Accepted
31.63
import numpy as np n, m = list(map(int, input().split())) S = [] for _ in range(m): *a, = list(map(int, input().split())) l = a[1:] S.append(l) *p, = list(map(int, input().split())) ans = 0 for i in range(2**n): tmp = np.array([i >> j & 1 for j in range(n)]) if p == [sum(tmp[np.array(...
n, m = list(map(int, input().split())) S = [] for _ in range(m): S.append(list(map(int, input().split()))[1:]) *p, = list(map(int, input().split())) ans = 0 for i in range(2**n): switch = [i >> j & 1 for j in range(n)] c = 0 for k, s in enumerate(S): count = 0 for s1 in s: ...
16
20
356
462
import numpy as np n, m = list(map(int, input().split())) S = [] for _ in range(m): (*a,) = list(map(int, input().split())) l = a[1:] S.append(l) (*p,) = list(map(int, input().split())) ans = 0 for i in range(2**n): tmp = np.array([i >> j & 1 for j in range(n)]) if p == [sum(tmp[np.array(s) - 1]) %...
n, m = list(map(int, input().split())) S = [] for _ in range(m): S.append(list(map(int, input().split()))[1:]) (*p,) = list(map(int, input().split())) ans = 0 for i in range(2**n): switch = [i >> j & 1 for j in range(n)] c = 0 for k, s in enumerate(S): count = 0 for s1 in s: ...
false
20
[ "-import numpy as np", "-", "- (*a,) = list(map(int, input().split()))", "- l = a[1:]", "- S.append(l)", "+ S.append(list(map(int, input().split()))[1:])", "- tmp = np.array([i >> j & 1 for j in range(n)])", "- if p == [sum(tmp[np.array(s) - 1]) % 2 for s in S]:", "+ switch = [i...
false
0.4084
0.039105
10.443601
[ "s999727449", "s274500052" ]
u350064373
p02409
python
s339254205
s052873432
60
40
7,732
7,772
Accepted
Accepted
33.33
R=range l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)] for i in R(int(eval(input()))):b,f,r,v=list(map(int,input().split()));l[b-1][f-1][r-1]+=v for i in R(4): for k in l[i]:print(("",*k)) if i!=3:print(("#"*20))
R=range I=input p=print l=[[[0 for i in R(10)]for j in R(3)]for s in R(4)] for i in R(int(I())):b,f,r,v=map(int,I().split());l[b-1][f-1][r-1]+=v for i in R(4): for k in l[i]:p("",*k) if i!=3:p("#"*20)
6
8
207
209
R = range l = [[[0 for i in R(10)] for j in R(3)] for s in R(4)] for i in R(int(eval(input()))): b, f, r, v = list(map(int, input().split())) l[b - 1][f - 1][r - 1] += v for i in R(4): for k in l[i]: print(("", *k)) if i != 3: print(("#" * 20))
R = range I = input p = print l = [[[0 for i in R(10)] for j in R(3)] for s in R(4)] for i in R(int(I())): b, f, r, v = map(int, I().split()) l[b - 1][f - 1][r - 1] += v for i in R(4): for k in l[i]: p("", *k) if i != 3: p("#" * 20)
false
25
[ "+I = input", "+p = print", "-for i in R(int(eval(input()))):", "- b, f, r, v = list(map(int, input().split()))", "+for i in R(int(I())):", "+ b, f, r, v = map(int, I().split())", "- print((\"\", *k))", "+ p(\"\", *k)", "- print((\"#\" * 20))", "+ p(\"#\" * 20)" ]
false
0.039142
0.039215
0.998135
[ "s339254205", "s052873432" ]
u644907318
p03107
python
s419354453
s882705877
183
165
39,280
39,280
Accepted
Accepted
9.84
S = input().strip() N = len(S) k = 0 for i in range(N): if S[i]=="0": k += 1 m = min(k,N-k) print((2*m))
S = input().strip() N = len(S) cnt = 0 for i in range(N): if S[i]=="1": cnt += 1 print((min(cnt,N-cnt)*2))
8
7
121
122
S = input().strip() N = len(S) k = 0 for i in range(N): if S[i] == "0": k += 1 m = min(k, N - k) print((2 * m))
S = input().strip() N = len(S) cnt = 0 for i in range(N): if S[i] == "1": cnt += 1 print((min(cnt, N - cnt) * 2))
false
12.5
[ "-k = 0", "+cnt = 0", "- if S[i] == \"0\":", "- k += 1", "-m = min(k, N - k)", "-print((2 * m))", "+ if S[i] == \"1\":", "+ cnt += 1", "+print((min(cnt, N - cnt) * 2))" ]
false
0.098092
0.007684
12.765436
[ "s419354453", "s882705877" ]
u493520238
p03472
python
s213476154
s771818748
1,088
211
70,104
86,700
Accepted
Accepted
80.61
import math n,h = list(map(int, input().split())) al = [] bl = [] for _ in range(n): a,b = list(map(int, input().split())) al.append((a,'swing')) bl.append((b,'throw')) abl = al + bl abl.sort(reverse=True) remain_h = h ans = 0 for v in abl: damage, command = v if command == 'swin...
n,h = list(map(int, input().split())) al = [] bl = [] for _ in range(n): a,b = list(map(int, input().split())) al.append(a) bl.append(b) al.sort(reverse=True) bl.sort(reverse=True) amax = al[0] ans = 0 rem = h for b in bl: if b >= amax: rem -= b ans += 1 else: ...
27
27
486
424
import math n, h = list(map(int, input().split())) al = [] bl = [] for _ in range(n): a, b = list(map(int, input().split())) al.append((a, "swing")) bl.append((b, "throw")) abl = al + bl abl.sort(reverse=True) remain_h = h ans = 0 for v in abl: damage, command = v if command == "swing": ans...
n, h = list(map(int, input().split())) al = [] bl = [] for _ in range(n): a, b = list(map(int, input().split())) al.append(a) bl.append(b) al.sort(reverse=True) bl.sort(reverse=True) amax = al[0] ans = 0 rem = h for b in bl: if b >= amax: rem -= b ans += 1 else: break if ...
false
0
[ "-import math", "-", "- al.append((a, \"swing\"))", "- bl.append((b, \"throw\"))", "-abl = al + bl", "-abl.sort(reverse=True)", "-remain_h = h", "+ al.append(a)", "+ bl.append(b)", "+al.sort(reverse=True)", "+bl.sort(reverse=True)", "+amax = al[0]", "-for v in abl:", "- dama...
false
0.036672
0.075417
0.486252
[ "s213476154", "s771818748" ]
u594244257
p02954
python
s429808366
s732584285
117
92
20,900
10,484
Accepted
Accepted
21.37
def solve(): S = eval(input()) result = [0] * len(S) children_position = [] even_odd_sum = [] even_sum = 0 odd_sum = 0 R_i = 0 L_i = -2 for idx, s in enumerate(S): if s == 'R': R_i = idx if L_i+1 == R_i: eve...
S = eval(input()) ret = [0] * len(S) cont_R = 0 idx_R = 0 cont_L = 0 for i,s in enumerate(S): if s == 'R': cont_L = 0 cont_R += 1 idx_R = i idx_L = i+1 elif s == 'L': if idx_L == i: q = cont_R//2 r = cont_R%2 ret[idx_R]...
39
27
1,135
563
def solve(): S = eval(input()) result = [0] * len(S) children_position = [] even_odd_sum = [] even_sum = 0 odd_sum = 0 R_i = 0 L_i = -2 for idx, s in enumerate(S): if s == "R": R_i = idx if L_i + 1 == R_i: even_odd_sum.append((even_sum,...
S = eval(input()) ret = [0] * len(S) cont_R = 0 idx_R = 0 cont_L = 0 for i, s in enumerate(S): if s == "R": cont_L = 0 cont_R += 1 idx_R = i idx_L = i + 1 elif s == "L": if idx_L == i: q = cont_R // 2 r = cont_R % 2 ret[idx_R] = q + r ...
false
30.769231
[ "-def solve():", "- S = eval(input())", "- result = [0] * len(S)", "- children_position = []", "- even_odd_sum = []", "- even_sum = 0", "- odd_sum = 0", "- R_i = 0", "- L_i = -2", "- for idx, s in enumerate(S):", "- if s == \"R\":", "- R_i = idx", ...
false
0.095458
0.045414
2.101939
[ "s429808366", "s732584285" ]
u334712262
p02788
python
s445704835
s842611603
1,254
1,147
110,344
100,796
Accepted
Accepted
8.53
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
88
86
1,667
1,611
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
false
2.272727
[ "- X = [x for x, _ in XH]", "- H = [h for _, h in XH]" ]
false
0.10194
0.091371
1.115677
[ "s445704835", "s842611603" ]
u953237709
p03060
python
s383279887
s010826167
521
18
42,348
3,060
Accepted
Accepted
96.55
n = int(eval(input())) value = list(map(int, input().split())) cost = list(map(int, input().split())) ret = 0 for state in range((1 << n)): values = costs = 0 for shift in range(n): if (state >> shift) & 1 == 1: values += value[shift] costs += cost[shift] ret = max(...
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) print((sum(max(v[i] - c[i], 0) for i in range(n))))
12
4
346
141
n = int(eval(input())) value = list(map(int, input().split())) cost = list(map(int, input().split())) ret = 0 for state in range((1 << n)): values = costs = 0 for shift in range(n): if (state >> shift) & 1 == 1: values += value[shift] costs += cost[shift] ret = max(ret, value...
n = int(eval(input())) v = list(map(int, input().split())) c = list(map(int, input().split())) print((sum(max(v[i] - c[i], 0) for i in range(n))))
false
66.666667
[ "-value = list(map(int, input().split()))", "-cost = list(map(int, input().split()))", "-ret = 0", "-for state in range((1 << n)):", "- values = costs = 0", "- for shift in range(n):", "- if (state >> shift) & 1 == 1:", "- values += value[shift]", "- costs += cost[...
false
0.082624
0.037066
2.229106
[ "s383279887", "s010826167" ]
u562935282
p03846
python
s282520493
s306319457
107
65
14,008
14,820
Accepted
Accepted
39.25
def inpl(): return input().split() n = int(eval(input())) a = sorted(list(map(int, inpl()))) p = 10 ** 9 + 7 if a[0] == 0: st = 1 next_value = 2 else: st = 0 next_value = 1 ans = 1 found = False for i in range(st, n): if (next_value == a[i]): if found: ne...
from collections import Counter MOD = 10 ** 9 + 7 N = int(eval(input())) a = list(map(int, input().split())) ans = 2 ** (N // 2) % MOD flg = True b = Counter(a) if N % 2 == 1: for i in range(0, N, 2): if i == 0: if b[i] != 1: flg = False break ...
29
28
523
540
def inpl(): return input().split() n = int(eval(input())) a = sorted(list(map(int, inpl()))) p = 10**9 + 7 if a[0] == 0: st = 1 next_value = 2 else: st = 0 next_value = 1 ans = 1 found = False for i in range(st, n): if next_value == a[i]: if found: next_value += 2 ...
from collections import Counter MOD = 10**9 + 7 N = int(eval(input())) a = list(map(int, input().split())) ans = 2 ** (N // 2) % MOD flg = True b = Counter(a) if N % 2 == 1: for i in range(0, N, 2): if i == 0: if b[i] != 1: flg = False break else: ...
false
3.448276
[ "-def inpl():", "- return input().split()", "+from collections import Counter", "-", "-n = int(eval(input()))", "-a = sorted(list(map(int, inpl())))", "-p = 10**9 + 7", "-if a[0] == 0:", "- st = 1", "- next_value = 2", "+MOD = 10**9 + 7", "+N = int(eval(input()))", "+a = list(map(in...
false
0.095847
0.066413
1.443208
[ "s282520493", "s306319457" ]
u794173881
p02889
python
s166474950
s605410991
1,662
1,024
76,764
74,332
Accepted
Accepted
38.39
from collections import deque import sys import random input = sys.stdin.readline n, m, l = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(m)] graph = [[] for i in range(n)] for i in range(m): a, b, cost = info[i] if cost > l: continue a -= 1 ...
from collections import deque import sys input = sys.stdin.readline n, m, l = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(m)] graph = [[] for i in range(n)] for i in range(m): a, b, cost = info[i] if cost > l: continue a -= 1 b -= 1 ...
77
66
2,199
1,496
from collections import deque import sys import random input = sys.stdin.readline n, m, l = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(m)] graph = [[] for i in range(n)] for i in range(m): a, b, cost = info[i] if cost > l: continue a -= 1 b -= 1 g...
from collections import deque import sys input = sys.stdin.readline n, m, l = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(m)] graph = [[] for i in range(n)] for i in range(m): a, b, cost = info[i] if cost > l: continue a -= 1 b -= 1 graph[a].append...
false
14.285714
[ "-import random", "-for i in range(n):", "- graph[i] = random.sample(graph[i], len(graph[i]))", "-def dfs(start):", "- INF = float(\"inf\")", "- visited_t = [INF] * n # 回数, 残り燃料", "- visited_l = [0] * n", "- visited_t[start] = 0", "- q = deque([start])", "- while q:", "- ...
false
0.043256
0.041285
1.04773
[ "s166474950", "s605410991" ]
u699699071
p03854
python
s208264664
s555319095
22
19
3,188
3,188
Accepted
Accepted
13.64
s = eval(input()) t = s.replace("dreameraser","1") t = t.replace("dreamerase","2") t = t.replace("dreamer","3") t = t.replace("eraser","4") t = t.replace("dream","5") t = t.replace("erase","6") try: int(t) print("YES") except : print("NO")
s = eval(input()) t = s.replace("eraser","") t = t.replace("erase","") t = t.replace("dreamer","") t = t.replace("dream","") if len(t)==0: print("YES") else : print("NO")
14
11
260
184
s = eval(input()) t = s.replace("dreameraser", "1") t = t.replace("dreamerase", "2") t = t.replace("dreamer", "3") t = t.replace("eraser", "4") t = t.replace("dream", "5") t = t.replace("erase", "6") try: int(t) print("YES") except: print("NO")
s = eval(input()) t = s.replace("eraser", "") t = t.replace("erase", "") t = t.replace("dreamer", "") t = t.replace("dream", "") if len(t) == 0: print("YES") else: print("NO")
false
21.428571
[ "-t = s.replace(\"dreameraser\", \"1\")", "-t = t.replace(\"dreamerase\", \"2\")", "-t = t.replace(\"dreamer\", \"3\")", "-t = t.replace(\"eraser\", \"4\")", "-t = t.replace(\"dream\", \"5\")", "-t = t.replace(\"erase\", \"6\")", "-try:", "- int(t)", "+t = s.replace(\"eraser\", \"\")", "+t = t....
false
0.045394
0.043493
1.043716
[ "s208264664", "s555319095" ]
u222668979
p02945
python
s165863164
s362912647
173
17
38,384
2,940
Accepted
Accepted
90.17
a,b= list(map(int,input().split())) print((max((a+b,a-b,a*b))))
a,b= list(map(int,input().split())) print((max(a+b,a-b,a*b)))
2
2
57
55
a, b = list(map(int, input().split())) print((max((a + b, a - b, a * b))))
a, b = list(map(int, input().split())) print((max(a + b, a - b, a * b)))
false
0
[ "-print((max((a + b, a - b, a * b))))", "+print((max(a + b, a - b, a * b)))" ]
false
0.040125
0.039721
1.010156
[ "s165863164", "s362912647" ]
u977389981
p02988
python
s361514428
s698228872
171
17
38,384
3,060
Accepted
Accepted
90.06
N = int(eval(input())) P = [int(i) for i in input().split()] cnt = 0 for i in range(1, N - 1): A = [P[i - 1], P[i], P[i + 1]] maxA = max(A) minA = min(A) if P[i] != maxA and P[i] != minA: cnt += 1 print(cnt)
n = int(eval(input())) P = [int(i) for i in input().split()] ans = 0 for i in range(1, n - 1): if P[i] != max(P[i - 1], P[i], P[i + 1]) and P[i] != min(P[i - 1], P[i], P[i + 1]): ans += 1 print(ans)
12
9
246
222
N = int(eval(input())) P = [int(i) for i in input().split()] cnt = 0 for i in range(1, N - 1): A = [P[i - 1], P[i], P[i + 1]] maxA = max(A) minA = min(A) if P[i] != maxA and P[i] != minA: cnt += 1 print(cnt)
n = int(eval(input())) P = [int(i) for i in input().split()] ans = 0 for i in range(1, n - 1): if P[i] != max(P[i - 1], P[i], P[i + 1]) and P[i] != min(P[i - 1], P[i], P[i + 1]): ans += 1 print(ans)
false
25
[ "-N = int(eval(input()))", "+n = int(eval(input()))", "-cnt = 0", "-for i in range(1, N - 1):", "- A = [P[i - 1], P[i], P[i + 1]]", "- maxA = max(A)", "- minA = min(A)", "- if P[i] != maxA and P[i] != minA:", "- cnt += 1", "-print(cnt)", "+ans = 0", "+for i in range(1, n - 1...
false
0.048488
0.105494
0.459632
[ "s361514428", "s698228872" ]
u634079249
p02641
python
s089858383
s218218281
176
160
37,552
37,544
Accepted
Accepted
9.09
import sys, os, math, bisect, itertools, collections, heapq, queue from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict # import fractions sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il...
import sys, os, math, bisect, itertools, collections, heapq, queue from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict # import fractions sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il...
43
48
1,223
1,293
import sys, os, math, bisect, itertools, collections, heapq, queue from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict # import fractions sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: l...
import sys, os, math, bisect, itertools, collections, heapq, queue from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall from decimal import Decimal from collections import defaultdict # import fractions sys.setrecursionlimit(10000000) ii = lambda: int(sys.stdin.buffer.readline().rstrip()) il = lambda: l...
false
10.416667
[ "+ if len(P) == 0:", "+ print(X)", "+ exit()", "+ mx = max(P)", "+ p = MAX", "- s = MAX", "- for n in range(-101, 102):", "- if n not in P and abs(X - n) < s:", "- s = abs(X - n)", "+ for n in range(mx + 2):", "+ if n not in P and p > abs(...
false
0.036456
0.034755
1.048935
[ "s089858383", "s218218281" ]
u983918956
p03221
python
s362852552
s159282118
970
722
65,240
37,696
Accepted
Accepted
25.57
N,M = list(map(int,input().split())) city = [] count = 1 for i in range(M): p,y = list(map(int,input().split())) city.append([p,y]) city_sorted = sorted(city) for i in range(M): if city_sorted[i][0] == city_sorted[i-1][0] and i != 0: count += 1 else: count = 1 city_sorted...
N,M = list(map(int,input().split())) info = [list(map(int,input().split())) for i in range(M)] info_new = sorted(info,key=lambda x:(x[0],x[1])) note = info_new[0][0] cnt = 1 for i in range(M): if info_new[i][0] == note: info_new[i][1] = cnt cnt += 1 else: note = info_new[i][0] ...
17
20
500
543
N, M = list(map(int, input().split())) city = [] count = 1 for i in range(M): p, y = list(map(int, input().split())) city.append([p, y]) city_sorted = sorted(city) for i in range(M): if city_sorted[i][0] == city_sorted[i - 1][0] and i != 0: count += 1 else: count = 1 city_sorted[i][1...
N, M = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(M)] info_new = sorted(info, key=lambda x: (x[0], x[1])) note = info_new[0][0] cnt = 1 for i in range(M): if info_new[i][0] == note: info_new[i][1] = cnt cnt += 1 else: note = info_new[i][0] ...
false
15
[ "-city = []", "-count = 1", "+info = [list(map(int, input().split())) for i in range(M)]", "+info_new = sorted(info, key=lambda x: (x[0], x[1]))", "+note = info_new[0][0]", "+cnt = 1", "- p, y = list(map(int, input().split()))", "- city.append([p, y])", "-city_sorted = sorted(city)", "+ i...
false
0.037289
0.061309
0.608216
[ "s362852552", "s159282118" ]
u677267454
p03087
python
s152183268
s831139804
834
406
7,748
11,876
Accepted
Accepted
51.32
n, q = list(map(int, input().split())) s = eval(input()) t = [0] * (n + 1) for i in range(n): t[i + 1] = t[i] + (1 if s[i:i+2] == 'AC' else 0) for i in range(q): l, r = list(map(int, input().split())) print((t[r - 1] - t[l - 1]))
n, q = list(map(int, input().split())) s = eval(input()) t = [0] * (n + 1) for i in range(n): t[i + 1] = t[i] + (1 if s[i:i+2] == 'AC' else 0) ans = [] for i in range(q): l, r = list(map(int, input().split())) ans.append(t[r - 1] - t[l - 1]) for a in ans: print(a)
10
14
233
279
n, q = list(map(int, input().split())) s = eval(input()) t = [0] * (n + 1) for i in range(n): t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0) for i in range(q): l, r = list(map(int, input().split())) print((t[r - 1] - t[l - 1]))
n, q = list(map(int, input().split())) s = eval(input()) t = [0] * (n + 1) for i in range(n): t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0) ans = [] for i in range(q): l, r = list(map(int, input().split())) ans.append(t[r - 1] - t[l - 1]) for a in ans: print(a)
false
28.571429
[ "+ans = []", "- print((t[r - 1] - t[l - 1]))", "+ ans.append(t[r - 1] - t[l - 1])", "+for a in ans:", "+ print(a)" ]
false
0.049313
0.046267
1.065837
[ "s152183268", "s831139804" ]
u621935300
p03556
python
s536582201
s783846815
27
11
5,764
2,568
Accepted
Accepted
59.26
import sys N=eval(input()) for i in range(100000): if i*i==N: print(i*i) sys.exit() elif i*i>N: print((i-1)*(i-1)) sys.exit() else: continue
import math N=eval(input()) print(int(math.sqrt(N))*int(math.sqrt(N)))
14
3
165
65
import sys N = eval(input()) for i in range(100000): if i * i == N: print(i * i) sys.exit() elif i * i > N: print((i - 1) * (i - 1)) sys.exit() else: continue
import math N = eval(input()) print(int(math.sqrt(N)) * int(math.sqrt(N)))
false
78.571429
[ "-import sys", "+import math", "-for i in range(100000):", "- if i * i == N:", "- print(i * i)", "- sys.exit()", "- elif i * i > N:", "- print((i - 1) * (i - 1))", "- sys.exit()", "- else:", "- continue", "+print(int(math.sqrt(N)) * int(math.sqrt(N))...
false
0.034421
0.036377
0.94624
[ "s536582201", "s783846815" ]
u790905630
p02866
python
s296403227
s921449213
337
80
14,396
14,396
Accepted
Accepted
76.26
def main(): N = eval(input()) D = list(map(int,input().split())) M = max(D) countlist=[0] * (M + 1) ans=1 for i in D: countlist[i]+=1 if countlist[0]!=1 : ans = 0 else : if D[0]!=0 : ans = 0 else: for i in range(...
def main(): N = eval(input()) D = list(map(int,input().split())) M = max(D) countlist=[0] * (M + 1) ans=1 for i in D: countlist[i]+=1 if countlist[0]!=1 : ans = 0 else : if D[0]!=0 : ans = 0 else: for i in range(...
24
24
449
456
def main(): N = eval(input()) D = list(map(int, input().split())) M = max(D) countlist = [0] * (M + 1) ans = 1 for i in D: countlist[i] += 1 if countlist[0] != 1: ans = 0 else: if D[0] != 0: ans = 0 else: for i in range(2, M + 1): ...
def main(): N = eval(input()) D = list(map(int, input().split())) M = max(D) countlist = [0] * (M + 1) ans = 1 for i in D: countlist[i] += 1 if countlist[0] != 1: ans = 0 else: if D[0] != 0: ans = 0 else: for i in range(2, M + 1): ...
false
0
[ "- ans *= countlist[i - 1] ** countlist[i]", "- print((ans % 998244353))", "+ ans = (ans * (countlist[i - 1] ** countlist[i])) % 998244353", "+ print(ans)" ]
false
0.03772
0.045413
0.830601
[ "s296403227", "s921449213" ]
u894953648
p03001
python
s890135289
s448800531
19
17
3,064
2,940
Accepted
Accepted
10.53
a=list(map(int,input().split())) print((a[0]*a[1]/2,1 if a[0]/2==a[2] and a[1]/2==a[3] else 0))
a=list(map(int,input().split())) ans=str(a[0]*a[1]/2) if a[0]/2==a[2] and a[1]/2==a[3]: print((ans+" 1")) else:print((ans+" 0"))
2
6
94
134
a = list(map(int, input().split())) print((a[0] * a[1] / 2, 1 if a[0] / 2 == a[2] and a[1] / 2 == a[3] else 0))
a = list(map(int, input().split())) ans = str(a[0] * a[1] / 2) if a[0] / 2 == a[2] and a[1] / 2 == a[3]: print((ans + " 1")) else: print((ans + " 0"))
false
66.666667
[ "-print((a[0] * a[1] / 2, 1 if a[0] / 2 == a[2] and a[1] / 2 == a[3] else 0))", "+ans = str(a[0] * a[1] / 2)", "+if a[0] / 2 == a[2] and a[1] / 2 == a[3]:", "+ print((ans + \" 1\"))", "+else:", "+ print((ans + \" 0\"))" ]
false
0.047014
0.049493
0.949909
[ "s890135289", "s448800531" ]
u366886346
p03569
python
s556741525
s398721974
809
81
9,880
12,696
Accepted
Accepted
89.99
s=list(eval(input())) ans=0 for i in range(len(s)): if len(s)<=1: break if s[0]==s[-1]: del s[0] del s[-1] else: if s[0]=="x": ans+=1 del s[0] elif s[-1]=="x": ans+=1 del s[-1] else: a...
s=eval(input()) t="" num=[] for i in range(len(s)): if s[i]!="x": t+=s[i] num.append(i) yn=0 for i in range(-(len(t)//-2)): if t[i]!=t[-1-i]: yn=1 break if yn==1: print((-1)) else: if len(num)==0: print((0)) else: ans=abs(num[0]-(len(...
19
22
351
446
s = list(eval(input())) ans = 0 for i in range(len(s)): if len(s) <= 1: break if s[0] == s[-1]: del s[0] del s[-1] else: if s[0] == "x": ans += 1 del s[0] elif s[-1] == "x": ans += 1 del s[-1] else: a...
s = eval(input()) t = "" num = [] for i in range(len(s)): if s[i] != "x": t += s[i] num.append(i) yn = 0 for i in range(-(len(t) // -2)): if t[i] != t[-1 - i]: yn = 1 break if yn == 1: print((-1)) else: if len(num) == 0: print((0)) else: ans = abs(num[...
false
13.636364
[ "-s = list(eval(input()))", "-ans = 0", "+s = eval(input())", "+t = \"\"", "+num = []", "- if len(s) <= 1:", "+ if s[i] != \"x\":", "+ t += s[i]", "+ num.append(i)", "+yn = 0", "+for i in range(-(len(t) // -2)):", "+ if t[i] != t[-1 - i]:", "+ yn = 1", "- i...
false
0.039014
0.046323
0.842208
[ "s556741525", "s398721974" ]
u519939795
p03610
python
s124431109
s717427190
68
41
4,596
3,188
Accepted
Accepted
39.71
s = input() for i in range(0,len(s),2): print(s[i],end="")
s = eval(input()) ans = "" for i in range(len(s)): if i%2 == 0: ans = ans + s[i] print(ans)
3
6
64
102
s = input() for i in range(0, len(s), 2): print(s[i], end="")
s = eval(input()) ans = "" for i in range(len(s)): if i % 2 == 0: ans = ans + s[i] print(ans)
false
50
[ "-s = input()", "-for i in range(0, len(s), 2):", "- print(s[i], end=\"\")", "+s = eval(input())", "+ans = \"\"", "+for i in range(len(s)):", "+ if i % 2 == 0:", "+ ans = ans + s[i]", "+print(ans)" ]
false
0.039285
0.040595
0.967735
[ "s124431109", "s717427190" ]
u347600233
p02836
python
s605019084
s825088844
30
26
9,040
9,000
Accepted
Accepted
13.33
s = eval(input()) n = len(s) print((sum(t != u for t, u in zip(s[:n//2], s[-(-n//2):][::-1]))))
s = eval(input()) n = len(s) print((sum(t != u for t, u in zip(s[:n//2], s[::-1]))))
3
3
89
78
s = eval(input()) n = len(s) print((sum(t != u for t, u in zip(s[: n // 2], s[-(-n // 2) :][::-1]))))
s = eval(input()) n = len(s) print((sum(t != u for t, u in zip(s[: n // 2], s[::-1]))))
false
0
[ "-print((sum(t != u for t, u in zip(s[: n // 2], s[-(-n // 2) :][::-1]))))", "+print((sum(t != u for t, u in zip(s[: n // 2], s[::-1]))))" ]
false
0.042368
0.041108
1.030641
[ "s605019084", "s825088844" ]
u156815136
p02597
python
s961240555
s139749090
118
85
10,672
10,748
Accepted
Accepted
27.97
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counte...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdi...
62
57
1,435
1,241
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Co...
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate, product # (string,3) 3回 # from collections import deque from collections import deque, defaul...
false
8.064516
[ "-from itertools import combinations, permutations, accumulate # (string,3) 3回", "+from itertools import combinations, permutations, accumulate, product # (string,3) 3回", "+import math", "+import bisect", "+import heapq", "-# import bisect", "-#", "-# d = m - k[i] - k[j]", "-# if kk[bisect.b...
false
0.036521
0.069823
0.52305
[ "s961240555", "s139749090" ]
u203843959
p02796
python
s998502439
s453814430
453
314
26,008
22,804
Accepted
Accepted
30.68
import bisect N=int(eval(input())) rllist=[] for _ in range(N): X,L=list(map(int,input().split())) rllist.append((X+L,X-L)) rllist.sort() #print(rllist) dp=[0]*N for i in range(N): r,l=rllist[i] pos=bisect.bisect(rllist,(l,float("inf"))) #print(i,pos) dp[i]=max(dp[i-1],dp[pos-1]+1) ...
N=int(eval(input())) rllist=[] for _ in range(N): X,L=list(map(int,input().split())) rllist.append((X+L,X-L)) rllist.sort() #print(rllist) answer=0 max_r=-float("inf") for r,l in rllist: #print(max_r,l) if max_r<=l: answer+=1 max_r=max(max_r,r) print(answer)
20
18
334
284
import bisect N = int(eval(input())) rllist = [] for _ in range(N): X, L = list(map(int, input().split())) rllist.append((X + L, X - L)) rllist.sort() # print(rllist) dp = [0] * N for i in range(N): r, l = rllist[i] pos = bisect.bisect(rllist, (l, float("inf"))) # print(i,pos) dp[i] = max(dp[i ...
N = int(eval(input())) rllist = [] for _ in range(N): X, L = list(map(int, input().split())) rllist.append((X + L, X - L)) rllist.sort() # print(rllist) answer = 0 max_r = -float("inf") for r, l in rllist: # print(max_r,l) if max_r <= l: answer += 1 max_r = max(max_r, r) print(answer)
false
10
[ "-import bisect", "-", "-dp = [0] * N", "-for i in range(N):", "- r, l = rllist[i]", "- pos = bisect.bisect(rllist, (l, float(\"inf\")))", "- # print(i,pos)", "- dp[i] = max(dp[i - 1], dp[pos - 1] + 1)", "-# print(dp)", "-print((dp[-1]))", "+answer = 0", "+max_r = -float(\"inf\")",...
false
0.038433
0.043844
0.876567
[ "s998502439", "s453814430" ]