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
u440161695
p03160
python
s528421428
s463814378
163
136
13,980
13,980
Accepted
Accepted
16.56
N=int(eval(input())) A=list(map(int,input().split())) A+=[0] A+=[0] dp=[float("INF")]*(N+2) dp[0]=0 dp[1]=abs(A[1]-A[0]) for i in range(N): dp[i+1]=min(dp[i+1],abs(A[i+1]-A[i])+dp[i]) dp[i+2]=min(dp[i+2],abs(A[i+2]-A[i])+dp[i]) print((dp[N-1]))
N=int(eval(input())) A=list(map(int,input().split())) dp=[float("INF")]*N dp[0]=0 dp[1]=abs(A[0]-A[1]) for i in range(2,N): dp[i]=min(dp[i],abs(A[i]-A[i-1])+dp[i-1],abs(A[i-2]-A[i])+dp[i-2]) print((dp[-1]))
11
8
250
208
N = int(eval(input())) A = list(map(int, input().split())) A += [0] A += [0] dp = [float("INF")] * (N + 2) dp[0] = 0 dp[1] = abs(A[1] - A[0]) for i in range(N): dp[i + 1] = min(dp[i + 1], abs(A[i + 1] - A[i]) + dp[i]) dp[i + 2] = min(dp[i + 2], abs(A[i + 2] - A[i]) + dp[i]) print((dp[N - 1]))
N = int(eval(input())) A = list(map(int, input().split())) dp = [float("INF")] * N dp[0] = 0 dp[1] = abs(A[0] - A[1]) for i in range(2, N): dp[i] = min( dp[i], abs(A[i] - A[i - 1]) + dp[i - 1], abs(A[i - 2] - A[i]) + dp[i - 2] ) print((dp[-1]))
false
27.272727
[ "-A += [0]", "-A += [0]", "-dp = [float(\"INF\")] * (N + 2)", "+dp = [float(\"INF\")] * N", "-dp[1] = abs(A[1] - A[0])", "-for i in range(N):", "- dp[i + 1] = min(dp[i + 1], abs(A[i + 1] - A[i]) + dp[i])", "- dp[i + 2] = min(dp[i + 2], abs(A[i + 2] - A[i]) + dp[i])", "-print((dp[N - 1]))", "...
false
0.049791
0.049594
1.003984
[ "s528421428", "s463814378" ]
u540761833
p03457
python
s122727710
s403693498
499
386
27,380
3,064
Accepted
Accepted
22.65
N = int(eval(input())) flag = 'Yes' txy = [[0,0,0]] for i in range(N): a = list(map(int,input().split())) txy.append(a) td = txy[i+1][0] - txy[i][0] xd = abs(txy[i+1][1] - txy[i][1]) yd = abs(txy[i+1][2] - txy[i][2]) if (td < xd + yd) or ((td-(xd+yd))%2 == 1): flag = 'No' prin...
N = int(eval(input())) now = [0,0] tnow = 0 ans = 'Yes' for i in range(N): t,x,y = list(map(int,input().split())) dis = abs(x-now[0]) + abs(y-now[1]) if t-tnow >= dis and (t-tnow)%2 == dis%2: tnow = t now = [x,y] else: ans = 'No' break print(ans)
12
14
321
295
N = int(eval(input())) flag = "Yes" txy = [[0, 0, 0]] for i in range(N): a = list(map(int, input().split())) txy.append(a) td = txy[i + 1][0] - txy[i][0] xd = abs(txy[i + 1][1] - txy[i][1]) yd = abs(txy[i + 1][2] - txy[i][2]) if (td < xd + yd) or ((td - (xd + yd)) % 2 == 1): flag = "No" ...
N = int(eval(input())) now = [0, 0] tnow = 0 ans = "Yes" for i in range(N): t, x, y = list(map(int, input().split())) dis = abs(x - now[0]) + abs(y - now[1]) if t - tnow >= dis and (t - tnow) % 2 == dis % 2: tnow = t now = [x, y] else: ans = "No" break print(ans)
false
14.285714
[ "-flag = \"Yes\"", "-txy = [[0, 0, 0]]", "+now = [0, 0]", "+tnow = 0", "+ans = \"Yes\"", "- a = list(map(int, input().split()))", "- txy.append(a)", "- td = txy[i + 1][0] - txy[i][0]", "- xd = abs(txy[i + 1][1] - txy[i][1])", "- yd = abs(txy[i + 1][2] - txy[i][2])", "- if (td <...
false
0.127809
0.084969
1.504183
[ "s122727710", "s403693498" ]
u894114233
p00519
python
s727904415
s225396369
38,310
24,410
921,344
520,512
Accepted
Accepted
36.28
from collections import deque import heapq def dijkstra(s,g,m): color=[0]*n dis=[float('inf')]*n dis[s]=0 heapq.heappush(pq,[0,s]) while len(pq)!=0: t,u=heapq.heappop(pq) color[u]=2 if dis[u]<t: continue for v in g[u]: if color[v...
from collections import deque import heapq def dijkstra(s,g,m): color=[0]*n dis=[float('inf')]*n dis[s]=0 heapq.heappush(pq,[0,s]) while len(pq)!=0: t,u=heapq.heappop(pq) color[u]=2 if dis[u]<t: continue for v in g[u]: if color[v...
53
50
1,314
1,290
from collections import deque import heapq def dijkstra(s, g, m): color = [0] * n dis = [float("inf")] * n dis[s] = 0 heapq.heappush(pq, [0, s]) while len(pq) != 0: t, u = heapq.heappop(pq) color[u] = 2 if dis[u] < t: continue for v in g[u]: ...
from collections import deque import heapq def dijkstra(s, g, m): color = [0] * n dis = [float("inf")] * n dis[s] = 0 heapq.heappush(pq, [0, s]) while len(pq) != 0: t, u = heapq.heappop(pq) color[u] = 2 if dis[u] < t: continue for v in g[u]: ...
false
5.660377
[ "+cost = [[float(\"inf\")] * n for _ in range(n)]", "+newg = [[] * n for _ in range(n)]", "- q.append(j)", "-cost = [[float(\"inf\")] * n for _ in range(n)]", "-newg = [[] * n for _ in range(n)]", "-for i in range(n):", "- for j in range(n):", "- if d[i][j] <= cr[i][1]:", "-...
false
0.089119
0.05764
1.546132
[ "s727904415", "s225396369" ]
u491762407
p02947
python
s371293066
s797535562
394
341
18,236
19,788
Accepted
Accepted
13.45
from collections import Counter N = int(eval(input())) ans = {} answer = 0 for _ in range(N): s = "".join(sorted(eval(input()))) if s not in ans: ans[s] = 0 else: ans[s] += 1 answer += ans[s] print(answer)
N = int(eval(input())) s = [''.join(sorted(eval(input()))) for _ in range(N)] from collections import Counter counter = Counter(s) ans = sum(n*(n-1)//2 for n in list(counter.values())) print(ans)
17
7
255
185
from collections import Counter N = int(eval(input())) ans = {} answer = 0 for _ in range(N): s = "".join(sorted(eval(input()))) if s not in ans: ans[s] = 0 else: ans[s] += 1 answer += ans[s] print(answer)
N = int(eval(input())) s = ["".join(sorted(eval(input()))) for _ in range(N)] from collections import Counter counter = Counter(s) ans = sum(n * (n - 1) // 2 for n in list(counter.values())) print(ans)
false
58.823529
[ "+N = int(eval(input()))", "+s = [\"\".join(sorted(eval(input()))) for _ in range(N)]", "-N = int(eval(input()))", "-ans = {}", "-answer = 0", "-for _ in range(N):", "- s = \"\".join(sorted(eval(input())))", "- if s not in ans:", "- ans[s] = 0", "- else:", "- ans[s] += 1",...
false
0.03396
0.105171
0.322903
[ "s371293066", "s797535562" ]
u254871849
p02722
python
s149459365
s794890241
210
188
3,952
3,952
Accepted
Accepted
10.48
import sys from math import sqrt, floor def divisors(n): res = set() for i in range(1, floor(sqrt(n)) + 1): if n % i == 0: res.add(i) res.add(n // i) return res - set([1]) n = int(sys.stdin.readline().rstrip()) def main(): res = divisors(n - 1) cnt ...
import sys from math import sqrt, floor def divisors(n): res = set() for i in range(1, floor(sqrt(n)) + 1): if not n % i: res.add(i) res.add(n // i) return res - set([1]) n = int(sys.stdin.readline().rstrip()) def main(): res = divisors(n - 1) cnt =...
27
26
562
529
import sys from math import sqrt, floor def divisors(n): res = set() for i in range(1, floor(sqrt(n)) + 1): if n % i == 0: res.add(i) res.add(n // i) return res - set([1]) n = int(sys.stdin.readline().rstrip()) def main(): res = divisors(n - 1) cnt = len(res) ...
import sys from math import sqrt, floor def divisors(n): res = set() for i in range(1, floor(sqrt(n)) + 1): if not n % i: res.add(i) res.add(n // i) return res - set([1]) n = int(sys.stdin.readline().rstrip()) def main(): res = divisors(n - 1) cnt = len(res) ...
false
3.703704
[ "- if n % i == 0:", "+ if not n % i:", "- if i in res:", "- continue", "- while m % i == 0:", "+ while not m % i:" ]
false
0.05589
0.08247
0.677707
[ "s149459365", "s794890241" ]
u597374218
p02622
python
s644819183
s910355390
59
48
9,432
9,220
Accepted
Accepted
18.64
S = eval(input()) T = eval(input()) count = 0 for i in range(len(S)): if S[i] != T[i]: count += 1 print(count)
S = eval(input()) T = eval(input()) print((sum(1 for s, t in zip(S, T) if s != t)))
7
3
116
71
S = eval(input()) T = eval(input()) count = 0 for i in range(len(S)): if S[i] != T[i]: count += 1 print(count)
S = eval(input()) T = eval(input()) print((sum(1 for s, t in zip(S, T) if s != t)))
false
57.142857
[ "-count = 0", "-for i in range(len(S)):", "- if S[i] != T[i]:", "- count += 1", "-print(count)", "+print((sum(1 for s, t in zip(S, T) if s != t)))" ]
false
0.037514
0.038917
0.96395
[ "s644819183", "s910355390" ]
u790710233
p02743
python
s121552778
s057322464
93
17
5,076
2,940
Accepted
Accepted
81.72
from decimal import Decimal, getcontext getcontext().prec = 1000 a, b, c = list(map(Decimal, input().split())) print(("Yes" if a+b+Decimal(2)*((a*b)**Decimal(0.5)) < c else "No"))
a, b, c = list(map(int, input().split())) if c-a-b < 0: print("No") else: print(("Yes" if (c-a-b)**2-4*a*b > 0 else "No"))
4
5
175
127
from decimal import Decimal, getcontext getcontext().prec = 1000 a, b, c = list(map(Decimal, input().split())) print(("Yes" if a + b + Decimal(2) * ((a * b) ** Decimal(0.5)) < c else "No"))
a, b, c = list(map(int, input().split())) if c - a - b < 0: print("No") else: print(("Yes" if (c - a - b) ** 2 - 4 * a * b > 0 else "No"))
false
20
[ "-from decimal import Decimal, getcontext", "-", "-getcontext().prec = 1000", "-a, b, c = list(map(Decimal, input().split()))", "-print((\"Yes\" if a + b + Decimal(2) * ((a * b) ** Decimal(0.5)) < c else \"No\"))", "+a, b, c = list(map(int, input().split()))", "+if c - a - b < 0:", "+ print(\"No\")...
false
0.0969
0.091079
1.063911
[ "s121552778", "s057322464" ]
u588341295
p03112
python
s257552105
s814277990
1,393
1,265
30,124
30,120
Accepted
Accepted
9.19
# -*- coding: utf-8 -*- import sys, re from collections import deque, defaultdict, Counter from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10 if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd from heapq import heappop, heappush, heapify, heappushpop from b...
# -*- coding: utf-8 -*- import sys, re from collections import deque, defaultdict, Counter from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10 if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd from heapq import heappop, heappush, heapify, heappushpop from b...
94
90
2,716
2,602
# -*- coding: utf-8 -*- import sys, re from collections import deque, defaultdict, Counter from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10 if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd from heapq import heappop, heappush, heapify, heappushpop from bi...
# -*- coding: utf-8 -*- import sys, re from collections import deque, defaultdict, Counter from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10 if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd from heapq import heappop, heappush, heapify, heappushpop from bi...
false
4.255319
[ "-S = [0] * (A + 2)", "+S = [-INF] * (A + 2)", "-T = [0] * (B + 2)", "+T = [-INF] * (B + 2)", "- if S[idx] != 0:", "- # idx番目の神社に行く", "- dist1 = x - S[idx]", "- # idx番目の神社から一番近い寺に行く", "- dist1 += min(L1[idx], R1[idx])", "+ # idx番目の神社に行く", "+ dist1 = x - S[idx...
false
0.048965
0.037125
1.318897
[ "s257552105", "s814277990" ]
u945181840
p02773
python
s945225033
s882460988
368
299
45,044
38,520
Accepted
Accepted
18.75
import sys from collections import Counter read = sys.stdin.read N, *S = list(map(str, read().split())) s = Counter(S).most_common() n = s[0][1] answer = [i for i, j in s if j == n] answer.sort() print(('\n'.join(answer)))
import sys from collections import Counter read = sys.stdin.read N, *S = list(map(str, read().split())) s = Counter(S) n = max(s.values()) answer = [i for i, j in list(s.items()) if j == n] answer.sort() print(('\n'.join(answer)))
11
11
227
229
import sys from collections import Counter read = sys.stdin.read N, *S = list(map(str, read().split())) s = Counter(S).most_common() n = s[0][1] answer = [i for i, j in s if j == n] answer.sort() print(("\n".join(answer)))
import sys from collections import Counter read = sys.stdin.read N, *S = list(map(str, read().split())) s = Counter(S) n = max(s.values()) answer = [i for i, j in list(s.items()) if j == n] answer.sort() print(("\n".join(answer)))
false
0
[ "-s = Counter(S).most_common()", "-n = s[0][1]", "-answer = [i for i, j in s if j == n]", "+s = Counter(S)", "+n = max(s.values())", "+answer = [i for i, j in list(s.items()) if j == n]" ]
false
0.083905
0.076847
1.091842
[ "s945225033", "s882460988" ]
u977389981
p03495
python
s838992505
s432813169
205
185
37,732
37,784
Accepted
Accepted
9.76
from collections import Counter n, k = list(map(int, input().split())) A = Counter([int(i) for i in input().split()]).most_common() count = 0 if len(A) > k: for i in range(len(A) - k): count += A[k + i][1] print(count)
from collections import Counter N, K = list(map(int, input().split())) A = Counter([int(i) for i in input().split()]).most_common() cnt = 0 for a in A[K:]: cnt += a[1] print(cnt)
11
7
245
182
from collections import Counter n, k = list(map(int, input().split())) A = Counter([int(i) for i in input().split()]).most_common() count = 0 if len(A) > k: for i in range(len(A) - k): count += A[k + i][1] print(count)
from collections import Counter N, K = list(map(int, input().split())) A = Counter([int(i) for i in input().split()]).most_common() cnt = 0 for a in A[K:]: cnt += a[1] print(cnt)
false
36.363636
[ "-n, k = list(map(int, input().split()))", "+N, K = list(map(int, input().split()))", "-count = 0", "-if len(A) > k:", "- for i in range(len(A) - k):", "- count += A[k + i][1]", "-print(count)", "+cnt = 0", "+for a in A[K:]:", "+ cnt += a[1]", "+print(cnt)" ]
false
0.058072
0.057267
1.014041
[ "s838992505", "s432813169" ]
u952656646
p03061
python
s817310609
s841805681
1,866
213
14,276
14,436
Accepted
Accepted
88.59
class SegmentTree: def __init__(self, seq, func="min"): if func=="min": self.f = min self.e = float('inf') if func=="max": self.f = max self.e = -float('inf') if func=="gcd": self.f = gcd self.e = 0 se...
def gcd(a, b): if b==0: return a while b>0: a, b = b, a%b return a N = int(eval(input())) A = list(map(int, input().split())) S_left = [0 for _ in range(N+1)] S_right = [0 for _ in range(N+1)] for i in range(N): S_left[i+1] = gcd(S_left[i], A[i]) S_right[i+1] = gcd(S_righ...
67
20
1,860
499
class SegmentTree: def __init__(self, seq, func="min"): if func == "min": self.f = min self.e = float("inf") if func == "max": self.f = max self.e = -float("inf") if func == "gcd": self.f = gcd self.e = 0 self._n...
def gcd(a, b): if b == 0: return a while b > 0: a, b = b, a % b return a N = int(eval(input())) A = list(map(int, input().split())) S_left = [0 for _ in range(N + 1)] S_right = [0 for _ in range(N + 1)] for i in range(N): S_left[i + 1] = gcd(S_left[i], A[i]) S_right[i + 1] = gcd(S_...
false
70.149254
[ "-class SegmentTree:", "- def __init__(self, seq, func=\"min\"):", "- if func == \"min\":", "- self.f = min", "- self.e = float(\"inf\")", "- if func == \"max\":", "- self.f = max", "- self.e = -float(\"inf\")", "- if func == \"gcd\...
false
0.042613
0.079718
0.534551
[ "s817310609", "s841805681" ]
u555767343
p02829
python
s662264900
s092746571
186
163
38,256
38,256
Accepted
Accepted
12.37
a = int(eval(input())) b = int(eval(input())) A = [1, 2, 3] A[a-1]= 0 A[b-1] = 0 print((sum(A)))
a = int(eval(input())) b = int(eval(input())) print((6-a-b))
7
3
89
48
a = int(eval(input())) b = int(eval(input())) A = [1, 2, 3] A[a - 1] = 0 A[b - 1] = 0 print((sum(A)))
a = int(eval(input())) b = int(eval(input())) print((6 - a - b))
false
57.142857
[ "-A = [1, 2, 3]", "-A[a - 1] = 0", "-A[b - 1] = 0", "-print((sum(A)))", "+print((6 - a - b))" ]
false
0.04446
0.043092
1.031733
[ "s662264900", "s092746571" ]
u624454021
p00015
python
s481051444
s440168473
30
20
7,652
7,584
Accepted
Accepted
33.33
import math n = int(eval(input())); for i in range(n): num1 = int(eval(input())); num2 = int(eval(input())); total = num1 + num2; if len(str(total)) > 80: print("overflow"); else: print(total);
import math n = int(eval(input())); for i in range(0,n): num1 = int(eval(input())); num2 = int(eval(input())); total = num1 + num2; if len(str(total)) > 80: print("overflow"); else: print(total);
15
15
250
252
import math n = int(eval(input())) for i in range(n): num1 = int(eval(input())) num2 = int(eval(input())) total = num1 + num2 if len(str(total)) > 80: print("overflow") else: print(total)
import math n = int(eval(input())) for i in range(0, n): num1 = int(eval(input())) num2 = int(eval(input())) total = num1 + num2 if len(str(total)) > 80: print("overflow") else: print(total)
false
0
[ "-for i in range(n):", "+for i in range(0, n):" ]
false
0.04673
0.03677
1.270853
[ "s481051444", "s440168473" ]
u219417113
p03053
python
s085480489
s734036200
998
684
169,180
169,052
Accepted
Accepted
31.46
from collections import deque h, w = list(map(int, input().split())) a = [list(eval(input())) for _ in range(h)] move = [(1,0), (0,1), (-1,0), (0,-1)] queue = deque() visited = [[-1] * w for _ in range(h)] for row in range(h): for col in range(w): if a[row][col] == "#": visited[row]...
from collections import deque h, w = list(map(int, input().split())) a = [list(eval(input())) for _ in range(h)] move = [(1,0), (0,1), (-1,0), (0,-1)] queue = deque() visited = [[-1] * w for _ in range(h)] for row in range(h): for col in range(w): if a[row][col] == "#": visited[row]...
23
23
719
717
from collections import deque h, w = list(map(int, input().split())) a = [list(eval(input())) for _ in range(h)] move = [(1, 0), (0, 1), (-1, 0), (0, -1)] queue = deque() visited = [[-1] * w for _ in range(h)] for row in range(h): for col in range(w): if a[row][col] == "#": visited[row][col] = ...
from collections import deque h, w = list(map(int, input().split())) a = [list(eval(input())) for _ in range(h)] move = [(1, 0), (0, 1), (-1, 0), (0, -1)] queue = deque() visited = [[-1] * w for _ in range(h)] for row in range(h): for col in range(w): if a[row][col] == "#": visited[row][col] = ...
false
0
[ "- a[row + drow : row + drow + 1]", "- and a[row + drow][col + dcol : col + dcol + 1]", "+ row + drow >= 0", "+ and row + drow < h", "+ and col + dcol >= 0", "+ and col + dcol < w" ]
false
0.0361
0.036824
0.980348
[ "s085480489", "s734036200" ]
u554781254
p02658
python
s731032830
s265151850
91
75
21,732
21,732
Accepted
Accepted
17.58
import sys sys.setrecursionlimit(10 ** 9) input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A = sorted(A) total = A[0] limit = 10 ** 18 for a in A[1:]: total *= a if total > limit: print((-1)) exit() print(total)
import sys sys.setrecursionlimit(10 ** 9) input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) limit = 10 ** 18 A = sorted(A) total = A[0] if total == 0: print(total) exit() for a in A[1:]: total *= a if total > limit: print((-1)) ...
19
22
288
334
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) A = sorted(A) total = A[0] limit = 10**18 for a in A[1:]: total *= a if total > limit: print((-1)) exit() print(total)
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) limit = 10**18 A = sorted(A) total = A[0] if total == 0: print(total) exit() for a in A[1:]: total *= a if total > limit: print((-1)) exit() print(total)
false
13.636364
[ "+limit = 10**18", "-limit = 10**18", "+if total == 0:", "+ print(total)", "+ exit()" ]
false
0.088413
0.038873
2.274415
[ "s731032830", "s265151850" ]
u357751375
p03106
python
s027333853
s910897517
31
27
8,960
9,108
Accepted
Accepted
12.9
a,b,k = list(map(int,input().split())) c = 0 i = max(a,b) while i > 0: if a % i == 0: if b % i == 0: c += 1 if c == k: print(i) break i -= 1
a,b,k = list(map(int,input().split())) t = [] for i in range(1,100+1): if a % i == 0 and b % i == 0: t.append(i) t.sort(reverse=True) print((t[k-1]))
14
7
198
159
a, b, k = list(map(int, input().split())) c = 0 i = max(a, b) while i > 0: if a % i == 0: if b % i == 0: c += 1 if c == k: print(i) break i -= 1
a, b, k = list(map(int, input().split())) t = [] for i in range(1, 100 + 1): if a % i == 0 and b % i == 0: t.append(i) t.sort(reverse=True) print((t[k - 1]))
false
50
[ "-c = 0", "-i = max(a, b)", "-while i > 0:", "- if a % i == 0:", "- if b % i == 0:", "- c += 1", "- if c == k:", "- print(i)", "- break", "- i -= 1", "+t = []", "+for i in range(1, 100 + 1):", "+ if a % i == 0 and b % i == 0:", "+ t.append...
false
0.044477
0.107093
0.41531
[ "s027333853", "s910897517" ]
u907668975
p02781
python
s080381774
s676081285
476
26
3,060
3,812
Accepted
Accepted
94.54
def solve(n,k) : if n <= 9 and k == 1 : return n elif n <= 9 and k >= 2 : return 0 elif k == 0: return 1 else : m = n //10 r = n % 10 return r * solve(m,k-1) + (9 - r) * solve(m-1,k-1) + solve(m,k) n = int(eval(input())) k = int(eval(input()...
from functools import lru_cache @lru_cache(None) def solve(n,k) : if n <= 9 and k == 1 : return n elif n <= 9 and k >= 2 : return 0 elif k == 0: return 1 else : m = n //10 r = n % 10 return r * solve(m,k-1) + (9 - r) * solve(m-1,k-1) + solve(m...
15
17
330
381
def solve(n, k): if n <= 9 and k == 1: return n elif n <= 9 and k >= 2: return 0 elif k == 0: return 1 else: m = n // 10 r = n % 10 return r * solve(m, k - 1) + (9 - r) * solve(m - 1, k - 1) + solve(m, k) n = int(eval(input())) k = int(eval(input())) pri...
from functools import lru_cache @lru_cache(None) def solve(n, k): if n <= 9 and k == 1: return n elif n <= 9 and k >= 2: return 0 elif k == 0: return 1 else: m = n // 10 r = n % 10 return r * solve(m, k - 1) + (9 - r) * solve(m - 1, k - 1) + solve(m, k) ...
false
11.764706
[ "+from functools import lru_cache", "+", "+", "+@lru_cache(None)" ]
false
0.132125
0.03608
3.661996
[ "s080381774", "s676081285" ]
u440566786
p03160
python
s797770018
s608668772
243
219
50,288
52,976
Accepted
Accepted
9.88
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=sys.stdin.readline def resolve(): n=int(eval(input())) H=list(map(int,input().split())) dp=[0]*n dp[1]=abs(H[1]-H[0]) for i in range(2,n): dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2])) ...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() def resolve(): n, k = int(eval(input())), 2 dp = [INF] * n dp[0] = 0 H = list(map(int, input().split())) for i in range(n): for pi in range(i - k, i)...
14
17
343
458
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = sys.stdin.readline def resolve(): n = int(eval(input())) H = list(map(int, input().split())) dp = [0] * n dp[1] = abs(H[1] - H[0]) for i in range(2, n): dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda: sys.stdin.readline().rstrip() def resolve(): n, k = int(eval(input())), 2 dp = [INF] * n dp[0] = 0 H = list(map(int, input().split())) for i in range(n): for pi in range(i - k, i): ...
false
17.647059
[ "+INF = 1 << 60", "+MOD = 10**9 + 7 # 998244353", "-INF = float(\"inf\")", "-MOD = 10**9 + 7", "-input = sys.stdin.readline", "+input = lambda: sys.stdin.readline().rstrip()", "- n = int(eval(input()))", "+ n, k = int(eval(input())), 2", "+ dp = [INF] * n", "+ dp[0] = 0", "- dp =...
false
0.090808
0.045162
2.010706
[ "s797770018", "s608668772" ]
u203843959
p02947
python
s660738607
s964365851
418
291
17,800
18,192
Accepted
Accepted
30.38
N=int(eval(input())) s_dic={} for i in range(N): s=list(eval(input())) s.sort() s_str="".join(s) if s_str in s_dic: s_dic[s_str]+=1 else: s_dic[s_str]=1 #print(s_dic) answer=0 for key in s_dic: answer+=(s_dic[key]*(s_dic[key]-1))//2 print(answer)
from collections import defaultdict import sys input=sys.stdin.readline N=int(eval(input())) s_dic=defaultdict(int) for i in range(N): s=list(input().rstrip()) s.sort() s_str="".join(s) s_dic[s_str]+=1 #print(s_dic) answer=0 for val in list(s_dic.values()): answer+=(val*(val-1))//2 print(a...
19
18
278
314
N = int(eval(input())) s_dic = {} for i in range(N): s = list(eval(input())) s.sort() s_str = "".join(s) if s_str in s_dic: s_dic[s_str] += 1 else: s_dic[s_str] = 1 # print(s_dic) answer = 0 for key in s_dic: answer += (s_dic[key] * (s_dic[key] - 1)) // 2 print(answer)
from collections import defaultdict import sys input = sys.stdin.readline N = int(eval(input())) s_dic = defaultdict(int) for i in range(N): s = list(input().rstrip()) s.sort() s_str = "".join(s) s_dic[s_str] += 1 # print(s_dic) answer = 0 for val in list(s_dic.values()): answer += (val * (val - 1)...
false
5.263158
[ "+from collections import defaultdict", "+import sys", "+", "+input = sys.stdin.readline", "-s_dic = {}", "+s_dic = defaultdict(int)", "- s = list(eval(input()))", "+ s = list(input().rstrip())", "- if s_str in s_dic:", "- s_dic[s_str] += 1", "- else:", "- s_dic[s_str...
false
0.057437
0.05906
0.972525
[ "s660738607", "s964365851" ]
u293528047
p04001
python
s567364978
s476927118
27
23
3,060
4,140
Accepted
Accepted
14.81
s = eval(input()) l = len(s) ans = 0 for i in range(2**(l-1)): f = "" for n in range(l): f += s[n] if (i>>n) & 1: f += "+" ans += eval(f) print(ans)
s = eval(input()) l = len(s) f = "" for i in range(2**(l-1)): for n in range(l): f += s[n] if (i>>n) & 1: f += "+" f += "+" f += "0" print((eval(f)))
13
13
196
191
s = eval(input()) l = len(s) ans = 0 for i in range(2 ** (l - 1)): f = "" for n in range(l): f += s[n] if (i >> n) & 1: f += "+" ans += eval(f) print(ans)
s = eval(input()) l = len(s) f = "" for i in range(2 ** (l - 1)): for n in range(l): f += s[n] if (i >> n) & 1: f += "+" f += "+" f += "0" print((eval(f)))
false
0
[ "-ans = 0", "+f = \"\"", "- f = \"\"", "- ans += eval(f)", "-print(ans)", "+ f += \"+\"", "+f += \"0\"", "+print((eval(f)))" ]
false
0.082969
0.050271
1.650449
[ "s567364978", "s476927118" ]
u347640436
p03201
python
s046764527
s907397280
672
614
44,560
44,560
Accepted
Accepted
8.63
from bisect import bisect_right n = int(eval(input())) d = {} amax = 0 for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 amax = max(amax, a) t = 1 valids = [] while t < 2 * amax: t *= 2 valids.append(t) result = 0 while True: prev = result keys = list(d.keys...
from bisect import bisect_right n = int(eval(input())) d = {} amax = 0 for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 amax = max(d.keys()) t = 1 valids = [] while t < 2 * amax: t *= 2 valids.append(t) result = 0 while True: prev = result keys = list(d.keys(...
43
43
792
791
from bisect import bisect_right n = int(eval(input())) d = {} amax = 0 for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 amax = max(amax, a) t = 1 valids = [] while t < 2 * amax: t *= 2 valids.append(t) result = 0 while True: prev = result keys = list(d...
from bisect import bisect_right n = int(eval(input())) d = {} amax = 0 for a in map(int, input().split()): if a in d: d[a] += 1 else: d[a] = 1 amax = max(d.keys()) t = 1 valids = [] while t < 2 * amax: t *= 2 valids.append(t) result = 0 while True: prev = result keys = list(d.ke...
false
0
[ "- amax = max(amax, a)", "+amax = max(d.keys())" ]
false
0.037796
0.036828
1.026284
[ "s046764527", "s907397280" ]
u419963262
p03473
python
s926592516
s695214029
19
17
2,940
2,940
Accepted
Accepted
10.53
print((24*2-int(eval(input()))))
print((48-int(eval(input()))))
1
1
24
23
print((24 * 2 - int(eval(input()))))
print((48 - int(eval(input()))))
false
0
[ "-print((24 * 2 - int(eval(input()))))", "+print((48 - int(eval(input()))))" ]
false
0.043674
0.044218
0.987702
[ "s926592516", "s695214029" ]
u930705402
p03855
python
s254393486
s363540135
1,615
643
119,760
156,652
Accepted
Accepted
60.19
from collections import Counter def find(x): if(par[x]==x): return x else: par[x]=find(par[x]) return par[x] def union(a,b): a=find(a) b=find(b) if(a==b): return 0 else: if rank[a]>rank[b]: par[b]=a siz[a]+=siz[b] ...
from collections import Counter class UnionFind: def __init__(self,N): self.par=[i for i in range(N)] self.siz=[1 for _ in range(N)] self.rank=[0 for _ in range(N)] def find(self,x): if self.par[x]==x: return x else: self.par[x]=self.find...
50
45
1,068
1,286
from collections import Counter def find(x): if par[x] == x: return x else: par[x] = find(par[x]) return par[x] def union(a, b): a = find(a) b = find(b) if a == b: return 0 else: if rank[a] > rank[b]: par[b] = a siz[a] += siz[b]...
from collections import Counter class UnionFind: def __init__(self, N): self.par = [i for i in range(N)] self.siz = [1 for _ in range(N)] self.rank = [0 for _ in range(N)] def find(self, x): if self.par[x] == x: return x else: self.par[x] = self...
false
10
[ "-def find(x):", "- if par[x] == x:", "- return x", "- else:", "- par[x] = find(par[x])", "- return par[x]", "+class UnionFind:", "+ def __init__(self, N):", "+ self.par = [i for i in range(N)]", "+ self.siz = [1 for _ in range(N)]", "+ self.ran...
false
0.066876
0.127358
0.525104
[ "s254393486", "s363540135" ]
u892487306
p03946
python
s461613311
s375307422
91
78
24,144
14,252
Accepted
Accepted
14.29
def main(): N, T = list(map(int, input().split(' '))) A = list(map(int, input().split(' '))) target_list = list() price_buy, town_num_buy = A[N - 1], 1 price_sell, town_num_sell = A[N - 1], 1 for t in range(N - 2, -1, -1): price = A[t] if price < price_buy: p...
def main(): N, T = list(map(int, input().split(' '))) A = list(map(int, input().split(' '))) score_list = [0 for _ in range(N)] min_price = A[0] for i in range(N): a = A[i] score_list[i] = a - min_price min_price = min(a, min_price) max_score = max(score_list) ...
39
19
1,283
476
def main(): N, T = list(map(int, input().split(" "))) A = list(map(int, input().split(" "))) target_list = list() price_buy, town_num_buy = A[N - 1], 1 price_sell, town_num_sell = A[N - 1], 1 for t in range(N - 2, -1, -1): price = A[t] if price < price_buy: price_buy ...
def main(): N, T = list(map(int, input().split(" "))) A = list(map(int, input().split(" "))) score_list = [0 for _ in range(N)] min_price = A[0] for i in range(N): a = A[i] score_list[i] = a - min_price min_price = min(a, min_price) max_score = max(score_list) ans = 0...
false
51.282051
[ "- target_list = list()", "- price_buy, town_num_buy = A[N - 1], 1", "- price_sell, town_num_sell = A[N - 1], 1", "- for t in range(N - 2, -1, -1):", "- price = A[t]", "- if price < price_buy:", "- price_buy = price", "- town_num_buy = 1", "- el...
false
0.0486
0.115121
0.422163
[ "s461613311", "s375307422" ]
u260980560
p02345
python
s598269460
s681555471
1,960
1,220
9,300
12,512
Accepted
Accepted
37.76
n, q = list(map(int, input().split())) n0 = 2**n.bit_length() INF = 2**31-1 data = [INF]*(n0*2) def update(k, a): k += n0 - 1 data[k] = a while k: k = (k - 1) / 2 data[k] = min(data[2*k+1], data[2*k+2]) def query(a, b, k, l, r): if b <= l or r <= a: return INF if...
import sys readline = sys.stdin.readline write = sys.stdout.write N, Q = list(map(int, readline().split())) N0 = 2**(N-1).bit_length() INF = 2**31-1 data = [INF]*(2*N0) def update(k, x): k += N0-1 data[k] = x while k >= 0: k = (k - 1) // 2 data[k] = min(data[2*k+1], data[2*k+2]...
23
39
626
783
n, q = list(map(int, input().split())) n0 = 2 ** n.bit_length() INF = 2**31 - 1 data = [INF] * (n0 * 2) def update(k, a): k += n0 - 1 data[k] = a while k: k = (k - 1) / 2 data[k] = min(data[2 * k + 1], data[2 * k + 2]) def query(a, b, k, l, r): if b <= l or r <= a: return INF...
import sys readline = sys.stdin.readline write = sys.stdout.write N, Q = list(map(int, readline().split())) N0 = 2 ** (N - 1).bit_length() INF = 2**31 - 1 data = [INF] * (2 * N0) def update(k, x): k += N0 - 1 data[k] = x while k >= 0: k = (k - 1) // 2 data[k] = min(data[2 * k + 1], data[2...
false
41.025641
[ "-n, q = list(map(int, input().split()))", "-n0 = 2 ** n.bit_length()", "+import sys", "+", "+readline = sys.stdin.readline", "+write = sys.stdout.write", "+N, Q = list(map(int, readline().split()))", "+N0 = 2 ** (N - 1).bit_length()", "-data = [INF] * (n0 * 2)", "+data = [INF] * (2 * N0)", "-de...
false
0.045926
0.0455
1.009368
[ "s598269460", "s681555471" ]
u785578220
p03450
python
s821797731
s156701291
1,178
737
11,808
8,948
Accepted
Accepted
37.44
class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) # 根への距離を管理 self.weight = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else: y = self.find(self....
def main(): import sys input = sys.stdin.readline def find(x): if par[x] < 0: return x else: px = find(par[x]) wei[x] += wei[par[x]] par[x] = px return px def weight(x): find(x) return wei[x] ...
62
62
1,623
1,225
class WeightedUnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] self.rank = [0] * (n + 1) # 根への距離を管理 self.weight = [0] * (n + 1) # 検索 def find(self, x): if self.par[x] == x: return x else: y = self.find(self.par[x]...
def main(): import sys input = sys.stdin.readline def find(x): if par[x] < 0: return x else: px = find(par[x]) wei[x] += wei[par[x]] par[x] = px return px def weight(x): find(x) return wei[x] def unite(x,...
false
0
[ "-class WeightedUnionFind:", "- def __init__(self, n):", "- self.par = [i for i in range(n + 1)]", "- self.rank = [0] * (n + 1)", "- # 根への距離を管理", "- self.weight = [0] * (n + 1)", "+def main():", "+ import sys", "- # 検索", "- def find(self, x):", "- i...
false
0.041718
0.042542
0.980621
[ "s821797731", "s156701291" ]
u546285759
p01852
python
s007097561
s071612278
70
40
7,700
7,708
Accepted
Accepted
42.86
n = int(eval(input())) print((0 if n == 0 else len(str(bin(n))[2:])))
n = int(eval(input())) print((0 * (n == 0) + len(str(bin(n))[2:]) * (n != 0)))
2
2
62
71
n = int(eval(input())) print((0 if n == 0 else len(str(bin(n))[2:])))
n = int(eval(input())) print((0 * (n == 0) + len(str(bin(n))[2:]) * (n != 0)))
false
0
[ "-print((0 if n == 0 else len(str(bin(n))[2:])))", "+print((0 * (n == 0) + len(str(bin(n))[2:]) * (n != 0)))" ]
false
0.037056
0.094542
0.391957
[ "s007097561", "s071612278" ]
u309120194
p02583
python
s764548573
s175703499
166
132
20,256
9,204
Accepted
Accepted
20.48
N = int(eval(input())) L = list(map(int, input().split())) ans = 0 if(N >= 3): t = [] for i in range(N): for j in range(i+1, N): for k in range(j+1, N): if((L[i] != L[j]) & (L[i] != L[k]) & (L[j] != L[k]) & (abs(L[j]-L[k]) < L[i]) & (L[i] < L[j]+L[k])): t.append((L[i], L[j], L[k])) a...
N = int(eval(input())) L = list(map(int, input().split())) ans = 0 for i in range(N): for j in range(i+1, N): for k in range(j+1, N): if(L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and abs(L[j]-L[k]) < L[i] and L[i] < L[j]+L[k]): ans +=1 print(ans)
13
11
339
288
N = int(eval(input())) L = list(map(int, input().split())) ans = 0 if N >= 3: t = [] for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): if ( (L[i] != L[j]) & (L[i] != L[k]) & (L[j] != L[k]) ...
N = int(eval(input())) L = list(map(int, input().split())) ans = 0 for i in range(N): for j in range(i + 1, N): for k in range(j + 1, N): if ( L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and abs(L[j] - L[k]) < L[i] ...
false
15.384615
[ "-if N >= 3:", "- t = []", "- for i in range(N):", "- for j in range(i + 1, N):", "- for k in range(j + 1, N):", "- if (", "- (L[i] != L[j])", "- & (L[i] != L[k])", "- & (L[j] != L[k])", "- ...
false
0.036582
0.034797
1.051326
[ "s764548573", "s175703499" ]
u353895424
p02923
python
s971535038
s601667204
226
77
63,856
14,252
Accepted
Accepted
65.93
n=int(eval(input())) h=list(map(int,input().split())) h=h[::-1] dp=[0]*n for i in range(1,n): if h[i] >= h[i-1]: dp[i] = 1+dp[i-1] print((max(dp)))
n = int(eval(input())) h = list(map(int, input().split())) ans = 0 cnt = 0 for i in range(n-1): if h[i] >= h[i+1]: cnt += 1 else: ans = max(ans, cnt) cnt = 0 ans = max(ans, cnt) print(ans)
8
15
170
232
n = int(eval(input())) h = list(map(int, input().split())) h = h[::-1] dp = [0] * n for i in range(1, n): if h[i] >= h[i - 1]: dp[i] = 1 + dp[i - 1] print((max(dp)))
n = int(eval(input())) h = list(map(int, input().split())) ans = 0 cnt = 0 for i in range(n - 1): if h[i] >= h[i + 1]: cnt += 1 else: ans = max(ans, cnt) cnt = 0 ans = max(ans, cnt) print(ans)
false
46.666667
[ "-h = h[::-1]", "-dp = [0] * n", "-for i in range(1, n):", "- if h[i] >= h[i - 1]:", "- dp[i] = 1 + dp[i - 1]", "-print((max(dp)))", "+ans = 0", "+cnt = 0", "+for i in range(n - 1):", "+ if h[i] >= h[i + 1]:", "+ cnt += 1", "+ else:", "+ ans = max(ans, cnt)", ...
false
0.042098
0.092332
0.455948
[ "s971535038", "s601667204" ]
u905203728
p02684
python
s044543239
s804739142
129
118
120,836
120,492
Accepted
Accepted
8.53
n,k=list(map(int,input().split())) A=list(map(int,input().split())) time=0 color=["white" for _ in range(n+1)] D=[-1 for _ in range(n+1)] C,s=[],A[0] point=0 while 1: if color[s]=="white": color[s]="gray" C.append(s) D[s]=time time +=1 s=A[s-1] else: ...
n,k=list(map(int,input().split())) A=list(map(int,input().split())) time=0 color=["white" for _ in range(n+1)] D=[-1 for _ in range(n+1)] C,s=[],A[0] point=0 while 1: if color[s]=="white": color[s]="gray" C.append(s) D[s]=time time +=1 s=A[s-1] else: ...
24
24
442
442
n, k = list(map(int, input().split())) A = list(map(int, input().split())) time = 0 color = ["white" for _ in range(n + 1)] D = [-1 for _ in range(n + 1)] C, s = [], A[0] point = 0 while 1: if color[s] == "white": color[s] = "gray" C.append(s) D[s] = time time += 1 s = A[s - ...
n, k = list(map(int, input().split())) A = list(map(int, input().split())) time = 0 color = ["white" for _ in range(n + 1)] D = [-1 for _ in range(n + 1)] C, s = [], A[0] point = 0 while 1: if color[s] == "white": color[s] = "gray" C.append(s) D[s] = time time += 1 s = A[s - ...
false
0
[ "- k -= point + 1", "- print((loop[k % len(loop)]))", "+ k -= point", "+ print((loop[k % len(loop) - 1]))" ]
false
0.048363
0.039451
1.225912
[ "s044543239", "s804739142" ]
u790710233
p02678
python
s443715944
s708021187
732
494
35,596
38,024
Accepted
Accepted
32.51
from collections import deque n, m = list(map(int, input().split())) edges = [[]for _ in range(n)] for _ in range(m): a, b = [int(x)-1 for x in input().split()] edges[a].append(b) edges[b].append(a) next_v = deque([0]) history = [-1]*n INF = 10**18 dist = [INF]*n dist[0] = 0 while next_v: ...
from collections import deque import sys input = sys.stdin.readline n, m = list(map(int, input().split())) edges = [[]for _ in range(n)] for _ in range(m): a, b = [int(x)-1 for x in input().split()] edges[a].append(b) edges[b].append(a) next_v = deque([0]) prev = [-1]*n while next_v: v = n...
28
22
566
509
from collections import deque n, m = list(map(int, input().split())) edges = [[] for _ in range(n)] for _ in range(m): a, b = [int(x) - 1 for x in input().split()] edges[a].append(b) edges[b].append(a) next_v = deque([0]) history = [-1] * n INF = 10**18 dist = [INF] * n dist[0] = 0 while next_v: v = ne...
from collections import deque import sys input = sys.stdin.readline n, m = list(map(int, input().split())) edges = [[] for _ in range(n)] for _ in range(m): a, b = [int(x) - 1 for x in input().split()] edges[a].append(b) edges[b].append(a) next_v = deque([0]) prev = [-1] * n while next_v: v = next_v.po...
false
21.428571
[ "+import sys", "+input = sys.stdin.readline", "-history = [-1] * n", "-INF = 10**18", "-dist = [INF] * n", "-dist[0] = 0", "+prev = [-1] * n", "- if dist[v2] <= dist[v] + 1:", "+ if prev[v2] != -1:", "- dist[v2] = dist[v] + 1", "- history[v2] = v", "+ prev[v2...
false
0.05232
0.037123
1.409378
[ "s443715944", "s708021187" ]
u028973125
p03818
python
s404031113
s297100265
233
81
59,692
22,096
Accepted
Accepted
65.24
import sys from collections import Counter N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().strip().split())) counter = Counter(A) even_count = 0 for (n, count) in list(counter.items()): if count % 2 == 1: N -= count // 2 * 2 counter[n] = 1 else: ...
import sys from collections import Counter input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) counter = Counter(A) # print(counter) ans = 0 tmp = 0 for n, count in list(counter.items()): r = (count - 1) // 2 count -= 1 + 2*r ans += 2*r if count == 1: ...
18
19
414
358
import sys from collections import Counter N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().strip().split())) counter = Counter(A) even_count = 0 for (n, count) in list(counter.items()): if count % 2 == 1: N -= count // 2 * 2 counter[n] = 1 else: N -= count -...
import sys from collections import Counter input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) counter = Counter(A) # print(counter) ans = 0 tmp = 0 for n, count in list(counter.items()): r = (count - 1) // 2 count -= 1 + 2 * r ans += 2 * r if count == 1: tmp +...
false
5.263158
[ "-N = int(sys.stdin.readline().strip())", "-A = list(map(int, sys.stdin.readline().strip().split()))", "+input = sys.stdin.readline", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "-even_count = 0", "-for (n, count) in list(counter.items()):", "- if count % 2 == 1:", "- ...
false
0.069212
0.039654
1.745418
[ "s404031113", "s297100265" ]
u225388820
p03254
python
s949468581
s291037520
161
17
38,384
3,064
Accepted
Accepted
89.44
n,x= list(map(int, input().split())) a= sorted(list(map(int, input().split()))) cnt=0 for i in range(n): if x>=a[i]: cnt+=1 x-=a[i] else: break if i==n-1 and x>0: cnt-=1 print(cnt)
n,x=list(map(int,input().split())) a=sorted(list(map(int,input().split()))) if a[0]>x: print((0)) exit() cnt=1 for i in range(1,n): a[i]+=a[i-1] if a[i]>x: break cnt+=1 if cnt==n and a[-1]!=x: cnt-=1 print(cnt)
12
14
229
247
n, x = list(map(int, input().split())) a = sorted(list(map(int, input().split()))) cnt = 0 for i in range(n): if x >= a[i]: cnt += 1 x -= a[i] else: break if i == n - 1 and x > 0: cnt -= 1 print(cnt)
n, x = list(map(int, input().split())) a = sorted(list(map(int, input().split()))) if a[0] > x: print((0)) exit() cnt = 1 for i in range(1, n): a[i] += a[i - 1] if a[i] > x: break cnt += 1 if cnt == n and a[-1] != x: cnt -= 1 print(cnt)
false
14.285714
[ "-cnt = 0", "-for i in range(n):", "- if x >= a[i]:", "- cnt += 1", "- x -= a[i]", "- else:", "+if a[0] > x:", "+ print((0))", "+ exit()", "+cnt = 1", "+for i in range(1, n):", "+ a[i] += a[i - 1]", "+ if a[i] > x:", "- if i == n - 1 and x > 0:", "- ...
false
0.068288
0.033799
2.020381
[ "s949468581", "s291037520" ]
u768559443
p02923
python
s941270795
s544603842
94
76
14,252
14,224
Accepted
Accepted
19.15
n=int(eval(input())) h=list(map(int,input().split())) cnt=0 ans=0 for i in range(1,n): if h[i-1]>=h[i]: cnt+=1 ans=max(ans,cnt) else: cnt=0 print(ans)
n=int(eval(input())) h=list(map(int,input().split())) dp=[0]*n cnt=0 for i in range(1,n): if h[i-1]>=h[i]: cnt+=1 else: cnt=0 dp[i]=cnt print((max(dp)))
13
11
190
182
n = int(eval(input())) h = list(map(int, input().split())) cnt = 0 ans = 0 for i in range(1, n): if h[i - 1] >= h[i]: cnt += 1 ans = max(ans, cnt) else: cnt = 0 print(ans)
n = int(eval(input())) h = list(map(int, input().split())) dp = [0] * n cnt = 0 for i in range(1, n): if h[i - 1] >= h[i]: cnt += 1 else: cnt = 0 dp[i] = cnt print((max(dp)))
false
15.384615
[ "+dp = [0] * n", "-ans = 0", "- ans = max(ans, cnt)", "-print(ans)", "+ dp[i] = cnt", "+print((max(dp)))" ]
false
0.036181
0.036802
0.983112
[ "s941270795", "s544603842" ]
u141610915
p02973
python
s478676517
s372740263
588
333
46,952
52,188
Accepted
Accepted
43.37
from bisect import bisect_right as br N = int(eval(input())) inf = 10 ** 9 + 1 lis = [inf] * (N + 1) res = 0 for _ in range(N): a = -int(eval(input())) ind = br(lis, a) if a <= lis[ind]: lis[ind] = a for i in range(1, N + 1): if lis[i] == inf: break res = i print((res + 1))
import sys from bisect import bisect_right as br input = sys.stdin.readline N = int(eval(input())) a = [] for _ in range(N): a.append(int(eval(input()))) lis = [float("inf") for _ in range(N)] reva = a[: : -1] for i in range(N): j = br(lis, reva[i]) lis[j] = reva[i] res = N for i in range(N): if ...
16
19
294
367
from bisect import bisect_right as br N = int(eval(input())) inf = 10**9 + 1 lis = [inf] * (N + 1) res = 0 for _ in range(N): a = -int(eval(input())) ind = br(lis, a) if a <= lis[ind]: lis[ind] = a for i in range(1, N + 1): if lis[i] == inf: break res = i print((res + 1))
import sys from bisect import bisect_right as br input = sys.stdin.readline N = int(eval(input())) a = [] for _ in range(N): a.append(int(eval(input()))) lis = [float("inf") for _ in range(N)] reva = a[::-1] for i in range(N): j = br(lis, reva[i]) lis[j] = reva[i] res = N for i in range(N): if lis[i] =...
false
15.789474
[ "+import sys", "+input = sys.stdin.readline", "-inf = 10**9 + 1", "-lis = [inf] * (N + 1)", "-res = 0", "+a = []", "- a = -int(eval(input()))", "- ind = br(lis, a)", "- if a <= lis[ind]:", "- lis[ind] = a", "-for i in range(1, N + 1):", "- if lis[i] == inf:", "+ a.appen...
false
0.039109
0.088106
0.443885
[ "s478676517", "s372740263" ]
u141574039
p02675
python
s838505106
s669530534
23
20
9,056
9,176
Accepted
Accepted
13.04
N=eval(input()) #print(N[-1]) if N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9": print("hon") elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8": print("pon") else: print("bon")
L=["pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"] N=list(eval(input())) print((L[int(N[-1])]))
8
3
211
102
N = eval(input()) # print(N[-1]) if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9": print("hon") elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8": print("pon") else: print("bon")
L = ["pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"] N = list(eval(input())) print((L[int(N[-1])]))
false
62.5
[ "-N = eval(input())", "-# print(N[-1])", "-if N[-1] == \"2\" or N[-1] == \"4\" or N[-1] == \"5\" or N[-1] == \"7\" or N[-1] == \"9\":", "- print(\"hon\")", "-elif N[-1] == \"0\" or N[-1] == \"1\" or N[-1] == \"6\" or N[-1] == \"8\":", "- print(\"pon\")", "-else:", "- print(\"bon\")", "+L = ...
false
0.045381
0.039519
1.148337
[ "s838505106", "s669530534" ]
u729133443
p03261
python
s332330534
s704751733
179
17
38,256
2,940
Accepted
Accepted
90.5
l=open(0).readlines()[1:];print(('YNeos'[any(a[-2]!=b[0]*l.count(a)for a,b in zip(l,l[1:]))::2]))
_,*l=open(0).readlines();print(('YNeos'[any(a[-2]!=b[0]*l.count(a)for a,b in zip(l,l[1:]))::2]))
1
1
95
94
l = open(0).readlines()[1:] print(("YNeos"[any(a[-2] != b[0] * l.count(a) for a, b in zip(l, l[1:])) :: 2]))
_, *l = open(0).readlines() print(("YNeos"[any(a[-2] != b[0] * l.count(a) for a, b in zip(l, l[1:])) :: 2]))
false
0
[ "-l = open(0).readlines()[1:]", "+_, *l = open(0).readlines()" ]
false
0.039296
0.008361
4.70012
[ "s332330534", "s704751733" ]
u729133443
p02929
python
s581253330
s292764104
233
205
3,512
3,512
Accepted
Accepted
12.02
n,s=open(0) n=int(n) a=l=s[0]<'W'>s[-2] r=f=0 for b,c in zip(s,s[1:-1]):f^=b==c;a=a*(max(1,n))*(l-r)**f%(10**9+7);n-=1;r+=f;l+=f^1 print((a*(l==r)))
n,s=open(0) n=int(n) a=l=s[0]<'W'>s[-2] r=f=0 for b,c in zip(s,s[1:-1]):f^=b==c;a=a*(n<1or n)*(l-r)**f%(10**9+7);n-=1;r+=f;l+=f^1 print((a*(l==r)))
6
6
151
150
n, s = open(0) n = int(n) a = l = s[0] < "W" > s[-2] r = f = 0 for b, c in zip(s, s[1:-1]): f ^= b == c a = a * (max(1, n)) * (l - r) ** f % (10**9 + 7) n -= 1 r += f l += f ^ 1 print((a * (l == r)))
n, s = open(0) n = int(n) a = l = s[0] < "W" > s[-2] r = f = 0 for b, c in zip(s, s[1:-1]): f ^= b == c a = a * (n < 1 or n) * (l - r) ** f % (10**9 + 7) n -= 1 r += f l += f ^ 1 print((a * (l == r)))
false
0
[ "- a = a * (max(1, n)) * (l - r) ** f % (10**9 + 7)", "+ a = a * (n < 1 or n) * (l - r) ** f % (10**9 + 7)" ]
false
0.03811
0.037768
1.009063
[ "s581253330", "s292764104" ]
u088552457
p03945
python
s439401570
s080175890
49
36
13,796
3,188
Accepted
Accepted
26.53
s = eval(input()) c = [] f = s[0] count = 1 for si in list(s): if f != si: count += 1 c.append(count) f = si else: c.append(count) stone_count = len(set(c)) if stone_count == 2: print((1)) exit() if stone_count == 1: print((0)) exit() print((stone_count - 1))
def main(): s = eval(input()) if set(s) == 1: print((0)) exit() group_count = 1 v = s[0] for i in range(1, len(s)): if v == s[i]: continue group_count += 1 v = s[i] print((group_count-1)) def input_list(): return list(map(int, input().split())) import...
23
21
303
317
s = eval(input()) c = [] f = s[0] count = 1 for si in list(s): if f != si: count += 1 c.append(count) f = si else: c.append(count) stone_count = len(set(c)) if stone_count == 2: print((1)) exit() if stone_count == 1: print((0)) exit() print((stone_count - 1))
def main(): s = eval(input()) if set(s) == 1: print((0)) exit() group_count = 1 v = s[0] for i in range(1, len(s)): if v == s[i]: continue group_count += 1 v = s[i] print((group_count - 1)) def input_list(): return list(map(int, input().s...
false
8.695652
[ "-s = eval(input())", "-c = []", "-f = s[0]", "-count = 1", "-for si in list(s):", "- if f != si:", "- count += 1", "- c.append(count)", "- f = si", "- else:", "- c.append(count)", "-stone_count = len(set(c))", "-if stone_count == 2:", "- print((1))", ...
false
0.037855
0.035542
1.06507
[ "s439401570", "s080175890" ]
u189487046
p02843
python
s025351693
s101718605
145
30
2,940
2,940
Accepted
Accepted
79.31
# 品物数を決めると合計金額は100*個数~105*個数の範囲となる # xが範囲内にあれば買い方が存在する。なければしない。 x = int(eval(input())) for i in range(1, 1000001): if 100*i <= x <= 105*i: print((1)) break else: print((0))
X = int(eval(input())) for i in range(1, 100001): if 100*i <= X <= 105*i: print((1)) exit(0) print((0))
10
7
197
121
# 品物数を決めると合計金額は100*個数~105*個数の範囲となる # xが範囲内にあれば買い方が存在する。なければしない。 x = int(eval(input())) for i in range(1, 1000001): if 100 * i <= x <= 105 * i: print((1)) break else: print((0))
X = int(eval(input())) for i in range(1, 100001): if 100 * i <= X <= 105 * i: print((1)) exit(0) print((0))
false
30
[ "-# 品物数を決めると合計金額は100*個数~105*個数の範囲となる", "-# xが範囲内にあれば買い方が存在する。なければしない。", "-x = int(eval(input()))", "-for i in range(1, 1000001):", "- if 100 * i <= x <= 105 * i:", "+X = int(eval(input()))", "+for i in range(1, 100001):", "+ if 100 * i <= X <= 105 * i:", "- break", "-else:", "- p...
false
0.615949
0.046304
13.302286
[ "s025351693", "s101718605" ]
u018679195
p02773
python
s952737953
s872979395
866
295
46,732
36,444
Accepted
Accepted
65.94
N=eval(input()) n=int(N) p=[] for i in range(n): p.append(eval(input())) ha = {} for i in p : if (i not in list(ha.keys())) : ha[i] = 1 else : ha[i] += 1 res = list(ha.items()) res = sorted(list(ha.items()), key = lambda x : x[1] , reverse = True ) i = 1 k = res[0][...
''' Online Python Compiler. Code, Compile, Run and Debug python program online. Write your code in this editor and press "Run" button to execute it. ''' from sys import stdin def read(): return stdin.readline().strip() dict={} output=[] iteration=int(rea...
30
34
417
667
N = eval(input()) n = int(N) p = [] for i in range(n): p.append(eval(input())) ha = {} for i in p: if i not in list(ha.keys()): ha[i] = 1 else: ha[i] += 1 res = list(ha.items()) res = sorted(list(ha.items()), key=lambda x: x[1], reverse=True) i = 1 k = res[0][1] while i < len(res) and res[i]...
""" Online Python Compiler. Code, Compile, Run and Debug python program online. Write your code in this editor and press "Run" button to execute it. """ from sys import stdin def read(): return stdin.readline().strip() dict = {} output = [] iteration = int(read()) max...
false
11.764706
[ "-N = eval(input())", "-n = int(N)", "-p = []", "-for i in range(n):", "- p.append(eval(input()))", "-ha = {}", "-for i in p:", "- if i not in list(ha.keys()):", "- ha[i] = 1", "- else:", "- ha[i] += 1", "-res = list(ha.items())", "-res = sorted(list(ha.items()), key=l...
false
0.091041
0.046048
1.977098
[ "s952737953", "s872979395" ]
u989345508
p02644
python
s383950965
s429283937
2,994
349
1,016,712
93,840
Accepted
Accepted
88.34
import sys inf=1000002 sys.setrecursionlimit(inf) from collections import deque h,w,k=list(map(int,input().split())) x1,y1,x2,y2=list(map(int,input().split())) c=[eval(input()) for i in range(h)] dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)] now=deque([[x1-1,y1-1]]) dp[x1-1][y1-1]=0 d...
h,w,k=map(int,input().split()) r,s,t,u=map(lambda x:int(x)-1,input().split()) b=[input()for _ in range(h)] l=[[-1]*w for _ in range(h)] l[r][s]=0 from collections import* d=deque([(r,s)]) while d: x,y=d.popleft() if(x==t)&(y==u):exit(print(l[x][y])) for e,f in [[1,0],[-1,0],[0,-1],[0,1]]: for i in ...
49
18
1,395
515
import sys inf = 1000002 sys.setrecursionlimit(inf) from collections import deque h, w, k = list(map(int, input().split())) x1, y1, x2, y2 = list(map(int, input().split())) c = [eval(input()) for i in range(h)] dp = [[inf if c[i][j] == "." else -1 for j in range(w)] for i in range(h)] now = deque([[x1 - 1, y1 - 1]]) ...
h, w, k = map(int, input().split()) r, s, t, u = map(lambda x: int(x) - 1, input().split()) b = [input() for _ in range(h)] l = [[-1] * w for _ in range(h)] l[r][s] = 0 from collections import * d = deque([(r, s)]) while d: x, y = d.popleft() if (x == t) & (y == u): exit(print(l[x][y])) for e, f in...
false
63.265306
[ "-import sys", "+h, w, k = map(int, input().split())", "+r, s, t, u = map(lambda x: int(x) - 1, input().split())", "+b = [input() for _ in range(h)]", "+l = [[-1] * w for _ in range(h)]", "+l[r][s] = 0", "+from collections import *", "-inf = 1000002", "-sys.setrecursionlimit(inf)", "-from collecti...
false
0.111324
0.088471
1.258301
[ "s383950965", "s429283937" ]
u753803401
p03053
python
s687291158
s171722020
826
743
183,004
146,140
Accepted
Accepted
10.05
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 h, w = list(map(int, readline().split())) a = [list(str(readline().rstrip().decode('utf-8'))) for _ in range(h)] fq = [[True] * w for _ in range(h)] ql = collections.deque() for i i...
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 h, w = list(map(int, readline().split())) a = [] ql = collections.deque() for i in range(h): al = list(str(readline().rstrip().decode('utf-8'))) ta = [] for j ...
33
38
945
1,000
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 h, w = list(map(int, readline().split())) a = [list(str(readline().rstrip().decode("utf-8"))) for _ in range(h)] fq = [[True] * w for _ in range(h)] ql = collections.deque() for i in range(h): ...
import sys import collections def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 h, w = list(map(int, readline().split())) a = [] ql = collections.deque() for i in range(h): al = list(str(readline().rstrip().decode("utf-8"))) ta = [] for j in range(w): ...
false
13.157895
[ "- a = [list(str(readline().rstrip().decode(\"utf-8\"))) for _ in range(h)]", "- fq = [[True] * w for _ in range(h)]", "+ a = []", "+ al = list(str(readline().rstrip().decode(\"utf-8\")))", "+ ta = []", "- if a[i][j] == \"#\":", "- fq[i][j] = False", "+...
false
0.070301
0.059203
1.187465
[ "s687291158", "s171722020" ]
u620084012
p03013
python
s757956702
s166436443
470
162
51,672
80,740
Accepted
Accepted
65.53
MOD = 10**9 + 7 N, M = list(map(int,input().split())) a = [int(eval(input())) for k in range(M)] + [-1] dp = [0]*(N+1) i = 0 dp[0] = 1 if a[0] == 1: dp[1] = 0 i += 1 else: dp[1] = 1 for k in range(2,N+1): if k == a[i]: dp[k] = 0 i += 1 else: dp[k] = dp...
MOD = 10**9 + 7 N, M = list(map(int,input().split())) a = [int(eval(input())) for k in range(M)] dp = [0]*(N+2) dp[0] = 1 for e in a: dp[e] = -1 for k in range(N): if dp[k] != -1: if dp[k+1] != -1: dp[k+1] += dp[k] dp[k+1] %= MOD if dp[k+2] != -1: ...
23
16
360
375
MOD = 10**9 + 7 N, M = list(map(int, input().split())) a = [int(eval(input())) for k in range(M)] + [-1] dp = [0] * (N + 1) i = 0 dp[0] = 1 if a[0] == 1: dp[1] = 0 i += 1 else: dp[1] = 1 for k in range(2, N + 1): if k == a[i]: dp[k] = 0 i += 1 else: dp[k] = dp[k - 1] + dp[k -...
MOD = 10**9 + 7 N, M = list(map(int, input().split())) a = [int(eval(input())) for k in range(M)] dp = [0] * (N + 2) dp[0] = 1 for e in a: dp[e] = -1 for k in range(N): if dp[k] != -1: if dp[k + 1] != -1: dp[k + 1] += dp[k] dp[k + 1] %= MOD if dp[k + 2] != -1: ...
false
30.434783
[ "-a = [int(eval(input())) for k in range(M)] + [-1]", "-dp = [0] * (N + 1)", "-i = 0", "+a = [int(eval(input())) for k in range(M)]", "+dp = [0] * (N + 2)", "-if a[0] == 1:", "- dp[1] = 0", "- i += 1", "-else:", "- dp[1] = 1", "-for k in range(2, N + 1):", "- if k == a[i]:", "- ...
false
0.038239
0.038207
1.000841
[ "s757956702", "s166436443" ]
u047796752
p02706
python
s151943591
s983982355
76
62
68,224
68,160
Accepted
Accepted
18.42
import sys input = sys.stdin.readline from collections import * from math import * N, M = list(map(int, input().split())) A = list(map(int, input().split())) S = sum(A) if S>N: print((-1)) else: print((N-S))
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) S = sum(A) if S>N: print((-1)) else: print((N-S))
13
11
219
172
import sys input = sys.stdin.readline from collections import * from math import * N, M = list(map(int, input().split())) A = list(map(int, input().split())) S = sum(A) if S > N: print((-1)) else: print((N - S))
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) A = list(map(int, input().split())) S = sum(A) if S > N: print((-1)) else: print((N - S))
false
15.384615
[ "-from collections import *", "-from math import *", "-" ]
false
0.034843
0.037046
0.940528
[ "s151943591", "s983982355" ]
u287132915
p02984
python
s179769578
s590142547
261
111
26,304
103,124
Accepted
Accepted
57.47
import numpy as np n = int(eval(input())) dam = list(map(int, input().split())) yama = [-1] * n min_dam = min(dam) min_dam_arg = np.argmin(dam) s = sum(dam) yama[0] = s - 2 * sum(dam[1::2]) for i in range(1, n): yama[i] = 2 * (dam[i-1] - yama[i-1]/2) yama = list(map(int, yama)) print((' '.join(ma...
n = int(eval(input())) a = list(map(int, input().split())) m = [0 for i in range(n)] for i in range(n): if i%2 == 0: m[0] += a[i] else: m[0] -= a[i] for i in range(1, n): m[i] = 2*a[i-1] - m[i-1] print((' '.join(map(str, m))))
16
13
321
260
import numpy as np n = int(eval(input())) dam = list(map(int, input().split())) yama = [-1] * n min_dam = min(dam) min_dam_arg = np.argmin(dam) s = sum(dam) yama[0] = s - 2 * sum(dam[1::2]) for i in range(1, n): yama[i] = 2 * (dam[i - 1] - yama[i - 1] / 2) yama = list(map(int, yama)) print((" ".join(map(str, yama)...
n = int(eval(input())) a = list(map(int, input().split())) m = [0 for i in range(n)] for i in range(n): if i % 2 == 0: m[0] += a[i] else: m[0] -= a[i] for i in range(1, n): m[i] = 2 * a[i - 1] - m[i - 1] print((" ".join(map(str, m))))
false
18.75
[ "-import numpy as np", "-", "-dam = list(map(int, input().split()))", "-yama = [-1] * n", "-min_dam = min(dam)", "-min_dam_arg = np.argmin(dam)", "-s = sum(dam)", "-yama[0] = s - 2 * sum(dam[1::2])", "+a = list(map(int, input().split()))", "+m = [0 for i in range(n)]", "+for i in range(n):", "...
false
0.204805
0.037314
5.488726
[ "s179769578", "s590142547" ]
u545368057
p03014
python
s723309247
s825552522
1,084
934
180,996
103,128
Accepted
Accepted
13.84
H,W = list(map(int,input().split())) S = [eval(input()) for i in range(H)] # 4方向の累積和をとって計算する Rs = [[0]*W for i in range(H)] Ls = [[0]*W for i in range(H)] Ds = [[0]*W for i in range(H)] Us = [[0]*W for i in range(H)] for i in range(H): tmp = 0 # 順方向(左にどれだけ伸びてるか) for j in range(W): if ...
H,W = list(map(int,input().split())) S = [eval(input()) for i in range(H)] ### その1 """ # 4方向の累積和をとって計算する Rs = [[0]*W for i in range(H)] Ls = [[0]*W for i in range(H)] Ds = [[0]*W for i in range(H)] Us = [[0]*W for i in range(H)] for i in range(H): tmp = 0 # 順方向(左にどれだけ伸びてるか) for j in range(W)...
55
103
1,234
2,221
H, W = list(map(int, input().split())) S = [eval(input()) for i in range(H)] # 4方向の累積和をとって計算する Rs = [[0] * W for i in range(H)] Ls = [[0] * W for i in range(H)] Ds = [[0] * W for i in range(H)] Us = [[0] * W for i in range(H)] for i in range(H): tmp = 0 # 順方向(左にどれだけ伸びてるか) for j in range(W): if S[i][...
H, W = list(map(int, input().split())) S = [eval(input()) for i in range(H)] ### その1 """ # 4方向の累積和をとって計算する Rs = [[0]*W for i in range(H)] Ls = [[0]*W for i in range(H)] Ds = [[0]*W for i in range(H)] Us = [[0]*W for i in range(H)] for i in range(H): tmp = 0 # 順方向(左にどれだけ伸びてるか) for j in range(W): if S...
false
46.601942
[ "+### その1", "+\"\"\"", "-Rs = [[0] * W for i in range(H)]", "-Ls = [[0] * W for i in range(H)]", "-Ds = [[0] * W for i in range(H)]", "-Us = [[0] * W for i in range(H)]", "+Rs = [[0]*W for i in range(H)]", "+Ls = [[0]*W for i in range(H)]", "+Ds = [[0]*W for i in range(H)]", "+Us = [[0]*W for i in...
false
0.036946
0.046588
0.793033
[ "s723309247", "s825552522" ]
u038408819
p03013
python
s045138015
s588306297
213
179
7,764
7,848
Accepted
Accepted
15.96
N, M = list(map(int, input().split())) #a = [int(input()) for _ in range(M)] issafe = [True] * (N + 1) for i in range(M): issafe[int(eval(input()))] = False dp = [0] * (N + 1) dp[0] = 1 if issafe[1]: dp[1] = 1 mod = 1000000007 for i in range(2, N + 1): if issafe[i - 1]: dp[i] += dp[i...
n, m = list(map(int, input().split())) a = [int(eval(input())) for _ in range(m)] dp = [0] * (n + 1) for i in range(m): dp[a[i]] = -1 #dp mod = 10 ** 9 + 7 dp[0] = 1 if dp[1] != -1: dp[1] = 1 for i in range(2, n + 1): if dp[i - 1] == -1 and dp[i - 2] == -1: print((0)) quit() ...
20
30
404
639
N, M = list(map(int, input().split())) # a = [int(input()) for _ in range(M)] issafe = [True] * (N + 1) for i in range(M): issafe[int(eval(input()))] = False dp = [0] * (N + 1) dp[0] = 1 if issafe[1]: dp[1] = 1 mod = 1000000007 for i in range(2, N + 1): if issafe[i - 1]: dp[i] += dp[i - 1] if is...
n, m = list(map(int, input().split())) a = [int(eval(input())) for _ in range(m)] dp = [0] * (n + 1) for i in range(m): dp[a[i]] = -1 # dp mod = 10**9 + 7 dp[0] = 1 if dp[1] != -1: dp[1] = 1 for i in range(2, n + 1): if dp[i - 1] == -1 and dp[i - 2] == -1: print((0)) quit() if dp[i] == -...
false
33.333333
[ "-N, M = list(map(int, input().split()))", "-# a = [int(input()) for _ in range(M)]", "-issafe = [True] * (N + 1)", "-for i in range(M):", "- issafe[int(eval(input()))] = False", "-dp = [0] * (N + 1)", "+n, m = list(map(int, input().split()))", "+a = [int(eval(input())) for _ in range(m)]", "+dp ...
false
0.032467
0.03391
0.957441
[ "s045138015", "s588306297" ]
u228223940
p03157
python
s123238918
s267106914
1,931
677
10,692
156,780
Accepted
Accepted
64.94
import queue h,w = list(map(int,input().split())) si = [eval(input()) for i in range(h)] q = queue.Queue() check = [-1]*(h*w) vx = [0,1,0,-1] vy = [1,0,-1,0] for i in range(h*w): y = i//w x = i%w if si[y][x] == '#': if check[i] != -1: continue q.put([i,'#']...
import sys sys.setrecursionlimit(10**7) h,w = list(map(int,input().split())) si = [eval(input()) for i in range(h)] check = [-1]*(h*w) #print(check,check==-1) #exit() vx = [0,1,0,-1] vy = [1,0,-1,0] def dfs(num,clr): #print(min(check)) #if min(check) > -1: # return y = ...
62
71
1,464
1,494
import queue h, w = list(map(int, input().split())) si = [eval(input()) for i in range(h)] q = queue.Queue() check = [-1] * (h * w) vx = [0, 1, 0, -1] vy = [1, 0, -1, 0] for i in range(h * w): y = i // w x = i % w if si[y][x] == "#": if check[i] != -1: continue q.put([i, "#"]) ...
import sys sys.setrecursionlimit(10**7) h, w = list(map(int, input().split())) si = [eval(input()) for i in range(h)] check = [-1] * (h * w) # print(check,check==-1) # exit() vx = [0, 1, 0, -1] vy = [1, 0, -1, 0] def dfs(num, clr): # print(min(check)) # if min(check) > -1: # return y = num // w ...
false
12.676056
[ "-import queue", "+import sys", "+sys.setrecursionlimit(10**7)", "-q = queue.Queue()", "+# print(check,check==-1)", "+# exit()", "+", "+", "+def dfs(num, clr):", "+ # print(min(check))", "+ # if min(check) > -1:", "+ # return", "+ y = num // w", "+ x = num % w", "+ f...
false
0.061296
0.043656
1.404095
[ "s123238918", "s267106914" ]
u678167152
p03048
python
s715308059
s252629615
894
161
3,060
73,472
Accepted
Accepted
81.99
R, G, B, N = list(map(int, input().split())) def solve(): ans = 0 for i in range(N//R+1): b1 = N - i*R for j in range(b1//G+1): b2 = b1 - j*G if b2%B==0: ans += 1 return ans print((solve()))
def solve(): ans = 0 R, G, B, N = list(map(int, input().split())) for r in range(N//R+1): for g in range(N//G+1): bb = N-r*R-g*G if bb>=0 and bb%B==0: ans += 1 return ans print((solve()))
11
10
260
220
R, G, B, N = list(map(int, input().split())) def solve(): ans = 0 for i in range(N // R + 1): b1 = N - i * R for j in range(b1 // G + 1): b2 = b1 - j * G if b2 % B == 0: ans += 1 return ans print((solve()))
def solve(): ans = 0 R, G, B, N = list(map(int, input().split())) for r in range(N // R + 1): for g in range(N // G + 1): bb = N - r * R - g * G if bb >= 0 and bb % B == 0: ans += 1 return ans print((solve()))
false
9.090909
[ "-R, G, B, N = list(map(int, input().split()))", "-", "-", "- for i in range(N // R + 1):", "- b1 = N - i * R", "- for j in range(b1 // G + 1):", "- b2 = b1 - j * G", "- if b2 % B == 0:", "+ R, G, B, N = list(map(int, input().split()))", "+ for r in ran...
false
0.082185
0.272478
0.301623
[ "s715308059", "s252629615" ]
u263830634
p03215
python
s927870450
s054970109
306
241
65,788
65,788
Accepted
Accepted
21.24
N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) for i in range(N): A[i + 1] += A[i] B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)] ans = 0 t = 40 while t: count = 0 tmp = pow(2, t -1) for b in B: if ((b & (tmp + ans)) == (tmp + ...
def main(): N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) for i in range(N): A[i + 1] += A[i] B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)] ans = 0 t = 40 while t: count = 0 tmp = pow(2, t -1) ...
21
26
411
565
N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) for i in range(N): A[i + 1] += A[i] B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)] ans = 0 t = 40 while t: count = 0 tmp = pow(2, t - 1) for b in B: if (b & (tmp + ans)) == (tmp + ans): ...
def main(): N, K = list(map(int, input().split())) A = [0] + list(map(int, input().split())) for i in range(N): A[i + 1] += A[i] B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)] ans = 0 t = 40 while t: count = 0 tmp = pow(2, t - 1) for b in B: ...
false
19.230769
[ "-N, K = list(map(int, input().split()))", "-A = [0] + list(map(int, input().split()))", "-for i in range(N):", "- A[i + 1] += A[i]", "-B = [A[j] - A[i] for i in range(N) for j in range(i + 1, N + 1)]", "-ans = 0", "-t = 40", "-while t:", "- count = 0", "- tmp = pow(2, t - 1)", "- fo...
false
0.037594
0.037203
1.010514
[ "s927870450", "s054970109" ]
u190405389
p03837
python
s046274331
s172490540
590
352
7,076
4,080
Accepted
Accepted
40.34
n,m = list(map(int,input().split())) abc = [list(map(int, input().split())) for i in range(m)] d = [[0]*n for i in range(n)] e = [[[-1]for j in range(n)] for i in range(n)] for i in range(n): for j in range(n): if i!=j: d[i][j]=float('inf') for i in range(m): d[abc[i][0]...
n,m = list(map(int,input().split())) abc = [list(map(int, input().split())) for i in range(m)] d = [[0]*n for i in range(n)] e = [[0]*n for i in range(n)] for i in range(n): for j in range(n): if i!=j: d[i][j]=float('inf') e[i][j]=float('inf') for i in range(m): d...
38
32
853
781
n, m = list(map(int, input().split())) abc = [list(map(int, input().split())) for i in range(m)] d = [[0] * n for i in range(n)] e = [[[-1] for j in range(n)] for i in range(n)] for i in range(n): for j in range(n): if i != j: d[i][j] = float("inf") for i in range(m): d[abc[i][0] - 1][abc[i]...
n, m = list(map(int, input().split())) abc = [list(map(int, input().split())) for i in range(m)] d = [[0] * n for i in range(n)] e = [[0] * n for i in range(n)] for i in range(n): for j in range(n): if i != j: d[i][j] = float("inf") e[i][j] = float("inf") for i in range(m): d[abc...
false
15.789474
[ "-e = [[[-1] for j in range(n)] for i in range(n)]", "+e = [[0] * n for i in range(n)]", "+ e[i][j] = float(\"inf\")", "- e[abc[i][0] - 1][abc[i][1] - 1] = [i]", "- e[abc[i][1] - 1][abc[i][0] - 1] = [i]", "+ e[abc[i][0] - 1][abc[i][1] - 1] = abc[i][2]", "+ e[abc[i][1] - 1][abc[i][...
false
0.007311
0.032381
0.225787
[ "s046274331", "s172490540" ]
u780475861
p03319
python
s128869167
s158093138
40
17
13,940
3,060
Accepted
Accepted
57.5
n, k, *_ = list(map(int, open(0).read().split())) print(((n - 2) // (k - 1) + 1))
n, k = list(map(int, open(0).readline().split())) print(((n - 2) // (k - 1) + 1))
2
2
74
74
n, k, *_ = list(map(int, open(0).read().split())) print(((n - 2) // (k - 1) + 1))
n, k = list(map(int, open(0).readline().split())) print(((n - 2) // (k - 1) + 1))
false
0
[ "-n, k, *_ = list(map(int, open(0).read().split()))", "+n, k = list(map(int, open(0).readline().split()))" ]
false
0.038941
0.039124
0.995314
[ "s128869167", "s158093138" ]
u968166680
p03546
python
s699145100
s439181616
191
31
40,156
6,308
Accepted
Accepted
83.77
from sys import stdin, setrecursionlimit setrecursionlimit(10 ** 9) INF = 1 << 60 def input(): return stdin.readline().strip() def main(): H, W = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(10)] A = [list(map(int, input().split())) for _ in range...
import sys from collections import Counter read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): H, W = list(map(int, readline().split())) C = [list(map(int, readline().split())) for _ in range(10)] A = li...
33
34
722
749
from sys import stdin, setrecursionlimit setrecursionlimit(10**9) INF = 1 << 60 def input(): return stdin.readline().strip() def main(): H, W = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(10)] A = [list(map(int, input().split())) for _ in range(H)] for k ...
import sys from collections import Counter read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def main(): H, W = list(map(int, readline().split())) C = [list(map(int, readline().split())) for _ in range(10)] A = list(map(int, rea...
false
2.941176
[ "-from sys import stdin, setrecursionlimit", "+import sys", "+from collections import Counter", "-setrecursionlimit(10**9)", "+read = sys.stdin.read", "+readline = sys.stdin.readline", "+readlines = sys.stdin.readlines", "+sys.setrecursionlimit(10**9)", "-def input():", "- return stdin.readline...
false
0.046068
0.088397
0.521147
[ "s699145100", "s439181616" ]
u716530146
p02900
python
s510169935
s067707158
301
142
64,620
3,316
Accepted
Accepted
52.82
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect, string from fractions import gcd input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') mod = 10**9+7 ans = 0 ;count = 0 ;pro = 1 a,b=list(map(int,input().split())) g=gcd(a,b) def prime_factor(n):...
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 a,b = list(map(int,input().split())) def prime_factor(n): ass = [] for i in range(2,int...
26
30
623
718
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect, string from fractions import gcd input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") inf = float("inf") mod = 10**9 + 7 ans = 0 count = 0 pro = 1 a, b = list(map(int, input().split())) g = gcd(a, b) def prime_factor(n): ...
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") inf = float("inf") mod = 10**9 + 7 mans = inf ans = 0 count = 0 pro = 1 a, b = list(map(int, input().split())) def prime_factor(n): ass = [] for i in range(2, int(n**0....
false
13.333333
[ "-import sys, math, itertools, heapq, collections, bisect, string", "-from fractions import gcd", "+import sys, math, itertools, collections, bisect", "+mans = inf", "-g = gcd(a, b)", "-pr = prime_factor(g)", "-print((len(pr) + 1))", "-# print(pr)", "+def gcd(a, b):", "+ while b != 0:", "+ ...
false
0.046998
0.040982
1.146794
[ "s510169935", "s067707158" ]
u998169143
p02717
python
s820375400
s825695715
114
25
27,108
9,096
Accepted
Accepted
78.07
import numpy as np X, Y, Z = list(map(int, input().split())) print((Z, X, Y))
X, Y, Z = list(map(int, input().split())) A = Y B = X C = Z print((C, B, A))
4
7
74
76
import numpy as np X, Y, Z = list(map(int, input().split())) print((Z, X, Y))
X, Y, Z = list(map(int, input().split())) A = Y B = X C = Z print((C, B, A))
false
42.857143
[ "-import numpy as np", "-", "-print((Z, X, Y))", "+A = Y", "+B = X", "+C = Z", "+print((C, B, A))" ]
false
0.064037
0.080777
0.792765
[ "s820375400", "s825695715" ]
u320567105
p03112
python
s731205473
s550265968
1,999
906
117,336
16,128
Accepted
Accepted
54.68
ri = lambda: int(eval(input())) rl = lambda: list(map(int,input().split())) A,B,Q=rl() s=[0]*(A+2) t=[0]*(B+2) X=[0]*Q for i in range(1,A+1): s[i]=ri() s[0],s[A+1]=-float('inf'),float('inf') s.sort() for i in range(1,B+1): t[i]=ri() t[0],t[B+1]=-float('inf'),float('inf') t.sort() for i in range(...
ri = lambda: int(eval(input())) rl = lambda: list(map(int,input().split())) rr = lambda N: [ri() for _ in range(N)] INF = 10**18 A,B,Q=rl() s = [-INF] + rr(A) + [INF] t = [-INF] + rr(B) + [INF] X= rr(Q) import bisect for x in X: s_i = bisect.bisect_left(s,x) t_i = bisect.bisect_left(t,x) s_l...
30
22
637
508
ri = lambda: int(eval(input())) rl = lambda: list(map(int, input().split())) A, B, Q = rl() s = [0] * (A + 2) t = [0] * (B + 2) X = [0] * Q for i in range(1, A + 1): s[i] = ri() s[0], s[A + 1] = -float("inf"), float("inf") s.sort() for i in range(1, B + 1): t[i] = ri() t[0], t[B + 1] = -float("inf"), float("inf...
ri = lambda: int(eval(input())) rl = lambda: list(map(int, input().split())) rr = lambda N: [ri() for _ in range(N)] INF = 10**18 A, B, Q = rl() s = [-INF] + rr(A) + [INF] t = [-INF] + rr(B) + [INF] X = rr(Q) import bisect for x in X: s_i = bisect.bisect_left(s, x) t_i = bisect.bisect_left(t, x) s_l = x - ...
false
26.666667
[ "+rr = lambda N: [ri() for _ in range(N)]", "+INF = 10**18", "-s = [0] * (A + 2)", "-t = [0] * (B + 2)", "-X = [0] * Q", "-for i in range(1, A + 1):", "- s[i] = ri()", "-s[0], s[A + 1] = -float(\"inf\"), float(\"inf\")", "-s.sort()", "-for i in range(1, B + 1):", "- t[i] = ri()", "-t[0],...
false
0.047672
0.048154
0.989993
[ "s731205473", "s550265968" ]
u392319141
p02813
python
s693198937
s439290804
36
33
7,924
7,924
Accepted
Accepted
8.33
from itertools import permutations N = int(eval(input())) A = tuple(map(int, input().split())) B = tuple(map(int, input().split())) P = [] for perm in permutations(list(range(1, N + 1)), r=N): P.append(tuple(perm)) P.sort() print((abs(P.index(A) - P.index(B))))
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) X = [tuple(p) for p in permutations(list(range(1, N + 1)), r=N)] X.sort() print((abs(X.index(P) - X.index(Q))))
12
10
265
242
from itertools import permutations N = int(eval(input())) A = tuple(map(int, input().split())) B = tuple(map(int, input().split())) P = [] for perm in permutations(list(range(1, N + 1)), r=N): P.append(tuple(perm)) P.sort() print((abs(P.index(A) - P.index(B))))
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) X = [tuple(p) for p in permutations(list(range(1, N + 1)), r=N)] X.sort() print((abs(X.index(P) - X.index(Q))))
false
16.666667
[ "-A = tuple(map(int, input().split()))", "-B = tuple(map(int, input().split()))", "-P = []", "-for perm in permutations(list(range(1, N + 1)), r=N):", "- P.append(tuple(perm))", "-P.sort()", "-print((abs(P.index(A) - P.index(B))))", "+P = tuple(map(int, input().split()))", "+Q = tuple(map(int, in...
false
0.048179
0.092013
0.52361
[ "s693198937", "s439290804" ]
u169696482
p03244
python
s336236186
s221303204
456
87
23,384
20,700
Accepted
Accepted
80.92
import numpy as np n = int(eval(input())) v = list(map(int, input().split())) v_odd = [] v_even = [] for i in range(n): if i%2 == 0: v_odd.append(v[i]) else: v_even.append(v[i]) vs_odd = np.array(v_odd) vs_even = np.array(v_even) count_odd = np.bincount(vs_odd) count_even = np.bincount(vs_eve...
from collections import Counter n=int(eval(input())) v=list(map(int,input().split())) a=Counter(v[0::2]).most_common() b=Counter(v[1::2]).most_common() a.append([0,0]) b.append([0,0]) if a[0][0]!=b[0][0]: print((n-(a[0][1]+b[0][1]))) else: print((min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1]))))
42
11
1,080
301
import numpy as np n = int(eval(input())) v = list(map(int, input().split())) v_odd = [] v_even = [] for i in range(n): if i % 2 == 0: v_odd.append(v[i]) else: v_even.append(v[i]) vs_odd = np.array(v_odd) vs_even = np.array(v_even) count_odd = np.bincount(vs_odd) count_even = np.bincount(vs_eve...
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) a = Counter(v[0::2]).most_common() b = Counter(v[1::2]).most_common() a.append([0, 0]) b.append([0, 0]) if a[0][0] != b[0][0]: print((n - (a[0][1] + b[0][1]))) else: print((min(n - (a[1][1] + b[0][1]), n - (a[0][1] + b[1...
false
73.809524
[ "-import numpy as np", "+from collections import Counter", "-v_odd = []", "-v_even = []", "-for i in range(n):", "- if i % 2 == 0:", "- v_odd.append(v[i])", "- else:", "- v_even.append(v[i])", "-vs_odd = np.array(v_odd)", "-vs_even = np.array(v_even)", "-count_odd = np.binc...
false
0.272707
0.0478
5.705193
[ "s336236186", "s221303204" ]
u973203074
p02412
python
s215749679
s030941563
3,470
630
5,608
5,604
Accepted
Accepted
81.84
def dfs(i, j, s): if j > 3: return if j == 3 and s == x: ans.append(1) for k in range(1, i): if s + k > x: break dfs(k, j + 1, s + k) while True: ans = [] n, x = list(map(int, input().split())) if n == x == 0: break for ...
def calc(n, x): result = 0 for i in range(3, n + 1): for j in range(2, i): for k in range(1, j): if sum([i, j, k]) == x: result += 1 return str(result) ans = [] while True: n, x = list(map(int, input().split())) if n == x == 0: ...
21
17
381
379
def dfs(i, j, s): if j > 3: return if j == 3 and s == x: ans.append(1) for k in range(1, i): if s + k > x: break dfs(k, j + 1, s + k) while True: ans = [] n, x = list(map(int, input().split())) if n == x == 0: break for i in range(3, n + ...
def calc(n, x): result = 0 for i in range(3, n + 1): for j in range(2, i): for k in range(1, j): if sum([i, j, k]) == x: result += 1 return str(result) ans = [] while True: n, x = list(map(int, input().split())) if n == x == 0: break ...
false
19.047619
[ "-def dfs(i, j, s):", "- if j > 3:", "- return", "- if j == 3 and s == x:", "- ans.append(1)", "- for k in range(1, i):", "- if s + k > x:", "- break", "- dfs(k, j + 1, s + k)", "+def calc(n, x):", "+ result = 0", "+ for i in range(3, n + 1...
false
0.073315
0.075849
0.966591
[ "s215749679", "s030941563" ]
u401487574
p02762
python
s661622110
s313431186
819
540
84,400
90,608
Accepted
Accepted
34.07
import sys sys.setrecursionlimit(10**6) def main(): class unionfind(): def __init__(self,n): self.par = [i for i in range(n)] self.size = [1 for i in range(n)] self.rank = [0 for i in range(n)] def root(self,x): if self.par[x] == x: ...
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq ceil = math.ceil class unionfind(): ...
58
61
1,548
1,605
import sys sys.setrecursionlimit(10**6) def main(): class unionfind: def __init__(self, n): self.par = [i for i in range(n)] self.size = [1 for i in range(n)] self.rank = [0 for i in range(n)] def root(self, x): if self.par[x] == x: ...
ma = lambda: map(int, input().split()) lma = lambda: list(map(int, input().split())) tma = lambda: tuple(map(int, input().split())) ni = lambda: int(input()) yn = lambda fl: print("Yes") if fl else print("No") import collections import math import itertools import heapq as hq ceil = math.ceil class unionfind: de...
false
4.918033
[ "-import sys", "+ma = lambda: map(int, input().split())", "+lma = lambda: list(map(int, input().split()))", "+tma = lambda: tuple(map(int, input().split()))", "+ni = lambda: int(input())", "+yn = lambda fl: print(\"Yes\") if fl else print(\"No\")", "+import collections", "+import math", "+import ite...
false
0.075235
0.037274
2.018413
[ "s661622110", "s313431186" ]
u186082958
p00991
python
s467622357
s731270079
50
30
7,780
7,804
Accepted
Accepted
40
from math import factorial def comb (x,y): return factorial(x)//factorial(x-y)//factorial(y) w,h,ax,ay,bx,by=list(map(int,input().split())) dx=abs(ax-bx) dx=min(dx,w-dx) dy=abs(ay-by) dy=min(dy,h-dy) ans=1 if dx*2==w:ans*=2 if dy*2==h:ans*=2 ans*=comb(dx+dy,dx) print((ans%100000007))
from math import factorial def comb (x,y): return factorial(x)//factorial(x-y)//factorial(y) w,h,ax,ay,bx,by=list(map(int,input().split())) dx=abs(ax-bx) dx=min(dx,w-dx) dy=abs(ay-by) dy=min(dy,h-dy) an=1 if dx*2==w:an*=2 if dy*2==h:an*=2 an*=comb(dx+dy,dx) print((an%int(1E8+7)))
14
14
291
287
from math import factorial def comb(x, y): return factorial(x) // factorial(x - y) // factorial(y) w, h, ax, ay, bx, by = list(map(int, input().split())) dx = abs(ax - bx) dx = min(dx, w - dx) dy = abs(ay - by) dy = min(dy, h - dy) ans = 1 if dx * 2 == w: ans *= 2 if dy * 2 == h: ans *= 2 ans *= comb(dx...
from math import factorial def comb(x, y): return factorial(x) // factorial(x - y) // factorial(y) w, h, ax, ay, bx, by = list(map(int, input().split())) dx = abs(ax - bx) dx = min(dx, w - dx) dy = abs(ay - by) dy = min(dy, h - dy) an = 1 if dx * 2 == w: an *= 2 if dy * 2 == h: an *= 2 an *= comb(dx + d...
false
0
[ "-ans = 1", "+an = 1", "- ans *= 2", "+ an *= 2", "- ans *= 2", "-ans *= comb(dx + dy, dx)", "-print((ans % 100000007))", "+ an *= 2", "+an *= comb(dx + dy, dx)", "+print((an % int(1e8 + 7)))" ]
false
0.044308
0.048331
0.916752
[ "s467622357", "s731270079" ]
u150984829
p00458
python
s501941149
s908921808
310
260
5,732
5,740
Accepted
Accepted
16.13
def b(M,x,y,n=1): M[x][y]=0;t=[] if M[x-1][y]:t+=[b(M,x-1,y,n+1)] if M[x][y-1]:t+=[b(M,x,y-1,n+1)] if M[x+1][y]:t+=[b(M,x+1,y,n+1)] if M[x][y+1]:t+=[b(M,x,y+1,n+1)] M[x][y]=1 return max([n]+t) for e in iter(input,'0'): n,m=int(e),int(eval(input())) P=[[0]*(n+2)for _ in[0]*(m+2)] for i in range(m):P...
def b(M,x,y,n=1): M[x][y]=0;a=n if M[x-1][y]:a=max(a,b(M,x-1,y,n+1)) if M[x][y-1]:a=max(a,b(M,x,y-1,n+1)) if M[x+1][y]:a=max(a,b(M,x+1,y,n+1)) if M[x][y+1]:a=max(a,b(M,x,y+1,n+1)) M[x][y]=1 return a for e in iter(input,'0'): n,m=int(e),int(eval(input())) P=[[0]*(n+2)for _ in[0]*(m+2)] for i in rang...
13
13
426
432
def b(M, x, y, n=1): M[x][y] = 0 t = [] if M[x - 1][y]: t += [b(M, x - 1, y, n + 1)] if M[x][y - 1]: t += [b(M, x, y - 1, n + 1)] if M[x + 1][y]: t += [b(M, x + 1, y, n + 1)] if M[x][y + 1]: t += [b(M, x, y + 1, n + 1)] M[x][y] = 1 return max([n] + t) fo...
def b(M, x, y, n=1): M[x][y] = 0 a = n if M[x - 1][y]: a = max(a, b(M, x - 1, y, n + 1)) if M[x][y - 1]: a = max(a, b(M, x, y - 1, n + 1)) if M[x + 1][y]: a = max(a, b(M, x + 1, y, n + 1)) if M[x][y + 1]: a = max(a, b(M, x, y + 1, n + 1)) M[x][y] = 1 retur...
false
0
[ "- t = []", "+ a = n", "- t += [b(M, x - 1, y, n + 1)]", "+ a = max(a, b(M, x - 1, y, n + 1))", "- t += [b(M, x, y - 1, n + 1)]", "+ a = max(a, b(M, x, y - 1, n + 1))", "- t += [b(M, x + 1, y, n + 1)]", "+ a = max(a, b(M, x + 1, y, n + 1))", "- ...
false
0.044257
0.044145
1.002553
[ "s501941149", "s908921808" ]
u009961299
p02394
python
s917327742
s681704128
30
20
6,724
5,600
Accepted
Accepted
33.33
( w, h, x, y, r ) = list(map ( int, input ( ).split ( ) )) if ( 0 <= x - r ) and ( x + r <= w ) and ( 0 <= y - r ) and ( y + r <= h ): print ( "Yes" ) else: print ( "No" )
c = input().split() W, H, x, y, r = int(c[0]), int(c[1]), int(c[2]), int(c[3]), int(c[4]) if r <= x <= W - r and r <= y <= H - r: print("Yes") else: print("No")
6
8
175
178
(w, h, x, y, r) = list(map(int, input().split())) if (0 <= x - r) and (x + r <= w) and (0 <= y - r) and (y + r <= h): print("Yes") else: print("No")
c = input().split() W, H, x, y, r = int(c[0]), int(c[1]), int(c[2]), int(c[3]), int(c[4]) if r <= x <= W - r and r <= y <= H - r: print("Yes") else: print("No")
false
25
[ "-(w, h, x, y, r) = list(map(int, input().split()))", "-if (0 <= x - r) and (x + r <= w) and (0 <= y - r) and (y + r <= h):", "+c = input().split()", "+W, H, x, y, r = int(c[0]), int(c[1]), int(c[2]), int(c[3]), int(c[4])", "+if r <= x <= W - r and r <= y <= H - r:" ]
false
0.131233
0.12874
1.019365
[ "s917327742", "s681704128" ]
u193927973
p02888
python
s690718547
s126781231
1,034
342
74,844
74,296
Accepted
Accepted
66.92
from bisect import bisect_left N=int(eval(input())) y=list(map(int, input().split())) y.sort() ans=0 for i in range(N-2): for j in range(i+1, N-1): tmp=y[i]+y[j] ans+=bisect_left(y[(j+1):],tmp) print(ans)
from bisect import bisect_left N=int(eval(input())) y=list(map(int, input().split())) y.sort() ans=0 for i in range(N-2): for j in range(i+1, N-1): tmp=y[i]+y[j] ans+=bisect_left(y,tmp)-j-1 print(ans)
10
10
217
214
from bisect import bisect_left N = int(eval(input())) y = list(map(int, input().split())) y.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): tmp = y[i] + y[j] ans += bisect_left(y[(j + 1) :], tmp) print(ans)
from bisect import bisect_left N = int(eval(input())) y = list(map(int, input().split())) y.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): tmp = y[i] + y[j] ans += bisect_left(y, tmp) - j - 1 print(ans)
false
0
[ "- ans += bisect_left(y[(j + 1) :], tmp)", "+ ans += bisect_left(y, tmp) - j - 1" ]
false
0.038485
0.182726
0.210617
[ "s690718547", "s126781231" ]
u523545435
p02647
python
s653392630
s246263374
330
272
173,284
169,248
Accepted
Accepted
17.58
n,k=list(map(int,input().split())) A=list(map(int,input().split())) def culc(L): subL=[0]*(n+1) for i in range(n): temp=L[i] bottom=max(i-temp,0) top=min(i+temp,n-1) subL[bottom]+=1 subL[top+1]-=1 resL=[0]*n resL[0]=subL[0] for i in ran...
n,k=list(map(int,input().split())) A=list(map(int,input().split())) def culc(L): subL=[0]*(n+1) for i in range(n): temp=L[i] bottom=max(i-temp,0) top=min(i+temp,n-1) subL[bottom]+=1 subL[top+1]-=1 resL=[0]*n resL[0]=subL[0] for i in ran...
25
25
435
435
n, k = list(map(int, input().split())) A = list(map(int, input().split())) def culc(L): subL = [0] * (n + 1) for i in range(n): temp = L[i] bottom = max(i - temp, 0) top = min(i + temp, n - 1) subL[bottom] += 1 subL[top + 1] -= 1 resL = [0] * n resL[0] = subL[0]...
n, k = list(map(int, input().split())) A = list(map(int, input().split())) def culc(L): subL = [0] * (n + 1) for i in range(n): temp = L[i] bottom = max(i - temp, 0) top = min(i + temp, n - 1) subL[bottom] += 1 subL[top + 1] -= 1 resL = [0] * n resL[0] = subL[0]...
false
0
[ "-for i in range(min(k, 50)):", "+for i in range(min(k, 41)):" ]
false
0.047441
0.087865
0.539933
[ "s653392630", "s246263374" ]
u492556875
p02383
python
s345069704
s336285619
40
30
6,728
6,752
Accepted
Accepted
25
import sys dice = [int(i) for i in sys.stdin.readline().split()] command = sys.stdin.readline().strip() for c in command: if c == "N": dice = (dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]) elif c == "S": dice = (dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]) elif c =...
import sys class Dice(object): def __init__(self, dice): self.__dice = dice def roll_north(self): self.__dice = (self.__dice[1], self.__dice[5], self.__dice[2], self.__dice[3], self.__dice[0], self.__dice[4]) def roll_south(self): self.__dice = (s...
14
38
504
1,188
import sys dice = [int(i) for i in sys.stdin.readline().split()] command = sys.stdin.readline().strip() for c in command: if c == "N": dice = (dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]) elif c == "S": dice = (dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]) elif c == "W": ...
import sys class Dice(object): def __init__(self, dice): self.__dice = dice def roll_north(self): self.__dice = ( self.__dice[1], self.__dice[5], self.__dice[2], self.__dice[3], self.__dice[0], self.__dice[4], ) ...
false
63.157895
[ "-dice = [int(i) for i in sys.stdin.readline().split()]", "+", "+class Dice(object):", "+ def __init__(self, dice):", "+ self.__dice = dice", "+", "+ def roll_north(self):", "+ self.__dice = (", "+ self.__dice[1],", "+ self.__dice[5],", "+ sel...
false
0.09179
0.073587
1.247359
[ "s345069704", "s336285619" ]
u559126797
p03845
python
s325468582
s932994496
30
17
3,444
3,060
Accepted
Accepted
43.33
import copy N=int(eval(input())) T=list(map(int,input().split())) M=int(eval(input())) Drink=[list(map(int,input().split())) for _ in range(M)] for i in range(M): p=Drink[i][0] x=Drink[i][1] answer=copy.deepcopy(T) answer[p-1]=x print((sum(answer)))
N=int(eval(input())) T=list(map(int,input().split())) M=int(eval(input())) Drink=[list(map(int,input().split())) for _ in range(M)] answer=sum(T) for i in range(M): p=Drink[i][0] x=Drink[i][1] print((answer-T[p-1]+x))
11
9
266
224
import copy N = int(eval(input())) T = list(map(int, input().split())) M = int(eval(input())) Drink = [list(map(int, input().split())) for _ in range(M)] for i in range(M): p = Drink[i][0] x = Drink[i][1] answer = copy.deepcopy(T) answer[p - 1] = x print((sum(answer)))
N = int(eval(input())) T = list(map(int, input().split())) M = int(eval(input())) Drink = [list(map(int, input().split())) for _ in range(M)] answer = sum(T) for i in range(M): p = Drink[i][0] x = Drink[i][1] print((answer - T[p - 1] + x))
false
18.181818
[ "-import copy", "-", "+answer = sum(T)", "- answer = copy.deepcopy(T)", "- answer[p - 1] = x", "- print((sum(answer)))", "+ print((answer - T[p - 1] + x))" ]
false
0.047408
0.066546
0.712405
[ "s325468582", "s932994496" ]
u113310313
p03062
python
s175082196
s720281974
480
414
119,080
114,172
Accepted
Accepted
13.75
import sys sys.setrecursionlimit(1000000) class Solution(): def dp(self, pos, sign): if pos == self.n-1: if sign == 0: return +self.lst[pos] else: return -self.lst[pos] elif (pos, sign) in self.vis: return self.rcd[pos][...
# D - Flipping Signs # https://atcoder.jp/contests/abc125/tasks/abc125_ import sys sys.setrecursionlimit(1000000) N = int(eval(input())) A = list( map(int, input().split()) ) visit = dict() def dp(pos, sign): # terminal condition if pos == N-1: if sign == 0: return A[pos] ...
30
33
1,000
781
import sys sys.setrecursionlimit(1000000) class Solution: def dp(self, pos, sign): if pos == self.n - 1: if sign == 0: return +self.lst[pos] else: return -self.lst[pos] elif (pos, sign) in self.vis: return self.rcd[pos][sign] ...
# D - Flipping Signs # https://atcoder.jp/contests/abc125/tasks/abc125_ import sys sys.setrecursionlimit(1000000) N = int(eval(input())) A = list(map(int, input().split())) visit = dict() def dp(pos, sign): # terminal condition if pos == N - 1: if sign == 0: return A[pos] else: ...
false
9.090909
[ "+# D - Flipping Signs", "+# https://atcoder.jp/contests/abc125/tasks/abc125_", "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+visit = dict()", "-class Solution:", "- def dp(self, pos, sign):", "- if pos == self.n - 1:", "- if sign == 0:", "- ...
false
0.046245
0.045498
1.016414
[ "s175082196", "s720281974" ]
u761529120
p03835
python
s085916766
s995337249
1,486
668
2,940
9,084
Accepted
Accepted
55.05
K, S = list(map(int, input().split())) cnt = 0 for x in range(K+1): for y in range(K+1): z = S - y - x if 0 <= z <= K: cnt += 1 print(cnt)
def main(): K, S = list(map(int, input().split())) ans = 0 for i in range(K+1): for j in range(K+1): tmp = i + j if 0 <= S - tmp <= K: ans += 1 print(ans) if __name__ == "__main__": main()
10
12
175
262
K, S = list(map(int, input().split())) cnt = 0 for x in range(K + 1): for y in range(K + 1): z = S - y - x if 0 <= z <= K: cnt += 1 print(cnt)
def main(): K, S = list(map(int, input().split())) ans = 0 for i in range(K + 1): for j in range(K + 1): tmp = i + j if 0 <= S - tmp <= K: ans += 1 print(ans) if __name__ == "__main__": main()
false
16.666667
[ "-K, S = list(map(int, input().split()))", "-cnt = 0", "-for x in range(K + 1):", "- for y in range(K + 1):", "- z = S - y - x", "- if 0 <= z <= K:", "- cnt += 1", "-print(cnt)", "+def main():", "+ K, S = list(map(int, input().split()))", "+ ans = 0", "+ fo...
false
0.035424
0.035309
1.003263
[ "s085916766", "s995337249" ]
u603745966
p03074
python
s517117633
s977556073
105
93
5,264
9,104
Accepted
Accepted
11.43
from functools import reduce import math def main(): # N! を求める # f = math.factorial(N) # 切り捨て # 4 // 3 # 切り上げ #-(-4 // 3) # 初期値用:十分大きい数(100億) # 1e10 # 初期値用:十分小さい数(-100億) # -1e10 # 1文字のみを読み込み # 入力:2 # a = input().rstrip() # 変数:...
from functools import reduce import math def main(): # N! を求める # f = math.factorial(N) # 切り捨て # 4 // 3 # 切り上げ #-(-4 // 3) # 初期値用:十分大きい数(100億) # 1e10 # 初期値用:十分小さい数(-100億) # -1e10 # 1文字のみを読み込み # 入力:2 # a = input().rstrip() # 変数:...
73
78
1,543
1,690
from functools import reduce import math def main(): # N! を求める # f = math.factorial(N) # 切り捨て # 4 // 3 # 切り上げ # -(-4 // 3) # 初期値用:十分大きい数(100億) # 1e10 # 初期値用:十分小さい数(-100億) # -1e10 # 1文字のみを読み込み # 入力:2 # a = input().rstrip() # 変数:a='2' # スペース区切りで標準入力を配列として読み込み ...
from functools import reduce import math def main(): # N! を求める # f = math.factorial(N) # 切り捨て # 4 // 3 # 切り上げ # -(-4 // 3) # 初期値用:十分大きい数(100億) # 1e10 # 初期値用:十分小さい数(-100億) # -1e10 # 1文字のみを読み込み # 入力:2 # a = input().rstrip() # 変数:a='2' # スペース区切りで標準入力を配列として読み込み ...
false
6.410256
[ "+ sum = []", "+ sum.append(0)", "+ for i in range(0, len(Nums)):", "+ sum.append(sum[i] + Nums[i])", "- Nextleft = i", "- Nextright = min(i + Add, len(Nums))", "- while Nextleft > left:", "- tmp -= Nums[left]", "- left += 1", "- wh...
false
0.056049
0.034235
1.637161
[ "s517117633", "s977556073" ]
u721316601
p02954
python
s496370203
s608473378
831
106
19,628
10,492
Accepted
Accepted
87.24
import math import numpy as np S = eval(input()) ans = np.zeros((len(S)), dtype=np.int) count = idx = i = 0 while i < len(S): if S[i:i+2] == 'RL': idx = i ans[idx:idx+2] += [count//2+1, math.ceil(count/2)+1] i += 2 count = 0 elif S[i:i+2] == 'LR': count +=...
import math S = eval(input()) ans = [0 for i in range(len(S))] count = idx = i = 0 while i < len(S): if S[i:i+2] == 'RL': idx = i ans[idx] += count//2+1 ans[idx+1] += math.ceil(count/2)+1 i += 2 count = 0 elif S[i:i+2] == 'LR': count += 1 ...
25
26
542
548
import math import numpy as np S = eval(input()) ans = np.zeros((len(S)), dtype=np.int) count = idx = i = 0 while i < len(S): if S[i : i + 2] == "RL": idx = i ans[idx : idx + 2] += [count // 2 + 1, math.ceil(count / 2) + 1] i += 2 count = 0 elif S[i : i + 2] == "LR": cou...
import math S = eval(input()) ans = [0 for i in range(len(S))] count = idx = i = 0 while i < len(S): if S[i : i + 2] == "RL": idx = i ans[idx] += count // 2 + 1 ans[idx + 1] += math.ceil(count / 2) + 1 i += 2 count = 0 elif S[i : i + 2] == "LR": count += 1 ...
false
3.846154
[ "-import numpy as np", "-ans = np.zeros((len(S)), dtype=np.int)", "+ans = [0 for i in range(len(S))]", "- ans[idx : idx + 2] += [count // 2 + 1, math.ceil(count / 2) + 1]", "+ ans[idx] += count // 2 + 1", "+ ans[idx + 1] += math.ceil(count / 2) + 1", "- ans[idx : idx + 2] += ...
false
0.280317
0.03606
7.773636
[ "s496370203", "s608473378" ]
u252828980
p02952
python
s071848618
s659989931
72
58
2,940
3,064
Accepted
Accepted
19.44
n = int(eval(input())) num = 0 for i in range(n): if len(str(i+1))%2 == 1: num += 1 print(num)
n = int(eval(input())) cnt = 0 for i in range(1,n+1): s = len(str(i)) if s%2 == 1: cnt +=1 print(cnt)
6
8
99
119
n = int(eval(input())) num = 0 for i in range(n): if len(str(i + 1)) % 2 == 1: num += 1 print(num)
n = int(eval(input())) cnt = 0 for i in range(1, n + 1): s = len(str(i)) if s % 2 == 1: cnt += 1 print(cnt)
false
25
[ "-num = 0", "-for i in range(n):", "- if len(str(i + 1)) % 2 == 1:", "- num += 1", "-print(num)", "+cnt = 0", "+for i in range(1, n + 1):", "+ s = len(str(i))", "+ if s % 2 == 1:", "+ cnt += 1", "+print(cnt)" ]
false
0.047519
0.04796
0.990795
[ "s071848618", "s659989931" ]
u857657465
p02630
python
s686728271
s430337006
482
307
21,172
20,608
Accepted
Accepted
36.31
n = int(eval(input()))+1 a = list(map(int, input().split())) cnt = [] for i in range(100005): cnt.append(0) sum = 0 for i in a: cnt[i] += 1 for i in range(100005): sum += i * cnt[i] q = int(eval(input())) for i in range(q): b, c = list(map(int, input().split())) sum += (c-b)*cnt[b...
n = int(eval(input()))+1 a = list(map(int, input().split())) cnt = [] for i in range(100005): cnt.append(0) sum = 0 # a.count(i)を使うとTLE # count()がO(N)のためfor内で使用するとO(N2)になる? for i in a: cnt[i] += 1 for i in range(100005): sum += i * cnt[i] q = int(eval(input())) ans = [] for i in range(q): ...
24
25
366
460
n = int(eval(input())) + 1 a = list(map(int, input().split())) cnt = [] for i in range(100005): cnt.append(0) sum = 0 for i in a: cnt[i] += 1 for i in range(100005): sum += i * cnt[i] q = int(eval(input())) for i in range(q): b, c = list(map(int, input().split())) sum += (c - b) * cnt[b] cnt[c] ...
n = int(eval(input())) + 1 a = list(map(int, input().split())) cnt = [] for i in range(100005): cnt.append(0) sum = 0 # a.count(i)を使うとTLE # count()がO(N)のためfor内で使用するとO(N2)になる? for i in a: cnt[i] += 1 for i in range(100005): sum += i * cnt[i] q = int(eval(input())) ans = [] for i in range(q): b, c = list(...
false
4
[ "+# a.count(i)を使うとTLE", "+# count()がO(N)のためfor内で使用するとO(N2)になる?", "+ans = []", "- print(sum)", "+ ans.append(sum)", "+for i in ans:", "+ print(i)" ]
false
0.169202
0.245422
0.689435
[ "s686728271", "s430337006" ]
u380524497
p02839
python
s848317545
s368125411
69
59
14,964
3,316
Accepted
Accepted
14.49
import sys input = sys.stdin.readline h, w = list(map(int, input().split())) A = [] for i in range(h): line = list(map(int, input().split())) A.append(line) for i in range(h): line = list(map(int, input().split())) for j, num in enumerate(line): A[i][j] = abs(A[i][j] - num) ...
import sys input = sys.stdin.readline h, w = list(map(int, input().split())) A = [] for i in range(h): line = list(map(int, input().split())) A.append(line) for i in range(h): line = list(map(int, input().split())) for j, num in enumerate(line): A[i][j] = abs(A[i][j] - num) ...
50
50
995
952
import sys input = sys.stdin.readline h, w = list(map(int, input().split())) A = [] for i in range(h): line = list(map(int, input().split())) A.append(line) for i in range(h): line = list(map(int, input().split())) for j, num in enumerate(line): A[i][j] = abs(A[i][j] - num) const = 6400 bitset ...
import sys input = sys.stdin.readline h, w = list(map(int, input().split())) A = [] for i in range(h): line = list(map(int, input().split())) A.append(line) for i in range(h): line = list(map(int, input().split())) for j, num in enumerate(line): A[i][j] = abs(A[i][j] - num) const = 6400 bitset ...
false
0
[ "-DP = [[0] * w for _ in range(h)]", "-DP[0][0] = bitset >> A[0][0]", "+DP = [0] * w", "+DP[0] = bitset >> A[0][0]", "- bit = DP[y][x]", "+ bit = DP[x]", "- DP[y + 1][x] |= new1 | new2", "+ DP[x] = new1 | new2", "- bit = DP[y][x]", "+ bit = DP[x]", "- DP[y][x + 1] |= new1 | ...
false
0.040899
0.040805
1.002305
[ "s848317545", "s368125411" ]
u357630630
p03556
python
s749708848
s981291377
65
43
5,792
7,704
Accepted
Accepted
33.85
N=int(input());[exit(0)if i**2>N else print(i**2)if(i+1)**2>N else print(end="")for i in range(1,N+1)]
N=int(input());[exit(0)if i**2>N else print(i**2)if(i+1)**2>N else lambda x:x for i in range(1,N+1)]
1
1
102
100
N = int(input()) [ exit(0) if i ** 2 > N else print(i**2) if (i + 1) ** 2 > N else print(end="") for i in range(1, N + 1) ]
N = int(input()) [ exit(0) if i ** 2 > N else print(i**2) if (i + 1) ** 2 > N else lambda x: x for i in range(1, N + 1) ]
false
0
[ "- exit(0) if i ** 2 > N else print(i**2) if (i + 1) ** 2 > N else print(end=\"\")", "+ exit(0) if i ** 2 > N else print(i**2) if (i + 1) ** 2 > N else lambda x: x" ]
false
0.050356
0.050983
0.987705
[ "s749708848", "s981291377" ]
u102461423
p03768
python
s623619971
s184731143
1,455
416
75,736
61,800
Accepted
Accepted
71.41
import sys input = sys.stdin.readline N,M = list(map(int,input().split())) AB = [[int(x) for x in input().split()] for _ in range(M)] Q = int(eval(input())) VDC = [[int(x) for x in input().split()] for _ in range(Q)] graph = [[] for _ in range(N+1)] for a,b in AB: graph[a].append(b) graph[b].append...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def graph_input(N, M): G = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, readline().split())) G[a].append(b) G[b].appe...
40
53
1,000
1,433
import sys input = sys.stdin.readline N, M = list(map(int, input().split())) AB = [[int(x) for x in input().split()] for _ in range(M)] Q = int(eval(input())) VDC = [[int(x) for x in input().split()] for _ in range(Q)] graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) col...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def graph_input(N, M): G = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, readline().split())) G[a].append(b) G[b].append(a) i...
false
24.528302
[ "+import numpy as np", "-input = sys.stdin.readline", "-N, M = list(map(int, input().split()))", "-AB = [[int(x) for x in input().split()] for _ in range(M)]", "-Q = int(eval(input()))", "-VDC = [[int(x) for x in input().split()] for _ in range(Q)]", "-graph = [[] for _ in range(N + 1)]", "-for a, b i...
false
0.053304
0.258547
0.206166
[ "s623619971", "s184731143" ]
u580697892
p03472
python
s184344976
s376044461
509
439
21,188
7,512
Accepted
Accepted
13.75
# coding: utf-8 from math import ceil N, H = list(map(int, input().split())) li = [] atop = 0 for _ in range(N): a, b = list(map(int, input().split())) atop = max(atop, a) li.append([a, b]) li.sort(key=lambda x: x[1], reverse=True) # print(li) ans = ceil(H/atop) cnt = 0 for i in range(N): ...
# coding: utf-8 from math import ceil N, H = list(map(int, input().split())) li = [] atop = 0 for _ in range(N): a, b = list(map(int, input().split())) atop = max(atop, a) li.append(b) li.sort(reverse=True) # print(li) ans = ceil(H/atop) cnt = 0 for i in range(N): H -= li[i] cnt += 1 ...
18
18
395
367
# coding: utf-8 from math import ceil N, H = list(map(int, input().split())) li = [] atop = 0 for _ in range(N): a, b = list(map(int, input().split())) atop = max(atop, a) li.append([a, b]) li.sort(key=lambda x: x[1], reverse=True) # print(li) ans = ceil(H / atop) cnt = 0 for i in range(N): H -= li[i][...
# coding: utf-8 from math import ceil N, H = list(map(int, input().split())) li = [] atop = 0 for _ in range(N): a, b = list(map(int, input().split())) atop = max(atop, a) li.append(b) li.sort(reverse=True) # print(li) ans = ceil(H / atop) cnt = 0 for i in range(N): H -= li[i] cnt += 1 ans = mi...
false
0
[ "- li.append([a, b])", "-li.sort(key=lambda x: x[1], reverse=True)", "+ li.append(b)", "+li.sort(reverse=True)", "- H -= li[i][1]", "+ H -= li[i]" ]
false
0.089933
0.036706
2.450093
[ "s184344976", "s376044461" ]
u692632484
p04035
python
s024342325
s848270431
165
126
14,620
14,264
Accepted
Accepted
23.64
temp=input().split() N=int(temp[0]) L=int(temp[1]) a=[int(i) for i in input().split()] flag=False ans=[] for i in range(N-1): if a[i]+a[i+1]>=L: print("Possible") flag=True ans.append(i) break else: print("Impossible") if flag==True: while ans[-1]>0: ans.append(ans[-1]-1) if ans[0]<N-...
N,L=[int(i) for i in input().split()] A=[int(i) for i in input().split()] res=-1 for i in range(N-1): if A[i]+A[i+1]>=L: res=i break if res!=-1: print("Possible") for i in range(res): print((i+1)) for i in range(N-1,res,-1): print(i) else: print("Impossible")
25
16
442
287
temp = input().split() N = int(temp[0]) L = int(temp[1]) a = [int(i) for i in input().split()] flag = False ans = [] for i in range(N - 1): if a[i] + a[i + 1] >= L: print("Possible") flag = True ans.append(i) break else: print("Impossible") if flag == True: while ans[-1] > 0:...
N, L = [int(i) for i in input().split()] A = [int(i) for i in input().split()] res = -1 for i in range(N - 1): if A[i] + A[i + 1] >= L: res = i break if res != -1: print("Possible") for i in range(res): print((i + 1)) for i in range(N - 1, res, -1): print(i) else: pri...
false
36
[ "-temp = input().split()", "-N = int(temp[0])", "-L = int(temp[1])", "-a = [int(i) for i in input().split()]", "-flag = False", "-ans = []", "+N, L = [int(i) for i in input().split()]", "+A = [int(i) for i in input().split()]", "+res = -1", "- if a[i] + a[i + 1] >= L:", "- print(\"Poss...
false
0.040935
0.074307
0.550892
[ "s024342325", "s848270431" ]
u811967730
p03778
python
s593268123
s481452910
19
17
3,060
2,940
Accepted
Accepted
10.53
W, a, b = list(map(int, input().split())) if abs(a - b) > W: ans = abs(a - b) - W else: ans = 0 print(ans)
W, a, b = list(map(int, input().split())) dist = abs(a - b) if dist > W: print((dist - W)) else: print((0))
8
8
118
115
W, a, b = list(map(int, input().split())) if abs(a - b) > W: ans = abs(a - b) - W else: ans = 0 print(ans)
W, a, b = list(map(int, input().split())) dist = abs(a - b) if dist > W: print((dist - W)) else: print((0))
false
0
[ "-if abs(a - b) > W:", "- ans = abs(a - b) - W", "+dist = abs(a - b)", "+if dist > W:", "+ print((dist - W))", "- ans = 0", "-print(ans)", "+ print((0))" ]
false
0.043617
0.044966
0.970014
[ "s593268123", "s481452910" ]
u392319141
p03566
python
s485149812
s934083821
424
99
6,260
3,700
Accepted
Accepted
76.65
N = int(eval(input())) T = list([int(t) * 10 for t in input().split()]) V = list(map(int, input().split())) + [0] R = sum(T) maxSpeed = [10**18] * (R + 1) maxSpeed[0] = 0 maxSpeed[R] = 0 now = 0 for i, t in enumerate(T): now += t maxSpeed[now] = min(V[i], V[i + 1]) now = 0 for v, t in zip(V, T):...
N = int(eval(input())) T = list(map(int, input().split())) V = list(map(int, input().split())) M = 2 dt = 1 / M R = sum(T) maxSpeeds = [10**18] * (R * M + 1) now = 0 for t, v in zip(T, V): for i in range(t * M + 1): maxSpeeds[now + i] = min(maxSpeeds[now + i], v) now += t * M maxSpeeds[0...
31
24
750
597
N = int(eval(input())) T = list([int(t) * 10 for t in input().split()]) V = list(map(int, input().split())) + [0] R = sum(T) maxSpeed = [10**18] * (R + 1) maxSpeed[0] = 0 maxSpeed[R] = 0 now = 0 for i, t in enumerate(T): now += t maxSpeed[now] = min(V[i], V[i + 1]) now = 0 for v, t in zip(V, T): for i in ra...
N = int(eval(input())) T = list(map(int, input().split())) V = list(map(int, input().split())) M = 2 dt = 1 / M R = sum(T) maxSpeeds = [10**18] * (R * M + 1) now = 0 for t, v in zip(T, V): for i in range(t * M + 1): maxSpeeds[now + i] = min(maxSpeeds[now + i], v) now += t * M maxSpeeds[0] = 0 maxSpeeds[...
false
22.580645
[ "-T = list([int(t) * 10 for t in input().split()])", "-V = list(map(int, input().split())) + [0]", "+T = list(map(int, input().split()))", "+V = list(map(int, input().split()))", "+M = 2", "+dt = 1 / M", "-maxSpeed = [10**18] * (R + 1)", "-maxSpeed[0] = 0", "-maxSpeed[R] = 0", "+maxSpeeds = [10**1...
false
0.090665
0.063199
1.4346
[ "s485149812", "s934083821" ]
u766684188
p03829
python
s468242410
s888045992
115
92
14,252
14,252
Accepted
Accepted
20
n,a,b=list(map(int,input().split())) X=list(map(int,input().split())) D=[] for i in range(n-1): D.append(X[i+1]-X[i]) ans=0 for i in range(n-1): ans+=min(a*D[i],b) print(ans)
n,a,b=list(map(int,input().split())) X=list(map(int,input().split())) ans=0 for i in range(n-1): ans+=min(a*(X[i+1]-X[i]),b) print(ans)
9
6
184
138
n, a, b = list(map(int, input().split())) X = list(map(int, input().split())) D = [] for i in range(n - 1): D.append(X[i + 1] - X[i]) ans = 0 for i in range(n - 1): ans += min(a * D[i], b) print(ans)
n, a, b = list(map(int, input().split())) X = list(map(int, input().split())) ans = 0 for i in range(n - 1): ans += min(a * (X[i + 1] - X[i]), b) print(ans)
false
33.333333
[ "-D = []", "-for i in range(n - 1):", "- D.append(X[i + 1] - X[i])", "- ans += min(a * D[i], b)", "+ ans += min(a * (X[i + 1] - X[i]), b)" ]
false
0.098921
0.14406
0.686665
[ "s468242410", "s888045992" ]
u893063840
p02721
python
s098469458
s790287809
429
260
20,528
21,780
Accepted
Accepted
39.39
from bisect import bisect_left, bisect_right n, k, c = map(int, input().split()) s = input() work = [i for i, e in enumerate(s, 1) if e == "o"] INF = 10 ** 9 work_l = [] prev = -INF for e in work: if e - prev > c: work_l.append(e) prev = e work_r = [] prev = INF for e in work[::...
n, k, c = map(int, input().split()) s = input() INF = 10 ** 9 work = [i for i, e in enumerate(s, 1) if e == "o"] l = [0] * (n + 1) r = [0] * (n + 1) prev = -INF cnt = 0 for e in work: if e - prev > c: cnt += 1 l[cnt] = e prev = e prev = INF cnt = 0 for e in work[::-1]: ...
33
33
603
538
from bisect import bisect_left, bisect_right n, k, c = map(int, input().split()) s = input() work = [i for i, e in enumerate(s, 1) if e == "o"] INF = 10**9 work_l = [] prev = -INF for e in work: if e - prev > c: work_l.append(e) prev = e work_r = [] prev = INF for e in work[::-1]: if prev - e >...
n, k, c = map(int, input().split()) s = input() INF = 10**9 work = [i for i, e in enumerate(s, 1) if e == "o"] l = [0] * (n + 1) r = [0] * (n + 1) prev = -INF cnt = 0 for e in work: if e - prev > c: cnt += 1 l[cnt] = e prev = e prev = INF cnt = 0 for e in work[::-1]: if prev - e > c: ...
false
0
[ "-from bisect import bisect_left, bisect_right", "-", "+INF = 10**9", "-INF = 10**9", "-work_l = []", "+l = [0] * (n + 1)", "+r = [0] * (n + 1)", "+cnt = 0", "- work_l.append(e)", "+ cnt += 1", "+ l[cnt] = e", "-work_r = []", "+cnt = 0", "- work_r.append(e)", ...
false
0.181507
0.044743
4.056676
[ "s098469458", "s790287809" ]
u644907318
p03045
python
s524182188
s411261609
497
389
109,420
119,440
Accepted
Accepted
21.73
def find(x): while x!=T[x][0]: x = T[x][0] return x def union(x,y): a = find(x) b = find(y) if T[a][1]>T[b][1]: T[b][0] = a elif T[a][1]==T[b][1]: T[b][0] = a T[a][1] += 1 else: T[a][0] = b N,M = list(map(int,input().split())) A = [list(...
def find(x): while x!=T[x][0]: x = T[x][0] return x def union(x,y): ax = find(x) ay = find(y) if T[ax][1]>T[ay][1]: T[ay][0] = ax elif T[ax][1]==T[ay][1]: T[ay][0] = ax T[ax][1] += 1 else: T[ax][0] = ay N,M = list(map(int,input().split())...
29
30
621
658
def find(x): while x != T[x][0]: x = T[x][0] return x def union(x, y): a = find(x) b = find(y) if T[a][1] > T[b][1]: T[b][0] = a elif T[a][1] == T[b][1]: T[b][0] = a T[a][1] += 1 else: T[a][0] = b N, M = list(map(int, input().split())) A = [list(ma...
def find(x): while x != T[x][0]: x = T[x][0] return x def union(x, y): ax = find(x) ay = find(y) if T[ax][1] > T[ay][1]: T[ay][0] = ax elif T[ax][1] == T[ay][1]: T[ay][0] = ax T[ax][1] += 1 else: T[ax][0] = ay N, M = list(map(int, input().split()))...
false
3.333333
[ "- a = find(x)", "- b = find(y)", "- if T[a][1] > T[b][1]:", "- T[b][0] = a", "- elif T[a][1] == T[b][1]:", "- T[b][0] = a", "- T[a][1] += 1", "+ ax = find(x)", "+ ay = find(y)", "+ if T[ax][1] > T[ay][1]:", "+ T[ay][0] = ax", "+ elif T[ax][1...
false
0.04845
0.051938
0.93284
[ "s524182188", "s411261609" ]
u071970578
p02983
python
s626553342
s766723900
682
53
3,060
3,060
Accepted
Accepted
92.23
L, R = list(map(int, input().split())) # n mod 2019 の答えは 0 ~ 2018 のいずれか # それぞれのmodを取った積のmodでも同じ答えになる def get_ans(): # 差が2018以上なら積が0の組み合わせが存在する if R - L >= 2018: return 0 # 総当たり ans = 2019 for X in range(L, R): for Y in range(X + 1, R + 1): ans = min((an...
L, R = list(map(int, input().split())) # n mod 2019 の答えは 0 ~ 2018 のいずれか # それぞれのmodを取った積のmodでも同じ答えになる def get_ans(): # 差が2018以上なら積が0の組み合わせが存在する if R - L >= 2018: return 0 # 総当たり ans = 2019 for X in range(L, R): for Y in range(X + 1, R + 1): ans = min((an...
21
23
373
425
L, R = list(map(int, input().split())) # n mod 2019 の答えは 0 ~ 2018 のいずれか # それぞれのmodを取った積のmodでも同じ答えになる def get_ans(): # 差が2018以上なら積が0の組み合わせが存在する if R - L >= 2018: return 0 # 総当たり ans = 2019 for X in range(L, R): for Y in range(X + 1, R + 1): ans = min((ans, (X * Y) % 2019))...
L, R = list(map(int, input().split())) # n mod 2019 の答えは 0 ~ 2018 のいずれか # それぞれのmodを取った積のmodでも同じ答えになる def get_ans(): # 差が2018以上なら積が0の組み合わせが存在する if R - L >= 2018: return 0 # 総当たり ans = 2019 for X in range(L, R): for Y in range(X + 1, R + 1): ans = min((ans, (X * Y) % 2019))...
false
8.695652
[ "+ if ans == 0:", "+ return 0" ]
false
0.124134
0.037105
3.345479
[ "s626553342", "s766723900" ]
u775681539
p02838
python
s269120163
s406893956
1,982
383
42,156
48,848
Accepted
Accepted
80.68
#python3 n = int(eval(input())) a = list(map(int,input().split())) mod = 10**9+7 md = len(bin(max(a)))-2 ans = 0 for d in range(md): cnt1 = sum([1 for i in a if ((i>>d)&1)]) ans += cnt1 * (n-cnt1) * (1<<d) ans %= mod print((ans%mod))
#python3 import numpy as np n=int(eval(input())) a=np.array([int(i) for i in input().split()]) mod=int(1e9+7) ans=0 for k in range(60): b = (a>>k)&1 m = np.count_nonzero(b) ans += m*(n-m)*2**k print((ans%mod))
12
11
295
217
# python3 n = int(eval(input())) a = list(map(int, input().split())) mod = 10**9 + 7 md = len(bin(max(a))) - 2 ans = 0 for d in range(md): cnt1 = sum([1 for i in a if ((i >> d) & 1)]) ans += cnt1 * (n - cnt1) * (1 << d) ans %= mod print((ans % mod))
# python3 import numpy as np n = int(eval(input())) a = np.array([int(i) for i in input().split()]) mod = int(1e9 + 7) ans = 0 for k in range(60): b = (a >> k) & 1 m = np.count_nonzero(b) ans += m * (n - m) * 2**k print((ans % mod))
false
8.333333
[ "+import numpy as np", "+", "-a = list(map(int, input().split()))", "-mod = 10**9 + 7", "-md = len(bin(max(a))) - 2", "+a = np.array([int(i) for i in input().split()])", "+mod = int(1e9 + 7)", "-for d in range(md):", "- cnt1 = sum([1 for i in a if ((i >> d) & 1)])", "- ans += cnt1 * (n - cnt...
false
0.040579
0.170664
0.237773
[ "s269120163", "s406893956" ]
u472065247
p03472
python
s004930137
s437070441
464
415
34,524
36,084
Accepted
Accepted
10.56
n, h = list(map(int, input().split())) l = [list(map(int, input().split())) for _ in range(n)] max_a = max(l, key=lambda x: x[0])[0] l = [[a, b] for a, b in l if b > max_a] l.sort(key=lambda x: x[1], reverse=True) c = 0 for a, b in l: h -= b c += 1 if h <= 0: print(c) exit() print((c + h...
n, h = list(map(int, input().split())) l = [list(map(int, input().split())) for _ in range(n)] A, B = list(zip(*l)) max_a = max(A) c = 0 for b in sorted([b for b in B if b > max_a], reverse=True): h -= b c += 1 if h <= 0: print(c) exit() print((c + h // max_a + (h % max_a != 0)))
16
12
342
291
n, h = list(map(int, input().split())) l = [list(map(int, input().split())) for _ in range(n)] max_a = max(l, key=lambda x: x[0])[0] l = [[a, b] for a, b in l if b > max_a] l.sort(key=lambda x: x[1], reverse=True) c = 0 for a, b in l: h -= b c += 1 if h <= 0: print(c) exit() print((c + h // ...
n, h = list(map(int, input().split())) l = [list(map(int, input().split())) for _ in range(n)] A, B = list(zip(*l)) max_a = max(A) c = 0 for b in sorted([b for b in B if b > max_a], reverse=True): h -= b c += 1 if h <= 0: print(c) exit() print((c + h // max_a + (h % max_a != 0)))
false
25
[ "-max_a = max(l, key=lambda x: x[0])[0]", "-l = [[a, b] for a, b in l if b > max_a]", "-l.sort(key=lambda x: x[1], reverse=True)", "+A, B = list(zip(*l))", "+max_a = max(A)", "-for a, b in l:", "+for b in sorted([b for b in B if b > max_a], reverse=True):" ]
false
0.044116
0.045881
0.961515
[ "s004930137", "s437070441" ]
u600402037
p02734
python
s825485637
s117788806
1,737
525
3,828
82,268
Accepted
Accepted
69.78
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 998244353 N, S = lr() A = lr() dp = [0] * (S+1) answer = 0 for a in A: dp[0] += 1 # Lの数は1個ずつ加わる prev = dp.copy() for i in range(S-a+1): dp[i+a] += prev[i] ...
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 998244353 N, S = lr() A = lr() dp = [0] * (S+1) answer = 0 for a in A: dp[0] += 1 # Lの数は1個ずつ加わる prev = dp[:] for i in range(S-a+1): dp[i+a] += prev[i] an...
20
20
379
377
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 998244353 N, S = lr() A = lr() dp = [0] * (S + 1) answer = 0 for a in A: dp[0] += 1 # Lの数は1個ずつ加わる prev = dp.copy() for i in range(S - a + 1): dp[i + a] += prev[i] answer...
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 998244353 N, S = lr() A = lr() dp = [0] * (S + 1) answer = 0 for a in A: dp[0] += 1 # Lの数は1個ずつ加わる prev = dp[:] for i in range(S - a + 1): dp[i + a] += prev[i] answer += ...
false
0
[ "- prev = dp.copy()", "+ prev = dp[:]", "- answer += dp[-1] # その位置Rとした時", "+ answer += dp[-1] # その位置をRとした時" ]
false
0.037645
0.045604
0.82548
[ "s825485637", "s117788806" ]
u207799478
p02663
python
s906915214
s704222541
208
142
68,624
77,284
Accepted
Accepted
31.73
import math import string import collections from collections import Counter from collections import deque def readints(): return list(map(int, input().split())) def nCr(n, r): return math.factorial(n)//(math.factorial(n-r)*math.factorial(r)) def has_duplicates2(seq): seen = [] fo...
from copy import deepcopy import math import string import collections from collections import Counter from collections import deque from decimal import Decimal import sys import fractions from operator import itemgetter import itertools import copy def readints(): return list(map(int, input().spli...
39
47
762
914
import math import string import collections from collections import Counter from collections import deque def readints(): return list(map(int, input().split())) def nCr(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) def has_duplicates2(seq): seen = [] for item in s...
from copy import deepcopy import math import string import collections from collections import Counter from collections import deque from decimal import Decimal import sys import fractions from operator import itemgetter import itertools import copy def readints(): return list(map(int, input().split())) def nCr...
false
17.021277
[ "+from copy import deepcopy", "+from decimal import Decimal", "+import sys", "+import fractions", "+from operator import itemgetter", "+import itertools", "+import copy", "-h = (h2 - h1) * 60", "-m = m2 - m1", "-sum = h + m", "-print((sum - k))", "+ans = (h2 - h1) * 60", "+ans += m2 - m1", ...
false
0.007113
0.035411
0.200867
[ "s906915214", "s704222541" ]
u077291787
p02927
python
s498929484
s411220049
27
17
3,064
2,940
Accepted
Accepted
37.04
# jsc2019-qualA - Takahashi Calendar # exhaustive search def main(): M, D = tuple(map(int, input().split())) ans = 0 for m in range(1, M + 1): for d in range(1, D + 1): if len(str(d)) != 1: d1, d10 = int(str(d)[1]), int(str(d)[0]) if d1 >= 2 and d...
# jsc2019-qualA - Takahashi Calendar def main(): M, D = tuple(map(int, input().split())) ans = 0 for d in range(22, D + 1): d1, d10 = d % 10, d // 10 ans += 1 if d1 >= 2 and d1 * d10 <= M else 0 print(ans) if __name__ == "__main__": main()
16
12
442
288
# jsc2019-qualA - Takahashi Calendar # exhaustive search def main(): M, D = tuple(map(int, input().split())) ans = 0 for m in range(1, M + 1): for d in range(1, D + 1): if len(str(d)) != 1: d1, d10 = int(str(d)[1]), int(str(d)[0]) if d1 >= 2 and d10 >= 2: ...
# jsc2019-qualA - Takahashi Calendar def main(): M, D = tuple(map(int, input().split())) ans = 0 for d in range(22, D + 1): d1, d10 = d % 10, d // 10 ans += 1 if d1 >= 2 and d1 * d10 <= M else 0 print(ans) if __name__ == "__main__": main()
false
25
[ "-# exhaustive search", "- for m in range(1, M + 1):", "- for d in range(1, D + 1):", "- if len(str(d)) != 1:", "- d1, d10 = int(str(d)[1]), int(str(d)[0])", "- if d1 >= 2 and d10 >= 2:", "- ans += 1 if d1 * d10 == m else 0", "+ ...
false
0.067889
0.040789
1.664391
[ "s498929484", "s411220049" ]
u363207161
p02803
python
s898594106
s611653343
407
373
3,316
3,316
Accepted
Accepted
8.35
# https://atcoder.jp/contests/abc151/tasks/abc151_d from collections import deque h, w = list(map(int, input().split())) maze = [list(eval(input())) for i in range(h)] def bfs(sx, sy): count = [[0] * w for i in range(h)] check = [[0] * w for i in range(h)] check[sx][sy] = 1 d = deque([[s...
# https://atcoder.jp/contests/abc151/tasks/abc151_d from collections import deque h, w = list(map(int, input().split())) maze = [list(eval(input())) for i in range(h)] def bfs(sx, sy): result = 0 count = [[-1] * w for i in range(h)] count[sx][sy] = 0 d = deque([[sx, sy]]) while d: ...
42
37
1,057
932
# https://atcoder.jp/contests/abc151/tasks/abc151_d from collections import deque h, w = list(map(int, input().split())) maze = [list(eval(input())) for i in range(h)] def bfs(sx, sy): count = [[0] * w for i in range(h)] check = [[0] * w for i in range(h)] check[sx][sy] = 1 d = deque([[sx, sy]]) ...
# https://atcoder.jp/contests/abc151/tasks/abc151_d from collections import deque h, w = list(map(int, input().split())) maze = [list(eval(input())) for i in range(h)] def bfs(sx, sy): result = 0 count = [[-1] * w for i in range(h)] count[sx][sy] = 0 d = deque([[sx, sy]]) while d: x, y = ...
false
11.904762
[ "- count = [[0] * w for i in range(h)]", "- check = [[0] * w for i in range(h)]", "- check[sx][sy] = 1", "+ result = 0", "+ count = [[-1] * w for i in range(h)]", "+ count[sx][sy] = 0", "+ result = count[x][y]", "- or check[tx][ty] == 1", "+ or ...
false
0.035759
0.037151
0.96254
[ "s898594106", "s611653343" ]
u597455618
p03244
python
s995983672
s955130308
108
90
21,084
25,180
Accepted
Accepted
16.67
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1, v2 = [], [] for i in range(n): if i%2: v1.append(v[i]) else: v2.append(v[i]) vv1 = Counter(v1).most_common() vv2 = Counter(v2).most_common() if vv1[0] != vv2[0]: print((n - vv1[0][1] - ...
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1, v2 = v[::2], v[1::2] vv1 = Counter(v1).most_common() vv2 = Counter(v2).most_common() if len(set(v)) == 1: print((n//2)) elif vv1[0] != vv2[0]: print((n - vv1[0][1] - vv2[0][1])) else: print((n - max(v...
22
13
662
354
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1, v2 = [], [] for i in range(n): if i % 2: v1.append(v[i]) else: v2.append(v[i]) vv1 = Counter(v1).most_common() vv2 = Counter(v2).most_common() if vv1[0] != vv2[0]: print((n - vv1[0][1] - vv2[0][1]...
from collections import Counter n = int(eval(input())) v = list(map(int, input().split())) v1, v2 = v[::2], v[1::2] vv1 = Counter(v1).most_common() vv2 = Counter(v2).most_common() if len(set(v)) == 1: print((n // 2)) elif vv1[0] != vv2[0]: print((n - vv1[0][1] - vv2[0][1])) else: print((n - max(vv1[1][1] +...
false
40.909091
[ "-v1, v2 = [], []", "-for i in range(n):", "- if i % 2:", "- v1.append(v[i])", "- else:", "- v2.append(v[i])", "+v1, v2 = v[::2], v[1::2]", "-if vv1[0] != vv2[0]:", "+if len(set(v)) == 1:", "+ print((n // 2))", "+elif vv1[0] != vv2[0]:", "- if len(vv1) == len(vv2) == ...
false
0.100022
0.136006
0.735424
[ "s995983672", "s955130308" ]
u604774382
p02380
python
s478437457
s917307858
30
20
6,876
5,700
Accepted
Accepted
33.33
import math a, b, degC = [ float( i ) for i in input( ).split( " " ) ] radC = degC*math.pi/ 180.0 h = math.sin( radC ) * b S = (a*h)/2 x = math.cos( radC ) * b x -= a c = math.sqrt( x**2 + h**2 ) L = a + b + c print( S ) print( L ) print( h )
import math a,b,C= [ float( val ) for val in input().split( ' ' ) ] radiansC = math.radians(C) h = math.sin(radiansC)*b S = (a*h)/2 c = math.sqrt( a*a+b*b-2*a*b*math.cos(radiansC) ) L = a+b+c print( S ) print( L ) print( h )
14
11
260
236
import math a, b, degC = [float(i) for i in input().split(" ")] radC = degC * math.pi / 180.0 h = math.sin(radC) * b S = (a * h) / 2 x = math.cos(radC) * b x -= a c = math.sqrt(x**2 + h**2) L = a + b + c print(S) print(L) print(h)
import math a, b, C = [float(val) for val in input().split(" ")] radiansC = math.radians(C) h = math.sin(radiansC) * b S = (a * h) / 2 c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(radiansC)) L = a + b + c print(S) print(L) print(h)
false
21.428571
[ "-a, b, degC = [float(i) for i in input().split(\" \")]", "-radC = degC * math.pi / 180.0", "-h = math.sin(radC) * b", "+a, b, C = [float(val) for val in input().split(\" \")]", "+radiansC = math.radians(C)", "+h = math.sin(radiansC) * b", "-x = math.cos(radC) * b", "-x -= a", "-c = math.sqrt(x**2 +...
false
0.054028
0.052758
1.024077
[ "s478437457", "s917307858" ]
u002459665
p02803
python
s559384536
s951946496
361
250
3,192
3,192
Accepted
Accepted
30.75
H, W = list(map(int, input().split())) S = [] for i in range(H): s = eval(input()) S.append(list(s)) def is_street(s, t): return S[s][t] == '.' def count(maze): r = -1 for i in range(H): for j in range(W): r = max(r, maze[i][j]) return r def bfs(h, w): ...
H, W = list(map(int, input().split())) S = [] for i in range(H): s = eval(input()) S.append(list(s)) def is_street(s, t): """ 道であること(壁ではないこと)を確認 """ return S[s][t] == '.' def count(maze): """ 最大のコストを探索 """ r = -1 for i in range(H): for j in range(W...
60
78
1,481
1,588
H, W = list(map(int, input().split())) S = [] for i in range(H): s = eval(input()) S.append(list(s)) def is_street(s, t): return S[s][t] == "." def count(maze): r = -1 for i in range(H): for j in range(W): r = max(r, maze[i][j]) return r def bfs(h, w): m = [] fo...
H, W = list(map(int, input().split())) S = [] for i in range(H): s = eval(input()) S.append(list(s)) def is_street(s, t): """ 道であること(壁ではないこと)を確認 """ return S[s][t] == "." def count(maze): """ 最大のコストを探索 """ r = -1 for i in range(H): for j in range(W): r...
false
23.076923
[ "+ \"\"\"", "+ 道であること(壁ではないこと)を確認", "+ \"\"\"", "+ \"\"\"", "+ 最大のコストを探索", "+ \"\"\"", "- m = []", "+ \"\"\"", "+ h: スタート位置(高さ)", "+ w: スタート位置(横)", "+ \"\"\"", "+ m = [] # スタート地点からの距離が入る", "- m[h][w] = 0", "- q = [[h, w]]", "+ m[h][w] = 0 # ...
false
0.042586
0.034943
1.218712
[ "s559384536", "s951946496" ]
u665038048
p03107
python
s685497792
s989010322
28
18
3,956
3,188
Accepted
Accepted
35.71
S = list(map(str, input().strip())) num_of_zero = S.count('0') num_of_one = S.count('1') if num_of_zero <= num_of_one: delete_num = 2 * num_of_zero else: delete_num = 2 * num_of_one print(delete_num)
S = eval(input()) N = len(S) num_one = S.count('1') num_zero = S.count('0') print((N - abs(num_one - num_zero)))
8
5
215
109
S = list(map(str, input().strip())) num_of_zero = S.count("0") num_of_one = S.count("1") if num_of_zero <= num_of_one: delete_num = 2 * num_of_zero else: delete_num = 2 * num_of_one print(delete_num)
S = eval(input()) N = len(S) num_one = S.count("1") num_zero = S.count("0") print((N - abs(num_one - num_zero)))
false
37.5
[ "-S = list(map(str, input().strip()))", "-num_of_zero = S.count(\"0\")", "-num_of_one = S.count(\"1\")", "-if num_of_zero <= num_of_one:", "- delete_num = 2 * num_of_zero", "-else:", "- delete_num = 2 * num_of_one", "-print(delete_num)", "+S = eval(input())", "+N = len(S)", "+num_one = S.c...
false
0.078022
0.036725
2.1245
[ "s685497792", "s989010322" ]
u428132025
p02833
python
s990364305
s643137894
20
18
3,188
2,940
Accepted
Accepted
10
import math N = int(eval(input())) ans = 0 if N % 2 == 1: pass else: div = 10 #for i in range(0, 25): while div <= N: ans += N // div div *= 5 print(ans)
N = int(eval(input())) ans = 0 if N % 2 == 1: pass else: div = 10 for i in range(0, 25): #while div <= N: ans += N // div div *= 5 print(ans)
15
13
196
181
import math N = int(eval(input())) ans = 0 if N % 2 == 1: pass else: div = 10 # for i in range(0, 25): while div <= N: ans += N // div div *= 5 print(ans)
N = int(eval(input())) ans = 0 if N % 2 == 1: pass else: div = 10 for i in range(0, 25): # while div <= N: ans += N // div div *= 5 print(ans)
false
13.333333
[ "-import math", "-", "- # for i in range(0, 25):", "- while div <= N:", "+ for i in range(0, 25):", "+ # while div <= N:" ]
false
0.044559
0.04441
1.003362
[ "s990364305", "s643137894" ]
u489959379
p02862
python
s151565908
s610505846
640
233
82,476
3,192
Accepted
Accepted
63.59
import sys input = sys.stdin.readline MOD = 1000000007 def comb_mod(n, r, mod): if n < r: return 0 elif n < 0 or r < 0: return 0 else: fac = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, n + 1): fac.append(fac[-1] * i % mod) ...
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 class CmbMod: def __init__(self, n, p): """ 二項係数nCr(n個の区別できるものからr個のものを選ぶ組み合わせの数)をpで割った余りを求める """ self.n = n self.p = p self.fact = [1, 1] ...
29
71
654
1,876
import sys input = sys.stdin.readline MOD = 1000000007 def comb_mod(n, r, mod): if n < r: return 0 elif n < 0 or r < 0: return 0 else: fac = [1, 1] finv = [1, 1] inv = [0, 1] for i in range(2, n + 1): fac.append(fac[-1] * i % mod) in...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 class CmbMod: def __init__(self, n, p): """ 二項係数nCr(n個の区別できるものからr個のものを選ぶ組み合わせの数)をpで割った余りを求める """ self.n = n self.p = p self.fact = [1, 1] self.factinv = ...
false
59.15493
[ "+sys.setrecursionlimit(10**7)", "-MOD = 1000000007", "+f_inf = float(\"inf\")", "+mod = 10**9 + 7", "-def comb_mod(n, r, mod):", "- if n < r:", "- return 0", "- elif n < 0 or r < 0:", "- return 0", "- else:", "- fac = [1, 1]", "- finv = [1, 1]", "- ...
false
0.209815
0.318882
0.657969
[ "s151565908", "s610505846" ]
u557494880
p04013
python
s080912547
s309155576
441
53
96,732
5,748
Accepted
Accepted
87.98
N, A = list(map(int,input().split())) X = list(map(int,input().split())) dp = [[[0 for i in range(N*50+1)] for j in range(N+1)] for k in range(N+1)] for i in range(N+1): dp[i][0][0] = 1 for i in range(1,N+1): x = X[i-1] for j in range(1,N+1): for k in range(N*50+1): if k < x: ...
N,A = list(map(int,input().split())) X = list(map(int,input().split())) for i in range(N): X[i] -= A dp = [[0 for i in range(5001)] for i in range(N+1)] dp[0][2500] = 1 u = 2500 d = 2500 for i in range(1,N+1): x = X[i-1] if x <= 0: d += x else: u += x for j in range(d,u...
21
17
608
387
N, A = list(map(int, input().split())) X = list(map(int, input().split())) dp = [[[0 for i in range(N * 50 + 1)] for j in range(N + 1)] for k in range(N + 1)] for i in range(N + 1): dp[i][0][0] = 1 for i in range(1, N + 1): x = X[i - 1] for j in range(1, N + 1): for k in range(N * 50 + 1): ...
N, A = list(map(int, input().split())) X = list(map(int, input().split())) for i in range(N): X[i] -= A dp = [[0 for i in range(5001)] for i in range(N + 1)] dp[0][2500] = 1 u = 2500 d = 2500 for i in range(1, N + 1): x = X[i - 1] if x <= 0: d += x else: u += x for j in range(d, u + ...
false
19.047619
[ "-dp = [[[0 for i in range(N * 50 + 1)] for j in range(N + 1)] for k in range(N + 1)]", "-for i in range(N + 1):", "- dp[i][0][0] = 1", "+for i in range(N):", "+ X[i] -= A", "+dp = [[0 for i in range(5001)] for i in range(N + 1)]", "+dp[0][2500] = 1", "+u = 2500", "+d = 2500", "- for j in...
false
0.049158
0.079476
0.618523
[ "s080912547", "s309155576" ]
u597374218
p02725
python
s831075973
s950455447
219
112
26,420
25,840
Accepted
Accepted
48.86
K,N=list(map(int,input().split())) A=list(map(int,input().split())) distance=max(A)-min(A) for i in range(N): A.append(A[i]+K) for i in range(N): distance=min(distance,A[i+N-1]-A[i]) print(distance)
K,N=list(map(int,input().split())) A=list(map(int,input().split())) A+=[A[0]+K] print((min(K-(A[i+1]-A[i]) for i in range(N))))
8
4
207
122
K, N = list(map(int, input().split())) A = list(map(int, input().split())) distance = max(A) - min(A) for i in range(N): A.append(A[i] + K) for i in range(N): distance = min(distance, A[i + N - 1] - A[i]) print(distance)
K, N = list(map(int, input().split())) A = list(map(int, input().split())) A += [A[0] + K] print((min(K - (A[i + 1] - A[i]) for i in range(N))))
false
50
[ "-distance = max(A) - min(A)", "-for i in range(N):", "- A.append(A[i] + K)", "-for i in range(N):", "- distance = min(distance, A[i + N - 1] - A[i])", "-print(distance)", "+A += [A[0] + K]", "+print((min(K - (A[i + 1] - A[i]) for i in range(N))))" ]
false
0.052352
0.035384
1.479529
[ "s831075973", "s950455447" ]
u796942881
p03401
python
s770760287
s611336043
143
111
19,148
20,032
Accepted
Accepted
22.38
input = open(0).read N, *A = [int(i) for i in input().split()] def main(): l = [abs(A[i + 1] - A[i]) for i in range(N - 1)] num = sum(l) print((num - l[0] + abs(A[1]) + abs(A[-1]))) if N != 2: print(("\n".join( [str(num - l[i] - l[i + 1] + abs(A[...
def main(): N = int(eval(input())) A = [0] + [int(i) for i in input().split()] + [0] d = [abs(A[i + 1] - A[i]) for i in range(N + 1)] num = sum(d) print(("\n".join( [str(num - d[i] - d[i + 1] + abs(A[i] - A[i + 2])) for i in range(N)]))) return main()
23
13
476
300
input = open(0).read N, *A = [int(i) for i in input().split()] def main(): l = [abs(A[i + 1] - A[i]) for i in range(N - 1)] num = sum(l) print((num - l[0] + abs(A[1]) + abs(A[-1]))) if N != 2: print( ( "\n".join( [ str( ...
def main(): N = int(eval(input())) A = [0] + [int(i) for i in input().split()] + [0] d = [abs(A[i + 1] - A[i]) for i in range(N + 1)] num = sum(d) print( ( "\n".join( [str(num - d[i] - d[i + 1] + abs(A[i] - A[i + 2])) for i in range(N)] ) ) ...
false
43.478261
[ "-input = open(0).read", "-N, *A = [int(i) for i in input().split()]", "-", "-", "- l = [abs(A[i + 1] - A[i]) for i in range(N - 1)]", "- num = sum(l)", "- print((num - l[0] + abs(A[1]) + abs(A[-1])))", "- if N != 2:", "- print(", "- (", "- \"\\n\".jo...
false
0.100388
0.042744
2.348607
[ "s770760287", "s611336043" ]