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
u263830634
p02839
python
s623955380
s129831038
265
119
29,844
22,136
Accepted
Accepted
55.09
import numpy as np H, W = list(map(int, input().split())) A = np.array([list(map(int, input().split())) for _ in range(H)]) B = np.array([list(map(int, input().split())) for _ in range(H)]) C = abs(A - B) # print (C) D = 80 * (H + W + 1) + 10 D2 = D * 2 dp = [[0] * (W) for _ in range(H)] dp[0][0] = 1 <...
H, W = list(map(int, input().split())) A = [tuple(map(int, input().split())) for _ in range(H)] B = [tuple(map(int, input().split())) for _ in range(H)] C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)] D = 80 * (H + W) + 1 D2 = D * 2 dp = [[0] * W for _ in range(H)] dp[0][0] |= 1 << (...
43
34
902
773
import numpy as np H, W = list(map(int, input().split())) A = np.array([list(map(int, input().split())) for _ in range(H)]) B = np.array([list(map(int, input().split())) for _ in range(H)]) C = abs(A - B) # print (C) D = 80 * (H + W + 1) + 10 D2 = D * 2 dp = [[0] * (W) for _ in range(H)] dp[0][0] = 1 << (D - int(C[0][...
H, W = list(map(int, input().split())) A = [tuple(map(int, input().split())) for _ in range(H)] B = [tuple(map(int, input().split())) for _ in range(H)] C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)] D = 80 * (H + W) + 1 D2 = D * 2 dp = [[0] * W for _ in range(H)] dp[0][0] |= 1 << (D + C[0][0]) dp[0...
false
20.930233
[ "-import numpy as np", "-", "-A = np.array([list(map(int, input().split())) for _ in range(H)])", "-B = np.array([list(map(int, input().split())) for _ in range(H)])", "-C = abs(A - B)", "-# print (C)", "-D = 80 * (H + W + 1) + 10", "+A = [tuple(map(int, input().split())) for _ in range(H)]", "+B = ...
false
0.261165
0.129771
2.012511
[ "s623955380", "s129831038" ]
u968166680
p03283
python
s939374857
s684396617
549
338
23,764
48,548
Accepted
Accepted
38.43
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): N, M, Q = list(map(int, readline().split())) A = [[0] * (N + 1) for _ in range(N + 1)] for _ in range(M): l, r = list(map(int, readl...
import sys read = sys.stdin.buffer.read def main(): N, M, Q, *LRPQ = list(map(int, read().split())) LR = LRPQ[: 2 * M] PQ = LRPQ[2 * M :] A = [[0] * (N + 1) for _ in range(N + 1)] for l, r in zip(LR[::2], LR[1::2]): A[l][r] += 1 for i in range(N): for j in...
33
28
757
638
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def main(): N, M, Q = list(map(int, readline().split())) A = [[0] * (N + 1) for _ in range(N + 1)] for _ in range(M): l, r = list(map(int, readline().split()))...
import sys read = sys.stdin.buffer.read def main(): N, M, Q, *LRPQ = list(map(int, read().split())) LR = LRPQ[: 2 * M] PQ = LRPQ[2 * M :] A = [[0] * (N + 1) for _ in range(N + 1)] for l, r in zip(LR[::2], LR[1::2]): A[l][r] += 1 for i in range(N): for j in range(N): ...
false
15.151515
[ "-read = sys.stdin.read", "-readline = sys.stdin.readline", "-readlines = sys.stdin.readlines", "-sys.setrecursionlimit(10**9)", "-INF = 1 << 60", "+read = sys.stdin.buffer.read", "- N, M, Q = list(map(int, readline().split()))", "+ N, M, Q, *LRPQ = list(map(int, read().split()))", "+ LR = ...
false
0.046397
0.03863
1.201078
[ "s939374857", "s684396617" ]
u847923740
p02682
python
s611634533
s651620998
63
56
61,552
61,812
Accepted
Accepted
11.11
a,b,c,k=list(map(int,input().split(" "))) if a >= k: print(k) elif b >= k-a: print(a) else: print((2*a+b-k))
a,b,c,k=list(map(int,input().split())) if a >= k: print(k) elif a+b < k: print((a-(k-a-b))) else: print(a)
7
10
112
130
a, b, c, k = list(map(int, input().split(" "))) if a >= k: print(k) elif b >= k - a: print(a) else: print((2 * a + b - k))
a, b, c, k = list(map(int, input().split())) if a >= k: print(k) elif a + b < k: print((a - (k - a - b))) else: print(a)
false
30
[ "-a, b, c, k = list(map(int, input().split(\" \")))", "+a, b, c, k = list(map(int, input().split()))", "-elif b >= k - a:", "+elif a + b < k:", "+ print((a - (k - a - b)))", "+else:", "-else:", "- print((2 * a + b - k))" ]
false
0.063226
0.041306
1.530657
[ "s611634533", "s651620998" ]
u067983636
p03634
python
s537909702
s407903135
1,867
1,246
109,720
67,036
Accepted
Accepted
33.26
import queue N = int(eval(input())) E = {n: set() for n in range(N)} for _ in range(N - 1): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 E[a].add((b, c)) E[b].add((a, c)) Q, K = list(map(int, input().split())) K -= 1 dist = [-1] * N already = set() que = queue.Queue() ...
import queue import sys input = sys.stdin.readline N = int(eval(input())) E = {n: set() for n in range(N)} for _ in range(N - 1): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 E[a].add((b, c)) E[b].add((a, c)) def m(): Q, K = list(map(int, input().split())) K -= ...
33
42
638
856
import queue N = int(eval(input())) E = {n: set() for n in range(N)} for _ in range(N - 1): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 E[a].add((b, c)) E[b].add((a, c)) Q, K = list(map(int, input().split())) K -= 1 dist = [-1] * N already = set() que = queue.Queue() que.put((K, 0)) whi...
import queue import sys input = sys.stdin.readline N = int(eval(input())) E = {n: set() for n in range(N)} for _ in range(N - 1): a, b, c = list(map(int, input().split())) a -= 1 b -= 1 E[a].add((b, c)) E[b].add((a, c)) def m(): Q, K = list(map(int, input().split())) K -= 1 dist = [-1...
false
21.428571
[ "+import sys", "+input = sys.stdin.readline", "-Q, K = list(map(int, input().split()))", "-K -= 1", "-dist = [-1] * N", "-already = set()", "-que = queue.Queue()", "-que.put((K, 0))", "-while not que.empty():", "- now, d = que.get()", "- already.add(now)", "- dist[now] = d", "- o...
false
0.04428
0.044298
0.9996
[ "s537909702", "s407903135" ]
u375616706
p03551
python
s247031212
s019210236
178
19
38,896
3,064
Accepted
Accepted
89.33
N, M = list(map(int, input().split())) total_time = M*1900+(N-M)*100 e = 0 err = 10**(-3) prev = -100 i = 0 while abs(prev-e) > err: prev = e e += (1-(1/2)**M)**i*(1/2)**M*total_time*(i+1) i += 1 def floor(x, y): return ((-x)//y)*(-1) print((int(floor(e, 1))))
N, M = list(map(int, input().split())) # 一回の思考にかかる時間 total_time = M*1900+(N-M)*100 e = 0 err = 10**(-3) # 許容誤差(答えが整数だから、いい感じに近くなったら打ち切って、四捨五入) prev = -1 i = 0 while abs(prev-e) > err: prev = e e += (1-(1/2)**M)**i*(1/2)**M*total_time*(i+1) i += 1 def floor(x, y): return ((-x)//y)*...
18
22
291
350
N, M = list(map(int, input().split())) total_time = M * 1900 + (N - M) * 100 e = 0 err = 10 ** (-3) prev = -100 i = 0 while abs(prev - e) > err: prev = e e += (1 - (1 / 2) ** M) ** i * (1 / 2) ** M * total_time * (i + 1) i += 1 def floor(x, y): return ((-x) // y) * (-1) print((int(floor(e, 1))))
N, M = list(map(int, input().split())) # 一回の思考にかかる時間 total_time = M * 1900 + (N - M) * 100 e = 0 err = 10 ** (-3) # 許容誤差(答えが整数だから、いい感じに近くなったら打ち切って、四捨五入) prev = -1 i = 0 while abs(prev - e) > err: prev = e e += (1 - (1 / 2) ** M) ** i * (1 / 2) ** M * total_time * (i + 1) i += 1 def floor(x, y): retur...
false
18.181818
[ "+# 一回の思考にかかる時間", "-err = 10 ** (-3)", "-prev = -100", "+err = 10 ** (-3) # 許容誤差(答えが整数だから、いい感じに近くなったら打ち切って、四捨五入)", "+prev = -1" ]
false
0.149505
0.046581
3.209586
[ "s247031212", "s019210236" ]
u644907318
p02882
python
s183413948
s396314397
181
163
38,384
38,640
Accepted
Accepted
9.94
import math a,b,x = list(map(int,input().split())) if x>=a*a*b/2: deg = math.degrees(math.atan(2*(a*a*b-x)/(a**3))) else: deg = math.degrees(math.atan(a*b*b/(2*x))) print(deg)
import math a,b,x = list(map(int,input().split())) if x>a**2*b/2: k = math.degrees(math.atan((2*a**2*b-2*x)/a**3)) else: k = math.degrees(math.asin(b/(4*x**2/a**2/b**2+b**2)**0.5)) print(k)
7
7
183
197
import math a, b, x = list(map(int, input().split())) if x >= a * a * b / 2: deg = math.degrees(math.atan(2 * (a * a * b - x) / (a**3))) else: deg = math.degrees(math.atan(a * b * b / (2 * x))) print(deg)
import math a, b, x = list(map(int, input().split())) if x > a**2 * b / 2: k = math.degrees(math.atan((2 * a**2 * b - 2 * x) / a**3)) else: k = math.degrees(math.asin(b / (4 * x**2 / a**2 / b**2 + b**2) ** 0.5)) print(k)
false
0
[ "-if x >= a * a * b / 2:", "- deg = math.degrees(math.atan(2 * (a * a * b - x) / (a**3)))", "+if x > a**2 * b / 2:", "+ k = math.degrees(math.atan((2 * a**2 * b - 2 * x) / a**3))", "- deg = math.degrees(math.atan(a * b * b / (2 * x)))", "-print(deg)", "+ k = math.degrees(math.asin(b / (4 * x...
false
0.037576
0.034703
1.082785
[ "s183413948", "s396314397" ]
u446774692
p03722
python
s823572815
s457122054
1,259
27
3,572
3,444
Accepted
Accepted
97.86
N,M = list(map(int,input().split())) abc = [] for _ in range(M): abc.append(list(map(int,input().split()))) cost = [-float('inf')]*N cost[0] = 0 for i in range(N): update = False for a,b,c in abc: a,b = a-1,b-1 if cost[a] != -(10**10)*N: if cost[b] < cost[a] + c: ...
N,M = list(map(int,input().split())) abc = [] for _ in range(M): abc.append(list(map(int,input().split()))) cost = [-float('inf')]*N cost[0] = 0 for i in range(2): for a,b,c in abc: a,b = a-1,b-1 cost[b] = max(cost[b], cost[a] + c) if i == 0: ans = cost[N-1] els...
26
23
562
403
N, M = list(map(int, input().split())) abc = [] for _ in range(M): abc.append(list(map(int, input().split()))) cost = [-float("inf")] * N cost[0] = 0 for i in range(N): update = False for a, b, c in abc: a, b = a - 1, b - 1 if cost[a] != -(10**10) * N: if cost[b] < cost[a] + c: ...
N, M = list(map(int, input().split())) abc = [] for _ in range(M): abc.append(list(map(int, input().split()))) cost = [-float("inf")] * N cost[0] = 0 for i in range(2): for a, b, c in abc: a, b = a - 1, b - 1 cost[b] = max(cost[b], cost[a] + c) if i == 0: ans = cost[N - 1] else: ...
false
11.538462
[ "-for i in range(N):", "- update = False", "+for i in range(2):", "- if cost[a] != -(10**10) * N:", "- if cost[b] < cost[a] + c:", "- cost[b] = cost[a] + c", "- update = True", "+ cost[b] = max(cost[b], cost[a] + c)", "+ ans = cost[N -...
false
0.055024
0.037094
1.483358
[ "s823572815", "s457122054" ]
u203843959
p03148
python
s000229899
s513277796
782
562
27,112
27,112
Accepted
Accepted
28.13
from collections import defaultdict import heapq N,K=list(map(int,input().split())) hq=[] tset_all=set() for i in range(N): t,d=list(map(int,input().split())) heapq.heappush(hq,(-d,t)) tset_all.add(t) #print(heapq) hq_K=[] dsum=0 tdic=defaultdict(int) for i in range(K): md,t=heapq.heappop(hq) ...
from collections import defaultdict N,K=list(map(int,input().split())) dtlist=[] tset_all=set() for i in range(N): t,d=list(map(int,input().split())) dtlist.append((d,t)) tset_all.add(t) dtlist.sort() #print(heapq) dtlist_Krev=[] dsum=0 tdic=defaultdict(int) for i in range(K): d,t=dtlist.pop()...
46
47
892
920
from collections import defaultdict import heapq N, K = list(map(int, input().split())) hq = [] tset_all = set() for i in range(N): t, d = list(map(int, input().split())) heapq.heappush(hq, (-d, t)) tset_all.add(t) # print(heapq) hq_K = [] dsum = 0 tdic = defaultdict(int) for i in range(K): md, t = hea...
from collections import defaultdict N, K = list(map(int, input().split())) dtlist = [] tset_all = set() for i in range(N): t, d = list(map(int, input().split())) dtlist.append((d, t)) tset_all.add(t) dtlist.sort() # print(heapq) dtlist_Krev = [] dsum = 0 tdic = defaultdict(int) for i in range(K): d, t ...
false
2.12766
[ "-import heapq", "-hq = []", "+dtlist = []", "- heapq.heappush(hq, (-d, t))", "+ dtlist.append((d, t))", "+dtlist.sort()", "-hq_K = []", "+dtlist_Krev = []", "- md, t = heapq.heappop(hq)", "- heapq.heappush(hq_K, ((-md, t)))", "- dsum -= md", "+ d, t = dtlist.pop()", "+ ...
false
0.047447
0.090974
0.521547
[ "s000229899", "s513277796" ]
u256678932
p02414
python
s799088181
s526939042
510
280
8,900
6,880
Accepted
Accepted
45.1
n, m, l = list(map(int, input().split(' '))) A = [] for i in range(n): A.append(list(map(int, input().split(' ')))) B = [] for i in range(m): B.append(list(map(int, input().split(' ')))) C = [[0 for i in range(l)] for j in range(n)] for i in range(n): for j in range(l): for k in ...
def main(): n, m, l = [int(x) for x in input().split()] a = readMatrix(n, m) b = readMatrix(m, l) printMatrix(multiplyAB(a, b)) def readMatrix(r, c): m = [] for _ in range(r): m.append([int(x) for x in input().split()]) return m def multiplyAB(a, b): n = len(...
20
36
422
689
n, m, l = list(map(int, input().split(" "))) A = [] for i in range(n): A.append(list(map(int, input().split(" ")))) B = [] for i in range(m): B.append(list(map(int, input().split(" ")))) C = [[0 for i in range(l)] for j in range(n)] for i in range(n): for j in range(l): for k in range(m): ...
def main(): n, m, l = [int(x) for x in input().split()] a = readMatrix(n, m) b = readMatrix(m, l) printMatrix(multiplyAB(a, b)) def readMatrix(r, c): m = [] for _ in range(r): m.append([int(x) for x in input().split()]) return m def multiplyAB(a, b): n = len(a) m = len(b)...
false
44.444444
[ "-n, m, l = list(map(int, input().split(\" \")))", "-A = []", "-for i in range(n):", "- A.append(list(map(int, input().split(\" \"))))", "-B = []", "-for i in range(m):", "- B.append(list(map(int, input().split(\" \"))))", "-C = [[0 for i in range(l)] for j in range(n)]", "-for i in range(n):"...
false
0.035465
0.035475
0.999702
[ "s799088181", "s526939042" ]
u316386814
p03088
python
s547440767
s151027385
54
49
3,316
3,316
Accepted
Accepted
9.26
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().spl...
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().spl...
36
36
1,052
1,056
import sys sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin....
import sys sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin....
false
0
[ "- dp[\"TTT\"] += 1", "+ dp[\"000\"] += 1", "- for p1, p2, p3, cur in product(\"ACGT\", repeat=4):", "- if p2 + p1 + cur in [\"AGC\", \"GAC\", \"ACG\"]:", "- continue", "- if p3 + p1 + cur == \"AGC\":", "- continue", "- if p3 ...
false
0.052594
0.047094
1.116778
[ "s547440767", "s151027385" ]
u637175065
p03061
python
s473180908
s821091985
1,051
74
85,612
16,860
Accepted
Accepted
92.96
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(int, s...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(int, s...
81
124
2,083
2,923
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools import random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI...
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools import random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI...
false
34.677419
[ "- a = sorted(LI())", "+ ac = collections.Counter(LI())", "+ if n == 2:", "+ return max(ac.keys())", "+ a = []", "+ aa = []", "+ for k, v in ac.items():", "+ if v > 1:", "+ aa.append(k)", "+ else:", "+ a.append(k)", "+ tr = -1", ...
false
0.096483
0.045872
2.103316
[ "s473180908", "s821091985" ]
u800396927
p03078
python
s328313275
s063731095
511
165
223,256
79,696
Accepted
Accepted
67.71
X,Y,Z,K = list(map(int,input().split())) K = min(K,X*Y*Z) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort(reverse = True) B.sort(reverse = True) C.sort(reverse = True) sum2 = [] for a in A: for b in B: sum2.append(a+b) sum2.sort(rev...
import heapq X,Y,Z,K = list(map(int,input().split())) K = min(K,X*Y*Z) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort(reverse = True) B.sort(reverse = True) C.sort(reverse = True) set_ = set() hq = [(-(A[0]+B[0]+C[0]),0,0,0)] heapq.heapify(...
22
28
487
810
X, Y, Z, K = list(map(int, input().split())) K = min(K, X * Y * Z) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) sum2 = [] for a in A: for b in B: sum2.append(a + b) sum2.sort(reverse...
import heapq X, Y, Z, K = list(map(int, input().split())) K = min(K, X * Y * Z) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) set_ = set() hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)] heapq.heapify(h...
false
21.428571
[ "+import heapq", "+", "-sum2 = []", "-for a in A:", "- for b in B:", "- sum2.append(a + b)", "-sum2.sort(reverse=True)", "-sum2 = sum2[:K]", "-idx = 0", "-sum3 = []", "-for c in C:", "- for s in sum2:", "- sum3.append(c + s)", "-sum3.sort(reverse=True)", "-for i in ra...
false
0.035629
0.036937
0.964606
[ "s328313275", "s063731095" ]
u844005364
p02838
python
s891578153
s537718906
1,558
874
138,552
137,400
Accepted
Accepted
43.9
n = int(eval(input())) arr = list(map(int, input().split())) mod = 10 ** 9 + 7 res = 0 for d in range(60): one = sum(x % 2 == 1 for x in arr) res += one * (n - one) * 2 ** d res %= mod arr = [x // 2 for x in arr] print(res)
n = int(eval(input())) arr = list(map(int, input().split())) mod = 10 ** 9 + 7 res = 0 for d in range(60): one = sum(x & 1 for x in arr) res += one * (n - one) * (1 << d) res %= mod arr = [x >> 1 for x in arr] print(res)
13
13
249
246
n = int(eval(input())) arr = list(map(int, input().split())) mod = 10**9 + 7 res = 0 for d in range(60): one = sum(x % 2 == 1 for x in arr) res += one * (n - one) * 2**d res %= mod arr = [x // 2 for x in arr] print(res)
n = int(eval(input())) arr = list(map(int, input().split())) mod = 10**9 + 7 res = 0 for d in range(60): one = sum(x & 1 for x in arr) res += one * (n - one) * (1 << d) res %= mod arr = [x >> 1 for x in arr] print(res)
false
0
[ "- one = sum(x % 2 == 1 for x in arr)", "- res += one * (n - one) * 2**d", "+ one = sum(x & 1 for x in arr)", "+ res += one * (n - one) * (1 << d)", "- arr = [x // 2 for x in arr]", "+ arr = [x >> 1 for x in arr]" ]
false
0.04317
0.038393
1.124418
[ "s891578153", "s537718906" ]
u936985471
p03476
python
s964568984
s427908669
862
180
4,980
12,540
Accepted
Accepted
79.12
Q=int(eval(input())) fact=[True]*(10**5+1) fact[0]=False fact[1]=False num=[0]*(10**5+1) cur=0 for i in range(len(fact)): if fact[i]: for j in range(i*2,len(fact),i): fact[j]=False if fact[(i+1)//2]: cur+=1 num[i]=cur for i in range(Q): l,r=list(map(int,input().split(...
import sys readline = sys.stdin.readline Q = int(readline()) # 10 ** 5までの「2017に似た数」を全て求めておく fact = [True] * (10 ** 5 + 1) fact[0] = False fact[1] = False like2017 = [0] * (10 ** 5 + 1) for i in range(2, len(fact)): if fact[i]: if i % 2 == 1 and fact[(i + 1) // 2]: like2017[i] = 1 for j...
19
24
338
553
Q = int(eval(input())) fact = [True] * (10**5 + 1) fact[0] = False fact[1] = False num = [0] * (10**5 + 1) cur = 0 for i in range(len(fact)): if fact[i]: for j in range(i * 2, len(fact), i): fact[j] = False if fact[(i + 1) // 2]: cur += 1 num[i] = cur for i in range(Q): ...
import sys readline = sys.stdin.readline Q = int(readline()) # 10 ** 5までの「2017に似た数」を全て求めておく fact = [True] * (10**5 + 1) fact[0] = False fact[1] = False like2017 = [0] * (10**5 + 1) for i in range(2, len(fact)): if fact[i]: if i % 2 == 1 and fact[(i + 1) // 2]: like2017[i] = 1 for j in r...
false
20.833333
[ "-Q = int(eval(input()))", "+import sys", "+", "+readline = sys.stdin.readline", "+Q = int(readline())", "+# 10 ** 5までの「2017に似た数」を全て求めておく", "-num = [0] * (10**5 + 1)", "-cur = 0", "-for i in range(len(fact)):", "+like2017 = [0] * (10**5 + 1)", "+for i in range(2, len(fact)):", "+ if i %...
false
0.149827
0.127939
1.171085
[ "s964568984", "s427908669" ]
u046187684
p02996
python
s111514804
s538713716
701
565
54,024
51,332
Accepted
Accepted
19.4
def solve(string): n, *ab = list(map(int, string.split())) ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: (x[1], x[0])) past = 0 for a, b in ab: past += a if past > b: return "No" return "Yes" if __name__ == '__main__': n = int(eval(input())) print...
def solve(string): n, *ab = list(map(int, string.split())) ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1]) past = 0 for a, b in ab: past += a if past > b: return "No" return "Yes" if __name__ == '__main__': n = int(eval(input())) print((solve(...
14
14
375
367
def solve(string): n, *ab = list(map(int, string.split())) ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: (x[1], x[0])) past = 0 for a, b in ab: past += a if past > b: return "No" return "Yes" if __name__ == "__main__": n = int(eval(input())) print((solve("{}\n...
def solve(string): n, *ab = list(map(int, string.split())) ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1]) past = 0 for a, b in ab: past += a if past > b: return "No" return "Yes" if __name__ == "__main__": n = int(eval(input())) print((solve("{}\n".format...
false
0
[ "- ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: (x[1], x[0]))", "+ ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1])" ]
false
0.039214
0.037271
1.052142
[ "s111514804", "s538713716" ]
u761529120
p03074
python
s245895031
s983842621
202
75
48,608
86,156
Accepted
Accepted
62.87
from itertools import accumulate def length(S): cnt = 1 A = [] for i in range(len(S)-1): if S[i] == S[i+1]: cnt += 1 else: A.append(cnt) cnt = 1 else: A.append(cnt) return A def main(): N, K = list(map(int, input().s...
from itertools import accumulate def runlength(S): cnt = 1 A = [] for i in range(len(S)-1): if S[i] == S[i+1]: cnt += 1 else: A.append(cnt) cnt = 1 else: A.append(cnt) return A def main(): N, K = list(map(int, inpu...
44
49
947
872
from itertools import accumulate def length(S): cnt = 1 A = [] for i in range(len(S) - 1): if S[i] == S[i + 1]: cnt += 1 else: A.append(cnt) cnt = 1 else: A.append(cnt) return A def main(): N, K = list(map(int, input().split())) ...
from itertools import accumulate def runlength(S): cnt = 1 A = [] for i in range(len(S) - 1): if S[i] == S[i + 1]: cnt += 1 else: A.append(cnt) cnt = 1 else: A.append(cnt) return A def main(): N, K = list(map(int, input().split())) ...
false
10.204082
[ "-def length(S):", "+def runlength(S):", "- lens = length(S)", "- A = [0] + list(accumulate(lens))", "+ T = []", "+ prev = \"1\"", "+ cnt = 0", "+ for c in S:", "+ if prev == c:", "+ cnt += 1", "+ else:", "+ T.append(cnt)", "+ ...
false
0.042913
0.046611
0.920647
[ "s245895031", "s983842621" ]
u197300260
p03254
python
s400734176
s342560973
24
18
3,696
3,064
Accepted
Accepted
25
# _*_ coding:utf-8 _*_ # Atcoder_Beginners_Contest- # Atcoder_Grand_Contest- # TODO https://atcoder.jp/contests/abc/tasks/abc_ import time from contextlib import contextmanager # from time import sleep @contextmanager def timer(title): t0 = time.time() yield print(("{} - done in {:.0f}s".format(title,t...
# _*_ coding:utf-8 _*_ # Atcoder_Grand_Contest027-a # https://atcoder.jp/contests/agc027/tasks/agc027_a def countJoyChild(haveCookie,joyMeterList): joyMeterList.sort() childsCount = len(joyMeterList) sendCookieRangeMax = list(range(0,childsCount,+1)) sendCookieChilds = 0 for i in sendCookieRangeMax : ...
37
27
1,013
753
# _*_ coding:utf-8 _*_ # Atcoder_Beginners_Contest- # Atcoder_Grand_Contest- # TODO https://atcoder.jp/contests/abc/tasks/abc_ import time from contextlib import contextmanager # from time import sleep @contextmanager def timer(title): t0 = time.time() yield print(("{} - done in {:.0f}s".format(title, t...
# _*_ coding:utf-8 _*_ # Atcoder_Grand_Contest027-a # https://atcoder.jp/contests/agc027/tasks/agc027_a def countJoyChild(haveCookie, joyMeterList): joyMeterList.sort() childsCount = len(joyMeterList) sendCookieRangeMax = list(range(0, childsCount, +1)) sendCookieChilds = 0 for i in sendCookieRang...
false
27.027027
[ "-# Atcoder_Beginners_Contest-", "-# Atcoder_Grand_Contest-", "-# TODO https://atcoder.jp/contests/abc/tasks/abc_", "-import time", "-from contextlib import contextmanager", "-", "-# from time import sleep", "-@contextmanager", "-def timer(title):", "- t0 = time.time()", "- yield", "-...
false
0.03877
0.038105
1.017435
[ "s400734176", "s342560973" ]
u287132915
p02665
python
s703085159
s930806016
120
87
22,148
90,164
Accepted
Accepted
27.5
n = int(eval(input())) a = list(map(int, input().split())) sita_maxi = [0 for i in range(n+1)] sita_maxi[n] = a[n] for i in range(n-1, -1, -1): sita_maxi[i] = sita_maxi[i+1] + a[i] if a[0] > 1: print((-1)) exit() lst = [1] for i in range(1, n+1): lst.append(min((lst[i-1]-a[i-1])*2, sita...
n = int(eval(input())) a = list(map(int, input().split())) if a[0] != 0: if n == 0 and a[0] == 1: print((1)) else: print((-1)) exit() ruiseki = a[::-1] for i in range(1, n+1): ruiseki[i] += ruiseki[i-1] ruiseki = ruiseki[::-1] node = [1] komoti = [1] for i in range(1,...
20
27
400
513
n = int(eval(input())) a = list(map(int, input().split())) sita_maxi = [0 for i in range(n + 1)] sita_maxi[n] = a[n] for i in range(n - 1, -1, -1): sita_maxi[i] = sita_maxi[i + 1] + a[i] if a[0] > 1: print((-1)) exit() lst = [1] for i in range(1, n + 1): lst.append(min((lst[i - 1] - a[i - 1]) * 2, sita_...
n = int(eval(input())) a = list(map(int, input().split())) if a[0] != 0: if n == 0 and a[0] == 1: print((1)) else: print((-1)) exit() ruiseki = a[::-1] for i in range(1, n + 1): ruiseki[i] += ruiseki[i - 1] ruiseki = ruiseki[::-1] node = [1] komoti = [1] for i in range(1, n + 1): ai ...
false
25.925926
[ "-sita_maxi = [0 for i in range(n + 1)]", "-sita_maxi[n] = a[n]", "-for i in range(n - 1, -1, -1):", "- sita_maxi[i] = sita_maxi[i + 1] + a[i]", "-if a[0] > 1:", "- print((-1))", "+if a[0] != 0:", "+ if n == 0 and a[0] == 1:", "+ print((1))", "+ else:", "+ print((-1))",...
false
0.032327
0.097867
0.330316
[ "s703085159", "s930806016" ]
u964904181
p03389
python
s605274434
s988513557
113
28
27,204
9,000
Accepted
Accepted
75.22
import numpy as np # A, B, C = [11, 12, 15] A, B, C = list(map(int, input().split())) vals = np.array([A, B, C]) vals = np.sort(vals) sumval = vals.sum() cn = vals[-1] + np.sum(vals[:2]) % 2 n = (3 * cn - sumval) // 2 print(n)
lst = list(map(int, input().split())) mval = max(lst) sval = sum(lst) cn = mval + (sval-mval) % 2 n = (cn * 3 - sval) // 2 print(n)
19
8
255
141
import numpy as np # A, B, C = [11, 12, 15] A, B, C = list(map(int, input().split())) vals = np.array([A, B, C]) vals = np.sort(vals) sumval = vals.sum() cn = vals[-1] + np.sum(vals[:2]) % 2 n = (3 * cn - sumval) // 2 print(n)
lst = list(map(int, input().split())) mval = max(lst) sval = sum(lst) cn = mval + (sval - mval) % 2 n = (cn * 3 - sval) // 2 print(n)
false
57.894737
[ "-import numpy as np", "-", "-# A, B, C = [11, 12, 15]", "-A, B, C = list(map(int, input().split()))", "-vals = np.array([A, B, C])", "-vals = np.sort(vals)", "-sumval = vals.sum()", "-cn = vals[-1] + np.sum(vals[:2]) % 2", "-n = (3 * cn - sumval) // 2", "+lst = list(map(int, input().split()))", ...
false
0.167443
0.041582
4.026805
[ "s605274434", "s988513557" ]
u775681539
p02720
python
s429157462
s279989030
135
72
17,480
23,796
Accepted
Accepted
46.67
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque cnt = 0 def main(): K = int(readline()) cnd = [i for i in range(1, 10)] dq = deque() for i in range(1, 10): dq.append(i) cnt = 0...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): K = int(readline()) dq = [] for i in range(1, 10): dq.append(i) for i in range(K): v = dq[i] r = v%10 if r == 9: dq.app...
41
27
955
625
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque cnt = 0 def main(): K = int(readline()) cnd = [i for i in range(1, 10)] dq = deque() for i in range(1, 10): dq.append(i) cnt = 0 while len...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(): K = int(readline()) dq = [] for i in range(1, 10): dq.append(i) for i in range(K): v = dq[i] r = v % 10 if r == 9: dq.append(v * ...
false
34.146341
[ "-from collections import deque", "-", "-cnt = 0", "- cnd = [i for i in range(1, 10)]", "- dq = deque()", "+ dq = []", "- cnt = 0", "- while len(dq) > 0:", "- cnt += 1", "- x = dq.popleft()", "- v = x % 10", "- if v == 0:", "- for i in (0...
false
0.108946
0.052689
2.067728
[ "s429157462", "s279989030" ]
u888092736
p03355
python
s404249095
s124415889
45
40
10,496
10,188
Accepted
Accepted
11.11
S = eval(input()) N = len(S) K = int(eval(input())) ans = set() for i in range(N): for j in range(i + 1, i + K + 1): ans.add(S[i:j]) print((sorted(list(ans))[K - 1]))
S = eval(input()) N = len(S) K = int(eval(input())) ans = set() for i in range(1, K + 1): for j in range(N - i + 1): ans.add(S[j : j + i]) print((sorted(ans)[K - 1]))
8
9
172
174
S = eval(input()) N = len(S) K = int(eval(input())) ans = set() for i in range(N): for j in range(i + 1, i + K + 1): ans.add(S[i:j]) print((sorted(list(ans))[K - 1]))
S = eval(input()) N = len(S) K = int(eval(input())) ans = set() for i in range(1, K + 1): for j in range(N - i + 1): ans.add(S[j : j + i]) print((sorted(ans)[K - 1]))
false
11.111111
[ "-for i in range(N):", "- for j in range(i + 1, i + K + 1):", "- ans.add(S[i:j])", "-print((sorted(list(ans))[K - 1]))", "+for i in range(1, K + 1):", "+ for j in range(N - i + 1):", "+ ans.add(S[j : j + i])", "+print((sorted(ans)[K - 1]))" ]
false
0.121682
0.045275
2.687619
[ "s404249095", "s124415889" ]
u452764412
p00483
python
s575313420
s935276238
3,240
2,030
266,268
19,892
Accepted
Accepted
37.35
M, N = list(map(int, input().split())) K = eval(input()) D = {} for i in range(M+1): D[i, 0] = 0, 0 for j in range(N+1): D[0, j] = 0, 0 for i in range(1, M+1): a = input() for j in range(1, N+1): if a[j-1] == 'J': D[i, j] = (D[i-1, j][0] + D[i, j-1][0] - D[i-1, j-1][...
from array import array M, N = list(map(int, input().split())) K = eval(input()) D0 = [array('l', [0]) * (N+1) for _ in range(M+1)] D1 = [array('l', [0]) * (N+1) for _ in range(M+1)] for i in range(1, M+1): a = input() for j in range(1, N+1): D0[i][j] = D0[i-1][j] + D0[i][j-1] - D0[i-1][j-...
29
20
993
674
M, N = list(map(int, input().split())) K = eval(input()) D = {} for i in range(M + 1): D[i, 0] = 0, 0 for j in range(N + 1): D[0, j] = 0, 0 for i in range(1, M + 1): a = input() for j in range(1, N + 1): if a[j - 1] == "J": D[i, j] = ( D[i - 1, j][0] + D[i, j - 1][0] ...
from array import array M, N = list(map(int, input().split())) K = eval(input()) D0 = [array("l", [0]) * (N + 1) for _ in range(M + 1)] D1 = [array("l", [0]) * (N + 1) for _ in range(M + 1)] for i in range(1, M + 1): a = input() for j in range(1, N + 1): D0[i][j] = D0[i - 1][j] + D0[i][j - 1] - D0[i - ...
false
31.034483
[ "+from array import array", "+", "-D = {}", "-for i in range(M + 1):", "- D[i, 0] = 0, 0", "-for j in range(N + 1):", "- D[0, j] = 0, 0", "+D0 = [array(\"l\", [0]) * (N + 1) for _ in range(M + 1)]", "+D1 = [array(\"l\", [0]) * (N + 1) for _ in range(M + 1)]", "- if a[j - 1] == \"J\":"...
false
0.037625
0.115761
0.325021
[ "s575313420", "s935276238" ]
u299869545
p02686
python
s220085904
s660545643
1,411
1,304
284,560
203,756
Accepted
Accepted
7.58
n = int(eval(input())) s = [0] * n inc = [[] for _ in range(1100000)] zeros = [] dec = [[] for _ in range(1100000)] for i in range(n): s[i] = eval(input()) start = 0 minimum = 0 now = 0 for c in s[i]: if c == '(':now += 1 else: now -= 1 minimum = min(minimum, n...
n = int(eval(input())) s = [0] * n inc = [] zeros = [] dec = [] for i in range(n): s[i] = eval(input()) start = 0 minimum = 0 now = 0 for c in s[i]: if c == '(':now += 1 else: now -= 1 minimum = min(minimum, now) end = now if end == 0: ...
56
58
1,209
1,073
n = int(eval(input())) s = [0] * n inc = [[] for _ in range(1100000)] zeros = [] dec = [[] for _ in range(1100000)] for i in range(n): s[i] = eval(input()) start = 0 minimum = 0 now = 0 for c in s[i]: if c == "(": now += 1 else: now -= 1 minimum = min(...
n = int(eval(input())) s = [0] * n inc = [] zeros = [] dec = [] for i in range(n): s[i] = eval(input()) start = 0 minimum = 0 now = 0 for c in s[i]: if c == "(": now += 1 else: now -= 1 minimum = min(minimum, now) end = now if end == 0: ...
false
3.448276
[ "-inc = [[] for _ in range(1100000)]", "+inc = []", "-dec = [[] for _ in range(1100000)]", "+dec = []", "- zeros.append(i)", "+ zeros.append((minimum, i))", "- inc[minimum].append(i)", "+ inc.append((minimum, i))", "- dec[minimum].append(i)", "+ dec.append...
false
1.227116
0.0434
28.274634
[ "s220085904", "s660545643" ]
u755585099
p03160
python
s264696256
s723031508
125
106
14,056
13,928
Accepted
Accepted
15.2
n = int(eval(input())) hs = tuple(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): d1 = a + abs(hs[i] - hs[i-2]) d2 = b + abs(hs[i] - hs[i-1]) a, b = b, min(d1, d2) print(b)
n = int(eval(input())) hs = list(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): d1 = a + abs(hs[i] - hs[i-2]) d2 = b + abs(hs[i] - hs[i-1]) a, b = b, d1 if d1 <= d2 else d2 print(b)
11
11
215
225
n = int(eval(input())) hs = tuple(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): d1 = a + abs(hs[i] - hs[i - 2]) d2 = b + abs(hs[i] - hs[i - 1]) a, b = b, min(d1, d2) print(b)
n = int(eval(input())) hs = list(map(int, input().split())) a, b = 0, abs(hs[1] - hs[0]) for i in range(2, n): d1 = a + abs(hs[i] - hs[i - 2]) d2 = b + abs(hs[i] - hs[i - 1]) a, b = b, d1 if d1 <= d2 else d2 print(b)
false
0
[ "-hs = tuple(map(int, input().split()))", "+hs = list(map(int, input().split()))", "- a, b = b, min(d1, d2)", "+ a, b = b, d1 if d1 <= d2 else d2" ]
false
0.046973
0.082162
0.571707
[ "s264696256", "s723031508" ]
u097319437
p02595
python
s154355545
s395842015
348
294
107,676
75,080
Accepted
Accepted
15.52
def resolve(): N, D = list(map(int, input().split())) P = [list(map(int, input().split())) for x in range(N)] cnt = 0 for p in P: d = (p[0] ** 2 + p[1] ** 2) ** 0.5 if d <= D: cnt += 1 print(cnt) resolve()
def resolve(): N, D = list(map(int, input().split())) cnt = 0 for n in range(N): x, y = list(map(int, input().split())) d = (x ** 2 + y ** 2) ** 0.5 if d <= D: cnt += 1 print(cnt) resolve()
12
12
260
242
def resolve(): N, D = list(map(int, input().split())) P = [list(map(int, input().split())) for x in range(N)] cnt = 0 for p in P: d = (p[0] ** 2 + p[1] ** 2) ** 0.5 if d <= D: cnt += 1 print(cnt) resolve()
def resolve(): N, D = list(map(int, input().split())) cnt = 0 for n in range(N): x, y = list(map(int, input().split())) d = (x**2 + y**2) ** 0.5 if d <= D: cnt += 1 print(cnt) resolve()
false
0
[ "- P = [list(map(int, input().split())) for x in range(N)]", "- for p in P:", "- d = (p[0] ** 2 + p[1] ** 2) ** 0.5", "+ for n in range(N):", "+ x, y = list(map(int, input().split()))", "+ d = (x**2 + y**2) ** 0.5" ]
false
0.165726
0.127572
1.299077
[ "s154355545", "s395842015" ]
u620084012
p02861
python
s462612754
s572059818
211
17
42,476
3,060
Accepted
Accepted
91.94
import itertools, math N = int(eval(input())) d = [list(map(int,input().split())) for k in range(N)] ans = 0 for e in itertools.permutations(d): temp = 0 for k in range(len(e)-1): temp += math.sqrt((e[k][0] - e[k+1][0])**2 + (e[k][1] - e[k+1][1])**2) ans += temp f = 1 for k in range(2,N+1)...
N = int(eval(input())) C = [] for _ in range(N): C.append(list(map(int,input().split()))) s = 0 for k in range(N-1): for l in range(k+1,N): s += ((C[k][0]-C[l][0])**2 + (C[k][1]-C[l][1])**2)**(1/2) print((s/(N/2)))
14
10
344
233
import itertools, math N = int(eval(input())) d = [list(map(int, input().split())) for k in range(N)] ans = 0 for e in itertools.permutations(d): temp = 0 for k in range(len(e) - 1): temp += math.sqrt((e[k][0] - e[k + 1][0]) ** 2 + (e[k][1] - e[k + 1][1]) ** 2) ans += temp f = 1 for k in range(2, N...
N = int(eval(input())) C = [] for _ in range(N): C.append(list(map(int, input().split()))) s = 0 for k in range(N - 1): for l in range(k + 1, N): s += ((C[k][0] - C[l][0]) ** 2 + (C[k][1] - C[l][1]) ** 2) ** (1 / 2) print((s / (N / 2)))
false
28.571429
[ "-import itertools, math", "-", "-d = [list(map(int, input().split())) for k in range(N)]", "-ans = 0", "-for e in itertools.permutations(d):", "- temp = 0", "- for k in range(len(e) - 1):", "- temp += math.sqrt((e[k][0] - e[k + 1][0]) ** 2 + (e[k][1] - e[k + 1][1]) ** 2)", "- ans +=...
false
0.120097
0.043535
2.758591
[ "s462612754", "s572059818" ]
u371132735
p03730
python
s524856046
s479070604
26
24
9,092
9,164
Accepted
Accepted
7.69
A, B, C = list(map(int, input().split())) ans = 'NO' for i in range(1, 1000): if A*i % B == C: ans = 'YES' print(ans)
A, B, C = list(map(int, input().split())) ans = 'NO' for i in range(1, 1000): if A*i % B == C: ans = 'YES' break print(ans)
6
8
129
146
A, B, C = list(map(int, input().split())) ans = "NO" for i in range(1, 1000): if A * i % B == C: ans = "YES" print(ans)
A, B, C = list(map(int, input().split())) ans = "NO" for i in range(1, 1000): if A * i % B == C: ans = "YES" break print(ans)
false
25
[ "+ break" ]
false
0.036017
0.03652
0.986215
[ "s524856046", "s479070604" ]
u532966492
p03078
python
s606904921
s916010082
1,832
133
112,348
8,708
Accepted
Accepted
92.74
X,Y,Z,K = list(map(int,input().split())) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ans = [] for j in range(X): if j+1 > K: break for k in range(Y): if j*k...
X,Y,Z,K=list(map(int,input().split())) A=list(map(int,input().split())) B=list(map(int,input().split())) C=list(map(int,input().split())) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ans=[] for i in range(X): j=0 while((i+1)*(j+1)<K+1 and j<Y): k=0 while((i+1)*(j+1)*(k+1)<K+1 and k<Z...
25
19
572
427
X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ans = [] for j in range(X): if j + 1 > K: break for k in range(Y): if j * k + 1 ...
X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort(reverse=True) B.sort(reverse=True) C.sort(reverse=True) ans = [] for i in range(X): j = 0 while (i + 1) * (j + 1) < K + 1 and j < Y: k = 0 ...
false
24
[ "-for j in range(X):", "- if j + 1 > K:", "- break", "- for k in range(Y):", "- if j * k + 1 > K:", "- break", "- for l in range(Z):", "- if j * k * l + 1 <= K:", "- ans.append(A[j] + B[k] + C[l])", "- else:", "- ...
false
0.078259
0.037068
2.111203
[ "s606904921", "s916010082" ]
u077291787
p03434
python
s016115351
s159632552
19
17
2,940
3,060
Accepted
Accepted
10.53
# ABC088B - Card Game for Two n = int(eval(input())) lst = sorted(list(map(int, input().rstrip().split())), reverse=True) total = 0 for i in range(n): if i % 2 == 0: total += lst[i] else: total -= lst[i] print(total)
# ABC088B - Card Game for Two import sys input = sys.stdin.readline n = int(eval(input())) lst = sorted(list(map(int, input().rstrip().split())), reverse=True) total = 0 for i in range(n): if i % 2 == 0: total += lst[i] else: total -= lst[i] print(total)
10
13
243
285
# ABC088B - Card Game for Two n = int(eval(input())) lst = sorted(list(map(int, input().rstrip().split())), reverse=True) total = 0 for i in range(n): if i % 2 == 0: total += lst[i] else: total -= lst[i] print(total)
# ABC088B - Card Game for Two import sys input = sys.stdin.readline n = int(eval(input())) lst = sorted(list(map(int, input().rstrip().split())), reverse=True) total = 0 for i in range(n): if i % 2 == 0: total += lst[i] else: total -= lst[i] print(total)
false
23.076923
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.047178
0.044318
1.064513
[ "s016115351", "s159632552" ]
u218843509
p02991
python
s756244206
s970095057
1,035
953
62,340
60,036
Accepted
Accepted
7.92
import heapq, sys def input(): return sys.stdin.readline()[:-1] class DijkstraList(): #隣接リスト版 #同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ def __init__(self, adj, start): self.list = adj self.start = start self.size = len(adj) def solve(self): self.dist = [10**30 for _ in range(self.size)] self.dist[...
import heapq, sys def input(): return sys.stdin.readline()[:-1] class DijkstraList(): #隣接リスト版 #同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ def __init__(self, adj, start): self.list = adj self.start = start self.size = len(adj) def solve(self): self.dist = [10**30 for _ in range(self.size)] self.dist[...
56
48
1,346
1,118
import heapq, sys def input(): return sys.stdin.readline()[:-1] class DijkstraList: # 隣接リスト版 # 同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ def __init__(self, adj, start): self.list = adj self.start = start self.size = len(adj) def solve(self): self.dist = [10**30 for _ in ra...
import heapq, sys def input(): return sys.stdin.readline()[:-1] class DijkstraList: # 隣接リスト版 # 同一頂点の複数回探索を防ぐため訪問した頂点数を変数cntで持つ def __init__(self, adj, start): self.list = adj self.start = start self.size = len(adj) def solve(self): self.dist = [10**30 for _ in ra...
false
14.285714
[ "- self.prev = [-1 for _ in range(self.size)]", "- self.prev[v] = u", "-", "- def path(self, goal):", "- self.path = [goal]", "- while self.path[-1] != self.start:", "- self.path.append(self.prev[self.path[-1]])", "- return self.path[::-1]" ...
false
0.042965
0.144886
0.296544
[ "s756244206", "s970095057" ]
u714378447
p03353
python
s915415042
s856750460
40
36
5,176
5,052
Accepted
Accepted
10
from heapq import heappush, heappop s = eval(input()) K = int(eval(input())) N = len(s) heap = [] cnt = 0 for i in range(N): for j in range(i+1, min(i+K+1, N+1)): heappush(heap, s[i:j]) l = list(set(heap)) l.sort() print((l[K-1]))
s = eval(input()) K = int(eval(input())) N = len(s) l = [] cnt = 0 for i in range(N): for j in range(i+1, min(i+K+1, N+1)): l.append(s[i:j]) l = list(set(l)) l.sort() print((l[K-1]))
13
12
232
183
from heapq import heappush, heappop s = eval(input()) K = int(eval(input())) N = len(s) heap = [] cnt = 0 for i in range(N): for j in range(i + 1, min(i + K + 1, N + 1)): heappush(heap, s[i:j]) l = list(set(heap)) l.sort() print((l[K - 1]))
s = eval(input()) K = int(eval(input())) N = len(s) l = [] cnt = 0 for i in range(N): for j in range(i + 1, min(i + K + 1, N + 1)): l.append(s[i:j]) l = list(set(l)) l.sort() print((l[K - 1]))
false
7.692308
[ "-from heapq import heappush, heappop", "-", "-heap = []", "+l = []", "- heappush(heap, s[i:j])", "-l = list(set(heap))", "+ l.append(s[i:j])", "+l = list(set(l))" ]
false
0.044895
0.041089
1.092635
[ "s915415042", "s856750460" ]
u614314290
p03448
python
s752358755
s086522655
55
18
3,060
3,060
Accepted
Accepted
67.27
A, B, C, X = list(map(int, [eval(input()) for _ in range(4)])) count = 0 for a in range(A + 1): for b in range(B + 1): for c in range(C + 1): value = 500 * a + 100 * b + 50 * c if X == value: count += 1 print(count)
A, B, C, X = list(map(int, [eval(input()) for _ in range(4)])) count = 0 for a in range(A + 1): for b in range(B + 1): value = 500 * a + 100 * b #print(value) if value <= X and (X - value) // 50 <= C: count += 1 print(count)
10
10
226
232
A, B, C, X = list(map(int, [eval(input()) for _ in range(4)])) count = 0 for a in range(A + 1): for b in range(B + 1): for c in range(C + 1): value = 500 * a + 100 * b + 50 * c if X == value: count += 1 print(count)
A, B, C, X = list(map(int, [eval(input()) for _ in range(4)])) count = 0 for a in range(A + 1): for b in range(B + 1): value = 500 * a + 100 * b # print(value) if value <= X and (X - value) // 50 <= C: count += 1 print(count)
false
0
[ "- for c in range(C + 1):", "- value = 500 * a + 100 * b + 50 * c", "- if X == value:", "- count += 1", "+ value = 500 * a + 100 * b", "+ # print(value)", "+ if value <= X and (X - value) // 50 <= C:", "+ count += 1" ]
false
0.097823
0.09612
1.017725
[ "s752358755", "s086522655" ]
u285443936
p03162
python
s713147596
s557086718
962
389
47,344
68,436
Accepted
Accepted
59.56
N = int(eval(input())) A = [list(map(int, input().split())) for i in range(N)] dp = [[0]*3 for i in range(N+1)] for i in range(1,N+1): for j in range(3): for k in range(3): if j != k: dp[i][k] = max(dp[i][k],dp[i-1][j]+A[i-1][k]) print((max(dp[-1])))
import sys input = sys.stdin.readline N = int(eval(input())) table = [] dp = [[0]*3 for i in range(N)] for i in range(N): a,b,c = list(map(int, input().split())) table.append((a,b,c)) dp[0] = table[0] for i in range(1,N): for j in range(3): for k in range(3): if j==k: ...
9
18
270
411
N = int(eval(input())) A = [list(map(int, input().split())) for i in range(N)] dp = [[0] * 3 for i in range(N + 1)] for i in range(1, N + 1): for j in range(3): for k in range(3): if j != k: dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i - 1][k]) print((max(dp[-1])))
import sys input = sys.stdin.readline N = int(eval(input())) table = [] dp = [[0] * 3 for i in range(N)] for i in range(N): a, b, c = list(map(int, input().split())) table.append((a, b, c)) dp[0] = table[0] for i in range(1, N): for j in range(3): for k in range(3): if j == k: ...
false
50
[ "+import sys", "+", "+input = sys.stdin.readline", "-A = [list(map(int, input().split())) for i in range(N)]", "-dp = [[0] * 3 for i in range(N + 1)]", "-for i in range(1, N + 1):", "+table = []", "+dp = [[0] * 3 for i in range(N)]", "+for i in range(N):", "+ a, b, c = list(map(int, input().spl...
false
0.046879
0.043977
1.065988
[ "s713147596", "s557086718" ]
u753803401
p02880
python
s149582712
s468001208
186
172
39,856
38,400
Accepted
Accepted
7.53
import sys def solve(): sys.setrecursionlimit(2000) input = sys.stdin.readline mod = 10 ** 9 + 7 n = int(input().rstrip('\n')) for i in range(1, 10): for j in range(1, 10): if n == i * j: print("Yes") exit() print("No") if _...
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 n = int(readline()) for i in range(1, 10): for j in range(1, 10): if i * j == n: print("Yes") exit() print("No") if __name__ == '__main__': solve...
18
17
356
323
import sys def solve(): sys.setrecursionlimit(2000) input = sys.stdin.readline mod = 10**9 + 7 n = int(input().rstrip("\n")) for i in range(1, 10): for j in range(1, 10): if n == i * j: print("Yes") exit() print("No") if __name__ == "__main...
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 n = int(readline()) for i in range(1, 10): for j in range(1, 10): if i * j == n: print("Yes") exit() print("No") if __name__ == "__main__": solve()
false
5.555556
[ "- sys.setrecursionlimit(2000)", "- input = sys.stdin.readline", "+ readline = sys.stdin.buffer.readline", "- n = int(input().rstrip(\"\\n\"))", "+ n = int(readline())", "- if n == i * j:", "+ if i * j == n:" ]
false
0.036346
0.041221
0.881735
[ "s149582712", "s468001208" ]
u497046426
p02901
python
s090460625
s415941704
1,625
1,294
3,188
3,188
Accepted
Accepted
20.37
def main(): INF = float('inf') N, M = list(map(int, input().split())) dp = [INF for _ in range(2**N)] dp[0] = 0 for i in range(M): a, _ = list(map(int, input().split())) *C, = list(map(int, input().split())) open_bit = 0 for i in C: open_bit |= 1 << i-1 ...
INF = float('inf') N, M = list(map(int, input().split())) dp = [INF for _ in range(2**N)] dp[0] = 0 for i in range(M): a, _ = list(map(int, input().split())) *C, = list(map(int, input().split())) open_bit = 0 for i in C: open_bit |= 1 << i-1 for i in range(2**N): temp = dp[i] + a ...
14
13
459
397
def main(): INF = float("inf") N, M = list(map(int, input().split())) dp = [INF for _ in range(2**N)] dp[0] = 0 for i in range(M): a, _ = list(map(int, input().split())) (*C,) = list(map(int, input().split())) open_bit = 0 for i in C: open_bit |= 1 << i - ...
INF = float("inf") N, M = list(map(int, input().split())) dp = [INF for _ in range(2**N)] dp[0] = 0 for i in range(M): a, _ = list(map(int, input().split())) (*C,) = list(map(int, input().split())) open_bit = 0 for i in C: open_bit |= 1 << i - 1 for i in range(2**N): temp = dp[i] + a...
false
7.142857
[ "-def main():", "- INF = float(\"inf\")", "- N, M = list(map(int, input().split()))", "- dp = [INF for _ in range(2**N)]", "- dp[0] = 0", "- for i in range(M):", "- a, _ = list(map(int, input().split()))", "- (*C,) = list(map(int, input().split()))", "- open_bit =...
false
0.039637
0.114139
0.347273
[ "s090460625", "s415941704" ]
u761529120
p03240
python
s733709789
s461004178
204
97
42,224
74,608
Accepted
Accepted
52.45
def main(): N = int(eval(input())) p = [] for i in range(N): x,y,h = list(map(int,input().split())) p.append([x,y,h]) p.sort(key=lambda x: x[2]) a,b,c = p[-1] for i in range(101): for j in range(101): H = c + abs(a - i) + abs(b - j) f...
def main(): N = int(eval(input())) X = [0] * N Y = [0] * N H = [0] * N for i in range(N): X[i], Y[i], H[i] = list(map(int, input().split())) ans = [] for x in range(101): for y in range(101): tmp = 0 for i in range(N): if H[...
21
34
496
843
def main(): N = int(eval(input())) p = [] for i in range(N): x, y, h = list(map(int, input().split())) p.append([x, y, h]) p.sort(key=lambda x: x[2]) a, b, c = p[-1] for i in range(101): for j in range(101): H = c + abs(a - i) + abs(b - j) for x, y...
def main(): N = int(eval(input())) X = [0] * N Y = [0] * N H = [0] * N for i in range(N): X[i], Y[i], H[i] = list(map(int, input().split())) ans = [] for x in range(101): for y in range(101): tmp = 0 for i in range(N): if H[i] == 0: ...
false
38.235294
[ "- p = []", "+ X = [0] * N", "+ Y = [0] * N", "+ H = [0] * N", "- x, y, h = list(map(int, input().split()))", "- p.append([x, y, h])", "- p.sort(key=lambda x: x[2])", "- a, b, c = p[-1]", "- for i in range(101):", "- for j in range(101):", "- ...
false
0.03935
0.05763
0.682806
[ "s733709789", "s461004178" ]
u832152513
p04025
python
s993846019
s673902972
184
166
38,256
38,896
Accepted
Accepted
9.78
n = int(eval(input())) a = list(map(int, input().split())) s = sum(a) m1 = s // n m2 = -(-s // n) ans1 = 0 ans2 = 0 for x in a: ans1 += (x - m1)**2 ans2 += (x - m2)**2 print((min(ans1, ans2)))
n = int(eval(input())) a = list(map(int, input().split())) ans = float("inf") for i in range(-100, 101): tmp = 0 for ai in a: tmp += (ai - i) ** 2 ans = min(ans, tmp) print(ans)
14
11
208
203
n = int(eval(input())) a = list(map(int, input().split())) s = sum(a) m1 = s // n m2 = -(-s // n) ans1 = 0 ans2 = 0 for x in a: ans1 += (x - m1) ** 2 ans2 += (x - m2) ** 2 print((min(ans1, ans2)))
n = int(eval(input())) a = list(map(int, input().split())) ans = float("inf") for i in range(-100, 101): tmp = 0 for ai in a: tmp += (ai - i) ** 2 ans = min(ans, tmp) print(ans)
false
21.428571
[ "-s = sum(a)", "-m1 = s // n", "-m2 = -(-s // n)", "-ans1 = 0", "-ans2 = 0", "-for x in a:", "- ans1 += (x - m1) ** 2", "- ans2 += (x - m2) ** 2", "-print((min(ans1, ans2)))", "+ans = float(\"inf\")", "+for i in range(-100, 101):", "+ tmp = 0", "+ for ai in a:", "+ tmp +...
false
0.044896
0.044344
1.012442
[ "s993846019", "s673902972" ]
u187233527
p03317
python
s743350482
s961810347
28
17
3,060
3,060
Accepted
Accepted
39.29
N, K = list(map(int, input().split())) N -= K ans = 1 while N > 0: N -= K - 1 ans += 1 print(ans)
import math n, k = list(map(int, input().split())) print((math.ceil((n - 1) / (k - 1))))
7
4
101
84
N, K = list(map(int, input().split())) N -= K ans = 1 while N > 0: N -= K - 1 ans += 1 print(ans)
import math n, k = list(map(int, input().split())) print((math.ceil((n - 1) / (k - 1))))
false
42.857143
[ "-N, K = list(map(int, input().split()))", "-N -= K", "-ans = 1", "-while N > 0:", "- N -= K - 1", "- ans += 1", "-print(ans)", "+import math", "+", "+n, k = list(map(int, input().split()))", "+print((math.ceil((n - 1) / (k - 1))))" ]
false
0.045435
0.045927
0.989303
[ "s743350482", "s961810347" ]
u046187684
p03309
python
s369742856
s455017863
338
208
106,612
28,048
Accepted
Accepted
38.46
from collections import Counter def solve(string): n, *a = list(map(int, string.split())) a = sorted([_a - i - 1 for i, _a in enumerate(a)]) median = a[len(a) // 2] return str(sum([abs(_a - median) for _a in a])) if __name__ == '__main__': print((solve("\n".join([eval(input()), eval(i...
def solve(string): n, *a = list(map(int, string.split())) a = sorted([_a - i - 1 for i, _a in enumerate(a)]) median = a[len(a) // 2] return str(sum([abs(_a - median) for _a in a])) if __name__ == '__main__': print((solve("\n".join([eval(input()), eval(input())]))))
12
9
313
276
from collections import Counter def solve(string): n, *a = list(map(int, string.split())) a = sorted([_a - i - 1 for i, _a in enumerate(a)]) median = a[len(a) // 2] return str(sum([abs(_a - median) for _a in a])) if __name__ == "__main__": print((solve("\n".join([eval(input()), eval(input())])))...
def solve(string): n, *a = list(map(int, string.split())) a = sorted([_a - i - 1 for i, _a in enumerate(a)]) median = a[len(a) // 2] return str(sum([abs(_a - median) for _a in a])) if __name__ == "__main__": print((solve("\n".join([eval(input()), eval(input())]))))
false
25
[ "-from collections import Counter", "-", "-" ]
false
0.03558
0.05311
0.669919
[ "s369742856", "s455017863" ]
u625046108
p02678
python
s655421296
s933162798
794
625
109,888
96,988
Accepted
Accepted
21.28
import heapq N,M = list(map(int, input().split())) nl = {i:[] for i in range(1,N+1)} rlt = [-1]*(N+1) for _ in range(M): a,b = list(map(int, input().split())) nl[a].append(b) nl[b].append(a) ds = [float('inf')]*(N+1) ds[1] = 0 h = [] heapq.heappush(h,[0,1]) while(len(h) > 0): tmp = heapq.he...
from collections import deque N,M = list(map(int, input().split())) nl = {i:[] for i in range(1,N+1)} rlt = [-1]*(N+1) for _ in range(M): a,b = list(map(int, input().split())) nl[a].append(b) nl[b].append(a) ds = [float('inf')]*(N+1) ds[1] = 0 h = deque() h.append(1) while(len(h) > 0): v...
33
30
584
528
import heapq N, M = list(map(int, input().split())) nl = {i: [] for i in range(1, N + 1)} rlt = [-1] * (N + 1) for _ in range(M): a, b = list(map(int, input().split())) nl[a].append(b) nl[b].append(a) ds = [float("inf")] * (N + 1) ds[1] = 0 h = [] heapq.heappush(h, [0, 1]) while len(h) > 0: tmp = heapq...
from collections import deque N, M = list(map(int, input().split())) nl = {i: [] for i in range(1, N + 1)} rlt = [-1] * (N + 1) for _ in range(M): a, b = list(map(int, input().split())) nl[a].append(b) nl[b].append(a) ds = [float("inf")] * (N + 1) ds[1] = 0 h = deque() h.append(1) while len(h) > 0: v =...
false
9.090909
[ "-import heapq", "+from collections import deque", "-h = []", "-heapq.heappush(h, [0, 1])", "+h = deque()", "+h.append(1)", "- tmp = heapq.heappop(h)", "- v = tmp[1]", "- if ds[v] < tmp[0]:", "- continue", "+ v = h.popleft()", "- if ds[j] > ds[v] + 1:", "+ if...
false
0.038469
0.040732
0.944432
[ "s655421296", "s933162798" ]
u631025015
p02711
python
s025540218
s985108495
23
21
9,140
9,148
Accepted
Accepted
8.7
N=int(eval(input(""))) if N % 10 == 7 or (N - N % 10) / 10 % 10 == 7 or (N - N % 100)/100 == 7: print("Yes") else: print("No")
N=int(eval(input(""))) if N % 10 == 7 or N // 10 % 10 == 7 or N //100 == 7: print("Yes") else: print("No")
5
5
128
108
N = int(eval(input(""))) if N % 10 == 7 or (N - N % 10) / 10 % 10 == 7 or (N - N % 100) / 100 == 7: print("Yes") else: print("No")
N = int(eval(input(""))) if N % 10 == 7 or N // 10 % 10 == 7 or N // 100 == 7: print("Yes") else: print("No")
false
0
[ "-if N % 10 == 7 or (N - N % 10) / 10 % 10 == 7 or (N - N % 100) / 100 == 7:", "+if N % 10 == 7 or N // 10 % 10 == 7 or N // 100 == 7:" ]
false
0.038907
0.037549
1.036166
[ "s025540218", "s985108495" ]
u611249982
p04013
python
s415922356
s184195216
227
183
5,732
5,744
Accepted
Accepted
19.38
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] nx = n * max(max(x), a) y = [xi - a for xi in x] dp = [[0 for j in range(2 * nx + 1)] for i in range(n + 1)] dp[0][nx] = 1 for i in range(n): for j in range(2 * nx + 1): if not 0 <= j - y[i] <= 2 * nx: dp...
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] nx = n * max(max(x), a) y = [xi - a for xi in x] dp = [[0 for j in range(2 * nx + 1)] for i in range(n + 1)] dp[0][nx] = 1 for i in range(n): for j in range(2 * nx + 1): if j - y[i] > 2 * nx: dp[i + 1][j]...
16
16
455
426
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] nx = n * max(max(x), a) y = [xi - a for xi in x] dp = [[0 for j in range(2 * nx + 1)] for i in range(n + 1)] dp[0][nx] = 1 for i in range(n): for j in range(2 * nx + 1): if not 0 <= j - y[i] <= 2 * nx: dp[i + 1][j] = ...
n, a = [int(i) for i in input().split()] x = [int(i) for i in input().split()] nx = n * max(max(x), a) y = [xi - a for xi in x] dp = [[0 for j in range(2 * nx + 1)] for i in range(n + 1)] dp[0][nx] = 1 for i in range(n): for j in range(2 * nx + 1): if j - y[i] > 2 * nx: dp[i + 1][j] = dp[i][j] ...
false
0
[ "- if not 0 <= j - y[i] <= 2 * nx:", "+ if j - y[i] > 2 * nx:", "- elif j - y[i] <= 2 * nx:", "+ else:" ]
false
0.045623
0.045491
1.002902
[ "s415922356", "s184195216" ]
u671861352
p02990
python
s988317618
s196759534
549
21
3,316
3,316
Accepted
Accepted
96.17
N, K = tuple(map(int, input().split())) def cmb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot >...
N, K = list(map(int, input().split())) mod = 10 ** 9 + 7 a = N - K + 1 b = 1 print(a) for i in range(2, K+1): a = a * (N - K + 2 - i) // i b = b * (K - i + 1) // (i - 1) print((a * b % mod))
34
10
812
204
N, K = tuple(map(int, input().split())) def cmb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] ...
N, K = list(map(int, input().split())) mod = 10**9 + 7 a = N - K + 1 b = 1 print(a) for i in range(2, K + 1): a = a * (N - K + 2 - i) // i b = b * (K - i + 1) // (i - 1) print((a * b % mod))
false
70.588235
[ "-N, K = tuple(map(int, input().split()))", "-", "-", "-def cmb(n, r):", "- if n - r < r:", "- r = n - r", "- if r == 0:", "- return 1", "- if r == 1:", "- return n", "- numerator = [n - r + k + 1 for k in range(r)]", "- denominator = [k + 1 for k in range(r...
false
0.044431
0.035982
1.234807
[ "s988317618", "s196759534" ]
u613805578
p02397
python
s734727116
s244918180
30
20
6,320
6,252
Accepted
Accepted
33.33
while 1: x, y = list(map(int, input().split())) if x == 0 and y == 0: break else: if x > y: print('%s %s' % (y,x)) else: print('%s %s' % (x,y))
while 1: x, y = list(map(int, input().split())) if x == 0 and y == 0: break elif x > y: print('%s %s' % (y,x)) else: print('%s %s' % (x,y))
10
9
199
179
while 1: x, y = list(map(int, input().split())) if x == 0 and y == 0: break else: if x > y: print("%s %s" % (y, x)) else: print("%s %s" % (x, y))
while 1: x, y = list(map(int, input().split())) if x == 0 and y == 0: break elif x > y: print("%s %s" % (y, x)) else: print("%s %s" % (x, y))
false
10
[ "+ elif x > y:", "+ print(\"%s %s\" % (y, x))", "- if x > y:", "- print(\"%s %s\" % (y, x))", "- else:", "- print(\"%s %s\" % (x, y))", "+ print(\"%s %s\" % (x, y))" ]
false
0.047392
0.070292
0.674227
[ "s734727116", "s244918180" ]
u796942881
p02983
python
s028443543
s463049997
58
18
6,808
3,060
Accepted
Accepted
68.97
def main(): L, R = list(map(int, input().split())) # 60 の相異なる素因数は 3, 673 の 2つ if L + 672 <= R: print((0)) return lst = [] for i in range(L, R + 1): for j in range(i + 1, R + 1): if i * j % 2019 == 0: print((0)) return ...
def main(): L, R = list(map(int, input().split())) # 60 の相異なる素因数は 3, 673 の 2つ if L + 672 <= R: print((0)) return lst = [] for i in range(L, R + 1): for j in range(i + 1, R + 1): if i * j % 2019 == 0: print((0)) return ...
18
22
390
498
def main(): L, R = list(map(int, input().split())) # 60 の相異なる素因数は 3, 673 の 2つ if L + 672 <= R: print((0)) return lst = [] for i in range(L, R + 1): for j in range(i + 1, R + 1): if i * j % 2019 == 0: print((0)) return ls...
def main(): L, R = list(map(int, input().split())) # 60 の相異なる素因数は 3, 673 の 2つ if L + 672 <= R: print((0)) return lst = [] for i in range(L, R + 1): for j in range(i + 1, R + 1): if i * j % 2019 == 0: print((0)) return ls...
false
18.181818
[ "+ if i * j % 2019 == 1:", "+ break", "+ if i * j % 2019 == 1:", "+ break" ]
false
0.043629
0.038263
1.140253
[ "s028443543", "s463049997" ]
u254871849
p03244
python
s653230474
s162692092
115
88
20,692
20,564
Accepted
Accepted
23.48
# 2019-11-10 17:11:42(JST) import sys import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce import operator as op # from scipy.misc import comb # float # im...
import sys from collections import Counter n, *v = list(map(int, sys.stdin.read().split())) def main(): c1 = sorted(list(Counter(v[::2]).items()), reverse=True, key=lambda x: x[1]) c2 = sorted(list(Counter(v[1::2]).items()), reverse=True, key=lambda x: x[1]) if c1[0][0] != c2[0][0]: ...
48
24
1,344
703
# 2019-11-10 17:11:42(JST) import sys import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools # from functools import reduce import operator as op # from scipy.misc import comb # float # import num...
import sys from collections import Counter n, *v = list(map(int, sys.stdin.read().split())) def main(): c1 = sorted(list(Counter(v[::2]).items()), reverse=True, key=lambda x: x[1]) c2 = sorted(list(Counter(v[1::2]).items()), reverse=True, key=lambda x: x[1]) if c1[0][0] != c2[0][0]: return n // 2...
false
50
[ "-# 2019-11-10 17:11:42(JST)", "-import collections", "+from collections import Counter", "-# import math", "-# from string import ascii_lowercase, ascii_uppercase, digits", "-# from bisect import bisect_left as bi_l, bisect_right as bi_r", "-# import itertools", "-# from functools import reduce", "...
false
0.036512
0.0435
0.839363
[ "s653230474", "s162692092" ]
u347184682
p02989
python
s906839098
s466698093
80
69
14,396
20,756
Accepted
Accepted
13.75
n=int(eval(input())) d=[int(x) for x in input().rstrip().split()] d.sort() if d[n//2-1]==d[n//2]: print((0)) else: print((d[n//2]-d[n//2-1]))
n=int(eval(input())) d=[int(x) for x in input().rstrip().split()] d.sort() ind=n//2 if d[ind-1]==d[ind]: print((0)) else: print((d[ind]-d[ind-1]))
7
11
142
154
n = int(eval(input())) d = [int(x) for x in input().rstrip().split()] d.sort() if d[n // 2 - 1] == d[n // 2]: print((0)) else: print((d[n // 2] - d[n // 2 - 1]))
n = int(eval(input())) d = [int(x) for x in input().rstrip().split()] d.sort() ind = n // 2 if d[ind - 1] == d[ind]: print((0)) else: print((d[ind] - d[ind - 1]))
false
36.363636
[ "-if d[n // 2 - 1] == d[n // 2]:", "+ind = n // 2", "+if d[ind - 1] == d[ind]:", "- print((d[n // 2] - d[n // 2 - 1]))", "+ print((d[ind] - d[ind - 1]))" ]
false
0.048263
0.048047
1.004492
[ "s906839098", "s466698093" ]
u806403461
p02683
python
s263534755
s103102850
92
82
9,312
9,256
Accepted
Accepted
10.87
n, m, x = list(map(int, input().split())) a_list = list() l = list() ans = [] for i in range(0, n): a_list.append(list(map(int, input().split()))) for i in range(1, 2**n): num = format(i, '0' + str(n) + 'b') l.append(num) # print(l) list_len = len(l) s = 0 tmp = [0]*(m+1) for ...
n, m, x = list(map(int, input().split())) a_list = list() c_list = list() INF = 1001001001 for i in range(0, n): tmp = list(map(int, input().split())) c = tmp.pop(0) c_list.append(c) a_list.append(tmp) ans = INF for s in range(0, 1 << n): cost = 0 d = [0]*m for i in ra...
40
34
716
639
n, m, x = list(map(int, input().split())) a_list = list() l = list() ans = [] for i in range(0, n): a_list.append(list(map(int, input().split()))) for i in range(1, 2**n): num = format(i, "0" + str(n) + "b") l.append(num) # print(l) list_len = len(l) s = 0 tmp = [0] * (m + 1) for i in range(0, list_len): ...
n, m, x = list(map(int, input().split())) a_list = list() c_list = list() INF = 1001001001 for i in range(0, n): tmp = list(map(int, input().split())) c = tmp.pop(0) c_list.append(c) a_list.append(tmp) ans = INF for s in range(0, 1 << n): cost = 0 d = [0] * m for i in range(0, n): if...
false
15
[ "-l = list()", "-ans = []", "+c_list = list()", "+INF = 1001001001", "- a_list.append(list(map(int, input().split())))", "-for i in range(1, 2**n):", "- num = format(i, \"0\" + str(n) + \"b\")", "- l.append(num)", "-# print(l)", "-list_len = len(l)", "-s = 0", "-tmp = [0] * (m + 1)", ...
false
0.045322
0.15542
0.291612
[ "s263534755", "s103102850" ]
u123756661
p03086
python
s679870919
s994757721
172
63
38,384
61,812
Accepted
Accepted
63.37
d={"A","C","G","T"} ans=chk=0 s=eval(input()) for i in s: if i in d: chk+=1 ans=max(ans,chk) else: chk=0 print(ans)
s=eval(input()) ans=chk=0 for i in s: if i in "ACGT": chk+=1 else: chk=0 ans=max(ans,chk) print(ans)
10
7
151
112
d = {"A", "C", "G", "T"} ans = chk = 0 s = eval(input()) for i in s: if i in d: chk += 1 ans = max(ans, chk) else: chk = 0 print(ans)
s = eval(input()) ans = chk = 0 for i in s: if i in "ACGT": chk += 1 else: chk = 0 ans = max(ans, chk) print(ans)
false
30
[ "-d = {\"A\", \"C\", \"G\", \"T\"}", "+s = eval(input())", "-s = eval(input())", "- if i in d:", "+ if i in \"ACGT\":", "- ans = max(ans, chk)", "+ ans = max(ans, chk)" ]
false
0.035763
0.04171
0.857418
[ "s679870919", "s994757721" ]
u969077316
p03503
python
s664951395
s237818756
358
246
13,128
3,064
Accepted
Accepted
31.28
import numpy as np N = int(eval(input())) F = [list(map(int, input().strip().split())) for i in range(N)] P = [list(map(int, input().strip().split())) for i in range(N)] maxProfit = -1000000000 for i in range(1,1024): openTime = list(map(int, list("{:0>10}".format(bin(i)[2:])))) thisProfit = 0 ...
N = int(eval(input())) F = [list(map(int, input().strip().split())) for i in range(N)] P = [list(map(int, input().strip().split())) for i in range(N)] maxProfit = -1000000000 for i in range(1,1024): openTime = list(map(int, list("{:0>10}".format(bin(i)[2:])))) thisProfit = 0 for n in range(N): ...
23
20
632
608
import numpy as np N = int(eval(input())) F = [list(map(int, input().strip().split())) for i in range(N)] P = [list(map(int, input().strip().split())) for i in range(N)] maxProfit = -1000000000 for i in range(1, 1024): openTime = list(map(int, list("{:0>10}".format(bin(i)[2:])))) thisProfit = 0 for n in ra...
N = int(eval(input())) F = [list(map(int, input().strip().split())) for i in range(N)] P = [list(map(int, input().strip().split())) for i in range(N)] maxProfit = -1000000000 for i in range(1, 1024): openTime = list(map(int, list("{:0>10}".format(bin(i)[2:])))) thisProfit = 0 for n in range(N): shop...
false
13.043478
[ "-import numpy as np", "-" ]
false
0.042571
0.119391
0.356568
[ "s664951395", "s237818756" ]
u768152935
p03162
python
s423438923
s425156634
694
634
58,220
59,628
Accepted
Accepted
8.65
import math from math import sqrt import sys from collections import deque, defaultdict from heapq import heappop,heappush from copy import deepcopy INF=10**18 MOD=10**9+7 MAX=10**5+7 def main(): N=int(eval(input())) dp=[[0]*3 for i in range(MAX)] for i in range(N): a,b,c=list(map(int...
import math from math import sqrt import sys from collections import deque, defaultdict from heapq import heappop,heappush from copy import deepcopy INF=10**18 MOD=10**9+7 MAX=10**5+7 def main(): N=int(eval(input())) dp=[[0]*3 for i in range(MAX)] for i in range(N): a,b,c=list(map(int...
29
29
567
525
import math from math import sqrt import sys from collections import deque, defaultdict from heapq import heappop, heappush from copy import deepcopy INF = 10**18 MOD = 10**9 + 7 MAX = 10**5 + 7 def main(): N = int(eval(input())) dp = [[0] * 3 for i in range(MAX)] for i in range(N): a, b, c = lis...
import math from math import sqrt import sys from collections import deque, defaultdict from heapq import heappop, heappush from copy import deepcopy INF = 10**18 MOD = 10**9 + 7 MAX = 10**5 + 7 def main(): N = int(eval(input())) dp = [[0] * 3 for i in range(MAX)] for i in range(N): a, b, c = lis...
false
0
[ "- dp[i + 1][0] = max([dp[i + 1][0], dp[i][1] + a, dp[i][2] + a])", "- dp[i + 1][1] = max([dp[i + 1][1], dp[i][2] + b, dp[i][0] + b])", "- dp[i + 1][2] = max([dp[i + 1][2], dp[i][0] + c, dp[i][1] + c])", "+ dp[i + 1][0] = max(dp[i][1] + a, dp[i][2] + a)", "+ dp[i + 1][1] =...
false
0.070542
0.078445
0.899247
[ "s423438923", "s425156634" ]
u094191970
p02691
python
s004652821
s693154603
294
215
63,628
50,592
Accepted
Accepted
26.87
from collections import Counter n=int(eval(input())) a=list(map(int,input().split())) q1=[] q2=[] for i in range(n): q1.append(i+a[i]) q2.append(i-a[i]) c1=Counter(q1) c2=Counter(q2) ans=0 for i in list(c1.keys()): num1=c1[i] num2=c2[i] ans+=num1*num2 print(ans)
from collections import Counter n=int(eval(input())) a=list(map(int,input().split())) q1=[] q2=[] for i in range(n): q1.append(i+a[i]) q2.append(i-a[i]) c2=Counter(q2) ans=0 for i in q1: ans+=c2[i] print(ans)
22
19
287
232
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) q1 = [] q2 = [] for i in range(n): q1.append(i + a[i]) q2.append(i - a[i]) c1 = Counter(q1) c2 = Counter(q2) ans = 0 for i in list(c1.keys()): num1 = c1[i] num2 = c2[i] ans += num1 * num2 print(ans)
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) q1 = [] q2 = [] for i in range(n): q1.append(i + a[i]) q2.append(i - a[i]) c2 = Counter(q2) ans = 0 for i in q1: ans += c2[i] print(ans)
false
13.636364
[ "-c1 = Counter(q1)", "-for i in list(c1.keys()):", "- num1 = c1[i]", "- num2 = c2[i]", "- ans += num1 * num2", "+for i in q1:", "+ ans += c2[i]" ]
false
0.077144
0.034973
2.205848
[ "s004652821", "s693154603" ]
u477650749
p03073
python
s094169665
s321142637
64
57
3,188
3,188
Accepted
Accepted
10.94
S = eval(input()) count_0 = 0 count_1 = 0 for i,s in enumerate(S): if s == "0" and i%2==0: count_1 += 1 elif s=="1" and i%2==0: count_0 += 1 if s == "1" and i%2==1: count_1 += 1 elif s=="0" and i%2==1: count_0 += 1 print((min(count_0,count_1)))
S = eval(input()) count_0 = 0 count_1 = 0 for i,s in enumerate(S): if s == "0" and i%2==0: count_1 += 1 continue elif s=="1" and i%2==0: count_0 += 1 continue if s == "1" and i%2==1: count_1 += 1 elif s=="0" and i%2==1: count_0 += 1 pri...
17
18
305
339
S = eval(input()) count_0 = 0 count_1 = 0 for i, s in enumerate(S): if s == "0" and i % 2 == 0: count_1 += 1 elif s == "1" and i % 2 == 0: count_0 += 1 if s == "1" and i % 2 == 1: count_1 += 1 elif s == "0" and i % 2 == 1: count_0 += 1 print((min(count_0, count_1)))
S = eval(input()) count_0 = 0 count_1 = 0 for i, s in enumerate(S): if s == "0" and i % 2 == 0: count_1 += 1 continue elif s == "1" and i % 2 == 0: count_0 += 1 continue if s == "1" and i % 2 == 1: count_1 += 1 elif s == "0" and i % 2 == 1: count_0 += 1 pr...
false
5.555556
[ "+ continue", "+ continue" ]
false
0.096241
0.039967
2.408005
[ "s094169665", "s321142637" ]
u408620326
p02768
python
s224492297
s041117767
232
98
18,804
3,064
Accepted
Accepted
57.76
import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline n, a, b = [int(x) for x in input().strip().split()] mod = 10 ** 9 + 7 ans = pow(2, n, mod) - 1 fact = [1] * (b + 1) for i in range(1, b+1): fact[i] = (fact[i-1] * i) % mod inv = [1] * (b + 1) inv[-1] = pow(fact[-1], mod-2, mod) for ...
import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline n, a, b = [int(x) for x in input().strip().split()] mod = 10 ** 9 + 7 ans = pow(2, n, mod) - 1 num = 1 den = 1 for i in range(a): den = (den * (i+1)) % mod num = (num * (n-i)) % mod ans = (ans - (num * pow(den, mod-2, mod)) % mod ...
25
20
593
485
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline n, a, b = [int(x) for x in input().strip().split()] mod = 10**9 + 7 ans = pow(2, n, mod) - 1 fact = [1] * (b + 1) for i in range(1, b + 1): fact[i] = (fact[i - 1] * i) % mod inv = [1] * (b + 1) inv[-1] = pow(fact[-1], mod - 2, mod) for i in range(1...
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline n, a, b = [int(x) for x in input().strip().split()] mod = 10**9 + 7 ans = pow(2, n, mod) - 1 num = 1 den = 1 for i in range(a): den = (den * (i + 1)) % mod num = (num * (n - i)) % mod ans = (ans - (num * pow(den, mod - 2, mod)) % mod) % mod for...
false
20
[ "-fact = [1] * (b + 1)", "-for i in range(1, b + 1):", "- fact[i] = (fact[i - 1] * i) % mod", "-inv = [1] * (b + 1)", "-inv[-1] = pow(fact[-1], mod - 2, mod)", "-for i in range(1, b):", "- inv[-1 - i] = (inv[-1 - i + 1] * (b - (i - 1))) % mod", "-", "-", "-def nCr(n, r):", "- ret = 1", ...
false
0.244433
0.182776
1.337341
[ "s224492297", "s041117767" ]
u489959379
p02726
python
s809756601
s598799810
1,954
1,005
4,200
105,308
Accepted
Accepted
48.57
import sys from collections import deque sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, x, y = list(map(int, input().split())) tree = [[] for _ in range(n)] for i in range(1, n): tree[i - 1].append(i) tree[i].append(i - 1) tree[x ...
import sys from collections import deque sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): def bfs(root): dist = [f_inf] * n dist[root] = 0 que = deque() que.append(root) while que: p...
42
43
914
977
import sys from collections import deque sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): n, x, y = list(map(int, input().split())) tree = [[] for _ in range(n)] for i in range(1, n): tree[i - 1].append(i) tree[i].append(i - 1) tree[x - 1].append(y - 1)...
import sys from collections import deque sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): def bfs(root): dist = [f_inf] * n dist[root] = 0 que = deque() que.append(root) while que: prev = que.popleft() ...
false
2.325581
[ "+input = sys.stdin.readline", "+ def bfs(root):", "+ dist = [f_inf] * n", "+ dist[root] = 0", "+ que = deque()", "+ que.append(root)", "+ while que:", "+ prev = que.popleft()", "+ for next in tree[prev]:", "+ if dist[next]...
false
0.036393
0.035738
1.018305
[ "s809756601", "s598799810" ]
u905203728
p02973
python
s470777236
s029625259
557
191
56,792
82,508
Accepted
Accepted
65.71
from bisect import bisect_right n=int(eval(input())) A=[int(eval(input())) for _ in range(n)][::-1] DP=[A[0]] for i in range(1,n): num=A[i] if DP[-1]<=num: DP.append(num) else: index=bisect_right(DP,num) DP[index]=num print((len(DP)))
from bisect import bisect_right n=int(eval(input())) A=[int(eval(input())) for _ in range(n)][::-1] DP=[A[0]] for i in range(1,n): num=A[i] if num>=DP[-1]: DP.append(num) else: index=bisect_right(DP,num) DP[index]=num print((len(DP)))
13
13
269
269
from bisect import bisect_right n = int(eval(input())) A = [int(eval(input())) for _ in range(n)][::-1] DP = [A[0]] for i in range(1, n): num = A[i] if DP[-1] <= num: DP.append(num) else: index = bisect_right(DP, num) DP[index] = num print((len(DP)))
from bisect import bisect_right n = int(eval(input())) A = [int(eval(input())) for _ in range(n)][::-1] DP = [A[0]] for i in range(1, n): num = A[i] if num >= DP[-1]: DP.append(num) else: index = bisect_right(DP, num) DP[index] = num print((len(DP)))
false
0
[ "- if DP[-1] <= num:", "+ if num >= DP[-1]:" ]
false
0.063458
0.057827
1.097377
[ "s470777236", "s029625259" ]
u086566114
p02418
python
s668806887
s639818957
20
10
6,388
6,388
Accepted
Accepted
50
ring = input() * 2 word = input() if ring.find(word) != -1: print("Yes") else: print("No")
ring = input() * 2 word = input() if word in ring: print("Yes") else: print("No")
7
7
113
104
ring = input() * 2 word = input() if ring.find(word) != -1: print("Yes") else: print("No")
ring = input() * 2 word = input() if word in ring: print("Yes") else: print("No")
false
0
[ "-if ring.find(word) != -1:", "+if word in ring:" ]
false
0.046499
0.042686
1.089322
[ "s668806887", "s639818957" ]
u623819879
p03291
python
s174938334
s645816825
800
580
27,636
27,616
Accepted
Accepted
27.5
import sys sys.setrecursionlimit(1000000) #def input(): # return sys.stdin.readline()[:-1] ''' n=int(input()) for i in range(n): a[i]=int(input()) a[i],b[i]=map(int,input().split()) a=[int(x) for x in input().split()] n,m=map(int,input.split()) from operator import itemgetter a = [(1, "c", 1), ...
s=eval(input()) n=len(s) dc=dict() dc['A']=0 dc['B']=1 dc['C']=2 dc['?']=3 dp=[[0 for i in range(4)] for j in range(n+1)] dp[0][0]=1 mo=10**9+7 for i in range(n): for t in range(4): ch=s[i] m = 1 if dc[ch]==t-1 or dc[ch]==3 else 0 if t!=0: dp[i+1][t]+=(dp[i][t-1]...
93
21
2,271
411
import sys sys.setrecursionlimit(1000000) # def input(): # return sys.stdin.readline()[:-1] """ n=int(input()) for i in range(n): a[i]=int(input()) a[i],b[i]=map(int,input().split()) a=[int(x) for x in input().split()] n,m=map(int,input.split()) from operator import itemgetter a = [(1, "c", 1), (1, "b", 3),...
s = eval(input()) n = len(s) dc = dict() dc["A"] = 0 dc["B"] = 1 dc["C"] = 2 dc["?"] = 3 dp = [[0 for i in range(4)] for j in range(n + 1)] dp[0][0] = 1 mo = 10**9 + 7 for i in range(n): for t in range(4): ch = s[i] m = 1 if dc[ch] == t - 1 or dc[ch] == 3 else 0 if t != 0: dp[i +...
false
77.419355
[ "-import sys", "-", "-sys.setrecursionlimit(1000000)", "-# def input():", "-# return sys.stdin.readline()[:-1]", "-\"\"\"", "-n=int(input())", "-for i in range(n):", "- a[i]=int(input())", "- a[i],b[i]=map(int,input().split())", "-a=[int(x) for x in input().split()]", "-n,m=map(int,in...
false
0.055542
0.042219
1.315573
[ "s174938334", "s645816825" ]
u852690916
p03095
python
s056902804
s883409419
182
26
39,408
3,508
Accepted
Accepted
85.71
import sys from collections import Counter def main(): input = sys.stdin.readline N = int(eval(input())) S = input().rstrip() C = Counter(S) ans = Mint(1) for a in list(C.values()): ans *= a+1 print((ans - 1)) class Mint: def __init__(self, value=0, mod=10**9+7): ...
N=int(eval(input())) S=eval(input()) MOD = 10**9+7 class Mint: def __init__(self, value=0): self.value = value % MOD if self.value < 0: self.value += MOD @staticmethod def get_value(x): return x.value if isinstance(x, Mint) else x def inverse(self): a, b = self.va...
82
79
2,410
2,230
import sys from collections import Counter def main(): input = sys.stdin.readline N = int(eval(input())) S = input().rstrip() C = Counter(S) ans = Mint(1) for a in list(C.values()): ans *= a + 1 print((ans - 1)) class Mint: def __init__(self, value=0, mod=10**9 + 7): ...
N = int(eval(input())) S = eval(input()) MOD = 10**9 + 7 class Mint: def __init__(self, value=0): self.value = value % MOD if self.value < 0: self.value += MOD @staticmethod def get_value(x): return x.value if isinstance(x, Mint) else x def inverse(self): ...
false
3.658537
[ "-import sys", "-from collections import Counter", "-", "-", "-def main():", "- input = sys.stdin.readline", "- N = int(eval(input()))", "- S = input().rstrip()", "- C = Counter(S)", "- ans = Mint(1)", "- for a in list(C.values()):", "- ans *= a + 1", "- print((an...
false
0.036401
0.103331
0.352273
[ "s056902804", "s883409419" ]
u074220993
p03634
python
s445700930
s242992105
1,355
1,112
65,764
95,308
Accepted
Accepted
17.93
N =int(eval(input())) #graph作成 graph = [[] for _ in range(N)] for _ in range(N-1): a, b, c = list(map(int, input().split())) graph[a-1].append((b-1,c)) graph[b-1].append((a-1,c)) Q, K = list(map(int, input().split())) K -= 1 query = [tuple(int(x) for x in input().split()) for _ in range(Q)] ...
from collections import namedtuple, deque N = int(eval(input())) connection = [[] for _ in range(N)] branch = namedtuple('branch',['id', 'dist']) for _ in range(N-1): a, b, c = list(map(int, input().split())) connection[a-1].append(branch(b-1, c)) connection[b-1].append(branch(a-1, c)) dist = [0...
30
30
659
805
N = int(eval(input())) # graph作成 graph = [[] for _ in range(N)] for _ in range(N - 1): a, b, c = list(map(int, input().split())) graph[a - 1].append((b - 1, c)) graph[b - 1].append((a - 1, c)) Q, K = list(map(int, input().split())) K -= 1 query = [tuple(int(x) for x in input().split()) for _ in range(Q)] se...
from collections import namedtuple, deque N = int(eval(input())) connection = [[] for _ in range(N)] branch = namedtuple("branch", ["id", "dist"]) for _ in range(N - 1): a, b, c = list(map(int, input().split())) connection[a - 1].append(branch(b - 1, c)) connection[b - 1].append(branch(a - 1, c)) dist = [0...
false
0
[ "+from collections import namedtuple, deque", "+", "-# graph作成", "-graph = [[] for _ in range(N)]", "+connection = [[] for _ in range(N)]", "+branch = namedtuple(\"branch\", [\"id\", \"dist\"])", "- graph[a - 1].append((b - 1, c))", "- graph[b - 1].append((a - 1, c))", "+ connection[a - 1]....
false
0.036739
0.037888
0.969662
[ "s445700930", "s242992105" ]
u562935282
p03488
python
s585285912
s125423082
37
28
3,188
3,188
Accepted
Accepted
24.32
def main(): SFT = 8000 CMDs = list(map(len, input().split('T'))) X, Y = list(map(int, input().split())) # [-SFT,SFT] -> [0,SFT*2] axis = 0 curr = [1 << (next(CMDs) + SFT), 1 << SFT] for d in CMDs: axis ^= 1 curr[axis] = (curr[axis] >> d) | (curr[axis] << d) ...
def main(): *CMDs, = list(map(len, input().split('T'))) X, Y = list(map(int, input().split())) X -= CMDs[0] # この操作だけは対称性がない def is_reachable(cmds, goal): SFT = 8000 # [-SFT,SFT] -> [0,SFT*2] dp = 1 << SFT for d in cmds: dp = (dp >> d) | (dp << d)...
19
24
455
592
def main(): SFT = 8000 CMDs = list(map(len, input().split("T"))) X, Y = list(map(int, input().split())) # [-SFT,SFT] -> [0,SFT*2] axis = 0 curr = [1 << (next(CMDs) + SFT), 1 << SFT] for d in CMDs: axis ^= 1 curr[axis] = (curr[axis] >> d) | (curr[axis] << d) cond = (curr[0...
def main(): (*CMDs,) = list(map(len, input().split("T"))) X, Y = list(map(int, input().split())) X -= CMDs[0] # この操作だけは対称性がない def is_reachable(cmds, goal): SFT = 8000 # [-SFT,SFT] -> [0,SFT*2] dp = 1 << SFT for d in cmds: dp = (dp >> d) | (dp << d) r...
false
20.833333
[ "- SFT = 8000", "- CMDs = list(map(len, input().split(\"T\")))", "+ (*CMDs,) = list(map(len, input().split(\"T\")))", "- # [-SFT,SFT] -> [0,SFT*2]", "- axis = 0", "- curr = [1 << (next(CMDs) + SFT), 1 << SFT]", "- for d in CMDs:", "- axis ^= 1", "- curr[axis] = (cu...
false
0.046481
0.039975
1.162733
[ "s585285912", "s125423082" ]
u863397945
p03012
python
s785282710
s274817956
28
24
9,176
8,968
Accepted
Accepted
14.29
N = int(eval(input())) l = list(map(int, input().split())) ans = 999999 for i in range(N): f = l[:i] s = l[i:] diff = abs(sum(f)-sum(s)) if diff <= ans: ans = diff print(ans)
N = int(eval(input())) weights = list(map(int,input().split())) ans = 100*1000 for i in range(N): f = sum(weights[:i]) s = sum(weights[i:]) dif = abs(f-s) if dif < ans: ans = dif print(ans)
13
15
211
238
N = int(eval(input())) l = list(map(int, input().split())) ans = 999999 for i in range(N): f = l[:i] s = l[i:] diff = abs(sum(f) - sum(s)) if diff <= ans: ans = diff print(ans)
N = int(eval(input())) weights = list(map(int, input().split())) ans = 100 * 1000 for i in range(N): f = sum(weights[:i]) s = sum(weights[i:]) dif = abs(f - s) if dif < ans: ans = dif print(ans)
false
13.333333
[ "-l = list(map(int, input().split()))", "-ans = 999999", "+weights = list(map(int, input().split()))", "+ans = 100 * 1000", "- f = l[:i]", "- s = l[i:]", "- diff = abs(sum(f) - sum(s))", "- if diff <= ans:", "- ans = diff", "+ f = sum(weights[:i])", "+ s = sum(weights[i:...
false
0.043976
0.132922
0.330837
[ "s785282710", "s274817956" ]
u689322583
p03680
python
s484502650
s693512344
219
53
7,084
7,068
Accepted
Accepted
75.8
#coding: utf-8 N = int(eval(input())) a = [] for i in range(N): a.append(int(eval(input()))) start = 0 count = 0 for i in range(N): count += 1 next = a[start] if(next == 2): print(count) break start = next - 1 else: print((-1))
import sys N = list(map(int, sys.stdin)) bot = N[1] for i in range(N[0]): if bot == 2: print((i+1)) break bot = N[bot] else: print((-1))
19
12
274
173
# coding: utf-8 N = int(eval(input())) a = [] for i in range(N): a.append(int(eval(input()))) start = 0 count = 0 for i in range(N): count += 1 next = a[start] if next == 2: print(count) break start = next - 1 else: print((-1))
import sys N = list(map(int, sys.stdin)) bot = N[1] for i in range(N[0]): if bot == 2: print((i + 1)) break bot = N[bot] else: print((-1))
false
36.842105
[ "-# coding: utf-8", "-N = int(eval(input()))", "-a = []", "-for i in range(N):", "- a.append(int(eval(input())))", "-start = 0", "-count = 0", "-for i in range(N):", "- count += 1", "- next = a[start]", "- if next == 2:", "- print(count)", "+import sys", "+", "+N = lis...
false
0.034743
0.037809
0.918921
[ "s484502650", "s693512344" ]
u203843959
p02955
python
s337546239
s896443168
1,400
630
51,804
3,188
Accepted
Accepted
55
N,K=list(map(int,input().split())) alist=list(map(int,input().split())) sum_a=sum(alist) alist.sort() #print(sum_a,alist) #M=1の場合にも対応 divisor_set=set() for i in range(1,int(sum_a**0.5)+1): if sum_a%i==0: divisor_set.add(i) divisor_set.add(sum_a//i) divisor_list=list(divisor_set) divisor_list.s...
N,K=list(map(int,input().split())) alist=list(map(int,input().split())) sum_a=sum(alist) alist.sort() #print(sum_a,alist) #M=1の場合にも対応 divisor_set=set() for i in range(1,int(sum_a**0.5)+1): if sum_a%i==0: divisor_set.add(i) divisor_set.add(sum_a//i) divisor_list=list(divisor_set) divisor_list.s...
38
38
760
781
N, K = list(map(int, input().split())) alist = list(map(int, input().split())) sum_a = sum(alist) alist.sort() # print(sum_a,alist) # M=1の場合にも対応 divisor_set = set() for i in range(1, int(sum_a**0.5) + 1): if sum_a % i == 0: divisor_set.add(i) divisor_set.add(sum_a // i) divisor_list = list(divisor_s...
N, K = list(map(int, input().split())) alist = list(map(int, input().split())) sum_a = sum(alist) alist.sort() # print(sum_a,alist) # M=1の場合にも対応 divisor_set = set() for i in range(1, int(sum_a**0.5) + 1): if sum_a % i == 0: divisor_set.add(i) divisor_set.add(sum_a // i) divisor_list = list(divisor_s...
false
0
[ "- r1list, r2list = [], []", "+ s1list, s2list = [0], [0]", "- r1list.append(r1)", "- r2list.append(r2)", "- # print(d,r1list,r2list)", "+ s1list.append(s1list[-1] + r1)", "+ s2list.append(s2list[-1] + r2)", "+ # print(d,s1list,s2list)", "- r1sum = sum(...
false
0.035821
0.035035
1.02243
[ "s337546239", "s896443168" ]
u879309973
p02554
python
s580730994
s311756482
1,537
1,080
239,052
111,968
Accepted
Accepted
29.73
MOD = 10**9+7 def solve(n): """ 0: {} 1: {0} 2: {9} 3: {0,9} """ dp = [[0]*4 for i in range(n+1)] dp[0][0] = 1 for i in range(n): dp[i+1][3] = (10*dp[i][3] + dp[i][2] + dp[i][1]) % MOD dp[i+1][2] = (9*dp[i][2] + dp[i][0]) % MOD dp[i+1][1] = (9*dp[...
MOD = 10**9+7 def solve(n): """ 0: {} 1: {0} 2: {9} 3: {0,9} """ dp = [[0]*4 for i in range(n+1)] dp[0][0] = 1 x = [1,0,0,0] for i in range(n): x = [ (8*x[0]) % MOD, (9*x[1] + x[0]) % MOD, (9*x[2] + x[0]) % MOD, ...
19
22
442
418
MOD = 10**9 + 7 def solve(n): """ 0: {} 1: {0} 2: {9} 3: {0,9} """ dp = [[0] * 4 for i in range(n + 1)] dp[0][0] = 1 for i in range(n): dp[i + 1][3] = (10 * dp[i][3] + dp[i][2] + dp[i][1]) % MOD dp[i + 1][2] = (9 * dp[i][2] + dp[i][0]) % MOD dp[i + 1][1] = (...
MOD = 10**9 + 7 def solve(n): """ 0: {} 1: {0} 2: {9} 3: {0,9} """ dp = [[0] * 4 for i in range(n + 1)] dp[0][0] = 1 x = [1, 0, 0, 0] for i in range(n): x = [ (8 * x[0]) % MOD, (9 * x[1] + x[0]) % MOD, (9 * x[2] + x[0]) % MOD, ...
false
13.636364
[ "+ x = [1, 0, 0, 0]", "- dp[i + 1][3] = (10 * dp[i][3] + dp[i][2] + dp[i][1]) % MOD", "- dp[i + 1][2] = (9 * dp[i][2] + dp[i][0]) % MOD", "- dp[i + 1][1] = (9 * dp[i][1] + dp[i][0]) % MOD", "- dp[i + 1][0] = (8 * dp[i][0]) % MOD", "- return dp[n][3]", "+ x = [", ...
false
0.323497
0.236409
1.368377
[ "s580730994", "s311756482" ]
u309834353
p02726
python
s624548508
s889529298
1,751
1,505
14,592
21,408
Accepted
Accepted
14.05
def main(): dist = [] import numpy as np from collections import deque n, x, y = list(map(int,input().split())) g = [[] for _ in range(n)] for i in range(n-1): g[i] += i+1, g[i+1] += i, g[x-1] += y-1, g[y-1] += x-1, a = [0]*n for start in range(n): ...
def main(): dist = [] import numpy as np from collections import deque n, x, y = list(map(int,input().split())) g = [[] for _ in range(n)] for i in range(n-1): g[i] += i+1, g[i+1] += i, g[x-1] += y-1, g[y-1] += x-1, a = [0]*n for start in range(n): ...
33
34
863
886
def main(): dist = [] import numpy as np from collections import deque n, x, y = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(n - 1): g[i] += (i + 1,) g[i + 1] += (i,) g[x - 1] += (y - 1,) g[y - 1] += (x - 1,) a = [0] * n for start in...
def main(): dist = [] import numpy as np from collections import deque n, x, y = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(n - 1): g[i] += (i + 1,) g[i + 1] += (i,) g[x - 1] += (y - 1,) g[y - 1] += (x - 1,) a = [0] * n for start in...
false
2.941176
[ "+ add, pop = q.append, q.popleft", "- v = q.popleft()", "+ v = pop()", "- q.append(nv)", "+ add(nv)", "- # for i in range(1,n):", "- # print(int(a[i]/2))", "- print((\" \".join(str(i // 2) for i in a[1:])))", "+ for ...
false
0.120929
0.084021
1.439273
[ "s624548508", "s889529298" ]
u499381410
p02892
python
s085658210
s423289552
1,674
670
47,676
58,844
Accepted
Accepted
59.98
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations import sys import string INF = float('inf') def LI(): return list(map(int, sys.stdin.readline().split())) de...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys from copy import deepcopy import string from bisect import bisect_left, bisect_right from ma...
58
81
1,509
2,147
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations import sys import string INF = float("inf") def LI(): return list(map(int, sys.stdin.readline().split())) def I()...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys from copy import deepcopy import string from bisect import bisect_left, bisect_right from math import ...
false
28.395062
[ "-from itertools import permutations, accumulate, combinations", "+from itertools import permutations, accumulate, combinations, product", "+from copy import deepcopy", "+from bisect import bisect_left, bisect_right", "+from math import factorial, ceil, floor", "+from operator import mul", "+from functo...
false
0.078763
0.040542
1.942769
[ "s085658210", "s423289552" ]
u426534722
p02237
python
s196905105
s874170620
30
20
8,524
8,400
Accepted
Accepted
33.33
from sys import stdin n = int(stdin.readline()) v = [[0] * (n + 1) for i in range(n + 1)] for u in range(1, n + 1): U = [int(j) for j in stdin.readline().split()] for k in U[2:]: v[u][k] += 1 for i in range(1, n + 1): print((*v[i][1:]))
from sys import stdin n = int(stdin.readline()) v = [[0] * n for _ in range(n)] for u in range(n): l = list(map(int, stdin.readline().split())) for k in l[2:]: v[u][k - 1] = 1 print((*v[u]))
9
8
262
215
from sys import stdin n = int(stdin.readline()) v = [[0] * (n + 1) for i in range(n + 1)] for u in range(1, n + 1): U = [int(j) for j in stdin.readline().split()] for k in U[2:]: v[u][k] += 1 for i in range(1, n + 1): print((*v[i][1:]))
from sys import stdin n = int(stdin.readline()) v = [[0] * n for _ in range(n)] for u in range(n): l = list(map(int, stdin.readline().split())) for k in l[2:]: v[u][k - 1] = 1 print((*v[u]))
false
11.111111
[ "-v = [[0] * (n + 1) for i in range(n + 1)]", "-for u in range(1, n + 1):", "- U = [int(j) for j in stdin.readline().split()]", "- for k in U[2:]:", "- v[u][k] += 1", "-for i in range(1, n + 1):", "- print((*v[i][1:]))", "+v = [[0] * n for _ in range(n)]", "+for u in range(n):", "+...
false
0.1627
0.040866
3.981358
[ "s196905105", "s874170620" ]
u389910364
p03252
python
s642132456
s353860892
220
203
15,688
17,228
Accepted
Accepted
7.73
import bisect import heapq import itertools import math import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter ...
import bisect import cmath import heapq import itertools import math import operator import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce fro...
42
45
815
902
import bisect import heapq import itertools import math import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter import numpy as...
import bisect import cmath import heapq import itertools import math import operator import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator impo...
false
6.666667
[ "+import cmath", "+import operator", "-from operator import itemgetter", "+from operator import itemgetter, mul, add, xor", "-sys.setrecursionlimit(2147483647)", "+sys.setrecursionlimit(10**9)", "-S = sys.stdin.readline().rstrip()", "-T = sys.stdin.readline().rstrip()", "-table = {}", "-ok = True"...
false
0.039748
0.040039
0.992737
[ "s642132456", "s353860892" ]
u604774382
p02417
python
s097531701
s006173768
30
20
6,728
4,240
Accepted
Accepted
33.33
import sys chash = {} for i in range( ord( 'a' ), ord( 'z' )+1 ): chash[ chr( i ) ] = 0 lines = sys.stdin.readlines() for i in range( len( lines ) ): for j in range( len( lines[i] ) ): if lines[i][j].isalpha(): chash[ lines[i][j].lower() ] += 1 for i in range( ord( 'a' ), ord( 'z' )+...
import sys chash = {} for i in range( ord( 'a' ), ord( 'z' )+1 ): chash[ chr( i ) ] = 0 for line in sys.stdin: for i in range( len( line ) ): if line[i].isalpha(): chash[ line[i].lower() ] += 1 for i in range( ord( 'a' ), ord( 'z' )+1 ): print(( "{:s} : {:d}".format( ch...
14
13
391
348
import sys chash = {} for i in range(ord("a"), ord("z") + 1): chash[chr(i)] = 0 lines = sys.stdin.readlines() for i in range(len(lines)): for j in range(len(lines[i])): if lines[i][j].isalpha(): chash[lines[i][j].lower()] += 1 for i in range(ord("a"), ord("z") + 1): print(("{:s} : {:d}"...
import sys chash = {} for i in range(ord("a"), ord("z") + 1): chash[chr(i)] = 0 for line in sys.stdin: for i in range(len(line)): if line[i].isalpha(): chash[line[i].lower()] += 1 for i in range(ord("a"), ord("z") + 1): print(("{:s} : {:d}".format(chr(i), chash[chr(i)])))
false
7.142857
[ "-lines = sys.stdin.readlines()", "-for i in range(len(lines)):", "- for j in range(len(lines[i])):", "- if lines[i][j].isalpha():", "- chash[lines[i][j].lower()] += 1", "+for line in sys.stdin:", "+ for i in range(len(line)):", "+ if line[i].isalpha():", "+ ...
false
0.050167
0.049532
1.012821
[ "s097531701", "s006173768" ]
u941753895
p03574
python
s003421096
s498239297
24
22
3,064
3,188
Accepted
Accepted
8.33
h,w=list(map(int,input().split())) l=[] for i in range(h): l.append(eval(input())) al=[] for i in range(h): s='' for j in range(w): if l[i][j]=='#': s+='#' continue c=0 if i>0 and j>0 and l[i-1][j-1]=='#': c+=1 if i>0 and l[i-1][j]=='#': c+=1 if i>0 and ...
# 入力 H,W=list(map(int,input().split())) l=[] for i in range(H): l.append(list(eval(input()))) for i in range(H): for j in range(W): # 地雷数のカウンタ c=0 # '#'の場合はなにもしない if l[i][j]=='#': pass # '#'以外の場合 else: # 左上 if 0<i and 0<j and l[i-1][j-1]=='#': ...
32
48
664
848
h, w = list(map(int, input().split())) l = [] for i in range(h): l.append(eval(input())) al = [] for i in range(h): s = "" for j in range(w): if l[i][j] == "#": s += "#" continue c = 0 if i > 0 and j > 0 and l[i - 1][j - 1] == "#": c += 1 i...
# 入力 H, W = list(map(int, input().split())) l = [] for i in range(H): l.append(list(eval(input()))) for i in range(H): for j in range(W): # 地雷数のカウンタ c = 0 # '#'の場合はなにもしない if l[i][j] == "#": pass # '#'以外の場合 else: # 左上 if 0 < i an...
false
33.333333
[ "-h, w = list(map(int, input().split()))", "+# 入力", "+H, W = list(map(int, input().split()))", "-for i in range(h):", "- l.append(eval(input()))", "-al = []", "-for i in range(h):", "- s = \"\"", "- for j in range(w):", "+for i in range(H):", "+ l.append(list(eval(input())))", "+fo...
false
0.042059
0.042839
0.981784
[ "s003421096", "s498239297" ]
u638456847
p02912
python
s223360721
s545761748
160
137
14,184
14,180
Accepted
Accepted
14.37
from heapq import heappush, heappop N,M = list(map(int, input().split())) hq = [] for i in input().split(): heappush(hq, -int(i)) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq)))
from heapq import heappush, heappop, heapify def main(): N,M = list(map(int, input().split())) hq = [-int(i) for i in input().split()] heapify(hq) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq))) if __name__ == "__main__": ma...
12
17
232
322
from heapq import heappush, heappop N, M = list(map(int, input().split())) hq = [] for i in input().split(): heappush(hq, -int(i)) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq)))
from heapq import heappush, heappop, heapify def main(): N, M = list(map(int, input().split())) hq = [-int(i) for i in input().split()] heapify(hq) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq))) if __name__ == "__main__": main()
false
29.411765
[ "-from heapq import heappush, heappop", "+from heapq import heappush, heappop, heapify", "-N, M = list(map(int, input().split()))", "-hq = []", "-for i in input().split():", "- heappush(hq, -int(i))", "-for i in range(M):", "- tmp = -heappop(hq) // 2", "- heappush(hq, -tmp)", "-print((-su...
false
0.111973
0.051491
2.174617
[ "s223360721", "s545761748" ]
u231189826
p02723
python
s724331399
s382616521
188
165
38,256
38,384
Accepted
Accepted
12.23
S = list(eval(input())) if S[2] == S[3] and S[4] == S[5]: print('Yes') else: print('No')
S = list(eval(input())) print(('YNeos'[S[2::2]!=S[3::2]::2]))
6
2
96
55
S = list(eval(input())) if S[2] == S[3] and S[4] == S[5]: print("Yes") else: print("No")
S = list(eval(input())) print(("YNeos"[S[2::2] != S[3::2] :: 2]))
false
66.666667
[ "-if S[2] == S[3] and S[4] == S[5]:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+print((\"YNeos\"[S[2::2] != S[3::2] :: 2]))" ]
false
0.043862
0.097276
0.450907
[ "s724331399", "s382616521" ]
u353797797
p02610
python
s796839312
s029325399
1,809
650
128,164
42,440
Accepted
Accepted
64.07
from heapq import * import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): r...
from heapq import * import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): r...
80
44
2,343
1,116
from heapq import * import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_n...
from heapq import * import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_n...
false
45
[ "-class SegtreeMax:", "- def __init__(self, aa):", "- n = len(aa)", "- self.inf = 10**16", "- tree_width = 2", "- while tree_width < n:", "- tree_width *= 2", "- self.tree_width = tree_width", "- self.tree = [0] * (tree_width * 2 - 1)", "- ...
false
0.046869
0.108524
0.431872
[ "s796839312", "s029325399" ]
u413021823
p02613
python
s468374072
s018512120
89
81
68,004
73,800
Accepted
Accepted
8.99
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N = I() ac = 0 wa = 0 tle = 0 re = 0 for i in range(N): t = S(...
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N = I() ac = 0 wa = 0 tle = 0 re = 0 for _ in range(N): t = S(...
26
26
571
591
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N = I() ac = 0 wa = 0 tle = 0 re = 0 for i in range(N)...
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) N = I() ac = 0 wa = 0 tle = 0 re = 0 for _ in range(N)...
false
0
[ "-for i in range(N):", "+for _ in range(N):", "-print((\"AC x \" + str(ac)))", "-print((\"WA x \" + str(wa)))", "-print((\"TLE x \" + str(tle)))", "-print((\"RE x \" + str(re)))", "+print((\"AC x {}\".format(ac)))", "+print((\"WA x {}\".format(wa)))", "+print((\"TLE x {}\".format(tle)))", "+print(...
false
0.042674
0.042244
1.010193
[ "s468374072", "s018512120" ]
u347640436
p03329
python
s290297457
s358470939
403
332
3,828
3,828
Accepted
Accepted
17.62
# DP(配るDP) INF = float('inf') N = int(eval(input())) c = [1] t = 6 while t <= N: c.append(t) t *= 6 t = 9 while t <= N: c.append(t) t *= 9 dp = [INF] * (N + 1) dp[0] = 0 for i in range(N): t0 = dp[i] + 1 for j in c: t1 = i + j if t1 <= N and dp[t1] > t0: ...
# DP(配るDP) INF = float('inf') N = int(eval(input())) c = [1] t = 6 while t <= N: c.append(t) t *= 6 t = 9 while t <= N: c.append(t) t *= 9 dp = [INF] * (N + 1) dp[0] = 0 for i in range(N): t0 = dp[i] + 1 for j in c: t1 = i + j if t1 <= N and dp[t1] > t0: ...
26
24
392
352
# DP(配るDP) INF = float("inf") N = int(eval(input())) c = [1] t = 6 while t <= N: c.append(t) t *= 6 t = 9 while t <= N: c.append(t) t *= 9 dp = [INF] * (N + 1) dp[0] = 0 for i in range(N): t0 = dp[i] + 1 for j in c: t1 = i + j if t1 <= N and dp[t1] > t0: dp[t1] = t0 ...
# DP(配るDP) INF = float("inf") N = int(eval(input())) c = [1] t = 6 while t <= N: c.append(t) t *= 6 t = 9 while t <= N: c.append(t) t *= 9 dp = [INF] * (N + 1) dp[0] = 0 for i in range(N): t0 = dp[i] + 1 for j in c: t1 = i + j if t1 <= N and dp[t1] > t0: dp[t1] = t0 p...
false
7.692308
[ "- if t1 == N:", "- break" ]
false
0.315139
0.008208
38.395282
[ "s290297457", "s358470939" ]
u699296734
p03680
python
s089913773
s248081281
196
179
13,712
18,972
Accepted
Accepted
8.67
n = int(eval(input())) a = [0] * n for i in range(n): a[i] = int(eval(input())) counter = 0 now = 1 visit = [False] * n visit[0] = True while True: counter += 1 if a[now - 1] == 2: print(counter) break elif visit[a[now - 1]-1] == True: print((-1)) break ...
n = int(eval(input())) a = [0] * n for i in range(n): a[i] = int(eval(input())) visit = set() now = 1 for i in range(1, n + 10): if now not in visit: visit.add(now) now = a[now - 1] else: print((-1)) break if now == 2: print(i) break
20
17
374
301
n = int(eval(input())) a = [0] * n for i in range(n): a[i] = int(eval(input())) counter = 0 now = 1 visit = [False] * n visit[0] = True while True: counter += 1 if a[now - 1] == 2: print(counter) break elif visit[a[now - 1] - 1] == True: print((-1)) break else: ...
n = int(eval(input())) a = [0] * n for i in range(n): a[i] = int(eval(input())) visit = set() now = 1 for i in range(1, n + 10): if now not in visit: visit.add(now) now = a[now - 1] else: print((-1)) break if now == 2: print(i) break
false
15
[ "-counter = 0", "+visit = set()", "-visit = [False] * n", "-visit[0] = True", "-while True:", "- counter += 1", "- if a[now - 1] == 2:", "- print(counter)", "- break", "- elif visit[a[now - 1] - 1] == True:", "+for i in range(1, n + 10):", "+ if now not in visit:", ...
false
0.0471
0.045707
1.030489
[ "s089913773", "s248081281" ]
u923662841
p03031
python
s279392210
s425880943
141
39
27,116
9,188
Accepted
Accepted
72.34
import numpy as np N,M = list(map(int, input().split())) S = [] for i in range(M): k,*s = list(map(int, input().split())) T = [0]*N for j in s: T[j-1]=1 S.append(T) P = list(map(int, input().split())) ans =0 for x in range(2**N): y = format(x,"0{}b".format(N)) z = list(map(i...
N,M = list(map(int, input().split())) s = [list(map(int, input().split()))[1:] for _ in range(M)] p = list(map(int, input().split())) count = 0 for i in range(1<<N): for m in range(M): switch=0 for j in range(N): if (i>>j)&1 and j+1 in s[m]: switch += 1 ...
18
15
426
397
import numpy as np N, M = list(map(int, input().split())) S = [] for i in range(M): k, *s = list(map(int, input().split())) T = [0] * N for j in s: T[j - 1] = 1 S.append(T) P = list(map(int, input().split())) ans = 0 for x in range(2**N): y = format(x, "0{}b".format(N)) z = list(map(int...
N, M = list(map(int, input().split())) s = [list(map(int, input().split()))[1:] for _ in range(M)] p = list(map(int, input().split())) count = 0 for i in range(1 << N): for m in range(M): switch = 0 for j in range(N): if (i >> j) & 1 and j + 1 in s[m]: switch += 1 ...
false
16.666667
[ "-import numpy as np", "-", "-S = []", "-for i in range(M):", "- k, *s = list(map(int, input().split()))", "- T = [0] * N", "- for j in s:", "- T[j - 1] = 1", "- S.append(T)", "-P = list(map(int, input().split()))", "-ans = 0", "-for x in range(2**N):", "- y = format(x,...
false
0.168182
0.039961
4.208641
[ "s279392210", "s425880943" ]
u945181840
p03253
python
s005068338
s864410583
974
23
121,844
3,572
Accepted
Accepted
97.64
from itertools import groupby N, M = list(map(int, input().split())) mod = 10 ** 9 + 7 def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: ...
from itertools import groupby from operator import mul from functools import reduce N, M = list(map(int, input().split())) mod = 10 ** 9 + 7 def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: ...
67
46
1,299
866
from itertools import groupby N, M = list(map(int, input().split())) mod = 10**9 + 7 def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if ...
from itertools import groupby from operator import mul from functools import reduce N, M = list(map(int, input().split())) mod = 10**9 + 7 def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) ...
false
31.343284
[ "+from operator import mul", "+from functools import reduce", "-def make_table(n, mod=10**9 + 7):", "- N = n", "- # 元テーブル", "- g1 = [0] * (N + 1)", "- g1[0] = 1", "- g1[1] = 1", "- # 逆元テーブル", "- g2 = [0] * (N + 1)", "- g2[0] = 1", "- g2[1] = 1", "- # 逆元テーブル計算用テー...
false
2.276182
0.041284
55.135146
[ "s005068338", "s864410583" ]
u998082063
p02676
python
s961916913
s885205789
26
24
10,060
9,164
Accepted
Accepted
7.69
from collections import defaultdict, deque import sys import heapq import bisect import itertools import queue import copy import time sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readli...
K = int(eval(input())) S = list(eval(input())) if K >= len(S): print((''.join(S))) else: s = ''.join(S[:K]) print(f'{s}...')
27
8
539
134
from collections import defaultdict, deque import sys import heapq import bisect import itertools import queue import copy import time sys.setrecursionlimit(10**8) INF = float("inf") mod = 10**9 + 7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline...
K = int(eval(input())) S = list(eval(input())) if K >= len(S): print(("".join(S))) else: s = "".join(S[:K]) print(f"{s}...")
false
70.37037
[ "-from collections import defaultdict, deque", "-import sys", "-import heapq", "-import bisect", "-import itertools", "-import queue", "-import copy", "-import time", "-", "-sys.setrecursionlimit(10**8)", "-INF = float(\"inf\")", "-mod = 10**9 + 7", "-eps = 10**-7", "-", "-", "-def inp...
false
0.061756
0.03709
1.665056
[ "s961916913", "s885205789" ]
u091051505
p02623
python
s469138386
s900812498
336
298
47,704
47,500
Accepted
Accepted
11.31
from bisect import bisect_right n, m, k = list(map(int, input().split())) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] A = [0] B = [0] for i in range(n): A.append(A[-1] + a[i]) for j in range(m): B.append(B[-1] + b[j]) ans = 0 for i in range(n + 1): time = ...
from bisect import bisect_right n, m, k = list(map(int, input().split())) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] A = [0] B = [0] for i in range(n): A.append(A[-1] + a[i]) for j in range(m): B.append(B[-1] + b[j]) ans = 0 j = m for i in range(n + 1): ...
21
21
458
424
from bisect import bisect_right n, m, k = list(map(int, input().split())) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] A = [0] B = [0] for i in range(n): A.append(A[-1] + a[i]) for j in range(m): B.append(B[-1] + b[j]) ans = 0 for i in range(n + 1): time = A[i] b_index = ...
from bisect import bisect_right n, m, k = list(map(int, input().split())) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] A = [0] B = [0] for i in range(n): A.append(A[-1] + a[i]) for j in range(m): B.append(B[-1] + b[j]) ans = 0 j = m for i in range(n + 1): if A[i] > k: ...
false
0
[ "+j = m", "- time = A[i]", "- b_index = 0", "- if time > k:", "+ if A[i] > k:", "- b_index = bisect_right(B, k - time)", "- ans = max(ans, i + b_index - 1)", "+ while B[j] > k - A[i]:", "+ j -= 1", "+ ans = max(ans, i + j)" ]
false
0.097848
0.075432
1.297177
[ "s469138386", "s900812498" ]
u788137651
p03109
python
s783572896
s755099320
20
18
2,940
2,940
Accepted
Accepted
10
y, m, d = list(map(int, input().split("/"))) if y <= 2018: heisei = True elif y == 2019 and m <= 4: heisei = True else: heisei = False if heisei: print("Heisei") else: print("TBD")
S = eval(input()) if S > "2019/04/30": print("TBD") else: print("Heisei")
11
5
205
80
y, m, d = list(map(int, input().split("/"))) if y <= 2018: heisei = True elif y == 2019 and m <= 4: heisei = True else: heisei = False if heisei: print("Heisei") else: print("TBD")
S = eval(input()) if S > "2019/04/30": print("TBD") else: print("Heisei")
false
54.545455
[ "-y, m, d = list(map(int, input().split(\"/\")))", "-if y <= 2018:", "- heisei = True", "-elif y == 2019 and m <= 4:", "- heisei = True", "+S = eval(input())", "+if S > \"2019/04/30\":", "+ print(\"TBD\")", "- heisei = False", "-if heisei:", "-else:", "- print(\"TBD\")" ]
false
0.277938
0.046681
5.953933
[ "s783572896", "s755099320" ]
u526603504
p03031
python
s996844133
s587471072
203
33
42,732
3,064
Accepted
Accepted
83.74
N, M = list(map(int, input().split())) sss = [] for _ in range(M): k, *ss = [int(x) - 1 for x in input().split()] sss.append(ss) ps = list([x == '0' for x in input().split()]) # 全てのスイッチのパターンをチェック cnt = 0 for i in range(2 ** N): lights = ps[:] for j, ss in enumerate(sss): for s in ...
import itertools N, M = list(map(int, input().split())) skss = [] for _ in range(M): k, *sks = list(map(int, input().split())) skss.append(set(sks)) pMs = list([x == '0' for x in input().split()]) count = 0 for i in range(2 ** N): pMstmp = pMs[:] for j, b in enumerate(format(i, '0' + str(N...
20
22
451
537
N, M = list(map(int, input().split())) sss = [] for _ in range(M): k, *ss = [int(x) - 1 for x in input().split()] sss.append(ss) ps = list([x == "0" for x in input().split()]) # 全てのスイッチのパターンをチェック cnt = 0 for i in range(2**N): lights = ps[:] for j, ss in enumerate(sss): for s in ss: i...
import itertools N, M = list(map(int, input().split())) skss = [] for _ in range(M): k, *sks = list(map(int, input().split())) skss.append(set(sks)) pMs = list([x == "0" for x in input().split()]) count = 0 for i in range(2**N): pMstmp = pMs[:] for j, b in enumerate(format(i, "0" + str(N) + "b")): ...
false
9.090909
[ "+import itertools", "+", "-sss = []", "+skss = []", "- k, *ss = [int(x) - 1 for x in input().split()]", "- sss.append(ss)", "-ps = list([x == \"0\" for x in input().split()])", "-# 全てのスイッチのパターンをチェック", "-cnt = 0", "+ k, *sks = list(map(int, input().split()))", "+ skss.append(set(sks)...
false
0.040689
0.035195
1.156113
[ "s996844133", "s587471072" ]
u474925961
p03137
python
s754401300
s980173284
1,745
250
23,044
23,048
Accepted
Accepted
85.67
import numpy as np n,m=list(map(int,input().split())) x=list(map(int,input().split())) arr=np.array(sorted(x)) dif=np.diff(arr) lis=dif.tolist() lis=sorted(lis,reverse=True) for i in range(n-1): if len(lis)>0: lis.pop(0) print((sum(lis)))
import numpy as np n,m=list(map(int,input().split())) x=list(map(int,input().split())) arr=np.array(sorted(x)) dif=np.diff(arr) lis=dif.tolist() lis=sorted(lis) for i in range(n-1): if len(lis)>0: lis.pop() print((sum(lis)))
15
15
260
246
import numpy as np n, m = list(map(int, input().split())) x = list(map(int, input().split())) arr = np.array(sorted(x)) dif = np.diff(arr) lis = dif.tolist() lis = sorted(lis, reverse=True) for i in range(n - 1): if len(lis) > 0: lis.pop(0) print((sum(lis)))
import numpy as np n, m = list(map(int, input().split())) x = list(map(int, input().split())) arr = np.array(sorted(x)) dif = np.diff(arr) lis = dif.tolist() lis = sorted(lis) for i in range(n - 1): if len(lis) > 0: lis.pop() print((sum(lis)))
false
0
[ "-lis = sorted(lis, reverse=True)", "+lis = sorted(lis)", "- lis.pop(0)", "+ lis.pop()" ]
false
0.007267
0.21882
0.033208
[ "s754401300", "s980173284" ]
u287132915
p02735
python
s881365328
s722775549
45
31
3,432
3,316
Accepted
Accepted
31.11
h, w = list(map(int, input().split())) lst = [['*' for i in range(w+2)]] for i in range(h): string = eval(input()) lsti = ['*'] for j in range(w): lsti.append(string[j]) if string[j] == 's': start = (i+1, j+1) elif string[j] == 'g': goal = (i+1, j+1)...
h, w = list(map(int, input().split())) lst = [['*' for i in range(w+2)]] for i in range(h): lsti = ['*'] lsti.extend(list(eval(input()))) lsti.append('*') lst.append(lsti) lst.append(['*' for i in range(w+2)]) lst_cnt = [[300 for i in range(w+2)] for j in range(h+2)] if lst[1][1] == '#': lst_...
56
30
1,990
942
h, w = list(map(int, input().split())) lst = [["*" for i in range(w + 2)]] for i in range(h): string = eval(input()) lsti = ["*"] for j in range(w): lsti.append(string[j]) if string[j] == "s": start = (i + 1, j + 1) elif string[j] == "g": goal = (i + 1, j + 1)...
h, w = list(map(int, input().split())) lst = [["*" for i in range(w + 2)]] for i in range(h): lsti = ["*"] lsti.extend(list(eval(input()))) lsti.append("*") lst.append(lsti) lst.append(["*" for i in range(w + 2)]) lst_cnt = [[300 for i in range(w + 2)] for j in range(h + 2)] if lst[1][1] == "#": lst...
false
46.428571
[ "- string = eval(input())", "- for j in range(w):", "- lsti.append(string[j])", "- if string[j] == \"s\":", "- start = (i + 1, j + 1)", "- elif string[j] == \"g\":", "- goal = (i + 1, j + 1)", "+ lsti.extend(list(eval(input())))", "-queue_new = [(1...
false
0.035648
0.073534
0.484786
[ "s881365328", "s722775549" ]
u678167152
p02732
python
s006012894
s051838830
333
281
34,664
34,140
Accepted
Accepted
15.62
N = int(input()) A = list(map(int, input().split())) di = {} B = set(A) for b in B: di[b] = 0 total = 0 for a in A: di[a]+=1 for v in di.values(): total += v*(v-1)//2 #print(di.values(),total) ans = [] for a in A: ans.append(total-di[a]+1) print(*ans,sep='\n')
from collections import Counter def solve(): N = int(input()) A = list(map(int, input().split())) c = Counter(A) cnt = 0 for k,v in c.items(): cnt += v*(v-1)//2 ans = [cnt]*N for i in range(N): ans[i] -= c[A[i]]*(c[A[i]]-1)//2 ans[i] += (c[A[i]]-1)*(c[A[i]]-2)//2 return ans ...
17
15
285
344
N = int(input()) A = list(map(int, input().split())) di = {} B = set(A) for b in B: di[b] = 0 total = 0 for a in A: di[a] += 1 for v in di.values(): total += v * (v - 1) // 2 # print(di.values(),total) ans = [] for a in A: ans.append(total - di[a] + 1) print(*ans, sep="\n")
from collections import Counter def solve(): N = int(input()) A = list(map(int, input().split())) c = Counter(A) cnt = 0 for k, v in c.items(): cnt += v * (v - 1) // 2 ans = [cnt] * N for i in range(N): ans[i] -= c[A[i]] * (c[A[i]] - 1) // 2 ans[i] += (c[A[i]] - 1) ...
false
11.764706
[ "-N = int(input())", "-A = list(map(int, input().split()))", "-di = {}", "-B = set(A)", "-for b in B:", "- di[b] = 0", "-total = 0", "-for a in A:", "- di[a] += 1", "-for v in di.values():", "- total += v * (v - 1) // 2", "-# print(di.values(),total)", "-ans = []", "-for a in A:",...
false
0.007545
0.03593
0.209996
[ "s006012894", "s051838830" ]
u535171899
p03290
python
s754281626
s975989333
145
28
3,064
3,064
Accepted
Accepted
80.69
d,g = list(map(int,input().split())) p_input = [0]*d c_input = [0]*d for i in range(d): p_input[i],c_input[i] = list(map(int,input().split())) ans=float('inf') for i in range(2**d): problem=0 point=0 for j in range(d): if ((i>>j)&1): problem+=p_input[j] po...
d,g = list(map(int,input().split())) P = [0]*d C = [0]*d for i in range(d): P[i],C[i] = list(map(int,input().split())) ans = float('inf') for i in range(2**d): tmp = 0 res = 0 for j in range(d): if ((i>>j)&1): tmp+=C[j]+(j+1)*100*P[j] res+=P[j] if tmp<g...
29
30
711
792
d, g = list(map(int, input().split())) p_input = [0] * d c_input = [0] * d for i in range(d): p_input[i], c_input[i] = list(map(int, input().split())) ans = float("inf") for i in range(2**d): problem = 0 point = 0 for j in range(d): if (i >> j) & 1: problem += p_input[j] ...
d, g = list(map(int, input().split())) P = [0] * d C = [0] * d for i in range(d): P[i], C[i] = list(map(int, input().split())) ans = float("inf") for i in range(2**d): tmp = 0 res = 0 for j in range(d): if (i >> j) & 1: tmp += C[j] + (j + 1) * 100 * P[j] res += P[j] i...
false
3.333333
[ "-p_input = [0] * d", "-c_input = [0] * d", "+P = [0] * d", "+C = [0] * d", "- p_input[i], c_input[i] = list(map(int, input().split()))", "+ P[i], C[i] = list(map(int, input().split()))", "- problem = 0", "- point = 0", "+ tmp = 0", "+ res = 0", "- problem += p_input...
false
0.006036
0.051767
0.116599
[ "s754281626", "s975989333" ]
u021019433
p02948
python
s072766243
s449815676
529
447
17,624
18,388
Accepted
Accepted
15.5
from heapq import * R = lambda: list(map(int, input().split())) n, m = R() c = [[] for _ in range(m)] for _ in range(n): a, b = R() if a <= m: heappush(c[m - a], -b) r=0 for i in range(m - 1, -1, -1): if c[i]: r -= heappop(c[i]) if i: f = len(c[i]) > len(c[...
from heapq import heappush, heappop R = lambda: list(map(int, input().split())) n, m = R() c = [[] for _ in range(m)] for _ in range(n): a, b = R() if a <= m: c[m - a].append(b) r=0 h = [] for l in reversed(c): for x in l: heappush(h, -x) if h: r -= heappop(h) p...
21
17
512
322
from heapq import * R = lambda: list(map(int, input().split())) n, m = R() c = [[] for _ in range(m)] for _ in range(n): a, b = R() if a <= m: heappush(c[m - a], -b) r = 0 for i in range(m - 1, -1, -1): if c[i]: r -= heappop(c[i]) if i: f = len(c[i]) > len(c[i - 1]) ...
from heapq import heappush, heappop R = lambda: list(map(int, input().split())) n, m = R() c = [[] for _ in range(m)] for _ in range(n): a, b = R() if a <= m: c[m - a].append(b) r = 0 h = [] for l in reversed(c): for x in l: heappush(h, -x) if h: r -= heappop(h) print(r)
false
19.047619
[ "-from heapq import *", "+from heapq import heappush, heappop", "- heappush(c[m - a], -b)", "+ c[m - a].append(b)", "-for i in range(m - 1, -1, -1):", "- if c[i]:", "- r -= heappop(c[i])", "- if i:", "- f = len(c[i]) > len(c[i - 1])", "- h, g = ...
false
0.057619
0.031973
1.802107
[ "s072766243", "s449815676" ]
u201928947
p02708
python
s491891475
s174020478
62
55
63,212
61,920
Accepted
Accepted
11.29
n,k = list(map(int,input().split())) mod = 10**9+7 ans = 0 for i in range(k,n+2): ans += i*(n-i+1)+1 ans %= mod print(ans)
n,k = list(map(int,input().split())) mod = 10**9+7 print((((-(2*(n+1)**3+3*(n+1)**2+n+1)//6)+(n*(n+1)**2+n*(n+1))//2+((n+1)**2+n+1)//2-((k-1)*n+(k-1)**2*n)//2+n+(k+2*(k-1)**3+3*(k-1)**2-1)//6-(k+(k-1)**2-1)//2-k+2) % mod))
7
3
130
216
n, k = list(map(int, input().split())) mod = 10**9 + 7 ans = 0 for i in range(k, n + 2): ans += i * (n - i + 1) + 1 ans %= mod print(ans)
n, k = list(map(int, input().split())) mod = 10**9 + 7 print( ( ( (-(2 * (n + 1) ** 3 + 3 * (n + 1) ** 2 + n + 1) // 6) + (n * (n + 1) ** 2 + n * (n + 1)) // 2 + ((n + 1) ** 2 + n + 1) // 2 - ((k - 1) * n + (k - 1) ** 2 * n) // 2 + n + ...
false
57.142857
[ "-ans = 0", "-for i in range(k, n + 2):", "- ans += i * (n - i + 1) + 1", "- ans %= mod", "-print(ans)", "+print(", "+ (", "+ (", "+ (-(2 * (n + 1) ** 3 + 3 * (n + 1) ** 2 + n + 1) // 6)", "+ + (n * (n + 1) ** 2 + n * (n + 1)) // 2", "+ + ((n + 1)...
false
0.135398
0.087072
1.555017
[ "s491891475", "s174020478" ]
u620084012
p03705
python
s146239326
s915243214
161
17
38,256
2,940
Accepted
Accepted
89.44
N, A, B = list(map(int,input().split())) if N == 1: print((1 if A==B else 0)) else: if A > B: print((0)) else: m = A*(N-1)+B M = B*(N-1)+A print((M-m+1))
N, A, B = list(map(int,input().split())) if A > B: print((0)) exit(0) if N == 1: if A != B: print((0)) else: print((1)) else: print(((N-1)*B+A-(N-1)*A-B+1))
10
11
195
189
N, A, B = list(map(int, input().split())) if N == 1: print((1 if A == B else 0)) else: if A > B: print((0)) else: m = A * (N - 1) + B M = B * (N - 1) + A print((M - m + 1))
N, A, B = list(map(int, input().split())) if A > B: print((0)) exit(0) if N == 1: if A != B: print((0)) else: print((1)) else: print(((N - 1) * B + A - (N - 1) * A - B + 1))
false
9.090909
[ "+if A > B:", "+ print((0))", "+ exit(0)", "- print((1 if A == B else 0))", "-else:", "- if A > B:", "+ if A != B:", "- m = A * (N - 1) + B", "- M = B * (N - 1) + A", "- print((M - m + 1))", "+ print((1))", "+else:", "+ print(((N - 1) * B + A - (...
false
0.047571
0.044167
1.077063
[ "s146239326", "s915243214" ]
u060793972
p02996
python
s102693417
s730325005
958
457
53,724
49,116
Accepted
Accepted
52.3
n=int(eval(input())) l=list() for i in range(n): l.append(list(map(int,input().split()))) l.sort(key=lambda x:x[1]) t=0#time p=True for i,j in l: t+=i if t>j: p=False print('No') break if p: print('Yes')
n,*pl=list(map(int,open(0).read().split())) l=[[pl[i],pl[i+1]] for i in range(0,n*2,2)] l.sort(key=lambda x:x[1]) t=0#time p=True for i,j in l: t+=i if t>j: p=False print('No') break if p: print('Yes')
15
13
251
243
n = int(eval(input())) l = list() for i in range(n): l.append(list(map(int, input().split()))) l.sort(key=lambda x: x[1]) t = 0 # time p = True for i, j in l: t += i if t > j: p = False print("No") break if p: print("Yes")
n, *pl = list(map(int, open(0).read().split())) l = [[pl[i], pl[i + 1]] for i in range(0, n * 2, 2)] l.sort(key=lambda x: x[1]) t = 0 # time p = True for i, j in l: t += i if t > j: p = False print("No") break if p: print("Yes")
false
13.333333
[ "-n = int(eval(input()))", "-l = list()", "-for i in range(n):", "- l.append(list(map(int, input().split())))", "+n, *pl = list(map(int, open(0).read().split()))", "+l = [[pl[i], pl[i + 1]] for i in range(0, n * 2, 2)]" ]
false
0.078757
0.051719
1.5228
[ "s102693417", "s730325005" ]
u060694763
p02780
python
s161195829
s901046496
179
163
23,588
24,808
Accepted
Accepted
8.94
N, K = list(map(int, input().split())) P = list(map(float, input().split())) p = [0] for i in range(N): p.append(p[-1] + (P[i] + 1) / 2) print((max(p[i+K] - p[i] for i in range(N-K+1))))
N, K = list(map(int, input().split())) P = list(map(int, input().split())) p = [0] for i in range(N): p.append(p[-1] + (P[i] + 1) / 2) print((max([p[j + K] - p[j] for j in range(N - K + 1)])))
8
8
198
204
N, K = list(map(int, input().split())) P = list(map(float, input().split())) p = [0] for i in range(N): p.append(p[-1] + (P[i] + 1) / 2) print((max(p[i + K] - p[i] for i in range(N - K + 1))))
N, K = list(map(int, input().split())) P = list(map(int, input().split())) p = [0] for i in range(N): p.append(p[-1] + (P[i] + 1) / 2) print((max([p[j + K] - p[j] for j in range(N - K + 1)])))
false
0
[ "-P = list(map(float, input().split()))", "+P = list(map(int, input().split()))", "-print((max(p[i + K] - p[i] for i in range(N - K + 1))))", "+print((max([p[j + K] - p[j] for j in range(N - K + 1)])))" ]
false
0.042863
0.043482
0.985768
[ "s161195829", "s901046496" ]
u231095456
p03805
python
s387009162
s964283008
32
28
3,064
3,064
Accepted
Accepted
12.5
import sys input = sys.stdin.readline N, M = list(map(int,input().split())) edge_from = [[] for _ in range(N)] for i in range(M): a, b = list(map(int,input().split())) a -= 1 b -= 1 edge_from[a].append(b) edge_from[b].append(a) def rec(v, visited): if len(visited) == N: ret...
N, M = list(map(int,input().split())) edges = [[] for _ in range(N)] for _ in range(M): a,b = list(map(int,input().split())) edges[a-1].append(b-1) edges[b-1].append(a-1) def dfs(i, used): if len(used) == N: return 1 ans = 0 for j in edges[i]: if j not in used: ...
20
16
481
375
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) edge_from = [[] for _ in range(N)] for i in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 edge_from[a].append(b) edge_from[b].append(a) def rec(v, visited): if len(visited) == N: return 1 ...
N, M = list(map(int, input().split())) edges = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) edges[a - 1].append(b - 1) edges[b - 1].append(a - 1) def dfs(i, used): if len(used) == N: return 1 ans = 0 for j in edges[i]: if j not in used: ...
false
20
[ "-import sys", "-", "-input = sys.stdin.readline", "-edge_from = [[] for _ in range(N)]", "-for i in range(M):", "+edges = [[] for _ in range(N)]", "+for _ in range(M):", "- a -= 1", "- b -= 1", "- edge_from[a].append(b)", "- edge_from[b].append(a)", "+ edges[a - 1].append(b - 1...
false
0.036332
0.036686
0.990365
[ "s387009162", "s964283008" ]
u489959379
p03031
python
s111402380
s007030790
36
30
3,064
3,064
Accepted
Accepted
16.67
n, m = list(map(int, input().split())) s = [] for _ in range(m): _, *args = list(map(int, input().split())) s.append(args) p = list(map(int, input().split())) ans = 0 for i in range(2 ** n): for j in range(m): sw = 0 for k in range(n): if (i >> k) & 1 and k + 1 in s[j]...
from itertools import product n, m = list(map(int, input().split())) ks = [] for i in range(m): k, *arg = list(map(int, input().split())) ks.append((k, arg)) p = list(map(int, input().split())) res = 0 for pattern in product((0, 1), repeat=n): for i in range(m): cnt = 0 k, s =...
18
22
423
471
n, m = list(map(int, input().split())) s = [] for _ in range(m): _, *args = list(map(int, input().split())) s.append(args) p = list(map(int, input().split())) ans = 0 for i in range(2**n): for j in range(m): sw = 0 for k in range(n): if (i >> k) & 1 and k + 1 in s[j]: ...
from itertools import product n, m = list(map(int, input().split())) ks = [] for i in range(m): k, *arg = list(map(int, input().split())) ks.append((k, arg)) p = list(map(int, input().split())) res = 0 for pattern in product((0, 1), repeat=n): for i in range(m): cnt = 0 k, s = ks[i] ...
false
18.181818
[ "+from itertools import product", "+", "-s = []", "-for _ in range(m):", "- _, *args = list(map(int, input().split()))", "- s.append(args)", "+ks = []", "+for i in range(m):", "+ k, *arg = list(map(int, input().split()))", "+ ks.append((k, arg))", "-ans = 0", "-for i in range(2**n)...
false
0.045845
0.045192
1.014452
[ "s111402380", "s007030790" ]
u442472098
p02257
python
s581490679
s351137521
3,550
690
6,892
6,732
Accepted
Accepted
80.56
#!/usr/bin/env python3 from itertools import takewhile from math import sqrt def is_prime(primes, i): if i in primes: return True for p in takewhile(lambda x: x * x <= i, sorted(primes)): if i % p == 0: return False return True def sieve_of_eratosthenes(max): ...
#!/usr/bin/env python3 from itertools import count, takewhile def prime(): prime = [] def _isPrime(n): for d in takewhile(lambda x: x * x <= n, prime): if n % d == 0: return False return True for i in count(2): if _isPrime(i): ...
34
33
802
699
#!/usr/bin/env python3 from itertools import takewhile from math import sqrt def is_prime(primes, i): if i in primes: return True for p in takewhile(lambda x: x * x <= i, sorted(primes)): if i % p == 0: return False return True def sieve_of_eratosthenes(max): is_prime = [...
#!/usr/bin/env python3 from itertools import count, takewhile def prime(): prime = [] def _isPrime(n): for d in takewhile(lambda x: x * x <= n, prime): if n % d == 0: return False return True for i in count(2): if _isPrime(i): prime.append(...
false
2.941176
[ "-from itertools import takewhile", "-from math import sqrt", "+from itertools import count, takewhile", "+", "+", "+def prime():", "+ prime = []", "+", "+ def _isPrime(n):", "+ for d in takewhile(lambda x: x * x <= n, prime):", "+ if n % d == 0:", "+ ret...
false
0.037995
0.04638
0.819216
[ "s581490679", "s351137521" ]
u379959788
p02744
python
s855518635
s047475211
200
145
4,412
12,980
Accepted
Accepted
27.5
# D N = int(eval(input())) al = [chr(ord('a') + i) for i in range(26)] def dfs(S, i): if len(S) == N: yield S return for j in range(i): for w in dfs(S + al[j], i): yield w for w in dfs(S + al[i], i + 1): yield w for w in dfs('', 0): print(w)
# D N = int(eval(input())) al = [chr(ord('a') + i) for i in range(26)] ans = ['a'] for i in range(N-1): tmp = [] for s in ans: stop = ord(max(s)) + 1 for i in range(ord('a'), stop+1): tmp.append(s + chr(i)) ans = tmp for s in ans: print(s)
17
15
314
293
# D N = int(eval(input())) al = [chr(ord("a") + i) for i in range(26)] def dfs(S, i): if len(S) == N: yield S return for j in range(i): for w in dfs(S + al[j], i): yield w for w in dfs(S + al[i], i + 1): yield w for w in dfs("", 0): print(w)
# D N = int(eval(input())) al = [chr(ord("a") + i) for i in range(26)] ans = ["a"] for i in range(N - 1): tmp = [] for s in ans: stop = ord(max(s)) + 1 for i in range(ord("a"), stop + 1): tmp.append(s + chr(i)) ans = tmp for s in ans: print(s)
false
11.764706
[ "-", "-", "-def dfs(S, i):", "- if len(S) == N:", "- yield S", "- return", "- for j in range(i):", "- for w in dfs(S + al[j], i):", "- yield w", "- for w in dfs(S + al[i], i + 1):", "- yield w", "-", "-", "-for w in dfs(\"\", 0):", "- pr...
false
0.035212
0.056701
0.621025
[ "s855518635", "s047475211" ]
u289547799
p03161
python
s545673021
s085347860
432
374
84,064
56,032
Accepted
Accepted
13.43
n, k = list(map(int, input().split())) step = list(map(int, input().split())) ans = [float('inf')]*(10**6) ans[0] = 0 def dp(n): for i in range(n): for j in range(k+1): if i+j < n: ans[i+j] = min(ans[i+j], ans[i] + abs(step[i+j] - step[i])) return ans[n-1] print((dp(n)))
n, k = list(map(int, input().split())) lst = list(map(int, input().split())) + [0]*k ans = [float('inf')]*(n+k) ans[0] = 0 def dp(): for i in range(n): for j in range(1, k+1): ans[i+j] = min(ans[i+j], ans[i] + abs(lst[i+j]-lst[i])) dp() print((ans[n-1]))
14
13
301
273
n, k = list(map(int, input().split())) step = list(map(int, input().split())) ans = [float("inf")] * (10**6) ans[0] = 0 def dp(n): for i in range(n): for j in range(k + 1): if i + j < n: ans[i + j] = min(ans[i + j], ans[i] + abs(step[i + j] - step[i])) return ans[n - 1] p...
n, k = list(map(int, input().split())) lst = list(map(int, input().split())) + [0] * k ans = [float("inf")] * (n + k) ans[0] = 0 def dp(): for i in range(n): for j in range(1, k + 1): ans[i + j] = min(ans[i + j], ans[i] + abs(lst[i + j] - lst[i])) dp() print((ans[n - 1]))
false
7.142857
[ "-step = list(map(int, input().split()))", "-ans = [float(\"inf\")] * (10**6)", "+lst = list(map(int, input().split())) + [0] * k", "+ans = [float(\"inf\")] * (n + k)", "-def dp(n):", "+def dp():", "- for j in range(k + 1):", "- if i + j < n:", "- ans[i + j] = min(an...
false
0.059821
0.039114
1.529416
[ "s545673021", "s085347860" ]
u626331732
p03854
python
s837547244
s384160066
71
18
3,188
3,188
Accepted
Accepted
74.65
s = eval(input()) while True: if s[-7:] == 'dreamer': s = s[:-7] elif s[-6:] == 'eraser': s = s[:-6] elif s[-5:] == 'dream': s = s[:-5] elif s[-5:] == 'erase': s = s[:-5] else: print('NO') break if len(s) == 0: print('YES') ...
target = ['eraser', 'erase', 'dreamer', 'dream'] s = eval(input()) for x in target: s = s.replace(x, "") if s == "": print("YES") else: print("NO")
17
10
329
164
s = eval(input()) while True: if s[-7:] == "dreamer": s = s[:-7] elif s[-6:] == "eraser": s = s[:-6] elif s[-5:] == "dream": s = s[:-5] elif s[-5:] == "erase": s = s[:-5] else: print("NO") break if len(s) == 0: print("YES") break
target = ["eraser", "erase", "dreamer", "dream"] s = eval(input()) for x in target: s = s.replace(x, "") if s == "": print("YES") else: print("NO")
false
41.176471
[ "+target = [\"eraser\", \"erase\", \"dreamer\", \"dream\"]", "-while True:", "- if s[-7:] == \"dreamer\":", "- s = s[:-7]", "- elif s[-6:] == \"eraser\":", "- s = s[:-6]", "- elif s[-5:] == \"dream\":", "- s = s[:-5]", "- elif s[-5:] == \"erase\":", "- s = s...
false
0.075518
0.054568
1.38391
[ "s837547244", "s384160066" ]
u761529120
p03575
python
s959363174
s460051170
184
78
40,048
73,948
Accepted
Accepted
57.61
N, M = list(map(int, input().split())) graph = [[0 for i in range(N)] for j in range(N)] edges = [] for m in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 edges.append([a,b]) graph[a][b] = 1 graph[b][a] = 1 ans = 0 for a,b in edges: graph[a][b] = 0 graph[b...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): ...
34
68
688
1,677
N, M = list(map(int, input().split())) graph = [[0 for i in range(N)] for j in range(N)] edges = [] for m in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 edges.append([a, b]) graph[a][b] = 1 graph[b][a] = 1 ans = 0 for a, b in edges: graph[a][b] = 0 graph[b][a] = 0 ...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = se...
false
50
[ "-N, M = list(map(int, input().split()))", "-graph = [[0 for i in range(N)] for j in range(N)]", "-edges = []", "-for m in range(M):", "- a, b = list(map(int, input().split()))", "- a -= 1", "- b -= 1", "- edges.append([a, b])", "- graph[a][b] = 1", "- graph[b][a] = 1", "-ans =...
false
0.081471
0.057428
1.418676
[ "s959363174", "s460051170" ]
u527867336
p03069
python
s813627861
s782324735
124
78
12,764
3,500
Accepted
Accepted
37.1
# coding:utf-8 def main(): N = int(eval(input())) s = eval(input()) count_white = 0 count_black = 0 count_border = N temp = "" patern3_white = [0]*N patern3_black = [0]*N # patern3 = [] if (not "." in s) or (not "#" in s): print((0)) return f...
# coding:utf-8 def main(): N = int(eval(input())) s = eval(input()) count_white = 0 count_black = 0 count_border = N # patern_border_white = [0]*N # patern_border_black = [0]*N if (not "." in s) or (not "#" in s): print((0)) return for i in s: ...
54
62
1,485
1,927
# coding:utf-8 def main(): N = int(eval(input())) s = eval(input()) count_white = 0 count_black = 0 count_border = N temp = "" patern3_white = [0] * N patern3_black = [0] * N # patern3 = [] if (not "." in s) or (not "#" in s): print((0)) return for i in s: ...
# coding:utf-8 def main(): N = int(eval(input())) s = eval(input()) count_white = 0 count_black = 0 count_border = N # patern_border_white = [0]*N # patern_border_black = [0]*N if (not "." in s) or (not "#" in s): print((0)) return for i in s: if i == ".": ...
false
12.903226
[ "- temp = \"\"", "- patern3_white = [0] * N", "- patern3_black = [0] * N", "- # patern3 = []", "+ # patern_border_white = [0]*N", "+ # patern_border_black = [0]*N", "+ patern_border_white = 0", "+ patern_border_black = 0", "+ temp_border_white = 0", "+ temp_border_bla...
false
0.035463
0.037988
0.933535
[ "s813627861", "s782324735" ]