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
u359358631
p02718
python
s603269715
s435290887
87
76
61,912
61,392
Accepted
Accepted
12.64
def main(): n, m = list(map(int, input().split())) a_lst = list(map(int, input().split())) total = sum(a_lst) cnt = 0 for a in a_lst: if a >= total / (4 * m): cnt += 1 if cnt >= m: ans = "Yes" else: ans = "No" print(ans) if __nam...
def main(): n, m = list(map(int, input().split())) a_lst = list(map(int, input().split())) total = sum(a_lst) cnt = 0 for a in a_lst: if a * 4 * m >= total: cnt += 1 if cnt >= m: ans = "Yes" else: ans = "No" print(ans) if __name_...
20
20
345
343
def main(): n, m = list(map(int, input().split())) a_lst = list(map(int, input().split())) total = sum(a_lst) cnt = 0 for a in a_lst: if a >= total / (4 * m): cnt += 1 if cnt >= m: ans = "Yes" else: ans = "No" print(ans) if __name__ == "__main__": ...
def main(): n, m = list(map(int, input().split())) a_lst = list(map(int, input().split())) total = sum(a_lst) cnt = 0 for a in a_lst: if a * 4 * m >= total: cnt += 1 if cnt >= m: ans = "Yes" else: ans = "No" print(ans) if __name__ == "__main__": ...
false
0
[ "- if a >= total / (4 * m):", "+ if a * 4 * m >= total:" ]
false
0.034907
0.035384
0.98653
[ "s603269715", "s435290887" ]
u145231176
p03608
python
s758540155
s470044655
562
355
78,680
84,556
Accepted
Accepted
36.83
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
82
80
2,011
2,063
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
false
2.439024
[ "-import heapq", "+from heapq import heapify, heappop, heappush", "-from fractions import gcd", "-import copy", "-from itertools import permutations", "-from operator import mul", "+from copy import deepcopy", "+from itertools import combinations, permutations, product", "+from operator import mul, ...
false
0.087795
0.05182
1.694217
[ "s758540155", "s470044655" ]
u165447384
p02271
python
s401874427
s514870935
16,620
50
5,640
5,932
Accepted
Accepted
99.7
n = int(eval(input())) A = list(map(int,input().split())) m = int(eval(input())) B = list(map(int,input().split())) def solve2(x,y): if x==n: S[y] = 1 else: solve2(x+1,y) if y+A[x] < 2001: solve2(x+1,y+A[x]) S = [0 for i in range(2001)] solve2(0,...
n = int(eval(input())) A = list(map(int,input().split())) m = int(eval(input())) B = list(map(int,input().split())) T = [[0]*2001 for i in range(n)] T[0][0] = 1 T[0][A[0]] = 1 for i in range(1,n): for j in range(2001): T[i][j] = T[i-1][j] if (j - A[i] >=0) and (T[i-1][j-A[i]] == 1): ...
37
21
746
440
n = int(eval(input())) A = list(map(int, input().split())) m = int(eval(input())) B = list(map(int, input().split())) def solve2(x, y): if x == n: S[y] = 1 else: solve2(x + 1, y) if y + A[x] < 2001: solve2(x + 1, y + A[x]) S = [0 for i in range(2001)] solve2(0, 0) def s...
n = int(eval(input())) A = list(map(int, input().split())) m = int(eval(input())) B = list(map(int, input().split())) T = [[0] * 2001 for i in range(n)] T[0][0] = 1 T[0][A[0]] = 1 for i in range(1, n): for j in range(2001): T[i][j] = T[i - 1][j] if (j - A[i] >= 0) and (T[i - 1][j - A[i]] == 1): ...
false
43.243243
[ "-", "-", "-def solve2(x, y):", "- if x == n:", "- S[y] = 1", "+T = [[0] * 2001 for i in range(n)]", "+T[0][0] = 1", "+T[0][A[0]] = 1", "+for i in range(1, n):", "+ for j in range(2001):", "+ T[i][j] = T[i - 1][j]", "+ if (j - A[i] >= 0) and (T[i - 1][j - A[i]] == 1)...
false
0.05208
0.058471
0.890692
[ "s401874427", "s514870935" ]
u077898957
p03352
python
s653263344
s590891785
21
18
2,940
2,940
Accepted
Accepted
14.29
x = int(eval(input())) bp = 0 for i in range(x): for j in range(9): if((i+1)**(j+2)<=x): bp = max(bp,(i+1)**(j+2)) print(bp)
import math x=int(eval(input())) a=int(math.sqrt(x)//1) ans=1 for i in range(1,a+1): for j in range(2,a+1): if i**j<=x: ans=max(ans,i**j) print(ans)
7
10
149
177
x = int(eval(input())) bp = 0 for i in range(x): for j in range(9): if (i + 1) ** (j + 2) <= x: bp = max(bp, (i + 1) ** (j + 2)) print(bp)
import math x = int(eval(input())) a = int(math.sqrt(x) // 1) ans = 1 for i in range(1, a + 1): for j in range(2, a + 1): if i**j <= x: ans = max(ans, i**j) print(ans)
false
30
[ "+import math", "+", "-bp = 0", "-for i in range(x):", "- for j in range(9):", "- if (i + 1) ** (j + 2) <= x:", "- bp = max(bp, (i + 1) ** (j + 2))", "-print(bp)", "+a = int(math.sqrt(x) // 1)", "+ans = 1", "+for i in range(1, a + 1):", "+ for j in range(2, a + 1):", ...
false
0.045058
0.04855
0.928074
[ "s653263344", "s590891785" ]
u977389981
p03262
python
s979618459
s181283550
154
123
14,224
14,252
Accepted
Accepted
20.13
n, x = list(map(int, input().split())) X = list(map(int, input().split())) X.sort(reverse=True) D = [] for i in range(len(X)): dist = abs(x - X[i]) D.append(dist) def gcd(i, j): while j != 0: i, j = j, i % j return i for i in range(len(D) - 1): D[i + 1] = gcd(D[i], D[i + 1]...
n, x = list(map(int, input().split())) city = list(map(int, input().split())) D = [] for i in range(n): dis = abs(x - city[i]) D.append(dis) def gdc(x, y): if x%y == 0: return y x, y = y, x%y return gdc(x, y) for i in range(n-1): D[i + 1] = gdc(D[i], D[i + 1]) pr...
18
18
331
324
n, x = list(map(int, input().split())) X = list(map(int, input().split())) X.sort(reverse=True) D = [] for i in range(len(X)): dist = abs(x - X[i]) D.append(dist) def gcd(i, j): while j != 0: i, j = j, i % j return i for i in range(len(D) - 1): D[i + 1] = gcd(D[i], D[i + 1]) print((D[-1]...
n, x = list(map(int, input().split())) city = list(map(int, input().split())) D = [] for i in range(n): dis = abs(x - city[i]) D.append(dis) def gdc(x, y): if x % y == 0: return y x, y = y, x % y return gdc(x, y) for i in range(n - 1): D[i + 1] = gdc(D[i], D[i + 1]) print((D[-1]))
false
0
[ "-X = list(map(int, input().split()))", "-X.sort(reverse=True)", "+city = list(map(int, input().split()))", "-for i in range(len(X)):", "- dist = abs(x - X[i])", "- D.append(dist)", "+for i in range(n):", "+ dis = abs(x - city[i])", "+ D.append(dis)", "-def gcd(i, j):", "- while j...
false
0.039245
0.04479
0.876209
[ "s979618459", "s181283550" ]
u546285759
p00341
python
s820496292
s641249280
30
20
7,684
7,636
Accepted
Accepted
33.33
e= sorted(list(map(int, input().split()))) print(("yes" if len(set(e[:4]))==len(set(e[4:8]))==len(set(e[8:]))==1 else "no"))
e = sorted(map(int, input().split())) print(("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no"))
2
2
123
124
e = sorted(list(map(int, input().split()))) print(("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no"))
e = sorted(map(int, input().split())) print(("yes" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else "no"))
false
0
[ "-e = sorted(list(map(int, input().split())))", "+e = sorted(map(int, input().split()))" ]
false
0.043038
0.03769
1.141894
[ "s820496292", "s641249280" ]
u678167152
p03623
python
s903483254
s011581283
172
17
38,384
2,940
Accepted
Accepted
90.12
x, a, b = list(map(int, input().split())) ans = 'A' if abs(x-a)>abs(x-b): ans='B' print(ans) #print(*ans, sep='\n')
A, B, C = list(map(int, input().split())) def check(): if abs(B-A)<abs(C-A): return 'A' return 'B' print((check()))
7
6
119
128
x, a, b = list(map(int, input().split())) ans = "A" if abs(x - a) > abs(x - b): ans = "B" print(ans) # print(*ans, sep='\n')
A, B, C = list(map(int, input().split())) def check(): if abs(B - A) < abs(C - A): return "A" return "B" print((check()))
false
14.285714
[ "-x, a, b = list(map(int, input().split()))", "-ans = \"A\"", "-if abs(x - a) > abs(x - b):", "- ans = \"B\"", "-print(ans)", "-# print(*ans, sep='\\n')", "+A, B, C = list(map(int, input().split()))", "+", "+", "+def check():", "+ if abs(B - A) < abs(C - A):", "+ return \"A\"", ...
false
0.03852
0.038124
1.01039
[ "s903483254", "s011581283" ]
u163907160
p04045
python
s129021065
s849023036
400
219
12,420
12,384
Accepted
Accepted
45.25
import collections import numpy as np import sys sys.setrecursionlimit(10000000) import copy #N=int(input()) N,K=list(map(int,input().split())) D=list(map(int,input().split())) for i in range(N,100000): t=set(map(int,list(str(i)))) temp=D+list(t) temp2=set(temp) if len(temp)==len(temp2): ...
import collections import numpy as np import sys sys.setrecursionlimit(10000000) import copy #N=int(input()) N,K=list(map(int,input().split())) D=set(eval(input())) while len(set(str(N))&D)>0: N+=1 print(N)
17
11
390
209
import collections import numpy as np import sys sys.setrecursionlimit(10000000) import copy # N=int(input()) N, K = list(map(int, input().split())) D = list(map(int, input().split())) for i in range(N, 100000): t = set(map(int, list(str(i)))) temp = D + list(t) temp2 = set(temp) if len(temp) == len(t...
import collections import numpy as np import sys sys.setrecursionlimit(10000000) import copy # N=int(input()) N, K = list(map(int, input().split())) D = set(eval(input())) while len(set(str(N)) & D) > 0: N += 1 print(N)
false
35.294118
[ "-D = list(map(int, input().split()))", "-for i in range(N, 100000):", "- t = set(map(int, list(str(i))))", "- temp = D + list(t)", "- temp2 = set(temp)", "- if len(temp) == len(temp2):", "- # print(temp)", "- # print(temp2)", "- print(i)", "- exit()", "+D...
false
0.102402
0.082398
1.242762
[ "s129021065", "s849023036" ]
u391589398
p03150
python
s710588747
s790771992
99
64
70,720
64,224
Accepted
Accepted
35.35
import re S = eval(input()) k = 'keyence' for i in range(0, len(k)+1): rs = '^' + k[:i] + '.*' + k[i:] + '$' if re.match(rs, S) is not None: print('YES') break else: print('NO')
S = eval(input()) ans = False for i in range(0, len(S)): for j in range(len(S)-i+1): ns = S[:j] + S[j+i:] if ns == 'keyence': ans = True break if ans: break print(('YES' if ans else 'NO'))
11
11
211
247
import re S = eval(input()) k = "keyence" for i in range(0, len(k) + 1): rs = "^" + k[:i] + ".*" + k[i:] + "$" if re.match(rs, S) is not None: print("YES") break else: print("NO")
S = eval(input()) ans = False for i in range(0, len(S)): for j in range(len(S) - i + 1): ns = S[:j] + S[j + i :] if ns == "keyence": ans = True break if ans: break print(("YES" if ans else "NO"))
false
0
[ "-import re", "-", "-k = \"keyence\"", "-for i in range(0, len(k) + 1):", "- rs = \"^\" + k[:i] + \".*\" + k[i:] + \"$\"", "- if re.match(rs, S) is not None:", "- print(\"YES\")", "+ans = False", "+for i in range(0, len(S)):", "+ for j in range(len(S) - i + 1):", "+ ns = S...
false
0.046089
0.132764
0.347149
[ "s710588747", "s790771992" ]
u777923818
p03504
python
s491405332
s342981568
1,547
524
27,956
19,540
Accepted
Accepted
66.13
def inpl(): return tuple(map(int, input().split())) N, C = inpl() P = sorted([inpl() for _ in range(N)]) R = [[[-1, 0, -1]] for _ in range(30)] for s, t, c in P: i = 0 # 連続録画を探す sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][1] <= s] if sr: R[min(sr)].append([s, t, c]) ...
# -*- coding: utf-8 -*- from itertools import accumulate def inpl(): return tuple(map(int, input().split())) N, C = inpl() P = [[] for _ in range(C)] for _ in range(N): s, t, c = inpl() P[c-1].append((2*s, 2*t)) S = [0 for _ in range(2*10**5 + 3)] for p in P: if len(p) == 0: continu...
22
29
531
606
def inpl(): return tuple(map(int, input().split())) N, C = inpl() P = sorted([inpl() for _ in range(N)]) R = [[[-1, 0, -1]] for _ in range(30)] for s, t, c in P: i = 0 # 連続録画を探す sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][1] <= s] if sr: R[min(sr)].append([s, t, c]) els...
# -*- coding: utf-8 -*- from itertools import accumulate def inpl(): return tuple(map(int, input().split())) N, C = inpl() P = [[] for _ in range(C)] for _ in range(N): s, t, c = inpl() P[c - 1].append((2 * s, 2 * t)) S = [0 for _ in range(2 * 10**5 + 3)] for p in P: if len(p) == 0: continue...
false
24.137931
[ "+# -*- coding: utf-8 -*-", "+from itertools import accumulate", "+", "+", "-P = sorted([inpl() for _ in range(N)])", "-R = [[[-1, 0, -1]] for _ in range(30)]", "-for s, t, c in P:", "- i = 0", "- # 連続録画を探す", "- sr = [i for i in range(30) if R[i][-1][2] == c and R[i][-1][1] <= s]", "- ...
false
0.095082
0.136066
0.698791
[ "s491405332", "s342981568" ]
u580697892
p02819
python
s485567276
s820957774
168
17
14,032
3,060
Accepted
Accepted
89.88
# coding: utf-8 from bisect import bisect_left def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False r...
# coding: utf-8 def elatostenes(x): for i in range(2, int(x ** 0.5)+1): if x % i == 0: return False return True X = int(eval(input())) while True: if elatostenes(X): print(X) exit() else: X += 1
16
14
443
262
# coding: utf-8 from bisect import bisect_left def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return [i ...
# coding: utf-8 def elatostenes(x): for i in range(2, int(x**0.5) + 1): if x % i == 0: return False return True X = int(eval(input())) while True: if elatostenes(X): print(X) exit() else: X += 1
false
12.5
[ "-from bisect import bisect_left", "-", "-", "-def primes(n):", "- is_prime = [True] * (n + 1)", "- is_prime[0] = False", "- is_prime[1] = False", "- for i in range(2, int(n**0.5) + 1):", "- if not is_prime[i]:", "- continue", "- for j in range(i * 2, n + 1, ...
false
0.600942
0.041318
14.544329
[ "s485567276", "s820957774" ]
u102461423
p03160
python
s776023061
s037551676
168
129
14,104
11,588
Accepted
Accepted
23.21
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) N = int(eval(input())) H = [int(x) for x in input().split()] dp = [0] * N dp[1] = abs(H[1]-H[0]) for i in range(2,N): dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]) for k in [1,2]) answer = dp[-1] print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,*H = list(map(int,read().split())) dp = [0]*N for i in range(1,N): x = dp[i-1] + abs(H[i]-H[i-1]) if i > 1: y = dp[i-2] + abs(H[i]-H[i-2]) if x>y: x=y dp[i] = ...
14
17
285
349
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) N = int(eval(input())) H = [int(x) for x in input().split()] dp = [0] * N dp[1] = abs(H[1] - H[0]) for i in range(2, N): dp[i] = min(dp[i - k] + abs(H[i] - H[i - k]) for k in [1, 2]) answer = dp[-1] print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *H = list(map(int, read().split())) dp = [0] * N for i in range(1, N): x = dp[i - 1] + abs(H[i] - H[i - 1]) if i > 1: y = dp[i - 2] + abs(H[i] - H[i - 2]) if x > y: ...
false
17.647059
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-N = int(eval(input()))", "-H = [int(x) for x in input().split()]", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "+N, *H = list(map(int, read().split()))", "-dp[1]...
false
0.038046
0.036694
1.036837
[ "s776023061", "s037551676" ]
u977389981
p03379
python
s251817549
s844207758
354
326
26,180
26,772
Accepted
Accepted
7.91
n = int(eval(input())) A = list(map(int, input().split())) sortA = sorted(A) for i in range(n): if A[i] <= sortA[(n // 2) - 1]: print((sortA[n // 2])) else: print((sortA[(n // 2) - 1]))
n = int(eval(input())) A = [int(i) for i in input().split()] sortA = sorted(A) mid = sortA[n//2 - 1] midnext = sortA[n//2] for i in range(n): if A[i] <= mid: print(midnext) else: print(mid)
9
12
208
220
n = int(eval(input())) A = list(map(int, input().split())) sortA = sorted(A) for i in range(n): if A[i] <= sortA[(n // 2) - 1]: print((sortA[n // 2])) else: print((sortA[(n // 2) - 1]))
n = int(eval(input())) A = [int(i) for i in input().split()] sortA = sorted(A) mid = sortA[n // 2 - 1] midnext = sortA[n // 2] for i in range(n): if A[i] <= mid: print(midnext) else: print(mid)
false
25
[ "-A = list(map(int, input().split()))", "+A = [int(i) for i in input().split()]", "+mid = sortA[n // 2 - 1]", "+midnext = sortA[n // 2]", "- if A[i] <= sortA[(n // 2) - 1]:", "- print((sortA[n // 2]))", "+ if A[i] <= mid:", "+ print(midnext)", "- print((sortA[(n // 2) - 1]...
false
0.078098
0.042802
1.824627
[ "s251817549", "s844207758" ]
u094191970
p03273
python
s730169558
s549861519
20
18
3,064
3,188
Accepted
Accepted
10
h,w=list(map(int,input().split())) a=[list(eval(input())) for i in range(h)] for i in range(h): if '#' not in a[i]: a[i]=['n']*w for i in range(w): l=[a[j][i] for j in range(len(a))] if '#' not in l: for k in range(len(a)): a[k][i]='n' for i in a: l=[x for x in i if...
h,w=list(map(int,input().split())) a=[list(eval(input())) for i in range(h)] l1=[] for i in a: if '#' in i: l1.append(i) l2=[] for i in zip(*l1): if '#' in i: l2.append(i) l3=list(zip(*l2)) for i in l3: print((''.join(i)))
14
14
354
244
h, w = list(map(int, input().split())) a = [list(eval(input())) for i in range(h)] for i in range(h): if "#" not in a[i]: a[i] = ["n"] * w for i in range(w): l = [a[j][i] for j in range(len(a))] if "#" not in l: for k in range(len(a)): a[k][i] = "n" for i in a: l = [x for x i...
h, w = list(map(int, input().split())) a = [list(eval(input())) for i in range(h)] l1 = [] for i in a: if "#" in i: l1.append(i) l2 = [] for i in zip(*l1): if "#" in i: l2.append(i) l3 = list(zip(*l2)) for i in l3: print(("".join(i)))
false
0
[ "-for i in range(h):", "- if \"#\" not in a[i]:", "- a[i] = [\"n\"] * w", "-for i in range(w):", "- l = [a[j][i] for j in range(len(a))]", "- if \"#\" not in l:", "- for k in range(len(a)):", "- a[k][i] = \"n\"", "+l1 = []", "- l = [x for x in i if x != \"n\"]"...
false
0.007314
0.112374
0.065084
[ "s730169558", "s549861519" ]
u427344224
p03166
python
s789728072
s285140323
762
674
125,180
125,180
Accepted
Accepted
11.55
import sys sys.setrecursionlimit(10 ** 8) N, M = list(map(int, input().split())) graph = [dict() for _ in range(N)] for i in range(M): x, y = list(map(int, input().split())) graph[y - 1][x - 1] = 1 dp = [0 for _ in range(N)] def dfs(u): if dp[u] != 0: return dp[u] max_dis ...
import sys sys.setrecursionlimit(10 ** 8) N, M = list(map(int, input().split())) graph = [dict() for _ in range(N)] for i in range(M): x, y = list(map(int, input().split())) graph[y - 1][x - 1] = 1 dp = [0 for _ in range(N)] def dfs(u): if dp[u] != 0 or len(graph[u]) == 0: retu...
29
29
504
526
import sys sys.setrecursionlimit(10**8) N, M = list(map(int, input().split())) graph = [dict() for _ in range(N)] for i in range(M): x, y = list(map(int, input().split())) graph[y - 1][x - 1] = 1 dp = [0 for _ in range(N)] def dfs(u): if dp[u] != 0: return dp[u] max_dis = 0 for f in list(...
import sys sys.setrecursionlimit(10**8) N, M = list(map(int, input().split())) graph = [dict() for _ in range(N)] for i in range(M): x, y = list(map(int, input().split())) graph[y - 1][x - 1] = 1 dp = [0 for _ in range(N)] def dfs(u): if dp[u] != 0 or len(graph[u]) == 0: return dp[u] max_dis ...
false
0
[ "- if dp[u] != 0:", "+ if dp[u] != 0 or len(graph[u]) == 0:" ]
false
0.038645
0.043243
0.893684
[ "s789728072", "s285140323" ]
u079022693
p02821
python
s987898608
s439661307
412
311
55,356
56,248
Accepted
Accepted
24.51
N, M = list(map(int, input().split())) a = [10**18] + sorted(map(int, input().split()), reverse=True) def solve(x): count = 0 j = N for i in range(1, N+1): while a[i] + a[j] < x: j -= 1 count += j return count left, right = 0, 10**18 while left < right - 1: m...
N, M = list(map(int, input().split())) a = [2*10**5+1] + sorted(map(int, input().split()), reverse=True) def solve(x): count = 0 j = N for i in range(1, N+1): while a[i] + a[j] < x: j -= 1 count += j return count left, right = 0, 2*10**5+1 while left < right - 1: ...
40
39
648
652
N, M = list(map(int, input().split())) a = [10**18] + sorted(map(int, input().split()), reverse=True) def solve(x): count = 0 j = N for i in range(1, N + 1): while a[i] + a[j] < x: j -= 1 count += j return count left, right = 0, 10**18 while left < right - 1: mid = (l...
N, M = list(map(int, input().split())) a = [2 * 10**5 + 1] + sorted(map(int, input().split()), reverse=True) def solve(x): count = 0 j = N for i in range(1, N + 1): while a[i] + a[j] < x: j -= 1 count += j return count left, right = 0, 2 * 10**5 + 1 while left < right - 1...
false
2.5
[ "-a = [10**18] + sorted(map(int, input().split()), reverse=True)", "+a = [2 * 10**5 + 1] + sorted(map(int, input().split()), reverse=True)", "-left, right = 0, 10**18", "+left, right = 0, 2 * 10**5 + 1" ]
false
0.071099
0.037264
1.907996
[ "s987898608", "s439661307" ]
u188827677
p03993
python
s429904984
s046943120
92
77
24,176
20,488
Accepted
Accepted
16.3
n = int(eval(input())) a = list(map(int, input().split())) d = {} ans = 0 for i in range(n): if a[i] in d and d[a[i]] == i+1: ans += 1 else: d[i+1] = a[i] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) d = {} ans = 0 for num,i in enumerate(a,1): if i not in d: d[num] = i else: if d[i] == num: ans += 1 print(ans)
9
10
172
182
n = int(eval(input())) a = list(map(int, input().split())) d = {} ans = 0 for i in range(n): if a[i] in d and d[a[i]] == i + 1: ans += 1 else: d[i + 1] = a[i] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) d = {} ans = 0 for num, i in enumerate(a, 1): if i not in d: d[num] = i else: if d[i] == num: ans += 1 print(ans)
false
10
[ "-for i in range(n):", "- if a[i] in d and d[a[i]] == i + 1:", "- ans += 1", "+for num, i in enumerate(a, 1):", "+ if i not in d:", "+ d[num] = i", "- d[i + 1] = a[i]", "+ if d[i] == num:", "+ ans += 1" ]
false
0.106785
0.155319
0.687523
[ "s429904984", "s046943120" ]
u330314953
p03814
python
s365398828
s793440580
89
61
3,512
3,516
Accepted
Accepted
31.46
s = str(eval(input())) a = 199999 z = 0 for i in range(len(s)): if s[i] == "A": a = min(a,i) elif s[i] == "Z": z = max(z,i) print((z - a + 1))
s = str(eval(input())) z = 0 a = s.find("A") for i in range(len(s)): if s[i] == "Z": z = max(z,i) print((z - a + 1))
13
11
175
129
s = str(eval(input())) a = 199999 z = 0 for i in range(len(s)): if s[i] == "A": a = min(a, i) elif s[i] == "Z": z = max(z, i) print((z - a + 1))
s = str(eval(input())) z = 0 a = s.find("A") for i in range(len(s)): if s[i] == "Z": z = max(z, i) print((z - a + 1))
false
15.384615
[ "-a = 199999", "+a = s.find(\"A\")", "- if s[i] == \"A\":", "- a = min(a, i)", "- elif s[i] == \"Z\":", "+ if s[i] == \"Z\":" ]
false
0.036848
0.036757
1.002482
[ "s365398828", "s793440580" ]
u647999897
p02720
python
s248182072
s585081602
266
136
53,872
80,736
Accepted
Accepted
48.87
def solve(): K = int(eval(input())) all = [] for i in range(1,10): dfs(1,i,all) all.sort() print((all[K-1])) def dfs(d, val, all): all.append(val) if d == 10: return for j in [-1,0,1]: add = val % 10 + j if 0 <= add <= 9: ...
def solve(): K = int(eval(input())) lunluns = [] for i in range(1,10): dfs(1,i,lunluns) lunluns.sort() print((lunluns[K-1])) def dfs(d,now,lunluns): lunluns.append(now) if d == 10: return for i in [-1,0,1]: add = now % 10 + i ...
22
23
392
424
def solve(): K = int(eval(input())) all = [] for i in range(1, 10): dfs(1, i, all) all.sort() print((all[K - 1])) def dfs(d, val, all): all.append(val) if d == 10: return for j in [-1, 0, 1]: add = val % 10 + j if 0 <= add <= 9: dfs(d + 1, va...
def solve(): K = int(eval(input())) lunluns = [] for i in range(1, 10): dfs(1, i, lunluns) lunluns.sort() print((lunluns[K - 1])) def dfs(d, now, lunluns): lunluns.append(now) if d == 10: return for i in [-1, 0, 1]: add = now % 10 + i if 0 <= add <= 9: ...
false
4.347826
[ "- all = []", "+ lunluns = []", "- dfs(1, i, all)", "- all.sort()", "- print((all[K - 1]))", "+ dfs(1, i, lunluns)", "+ lunluns.sort()", "+ print((lunluns[K - 1]))", "-def dfs(d, val, all):", "- all.append(val)", "+def dfs(d, now, lunluns):", "+ lunluns.ap...
false
0.193276
0.005874
32.904299
[ "s248182072", "s585081602" ]
u123745130
p02602
python
s423601191
s172976984
192
153
31,684
31,720
Accepted
Accepted
20.31
n,k=list(map(int,input().split())) lst_1=list(map(int,input().split())) # print(lst_1) lst_2=[] for i in range(n-k): temp=1 temp=lst_1[i+k]/lst_1[i] lst_2.append(temp) for i in lst_2: if i>1: print("Yes") else:print("No")
n,k=list(map(int,input().split())) lst_1=list(map(int,input().split())) # print(lst_1) for i in range(n-k): if(lst_1[i+k]>lst_1[i]): print("Yes") else:print("No")
12
7
255
178
n, k = list(map(int, input().split())) lst_1 = list(map(int, input().split())) # print(lst_1) lst_2 = [] for i in range(n - k): temp = 1 temp = lst_1[i + k] / lst_1[i] lst_2.append(temp) for i in lst_2: if i > 1: print("Yes") else: print("No")
n, k = list(map(int, input().split())) lst_1 = list(map(int, input().split())) # print(lst_1) for i in range(n - k): if lst_1[i + k] > lst_1[i]: print("Yes") else: print("No")
false
41.666667
[ "-lst_2 = []", "- temp = 1", "- temp = lst_1[i + k] / lst_1[i]", "- lst_2.append(temp)", "-for i in lst_2:", "- if i > 1:", "+ if lst_1[i + k] > lst_1[i]:" ]
false
0.043969
0.044734
0.982897
[ "s423601191", "s172976984" ]
u515775940
p02747
python
s500823804
s919950391
20
17
3,188
2,940
Accepted
Accepted
15
import re s = str(eval(input())) flag = True s_array = s.split('hi') for list in s_array: res = re.match('[a-z0-9]', list) if res and len(res.group()) > 0 : flag = False break if flag: print('Yes') else: print('No')
s = eval(input()) replaced_str = s.replace('hi','') if len(replaced_str) > 0: print('No') else: print('Yes')
18
6
283
111
import re s = str(eval(input())) flag = True s_array = s.split("hi") for list in s_array: res = re.match("[a-z0-9]", list) if res and len(res.group()) > 0: flag = False break if flag: print("Yes") else: print("No")
s = eval(input()) replaced_str = s.replace("hi", "") if len(replaced_str) > 0: print("No") else: print("Yes")
false
66.666667
[ "-import re", "-", "-s = str(eval(input()))", "-flag = True", "-s_array = s.split(\"hi\")", "-for list in s_array:", "- res = re.match(\"[a-z0-9]\", list)", "- if res and len(res.group()) > 0:", "- flag = False", "- break", "-if flag:", "+s = eval(input())", "+replaced_st...
false
0.059394
0.054415
1.091508
[ "s500823804", "s919950391" ]
u957167787
p02996
python
s530601325
s577204404
1,096
988
61,536
55,260
Accepted
Accepted
9.85
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N)] AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート AB = sorted(AB, key=lambda x: x[1]) t = 0 for i in range(N): if t <= AB[i][1] - AB[i][0]: # B-A以下のとき t += AB[i][0] continue else: print('N...
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N)] # AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート AB = sorted(AB, key=lambda x: x[1]) # B-Aが同じ値の時はBが小さい順に並び替え t = 0 for i in range(N): if t <= AB[i][1] - AB[i][0]: # B-A以下のとき t += AB[i][0] continue ...
20
20
421
447
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N)] AB = sorted(AB, key=lambda x: x[1] - x[0]) # B-Aが小さい順にソート AB = sorted(AB, key=lambda x: x[1]) t = 0 for i in range(N): if t <= AB[i][1] - AB[i][0]: # B-A以下のとき t += AB[i][0] continue else: print("No") ...
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(N)] # AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート AB = sorted(AB, key=lambda x: x[1]) # B-Aが同じ値の時はBが小さい順に並び替え t = 0 for i in range(N): if t <= AB[i][1] - AB[i][0]: # B-A以下のとき t += AB[i][0] continue else: ...
false
0
[ "-AB = sorted(AB, key=lambda x: x[1] - x[0]) # B-Aが小さい順にソート", "-AB = sorted(AB, key=lambda x: x[1])", "+# AB = sorted(AB, key=lambda x: x[1]-x[0]) # B-Aが小さい順にソート", "+AB = sorted(AB, key=lambda x: x[1]) # B-Aが同じ値の時はBが小さい順に並び替え" ]
false
0.066223
0.037545
1.763823
[ "s530601325", "s577204404" ]
u057668615
p02659
python
s105793018
s047755055
23
20
9,096
9,120
Accepted
Accepted
13.04
A, B = list(map(float, input().split())) #print(A*B) print((int((int(A+0.5)*int(B*100+0.5))//100)))
A, B = list(map(float, input().split())) #print(A*B) print((int((int(A)*int(B*100+0.5))//100)))
3
3
100
96
A, B = list(map(float, input().split())) # print(A*B) print((int((int(A + 0.5) * int(B * 100 + 0.5)) // 100)))
A, B = list(map(float, input().split())) # print(A*B) print((int((int(A) * int(B * 100 + 0.5)) // 100)))
false
0
[ "-print((int((int(A + 0.5) * int(B * 100 + 0.5)) // 100)))", "+print((int((int(A) * int(B * 100 + 0.5)) // 100)))" ]
false
0.036399
0.036666
0.992729
[ "s105793018", "s047755055" ]
u968166680
p02685
python
s057857567
s658643604
660
297
32,496
32,564
Accepted
Accepted
55
from sys import stdin, setrecursionlimit from math import factorial setrecursionlimit(10 ** 9) INF = 1 << 60 def input(): return stdin.readline().strip() def main(): N, M, K = list(map(int, input().split())) MOD = 998244353 fac = [0] * (N + 10) finv = [0] * (N + 10) inv = [0...
from sys import stdin, setrecursionlimit from math import factorial setrecursionlimit(10 ** 9) INF = 1 << 60 def input(): return stdin.readline().strip() def main(): N, M, K = list(map(int, input().split())) MOD = 998244353 COM_MAX = N fac, finv, inv = [0] * (COM_MAX + 1), [0] ...
43
47
947
1,042
from sys import stdin, setrecursionlimit from math import factorial setrecursionlimit(10**9) INF = 1 << 60 def input(): return stdin.readline().strip() def main(): N, M, K = list(map(int, input().split())) MOD = 998244353 fac = [0] * (N + 10) finv = [0] * (N + 10) inv = [0] * (N + 10) f...
from sys import stdin, setrecursionlimit from math import factorial setrecursionlimit(10**9) INF = 1 << 60 def input(): return stdin.readline().strip() def main(): N, M, K = list(map(int, input().split())) MOD = 998244353 COM_MAX = N fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0...
false
8.510638
[ "- fac = [0] * (N + 10)", "- finv = [0] * (N + 10)", "- inv = [0] * (N + 10)", "+ COM_MAX = N", "+ fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)", "- for i in range(2, N + 2):", "+ for i in range(2, COM_MAX + 1):", "- def COM(n, k):", "+ de...
false
0.167649
0.157721
1.062948
[ "s057857567", "s658643604" ]
u670180528
p02889
python
s156946871
s783887172
1,541
436
40,860
40,888
Accepted
Accepted
71.71
from scipy.sparse import* f=csgraph.floyd_warshall I=9e9 n,m,l,*t=list(map(int,open(0).read().split())) d=eval('[I]*-~n,'*-~n) for a,b,c in zip(*[iter(t[:m*3])]*3):d[a][b]=c d=f(d,0) d[d>l]=I d[d<I]=1 d=f(d) for i in zip(*[iter(t[m*3+1:])]*2): print(((I>d[i])*int(d[i])-1))
def main(): from scipy.sparse.csgraph import floyd_warshall import numpy as np n, m, l, *L = list(map(int, open(0).read().split())) abc = L[:3 * m]; st = L[3 * m + 1:] r = [[float("inf")] * n for _ in range(n)] for a, b, c in zip(*[iter(abc)] * 3): if c <= l: r[a - 1][b - 1] = c fw = floyd_warshall(r...
12
23
277
560
from scipy.sparse import * f = csgraph.floyd_warshall I = 9e9 n, m, l, *t = list(map(int, open(0).read().split())) d = eval("[I]*-~n," * -~n) for a, b, c in zip(*[iter(t[: m * 3])] * 3): d[a][b] = c d = f(d, 0) d[d > l] = I d[d < I] = 1 d = f(d) for i in zip(*[iter(t[m * 3 + 1 :])] * 2): print(((I > d[i]) * in...
def main(): from scipy.sparse.csgraph import floyd_warshall import numpy as np n, m, l, *L = list(map(int, open(0).read().split())) abc = L[: 3 * m] st = L[3 * m + 1 :] r = [[float("inf")] * n for _ in range(n)] for a, b, c in zip(*[iter(abc)] * 3): if c <= l: r[a - 1][b...
false
47.826087
[ "-from scipy.sparse import *", "+def main():", "+ from scipy.sparse.csgraph import floyd_warshall", "+ import numpy as np", "-f = csgraph.floyd_warshall", "-I = 9e9", "-n, m, l, *t = list(map(int, open(0).read().split()))", "-d = eval(\"[I]*-~n,\" * -~n)", "-for a, b, c in zip(*[iter(t[: m * 3...
false
0.609441
1.002941
0.607654
[ "s156946871", "s783887172" ]
u657913472
p03473
python
s343477773
s298492442
17
11
2,940
2,572
Accepted
Accepted
35.29
print((48-int(eval(input()))))
print(48-eval(input()))
1
1
22
16
print((48 - int(eval(input()))))
print(48 - eval(input()))
false
0
[ "-print((48 - int(eval(input()))))", "+print(48 - eval(input()))" ]
false
0.037968
0.03989
0.951818
[ "s343477773", "s298492442" ]
u863442865
p02762
python
s812197157
s988658732
1,119
902
122,528
95,776
Accepted
Accepted
19.39
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby #from itertools import product from bisect import bisec...
#木作って終わり、問題文難しい # def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby #from itertools import product fr...
72
69
1,904
1,688
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby # from itertools import product from bisect import bisect_l...
# 木作って終わり、問題文難しい # def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque # from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby # from itertools import product from bis...
false
4.166667
[ "+# 木作って終わり、問題文難しい", "+#", "- def members(par, x, n):", "- root = find(par, x)", "- return [i for i in range(n) if find(par, i) == root]", "-", "- block = [[] for _ in range(n)] # 頂点数, 場合によって変える", "- for _ in range(k):", "- a, b = list(map(int, input().split()))", "-...
false
0.116047
0.069387
1.672448
[ "s812197157", "s988658732" ]
u607563136
p02861
python
s172031615
s625009444
327
295
13,860
13,780
Accepted
Accepted
9.79
from itertools import permutations import math n = int(eval(input())) x,y = [],[] for _ in range(n): x_, y_ =list(map(int,input().split())) x.append(x_) y.append(y_) c = list(permutations([i for i in range(1,n+1)],n)) g = [[-1]*(n+1) for _ in range(n+1)] sum = 0 for ci in (c): tmp = 0 ...
from itertools import permutations import math n = int(eval(input())) x,y = [],[] for _ in range(n): x_, y_ =list(map(int,input().split())) x.append(x_) y.append(y_) c = list(permutations([i for i in range(1,n+1)],n)) sum = 0 for ci in (c): tmp = 0 for i in range(len(ci)-1): ...
23
17
584
452
from itertools import permutations import math n = int(eval(input())) x, y = [], [] for _ in range(n): x_, y_ = list(map(int, input().split())) x.append(x_) y.append(y_) c = list(permutations([i for i in range(1, n + 1)], n)) g = [[-1] * (n + 1) for _ in range(n + 1)] sum = 0 for ci in c: tmp = 0 f...
from itertools import permutations import math n = int(eval(input())) x, y = [], [] for _ in range(n): x_, y_ = list(map(int, input().split())) x.append(x_) y.append(y_) c = list(permutations([i for i in range(1, n + 1)], n)) sum = 0 for ci in c: tmp = 0 for i in range(len(ci) - 1): tmp += ...
false
26.086957
[ "-g = [[-1] * (n + 1) for _ in range(n + 1)]", "- if g[ci[i]][ci[i + 1]] == -1:", "- tmp += math.sqrt(", "- (x[ci[i] - 1] - x[ci[i + 1] - 1]) ** 2", "- + (y[ci[i] - 1] - y[ci[i + 1] - 1]) ** 2", "- )", "- else:", "- tmp += g[...
false
0.045539
0.049374
0.922333
[ "s172031615", "s625009444" ]
u912237403
p00124
python
s942741603
s388894440
20
10
4,240
4,236
Accepted
Accepted
50
f=0 while 1: n=eval(input()) if n==0: break if f>0: print() N=[""]*n C=[0]*n for i in range(n): s=input() p=s.index(" ") N[i]=s[:p] a,b,c=list(map(int,s[p+1:].split(" "))) C[i]=(i,a*3+c) C=sorted(C,key=lambda x:(-x[1],x[0])) for e in C: print("".join([N[e[0]],",",str(e[...
f=0 while 1: n=eval(input()) if n==0: break if f>0: print() C=[()]*n for i in range(n): s=input() p=s.index(" ") a,b,c=list(map(int,s[p+1:].split(" "))) C[i]=(i,a*3+c,s[:p]) C=sorted(C,key=lambda x:(-x[1],x[0])) for e in C: print(e[2]+","+str(e[1])) f=1
16
14
322
287
f = 0 while 1: n = eval(input()) if n == 0: break if f > 0: print() N = [""] * n C = [0] * n for i in range(n): s = input() p = s.index(" ") N[i] = s[:p] a, b, c = list(map(int, s[p + 1 :].split(" "))) C[i] = (i, a * 3 + c) C = sorted(C...
f = 0 while 1: n = eval(input()) if n == 0: break if f > 0: print() C = [()] * n for i in range(n): s = input() p = s.index(" ") a, b, c = list(map(int, s[p + 1 :].split(" "))) C[i] = (i, a * 3 + c, s[:p]) C = sorted(C, key=lambda x: (-x[1], x[0]))...
false
12.5
[ "- N = [\"\"] * n", "- C = [0] * n", "+ C = [()] * n", "- N[i] = s[:p]", "- C[i] = (i, a * 3 + c)", "+ C[i] = (i, a * 3 + c, s[:p])", "- print(\"\".join([N[e[0]], \",\", str(e[1])]))", "+ print(e[2] + \",\" + str(e[1]))" ]
false
0.040167
0.041558
0.966532
[ "s942741603", "s388894440" ]
u761320129
p03608
python
s635835945
s018403455
560
309
72,152
77,892
Accepted
Accepted
44.82
N,M,R = list(map(int,input().split())) rs = list(map(int,input().split())) ABC = [tuple(map(int,input().split())) for i in range(M)] INF = float('inf') d = [[INF]*N for _ in range(N)] for a,b,c in ABC: a,b = a-1,b-1 d[a][b] = d[b][a] = c for i in range(N): d[i][i] = 0 for k in range(N): f...
N,M,R = list(map(int,input().split())) R = list(map(int,input().split())) ABC = [tuple(map(int,input().split())) for i in range(M)] INF = float('inf') d = [[INF]*N for _ in range(N)] for i in range(N): d[i][i] = 0 for a,b,c in ABC: a,b = a-1,b-1 d[a][b] = d[b][a] = c for k in range(N): fo...
26
25
616
595
N, M, R = list(map(int, input().split())) rs = list(map(int, input().split())) ABC = [tuple(map(int, input().split())) for i in range(M)] INF = float("inf") d = [[INF] * N for _ in range(N)] for a, b, c in ABC: a, b = a - 1, b - 1 d[a][b] = d[b][a] = c for i in range(N): d[i][i] = 0 for k in range(N): f...
N, M, R = list(map(int, input().split())) R = list(map(int, input().split())) ABC = [tuple(map(int, input().split())) for i in range(M)] INF = float("inf") d = [[INF] * N for _ in range(N)] for i in range(N): d[i][i] = 0 for a, b, c in ABC: a, b = a - 1, b - 1 d[a][b] = d[b][a] = c for k in range(N): fo...
false
3.846154
[ "-rs = list(map(int, input().split()))", "+R = list(map(int, input().split()))", "+for i in range(N):", "+ d[i][i] = 0", "-for i in range(N):", "- d[i][i] = 0", "-for ptn in itertools.permutations(rs):", "+for ptn in itertools.permutations(R):", "- a, b = a - 1, b - 1", "- tmp ...
false
0.046486
0.046393
1.002021
[ "s635835945", "s018403455" ]
u699296734
p03721
python
s783865689
s601602577
355
225
27,612
11,568
Accepted
Accepted
36.62
n, k = list(map(int, input().split())) sum_b = 0 ab_list = [] for i in range(n): ab_list.append(list(map(int, input().split()))) ab_list.sort() for i in range(n): a, b = ab_list[i] sum_b += b if sum_b >= k: print(a) break
n, k = list(map(int, input().split())) bucket = [0] * 10 ** 5 for i in range(n): a, b = list(map(int, input().split())) bucket[a - 1] += b sum_b = 0 for i in range(len(bucket)): sum_b += bucket[i] if sum_b >= k: print((i + 1)) break
14
12
263
263
n, k = list(map(int, input().split())) sum_b = 0 ab_list = [] for i in range(n): ab_list.append(list(map(int, input().split()))) ab_list.sort() for i in range(n): a, b = ab_list[i] sum_b += b if sum_b >= k: print(a) break
n, k = list(map(int, input().split())) bucket = [0] * 10**5 for i in range(n): a, b = list(map(int, input().split())) bucket[a - 1] += b sum_b = 0 for i in range(len(bucket)): sum_b += bucket[i] if sum_b >= k: print((i + 1)) break
false
14.285714
[ "+bucket = [0] * 10**5", "+for i in range(n):", "+ a, b = list(map(int, input().split()))", "+ bucket[a - 1] += b", "-ab_list = []", "-for i in range(n):", "- ab_list.append(list(map(int, input().split())))", "-ab_list.sort()", "-for i in range(n):", "- a, b = ab_list[i]", "- sum_...
false
0.036191
0.038402
0.94244
[ "s783865689", "s601602577" ]
u057109575
p02744
python
s719775470
s344309660
447
166
56,920
78,192
Accepted
Accepted
62.86
N = int(eval(input())) def dfs(x): if len(x) == N: s = "".join(chr(v + ord("a")) for v in x) print(s) return val = max(x) for i in range(val + 2): x.append(i) dfs(x) x.pop() dfs([0])
N = int(eval(input())) def func(x): if len(x) == N: print(("".join(x))) return last = ord(max(x)) - ord("a") + 1 if x else 0 for i in range(min(26, last) + 1): x.append(chr(ord("a") + i)) func(x) x.pop() func([])
16
17
256
279
N = int(eval(input())) def dfs(x): if len(x) == N: s = "".join(chr(v + ord("a")) for v in x) print(s) return val = max(x) for i in range(val + 2): x.append(i) dfs(x) x.pop() dfs([0])
N = int(eval(input())) def func(x): if len(x) == N: print(("".join(x))) return last = ord(max(x)) - ord("a") + 1 if x else 0 for i in range(min(26, last) + 1): x.append(chr(ord("a") + i)) func(x) x.pop() func([])
false
5.882353
[ "-def dfs(x):", "+def func(x):", "- s = \"\".join(chr(v + ord(\"a\")) for v in x)", "- print(s)", "+ print((\"\".join(x)))", "- val = max(x)", "- for i in range(val + 2):", "- x.append(i)", "- dfs(x)", "+ last = ord(max(x)) - ord(\"a\") + 1 if x else 0",...
false
0.106215
0.043598
2.436265
[ "s719775470", "s344309660" ]
u348805958
p02659
python
s200295349
s546973770
26
24
9,920
9,172
Accepted
Accepted
7.69
#!python3 iim = lambda: list(map(int, input().rstrip().split())) from decimal import Decimal def resolve(): a, b = input().split() a = int(a); b = int(b.replace(".", "")) print((a*b//100)) if __name__ == "__main__": resolve()
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def resolve(): a, b = input().split() a = int(a); b = int(b.replace(".", "")) print((a*b//100)) if __name__ == "__main__": resolve()
13
12
250
221
#!python3 iim = lambda: list(map(int, input().rstrip().split())) from decimal import Decimal def resolve(): a, b = input().split() a = int(a) b = int(b.replace(".", "")) print((a * b // 100)) if __name__ == "__main__": resolve()
#!python3 iim = lambda: list(map(int, input().rstrip().split())) def resolve(): a, b = input().split() a = int(a) b = int(b.replace(".", "")) print((a * b // 100)) if __name__ == "__main__": resolve()
false
7.692308
[ "-from decimal import Decimal" ]
false
0.076485
0.043262
1.767934
[ "s200295349", "s546973770" ]
u729939940
p02773
python
s202670820
s660323050
564
338
38,092
38,468
Accepted
Accepted
40.07
import sys N = int(eval(input())) S = (str(x) for x in sys.stdin.read().split()) cnt = {} for s in S: if cnt.get(s): cnt[s] = cnt[s] + 1 else: cnt[s] = 1 max_cnt = max(cnt.values()) keys = [k for k, v in list(cnt.items()) if v == max_cnt] for k in sorted(keys): print(k)
import sys from collections import Counter N = int(eval(input())) S = (str(x) for x in sys.stdin.read().split()) cnt = Counter(s for s in S) max_cnt = max(cnt.values()) keys = [k for k, v in list(cnt.items()) if v == max_cnt] print(("\n".join(sorted(keys))))
13
8
284
251
import sys N = int(eval(input())) S = (str(x) for x in sys.stdin.read().split()) cnt = {} for s in S: if cnt.get(s): cnt[s] = cnt[s] + 1 else: cnt[s] = 1 max_cnt = max(cnt.values()) keys = [k for k, v in list(cnt.items()) if v == max_cnt] for k in sorted(keys): print(k)
import sys from collections import Counter N = int(eval(input())) S = (str(x) for x in sys.stdin.read().split()) cnt = Counter(s for s in S) max_cnt = max(cnt.values()) keys = [k for k, v in list(cnt.items()) if v == max_cnt] print(("\n".join(sorted(keys))))
false
38.461538
[ "+from collections import Counter", "-cnt = {}", "-for s in S:", "- if cnt.get(s):", "- cnt[s] = cnt[s] + 1", "- else:", "- cnt[s] = 1", "+cnt = Counter(s for s in S)", "-for k in sorted(keys):", "- print(k)", "+print((\"\\n\".join(sorted(keys))))" ]
false
0.037982
0.105362
0.360492
[ "s202670820", "s660323050" ]
u871934301
p02689
python
s404384463
s866620392
408
301
29,524
20,032
Accepted
Accepted
26.23
N,M=list(map(int,input().split())) H=list(map(int,input().split())) l=[[]*i for i in range(N)] for i in range(M): A,B=list(map(int,input().split())) l[A-1].append(B) l[B-1].append(A) ans=0 for j in range(N): if all(H[elem-1]<H[j] for elem in l[j])==True: ans+=1 print(ans) ...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) A = [0] * N for i in range(M): a, b = list(map(int, input().split())) A[a-1] = max(A[a-1], H[b-1]) A[b-1] = max(A[b-1], H[a-1]) res = sum([H[i] > A[i] for i in range(N)]) print(res)
35
11
350
268
N, M = list(map(int, input().split())) H = list(map(int, input().split())) l = [[] * i for i in range(N)] for i in range(M): A, B = list(map(int, input().split())) l[A - 1].append(B) l[B - 1].append(A) ans = 0 for j in range(N): if all(H[elem - 1] < H[j] for elem in l[j]) == True: ans += 1 print...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) A = [0] * N for i in range(M): a, b = list(map(int, input().split())) A[a - 1] = max(A[a - 1], H[b - 1]) A[b - 1] = max(A[b - 1], H[a - 1]) res = sum([H[i] > A[i] for i in range(N)]) print(res)
false
68.571429
[ "-l = [[] * i for i in range(N)]", "+A = [0] * N", "- A, B = list(map(int, input().split()))", "- l[A - 1].append(B)", "- l[B - 1].append(A)", "-ans = 0", "-for j in range(N):", "- if all(H[elem - 1] < H[j] for elem in l[j]) == True:", "- ans += 1", "-print(ans)", "+ a, b =...
false
0.03771
0.101867
0.370193
[ "s404384463", "s866620392" ]
u000623733
p03048
python
s529676500
s238716642
1,850
546
2,940
120,156
Accepted
Accepted
70.49
R, G, B, N = list(map(int, input().split())) count = 0 for i in range(N // R + 1): n = N - R * i for j in range(n // G + 1): if (n - G*j) >= 0 and (n - G*j) % B == 0: count += 1 print(count)
R, G ,B, N = list(map(int, input().split())) tmp = [R, G, B] tmp.sort() R, G, B = tmp[2], tmp[1], tmp[0] num_R = N // R + 1 num_G = N // G RG = [[N - R*i for i in range(num_R)]] for j in range(num_G): RG.append([RG[-1][i] - G for i in range(num_R)]) check = lambda x: 0 if x < 0 else 1 if x == 0 e...
10
23
224
456
R, G, B, N = list(map(int, input().split())) count = 0 for i in range(N // R + 1): n = N - R * i for j in range(n // G + 1): if (n - G * j) >= 0 and (n - G * j) % B == 0: count += 1 print(count)
R, G, B, N = list(map(int, input().split())) tmp = [R, G, B] tmp.sort() R, G, B = tmp[2], tmp[1], tmp[0] num_R = N // R + 1 num_G = N // G RG = [[N - R * i for i in range(num_R)]] for j in range(num_G): RG.append([RG[-1][i] - G for i in range(num_R)]) check = lambda x: 0 if x < 0 else 1 if x == 0 else 1 if x % B ==...
false
56.521739
[ "+tmp = [R, G, B]", "+tmp.sort()", "+R, G, B = tmp[2], tmp[1], tmp[0]", "+num_R = N // R + 1", "+num_G = N // G", "+RG = [[N - R * i for i in range(num_R)]]", "+for j in range(num_G):", "+ RG.append([RG[-1][i] - G for i in range(num_R)])", "+check = lambda x: 0 if x < 0 else 1 if x == 0 else 1 if...
false
0.079615
0.064598
1.232458
[ "s529676500", "s238716642" ]
u131984977
p02420
python
s056042467
s188561509
30
20
6,724
7,648
Accepted
Accepted
33.33
while True: text = eval(input()) if text == '-': break count = int(eval(input())) for c in range(count): index = int(eval(input())) text = text[index:] + text[:index] print(text)
while True: s = eval(input()) if s == '-': break m = int(eval(input())) for mi in range(m): h = int(eval(input())) s = s[h:] + s[:h] print(s)
11
11
216
179
while True: text = eval(input()) if text == "-": break count = int(eval(input())) for c in range(count): index = int(eval(input())) text = text[index:] + text[:index] print(text)
while True: s = eval(input()) if s == "-": break m = int(eval(input())) for mi in range(m): h = int(eval(input())) s = s[h:] + s[:h] print(s)
false
0
[ "- text = eval(input())", "- if text == \"-\":", "+ s = eval(input())", "+ if s == \"-\":", "- count = int(eval(input()))", "- for c in range(count):", "- index = int(eval(input()))", "- text = text[index:] + text[:index]", "- print(text)", "+ m = int(eval(inp...
false
0.044192
0.04557
0.969754
[ "s056042467", "s188561509" ]
u250583425
p03127
python
s288265362
s268363377
805
80
54,216
16,276
Accepted
Accepted
90.06
import sys from functools import lru_cache def input(): return sys.stdin.readline().rstrip() @lru_cache(maxsize=None) def gcd(m, n): if n == 0: return m else: return gcd(n, m % n) def main(): _ = int(eval(input())) A = tuple(map(int, input().split())) ans = A[0] ...
import sys from fractions import gcd def input(): return sys.stdin.readline().rstrip() def main(): _ = int(eval(input())) A = tuple(map(int, input().split())) ans = A[0] for a in A[1:]: ans = gcd(ans, a) print(ans) if __name__ == '__main__': main()
22
15
421
296
import sys from functools import lru_cache def input(): return sys.stdin.readline().rstrip() @lru_cache(maxsize=None) def gcd(m, n): if n == 0: return m else: return gcd(n, m % n) def main(): _ = int(eval(input())) A = tuple(map(int, input().split())) ans = A[0] for a i...
import sys from fractions import gcd def input(): return sys.stdin.readline().rstrip() def main(): _ = int(eval(input())) A = tuple(map(int, input().split())) ans = A[0] for a in A[1:]: ans = gcd(ans, a) print(ans) if __name__ == "__main__": main()
false
31.818182
[ "-from functools import lru_cache", "+from fractions import gcd", "-", "-", "-@lru_cache(maxsize=None)", "-def gcd(m, n):", "- if n == 0:", "- return m", "- else:", "- return gcd(n, m % n)" ]
false
0.055545
0.0578
0.961
[ "s288265362", "s268363377" ]
u644907318
p03050
python
s250278837
s081391919
74
68
64,480
64,084
Accepted
Accepted
8.11
N = int(eval(input())) A = [] for i in range(1,int(N**0.5)+1): if N%i==0: a = i b = N//i if a>b: a,b = b,a if 0<a<b-1: A.append(b-1) print((sum(A)))
N = int(eval(input())) cnt = 0 if N>2: for x in range(2,int(N**0.5)+1): if N%x==0: y = N//x if N//(x-1)==N%(x-1): cnt += x-1 if N//(y-1)==N%(y-1): cnt += y-1 cnt += N-1 print(cnt)
11
12
210
268
N = int(eval(input())) A = [] for i in range(1, int(N**0.5) + 1): if N % i == 0: a = i b = N // i if a > b: a, b = b, a if 0 < a < b - 1: A.append(b - 1) print((sum(A)))
N = int(eval(input())) cnt = 0 if N > 2: for x in range(2, int(N**0.5) + 1): if N % x == 0: y = N // x if N // (x - 1) == N % (x - 1): cnt += x - 1 if N // (y - 1) == N % (y - 1): cnt += y - 1 cnt += N - 1 print(cnt)
false
8.333333
[ "-A = []", "-for i in range(1, int(N**0.5) + 1):", "- if N % i == 0:", "- a = i", "- b = N // i", "- if a > b:", "- a, b = b, a", "- if 0 < a < b - 1:", "- A.append(b - 1)", "-print((sum(A)))", "+cnt = 0", "+if N > 2:", "+ for x in rang...
false
0.206871
0.394404
0.524515
[ "s250278837", "s081391919" ]
u775681539
p02803
python
s438202819
s066018411
697
580
3,436
3,316
Accepted
Accepted
16.79
#python3 from collections import deque from collections import namedtuple Vertex = namedtuple('Vertex', ['i', 'j']) INF = int(1e10) di = [1, 0, -1, 0] dj = [0, 1, 0, -1] def main(): h, w = list(map(int, input().split())) maze = [eval(input()) for i in range(h)] ans = 0 for si in range...
#python3 from collections import deque INF = int(1e20) di = [1, 0, -1, 0] dj = [0, 1, 0, -1] def main(): h, w = list(map(int, input().split())) maze = [eval(input()) for i in range(h)] ans = 0 for si in range(h): for sj in range(w): if maze[si][sj] == '#': ...
50
46
1,344
1,257
# python3 from collections import deque from collections import namedtuple Vertex = namedtuple("Vertex", ["i", "j"]) INF = int(1e10) di = [1, 0, -1, 0] dj = [0, 1, 0, -1] def main(): h, w = list(map(int, input().split())) maze = [eval(input()) for i in range(h)] ans = 0 for si in range(h): fo...
# python3 from collections import deque INF = int(1e20) di = [1, 0, -1, 0] dj = [0, 1, 0, -1] def main(): h, w = list(map(int, input().split())) maze = [eval(input()) for i in range(h)] ans = 0 for si in range(h): for sj in range(w): if maze[si][sj] == "#": continu...
false
8
[ "-from collections import namedtuple", "-Vertex = namedtuple(\"Vertex\", [\"i\", \"j\"])", "-INF = int(1e10)", "+INF = int(1e20)", "- q.append(Vertex(i, j))", "+ q.append((i, j))" ]
false
0.036985
0.038238
0.967232
[ "s438202819", "s066018411" ]
u914007790
p00006
python
s265429640
s912364006
30
20
7,356
7,348
Accepted
Accepted
33.33
a = list(input()) for i in a[::-1]: print(i, end="") print()
a = list(eval(input())) a.reverse() print((''.join(a)))
4
3
67
49
a = list(input()) for i in a[::-1]: print(i, end="") print()
a = list(eval(input())) a.reverse() print(("".join(a)))
false
25
[ "-a = list(input())", "-for i in a[::-1]:", "- print(i, end=\"\")", "-print()", "+a = list(eval(input()))", "+a.reverse()", "+print((\"\".join(a)))" ]
false
0.044958
0.041455
1.08452
[ "s265429640", "s912364006" ]
u012694084
p03147
python
s323384425
s345163519
24
18
3,064
2,940
Accepted
Accepted
25
N = int(eval(input())) h = list(map(int, input().split())) current_h = [0] * N c = 0 l = 0 while True: escape_loop = False while current_h[l] == h[l]: if l + 1 < N: l += 1 else: escape_loop = True break if escape_loop: break ...
N = int(eval(input())) h = list(map(int, input().split())) s = h[0] for i in range(1, N): s += max(0, h[i] - h[i - 1]) print(s)
30
8
532
135
N = int(eval(input())) h = list(map(int, input().split())) current_h = [0] * N c = 0 l = 0 while True: escape_loop = False while current_h[l] == h[l]: if l + 1 < N: l += 1 else: escape_loop = True break if escape_loop: break r = l while Tru...
N = int(eval(input())) h = list(map(int, input().split())) s = h[0] for i in range(1, N): s += max(0, h[i] - h[i - 1]) print(s)
false
73.333333
[ "-current_h = [0] * N", "-c = 0", "-l = 0", "-while True:", "- escape_loop = False", "- while current_h[l] == h[l]:", "- if l + 1 < N:", "- l += 1", "- else:", "- escape_loop = True", "- break", "- if escape_loop:", "- break", ...
false
0.033026
0.034248
0.964314
[ "s323384425", "s345163519" ]
u454557108
p03565
python
s075022517
s131748754
20
17
3,064
3,064
Accepted
Accepted
15
import sys s = eval(input()) t = eval(input()) tl = len(t) ; sl = len(s) c = 1 for i in range(sl,tl-1,-1) : st = s[i-tl:i] c = 0 for j in range(tl) : if st[j] == '?' : continue elif st[j] != '?' and st[j] == t[j] : continue c = 1 break if c == 0 : s = s[:i-t...
import sys s = eval(input()) t = eval(input()) tl = len(t) ; sl = len(s) if tl > sl : print('UNRESTORABLE') sys.exit() for i in range(sl,tl-1,-1) : st = s[i-tl:i] c = 0 for j in range(tl) : if st[j] == '?' : continue elif st[j] != '?' and st[j] == t[j] : continue ...
26
29
412
460
import sys s = eval(input()) t = eval(input()) tl = len(t) sl = len(s) c = 1 for i in range(sl, tl - 1, -1): st = s[i - tl : i] c = 0 for j in range(tl): if st[j] == "?": continue elif st[j] != "?" and st[j] == t[j]: continue c = 1 break if c == 0...
import sys s = eval(input()) t = eval(input()) tl = len(t) sl = len(s) if tl > sl: print("UNRESTORABLE") sys.exit() for i in range(sl, tl - 1, -1): st = s[i - tl : i] c = 0 for j in range(tl): if st[j] == "?": continue elif st[j] != "?" and st[j] == t[j]: con...
false
10.344828
[ "-c = 1", "+if tl > sl:", "+ print(\"UNRESTORABLE\")", "+ sys.exit()" ]
false
0.041085
0.041411
0.992129
[ "s075022517", "s131748754" ]
u019685451
p02584
python
s368297586
s123119017
31
27
9,184
9,080
Accepted
Accepted
12.9
from math import floor def solve(X, D, lb, ub): # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int) ts = [ lb, ub, max(min(floor(-X / D), ub), lb), max(min(floor(-X / D) + 1, ub), lb), ] return min([abs(X + t * D) for t in ts]) X, K, D = list(map(int...
from math import floor def solve(X, D, lb, ub): # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int) ts = [ lb, ub, max(min(floor(-X / D), ub), lb), max(min(floor(-X / D) + 1, ub), lb), ] return min([abs(X + t * D) for t in ts]) X, K, D = list(map(int, i...
27
22
742
578
from math import floor def solve(X, D, lb, ub): # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int) ts = [ lb, ub, max(min(floor(-X / D), ub), lb), max(min(floor(-X / D) + 1, ub), lb), ] return min([abs(X + t * D) for t in ts]) X, K, D = list(map(int, input().spl...
from math import floor def solve(X, D, lb, ub): # min abs(X + t * D) (lb <= t <= ub) (lb, ub, t are int) ts = [ lb, ub, max(min(floor(-X / D), ub), lb), max(min(floor(-X / D) + 1, ub), lb), ] return min([abs(X + t * D) for t in ts]) X, K, D = list(map(int, input().spl...
false
18.518519
[ "-y1 = X - K * D", "-y2 = X + K * D", "-if (y1 > 0 and y2 > 0) or (y1 < 0 and y2 < 0): # same sign", "- print((min(abs(y1), abs(y2))))", "+if K % 2 == 0:", "+ ans = solve(X, D * 2, -(K // 2), +(K // 2))", "- if K % 2 == 0:", "- ans = solve(X, D * 2, -(K // 2), +(K // 2))", "- els...
false
0.037632
0.040501
0.929151
[ "s368297586", "s123119017" ]
u169200126
p02659
python
s066087266
s654859963
25
23
9,104
9,044
Accepted
Accepted
8
a, b = list(map(float, input().split())) b = float(b)*1000 b = int(b) c = int(a)*b//1000 print((int(c)))
a, b = list(map(float, input().split())) b = float(b)*1000 b = int(b) c = (int(a)*b)//1000 print((int(c)))
6
6
103
105
a, b = list(map(float, input().split())) b = float(b) * 1000 b = int(b) c = int(a) * b // 1000 print((int(c)))
a, b = list(map(float, input().split())) b = float(b) * 1000 b = int(b) c = (int(a) * b) // 1000 print((int(c)))
false
0
[ "-c = int(a) * b // 1000", "+c = (int(a) * b) // 1000" ]
false
0.056286
0.097086
0.579749
[ "s066087266", "s654859963" ]
u983918956
p03700
python
s288088731
s314598955
1,252
1,142
11,036
7,076
Accepted
Accepted
8.79
N,A,B = list(map(int,input().split())) H = [int(eval(input())) for _ in range(N)] d = A-B def judge(k): cnt = 0 remain = [max(h-k*B,0) for h in H] for r in remain: cnt += -(-r // d) if cnt <= k: return True else: return False def biserch(ok,ng,judge): w...
import sys input = sys.stdin.readline N,A,B = list(map(int,input().split())) H = [int(eval(input())) for _ in range(N)] def judge(k): cnt = 0 for h in H: cnt += -(-(max(h-k*B,0))//(A-B)) if cnt <= k: return True return False def biserch(ok,ng,judge): while abs(ok-ng...
26
25
499
486
N, A, B = list(map(int, input().split())) H = [int(eval(input())) for _ in range(N)] d = A - B def judge(k): cnt = 0 remain = [max(h - k * B, 0) for h in H] for r in remain: cnt += -(-r // d) if cnt <= k: return True else: return False def biserch(ok, ng, judge): whil...
import sys input = sys.stdin.readline N, A, B = list(map(int, input().split())) H = [int(eval(input())) for _ in range(N)] def judge(k): cnt = 0 for h in H: cnt += -(-(max(h - k * B, 0)) // (A - B)) if cnt <= k: return True return False def biserch(ok, ng, judge): while abs(ok -...
false
3.846154
[ "+import sys", "+", "+input = sys.stdin.readline", "-d = A - B", "- remain = [max(h - k * B, 0) for h in H]", "- for r in remain:", "- cnt += -(-r // d)", "+ for h in H:", "+ cnt += -(-(max(h - k * B, 0)) // (A - B))", "- else:", "- return False", "+ return ...
false
0.047182
0.048033
0.982271
[ "s288088731", "s314598955" ]
u079022693
p02947
python
s914449165
s545473545
408
212
18,732
19,460
Accepted
Accepted
48.04
N=int(eval(input())) s=[0]*N essence={} count=0 for i in range(N): s_i="".join(sorted(eval(input()))) s[i]=s_i if s[i] not in essence: essence.setdefault(s[i],1) else: count+=essence[s[i]] essence[s[i]]+=1 print(count)
from sys import stdin def nC2(n): return n*(n-1)//2 def main(): #入力 readline=stdin.readline N=int(readline()) s=[""]*N for i in range(N): a=list(readline().strip()) a.sort() s[i]="".join(a) d=dict() for i in range(N): if s[i] not in d: ...
14
32
250
556
N = int(eval(input())) s = [0] * N essence = {} count = 0 for i in range(N): s_i = "".join(sorted(eval(input()))) s[i] = s_i if s[i] not in essence: essence.setdefault(s[i], 1) else: count += essence[s[i]] essence[s[i]] += 1 print(count)
from sys import stdin def nC2(n): return n * (n - 1) // 2 def main(): # 入力 readline = stdin.readline N = int(readline()) s = [""] * N for i in range(N): a = list(readline().strip()) a.sort() s[i] = "".join(a) d = dict() for i in range(N): if s[i] not i...
false
56.25
[ "-N = int(eval(input()))", "-s = [0] * N", "-essence = {}", "-count = 0", "-for i in range(N):", "- s_i = \"\".join(sorted(eval(input())))", "- s[i] = s_i", "- if s[i] not in essence:", "- essence.setdefault(s[i], 1)", "- else:", "- count += essence[s[i]]", "- ...
false
0.039586
0.039822
0.994062
[ "s914449165", "s545473545" ]
u071680334
p02720
python
s229579859
s587221625
825
648
3,064
22,688
Accepted
Accepted
21.45
def func(n): s = str(n) L = len(s) for i in reversed(list(range(L-1))): x = int(s[i]) y = int(s[i+1]) if abs(x-y) > 1: buf = 10**(L-(i+1)-1) if x > y: return int(s[:i] + str(x) + str(x-1)) * buf else: retu...
import queue def main(): k = int(eval(input())) q = queue.Queue() for i in range(1, 10): q.put(str(i)) ans = "" for i in range(1, k+1): ans = q.get() if i < k: p = int(ans[-1]) if p == 0: q.put(ans + "0") ...
31
25
699
585
def func(n): s = str(n) L = len(s) for i in reversed(list(range(L - 1))): x = int(s[i]) y = int(s[i + 1]) if abs(x - y) > 1: buf = 10 ** (L - (i + 1) - 1) if x > y: return int(s[:i] + str(x) + str(x - 1)) * buf else: ...
import queue def main(): k = int(eval(input())) q = queue.Queue() for i in range(1, 10): q.put(str(i)) ans = "" for i in range(1, k + 1): ans = q.get() if i < k: p = int(ans[-1]) if p == 0: q.put(ans + "0") q.put(ans +...
false
19.354839
[ "-def func(n):", "- s = str(n)", "- L = len(s)", "- for i in reversed(list(range(L - 1))):", "- x = int(s[i])", "- y = int(s[i + 1])", "- if abs(x - y) > 1:", "- buf = 10 ** (L - (i + 1) - 1)", "- if x > y:", "- return int(s[:i] + ...
false
0.10283
0.182927
0.562136
[ "s229579859", "s587221625" ]
u163320134
p03201
python
s400829273
s356958722
570
454
109,780
109,652
Accepted
Accepted
20.35
n=int(eval(input())) arr=list(map(int,input().split())) arr=sorted(arr,reverse=True) dic={} for val in arr: if val not in dic: dic[val]=1 else: dic[val]+=1 ans=0 for val in arr: for i in range(40): if val<2**i: persuit=2**i break if persuit-val==val: if val in dic: ...
from bisect import bisect_left n=int(eval(input())) arr=list(map(int,input().split())) arr=sorted(arr,reverse=True) dic={} for val in arr: if val not in dic: dic[val]=1 else: dic[val]+=1 arr2=[] for i in range(40): arr2.append(2**i) ans=0 for val in arr: pos=bisect_left(arr2,val) if ...
38
44
735
854
n = int(eval(input())) arr = list(map(int, input().split())) arr = sorted(arr, reverse=True) dic = {} for val in arr: if val not in dic: dic[val] = 1 else: dic[val] += 1 ans = 0 for val in arr: for i in range(40): if val < 2**i: persuit = 2**i break if per...
from bisect import bisect_left n = int(eval(input())) arr = list(map(int, input().split())) arr = sorted(arr, reverse=True) dic = {} for val in arr: if val not in dic: dic[val] = 1 else: dic[val] += 1 arr2 = [] for i in range(40): arr2.append(2**i) ans = 0 for val in arr: pos = bisect_l...
false
13.636364
[ "+from bisect import bisect_left", "+", "+arr2 = []", "+for i in range(40):", "+ arr2.append(2**i)", "- for i in range(40):", "- if val < 2**i:", "- persuit = 2**i", "- break", "+ pos = bisect_left(arr2, val)", "+ if val == arr2[pos]:", "+ persui...
false
0.112892
0.046791
2.412698
[ "s400829273", "s356958722" ]
u952708174
p03674
python
s540020607
s693537432
258
232
27,912
31,568
Accepted
Accepted
10.08
def d_11(MOD=10**9 + 7): from collections import Counter class Combination(object): """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb""" __slots__ = ["mod", "factorial", "inverse"] def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7): ...
def d_11(MOD=10**9 + 7): class Combination(object): """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb""" __slots__ = ["mod", "factorial", "inverse"] def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7): fac, inv = [1], [] fac...
39
39
1,376
1,315
def d_11(MOD=10**9 + 7): from collections import Counter class Combination(object): """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb""" __slots__ = ["mod", "factorial", "inverse"] def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7): fac...
def d_11(MOD=10**9 + 7): class Combination(object): """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb""" __slots__ = ["mod", "factorial", "inverse"] def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7): fac, inv = [1], [] fac_appen...
false
0
[ "- from collections import Counter", "-", "- c = Counter(A).most_common(n=1)[0][0] # 重複した整数の値を取得", "- index = [i for i, x in enumerate(A) if x == c] # 重複した整数のインデックス", "- left = index[0] + 1", "- right = index[1] + 1", "- comb = Combination(N + 1).combination", "- ans = [", "- ...
false
0.04486
0.066027
0.679418
[ "s540020607", "s693537432" ]
u077291787
p03959
python
s077527684
s237569503
88
78
19,136
19,140
Accepted
Accepted
11.36
# code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists from bisect import bisect_left as bs def main(): """ /----\ <- xi (= yi) / \--\ / \ xi yi 0 ~ xi / xi ~ yi / yi+1 ~ N-1 """ N = int(eval(input())) T = tuple(map(int, input().split())) ...
# code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists from bisect import bisect_left as bs def main(): """ /----\ <- xi (= yi) / \--\ / \ xi yi 0 ~ xi / xi ~ yi / yi+1 ~ N-1 """ N = int(eval(input())) T = tuple(map(int, input().split())) ...
44
39
1,124
1,018
# code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists from bisect import bisect_left as bs def main(): """ /----\ <- xi (= yi) / \--\ / \ xi yi 0 ~ xi / xi ~ yi / yi+1 ~ N-1 """ N = int(eval(input())) T = tuple(map(int, input().split())) A = tuple(map...
# code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists from bisect import bisect_left as bs def main(): """ /----\ <- xi (= yi) / \--\ / \ xi yi 0 ~ xi / xi ~ yi / yi+1 ~ N-1 """ N = int(eval(input())) T = tuple(map(int, input().split())) A = tuple(map...
false
11.363636
[ "- x, y, xi, yi = 0, 0, 0, 0 # max of x, y and the indices", "- for i, t in enumerate(T):", "- if t > x:", "- x, xi = t, i", "- for i, a in enumerate(A):", "- if a >= y:", "- y, yi = a, i", "+ x, y = T[-1], A[0] # max of x, y", "+ xi, yi = T.index...
false
0.049886
0.050221
0.993341
[ "s077527684", "s237569503" ]
u730769327
p03436
python
s155660033
s760159194
235
81
43,240
74,444
Accepted
Accepted
65.53
import queue INF=10**8 r,c=list(map(int,input().split())) #sy,sx=map(int,input().split()) #gy,gx=map(int,input().split()) maze=[eval(input()) for _ in range(r)] d=[[INF for i in range(r)] for _ in range(c)] sx,sy=1,1 gx,gy=r,c cnt=0 for i in range(r): for j in range(c): if maze[i][j]=='.': cnt+...
from collections import deque INF=10**18 h,w=list(map(int,input().split())) a=[eval(input()) for _ in range(h)] d=[[INF for _ in range(w)]for _ in range(h)] dx=[0,1,0,-1] dy=[1,0,-1,0] sx,sy=0,0 gx,gy=h-1,w-1 d[sx][sy]=1 q=deque([(sx,sy)]) while q: x,y=q.popleft() if (x,y)==(gx,gy):break for i in ra...
38
26
728
579
import queue INF = 10**8 r, c = list(map(int, input().split())) # sy,sx=map(int,input().split()) # gy,gx=map(int,input().split()) maze = [eval(input()) for _ in range(r)] d = [[INF for i in range(r)] for _ in range(c)] sx, sy = 1, 1 gx, gy = r, c cnt = 0 for i in range(r): for j in range(c): if maze[i][j] ...
from collections import deque INF = 10**18 h, w = list(map(int, input().split())) a = [eval(input()) for _ in range(h)] d = [[INF for _ in range(w)] for _ in range(h)] dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] sx, sy = 0, 0 gx, gy = h - 1, w - 1 d[sx][sy] = 1 q = deque([(sx, sy)]) while q: x, y = q.popleft() if (x...
false
31.578947
[ "-import queue", "+from collections import deque", "-INF = 10**8", "-r, c = list(map(int, input().split()))", "-# sy,sx=map(int,input().split())", "-# gy,gx=map(int,input().split())", "-maze = [eval(input()) for _ in range(r)]", "-d = [[INF for i in range(r)] for _ in range(c)]", "-sx, sy = 1, 1", ...
false
0.048226
0.046572
1.035509
[ "s155660033", "s760159194" ]
u072717685
p02707
python
s408255942
s519819035
184
118
35,596
31,612
Accepted
Accepted
35.87
from collections import Counter def main(): n = int(eval(input())) a = list(map(int, input().split())) cnt = [0] * n ac = Counter(a) for i in range(n): cnt[i] = ac[i+1] for i2 in range(n): print((cnt[i2])) if __name__ == '__main__': main()
import sys read = sys.stdin.read readlines = sys.stdin.readlines from math import pi def main(): n, *a = map(int, read().split()) cnt = [0] * n for ae in a: cnt[ae-1] += 1 print(*cnt, sep='\n') if __name__ == '__main__': main()
14
13
290
269
from collections import Counter def main(): n = int(eval(input())) a = list(map(int, input().split())) cnt = [0] * n ac = Counter(a) for i in range(n): cnt[i] = ac[i + 1] for i2 in range(n): print((cnt[i2])) if __name__ == "__main__": main()
import sys read = sys.stdin.read readlines = sys.stdin.readlines from math import pi def main(): n, *a = map(int, read().split()) cnt = [0] * n for ae in a: cnt[ae - 1] += 1 print(*cnt, sep="\n") if __name__ == "__main__": main()
false
7.142857
[ "-from collections import Counter", "+import sys", "+", "+read = sys.stdin.read", "+readlines = sys.stdin.readlines", "+from math import pi", "- n = int(eval(input()))", "- a = list(map(int, input().split()))", "+ n, *a = map(int, read().split())", "- ac = Counter(a)", "- for i in...
false
0.038197
0.038603
0.989479
[ "s408255942", "s519819035" ]
u565380863
p03373
python
s617573857
s716250913
103
18
3,064
3,064
Accepted
Accepted
82.52
import sys def input(): return sys.stdin.readline()[:-1] def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def imi(N: int, t: type = int): return [ii(t) for _ in range(N)] def iml(N: int, t: type = int): return [i...
import sys def input(): return sys.stdin.readline()[:-1] def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def imi(N: int, t: type = int): return [ii(t) for _ in range(N)] def iml(N: int, t: type = int): return [i...
30
35
536
561
import sys def input(): return sys.stdin.readline()[:-1] def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def imi(N: int, t: type = int): return [ii(t) for _ in range(N)] def iml(N: int, t: type = int): return [il(t) for _ in range(...
import sys def input(): return sys.stdin.readline()[:-1] def ii(t: type = int): return t(eval(input())) def il(t: type = int): return list(map(t, input().split())) def imi(N: int, t: type = int): return [ii(t) for _ in range(N)] def iml(N: int, t: type = int): return [il(t) for _ in range(...
false
14.285714
[ "-m = A * X + B * Y", "-for i in range(2, 2 * max(X, Y) + 1, 2):", "- tmp = A * max(X - i // 2, 0) + B * max(Y - i // 2, 0) + C * i", "- if tmp < m:", "- m = tmp", "-print(m)", "+if A + B < 2 * C:", "+ print((A * X + B * Y))", "+ exit()", "+p = min(X, Y) * 2 * C", "+n = max(X ...
false
0.070215
0.038027
1.846448
[ "s617573857", "s716250913" ]
u945181840
p03607
python
s314000835
s225286791
207
190
11,884
16,640
Accepted
Accepted
8.21
N = int(eval(input())) A = set([]) for i in range(N): temp = int(eval(input())) if temp not in A: A.add(temp) else: A.remove(temp) print((len(A)))
from collections import Counter N = int(eval(input())) A = [int(eval(input())) for i in range(N)] a = list(Counter(A).values()) a = [i for i in a if i % 2 == 1] print((len(a)))
11
8
172
171
N = int(eval(input())) A = set([]) for i in range(N): temp = int(eval(input())) if temp not in A: A.add(temp) else: A.remove(temp) print((len(A)))
from collections import Counter N = int(eval(input())) A = [int(eval(input())) for i in range(N)] a = list(Counter(A).values()) a = [i for i in a if i % 2 == 1] print((len(a)))
false
27.272727
[ "+from collections import Counter", "+", "-A = set([])", "-for i in range(N):", "- temp = int(eval(input()))", "- if temp not in A:", "- A.add(temp)", "- else:", "- A.remove(temp)", "-print((len(A)))", "+A = [int(eval(input())) for i in range(N)]", "+a = list(Counter(A)....
false
0.122471
0.064324
1.903987
[ "s314000835", "s225286791" ]
u413165887
p03096
python
s538447583
s291459069
835
763
85,668
73,124
Accepted
Accepted
8.62
n = int(eval(input())) c = [int(eval(input())) for _i in range(n)] c.append(-1) dic = {} dp = [0 for _i in range(n+1)] dp[n] = 1 mod = 10**9 +7 for i in range(n): if c[i-1] != c[i]: if c[i] in dic: dp[i] = (dp[i-1] + dic[c[i]])%mod else: dp[i] = dp[i-1] d...
n = int(eval(input())) c = [int(eval(input())) for _i in range(n)] c.append(-1) dic = [-1 for _i in range(10**5 *2 +1)] dp = [0 for _i in range(n+1)] dp[n] = 1 mod = 10**9 +7 for i in range(n): if c[i-1] != c[i]: if dic[c[i]] > 0: dp[i] = (dp[i-1] + dic[c[i]])%mod else: ...
18
18
386
419
n = int(eval(input())) c = [int(eval(input())) for _i in range(n)] c.append(-1) dic = {} dp = [0 for _i in range(n + 1)] dp[n] = 1 mod = 10**9 + 7 for i in range(n): if c[i - 1] != c[i]: if c[i] in dic: dp[i] = (dp[i - 1] + dic[c[i]]) % mod else: dp[i] = dp[i - 1] dic...
n = int(eval(input())) c = [int(eval(input())) for _i in range(n)] c.append(-1) dic = [-1 for _i in range(10**5 * 2 + 1)] dp = [0 for _i in range(n + 1)] dp[n] = 1 mod = 10**9 + 7 for i in range(n): if c[i - 1] != c[i]: if dic[c[i]] > 0: dp[i] = (dp[i - 1] + dic[c[i]]) % mod else: ...
false
0
[ "-dic = {}", "+dic = [-1 for _i in range(10**5 * 2 + 1)]", "- if c[i] in dic:", "+ if dic[c[i]] > 0:" ]
false
0.03977
0.051837
0.767197
[ "s538447583", "s291459069" ]
u969190727
p03253
python
s366068977
s306633287
1,975
180
114,396
18,932
Accepted
Accepted
90.89
import collections import math n,m=list(map(int,input().split())) flag=0 P=[] p=m while flag==0: cur=p for i in range(2,int(p**0.5)+1): if p%i==0: P.append(i) p//=i break if p==cur: P.append(p) flag=1 c=collections.Counter(P) Primes=set(P) def f(i): return math.f...
import sys input=lambda: sys.stdin.readline().rstrip() mod=10**9+7 n,m=list(map(int,input().split())) n_max=2*(10**5+1) F,FI=[0]*(n_max+1),[0]*(n_max+1) F[0],FI[0]=1,1 for i in range(n_max): F[i+1]=(F[i]*(i+1))%mod FI[n_max-1]=pow(F[n_max-1],mod-2,mod) for i in reversed(list(range(n_max-1))): FI[i]=(FI[i...
27
27
470
570
import collections import math n, m = list(map(int, input().split())) flag = 0 P = [] p = m while flag == 0: cur = p for i in range(2, int(p**0.5) + 1): if p % i == 0: P.append(i) p //= i break if p == cur: P.append(p) flag = 1 c = collections.Cou...
import sys input = lambda: sys.stdin.readline().rstrip() mod = 10**9 + 7 n, m = list(map(int, input().split())) n_max = 2 * (10**5 + 1) F, FI = [0] * (n_max + 1), [0] * (n_max + 1) F[0], FI[0] = 1, 1 for i in range(n_max): F[i + 1] = (F[i] * (i + 1)) % mod FI[n_max - 1] = pow(F[n_max - 1], mod - 2, mod) for i in r...
false
0
[ "-import collections", "-import math", "+import sys", "+input = lambda: sys.stdin.readline().rstrip()", "+mod = 10**9 + 7", "-flag = 0", "-P = []", "-p = m", "-while flag == 0:", "- cur = p", "- for i in range(2, int(p**0.5) + 1):", "- if p % i == 0:", "- P.append(i)"...
false
0.191932
0.30784
0.623478
[ "s366068977", "s306633287" ]
u588341295
p03837
python
s954252202
s128380339
647
427
3,444
3,948
Accepted
Accepted
34
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 N, M = list(map(int, input().split())) G = [[float('inf')] * N for i in range(N)] edges = [None] * M for i in range(M): a, b, c = list(map(int, inpu...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in ...
33
56
729
1,568
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10**9) INF = float("inf") MOD = 10**9 + 7 N, M = list(map(int, input().split())) G = [[float("inf")] * N for i in range(N)] edges = [None] * M for i in range(M): a, b, c = list(map(int, input().split())...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in rang...
false
41.071429
[ "+def list2d(a, b, c):", "+ return [[c] * b for i in range(a)]", "+", "+", "+def list3d(a, b, c, d):", "+ return [[[d] * c for j in range(b)] for i in range(a)]", "+", "+", "+def list4d(a, b, c, d, e):", "+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]", "+"...
false
0.049042
0.053486
0.916908
[ "s954252202", "s128380339" ]
u996665352
p03031
python
s424193758
s154648095
36
20
3,064
3,064
Accepted
Accepted
44.44
N,M = list(map(int,input().split())) in_M =[[]]*M for m in range(M): in_M[m] = list(map(int,input().split())) out_M = list(map(int,input().split())) all_on_cnt = 0 for i in range(2**N): switch = [0]*N for j in range(N): if((i>>j) & 1): # iをj回右シフトさせ末尾をみる switch[j] = 1 ...
n,m = list(map(int,input().split())) swi = [] for _ in range(m): k, *sss = list(map(int,input().split())) t = 0 for s in sss: t += 1 << (s-1) swi.append(t) ppp = list(map(int,input().split())) ans = 0 for bit in range(1<<n): for s,p in zip(swi,ppp): t = bit&s c...
23
20
566
424
N, M = list(map(int, input().split())) in_M = [[]] * M for m in range(M): in_M[m] = list(map(int, input().split())) out_M = list(map(int, input().split())) all_on_cnt = 0 for i in range(2**N): switch = [0] * N for j in range(N): if (i >> j) & 1: # iをj回右シフトさせ末尾をみる switch[j] = 1 for j...
n, m = list(map(int, input().split())) swi = [] for _ in range(m): k, *sss = list(map(int, input().split())) t = 0 for s in sss: t += 1 << (s - 1) swi.append(t) ppp = list(map(int, input().split())) ans = 0 for bit in range(1 << n): for s, p in zip(swi, ppp): t = bit & s c = ...
false
13.043478
[ "-N, M = list(map(int, input().split()))", "-in_M = [[]] * M", "-for m in range(M):", "- in_M[m] = list(map(int, input().split()))", "-out_M = list(map(int, input().split()))", "-all_on_cnt = 0", "-for i in range(2**N):", "- switch = [0] * N", "- for j in range(N):", "- if (i >> j)...
false
0.049565
0.04707
1.053016
[ "s424193758", "s154648095" ]
u102461423
p03666
python
s521713773
s293856080
294
126
31,932
42,708
Accepted
Accepted
57.14
import sys input = sys.stdin.readline # 加算・減算の回数を固定すると範囲が決まる import numpy as np N,A,B,C,D = list(map(int,input().split())) # 加算の回数をもとに rng = np.arange(N,dtype=np.int64) upper = D*rng - C*rng[::-1] lower = C*rng - D*rng[::-1] answer = 'YES' if ((lower <= B-A) & (B-A <= upper)).any() else 'NO' print(a...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, A, B, C, D = list(map(int, read().split())) N -= 1 x = np.arange(N + 1, dtype=np.int64) # 増加回数 low = C * x - D * (N - x) high = D * x - C * (N - x) diff = B - A ...
16
18
320
392
import sys input = sys.stdin.readline # 加算・減算の回数を固定すると範囲が決まる import numpy as np N, A, B, C, D = list(map(int, input().split())) # 加算の回数をもとに rng = np.arange(N, dtype=np.int64) upper = D * rng - C * rng[::-1] lower = C * rng - D * rng[::-1] answer = "YES" if ((lower <= B - A) & (B - A <= upper)).any() else "NO" print(a...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, A, B, C, D = list(map(int, read().split())) N -= 1 x = np.arange(N + 1, dtype=np.int64) # 増加回数 low = C * x - D * (N - x) high = D * x - C * (N - x) diff = B - A cond = np.any((low ...
false
11.111111
[ "-", "-input = sys.stdin.readline", "-# 加算・減算の回数を固定すると範囲が決まる", "-N, A, B, C, D = list(map(int, input().split()))", "-# 加算の回数をもとに", "-rng = np.arange(N, dtype=np.int64)", "-upper = D * rng - C * rng[::-1]", "-lower = C * rng - D * rng[::-1]", "-answer = \"YES\" if ((lower <= B - A) & (B - A <= upper)...
false
0.454439
0.551104
0.824596
[ "s521713773", "s293856080" ]
u840247626
p02258
python
s797058703
s221304054
670
610
5,620
5,620
Accepted
Accepted
8.96
s_max = -float('inf') s = 0 for i in range(int(eval(input()))): r = int(eval(input())) if i: d = r - prev s = max(s, 0) + d s_max = max(s, s_max) prev = r print(s_max)
s_max = -float('inf') s = 0 for i in range(int(eval(input()))): r = int(eval(input())) if i: s = max(s, 0) + r - prev s_max = max(s, s_max) prev = r print(s_max)
10
9
174
165
s_max = -float("inf") s = 0 for i in range(int(eval(input()))): r = int(eval(input())) if i: d = r - prev s = max(s, 0) + d s_max = max(s, s_max) prev = r print(s_max)
s_max = -float("inf") s = 0 for i in range(int(eval(input()))): r = int(eval(input())) if i: s = max(s, 0) + r - prev s_max = max(s, s_max) prev = r print(s_max)
false
10
[ "- d = r - prev", "- s = max(s, 0) + d", "+ s = max(s, 0) + r - prev" ]
false
0.042165
0.039165
1.076605
[ "s797058703", "s221304054" ]
u760794812
p02831
python
s753392177
s910210015
35
17
5,048
2,940
Accepted
Accepted
51.43
import fractions A,B = list(map(int,input().split())) def lcm(x, y): return (x * y) // fractions.gcd(x, y) print((lcm(A, B)))
A,B = list(map(int,input().split())) #a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a #a,bの最小公倍数 def lcm(a, b): return a * b // gcd (a, b) Answer = lcm(A,B) print(Answer)
7
14
129
213
import fractions A, B = list(map(int, input().split())) def lcm(x, y): return (x * y) // fractions.gcd(x, y) print((lcm(A, B)))
A, B = list(map(int, input().split())) # a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a # a,bの最小公倍数 def lcm(a, b): return a * b // gcd(a, b) Answer = lcm(A, B) print(Answer)
false
50
[ "-import fractions", "-", "+# a,bの最大公約数", "+def gcd(a, b):", "+ while b:", "+ a, b = b, a % b", "+ return a", "-def lcm(x, y):", "- return (x * y) // fractions.gcd(x, y)", "+# a,bの最小公倍数", "+def lcm(a, b):", "+ return a * b // gcd(a, b)", "-print((lcm(A, B)))", "+Answer =...
false
0.054849
0.042686
1.284946
[ "s753392177", "s910210015" ]
u150984829
p02414
python
s843984095
s262661444
470
130
7,044
7,008
Accepted
Accepted
72.34
n,m,l=list(map(int,input().split())) a=[[int(_) for _ in input().split()] for i in range(n)] b=[[int(_) for _ in input().split()] for i in range(m)] c=[[0]*l for _ in range(n)] for i in range(n): for j in range(l): for k in range(m): c[i][j]+=a[i][k]*b[k][j] for i in range(n): print((*c[i]))
n,m,l=map(int,input().split()) a=[list(map(int,input().split())) for _ in range(n)] b=[list(map(int,input().split())) for _ in range(m)] [print(*x)for x in[[sum(s*t for s,t in zip(c,l))for l in zip(*b)]for c in a]]
10
4
300
217
n, m, l = list(map(int, input().split())) a = [[int(_) for _ in input().split()] for i in range(n)] b = [[int(_) for _ in input().split()] for i in range(m)] c = [[0] * l for _ in range(n)] for i in range(n): for j in range(l): for k in range(m): c[i][j] += a[i][k] * b[k][j] for i in range(n): ...
n, m, l = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(n)] b = [list(map(int, input().split())) for _ in range(m)] [print(*x) for x in [[sum(s * t for s, t in zip(c, l)) for l in zip(*b)] for c in a]]
false
60
[ "-n, m, l = list(map(int, input().split()))", "-a = [[int(_) for _ in input().split()] for i in range(n)]", "-b = [[int(_) for _ in input().split()] for i in range(m)]", "-c = [[0] * l for _ in range(n)]", "-for i in range(n):", "- for j in range(l):", "- for k in range(m):", "- c...
false
0.044805
0.044973
0.996268
[ "s843984095", "s262661444" ]
u163320134
p02972
python
s389289879
s327969892
839
679
68,956
14,096
Accepted
Accepted
19.07
def div(val): ret=[] for i in range(1,int(val**0.5)+1): if val%i==0: ret.append(i) if val//i!=i: ret.append(val//i) return ret n=int(eval(input())) arr=list(map(int,input().split())) cnt=[0]*n num=0 ans=[] for i in range(n-1,-1,-1): if (arr[i]+cnt[i])%2==0: continue ...
n=int(eval(input())) arr=list(map(int,input().split())) flag=[-1]*n ans=[] for i in range(n-1,-1,-1): cnt=0 for j in range(i,n,i+1): if j==i: continue else: if flag[j]==1: cnt+=1 if (arr[i]+cnt)%2==0: flag[i]=0 else: flag[i]=1 ans.append(i+1) num=len(ans)...
27
23
458
374
def div(val): ret = [] for i in range(1, int(val**0.5) + 1): if val % i == 0: ret.append(i) if val // i != i: ret.append(val // i) return ret n = int(eval(input())) arr = list(map(int, input().split())) cnt = [0] * n num = 0 ans = [] for i in range(n - 1, -1...
n = int(eval(input())) arr = list(map(int, input().split())) flag = [-1] * n ans = [] for i in range(n - 1, -1, -1): cnt = 0 for j in range(i, n, i + 1): if j == i: continue else: if flag[j] == 1: cnt += 1 if (arr[i] + cnt) % 2 == 0: flag[i] = ...
false
14.814815
[ "-def div(val):", "- ret = []", "- for i in range(1, int(val**0.5) + 1):", "- if val % i == 0:", "- ret.append(i)", "- if val // i != i:", "- ret.append(val // i)", "- return ret", "-", "-", "-cnt = [0] * n", "-num = 0", "+flag = [-1] * n"...
false
0.044456
0.037436
1.187524
[ "s389289879", "s327969892" ]
u017810624
p02793
python
s121480011
s031793636
372
339
114,800
54,876
Accepted
Accepted
8.87
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 def fact(n): fct=[] b,e=2,0 while b*b<= n: while n%b==0: n=n...
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 def fact(n): fct=[] b,e=2,0 while b*b<=n: while n%b==0: n=n/...
45
45
782
761
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 def fact(n):...
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 def fact(n):...
false
0
[ "-l = [0 for i in range(10**6)]", "+l = [0] * 10**6" ]
false
1.013581
0.985441
1.028555
[ "s121480011", "s031793636" ]
u075012704
p03579
python
s746875903
s081876384
541
459
31,084
31,156
Accepted
Accepted
15.16
import sys sys.setrecursionlimit(10**9) 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())) a, b = a-1, b-1 G[a].append(b) G[b].append(a) # 0は未着色を表す color = [0] * N # 二部グラフ判定dfs def dfs(v, c): color[v] = c ...
# 忘れないように import sys sys.setrecursionlimit(10**9) 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())) a, b = a - 1, b - 1 G[a].append(b) G[b].append(a) # 0は未着色を表す color = [0] * N # 二部グラフ判定dfs def dfs(v, c): ...
29
38
569
665
import sys sys.setrecursionlimit(10**9) 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())) a, b = a - 1, b - 1 G[a].append(b) G[b].append(a) # 0は未着色を表す color = [0] * N # 二部グラフ判定dfs def dfs(v, c): color[v] = c for to in G[v...
# 忘れないように import sys sys.setrecursionlimit(10**9) 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())) a, b = a - 1, b - 1 G[a].append(b) G[b].append(a) # 0は未着色を表す color = [0] * N # 二部グラフ判定dfs def dfs(v, c): color[v] = c for...
false
23.684211
[ "+# 忘れないように", "-print((N * (N - 1) // 2 - M if not dfs(0, 1) else color.count(1) * color.count(-1) - M))", "+Bipartite = dfs(0, 1)", "+if Bipartite:", "+ White = color.count(1)", "+ Black = color.count(-1)", "+ print((White * Black - M))", "+else:", "+ print((N * (N - 1) // 2 - M))" ]
false
0.099436
0.03646
2.727226
[ "s746875903", "s081876384" ]
u604774382
p02389
python
s245489739
s283183202
30
20
6,720
4,192
Accepted
Accepted
33.33
#coding:utf-8 import sys ab=sys.stdin.readline() rect=ab.split( ' ' ) for i in range(2): rect[i]=int( rect[i]) print(( "{} {}".format( rect[0]*rect[1], rect[0]*2+rect[1]*2) ))
import sys a, b = [ int( val ) for val in sys.stdin.readline().split( " " ) ] print(( "{} {}".format( a*b, a*2+b*2 ) ))
8
4
182
121
# coding:utf-8 import sys ab = sys.stdin.readline() rect = ab.split(" ") for i in range(2): rect[i] = int(rect[i]) print(("{} {}".format(rect[0] * rect[1], rect[0] * 2 + rect[1] * 2)))
import sys a, b = [int(val) for val in sys.stdin.readline().split(" ")] print(("{} {}".format(a * b, a * 2 + b * 2)))
false
50
[ "-# coding:utf-8", "-ab = sys.stdin.readline()", "-rect = ab.split(\" \")", "-for i in range(2):", "- rect[i] = int(rect[i])", "-print((\"{} {}\".format(rect[0] * rect[1], rect[0] * 2 + rect[1] * 2)))", "+a, b = [int(val) for val in sys.stdin.readline().split(\" \")]", "+print((\"{} {}\".format(a *...
false
0.037677
0.0391
0.963611
[ "s245489739", "s283183202" ]
u248670337
p03244
python
s574348200
s542768237
120
87
24,108
20,572
Accepted
Accepted
27.5
from collections import Counter n=int(eval(input())) V=list(map(int,input().split())) E=Counter(V[::2]).most_common() O=Counter(V[1::2]).most_common() if E[0][0]==O[0][0]: E2=Counter(V[1::2]).most_common()[1][1] if len(E)>1 else 0 O2=Counter(V[::2]).most_common()[1][1] if len(O)>1 else 0 print((n-E[0][1]-O[0...
from collections import Counter n=int(eval(input())) V=list(map(int,input().split())) E=Counter(V[::2]).most_common()+[(0,0)] O=Counter(V[1::2]).most_common()+[(0,0)] print((n-E[0][1]-O[0][1] if E[0][0]!=O[0][0] else n-max(E[0][1]+O[1][1],O[0][1]+E[1][1])))
9
6
372
254
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) E = Counter(V[::2]).most_common() O = Counter(V[1::2]).most_common() if E[0][0] == O[0][0]: E2 = Counter(V[1::2]).most_common()[1][1] if len(E) > 1 else 0 O2 = Counter(V[::2]).most_common()[1][1] if len(O) > 1 else 0 pri...
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) E = Counter(V[::2]).most_common() + [(0, 0)] O = Counter(V[1::2]).most_common() + [(0, 0)] print( ( n - E[0][1] - O[0][1] if E[0][0] != O[0][0] else n - max(E[0][1] + O[1][1], O[0][1] + E[1][1]) )...
false
33.333333
[ "-E = Counter(V[::2]).most_common()", "-O = Counter(V[1::2]).most_common()", "-if E[0][0] == O[0][0]:", "- E2 = Counter(V[1::2]).most_common()[1][1] if len(E) > 1 else 0", "- O2 = Counter(V[::2]).most_common()[1][1] if len(O) > 1 else 0", "+E = Counter(V[::2]).most_common() + [(0, 0)]", "+O = Coun...
false
0.043385
0.039768
1.090959
[ "s574348200", "s542768237" ]
u729133443
p02937
python
s171061961
s737815022
1,986
1,568
3,856
3,976
Accepted
Accepted
21.05
import math import heapq import collections S = eval(input()) T = eval(input()) lenS = len(S) lenT = len(T) F1 = [False]*26 F2 = [False]*26 alpha = 'abcdefghijklmnopqrstuvwxyz' for i in range(lenS): F1[alpha.index(S[i])] = True for i in range(lenT): F2[alpha.index(T[i])] = True for i in range(26...
import sys import math import bisect import heapq import collections S = eval(input()) T = eval(input()) lenS = len(S) lenT = len(T) F1 = [False]*26 F2 = [False]*26 alpha = 'abcdefghijklmnopqrstuvwxyz' for i in range(lenS): F1[alpha.index(S[i])] = True for i in range(lenT): F2[alpha.index(T[i])...
28
30
523
554
import math import heapq import collections S = eval(input()) T = eval(input()) lenS = len(S) lenT = len(T) F1 = [False] * 26 F2 = [False] * 26 alpha = "abcdefghijklmnopqrstuvwxyz" for i in range(lenS): F1[alpha.index(S[i])] = True for i in range(lenT): F2[alpha.index(T[i])] = True for i in range(26): if n...
import sys import math import bisect import heapq import collections S = eval(input()) T = eval(input()) lenS = len(S) lenT = len(T) F1 = [False] * 26 F2 = [False] * 26 alpha = "abcdefghijklmnopqrstuvwxyz" for i in range(lenS): F1[alpha.index(S[i])] = True for i in range(lenT): F2[alpha.index(T[i])] = True for...
false
6.666667
[ "+import sys", "+import bisect", "- exit()", "+ sys.exit()" ]
false
0.095383
0.118213
0.806879
[ "s171061961", "s737815022" ]
u620868411
p03426
python
s206227312
s258851873
931
613
14,872
46,908
Accepted
Accepted
34.16
# coding=utf-8 line = input().split(" ") h = int(line[0]) w = int(line[1]) d = int(line[2]) table = [0 for _ in range(h*w+1)] for hi in range(h): line = list(map(int, input().split(" "))) for wi in range(w): table[line[wi]] = (hi+1, wi+1) def calc(l,r): ret = 0 if l!=r: ...
# -*- coding: utf-8 -*- h,w,d = list(map(int, input().split())) dd = {} for hi in range(h): line = list(map(int, input().split())) for wi in range(w): dd[line[wi]] = (hi, wi) q = int(eval(input())) lr = [list(map(int, input().split())) for _ in range(q)] acc = [0]*(h*w+1) for i in range(h*w+...
36
22
733
503
# coding=utf-8 line = input().split(" ") h = int(line[0]) w = int(line[1]) d = int(line[2]) table = [0 for _ in range(h * w + 1)] for hi in range(h): line = list(map(int, input().split(" "))) for wi in range(w): table[line[wi]] = (hi + 1, wi + 1) def calc(l, r): ret = 0 if l != r: c1 =...
# -*- coding: utf-8 -*- h, w, d = list(map(int, input().split())) dd = {} for hi in range(h): line = list(map(int, input().split())) for wi in range(w): dd[line[wi]] = (hi, wi) q = int(eval(input())) lr = [list(map(int, input().split())) for _ in range(q)] acc = [0] * (h * w + 1) for i in range(h * w + ...
false
38.888889
[ "-# coding=utf-8", "-line = input().split(\" \")", "-h = int(line[0])", "-w = int(line[1])", "-d = int(line[2])", "-table = [0 for _ in range(h * w + 1)]", "+# -*- coding: utf-8 -*-", "+h, w, d = list(map(int, input().split()))", "+dd = {}", "- line = list(map(int, input().split(\" \")))", "+...
false
0.045755
0.154534
0.296086
[ "s206227312", "s258851873" ]
u088552457
p03244
python
s686413513
s605434838
125
114
26,248
25,860
Accepted
Accepted
8.8
def main(): n = int(eval(input())) v = input_list() evens = [] odds = [] vs = v[:] kind = len(set(vs)) if kind == 1: print((n//2)) exit(0) for i, vv in enumerate(v): if i % 2 == 0: evens.append(vv) else: odds.append(vv) ec = collections.Counter(evens) ...
import math import fractions from functools import reduce def main(): n = int(eval(input())) a = input_list() if len(set(a)) == 1: print((n//2)) exit(0) evens = {} odds = {} for i, v in enumerate(a): if i % 2 == 0: if v in evens: ...
65
69
1,232
1,756
def main(): n = int(eval(input())) v = input_list() evens = [] odds = [] vs = v[:] kind = len(set(vs)) if kind == 1: print((n // 2)) exit(0) for i, vv in enumerate(v): if i % 2 == 0: evens.append(vv) else: odds.append(vv) ec = c...
import math import fractions from functools import reduce def main(): n = int(eval(input())) a = input_list() if len(set(a)) == 1: print((n // 2)) exit(0) evens = {} odds = {} for i, v in enumerate(a): if i % 2 == 0: if v in evens: evens[v] +...
false
5.797101
[ "+import math", "+import fractions", "+from functools import reduce", "+", "+", "- v = input_list()", "- evens = []", "- odds = []", "- vs = v[:]", "- kind = len(set(vs))", "- if kind == 1:", "+ a = input_list()", "+ if len(set(a)) == 1:", "- for i, vv in enumera...
false
0.048142
0.045354
1.061462
[ "s686413513", "s605434838" ]
u319410662
p03659
python
s362468526
s529891714
255
174
27,440
18,416
Accepted
Accepted
31.76
N, = list(map(int, input().split())) a = list(map(int, input().split())) sl = [0]*N sl[0] = a[0] for i in range(N-1): sl[i+1] = sl[i]+a[i+1] sr = [0]*N sr[N-1] = a[N-1] for i in range(N-1,0,-1): sr[i-1] = sr[i]+a[i-1] r = abs(sl[0]-sr[1]) for i in range(1, N-1): r = min(r, abs(sl[i]-sr[i+1])) print(r...
N, = list(map(int, input().split())) a = list(map(int, input().split())) x = a[0] y = sum(a) - a[0] r = abs(x-y) for ai in a[1:N-1]: x += ai y -= ai r = min(r, abs(x-y)) print(r)
14
10
316
188
(N,) = list(map(int, input().split())) a = list(map(int, input().split())) sl = [0] * N sl[0] = a[0] for i in range(N - 1): sl[i + 1] = sl[i] + a[i + 1] sr = [0] * N sr[N - 1] = a[N - 1] for i in range(N - 1, 0, -1): sr[i - 1] = sr[i] + a[i - 1] r = abs(sl[0] - sr[1]) for i in range(1, N - 1): r = min(r, ab...
(N,) = list(map(int, input().split())) a = list(map(int, input().split())) x = a[0] y = sum(a) - a[0] r = abs(x - y) for ai in a[1 : N - 1]: x += ai y -= ai r = min(r, abs(x - y)) print(r)
false
28.571429
[ "-sl = [0] * N", "-sl[0] = a[0]", "-for i in range(N - 1):", "- sl[i + 1] = sl[i] + a[i + 1]", "-sr = [0] * N", "-sr[N - 1] = a[N - 1]", "-for i in range(N - 1, 0, -1):", "- sr[i - 1] = sr[i] + a[i - 1]", "-r = abs(sl[0] - sr[1])", "-for i in range(1, N - 1):", "- r = min(r, abs(sl[i] -...
false
0.035128
0.036483
0.962856
[ "s362468526", "s529891714" ]
u350997995
p03497
python
s445177946
s884885880
173
160
39,344
39,344
Accepted
Accepted
7.51
import collections N,K = list(map(int,input().split())) A = list(map(int,input().split())) c = collections.Counter(A).most_common()[::-1] k = len(c) if k<=K:print((0)) else: print((sum([e[1] for e in c[:k-K]])))
from collections import Counter N,K = list(map(int,input().split())) A = list(map(int,input().split())) C = Counter(A).most_common() if len(C)<=K: print((0)) else: ans = 0 for c in C[:K]: ans+=c[1] print((N-ans))
7
11
207
236
import collections N, K = list(map(int, input().split())) A = list(map(int, input().split())) c = collections.Counter(A).most_common()[::-1] k = len(c) if k <= K: print((0)) else: print((sum([e[1] for e in c[: k - K]])))
from collections import Counter N, K = list(map(int, input().split())) A = list(map(int, input().split())) C = Counter(A).most_common() if len(C) <= K: print((0)) else: ans = 0 for c in C[:K]: ans += c[1] print((N - ans))
false
36.363636
[ "-import collections", "+from collections import Counter", "-c = collections.Counter(A).most_common()[::-1]", "-k = len(c)", "-if k <= K:", "+C = Counter(A).most_common()", "+if len(C) <= K:", "- print((sum([e[1] for e in c[: k - K]])))", "+ ans = 0", "+ for c in C[:K]:", "+ ans ...
false
0.153897
0.044427
3.464025
[ "s445177946", "s884885880" ]
u624475441
p03296
python
s361461470
s189560979
28
17
2,940
2,940
Accepted
Accepted
39.29
eval(input()) cnt=0 now=0 res=0 for a in map(int,input().split()): if a==now: cnt+=1 else: res+=cnt//2 cnt=1 now=a print((res+cnt//2))
eval(input()) ans=x=0 for a in input().split(): ans+=a==x x=a*(a!=x) print(ans)
12
6
173
86
eval(input()) cnt = 0 now = 0 res = 0 for a in map(int, input().split()): if a == now: cnt += 1 else: res += cnt // 2 cnt = 1 now = a print((res + cnt // 2))
eval(input()) ans = x = 0 for a in input().split(): ans += a == x x = a * (a != x) print(ans)
false
50
[ "-cnt = 0", "-now = 0", "-res = 0", "-for a in map(int, input().split()):", "- if a == now:", "- cnt += 1", "- else:", "- res += cnt // 2", "- cnt = 1", "- now = a", "-print((res + cnt // 2))", "+ans = x = 0", "+for a in input().split():", "+ ans += a == x"...
false
0.045701
0.045445
1.005635
[ "s361461470", "s189560979" ]
u289288647
p02608
python
s076543401
s536208959
504
432
9,264
9,100
Accepted
Accepted
14.29
n = int(eval(input())) ans = [0 for _ in range(10050)] for i in range(1, 105): for j in range(1, 105): for k in range(1, 105): v = i*i+j*j+k*k+i*j+j*k+k*i; if v < 10050: ans[v] += 1 for i in range(n): print((ans[i+1]))
n = int(eval(input())) ans = [0 for _ in range(10050)] for i in range(1, 101): for j in range(1, 101): for k in range(1, 101): v = i*i+j*j+k*k+i*j+j*k+k*i; if v < 10050: ans[v] += 1 for i in range(n): print((ans[i+1]))
10
10
276
276
n = int(eval(input())) ans = [0 for _ in range(10050)] for i in range(1, 105): for j in range(1, 105): for k in range(1, 105): v = i * i + j * j + k * k + i * j + j * k + k * i if v < 10050: ans[v] += 1 for i in range(n): print((ans[i + 1]))
n = int(eval(input())) ans = [0 for _ in range(10050)] for i in range(1, 101): for j in range(1, 101): for k in range(1, 101): v = i * i + j * j + k * k + i * j + j * k + k * i if v < 10050: ans[v] += 1 for i in range(n): print((ans[i + 1]))
false
0
[ "-for i in range(1, 105):", "- for j in range(1, 105):", "- for k in range(1, 105):", "+for i in range(1, 101):", "+ for j in range(1, 101):", "+ for k in range(1, 101):" ]
false
3.966947
1.260174
3.147936
[ "s076543401", "s536208959" ]
u263830634
p03252
python
s236345121
s166998002
149
47
6,704
6,832
Accepted
Accepted
68.46
import sys S = list(eval(input())) T = list(eval(input())) #print (S) dic1 = dict() dic2 = dict() for i in range(len(S)): if not S[i] in list(dic1.keys()): dic1[S[i]] = 1 else: dic1[S[i]] += 1 if not T[i] in list(dic2.keys()): dic2[T[i]] = 1 else: dic2[T[i...
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 9) MOD = 10 ** 9 + 7 from collections import Counter S = list(eval(input())) T = list(eval(input())) SC = Counter(S) TC = Counter(T) lstS = [] for s in SC: lstS.append(SC[s]) lstT = [] for t in TC: lstT.append(TC[t]) ls...
26
28
544
394
import sys S = list(eval(input())) T = list(eval(input())) # print (S) dic1 = dict() dic2 = dict() for i in range(len(S)): if not S[i] in list(dic1.keys()): dic1[S[i]] = 1 else: dic1[S[i]] += 1 if not T[i] in list(dic2.keys()): dic2[T[i]] = 1 else: dic2[T[i]] += 1 # prin...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**9) MOD = 10**9 + 7 from collections import Counter S = list(eval(input())) T = list(eval(input())) SC = Counter(S) TC = Counter(T) lstS = [] for s in SC: lstS.append(SC[s]) lstT = [] for t in TC: lstT.append(TC[t]) lstS.sort() lstT.sort() if lstS...
false
7.142857
[ "+", "+input = sys.stdin.readline", "+sys.setrecursionlimit(10**9)", "+MOD = 10**9 + 7", "+from collections import Counter", "-# print (S)", "-dic1 = dict()", "-dic2 = dict()", "-for i in range(len(S)):", "- if not S[i] in list(dic1.keys()):", "- dic1[S[i]] = 1", "- else:", "- ...
false
0.035801
0.034937
1.02473
[ "s236345121", "s166998002" ]
u896741788
p02579
python
s727807808
s966975479
1,917
555
151,740
99,356
Accepted
Accepted
71.05
import sys input=sys.stdin.buffer.readline inputs=sys.stdin.buffer.readlines sys.setrecursionlimit(10**9) h,w=list(map(int,input().split())) nx,ny=list(map(int,input().split())) gx,gy=list(map(int,input().split())) maze=[eval(input())for i in range(h)] from heapq import heapify, heappop, heappush seen=set() g...
import sys input=sys.stdin.buffer.readline inputs=sys.stdin.buffer.readlines sys.setrecursionlimit(10**9) h,w=list(map(int,input().split())) nx,ny=list(map(int,input().split())) gx,gy=list(map(int,input().split())) maze=[eval(input())for i in range(h)] #. 46 # 35 nx-=1;ny-=1;gx-=1;gy-=1 from collections impor...
35
37
1,152
1,154
import sys input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines sys.setrecursionlimit(10**9) h, w = list(map(int, input().split())) nx, ny = list(map(int, input().split())) gx, gy = list(map(int, input().split())) maze = [eval(input()) for i in range(h)] from heapq import heapify, heappop, heappush s...
import sys input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines sys.setrecursionlimit(10**9) h, w = list(map(int, input().split())) nx, ny = list(map(int, input().split())) gx, gy = list(map(int, input().split())) maze = [eval(input()) for i in range(h)] # . 46 # 35 nx -= 1 ny -= 1 gx -= 1 gy -= 1 fro...
false
5.405405
[ "-from heapq import heapify, heappop, heappush", "-", "-seen = set()", "+# . 46 # 35", "+nx -= 1", "+ny -= 1", "-SIZE = h * w", "-hq = [(nx - 1) * w + ny - 1]", "-while hq:", "- d = heappop(hq)", "- c, d = divmod(d, SIZE)", "- x, y = divmod(d, w)", "- if w * x + y in seen:", "-...
false
0.035863
0.057995
0.618373
[ "s727807808", "s966975479" ]
u729133443
p03331
python
s401833139
s633042727
312
17
3,848
2,940
Accepted
Accepted
94.55
n=int(eval(input()));print((min([sum(list(map(int,str(i)))+list(map(int,str(n-i))))for i in range(1, n)])))
a=sum(int(i)for i in eval(input()));print((a if a!=1else 10))
1
1
99
53
n = int(eval(input())) print( ( min( [ sum(list(map(int, str(i))) + list(map(int, str(n - i)))) for i in range(1, n) ] ) ) )
a = sum(int(i) for i in eval(input())) print((a if a != 1 else 10))
false
0
[ "-n = int(eval(input()))", "-print(", "- (", "- min(", "- [", "- sum(list(map(int, str(i))) + list(map(int, str(n - i))))", "- for i in range(1, n)", "- ]", "- )", "- )", "-)", "+a = sum(int(i) for i in eval(input()))", ...
false
0.132092
0.036741
3.59519
[ "s401833139", "s633042727" ]
u853185302
p02897
python
s696451574
s854421849
19
17
2,940
2,940
Accepted
Accepted
10.53
N = int(eval(input())) print(((N//2)/N if N%2 == 0 else ((N+1)//2)/N))
n = int(eval(input())) print((-(-n//2)/n))
2
2
63
35
N = int(eval(input())) print(((N // 2) / N if N % 2 == 0 else ((N + 1) // 2) / N))
n = int(eval(input())) print((-(-n // 2) / n))
false
0
[ "-N = int(eval(input()))", "-print(((N // 2) / N if N % 2 == 0 else ((N + 1) // 2) / N))", "+n = int(eval(input()))", "+print((-(-n // 2) / n))" ]
false
0.042158
0.073314
0.575037
[ "s696451574", "s854421849" ]
u210440747
p03295
python
s418645657
s722960559
821
522
29,324
28,572
Accepted
Accepted
36.42
#!/usr/bin/python3 # -*- coding:utf-8 -*- import numpy from collections import defaultdict def main(): n, m = list(map(int, input().split())) db2a = defaultdict(list) for _ in range(m): a, b = list(map(int, input().split())) db2a[b-1].append(a-1) cnts = numpy.zeros(n, dtype=numpy.int...
#!/usr/bin/python3 # -*- coding:utf-8 -*- import numpy from collections import defaultdict def main(): n, m = list(map(int, input().split())) db2a = defaultdict(list) for _ in range(m): a, b = list(map(int, input().split())) db2a[b-1].append(a-1) cnt = 0 end = 0 for b in sorted...
25
24
531
437
#!/usr/bin/python3 # -*- coding:utf-8 -*- import numpy from collections import defaultdict def main(): n, m = list(map(int, input().split())) db2a = defaultdict(list) for _ in range(m): a, b = list(map(int, input().split())) db2a[b - 1].append(a - 1) cnts = numpy.zeros(n, dtype=numpy.i...
#!/usr/bin/python3 # -*- coding:utf-8 -*- import numpy from collections import defaultdict def main(): n, m = list(map(int, input().split())) db2a = defaultdict(list) for _ in range(m): a, b = list(map(int, input().split())) db2a[b - 1].append(a - 1) cnt = 0 end = 0 for b in so...
false
4
[ "- cnts = numpy.zeros(n, dtype=numpy.int)", "- i = 0", "+ cnt = 0", "+ end = 0", "- cnts[i:b] = cnts[i - 1]", "- cnts[b] = max(cnts[max(db2a[b])] + 1, cnts[b - 1])", "- i = b + 1", "- cnts[i:] = cnts[i - 1]", "- print((cnts[-1]))", "+ if end <= max(db2...
false
0.207123
0.062339
3.322554
[ "s418645657", "s722960559" ]
u852690916
p02937
python
s608797956
s854184768
245
107
47,368
78,560
Accepted
Accepted
56.33
import sys import bisect def main(): input = sys.stdin.readline s = input().rstrip() t = input().rstrip() letters = set(t) indices = dict() for l in letters: lst = [] left = 0 while left < len(s): i = s.find(l, left) if i < 0: break ...
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) from bisect import bisect_left from collections import defaultdict import sys def main(S, T): D = defaultdict(list) for i, s in enumerate(S): D[s].append(i + 1) cycle = 0 idx = 0 N = len(S) for t in T: if not D[t]: ...
40
28
878
678
import sys import bisect def main(): input = sys.stdin.readline s = input().rstrip() t = input().rstrip() letters = set(t) indices = dict() for l in letters: lst = [] left = 0 while left < len(s): i = s.find(l, left) if i < 0: bre...
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) from bisect import bisect_left from collections import defaultdict import sys def main(S, T): D = defaultdict(list) for i, s in enumerate(S): D[s].append(i + 1) cycle = 0 idx = 0 N = len(S) for t in T: if not D[t]: retu...
false
30
[ "+# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)", "+from bisect import bisect_left", "+from collections import defaultdict", "-import bisect", "-def main():", "+def main(S, T):", "+ D = defaultdict(list)", "+ for i, s in enumerate(S):", "+ D[s].append(i + 1)", "+ cycle = 0", "+ ...
false
0.034767
0.036956
0.940755
[ "s608797956", "s854184768" ]
u401686269
p03163
python
s885537986
s771992778
687
322
169,164
150,540
Accepted
Accepted
53.13
N, W = list(map(int, input().split())) wv = [[0 for i in range(2)] for j in range(N)] dp = [[0 for i in range(N+1)] for j in range(W+1)] for i in range(N): wv[i] = list(map(int, input().split())) for i in range(N): for w in range(1,W+1): if w < wv[i][0]: dp[w][i+1] = dp[w][i] else: ...
N,W=list(map(int,input().split())) wv = [tuple(map(int,input().split())) for _ in range(N)] dp = [[0]*(W+1) for _ in range(N+1)] for i in range(1,N+1): for j in range(1, W+1): if j >= wv[i-1][0]: dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1]) else: dp[i][j] = dp[i-1][j] ...
15
13
391
339
N, W = list(map(int, input().split())) wv = [[0 for i in range(2)] for j in range(N)] dp = [[0 for i in range(N + 1)] for j in range(W + 1)] for i in range(N): wv[i] = list(map(int, input().split())) for i in range(N): for w in range(1, W + 1): if w < wv[i][0]: dp[w][i + 1] = dp[w][i] ...
N, W = list(map(int, input().split())) wv = [tuple(map(int, input().split())) for _ in range(N)] dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, W + 1): if j >= wv[i - 1][0]: dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wv[i - 1][0]] + wv[i - 1][1]) e...
false
13.333333
[ "-wv = [[0 for i in range(2)] for j in range(N)]", "-dp = [[0 for i in range(N + 1)] for j in range(W + 1)]", "-for i in range(N):", "- wv[i] = list(map(int, input().split()))", "-for i in range(N):", "- for w in range(1, W + 1):", "- if w < wv[i][0]:", "- dp[w][i + 1] = dp[w][...
false
0.047337
0.047786
0.990609
[ "s885537986", "s771992778" ]
u054825571
p02924
python
s604884871
s019913816
120
29
61,608
9,164
Accepted
Accepted
75.83
N=int(eval(input())) print((N*(N-1)//2))
n=int(eval(input())) print((n*(n-1)//2))
2
2
33
33
N = int(eval(input())) print((N * (N - 1) // 2))
n = int(eval(input())) print((n * (n - 1) // 2))
false
0
[ "-N = int(eval(input()))", "-print((N * (N - 1) // 2))", "+n = int(eval(input()))", "+print((n * (n - 1) // 2))" ]
false
0.041204
0.046594
0.884333
[ "s604884871", "s019913816" ]
u922449550
p02689
python
s296493910
s158761691
426
388
30,628
29,420
Accepted
Accepted
8.92
N, M = list(map(int, input().split())) H = 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) g[b-1].append(a-1) d = [[0, -1]] ans = 0 is_visit = [False] * N def search(node): global is_visit globa...
N, M = list(map(int, input().split())) H = 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); g[b-1].append(a-1) ans = 0 for i in range(N): neighbors = g[i] h = H[i] res = True for node in neighbors: res ...
38
17
772
350
N, M = list(map(int, input().split())) H = 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) g[b - 1].append(a - 1) d = [[0, -1]] ans = 0 is_visit = [False] * N def search(node): global is_visit global ans ...
N, M = list(map(int, input().split())) H = 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) g[b - 1].append(a - 1) ans = 0 for i in range(N): neighbors = g[i] h = H[i] res = True for node in neighbors:...
false
55.263158
[ "-d = [[0, -1]]", "-is_visit = [False] * N", "-", "-", "-def search(node):", "- global is_visit", "- global ans", "- d = [node]", "- while d:", "- node = d.pop()", "- h = H[node]", "- children = g[node]", "- res = True", "- for child in childr...
false
0.037753
0.041256
0.915088
[ "s296493910", "s158761691" ]
u333190709
p02844
python
s139259923
s083441610
285
23
12,020
3,064
Accepted
Accepted
91.93
#!/usr/bin/env python3 import sys def solve(N: int, S: str): def nx(S): res = [[N+1] * 10 for _ in range(N+1)] for i in range(N-1, -1, -1): for j in range(10): res[i][j] = res[i+1][j] res[i][int(S[i])] = i return res dp = [[0] * 3 for _...
#!/usr/bin/env python3 import sys def solve(N: int, S: str): counter = 0 for i in range(1000): c = i % 10 b = (i // 10) % 10 a = (i // 100) % 10 aa = S.find(str(a)) if aa != -1 and aa < N - 2: bb = S[aa+1:].find(str(b)) if bb != -1 a...
41
33
1,210
776
#!/usr/bin/env python3 import sys def solve(N: int, S: str): def nx(S): res = [[N + 1] * 10 for _ in range(N + 1)] for i in range(N - 1, -1, -1): for j in range(10): res[i][j] = res[i + 1][j] res[i][int(S[i])] = i return res dp = [[0] * 3 for _ ...
#!/usr/bin/env python3 import sys def solve(N: int, S: str): counter = 0 for i in range(1000): c = i % 10 b = (i // 10) % 10 a = (i // 100) % 10 aa = S.find(str(a)) if aa != -1 and aa < N - 2: bb = S[aa + 1 :].find(str(b)) if bb != -1 and bb < N ...
false
19.512195
[ "- def nx(S):", "- res = [[N + 1] * 10 for _ in range(N + 1)]", "- for i in range(N - 1, -1, -1):", "- for j in range(10):", "- res[i][j] = res[i + 1][j]", "- res[i][int(S[i])] = i", "- return res", "-", "- dp = [[0] * 3 for _ in range(...
false
0.045702
0.038003
1.202604
[ "s139259923", "s083441610" ]
u340781749
p03112
python
s934505745
s022903461
805
641
129,132
58,724
Accepted
Accepted
20.37
import bisect import sys a, b, q = list(map(int, input().split())) lines = sys.stdin.readlines() sss = list(map(int, lines[:a])) ttt = list(map(int, lines[a:a + b])) xxx = list(map(int, lines[a + b:])) nearest_temples = [0] * a nearest_shrines = [0] * b for i, s in enumerate(sss): ti = bisect.bisect(t...
import bisect import sys SENTINEL = 10 ** 12 a, b, q = list(map(int, input().split())) lines = sys.stdin.readlines() sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL] ttt = [-SENTINEL] + list(map(int, lines[a:a + b])) + [SENTINEL] xxx = list(map(int, lines[a + b:])) nearest_temples = [SENTINEL] +...
43
30
1,197
1,028
import bisect import sys a, b, q = list(map(int, input().split())) lines = sys.stdin.readlines() sss = list(map(int, lines[:a])) ttt = list(map(int, lines[a : a + b])) xxx = list(map(int, lines[a + b :])) nearest_temples = [0] * a nearest_shrines = [0] * b for i, s in enumerate(sss): ti = bisect.bisect(ttt, s) ...
import bisect import sys SENTINEL = 10**12 a, b, q = list(map(int, input().split())) lines = sys.stdin.readlines() sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL] ttt = [-SENTINEL] + list(map(int, lines[a : a + b])) + [SENTINEL] xxx = list(map(int, lines[a + b :])) nearest_temples = [SENTINEL] + [0] * a + [...
false
30.232558
[ "+SENTINEL = 10**12", "-sss = list(map(int, lines[:a]))", "-ttt = list(map(int, lines[a : a + b]))", "+sss = [-SENTINEL] + list(map(int, lines[:a])) + [SENTINEL]", "+ttt = [-SENTINEL] + list(map(int, lines[a : a + b])) + [SENTINEL]", "-nearest_temples = [0] * a", "-nearest_shrines = [0] * b", "-for i,...
false
0.007964
0.040605
0.196124
[ "s934505745", "s022903461" ]
u768496010
p02813
python
s297921043
s411255346
48
19
8,052
3,188
Accepted
Accepted
60.42
n = int(eval(input())) p = list(map(int,input().split())) q = list(map(int,input().split())) import itertools plist = list(itertools.permutations([i+1 for i in range(n)])) count = 1 resultp = 0 resultq = 0 for pp in plist: if(list(pp) == p): resultp = count if (list(pp) == q): ...
import math # 数列が何番目かを返却するメソッド def junban(N, str): int_list = str.split() # 入力文字を配列化 int_list = [int(i) for i in int_list] used_list = [] num = 0 for element in int_list: N -= 1 used_count = 0 for used in used_list: if element > used: ...
20
31
380
644
n = int(eval(input())) p = list(map(int, input().split())) q = list(map(int, input().split())) import itertools plist = list(itertools.permutations([i + 1 for i in range(n)])) count = 1 resultp = 0 resultq = 0 for pp in plist: if list(pp) == p: resultp = count if list(pp) == q: resultq = count ...
import math # 数列が何番目かを返却するメソッド def junban(N, str): int_list = str.split() # 入力文字を配列化 int_list = [int(i) for i in int_list] used_list = [] num = 0 for element in int_list: N -= 1 used_count = 0 for used in used_list: if element > used: used_count ...
false
35.483871
[ "-n = int(eval(input()))", "-p = list(map(int, input().split()))", "-q = list(map(int, input().split()))", "-import itertools", "+import math", "-plist = list(itertools.permutations([i + 1 for i in range(n)]))", "-count = 1", "-resultp = 0", "-resultq = 0", "-for pp in plist:", "- if list(pp)...
false
0.120349
0.05576
2.158344
[ "s297921043", "s411255346" ]
u707808519
p02732
python
s356582927
s768068320
682
380
26,140
26,140
Accepted
Accepted
44.28
import bisect N = int(eval(input())) A = [int(x) for x in input().split()] B = sorted(A) cnt = [0] * (N+1) for k in range(1, N+1): cnt[k] = bisect.bisect_left(B, k+1) for k in range(N): cnt[-1-k] -= cnt[-2-k] ALL = 0 for i in range(1, N+1): ALL += cnt[i]*(cnt[i]-1)//2 for k in range(N): ...
N = int(eval(input())) A = list(map(int, input().split())) cnt = [0] * (N+1) for i in range(N): cnt[A[i]] += 1 nsum = [cnt[n]*(cnt[n]-1)//2 for n in range(N+1)] SUM = sum(nsum) for k in range(N): kadd = cnt[A[k]] - 1 print((SUM - nsum[A[k]] + kadd*(kadd-1)//2))
19
13
410
280
import bisect N = int(eval(input())) A = [int(x) for x in input().split()] B = sorted(A) cnt = [0] * (N + 1) for k in range(1, N + 1): cnt[k] = bisect.bisect_left(B, k + 1) for k in range(N): cnt[-1 - k] -= cnt[-2 - k] ALL = 0 for i in range(1, N + 1): ALL += cnt[i] * (cnt[i] - 1) // 2 for k in range(N): ...
N = int(eval(input())) A = list(map(int, input().split())) cnt = [0] * (N + 1) for i in range(N): cnt[A[i]] += 1 nsum = [cnt[n] * (cnt[n] - 1) // 2 for n in range(N + 1)] SUM = sum(nsum) for k in range(N): kadd = cnt[A[k]] - 1 print((SUM - nsum[A[k]] + kadd * (kadd - 1) // 2))
false
31.578947
[ "-import bisect", "-", "-A = [int(x) for x in input().split()]", "-B = sorted(A)", "+A = list(map(int, input().split()))", "-for k in range(1, N + 1):", "- cnt[k] = bisect.bisect_left(B, k + 1)", "+for i in range(N):", "+ cnt[A[i]] += 1", "+nsum = [cnt[n] * (cnt[n] - 1) // 2 for n in range(N...
false
0.007244
0.037584
0.19274
[ "s356582927", "s768068320" ]
u119714109
p03608
python
s205981505
s752295465
399
253
45,148
4,084
Accepted
Accepted
36.59
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() n,m,r=na() rs = na() for i in range(r): rs[i] -= 1 g = [[99999999999]*n for _ in range(n)] for i in range(n): g[i][i] = 0 for i in range(m): a, b, c = ...
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() n,m,r=na() rs = na() for i in range(r): rs[i] -= 1 g = [[99999999999]*n for _ in range(n)] for i in range(n): g[i][i] = 0 for i in range(m): a, b, c = ...
36
71
697
1,471
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() n, m, r = na() rs = na() for i in range(r): rs[i] -= 1 g = [[99999999999] * n for _ in range(n)] for i in range(n): g[i][i] = 0 for i in range(m): a, b, c = na() a -= ...
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline() n, m, r = na() rs = na() for i in range(r): rs[i] -= 1 g = [[99999999999] * n for _ in range(n)] for i in range(n): g[i][i] = 0 for i in range(m): a, b, c = na() a -= ...
false
49.295775
[ "-for k in range(n):", "- for i in range(n):", "- for j in range(n):", "- g[i][j] = min(g[i][j], g[i][k] + g[k][j])", "+from heapq import *", "+", "+", "+def dijkstra(g, start):", "+ n = len(g)", "+ ds = [1e18] * n", "+ ds[start] = 0", "+ h = []", "+ heapp...
false
0.078667
0.091509
0.859667
[ "s205981505", "s752295465" ]
u347184682
p02832
python
s609347469
s262076419
177
103
25,768
32,320
Accepted
Accepted
41.81
n=int(eval(input())) a=[int(x) for x in input().rstrip().split()] cnt=0 now=0 for i in range(n): while(now<n): if a[now]==i+1: cnt+=1 break else: now+=1 if cnt==0: print((-1)) else: print((n-cnt))
n=int(eval(input())) a=[int(x) for x in input().rstrip().split()] now=1 cnt=0 for i in range(n): if now==a[i]: now+=1 else: cnt+=1 if n==cnt: print((-1)) else: print(cnt)
16
15
235
195
n = int(eval(input())) a = [int(x) for x in input().rstrip().split()] cnt = 0 now = 0 for i in range(n): while now < n: if a[now] == i + 1: cnt += 1 break else: now += 1 if cnt == 0: print((-1)) else: print((n - cnt))
n = int(eval(input())) a = [int(x) for x in input().rstrip().split()] now = 1 cnt = 0 for i in range(n): if now == a[i]: now += 1 else: cnt += 1 if n == cnt: print((-1)) else: print(cnt)
false
6.25
[ "+now = 1", "-now = 0", "- while now < n:", "- if a[now] == i + 1:", "- cnt += 1", "- break", "- else:", "- now += 1", "-if cnt == 0:", "+ if now == a[i]:", "+ now += 1", "+ else:", "+ cnt += 1", "+if n == cnt:", "- ...
false
0.043792
0.044467
0.98481
[ "s609347469", "s262076419" ]
u644907318
p03681
python
s384020865
s634041166
195
74
39,856
79,656
Accepted
Accepted
62.05
p = 10**9+7 N,M = list(map(int,input().split())) a = 1 for i in range(2,N+1): a = (a*i)%p b = 1 for i in range(2,M+1): b = (b*i)%p if M==N: n = (2*a*b)%p elif M==N-1 or N==M-1: n = (a*b)%p else: n = 0 print(n)
p = 10**9+7 N,M = list(map(int,input().split())) A = [1 for _ in range(N+1)] for i in range(2,N+1): A[i] = (i*A[i-1])%p B = [1 for _ in range(M+1)] for i in range(2,M+1): B[i] = (i*B[i-1])%p if abs(N-M)>1: ans = 0 elif abs(N-M)==1: ans = (A[N]*B[M])%p elif abs(N-M)==0: ans = (2*A[N]*B[M...
15
15
237
330
p = 10**9 + 7 N, M = list(map(int, input().split())) a = 1 for i in range(2, N + 1): a = (a * i) % p b = 1 for i in range(2, M + 1): b = (b * i) % p if M == N: n = (2 * a * b) % p elif M == N - 1 or N == M - 1: n = (a * b) % p else: n = 0 print(n)
p = 10**9 + 7 N, M = list(map(int, input().split())) A = [1 for _ in range(N + 1)] for i in range(2, N + 1): A[i] = (i * A[i - 1]) % p B = [1 for _ in range(M + 1)] for i in range(2, M + 1): B[i] = (i * B[i - 1]) % p if abs(N - M) > 1: ans = 0 elif abs(N - M) == 1: ans = (A[N] * B[M]) % p elif abs(N - M...
false
0
[ "-a = 1", "+A = [1 for _ in range(N + 1)]", "- a = (a * i) % p", "-b = 1", "+ A[i] = (i * A[i - 1]) % p", "+B = [1 for _ in range(M + 1)]", "- b = (b * i) % p", "-if M == N:", "- n = (2 * a * b) % p", "-elif M == N - 1 or N == M - 1:", "- n = (a * b) % p", "-else:", "- n = ...
false
0.03772
0.148711
0.253649
[ "s384020865", "s634041166" ]
u631277801
p02937
python
s869011868
s288305394
1,995
268
378,916
54,740
Accepted
Accepted
86.57
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.r...
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.r...
59
48
1,309
1,076
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
false
18.644068
[ "-from collections import defaultdict", "+# 判定", "-for ti in t:", "+tset = set(list(t))", "+for ti in tset:", "- break", "- charidx = defaultdict(list)", "- for i, si in enumerate(s):", "- charidx[si].append(i)", "- for i, si in enumerate(s):", "- charidx[si].append...
false
0.042743
0.0369
1.158347
[ "s869011868", "s288305394" ]
u054556734
p02900
python
s204598109
s998716935
196
146
38,688
3,316
Accepted
Accepted
25.51
import collections as col def prime(n): ans = [] num = n for i in range(2,int(n**0.5)+1): if i%2==0 and i!=2: continue while num%i == 0: num //= i ; ans.append(i) if num != 1: ans.append(num) return ans def gcd(a,b): return gcd(b,a%b) if a%b else b a,b = list(map(int,...
import collections as col import math def prime(n): ans = [] num = n for i in range(2,int(n**0.5)+1): if i%2==0 and i!=2: continue while num%i == 0: num //= i ; ans.append(i) if num != 1: ans.append(num) return ans def gcd(a,b): return gcd(b,a%b) if a%b else b a,b = ...
19
20
427
456
import collections as col def prime(n): ans = [] num = n for i in range(2, int(n**0.5) + 1): if i % 2 == 0 and i != 2: continue while num % i == 0: num //= i ans.append(i) if num != 1: ans.append(num) return ans def gcd(a, b): retur...
import collections as col import math def prime(n): ans = [] num = n for i in range(2, int(n**0.5) + 1): if i % 2 == 0 and i != 2: continue while num % i == 0: num //= i ans.append(i) if num != 1: ans.append(num) return ans def gcd(a, b...
false
5
[ "+import math", "-primes = prime(gcd(a, b))", "+primes = prime(gcd(a, b)) # math.gcdは使用禁止?" ]
false
0.044383
0.046777
0.948826
[ "s204598109", "s998716935" ]
u263830634
p03775
python
s898961756
s675272188
35
28
3,188
3,064
Accepted
Accepted
20
from math import sqrt N = int(eval(input())) n = int(sqrt(N)) + 10 def f(A, B): a = len(str(A)) b = len(str(B)) return max(a, b) ans = 10 ** 10 for i in range(1, n): if (N//i) * i == N: ans = min(ans, f(i, N//i)) print (ans)
N = int(eval(input())) def make_divisors(n): import math divisors = [] for i in range(1, int(math.sqrt(n)) + 1): if n % i == 0: #割り切れるとき divisors.append(i) if i != n//i: divisors.append(n//i) divisors.sort() return divisors def F(A, B): ...
17
29
263
485
from math import sqrt N = int(eval(input())) n = int(sqrt(N)) + 10 def f(A, B): a = len(str(A)) b = len(str(B)) return max(a, b) ans = 10**10 for i in range(1, n): if (N // i) * i == N: ans = min(ans, f(i, N // i)) print(ans)
N = int(eval(input())) def make_divisors(n): import math divisors = [] for i in range(1, int(math.sqrt(n)) + 1): if n % i == 0: # 割り切れるとき divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort() return divisors def F(A, B): ...
false
41.37931
[ "-from math import sqrt", "-", "-n = int(sqrt(N)) + 10", "-def f(A, B):", "- a = len(str(A))", "- b = len(str(B))", "- return max(a, b)", "+def make_divisors(n):", "+ import math", "+", "+ divisors = []", "+ for i in range(1, int(math.sqrt(n)) + 1):", "+ if n % i == ...
false
0.057429
0.051865
1.107278
[ "s898961756", "s675272188" ]
u628583308
p02726
python
s099552901
s244711795
1,210
1,019
3,948
3,948
Accepted
Accepted
15.79
#!/usr/bin/env python3 import sys import collections def solve(N: int, X: int, Y: int): def len_shortest_path(i, j, X, Y): return min(abs(j-i), abs(X-i) + abs(Y-j) + 1) result = collections.defaultdict(int) for i in range(1, N+1): for j in range(i+1, N+1): shortest_pat...
#!/usr/bin/env python3 import sys import collections def solve(N: int, X: int, Y: int): X = X - 1 Y = Y - 1 counter = collections.defaultdict(int) for i in range(N): for j in range(i+1, N): k = min(j - i, abs(Y-j) + abs(X-i) + 1) counter[k] += 1 for i i...
85
32
2,214
897
#!/usr/bin/env python3 import sys import collections def solve(N: int, X: int, Y: int): def len_shortest_path(i, j, X, Y): return min(abs(j - i), abs(X - i) + abs(Y - j) + 1) result = collections.defaultdict(int) for i in range(1, N + 1): for j in range(i + 1, N + 1): shortest...
#!/usr/bin/env python3 import sys import collections def solve(N: int, X: int, Y: int): X = X - 1 Y = Y - 1 counter = collections.defaultdict(int) for i in range(N): for j in range(i + 1, N): k = min(j - i, abs(Y - j) + abs(X - i) + 1) counter[k] += 1 for i in range...
false
62.352941
[ "- def len_shortest_path(i, j, X, Y):", "- return min(abs(j - i), abs(X - i) + abs(Y - j) + 1)", "-", "- result = collections.defaultdict(int)", "- for i in range(1, N + 1):", "- for j in range(i + 1, N + 1):", "- shortest_path = len_shortest_path(i, j, X, Y)", "- ...
false
0.03942
0.037792
1.043087
[ "s099552901", "s244711795" ]
u462329577
p02583
python
s253434457
s671909041
164
118
9,208
9,188
Accepted
Accepted
28.05
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): if max(a[i], a[j], a[k]) * 2 < sum([a[i], a[j], a[k]]): if a[i] != a[j] and a[i] != a[k] and a[j] != a[k]: ...
#!/usr/bin/env python3 n = int(eval(input())) l = list(map(int, input().split())) l.sort() ans = 0 for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): if ( l[i] != l[j] and l[j] != l[k] and l[i] > l[k] - l[j] ...
11
16
352
399
#!/usr/bin/env python3 n = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): if max(a[i], a[j], a[k]) * 2 < sum([a[i], a[j], a[k]]): if a[i] != a[j] and a[i] != a[k] and a[j] != a[k]: ...
#!/usr/bin/env python3 n = int(eval(input())) l = list(map(int, input().split())) l.sort() ans = 0 for i in range(n): for j in range(i + 1, n): for k in range(j + 1, n): if ( l[i] != l[j] and l[j] != l[k] and l[i] > l[k] - l[j] and ...
false
31.25
[ "-a = list(map(int, input().split()))", "-cnt = 0", "+l = list(map(int, input().split()))", "+l.sort()", "+ans = 0", "- if max(a[i], a[j], a[k]) * 2 < sum([a[i], a[j], a[k]]):", "- if a[i] != a[j] and a[i] != a[k] and a[j] != a[k]:", "- cnt += 1", "-print...
false
0.033419
0.033164
1.007693
[ "s253434457", "s671909041" ]
u304058693
p02571
python
s436948947
s525678551
134
123
14,340
14,324
Accepted
Accepted
8.21
s = eval(input()) t = eval(input()) cnt = [] for i in range(len(s) - len(t) + 1): cnt1 = 0 for k in range(len(t)): if t[k] == s[i: i + len(t)][k]: cnt1 += 1 cnt.append(cnt1) #print(t[i:k], s[i:], k-i) else: cnt.append(0) #print(t[...
s = eval(input()) t = eval(input()) cnt = [] for i in range(len(s) - len(t) + 1): cnt1 = 0 for k in range(len(t)): if t[k] == s[i: i + len(t)][k]: cnt1 += 1 cnt.append(cnt1) #print(t[i:k], s[i:], k-i) else: cnt.append(0) #...
16
16
360
368
s = eval(input()) t = eval(input()) cnt = [] for i in range(len(s) - len(t) + 1): cnt1 = 0 for k in range(len(t)): if t[k] == s[i : i + len(t)][k]: cnt1 += 1 cnt.append(cnt1) # print(t[i:k], s[i:], k-i) else: cnt.append(0) # print(t[i:k], k - i) # ...
s = eval(input()) t = eval(input()) cnt = [] for i in range(len(s) - len(t) + 1): cnt1 = 0 for k in range(len(t)): if t[k] == s[i : i + len(t)][k]: cnt1 += 1 cnt.append(cnt1) # print(t[i:k], s[i:], k-i) else: cnt.append(0) # print(t[i:k...
false
0
[ "- else:", "- cnt.append(0)", "- # print(t[i:k], k - i)", "+ else:", "+ cnt.append(0)", "+ # print(t[i:k], k - i)" ]
false
0.09735
0.124479
0.782056
[ "s436948947", "s525678551" ]
u631277801
p03645
python
s528885930
s880516313
350
308
37,072
19,036
Accepted
Accepted
12
import sys sdin = sys.stdin.readline N,M = list(map(int, sdin().split())) AB = [] for i in range(M): AB.append(tuple(map(int, sdin().split()))) to_mid = set() from_mid = set() for a,b in AB: if a==1: to_mid.add(b) if b==N: from_mid.add(a) if to_mid & from_mid...
import sys stdin = sys.stdin def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return...
21
33
371
718
import sys sdin = sys.stdin.readline N, M = list(map(int, sdin().split())) AB = [] for i in range(M): AB.append(tuple(map(int, sdin().split()))) to_mid = set() from_mid = set() for a, b in AB: if a == 1: to_mid.add(b) if b == N: from_mid.add(a) if to_mid & from_mid: print("POSSIBLE") el...
import sys stdin = sys.stdin def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().r...
false
36.363636
[ "-sdin = sys.stdin.readline", "-N, M = list(map(int, sdin().split()))", "-AB = []", "-for i in range(M):", "- AB.append(tuple(map(int, sdin().split())))", "-to_mid = set()", "-from_mid = set()", "-for a, b in AB:", "+stdin = sys.stdin", "+", "+", "+def li():", "+ return list(map(int, s...
false
0.035847
0.042412
0.84522
[ "s528885930", "s880516313" ]
u729133443
p03343
python
s078024158
s613825070
1,995
1,558
3,392
115,036
Accepted
Accepted
21.9
def main(): n,k,q,*a=list(map(int,open(0).read().split())) s=sorted m=1e18 for b in a: i=[i for i,t in enumerate(a)if t<b] l=s(u for t in[s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])]for u in t) if len(l)>=q:m=min(m,l[q-1]-b) print(m) main()
n,k,q,*a=list(map(int,open(0).read().split())) s=sorted m=1e9 for b in a: i=[i for i,t in enumerate(a)if t<b];l=s(sum([s(a[i+1:j])[::-1][k-1:]for i,j in zip([-1]+i,i+[n])],[])) if len(l)>=q:m=min(m,l[q-1]-b) print(m)
10
7
295
218
def main(): n, k, q, *a = list(map(int, open(0).read().split())) s = sorted m = 1e18 for b in a: i = [i for i, t in enumerate(a) if t < b] l = s( u for t in [s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])] for u in t ) ...
n, k, q, *a = list(map(int, open(0).read().split())) s = sorted m = 1e9 for b in a: i = [i for i, t in enumerate(a) if t < b] l = s(sum([s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] + i, i + [n])], [])) if len(l) >= q: m = min(m, l[q - 1] - b) print(m)
false
30
[ "-def main():", "- n, k, q, *a = list(map(int, open(0).read().split()))", "- s = sorted", "- m = 1e18", "- for b in a:", "- i = [i for i, t in enumerate(a) if t < b]", "- l = s(", "- u", "- for t in [s(a[i + 1 : j])[::-1][k - 1 :] for i, j in zip([-1] ...
false
0.071191
0.03428
2.076745
[ "s078024158", "s613825070" ]
u489959379
p02923
python
s214211009
s831400252
93
66
14,252
14,480
Accepted
Accepted
29.03
n = int(eval(input())) h = list(map(int, input().split())) h.reverse() ans = 0 value = 0 for i in range(1, n): if h[i-1] <= h[i]: value += 1 else: value = 0 ans = max(ans, value) print(ans)
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) H = list(map(int, input().split())) res = 0 cnt = 0 for i in range(1, n): if H[i - 1] >= H[i]: cnt += 1 else: res = max(...
14
25
227
433
n = int(eval(input())) h = list(map(int, input().split())) h.reverse() ans = 0 value = 0 for i in range(1, n): if h[i - 1] <= h[i]: value += 1 else: value = 0 ans = max(ans, value) print(ans)
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) H = list(map(int, input().split())) res = 0 cnt = 0 for i in range(1, n): if H[i - 1] >= H[i]: cnt += 1 else: res = max(res, cnt) ...
false
44
[ "-n = int(eval(input()))", "-h = list(map(int, input().split()))", "-h.reverse()", "-ans = 0", "-value = 0", "-for i in range(1, n):", "- if h[i - 1] <= h[i]:", "- value += 1", "- else:", "- value = 0", "- ans = max(ans, value)", "-print(ans)", "+import sys", "+", ...
false
0.041121
0.101729
0.404215
[ "s214211009", "s831400252" ]