user_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
submission_id_v0
stringlengths
10
10
submission_id_v1
stringlengths
10
10
cpu_time_v0
int64
10
38.3k
cpu_time_v1
int64
0
24.7k
memory_v0
int64
2.57k
1.02M
memory_v1
int64
2.57k
869k
status_v0
stringclasses
1 value
status_v1
stringclasses
1 value
improvement_frac
float64
7.51
100
input
stringlengths
20
4.55k
target
stringlengths
17
3.34k
code_v0_loc
int64
1
148
code_v1_loc
int64
1
184
code_v0_num_chars
int64
13
4.55k
code_v1_num_chars
int64
14
3.34k
code_v0_no_empty_lines
stringlengths
21
6.88k
code_v1_no_empty_lines
stringlengths
20
4.93k
code_same
bool
1 class
relative_loc_diff_percent
float64
0
79.8
diff
list
diff_only_import_comment
bool
1 class
measured_runtime_v0
float64
0.01
4.45
measured_runtime_v1
float64
0.01
4.31
runtime_lift
float64
0
359
key
list
u352394527
p00484
python
s674722035
s910536522
1,230
650
6,524
6,312
Accepted
Accepted
47.15
def solve(): n, k = list(map(int,input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [[0] for i in range(group_num)] for i in range(n): c,g = list(map(int,input().split())) book_map[g - 1].append(c) for i in range(group_num): book_map[i].sort(rev...
def solve(): n, k = list(map(int,input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [[0] for i in range(group_num)] for i in range(n): c,g = list(map(int,input().split())) book_map[g - 1].append(c) for i in range(group_num): book_map[i].sort(rev...
28
34
772
833
def solve(): n, k = list(map(int, input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [[0] for i in range(group_num)] for i in range(n): c, g = list(map(int, input().split())) book_map[g - 1].append(c) for i in range(group_num): book_map[i...
def solve(): n, k = list(map(int, input().split())) group_num = 10 book_map = [[] for i in range(group_num)] acc_map = [[0] for i in range(group_num)] for i in range(n): c, g = list(map(int, input().split())) book_map[g - 1].append(c) for i in range(group_num): book_map[i...
false
17.647059
[ "- for j in range(len(book_map[i])):", "- book_map[i][j] += j * 2", "- acc += book_map[i][j]", "- acc_map[i].append(acc)", "- # print(acc_map)", "+ bmi = book_map[i]", "+ append = acc_map[i].append", "+ for j in range(len(bmi)):", "+ ...
false
0.036098
0.035941
1.004378
[ "s674722035", "s910536522" ]
u816631826
p02676
python
s185761289
s248299245
32
29
8,960
9,116
Accepted
Accepted
9.38
K = int(eval(input())) S = eval(input()) if len(S) > K: print((S[:K] + "...")) else: print(S)
#input an interget k=int(input()) #input an string str1=str(input()) #get the length of the string x=int(len(str1)) #initialise y y=0 #make a second string for the appending str2="..." #if statement about how the string will function #if the string is the same length as k then print it if x<=k: print...
8
21
101
464
K = int(eval(input())) S = eval(input()) if len(S) > K: print((S[:K] + "...")) else: print(S)
# input an interget k = int(input()) # input an string str1 = str(input()) # get the length of the string x = int(len(str1)) # initialise y y = 0 # make a second string for the appending str2 = "..." # if statement about how the string will function # if the string is the same length as k then print it if x <= k: p...
false
61.904762
[ "-K = int(eval(input()))", "-S = eval(input())", "-if len(S) > K:", "- print((S[:K] + \"...\"))", "+# input an interget", "+k = int(input())", "+# input an string", "+str1 = str(input())", "+# get the length of the string", "+x = int(len(str1))", "+# initialise y", "+y = 0", "+# make a se...
false
0.037626
0.03725
1.010093
[ "s185761289", "s248299245" ]
u133936772
p02642
python
s053145536
s236336630
418
353
40,332
33,208
Accepted
Accepted
15.55
INF=10**6+1 n,*l=list(map(int,open(0).read().split())) from collections import * c=Counter(l) l=sorted(c.keys()) a=[] b=[0]*INF for i in l: b[i]=1 for i in l: if b[i]: if c[i]<2: a+=[i] for j in range(2*i,INF,i): b[j]=0 print((len(a)))
M=10**6+1 _,*l=list(map(int,open(0).read().split())) b=[0]*M for i in l: b[i]+=1 a=[] for i in sorted(l): if b[i]: if b[i]==1: a+=[i] for j in range(i,M,i): b[j]=0 print((len(a)))
13
10
251
190
INF = 10**6 + 1 n, *l = list(map(int, open(0).read().split())) from collections import * c = Counter(l) l = sorted(c.keys()) a = [] b = [0] * INF for i in l: b[i] = 1 for i in l: if b[i]: if c[i] < 2: a += [i] for j in range(2 * i, INF, i): b[j] = 0 print((len(a)))
M = 10**6 + 1 _, *l = list(map(int, open(0).read().split())) b = [0] * M for i in l: b[i] += 1 a = [] for i in sorted(l): if b[i]: if b[i] == 1: a += [i] for j in range(i, M, i): b[j] = 0 print((len(a)))
false
23.076923
[ "-INF = 10**6 + 1", "-n, *l = list(map(int, open(0).read().split()))", "-from collections import *", "-", "-c = Counter(l)", "-l = sorted(c.keys())", "+M = 10**6 + 1", "+_, *l = list(map(int, open(0).read().split()))", "+b = [0] * M", "+for i in l:", "+ b[i] += 1", "-b = [0] * INF", "-for...
false
0.116106
0.175386
0.662004
[ "s053145536", "s236336630" ]
u580073714
p02773
python
s886855865
s354368311
793
619
47,668
50,288
Accepted
Accepted
21.94
import collections N = int(eval(input())) A =[] for i in range(N): A.append(eval(input())) ans =[] c = collections.Counter(A) m = c.most_common() ma = m[0][1] for i in range(len(m)): if m[i][1] == ma: ans.append(m[i][0]) ans.sort() for i in range(len(ans)): print((ans[i]))
import collections N = int(eval(input())) A =[] for i in range(N): A.append(eval(input())) ans =[] c = collections.Counter(A) m = c.most_common() ma = m[0][1] for i in range(len(m)): if m[i][1] == ma: ans.append(m[i][0]) ans.sort() print(("\n".join(ans)))
19
18
305
282
import collections N = int(eval(input())) A = [] for i in range(N): A.append(eval(input())) ans = [] c = collections.Counter(A) m = c.most_common() ma = m[0][1] for i in range(len(m)): if m[i][1] == ma: ans.append(m[i][0]) ans.sort() for i in range(len(ans)): print((ans[i]))
import collections N = int(eval(input())) A = [] for i in range(N): A.append(eval(input())) ans = [] c = collections.Counter(A) m = c.most_common() ma = m[0][1] for i in range(len(m)): if m[i][1] == ma: ans.append(m[i][0]) ans.sort() print(("\n".join(ans)))
false
5.263158
[ "-for i in range(len(ans)):", "- print((ans[i]))", "+print((\"\\n\".join(ans)))" ]
false
0.03645
0.059967
0.607827
[ "s886855865", "s354368311" ]
u766163292
p02467
python
s564151027
s451342194
60
20
8,056
5,680
Accepted
Accepted
66.67
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import collections import itertools def prime_factorization(n): assert n > 0 if n == 1: return collections.deque([1]) else: result = collections.deque() for i in itertools.count(2): if i * i > n: ...
#!/usr/bin/env python3 """Compute the prime factorization of the given integer by trial division. Verification: [NTL_1_A](https://example.com) """ import math def factorize_trial_division(n): """Compute the prime factorization of the given integer `n` by trival division. Returns: the prime fa...
29
37
693
793
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import collections import itertools def prime_factorization(n): assert n > 0 if n == 1: return collections.deque([1]) else: result = collections.deque() for i in itertools.count(2): if i * i > n: break ...
#!/usr/bin/env python3 """Compute the prime factorization of the given integer by trial division. Verification: [NTL_1_A](https://example.com) """ import math def factorize_trial_division(n): """Compute the prime factorization of the given integer `n` by trival division. Returns: the prime factors as a list. ...
false
21.621622
[ "-# -*- coding: utf-8 -*-", "-import collections", "-import itertools", "+\"\"\"Compute the prime factorization of the given integer by trial division.", "+Verification: [NTL_1_A](https://example.com)", "+\"\"\"", "+import math", "-def prime_factorization(n):", "- assert n > 0", "- if n == 1...
false
0.035577
0.045099
0.788862
[ "s564151027", "s451342194" ]
u007263493
p02934
python
s335052929
s373635643
269
17
17,984
2,940
Accepted
Accepted
93.68
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) import numpy as np N = int(eval(input())) A = np.array(input().split(),np.int32) answer = 1/(1/A).sum() print(answer)
n = eval(input()) r = 0 for s in input().split(): r +=1/int(s) print((1/r))
10
5
193
75
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import numpy as np N = int(eval(input())) A = np.array(input().split(), np.int32) answer = 1 / (1 / A).sum() print(answer)
n = eval(input()) r = 0 for s in input().split(): r += 1 / int(s) print((1 / r))
false
50
[ "-import sys", "-", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-import numpy as np", "-", "-N = int(eval(input()))", "-A = np.array(input().split(), np.int32)", "-answer = 1 / (1 / A).sum()", "-print(answer)", "+n = eval(input())", "+r = 0", "+for s in input().split():"...
false
0.787881
0.035095
22.449798
[ "s335052929", "s373635643" ]
u347640436
p03634
python
s319476476
s470233361
946
706
55,376
61,332
Accepted
Accepted
25.37
N = int(eval(input())) links = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) links[a].append((b, c)) links[b].append((a, c)) Q, K = list(map(int, input().split())) d = [float('inf')] * (N + 1) d[K] = 0 q = [K] while q: i = q.pop() for j, ...
# ダイクストラ法 from heapq import heappop, heappush N = int(eval(input())) links = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) links[a].append((b, c)) links[b].append((a, c)) Q, K = list(map(int, input().split())) d = [float('inf')] * (N + 1) d[K] = ...
24
31
547
711
N = int(eval(input())) links = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) links[a].append((b, c)) links[b].append((a, c)) Q, K = list(map(int, input().split())) d = [float("inf")] * (N + 1) d[K] = 0 q = [K] while q: i = q.pop() for j, c in links[i]: ...
# ダイクストラ法 from heapq import heappop, heappush N = int(eval(input())) links = [[] for _ in range(N + 1)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) links[a].append((b, c)) links[b].append((a, c)) Q, K = list(map(int, input().split())) d = [float("inf")] * (N + 1) d[K] = 0 # prev = [Non...
false
22.580645
[ "+# ダイクストラ法", "+from heapq import heappop, heappush", "+", "-q = [K]", "+# prev = [None] * (N + 1)", "+q = [(0, K)]", "- i = q.pop()", "- for j, c in links[i]:", "- if d[i] + c < d[j]:", "- d[j] = d[i] + c", "- q.append(j)", "+ _, u = heappop(q)", "+ ...
false
0.058879
0.084404
0.69758
[ "s319476476", "s470233361" ]
u392319141
p02863
python
s543019068
s689886256
563
464
58,072
48,616
Accepted
Accepted
17.58
N, T = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort() INF = float('inf') dp = [-INF] * (T + 1) dp[0] = 0 for a, b in AB: newDp = dp[::] for t, d in enumerate(dp[:T]): newDp[min(T, t + a)] = max(newDp[min(T, t + a)], d + b) dp = newDp...
N, T = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort() INF = float('inf') dp = [-INF] * (T + 1) dp[0] = 0 for a, b in AB: for t in range(T)[:: -1]: dp[min(T, t + a)] = max(dp[min(T, t + a)], dp[t] + b) print((max(dp)))
15
13
332
289
N, T = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort() INF = float("inf") dp = [-INF] * (T + 1) dp[0] = 0 for a, b in AB: newDp = dp[::] for t, d in enumerate(dp[:T]): newDp[min(T, t + a)] = max(newDp[min(T, t + a)], d + b) dp = newDp print((max(dp...
N, T = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for _ in range(N)] AB.sort() INF = float("inf") dp = [-INF] * (T + 1) dp[0] = 0 for a, b in AB: for t in range(T)[::-1]: dp[min(T, t + a)] = max(dp[min(T, t + a)], dp[t] + b) print((max(dp)))
false
13.333333
[ "- newDp = dp[::]", "- for t, d in enumerate(dp[:T]):", "- newDp[min(T, t + a)] = max(newDp[min(T, t + a)], d + b)", "- dp = newDp", "+ for t in range(T)[::-1]:", "+ dp[min(T, t + a)] = max(dp[min(T, t + a)], dp[t] + b)" ]
false
0.115018
0.117558
0.978391
[ "s543019068", "s689886256" ]
u754022296
p03822
python
s903794959
s183925110
419
321
131,496
131,480
Accepted
Accepted
23.39
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import heapq def main(): n = int(eval(input())) T = [[] for _ in range(n)] for i in range(1, n): a = int(eval(input())) a -= 1 T[a].append(i) def dfs(v): if not T[v]: return 0 L = [] for i in T[...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import heapq def main(): n = int(eval(input())) T = [[] for _ in range(n)] for i in range(1, n): a = int(eval(input())) a -= 1 T[a].append(i) def dfs(v): if not T[v]: return 0 L = [] for i in T[...
30
30
544
524
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import heapq def main(): n = int(eval(input())) T = [[] for _ in range(n)] for i in range(1, n): a = int(eval(input())) a -= 1 T[a].append(i) def dfs(v): if not T[v]: return 0 L = [...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import heapq def main(): n = int(eval(input())) T = [[] for _ in range(n)] for i in range(1, n): a = int(eval(input())) a -= 1 T[a].append(i) def dfs(v): if not T[v]: return 0 L = [...
false
0
[ "- for _ in range(len(T[v]) - 1):", "+ while L:" ]
false
0.101967
0.037698
2.704856
[ "s903794959", "s183925110" ]
u088552457
p03053
python
s421457002
s481538599
297
267
154,588
115,864
Accepted
Accepted
10.1
# import sys # input = sys.stdin.readline import itertools import collections # 持っているビスケットを叩き、1枚増やす # ビスケット A枚を 1円に交換する # 1円をビスケット B枚に交換する def main(): h, w = input_list() grids = [list(eval(input())) for i in range(h)] dist = [[-1]*w for _ in range(h)] black_cells = collections.deque() ...
# import sys # input = sys.stdin.readline import collections def main(): H, W = input_list() grid = [eval(input()) for i in range(H)] dist = [[-1]*W for _ in range(H)] black_cells = collections.deque() for h in range(H): for w in range(W): if grid[h][w] == '#': ...
50
45
1,208
1,184
# import sys # input = sys.stdin.readline import itertools import collections # 持っているビスケットを叩き、1枚増やす # ビスケット A枚を 1円に交換する # 1円をビスケット B枚に交換する def main(): h, w = input_list() grids = [list(eval(input())) for i in range(h)] dist = [[-1] * w for _ in range(h)] black_cells = collections.deque() for hi in ...
# import sys # input = sys.stdin.readline import collections def main(): H, W = input_list() grid = [eval(input()) for i in range(H)] dist = [[-1] * W for _ in range(H)] black_cells = collections.deque() for h in range(H): for w in range(W): if grid[h][w] == "#": ...
false
10
[ "-import itertools", "-# 持っているビスケットを叩き、1枚増やす", "-# ビスケット A枚を 1円に交換する", "-# 1円をビスケット B枚に交換する", "+", "- h, w = input_list()", "- grids = [list(eval(input())) for i in range(h)]", "- dist = [[-1] * w for _ in range(h)]", "+ H, W = input_list()", "+ grid = [eval(input()) for i in range(...
false
0.042031
0.038959
1.078863
[ "s421457002", "s481538599" ]
u703950586
p03078
python
s964109673
s007975919
1,055
565
196,128
48,728
Accepted
Accepted
46.45
import sys,queue,math,copy,itertools,bisect,collections LI = lambda : [int(x) for x in sys.stdin.readline().split()] X,Y,Z,K = LI() A = LI() B = LI() C = LI() A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = A[0] + B[0] + C[0] l = 0 while h > l+1: m = (h+l) // 2 num = 0 ...
import sys,queue,math,copy,itertools,bisect,collections LI = lambda : [int(x) for x in sys.stdin.readline().split()] X,Y,Z,K = LI() A = LI() B = LI() C = LI() A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = A[0] + B[0] + C[0] +1 l = 0 while h > l+1: m = (h+l) // 2 num = 0...
52
52
1,001
1,000
import sys, queue, math, copy, itertools, bisect, collections LI = lambda: [int(x) for x in sys.stdin.readline().split()] X, Y, Z, K = LI() A = LI() B = LI() C = LI() A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = A[0] + B[0] + C[0] l = 0 while h > l + 1: m = (h + l) // 2 num = 0 for a ...
import sys, queue, math, copy, itertools, bisect, collections LI = lambda: [int(x) for x in sys.stdin.readline().split()] X, Y, Z, K = LI() A = LI() B = LI() C = LI() A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) h = A[0] + B[0] + C[0] + 1 l = 0 while h > l + 1: m = (h + l) // 2 num = 0 fo...
false
0
[ "-h = A[0] + B[0] + C[0]", "+h = A[0] + B[0] + C[0] + 1", "-print(*ans[:K], sep=\"\\n\")", "+print(*ans, sep=\"\\n\")" ]
false
0.037304
0.035426
1.053027
[ "s964109673", "s007975919" ]
u255673886
p03436
python
s693256521
s617302511
208
130
40,816
77,680
Accepted
Accepted
37.5
import sys readline = sys.stdin.buffer.readline from collections import deque import copy def myinput(): return list(map(int,readline().split())) def mycol(data,col): return [ row[col] for row in data ] h,w = myinput() maze = [ list(eval(input())) for _ in range(h) ] # print(maze) white =...
from collections import deque from heapq import heapify,heappop,heappush,heappushpop from copy import copy,deepcopy from itertools import product,permutations,combinations,combinations_with_replacement from collections import defaultdict,Counter from bisect import bisect_left,bisect_right from math import gcd,cei...
65
144
1,396
3,241
import sys readline = sys.stdin.buffer.readline from collections import deque import copy def myinput(): return list(map(int, readline().split())) def mycol(data, col): return [row[col] for row in data] h, w = myinput() maze = [list(eval(input())) for _ in range(h)] # print(maze) white = 0 black = 0 for ...
from collections import deque from heapq import heapify, heappop, heappush, heappushpop from copy import copy, deepcopy from itertools import product, permutations, combinations, combinations_with_replacement from collections import defaultdict, Counter from bisect import bisect_left, bisect_right from math import gcd,...
false
54.861111
[ "-import sys", "+from collections import deque", "+from heapq import heapify, heappop, heappush, heappushpop", "+from copy import copy, deepcopy", "+from itertools import product, permutations, combinations, combinations_with_replacement", "+from collections import defaultdict, Counter", "+from bisect i...
false
0.098441
0.16839
0.584602
[ "s693256521", "s617302511" ]
u841599623
p02713
python
s409412137
s818146752
1,385
486
9,192
73,180
Accepted
Accepted
64.91
import math K=int(eval(input())) c = 0 for i in range(1,K+1): for j in range(1,K+1): if math.gcd(i,j) == 1: c += K else: for k in range(1,K+1): if i == j == k: c += i elif i == j: c += math.gcd(i,k) elif i == k: c += math.gcd(i,j)...
import math K=int(eval(input())) c = 0 for i in range(1,K+1): for j in range(1,K+1): for k in range(1,K+1): if i == j == k: c += i elif i == j: c += math.gcd(i,k) elif i == k: c += math.gcd(i,j) elif j == k: c += math.gcd(i,k) else: ...
20
17
435
360
import math K = int(eval(input())) c = 0 for i in range(1, K + 1): for j in range(1, K + 1): if math.gcd(i, j) == 1: c += K else: for k in range(1, K + 1): if i == j == k: c += i elif i == j: c += math.g...
import math K = int(eval(input())) c = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): if i == j == k: c += i elif i == j: c += math.gcd(i, k) elif i == k: c += math.gcd(i, j) eli...
false
15
[ "- if math.gcd(i, j) == 1:", "- c += K", "- else:", "- for k in range(1, K + 1):", "- if i == j == k:", "- c += i", "- elif i == j:", "- c += math.gcd(i, k)", "- elif i == k:", "-...
false
0.137604
0.038782
3.548143
[ "s409412137", "s818146752" ]
u545368057
p02934
python
s008768979
s463131437
162
17
38,256
2,940
Accepted
Accepted
89.51
N = int(eval(input())) As = list(map(int, input().split())) rev = 0 for a in As: rev += 1/a print((1/rev))
N = int(eval(input())) As = list(map(int,input().split())) cnt = 0 for a in As: cnt += 1/a print((1/cnt))
7
9
110
114
N = int(eval(input())) As = list(map(int, input().split())) rev = 0 for a in As: rev += 1 / a print((1 / rev))
N = int(eval(input())) As = list(map(int, input().split())) cnt = 0 for a in As: cnt += 1 / a print((1 / cnt))
false
22.222222
[ "-rev = 0", "+cnt = 0", "- rev += 1 / a", "-print((1 / rev))", "+ cnt += 1 / a", "+print((1 / cnt))" ]
false
0.035825
0.035613
1.005974
[ "s008768979", "s463131437" ]
u876616721
p02622
python
s649294453
s577469536
65
60
9,392
9,324
Accepted
Accepted
7.69
s = eval(input()) t = eval(input()) #print(s) #print(t) n = 0 for i in range(0,len(s)): #print('i=',i) if s[i] == t[i]: n = n + 0 else: n = n + 1 print(n)
s = eval(input()) t = eval(input()) #print(s) #print(t) n = 0 for i in range(0,len(s)): #print('i=',i) if s[i] != t[i]: n = n + 1 print(n)
12
10
167
144
s = eval(input()) t = eval(input()) # print(s) # print(t) n = 0 for i in range(0, len(s)): # print('i=',i) if s[i] == t[i]: n = n + 0 else: n = n + 1 print(n)
s = eval(input()) t = eval(input()) # print(s) # print(t) n = 0 for i in range(0, len(s)): # print('i=',i) if s[i] != t[i]: n = n + 1 print(n)
false
16.666667
[ "- if s[i] == t[i]:", "- n = n + 0", "- else:", "+ if s[i] != t[i]:" ]
false
0.036735
0.036382
1.009701
[ "s649294453", "s577469536" ]
u057109575
p03557
python
s274120437
s820099795
382
310
24,392
24,096
Accepted
Accepted
18.85
from bisect import bisect_right N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) cnt = [0] * N for i in range(N): cnt[i] = N - bisect_right(C, B[i]) cumsum = [0] * (N + 1) for i in range(N): ...
N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) from bisect import bisect_left, bisect_right res = 0 for b in B: res += bisect_left(A, b) * (N - bisect_right(C, b)) print(res)
20
12
453
295
from bisect import bisect_right N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) cnt = [0] * N for i in range(N): cnt[i] = N - bisect_right(C, B[i]) cumsum = [0] * (N + 1) for i in range(N): cumsum[i + 1] ...
N = int(eval(input())) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) from bisect import bisect_left, bisect_right res = 0 for b in B: res += bisect_left(A, b) * (N - bisect_right(C, b)) print(res)
false
40
[ "-from bisect import bisect_right", "-", "-cnt = [0] * N", "-for i in range(N):", "- cnt[i] = N - bisect_right(C, B[i])", "-cumsum = [0] * (N + 1)", "-for i in range(N):", "- cumsum[i + 1] = cumsum[i] + cnt[N - i - 1]", "+from bisect import bisect_left, bisect_right", "+", "-for i in range...
false
0.047663
0.047864
0.995794
[ "s274120437", "s820099795" ]
u347184682
p02838
python
s928237734
s266676156
1,947
238
50,972
68,904
Accepted
Accepted
87.78
n = int(eval(input())) a = list(map(int,input().split())) mod = 10**9+7 ans = 0 for i in range(60): keta=1<<i cnt=0 for j in a: if keta & j: cnt+=1 ans+=((keta%mod)*cnt*(n-cnt))%mod print((ans%mod))
import numpy as np n = int(eval(input())) a = list(map(int,input().split())) mod = 10**9+7 ans = 0 a=np.array(a) for i in range(60): keta = a>>i & 1 num1 = int(keta.sum()) num0 = n - num1 ans+= ((2**i)%mod)*(num1*num0) ans%=mod print(ans)
14
15
224
259
n = int(eval(input())) a = list(map(int, input().split())) mod = 10**9 + 7 ans = 0 for i in range(60): keta = 1 << i cnt = 0 for j in a: if keta & j: cnt += 1 ans += ((keta % mod) * cnt * (n - cnt)) % mod print((ans % mod))
import numpy as np n = int(eval(input())) a = list(map(int, input().split())) mod = 10**9 + 7 ans = 0 a = np.array(a) for i in range(60): keta = a >> i & 1 num1 = int(keta.sum()) num0 = n - num1 ans += ((2**i) % mod) * (num1 * num0) ans %= mod print(ans)
false
6.666667
[ "+import numpy as np", "+", "+a = np.array(a)", "- keta = 1 << i", "- cnt = 0", "- for j in a:", "- if keta & j:", "- cnt += 1", "- ans += ((keta % mod) * cnt * (n - cnt)) % mod", "-print((ans % mod))", "+ keta = a >> i & 1", "+ num1 = int(keta.sum())", "+...
false
0.048156
0.229886
0.209477
[ "s928237734", "s266676156" ]
u680004123
p03416
python
s626385538
s540400007
71
45
3,060
3,060
Accepted
Accepted
36.62
a, b = map(int, input().split()) count = 0 for i in range(a, b+1): i = str(i) if str(i[0]) == str(i[4]) and\ str(i[1]) == str(i[3]): count += 1 print(count)
a, b = map(str, input().split()) count = 0 for i in range(int(a), int(b)+1): num = str(i) if num[0] == num[4] and \ num[1] == num[3]: count += 1 print(count)
8
8
211
204
a, b = map(int, input().split()) count = 0 for i in range(a, b + 1): i = str(i) if str(i[0]) == str(i[4]) and str(i[1]) == str(i[3]): count += 1 print(count)
a, b = map(str, input().split()) count = 0 for i in range(int(a), int(b) + 1): num = str(i) if num[0] == num[4] and num[1] == num[3]: count += 1 print(count)
false
0
[ "-a, b = map(int, input().split())", "+a, b = map(str, input().split())", "-for i in range(a, b + 1):", "- i = str(i)", "- if str(i[0]) == str(i[4]) and str(i[1]) == str(i[3]):", "+for i in range(int(a), int(b) + 1):", "+ num = str(i)", "+ if num[0] == num[4] and num[1] == num[3]:" ]
false
0.045989
0.079232
0.580437
[ "s626385538", "s540400007" ]
u150491838
p03854
python
s103161786
s537657004
30
24
3,188
3,316
Accepted
Accepted
20
def main(): s = eval(input()) i = 0 is_ok = True while i < len(s): if i <= len(s) < i + 7: if i <= len(s) < i + 4: is_ok = False break next_word = s[i:i+5] if next_word == 'dream': if s[i+5:i+7] == 'er': ...
def main(): s = eval(input()) i = 0 is_ok = True while i < len(s): if i <= len(s) < i + 7: if i <= len(s) < i + 4: is_ok = False break next_word = s[i:i+5] if next_word == 'dream': if s[i+5:i+7] == 'er': ...
43
64
922
1,330
def main(): s = eval(input()) i = 0 is_ok = True while i < len(s): if i <= len(s) < i + 7: if i <= len(s) < i + 4: is_ok = False break next_word = s[i : i + 5] if next_word == "dream": if s[i + 5 : i + 7] == "er": ...
def main(): s = eval(input()) i = 0 is_ok = True while i < len(s): if i <= len(s) < i + 7: if i <= len(s) < i + 4: is_ok = False break next_word = s[i : i + 5] if next_word == "dream": if s[i + 5 : i + 7] == "er": ...
false
32.8125
[ "+def main2():", "+ s = eval(input())", "+ i = len(s)", "+ while i > 0:", "+ if s[i - 5 : i] == \"dream\":", "+ i -= 5", "+ elif s[i - 7 : i] == \"dreamer\":", "+ i -= 7", "+ elif s[i - 5 : i] == \"erase\":", "+ i -= 5", "+ el...
false
0.044432
0.087261
0.509193
[ "s103161786", "s537657004" ]
u281610856
p03356
python
s780163732
s994280322
767
606
22,724
23,448
Accepted
Accepted
20.99
class UnionFind: def __init__(self, n): self.n = n self.par = [-1] * n def find(self, x): if self.par[x] < 0: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def unite(self, x, y): x = self.find...
import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n # 各要素の親要素の番号を格納するリスト def find(self, x): # 要素xが属するグループの根を返す if self.parents[x] < 0: return x else: self.parents[x] = self.find...
48
76
1,082
2,023
class UnionFind: def __init__(self, n): self.n = n self.par = [-1] * n def find(self, x): if self.par[x] < 0: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def unite(self, x, y): x = self.find(x) y...
import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n # 各要素の親要素の番号を格納するリスト def find(self, x): # 要素xが属するグループの根を返す if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parent...
false
36.842105
[ "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "- self.par = [-1] * n", "+ self.parents = [-1] * n # 各要素の親要素の番号を格納するリスト", "- def find(self, x):", "- if self.par[x] < 0:", "+ def find(self, x): # 要素xが属するグループの根を返す", "+ if self.parents[x] < 0:", "...
false
0.007915
0.042716
0.185287
[ "s780163732", "s994280322" ]
u285891772
p03556
python
s047114533
s032693401
48
39
5,324
5,140
Accepted
Accepted
18.75
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
23
22
819
818
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_...
false
4.347826
[ "-print((int(sqrt(N)) ** 2))", "+print((int(N ** (1 / 2)) ** 2))" ]
false
0.037969
0.119911
0.316646
[ "s047114533", "s032693401" ]
u750822433
p02753
python
s423202914
s343381718
178
63
38,384
61,856
Accepted
Accepted
64.61
S=eval(input()) if(S=='AAA' or S=='BBB'): print('No') else: print('Yes')
a=eval(input()) if(a=='AAA' or a=='BBB'): print('No') else: print('Yes')
6
6
81
81
S = eval(input()) if S == "AAA" or S == "BBB": print("No") else: print("Yes")
a = eval(input()) if a == "AAA" or a == "BBB": print("No") else: print("Yes")
false
0
[ "-S = eval(input())", "-if S == \"AAA\" or S == \"BBB\":", "+a = eval(input())", "+if a == \"AAA\" or a == \"BBB\":" ]
false
0.080586
0.043314
1.860505
[ "s423202914", "s343381718" ]
u556589653
p03434
python
s327861610
s765268862
173
17
38,384
3,060
Accepted
Accepted
90.17
N = int(eval(input())) A = list(map(int,input().split())) A.sort() A.reverse() a = 0 b = 0 for i in range(N): if i%2 == 0: a += A[i] else: b += A[i] print((a-b))
N = int(eval(input())) A = 0 B = 0 ls1 = list(map(int,input().split())) ls1.sort() ls1.reverse() for i in range(N): if i%2 == 0: A += ls1[i] else: B += ls1[i] print((A-B))
12
12
176
198
N = int(eval(input())) A = list(map(int, input().split())) A.sort() A.reverse() a = 0 b = 0 for i in range(N): if i % 2 == 0: a += A[i] else: b += A[i] print((a - b))
N = int(eval(input())) A = 0 B = 0 ls1 = list(map(int, input().split())) ls1.sort() ls1.reverse() for i in range(N): if i % 2 == 0: A += ls1[i] else: B += ls1[i] print((A - B))
false
0
[ "-A = list(map(int, input().split()))", "-A.sort()", "-A.reverse()", "-a = 0", "-b = 0", "+A = 0", "+B = 0", "+ls1 = list(map(int, input().split()))", "+ls1.sort()", "+ls1.reverse()", "- a += A[i]", "+ A += ls1[i]", "- b += A[i]", "-print((a - b))", "+ B += ls...
false
0.137262
0.037214
3.688409
[ "s327861610", "s765268862" ]
u991567869
p02748
python
s382676923
s938116568
438
230
18,736
18,616
Accepted
Accepted
47.49
A, B, M = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**6 for i in range(M): x, y, c = list(map(int, input().split())) ans = min(ans, a[x - 1] + b[y - 1] - c) ans = min(ans, min(a) + min(b)) print(ans)
import sys input = sys.stdin.readline def main(): A, B, M = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**6 for i in range(M): x, y, c = list(map(int, input().split())) ans = min(ans, a[x - 1] + b[y - 1]...
12
18
279
380
A, B, M = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**6 for i in range(M): x, y, c = list(map(int, input().split())) ans = min(ans, a[x - 1] + b[y - 1] - c) ans = min(ans, min(a) + min(b)) print(ans)
import sys input = sys.stdin.readline def main(): A, B, M = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**6 for i in range(M): x, y, c = list(map(int, input().split())) ans = min(ans, a[x - 1] + b[y - 1] - c) ...
false
33.333333
[ "-A, B, M = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-b = list(map(int, input().split()))", "-ans = 10**6", "-for i in range(M):", "- x, y, c = list(map(int, input().split()))", "- ans = min(ans, a[x - 1] + b[y - 1] - c)", "-ans = min(ans, min(a) + min(b))", "...
false
0.060417
0.067874
0.890141
[ "s382676923", "s938116568" ]
u247753603
p02706
python
s055821270
s135577487
32
27
10,180
9,860
Accepted
Accepted
15.62
N,M = list(map(int,input().split())) A = list(map(int,input().split())) A_sum = sum(A) ans = N - A_sum if ans>=0: print(ans) else: print((-1))
N,M = list(map(int,input().split())) A = list(map(int,input().split())) A_sum = sum(A) if N - A_sum>=0: print((N - A_sum)) else: print((-1))
10
9
153
149
N, M = list(map(int, input().split())) A = list(map(int, input().split())) A_sum = sum(A) ans = N - A_sum if ans >= 0: print(ans) else: print((-1))
N, M = list(map(int, input().split())) A = list(map(int, input().split())) A_sum = sum(A) if N - A_sum >= 0: print((N - A_sum)) else: print((-1))
false
10
[ "-ans = N - A_sum", "-if ans >= 0:", "- print(ans)", "+if N - A_sum >= 0:", "+ print((N - A_sum))" ]
false
0.036722
0.035235
1.042228
[ "s055821270", "s135577487" ]
u600402037
p02819
python
s097322927
s886783836
176
17
14,000
3,060
Accepted
Accepted
90.34
import sys #import numpy as np stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only rs = lambda: stdin.readline().rstrip() # ignore trailing spaces X = ri() def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_pr...
import sys sys.setrecursionlimit(10 ** 7) sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) X = ir() def check(n): if X == 2: return True if n % 2 == 0: return False f = 3 while f * f <= n: if n % f == 0...
27
29
657
493
import sys # import numpy as np stdin = sys.stdin ri = lambda: int(rs()) rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only rs = lambda: stdin.readline().rstrip() # ignore trailing spaces X = ri() def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = ...
import sys sys.setrecursionlimit(10**7) sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) X = ir() def check(n): if X == 2: return True if n % 2 == 0: return False f = 3 while f * f <= n: if n % f == 0: retu...
false
6.896552
[ "-# import numpy as np", "-stdin = sys.stdin", "-ri = lambda: int(rs())", "-rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only", "-rs = lambda: stdin.readline().rstrip() # ignore trailing spaces", "-X = ri()", "+sys.setrecursionlimit(10**7)", "+sr = lambda: sys.stdin.rea...
false
0.528246
0.03601
14.669609
[ "s097322927", "s886783836" ]
u191874006
p02925
python
s699803881
s278229554
1,986
440
110,040
63,448
Accepted
Accepted
77.84
#!/usr/bin/env python3 #ABC139 E import sys import math import bisect import time sys.setrecursionlimit(1000000000) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operat...
#!/usr/bin/env python3 #ABC139 E import sys import math import bisect import time sys.setrecursionlimit(1000000000) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operat...
57
39
1,382
967
#!/usr/bin/env python3 # ABC139 E import sys import math import bisect import time sys.setrecursionlimit(1000000000) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import i...
#!/usr/bin/env python3 # ABC139 E import sys import math import bisect import time sys.setrecursionlimit(1000000000) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import i...
false
31.578947
[ "-a = [deque() for _ in range(n)]", "-for i in range(1, n + 1):", "- x = LI()", "- for j in x:", "- a[i - 1].append((i, j))", "-ans = 0", "-s = time.time()", "-for j in range(n * (n - 1) // 2 + 1):", "- check = [1] * n", "- flg = False", "- flg2 = False", "- if time.ti...
false
0.042787
0.080936
0.528646
[ "s699803881", "s278229554" ]
u735654057
p04030
python
s783558198
s135797716
22
17
2,940
2,940
Accepted
Accepted
22.73
s = eval(input()) p = [] for token in list(s): if token == "B": if not len(p) == 0: p.pop() else: p.append(token) print(("".join(p)))
# https://atcoder.jp/contests/abc043/tasks/abc043_b s = list(eval(input())) result = [] for c in s: if c == 'B': if len(result) > 0: result.pop() else: result.append(c) print((''.join(result)))
12
11
176
233
s = eval(input()) p = [] for token in list(s): if token == "B": if not len(p) == 0: p.pop() else: p.append(token) print(("".join(p)))
# https://atcoder.jp/contests/abc043/tasks/abc043_b s = list(eval(input())) result = [] for c in s: if c == "B": if len(result) > 0: result.pop() else: result.append(c) print(("".join(result)))
false
8.333333
[ "-s = eval(input())", "-p = []", "-for token in list(s):", "- if token == \"B\":", "- if not len(p) == 0:", "- p.pop()", "+# https://atcoder.jp/contests/abc043/tasks/abc043_b", "+s = list(eval(input()))", "+result = []", "+for c in s:", "+ if c == \"B\":", "+ if ...
false
0.204137
0.111341
1.833447
[ "s783558198", "s135797716" ]
u294385082
p03611
python
s240703625
s485702713
154
98
14,836
13,964
Accepted
Accepted
36.36
n = int(eval(input())) a = list(map(int,input().split())) dict = {} ans = 0 for i in range(n): if a[i] not in dict: dict[a[i]] = 1 else: dict[a[i]] += 1 l = sorted(dict.items()) l += [(-1,0),(-2,0)] for j in range(len(l)-2): if l[j][0]+1 == l[j+1][0] and l[j][0]+2 == l[j+2][0]: ans...
n = int(eval(input())) a = list(map(int,input().split())) ans = 0 l = [0]*100001 for i in a: l[i] += 1 for i in range(len(l)-2): ans = max(ans,l[i]+l[i+1]+l[i+2]) print(ans)
25
14
564
193
n = int(eval(input())) a = list(map(int, input().split())) dict = {} ans = 0 for i in range(n): if a[i] not in dict: dict[a[i]] = 1 else: dict[a[i]] += 1 l = sorted(dict.items()) l += [(-1, 0), (-2, 0)] for j in range(len(l) - 2): if l[j][0] + 1 == l[j + 1][0] and l[j][0] + 2 == l[j + 2][0]:...
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 l = [0] * 100001 for i in a: l[i] += 1 for i in range(len(l) - 2): ans = max(ans, l[i] + l[i + 1] + l[i + 2]) print(ans)
false
44
[ "-dict = {}", "-for i in range(n):", "- if a[i] not in dict:", "- dict[a[i]] = 1", "- else:", "- dict[a[i]] += 1", "-l = sorted(dict.items())", "-l += [(-1, 0), (-2, 0)]", "-for j in range(len(l) - 2):", "- if l[j][0] + 1 == l[j + 1][0] and l[j][0] + 2 == l[j + 2][0]:", "-...
false
0.048334
0.131044
0.368841
[ "s240703625", "s485702713" ]
u766163292
p02362
python
s561087068
s280531390
3,030
730
8,728
8,644
Accepted
Accepted
75.91
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array import collections G_INF = 2 ** 31 class GraphError(Exception): pass class GraphSearchError(GraphError): def __init__(self, reason): self.reason = reason def __str__(self): return str(reason) class ...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array import collections G_INF = 2 ** 31 # ??°???????????¢?????????????????????????????? class GraphError(Exception): pass # ??°???????????¢?´¢??§??????????????????????????¨?????¨????????????????????? class GraphSearchError(GraphError): ...
81
100
2,249
3,324
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array import collections G_INF = 2**31 class GraphError(Exception): pass class GraphSearchError(GraphError): def __init__(self, reason): self.reason = reason def __str__(self): return str(reason) class ShortestPathFasterAlgorithm(...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array import collections G_INF = 2**31 # ??°???????????¢?????????????????????????????? class GraphError(Exception): pass # ??°???????????¢?´¢??§??????????????????????????¨?????¨????????????????????? class GraphSearchError(GraphError): def __init__(self, r...
false
19
[ "-", "-", "+# ??°???????????¢??????????????????????????????", "+# ??°???????????¢?´¢??§??????????????????????????¨?????¨?????????????????????", "+# Shortest Path Faster Algorithm??¬???", "+ # ??????????????°", "+ # ??£??\\?????????", "+ # ?????????????????????????????£??\\????????...
false
0.037482
0.038119
0.983292
[ "s561087068", "s280531390" ]
u347640436
p02763
python
s292809526
s889155241
696
455
48,212
49,688
Accepted
Accepted
34.63
class SegmentTree(): _data = [] _offset = 0 _size = 0 def __init__(self, size): _size = size t = 1 while t < size: t *= 2 self._offset = t - 1 self._data = [0 for _ in range(t * 2 - 1)] def update_all(self, iterable): self._...
# Segment tree (Bitwise Or) from operator import or_ class SegmentTree: _f = None _data = None _offset = None _size = None def __init__(self, size, f): self._f = f self._size = size t = 1 while t < size: t *= 2 self._offset = t -...
55
73
1,511
1,837
class SegmentTree: _data = [] _offset = 0 _size = 0 def __init__(self, size): _size = size t = 1 while t < size: t *= 2 self._offset = t - 1 self._data = [0 for _ in range(t * 2 - 1)] def update_all(self, iterable): self._data[self._offse...
# Segment tree (Bitwise Or) from operator import or_ class SegmentTree: _f = None _data = None _offset = None _size = None def __init__(self, size, f): self._f = f self._size = size t = 1 while t < size: t *= 2 self._offset = t - 1 self....
false
24.657534
[ "+# Segment tree (Bitwise Or)", "+from operator import or_", "+", "+", "- _data = []", "- _offset = 0", "- _size = 0", "+ _f = None", "+ _data = None", "+ _offset = None", "+ _size = None", "- def __init__(self, size):", "- _size = size", "+ def __init__(s...
false
0.038339
0.007463
5.137474
[ "s292809526", "s889155241" ]
u414458988
p02777
python
s641915254
s647018876
173
160
38,384
38,256
Accepted
Accepted
7.51
def main(): from sys import stdin, setrecursionlimit #from sys import stdin, setrecursionlimit #setrecursionlimit(10**9) #n = int(stdin.readline()[:-1]) #r = stdin.readline()[:-1] #r = [stdin.readline() for i in range(n)] #t = [int(stdin.readline()) for i in range(n)] #n = i...
def main(): s,t = input().split() a,b = list(map(int,input().split())) u = eval(input()) if s == u: print((a-1,b)) else: print((a,b-1)) if __name__ == '__main__': main()
32
12
860
212
def main(): from sys import stdin, setrecursionlimit # from sys import stdin, setrecursionlimit # setrecursionlimit(10**9) # n = int(stdin.readline()[:-1]) # r = stdin.readline()[:-1] # r = [stdin.readline() for i in range(n)] # t = [int(stdin.readline()) for i in range(n)] # n = int(r)...
def main(): s, t = input().split() a, b = list(map(int, input().split())) u = eval(input()) if s == u: print((a - 1, b)) else: print((a, b - 1)) if __name__ == "__main__": main()
false
62.5
[ "- from sys import stdin, setrecursionlimit", "-", "- # from sys import stdin, setrecursionlimit", "- # setrecursionlimit(10**9)", "- # n = int(stdin.readline()[:-1])", "- # r = stdin.readline()[:-1]", "- # r = [stdin.readline() for i in range(n)]", "- # t = [int(stdin.readline())...
false
0.037433
0.061544
0.608233
[ "s641915254", "s647018876" ]
u222668979
p03196
python
s203359889
s778518839
186
169
38,512
38,512
Accepted
Accepted
9.14
from collections import defaultdict def factorize(N): p = 2 PRIME = [] while p * p <= N: if N % p == 0: N //= p PRIME.append(p) else: p += 1 if N > 1: PRIME.append(N) return PRIME n, p = list(map(int, input().split())) ...
from collections import defaultdict def factorize(N): p = 2 PRIME = defaultdict(int) while p * p <= N: if N % p == 0: N //= p PRIME[p] += 1 else: p += 1 if N > 1: PRIME[N] += 1 return PRIME n, p = list(map(int, input()....
27
25
482
442
from collections import defaultdict def factorize(N): p = 2 PRIME = [] while p * p <= N: if N % p == 0: N //= p PRIME.append(p) else: p += 1 if N > 1: PRIME.append(N) return PRIME n, p = list(map(int, input().split())) prime = factorize...
from collections import defaultdict def factorize(N): p = 2 PRIME = defaultdict(int) while p * p <= N: if N % p == 0: N //= p PRIME[p] += 1 else: p += 1 if N > 1: PRIME[N] += 1 return PRIME n, p = list(map(int, input().split())) prime =...
false
7.407407
[ "- PRIME = []", "+ PRIME = defaultdict(int)", "- PRIME.append(p)", "+ PRIME[p] += 1", "- PRIME.append(N)", "+ PRIME[N] += 1", "-cnt = defaultdict(int)", "-for i in prime:", "- cnt[i] += 1", "-for j in cnt:", "- if cnt[j] >= n:", "- ans *= ...
false
0.047734
0.045212
1.055765
[ "s203359889", "s778518839" ]
u600402037
p03042
python
s532071957
s067807627
19
17
3,060
3,060
Accepted
Accepted
10.53
S = eval(input()) S1 = int(S[:2]) S2 = int(S[2:]) b1,b2 = False,False if 1 <= S1 <= 12: b1 = True if 1 <= S2 <= 12: b2 = True print(('AMBIGUOUS' if b1 and b2 else 'YYMM' if b2 else 'MMYY' if b1 else 'NA'))
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) S = list(sr()) head = int(''.join(S[:2])) tail = int(''.join(S[2:])) bl_head = (1 <= head <= 12) bl_tail = (1 <= tail <= 12) if bl_head and bl_tail: answer = "AMBIGUO...
9
22
213
439
S = eval(input()) S1 = int(S[:2]) S2 = int(S[2:]) b1, b2 = False, False if 1 <= S1 <= 12: b1 = True if 1 <= S2 <= 12: b2 = True print(("AMBIGUOUS" if b1 and b2 else "YYMM" if b2 else "MMYY" if b1 else "NA"))
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) S = list(sr()) head = int("".join(S[:2])) tail = int("".join(S[2:])) bl_head = 1 <= head <= 12 bl_tail = 1 <= tail <= 12 if bl_head and bl_tail: answer = "AMBIGUOUS" elif bl_head: ...
false
59.090909
[ "-S = eval(input())", "-S1 = int(S[:2])", "-S2 = int(S[2:])", "-b1, b2 = False, False", "-if 1 <= S1 <= 12:", "- b1 = True", "-if 1 <= S2 <= 12:", "- b2 = True", "-print((\"AMBIGUOUS\" if b1 and b2 else \"YYMM\" if b2 else \"MMYY\" if b1 else \"NA\"))", "+# coding: utf-8", "+import sys", ...
false
0.051245
0.049485
1.035583
[ "s532071957", "s067807627" ]
u797673668
p00588
python
s384548735
s598140921
300
230
9,624
9,648
Accepted
Accepted
23.33
pre = [ ((0, 1, 2), (1, 0, 1), (2, 1, 0)), ((3, 2, 2), (2, 1, 1), (2, 1, 1)), ((1, 1, 2), (1, 1, 2), (2, 2, 3)), ((3, 2, 2), (2, 2, 2), (2, 2, 3)), ] q = int(eval(input())) for _ in range(q): n = int(eval(input())) books = [c == 'Y' for c in eval(input())] books = [(0, 0)] + list...
from operator import add pre = [ ((0, 1, 2), (1, 0, 1), (2, 1, 0)), ((3, 2, 2), (2, 1, 1), (2, 1, 1)), ((1, 1, 2), (1, 1, 2), (2, 2, 3)), ((3, 2, 2), (2, 2, 2), (2, 2, 3)), ] q = int(eval(input())) for _ in range(q): n = int(eval(input())) books = [c == 'Y' for c in eval(input())] ...
18
20
615
630
pre = [ ((0, 1, 2), (1, 0, 1), (2, 1, 0)), ((3, 2, 2), (2, 1, 1), (2, 1, 1)), ((1, 1, 2), (1, 1, 2), (2, 2, 3)), ((3, 2, 2), (2, 2, 2), (2, 2, 3)), ] q = int(eval(input())) for _ in range(q): n = int(eval(input())) books = [c == "Y" for c in eval(input())] books = [(0, 0)] + list(zip(books[:...
from operator import add pre = [ ((0, 1, 2), (1, 0, 1), (2, 1, 0)), ((3, 2, 2), (2, 1, 1), (2, 1, 1)), ((1, 1, 2), (1, 1, 2), (2, 2, 3)), ((3, 2, 2), (2, 2, 2), (2, 2, 3)), ] q = int(eval(input())) for _ in range(q): n = int(eval(input())) books = [c == "Y" for c in eval(input())] books = [...
false
10
[ "+from operator import add", "+", "- new_ans = [min(a + c for a, c in zip(ans, costs)) for costs in pre[key]]", "+ new_ans = [min(list(map(add, ans, costs))) for costs in pre[key]]" ]
false
0.037887
0.036185
1.047018
[ "s384548735", "s598140921" ]
u201928947
p02558
python
s163683359
s013817608
356
248
77,336
75,120
Accepted
Accepted
30.34
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: while self.parents[x] >= 0: if self.parents[self.parents[x]] >= 0: self.p...
class UnionFind(): def __init__(self, N): self.N = N self.parents = [-1] * N def find(self, x): if self.parents[x] < 0: return x else: st = [] while self.parents[x] >= 0: st.append(x) x = self.parent...
63
44
1,615
1,014
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: while self.parents[x] >= 0: if self.parents[self.parents[x]] >= 0: self.parents[x] = s...
class UnionFind: def __init__(self, N): self.N = N self.parents = [-1] * N def find(self, x): if self.parents[x] < 0: return x else: st = [] while self.parents[x] >= 0: st.append(x) x = self.parents[x] ...
false
30.15873
[ "- def __init__(self, n):", "- self.n = n", "- self.parents = [-1] * n", "+ def __init__(self, N):", "+ self.N = N", "+ self.parents = [-1] * N", "+ st = []", "- if self.parents[self.parents[x]] >= 0:", "- self.parents[x]...
false
0.007673
0.042813
0.179214
[ "s163683359", "s013817608" ]
u428397309
p03087
python
s564774802
s464923496
671
391
68,892
64,604
Accepted
Accepted
41.73
# -*- coding: utf-8 -*- N, Q = list(map(int, input().split())) S = eval(input()) LR = [list(map(int, input().split())) for i in range(Q)] lst = [0] * N count = 0 for i in range(N - 1): if S[i] == 'A' and S[i + 1] == 'C': count += 1 lst[i + 1] = count for l, r in LR: ans = lst[r-1] -...
# -*- coding: utf-8 -*- import sys input = sys.stdin.readline N, Q = list(map(int, input().split())) S = eval(input()) LR = [list(map(int, input().split())) for i in range(Q)] lst = [0] * N count = 0 for i in range(N - 1): if S[i] == 'A' and S[i + 1] == 'C': count += 1 lst[i + 1] = coun...
16
19
334
376
# -*- coding: utf-8 -*- N, Q = list(map(int, input().split())) S = eval(input()) LR = [list(map(int, input().split())) for i in range(Q)] lst = [0] * N count = 0 for i in range(N - 1): if S[i] == "A" and S[i + 1] == "C": count += 1 lst[i + 1] = count for l, r in LR: ans = lst[r - 1] - lst[l - 1] ...
# -*- coding: utf-8 -*- import sys input = sys.stdin.readline N, Q = list(map(int, input().split())) S = eval(input()) LR = [list(map(int, input().split())) for i in range(Q)] lst = [0] * N count = 0 for i in range(N - 1): if S[i] == "A" and S[i + 1] == "C": count += 1 lst[i + 1] = count for l, r in LR...
false
15.789474
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.03713
0.037437
0.991811
[ "s564774802", "s464923496" ]
u298297089
p03108
python
s516791726
s998302534
725
566
82,264
36,800
Accepted
Accepted
21.93
def unite(par, i, j): j = get_par(par, j) par[j] = get_par(par, i) def get_par(par, p): while par[p] != p: p = par[p] return par[p] n,m = map(int,input().split()) edge = [list(map(int,input().split())) for _ in range(m)] res = n * (n-1) // 2 ans = [] cnt = [1 for _ in range(n+1)...
import sys sys.setrecursionlimit(10**9) def unite(par, i, j): j = get_par(par, j) par[j] = get_par(par, i) def get_par(par, p): while par[p] != p: p = par[p] return par[p] def resolve(): n,m = map(int, input().split()) bridges = [list(map(lambda x: int(x)-1, input()....
38
52
734
1,148
def unite(par, i, j): j = get_par(par, j) par[j] = get_par(par, i) def get_par(par, p): while par[p] != p: p = par[p] return par[p] n, m = map(int, input().split()) edge = [list(map(int, input().split())) for _ in range(m)] res = n * (n - 1) // 2 ans = [] cnt = [1 for _ in range(n + 1)] par ...
import sys sys.setrecursionlimit(10**9) def unite(par, i, j): j = get_par(par, j) par[j] = get_par(par, i) def get_par(par, p): while par[p] != p: p = par[p] return par[p] def resolve(): n, m = map(int, input().split()) bridges = [list(map(lambda x: int(x) - 1, input().split())) f...
false
26.923077
[ "+import sys", "+", "+sys.setrecursionlimit(10**9)", "+", "+", "-n, m = map(int, input().split())", "-edge = [list(map(int, input().split())) for _ in range(m)]", "-res = n * (n - 1) // 2", "-ans = []", "-cnt = [1 for _ in range(n + 1)]", "-par = [i for i in range(n + 1)]", "-for a, b in edge[...
false
0.039109
0.088397
0.44242
[ "s516791726", "s998302534" ]
u500376440
p02779
python
s693571185
s184257381
138
103
43,352
31,072
Accepted
Accepted
25.36
import collections N=int(eval(input())) A=list(map(int,input().split())) a=collections.Counter(A).most_common() print(("YES" if a[0][1]==1 else "NO"))
N=int(eval(input())) A=list(map(int,input().split())) a=set(A) print(("YES" if len(A)==len(a) else "NO"))
6
4
149
101
import collections N = int(eval(input())) A = list(map(int, input().split())) a = collections.Counter(A).most_common() print(("YES" if a[0][1] == 1 else "NO"))
N = int(eval(input())) A = list(map(int, input().split())) a = set(A) print(("YES" if len(A) == len(a) else "NO"))
false
33.333333
[ "-import collections", "-", "-a = collections.Counter(A).most_common()", "-print((\"YES\" if a[0][1] == 1 else \"NO\"))", "+a = set(A)", "+print((\"YES\" if len(A) == len(a) else \"NO\"))" ]
false
0.038153
0.045868
0.831811
[ "s693571185", "s184257381" ]
u427344224
p02989
python
s397167028
s550799519
141
76
14,396
14,428
Accepted
Accepted
46.1
N = int(eval(input())) d_list = list(map(int, input().split())) d_list.sort() from bisect import bisect_right ans = 0 for i in range(1, max(d_list)): idx = bisect_right(d_list, i) if N //2 == idx: ans += 1 print(ans)
N = int(eval(input())) d_list = list(map(int, input().split())) d_list.sort() print((d_list[N//2] - d_list[N//2 - 1]))
12
6
240
118
N = int(eval(input())) d_list = list(map(int, input().split())) d_list.sort() from bisect import bisect_right ans = 0 for i in range(1, max(d_list)): idx = bisect_right(d_list, i) if N // 2 == idx: ans += 1 print(ans)
N = int(eval(input())) d_list = list(map(int, input().split())) d_list.sort() print((d_list[N // 2] - d_list[N // 2 - 1]))
false
50
[ "-from bisect import bisect_right", "-", "-ans = 0", "-for i in range(1, max(d_list)):", "- idx = bisect_right(d_list, i)", "- if N // 2 == idx:", "- ans += 1", "-print(ans)", "+print((d_list[N // 2] - d_list[N // 2 - 1]))" ]
false
0.043998
0.052492
0.838189
[ "s397167028", "s550799519" ]
u934442292
p03575
python
s833364157
s730415548
21
18
3,316
3,064
Accepted
Accepted
14.29
import sys from collections import deque input = sys.stdin.readline def dfs(G, v, visited): visited[v] = True stack = deque([v]) while stack: v = stack.pop() for u in G[v]: if visited[u]: continue visited[u] = True stack.a...
import sys input = sys.stdin.readline # NOQA sys.setrecursionlimit(10 ** 7) # NOQA def dfs(G, v, visited): """G: graph, v: vertex""" visited[v] = True for c in G[v]: if visited[c]: continue dfs(G, c, visited) def main(): N, M = list(map(int, input().split...
49
48
958
987
import sys from collections import deque input = sys.stdin.readline def dfs(G, v, visited): visited[v] = True stack = deque([v]) while stack: v = stack.pop() for u in G[v]: if visited[u]: continue visited[u] = True stack.append(u) def ...
import sys input = sys.stdin.readline # NOQA sys.setrecursionlimit(10**7) # NOQA def dfs(G, v, visited): """G: graph, v: vertex""" visited[v] = True for c in G[v]: if visited[c]: continue dfs(G, c, visited) def main(): N, M = list(map(int, input().split())) a = [No...
false
2.040816
[ "-from collections import deque", "-input = sys.stdin.readline", "+input = sys.stdin.readline # NOQA", "+sys.setrecursionlimit(10**7) # NOQA", "+ \"\"\"G: graph, v: vertex\"\"\"", "- stack = deque([v])", "- while stack:", "- v = stack.pop()", "- for u in G[v]:", "- ...
false
0.042335
0.037373
1.132791
[ "s833364157", "s730415548" ]
u352394527
p00522
python
s388491653
s304275929
4,280
1,780
61,340
61,404
Accepted
Accepted
58.41
INF = 10 ** 20 m, n = list(map(int, input().split())) manju_lst = [int(eval(input())) for i in range(m)] manju_lst.sort(reverse=True) acc = 0 cum_sum = [0] for manju in manju_lst: acc += manju cum_sum.append(acc) clst = [] elst = [] for i in range(n): c, e = list(map(int, input().split())) ...
INF = 10 ** 20 def main(): m, n = list(map(int, input().split())) manju_lst = [int(eval(input())) for i in range(m)] manju_lst.sort(reverse=True) acc = 0 cum_sum = [0] for manju in manju_lst: acc += manju cum_sum.append(acc) clst = [] elst = [] for i in range(n): ...
40
50
931
1,142
INF = 10**20 m, n = list(map(int, input().split())) manju_lst = [int(eval(input())) for i in range(m)] manju_lst.sort(reverse=True) acc = 0 cum_sum = [0] for manju in manju_lst: acc += manju cum_sum.append(acc) clst = [] elst = [] for i in range(n): c, e = list(map(int, input().split())) clst.append(c) ...
INF = 10**20 def main(): m, n = list(map(int, input().split())) manju_lst = [int(eval(input())) for i in range(m)] manju_lst.sort(reverse=True) acc = 0 cum_sum = [0] for manju in manju_lst: acc += manju cum_sum.append(acc) clst = [] elst = [] for i in range(n): ...
false
20
[ "-m, n = list(map(int, input().split()))", "-manju_lst = [int(eval(input())) for i in range(m)]", "-manju_lst.sort(reverse=True)", "-acc = 0", "-cum_sum = [0]", "-for manju in manju_lst:", "- acc += manju", "- cum_sum.append(acc)", "-clst = []", "-elst = []", "-for i in range(n):", "- ...
false
0.041168
0.041263
0.997703
[ "s388491653", "s304275929" ]
u440566786
p03673
python
s014459829
s379194945
346
169
95,956
26,180
Accepted
Accepted
51.16
n = int(input()) l = list(map(int,input().split())) if n%2: print(*l[::-2], end=' ') print(*l[1::2]) else: print(*l[::-2], end=' ') print(*l[0::2])
n = int(eval(input())) l = list(map(int,input().split())) print((*(l[::-2]+l[n%2::2])))
8
3
170
81
n = int(input()) l = list(map(int, input().split())) if n % 2: print(*l[::-2], end=" ") print(*l[1::2]) else: print(*l[::-2], end=" ") print(*l[0::2])
n = int(eval(input())) l = list(map(int, input().split())) print((*(l[::-2] + l[n % 2 :: 2])))
false
62.5
[ "-n = int(input())", "+n = int(eval(input()))", "-if n % 2:", "- print(*l[::-2], end=\" \")", "- print(*l[1::2])", "-else:", "- print(*l[::-2], end=\" \")", "- print(*l[0::2])", "+print((*(l[::-2] + l[n % 2 :: 2])))" ]
false
0.041654
0.040767
1.021776
[ "s014459829", "s379194945" ]
u077291787
p03998
python
s706784362
s388530001
27
21
3,444
3,316
Accepted
Accepted
22.22
# ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit) from collections import deque lst = [deque(list(input().rstrip())) for _ in range(3)] abc = ["a", "b", "c"] turn = lst[0].popleft() while True: if not lst[abc.index(turn)]: print((turn.upper())) break turn = lst[abc.index(tu...
# ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit) from collections import deque def main(): S = [deque(list(input().rstrip())) for _ in range(3)] abc = {"a": 0, "b": 1, "c": 2} cur = S[0].popleft() while True: # search greedily idx = abc[cur] if not S[idx]: ...
12
18
332
438
# ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit) from collections import deque lst = [deque(list(input().rstrip())) for _ in range(3)] abc = ["a", "b", "c"] turn = lst[0].popleft() while True: if not lst[abc.index(turn)]: print((turn.upper())) break turn = lst[abc.index(turn)].popleft...
# ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit) from collections import deque def main(): S = [deque(list(input().rstrip())) for _ in range(3)] abc = {"a": 0, "b": 1, "c": 2} cur = S[0].popleft() while True: # search greedily idx = abc[cur] if not S[idx]: print(...
false
33.333333
[ "-lst = [deque(list(input().rstrip())) for _ in range(3)]", "-abc = [\"a\", \"b\", \"c\"]", "-turn = lst[0].popleft()", "-while True:", "- if not lst[abc.index(turn)]:", "- print((turn.upper()))", "- break", "- turn = lst[abc.index(turn)].popleft()", "+", "+def main():", "+ ...
false
0.035337
0.052983
0.666953
[ "s706784362", "s388530001" ]
u858748695
p02975
python
s723357027
s233040867
129
70
14,120
14,116
Accepted
Accepted
45.74
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) s = [0] * (n + 2) rs = [0] * (n + 2) for i in range(n): s[i + 1] = s[i] ^ a[i] rs[n - i] = rs[n - i + 1] ^ a[-i - 1] ans = all(a[i] == rs[i + 2] ^ s[i] for i in range(n)) print((['No', 'Yes'][ans]))
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) dic = {} for x in a: dic[x] = dic[x] + 1 if x in dic else 1 ans = all(k == 0 for k in list(dic.keys())) if n % 3 == 0: if all(v == n // 3 for v in list(dic.values())): x, y, z = list(dic.keys()) ans |...
10
16
290
438
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) s = [0] * (n + 2) rs = [0] * (n + 2) for i in range(n): s[i + 1] = s[i] ^ a[i] rs[n - i] = rs[n - i + 1] ^ a[-i - 1] ans = all(a[i] == rs[i + 2] ^ s[i] for i in range(n)) print((["No", "Yes"][ans]))
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) dic = {} for x in a: dic[x] = dic[x] + 1 if x in dic else 1 ans = all(k == 0 for k in list(dic.keys())) if n % 3 == 0: if all(v == n // 3 for v in list(dic.values())): x, y, z = list(dic.keys()) ans |= x ^ y == z ...
false
37.5
[ "-s = [0] * (n + 2)", "-rs = [0] * (n + 2)", "-for i in range(n):", "- s[i + 1] = s[i] ^ a[i]", "- rs[n - i] = rs[n - i + 1] ^ a[-i - 1]", "-ans = all(a[i] == rs[i + 2] ^ s[i] for i in range(n))", "+dic = {}", "+for x in a:", "+ dic[x] = dic[x] + 1 if x in dic else 1", "+ans = all(k == 0 ...
false
0.039235
0.062917
0.623605
[ "s723357027", "s233040867" ]
u573754721
p02787
python
s048552168
s963614867
443
380
42,332
43,532
Accepted
Accepted
14.22
h,n=list(map(int,input().split())) AB=[] maA=0 inf=float("inf") for i in range(n): a,b=list(map(int,input().split())) maA=max(maA,a) AB.append((a,b)) dp=[inf]*(h+maA+1) dp[0]=0 for i in range(h+1): for aj,bj in AB: dp[i+aj]=min(dp[i+aj],dp[i]+bj) print((min(dp[h:])))
h,n=list(map(int,input().split())) L=[] maA=0 inf=float("inf") for i in range(n): a,b=list(map(int,input().split())) L.append((a,b)) maA=max(maA,a) dp=[inf]*(h+maA+1) dp[0]=0 for i in range(h): for j in L: dp[i+j[0]]=min(dp[i+j[0]],dp[i]+j[1]) print((min(dp[h:]...
15
16
286
312
h, n = list(map(int, input().split())) AB = [] maA = 0 inf = float("inf") for i in range(n): a, b = list(map(int, input().split())) maA = max(maA, a) AB.append((a, b)) dp = [inf] * (h + maA + 1) dp[0] = 0 for i in range(h + 1): for aj, bj in AB: dp[i + aj] = min(dp[i + aj], dp[i] + bj) print((mi...
h, n = list(map(int, input().split())) L = [] maA = 0 inf = float("inf") for i in range(n): a, b = list(map(int, input().split())) L.append((a, b)) maA = max(maA, a) dp = [inf] * (h + maA + 1) dp[0] = 0 for i in range(h): for j in L: dp[i + j[0]] = min(dp[i + j[0]], dp[i] + j[1]) print((min(dp[h...
false
6.25
[ "-AB = []", "+L = []", "+ L.append((a, b))", "- AB.append((a, b))", "-for i in range(h + 1):", "- for aj, bj in AB:", "- dp[i + aj] = min(dp[i + aj], dp[i] + bj)", "+for i in range(h):", "+ for j in L:", "+ dp[i + j[0]] = min(dp[i + j[0]], dp[i] + j[1])" ]
false
0.101835
0.126497
0.805044
[ "s048552168", "s963614867" ]
u576917603
p02837
python
s052751585
s339542434
1,778
1,447
3,064
3,064
Accepted
Accepted
18.62
n=int(eval(input())) a=[] for i in range(n): x=int(eval(input())) aa=[[int(i) for i in input().split()] for i in range(x)] a.append(aa) #print(a) ans=0 for i in range(2**n): status=[True]*n for j in range(n): if ((i>>j)&1): status[j]=False check=[None]*n f...
n=int(eval(input())) a=[] for i in range(n): x=int(eval(input())) b=[[int(i) for i in input().split()] for i in range(x)] a.append(b) ans=0 for i in range(2**n): status=[True]*n for j in range(n): if ((i>>j)&1): status[j]=False judge=[None]*n contra...
32
37
984
989
n = int(eval(input())) a = [] for i in range(n): x = int(eval(input())) aa = [[int(i) for i in input().split()] for i in range(x)] a.append(aa) # print(a) ans = 0 for i in range(2**n): status = [True] * n for j in range(n): if (i >> j) & 1: status[j] = False check = [None] * ...
n = int(eval(input())) a = [] for i in range(n): x = int(eval(input())) b = [[int(i) for i in input().split()] for i in range(x)] a.append(b) ans = 0 for i in range(2**n): status = [True] * n for j in range(n): if (i >> j) & 1: status[j] = False judge = [None] * n contrad...
false
13.513514
[ "- aa = [[int(i) for i in input().split()] for i in range(x)]", "- a.append(aa)", "-# print(a)", "+ b = [[int(i) for i in input().split()] for i in range(x)]", "+ a.append(b)", "- check = [None] * n", "- flag = True", "- for i in range(n):", "- if status[i] == True:", "...
false
0.086777
0.047249
1.836609
[ "s052751585", "s339542434" ]
u790710233
p03326
python
s792035758
s462102390
1,215
39
9,156
9,212
Accepted
Accepted
96.79
from itertools import product n, m = list(map(int, input().split())) xyz = [tuple(map(int, input().split())) for _ in range(n)] ans = 0 for subset in product((-1, 1), repeat=3): INF = 10**18 dp = [-INF]*(n+1) dp[0] = 0 def func(xyz): return sum(x*a for x, a in zip(xyz, subset)) ...
from itertools import product n, m = list(map(int, input().split())) xyz = [tuple(map(int, input().split()))for _ in range(n)] ans = 0 for subset in product((-1, 1), repeat=3): def func(xyz): return sum(x*a for x, a in zip(xyz, subset)) score = sum(sorted(map(func, xyz), reverse=True)[:m]) ...
22
12
533
364
from itertools import product n, m = list(map(int, input().split())) xyz = [tuple(map(int, input().split())) for _ in range(n)] ans = 0 for subset in product((-1, 1), repeat=3): INF = 10**18 dp = [-INF] * (n + 1) dp[0] = 0 def func(xyz): return sum(x * a for x, a in zip(xyz, subset)) valu...
from itertools import product n, m = list(map(int, input().split())) xyz = [tuple(map(int, input().split())) for _ in range(n)] ans = 0 for subset in product((-1, 1), repeat=3): def func(xyz): return sum(x * a for x, a in zip(xyz, subset)) score = sum(sorted(map(func, xyz), reverse=True)[:m]) if ...
false
45.454545
[ "- INF = 10**18", "- dp = [-INF] * (n + 1)", "- dp[0] = 0", "- values = list(map(func, xyz))", "- for i, val in enumerate(values, 1):", "- for j in reversed(list(range(1, i + 1))):", "- dp[j] = max(dp[j - 1] + val, dp[j])", "- if ans < dp[m]:", "- ans = dp[...
false
0.058468
0.037827
1.545655
[ "s792035758", "s462102390" ]
u426683236
p03361
python
s367463198
s796117120
170
19
38,896
3,064
Accepted
Accepted
88.82
def solve(): H,W=map(int,input().split()) s=[] s.append(['.'] * (W+2)) for y in range(H): s.append(['.'] + list(input()) + ['.']) s.append(['.'] * (W+2)) for y in range(1,H): for x in range(1,W): if s[y][x] == '#': if s[y-1][x] == '.' and \ ...
def solve(): H, W = list(map(int, input().split())) S = [] for h in range(H): s = eval(input()) S.append(s) for h in range(H): for w in range(W): if S[h][w] == '#': ok = False if h > 0 and S[h - 1][w] == '#': ...
18
28
511
729
def solve(): H, W = map(int, input().split()) s = [] s.append(["."] * (W + 2)) for y in range(H): s.append(["."] + list(input()) + ["."]) s.append(["."] * (W + 2)) for y in range(1, H): for x in range(1, W): if s[y][x] == "#": if ( ...
def solve(): H, W = list(map(int, input().split())) S = [] for h in range(H): s = eval(input()) S.append(s) for h in range(H): for w in range(W): if S[h][w] == "#": ok = False if h > 0 and S[h - 1][w] == "#": ok = Tr...
false
35.714286
[ "- H, W = map(int, input().split())", "- s = []", "- s.append([\".\"] * (W + 2))", "- for y in range(H):", "- s.append([\".\"] + list(input()) + [\".\"])", "- s.append([\".\"] * (W + 2))", "- for y in range(1, H):", "- for x in range(1, W):", "- if s[y][x] ...
false
0.035419
0.036045
0.982646
[ "s367463198", "s796117120" ]
u844789719
p02801
python
s499605370
s472604082
175
38
38,640
9,764
Accepted
Accepted
78.29
import string abc = string.ascii_lowercase C = eval(input()) print((abc[abc.index(C) + 1]))
import string ab = string.ascii_lowercase bc = ab[1:] + 'a' c = eval(input()) for a, b in zip(ab, bc): if a == c: print(b)
4
7
87
135
import string abc = string.ascii_lowercase C = eval(input()) print((abc[abc.index(C) + 1]))
import string ab = string.ascii_lowercase bc = ab[1:] + "a" c = eval(input()) for a, b in zip(ab, bc): if a == c: print(b)
false
42.857143
[ "-abc = string.ascii_lowercase", "-C = eval(input())", "-print((abc[abc.index(C) + 1]))", "+ab = string.ascii_lowercase", "+bc = ab[1:] + \"a\"", "+c = eval(input())", "+for a, b in zip(ab, bc):", "+ if a == c:", "+ print(b)" ]
false
0.041851
0.250541
0.167044
[ "s499605370", "s472604082" ]
u585482323
p02824
python
s667021320
s775302974
288
244
58,736
58,736
Accepted
Accepted
15.28
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in...
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in...
56
56
1,292
1,285
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(...
false
0
[ "- cnt += min(m, max(0, aim - a[j]))", "+ cnt += min(m, aim - a[j])" ]
false
0.061754
0.075568
0.817196
[ "s667021320", "s775302974" ]
u856775981
p03030
python
s769611276
s749641988
21
18
9,168
3,060
Accepted
Accepted
14.29
N = int(eval(input())) ss = dict() sss = dict() for i in range(N): s, p = input().split() sss[s, p] = i + 1 if s in ss: ss[s] = ss[s] + ',' + p else: ss[s] = p ss_sorted = sorted(ss.items()) for tmp_ss in ss_sorted: s = tmp_ss[0] ps = list(map(int, tmp_ss[1].sp...
N = int(eval(input())) ss = list() for i in range(N): s, p = input().split() ss.append([s, int(p), i]) ss_sorted = sorted(ss, key=lambda x: (x[0], -x[1])) for out in ss_sorted: print((out[2] + 1))
20
12
400
215
N = int(eval(input())) ss = dict() sss = dict() for i in range(N): s, p = input().split() sss[s, p] = i + 1 if s in ss: ss[s] = ss[s] + "," + p else: ss[s] = p ss_sorted = sorted(ss.items()) for tmp_ss in ss_sorted: s = tmp_ss[0] ps = list(map(int, tmp_ss[1].split(","))) ps.s...
N = int(eval(input())) ss = list() for i in range(N): s, p = input().split() ss.append([s, int(p), i]) ss_sorted = sorted(ss, key=lambda x: (x[0], -x[1])) for out in ss_sorted: print((out[2] + 1))
false
40
[ "-ss = dict()", "-sss = dict()", "+ss = list()", "- sss[s, p] = i + 1", "- if s in ss:", "- ss[s] = ss[s] + \",\" + p", "- else:", "- ss[s] = p", "-ss_sorted = sorted(ss.items())", "-for tmp_ss in ss_sorted:", "- s = tmp_ss[0]", "- ps = list(map(int, tmp_ss[1].spli...
false
0.119745
0.048065
2.491321
[ "s769611276", "s749641988" ]
u849029577
p03086
python
s135149553
s488476786
183
161
38,256
38,384
Accepted
Accepted
12.02
s = eval(input()) count = 0 Max = 0 for i in s: if i in "ACGT": count += 1 Max = max(Max, count) else: count = 0 print(Max)
s = eval(input()) for i in s: if i not in "ACGT": s = s.replace(i, "1") s = s.split("1") print((len(max(s, key=len))))
11
6
160
127
s = eval(input()) count = 0 Max = 0 for i in s: if i in "ACGT": count += 1 Max = max(Max, count) else: count = 0 print(Max)
s = eval(input()) for i in s: if i not in "ACGT": s = s.replace(i, "1") s = s.split("1") print((len(max(s, key=len))))
false
45.454545
[ "-count = 0", "-Max = 0", "- if i in \"ACGT\":", "- count += 1", "- Max = max(Max, count)", "- else:", "- count = 0", "-print(Max)", "+ if i not in \"ACGT\":", "+ s = s.replace(i, \"1\")", "+s = s.split(\"1\")", "+print((len(max(s, key=len))))" ]
false
0.089394
0.087737
1.018892
[ "s135149553", "s488476786" ]
u062147869
p03374
python
s594555628
s134029668
684
552
32,272
28,464
Accepted
Accepted
19.3
import sys N,C = list(map(int,input().split())) table=[] for i in range(N): x,v=list(map(int,input().split())) table.append([x,v]) ans=0 if N==1: ans=max(0,table[0][1]-table[0][0],table[0][1]+table[0][0]-C) print(ans) sys.exit() V=[0]*N clo=[0]*N V[0]=table[0][1] clo[0]=V[0]-table[0][0...
N,C = list(map(int,input().split())) X=[] V=[] for i in range(N): x,v=list(map(int,input().split())) X.append(x) V.append(v) #時計回りで見る R=[0]*(N+1)#0番目は1に格納する Rans=[0]*(N+1) for i in range(N): R[i+1]=R[i]+V[i] Rans[i+1]=max(Rans[i],R[i+1]-X[i]) L=[0]*(N+1) Lans=[0]*(N+1) for i in range(...
37
22
862
573
import sys N, C = list(map(int, input().split())) table = [] for i in range(N): x, v = list(map(int, input().split())) table.append([x, v]) ans = 0 if N == 1: ans = max(0, table[0][1] - table[0][0], table[0][1] + table[0][0] - C) print(ans) sys.exit() V = [0] * N clo = [0] * N V[0] = table[0][1] cl...
N, C = list(map(int, input().split())) X = [] V = [] for i in range(N): x, v = list(map(int, input().split())) X.append(x) V.append(v) # 時計回りで見る R = [0] * (N + 1) # 0番目は1に格納する Rans = [0] * (N + 1) for i in range(N): R[i + 1] = R[i] + V[i] Rans[i + 1] = max(Rans[i], R[i + 1] - X[i]) L = [0] * (N + 1...
false
40.540541
[ "-import sys", "-", "-table = []", "+X = []", "+V = []", "- table.append([x, v])", "-ans = 0", "-if N == 1:", "- ans = max(0, table[0][1] - table[0][0], table[0][1] + table[0][0] - C)", "- print(ans)", "- sys.exit()", "-V = [0] * N", "-clo = [0] * N", "-V[0] = table[0][1]", "...
false
0.080501
0.075306
1.068981
[ "s594555628", "s134029668" ]
u968404618
p02689
python
s412605697
s404241481
491
397
42,340
42,252
Accepted
Accepted
19.14
n, m = list(map(int, input().split())) H = list(map(int, input().split())) graph = [[] for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 graph[a].append((H[b], b)) graph[b].append((H[a], a)) cnt = 0 for i in range(n): graph[i].sort(reverse=Tr...
def main(): ## IMPORT MODULE #import sys #sys.setrecursionlimit(100000) #input=lambda :sys.stdin.readline().rstrip() #f_inf=float("inf") #MOD=10**9+7 if 'get_ipython' in globals(): ## SAMPLE INPUT n, m = 4, 3 H = [1, 2, 3, 4] graph = [[(3, 2)], [(3, 2), (4, 3)], [(1, 0)...
20
41
411
864
n, m = list(map(int, input().split())) H = list(map(int, input().split())) graph = [[] for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 graph[a].append((H[b], b)) graph[b].append((H[a], a)) cnt = 0 for i in range(n): graph[i].sort(reverse=True) if gr...
def main(): ## IMPORT MODULE # import sys # sys.setrecursionlimit(100000) # input=lambda :sys.stdin.readline().rstrip() # f_inf=float("inf") # MOD=10**9+7 if "get_ipython" in globals(): ## SAMPLE INPUT n, m = 4, 3 H = [1, 2, 3, 4] graph = [[(3, 2)], [(3, 2), (...
false
51.219512
[ "-n, m = list(map(int, input().split()))", "-H = list(map(int, input().split()))", "-graph = [[] for _ in range(n)]", "-for i in range(m):", "- a, b = list(map(int, input().split()))", "- a -= 1", "- b -= 1", "- graph[a].append((H[b], b))", "- graph[b].append((H[a], a))", "-cnt = 0"...
false
0.046224
0.038636
1.196397
[ "s412605697", "s404241481" ]
u175034939
p03329
python
s856628933
s752668901
738
335
3,828
3,060
Accepted
Accepted
54.61
n = int(eval(input())) dp = [float('inf')]*100001 dp[0] = 0 for i in range(1,100001): p = 1 while p <= i: dp[i] = min(dp[i], dp[i-p] + 1) p *= 6 p = 1 while p <= i: dp[i] = min(dp[i], dp[i-p] + 1) p *= 9 print((dp[n]))
n = int(eval(input())) minC = n for i in range(n+1): cnt = 0 t = i while t > 0: cnt += t%6 t //= 6 t = n-i while t > 0: cnt += t%9 t //= 9 if minC > cnt: minC = cnt print(minC)
16
17
280
264
n = int(eval(input())) dp = [float("inf")] * 100001 dp[0] = 0 for i in range(1, 100001): p = 1 while p <= i: dp[i] = min(dp[i], dp[i - p] + 1) p *= 6 p = 1 while p <= i: dp[i] = min(dp[i], dp[i - p] + 1) p *= 9 print((dp[n]))
n = int(eval(input())) minC = n for i in range(n + 1): cnt = 0 t = i while t > 0: cnt += t % 6 t //= 6 t = n - i while t > 0: cnt += t % 9 t //= 9 if minC > cnt: minC = cnt print(minC)
false
5.882353
[ "-dp = [float(\"inf\")] * 100001", "-dp[0] = 0", "-for i in range(1, 100001):", "- p = 1", "- while p <= i:", "- dp[i] = min(dp[i], dp[i - p] + 1)", "- p *= 6", "- p = 1", "- while p <= i:", "- dp[i] = min(dp[i], dp[i - p] + 1)", "- p *= 9", "-print((dp[...
false
1.656568
0.067687
24.473954
[ "s856628933", "s752668901" ]
u677523557
p02757
python
s102263269
s278308853
175
88
13,352
83,048
Accepted
Accepted
49.71
import sys input = sys.stdin.readline from collections import Counter N, mod = list(map(int, input().split())) S = list(input().rstrip()) if mod == 2 or mod == 5: ans = 0 for i, s in enumerate(S): if int(s)%mod==0: ans += i+1 else: dp = [0] t = 1 for s in reverse...
import sys input = sys.stdin.readline N, P = list(map(int, input().split())) S = list(input().rstrip()) if P in {2, 5}: ans = 0 for i, s in enumerate(S): if int(s) % P == 0: ans += i+1 else: ans = 0 T = [0]*P T[0] = 1 tmp = 0 k = 1 for s in reversed...
25
24
486
438
import sys input = sys.stdin.readline from collections import Counter N, mod = list(map(int, input().split())) S = list(input().rstrip()) if mod == 2 or mod == 5: ans = 0 for i, s in enumerate(S): if int(s) % mod == 0: ans += i + 1 else: dp = [0] t = 1 for s in reversed(S): ...
import sys input = sys.stdin.readline N, P = list(map(int, input().split())) S = list(input().rstrip()) if P in {2, 5}: ans = 0 for i, s in enumerate(S): if int(s) % P == 0: ans += i + 1 else: ans = 0 T = [0] * P T[0] = 1 tmp = 0 k = 1 for s in reversed(S): t...
false
4
[ "-from collections import Counter", "-", "-N, mod = list(map(int, input().split()))", "+N, P = list(map(int, input().split()))", "-if mod == 2 or mod == 5:", "+if P in {2, 5}:", "- if int(s) % mod == 0:", "+ if int(s) % P == 0:", "- dp = [0]", "- t = 1", "+ ans = 0", "+ ...
false
0.114555
0.045829
2.499623
[ "s102263269", "s278308853" ]
u440566786
p02936
python
s208764669
s878123416
1,719
813
268,348
97,024
Accepted
Accepted
52.71
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): n,q=list(map(int,input().split())) E=[[] for _ in range(n)] for _ in range(n-1): a,b=list(map(int,input().split())) a-=1; b-=1 E[a].append(b...
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() def resolve(): n,q=list(map(int,input().split())) E=[[] for _ in range(n)] for _ in range(n-1): a,b=list(map(int,input().split())) a-=1; b-=1 E[a].append(b)...
29
30
616
635
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n, q = list(map(int, input().split())) E = [[] for _ in range(n)] for _ in range(n - 1): a, b = list(map(int, input().split())) a -= 1 b -= ...
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n, q = list(map(int, input().split())) E = [[] for _ in range(n)] for _ in range(n - 1): a, b = list(map(int, input().split())) a -= 1 b -= ...
false
3.333333
[ "- ans = [0] * n", "+ C = [0] * n", "- ans[p] += x", "-", "- def dfs(v, p=-1):", "- for u in E[v]:", "- if u == p:", "+ C[p] += x", "+ Q = [(0, -1)]", "+ while Q:", "+ v, p = Q.pop()", "+ for nv in E[v]:", "+ if p == nv:...
false
0.037126
0.068271
0.543802
[ "s208764669", "s878123416" ]
u244466744
p02713
python
s170352727
s701405111
1,479
1,285
9,068
9,156
Accepted
Accepted
13.12
import math K = int(eval(input())) rst = 0 for i in range(1, K + 1): for j in range(1, K + 1): tmp = math.gcd(i, j) for k in range(1, K + 1): rst += math.gcd(tmp, k) print(rst)
import math K = int(eval(input())) sum = 0 for i in range(1, K + 1): for j in range(1, K + 1): tmp = math.gcd(i, j) for k in range(1, K + 1): sum += math.gcd(tmp, k) print(sum)
9
12
211
207
import math K = int(eval(input())) rst = 0 for i in range(1, K + 1): for j in range(1, K + 1): tmp = math.gcd(i, j) for k in range(1, K + 1): rst += math.gcd(tmp, k) print(rst)
import math K = int(eval(input())) sum = 0 for i in range(1, K + 1): for j in range(1, K + 1): tmp = math.gcd(i, j) for k in range(1, K + 1): sum += math.gcd(tmp, k) print(sum)
false
25
[ "-rst = 0", "+sum = 0", "- rst += math.gcd(tmp, k)", "-print(rst)", "+ sum += math.gcd(tmp, k)", "+print(sum)" ]
false
0.184308
0.153327
1.202062
[ "s170352727", "s701405111" ]
u394721319
p02969
python
s129581839
s647631609
183
17
38,256
2,940
Accepted
Accepted
90.71
r = int(eval(input())) print((3*(r**2)))
r = int(eval(input())) print((3*r**2))
2
2
34
32
r = int(eval(input())) print((3 * (r**2)))
r = int(eval(input())) print((3 * r**2))
false
0
[ "-print((3 * (r**2)))", "+print((3 * r**2))" ]
false
0.104284
0.046982
2.219669
[ "s129581839", "s647631609" ]
u400765446
p02386
python
s299217851
s792119499
3,170
810
8,212
8,212
Accepted
Accepted
74.45
class Dice: def __init__(self): # 初期値がない場合 # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定 self.t = 1 self.s = 2 self.e = 3 self.w = 4 self.n = 5 self.b = 6 self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3} def __init__(self, t, s, e, ...
class Dice: def __init__(self): # 初期値がない場合 # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定 self.t = 1 self.s = 2 self.e = 3 self.w = 4 self.n = 5 self.b = 6 self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3} def __init__(self, t, s, e, ...
71
71
2,279
2,278
class Dice: def __init__(self): # 初期値がない場合 # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定 self.t = 1 self.s = 2 self.e = 3 self.w = 4 self.n = 5 self.b = 6 self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3} def __init__(self, t, s, e, w, n, b): ...
class Dice: def __init__(self): # 初期値がない場合 # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定 self.t = 1 self.s = 2 self.e = 3 self.w = 4 self.n = 5 self.b = 6 self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3} def __init__(self, t, s, e, w, n, b): ...
false
0
[ "- for _ in range(200):", "+ for _ in range(50):" ]
false
0.175021
0.048819
3.585082
[ "s299217851", "s792119499" ]
u606045429
p02661
python
s369572059
s371031167
335
184
58,308
55,380
Accepted
Accepted
45.07
N, *AB = list(map(int, open(0).read().split())) A = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[0]) B = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[1]) if N % 2 == 1: L = A[N // 2][0] R = B[N // 2][1] else: L = A[N // 2 - 1][0] + A[N // 2][0] R = B[N // 2 - 1][1] + B[N // 2][1] print((R...
N, *AB = list(map(int, open(0).read().split())) A = sorted(AB[::2]) B = sorted(AB[1::2]) if N % 2 == 1: L = A[N // 2] R = B[N // 2] else: L = A[N // 2 - 1] + A[N // 2] R = B[N // 2 - 1] + B[N // 2] print((R - L + 1))
13
13
322
239
N, *AB = list(map(int, open(0).read().split())) A = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[0]) B = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[1]) if N % 2 == 1: L = A[N // 2][0] R = B[N // 2][1] else: L = A[N // 2 - 1][0] + A[N // 2][0] R = B[N // 2 - 1][1] + B[N // 2][1] print((R - L + 1))
N, *AB = list(map(int, open(0).read().split())) A = sorted(AB[::2]) B = sorted(AB[1::2]) if N % 2 == 1: L = A[N // 2] R = B[N // 2] else: L = A[N // 2 - 1] + A[N // 2] R = B[N // 2 - 1] + B[N // 2] print((R - L + 1))
false
0
[ "-A = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[0])", "-B = sorted(zip(*[iter(AB)] * 2), key=lambda t: t[1])", "+A = sorted(AB[::2])", "+B = sorted(AB[1::2])", "- L = A[N // 2][0]", "- R = B[N // 2][1]", "+ L = A[N // 2]", "+ R = B[N // 2]", "- L = A[N // 2 - 1][0] + A[N // 2][0]",...
false
0.038761
0.085004
0.455989
[ "s369572059", "s371031167" ]
u366959492
p03438
python
s276992042
s168379992
29
26
4,596
4,600
Accepted
Accepted
10.34
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) cnt1=0 cnt2=0 ma=sum(b)-sum(a) if ma<0: print("No") exit() for i in range(n): if b[i]<=a[i]: cnt1+=a[i]-b[i] else: if (b[i]-a[i])%2==0: cnt2+=(b[i]-a[i]+1)//2 els...
n=int(eval(input())) a=list(map(int,input().split())) b=list(map(int,input().split())) cnt=0 for i in range(n): if a[i]<b[i]: cnt+=(b[i]-a[i])//2 else: cnt-=a[i]-b[i] if cnt<0: print("No") else: print("Yes")
25
16
493
256
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt1 = 0 cnt2 = 0 ma = sum(b) - sum(a) if ma < 0: print("No") exit() for i in range(n): if b[i] <= a[i]: cnt1 += a[i] - b[i] else: if (b[i] - a[i]) % 2 == 0: cnt2 += (b[i] - a[i] + ...
n = int(eval(input())) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt = 0 for i in range(n): if a[i] < b[i]: cnt += (b[i] - a[i]) // 2 else: cnt -= a[i] - b[i] if cnt < 0: print("No") else: print("Yes")
false
36
[ "-cnt1 = 0", "-cnt2 = 0", "-ma = sum(b) - sum(a)", "-if ma < 0:", "- print(\"No\")", "- exit()", "+cnt = 0", "- if b[i] <= a[i]:", "- cnt1 += a[i] - b[i]", "+ if a[i] < b[i]:", "+ cnt += (b[i] - a[i]) // 2", "- if (b[i] - a[i]) % 2 == 0:", "- cnt2 ...
false
0.096303
0.038568
2.496973
[ "s276992042", "s168379992" ]
u606878291
p02689
python
s304671106
s457345277
505
325
51,384
20,112
Accepted
Accepted
35.64
from collections import defaultdict N, M = list(map(int, input().split(' '))) H = tuple(map(int, input().split(' '))) edges = defaultdict(set) for _ in range(M): a, b = list(map(int, input().split(' '))) a -= 1 b -= 1 edges[a].add(b) edges[b].add(a) count = 0 for i in range(N): ...
N, M = list(map(int, input().split(' '))) H = tuple(map(int, input().split(' '))) one_hops = [0] * N for _ in range(M): a, b = list(map(int, input().split(' '))) a -= 1 b -= 1 one_hops[a] = max(one_hops[a], H[b]) one_hops[b] = max(one_hops[b], H[a]) print((len([0 for i in range(N) if H[...
23
12
433
327
from collections import defaultdict N, M = list(map(int, input().split(" "))) H = tuple(map(int, input().split(" "))) edges = defaultdict(set) for _ in range(M): a, b = list(map(int, input().split(" "))) a -= 1 b -= 1 edges[a].add(b) edges[b].add(a) count = 0 for i in range(N): hi = H[i] fo...
N, M = list(map(int, input().split(" "))) H = tuple(map(int, input().split(" "))) one_hops = [0] * N for _ in range(M): a, b = list(map(int, input().split(" "))) a -= 1 b -= 1 one_hops[a] = max(one_hops[a], H[b]) one_hops[b] = max(one_hops[b], H[a]) print((len([0 for i in range(N) if H[i] > one_hops...
false
47.826087
[ "-from collections import defaultdict", "-", "-edges = defaultdict(set)", "+one_hops = [0] * N", "- edges[a].add(b)", "- edges[b].add(a)", "-count = 0", "-for i in range(N):", "- hi = H[i]", "- for j in edges[i]:", "- if hi <= H[j]:", "- break", "- else:", ...
false
0.133788
0.075998
1.760412
[ "s304671106", "s457345277" ]
u576432509
p03761
python
s975334750
s215175720
24
18
3,064
3,064
Accepted
Accepted
25
n=int(eval(input())) s=[[] for i in range(n)] for i in range(n): s[i]=list(eval(input())) s1=list(set(s[0])) s1.sort() #print(s1) stmin=[50]*len(s1) for i in range(n): st=[0]*len(s1) for ii in range(len(s1)): for sij in s[i]: if s1[ii]==sij : st[ii]+=1 ...
n=int(eval(input())) s=[""]*n for i in range(n): s[i]=eval(input()) ss=list(set(s[0])) ss.sort() stmin=[50]*len(ss) for si in s: for ii in range(len(ss)): stmin[ii]=min(stmin[ii],si.count(ss[ii])) t="" for i in range(len(ss)): t=t+ss[i]*stmin[i] print(t)
22
16
447
280
n = int(eval(input())) s = [[] for i in range(n)] for i in range(n): s[i] = list(eval(input())) s1 = list(set(s[0])) s1.sort() # print(s1) stmin = [50] * len(s1) for i in range(n): st = [0] * len(s1) for ii in range(len(s1)): for sij in s[i]: if s1[ii] == sij: st[ii] += 1...
n = int(eval(input())) s = [""] * n for i in range(n): s[i] = eval(input()) ss = list(set(s[0])) ss.sort() stmin = [50] * len(ss) for si in s: for ii in range(len(ss)): stmin[ii] = min(stmin[ii], si.count(ss[ii])) t = "" for i in range(len(ss)): t = t + ss[i] * stmin[i] print(t)
false
27.272727
[ "-s = [[] for i in range(n)]", "+s = [\"\"] * n", "- s[i] = list(eval(input()))", "-s1 = list(set(s[0]))", "-s1.sort()", "-# print(s1)", "-stmin = [50] * len(s1)", "-for i in range(n):", "- st = [0] * len(s1)", "- for ii in range(len(s1)):", "- for sij in s[i]:", "- ...
false
0.047494
0.047722
0.995228
[ "s975334750", "s215175720" ]
u562935282
p02973
python
s345098733
s880978020
503
221
8,060
7,832
Accepted
Accepted
56.06
from bisect import bisect_left from collections import deque n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] q = deque([-1]) for x in a: insert_pos = bisect_left(q, x) - 1 # bisect_left[0,len(lis)] == 以上の最小 # 手前は未満の最大[-1,len(lis)) if insert_pos == -1: q.appendleft...
# LDS最長減少部分列 # 解説放送 # dilworthの定理 # パスを通してどの2点間も移動できないような点集合の点の個数 = 最小パス被覆 # 移動できないような点は # 右側(大きい値側)から見て以上になっているような数列 from bisect import bisect_right inf = 10 ** 9 + 1 n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] t = [inf] for x in reversed(a): if t[-1] <= x: t.appe...
21
25
392
423
from bisect import bisect_left from collections import deque n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] q = deque([-1]) for x in a: insert_pos = bisect_left(q, x) - 1 # bisect_left[0,len(lis)] == 以上の最小 # 手前は未満の最大[-1,len(lis)) if insert_pos == -1: q.appendleft(x) else:...
# LDS最長減少部分列 # 解説放送 # dilworthの定理 # パスを通してどの2点間も移動できないような点集合の点の個数 = 最小パス被覆 # 移動できないような点は # 右側(大きい値側)から見て以上になっているような数列 from bisect import bisect_right inf = 10**9 + 1 n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] t = [inf] for x in reversed(a): if t[-1] <= x: t.append(x) else: ...
false
16
[ "-from bisect import bisect_left", "-from collections import deque", "+# LDS最長減少部分列", "+# 解説放送", "+# dilworthの定理", "+# パスを通してどの2点間も移動できないような点集合の点の個数 = 最小パス被覆", "+# 移動できないような点は", "+# 右側(大きい値側)から見て以上になっているような数列", "+from bisect import bisect_right", "+inf = 10**9 + 1", "-q = deque([-1])", "-for x...
false
0.045103
0.107718
0.418718
[ "s345098733", "s880978020" ]
u561231954
p02889
python
s351685578
s457108934
1,714
1,568
59,864
19,880
Accepted
Accepted
8.52
MOD = 10 **9 + 7 INF = 10 ** 10 def main(): n,m,l = list(map(int,input().split())) dist = [[INF] * n for _ in range(n)] for _ in range(m): a,b,c = list(map(int,input().split())) a -= 1 b -= 1 dist[a][b] = c dist[b][a] = c for k in range(n): ...
MOD = 10 **9 + 7 INF = 10 ** 10 import numpy as np from scipy.sparse.csgraph import floyd_warshall from scipy.sparse import csr_matrix def main(): n,m,l = list(map(int,input().split())) dist = [[INF] * n for _ in range(n)] for _ in range(m): a,b,c = list(map(int,input().split())) ...
37
28
975
740
MOD = 10**9 + 7 INF = 10**10 def main(): n, m, l = list(map(int, input().split())) dist = [[INF] * n for _ in range(n)] for _ in range(m): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 dist[a][b] = c dist[b][a] = c for k in range(n): for i in r...
MOD = 10**9 + 7 INF = 10**10 import numpy as np from scipy.sparse.csgraph import floyd_warshall from scipy.sparse import csr_matrix def main(): n, m, l = list(map(int, input().split())) dist = [[INF] * n for _ in range(n)] for _ in range(m): a, b, c = list(map(int, input().split())) a -= 1...
false
24.324324
[ "+import numpy as np", "+from scipy.sparse.csgraph import floyd_warshall", "+from scipy.sparse import csr_matrix", "- for k in range(n):", "- for i in range(n):", "- for j in range(n):", "- dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])", "- cnt = [[INF] *...
false
0.042259
0.551379
0.076642
[ "s351685578", "s457108934" ]
u481559486
p02695
python
s154078566
s528674487
482
324
75,208
74,016
Accepted
Accepted
32.78
n, m, q = 0, 0, 0 ABCD = [] ans = 0 def dfs(ns): global ans A = [int(c) for c in ns.split()] if len(A) == n: s = 0 for qi in range(q): a, b, c, d = ABCD[qi] if A[b - 1] - A[a - 1] == c: s += d ans = max(s, ans) retu...
n, m, q = 0, 0, 0 ABCD = [] ans = 0 def dfs(A): global ans if len(A) == n: s = 0 for qi in range(q): a, b, c, d = ABCD[qi] if A[b - 1] - A[a - 1] == c: s += d ans = max(s, ans) return for i in range(A[-1], m + 1):...
36
37
677
656
n, m, q = 0, 0, 0 ABCD = [] ans = 0 def dfs(ns): global ans A = [int(c) for c in ns.split()] if len(A) == n: s = 0 for qi in range(q): a, b, c, d = ABCD[qi] if A[b - 1] - A[a - 1] == c: s += d ans = max(s, ans) return for i in ran...
n, m, q = 0, 0, 0 ABCD = [] ans = 0 def dfs(A): global ans if len(A) == n: s = 0 for qi in range(q): a, b, c, d = ABCD[qi] if A[b - 1] - A[a - 1] == c: s += d ans = max(s, ans) return for i in range(A[-1], m + 1): AC = A.copy(...
false
2.702703
[ "-def dfs(ns):", "+def dfs(A):", "- A = [int(c) for c in ns.split()]", "- dfs(\"{} {}\".format(ns, str(i)))", "+ AC = A.copy()", "+ AC.append(i)", "+ dfs(AC)", "- dfs(str(mi))", "+ dfs([mi])" ]
false
0.240232
0.100218
2.397084
[ "s154078566", "s528674487" ]
u992910889
p03032
python
s596606304
s109356619
258
206
54,508
41,456
Accepted
Accepted
20.16
# import string import unittest from io import StringIO import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): N, K = list(map(int, input().split())) V = list(map(int, input().split())) ans = 0 for l in range(K+1): for r ...
import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): N, K = list(map(int, input().split())) V = list(map(int, input().split())) ans = 0 for l in range(K+1): for r in range(K-l+1): if l+r > N or l+r>K: ...
40
37
914
864
# import string import unittest from io import StringIO import sys sys.setrecursionlimit(10**5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): N, K = list(map(int, input().split())) V = list(map(int, input().split())) ans = 0 for l in range(K + 1): for r in range(K...
import sys sys.setrecursionlimit(10**5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): N, K = list(map(int, input().split())) V = list(map(int, input().split())) ans = 0 for l in range(K + 1): for r in range(K - l + 1): if l + r > N or l + r > K: ...
false
7.5
[ "-# import string", "-import unittest", "-from io import StringIO", "- if l + r > N:", "+ if l + r > N or l + r > K:" ]
false
0.06441
0.107665
0.598247
[ "s596606304", "s109356619" ]
u077337864
p03819
python
s807683221
s985009449
1,982
1,307
122,748
115,580
Accepted
Accepted
34.06
def main(): n, m = list(map(int, input().split())) lr = [tuple(map(int, input().split())) for _ in range(n)] BIT = [0 for _ in range(m+1)] def bit_add(a, w): x = a while x <= m: BIT[x] += w x += x&-x def bit_sum(a): ret = 0 x = a while x > 0: ret += BIT[x...
import sys input = sys.stdin.readline sys.setrecursionlimit(pow(10, 6)) class BIT: def __init__(self, n): self.size = n self.tree = [0 for _ in range(n+1)] self.p = 2**(n.bit_length() - 1) self.dep = n.bit_length() def get(self, i): s = 0 while i ...
34
63
698
1,370
def main(): n, m = list(map(int, input().split())) lr = [tuple(map(int, input().split())) for _ in range(n)] BIT = [0 for _ in range(m + 1)] def bit_add(a, w): x = a while x <= m: BIT[x] += w x += x & -x def bit_sum(a): ret = 0 x = a ...
import sys input = sys.stdin.readline sys.setrecursionlimit(pow(10, 6)) class BIT: def __init__(self, n): self.size = n self.tree = [0 for _ in range(n + 1)] self.p = 2 ** (n.bit_length() - 1) self.dep = n.bit_length() def get(self, i): s = 0 while i > 0: ...
false
46.031746
[ "+import sys", "+", "+input = sys.stdin.readline", "+sys.setrecursionlimit(pow(10, 6))", "+", "+", "+class BIT:", "+ def __init__(self, n):", "+ self.size = n", "+ self.tree = [0 for _ in range(n + 1)]", "+ self.p = 2 ** (n.bit_length() - 1)", "+ self.dep = n.bit...
false
0.103285
0.049662
2.079757
[ "s807683221", "s985009449" ]
u816587940
p02804
python
s901436000
s728055106
566
384
37,856
25,956
Accepted
Accepted
32.16
#---------------------------------------------------------- P = 10**9 + 7 N = 200000 #使える最大値、値に注意 inv = [0] + [1] # 1/x finv = [1] + [1] # 1/x! fac = [1] + [1] # x! for i in range(2,N): inv += [inv[P % i] * (P - int(P / i)) % P] fac += [(fac[i-1] * i) % P] finv += [(finv[i-1] * inv[i]) % P] def comb(a...
#---------------------------------------------------------- P = 10**9 + 7 N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心 inv = [0] + [1] # 1/x finv = [1] + [1] # 1/x! fac = [1] + [1] # x! for i in range(2,N): inv += [inv[P % i] * (P - int(P / i)) % P] fac += [(fac[i-1] * i) % P] finv += [(finv[i-1] * inv[i...
41
41
1,084
1,105
# ---------------------------------------------------------- P = 10**9 + 7 N = 200000 # 使える最大値、値に注意 inv = [0] + [1] # 1/x finv = [1] + [1] # 1/x! fac = [1] + [1] # x! for i in range(2, N): inv += [inv[P % i] * (P - int(P / i)) % P] fac += [(fac[i - 1] * i) % P] finv += [(finv[i - 1] * inv[i]) % P] def...
# ---------------------------------------------------------- P = 10**9 + 7 N = 100001 # 使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心 inv = [0] + [1] # 1/x finv = [1] + [1] # 1/x! fac = [1] + [1] # x! for i in range(2, N): inv += [inv[P % i] * (P - int(P / i)) % P] fac += [(fac[i - 1] * i) % P] finv += [(finv[i - 1]...
false
0
[ "-N = 200000 # 使える最大値、値に注意", "+N = 100001 # 使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心" ]
false
0.437522
0.652125
0.670918
[ "s901436000", "s728055106" ]
u585482323
p03666
python
s861629913
s831312868
191
172
39,536
38,768
Accepted
Accepted
9.95
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline()...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) def LS...
118
49
2,224
1,131
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(x) for x in sys.stdin...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) d...
false
58.474576
[ "+from itertools import permutations, accumulate", "-import random", "- return [int(x) for x in sys.stdin.readline().split()]", "+ return [int(x) for x in sys.stdin.buffer.readline().split()]", "- return int(sys.stdin.readline())", "+ return int(sys.stdin.buffer.readline())", "- return li...
false
0.047095
0.051674
0.91138
[ "s861629913", "s831312868" ]
u202634017
p02726
python
s736667781
s093854647
1,493
1,319
3,444
3,444
Accepted
Accepted
11.65
n, x, y = list(map(int, input().split())) x = x - 1 y = y - 1 kl = [0] * (n - 1) for s in range(n - 1): for e in range(s+1, n): d = e-s if (e <= x)or(s >= y): kl[d - 1] += 1 else: kl[min(d, abs(s-x)+abs(e-y)+1)-1] += 1 for i in kl: print(i)
n, x, y = list(map(int, input().split())) x = x - 1 y = y - 1 kl = [0] * (n - 1) for s in range(n - 1): for e in range(s+1, n): d = e-s kl[min(d, abs(s-x)+abs(e-y)+1)-1] += 1 for i in kl: print(i)
15
12
307
228
n, x, y = list(map(int, input().split())) x = x - 1 y = y - 1 kl = [0] * (n - 1) for s in range(n - 1): for e in range(s + 1, n): d = e - s if (e <= x) or (s >= y): kl[d - 1] += 1 else: kl[min(d, abs(s - x) + abs(e - y) + 1) - 1] += 1 for i in kl: print(i)
n, x, y = list(map(int, input().split())) x = x - 1 y = y - 1 kl = [0] * (n - 1) for s in range(n - 1): for e in range(s + 1, n): d = e - s kl[min(d, abs(s - x) + abs(e - y) + 1) - 1] += 1 for i in kl: print(i)
false
20
[ "- if (e <= x) or (s >= y):", "- kl[d - 1] += 1", "- else:", "- kl[min(d, abs(s - x) + abs(e - y) + 1) - 1] += 1", "+ kl[min(d, abs(s - x) + abs(e - y) + 1) - 1] += 1" ]
false
0.043417
0.041949
1.034996
[ "s736667781", "s093854647" ]
u102461423
p03165
python
s023991613
s525996759
463
281
39,252
62,472
Accepted
Accepted
39.31
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) import numpy as np S = np.array(list(input().rstrip()), dtype='U1') T = np.array(list(input().rstrip()), dtype='U1') equal = (S[:,None] == T[None,:]) LS = len(S) LT = len(T) dp = [np.zeros(LT+1, dtype=np.int16)] for i in range(LS):...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = np.array(list(readline().decode()), 'U1')[:-1] T = np.array(list(readline().decode()), 'U1')[:-1] def longest_common_subsequence(S, T): """compute table dp satisfy...
43
39
822
1,106
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import numpy as np S = np.array(list(input().rstrip()), dtype="U1") T = np.array(list(input().rstrip()), dtype="U1") equal = S[:, None] == T[None, :] LS = len(S) LT = len(T) dp = [np.zeros(LT + 1, dtype=np.int16)] for i in range(LS): prev = dp[-1]...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines S = np.array(list(readline().decode()), "U1")[:-1] T = np.array(list(readline().decode()), "U1")[:-1] def longest_common_subsequence(S, T): """compute table dp satisfying: dp...
false
9.302326
[ "-", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-S = np.array(list(input().rstrip()), dtype=\"U1\")", "-T = np.array(list(input().rstrip()), dtype=\"U1\")", "-equal = S[:, None] == T[None, :]", "-LS = len(S)", "-LT = len(T)", "-dp = [np.zeros(LT + 1, dtype=np.int16)]", "-for ...
false
0.507055
0.530889
0.955107
[ "s023991613", "s525996759" ]
u983918956
p03450
python
s156882961
s820024628
1,362
1,232
8,812
57,164
Accepted
Accepted
9.54
import sys input = sys.stdin.readline class Unionfind: __slots__ = ["nodes","diff_weight"] def __init__(self, n): self.nodes = [-1]*n self.diff_weight = [0]*n def root(self, x): if self.nodes[x] < 0: return x else: root_x = self.root(s...
import sys input = sys.stdin.readline class WeightedUnionfind: __slots__ = ['nodes','diff_weight'] def __init__(self, n): self.nodes = [-1]*n self.diff_weight = [0]*n def root(self, x): if self.nodes[x] < 0: return x else: root_x = s...
56
59
1,447
1,507
import sys input = sys.stdin.readline class Unionfind: __slots__ = ["nodes", "diff_weight"] def __init__(self, n): self.nodes = [-1] * n self.diff_weight = [0] * n def root(self, x): if self.nodes[x] < 0: return x else: root_x = self.root(self.nod...
import sys input = sys.stdin.readline class WeightedUnionfind: __slots__ = ["nodes", "diff_weight"] def __init__(self, n): self.nodes = [-1] * n self.diff_weight = [0] * n def root(self, x): if self.nodes[x] < 0: return x else: root_x = self.root(...
false
5.084746
[ "-class Unionfind:", "+class WeightedUnionfind:", "-uf = Unionfind(N)", "+info = [list(map(int, input().split())) for i in range(M)]", "+wuf = WeightedUnionfind(N + 1)", "-for _ in range(M):", "- L, R, D = list(map(int, input().split()))", "- L -= 1", "- R -= 1", "- uf.unite(L, R, D)",...
false
0.040471
0.300588
0.134638
[ "s156882961", "s820024628" ]
u631277801
p03401
python
s932457086
s650366271
227
190
14,048
14,176
Accepted
Accepted
16.3
N = int(eval(input())) A = list(map(int, input().split())) A.append(0) A.insert(0,0) total = 0 for i in range(1,N+2): total += abs(A[i]-A[i-1]) for i in range(1,N+1): print((total - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1])))
N = int(eval(input())) A = list(map(int, input().split())) A.insert(0,0) A.append(0) cost = [0]*(N+1) for i in range(N+1): cost[i] = abs(A[i+1]-A[i]) total = sum(cost) for i in range(N): print((total - cost[i] - cost[i+1] + abs(A[i+2]-A[i])))
11
13
252
257
N = int(eval(input())) A = list(map(int, input().split())) A.append(0) A.insert(0, 0) total = 0 for i in range(1, N + 2): total += abs(A[i] - A[i - 1]) for i in range(1, N + 1): print( (total - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1])) )
N = int(eval(input())) A = list(map(int, input().split())) A.insert(0, 0) A.append(0) cost = [0] * (N + 1) for i in range(N + 1): cost[i] = abs(A[i + 1] - A[i]) total = sum(cost) for i in range(N): print((total - cost[i] - cost[i + 1] + abs(A[i + 2] - A[i])))
false
15.384615
[ "+A.insert(0, 0)", "-A.insert(0, 0)", "-total = 0", "-for i in range(1, N + 2):", "- total += abs(A[i] - A[i - 1])", "-for i in range(1, N + 1):", "- print(", "- (total - abs(A[i + 1] - A[i]) - abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i - 1]))", "- )", "+cost = [0] * (N + 1)", "+f...
false
0.035688
0.113977
0.313112
[ "s932457086", "s650366271" ]
u315078622
p03166
python
s020566904
s948386826
867
583
65,040
59,056
Accepted
Accepted
32.76
import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import connected_components def create_graph(V: int, edges: np.array, dtype=None): """csr_matrix を作成する もし精度が足りない場合は dtype=object にする。 """ return csr_matrix((edges[:, 2], (edges[:, 0], edges[:, 1])), ...
import sys sys.setrecursionlimit(2*10**5) def dfs(v, graph, memo): if memo[v] != -1: return memo[v] ret = 0 for c in graph[v]: ret = max(ret, dfs(c, graph, memo) + 1) memo[v] = ret return ret def main(): N, M = list(map(int, input().split())) graph = [[] f...
37
30
1,053
618
import numpy as np from scipy.sparse import csr_matrix from scipy.sparse.csgraph import connected_components def create_graph(V: int, edges: np.array, dtype=None): """csr_matrix を作成する もし精度が足りない場合は dtype=object にする。 """ return csr_matrix( (edges[:, 2], (edges[:, 0], edges[:, 1])), shape=(V, V),...
import sys sys.setrecursionlimit(2 * 10**5) def dfs(v, graph, memo): if memo[v] != -1: return memo[v] ret = 0 for c in graph[v]: ret = max(ret, dfs(c, graph, memo) + 1) memo[v] = ret return ret def main(): N, M = list(map(int, input().split())) graph = [[] for _ in range...
false
18.918919
[ "-import numpy as np", "-from scipy.sparse import csr_matrix", "-from scipy.sparse.csgraph import connected_components", "+import sys", "+", "+sys.setrecursionlimit(2 * 10**5)", "-def create_graph(V: int, edges: np.array, dtype=None):", "- \"\"\"csr_matrix を作成する", "- もし精度が足りない場合は dtype=object ...
false
0.316651
0.072425
4.372148
[ "s020566904", "s948386826" ]
u606045429
p02850
python
s103330275
s865089566
223
178
25,892
28,936
Accepted
Accepted
20.18
""" challenge case in: 3 1 3 2 3 out: 1 1 1 """ from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) B = AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): E[a].append(b) Q = deque([1]) C = [0] * (N + 1) while Q: v =...
""" challenge case in: 3 1 3 2 3 out: 1 1 1 """ from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) B = AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): E[a].append(b) Q = deque([1]) C = [0] * (N + 1) while Q: v =...
37
38
460
480
""" challenge case in: 3 1 3 2 3 out: 1 1 1 """ from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) B = AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): E[a].append(b) Q = deque([1]) C = [0] * (N + 1) while Q: v...
""" challenge case in: 3 1 3 2 3 out: 1 1 1 """ from collections import deque def main(): N, *AB = list(map(int, open(0).read().split())) B = AB[1::2] E = [[] for _ in range(N + 1)] for a, b in zip(*[iter(AB)] * 2): E[a].append(b) Q = deque([1]) C = [0] * (N + 1) while Q: v...
false
2.631579
[ "- print((max(C), *(C[b] for b in B)))", "+ print((max(C)))", "+ print((\"\\n\".join(str(C[b]) for b in B)))" ]
false
0.084734
0.043152
1.963631
[ "s103330275", "s865089566" ]
u392319141
p03017
python
s123477409
s781816991
76
20
3,572
3,700
Accepted
Accepted
73.68
n , a0 , b0 , c0 , d0 = list(map(int,input().split())) s = eval(input()) # a < b に変換する if a0 > b0 : # 入れ替える a = b0 b = a0 c = d0 d = c0 else : # 入れ替えない a = a0 b = b0 c = c0 d = d0 right = max(c,d) left = min(a,b) middle = max(a,b) for i in range(n-1) : if s[i] ...
N, A, B, C, D = list(map(int, input().split())) S = '$' + eval(input()) + '$' def isOk(fr, to): if S[fr: to + 1].count('##') > 0: return False return True if not (isOk(A, C) and isOk(C, D)): print('No') exit() def canSwitch(): if A + 1 == B and D < C and S[A: A + 3] == '...':...
38
39
852
1,035
n, a0, b0, c0, d0 = list(map(int, input().split())) s = eval(input()) # a < b に変換する if a0 > b0: # 入れ替える a = b0 b = a0 c = d0 d = c0 else: # 入れ替えない a = a0 b = b0 c = c0 d = d0 right = max(c, d) left = min(a, b) middle = max(a, b) for i in range(n - 1): if s[i] == "#" and s[i + 1] ==...
N, A, B, C, D = list(map(int, input().split())) S = "$" + eval(input()) + "$" def isOk(fr, to): if S[fr : to + 1].count("##") > 0: return False return True if not (isOk(A, C) and isOk(C, D)): print("No") exit() def canSwitch(): if A + 1 == B and D < C and S[A : A + 3] == "...": ...
false
2.564103
[ "-n, a0, b0, c0, d0 = list(map(int, input().split()))", "-s = eval(input())", "-# a < b に変換する", "-if a0 > b0: # 入れ替える", "- a = b0", "- b = a0", "- c = d0", "- d = c0", "-else: # 入れ替えない", "- a = a0", "- b = b0", "- c = c0", "- d = d0", "-right = max(c, d)", "-lef...
false
0.112695
0.047867
2.354342
[ "s123477409", "s781816991" ]
u787988531
p03557
python
s580605998
s059807891
651
590
56,376
57,144
Accepted
Accepted
9.37
N = int(input()) As = input().split(" ") Bs = input().split(" ") Cs = input().split(" ") As = [(int(i), 2) for i in As] Bs = [(int(i), 1) for i in Bs] Cs = [(int(i), 0) for i in Cs] l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ...
N = int(input()) As = [(int(i), 2) for i in input().split(" ")] Bs = [(int(i), 1) for i in input().split(" ")] Cs = [(int(i), 0) for i in input().split(" ")] l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ac += 1 elif i[1] ==...
25
21
435
406
N = int(input()) As = input().split(" ") Bs = input().split(" ") Cs = input().split(" ") As = [(int(i), 2) for i in As] Bs = [(int(i), 1) for i in Bs] Cs = [(int(i), 0) for i in Cs] l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ac += 1 elif i[1]...
N = int(input()) As = [(int(i), 2) for i in input().split(" ")] Bs = [(int(i), 1) for i in input().split(" ")] Cs = [(int(i), 0) for i in input().split(" ")] l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1) ac = 0 bc = 0 cc = 0 for i in l: if i[1] == 2: ac += 1 elif i[1] == 1: bc += ac ...
false
16
[ "-As = input().split(\" \")", "-Bs = input().split(\" \")", "-Cs = input().split(\" \")", "-As = [(int(i), 2) for i in As]", "-Bs = [(int(i), 1) for i in Bs]", "-Cs = [(int(i), 0) for i in Cs]", "+As = [(int(i), 2) for i in input().split(\" \")]", "+Bs = [(int(i), 1) for i in input().split(\" \")]", ...
false
0.049244
0.04043
1.218014
[ "s580605998", "s059807891" ]
u520276780
p02726
python
s539435010
s879528578
1,290
114
3,444
75,244
Accepted
Accepted
91.16
##? n,x,y = list(map(int,input().split( ))) x-=1;y-=1 cnt = [0]*n for i in range(n): for j in range(i+1,n): dist = min(abs(j-i),abs(x-i)+1+abs(j-y)) cnt[dist]+=1 for i in range(1,n): print((cnt[i]))
n,x,y=list(map(int, input().split())) cnts=[0]*n for i in range(1,n+1): for j in range(1,i): mn=min(abs(i-j),abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1) cnts[mn]+=1 for ci in cnts[1:]: print(ci)
11
8
226
217
##? n, x, y = list(map(int, input().split())) x -= 1 y -= 1 cnt = [0] * n for i in range(n): for j in range(i + 1, n): dist = min(abs(j - i), abs(x - i) + 1 + abs(j - y)) cnt[dist] += 1 for i in range(1, n): print((cnt[i]))
n, x, y = list(map(int, input().split())) cnts = [0] * n for i in range(1, n + 1): for j in range(1, i): mn = min(abs(i - j), abs(i - x) + abs(j - y) + 1, abs(i - y) + abs(j - x) + 1) cnts[mn] += 1 for ci in cnts[1:]: print(ci)
false
27.272727
[ "-##?", "-x -= 1", "-y -= 1", "-cnt = [0] * n", "-for i in range(n):", "- for j in range(i + 1, n):", "- dist = min(abs(j - i), abs(x - i) + 1 + abs(j - y))", "- cnt[dist] += 1", "-for i in range(1, n):", "- print((cnt[i]))", "+cnts = [0] * n", "+for i in range(1, n + 1):",...
false
0.087849
0.036609
2.399646
[ "s539435010", "s879528578" ]
u426534722
p02235
python
s058835948
s085525913
2,790
2,380
6,028
5,624
Accepted
Accepted
14.7
import sys readline = sys.stdin.readline from collections import defaultdict from bisect import bisect_left, bisect, insort_left, insort INF = 10000 def lcs(s1, s2): c = defaultdict(list) for i, s in enumerate(s1): c[s].append(i) for s in set(s2): c[s].append(INF) dp = [] ...
import sys readline = sys.stdin.readline for _ in range(int(eval(input()))): a = readline().strip() b = readline().strip() indices = [] for cb in b: bgn_idx = 0 for i, cur_idx in enumerate(indices): chr_idx = a.find(cb, bgn_idx) + 1 if not chr_idx: ...
33
20
959
589
import sys readline = sys.stdin.readline from collections import defaultdict from bisect import bisect_left, bisect, insort_left, insort INF = 10000 def lcs(s1, s2): c = defaultdict(list) for i, s in enumerate(s1): c[s].append(i) for s in set(s2): c[s].append(INF) dp = [] for s2_...
import sys readline = sys.stdin.readline for _ in range(int(eval(input()))): a = readline().strip() b = readline().strip() indices = [] for cb in b: bgn_idx = 0 for i, cur_idx in enumerate(indices): chr_idx = a.find(cb, bgn_idx) + 1 if not chr_idx: ...
false
39.393939
[ "-from collections import defaultdict", "-from bisect import bisect_left, bisect, insort_left, insort", "-", "-INF = 10000", "-", "-", "-def lcs(s1, s2):", "- c = defaultdict(list)", "- for i, s in enumerate(s1):", "- c[s].append(i)", "- for s in set(s2):", "- c[s].appen...
false
0.044759
0.045914
0.974856
[ "s058835948", "s085525913" ]
u282228874
p03339
python
s320802681
s518192920
197
143
42,016
3,672
Accepted
Accepted
27.41
N = int(eval(input())) S = eval(input()) E = S.count('E') res = E W = 0 for s in S: if s == 'E': E -= 1 else: W += 1 res = min(res,W+E) print(res)
N = int(eval(input())) S = eval(input()) E = S.count('E') W = 0 res = E for s in S: if s == 'E': E -= 1 else: W += 1 res = min(res,W+E) print(res)
12
12
173
173
N = int(eval(input())) S = eval(input()) E = S.count("E") res = E W = 0 for s in S: if s == "E": E -= 1 else: W += 1 res = min(res, W + E) print(res)
N = int(eval(input())) S = eval(input()) E = S.count("E") W = 0 res = E for s in S: if s == "E": E -= 1 else: W += 1 res = min(res, W + E) print(res)
false
0
[ "+W = 0", "-W = 0" ]
false
0.03995
0.037747
1.058376
[ "s320802681", "s518192920" ]
u729133443
p03469
python
s620263301
s135490397
167
17
38,256
2,940
Accepted
Accepted
89.82
print(('2018'+input()[4:]))
print((input(2018)[4:]))
1
1
25
22
print(("2018" + input()[4:]))
print((input(2018)[4:]))
false
0
[ "-print((\"2018\" + input()[4:]))", "+print((input(2018)[4:]))" ]
false
0.043833
0.044728
0.979987
[ "s620263301", "s135490397" ]
u934868410
p02888
python
s661194195
s214308202
1,402
783
46,300
45,696
Accepted
Accepted
44.15
from bisect import bisect from bisect import bisect_left n = int(eval(input())) l = list(map(int, input().split())) l.sort() ans = 0 for i in range(n): for j in range(i+1, n): left = l[j]-l[i] right = l[i]+l[j] ans += max(0, bisect_left(l, right) - max(j+1, bisect(l,left))) print(ans)
from bisect import bisect_left n = int(eval(input())) l = list(map(int, input().split())) l.sort() ans = 0 for i in range(n): for j in range(i+1, n): left = l[j]-l[i] right = l[i]+l[j] ans += max(0, bisect_left(l, right) - (j+1)) print(ans)
12
11
304
258
from bisect import bisect from bisect import bisect_left n = int(eval(input())) l = list(map(int, input().split())) l.sort() ans = 0 for i in range(n): for j in range(i + 1, n): left = l[j] - l[i] right = l[i] + l[j] ans += max(0, bisect_left(l, right) - max(j + 1, bisect(l, left))) print(a...
from bisect import bisect_left n = int(eval(input())) l = list(map(int, input().split())) l.sort() ans = 0 for i in range(n): for j in range(i + 1, n): left = l[j] - l[i] right = l[i] + l[j] ans += max(0, bisect_left(l, right) - (j + 1)) print(ans)
false
8.333333
[ "-from bisect import bisect", "- ans += max(0, bisect_left(l, right) - max(j + 1, bisect(l, left)))", "+ ans += max(0, bisect_left(l, right) - (j + 1))" ]
false
0.048483
0.038117
1.271951
[ "s661194195", "s214308202" ]
u057109575
p02762
python
s727207227
s079887601
698
623
143,236
136,592
Accepted
Accepted
10.74
class UnionFind: def __init__(self, n): self.par = list(range(n)) self.rank = [0] * n self.size = [1] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] ...
class UnionFind: def __init__(self, n): self.par = list(range(n)) self.rank = [0] * n self.size = [1] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] ...
62
64
1,397
1,436
class UnionFind: def __init__(self, n): self.par = list(range(n)) self.rank = [0] * n self.size = [1] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def unite(sel...
class UnionFind: def __init__(self, n): self.par = list(range(n)) self.rank = [0] * n self.size = [1] * n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def unite(sel...
false
3.125
[ "-block = [[] for _ in range(N + 1)]", "+blocked = [[] for _ in range(N + 1)]", "+for c, d in X:", "+ blocked[c].append(d)", "+ blocked[d].append(c)", "+tree = UnionFind(N + 1)", "+for a, b in X:", "+ tree.unite(a, b)", "+ans = [0] * (N + 1)", "+for i in range(1, N + 1):", "+ ans[i] ...
false
0.037171
0.037073
1.002645
[ "s727207227", "s079887601" ]
u823885866
p03125
python
s868311865
s277853026
29
26
9,164
9,048
Accepted
Accepted
10.34
import sys rm = lambda: list(map(int, sys.stdin.buffer.readline().split())) a, b = rm() print((b-a if b%a else a+b))
import sys rm = lambda: list(map(int, sys.stdin.buffer.readline().split())) a, b = rm() print((a+b if b%a == 0 else b-a))
5
5
113
119
import sys rm = lambda: list(map(int, sys.stdin.buffer.readline().split())) a, b = rm() print((b - a if b % a else a + b))
import sys rm = lambda: list(map(int, sys.stdin.buffer.readline().split())) a, b = rm() print((a + b if b % a == 0 else b - a))
false
0
[ "-print((b - a if b % a else a + b))", "+print((a + b if b % a == 0 else b - a))" ]
false
0.044349
0.039515
1.122328
[ "s868311865", "s277853026" ]
u225388820
p02720
python
s805320698
s543940077
228
166
19,852
7,708
Accepted
Accepted
27.19
k=int(eval(input())) ans=[i for i in range(1,10)] def dfs(x): if x>=3234566667: return for i in range(max(0,x%10-1),min(10,x%10+2)): ans.append(10*x+i) dfs(10*x+i) for i in range(1,10): dfs(i) print((sorted(ans)[k-1]))
k=int(eval(input())) a=[] def dfs(v): if v>3234566667: return a.append(v) for i in range(max(0,v%10-1),min(v%10+2,10)): dfs(10*v+i) for i in range(1,10): dfs(i) a.sort() print((a[k-1]))
11
12
256
220
k = int(eval(input())) ans = [i for i in range(1, 10)] def dfs(x): if x >= 3234566667: return for i in range(max(0, x % 10 - 1), min(10, x % 10 + 2)): ans.append(10 * x + i) dfs(10 * x + i) for i in range(1, 10): dfs(i) print((sorted(ans)[k - 1]))
k = int(eval(input())) a = [] def dfs(v): if v > 3234566667: return a.append(v) for i in range(max(0, v % 10 - 1), min(v % 10 + 2, 10)): dfs(10 * v + i) for i in range(1, 10): dfs(i) a.sort() print((a[k - 1]))
false
8.333333
[ "-ans = [i for i in range(1, 10)]", "+a = []", "-def dfs(x):", "- if x >= 3234566667:", "+def dfs(v):", "+ if v > 3234566667:", "- for i in range(max(0, x % 10 - 1), min(10, x % 10 + 2)):", "- ans.append(10 * x + i)", "- dfs(10 * x + i)", "+ a.append(v)", "+ for i in...
false
0.546527
0.569244
0.960092
[ "s805320698", "s543940077" ]
u183754334
p03448
python
s290015344
s407858613
76
49
3,060
2,940
Accepted
Accepted
35.53
A, B, C, X = [int(input().rstrip()) for _ in range(4)] count = 0 for a in range(A+1): sum_a = 500 * a for b in range(B+1): sum_b = 100 * b for c in range(C+1): sum_c = 50 * c total_sum = sum([sum_a, sum_b, sum_c]) if total_sum == X: ...
A, B, C, X = [int(input().rstrip()) for _ in range(4)] count = 0 for a in range(A+1): sum_a = 500 * a for b in range(B+1): sum_b = 100 * b for c in range(C+1): sum_c = 50 * c sum_all = sum_a + sum_b + sum_c if sum_all == X: count +=...
14
14
348
339
A, B, C, X = [int(input().rstrip()) for _ in range(4)] count = 0 for a in range(A + 1): sum_a = 500 * a for b in range(B + 1): sum_b = 100 * b for c in range(C + 1): sum_c = 50 * c total_sum = sum([sum_a, sum_b, sum_c]) if total_sum == X: count...
A, B, C, X = [int(input().rstrip()) for _ in range(4)] count = 0 for a in range(A + 1): sum_a = 500 * a for b in range(B + 1): sum_b = 100 * b for c in range(C + 1): sum_c = 50 * c sum_all = sum_a + sum_b + sum_c if sum_all == X: count += 1 pri...
false
0
[ "- total_sum = sum([sum_a, sum_b, sum_c])", "- if total_sum == X:", "+ sum_all = sum_a + sum_b + sum_c", "+ if sum_all == X:" ]
false
0.27447
0.13546
2.026199
[ "s290015344", "s407858613" ]
u562935282
p02987
python
s928658074
s694983249
163
17
38,384
2,940
Accepted
Accepted
89.57
s = list(eval(input())) s.sort() flg = (s[0] == s[1]) and (s[1] != s[2]) and (s[2] == s[3]) print(('Yes' if flg else 'No'))
def main(): *s, = eval(input()) s.sort() cond = s[0] == s[1] and s[1] != s[2] and s[2] == s[3] print(('Yes' if cond else 'No')) if __name__ == '__main__': main()
4
9
119
184
s = list(eval(input())) s.sort() flg = (s[0] == s[1]) and (s[1] != s[2]) and (s[2] == s[3]) print(("Yes" if flg else "No"))
def main(): (*s,) = eval(input()) s.sort() cond = s[0] == s[1] and s[1] != s[2] and s[2] == s[3] print(("Yes" if cond else "No")) if __name__ == "__main__": main()
false
55.555556
[ "-s = list(eval(input()))", "-s.sort()", "-flg = (s[0] == s[1]) and (s[1] != s[2]) and (s[2] == s[3])", "-print((\"Yes\" if flg else \"No\"))", "+def main():", "+ (*s,) = eval(input())", "+ s.sort()", "+ cond = s[0] == s[1] and s[1] != s[2] and s[2] == s[3]", "+ print((\"Yes\" if cond el...
false
0.113932
0.035795
3.182866
[ "s928658074", "s694983249" ]
u671060652
p03127
python
s039131960
s139002406
324
91
88,428
85,112
Accepted
Accepted
71.91
import itertools import math import fractions import functools import copy n = int(eval(input())) a = list(map(int, input().split())) def gcd(numbers): return functools.reduce(fractions.gcd, numbers) print((gcd(a)))
def main(): n = int(eval(input())) # n, m = map(int, input().split()) a = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] while True: currentmin = 10**10 currentminIndex = 0 for i in range(n): if currentmin > a[i...
10
30
221
723
import itertools import math import fractions import functools import copy n = int(eval(input())) a = list(map(int, input().split())) def gcd(numbers): return functools.reduce(fractions.gcd, numbers) print((gcd(a)))
def main(): n = int(eval(input())) # n, m = map(int, input().split()) a = list(map(int, input().split())) # s = input() # h = [int(input()) for _ in rane(n)] while True: currentmin = 10**10 currentminIndex = 0 for i in range(n): if currentmin > a[i] and a[i] !...
false
66.666667
[ "-import itertools", "-import math", "-import fractions", "-import functools", "-import copy", "-", "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "+def main():", "+ n = int(eval(input()))", "+ # n, m = map(int, input().split())", "+ a = list(map(int, input().split...
false
0.057923
0.006067
9.547913
[ "s039131960", "s139002406" ]
u799613351
p03488
python
s543455274
s590539714
1,417
651
3,700
20,212
Accepted
Accepted
54.06
s = eval(input()) x, y = list(map(int, input().split())) fs = s.split('T') f_num = [len(f) for f in fs] dir_lst = [[], []] for i in range(len(f_num)): dir_lst[i % 2].append(f_num[i]) x_lst = dir_lst[0] x -= x_lst[0] x_lst = x_lst[1:] y_lst = dir_lst[1] can_x = False can_y = False s = set([0]) fo...
s = eval(input()) x, y = list(map(int, input().split())) def part_sum0(a, A): # 初期化 N = len(a) dp = [[0 for i in range(A + 1)] for j in range(N + 1)] dp[0][0] = 1 # DP for i in range(N): for j in range(A + 1): if a[i] <= j: dp[i + 1][j] = dp[i...
40
56
660
1,098
s = eval(input()) x, y = list(map(int, input().split())) fs = s.split("T") f_num = [len(f) for f in fs] dir_lst = [[], []] for i in range(len(f_num)): dir_lst[i % 2].append(f_num[i]) x_lst = dir_lst[0] x -= x_lst[0] x_lst = x_lst[1:] y_lst = dir_lst[1] can_x = False can_y = False s = set([0]) for x_ in x_lst: s...
s = eval(input()) x, y = list(map(int, input().split())) def part_sum0(a, A): # 初期化 N = len(a) dp = [[0 for i in range(A + 1)] for j in range(N + 1)] dp[0][0] = 1 # DP for i in range(N): for j in range(A + 1): if a[i] <= j: dp[i + 1][j] = dp[i][j - a[i]] or ...
false
28.571429
[ "+", "+", "+def part_sum0(a, A):", "+ # 初期化", "+ N = len(a)", "+ dp = [[0 for i in range(A + 1)] for j in range(N + 1)]", "+ dp[0][0] = 1", "+ # DP", "+ for i in range(N):", "+ for j in range(A + 1):", "+ if a[i] <= j:", "+ dp[i + 1][j] = dp[i...
false
0.076033
0.043008
1.767879
[ "s543455274", "s590539714" ]
u633548583
p03161
python
s215060778
s220788531
1,984
507
13,980
53,216
Accepted
Accepted
74.45
def main(): n,k=list(map(int,input().split())) h=list(map(int,input().split())) dp=[10**5]*n dp[0]=0 for i in range(1,n): dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-k),i)) print((dp[n-1])) main()
n,k=list(map(int,input().split())) h=list(map(int,input().split())) dp=[10**10]*n dp[0]=0 for i in range(1,n): dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-k),i)) print((dp[n-1]))
10
7
245
191
def main(): n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [10**5] * n dp[0] = 0 for i in range(1, n): dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(0, i - k), i)) print((dp[n - 1])) main()
n, k = list(map(int, input().split())) h = list(map(int, input().split())) dp = [10**10] * n dp[0] = 0 for i in range(1, n): dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(0, i - k), i)) print((dp[n - 1]))
false
30
[ "-def main():", "- n, k = list(map(int, input().split()))", "- h = list(map(int, input().split()))", "- dp = [10**5] * n", "- dp[0] = 0", "- for i in range(1, n):", "- dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(0, i - k), i))", "- print((dp[n - 1]))", "-", "-"...
false
0.038215
0.044029
0.867934
[ "s215060778", "s220788531" ]
u111365362
p03354
python
s770368112
s585445890
818
726
88,428
72,428
Accepted
Accepted
11.25
#16:00 n,m = list(map(int,input().split())) a = list([int(x)-1 for x in input().split()]) pre = [i for i in range(n)] for _ in range(m): X,Y = list(map(int,input().split())) X -= 1 Y -= 1 while pre[X] != X: X = pre[X] while pre[Y] != Y: Y = pre[Y] if X == Y: continue elif X < Y: ...
n,m = list(map(int,input().split())) a = list([int(z)-1 for z in input().split()]) pre = [i for i in range(n)] for _ in range(m): x,y = [int(z)-1 for z in input().split()] while pre[x] != x: x = pre[x] while pre[y] != y: y = pre[y] if x == y: continue elif x < y: pre[y] = x else...
47
28
915
592
# 16:00 n, m = list(map(int, input().split())) a = list([int(x) - 1 for x in input().split()]) pre = [i for i in range(n)] for _ in range(m): X, Y = list(map(int, input().split())) X -= 1 Y -= 1 while pre[X] != X: X = pre[X] while pre[Y] != Y: Y = pre[Y] if X == Y: contin...
n, m = list(map(int, input().split())) a = list([int(z) - 1 for z in input().split()]) pre = [i for i in range(n)] for _ in range(m): x, y = [int(z) - 1 for z in input().split()] while pre[x] != x: x = pre[x] while pre[y] != y: y = pre[y] if x == y: continue elif x < y: ...
false
40.425532
[ "-# 16:00", "-a = list([int(x) - 1 for x in input().split()])", "+a = list([int(z) - 1 for z in input().split()])", "- X, Y = list(map(int, input().split()))", "- X -= 1", "- Y -= 1", "- while pre[X] != X:", "- X = pre[X]", "- while pre[Y] != Y:", "- Y = pre[Y]", "- ...
false
0.045355
0.045093
1.005797
[ "s770368112", "s585445890" ]
u227020436
p03241
python
s353538700
s518900150
1,298
166
38,896
38,512
Accepted
Accepted
87.21
N, M = list(map(int, input().split())) if N == 1: print(M) else: d = max(d for d in range(1, M // N + 1) if M % d == 0) print(d)
import math N, M = list(map(int, input().split())) def divisors(M): for d in range(1, math.floor(math.sqrt(M)) + 1): if M % d == 0: yield d yield M // d d = max(d for d in divisors(M) if d <= M // N) print(d)
7
12
142
252
N, M = list(map(int, input().split())) if N == 1: print(M) else: d = max(d for d in range(1, M // N + 1) if M % d == 0) print(d)
import math N, M = list(map(int, input().split())) def divisors(M): for d in range(1, math.floor(math.sqrt(M)) + 1): if M % d == 0: yield d yield M // d d = max(d for d in divisors(M) if d <= M // N) print(d)
false
41.666667
[ "+import math", "+", "-if N == 1:", "- print(M)", "-else:", "- d = max(d for d in range(1, M // N + 1) if M % d == 0)", "- print(d)", "+", "+", "+def divisors(M):", "+ for d in range(1, math.floor(math.sqrt(M)) + 1):", "+ if M % d == 0:", "+ yield d", "+ ...
false
0.060836
0.03837
1.585513
[ "s353538700", "s518900150" ]
u816872429
p03043
python
s645217570
s169315661
177
17
38,256
3,060
Accepted
Accepted
90.4
n, k = list(map(int, input().split())) b = 1.0 / n ret = 0 while n > 0: t = max(n - k + 1, 0) ret += b * t n -= t k -= k // 2 b *= 0.5 print(ret)
n, k = list(map(int, input().split())) ret = 0.0 p = 1.0 r = n + 1 while True: num = r - min(r, k) ret += num * p r -= num if k == 1: break k = (k + 1) // 2 p = p * 0.5 print((ret / n))
10
13
168
224
n, k = list(map(int, input().split())) b = 1.0 / n ret = 0 while n > 0: t = max(n - k + 1, 0) ret += b * t n -= t k -= k // 2 b *= 0.5 print(ret)
n, k = list(map(int, input().split())) ret = 0.0 p = 1.0 r = n + 1 while True: num = r - min(r, k) ret += num * p r -= num if k == 1: break k = (k + 1) // 2 p = p * 0.5 print((ret / n))
false
23.076923
[ "-b = 1.0 / n", "-ret = 0", "-while n > 0:", "- t = max(n - k + 1, 0)", "- ret += b * t", "- n -= t", "- k -= k // 2", "- b *= 0.5", "-print(ret)", "+ret = 0.0", "+p = 1.0", "+r = n + 1", "+while True:", "+ num = r - min(r, k)", "+ ret += num * p", "+ r -= num",...
false
0.071113
0.077009
0.92343
[ "s645217570", "s169315661" ]
u707124227
p03973
python
s334136736
s826160099
229
184
76,648
80,700
Accepted
Accepted
19.65
n=int(eval(input())) a=[int(eval(input())) for _ in range(n)] mi=1 ans=a[0]-1 for x in a[1:]: if x>mi+1: ans+=(x-1)//(mi+1) else: mi=max(mi,x) print(ans)
n=int(eval(input())) a=[int(eval(input())) for _ in range(n)] def main(n,a): pre=0 ans=0 for x in a: if pre+2<=x: # pre+1以上の数値を何回か引き算してxを1以上pre以下にする # 引き算の回数はなるべく多く if x%(pre+1)==0: tmp=x//(pre+1) ans+=tmp-1 pre=max(pre,1) else: tmp=x//(pre...
10
21
162
420
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] mi = 1 ans = a[0] - 1 for x in a[1:]: if x > mi + 1: ans += (x - 1) // (mi + 1) else: mi = max(mi, x) print(ans)
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] def main(n, a): pre = 0 ans = 0 for x in a: if pre + 2 <= x: # pre+1以上の数値を何回か引き算してxを1以上pre以下にする # 引き算の回数はなるべく多く if x % (pre + 1) == 0: tmp = x // (pre + 1) ans += t...
false
52.380952
[ "-mi = 1", "-ans = a[0] - 1", "-for x in a[1:]:", "- if x > mi + 1:", "- ans += (x - 1) // (mi + 1)", "- else:", "- mi = max(mi, x)", "-print(ans)", "+", "+", "+def main(n, a):", "+ pre = 0", "+ ans = 0", "+ for x in a:", "+ if pre + 2 <= x:", "+ ...
false
0.042086
0.09423
0.44663
[ "s334136736", "s826160099" ]
u119148115
p03575
python
s564495098
s657235087
206
84
41,708
73,820
Accepted
Accepted
59.22
import sys def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def S(): return sys.stdin.readline().rstrip() N,M = list(map(int,S().split())) ab = [LI() for i in range(M)] class UnionFind: def __init__(self,n): self.par = [i for i in range(n+1)] # 親のノード番号 self...
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
42
49
1,145
1,449
import sys def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def S(): return sys.stdin.readline().rstrip() N, M = list(map(int, S().split())) ab = [LI() for i in range(M)] class UnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] # 親のノード番号 ...
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
false
14.285714
[ "+", "+sys.setrecursionlimit(10**7)", "+", "+", "+def I():", "+ return int(sys.stdin.readline().rstrip())", "+", "+", "+def MI():", "+ return list(map(int, sys.stdin.readline().rstrip().split()))", "+def LI2():", "+ return list(map(int, sys.stdin.readline().rstrip())) # 空白なし", "+",...
false
0.049182
0.114485
0.429597
[ "s564495098", "s657235087" ]
u186838327
p03457
python
s967425993
s710242546
360
182
3,060
74,448
Accepted
Accepted
49.44
n = int(eval(input())) t_ = 0 x_ = 0 y_ = 0 for i in range(n): t, x, y = list(map(int, input().split())) d = (t-t_)-abs(x-x_)-abs(y-y_) if d < 0 or d%2 != 0: print('No') exit() else: t_ = t x_ = x y_ = y else: print('Yes')
n = int(eval(input())) TXY = [] tc, xc, yc = 0, 0, 0 for i in range(n): t, x, y = list(map(int, input().split())) d = abs(x-xc)+abs(y-yc) if d > t-tc or (t-tc-d)%2 == 1: print('No') exit() else: tc, xc, yc = t, x, y else: print('Yes')
17
13
289
279
n = int(eval(input())) t_ = 0 x_ = 0 y_ = 0 for i in range(n): t, x, y = list(map(int, input().split())) d = (t - t_) - abs(x - x_) - abs(y - y_) if d < 0 or d % 2 != 0: print("No") exit() else: t_ = t x_ = x y_ = y else: print("Yes")
n = int(eval(input())) TXY = [] tc, xc, yc = 0, 0, 0 for i in range(n): t, x, y = list(map(int, input().split())) d = abs(x - xc) + abs(y - yc) if d > t - tc or (t - tc - d) % 2 == 1: print("No") exit() else: tc, xc, yc = t, x, y else: print("Yes")
false
23.529412
[ "-t_ = 0", "-x_ = 0", "-y_ = 0", "+TXY = []", "+tc, xc, yc = 0, 0, 0", "- d = (t - t_) - abs(x - x_) - abs(y - y_)", "- if d < 0 or d % 2 != 0:", "+ d = abs(x - xc) + abs(y - yc)", "+ if d > t - tc or (t - tc - d) % 2 == 1:", "- t_ = t", "- x_ = x", "- y_ = y",...
false
0.0726
0.034769
2.088052
[ "s967425993", "s710242546" ]
u243699903
p04045
python
s327177014
s990294694
119
59
2,940
3,064
Accepted
Accepted
50.42
n, k = list(map(int, input().split())) dlist = [s for s in input().split()] ans = n while True: blnOk = True for d in str(ans): if d in dlist: blnOk = False if blnOk: print(ans) exit() else: ans += 1
n, k = list(map(int, input().split())) dlist = [s for s in input().split()] ans = n while True: blnOk = True for d in str(ans): if d in dlist: blnOk = False break if blnOk: print(ans) exit() else: ans += 1
13
14
266
285
n, k = list(map(int, input().split())) dlist = [s for s in input().split()] ans = n while True: blnOk = True for d in str(ans): if d in dlist: blnOk = False if blnOk: print(ans) exit() else: ans += 1
n, k = list(map(int, input().split())) dlist = [s for s in input().split()] ans = n while True: blnOk = True for d in str(ans): if d in dlist: blnOk = False break if blnOk: print(ans) exit() else: ans += 1
false
7.142857
[ "+ break" ]
false
0.047678
0.044404
1.073725
[ "s327177014", "s990294694" ]