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
u863955163
p02784
python
s783868903
s496294271
52
41
13,964
13,964
Accepted
Accepted
21.15
H, N = list(map(int, input().split())) A = list(map(int, input().split())) for i in A: H -= i if H < 1: print('Yes') exit() print('No')
H, N = list(map(int, input().split())) A = list(map(int, input().split())) print(('Yes' if sum(A) >= H else 'No'))
8
3
160
108
H, N = list(map(int, input().split())) A = list(map(int, input().split())) for i in A: H -= i if H < 1: print("Yes") exit() print("No")
H, N = list(map(int, input().split())) A = list(map(int, input().split())) print(("Yes" if sum(A) >= H else "No"))
false
62.5
[ "-for i in A:", "- H -= i", "- if H < 1:", "- print(\"Yes\")", "- exit()", "-print(\"No\")", "+print((\"Yes\" if sum(A) >= H else \"No\"))" ]
false
0.038283
0.038048
1.006184
[ "s783868903", "s496294271" ]
u832152513
p02900
python
s519963911
s005902668
473
287
65,768
65,768
Accepted
Accepted
39.32
import fractions a, b = list(map(int, input().split())) x = fractions.gcd(a,b) ans = [] i = 2 y = int(x**0.5) for j in range(10000000): if x%i == 0: x //= i ans.append(i) i = 2 y = int(x**0.5) elif i == y: ans.append(x) break else: ...
import fractions a, b = list(map(int, input().split())) x = fractions.gcd(a,b) ans = [] i = 2 y = int(x**0.5) while True: if x%i == 0: x //= i ans.append(i) elif i == y: ans.append(x) break elif x == 1: break else: i += 1 print((le...
22
22
348
327
import fractions a, b = list(map(int, input().split())) x = fractions.gcd(a, b) ans = [] i = 2 y = int(x**0.5) for j in range(10000000): if x % i == 0: x //= i ans.append(i) i = 2 y = int(x**0.5) elif i == y: ans.append(x) break else: i += 1 print((le...
import fractions a, b = list(map(int, input().split())) x = fractions.gcd(a, b) ans = [] i = 2 y = int(x**0.5) while True: if x % i == 0: x //= i ans.append(i) elif i == y: ans.append(x) break elif x == 1: break else: i += 1 print((len(set(ans)) + 1))
false
0
[ "-for j in range(10000000):", "+while True:", "- i = 2", "- y = int(x**0.5)", "+ break", "+ elif x == 1:" ]
false
1.559724
0.054328
28.709585
[ "s519963911", "s005902668" ]
u270681687
p03165
python
s657596748
s168030170
1,115
510
258,440
115,164
Accepted
Accepted
54.26
s = eval(input()) t = eval(input()) len_s = len(s) len_t = len(t) INF = float('inf') dp = [[-INF] * (len_t+1) for _ in range(len_s+1)] dp[0][0] = 0 for i in range(len_s+1): for j in range(len_t+1): if i+1 <= len_s and j <= len_t: dp[i+1][j] = max(dp[i+1][j], dp[i][j]) ...
s = eval(input()) t = eval(input()) len_s = len(s) len_t = len(t) dp = [[0] * 3010 for _ in range(3010)] for i in range(len_s): for j in range(len_t): if s[i] == t[j]: dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]) ...
34
29
756
599
s = eval(input()) t = eval(input()) len_s = len(s) len_t = len(t) INF = float("inf") dp = [[-INF] * (len_t + 1) for _ in range(len_s + 1)] dp[0][0] = 0 for i in range(len_s + 1): for j in range(len_t + 1): if i + 1 <= len_s and j <= len_t: dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]) if i ...
s = eval(input()) t = eval(input()) len_s = len(s) len_t = len(t) dp = [[0] * 3010 for _ in range(3010)] for i in range(len_s): for j in range(len_t): if s[i] == t[j]: dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]) dp...
false
14.705882
[ "-INF = float(\"inf\")", "-dp = [[-INF] * (len_t + 1) for _ in range(len_s + 1)]", "-dp[0][0] = 0", "-for i in range(len_s + 1):", "- for j in range(len_t + 1):", "- if i + 1 <= len_s and j <= len_t:", "- dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])", "- if i <= len_s and j +...
false
0.046821
0.038007
1.231884
[ "s657596748", "s168030170" ]
u146803137
p02594
python
s499783330
s786015246
63
32
61,764
9,164
Accepted
Accepted
49.21
ini = lambda : int(eval(input())) inm = lambda : list(map(int,input().split())) inl = lambda : list(map(int,input().split())) gcd = lambda x,y : gcd(y,x%y) if x%y else y x = ini() if x >= 30: print('Yes') else: print('No')
x = int(eval(input())) if x >= 30: print('Yes') else: print('No')
9
5
235
67
ini = lambda: int(eval(input())) inm = lambda: list(map(int, input().split())) inl = lambda: list(map(int, input().split())) gcd = lambda x, y: gcd(y, x % y) if x % y else y x = ini() if x >= 30: print("Yes") else: print("No")
x = int(eval(input())) if x >= 30: print("Yes") else: print("No")
false
44.444444
[ "-ini = lambda: int(eval(input()))", "-inm = lambda: list(map(int, input().split()))", "-inl = lambda: list(map(int, input().split()))", "-gcd = lambda x, y: gcd(y, x % y) if x % y else y", "-x = ini()", "+x = int(eval(input()))" ]
false
0.035175
0.035131
1.001242
[ "s499783330", "s786015246" ]
u062147869
p03560
python
s414080912
s155226951
976
328
89,520
77,488
Accepted
Accepted
66.39
from heapq import heappush,heappop K=int(eval(input())) table=[[] for i in range(K)] for i in range(K): table[i].append([1,(i+1)%K]) t = (10*i)%K if t!=i: table[i].append([0,t]) dij=[] visit=[False]*K val=[10**9]*K val[1]=0 heappush(dij,[0,1]) while dij: d,x=heappop(dij) if va...
from collections import deque K=int(eval(input())) table=[[] for i in range(K)] for i in range(K): table[i].append([1,(i+1)%K]) t = (10*i)%K if t!=i: table[i].append([0,t]) dij=deque() visit=[False]*K val=[10**9]*K val[1]=0 dij.append([0,1]) while dij: d,x=dij.popleft() if val...
22
25
478
564
from heapq import heappush, heappop K = int(eval(input())) table = [[] for i in range(K)] for i in range(K): table[i].append([1, (i + 1) % K]) t = (10 * i) % K if t != i: table[i].append([0, t]) dij = [] visit = [False] * K val = [10**9] * K val[1] = 0 heappush(dij, [0, 1]) while dij: d, x = he...
from collections import deque K = int(eval(input())) table = [[] for i in range(K)] for i in range(K): table[i].append([1, (i + 1) % K]) t = (10 * i) % K if t != i: table[i].append([0, t]) dij = deque() visit = [False] * K val = [10**9] * K val[1] = 0 dij.append([0, 1]) while dij: d, x = dij.po...
false
12
[ "-from heapq import heappush, heappop", "+from collections import deque", "-dij = []", "+dij = deque()", "-heappush(dij, [0, 1])", "+dij.append([0, 1])", "- d, x = heappop(dij)", "+ d, x = dij.popleft()", "- heappush(dij, [val[y], y])", "+ if q == 1:", "+ ...
false
0.044428
0.04614
0.962894
[ "s414080912", "s155226951" ]
u600402037
p03470
python
s076513520
s417429671
20
17
2,940
2,940
Accepted
Accepted
15
print((len(set([int(eval(input())) for _ in range(int(eval(input())))]))))
N = int(eval(input())) D = [int(eval(input())) for _ in range(N)] print((len(set(D))))
1
3
60
74
print((len(set([int(eval(input())) for _ in range(int(eval(input())))]))))
N = int(eval(input())) D = [int(eval(input())) for _ in range(N)] print((len(set(D))))
false
66.666667
[ "-print((len(set([int(eval(input())) for _ in range(int(eval(input())))]))))", "+N = int(eval(input()))", "+D = [int(eval(input())) for _ in range(N)]", "+print((len(set(D))))" ]
false
0.042102
0.040675
1.035087
[ "s076513520", "s417429671" ]
u562016607
p02902
python
s027103578
s044970339
804
256
3,820
43,116
Accepted
Accepted
68.16
from collections import deque N,M=list(map(int,input().split())) G=[[] for i in range(N)] for i in range(M): a,b=list(map(int,input().split())) G[a-1].append(b-1) K=[0 for i in range(N)] for i in range(N): for p in G[i]: K[p]+=1 q=deque(i for i in range(N) if K[i]==0) res=[] while q: ...
from collections import deque N,M=list(map(int,input().split())) G=[[] for i in range(N)] for i in range(M): a,b=list(map(int,input().split())) G[a-1].append(b-1) K=[0 for i in range(N)] for i in range(N): for p in G[i]: K[p]+=1 q=deque(i for i in range(N) if K[i]==0) res=[] while q: ...
48
24
1,131
488
from collections import deque N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(M): a, b = list(map(int, input().split())) G[a - 1].append(b - 1) K = [0 for i in range(N)] for i in range(N): for p in G[i]: K[p] += 1 q = deque(i for i in range(N) if K[i] == 0) res = []...
from collections import deque N, M = list(map(int, input().split())) G = [[] for i in range(N)] for i in range(M): a, b = list(map(int, input().split())) G[a - 1].append(b - 1) K = [0 for i in range(N)] for i in range(N): for p in G[i]: K[p] += 1 q = deque(i for i in range(N) if K[i] == 0) res = []...
false
50
[ "- exit()", "-X = {i for i in range(N)}", "-for st in range(N):", "- before = [-1 for i in range(N)]", "- q = deque([st])", "- flag = 0", "- while q:", "- r = q.popleft()", "- for p in G[r]:", "- if before[p] == -1:", "- before[p] = r", "-...
false
0.04645
0.039864
1.165202
[ "s027103578", "s044970339" ]
u871980676
p02803
python
s637797489
s242842841
797
646
59,864
52,196
Accepted
Accepted
18.95
# BFS queue import queue import copy import time sss = time.time() H, W = list(map(int,input().split())) b = [list(eval(input())) for _ in range(H)] dist = [[10**2 for _ in range(W)] for _ in range(H)] start = (-1,-1) qq = queue.Queue() # start把握 for i in range(H): for j in range(W): if b[i][j]...
# BFS queue import queue H, W = list(map(int,input().split())) b = [list(eval(input())) for _ in range(H)] dist = [[100]*W for _ in range(H)] start = (-1,-1) qq = queue.Queue() # start把握 for i in range(H): for j in range(W): if b[i][j] == '.': qq.put((i,j)) far = 0 move = [(-1,0), (...
54
48
1,370
1,216
# BFS queue import queue import copy import time sss = time.time() H, W = list(map(int, input().split())) b = [list(eval(input())) for _ in range(H)] dist = [[10**2 for _ in range(W)] for _ in range(H)] start = (-1, -1) qq = queue.Queue() # start把握 for i in range(H): for j in range(W): if b[i][j] == ".": ...
# BFS queue import queue H, W = list(map(int, input().split())) b = [list(eval(input())) for _ in range(H)] dist = [[100] * W for _ in range(H)] start = (-1, -1) qq = queue.Queue() # start把握 for i in range(H): for j in range(W): if b[i][j] == ".": qq.put((i, j)) far = 0 move = [(-1, 0), (0, -1)...
false
11.111111
[ "-import copy", "-import time", "-sss = time.time()", "-dist = [[10**2 for _ in range(W)] for _ in range(H)]", "+dist = [[100] * W for _ in range(H)]", "-def BFS(start, bb):", "- dist = [[10**2 for _ in range(W)] for _ in range(H)]", "+def BFS(start):", "+ dist = [[100] * W for _ in range(H)]"...
false
0.052947
0.049232
1.075446
[ "s637797489", "s242842841" ]
u413165887
p02972
python
s491604135
s459328572
1,237
420
15,516
14,744
Accepted
Accepted
66.05
import sys n = int(eval(input())) a = list(map(int, input().split())) box = [0 for _ in range(n+1)] result = [] for i in range(n, 0, -1): counter = 0 for j in range(1, (n//i)+1): counter += box[j*i] if counter % 2 != a[i-1]: box[i] = 1 result.append(i) for i in range(1,...
def main(): import sys n = int(eval(input())) a = list(map(int, input().split())) box = [0 for _ in range(n+1)] result = [] for i in range(n, 0, -1): counter = 0 for j in range(1, (n//i)+1): counter += box[j*i] if counter % 2 != a[i-1]: ...
24
28
545
703
import sys n = int(eval(input())) a = list(map(int, input().split())) box = [0 for _ in range(n + 1)] result = [] for i in range(n, 0, -1): counter = 0 for j in range(1, (n // i) + 1): counter += box[j * i] if counter % 2 != a[i - 1]: box[i] = 1 result.append(i) for i in range(1, n ...
def main(): import sys n = int(eval(input())) a = list(map(int, input().split())) box = [0 for _ in range(n + 1)] result = [] for i in range(n, 0, -1): counter = 0 for j in range(1, (n // i) + 1): counter += box[j * i] if counter % 2 != a[i - 1]: ...
false
14.285714
[ "-import sys", "+def main():", "+ import sys", "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-box = [0 for _ in range(n + 1)]", "-result = []", "-for i in range(n, 0, -1):", "- counter = 0", "- for j in range(1, (n // i) + 1):", "- counter += box[j * i]", ...
false
0.079426
0.040809
1.946265
[ "s491604135", "s459328572" ]
u508486691
p03806
python
s388242558
s298503562
1,295
1,060
47,964
47,324
Accepted
Accepted
18.15
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row,col): ...
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row,col): ...
78
80
1,752
1,814
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row, col):...
import sys import math from collections import defaultdict from bisect import bisect_left, bisect_right sys.setrecursionlimit(10**7) def input(): return sys.stdin.readline()[:-1] mod = 10**9 + 7 def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def LIR(row, col):...
false
2.5
[ "- for v in vals[::-1]:", "- left_a = v[0] - ka", "- left_b = v[1] - kb", "- if left_a < 0 or left_b < 0:", "- break", "- if d1[ka][kb] + d2[left_a][left_b] < ans:", "- ans = d1[ka][kb] + d2[left_a][left_b]", "+ if...
false
0.2752
0.270213
1.018458
[ "s388242558", "s298503562" ]
u836737505
p03612
python
s061563232
s184743380
85
66
13,880
14,008
Accepted
Accepted
22.35
n = int(eval(input())) l = list(map(int,input().split())) ans = 0 for i in range(n): if i != n-1: if i+1 == l[i]: a = l[i] b = l[i+1] l[i]=b l[i+1]=a ans += 1 else: if i+1 == l[i]: ans += 1 print(ans)
n = int(eval(input())) p = list(map(int,input().split())) ans = 0 for i in range(n-1): if i+1 == p[i]: p[i+1] = p[i] ans += 1 if p[n-1] == n: ans += 1 print(ans)
15
10
304
188
n = int(eval(input())) l = list(map(int, input().split())) ans = 0 for i in range(n): if i != n - 1: if i + 1 == l[i]: a = l[i] b = l[i + 1] l[i] = b l[i + 1] = a ans += 1 else: if i + 1 == l[i]: ans += 1 print(ans)
n = int(eval(input())) p = list(map(int, input().split())) ans = 0 for i in range(n - 1): if i + 1 == p[i]: p[i + 1] = p[i] ans += 1 if p[n - 1] == n: ans += 1 print(ans)
false
33.333333
[ "-l = list(map(int, input().split()))", "+p = list(map(int, input().split()))", "-for i in range(n):", "- if i != n - 1:", "- if i + 1 == l[i]:", "- a = l[i]", "- b = l[i + 1]", "- l[i] = b", "- l[i + 1] = a", "- ans += 1", "- e...
false
0.045361
0.04525
1.002438
[ "s061563232", "s184743380" ]
u179169725
p02972
python
s004629810
s795706498
370
335
65,400
70,876
Accepted
Accepted
9.46
# https://atcoder.jp/contests/abc134/tasks/abc134_d # よくわからん本当に緑diff? # とりあえずエラトステネスの篩のように倍数を列挙する感じでほぼ愚直にやる # N/2以上の整数に関しては即座に答えが決まる。 # 答えが決まった部分より下を引いていけば良いのでは? import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) ...
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): ''' H is number of rows ''' ret = [] for _ in range(H): ...
39
79
658
1,656
# https://atcoder.jp/contests/abc134/tasks/abc134_d # よくわからん本当に緑diff? # とりあえずエラトステネスの篩のように倍数を列挙する感じでほぼ愚直にやる # N/2以上の整数に関しては即座に答えが決まる。 # 答えが決まった部分より下を引いていけば良いのでは? import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) N = read_a_int...
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tupl...
false
50.632911
[ "-# https://atcoder.jp/contests/abc134/tasks/abc134_d", "-# よくわからん本当に緑diff?", "-# とりあえずエラトステネスの篩のように倍数を列挙する感じでほぼ愚直にやる", "-# N/2以上の整数に関しては即座に答えが決まる。", "-# 答えが決まった部分より下を引いていけば良いのでは?", "+sys.setrecursionlimit(1 << 25)", "+ra = range", "+enu = enumerate", "+def read_tuple(H):", "+ \"\"\"", "+ ...
false
0.054002
0.055126
0.979605
[ "s004629810", "s795706498" ]
u072053884
p02235
python
s973299669
s513853764
2,480
130
7,752
5,624
Accepted
Accepted
94.76
def lcs_len(x, y): indices = [0] for y_i in y: t_index = 0 for i, index in enumerate(indices, 1): c_index = x.find(y_i, t_index) + 1 if c_index: if i < len(indices): t_index = indices[i] indices[i] = min(c_i...
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' def llcs(x, y): pm = dict((list(zip(ascii_letters, [0] * 52)))) for c in pm: for i, xc in enumerate(x): if c == xc: pm[c] |= (1 << i) V = (1 << len(x)) - 1 for yc in y: ...
22
29
559
680
def lcs_len(x, y): indices = [0] for y_i in y: t_index = 0 for i, index in enumerate(indices, 1): c_index = x.find(y_i, t_index) + 1 if c_index: if i < len(indices): t_index = indices[i] indices[i] = min(c_index, t_i...
ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" def llcs(x, y): pm = dict((list(zip(ascii_letters, [0] * 52)))) for c in pm: for i, xc in enumerate(x): if c == xc: pm[c] |= 1 << i V = (1 << len(x)) - 1 for yc in y: V = (V + (V & pm[yc]...
false
24.137931
[ "-def lcs_len(x, y):", "- indices = [0]", "- for y_i in y:", "- t_index = 0", "- for i, index in enumerate(indices, 1):", "- c_index = x.find(y_i, t_index) + 1", "- if c_index:", "- if i < len(indices):", "- t_index = indice...
false
0.044138
0.036595
1.2061
[ "s973299669", "s513853764" ]
u425177436
p03039
python
s482355276
s620486107
117
41
3,064
3,064
Accepted
Accepted
64.96
mod = 10**9 + 7 def comb(n, k): x, y = 1, 1 k = min(k, n-k) for i in range(k): x *= n - i x %= mod y *= i + 1 y %= mod return x*pow(y, mod-2, mod) % mod N, M, K = list(map(int, input().split())) print(((sum(i*(N-i)*M**2 for i in range(N))+sum(i*(M-i)*N**2 f...
mod = 10**9 + 7 def comb(n, k): x, y = 1, 1 k = min(k, n-k) for i in range(k): x *= n - i x %= mod y *= i + 1 y %= mod return x*pow(y, mod-2, mod) % mod N, M, K = list(map(int, input().split())) print(((M*M%mod*((N**3-N)//6%mod)%mod+N*N%mod*((M**3-M)//6%mod...
14
14
355
344
mod = 10**9 + 7 def comb(n, k): x, y = 1, 1 k = min(k, n - k) for i in range(k): x *= n - i x %= mod y *= i + 1 y %= mod return x * pow(y, mod - 2, mod) % mod N, M, K = list(map(int, input().split())) print( ( ( sum(i * (N - i) * M**2 for i in ...
mod = 10**9 + 7 def comb(n, k): x, y = 1, 1 k = min(k, n - k) for i in range(k): x *= n - i x %= mod y *= i + 1 y %= mod return x * pow(y, mod - 2, mod) % mod N, M, K = list(map(int, input().split())) print( ( ( M * M % mod * ((N**3 - N) // 6 %...
false
0
[ "- sum(i * (N - i) * M**2 for i in range(N))", "- + sum(i * (M - i) * N**2 for i in range(M))", "+ M * M % mod * ((N**3 - N) // 6 % mod) % mod", "+ + N * N % mod * ((M**3 - M) // 6 % mod) % mod", "+ % mod" ]
false
0.043215
0.038777
1.114453
[ "s482355276", "s620486107" ]
u017810624
p02807
python
s236841583
s967658011
302
276
66,456
67,480
Accepted
Accepted
8.61
def extgcd(a,b): r = [1,0,a] w = [0,1,b] while w[2]!=1: q = r[2]//w[2] r2 = w w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]] r = r2 w = w2 return [w[0],w[1]] def mod_inv(a,m): x = extgcd(a,m)[0] return (m+x%m)%m n=int(eval(input())) x=list(...
n=int(eval(input())) x=list(map(int,input().split())) mod=10**9+7 inv=[0,1] for i in range(2,n+1): inv+=[inv[mod%i]*(mod-int(mod/i))%mod] l=[] z=1 for i in range(1,n): z*=i z%=mod l2=[z for i in range(n-1)] for i in range(n-1): l.append(x[i+1]-x[i]) for i in range(n-1): l2[i]*=inv[i+1] l2[i]...
37
26
691
467
def extgcd(a, b): r = [1, 0, a] w = [0, 1, b] while w[2] != 1: q = r[2] // w[2] r2 = w w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]] r = r2 w = w2 return [w[0], w[1]] def mod_inv(a, m): x = extgcd(a, m)[0] return (m + x % m) % m n = int(eval...
n = int(eval(input())) x = list(map(int, input().split())) mod = 10**9 + 7 inv = [0, 1] for i in range(2, n + 1): inv += [inv[mod % i] * (mod - int(mod / i)) % mod] l = [] z = 1 for i in range(1, n): z *= i z %= mod l2 = [z for i in range(n - 1)] for i in range(n - 1): l.append(x[i + 1] - x[i]) for i in...
false
29.72973
[ "-def extgcd(a, b):", "- r = [1, 0, a]", "- w = [0, 1, b]", "- while w[2] != 1:", "- q = r[2] // w[2]", "- r2 = w", "- w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]", "- r = r2", "- w = w2", "- return [w[0], w[1]]", "-", "-", "-def mo...
false
0.037351
0.037804
0.987996
[ "s236841583", "s967658011" ]
u173148629
p02629
python
s329067359
s634681494
35
30
8,992
9,096
Accepted
Accepted
14.29
N=int(eval(input())) ans=[] a=ord("a") tmp=0 while N>0: tmp+=1 if tmp==1: chrr=N%26-1 if chrr<0: chrr+=26 ans.append(chr(a+chrr)) else: chrr=((N-1)//(26**(tmp-1)))%26 if chrr<0: chrr+=26 ans.append(chr(a+chrr)) N-=...
N=int(eval(input())) ans=[] a=ord("a") while N>0: N-=1 chrr=N%26 ans.append(chr(a+chrr)) N//=26 print(("".join(ans[::-1])))
20
12
350
146
N = int(eval(input())) ans = [] a = ord("a") tmp = 0 while N > 0: tmp += 1 if tmp == 1: chrr = N % 26 - 1 if chrr < 0: chrr += 26 ans.append(chr(a + chrr)) else: chrr = ((N - 1) // (26 ** (tmp - 1))) % 26 if chrr < 0: chrr += 26 ans.app...
N = int(eval(input())) ans = [] a = ord("a") while N > 0: N -= 1 chrr = N % 26 ans.append(chr(a + chrr)) N //= 26 print(("".join(ans[::-1])))
false
40
[ "-tmp = 0", "- tmp += 1", "- if tmp == 1:", "- chrr = N % 26 - 1", "- if chrr < 0:", "- chrr += 26", "- ans.append(chr(a + chrr))", "- else:", "- chrr = ((N - 1) // (26 ** (tmp - 1))) % 26", "- if chrr < 0:", "- chrr += 26", "- ...
false
0.043949
0.04618
0.951676
[ "s329067359", "s634681494" ]
u623687794
p02597
python
s733733121
s782816192
82
64
71,300
63,164
Accepted
Accepted
21.95
n=int(eval(input())) c=eval(input()) if "R" not in c or "W" not in c:print((0));exit() rcnt=[0]*(n+1) wcnt=[0]*(n+1) for i in range(n): if c[i]=="W": wcnt[i+1]=wcnt[i]+1 rcnt[i+1]=rcnt[i] else: rcnt[i+1]=rcnt[i]+1 wcnt[i+1]=wcnt[i] ans=n+100 for i in range(n): c...
n=int(eval(input())) s=eval(input()) r=s.count('R') print((s[:r].count('W')))
19
4
414
66
n = int(eval(input())) c = eval(input()) if "R" not in c or "W" not in c: print((0)) exit() rcnt = [0] * (n + 1) wcnt = [0] * (n + 1) for i in range(n): if c[i] == "W": wcnt[i + 1] = wcnt[i] + 1 rcnt[i + 1] = rcnt[i] else: rcnt[i + 1] = rcnt[i] + 1 wcnt[i + 1] = wcnt[i] a...
n = int(eval(input())) s = eval(input()) r = s.count("R") print((s[:r].count("W")))
false
78.947368
[ "-c = eval(input())", "-if \"R\" not in c or \"W\" not in c:", "- print((0))", "- exit()", "-rcnt = [0] * (n + 1)", "-wcnt = [0] * (n + 1)", "-for i in range(n):", "- if c[i] == \"W\":", "- wcnt[i + 1] = wcnt[i] + 1", "- rcnt[i + 1] = rcnt[i]", "- else:", "- rc...
false
0.037684
0.037488
1.005212
[ "s733733121", "s782816192" ]
u577170763
p03163
python
s582972642
s513143930
406
361
119,532
81,468
Accepted
Accepted
11.08
N, W = list(map(int, input().split())) wv = [] for _ in range(N): wv.append(tuple(map(int, input().split()))) dp = [[0]*(W+1) for _ in range(N+1)] for i in range(N): wi, vi = wv[i] for j in range(wi): dp[i+1][j] = dp[i][j] for j in range(wi, W+1): dp[i+1][j] = max(dp[...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict geta = lambda fn: list(map(fn, input().split())) gete = lambda fn: fn(eval(input())) N, W = geta(int) cur = [0] * (W+1) for i in range(N): w, v = geta(int) update = cur[:] for j in range(w,W+1): tmp = c...
18
19
358
409
N, W = list(map(int, input().split())) wv = [] for _ in range(N): wv.append(tuple(map(int, input().split()))) dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(N): wi, vi = wv[i] for j in range(wi): dp[i + 1][j] = dp[i][j] for j in range(wi, W + 1): dp[i + 1][j] = max(dp[i][j], d...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict geta = lambda fn: list(map(fn, input().split())) gete = lambda fn: fn(eval(input())) N, W = geta(int) cur = [0] * (W + 1) for i in range(N): w, v = geta(int) update = cur[:] for j in range(w, W + 1): tmp = cur[j - w] +...
false
5.263158
[ "-N, W = list(map(int, input().split()))", "-wv = []", "-for _ in range(N):", "- wv.append(tuple(map(int, input().split())))", "-dp = [[0] * (W + 1) for _ in range(N + 1)]", "+# import sys", "+# sys.setrecursionlimit(10**5)", "+# from collections import defaultdict", "+geta = lambda fn: list(map(...
false
0.031963
0.041083
0.778017
[ "s582972642", "s513143930" ]
u073852194
p03160
python
s508016585
s466943127
157
125
20,536
20,512
Accepted
Accepted
20.38
INF = 10**18 N = int(eval(input())) H = list(map(int, input().split())) dp = [INF for _ in range(N)] dp[0] = 0 for i in range(N - 1): dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i])) if i != N - 2: dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i])) print((dp[N - 1]))
N = int(eval(input())) H = list(map(int, input().split())) dp = [0 for _ in range(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])) print((dp[N - 1]))
14
10
306
239
INF = 10**18 N = int(eval(input())) H = list(map(int, input().split())) dp = [INF for _ in range(N)] dp[0] = 0 for i in range(N - 1): dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i])) if i != N - 2: dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i])) print((dp[N - 1]))
N = int(eval(input())) H = list(map(int, input().split())) dp = [0 for _ in range(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])) print((dp[N - 1]))
false
28.571429
[ "-INF = 10**18", "-dp = [INF for _ in range(N)]", "-dp[0] = 0", "-for i in range(N - 1):", "- dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]))", "- if i != N - 2:", "- dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))", "+dp = [0 for _ in range(N)]", "+dp[1] = abs(H[1] - ...
false
0.045132
0.040967
1.101681
[ "s508016585", "s466943127" ]
u994988729
p03200
python
s057856828
s520747848
70
42
3,500
3,500
Accepted
Accepted
40
import sys input = sys.stdin.readline s = input().rstrip() ans = 0 pos = 0 for i in range(len(s)): if s[i] == "W": ans += i-pos pos += 1 print(ans)
S = eval(input()) b = 0 ans = 0 for s in S: if s == "B": b += 1 else: ans += b print(ans)
12
11
181
120
import sys input = sys.stdin.readline s = input().rstrip() ans = 0 pos = 0 for i in range(len(s)): if s[i] == "W": ans += i - pos pos += 1 print(ans)
S = eval(input()) b = 0 ans = 0 for s in S: if s == "B": b += 1 else: ans += b print(ans)
false
8.333333
[ "-import sys", "-", "-input = sys.stdin.readline", "-s = input().rstrip()", "+S = eval(input())", "+b = 0", "-pos = 0", "-for i in range(len(s)):", "- if s[i] == \"W\":", "- ans += i - pos", "- pos += 1", "+for s in S:", "+ if s == \"B\":", "+ b += 1", "+ el...
false
0.107451
0.036928
2.90977
[ "s057856828", "s520747848" ]
u912330011
p02552
python
s501011426
s336293949
30
24
9,140
8,892
Accepted
Accepted
20
print((int(not int(eval(input())))))
print((1 if eval(input())=='0' else 0))
1
1
28
31
print((int(not int(eval(input())))))
print((1 if eval(input()) == "0" else 0))
false
0
[ "-print((int(not int(eval(input())))))", "+print((1 if eval(input()) == \"0\" else 0))" ]
false
0.109629
0.044355
2.471628
[ "s501011426", "s336293949" ]
u945181840
p03283
python
s109911045
s181682501
1,834
1,450
15,288
99,788
Accepted
Accepted
20.94
import numpy as np import sys input = sys.stdin.readline N, M, Q = list(map(int, input().split())) city = np.zeros((N + 2, N + 1), dtype=np.int) for _ in range(M): L, R = list(map(int, input().split())) city[L][R] += 1 np.cumsum(city, axis=0, out=city) np.cumsum(city, axis=1, out=city) for _ i...
import numpy as np import sys readlines = sys.stdin.readlines() N, M, Q = list(map(int, readlines[0].split())) city = np.zeros((N + 2, N + 1), dtype=int) L, R = np.array([i.split() for i in readlines[1:M + 1]], dtype=int).T pq = [list(map(int, i.split())) for i in readlines[M + 1:]] np.add.at(city, (L, R), 1...
17
15
435
476
import numpy as np import sys input = sys.stdin.readline N, M, Q = list(map(int, input().split())) city = np.zeros((N + 2, N + 1), dtype=np.int) for _ in range(M): L, R = list(map(int, input().split())) city[L][R] += 1 np.cumsum(city, axis=0, out=city) np.cumsum(city, axis=1, out=city) for _ in range(Q): p...
import numpy as np import sys readlines = sys.stdin.readlines() N, M, Q = list(map(int, readlines[0].split())) city = np.zeros((N + 2, N + 1), dtype=int) L, R = np.array([i.split() for i in readlines[1 : M + 1]], dtype=int).T pq = [list(map(int, i.split())) for i in readlines[M + 1 :]] np.add.at(city, (L, R), 1) np.cu...
false
11.764706
[ "-input = sys.stdin.readline", "-N, M, Q = list(map(int, input().split()))", "-city = np.zeros((N + 2, N + 1), dtype=np.int)", "-for _ in range(M):", "- L, R = list(map(int, input().split()))", "- city[L][R] += 1", "+readlines = sys.stdin.readlines()", "+N, M, Q = list(map(int, readlines[0].spli...
false
0.22055
0.243396
0.906135
[ "s109911045", "s181682501" ]
u544587633
p02861
python
s810024539
s493790299
426
18
17,268
3,060
Accepted
Accepted
95.77
import sys import itertools import numpy as np lines = sys.stdin.readlines() N = int(lines[0].rstrip()) perms = list(itertools.permutations(list(range(N)))) combs = list(itertools.combinations(list(range(N)), 2)) arr_2d = np.zeros((N,2)) if N <= 2: arr_dist_memo = np.zeros((len(combs)+1,len(combs)+1)) ...
n=int(eval(input())) xy=[] for _ in range(n): x,y=list(map(int,input().split())) xy.append([x,y]) ans=0 for i in range(n): for j in range(n): ans+=((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5 print((ans/n))
31
10
787
215
import sys import itertools import numpy as np lines = sys.stdin.readlines() N = int(lines[0].rstrip()) perms = list(itertools.permutations(list(range(N)))) combs = list(itertools.combinations(list(range(N)), 2)) arr_2d = np.zeros((N, 2)) if N <= 2: arr_dist_memo = np.zeros((len(combs) + 1, len(combs) + 1)) else: ...
n = int(eval(input())) xy = [] for _ in range(n): x, y = list(map(int, input().split())) xy.append([x, y]) ans = 0 for i in range(n): for j in range(n): ans += ((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) ** 0.5 print((ans / n))
false
67.741935
[ "-import sys", "-import itertools", "-import numpy as np", "-", "-lines = sys.stdin.readlines()", "-N = int(lines[0].rstrip())", "-perms = list(itertools.permutations(list(range(N))))", "-combs = list(itertools.combinations(list(range(N)), 2))", "-arr_2d = np.zeros((N, 2))", "-if N <= 2:", "- ...
false
0.684083
0.048621
14.069595
[ "s810024539", "s493790299" ]
u250583425
p02983
python
s602859160
s904817733
514
298
3,064
3,064
Accepted
Accepted
42.02
import sys def input(): return sys.stdin.readline().rstrip() def main(): mod = 2019 l, r = list(map(int, input().split())) l_div = l // mod if mod * (l_div + 2) < r: print((0)) quit() elif mod * (l_div + 1) < r: print((1)) quit() ans = 2020 r_mo...
import sys def input(): return sys.stdin.readline().rstrip() def main(): mod = 2019 l, r = list(map(int, input().split())) l_div = l // mod if mod * (l_div + 2) < r: print((0)) quit() elif mod * (l_div + 1) < r: print((1)) quit() ans = 2020 r_mo...
22
24
503
558
import sys def input(): return sys.stdin.readline().rstrip() def main(): mod = 2019 l, r = list(map(int, input().split())) l_div = l // mod if mod * (l_div + 2) < r: print((0)) quit() elif mod * (l_div + 1) < r: print((1)) quit() ans = 2020 r_mod = r %...
import sys def input(): return sys.stdin.readline().rstrip() def main(): mod = 2019 l, r = list(map(int, input().split())) l_div = l // mod if mod * (l_div + 2) < r: print((0)) quit() elif mod * (l_div + 1) < r: print((1)) quit() ans = 2020 r_mod_1 = r...
false
8.333333
[ "- r_mod = r % mod", "- for i in range(l % mod, r_mod + 1):", "- for j in range(i + 1, r_mod + 1):", "- ans = min(ans, i * j % mod)", "+ r_mod_1 = r % mod + 1", "+ for i in range(l % mod, r_mod_1):", "+ for j in range(i + 1, r_mod_1):", "+ ij_mod = i * j...
false
0.036704
0.088984
0.412482
[ "s602859160", "s904817733" ]
u888092736
p02574
python
s409652624
s187813035
564
517
121,976
121,900
Accepted
Accepted
8.33
from math import gcd from functools import reduce class SmallestPrimeFactors: def __init__(self, n): self.spf = list(range(n + 1)) for i in range(2, int(n ** 0.5) + 1): if self.spf[i] == i: for j in range(i * i, n + 1, i): if self.spf[j] ==...
from math import gcd from functools import reduce class SmallestPrimeFactors: def __init__(self, n): self.spf = list(range(n + 1)) for i in range(2, int(n ** 0.5) + 1): if self.spf[i] == i: for j in range(i * i, n + 1, i): if self.spf[j] ==...
46
44
1,084
1,037
from math import gcd from functools import reduce class SmallestPrimeFactors: def __init__(self, n): self.spf = list(range(n + 1)) for i in range(2, int(n**0.5) + 1): if self.spf[i] == i: for j in range(i * i, n + 1, i): if self.spf[j] == j: ...
from math import gcd from functools import reduce class SmallestPrimeFactors: def __init__(self, n): self.spf = list(range(n + 1)) for i in range(2, int(n**0.5) + 1): if self.spf[i] == i: for j in range(i * i, n + 1, i): if self.spf[j] == j: ...
false
4.347826
[ "- M = max(A)", "- spf = SmallestPrimeFactors(M)", "- counter = [0] * (M + 1)", "+ spf = SmallestPrimeFactors(1_000_000)", "+ primes = set()", "- for np in new_primes:", "- if counter[np]:", "- return False", "- counter[np] = 1", "+ ...
false
0.03928
0.524872
0.074838
[ "s409652624", "s187813035" ]
u293198424
p03730
python
s474614974
s134446491
178
163
38,256
38,256
Accepted
Accepted
8.43
a,b,c = list(map(int,input().split())) flag = False for i in range(1,101): if (a*i)%b==c: flag = True print(('YES' if flag==True else 'NO'))
a,b,c = list(map(int,input().split())) flag = False for i in range(1,b+1): if (a*i-c)%b==0: flag = True print(('YES' if flag==True else 'NO'))
7
6
155
152
a, b, c = list(map(int, input().split())) flag = False for i in range(1, 101): if (a * i) % b == c: flag = True print(("YES" if flag == True else "NO"))
a, b, c = list(map(int, input().split())) flag = False for i in range(1, b + 1): if (a * i - c) % b == 0: flag = True print(("YES" if flag == True else "NO"))
false
14.285714
[ "-for i in range(1, 101):", "- if (a * i) % b == c:", "+for i in range(1, b + 1):", "+ if (a * i - c) % b == 0:" ]
false
0.034484
0.033967
1.015229
[ "s474614974", "s134446491" ]
u621935300
p02983
python
s894101947
s286602768
61
55
30,700
29,676
Accepted
Accepted
9.84
L,R=list(map(int, input().split())) a=L%2019 b=R%2019 T=[] ans=float("inf") if a<b: T=list(range(a,b+1)) if R-L>2018: print(0) quit() else: l=len(T) for i in range(l): for j in range(i+1,l): ans=min(ans, (T[i]*T[j])%2019 ) print(ans) else: print(0) quit()
import sys L,R=list(map(int, sys.stdin.readline().split())) sho1=(L-1)/2019 sho2=R/2019 if 1<=sho2-sho1: print(0) else: ans=float("inf") for i in range(L,R): for j in range(i+1,R+1): ans=min(ans,i*j%2019) print(ans)
22
12
291
255
L, R = list(map(int, input().split())) a = L % 2019 b = R % 2019 T = [] ans = float("inf") if a < b: T = list(range(a, b + 1)) if R - L > 2018: print(0) quit() else: l = len(T) for i in range(l): for j in range(i + 1, l): ans = min(ans, (T[i] * T[j...
import sys L, R = list(map(int, sys.stdin.readline().split())) sho1 = (L - 1) / 2019 sho2 = R / 2019 if 1 <= sho2 - sho1: print(0) else: ans = float("inf") for i in range(L, R): for j in range(i + 1, R + 1): ans = min(ans, i * j % 2019) print(ans)
false
45.454545
[ "-L, R = list(map(int, input().split()))", "-a = L % 2019", "-b = R % 2019", "-T = []", "-ans = float(\"inf\")", "-if a < b:", "- T = list(range(a, b + 1))", "- if R - L > 2018:", "- print(0)", "- quit()", "- else:", "- l = len(T)", "- for i in range(l):"...
false
0.105941
0.131987
0.80266
[ "s894101947", "s286602768" ]
u263753244
p03854
python
s263134493
s001687739
238
210
44,396
42,992
Accepted
Accepted
11.76
s=eval(input()) n=len(s) i=1 for j in range(n): if s[-i:-i-5:-1]=="maerd": i+=5 if s[-i:-i-5:-1]=="esare": i+=5 if s[-i:-i-6:-1]=="resare": i+=6 if s[-i:-i-7:-1]=="remaerd": i+=7 if i==n+1: print("YES") break if i != n+1: ...
s=eval(input()) n=len(s) i=1 for j in range(n//5): if s[-i:-i-5:-1]=="maerd": i+=5 if s[-i:-i-5:-1]=="esare": i+=5 if s[-i:-i-6:-1]=="resare": i+=6 if s[-i:-i-7:-1]=="remaerd": i+=7 if i==n+1: print("YES") break if i != n+1: ...
22
22
326
329
s = eval(input()) n = len(s) i = 1 for j in range(n): if s[-i : -i - 5 : -1] == "maerd": i += 5 if s[-i : -i - 5 : -1] == "esare": i += 5 if s[-i : -i - 6 : -1] == "resare": i += 6 if s[-i : -i - 7 : -1] == "remaerd": i += 7 if i == n + 1: print("YES") ...
s = eval(input()) n = len(s) i = 1 for j in range(n // 5): if s[-i : -i - 5 : -1] == "maerd": i += 5 if s[-i : -i - 5 : -1] == "esare": i += 5 if s[-i : -i - 6 : -1] == "resare": i += 6 if s[-i : -i - 7 : -1] == "remaerd": i += 7 if i == n + 1: print("YES") ...
false
0
[ "-for j in range(n):", "+for j in range(n // 5):" ]
false
0.039815
0.038159
1.043387
[ "s263134493", "s001687739" ]
u020390084
p02843
python
s428268873
s639088370
42
18
3,864
3,060
Accepted
Accepted
57.14
#!/usr/bin/env python3 import sys def solve(X: int): dp = [False for _ in range(X+1)] dp[0] = True prices = [100,101,102,103,104,105] for i in range(1,X+1): for price in prices: if i >= price: if dp[i-price]: dp[i] = dp[i-price] ...
#!/usr/bin/env python3 import sys def solve(X: int): for i in range(1000): if i*100 <= X <= i*105: print((1)) return print((0)) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): ...
30
25
653
464
#!/usr/bin/env python3 import sys def solve(X: int): dp = [False for _ in range(X + 1)] dp[0] = True prices = [100, 101, 102, 103, 104, 105] for i in range(1, X + 1): for price in prices: if i >= price: if dp[i - price]: dp[i] = dp[i - price] ...
#!/usr/bin/env python3 import sys def solve(X: int): for i in range(1000): if i * 100 <= X <= i * 105: print((1)) return print((0)) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word...
false
16.666667
[ "- dp = [False for _ in range(X + 1)]", "- dp[0] = True", "- prices = [100, 101, 102, 103, 104, 105]", "- for i in range(1, X + 1):", "- for price in prices:", "- if i >= price:", "- if dp[i - price]:", "- dp[i] = dp[i - price]", "- ...
false
0.038838
0.037228
1.043231
[ "s428268873", "s639088370" ]
u994988729
p02844
python
s667285158
s162253701
137
19
4,716
3,060
Accepted
Accepted
86.13
from collections import defaultdict n = int(eval(input())) S = eval(input()) d = defaultdict(list) for i, s in enumerate(S): d[s].append(i) ans = 0 for p in range(1000): p1, p2, p3 = str(p).zfill(3) i0 = -1 for i in d[p1]: if i > i0: i1 = i break e...
N = int(eval(input())) S = eval(input()) ans = 0 for x in range(0, 1000): pin = str(x).zfill(3) i = S.find(pin[0]) if i == -1: continue i = S.find(pin[1], i + 1) if i == -1: continue i = S.find(pin[2], i + 1) if i == -1: continue ans += 1 prin...
34
19
542
315
from collections import defaultdict n = int(eval(input())) S = eval(input()) d = defaultdict(list) for i, s in enumerate(S): d[s].append(i) ans = 0 for p in range(1000): p1, p2, p3 = str(p).zfill(3) i0 = -1 for i in d[p1]: if i > i0: i1 = i break else: contin...
N = int(eval(input())) S = eval(input()) ans = 0 for x in range(0, 1000): pin = str(x).zfill(3) i = S.find(pin[0]) if i == -1: continue i = S.find(pin[1], i + 1) if i == -1: continue i = S.find(pin[2], i + 1) if i == -1: continue ans += 1 print(ans)
false
44.117647
[ "-from collections import defaultdict", "-", "-n = int(eval(input()))", "+N = int(eval(input()))", "-d = defaultdict(list)", "-for i, s in enumerate(S):", "- d[s].append(i)", "-for p in range(1000):", "- p1, p2, p3 = str(p).zfill(3)", "- i0 = -1", "- for i in d[p1]:", "- if ...
false
0.044037
0.036257
1.214565
[ "s667285158", "s162253701" ]
u761320129
p03240
python
s485261669
s237075671
601
118
3,064
3,828
Accepted
Accepted
80.37
N = int(eval(input())) src = [tuple(map(int,input().split())) for i in range(N)] INF = float('inf') for cx in range(0,101): for cy in range(0,101): tmph = None maxh = INF for x,y,h in src: if h > 0: tmp = h + abs(x-cx) + abs(y-cy) if tm...
N = int(eval(input())) src = [tuple(map(int,input().split())) for i in range(N)] cands = [] for cx in range(0,101): for cy in range(0,101): tmph = None for x,y,h in src: if h == 0: continue ch = h + abs(x-cx) + abs(y-cy) if ch < 0: break if...
29
24
859
623
N = int(eval(input())) src = [tuple(map(int, input().split())) for i in range(N)] INF = float("inf") for cx in range(0, 101): for cy in range(0, 101): tmph = None maxh = INF for x, y, h in src: if h > 0: tmp = h + abs(x - cx) + abs(y - cy) if tmph ...
N = int(eval(input())) src = [tuple(map(int, input().split())) for i in range(N)] cands = [] for cx in range(0, 101): for cy in range(0, 101): tmph = None for x, y, h in src: if h == 0: continue ch = h + abs(x - cx) + abs(y - cy) if ch < 0: ...
false
17.241379
[ "-INF = float(\"inf\")", "+cands = []", "- maxh = INF", "- if h > 0:", "- tmp = h + abs(x - cx) + abs(y - cy)", "- if tmph is None:", "- tmph = tmp", "- else:", "- if tmp != tmph:", "- ...
false
0.040261
0.050508
0.797107
[ "s485261669", "s237075671" ]
u533039576
p02788
python
s795835685
s593049746
866
755
89,692
89,916
Accepted
Accepted
12.82
from operator import itemgetter from bisect import bisect_right import sys input = sys.stdin.readline n, d, a = list(map(int, input().split())) monster = [tuple(map(int, input().split())) for _ in range(n)] monster.sort(key=itemgetter(0)) xx = [xi for xi, hi in monster] ans = 0 imos = [0] * (n + 1) for i,...
from operator import itemgetter from bisect import bisect_right import sys input = sys.stdin.readline n, d, a = list(map(int, input().split())) monster = [tuple(map(int, input().split())) for _ in range(n)] monster.sort(key=itemgetter(0)) xx = [xi for xi, hi in monster] # 尺取 d_range = [-1] * n idx = 0 fo...
25
33
592
737
from operator import itemgetter from bisect import bisect_right import sys input = sys.stdin.readline n, d, a = list(map(int, input().split())) monster = [tuple(map(int, input().split())) for _ in range(n)] monster.sort(key=itemgetter(0)) xx = [xi for xi, hi in monster] ans = 0 imos = [0] * (n + 1) for i, (xi, hi) in ...
from operator import itemgetter from bisect import bisect_right import sys input = sys.stdin.readline n, d, a = list(map(int, input().split())) monster = [tuple(map(int, input().split())) for _ in range(n)] monster.sort(key=itemgetter(0)) xx = [xi for xi, hi in monster] # 尺取 d_range = [-1] * n idx = 0 for i, (xi, hi) ...
false
24.242424
[ "+# 尺取", "+d_range = [-1] * n", "+idx = 0", "+for i, (xi, hi) in enumerate(monster):", "+ while idx < n and xx[idx] - xi <= 2 * d:", "+ idx += 1", "+ d_range[i] = idx", "- idx = bisect_right(xx, xi + 2 * d)", "+ idx = d_range[i]" ]
false
0.090454
0.042231
2.141907
[ "s795835685", "s593049746" ]
u160244242
p03074
python
s652459678
s663147439
190
129
48,948
8,784
Accepted
Accepted
32.11
import itertools n, k = list(map(int, input().split())) s = eval(input()) before = s[0] count = 1 lst = [] head = True if before == '1' else False tail = True if s[-1] == '1' else False for i in s[1:]: if i == before: count += 1 else: lst.append(count) count = 1 ...
n, k = list(map(int, input().split())) s = eval(input()) index_lst = [] num_lst = [] before = '-1' for K, i in enumerate(s): if i != before: before = i index_lst.append(K) num_lst.append(int(i)) N = len(index_lst) index_lst += [n] * (2*k+10) #print('index_lst: ', index_lst) #p...
44
23
825
517
import itertools n, k = list(map(int, input().split())) s = eval(input()) before = s[0] count = 1 lst = [] head = True if before == "1" else False tail = True if s[-1] == "1" else False for i in s[1:]: if i == before: count += 1 else: lst.append(count) count = 1 before = i lst.a...
n, k = list(map(int, input().split())) s = eval(input()) index_lst = [] num_lst = [] before = "-1" for K, i in enumerate(s): if i != before: before = i index_lst.append(K) num_lst.append(int(i)) N = len(index_lst) index_lst += [n] * (2 * k + 10) # print('index_lst: ', index_lst) # print('num...
false
47.727273
[ "-import itertools", "-", "-before = s[0]", "-count = 1", "-lst = []", "-head = True if before == \"1\" else False", "-tail = True if s[-1] == \"1\" else False", "-for i in s[1:]:", "- if i == before:", "- count += 1", "+index_lst = []", "+num_lst = []", "+before = \"-1\"", "+for...
false
0.087849
0.035637
2.465108
[ "s652459678", "s663147439" ]
u547167033
p03253
python
s608769719
s121455338
24
20
3,316
3,064
Accepted
Accepted
16.67
from math import sqrt, floor from collections import defaultdict def comb(n,m): if m == 0: return 1 return comb(n-1,m-1)*n // m def facts(n): dic = defaultdict(int) for i in range(2,floor(sqrt(n))+1): while n % i == 0: n //= i dic[i] += 1 if n ...
from math import sqrt,floor def comb(n,m): if m == 0: return 1 return comb(n-1,m-1)*n // m n,m=list(map(int,input().split())) mod=10**9+7 def factorization(x): ans=[] for i in range(2,floor(sqrt(x))+1): if x%i==0: cnt=0 while x%i==0: x//=i cnt+=1 ans.appe...
24
26
554
500
from math import sqrt, floor from collections import defaultdict def comb(n, m): if m == 0: return 1 return comb(n - 1, m - 1) * n // m def facts(n): dic = defaultdict(int) for i in range(2, floor(sqrt(n)) + 1): while n % i == 0: n //= i dic[i] += 1 if...
from math import sqrt, floor def comb(n, m): if m == 0: return 1 return comb(n - 1, m - 1) * n // m n, m = list(map(int, input().split())) mod = 10**9 + 7 def factorization(x): ans = [] for i in range(2, floor(sqrt(x)) + 1): if x % i == 0: cnt = 0 while x % ...
false
7.692308
[ "-from collections import defaultdict", "-def facts(n):", "- dic = defaultdict(int)", "- for i in range(2, floor(sqrt(n)) + 1):", "- while n % i == 0:", "- n //= i", "- dic[i] += 1", "- if n == 1:", "- break", "- if n != 1:", "- dic[...
false
0.050098
0.046672
1.073417
[ "s608769719", "s121455338" ]
u535803878
p02852
python
s059029920
s121533127
189
77
51,504
87,228
Accepted
Accepted
59.26
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m = list(map(int, input().split())) s = eval(input()) c = n ans = [] while True: p = None for i in range(1,m+1): if c-i>=0 and s[c-i]=="0": ...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m = list(map(int, input().split())) s = eval(input()) c = n ans = [] while c>0: val = None for i in range(1,m+1): if c-i>=0 and s[c-i]=="0": ...
26
24
510
497
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") n, m = list(map(int, input().split())) s = eval(input()) c = n ans = [] while True: p = None for i in range(1, m + 1): if c - i >= 0 and s[c - i] == "0": ...
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") n, m = list(map(int, input().split())) s = eval(input()) c = n ans = [] while c > 0: val = None for i in range(1, m + 1): if c - i >= 0 and s[c - i] == "0": ...
false
7.692308
[ "-while True:", "- p = None", "+while c > 0:", "+ val = None", "- p = i", "- if p is None:", "+ val = i", "+ if val is None:", "- c -= p", "- ans.append(p)", "- if c == 0:", "- break", "+ c = c - val", "+ ans.append(val)" ]
false
0.040098
0.031424
1.276025
[ "s059029920", "s121533127" ]
u506705885
p02398
python
s267327410
s718350865
30
20
7,704
5,596
Accepted
Accepted
33.33
nums=[] nums=input().split() a=int(nums[0]) b=int(nums[1]) c=int(nums[2]) ans=0 for i in range(a,b+1): if c%i==0: ans+=1 print(ans)
a,b,c=list(map(int,input().split())) k=0 for i in range(a,b+1): if c%i==0: k+=1 print(k)
10
6
152
97
nums = [] nums = input().split() a = int(nums[0]) b = int(nums[1]) c = int(nums[2]) ans = 0 for i in range(a, b + 1): if c % i == 0: ans += 1 print(ans)
a, b, c = list(map(int, input().split())) k = 0 for i in range(a, b + 1): if c % i == 0: k += 1 print(k)
false
40
[ "-nums = []", "-nums = input().split()", "-a = int(nums[0])", "-b = int(nums[1])", "-c = int(nums[2])", "-ans = 0", "+a, b, c = list(map(int, input().split()))", "+k = 0", "- ans += 1", "-print(ans)", "+ k += 1", "+print(k)" ]
false
0.04865
0.050086
0.971316
[ "s267327410", "s718350865" ]
u866124363
p03000
python
s908976944
s177751466
21
17
3,316
2,940
Accepted
Accepted
19.05
N, X = list(map(int, input().split())) L = list(map(int, input().split())) D = 0 count = 1 for l in L: D += l if D <= X: count += 1 else: break print(count)
N, X = list(map(int, input().split())) now = 0 res = 1 for l in map(int, input().split()): now += l if now <= X: res += 1 print(res)
16
10
193
154
N, X = list(map(int, input().split())) L = list(map(int, input().split())) D = 0 count = 1 for l in L: D += l if D <= X: count += 1 else: break print(count)
N, X = list(map(int, input().split())) now = 0 res = 1 for l in map(int, input().split()): now += l if now <= X: res += 1 print(res)
false
37.5
[ "-L = list(map(int, input().split()))", "-D = 0", "-count = 1", "-for l in L:", "- D += l", "- if D <= X:", "- count += 1", "- else:", "- break", "-print(count)", "+now = 0", "+res = 1", "+for l in map(int, input().split()):", "+ now += l", "+ if now <= X:", ...
false
0.048856
0.048954
0.998012
[ "s908976944", "s177751466" ]
u920103253
p02696
python
s222841708
s449343636
23
21
9,188
9,200
Accepted
Accepted
8.7
def n0():return int(eval(input())) def n1():return [int(x) for x in input().split()] def n2(n):return [int(eval(input())) for _ in range(n)] def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] a,b,n=n1() if b<=n: i=b-1 else: i=n m=(a*i)//b-a*(i//b) print(m)
def n0():return int(eval(input())) def n1():return [int(x) for x in input().split()] def n2(n):return [int(eval(input())) for _ in range(n)] def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] a,b,n=n1() import math if b<=n: i=b-1 else: i=n m=math.floor((a*i)/b)-a*math.floor(i//b...
13
13
286
320
def n0(): return int(eval(input())) def n1(): return [int(x) for x in input().split()] def n2(n): return [int(eval(input())) for _ in range(n)] def n3(n): return [[int(x) for x in input().split()] for _ in range(n)] a, b, n = n1() if b <= n: i = b - 1 else: i = n m = (a * i) // b - a * (...
def n0(): return int(eval(input())) def n1(): return [int(x) for x in input().split()] def n2(n): return [int(eval(input())) for _ in range(n)] def n3(n): return [[int(x) for x in input().split()] for _ in range(n)] a, b, n = n1() import math if b <= n: i = b - 1 else: i = n m = math.fl...
false
0
[ "+import math", "+", "-m = (a * i) // b - a * (i // b)", "+m = math.floor((a * i) / b) - a * math.floor(i // b)" ]
false
0.039809
0.040232
0.989472
[ "s222841708", "s449343636" ]
u859897687
p02714
python
s559385975
s193115916
308
239
74,416
68,556
Accepted
Accepted
22.4
def main(): n=int(eval(input())) s=eval(input()) ans=0 d=dict() dr=[0]*n dg=[0]*n db=[0]*n mr=[0]*n mg=[0]*n mb=[0]*n for i in range(n): if s[i]=='R': dr[i]=1 mr[i]=1 if s[i]=='G': dg[i]=1 mg[i...
# ABC162D - RGB Triplets def main(): n=int(eval(input())) s=eval(input()) ans=0 d=[[0]*n for _ in range(3)] m=[[0]*n for _ in range(3)] l=[[0,2,1],[2,1,0],[1,0,2]] for i in range(n): d[ord(s[i])%3][i]=1 m[ord(s[i])%3][i]=1 for j in range(3): for i ...
65
28
1,438
650
def main(): n = int(eval(input())) s = eval(input()) ans = 0 d = dict() dr = [0] * n dg = [0] * n db = [0] * n mr = [0] * n mg = [0] * n mb = [0] * n for i in range(n): if s[i] == "R": dr[i] = 1 mr[i] = 1 if s[i] == "G": dg[...
# ABC162D - RGB Triplets def main(): n = int(eval(input())) s = eval(input()) ans = 0 d = [[0] * n for _ in range(3)] m = [[0] * n for _ in range(3)] l = [[0, 2, 1], [2, 1, 0], [1, 0, 2]] for i in range(n): d[ord(s[i]) % 3][i] = 1 m[ord(s[i]) % 3][i] = 1 for j in range(3)...
false
56.923077
[ "+# ABC162D - RGB Triplets", "- d = dict()", "- dr = [0] * n", "- dg = [0] * n", "- db = [0] * n", "- mr = [0] * n", "- mg = [0] * n", "- mb = [0] * n", "+ d = [[0] * n for _ in range(3)]", "+ m = [[0] * n for _ in range(3)]", "+ l = [[0, 2, 1], [2, 1, 0], [1, 0, 2]...
false
0.045877
0.105733
0.433895
[ "s559385975", "s193115916" ]
u981931040
p03361
python
s415812925
s605543918
27
22
3,316
3,064
Accepted
Accepted
18.52
H , W = list(map(int,input().split())) stage = list(list(eval(input())) for _ in range(H)) dx = [0,1,0,-1] dy = [1,0,-1,0] for i in range(H): for j in range(W): if stage[i][j] == ".": continue Flag = True for k in range(4): if 0 <= j + dx[k] < W and 0 <= i...
H, W = list(map(int, input().split())) canvas = list(list(eval(input())) for _ in range(H)) dx_list = [0, 1, 0, -1] dy_list = [1, 0, -1, 0] for x in range(W): for y in range(H): if canvas[y][x] == ".": continue is_connect = False for dx, dy in zip(dx_list, dy_list): ...
18
17
490
533
H, W = list(map(int, input().split())) stage = list(list(eval(input())) for _ in range(H)) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] for i in range(H): for j in range(W): if stage[i][j] == ".": continue Flag = True for k in range(4): if ( 0 <= j + dx[k] < ...
H, W = list(map(int, input().split())) canvas = list(list(eval(input())) for _ in range(H)) dx_list = [0, 1, 0, -1] dy_list = [1, 0, -1, 0] for x in range(W): for y in range(H): if canvas[y][x] == ".": continue is_connect = False for dx, dy in zip(dx_list, dy_list): i...
false
5.555556
[ "-stage = list(list(eval(input())) for _ in range(H))", "-dx = [0, 1, 0, -1]", "-dy = [1, 0, -1, 0]", "-for i in range(H):", "- for j in range(W):", "- if stage[i][j] == \".\":", "+canvas = list(list(eval(input())) for _ in range(H))", "+dx_list = [0, 1, 0, -1]", "+dy_list = [1, 0, -1, 0]"...
false
0.078916
0.041417
1.905427
[ "s415812925", "s605543918" ]
u513081876
p03289
python
s840760497
s690717764
21
17
2,940
3,060
Accepted
Accepted
19.05
S = eval(input()) if S[0] == 'A' and 'C' in S[2:-1] and S.count('C') ==1: S = S[1:].replace('C', '') if S.islower(): print('AC') else: print('WA') else: print('WA')
S = eval(input()) if S[0] == 'A' and S[2:-1].count('C') == 1: i = S.index('C') jj = S[1:i]+S[i+1:] if jj.islower() == True: print('AC') else: print('WA') else: print('WA')
9
10
198
210
S = eval(input()) if S[0] == "A" and "C" in S[2:-1] and S.count("C") == 1: S = S[1:].replace("C", "") if S.islower(): print("AC") else: print("WA") else: print("WA")
S = eval(input()) if S[0] == "A" and S[2:-1].count("C") == 1: i = S.index("C") jj = S[1:i] + S[i + 1 :] if jj.islower() == True: print("AC") else: print("WA") else: print("WA")
false
10
[ "-if S[0] == \"A\" and \"C\" in S[2:-1] and S.count(\"C\") == 1:", "- S = S[1:].replace(\"C\", \"\")", "- if S.islower():", "+if S[0] == \"A\" and S[2:-1].count(\"C\") == 1:", "+ i = S.index(\"C\")", "+ jj = S[1:i] + S[i + 1 :]", "+ if jj.islower() == True:" ]
false
0.041821
0.040818
1.024577
[ "s840760497", "s690717764" ]
u926556921
p02928
python
s325183314
s001747592
961
859
3,316
3,316
Accepted
Accepted
10.61
n, k = list(map(int,input().split())) a=list(map(int,input().split())) mod = 1000000007 need = (k * (k + 1)) // 2 need2 = ((k - 1) * k) // 2 ans = 0 freq = [] before = [] for i in range(0, 3000): freq.append(0) before.append(0) for i in range(0, n): for j in range(i + 1, n): if(a[i] > a...
n, k = list(map(int,input().split())) a=list(map(int,input().split())) mod = 1000000007 need = (k * (k + 1)) // 2 need2 = ((k - 1) * k) // 2 ans = 0 freq = [] before = [] for i in range(0, 3000): freq.append(0) before.append(0) for i in range(0, n): for j in range(i + 1, n): if(a[i] ...
34
34
510
527
n, k = list(map(int, input().split())) a = list(map(int, input().split())) mod = 1000000007 need = (k * (k + 1)) // 2 need2 = ((k - 1) * k) // 2 ans = 0 freq = [] before = [] for i in range(0, 3000): freq.append(0) before.append(0) for i in range(0, n): for j in range(i + 1, n): if a[i] > a[j]: ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) mod = 1000000007 need = (k * (k + 1)) // 2 need2 = ((k - 1) * k) // 2 ans = 0 freq = [] before = [] for i in range(0, 3000): freq.append(0) before.append(0) for i in range(0, n): for j in range(i + 1, n): if a[i] > a[j]: ...
false
0
[ "+ ans %= mod" ]
false
0.043704
0.04404
0.992369
[ "s325183314", "s001747592" ]
u767664985
p02720
python
s237687335
s227126933
233
169
12,228
19,384
Accepted
Accepted
27.47
from heapq import heapify, heappush, heappop def next_num(n): if n == 0: return [0, 1] elif n == 9: return [8, 9] else: return [n-1, n, n+1] K = int(eval(input())) lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapify(lunlun) for _ in range(K-1): now = heappop(lunlun...
from heapq import heapify, heappush, heappop K = int(eval(input())) ll = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapify(ll) def next_num(X): n = int(str(X)[-1]) if n == 0: return (0, 1) elif n == 9: return (8, 9) else: return (n-1, n, n+1) for _ in range(K-1): lli =...
22
24
415
444
from heapq import heapify, heappush, heappop def next_num(n): if n == 0: return [0, 1] elif n == 9: return [8, 9] else: return [n - 1, n, n + 1] K = int(eval(input())) lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapify(lunlun) for _ in range(K - 1): now = heappop(lunlun) for i ...
from heapq import heapify, heappush, heappop K = int(eval(input())) ll = [1, 2, 3, 4, 5, 6, 7, 8, 9] heapify(ll) def next_num(X): n = int(str(X)[-1]) if n == 0: return (0, 1) elif n == 9: return (8, 9) else: return (n - 1, n, n + 1) for _ in range(K - 1): lli = heappop(l...
false
8.333333
[ "-", "-def next_num(n):", "- if n == 0:", "- return [0, 1]", "- elif n == 9:", "- return [8, 9]", "- else:", "- return [n - 1, n, n + 1]", "+K = int(eval(input()))", "+ll = [1, 2, 3, 4, 5, 6, 7, 8, 9]", "+heapify(ll)", "-K = int(eval(input()))", "-lunlun = [1, 2...
false
0.063328
0.007235
8.752456
[ "s237687335", "s227126933" ]
u434630332
p03997
python
s069923863
s334313657
26
23
9,176
9,120
Accepted
Accepted
11.54
a = int(eval(input())) b = int(eval(input())) h = int(eval(input())) answer = (a + b) * h // 2 print(answer)
a = int(eval(input())) b = int(eval(input())) h = int(eval(input())) print(((a + b) * h // 2))
7
5
98
79
a = int(eval(input())) b = int(eval(input())) h = int(eval(input())) answer = (a + b) * h // 2 print(answer)
a = int(eval(input())) b = int(eval(input())) h = int(eval(input())) print(((a + b) * h // 2))
false
28.571429
[ "-answer = (a + b) * h // 2", "-print(answer)", "+print(((a + b) * h // 2))" ]
false
0.043076
0.07128
0.604316
[ "s069923863", "s334313657" ]
u186838327
p03645
python
s350423240
s980062235
1,335
930
85,452
49,112
Accepted
Accepted
30.34
n, m = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) a, b = a-1, b-1 g[a].append(b) g[b].append(a) from collections import deque queue = deque([]) queue.append(0) visited = [-1]*n visited[0] = 0 while queue: x = queu...
n, m = list(map(int, input().split())) l1 = [0]*n l2 = [0]*n for i in range(m): a, b = list(map(int, input().split())) a, b = a-1, b-1 if a == 0: l1[b] = 1 elif b == n-1: l2[a] = 1 else: continue for j in range(n): if l1[j] == 1 and l2[j] == 1: print('POSSIBLE') exit()...
29
21
589
343
n, m = list(map(int, input().split())) g = [[] for _ in range(n)] for i in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 g[a].append(b) g[b].append(a) from collections import deque queue = deque([]) queue.append(0) visited = [-1] * n visited[0] = 0 while queue: x = queue.popl...
n, m = list(map(int, input().split())) l1 = [0] * n l2 = [0] * n for i in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 if a == 0: l1[b] = 1 elif b == n - 1: l2[a] = 1 else: continue for j in range(n): if l1[j] == 1 and l2[j] == 1: print("PO...
false
27.586207
[ "-g = [[] for _ in range(n)]", "+l1 = [0] * n", "+l2 = [0] * n", "- g[a].append(b)", "- g[b].append(a)", "-from collections import deque", "-", "-queue = deque([])", "-queue.append(0)", "-visited = [-1] * n", "-visited[0] = 0", "-while queue:", "- x = queue.popleft()", "- for n...
false
0.143713
0.04124
3.484799
[ "s350423240", "s980062235" ]
u186838327
p03862
python
s053221119
s099105331
235
82
63,984
85,000
Accepted
Accepted
65.11
n, x = list(map(int, input().split())) l = list(map(int, input().split())) ans = 0 for i in range(n-1): s = l[i]+l[i+1] if s > x: if l[i+1] >= (s-x): l[i+1] -= (s-x) ans += (s-x) else: l[i+1] = 0 ans += (s-x) print(ans)
n,x = list(map(int, input().split())) A =list(map(int, input().split())) ans = 0 for i in range(n-1): y = A[i]+A[i+1] if y > x: r = y-x if A[i+1] >= r: A[i+1] -= r ans += r else: A[i+1] = 0 A[i] -= (r-A[i+1]) ans...
15
16
267
332
n, x = list(map(int, input().split())) l = list(map(int, input().split())) ans = 0 for i in range(n - 1): s = l[i] + l[i + 1] if s > x: if l[i + 1] >= (s - x): l[i + 1] -= s - x ans += s - x else: l[i + 1] = 0 ans += s - x print(ans)
n, x = list(map(int, input().split())) A = list(map(int, input().split())) ans = 0 for i in range(n - 1): y = A[i] + A[i + 1] if y > x: r = y - x if A[i + 1] >= r: A[i + 1] -= r ans += r else: A[i + 1] = 0 A[i] -= r - A[i + 1] a...
false
6.25
[ "-l = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "- s = l[i] + l[i + 1]", "- if s > x:", "- if l[i + 1] >= (s - x):", "- l[i + 1] -= s - x", "- ans += s - x", "+ y = A[i] + A[i + 1]", "+ if y > x:", "+ r = y - x", "+ ...
false
0.075822
0.036512
2.076641
[ "s053221119", "s099105331" ]
u863370423
p02700
python
s990284572
s092792166
72
22
68,848
8,908
Accepted
Accepted
69.44
from sys import stdin, stdout import math import bisect import queue a, b, c, d = list(map(int, stdin.readline().strip().split())) while True: c -= b if c <= 0: stdout.writelines('Yes\n') break a -= d if a <= 0: stdout.writelines('No\n') break
import math a,b,c,d=list(map(int,input().split(' '))) jojo=math.ceil(a/d) dio=math.ceil(c/b) if jojo>=dio: print('Yes') else: print('No')
16
8
303
146
from sys import stdin, stdout import math import bisect import queue a, b, c, d = list(map(int, stdin.readline().strip().split())) while True: c -= b if c <= 0: stdout.writelines("Yes\n") break a -= d if a <= 0: stdout.writelines("No\n") break
import math a, b, c, d = list(map(int, input().split(" "))) jojo = math.ceil(a / d) dio = math.ceil(c / b) if jojo >= dio: print("Yes") else: print("No")
false
50
[ "-from sys import stdin, stdout", "-import bisect", "-import queue", "-a, b, c, d = list(map(int, stdin.readline().strip().split()))", "-while True:", "- c -= b", "- if c <= 0:", "- stdout.writelines(\"Yes\\n\")", "- break", "- a -= d", "- if a <= 0:", "- stdou...
false
0.038037
0.045896
0.828773
[ "s990284572", "s092792166" ]
u347640436
p02660
python
s901990183
s167450477
475
110
27,172
9,224
Accepted
Accepted
76.84
from math import sqrt N = int(eval(input())) rn = int(sqrt(N)) sieve = [0] * (rn + 1) sieve[0] = -1 sieve[1] = -1 t = [0] * (rn + 1) for i in range(2, rn + 1): if sieve[i] != 0: continue sieve[i] = i j = i while j < rn + 1: t[j] = 1 j *= i for j in range(i ...
from math import sqrt def prime_factorize(n): result = [] for i in range(2, int(sqrt(n)) + 1): if n % i != 0: continue t = 0 while n % i == 0: n //= i t += 1 result.append((i, t)) if n == 1: break if n !...
33
30
605
542
from math import sqrt N = int(eval(input())) rn = int(sqrt(N)) sieve = [0] * (rn + 1) sieve[0] = -1 sieve[1] = -1 t = [0] * (rn + 1) for i in range(2, rn + 1): if sieve[i] != 0: continue sieve[i] = i j = i while j < rn + 1: t[j] = 1 j *= i for j in range(i * i, rn + 1, i): ...
from math import sqrt def prime_factorize(n): result = [] for i in range(2, int(sqrt(n)) + 1): if n % i != 0: continue t = 0 while n % i == 0: n //= i t += 1 result.append((i, t)) if n == 1: break if n != 1: re...
false
9.090909
[ "+", "+def prime_factorize(n):", "+ result = []", "+ for i in range(2, int(sqrt(n)) + 1):", "+ if n % i != 0:", "+ continue", "+ t = 0", "+ while n % i == 0:", "+ n //= i", "+ t += 1", "+ result.append((i, t))", "+ if n ...
false
0.628293
0.050589
12.419617
[ "s901990183", "s167450477" ]
u606045429
p04025
python
s257268075
s504122128
23
17
2,940
2,940
Accepted
Accepted
26.09
N = int(eval(input())) A = [int(i) for i in input().split()] mi = 1e10 for m in range(-100, 101): mi = min(mi, sum((a - m) ** 2 for a in A)) print(mi)
N = int(eval(input())) A = [int(i) for i in input().split()] m = round(sum(A) / N) print((sum((a - m) ** 2 for a in A)))
7
5
155
117
N = int(eval(input())) A = [int(i) for i in input().split()] mi = 1e10 for m in range(-100, 101): mi = min(mi, sum((a - m) ** 2 for a in A)) print(mi)
N = int(eval(input())) A = [int(i) for i in input().split()] m = round(sum(A) / N) print((sum((a - m) ** 2 for a in A)))
false
28.571429
[ "-mi = 1e10", "-for m in range(-100, 101):", "- mi = min(mi, sum((a - m) ** 2 for a in A))", "-print(mi)", "+m = round(sum(A) / N)", "+print((sum((a - m) ** 2 for a in A)))" ]
false
0.040055
0.033616
1.191557
[ "s257268075", "s504122128" ]
u624475441
p03194
python
s204710894
s625348537
102
89
3,444
3,316
Accepted
Accepted
12.75
from collections import Counter def prime_factor(n): res = Counter() for i in range(2, int(n**.5) + 1): while n % i == 0: res[i] += 1 n //= i if n != 1: res[n] += 1 return res N, P = list(map(int, input().split())) cnt = prime_factor(P) ans = 1 fo...
from collections import Counter def prime_factorize_fast(n, res=Counter()): while n % 2 == 0: res[2] += 1 n //= 2 while n % 3 == 0: res[3] += 1 n //= 3 d = 5 step = 2 while d <= int(n ** .5): while n % d == 0: res[d] += 1 ...
19
28
393
584
from collections import Counter def prime_factor(n): res = Counter() for i in range(2, int(n**0.5) + 1): while n % i == 0: res[i] += 1 n //= i if n != 1: res[n] += 1 return res N, P = list(map(int, input().split())) cnt = prime_factor(P) ans = 1 for f in cnt: ...
from collections import Counter def prime_factorize_fast(n, res=Counter()): while n % 2 == 0: res[2] += 1 n //= 2 while n % 3 == 0: res[3] += 1 n //= 3 d = 5 step = 2 while d <= int(n**0.5): while n % d == 0: res[d] += 1 n //= d ...
false
32.142857
[ "-def prime_factor(n):", "- res = Counter()", "- for i in range(2, int(n**0.5) + 1):", "- while n % i == 0:", "- res[i] += 1", "- n //= i", "+def prime_factorize_fast(n, res=Counter()):", "+ while n % 2 == 0:", "+ res[2] += 1", "+ n //= 2", "+ ...
false
0.114562
0.037967
3.017381
[ "s204710894", "s625348537" ]
u297574184
p02949
python
s040111801
s176852351
1,309
1,087
78,168
73,180
Accepted
Accepted
16.96
from collections import deque def BellmanFord(adjList, vSt, INF): numV = len(adjList) negINF = -INF costs = [INF] * numV costs[vSt] = 0 vNows = set([vSt]) for _ in range(numV): vChangeds = set() for vFr in vNows: costFr = costs[vFr] for vTo,...
from collections import deque import sys input = sys.stdin.readline INF = float('inf') def BellmanFord(adjList, vSt, INF): numV = len(adjList) negINF = -INF costs = [INF] * numV costs[vSt] = 0 vNows = set([vSt]) for _ in range(numV): vChangeds = set() for vFr in...
49
54
1,175
1,217
from collections import deque def BellmanFord(adjList, vSt, INF): numV = len(adjList) negINF = -INF costs = [INF] * numV costs[vSt] = 0 vNows = set([vSt]) for _ in range(numV): vChangeds = set() for vFr in vNows: costFr = costs[vFr] for vTo, wt in adjLis...
from collections import deque import sys input = sys.stdin.readline INF = float("inf") def BellmanFord(adjList, vSt, INF): numV = len(adjList) negINF = -INF costs = [INF] * numV costs[vSt] = 0 vNows = set([vSt]) for _ in range(numV): vChangeds = set() for vFr in vNows: ...
false
9.259259
[ "+import sys", "+", "+input = sys.stdin.readline", "+INF = float(\"inf\")", "- Q = deque(vNows)", "+ Q = deque(vNows)", "- adjL[A].append((B, -(C - P)))", "-costs = BellmanFord(adjL, 0, float(\"inf\"))", "-if costs[N - 1] == -float(\"inf\"):", "+ adjL[A].append((B, -C + P))", "+c...
false
0.038885
0.073383
0.529891
[ "s040111801", "s176852351" ]
u794173881
p02559
python
s613892294
s814730594
772
691
178,060
199,320
Accepted
Accepted
10.49
import sys input = sys.stdin.buffer.readline class BinaryIndexedTree: """一点加算、区間総和クエリをそれぞれO(logN)で答えるデータ構造。""" def __init__(self, n): self.size = n self.bit = [0] * (n + 1) def build(self, array): """arrayを初期値とするBinaryIndexedTreeを構築する。O(N)""" for i, val in enum...
import sys input = sys.stdin.buffer.readline class BinaryIndexedTree: """一点加算、区間総和クエリをそれぞれO(logN)で答えるデータ構造。""" def __init__(self, n): self.size = n self.bit = [0] * (n + 1) def build(self, array): """arrayを初期値とするBinaryIndexedTreeを構築する。O(N)""" for i, val in enum...
63
66
1,646
1,696
import sys input = sys.stdin.buffer.readline class BinaryIndexedTree: """一点加算、区間総和クエリをそれぞれO(logN)で答えるデータ構造。""" def __init__(self, n): self.size = n self.bit = [0] * (n + 1) def build(self, array): """arrayを初期値とするBinaryIndexedTreeを構築する。O(N)""" for i, val in enumerate(arra...
import sys input = sys.stdin.buffer.readline class BinaryIndexedTree: """一点加算、区間総和クエリをそれぞれO(logN)で答えるデータ構造。""" def __init__(self, n): self.size = n self.bit = [0] * (n + 1) def build(self, array): """arrayを初期値とするBinaryIndexedTreeを構築する。O(N)""" for i, val in enumerate(arra...
false
4.545455
[ "+ans = []", "- print((bit.sum(l, r)))", "+ ans.append(bit.sum(l, r))", "+print((\"\\n\".join(map(str, ans))))" ]
false
0.071108
0.07495
0.948742
[ "s613892294", "s814730594" ]
u753803401
p03555
python
s189554220
s369668508
150
17
12,444
2,940
Accepted
Accepted
88.67
import numpy a = [list(eval(input()))for _ in range(2)] b = a.copy() b = numpy.rot90(b, k=-2) if (a == b).all(): print("YES") else: print("NO")
s = eval(input()) t = eval(input()) for i in range(3): if s[i] != t[-i-1]: print("NO") exit() print("YES")
8
7
153
121
import numpy a = [list(eval(input())) for _ in range(2)] b = a.copy() b = numpy.rot90(b, k=-2) if (a == b).all(): print("YES") else: print("NO")
s = eval(input()) t = eval(input()) for i in range(3): if s[i] != t[-i - 1]: print("NO") exit() print("YES")
false
12.5
[ "-import numpy", "-", "-a = [list(eval(input())) for _ in range(2)]", "-b = a.copy()", "-b = numpy.rot90(b, k=-2)", "-if (a == b).all():", "- print(\"YES\")", "-else:", "- print(\"NO\")", "+s = eval(input())", "+t = eval(input())", "+for i in range(3):", "+ if s[i] != t[-i - 1]:", ...
false
0.174985
0.034902
5.013576
[ "s189554220", "s369668508" ]
u103902792
p03200
python
s106719200
s475201068
72
58
11,368
3,500
Accepted
Accepted
19.44
s= eval(input()) W = 'W' B = 'B' Bi = [] Wi = [] BC = s.count(B) WC = len(s) - BC for i in range(len(s)): if s[i] == B: Bi.append(i) else: Wi.append(i) W_dist = sum(Wi) - int((0 + WC-1)* (WC)/2) #print('W',str(W_dist)) B_dist = int((len(s)-1 + WC) * BC /2) - sum(Bi) #print('B',st...
S = eval(input()) BC = S.count('B') WC = len(S) - BC ans = 0 for i in range(len(S)): if S[i] == 'B': ans += WC else: WC -= 1 print(ans)
22
11
359
152
s = eval(input()) W = "W" B = "B" Bi = [] Wi = [] BC = s.count(B) WC = len(s) - BC for i in range(len(s)): if s[i] == B: Bi.append(i) else: Wi.append(i) W_dist = sum(Wi) - int((0 + WC - 1) * (WC) / 2) # print('W',str(W_dist)) B_dist = int((len(s) - 1 + WC) * BC / 2) - sum(Bi) # print('B',str(B_d...
S = eval(input()) BC = S.count("B") WC = len(S) - BC ans = 0 for i in range(len(S)): if S[i] == "B": ans += WC else: WC -= 1 print(ans)
false
50
[ "-s = eval(input())", "-W = \"W\"", "-B = \"B\"", "-Bi = []", "-Wi = []", "-BC = s.count(B)", "-WC = len(s) - BC", "-for i in range(len(s)):", "- if s[i] == B:", "- Bi.append(i)", "+S = eval(input())", "+BC = S.count(\"B\")", "+WC = len(S) - BC", "+ans = 0", "+for i in range(le...
false
0.03779
0.044273
0.853567
[ "s106719200", "s475201068" ]
u957513998
p02757
python
s629137874
s740152883
418
175
10,060
9,948
Accepted
Accepted
58.13
#!/usr/bin/python3 import sys from collections import Counter input = lambda: sys.stdin.readline().strip() n, p = [int(x) for x in input().split()] s = eval(input()) ans = 0 if p == 2 or p == 5: allowed_digits = '24680' if p == 2 else '50' for i, c in enumerate(s, start=1): if c in allowed_dig...
#!/usr/bin/python3 import sys from collections import Counter input = lambda: sys.stdin.readline().strip() n, p = [int(x) for x in input().split()] s = eval(input()) ans = 0 if p == 2 or p == 5: allowed_digits = '24680' if p == 2 else '50' for i, c in enumerate(s, start=1): if c in allowed_dig...
26
22
653
554
#!/usr/bin/python3 import sys from collections import Counter input = lambda: sys.stdin.readline().strip() n, p = [int(x) for x in input().split()] s = eval(input()) ans = 0 if p == 2 or p == 5: allowed_digits = "24680" if p == 2 else "50" for i, c in enumerate(s, start=1): if c in allowed_digits: ...
#!/usr/bin/python3 import sys from collections import Counter input = lambda: sys.stdin.readline().strip() n, p = [int(x) for x in input().split()] s = eval(input()) ans = 0 if p == 2 or p == 5: allowed_digits = "24680" if p == 2 else "50" for i, c in enumerate(s, start=1): if c in allowed_digits: ...
false
15.384615
[ "-", "- def minv(x, p):", "- return pow(x, p - 2, p)", "-", "- x, delta = 0, 1", "- for c in s:", "- x = ((x * 10) + ord(c) - ord(\"0\")) % p", "- y = (x * minv(delta, p)) % p", "- ans += count[y]", "- count[y] += 1", "- delta = (delta * 10) % p...
false
0.068269
0.066746
1.022821
[ "s629137874", "s740152883" ]
u102461423
p03178
python
s007190861
s002067692
1,209
494
22,916
12,776
Accepted
Accepted
59.14
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) import numpy as np from numpy.fft import rfft, irfft MOD = 10 ** 9 + 7 K = [int(x) for x in input().rstrip()] L = len(K) D = int(eval(input())) def convolve_ones(x,arr): # 0,1,...,x-1 after = np.zeros(D+x,dtype=np.int64) fo...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np import itertools K = list(map(int,readline().rstrip().decode('utf-8'))) D = int(read()) MOD = 10**9 + 7 Kcum = list(itertools.accumulate(K)) x = np.zeros(D,np.int64)...
39
36
892
719
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import numpy as np from numpy.fft import rfft, irfft MOD = 10**9 + 7 K = [int(x) for x in input().rstrip()] L = len(K) D = int(eval(input())) def convolve_ones(x, arr): # 0,1,...,x-1 after = np.zeros(D + x, dtype=np.int64) for i in range...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np import itertools K = list(map(int, readline().rstrip().decode("utf-8"))) D = int(read()) MOD = 10**9 + 7 Kcum = list(itertools.accumulate(K)) x = np.zeros(D, np.int64) x[0] = 1 answer...
false
7.692308
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "-from numpy.fft import rfft, irfft", "+import itertools", "+K = list(map(int, readline().rstrip().decode(\"utf-8\")))", ...
false
0.841143
0.644915
1.30427
[ "s007190861", "s002067692" ]
u757274384
p02713
python
s784663136
s115018005
1,985
1,198
9,188
9,172
Accepted
Accepted
39.65
from math import gcd k = int(eval(input())) ans = 0 for a in range(1,k+1): for b in range(1,k+1): for c in range(1,k+1): ans += gcd(a,gcd(b,c)) print(ans)
from math import gcd k = int(eval(input())) ans = 0 for a in range(1,k+1): for b in range(1,k+1): p = gcd(a,b) for c in range(1,k+1): ans += gcd(p,c) print(ans)
10
9
177
178
from math import gcd k = int(eval(input())) ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): for c in range(1, k + 1): ans += gcd(a, gcd(b, c)) print(ans)
from math import gcd k = int(eval(input())) ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): p = gcd(a, b) for c in range(1, k + 1): ans += gcd(p, c) print(ans)
false
10
[ "+ p = gcd(a, b)", "- ans += gcd(a, gcd(b, c))", "+ ans += gcd(p, c)" ]
false
0.122017
0.263861
0.46243
[ "s784663136", "s115018005" ]
u489959379
p03215
python
s697304748
s657438081
359
316
29,712
29,832
Accepted
Accepted
11.98
import sys from itertools import accumulate sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, k = list(map(int, input().split())) A = list(map(int, input().split())) R = [0] + list(accumulate(A)) subs = [] for left i...
import sys from itertools import accumulate sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, k = list(map(int, input().split())) A = list(map(int, input().split())) R = [0] + list(accumulate(A)) subs = [] for left i...
35
36
791
767
import sys from itertools import accumulate sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n, k = list(map(int, input().split())) A = list(map(int, input().split())) R = [0] + list(accumulate(A)) subs = [] for left in range(n): ...
import sys from itertools import accumulate sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): n, k = list(map(int, input().split())) A = list(map(int, input().split())) R = [0] + list(accumulate(A)) subs = [] for left in range(n + 1): ...
false
2.777778
[ "- for left in range(n):", "+ for left in range(n + 1):", "- subs.append(R[right] - R[left])", "- res = 0", "- for mask in reversed(list(range(40))):", "- if len(subs) == 0:", "- break", "+ num = R[right] - R[left]", "+ subs.append(num)"...
false
0.04776
0.007786
6.134483
[ "s697304748", "s657438081" ]
u073549161
p03319
python
s350727692
s375218895
246
39
52,476
13,812
Accepted
Accepted
84.15
n, k = list(map(int,input().split())) dat = list(map(int, input().split())) i = dat.index(1) + 1 # 1originでi個目に1がある import math b1 = k # 今1で占有した場所 a1 = 1 # 1にたどり着くまでに必要な個数 a2 = 0 if b1 < i: # もし、iがいまよりも手前にあるなら a2 += math.ceil( (i - k) / (k - 1) ) b1 += a2 * (k - 1) b1 = n if b1 > n else b1 # 1のターンでたどり着い...
import math n, k = list(map(int,input().split())) dat = list(map(int, input().split())) i = dat.index(1) + 1 # 1 origin で i 個目に 1 がある reach = k # 今1で占有した場所 a = math.ceil((n - reach) / (k - 1)) print((1+a))
14
7
370
203
n, k = list(map(int, input().split())) dat = list(map(int, input().split())) i = dat.index(1) + 1 # 1originでi個目に1がある import math b1 = k # 今1で占有した場所 a1 = 1 # 1にたどり着くまでに必要な個数 a2 = 0 if b1 < i: # もし、iがいまよりも手前にあるなら a2 += math.ceil((i - k) / (k - 1)) b1 += a2 * (k - 1) b1 = n if b1 > n else b1 # 1のターンでたどり着いた場所 a3 ...
import math n, k = list(map(int, input().split())) dat = list(map(int, input().split())) i = dat.index(1) + 1 # 1 origin で i 個目に 1 がある reach = k # 今1で占有した場所 a = math.ceil((n - reach) / (k - 1)) print((1 + a))
false
50
[ "+import math", "+", "-i = dat.index(1) + 1 # 1originでi個目に1がある", "-import math", "-", "-b1 = k # 今1で占有した場所", "-a1 = 1 # 1にたどり着くまでに必要な個数", "-a2 = 0", "-if b1 < i: # もし、iがいまよりも手前にあるなら", "- a2 += math.ceil((i - k) / (k - 1))", "-b1 += a2 * (k - 1)", "-b1 = n if b1 > n else b1 # 1のターンでたどり着...
false
0.047084
0.083485
0.563982
[ "s350727692", "s375218895" ]
u135847648
p03240
python
s112478575
s188763441
412
37
3,188
3,188
Accepted
Accepted
91.02
n = int(eval(input())) xyh = [list(map(int,input().split())) for _ in [0]*n] xyh = sorted(xyh,key=lambda x:x[2]) # H-|x-Cx|-|y-Cy| = h #全探索で良さそう for i in range(101): for j in range(101): Cx,Cy=i,j #print(Cx,Cy) x,y,h = xyh[-1][0],xyh[-1][1],xyh[-1][2] H = max( h+ abs(x-Cx)+ abs(y-Cy), 0) ...
n = int(eval(input())) xyh = [list(map(int,input().split())) for _ in [0]*n] xyh.sort(key=lambda x:x[2]) x0,y0,h0 = xyh[-1][0],xyh[-1][1],xyh[-1][2] #全探索で良さそう for Cx in range(101): for Cy in range(101): # H-|x-Cx|-|y-Cy| = h H = h0 + abs(x0-Cx) + abs(y0-Cy) tf = True for k in range(n-1): ...
20
19
440
511
n = int(eval(input())) xyh = [list(map(int, input().split())) for _ in [0] * n] xyh = sorted(xyh, key=lambda x: x[2]) # H-|x-Cx|-|y-Cy| = h # 全探索で良さそう for i in range(101): for j in range(101): Cx, Cy = i, j # print(Cx,Cy) x, y, h = xyh[-1][0], xyh[-1][1], xyh[-1][2] H = max(h + abs(x...
n = int(eval(input())) xyh = [list(map(int, input().split())) for _ in [0] * n] xyh.sort(key=lambda x: x[2]) x0, y0, h0 = xyh[-1][0], xyh[-1][1], xyh[-1][2] # 全探索で良さそう for Cx in range(101): for Cy in range(101): # H-|x-Cx|-|y-Cy| = h H = h0 + abs(x0 - Cx) + abs(y0 - Cy) tf = True for...
false
5
[ "-xyh = sorted(xyh, key=lambda x: x[2])", "-# H-|x-Cx|-|y-Cy| = h", "+xyh.sort(key=lambda x: x[2])", "+x0, y0, h0 = xyh[-1][0], xyh[-1][1], xyh[-1][2]", "-for i in range(101):", "- for j in range(101):", "- Cx, Cy = i, j", "- # print(Cx,Cy)", "- x, y, h = xyh[-1][0], xyh[-1][...
false
0.089384
0.038192
2.340377
[ "s112478575", "s188763441" ]
u009787707
p03361
python
s409022327
s557768971
124
26
27,084
9,096
Accepted
Accepted
79.03
import numpy as np H,W=list(map(int,input().split())) s=np.zeros((H+2,W+2),dtype=int) for i in range(H): s0=eval(input()) for j in range(W): if s0[j]==".": num=0 elif s0[j]=="#": num=1 s[i+1][j+1]=num ans_s=s[1:H+1,1:W+1] ...
dxdy = ((0,1),(0,-1),(1,0),(-1,0)) H, W = list(map(int,input().split())) S = [] S.append('.'*(W+2)) for h in range(H): s = eval(input()) S.append('.'+s+'.') S.append('.'*(W+2)) #print (S) for h in range(1,H+1): for w in range(1,W+1): if S[h][w] == '.': continue ...
31
26
572
527
import numpy as np H, W = list(map(int, input().split())) s = np.zeros((H + 2, W + 2), dtype=int) for i in range(H): s0 = eval(input()) for j in range(W): if s0[j] == ".": num = 0 elif s0[j] == "#": num = 1 s[i + 1][j + 1] = num ans_s = s[1 : H + 1, 1 : W + 1] an...
dxdy = ((0, 1), (0, -1), (1, 0), (-1, 0)) H, W = list(map(int, input().split())) S = [] S.append("." * (W + 2)) for h in range(H): s = eval(input()) S.append("." + s + ".") S.append("." * (W + 2)) # print (S) for h in range(1, H + 1): for w in range(1, W + 1): if S[h][w] == ".": continue...
false
16.129032
[ "-import numpy as np", "-", "+dxdy = ((0, 1), (0, -1), (1, 0), (-1, 0))", "-s = np.zeros((H + 2, W + 2), dtype=int)", "-for i in range(H):", "- s0 = eval(input())", "- for j in range(W):", "- if s0[j] == \".\":", "- num = 0", "- elif s0[j] == \"#\":", "- ...
false
0.261535
0.045779
5.712976
[ "s409022327", "s557768971" ]
u257374434
p02689
python
s031552269
s483331864
470
200
70,008
32,920
Accepted
Accepted
57.45
import bisect import collections import sys sys.setrecursionlimit(100000) input = sys.stdin.readline ACMOD = 1000000007 INF = 1 << 62 def lmi(): return list(map(int, input().split())) def llmi(n): return [lmi() for _ in range(n)] N, M = lmi() H = lmi() AB = llmi(M) adj = collection...
import bisect import collections import sys sys.setrecursionlimit(100000) input = sys.stdin.readline ACMOD = 1000000007 INF = 1 << 62 def lmi(): return list(map(int, input().split())) def llmi(n): return [lmi() for _ in range(n)] N, M = lmi() H = lmi() AB = llmi(M) flag = [1] * N ...
38
33
584
492
import bisect import collections import sys sys.setrecursionlimit(100000) input = sys.stdin.readline ACMOD = 1000000007 INF = 1 << 62 def lmi(): return list(map(int, input().split())) def llmi(n): return [lmi() for _ in range(n)] N, M = lmi() H = lmi() AB = llmi(M) adj = collections.defaultdict(set) for ...
import bisect import collections import sys sys.setrecursionlimit(100000) input = sys.stdin.readline ACMOD = 1000000007 INF = 1 << 62 def lmi(): return list(map(int, input().split())) def llmi(n): return [lmi() for _ in range(n)] N, M = lmi() H = lmi() AB = llmi(M) flag = [1] * N for a, b in AB: a = ...
false
13.157895
[ "-adj = collections.defaultdict(set)", "+flag = [1] * N", "- adj[a].add(b)", "- adj[b].add(a)", "-ans = 0", "-for i, h in enumerate(H):", "- flag = True", "- for j in adj[i]:", "- if H[j] >= h:", "- break", "- else:", "- ans += 1", "-print(ans)", "+ ...
false
0.077339
0.03719
2.079543
[ "s031552269", "s483331864" ]
u923172145
p02580
python
s512737397
s693645169
1,219
589
101,980
187,564
Accepted
Accepted
51.68
H, W, M = list(map(int, input().split())) A = [0 for _ in range(H)] B = [0 for _ in range(W)] C = set() for _ in range(M): h, w = list(map(int, input().split())) A[h-1] += 1 B[w-1] += 1 C.add((h-1, w-1)) d = max(A) e = max(B) ans = d+e F = set() G = set() for h in range(H): if A[h] ==...
H, W, M = list(map(int, input().split())) #方針 # 1,基本的には、行和の最大と列和の最大の和が答えとなる # 2,例外として、行和の最大を与える行と、列和の最大を与える列との交差点が、 # 全て爆破対象で埋まっている場合(飽和)、重複分の1を引く必要がある。 A = [0 for _ in range(H)] # 各行の爆破対象の個数 (行和) B = [0 for _ in range(W)] # 各列の爆破対象の個数 (列和) C = set() # 爆破対象の位置の集合 for _ in range(M): #入力処理 h, w = list(...
42
44
612
967
H, W, M = list(map(int, input().split())) A = [0 for _ in range(H)] B = [0 for _ in range(W)] C = set() for _ in range(M): h, w = list(map(int, input().split())) A[h - 1] += 1 B[w - 1] += 1 C.add((h - 1, w - 1)) d = max(A) e = max(B) ans = d + e F = set() G = set() for h in range(H): if A[h] == d: ...
H, W, M = list(map(int, input().split())) # 方針 # 1,基本的には、行和の最大と列和の最大の和が答えとなる # 2,例外として、行和の最大を与える行と、列和の最大を与える列との交差点が、 # 全て爆破対象で埋まっている場合(飽和)、重複分の1を引く必要がある。 A = [0 for _ in range(H)] # 各行の爆破対象の個数 (行和) B = [0 for _ in range(W)] # 各列の爆破対象の個数 (列和) C = set() # 爆破対象の位置の集合 for _ in range(M): # 入力処理 h, w = list(map(int...
false
4.545455
[ "-A = [0 for _ in range(H)]", "-B = [0 for _ in range(W)]", "-C = set()", "-for _ in range(M):", "+# 方針", "+# 1,基本的には、行和の最大と列和の最大の和が答えとなる", "+# 2,例外として、行和の最大を与える行と、列和の最大を与える列との交差点が、", "+# 全て爆破対象で埋まっている場合(飽和)、重複分の1を引く必要がある。", "+A = [0 for _ in range(H)] # 各行の爆破対象の個数 (行和)", "+B = [0 for _ in rang...
false
0.037394
0.062272
0.600498
[ "s512737397", "s693645169" ]
u011621222
p02354
python
s404364111
s440699722
230
120
16,388
16,376
Accepted
Accepted
47.83
N,S = list(map(int, input().split())) As = list(map(int, input().split())) i = 0 j = 0 sum = 0 m_l = float('inf') while True: while j < N and sum < S: sum += As[j] j += 1 if sum < S: break m_l = min(j-i, m_l) sum -= As[i] i += 1 """ while j < N: sum += As[j] j += 1 while i < j a...
n,s = list(map(int, input().split())) a = list(map(int, input().split())) ans = float("inf") ma = 0 mi = 0 v = 0 for i in range(n): v += a[i] if v >= s: ma = i while v >= s: v -= a[mi] mi += 1 ans = min(ans, ma-mi+2) ans = ans if ans != float("inf") ...
31
16
459
333
N, S = list(map(int, input().split())) As = list(map(int, input().split())) i = 0 j = 0 sum = 0 m_l = float("inf") while True: while j < N and sum < S: sum += As[j] j += 1 if sum < S: break m_l = min(j - i, m_l) sum -= As[i] i += 1 """ while j < N: sum += As[j] j += 1 whil...
n, s = list(map(int, input().split())) a = list(map(int, input().split())) ans = float("inf") ma = 0 mi = 0 v = 0 for i in range(n): v += a[i] if v >= s: ma = i while v >= s: v -= a[mi] mi += 1 ans = min(ans, ma - mi + 2) ans = ans if ans != float("inf") else 0 pr...
false
48.387097
[ "-N, S = list(map(int, input().split()))", "-As = list(map(int, input().split()))", "-i = 0", "-j = 0", "-sum = 0", "-m_l = float(\"inf\")", "-while True:", "- while j < N and sum < S:", "- sum += As[j]", "- j += 1", "- if sum < S:", "- break", "- m_l = min(j - ...
false
0.06082
0.061187
0.993994
[ "s404364111", "s440699722" ]
u130900604
p02570
python
s706371824
s940843374
536
68
70,952
62,416
Accepted
Accepted
87.31
def LI():return list(map(int,input().split())) def II():return int(input()) def yes():return print("Yes") def no():return print("No") INF=float("inf") from collections import deque, defaultdict, Counter from heapq import heappop, heappush from itertools import product, combinations from functools import reduce,...
def LI():return list(map(int,input().split())) def II():return int(input()) def yes():return print("Yes") def no():return print("No") #INF=float("inf") #from collections import deque, defaultdict, Counter #from heapq import heappop, heappush #from itertools import product, combinations #from functools import re...
89
89
2,452
2,445
def LI(): return list(map(int, input().split())) def II(): return int(input()) def yes(): return print("Yes") def no(): return print("No") INF = float("inf") from collections import deque, defaultdict, Counter from heapq import heappop, heappush from itertools import product, combinations from f...
def LI(): return list(map(int, input().split())) def II(): return int(input()) def yes(): return print("Yes") def no(): return print("No") # INF=float("inf") # from collections import deque, defaultdict, Counter # from heapq import heappop, heappush # from itertools import product, combinations ...
false
0
[ "-INF = float(\"inf\")", "-from collections import deque, defaultdict, Counter", "-from heapq import heappop, heappush", "-from itertools import product, combinations", "-from functools import reduce, lru_cache", "-from math import pi, gcd", "-from decimal import Decimal", "-", "-", "+# INF=float(...
false
0.081556
0.069452
1.174269
[ "s706371824", "s940843374" ]
u531220228
p02951
python
s066853836
s745666781
20
17
3,316
2,940
Accepted
Accepted
15
A,B,C = list(map(int, input().split())) if A-B<=C: print((C-(A-B))) else: print((0))
A, B, C = list(map(int, input().split())) res1 = A - B if res1 <= C: trans = res1 else: trans = C print((C - trans))
5
10
82
128
A, B, C = list(map(int, input().split())) if A - B <= C: print((C - (A - B))) else: print((0))
A, B, C = list(map(int, input().split())) res1 = A - B if res1 <= C: trans = res1 else: trans = C print((C - trans))
false
50
[ "-if A - B <= C:", "- print((C - (A - B)))", "+res1 = A - B", "+if res1 <= C:", "+ trans = res1", "- print((0))", "+ trans = C", "+print((C - trans))" ]
false
0.045284
0.114251
0.396356
[ "s066853836", "s745666781" ]
u555767343
p03835
python
s426869247
s890409426
259
81
41,964
67,160
Accepted
Accepted
68.73
K, S = list(map(int, input().split())) count = 0 for x in range(K+1): for y in range(K+1): if 0 <= S - x - y <= K: count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(K+1): for y in range(K+1): z = S - x - y if 0 <= z <= K: count += 1 print(count)
9
9
182
179
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): if 0 <= S - x - y <= K: count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - x - y if 0 <= z <= K: count += 1 print(count)
false
0
[ "- if 0 <= S - x - y <= K:", "+ z = S - x - y", "+ if 0 <= z <= K:" ]
false
0.04676
0.046463
1.00639
[ "s426869247", "s890409426" ]
u597455618
p02580
python
s752186629
s478020961
716
586
83,492
83,708
Accepted
Accepted
18.16
import sys h, w, m = list(map(int, input().split())) row = [0]*h col = [0]*w bomb = set() for x in sys.stdin.readlines(): H, W = list(map(int, x.split())) bomb.add((H-1, W-1)) row[H-1] += 1 col[W-1] += 1 maxrow = max(row) maxcol = max(col) ans = maxcol + maxrow - 1 p, q = [], [] for i ...
import sys def main(): h, w, m = list(map(int, input().split())) row = [0]*h col = [0]*w bomb = set() for x in sys.stdin.readlines(): H, W = list(map(int, x.split())) bomb.add((H-1, W-1)) row[H-1] += 1 col[W-1] += 1 maxrow = max(row) maxcol =...
29
35
559
718
import sys h, w, m = list(map(int, input().split())) row = [0] * h col = [0] * w bomb = set() for x in sys.stdin.readlines(): H, W = list(map(int, x.split())) bomb.add((H - 1, W - 1)) row[H - 1] += 1 col[W - 1] += 1 maxrow = max(row) maxcol = max(col) ans = maxcol + maxrow - 1 p, q = [], [] for i in ra...
import sys def main(): h, w, m = list(map(int, input().split())) row = [0] * h col = [0] * w bomb = set() for x in sys.stdin.readlines(): H, W = list(map(int, x.split())) bomb.add((H - 1, W - 1)) row[H - 1] += 1 col[W - 1] += 1 maxrow = max(row) maxcol = max...
false
17.142857
[ "-h, w, m = list(map(int, input().split()))", "-row = [0] * h", "-col = [0] * w", "-bomb = set()", "-for x in sys.stdin.readlines():", "- H, W = list(map(int, x.split()))", "- bomb.add((H - 1, W - 1))", "- row[H - 1] += 1", "- col[W - 1] += 1", "-maxrow = max(row)", "-maxcol = max(co...
false
0.033971
0.036056
0.942176
[ "s752186629", "s478020961" ]
u439063038
p02614
python
s777969557
s332141669
67
48
9,460
9,076
Accepted
Accepted
28.36
from collections import Counter H, W, K = list(map(int, input().split())) c = [eval(input()) for _ in range(H)] cnt = 0 for h in range(2**H): h_list = [] for _ in range(H): h_list.append(h%2) h //= 2 for w in range(2**W): w_list = [] for _ in range(W): ...
H, W, K = list(map(int, input().split())) c = [eval(input()) for _ in range(H)] cnt = 0 for rows in range(1 << H): for cols in range(1 << W): black = 0 for i in range(H): if (rows >> i) % 2 == 1: continue for j in range(W): if (cols...
27
17
635
453
from collections import Counter H, W, K = list(map(int, input().split())) c = [eval(input()) for _ in range(H)] cnt = 0 for h in range(2**H): h_list = [] for _ in range(H): h_list.append(h % 2) h //= 2 for w in range(2**W): w_list = [] for _ in range(W): w_list.a...
H, W, K = list(map(int, input().split())) c = [eval(input()) for _ in range(H)] cnt = 0 for rows in range(1 << H): for cols in range(1 << W): black = 0 for i in range(H): if (rows >> i) % 2 == 1: continue for j in range(W): if (cols >> j) % 2 =...
false
37.037037
[ "-from collections import Counter", "-", "-for h in range(2**H):", "- h_list = []", "- for _ in range(H):", "- h_list.append(h % 2)", "- h //= 2", "- for w in range(2**W):", "- w_list = []", "- for _ in range(W):", "- w_list.append(w % 2)", "- ...
false
0.041643
0.040716
1.022762
[ "s777969557", "s332141669" ]
u864197622
p02587
python
s228485222
s230737950
1,829
206
258,068
79,856
Accepted
Accepted
88.74
from random import randrange from heapq import heapify, heappush, heappop from time import time K = 60 rand = lambda: randrange(1 << K) sTime = time() N = int(eval(input())) S, IS, C = [], [], [] for _ in range(N): s, c = input().split() S.append(s) IS.append(s[::-1]) C.append(int(c)) D =...
from random import randrange from heapq import heapify, heappush, heappop from time import time K = 60 rand = lambda: randrange(1 << K) sTime = time() N = int(eval(input())) S, IS, C = [], [], [] for _ in range(N): s, c = input().split() S.append(s) IS.append(s[::-1]) C.append(int(c)) D =...
59
59
1,842
1,857
from random import randrange from heapq import heapify, heappush, heappop from time import time K = 60 rand = lambda: randrange(1 << K) sTime = time() N = int(eval(input())) S, IS, C = [], [], [] for _ in range(N): s, c = input().split() S.append(s) IS.append(s[::-1]) C.append(int(c)) D = {} done = set...
from random import randrange from heapq import heapify, heappush, heappop from time import time K = 60 rand = lambda: randrange(1 << K) sTime = time() N = int(eval(input())) S, IS, C = [], [], [] for _ in range(N): s, c = input().split() S.append(s) IS.append(s[::-1]) C.append(int(c)) D = {} done = [se...
false
0
[ "-done = set()", "+done = [set(), set()]", "- if r in done:", "- continue", "- done.add(r)", "+ if s in done[d]:", "+ continue", "+ done[d].add(s)" ]
false
0.03746
0.037821
0.990447
[ "s228485222", "s230737950" ]
u048800107
p02689
python
s906444093
s171786282
165
145
21,336
20,212
Accepted
Accepted
12.12
import copy from sys import stdin input = stdin.readline n,m = list(map(int,input().split())) h = list(map(int,input().split())) p = copy.copy(h) # path = list(list(map(int,input().split())) for x in range(m)) for i in range(m): x,y = list(map(int,input().split())) if h[x-1] > h[y-1]: p[y-...
# import copy from sys import stdin input = stdin.readline n,m = list(map(int,input().split())) h = list(map(int,input().split())) # p = copy.copy(h) p = [0]*n # path = list(list(map(int,input().split())) for x in range(m)) for i in range(m): x,y = list(map(int,input().split())) if h[x-1] > h[y-1]...
24
22
511
469
import copy from sys import stdin input = stdin.readline n, m = list(map(int, input().split())) h = list(map(int, input().split())) p = copy.copy(h) # path = list(list(map(int,input().split())) for x in range(m)) for i in range(m): x, y = list(map(int, input().split())) if h[x - 1] > h[y - 1]: p[y - 1]...
# import copy from sys import stdin input = stdin.readline n, m = list(map(int, input().split())) h = list(map(int, input().split())) # p = copy.copy(h) p = [0] * n # path = list(list(map(int,input().split())) for x in range(m)) for i in range(m): x, y = list(map(int, input().split())) if h[x - 1] > h[y - 1]: ...
false
8.333333
[ "-import copy", "+# import copy", "-p = copy.copy(h)", "+# p = copy.copy(h)", "+p = [0] * n", "- p[y - 1] = 0", "+ p[y - 1] = 1", "- p[x - 1] = 0", "+ p[x - 1] = 1", "- p[y - 1] = 0", "- p[x - 1] = 0", "-cnt = 0", "-for k in p:", "- if k != 0:",...
false
0.037152
0.045729
0.812425
[ "s906444093", "s171786282" ]
u339503988
p03162
python
s324009983
s545006960
958
676
47,348
84,952
Accepted
Accepted
29.44
n = int(eval(input())) s = [list(map(int, input().split())) for _ in range(n)] dp = [[0] * 3 for i in range(n+1)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i+1][k] = max(dp[i][j] + s[i][k], dp[i+1][k]) print((max(dp...
n = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(n)] dp = [[0, 0, 0] for _ in range(2 * n)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]) pri...
13
12
319
329
n = int(eval(input())) s = [list(map(int, input().split())) for _ in range(n)] dp = [[0] * 3 for i in range(n + 1)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i][j] + s[i][k], dp[i + 1][k]) print((max(dp[n])))
n = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(n)] dp = [[0, 0, 0] for _ in range(2 * n)] for i in range(n): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]) print((max(dp[n]...
false
7.692308
[ "-s = [list(map(int, input().split())) for _ in range(n)]", "-dp = [[0] * 3 for i in range(n + 1)]", "+abc = [list(map(int, input().split())) for _ in range(n)]", "+dp = [[0, 0, 0] for _ in range(2 * n)]", "- dp[i + 1][k] = max(dp[i][j] + s[i][k], dp[i + 1][k])", "+ dp[i + 1][k] = ma...
false
0.037128
0.178025
0.208556
[ "s324009983", "s545006960" ]
u029315034
p03283
python
s234789868
s061060749
2,044
1,182
80,344
18,372
Accepted
Accepted
42.17
N, M, Q = [int(v) for v in input().split()] p = [] q = [] x = [[0] * (N+1) for i in range(N+1)] c = [[0] * (N+1) for i in range(N+1)] for i in range(M): l, r = [int(v) for v in input().split()] x[l][r] += 1 for i in range(1, N+1): for j in range(1, N+1): c[i][j] = c[i][j-1] + x[i][j] fo...
N, M, Q = [int(v) for v in input().split()] p = [] q = [] c = [[0] * (N+1) for i in range(N+1)] for i in range(M): l, r = [int(v) for v in input().split()] c[l][r] += 1 for i in range(1, N+1): for j in range(1, N+1): c[i][j] += c[i][j-1] for i in range(1, N+1): for j in range(1, N+1...
22
22
544
551
N, M, Q = [int(v) for v in input().split()] p = [] q = [] x = [[0] * (N + 1) for i in range(N + 1)] c = [[0] * (N + 1) for i in range(N + 1)] for i in range(M): l, r = [int(v) for v in input().split()] x[l][r] += 1 for i in range(1, N + 1): for j in range(1, N + 1): c[i][j] = c[i][j - 1] + x[i][j] f...
N, M, Q = [int(v) for v in input().split()] p = [] q = [] c = [[0] * (N + 1) for i in range(N + 1)] for i in range(M): l, r = [int(v) for v in input().split()] c[l][r] += 1 for i in range(1, N + 1): for j in range(1, N + 1): c[i][j] += c[i][j - 1] for i in range(1, N + 1): for j in range(1, N + ...
false
0
[ "-x = [[0] * (N + 1) for i in range(N + 1)]", "- x[l][r] += 1", "+ c[l][r] += 1", "- c[i][j] = c[i][j - 1] + x[i][j]", "+ c[i][j] += c[i][j - 1]", "+for i in range(1, N + 1):", "+ for j in range(1, N + 1):", "+ c[i][j] += c[i - 1][j]", "-for i in range(Q):", "- ans...
false
0.038672
0.04422
0.874552
[ "s234789868", "s061060749" ]
u759934006
p00169
python
s103925195
s075010752
20
10
4,224
4,228
Accepted
Accepted
50
while True: cards = list(map(int, input().split())) if cards == [0]: break ace = 0 sum = 0 for i in cards: if i > 10: sum += 10 else: sum += i if i == 1: ace += 1 for i in range(ace): if sum + 1...
while True: cards = list(map(int, input().split())) if cards == [0]: break ace = 0 sum = 0 for i in cards: if i > 10: sum += 10 else: sum += i if i == 1: ace += 1 for i in range(ace): if sum <= ...
20
20
386
381
while True: cards = list(map(int, input().split())) if cards == [0]: break ace = 0 sum = 0 for i in cards: if i > 10: sum += 10 else: sum += i if i == 1: ace += 1 for i in range(ace): if sum + 10 <= 21: ...
while True: cards = list(map(int, input().split())) if cards == [0]: break ace = 0 sum = 0 for i in cards: if i > 10: sum += 10 else: sum += i if i == 1: ace += 1 for i in range(ace): if sum <= 11: su...
false
0
[ "- if sum + 10 <= 21:", "+ if sum <= 11:" ]
false
0.046654
0.067533
0.690834
[ "s103925195", "s075010752" ]
u644907318
p02762
python
s402005967
s681057695
1,432
875
124,388
129,752
Accepted
Accepted
38.9
from collections import deque N,M,K = list(map(int,input().split())) F = {i:set() for i in range(1,N+1)} B = {i:set() for i in range(1,N+1)} for _ in range(M): a,b = list(map(int,input().split())) F[a].add(b) F[b].add(a) for _ in range(K): c,d = list(map(int,input().split())) B[c].add(d) ...
def find(i): x = i while x!=G[x][0]: x = G[x][0] return x def union(i,j): ai = find(i) ni = G[ai][1] aj = find(j) nj = G[aj][1] if ai!=aj: if ni>=nj: G[aj][0] = ai if G[aj][1]==G[ai][1]: G[ai][1] += 1 G[ai...
36
44
879
969
from collections import deque N, M, K = list(map(int, input().split())) F = {i: set() for i in range(1, N + 1)} B = {i: set() for i in range(1, N + 1)} for _ in range(M): a, b = list(map(int, input().split())) F[a].add(b) F[b].add(a) for _ in range(K): c, d = list(map(int, input().split())) B[c].ad...
def find(i): x = i while x != G[x][0]: x = G[x][0] return x def union(i, j): ai = find(i) ni = G[ai][1] aj = find(j) nj = G[aj][1] if ai != aj: if ni >= nj: G[aj][0] = ai if G[aj][1] == G[ai][1]: G[ai][1] += 1 G[ai][2]...
false
18.181818
[ "-from collections import deque", "+def find(i):", "+ x = i", "+ while x != G[x][0]:", "+ x = G[x][0]", "+ return x", "+", "+", "+def union(i, j):", "+ ai = find(i)", "+ ni = G[ai][1]", "+ aj = find(j)", "+ nj = G[aj][1]", "+ if ai != aj:", "+ if ni ...
false
0.033795
0.040369
0.837135
[ "s402005967", "s681057695" ]
u500376440
p03329
python
s623785814
s987016072
216
97
9,180
9,668
Accepted
Accepted
55.09
N=int(eval(input())) ans=N for i in range(N+1): cnt=0 t=i while t>0: cnt+=t%6 t//=6 j=N-i while j>0: cnt+=j%9 j//=9 ans=min(ans,cnt) print(ans)
N=int(eval(input())) dp=[0]*(100000+1) a=1 b=6 c=9 for i in range(1,N+1): if i>=b*6: b*=6 if i>=c*9: c*=9 if i<6: dp[i]=i elif i<9: dp[i]=min(dp[i-a]+1,dp[i-b]+1) else: dp[i]=min([dp[i-a]+1,dp[i-b]+1,dp[i-c]+1]) print((dp[N]))
14
17
179
265
N = int(eval(input())) ans = N for i in range(N + 1): cnt = 0 t = i while t > 0: cnt += t % 6 t //= 6 j = N - i while j > 0: cnt += j % 9 j //= 9 ans = min(ans, cnt) print(ans)
N = int(eval(input())) dp = [0] * (100000 + 1) a = 1 b = 6 c = 9 for i in range(1, N + 1): if i >= b * 6: b *= 6 if i >= c * 9: c *= 9 if i < 6: dp[i] = i elif i < 9: dp[i] = min(dp[i - a] + 1, dp[i - b] + 1) else: dp[i] = min([dp[i - a] + 1, dp[i - b] + 1, dp...
false
17.647059
[ "-ans = N", "-for i in range(N + 1):", "- cnt = 0", "- t = i", "- while t > 0:", "- cnt += t % 6", "- t //= 6", "- j = N - i", "- while j > 0:", "- cnt += j % 9", "- j //= 9", "- ans = min(ans, cnt)", "-print(ans)", "+dp = [0] * (100000 + 1)", ...
false
0.295787
0.159178
1.858217
[ "s623785814", "s987016072" ]
u596536048
p03826
python
s476215088
s040069338
31
26
9,084
9,072
Accepted
Accepted
16.13
vertical1, horizontal1, vertical2, horizontal2 = list(map(int, input().split())) area1 = vertical1 * horizontal1 area2 = vertical2 * horizontal2 if area1 < area2: print(area2) else: print(area1)
A, B, C, D = list(map(int, input().split())) print((max(A * B, C * D)))
7
2
202
64
vertical1, horizontal1, vertical2, horizontal2 = list(map(int, input().split())) area1 = vertical1 * horizontal1 area2 = vertical2 * horizontal2 if area1 < area2: print(area2) else: print(area1)
A, B, C, D = list(map(int, input().split())) print((max(A * B, C * D)))
false
71.428571
[ "-vertical1, horizontal1, vertical2, horizontal2 = list(map(int, input().split()))", "-area1 = vertical1 * horizontal1", "-area2 = vertical2 * horizontal2", "-if area1 < area2:", "- print(area2)", "-else:", "- print(area1)", "+A, B, C, D = list(map(int, input().split()))", "+print((max(A * B, ...
false
0.036963
0.035286
1.047526
[ "s476215088", "s040069338" ]
u683134447
p02714
python
s577852993
s555608697
465
331
68,988
73,884
Accepted
Accepted
28.82
n = int(eval(input())) sl = list(eval(input())) sum_r = sl.count("R") sum_g = sl.count("G") sum_b = sl.count("B") rl = [] gl = [] bl = [] for s in sl: if s == "R": sum_r -= 1 if s == "G": sum_g -= 1 if s == "B": sum_b -= 1 rl.append(sum_r) gl.append(su...
n = int(eval(input())) sl = list(eval(input())) ans = sl.count("R") * sl.count("G") * sl.count("B") for i in range(n): for j in range(i+1, n): k = 2 * j - i if k < n: if len({sl[i], sl[j], sl[k]}) == 3: ans -= 1 print(ans)
44
14
933
277
n = int(eval(input())) sl = list(eval(input())) sum_r = sl.count("R") sum_g = sl.count("G") sum_b = sl.count("B") rl = [] gl = [] bl = [] for s in sl: if s == "R": sum_r -= 1 if s == "G": sum_g -= 1 if s == "B": sum_b -= 1 rl.append(sum_r) gl.append(sum_g) bl.append(sum_b...
n = int(eval(input())) sl = list(eval(input())) ans = sl.count("R") * sl.count("G") * sl.count("B") for i in range(n): for j in range(i + 1, n): k = 2 * j - i if k < n: if len({sl[i], sl[j], sl[k]}) == 3: ans -= 1 print(ans)
false
68.181818
[ "-sum_r = sl.count(\"R\")", "-sum_g = sl.count(\"G\")", "-sum_b = sl.count(\"B\")", "-rl = []", "-gl = []", "-bl = []", "-for s in sl:", "- if s == \"R\":", "- sum_r -= 1", "- if s == \"G\":", "- sum_g -= 1", "- if s == \"B\":", "- sum_b -= 1", "- rl.append...
false
0.040973
0.058195
0.704066
[ "s577852993", "s555608697" ]
u089830331
p02267
python
s471860505
s848338307
130
60
8,448
8,380
Accepted
Accepted
53.85
n = int(eval(input())) S = list(map(int, input().split())) q = int(eval(input())) T = list(map(int, input().split())) C = [] for s in S: for t in T: if s == t and not s in C: C.append(s) print((len(C)))
n = int(eval(input())) S = list(map(int, input().split())) q = int(eval(input())) T = list(map(int, input().split())) C = 0 for t in T: for s in S: if s == t: C += 1 break print(C)
10
12
204
198
n = int(eval(input())) S = list(map(int, input().split())) q = int(eval(input())) T = list(map(int, input().split())) C = [] for s in S: for t in T: if s == t and not s in C: C.append(s) print((len(C)))
n = int(eval(input())) S = list(map(int, input().split())) q = int(eval(input())) T = list(map(int, input().split())) C = 0 for t in T: for s in S: if s == t: C += 1 break print(C)
false
16.666667
[ "-C = []", "-for s in S:", "- for t in T:", "- if s == t and not s in C:", "- C.append(s)", "-print((len(C)))", "+C = 0", "+for t in T:", "+ for s in S:", "+ if s == t:", "+ C += 1", "+ break", "+print(C)" ]
false
0.038739
0.039677
0.976343
[ "s471860505", "s848338307" ]
u366959492
p02844
python
s172742555
s615228754
349
221
41,180
74,404
Accepted
Accepted
36.68
n=int(eval(input())) s=eval(input()) ans=0 for i in range(1000): if i<10: ss="00"+str(i) elif i<100: ss="0"+str(i) else: ss=str(i) k=0 for j in range(n): if s[j]==ss[k]: k+=1 if k==3: break if k==3: ans+=1 ...
n=int(eval(input())) s=eval(input()) ans=0 from collections import Counter c=Counter(s) for i in range(1000): x=str(i) if len(x)==1: x="00"+x elif len(x)==2: x="0"+x k=0 for j in range(n): if s[j]==x[k]: k+=1 if k==3: ans+=1 ...
19
20
319
346
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1000): if i < 10: ss = "00" + str(i) elif i < 100: ss = "0" + str(i) else: ss = str(i) k = 0 for j in range(n): if s[j] == ss[k]: k += 1 if k == 3: break if k == 3: ...
n = int(eval(input())) s = eval(input()) ans = 0 from collections import Counter c = Counter(s) for i in range(1000): x = str(i) if len(x) == 1: x = "00" + x elif len(x) == 2: x = "0" + x k = 0 for j in range(n): if s[j] == x[k]: k += 1 if k == 3: ...
false
5
[ "+from collections import Counter", "+", "+c = Counter(s)", "- if i < 10:", "- ss = \"00\" + str(i)", "- elif i < 100:", "- ss = \"0\" + str(i)", "- else:", "- ss = str(i)", "+ x = str(i)", "+ if len(x) == 1:", "+ x = \"00\" + x", "+ elif len(x) ...
false
0.078016
0.037713
2.068657
[ "s172742555", "s615228754" ]
u673361376
p03137
python
s473767353
s174818007
238
123
58,408
13,968
Accepted
Accepted
48.32
N,M = list(map(int,input().split())) if M == 1: print((0)) exit() X = sorted(list(map(int,input().split()))) difX = [0] + [X[i+1]-X[i] for i in range(M-1)] difX.sort(reverse=True) print((sum(difX)-sum(difX[:N-1])))
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) difX = [0] for i in range(1, M): difX.append(X[i]-X[i-1]) difX.sort(reverse=True) print((max(X) - min(X) - sum(difX[:N-1])))
9
7
217
209
N, M = list(map(int, input().split())) if M == 1: print((0)) exit() X = sorted(list(map(int, input().split()))) difX = [0] + [X[i + 1] - X[i] for i in range(M - 1)] difX.sort(reverse=True) print((sum(difX) - sum(difX[: N - 1])))
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) difX = [0] for i in range(1, M): difX.append(X[i] - X[i - 1]) difX.sort(reverse=True) print((max(X) - min(X) - sum(difX[: N - 1])))
false
22.222222
[ "-if M == 1:", "- print((0))", "- exit()", "-difX = [0] + [X[i + 1] - X[i] for i in range(M - 1)]", "+difX = [0]", "+for i in range(1, M):", "+ difX.append(X[i] - X[i - 1])", "-print((sum(difX) - sum(difX[: N - 1])))", "+print((max(X) - min(X) - sum(difX[: N - 1])))" ]
false
0.036448
0.041229
0.884039
[ "s473767353", "s174818007" ]
u546338822
p03045
python
s718170945
s643283744
1,983
1,076
35,536
38,688
Accepted
Accepted
45.74
def main(): n,m = list(map(int,input().split())) graph = {} for i in range(n): graph[i+1] = [] for i in range(m): x,y,z = list(map(int,input().split())) graph[x] += [y] graph[y] += [x] dis = [-1 for i in range (n)] ans = 0 for i in range(n): ...
def main(): n,m = list(map(int,input().split())) cards = [-1 for i in range(n)] mg = {} for i in range(n): mg[i+1] = [] for i in range(m): x,y,z = list(map(int,input().split())) mg[x].append(y) mg[y].append(x) ans = 0 for i in range(n): if ...
27
27
704
697
def main(): n, m = list(map(int, input().split())) graph = {} for i in range(n): graph[i + 1] = [] for i in range(m): x, y, z = list(map(int, input().split())) graph[x] += [y] graph[y] += [x] dis = [-1 for i in range(n)] ans = 0 for i in range(n): if d...
def main(): n, m = list(map(int, input().split())) cards = [-1 for i in range(n)] mg = {} for i in range(n): mg[i + 1] = [] for i in range(m): x, y, z = list(map(int, input().split())) mg[x].append(y) mg[y].append(x) ans = 0 for i in range(n): if cards...
false
0
[ "- graph = {}", "+ cards = [-1 for i in range(n)]", "+ mg = {}", "- graph[i + 1] = []", "+ mg[i + 1] = []", "- graph[x] += [y]", "- graph[y] += [x]", "- dis = [-1 for i in range(n)]", "+ mg[x].append(y)", "+ mg[y].append(x)", "- if dis...
false
0.046411
0.112535
0.412411
[ "s718170945", "s643283744" ]
u819048695
p03837
python
s874645140
s423950915
281
173
46,444
14,196
Accepted
Accepted
38.43
n,m=list(map(int,input().split())) inf=float("inf") data=[[inf]*(n+1) for i in range(n+1)] for i in range(1,n+1): data[i][i]=0 lst=[] for u in range(m): a,b,c=list(map(int,input().split())) data[a][b]=c data[b][a]=c lst.append([a,b,c]) for k in range(1,n+1): for i in range(1,n+1)...
import numpy as np from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson from scipy.sparse import csr_matrix n,m=list(map(int,input().split())) abc=[list(map(int,input().split())) for i in range(m)] data=np.zeros((n+1,n+1)) for u in abc: a,b,c=u data[a,b]=c ...
25
20
493
469
n, m = list(map(int, input().split())) inf = float("inf") data = [[inf] * (n + 1) for i in range(n + 1)] for i in range(1, n + 1): data[i][i] = 0 lst = [] for u in range(m): a, b, c = list(map(int, input().split())) data[a][b] = c data[b][a] = c lst.append([a, b, c]) for k in range(1, n + 1): fo...
import numpy as np from scipy.sparse.csgraph import ( shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, ) from scipy.sparse import csr_matrix n, m = list(map(int, input().split())) abc = [list(map(int, input().split())) for i in range(m)] data = np.zeros((n + 1, n + 1)) for u in abc: ...
false
20
[ "+import numpy as np", "+from scipy.sparse.csgraph import (", "+ shortest_path,", "+ floyd_warshall,", "+ dijkstra,", "+ bellman_ford,", "+ johnson,", "+)", "+from scipy.sparse import csr_matrix", "+", "-inf = float(\"inf\")", "-data = [[inf] * (n + 1) for i in range(n + 1)]", ...
false
0.14834
0.323448
0.458622
[ "s874645140", "s423950915" ]
u796942881
p03043
python
s793933508
s642471660
186
129
3,684
3,572
Accepted
Accepted
30.65
from functools import reduce from operator import mul import math def end_of_loop(): raise StopIteration def main(): N, K = list(map(int, input().split())) print((sum(reduce(mul, (0.5 if i << j < K else end_of_loop() ...
from functools import reduce from operator import mul def end_of_loop(): raise StopIteration def main(): N, K = list(map(int, input().split())) print((sum(reduce(mul, (0.5 if i << j < K else end_of_loop() for j...
20
19
432
401
from functools import reduce from operator import mul import math def end_of_loop(): raise StopIteration def main(): N, K = list(map(int, input().split())) print( ( sum( reduce( mul, ( 0.5 if i << j < K e...
from functools import reduce from operator import mul def end_of_loop(): raise StopIteration def main(): N, K = list(map(int, input().split())) print( ( sum( reduce( mul, (0.5 if i << j < K else end_of_loop() for j in range(K)), 1 / N ...
false
5
[ "-import math", "- mul,", "- (", "- 0.5 if i << j < K else end_of_loop()", "- for j in range(int(math.log2(K)) + 2)", "- ),", "- 1 / N,", "+ mul, (0.5 if i << j ...
false
0.036514
0.037435
0.975391
[ "s793933508", "s642471660" ]
u188827677
p02832
python
s214348024
s270786876
120
103
26,580
32,356
Accepted
Accepted
14.17
n = int(eval(input())) a = list(map(int, input().split())) t = 1 ans = 0 for i in range(n): if t != a[i]: ans += 1 a[i] = -1 else: t += 1 if all([i == -1 for i in a]): print((-1)) else: print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 t = 1 s = [] for i in a: if i != t: ans += 1 else: t += 1 s.append(i) if s == []: print((-1)) else: print(ans)
16
16
225
202
n = int(eval(input())) a = list(map(int, input().split())) t = 1 ans = 0 for i in range(n): if t != a[i]: ans += 1 a[i] = -1 else: t += 1 if all([i == -1 for i in a]): print((-1)) else: print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 t = 1 s = [] for i in a: if i != t: ans += 1 else: t += 1 s.append(i) if s == []: print((-1)) else: print(ans)
false
0
[ "+ans = 0", "-ans = 0", "-for i in range(n):", "- if t != a[i]:", "+s = []", "+for i in a:", "+ if i != t:", "- a[i] = -1", "-if all([i == -1 for i in a]):", "+ s.append(i)", "+if s == []:" ]
false
0.040724
0.040277
1.01109
[ "s214348024", "s270786876" ]
u784022244
p03283
python
s325804896
s713615704
1,582
639
13,296
74,296
Accepted
Accepted
59.61
N,M,Q=list(map(int, input().split())) L=[[0]*(N+1) for _ in range(N+1)] for i in range(M): l,r=list(map(int, input().split())) L[l][r]+=1 #print(L) for i in range(1,N+1): for j in range(1,N+1): L[i][j]+=L[i][j-1]+L[i-1][j]-L[i-1][j-1] #print(L) for i in range(Q): p,q=list(map(in...
N,M,Q=list(map(int, input().split())) L=[[0]*N for _ in range(N)] for i in range(M): l,r=list(map(int, input().split())) L[l-1][r-1]+=1 for i in range(N): for j in range(N): if i==0 and j==0: continue elif i==0: L[i][j]+=L[i][j-1] elif j==0: ...
17
28
387
600
N, M, Q = list(map(int, input().split())) L = [[0] * (N + 1) for _ in range(N + 1)] for i in range(M): l, r = list(map(int, input().split())) L[l][r] += 1 # print(L) for i in range(1, N + 1): for j in range(1, N + 1): L[i][j] += L[i][j - 1] + L[i - 1][j] - L[i - 1][j - 1] # print(L) for i in range(Q...
N, M, Q = list(map(int, input().split())) L = [[0] * N for _ in range(N)] for i in range(M): l, r = list(map(int, input().split())) L[l - 1][r - 1] += 1 for i in range(N): for j in range(N): if i == 0 and j == 0: continue elif i == 0: L[i][j] += L[i][j - 1] el...
false
39.285714
[ "-L = [[0] * (N + 1) for _ in range(N + 1)]", "+L = [[0] * N for _ in range(N)]", "- L[l][r] += 1", "-# print(L)", "-for i in range(1, N + 1):", "- for j in range(1, N + 1):", "- L[i][j] += L[i][j - 1] + L[i - 1][j] - L[i - 1][j - 1]", "+ L[l - 1][r - 1] += 1", "+for i in range(N):",...
false
0.038137
0.047415
0.804323
[ "s325804896", "s713615704" ]
u227082700
p03078
python
s576580639
s375408106
1,267
963
186,108
156,636
Accepted
Accepted
23.99
from heapq import heappop,heappush;import sys;input=sys.stdin.readline x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split())) q,h,l=[],[],0 for i in a: for j in b:heappush(q,-(i+j));l+=1 for _ in range(min(l,k)): t=heappop(q) ...
x,y,z,k=list(map(int,input().split()));a,b,c=list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split())) aa=[] for i in a: for j in b:aa.append(i+j) aa.sort(reverse=1) aa=aa[:k+1] s=[] for i in aa: for j in c:s.append(i+j) s.sort(reverse=1) for i in range(k):print((s[i]))
9
11
380
311
from heapq import heappop, heappush import sys input = sys.stdin.readline x, y, z, k = list(map(int, input().split())) a, b, c = ( list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())), ) q, h, l = [], [], 0 for i in a: for j in b: heappush(q, -(i + j...
x, y, z, k = list(map(int, input().split())) a, b, c = ( list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split())), ) aa = [] for i in a: for j in b: aa.append(i + j) aa.sort(reverse=1) aa = aa[: k + 1] s = [] for i in aa: for j in c: s.append(...
false
18.181818
[ "-from heapq import heappop, heappush", "-import sys", "-", "-input = sys.stdin.readline", "-q, h, l = [], [], 0", "+aa = []", "- heappush(q, -(i + j))", "- l += 1", "-for _ in range(min(l, k)):", "- t = heappop(q)", "- for i in c:", "- heappush(h, t - i)", "+ ...
false
0.038939
0.039001
0.998413
[ "s576580639", "s375408106" ]
u394721319
p03127
python
s194085239
s697904676
165
58
14,252
14,252
Accepted
Accepted
64.85
n = int(eval(input())) l = [int(i) for i in input().split()] m = [] flag = 0 while flag ==0: l.sort() p = len(l) for i in range(1,p): a = l[i]%l[0] if a != 0: l[i] = a else: l[i] = l[0] kkk = set(l) if len(kkk) <= 1 or min(l) == 1: ...
N = int(eval(input())) A = [int(i) for i in input().split()] b = min(A) for a in A: while True: if a%b == 0: break tb = b b = a%b a = tb print(b)
24
13
404
202
n = int(eval(input())) l = [int(i) for i in input().split()] m = [] flag = 0 while flag == 0: l.sort() p = len(l) for i in range(1, p): a = l[i] % l[0] if a != 0: l[i] = a else: l[i] = l[0] kkk = set(l) if len(kkk) <= 1 or min(l) == 1: flag = 1...
N = int(eval(input())) A = [int(i) for i in input().split()] b = min(A) for a in A: while True: if a % b == 0: break tb = b b = a % b a = tb print(b)
false
45.833333
[ "-n = int(eval(input()))", "-l = [int(i) for i in input().split()]", "-m = []", "-flag = 0", "-while flag == 0:", "- l.sort()", "- p = len(l)", "- for i in range(1, p):", "- a = l[i] % l[0]", "- if a != 0:", "- l[i] = a", "- else:", "- l[i]...
false
0.057325
0.047216
1.214101
[ "s194085239", "s697904676" ]
u347600233
p02684
python
s024298454
s583949205
177
155
32,304
32,328
Accepted
Accepted
12.43
n, k = list(map(int,input().split())) a = [int(i) for i in input().split()] s = [] ord = [-1] * (n+1) c, l = 1, 0 v = 1 while (ord[v] == -1): ord[v] = len(s) s.append(v) v = a[v-1] c = len(s) - ord[v] l = ord[v] print((s[k] if (k < l) else s[l + (k - l) % c]))
n, k = list(map(int, input().split())) a = [int(i) for i in input().split()] ord = [-1] * (n + 1) s = [] v = 1 c, l = 1, 0 while ord[v] == -1: ord[v] = len(s) s.append(v) v = a[v - 1] c = len(s) - ord[v] l = ord[v] print((s[k] if k < l else s[l + (k - l) % c]))
14
13
282
278
n, k = list(map(int, input().split())) a = [int(i) for i in input().split()] s = [] ord = [-1] * (n + 1) c, l = 1, 0 v = 1 while ord[v] == -1: ord[v] = len(s) s.append(v) v = a[v - 1] c = len(s) - ord[v] l = ord[v] print((s[k] if (k < l) else s[l + (k - l) % c]))
n, k = list(map(int, input().split())) a = [int(i) for i in input().split()] ord = [-1] * (n + 1) s = [] v = 1 c, l = 1, 0 while ord[v] == -1: ord[v] = len(s) s.append(v) v = a[v - 1] c = len(s) - ord[v] l = ord[v] print((s[k] if k < l else s[l + (k - l) % c]))
false
7.142857
[ "+ord = [-1] * (n + 1)", "-ord = [-1] * (n + 1)", "+v = 1", "-v = 1", "-print((s[k] if (k < l) else s[l + (k - l) % c]))", "+print((s[k] if k < l else s[l + (k - l) % c]))" ]
false
0.038034
0.048996
0.776279
[ "s024298454", "s583949205" ]
u228303592
p02725
python
s949747726
s395025609
141
120
26,436
32,248
Accepted
Accepted
14.89
k,n = list(map(int,input().split())) a = list(map(int,input().split())) b = [] for i in range(1,n): b.append(a[i] - a[i - 1]) b.append(k - a[n-1] + a[0]) b = sorted(b) print((sum(b[:n-1])))
k,n = list(map(int,input().split())) a = list(map(int,input().split())) b = [] for i in range(1,n): b.append(a[i] - a[i - 1]) b.append(k - a[n-1] + a[0]) b = sorted(b) print((sum(b[:-1])))
10
10
194
194
k, n = list(map(int, input().split())) a = list(map(int, input().split())) b = [] for i in range(1, n): b.append(a[i] - a[i - 1]) b.append(k - a[n - 1] + a[0]) b = sorted(b) print((sum(b[: n - 1])))
k, n = list(map(int, input().split())) a = list(map(int, input().split())) b = [] for i in range(1, n): b.append(a[i] - a[i - 1]) b.append(k - a[n - 1] + a[0]) b = sorted(b) print((sum(b[:-1])))
false
0
[ "-print((sum(b[: n - 1])))", "+print((sum(b[:-1])))" ]
false
0.0729
0.038759
1.880852
[ "s949747726", "s395025609" ]
u562935282
p03482
python
s160834282
s898491924
73
39
4,084
3,188
Accepted
Accepted
46.58
s = tuple(map(int, eval(input()))) n = len(s) ret = n p = s[0] for i, x in enumerate(s): if x != p: ret = min(ret, max(i, n - i)) p = x print(ret)
# https://emtubasa.hateblo.jp/entry/2019/02/14/000000_2 def main(): from itertools import tee S = eval(input()) L = len(S) s1, s2 = tee(iter(S), 2) next(s2) k = L for i, (c1, c2) in enumerate(zip(s1, s2), start=1): if c1 != c2: t = max(i, L - i) ...
10
26
167
515
s = tuple(map(int, eval(input()))) n = len(s) ret = n p = s[0] for i, x in enumerate(s): if x != p: ret = min(ret, max(i, n - i)) p = x print(ret)
# https://emtubasa.hateblo.jp/entry/2019/02/14/000000_2 def main(): from itertools import tee S = eval(input()) L = len(S) s1, s2 = tee(iter(S), 2) next(s2) k = L for i, (c1, c2) in enumerate(zip(s1, s2), start=1): if c1 != c2: t = max(i, L - i) if k > t: ...
false
61.538462
[ "-s = tuple(map(int, eval(input())))", "-n = len(s)", "-ret = n", "-p = s[0]", "-for i, x in enumerate(s):", "- if x != p:", "- ret = min(ret, max(i, n - i))", "- p = x", "-print(ret)", "+# https://emtubasa.hateblo.jp/entry/2019/02/14/000000_2", "+def main():", "+ from itertool...
false
0.047007
0.041158
1.142126
[ "s160834282", "s898491924" ]
u778814286
p03161
python
s192055307
s248634155
1,898
1,678
13,928
13,980
Accepted
Accepted
11.59
def solve(): n,k=[int(i) for i in input().split()] h=[int(i) for i in input().split()] dp=[0]*n for i, hi in enumerate(h): if i==0: continue dp[i]=min([dp[j] + abs(hi-h[j]) for j in range(max(i-k,0),i)]) return dp[n-1] print((solve()))
def solve(): n,k=[int(i) for i in input().split()] h=[int(i) for i in input().split()] dp=[0]*n for i, hi in enumerate(h): if i==0: continue x = max(0, i - k) dp[i]=min([dpj + abs(hi-hj) for dpj, hj in zip(dp[x:i], h[x:i])]) #スライサー[x:i]で[x]~[i-1]の部分リストを取得 return dp[n-1] print((solve(...
9
11
260
322
def solve(): n, k = [int(i) for i in input().split()] h = [int(i) for i in input().split()] dp = [0] * n for i, hi in enumerate(h): if i == 0: continue dp[i] = min([dp[j] + abs(hi - h[j]) for j in range(max(i - k, 0), i)]) return dp[n - 1] print((solve()))
def solve(): n, k = [int(i) for i in input().split()] h = [int(i) for i in input().split()] dp = [0] * n for i, hi in enumerate(h): if i == 0: continue x = max(0, i - k) dp[i] = min([dpj + abs(hi - hj) for dpj, hj in zip(dp[x:i], h[x:i])]) # スライサー[x:i]で[x]~[i-...
false
18.181818
[ "- dp[i] = min([dp[j] + abs(hi - h[j]) for j in range(max(i - k, 0), i)])", "+ x = max(0, i - k)", "+ dp[i] = min([dpj + abs(hi - hj) for dpj, hj in zip(dp[x:i], h[x:i])])", "+ # スライサー[x:i]で[x]~[i-1]の部分リストを取得" ]
false
0.036698
0.035528
1.032929
[ "s192055307", "s248634155" ]
u759412327
p03317
python
s660977663
s417934200
51
27
20,644
8,932
Accepted
Accepted
47.06
N,K = list(map(int,input().split())) A = list(map(int,input().split())) print((-(-(N-1)//(K-1))))
N,K = list(map(int,input().split())) print((-((1-N)//(K-1))))
3
2
91
54
N, K = list(map(int, input().split())) A = list(map(int, input().split())) print((-(-(N - 1) // (K - 1))))
N, K = list(map(int, input().split())) print((-((1 - N) // (K - 1))))
false
33.333333
[ "-A = list(map(int, input().split()))", "-print((-(-(N - 1) // (K - 1))))", "+print((-((1 - N) // (K - 1))))" ]
false
0.00736
0.062584
0.117594
[ "s660977663", "s417934200" ]
u347600233
p02630
python
s045537434
s489958127
595
349
27,784
27,996
Accepted
Accepted
41.34
from collections import Counter n = int(eval(input())) a = [int(i) for i in input().split()] cnt_a = Counter(a) q = int(eval(input())) s = [sum(a)] + [0] * q for i in range(q): b, c = list(map(int, input().split())) bn = cnt_a[b] s[i + 1] = s[i] + (c - b)*bn cnt_a[b] = 0 cnt_a[c] += bn ...
from collections import Counter n = int(input()) a = [int(i) for i in input().split()] cnt_a = Counter(a) q = int(input()) s = [sum(a)] + [0] * q for i in range(q): b, c = map(int, input().split()) bn = cnt_a[b] s[i + 1] = s[i] + (c - b)*bn cnt_a[b] = 0 cnt_a[c] += bn print(*s[1:], sep='...
13
13
320
324
from collections import Counter n = int(eval(input())) a = [int(i) for i in input().split()] cnt_a = Counter(a) q = int(eval(input())) s = [sum(a)] + [0] * q for i in range(q): b, c = list(map(int, input().split())) bn = cnt_a[b] s[i + 1] = s[i] + (c - b) * bn cnt_a[b] = 0 cnt_a[c] += bn print(...
from collections import Counter n = int(input()) a = [int(i) for i in input().split()] cnt_a = Counter(a) q = int(input()) s = [sum(a)] + [0] * q for i in range(q): b, c = map(int, input().split()) bn = cnt_a[b] s[i + 1] = s[i] + (c - b) * bn cnt_a[b] = 0 cnt_a[c] += bn print(*s[1:], sep="\n")
false
0
[ "-n = int(eval(input()))", "+n = int(input())", "-q = int(eval(input()))", "+q = int(input())", "- b, c = list(map(int, input().split()))", "+ b, c = map(int, input().split())", "- print((s[i + 1]))", "+print(*s[1:], sep=\"\\n\")" ]
false
0.042137
0.070363
0.598851
[ "s045537434", "s489958127" ]
u094999522
p02813
python
s054880189
s671472533
27
17
8,052
3,060
Accepted
Accepted
37.04
import itertools (n,),p,q=[tuple(map(int, i.split())) for i in open(0)] j=list(itertools.permutations(list(range(1, -~n)))) print((abs(j.index(p) - j.index(q))))
import math (n,),p,q=[list(map(int, i.split())) for i in open(0)] def c(l): s=0 t=list(range(1,n+1)) for i in range(n): s+=t.index(l[i])*math.factorial(n-i-1) t.remove(l[i]) return s print((abs(c(p)-c(q))))
4
10
156
245
import itertools (n,), p, q = [tuple(map(int, i.split())) for i in open(0)] j = list(itertools.permutations(list(range(1, -~n)))) print((abs(j.index(p) - j.index(q))))
import math (n,), p, q = [list(map(int, i.split())) for i in open(0)] def c(l): s = 0 t = list(range(1, n + 1)) for i in range(n): s += t.index(l[i]) * math.factorial(n - i - 1) t.remove(l[i]) return s print((abs(c(p) - c(q))))
false
60
[ "-import itertools", "+import math", "-(n,), p, q = [tuple(map(int, i.split())) for i in open(0)]", "-j = list(itertools.permutations(list(range(1, -~n))))", "-print((abs(j.index(p) - j.index(q))))", "+(n,), p, q = [list(map(int, i.split())) for i in open(0)]", "+", "+", "+def c(l):", "+ s = 0"...
false
0.0373
0.038408
0.971147
[ "s054880189", "s671472533" ]
u034426456
p02388
python
s761086720
s350889462
50
20
7,604
7,660
Accepted
Accepted
60
x = int(eval(input())) print((x ** 3))
x = eval(input()) y = int(x)**3 print(y)
2
3
31
36
x = int(eval(input())) print((x**3))
x = eval(input()) y = int(x) ** 3 print(y)
false
33.333333
[ "-x = int(eval(input()))", "-print((x**3))", "+x = eval(input())", "+y = int(x) ** 3", "+print(y)" ]
false
0.054932
0.038235
1.436689
[ "s761086720", "s350889462" ]
u833963136
p03167
python
s137219615
s961021925
680
126
165,236
84,056
Accepted
Accepted
81.47
h, w = list(map(int, input().split())) grid = [str(eval(input())) for _ in range(h)] dp = [[0] * 1050 for _ in range(1050)] MOD = int(1e9+7) dp[0][0] = 1 for i in range(h): for j in range(w): if i + 1 < h and grid[i+1][j] == '.': dp[i+1][j] += dp[i][j] if j + 1 < w and grid[i][j...
h, w = list(map(int, input().split())) grid = [str(eval(input())) for _ in range(h)] dp = [[0] * 1050 for _ in range(1050)] MOD = int(1e9+7) dp[0][0] = 1 for i in range(h): for j in range(w): dp[i][j] %= MOD if i + 1 < h and grid[i+1][j] == '.': dp[i+1][j] += dp[i][j] i...
13
13
401
401
h, w = list(map(int, input().split())) grid = [str(eval(input())) for _ in range(h)] dp = [[0] * 1050 for _ in range(1050)] MOD = int(1e9 + 7) dp[0][0] = 1 for i in range(h): for j in range(w): if i + 1 < h and grid[i + 1][j] == ".": dp[i + 1][j] += dp[i][j] if j + 1 < w and grid[i][j + ...
h, w = list(map(int, input().split())) grid = [str(eval(input())) for _ in range(h)] dp = [[0] * 1050 for _ in range(1050)] MOD = int(1e9 + 7) dp[0][0] = 1 for i in range(h): for j in range(w): dp[i][j] %= MOD if i + 1 < h and grid[i + 1][j] == ".": dp[i + 1][j] += dp[i][j] if j ...
false
0
[ "+ dp[i][j] %= MOD", "- dp[i][j] %= MOD" ]
false
0.039164
0.045376
0.863099
[ "s137219615", "s961021925" ]
u367130284
p03722
python
s856346668
s816860033
368
225
45,660
41,708
Accepted
Accepted
38.86
import sys input=sys.stdin.readline #危険!基本オフにしろ! def BELLMANFORD(point,d,n): cost = [-float("inf")for node in range(n+1)] cost[point]= 0 for i in range(n-1): #経路の長さは最大n-1であるため for now,lis in list(d.items()): for nex,c in lis: ...
import sys input=sys.stdin.readline #危険!基本オフにしろ! def BELLMANFORD(point,n,d): cost=[1e18]*(n+1) cost[point]=0 for i in range(n-1): for (nownode,nextnode,c) in d: if cost[nextnode]>cost[nownode]+c: #infが定数なので論理が逆 cost[nextnode]=cost[nownode]+c for (nownod...
47
33
1,199
762
import sys input = sys.stdin.readline # 危険!基本オフにしろ! def BELLMANFORD(point, d, n): cost = [-float("inf") for node in range(n + 1)] cost[point] = 0 for i in range(n - 1): # 経路の長さは最大n-1であるため for now, lis in list(d.items()): for nex, c in lis: if cost[nex] < cost[now] + ...
import sys input = sys.stdin.readline # 危険!基本オフにしろ! def BELLMANFORD(point, n, d): cost = [1e18] * (n + 1) cost[point] = 0 for i in range(n - 1): for (nownode, nextnode, c) in d: if cost[nextnode] > cost[nownode] + c: # infが定数なので論理が逆 cost[nextnode] = cost[nownode] + c...
false
29.787234
[ "-def BELLMANFORD(point, d, n):", "- cost = [-float(\"inf\") for node in range(n + 1)]", "+def BELLMANFORD(point, n, d):", "+ cost = [1e18] * (n + 1)", "- for i in range(n - 1): # 経路の長さは最大n-1であるため", "- for now, lis in list(d.items()):", "- for nex, c in lis:", "- ...
false
0.075443
0.037196
2.028238
[ "s856346668", "s816860033" ]
u644907318
p03673
python
s139739074
s889152765
362
154
96,852
105,380
Accepted
Accepted
57.46
n = int(eval(input())) A = list(map(int,input().split())) B = A[::-2] if n%2==0: C = A[::2] else: C = A[1::2] B = B+C print((*B))
n = int(eval(input())) A = list(map(int,input().split())) if n%2==0: B = A[1::2] C = A[::2] B = B[::-1] print((*(B+C))) else: B = A[::2] C = A[1::2] B = B[::-1] print((*(B+C)))
9
12
137
209
n = int(eval(input())) A = list(map(int, input().split())) B = A[::-2] if n % 2 == 0: C = A[::2] else: C = A[1::2] B = B + C print((*B))
n = int(eval(input())) A = list(map(int, input().split())) if n % 2 == 0: B = A[1::2] C = A[::2] B = B[::-1] print((*(B + C))) else: B = A[::2] C = A[1::2] B = B[::-1] print((*(B + C)))
false
25
[ "-B = A[::-2]", "+ B = A[1::2]", "+ B = B[::-1]", "+ print((*(B + C)))", "+ B = A[::2]", "-B = B + C", "-print((*B))", "+ B = B[::-1]", "+ print((*(B + C)))" ]
false
0.039536
0.12181
0.324568
[ "s139739074", "s889152765" ]
u150984829
p00513
python
s969151431
s036304941
5,770
2,160
5,996
5,996
Accepted
Accepted
62.56
a=0 for _ in[0]*int(eval(input())): n=int(eval(input())) for i in range(1,int(n**.5)+1): if(n-i)%(2*i+1)==0:break else:a+=1 print(a)
def p(x): if x%2==0:return 0 for i in range(3,int(x**.5+1),2): if x%i==0:return 0 return 1 print((sum(p(int(eval(input()))*2+1)for _ in[0]*int(eval(input())))))
7
6
132
157
a = 0 for _ in [0] * int(eval(input())): n = int(eval(input())) for i in range(1, int(n**0.5) + 1): if (n - i) % (2 * i + 1) == 0: break else: a += 1 print(a)
def p(x): if x % 2 == 0: return 0 for i in range(3, int(x**0.5 + 1), 2): if x % i == 0: return 0 return 1 print((sum(p(int(eval(input())) * 2 + 1) for _ in [0] * int(eval(input())))))
false
14.285714
[ "-a = 0", "-for _ in [0] * int(eval(input())):", "- n = int(eval(input()))", "- for i in range(1, int(n**0.5) + 1):", "- if (n - i) % (2 * i + 1) == 0:", "- break", "- else:", "- a += 1", "-print(a)", "+def p(x):", "+ if x % 2 == 0:", "+ return 0", ...
false
0.040605
0.040936
0.991906
[ "s969151431", "s036304941" ]