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
u519939795
p03338
python
s243724016
s776472345
21
17
3,064
2,940
Accepted
Accepted
19.05
n=int(eval(input())) s=eval(input()) t="" k="" l=[] for i in range(1,n): ans1=0 t=sorted(set(s[:i])) k=sorted(set(s[i:])) for i in t: for j in k: if i==j: ans1+=1 l.append(ans1) print((max(l)))
N = int(eval(input())) S = eval(input()) ans = 0 for i in range(N): ans = max(ans, len(set(S[:i]) & set(S[i:]))) print(ans)
15
7
249
123
n = int(eval(input())) s = eval(input()) t = "" k = "" l = [] for i in range(1, n): ans1 = 0 t = sorted(set(s[:i])) k = sorted(set(s[i:])) for i in t: for j in k: if i == j: ans1 += 1 l.append(ans1) print((max(l)))
N = int(eval(input())) S = eval(input()) ans = 0 for i in range(N): ans = max(ans, len(set(S[:i]) & set(S[i:]))) print(ans)
false
53.333333
[ "-n = int(eval(input()))", "-s = eval(input())", "-t = \"\"", "-k = \"\"", "-l = []", "-for i in range(1, n):", "- ans1 = 0", "- t = sorted(set(s[:i]))", "- k = sorted(set(s[i:]))", "- for i in t:", "- for j in k:", "- if i == j:", "- ans1 += 1", ...
false
0.047152
0.045816
1.029154
[ "s243724016", "s776472345" ]
u167988719
p03128
python
s154450292
s427308795
531
116
245,128
14,836
Accepted
Accepted
78.15
import sys import copy sys.setrecursionlimit(10**6) m = [0,2,5,5,4,5,6,3,7,6] def a_le_b(a, b): la, lb = len(a), len(b) if la == lb: for i in range(la): if a[i] < b[i]: return True elif a[i] > b[i]: return False return Tru...
m = [0,2,5,5,4,5,6,3,7,6] N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) for i in range(len(A)-1, 0, -1): for j in range(i-1, -1, -1): if m[A[i]] == m[A[j]]: del A[i] break dp = [-1] * (N+1) dp[0] = 0 for i in range(N)...
41
22
961
494
import sys import copy sys.setrecursionlimit(10**6) m = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6] def a_le_b(a, b): la, lb = len(a), len(b) if la == lb: for i in range(la): if a[i] < b[i]: return True elif a[i] > b[i]: return False return True ...
m = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6] N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) for i in range(len(A) - 1, 0, -1): for j in range(i - 1, -1, -1): if m[A[i]] == m[A[j]]: del A[i] break dp = [-1] * (N + 1) dp[0] = 0 for i in range(N): ...
false
46.341463
[ "-import sys", "-import copy", "-", "-sys.setrecursionlimit(10**6)", "-", "-", "-def a_le_b(a, b):", "- la, lb = len(a), len(b)", "- if la == lb:", "- for i in range(la):", "- if a[i] < b[i]:", "- return True", "- elif a[i] > b[i]:", "- ...
false
0.035894
0.035474
1.011819
[ "s154450292", "s427308795" ]
u481187938
p02834
python
s848612382
s765258662
275
251
107,704
107,324
Accepted
Accepted
8.73
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline...
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline...
76
68
2,764
2,578
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline().spl...
#!usr/bin/env python3 from collections import defaultdict, deque, Counter, OrderedDict from bisect import bisect_left, bisect_right from functools import reduce, lru_cache from heapq import heappush, heappop, heapify import itertools import math, fractions import sys, copy def L(): return sys.stdin.readline().spl...
false
10.526316
[ "- visit = [False] * N", "- q = deque([u - 1])", "- while q:", "- i = q.popleft()", "- visit[i] = True", "- if udist[i] < vdist[i]:", "- ans = max(ans, vdist[i] - 1)", "- for j in g[i]:", "- if not visit[j]:", "- ...
false
0.056258
0.038623
1.456576
[ "s848612382", "s765258662" ]
u328510800
p03207
python
s734888151
s228918557
26
24
9,108
9,136
Accepted
Accepted
7.69
N = int(eval(input())) P = sorted([int(eval(input())) for x in range(N)]) m = P[N-1] P = P[:N-1] print((sum(P) + m // 2))
N = int(eval(input())) m, *P = sorted([int(eval(input())) for x in range(N)], reverse=True) """ m = P[N-1] P = P[:N-1] """ print((sum(P) + m // 2))
6
9
113
143
N = int(eval(input())) P = sorted([int(eval(input())) for x in range(N)]) m = P[N - 1] P = P[: N - 1] print((sum(P) + m // 2))
N = int(eval(input())) m, *P = sorted([int(eval(input())) for x in range(N)], reverse=True) """ m = P[N-1] P = P[:N-1] """ print((sum(P) + m // 2))
false
33.333333
[ "-P = sorted([int(eval(input())) for x in range(N)])", "-m = P[N - 1]", "-P = P[: N - 1]", "+m, *P = sorted([int(eval(input())) for x in range(N)], reverse=True)", "+\"\"\"", "+m = P[N-1]", "+P = P[:N-1]", "+\"\"\"" ]
false
0.046459
0.04535
1.024464
[ "s734888151", "s228918557" ]
u337626942
p02595
python
s447614585
s000187438
497
319
9,636
69,792
Accepted
Accepted
35.81
n, d=list(map(int, input().split())) cnt=0 for i in range(n): x, y=list(map(int, input().split())) tmp=(x**2 +y**2)**0.5 if tmp<=d: cnt+=1 print(cnt)
n, d=list(map(int, input().split())) cnt=0 for i in range(n): x, y=list(map(int, input().split())) tmp=x**2 + y**2 if tmp<=d**2: cnt+=1 print(cnt)
10
10
168
165
n, d = list(map(int, input().split())) cnt = 0 for i in range(n): x, y = list(map(int, input().split())) tmp = (x**2 + y**2) ** 0.5 if tmp <= d: cnt += 1 print(cnt)
n, d = list(map(int, input().split())) cnt = 0 for i in range(n): x, y = list(map(int, input().split())) tmp = x**2 + y**2 if tmp <= d**2: cnt += 1 print(cnt)
false
0
[ "- tmp = (x**2 + y**2) ** 0.5", "- if tmp <= d:", "+ tmp = x**2 + y**2", "+ if tmp <= d**2:" ]
false
0.043241
0.044373
0.974487
[ "s447614585", "s000187438" ]
u384935968
p03385
python
s016949266
s700236356
31
24
8,992
9,032
Accepted
Accepted
22.58
S = eval(input()) if S[0] == S[1] or S[0] == S[2] or S[1] == S[2]: print ('No') else: print ('Yes')
S = list(eval(input())) S.sort() a = ['a','b','c'] if S == a: print('Yes') else: print('No')
6
9
107
100
S = eval(input()) if S[0] == S[1] or S[0] == S[2] or S[1] == S[2]: print("No") else: print("Yes")
S = list(eval(input())) S.sort() a = ["a", "b", "c"] if S == a: print("Yes") else: print("No")
false
33.333333
[ "-S = eval(input())", "-if S[0] == S[1] or S[0] == S[2] or S[1] == S[2]:", "+S = list(eval(input()))", "+S.sort()", "+a = [\"a\", \"b\", \"c\"]", "+if S == a:", "+ print(\"Yes\")", "+else:", "-else:", "- print(\"Yes\")" ]
false
0.04044
0.041103
0.983873
[ "s016949266", "s700236356" ]
u309423187
p02755
python
s399332841
s022037729
22
18
3,064
2,940
Accepted
Accepted
18.18
a, b = list(map(int, input().split())) for i in range(10000): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit(0) else : print((-1))
a, b = list(map(int, input().split())) for i in range(1001): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) break else:print((-1))
10
8
175
159
a, b = list(map(int, input().split())) for i in range(10000): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) exit(0) else: print((-1))
a, b = list(map(int, input().split())) for i in range(1001): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) break else: print((-1))
false
20
[ "-for i in range(10000):", "+for i in range(1001):", "- exit(0)", "+ break" ]
false
0.04871
0.045298
1.075317
[ "s399332841", "s022037729" ]
u039355749
p02693
python
s810922165
s277303200
60
21
61,948
9,176
Accepted
Accepted
65
k = int(eval(input())) a, b = list(map(int, input().split())) if (a%k == 0 or b%k == 0): print('OK') elif (a//k != b//k): print('OK') else: print('NG')
k = int(eval(input())) a, b = list(map(int, input().split())) Flag = False for i in range(a, b+1): if (i%k == 0): Flag = True if (Flag): print('OK') else: print('NG')
9
12
154
177
k = int(eval(input())) a, b = list(map(int, input().split())) if a % k == 0 or b % k == 0: print("OK") elif a // k != b // k: print("OK") else: print("NG")
k = int(eval(input())) a, b = list(map(int, input().split())) Flag = False for i in range(a, b + 1): if i % k == 0: Flag = True if Flag: print("OK") else: print("NG")
false
25
[ "-if a % k == 0 or b % k == 0:", "- print(\"OK\")", "-elif a // k != b // k:", "+Flag = False", "+for i in range(a, b + 1):", "+ if i % k == 0:", "+ Flag = True", "+if Flag:" ]
false
0.034623
0.04102
0.844047
[ "s810922165", "s277303200" ]
u298297089
p03266
python
s844009132
s012607425
184
158
39,024
3,064
Accepted
Accepted
14.13
n,k = list(map(int, input().split())) kk = 2*k if k % 2: tmp = (n//k)**3 print(tmp) exit() kk = 0 k2 = 0 kkk = 0 for i in range(k//2,n+1): if i % k == 0: kk += 1 if i % k == k//2: k2 += 1 if i % k == 0 and i % k == k//2: kkk += 1 # print(i, kk, k2, kkk...
n,k = list(map(int, input().split())) a = 0 b = 0 c = 0 kk = k // 2 for i in range(1,n+1): d = 2*i if k % 2 == 0 and i % k == kk: a += 1 if i % k == 0: b += 1 if (k % 2 == 0 and i % k == kk) and i % k == 0: c += 1 print((a**3 + b**3 - c**3)) # print(a,b,c)
19
16
349
304
n, k = list(map(int, input().split())) kk = 2 * k if k % 2: tmp = (n // k) ** 3 print(tmp) exit() kk = 0 k2 = 0 kkk = 0 for i in range(k // 2, n + 1): if i % k == 0: kk += 1 if i % k == k // 2: k2 += 1 if i % k == 0 and i % k == k // 2: kkk += 1 # print(i, kk, k2, kkk...
n, k = list(map(int, input().split())) a = 0 b = 0 c = 0 kk = k // 2 for i in range(1, n + 1): d = 2 * i if k % 2 == 0 and i % k == kk: a += 1 if i % k == 0: b += 1 if (k % 2 == 0 and i % k == kk) and i % k == 0: c += 1 print((a**3 + b**3 - c**3)) # print(a,b,c)
false
15.789474
[ "-kk = 2 * k", "-if k % 2:", "- tmp = (n // k) ** 3", "- print(tmp)", "- exit()", "-kk = 0", "-k2 = 0", "-kkk = 0", "-for i in range(k // 2, n + 1):", "+a = 0", "+b = 0", "+c = 0", "+kk = k // 2", "+for i in range(1, n + 1):", "+ d = 2 * i", "+ if k % 2 == 0 and i % k ==...
false
0.03766
0.037349
1.008322
[ "s844009132", "s012607425" ]
u355371431
p02813
python
s945021952
s488340546
212
174
46,192
44,656
Accepted
Accepted
17.92
import itertools N = int(eval(input())) P = list(map(int,input().split())) Q = list(map(int,input().split())) seq = [x for x in range(1,N+1)] L = list(itertools.permutations(seq)) for i in range(len(L)): X = list(L[i]) if X == P: a = i + 1 if X == Q: b = i + 1 ans = abs(a-b) pri...
import itertools N = int(eval(input())) P = tuple(map(int,input().split())) Q = tuple(map(int,input().split())) A = list(itertools.permutations(list(range(1,N+1)))) ans = abs(A.index(P) - A.index(Q)) print(ans)
14
9
321
208
import itertools N = int(eval(input())) P = list(map(int, input().split())) Q = list(map(int, input().split())) seq = [x for x in range(1, N + 1)] L = list(itertools.permutations(seq)) for i in range(len(L)): X = list(L[i]) if X == P: a = i + 1 if X == Q: b = i + 1 ans = abs(a - b) print(an...
import itertools N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) A = list(itertools.permutations(list(range(1, N + 1)))) ans = abs(A.index(P) - A.index(Q)) print(ans)
false
35.714286
[ "-P = list(map(int, input().split()))", "-Q = list(map(int, input().split()))", "-seq = [x for x in range(1, N + 1)]", "-L = list(itertools.permutations(seq))", "-for i in range(len(L)):", "- X = list(L[i])", "- if X == P:", "- a = i + 1", "- if X == Q:", "- b = i + 1", "-...
false
0.04675
0.13248
0.352885
[ "s945021952", "s488340546" ]
u790710233
p03830
python
s987706564
s251527095
25
22
3,444
3,316
Accepted
Accepted
12
from collections import defaultdict n = int(eval(input())) MOD = 10**9+7 def factorization(n): retval = [] tmp = n for i in range(2, int(-(-n**.5//1))+1): if tmp % i == 0: cnt = 0 while tmp % i == 0: cnt += 1 tmp //= i ...
from collections import defaultdict MOD = 10**9+7 n = int(eval(input())) def sieve(n): n += 1 res = [i for i in range(n)] for p in range(2, int(n**.5)+1): if res[p] < p: continue for q in range(p**2, n, p): if res[q] == q: res[q] = p ...
36
36
690
627
from collections import defaultdict n = int(eval(input())) MOD = 10**9 + 7 def factorization(n): retval = [] tmp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if tmp % i == 0: cnt = 0 while tmp % i == 0: cnt += 1 tmp //= i r...
from collections import defaultdict MOD = 10**9 + 7 n = int(eval(input())) def sieve(n): n += 1 res = [i for i in range(n)] for p in range(2, int(n**0.5) + 1): if res[p] < p: continue for q in range(p**2, n, p): if res[q] == q: res[q] = p return...
false
0
[ "+MOD = 10**9 + 7", "-MOD = 10**9 + 7", "-def factorization(n):", "- retval = []", "- tmp = n", "- for i in range(2, int(-(-(n**0.5) // 1)) + 1):", "- if tmp % i == 0:", "- cnt = 0", "- while tmp % i == 0:", "- cnt += 1", "- tmp...
false
0.038022
0.040249
0.944679
[ "s987706564", "s251527095" ]
u193264896
p03031
python
s993093794
s552165239
43
30
5,168
9,088
Accepted
Accepted
30.23
from collections import deque from collections import Counter from itertools import product, permutations,combinations from operator import itemgetter from heapq import heappop, heappush from bisect import bisect_left, bisect_right, bisect #pypyではscipy, numpyは使えない #from scipy.sparse.csgraph import shortest_path,...
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline from itertools import product sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): N, M = list(map(int, readline().split())) S = [] for _ in range(M): k, *s = list(map(int, readline().spli...
43
36
1,254
751
from collections import deque from collections import Counter from itertools import product, permutations, combinations from operator import itemgetter from heapq import heappop, heappush from bisect import bisect_left, bisect_right, bisect # pypyではscipy, numpyは使えない # from scipy.sparse.csgraph import shortest_path, fl...
import sys read = sys.stdin.read readline = sys.stdin.buffer.readline from itertools import product sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): N, M = list(map(int, readline().split())) S = [] for _ in range(M): k, *s = list(map(int, readline().split())) S...
false
16.27907
[ "-from collections import deque", "-from collections import Counter", "-from itertools import product, permutations, combinations", "-from operator import itemgetter", "-from heapq import heappop, heappush", "-from bisect import bisect_left, bisect_right, bisect", "-", "-# pypyではscipy, numpyは使えない", ...
false
0.041552
0.041445
1.002587
[ "s993093794", "s552165239" ]
u745087332
p03296
python
s304525939
s890925522
39
18
4,336
3,064
Accepted
Accepted
53.85
import random n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(1, n-1): if A[i] == A[i-1]: ans += 1 while(1): A[i] = random.randrange(10000)+1 if A[i] != A[i-1] and A[i] != A[i+1]: break if A[-1] == A[-2]: ans += 1 print(ans)
# coding:utf-8 import sys INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split()...
15
29
313
589
import random n = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(1, n - 1): if A[i] == A[i - 1]: ans += 1 while 1: A[i] = random.randrange(10000) + 1 if A[i] != A[i - 1] and A[i] != A[i + 1]: break if A[-1] == A[-2]: ans += ...
# coding:utf-8 import sys INF = float("inf") MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline...
false
48.275862
[ "-import random", "+# coding:utf-8", "+import sys", "-n = int(eval(input()))", "-A = list(map(int, input().split()))", "-ans = 0", "-for i in range(1, n - 1):", "- if A[i] == A[i - 1]:", "- ans += 1", "- while 1:", "- A[i] = random.randrange(10000) + 1", "- ...
false
0.070545
0.063171
1.116727
[ "s304525939", "s890925522" ]
u925567828
p02947
python
s777827712
s933703771
716
249
26,308
20,028
Accepted
Accepted
65.22
N =int(eval(input())) #横文字数、縦N行の行列を作成 s = [list(eval(input())) for i in range(N)] #文字列をアルファベット順に並び替える for i in range(len(s)): s[i].sort() s.sort() ans = 0 cnt = 1 for i in range(1,N): for j in range(10): #1文とその次の文の文字を比較 #異なっていた場合はbreak if(s[i][j] != s[i-1][j]): ...
import sys import collections from functools import reduce import operator as op def nCr(n,r): r = min(r,n-r) """ operator.mul = 掛け算を行う関数""" """引数の2つ目は先頭を示す""" up = reduce(op.mul,list(range(n,n-r,-1)),1) down= reduce(op.mul,list(range(r,0,-1)),1) return up // down def main(): ...
23
29
438
649
N = int(eval(input())) # 横文字数、縦N行の行列を作成 s = [list(eval(input())) for i in range(N)] # 文字列をアルファベット順に並び替える for i in range(len(s)): s[i].sort() s.sort() ans = 0 cnt = 1 for i in range(1, N): for j in range(10): # 1文とその次の文の文字を比較 # 異なっていた場合はbreak if s[i][j] != s[i - 1][j]: break ...
import sys import collections from functools import reduce import operator as op def nCr(n, r): r = min(r, n - r) """ operator.mul = 掛け算を行う関数""" """引数の2つ目は先頭を示す""" up = reduce(op.mul, list(range(n, n - r, -1)), 1) down = reduce(op.mul, list(range(r, 0, -1)), 1) return up // down def main(): ...
false
20.689655
[ "-N = int(eval(input()))", "-# 横文字数、縦N行の行列を作成", "-s = [list(eval(input())) for i in range(N)]", "-# 文字列をアルファベット順に並び替える", "-for i in range(len(s)):", "- s[i].sort()", "-s.sort()", "-ans = 0", "-cnt = 1", "-for i in range(1, N):", "- for j in range(10):", "- # 1文とその次の文の文字を比較", "- ...
false
0.083887
0.09226
0.90924
[ "s777827712", "s933703771" ]
u844789719
p02625
python
s124028008
s760453407
813
203
52,384
112,204
Accepted
Accepted
75.03
max_fact = 5 * 10**5 mod = 10**9 + 7 f = [1] * (max_fact + 1) for idx in range(2, max_fact + 1): f[idx] = f[idx - 1] * idx f[idx] %= mod fi = [pow(f[-1], mod - 2, mod)] for idx in range(max_fact, 0, -1): fi += [fi[-1] * idx % mod] fi = fi[::-1] def factorial(n): return f[n] def factori...
class Factorial: def __init__(self, max_fact, mod): #mod should be prime number #using homogeneous_product(n,r), max_fact ≧ max(n+r-1) f = [1] * (max_fact + 1) for idx in range(2, max_fact + 1): f[idx] = f[idx - 1] * idx f[idx] %= mod fi = [pow...
39
50
802
1,348
max_fact = 5 * 10**5 mod = 10**9 + 7 f = [1] * (max_fact + 1) for idx in range(2, max_fact + 1): f[idx] = f[idx - 1] * idx f[idx] %= mod fi = [pow(f[-1], mod - 2, mod)] for idx in range(max_fact, 0, -1): fi += [fi[-1] * idx % mod] fi = fi[::-1] def factorial(n): return f[n] def factorial_inverse(n):...
class Factorial: def __init__(self, max_fact, mod): # mod should be prime number # using homogeneous_product(n,r), max_fact ≧ max(n+r-1) f = [1] * (max_fact + 1) for idx in range(2, max_fact + 1): f[idx] = f[idx - 1] * idx f[idx] %= mod fi = [pow(f[-1]...
false
22
[ "+class Factorial:", "+ def __init__(self, max_fact, mod):", "+ # mod should be prime number", "+ # using homogeneous_product(n,r), max_fact ≧ max(n+r-1)", "+ f = [1] * (max_fact + 1)", "+ for idx in range(2, max_fact + 1):", "+ f[idx] = f[idx - 1] * idx", "+ ...
false
1.050094
0.69269
1.515965
[ "s124028008", "s760453407" ]
u170201762
p02852
python
s307434635
s788979360
573
191
75,740
49,888
Accepted
Accepted
66.67
N,M = list(map(int,input().split())) S = eval(input()) N0 = 2**(N-1).bit_length() INF = 2**31-1 # k番目の要素をxに更新 def update(k, x, data): k += N0-1 data[k] = x while k >= 0: k = (k - 1) // 2 data[k] = min(data[2*k+1], data[2*k+2]) # [l,r)の最小値 def query(l, r, data): L = l + N...
N,M = list(map(int,input().split())) S = eval(input()) S = S[::-1] s = 0 used = [0] while s < N: for i in range(M,-1,-1): if s+i > N: i = N-s if S[s+i]=='0': s += i used.append(s) break if i==0: break if s==N: ans = [] ...
63
24
1,310
481
N, M = list(map(int, input().split())) S = eval(input()) N0 = 2 ** (N - 1).bit_length() INF = 2**31 - 1 # k番目の要素をxに更新 def update(k, x, data): k += N0 - 1 data[k] = x while k >= 0: k = (k - 1) // 2 data[k] = min(data[2 * k + 1], data[2 * k + 2]) # [l,r)の最小値 def query(l, r, data): L = l ...
N, M = list(map(int, input().split())) S = eval(input()) S = S[::-1] s = 0 used = [0] while s < N: for i in range(M, -1, -1): if s + i > N: i = N - s if S[s + i] == "0": s += i used.append(s) break if i == 0: break if s == N: ans = [] ...
false
61.904762
[ "-N0 = 2 ** (N - 1).bit_length()", "-INF = 2**31 - 1", "-# k番目の要素をxに更新", "-def update(k, x, data):", "- k += N0 - 1", "- data[k] = x", "- while k >= 0:", "- k = (k - 1) // 2", "- data[k] = min(data[2 * k + 1], data[2 * k + 2])", "-", "-", "-# [l,r)の最小値", "-def query(l,...
false
0.039185
0.064966
0.603161
[ "s307434635", "s788979360" ]
u583507988
p03073
python
s631121366
s123277572
101
88
11,732
89,464
Accepted
Accepted
12.87
S = eval(input()) s = [] for _ in S: s.append(int(_)) s1 = [1] s2 = [0] for i in range(1,len(s)): if s1[i-1] == 0: s1.append(1) else: s1.append(0) if s2[i-1] == 0: s2.append(1) else: s2.append(0) a = 0 b = 0 for j in range(len(s)): if s[j] != s1[j]: a += 1 if ...
s=eval(input()) n=len(s) d=[] for i in range(n): d.append(int(s[i])) s1=[0] s2=[1] for i in range(1,n): if s1[i-1]==0: s1.append(1) else: s1.append(0) if s2[i-1]==1: s2.append(0) else: s2.append(1) a,b=0,0 for i in range(n): if d[i]!=s1[i]: a+=1 if d[i]!=s2[i]: ...
24
23
357
336
S = eval(input()) s = [] for _ in S: s.append(int(_)) s1 = [1] s2 = [0] for i in range(1, len(s)): if s1[i - 1] == 0: s1.append(1) else: s1.append(0) if s2[i - 1] == 0: s2.append(1) else: s2.append(0) a = 0 b = 0 for j in range(len(s)): if s[j] != s1[j]: a...
s = eval(input()) n = len(s) d = [] for i in range(n): d.append(int(s[i])) s1 = [0] s2 = [1] for i in range(1, n): if s1[i - 1] == 0: s1.append(1) else: s1.append(0) if s2[i - 1] == 1: s2.append(0) else: s2.append(1) a, b = 0, 0 for i in range(n): if d[i] != s1[i]...
false
4.166667
[ "-S = eval(input())", "-s = []", "-for _ in S:", "- s.append(int(_))", "-s1 = [1]", "-s2 = [0]", "-for i in range(1, len(s)):", "+s = eval(input())", "+n = len(s)", "+d = []", "+for i in range(n):", "+ d.append(int(s[i]))", "+s1 = [0]", "+s2 = [1]", "+for i in range(1, n):", "- ...
false
0.036128
0.072558
0.497917
[ "s631121366", "s123277572" ]
u353797797
p02793
python
s596991784
s525308205
1,990
962
262,644
4,212
Accepted
Accepted
51.66
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in ...
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in ...
31
62
670
1,557
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [...
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [...
false
50
[ "+class mint:", "+ def __init__(self, x):", "+ self.__x = x % md", "+", "+ def __str__(self):", "+ return str(self.__x)", "+", "+ def __add__(self, other):", "+ if isinstance(other, mint):", "+ other = other.__x", "+ return mint(self.__x + other)",...
false
0.035778
0.058059
0.616221
[ "s596991784", "s525308205" ]
u281303342
p03854
python
s527451825
s476504396
72
37
3,188
3,188
Accepted
Accepted
48.61
S = input()[::-1] T = ["dream"[::-1],"dreamer"[::-1],"erase"[::-1],"eraser"[::-1]] Ans = "YES" while len(S) > 0: if S[0:5] in T: S = S[5:] continue elif S[0:6] in T: S = S[6:] continue elif S[0:7] in T: S = S[7:] continue else: Ans = ...
import sys S = eval(input()) S = S[::-1] AR = [] A = ["dream","dreamer","erase","eraser"] for a in A: AR.append(a[::-1]) i = 0 while i < len(S): for ar in AR: l = len(ar) if ar == S[i:i+l]: i += l break else: print("NO") sys.exit() ...
17
22
351
332
S = input()[::-1] T = ["dream"[::-1], "dreamer"[::-1], "erase"[::-1], "eraser"[::-1]] Ans = "YES" while len(S) > 0: if S[0:5] in T: S = S[5:] continue elif S[0:6] in T: S = S[6:] continue elif S[0:7] in T: S = S[7:] continue else: Ans = "NO" ...
import sys S = eval(input()) S = S[::-1] AR = [] A = ["dream", "dreamer", "erase", "eraser"] for a in A: AR.append(a[::-1]) i = 0 while i < len(S): for ar in AR: l = len(ar) if ar == S[i : i + l]: i += l break else: print("NO") sys.exit() print("YES")...
false
22.727273
[ "-S = input()[::-1]", "-T = [\"dream\"[::-1], \"dreamer\"[::-1], \"erase\"[::-1], \"eraser\"[::-1]]", "-Ans = \"YES\"", "-while len(S) > 0:", "- if S[0:5] in T:", "- S = S[5:]", "- continue", "- elif S[0:6] in T:", "- S = S[6:]", "- continue", "- elif S[0:7] ...
false
0.035965
0.03477
1.03436
[ "s527451825", "s476504396" ]
u729939940
p02780
python
s265748038
s708115172
151
99
32,032
32,232
Accepted
Accepted
34.44
N,K=list(map(int,input().split())) P=list(map(int,input().split())) from itertools import accumulate acc=[0] acc.extend(accumulate(P)) ans=0 for i in range(N-K+1): exp=(acc[K+i]-acc[i]+K)/2 ans=max(exp,ans) print(ans)
N,K=list(map(int,input().split())) P=list(map(int,input().split())) from itertools import accumulate acc=[0]+list(accumulate(P)) print(((max(b-a for a,b in zip(acc,acc[K:]))+K)/2))
10
5
224
176
N, K = list(map(int, input().split())) P = list(map(int, input().split())) from itertools import accumulate acc = [0] acc.extend(accumulate(P)) ans = 0 for i in range(N - K + 1): exp = (acc[K + i] - acc[i] + K) / 2 ans = max(exp, ans) print(ans)
N, K = list(map(int, input().split())) P = list(map(int, input().split())) from itertools import accumulate acc = [0] + list(accumulate(P)) print(((max(b - a for a, b in zip(acc, acc[K:])) + K) / 2))
false
50
[ "-acc = [0]", "-acc.extend(accumulate(P))", "-ans = 0", "-for i in range(N - K + 1):", "- exp = (acc[K + i] - acc[i] + K) / 2", "- ans = max(exp, ans)", "-print(ans)", "+acc = [0] + list(accumulate(P))", "+print(((max(b - a for a, b in zip(acc, acc[K:])) + K) / 2))" ]
false
0.037184
0.007506
4.95419
[ "s265748038", "s708115172" ]
u227082700
p02559
python
s231343417
s257325711
4,456
3,785
65,076
65,068
Accepted
Accepted
15.06
import sys input = lambda: sys.stdin.readline().rstrip() # BinaryIndexedTree # O(logN)で累積和取得と値の更新 # add(i,x)...i番目にxを加算 # sum(i,j)...[i,j)の累積和を取得 class BinaryIndexedTree: def __init__(self, n): self.bit = [0] * n def add(self, i, x): i += 1 while i <= len(self.bit): self.bit[i-1] +...
import sys input = lambda: sys.stdin.readline().rstrip() # UnionFind class FenwickTree: def __init__(self,n): self.n=n self.bit=[0]*(n+1) def add(self,i,x): i+=1 while i<=n: self.bit[i]+=x i+=i&-i def sumsub(self,r): ans=0 while r: ans+=self.bit[r] ...
43
34
853
674
import sys input = lambda: sys.stdin.readline().rstrip() # BinaryIndexedTree # O(logN)で累積和取得と値の更新 # add(i,x)...i番目にxを加算 # sum(i,j)...[i,j)の累積和を取得 class BinaryIndexedTree: def __init__(self, n): self.bit = [0] * n def add(self, i, x): i += 1 while i <= len(self.bit): self.bi...
import sys input = lambda: sys.stdin.readline().rstrip() # UnionFind class FenwickTree: def __init__(self, n): self.n = n self.bit = [0] * (n + 1) def add(self, i, x): i += 1 while i <= n: self.bit[i] += x i += i & -i def sumsub(self, r): an...
false
20.930233
[ "-# BinaryIndexedTree", "-# O(logN)で累積和取得と値の更新", "-# add(i,x)...i番目にxを加算", "-# sum(i,j)...[i,j)の累積和を取得", "-class BinaryIndexedTree:", "+# UnionFind", "+class FenwickTree:", "- self.bit = [0] * n", "+ self.n = n", "+ self.bit = [0] * (n + 1)", "- while i <= len(self.bi...
false
0.046075
0.129742
0.355124
[ "s231343417", "s257325711" ]
u075304271
p02802
python
s882263647
s937256632
466
181
25,012
11,400
Accepted
Accepted
61.16
import numpy as np from collections import Counter import fractions import math def main(): n, m = list(map(int, input().split())) p_list, s_list = ["a"] * m, ["a"] * m for i in range(m): p_list[i], s_list[i] = list(map(str, input().split())) p_list[i] = int(p_list[i]) pena = 0 mon_list, ...
import math import collections import fractions import itertools def solve(): n, m = list(map(int, input().split())) mon = [0]*n mon2 = [0]*n for i in range(m): q, a = input().split() q = int(q) if a == "AC": mon[q-1] = 1 else: if m...
26
27
657
558
import numpy as np from collections import Counter import fractions import math def main(): n, m = list(map(int, input().split())) p_list, s_list = ["a"] * m, ["a"] * m for i in range(m): p_list[i], s_list[i] = list(map(str, input().split())) p_list[i] = int(p_list[i]) pena = 0 mon...
import math import collections import fractions import itertools def solve(): n, m = list(map(int, input().split())) mon = [0] * n mon2 = [0] * n for i in range(m): q, a = input().split() q = int(q) if a == "AC": mon[q - 1] = 1 else: if mon[q - 1...
false
3.703704
[ "-import numpy as np", "-from collections import Counter", "+import math", "+import collections", "-import math", "+import itertools", "-def main():", "+def solve():", "- p_list, s_list = [\"a\"] * m, [\"a\"] * m", "+ mon = [0] * n", "+ mon2 = [0] * n", "- p_list[i], s_list[i] ...
false
0.067112
0.045218
1.484194
[ "s882263647", "s937256632" ]
u644907318
p02779
python
s607792987
s798657535
311
146
109,908
118,052
Accepted
Accepted
53.05
N = int(eval(input())) A = list(map(int,input().split())) C = {} for i in range(N): a = A[i] if a not in C: C[a] = 0 C[a] += 1 flag = 0 for a in C: if C[a]>1: flag = 1 break if flag==0: print("YES") else: print("NO")
N = int(eval(input())) A = list(map(int,input().split())) C = {} for i in range(N): a = A[i] if a not in C: C[a] = 0 C[a] += 1 if len(C)==N: print("YES") else: print("NO")
17
12
274
204
N = int(eval(input())) A = list(map(int, input().split())) C = {} for i in range(N): a = A[i] if a not in C: C[a] = 0 C[a] += 1 flag = 0 for a in C: if C[a] > 1: flag = 1 break if flag == 0: print("YES") else: print("NO")
N = int(eval(input())) A = list(map(int, input().split())) C = {} for i in range(N): a = A[i] if a not in C: C[a] = 0 C[a] += 1 if len(C) == N: print("YES") else: print("NO")
false
29.411765
[ "-flag = 0", "-for a in C:", "- if C[a] > 1:", "- flag = 1", "- break", "-if flag == 0:", "+if len(C) == N:" ]
false
0.086827
0.037429
2.319798
[ "s607792987", "s798657535" ]
u539281377
p02887
python
s850468122
s059487601
56
35
3,316
3,316
Accepted
Accepted
37.5
N=int(eval(input())) S=eval(input()) T=S[0] for i in range(1,N): if S[i-1]!=S[i]: T+=S[i] print((len(T)))
N=int(eval(input())) S=eval(input()) print((1+sum(S[i]!=S[i-1] for i in range(1,N))))
7
3
109
73
N = int(eval(input())) S = eval(input()) T = S[0] for i in range(1, N): if S[i - 1] != S[i]: T += S[i] print((len(T)))
N = int(eval(input())) S = eval(input()) print((1 + sum(S[i] != S[i - 1] for i in range(1, N))))
false
57.142857
[ "-T = S[0]", "-for i in range(1, N):", "- if S[i - 1] != S[i]:", "- T += S[i]", "-print((len(T)))", "+print((1 + sum(S[i] != S[i - 1] for i in range(1, N))))" ]
false
0.047469
0.045093
1.052691
[ "s850468122", "s059487601" ]
u691018832
p03599
python
s803744614
s314262183
355
22
3,188
3,064
Accepted
Accepted
93.8
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) a, b, c, d, e, f = list(map(int, readline().split())) A = 100 * a B = 100 * b E = 100 * e / (100 + e) ans = [0, 0] check = 0 for i in range(f // A + 2): fo...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) a, b, c, d, e, f = list(map(int, readline().split())) A = 100 * a B = 100 * b E = e / (100 + e) ans = [0, 0] check = 0 for i in range(f // A + 2): for j in...
30
33
856
937
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) a, b, c, d, e, f = list(map(int, readline().split())) A = 100 * a B = 100 * b E = 100 * e / (100 + e) ans = [0, 0] check = 0 for i in range(f // A + 2): for j in range(f ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) a, b, c, d, e, f = list(map(int, readline().split())) A = 100 * a B = 100 * b E = e / (100 + e) ans = [0, 0] check = 0 for i in range(f // A + 2): for j in range(f // B +...
false
9.090909
[ "-E = 100 * e / (100 + e)", "+E = e / (100 + e)", "- for k in range(int((w * E / 100) // c) + 2):", "- for l in range(int((w * E / 100) // d) + 2):", "+ for k in range(int((w * E) // c) + 2):", "+ for l in range(int((w * E) // d) + 2):", "- n = 100 * s ...
false
0.120247
0.036964
3.253099
[ "s803744614", "s314262183" ]
u561083515
p03053
python
s867199294
s751828402
692
387
105,976
108,200
Accepted
Accepted
44.08
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline def main(): H,W = list(map(int,input().split())) # 番兵法 (#を外周に設置する) visited = [[True]*(W+2)] visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)] visited.append([True]*(W+2)) # #の位置を...
import sys input = sys.stdin.readline def main(): H,W = list(map(int,input().split())) # 番兵法 (#を外周に設置する) visited = [[True]*(W+2)] visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)] visited.append([True]*(W+2)) # #の位置をqに格納 q = [] for i in...
45
44
1,138
1,108
import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline def main(): H, W = list(map(int, input().split())) # 番兵法 (#を外周に設置する) visited = [[True] * (W + 2)] visited += [ [True] + [x == "#" for x in input().rstrip()] + [True] for _ in range(H) ] visited.append([True] * (W + 2))...
import sys input = sys.stdin.readline def main(): H, W = list(map(int, input().split())) # 番兵法 (#を外周に設置する) visited = [[True] * (W + 2)] visited += [ [True] + [x == "#" for x in input().rstrip()] + [True] for _ in range(H) ] visited.append([True] * (W + 2)) # #の位置をqに格納 q = [] ...
false
2.222222
[ "-sys.setrecursionlimit(10**6)" ]
false
0.037626
0.04157
0.905129
[ "s867199294", "s751828402" ]
u347640436
p03213
python
s406342390
s931167768
32
25
9,348
9,528
Accepted
Accepted
21.88
# エラトステネスの篩 def make_prime_table(N): sieve = list(range(N + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(2, int(N ** 0.5) + 1): if sieve[i] != i: continue for j in range(i * i, N + 1, i): if sieve[j] == j: sieve[j] = i return sieve...
# エラトステネスの篩 def make_prime_table(n): sieve = list(range(n + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(2, int(n ** 0.5) + 1): if sieve[i] != i: continue for j in range(i * i, n + 1, i): if sieve[j] == j: sieve[j] = i return sieve...
56
67
1,096
1,284
# エラトステネスの篩 def make_prime_table(N): sieve = list(range(N + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(2, int(N**0.5) + 1): if sieve[i] != i: continue for j in range(i * i, N + 1, i): if sieve[j] == j: sieve[j] = i return sieve N = int(ev...
# エラトステネスの篩 def make_prime_table(n): sieve = list(range(n + 1)) sieve[0] = -1 sieve[1] = -1 for i in range(2, int(n**0.5) + 1): if sieve[i] != i: continue for j in range(i * i, n + 1, i): if sieve[j] == j: sieve[j] = i return sieve def prime_...
false
16.41791
[ "-def make_prime_table(N):", "- sieve = list(range(N + 1))", "+def make_prime_table(n):", "+ sieve = list(range(n + 1))", "- for i in range(2, int(N**0.5) + 1):", "+ for i in range(2, int(n**0.5) + 1):", "- for j in range(i * i, N + 1, i):", "+ for j in range(i * i, n + 1, i)...
false
0.039835
0.081797
0.487
[ "s406342390", "s931167768" ]
u156314159
p02694
python
s462130352
s463995094
300
57
79,032
63,464
Accepted
Accepted
81
from sys import exit def main(): X = int(eval(input())) deposit = 100 i = 0 while True: deposit = int(deposit * 1.01) i += 1 if deposit >= X: print(i) exit() if __name__ == '__main__': main()
# from sys import exit def main(): x = int(eval(input())) d = 100 ans = 0 while d < x: d = int(d*1.01) ans += 1 print(ans) if __name__ == '__main__': main()
17
14
273
210
from sys import exit def main(): X = int(eval(input())) deposit = 100 i = 0 while True: deposit = int(deposit * 1.01) i += 1 if deposit >= X: print(i) exit() if __name__ == "__main__": main()
# from sys import exit def main(): x = int(eval(input())) d = 100 ans = 0 while d < x: d = int(d * 1.01) ans += 1 print(ans) if __name__ == "__main__": main()
false
17.647059
[ "-from sys import exit", "-", "-", "+# from sys import exit", "- X = int(eval(input()))", "- deposit = 100", "- i = 0", "- while True:", "- deposit = int(deposit * 1.01)", "- i += 1", "- if deposit >= X:", "- print(i)", "- exit()", "+ ...
false
0.048503
0.065265
0.743175
[ "s462130352", "s463995094" ]
u021548497
p02579
python
s012680481
s703307433
906
355
96,800
93,056
Accepted
Accepted
60.82
import sys from collections import deque input = sys.stdin.readline def main(): h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) s = [input().replace("\n", "") for _ in range(h)] ans = [[-1]*w for _ in ra...
import sys from collections import deque input = sys.stdin.readline def main(): h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch += 1 cw += 1 dh += 1 dw += 1 s = ["#"*(w+4)] s...
51
59
1,577
1,532
import sys from collections import deque input = sys.stdin.readline def main(): h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) s = [input().replace("\n", "") for _ in range(h)] ans = [[-1] * w for _ in range(h)] ans[ch ...
import sys from collections import deque input = sys.stdin.readline def main(): h, w = list(map(int, input().split())) ch, cw = list(map(int, input().split())) dh, dw = list(map(int, input().split())) ch += 1 cw += 1 dh += 1 dw += 1 s = ["#" * (w + 4)] s.append("#" * (w + 4)) ...
false
13.559322
[ "- s = [input().replace(\"\\n\", \"\") for _ in range(h)]", "- ans = [[-1] * w for _ in range(h)]", "- ans[ch - 1][cw - 1] = 0", "- not_yet = deque([(ch - 1, cw - 1)])", "+ ch += 1", "+ cw += 1", "+ dh += 1", "+ dw += 1", "+ s = [\"#\" * (w + 4)]", "+ s.append(\"#\" *...
false
0.035879
0.056006
0.640626
[ "s012680481", "s703307433" ]
u143509139
p02681
python
s841450517
s818562054
58
26
61,572
8,840
Accepted
Accepted
55.17
s = eval(input()) t = eval(input()) for i in range(26): if s + chr(i + ord('a')) == t: print('Yes') break else: print('No')
s = eval(input()) t = eval(input()) if s == t[:-1]: print('Yes') else: print('No')
8
6
143
84
s = eval(input()) t = eval(input()) for i in range(26): if s + chr(i + ord("a")) == t: print("Yes") break else: print("No")
s = eval(input()) t = eval(input()) if s == t[:-1]: print("Yes") else: print("No")
false
25
[ "-for i in range(26):", "- if s + chr(i + ord(\"a\")) == t:", "- print(\"Yes\")", "- break", "+if s == t[:-1]:", "+ print(\"Yes\")" ]
false
0.031904
0.032986
0.967192
[ "s841450517", "s818562054" ]
u879870653
p02984
python
s194445716
s136049955
297
157
71,012
17,988
Accepted
Accepted
47.14
N = int(eval(input())) A = list(map(int,input().split())) calc = 0 for i in range(0,len(A),2) : calc += A[i] for i in range(1,len(A),2) : calc -= A[i] p = calc//2 X = [0 for i in range(N)] X[0] = p for i in range(1,len(X)) : X[i] = A[i-1] - X[i-1] ans = [x*2 for x in X] print((*ans)...
N = int(eval(input())) A = list(map(int,input().split())) X = [] ans = [] x0 = 0 for i,a in enumerate(A) : x0 += (a if i % 2 == 0 else -a) x0 //= 2 X.append(x0) ans.append(2*x0) for i in range(1,N) : xi = A[i-1] - X[-1] X.append(xi) ans.append(2*xi) print((*ans))
20
15
314
285
N = int(eval(input())) A = list(map(int, input().split())) calc = 0 for i in range(0, len(A), 2): calc += A[i] for i in range(1, len(A), 2): calc -= A[i] p = calc // 2 X = [0 for i in range(N)] X[0] = p for i in range(1, len(X)): X[i] = A[i - 1] - X[i - 1] ans = [x * 2 for x in X] print((*ans))
N = int(eval(input())) A = list(map(int, input().split())) X = [] ans = [] x0 = 0 for i, a in enumerate(A): x0 += a if i % 2 == 0 else -a x0 //= 2 X.append(x0) ans.append(2 * x0) for i in range(1, N): xi = A[i - 1] - X[-1] X.append(xi) ans.append(2 * xi) print((*ans))
false
25
[ "-calc = 0", "-for i in range(0, len(A), 2):", "- calc += A[i]", "-for i in range(1, len(A), 2):", "- calc -= A[i]", "-p = calc // 2", "-X = [0 for i in range(N)]", "-X[0] = p", "-for i in range(1, len(X)):", "- X[i] = A[i - 1] - X[i - 1]", "-ans = [x * 2 for x in X]", "+X = []", "+...
false
0.057361
0.035485
1.616487
[ "s194445716", "s136049955" ]
u843175622
p03588
python
s122950170
s632176695
307
253
10,868
22,712
Accepted
Accepted
17.59
n=int(eval(input())) a=[0]*-~n;b=[0]*-~n mx=-1 mi=-1 for i in range(n): a[i], b[i] = list(map(int,input().split())) if a[i] > mx: mx = a[i]; mi = i print((mx+b[mi]))
n = int(eval(input())) ab = [tuple(map(int, input().split())) for _ in range(n)] ab.sort() ans = ab[0][0] + ab[n - 1][1] + (ab[n - 1][0] - ab[0][0]) print(ans)
10
6
169
160
n = int(eval(input())) a = [0] * -~n b = [0] * -~n mx = -1 mi = -1 for i in range(n): a[i], b[i] = list(map(int, input().split())) if a[i] > mx: mx = a[i] mi = i print((mx + b[mi]))
n = int(eval(input())) ab = [tuple(map(int, input().split())) for _ in range(n)] ab.sort() ans = ab[0][0] + ab[n - 1][1] + (ab[n - 1][0] - ab[0][0]) print(ans)
false
40
[ "-a = [0] * -~n", "-b = [0] * -~n", "-mx = -1", "-mi = -1", "-for i in range(n):", "- a[i], b[i] = list(map(int, input().split()))", "- if a[i] > mx:", "- mx = a[i]", "- mi = i", "-print((mx + b[mi]))", "+ab = [tuple(map(int, input().split())) for _ in range(n)]", "+ab.sort...
false
0.041022
0.039282
1.044287
[ "s122950170", "s632176695" ]
u857428111
p03715
python
s019239805
s954791384
312
195
65,644
39,920
Accepted
Accepted
37.5
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input= lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**9) def pin(type=int):return list(map(type,input().split())) def tupin(t=int):return tuple(pin(t)) def lispin(t=int):return list(pin(t)) #%%code from fractions import gcd def...
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input= lambda: sys.stdin.readline().rstrip() def pin(type=int):return list(map(type,input().split())) def tupin(t=int):return tuple(pin(t)) #%%code def resolve(): H,W=pin() if H%3==0 or W%3==0: print((0)) return # ...
39
33
905
703
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**9) def pin(type=int): return list(map(type, input().split())) def tupin(t=int): return tuple(pin(t)) def lispin(t=int): return list(pin(t)) #%%code from fractions ...
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input = lambda: sys.stdin.readline().rstrip() def pin(type=int): return list(map(type, input().split())) def tupin(t=int): return tuple(pin(t)) #%%code def resolve(): H, W = pin() if H % 3 == 0 or W % 3 == 0: print((0)) ...
false
15.384615
[ "-sys.setrecursionlimit(10**9)", "-def lispin(t=int):", "- return list(pin(t))", "-", "-", "-from fractions import gcd", "-", "-", "- # たてに切る", "- hori = 0 if W % 3 == 0 else H", "- # よこにきる", "- vert = 0 if H % 3 == 0 else W", "- # たてに切った後よこ", "- sp1 = H * W", "- ...
false
0.074109
0.069774
1.062137
[ "s019239805", "s954791384" ]
u644907318
p03221
python
s117891941
s939093824
1,124
934
53,120
82,452
Accepted
Accepted
16.9
N,M = list(map(int,input().split())) G = {} for i in range(M): P,Y = list(map(int,input().split())) if P not in G: G[P]=[] G[P].append((i+1,Y)) C = [] for P in G: G[P] = sorted(G[P],key=lambda x:x[1]) a = len(str(P)) x = "0"*(6-a)+str(P) for i in range(len(G[P])): ...
from bisect import bisect_left N,M = list(map(int,input().split())) C = {i:[] for i in range(1,N+1)} city = [0 for _ in range(M+1)] for j in range(1,M+1): p,y = list(map(int,input().split())) C[p].append((y,j)) city[j]=(p,y) for p in C: if len(C[p])>0: C[p] = sorted(C[p],key=lambda x:x...
19
21
458
537
N, M = list(map(int, input().split())) G = {} for i in range(M): P, Y = list(map(int, input().split())) if P not in G: G[P] = [] G[P].append((i + 1, Y)) C = [] for P in G: G[P] = sorted(G[P], key=lambda x: x[1]) a = len(str(P)) x = "0" * (6 - a) + str(P) for i in range(len(G[P])): ...
from bisect import bisect_left N, M = list(map(int, input().split())) C = {i: [] for i in range(1, N + 1)} city = [0 for _ in range(M + 1)] for j in range(1, M + 1): p, y = list(map(int, input().split())) C[p].append((y, j)) city[j] = (p, y) for p in C: if len(C[p]) > 0: C[p] = sorted(C[p], key...
false
9.52381
[ "+from bisect import bisect_left", "+", "-G = {}", "-for i in range(M):", "- P, Y = list(map(int, input().split()))", "- if P not in G:", "- G[P] = []", "- G[P].append((i + 1, Y))", "-C = []", "-for P in G:", "- G[P] = sorted(G[P], key=lambda x: x[1])", "- a = len(str(P))...
false
0.037662
0.038346
0.982167
[ "s117891941", "s939093824" ]
u644907318
p02777
python
s239266206
s171823308
160
63
38,256
61,896
Accepted
Accepted
60.62
S,T = input().split() A,B = list(map(int,input().split())) U = input().strip() if U==S: print((A-1,B)) else: print((A,B-1))
S,T = input().split() A,B = list(map(int,input().split())) U = input().strip() if S==U: print((A-1,B)) else: print((A,B-1))
7
7
127
127
S, T = input().split() A, B = list(map(int, input().split())) U = input().strip() if U == S: print((A - 1, B)) else: print((A, B - 1))
S, T = input().split() A, B = list(map(int, input().split())) U = input().strip() if S == U: print((A - 1, B)) else: print((A, B - 1))
false
0
[ "-if U == S:", "+if S == U:" ]
false
0.037042
0.037152
0.997029
[ "s239266206", "s171823308" ]
u479719434
p03167
python
s126348699
s448818889
958
494
44,608
44,636
Accepted
Accepted
48.43
mod = 10**9+7 def main(): H, W = list(map(int, input().split())) a = [eval(input()) for _ in range(H)] dp = [[0 for _ in range(W)] for _ in range(H)] dp[0][0] = 1 for i in range(H): for j in range(W): if a[i][j] == ".": if j+1 < W: ...
mod = 10**9+7 def main(): H, W = list(map(int, input().split())) a = [eval(input()) for _ in range(H)] dp = [[0 for _ in range(W)] for _ in range(H)] dp[0][0] = 1 for i in range(H): for j in range(W): if i != 0 or j != 0: if a[i][j] == ".": ...
22
19
555
462
mod = 10**9 + 7 def main(): H, W = list(map(int, input().split())) a = [eval(input()) for _ in range(H)] dp = [[0 for _ in range(W)] for _ in range(H)] dp[0][0] = 1 for i in range(H): for j in range(W): if a[i][j] == ".": if j + 1 < W: dp[i][...
mod = 10**9 + 7 def main(): H, W = list(map(int, input().split())) a = [eval(input()) for _ in range(H)] dp = [[0 for _ in range(W)] for _ in range(H)] dp[0][0] = 1 for i in range(H): for j in range(W): if i != 0 or j != 0: if a[i][j] == ".": ...
false
13.636364
[ "- if a[i][j] == \".\":", "- if j + 1 < W:", "- dp[i][j + 1] += dp[i][j]", "- dp[i][j + 1] %= mod", "- if i + 1 < H:", "- dp[i + 1][j] += dp[i][j]", "- dp[i + 1][j] %= mod", "+ ...
false
0.075428
0.032979
2.287146
[ "s126348699", "s448818889" ]
u777283665
p03578
python
s996615285
s130623653
262
239
67,680
67,680
Accepted
Accepted
8.78
from collections import Counter n = int(eval(input())) D = Counter(input().split()) m = int(eval(input())) for i, j in list(Counter(input().split()).items()): if i not in D or D[i] < j: print("NO") exit() print("YES")
from collections import Counter eval(input()) d = Counter(input().split()) eval(input()) t = Counter(input().split()) if all(ti in d and d[ti] >= tc for ti, tc in list(t.items())): print("YES") else: print("NO")
9
11
227
213
from collections import Counter n = int(eval(input())) D = Counter(input().split()) m = int(eval(input())) for i, j in list(Counter(input().split()).items()): if i not in D or D[i] < j: print("NO") exit() print("YES")
from collections import Counter eval(input()) d = Counter(input().split()) eval(input()) t = Counter(input().split()) if all(ti in d and d[ti] >= tc for ti, tc in list(t.items())): print("YES") else: print("NO")
false
18.181818
[ "-n = int(eval(input()))", "-D = Counter(input().split())", "-m = int(eval(input()))", "-for i, j in list(Counter(input().split()).items()):", "- if i not in D or D[i] < j:", "- print(\"NO\")", "- exit()", "-print(\"YES\")", "+eval(input())", "+d = Counter(input().split())", "+e...
false
0.036224
0.037418
0.968101
[ "s996615285", "s130623653" ]
u729133443
p03533
python
s058088426
s529190269
22
19
3,188
3,188
Accepted
Accepted
13.64
import re;print((['NO','YES'][re.match('A?KIHA?BA?RA?$',eval(input()))!=None]))
import re;print(('YES'if re.match('A?KIHA?BA?RA?$',eval(input()))else 'NO'))
1
1
71
68
import re print((["NO", "YES"][re.match("A?KIHA?BA?RA?$", eval(input())) != None]))
import re print(("YES" if re.match("A?KIHA?BA?RA?$", eval(input())) else "NO"))
false
0
[ "-print(([\"NO\", \"YES\"][re.match(\"A?KIHA?BA?RA?$\", eval(input())) != None]))", "+print((\"YES\" if re.match(\"A?KIHA?BA?RA?$\", eval(input())) else \"NO\"))" ]
false
0.049831
0.049373
1.009277
[ "s058088426", "s529190269" ]
u241159583
p03379
python
s761056506
s183281953
388
178
49,028
30,764
Accepted
Accepted
54.12
n = int(eval(input())) x = list(enumerate(map(int, input().split()))) x.sort(key=lambda x:x[1]) ans = [""]*n for i in range(n): if (n+1)//2 >= i+1: ans[x[i][0]] = x[(n+1)//2][1] else: ans[x[i][0]] = x[(n+1)//2-1][1] print(("\n".join(map(str, ans))))
n = int(eval(input())) X = list(map(int, input().split())) x = sorted(X) l = x[n//2-1] r = x[n//2] for i in range(n): if X[i] <= l: print(r) else: print(l)
9
10
254
182
n = int(eval(input())) x = list(enumerate(map(int, input().split()))) x.sort(key=lambda x: x[1]) ans = [""] * n for i in range(n): if (n + 1) // 2 >= i + 1: ans[x[i][0]] = x[(n + 1) // 2][1] else: ans[x[i][0]] = x[(n + 1) // 2 - 1][1] print(("\n".join(map(str, ans))))
n = int(eval(input())) X = list(map(int, input().split())) x = sorted(X) l = x[n // 2 - 1] r = x[n // 2] for i in range(n): if X[i] <= l: print(r) else: print(l)
false
10
[ "-x = list(enumerate(map(int, input().split())))", "-x.sort(key=lambda x: x[1])", "-ans = [\"\"] * n", "+X = list(map(int, input().split()))", "+x = sorted(X)", "+l = x[n // 2 - 1]", "+r = x[n // 2]", "- if (n + 1) // 2 >= i + 1:", "- ans[x[i][0]] = x[(n + 1) // 2][1]", "+ if X[i] <= ...
false
0.040243
0.077472
0.51946
[ "s761056506", "s183281953" ]
u707960254
p02697
python
s799146356
s584233622
105
96
79,968
80,352
Accepted
Accepted
8.57
def odd(): for i in range(M): print((order[i], reverse[i])) def multipule4(): d = 0 for i in range(M): if reverse[i] - order[i] == N//2: d = 1 print((order[i+d], reverse[i])) def even(): d = 0 for i in range(M): if i == (N//2-1) //2: ...
def main(): d = 0 for i in range(M): if N%4 == 0 and reverse[i] - order[i] == N//2: d = 1 if N%2 == 0 and i == (N//2-1) //2: d = 1 print((order[i+d], reverse[i])) N, M = list(map(int, input().split())) order = [i for i in range(2, N+1)] reverse = order...
29
13
548
326
def odd(): for i in range(M): print((order[i], reverse[i])) def multipule4(): d = 0 for i in range(M): if reverse[i] - order[i] == N // 2: d = 1 print((order[i + d], reverse[i])) def even(): d = 0 for i in range(M): if i == (N // 2 - 1) // 2: ...
def main(): d = 0 for i in range(M): if N % 4 == 0 and reverse[i] - order[i] == N // 2: d = 1 if N % 2 == 0 and i == (N // 2 - 1) // 2: d = 1 print((order[i + d], reverse[i])) N, M = list(map(int, input().split())) order = [i for i in range(2, N + 1)] reverse = ...
false
55.172414
[ "-def odd():", "- for i in range(M):", "- print((order[i], reverse[i]))", "-", "-", "-def multipule4():", "+def main():", "- if reverse[i] - order[i] == N // 2:", "+ if N % 4 == 0 and reverse[i] - order[i] == N // 2:", "- print((order[i + d], reverse[i]))", "-", ...
false
0.040843
0.040194
1.016135
[ "s799146356", "s584233622" ]
u691896522
p02781
python
s654233510
s279085629
1,953
169
83,804
38,256
Accepted
Accepted
91.35
n = eval(input()) K = int(eval(input())) len_n = len(n) ans = 0 #自由な数字を選んでいいのかどうか?、今使った0以外、今の桁数 def calc(free, count, now): global ans if count == K: ans += 1 return if now == len_n: return if free: for _ in range(9): calc(free, count + 1, now+1...
n = eval(input()) k = int(eval(input())) #nより小さいことが確定しているdp #dp_0[i][j] := i桁目まで決めて、0でない数字をj個使った時の数字の個数 dp_0 = [[0 for i in range(k+1)] for j in range(len(n))] #nより小さいことが確定していないdp #dp_1[i][j] := i桁目まで決めて、0でない数字をj個使った時の数字の個数。 dp_1 = [[0 for i in range(k+1)] for j in range(len(n))] dp_0[0][0] = 1 dp_0[0][1] = in...
30
34
730
1,125
n = eval(input()) K = int(eval(input())) len_n = len(n) ans = 0 # 自由な数字を選んでいいのかどうか?、今使った0以外、今の桁数 def calc(free, count, now): global ans if count == K: ans += 1 return if now == len_n: return if free: for _ in range(9): calc(free, count + 1, now + 1) # ...
n = eval(input()) k = int(eval(input())) # nより小さいことが確定しているdp # dp_0[i][j] := i桁目まで決めて、0でない数字をj個使った時の数字の個数 dp_0 = [[0 for i in range(k + 1)] for j in range(len(n))] # nより小さいことが確定していないdp # dp_1[i][j] := i桁目まで決めて、0でない数字をj個使った時の数字の個数。 dp_1 = [[0 for i in range(k + 1)] for j in range(len(n))] dp_0[0][0] = 1 dp_0[0][1] = int...
false
11.764706
[ "-K = int(eval(input()))", "-len_n = len(n)", "-ans = 0", "-# 自由な数字を選んでいいのかどうか?、今使った0以外、今の桁数", "-def calc(free, count, now):", "- global ans", "- if count == K:", "- ans += 1", "- return", "- if now == len_n:", "- return", "- if free:", "- for _ in ran...
false
0.061906
0.036595
1.691686
[ "s654233510", "s279085629" ]
u297574184
p02892
python
s381653158
s969395071
1,024
189
3,948
3,700
Accepted
Accepted
81.54
from collections import deque N = int(eval(input())) Sss = [eval(input()) for _ in range(N)] adjL = [[] for _ in range(N)] for i, Ss in enumerate(Sss): for j, S in enumerate(Ss): if S == '1': adjL[i].append(j) def IsBipartiteGraph(adjList): def bfs(vSt): colors[vSt] =...
from collections import deque N = int(eval(input())) Sss = [eval(input()) for _ in range(N)] adjL = [[] for _ in range(N)] for i, Ss in enumerate(Sss): for j, S in enumerate(Ss): if S == '1': adjL[i].append(j) def IsBipartiteGraph(adjList): def bfs(vSt): colors[vSt] =...
58
57
1,497
1,506
from collections import deque N = int(eval(input())) Sss = [eval(input()) for _ in range(N)] adjL = [[] for _ in range(N)] for i, Ss in enumerate(Sss): for j, S in enumerate(Ss): if S == "1": adjL[i].append(j) def IsBipartiteGraph(adjList): def bfs(vSt): colors[vSt] = 1 Q ...
from collections import deque N = int(eval(input())) Sss = [eval(input()) for _ in range(N)] adjL = [[] for _ in range(N)] for i, Ss in enumerate(Sss): for j, S in enumerate(Ss): if S == "1": adjL[i].append(j) def IsBipartiteGraph(adjList): def bfs(vSt): colors[vSt] = 1 Q ...
false
1.724138
[ "-def WarshallFloyd(adjList):", "+def getDiameterOfUnweightedGraph(adjList):", "- D = [[float(\"inf\")] * numV for _ in range(numV)]", "- for u, adj in enumerate(adjList):", "- for v in adj:", "- D[u][v] = 1", "- D[u][u] = 0", "- for k in range(numV):", "- Dk...
false
0.133438
0.085293
1.564477
[ "s381653158", "s969395071" ]
u298633786
p03012
python
s052729980
s876364751
323
154
21,536
12,744
Accepted
Accepted
52.32
import numpy as np num = int(eval(input())) inputs = np.array(input().split(), dtype=np.int32) left = 0 right = len(inputs)-1 diff = 0 while left <= right: if diff == 0: diff += inputs[left] - inputs[right] left += 1 right -= 1 elif diff < 0: diff += inputs[left...
import numpy as np N = int(eval(input())) inputs = np.array(input().split(), dtype=np.uint8) total = inputs.sum() s1 = 0 diffs = [] for t in range(N): s1 += inputs[t] s2 = total - s1 diff = np.abs(s1-s2) diffs.append(int(diff)) print((np.min(diffs)))
22
16
428
277
import numpy as np num = int(eval(input())) inputs = np.array(input().split(), dtype=np.int32) left = 0 right = len(inputs) - 1 diff = 0 while left <= right: if diff == 0: diff += inputs[left] - inputs[right] left += 1 right -= 1 elif diff < 0: diff += inputs[left] left ...
import numpy as np N = int(eval(input())) inputs = np.array(input().split(), dtype=np.uint8) total = inputs.sum() s1 = 0 diffs = [] for t in range(N): s1 += inputs[t] s2 = total - s1 diff = np.abs(s1 - s2) diffs.append(int(diff)) print((np.min(diffs)))
false
27.272727
[ "-num = int(eval(input()))", "-inputs = np.array(input().split(), dtype=np.int32)", "-left = 0", "-right = len(inputs) - 1", "-diff = 0", "-while left <= right:", "- if diff == 0:", "- diff += inputs[left] - inputs[right]", "- left += 1", "- right -= 1", "- elif diff <...
false
0.184499
0.181407
1.017044
[ "s052729980", "s876364751" ]
u645250356
p02838
python
s821938578
s077091170
843
218
119,980
124,184
Accepted
Accepted
74.14
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions from decimal import Decimal sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, ...
26
25
646
628
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions from decimal import Decimal sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush from bisect import bisect_left, bisect_right import sys, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return ...
false
3.846154
[ "-from heapq import heappop, heappush, heapify", "-import sys, bisect, math, itertools, fractions", "-from decimal import Decimal", "+from heapq import heappop, heappush", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools, fractions, pprint", "-a.sort()", "-lmx = len(bin(a...
false
0.167508
0.127871
1.309977
[ "s821938578", "s077091170" ]
u133936772
p02598
python
s719956788
s603950979
764
576
31,076
30,656
Accepted
Accepted
24.61
from math import * f=lambda:[*list(map(int,input().split()))] n,k=f() a=f() def ok(x): c=0 for i in a: c+=ceil(i/x) return c<=n+k l,r=0,10**9 while r-l>1: m=(l+r)/2 if ok(m): r=m else: l=m t=ceil(r) print((t-ok(t-1) if t>1 else t))
f=lambda:[*list(map(int,input().split()))] n,k=f() a=f() def ok(x): c=0 for i in a: c+=0--i//x return c<=n+k l,r=0,10**9 while r-l>1: m=l+r>>1 if ok(m): r=m else: l=m print(r)
16
14
254
198
from math import * f = lambda: [*list(map(int, input().split()))] n, k = f() a = f() def ok(x): c = 0 for i in a: c += ceil(i / x) return c <= n + k l, r = 0, 10**9 while r - l > 1: m = (l + r) / 2 if ok(m): r = m else: l = m t = ceil(r) print((t - ok(t - 1) if t > 1...
f = lambda: [*list(map(int, input().split()))] n, k = f() a = f() def ok(x): c = 0 for i in a: c += 0 - -i // x return c <= n + k l, r = 0, 10**9 while r - l > 1: m = l + r >> 1 if ok(m): r = m else: l = m print(r)
false
12.5
[ "-from math import *", "-", "- c += ceil(i / x)", "+ c += 0 - -i // x", "- m = (l + r) / 2", "+ m = l + r >> 1", "-t = ceil(r)", "-print((t - ok(t - 1) if t > 1 else t))", "+print(r)" ]
false
0.043216
0.098969
0.436666
[ "s719956788", "s603950979" ]
u707498674
p03599
python
s226947519
s432046968
985
503
3,064
94,888
Accepted
Accepted
48.93
import math A,B,C,D,E,F = list(map(int, input().split())) water = A suger = 0 for a in range(31): for b in range(31): subwater = A * a + B * b if subwater == 0: continue for c in range(1501): subsuger = C * c if subsuger <= subwater * E: ...
import math import bisect A,B,C,D,E,F = list(map(int, input().split())) x = [A * a + B * b for b in range(31) for a in range(31)] y = [C * c + D * d for d in range(1501) for c in range(1501)] x.remove(0) x = list(set(x)) y = list(set(y)) x.sort() y.sort() x = x[:bisect.bisect_right(x,F//100+1)] y = y[:bisect...
18
23
759
605
import math A, B, C, D, E, F = list(map(int, input().split())) water = A suger = 0 for a in range(31): for b in range(31): subwater = A * a + B * b if subwater == 0: continue for c in range(1501): subsuger = C * c if subsuger <= subwater * E: ...
import math import bisect A, B, C, D, E, F = list(map(int, input().split())) x = [A * a + B * b for b in range(31) for a in range(31)] y = [C * c + D * d for d in range(1501) for c in range(1501)] x.remove(0) x = list(set(x)) y = list(set(y)) x.sort() y.sort() x = x[: bisect.bisect_right(x, F // 100 + 1)] y = y[: bise...
false
21.73913
[ "+import bisect", "+x = [A * a + B * b for b in range(31) for a in range(31)]", "+y = [C * c + D * d for d in range(1501) for c in range(1501)]", "+x.remove(0)", "+x = list(set(x))", "+y = list(set(y))", "+x.sort()", "+y.sort()", "+x = x[: bisect.bisect_right(x, F // 100 + 1)]", "+y = y[: bisect.b...
false
2.510987
1.263896
1.986703
[ "s226947519", "s432046968" ]
u297574184
p02964
python
s322844898
s549977843
2,000
417
349,640
48,812
Accepted
Accepted
79.15
def solve(): N, K = list(map(int, input().split())) As = list(map(int, input().split())) def getDistNexts(As): lenA = len(As) poss = dict() for i, A in enumerate(As): if A not in poss: poss[A] = i + lenA distNexts = [0]*(lenA) ...
N, K = list(map(int, input().split())) As = list(map(int, input().split())) def getDistNexts(As): lenA = len(As) poss = dict() for i, A in enumerate(As): if A not in poss: poss[A] = i + lenA distNexts = [0]*(lenA) for i in reversed(list(range(lenA))): distNe...
54
48
1,264
1,028
def solve(): N, K = list(map(int, input().split())) As = list(map(int, input().split())) def getDistNexts(As): lenA = len(As) poss = dict() for i, A in enumerate(As): if A not in poss: poss[A] = i + lenA distNexts = [0] * (lenA) for i in r...
N, K = list(map(int, input().split())) As = list(map(int, input().split())) def getDistNexts(As): lenA = len(As) poss = dict() for i, A in enumerate(As): if A not in poss: poss[A] = i + lenA distNexts = [0] * (lenA) for i in reversed(list(range(lenA))): distNexts[i] = p...
false
11.111111
[ "-def solve():", "- N, K = list(map(int, input().split()))", "- As = list(map(int, input().split()))", "-", "- def getDistNexts(As):", "- lenA = len(As)", "- poss = dict()", "- for i, A in enumerate(As):", "- if A not in poss:", "- poss[A] = ...
false
0.08314
0.104934
0.792304
[ "s322844898", "s549977843" ]
u285891772
p03555
python
s329167294
s151613642
42
38
5,400
5,148
Accepted
Accepted
9.52
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ...
27
24
898
849
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_...
false
11.111111
[ "-if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:", "- print(\"YES\")", "-else:", "- print(\"NO\")", "+print((\"YES\" if a == b[::-1] else \"NO\"))" ]
false
0.040256
0.044
0.91491
[ "s329167294", "s151613642" ]
u793868662
p02953
python
s446362403
s293881010
71
65
14,252
14,224
Accepted
Accepted
8.45
def resolve(): n = int(eval(input())) h = list(map(int, input().split())) flag = 0 for i in range(n-1): if h[i] == h[i+1]: continue else: h[i+1] -= 1 if h[i] <= h[i+1]: continue else: print("No") ...
def resolve(): n = int(eval(input())) h = list(map(int, input().split())) OK = True for i in range(1, len(h)): if h[i] == h[i-1]: continue elif h[i] > h[i-1]: h[i] -= 1 else: OK = False break if OK: print("Y...
16
17
366
361
def resolve(): n = int(eval(input())) h = list(map(int, input().split())) flag = 0 for i in range(n - 1): if h[i] == h[i + 1]: continue else: h[i + 1] -= 1 if h[i] <= h[i + 1]: continue else: print("No") ...
def resolve(): n = int(eval(input())) h = list(map(int, input().split())) OK = True for i in range(1, len(h)): if h[i] == h[i - 1]: continue elif h[i] > h[i - 1]: h[i] -= 1 else: OK = False break if OK: print("Yes") ...
false
5.882353
[ "- flag = 0", "- for i in range(n - 1):", "- if h[i] == h[i + 1]:", "+ OK = True", "+ for i in range(1, len(h)):", "+ if h[i] == h[i - 1]:", "+ elif h[i] > h[i - 1]:", "+ h[i] -= 1", "- h[i + 1] -= 1", "- if h[i] <= h[i + 1]:", "-...
false
0.148678
0.073219
2.030587
[ "s446362403", "s293881010" ]
u359358631
p03157
python
s946314403
s747179347
194
179
108,620
108,692
Accepted
Accepted
7.73
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1 for _ in range(n)] # 各要素の親 自分が根の場合は -1 * (木の要素数) def root(self, x): # xが属する木の根を返す if self.parents[x] < 0: # 自分が根の場合 return x else: self.parents[x] = self.root(self.parents...
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1 for _ in range(n)] # 各要素の親 自分が根の場合は -1 * (木の要素数) def root(self, x): # xが属する木の根を返す if self.parents[x] < 0: # 自分が根の場合 return x else: self.parents[x] = self.root(self.parents...
64
65
1,827
1,972
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1 for _ in range(n)] # 各要素の親 自分が根の場合は -1 * (木の要素数) def root(self, x): # xが属する木の根を返す if self.parents[x] < 0: # 自分が根の場合 return x else: self.parents[x] = self.root(self.parents[x]) ...
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1 for _ in range(n)] # 各要素の親 自分が根の場合は -1 * (木の要素数) def root(self, x): # xが属する木の根を返す if self.parents[x] < 0: # 自分が根の場合 return x else: self.parents[x] = self.root(self.parents[x]) ...
false
1.538462
[ "- if self.parents[x_root] > self.parents[y_root]: # x_rootの要素数 > y_rootの要素数 にする", "+ if self.parents[x_root] > self.parents[y_root]: # x_rootの要素数 > y_rootの要素数 にしたい", "- self.parents[x_root] += self.parents[y_root]", "+ self.parents[x_root] += self.parents[y_root] # x_rootにy_roo...
false
0.037071
0.036223
1.023418
[ "s946314403", "s747179347" ]
u623814058
p03862
python
s143744224
s690553925
103
93
19,960
19,996
Accepted
Accepted
9.71
N,X=list(map(int,input().split())) *A,=list(map(int,input().split())) B=[a if a<=X else X for a in A] c=sum(A)-sum(B) for i in range(N-1): t=B[i]+B[i+1] if X < t: d=t-X B[i+1]-=d c+=d print(c)
f=lambda:list(map(int,input().split())) N,X=f() *A,=f() B=[a if a<=X else X for a in A] c=sum(A)-sum(B) for i in range(N-1): t=B[i]+B[i+1] if X < t: d=t-X B[i+1]-=d c+=d print(c)
12
13
206
199
N, X = list(map(int, input().split())) (*A,) = list(map(int, input().split())) B = [a if a <= X else X for a in A] c = sum(A) - sum(B) for i in range(N - 1): t = B[i] + B[i + 1] if X < t: d = t - X B[i + 1] -= d c += d print(c)
f = lambda: list(map(int, input().split())) N, X = f() (*A,) = f() B = [a if a <= X else X for a in A] c = sum(A) - sum(B) for i in range(N - 1): t = B[i] + B[i + 1] if X < t: d = t - X B[i + 1] -= d c += d print(c)
false
7.692308
[ "-N, X = list(map(int, input().split()))", "-(*A,) = list(map(int, input().split()))", "+f = lambda: list(map(int, input().split()))", "+N, X = f()", "+(*A,) = f()" ]
false
0.038087
0.072457
0.525645
[ "s143744224", "s690553925" ]
u678167152
p02971
python
s205216381
s556836066
542
492
12,508
14,752
Accepted
Accepted
9.23
N = int(eval(input())) A = [0]*N for i in range(N): A[i] = int(eval(input())) #print(A) M = max(A) ind = A.index(M) #print(ind) A.pop(ind) m = max(A) for i in range(N): #print(i) if i != ind: print(M) else: print(m)
def solve(): N = int(input()) A = [int(input()) for _ in range(N)] B = sorted(A) m = B[-1] m2 = B[-2] ans = [] for a in A: if a!=m: ans.append(m) else: ans.append(m2) return ans print(*solve(),sep='\n')
17
14
240
287
N = int(eval(input())) A = [0] * N for i in range(N): A[i] = int(eval(input())) # print(A) M = max(A) ind = A.index(M) # print(ind) A.pop(ind) m = max(A) for i in range(N): # print(i) if i != ind: print(M) else: print(m)
def solve(): N = int(input()) A = [int(input()) for _ in range(N)] B = sorted(A) m = B[-1] m2 = B[-2] ans = [] for a in A: if a != m: ans.append(m) else: ans.append(m2) return ans print(*solve(), sep="\n")
false
17.647059
[ "-N = int(eval(input()))", "-A = [0] * N", "-for i in range(N):", "- A[i] = int(eval(input()))", "-# print(A)", "-M = max(A)", "-ind = A.index(M)", "-# print(ind)", "-A.pop(ind)", "-m = max(A)", "-for i in range(N):", "- # print(i)", "- if i != ind:", "- print(M)", "- ...
false
0.008159
0.039595
0.20607
[ "s205216381", "s556836066" ]
u328510800
p03945
python
s989384799
s098085120
58
42
9,240
9,212
Accepted
Accepted
27.59
s = eval(input()) min_value = 10 ** 9 # 左端に置く場合 pivot = s[0] result = 0 for c in s: if pivot != c: pivot = c result += 1 min_value = min(min_value, result) # 右端に置く場合 result = 0 for c in reversed(s): if pivot != c: pivot = c result += 1 min_value = min(min_value, result) print(...
s = eval(input()) pivot = s[0] result = 0 for c in s: if pivot != c: pivot = c result += 1 print(result)
21
9
324
117
s = eval(input()) min_value = 10**9 # 左端に置く場合 pivot = s[0] result = 0 for c in s: if pivot != c: pivot = c result += 1 min_value = min(min_value, result) # 右端に置く場合 result = 0 for c in reversed(s): if pivot != c: pivot = c result += 1 min_value = min(min_value, result) print(min_v...
s = eval(input()) pivot = s[0] result = 0 for c in s: if pivot != c: pivot = c result += 1 print(result)
false
57.142857
[ "-min_value = 10**9", "-# 左端に置く場合", "-min_value = min(min_value, result)", "-# 右端に置く場合", "-result = 0", "-for c in reversed(s):", "- if pivot != c:", "- pivot = c", "- result += 1", "-min_value = min(min_value, result)", "-print(min_value)", "+print(result)" ]
false
0.070001
0.042225
1.65782
[ "s989384799", "s098085120" ]
u597374218
p03103
python
s029028266
s991607211
506
459
35,292
27,760
Accepted
Accepted
9.29
N,M=list(map(int,input().split())) AB=[list(map(int,input().split())) for i in range(N)] AB.sort(key=lambda AB:(AB[0],AB[1])) ans=0 count=0 for i in range(N): count=M-AB[i][1] if count>=0: ans+=AB[i][0]*AB[i][1] M=M-AB[i][1] else: ans+=AB[i][0]*M break print(ans)
N,M=list(map(int,input().split())) AB=[list(map(int,input().split())) for i in range(N)] AB.sort() ans=0 count=0 for i in range(N): count=M-AB[i][1] if count>=0: ans+=AB[i][0]*AB[i][1] M=count else: ans+=AB[i][0]*M break print(ans)
14
14
314
282
N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for i in range(N)] AB.sort(key=lambda AB: (AB[0], AB[1])) ans = 0 count = 0 for i in range(N): count = M - AB[i][1] if count >= 0: ans += AB[i][0] * AB[i][1] M = M - AB[i][1] else: ans += AB[i][0] * M ...
N, M = list(map(int, input().split())) AB = [list(map(int, input().split())) for i in range(N)] AB.sort() ans = 0 count = 0 for i in range(N): count = M - AB[i][1] if count >= 0: ans += AB[i][0] * AB[i][1] M = count else: ans += AB[i][0] * M break print(ans)
false
0
[ "-AB.sort(key=lambda AB: (AB[0], AB[1]))", "+AB.sort()", "- M = M - AB[i][1]", "+ M = count" ]
false
0.047243
0.04899
0.964338
[ "s029028266", "s991607211" ]
u724687935
p02614
python
s330214749
s262155480
93
55
68,616
9,176
Accepted
Accepted
40.86
from itertools import product H, W, K = list(map(int, input().split())) grid = [eval(input()) for _ in range(H)] ans = 0 for a in product([0, 1], repeat=H): for b in product([0, 1], repeat=W): cnt = 0 for i in range(H): if a[i] == 1: continue for...
from itertools import product H, W, K = list(map(int, input().split())) grid = [eval(input()) for _ in range(H)] ans = 0 for row in product([0, 1], repeat=H): for col in product([0, 1], repeat=W): cnt = 0 for i in range(H): for j in range(W): if row[i] == 0 a...
21
17
512
433
from itertools import product H, W, K = list(map(int, input().split())) grid = [eval(input()) for _ in range(H)] ans = 0 for a in product([0, 1], repeat=H): for b in product([0, 1], repeat=W): cnt = 0 for i in range(H): if a[i] == 1: continue for j in range(W...
from itertools import product H, W, K = list(map(int, input().split())) grid = [eval(input()) for _ in range(H)] ans = 0 for row in product([0, 1], repeat=H): for col in product([0, 1], repeat=W): cnt = 0 for i in range(H): for j in range(W): if row[i] == 0 and col[j] ==...
false
19.047619
[ "-for a in product([0, 1], repeat=H):", "- for b in product([0, 1], repeat=W):", "+for row in product([0, 1], repeat=H):", "+ for col in product([0, 1], repeat=W):", "- if a[i] == 1:", "- continue", "- if b[j] == 1:", "- continue", "-...
false
0.047419
0.079683
0.595096
[ "s330214749", "s262155480" ]
u767797498
p03785
python
s415781314
s234112070
223
138
13,308
19,908
Accepted
Accepted
38.12
n,c,k=list(map(int,input().split())) t=[int(eval(input())) for x in range(n)] t.sort() i=0 cnt=0 while i<n: departure=t[i]+k p=0 for j in range(i,n): if t[j] > departure or p==c: break p+=1 i+=p cnt+=1 print(cnt)
import sys n,c,k,*t = list(map(int, sys.stdin.read().split())) t.sort() i=0 cnt=0 while i<n: departure=t[i]+k p=0 for j in range(i,n): if t[j] > departure or p==c: break p+=1 i+=p cnt+=1 print(cnt)
16
17
240
234
n, c, k = list(map(int, input().split())) t = [int(eval(input())) for x in range(n)] t.sort() i = 0 cnt = 0 while i < n: departure = t[i] + k p = 0 for j in range(i, n): if t[j] > departure or p == c: break p += 1 i += p cnt += 1 print(cnt)
import sys n, c, k, *t = list(map(int, sys.stdin.read().split())) t.sort() i = 0 cnt = 0 while i < n: departure = t[i] + k p = 0 for j in range(i, n): if t[j] > departure or p == c: break p += 1 i += p cnt += 1 print(cnt)
false
5.882353
[ "-n, c, k = list(map(int, input().split()))", "-t = [int(eval(input())) for x in range(n)]", "+import sys", "+", "+n, c, k, *t = list(map(int, sys.stdin.read().split()))" ]
false
0.0762
0.037289
2.043489
[ "s415781314", "s234112070" ]
u934442292
p03805
python
s424714689
s036563216
55
35
3,064
3,064
Accepted
Accepted
36.36
import itertools N, M = list(map(int, input().split())) ab = [0] * M for i in range(M): ab[i] = list(map(int, input().split())) perms = itertools.permutations(list(range(1, N+1))) ans = 0 for perm in perms: if perm[0] != 1: continue is_goal = True for i in range(N-1): a = perm[i] b ...
# https://img.atcoder.jp/abc054/editorial.pdf N, M = list(map(int, input().split())) graph = [[False for _ in range(N)] for i in range(N)] for i in range(M): a, b = list(map(int, input().split())) graph[a-1][b-1] = graph[b-1][a-1] = True def dfs(v, visited): all_visited = True for i in range(N): ...
24
33
450
677
import itertools N, M = list(map(int, input().split())) ab = [0] * M for i in range(M): ab[i] = list(map(int, input().split())) perms = itertools.permutations(list(range(1, N + 1))) ans = 0 for perm in perms: if perm[0] != 1: continue is_goal = True for i in range(N - 1): a = perm[i] ...
# https://img.atcoder.jp/abc054/editorial.pdf N, M = list(map(int, input().split())) graph = [[False for _ in range(N)] for i in range(N)] for i in range(M): a, b = list(map(int, input().split())) graph[a - 1][b - 1] = graph[b - 1][a - 1] = True def dfs(v, visited): all_visited = True for i in range(N...
false
27.272727
[ "-import itertools", "+# https://img.atcoder.jp/abc054/editorial.pdf", "+N, M = list(map(int, input().split()))", "+graph = [[False for _ in range(N)] for i in range(N)]", "+for i in range(M):", "+ a, b = list(map(int, input().split()))", "+ graph[a - 1][b - 1] = graph[b - 1][a - 1] = True", "-N...
false
0.096849
0.042334
2.287715
[ "s424714689", "s036563216" ]
u912237403
p00074
python
s649452364
s107302699
20
10
4,216
4,212
Accepted
Accepted
50
N=60 def f(t): c,t=t%N,t/N b,a=t%N,t/N print("%02d:%02d:%02d"%(a,b,c)) return t1=2*N*N while 1: h,m,s=list(map(int,input().split())) if [h,m,s]==[-1,-1,-1]: break t2=(h*N+m)*N+s t=t1-t2 f(t) f(t*3)
N=60 def f(t): c,t=t%N,t/N print("%02d:%02d:%02d"%(t/N,t%N,c)) return while 1: h,m,s=list(map(int,input().split())) if [h,m,s]==[-1,-1,-1]: break t=7200-(h*N+m)*N-s f(t) f(t*3)
15
12
249
217
N = 60 def f(t): c, t = t % N, t / N b, a = t % N, t / N print("%02d:%02d:%02d" % (a, b, c)) return t1 = 2 * N * N while 1: h, m, s = list(map(int, input().split())) if [h, m, s] == [-1, -1, -1]: break t2 = (h * N + m) * N + s t = t1 - t2 f(t) f(t * 3)
N = 60 def f(t): c, t = t % N, t / N print("%02d:%02d:%02d" % (t / N, t % N, c)) return while 1: h, m, s = list(map(int, input().split())) if [h, m, s] == [-1, -1, -1]: break t = 7200 - (h * N + m) * N - s f(t) f(t * 3)
false
20
[ "- b, a = t % N, t / N", "- print(\"%02d:%02d:%02d\" % (a, b, c))", "+ print(\"%02d:%02d:%02d\" % (t / N, t % N, c))", "-t1 = 2 * N * N", "- t2 = (h * N + m) * N + s", "- t = t1 - t2", "+ t = 7200 - (h * N + m) * N - s" ]
false
0.04764
0.047196
1.009395
[ "s649452364", "s107302699" ]
u352394527
p00483
python
s680370282
s694891369
5,100
3,860
195,720
195,724
Accepted
Accepted
24.31
m, n = list(map(int,input().split())) k = int(eval(input())) mp = [eval(input()) for i in range(m)] dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)] for i in range(1, m + 1): for j in range(1, n + 1): for p in range(3): dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j - 1][p]...
def solve(): m, n = list(map(int,input().split())) k = int(eval(input())) mp = [eval(input()) for i in range(m)] dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)] for i in range(1, m + 1): for j in range(1, n + 1): for p in range(3): dp[i][j][p] = dp[i][j - 1][p] + dp[i - ...
18
19
784
819
m, n = list(map(int, input().split())) k = int(eval(input())) mp = [eval(input()) for i in range(m)] dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)] for i in range(1, m + 1): for j in range(1, n + 1): for p in range(3): dp[i][j][p] = dp[i][j - 1][p] + dp[i - 1][j][p] - dp[i - 1][j -...
def solve(): m, n = list(map(int, input().split())) k = int(eval(input())) mp = [eval(input()) for i in range(m)] dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)] for i in range(1, m + 1): for j in range(1, n + 1): for p in range(3): dp[i][j][p] = dp[i...
false
5.263158
[ "-m, n = list(map(int, input().split()))", "-k = int(eval(input()))", "-mp = [eval(input()) for i in range(m)]", "-dp = [[[0] * 3 for j in range(n + 1)] for i in range(m + 1)]", "-for i in range(1, m + 1):", "- for j in range(1, n + 1):", "- for p in range(3):", "- dp[i][j][p] = d...
false
0.104793
0.095479
1.097559
[ "s680370282", "s694891369" ]
u968404618
p02684
python
s033933066
s837770701
487
150
218,568
33,364
Accepted
Accepted
69.2
n, k = list(map(int, input().split())) A = list(map(int, input().split())) D = 60 #10**18は60桁なので2の59乗まで見る MAX_N = 200005 #頂点番号 to = [[0 for _ in range(MAX_N)] for _ in range(D)] #to[i][j]:jから2^i個先の頂点 for i in range(n): to[0][i] = A[i] to[0][i] -= 1 #ダブリングの表 for i in range(D-1): for j in ran...
def main(): ## IMPORT MODULE #import sys #sys.setrecursionlimit(100000) #input=lambda :sys.stdin.readline().rstrip() #f_inf=float("inf") #MOD=10**9+7 if 'get_ipython' in globals(): ## SAMPLE INPUT n, k = 4, 5 A = [3, 2, 4, 1] else: ##INPUT #n = input() n...
25
44
489
824
n, k = list(map(int, input().split())) A = list(map(int, input().split())) D = 60 # 10**18は60桁なので2の59乗まで見る MAX_N = 200005 # 頂点番号 to = [[0 for _ in range(MAX_N)] for _ in range(D)] # to[i][j]:jから2^i個先の頂点 for i in range(n): to[0][i] = A[i] to[0][i] -= 1 # ダブリングの表 for i in range(D - 1): for j in range(n): ...
def main(): ## IMPORT MODULE # import sys # sys.setrecursionlimit(100000) # input=lambda :sys.stdin.readline().rstrip() # f_inf=float("inf") # MOD=10**9+7 if "get_ipython" in globals(): ## SAMPLE INPUT n, k = 4, 5 A = [3, 2, 4, 1] else: ##INPUT # n...
false
43.181818
[ "-n, k = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-D = 60 # 10**18は60桁なので2の59乗まで見る", "-MAX_N = 200005 # 頂点番号", "-to = [[0 for _ in range(MAX_N)] for _ in range(D)]", "-# to[i][j]:jから2^i個先の頂点", "-for i in range(n):", "- to[0][i] = A[i]", "- to[0][i] -= 1", ...
false
0.665514
0.03673
18.118978
[ "s033933066", "s837770701" ]
u729972685
p03166
python
s760937979
s800200073
733
427
116,444
67,164
Accepted
Accepted
41.75
from sys import stdin, setrecursionlimit from collections import defaultdict input = stdin.readline setrecursionlimit(200000) N, M = list(map(int, input().split())) # d = [0] * (N + 1) adj = defaultdict(list) for _ in range(M): x, y = list(map(int, input().split())) adj[x].append(y) # d[y] += 1 ...
""" https://atcoder.jp/contests/dp/tasks/dp_g Using list to store adjacent list is faster than using sets. Maybe it is because the append operation of list in python is faster than add operation of sets. Using defaultdict instead of list to store adj is faster. Maybe it is because in case the graph is sparse, ...
26
32
572
936
from sys import stdin, setrecursionlimit from collections import defaultdict input = stdin.readline setrecursionlimit(200000) N, M = list(map(int, input().split())) # d = [0] * (N + 1) adj = defaultdict(list) for _ in range(M): x, y = list(map(int, input().split())) adj[x].append(y) # d[y] += 1 dp = [-1] *...
""" https://atcoder.jp/contests/dp/tasks/dp_g Using list to store adjacent list is faster than using sets. Maybe it is because the append operation of list in python is faster than add operation of sets. Using defaultdict instead of list to store adj is faster. Maybe it is because in case the graph is sparse, defauldic...
false
18.75
[ "-from sys import stdin, setrecursionlimit", "-from collections import defaultdict", "+\"\"\"", "+https://atcoder.jp/contests/dp/tasks/dp_g", "+Using list to store adjacent list is faster than using sets.", "+Maybe it is because the append operation of list in python is faster than add operation of sets."...
false
0.062631
0.063991
0.978751
[ "s760937979", "s800200073" ]
u512212329
p02726
python
s213753376
s394127849
469
408
52,444
52,060
Accepted
Accepted
13.01
from collections import deque n, x, y = [int(x) for x in input().split()] x -= 1 y -= 1 BIG = 65521 ans = {i: 0 for i in range(n)} def bfs(start_v): """ある始点からほかの全点に行くまでの最短距離を求める。""" qu = deque() qu_append = qu.append qu_popleft = qu.popleft qu_append(start_v) # 始点からvに移動するまでの最短距...
from collections import deque n, x, y = [int(x) for x in input().split()] x -= 1 y -= 1 BIG = 65521 ans = [0] * n def bfs(start_v): """ある始点からほかの全点に行くまでの最短距離を求める。""" qu = deque() qu_append = qu.append qu_popleft = qu.popleft qu_append(start_v) # 始点からvに移動するまでの最短距離: dist[v] d...
59
56
1,137
1,081
from collections import deque n, x, y = [int(x) for x in input().split()] x -= 1 y -= 1 BIG = 65521 ans = {i: 0 for i in range(n)} def bfs(start_v): """ある始点からほかの全点に行くまでの最短距離を求める。""" qu = deque() qu_append = qu.append qu_popleft = qu.popleft qu_append(start_v) # 始点からvに移動するまでの最短距離: dist[v] ...
from collections import deque n, x, y = [int(x) for x in input().split()] x -= 1 y -= 1 BIG = 65521 ans = [0] * n def bfs(start_v): """ある始点からほかの全点に行くまでの最短距離を求める。""" qu = deque() qu_append = qu.append qu_popleft = qu.popleft qu_append(start_v) # 始点からvに移動するまでの最短距離: dist[v] dist = [BIG] * n ...
false
5.084746
[ "-ans = {i: 0 for i in range(n)}", "+ans = [0] * n", "- if dist[i] != 0:", "- ans[dist[i]] += 1", "+ ans[dist[i]] += 1", "-# TLE" ]
false
0.037084
0.038204
0.970669
[ "s213753376", "s394127849" ]
u150984829
p02283
python
s385943868
s700441673
4,620
3,950
63,468
63,272
Accepted
Accepted
14.5
# 04:58 sec 63276 KB 912 bytes import sys class Node: __slots__ = ['key', 'left', 'right'] def __init__(self, key): self.key = key self.left = self.right = None class BST: def __init__(self): self.root = None def insert(self, key): x, y, z = self.roo...
import sys class Node: __slots__ = ['key', 'left', 'right'] def __init__(self, key): self.key = key self.left = self.right = None class BST: def __init__(self): self.root = None def insert(self, key): x, y = self.root, None while x != None: x, y = x...
32
30
1,002
948
# 04:58 sec 63276 KB 912 bytes import sys class Node: __slots__ = ["key", "left", "right"] def __init__(self, key): self.key = key self.left = self.right = None class BST: def __init__(self): self.root = None def insert(self, key): x, y, z = self.root, None, ...
import sys class Node: __slots__ = ["key", "left", "right"] def __init__(self, key): self.key = key self.left = self.right = None class BST: def __init__(self): self.root = None def insert(self, key): x, y = self.root, None while x != None: x, y ...
false
6.25
[ "-# 04:58 sec 63276 KB 912 bytes", "- x, y, z = self.root, None, Node(key)", "+ x, y = self.root, None", "- x, y = x.left if z.key < x.key else x.right, x", "+ x, y = x.left if key < x.key else x.right, x", "- self.root = z", "+ self.root ...
false
0.045999
0.047075
0.977154
[ "s385943868", "s700441673" ]
u077291787
p02623
python
s737536680
s215786471
316
235
58,144
55,204
Accepted
Accepted
25.63
# C - Tsundoku from bisect import bisect from itertools import accumulate def main(): N, M, K, *AB = list(map(int, open(0).read().split())) cum_A, cum_B = tuple(accumulate(AB[:N])), tuple(accumulate(AB[N:])) candidates = [] for cum_x, cum_y in ((cum_A, cum_B), (cum_B, cum_A)): for i,...
# C - Tsundoku from bisect import bisect from itertools import accumulate def main(): N, M, K, *AB = list(map(int, open(0).read().split())) cum_A, cum_B = tuple(accumulate([0] + AB[:N])), tuple(accumulate(AB[N:])) candidates = [] for i, a_time in enumerate(cum_A): if a_time > K: ...
21
20
598
518
# C - Tsundoku from bisect import bisect from itertools import accumulate def main(): N, M, K, *AB = list(map(int, open(0).read().split())) cum_A, cum_B = tuple(accumulate(AB[:N])), tuple(accumulate(AB[N:])) candidates = [] for cum_x, cum_y in ((cum_A, cum_B), (cum_B, cum_A)): for i, x_time in...
# C - Tsundoku from bisect import bisect from itertools import accumulate def main(): N, M, K, *AB = list(map(int, open(0).read().split())) cum_A, cum_B = tuple(accumulate([0] + AB[:N])), tuple(accumulate(AB[N:])) candidates = [] for i, a_time in enumerate(cum_A): if a_time > K: ca...
false
4.761905
[ "- cum_A, cum_B = tuple(accumulate(AB[:N])), tuple(accumulate(AB[N:]))", "+ cum_A, cum_B = tuple(accumulate([0] + AB[:N])), tuple(accumulate(AB[N:]))", "- for cum_x, cum_y in ((cum_A, cum_B), (cum_B, cum_A)):", "- for i, x_time in enumerate(cum_x, 1):", "- if x_time > K:", "- ...
false
0.036044
0.05945
0.606286
[ "s737536680", "s215786471" ]
u392319141
p03355
python
s788847611
s825533004
38
34
4,464
4,464
Accepted
Accepted
10.53
S = eval(input()) N = len(S) K = int(eval(input())) A = set() for i in range(N): for j in range(i + 1, N + 1): if j > i + K: break A.add(S[i:j]) A = list(A) A.sort() print((A[K - 1]))
S = eval(input()) K = int(eval(input())) A = set() for leng in range(1, K + 1): for i in range(len(S) - leng + 1): A.add(S[i: i + leng]) A = list(A) A.sort() print((A[K - 1]))
14
11
217
186
S = eval(input()) N = len(S) K = int(eval(input())) A = set() for i in range(N): for j in range(i + 1, N + 1): if j > i + K: break A.add(S[i:j]) A = list(A) A.sort() print((A[K - 1]))
S = eval(input()) K = int(eval(input())) A = set() for leng in range(1, K + 1): for i in range(len(S) - leng + 1): A.add(S[i : i + leng]) A = list(A) A.sort() print((A[K - 1]))
false
21.428571
[ "-N = len(S)", "-for i in range(N):", "- for j in range(i + 1, N + 1):", "- if j > i + K:", "- break", "- A.add(S[i:j])", "+for leng in range(1, K + 1):", "+ for i in range(len(S) - leng + 1):", "+ A.add(S[i : i + leng])" ]
false
0.085371
0.009239
9.239901
[ "s788847611", "s825533004" ]
u426764965
p02862
python
s501359570
s456217972
1,340
896
122,016
82,464
Accepted
Accepted
33.13
# D - Knight X, Y = list(map(int, input().split())) #### a = (2*Y - X) / 3 b = (2*X - Y) / 3 # https://qiita.com/derodero24/items/91b6468e66923a87f39f def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] % mod * g2[n-r] % mod mod = 10**9+7 #出力の制限 N...
# D - Knight X, Y = list(map(int, input().split())) #### a = (2*Y - X) / 3 b = (2*X - Y) / 3 # https://qiita.com/derodero24/items/91b6468e66923a87f39f # を一部修正 def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] % mod * g2[n-r] % mod mod = 10**9+7 ...
31
32
687
715
# D - Knight X, Y = list(map(int, input().split())) #### a = (2 * Y - X) / 3 b = (2 * X - Y) / 3 # https://qiita.com/derodero24/items/91b6468e66923a87f39f def cmb(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] % mod * g2[n - r] % mod mod = 10**9 + 7 # 出力の制限 N = 10*...
# D - Knight X, Y = list(map(int, input().split())) #### a = (2 * Y - X) / 3 b = (2 * X - Y) / 3 # https://qiita.com/derodero24/items/91b6468e66923a87f39f # を一部修正 def cmb(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] % mod * g2[n - r] % mod mod = 10**9 + 7 # 出力の制限...
false
3.125
[ "+# を一部修正", "-N = 10**6", "+N = int(a + b)", "-for i in range(2, N + 1):", "- g1.append((g1[-1] * i) % mod)", "- inverse.append((-inverse[mod % i] * (mod // i)) % mod)", "- g2.append((g2[-1] * inverse[-1]) % mod)", "+ for i in range(2, N + 1):", "+ g1.append((g1[-1] * i) % mod)", ...
false
2.330114
0.418988
5.56129
[ "s501359570", "s456217972" ]
u077291787
p03221
python
s907080916
s445156938
588
391
62,516
30,564
Accepted
Accepted
33.5
# ABC113C - ID import sys input = sys.stdin.readline def main(): N, M = map(int, input().split()) P = tuple(map(int, input().split()) for _ in range(M)) A = sorted((p, y, i) for i, (p, y) in enumerate(P)) ans, cnt = [""] * M, 1 ans[A[0][2]] = "{:06}{:06}".format(A[0][0], cnt) for i in...
# ABC113C - ID import sys input = sys.stdin.readline def main(): N, M = map(int, input().split()) ans, A, cnt = [""] * M, [], 1 for i in range(M): p, y = map(int, input().split()) A += [(p, y, i)] A.sort() ans[A[0][2]] = "{:06}{:06}".format(A[0][0], cnt) prev = A[0][...
21
25
556
565
# ABC113C - ID import sys input = sys.stdin.readline def main(): N, M = map(int, input().split()) P = tuple(map(int, input().split()) for _ in range(M)) A = sorted((p, y, i) for i, (p, y) in enumerate(P)) ans, cnt = [""] * M, 1 ans[A[0][2]] = "{:06}{:06}".format(A[0][0], cnt) for i in range(1...
# ABC113C - ID import sys input = sys.stdin.readline def main(): N, M = map(int, input().split()) ans, A, cnt = [""] * M, [], 1 for i in range(M): p, y = map(int, input().split()) A += [(p, y, i)] A.sort() ans[A[0][2]] = "{:06}{:06}".format(A[0][0], cnt) prev = A[0][0] for...
false
16
[ "- P = tuple(map(int, input().split()) for _ in range(M))", "- A = sorted((p, y, i) for i, (p, y) in enumerate(P))", "- ans, cnt = [\"\"] * M, 1", "+ ans, A, cnt = [\"\"] * M, [], 1", "+ for i in range(M):", "+ p, y = map(int, input().split())", "+ A += [(p, y, i)]", "+ ...
false
0.036669
0.036086
1.016153
[ "s907080916", "s445156938" ]
u437351386
p03363
python
s863473237
s793445466
263
162
41,728
37,556
Accepted
Accepted
38.4
from itertools import accumulate from collections import Counter n=int(eval(input())) a=list(map(int,input().split())) a=[0]+a A=list(accumulate(a)) B=Counter(A) ans=0 for i in B: ans=ans+int((B[i]*(B[i]-1)/2)) print(ans)
n=int(eval(input())) a=list(map(int,input().split())) from itertools import accumulate from collections import Counter a=[0]+list(accumulate(a)) a=Counter(a) ans=0 for i in a: ans=ans+a[i]*(a[i]-1)//2 print(ans)
11
10
227
217
from itertools import accumulate from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) a = [0] + a A = list(accumulate(a)) B = Counter(A) ans = 0 for i in B: ans = ans + int((B[i] * (B[i] - 1) / 2)) print(ans)
n = int(eval(input())) a = list(map(int, input().split())) from itertools import accumulate from collections import Counter a = [0] + list(accumulate(a)) a = Counter(a) ans = 0 for i in a: ans = ans + a[i] * (a[i] - 1) // 2 print(ans)
false
9.090909
[ "+n = int(eval(input()))", "+a = list(map(int, input().split()))", "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-a = [0] + a", "-A = list(accumulate(a))", "-B = Counter(A)", "+a = [0] + list(accumulate(a))", "+a = Counter(a)", "-for i in B:", "- ans = ans + int((B[i] * ...
false
0.036119
0.035804
1.008793
[ "s863473237", "s793445466" ]
u621509943
p03078
python
s285195245
s511265476
1,769
115
112,344
8,712
Accepted
Accepted
93.5
x,y,z,k = list(map(int,input().split())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort(reverse = True) b.sort(reverse = True) c.sort(reverse = True) h = [] for i in range(x): for j in range(y): if(i*j>k): break for l in ran...
x,y,z,k = list(map(int,input().split())) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort(reverse = True) b.sort(reverse = True) c.sort(reverse = True) h = [] for i in range(x): if(i + 1>k) : break for j in range(y): if((i + 1)*(j...
17
18
454
509
x, y, z, k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort(reverse=True) b.sort(reverse=True) c.sort(reverse=True) h = [] for i in range(x): for j in range(y): if i * j > k: break for l i...
x, y, z, k = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) a.sort(reverse=True) b.sort(reverse=True) c.sort(reverse=True) h = [] for i in range(x): if i + 1 > k: break for j in range(y): if (i + 1) * (j...
false
5.555556
[ "+ if i + 1 > k:", "+ break", "- if i * j > k:", "+ if (i + 1) * (j + 1) > k:", "- if i * j * l > k:", "+ if (i + 1) * (j + 1) * (l + 1) > k:" ]
false
0.034874
0.040074
0.870246
[ "s285195245", "s511265476" ]
u312025627
p03363
python
s378855697
s600169462
308
140
113,104
41,620
Accepted
Accepted
54.55
def main(): N = int(eval(input())) A = [int(i) for i in input().split()] from itertools import accumulate S = accumulate([0] + A) from collections import Counter c = Counter(S) ans = 0 for v in list(c.values()): if v > 1: ans += v*(v-1)//2 print(ans) ...
def main(): from itertools import accumulate from collections import Counter N = int(eval(input())) A = [int(i) for i in input().split()] S = list(accumulate([0] + A)) # print(S) c = Counter(S) ans = 0 for v in list(c.values()): ans += v*(v-1)//2 print(ans) ...
16
16
350
349
def main(): N = int(eval(input())) A = [int(i) for i in input().split()] from itertools import accumulate S = accumulate([0] + A) from collections import Counter c = Counter(S) ans = 0 for v in list(c.values()): if v > 1: ans += v * (v - 1) // 2 print(ans) if ...
def main(): from itertools import accumulate from collections import Counter N = int(eval(input())) A = [int(i) for i in input().split()] S = list(accumulate([0] + A)) # print(S) c = Counter(S) ans = 0 for v in list(c.values()): ans += v * (v - 1) // 2 print(ans) if __...
false
0
[ "+ from itertools import accumulate", "+ from collections import Counter", "+", "- from itertools import accumulate", "-", "- S = accumulate([0] + A)", "- from collections import Counter", "-", "+ S = list(accumulate([0] + A))", "+ # print(S)", "- if v > 1:", "- ...
false
0.044633
0.067888
0.657452
[ "s378855697", "s600169462" ]
u539367121
p02949
python
s569661464
s559871446
1,808
302
11,836
40,444
Accepted
Accepted
83.3
import sys sys.setrecursionlimit(10**5) def dfs(s): for i in to[s]: if not toflag[i]: toflag[i]=True dfs(i) def rdfs(s): for i in ot[s]: if not otflag[i]: otflag[i]=True rdfs(i) def bellman_ford(): for i in range(n): ...
import sys import numpy as np from scipy.sparse.csgraph import bellman_ford, NegativeCycleError from scipy.sparse import csr_matrix sys.setrecursionlimit(10**5) def dfs(s): for u in to[s]: if not toflag[u]: toflag[u]=True dfs(u) def rdfs(s): for u in ot[s]: if not otflag[u]: ...
65
62
1,294
1,266
import sys sys.setrecursionlimit(10**5) def dfs(s): for i in to[s]: if not toflag[i]: toflag[i] = True dfs(i) def rdfs(s): for i in ot[s]: if not otflag[i]: otflag[i] = True rdfs(i) def bellman_ford(): for i in range(n): upd = Fa...
import sys import numpy as np from scipy.sparse.csgraph import bellman_ford, NegativeCycleError from scipy.sparse import csr_matrix sys.setrecursionlimit(10**5) def dfs(s): for u in to[s]: if not toflag[u]: toflag[u] = True dfs(u) def rdfs(s): for u in ot[s]: if not ...
false
4.615385
[ "+import numpy as np", "+from scipy.sparse.csgraph import bellman_ford, NegativeCycleError", "+from scipy.sparse import csr_matrix", "- for i in to[s]:", "- if not toflag[i]:", "- toflag[i] = True", "- dfs(i)", "+ for u in to[s]:", "+ if not toflag[u]:", "...
false
0.037185
0.296289
0.125501
[ "s569661464", "s559871446" ]
u940139461
p02873
python
s948348097
s427305934
225
205
50,888
46,536
Accepted
Accepted
8.89
# https://atcoder.jp/contests/agc040/tasks/agc040_a s = eval(input()) A = [0] * (len(s) + 1) B = [0] * (len(s) + 1) for i in range(len(s)): if s[i] == '<': A[i + 1] = A[i] + 1 for i in range(len(s))[::-1]: if s[i] == '>': B[i] = B[i + 1] + 1 ans = 0 for i in range(len(s) + 1): ...
s = eval(input()) c = 0 dp = [0] * (len(s) + 1) for i in range(len(s)): if s[i] == '<': c += 1 dp[i + 1] = c else: c = 0 c = 0 for i in range(len(s))[::-1]: if s[i] == '>': c += 1 dp[i] = max(dp[i], c) else: c = 0 ans = sum(dp) print(ans...
16
19
350
315
# https://atcoder.jp/contests/agc040/tasks/agc040_a s = eval(input()) A = [0] * (len(s) + 1) B = [0] * (len(s) + 1) for i in range(len(s)): if s[i] == "<": A[i + 1] = A[i] + 1 for i in range(len(s))[::-1]: if s[i] == ">": B[i] = B[i + 1] + 1 ans = 0 for i in range(len(s) + 1): ans += max(A[i...
s = eval(input()) c = 0 dp = [0] * (len(s) + 1) for i in range(len(s)): if s[i] == "<": c += 1 dp[i + 1] = c else: c = 0 c = 0 for i in range(len(s))[::-1]: if s[i] == ">": c += 1 dp[i] = max(dp[i], c) else: c = 0 ans = sum(dp) print(ans)
false
15.789474
[ "-# https://atcoder.jp/contests/agc040/tasks/agc040_a", "-A = [0] * (len(s) + 1)", "-B = [0] * (len(s) + 1)", "+c = 0", "+dp = [0] * (len(s) + 1)", "- A[i + 1] = A[i] + 1", "+ c += 1", "+ dp[i + 1] = c", "+ else:", "+ c = 0", "+c = 0", "- B[i] = B[i + 1] +...
false
0.046801
0.042168
1.109883
[ "s948348097", "s427305934" ]
u609061751
p03945
python
s389618859
s164078452
48
43
3,956
3,188
Accepted
Accepted
10.42
import sys input = sys.stdin.readline S = list(input().rstrip()) N = len(S) cnt = 0 for i in range(N-1): if S[i] != S[i+1]: cnt += 1 print(cnt)
import sys input = sys.stdin.readline s = input().rstrip() cnt = 0 for i in range(len(s) - 1): if s[i] != s[i + 1]: cnt += 1 print(cnt)
10
9
169
157
import sys input = sys.stdin.readline S = list(input().rstrip()) N = len(S) cnt = 0 for i in range(N - 1): if S[i] != S[i + 1]: cnt += 1 print(cnt)
import sys input = sys.stdin.readline s = input().rstrip() cnt = 0 for i in range(len(s) - 1): if s[i] != s[i + 1]: cnt += 1 print(cnt)
false
10
[ "-S = list(input().rstrip())", "-N = len(S)", "+s = input().rstrip()", "-for i in range(N - 1):", "- if S[i] != S[i + 1]:", "+for i in range(len(s) - 1):", "+ if s[i] != s[i + 1]:" ]
false
0.062835
0.063332
0.99216
[ "s389618859", "s164078452" ]
u583507988
p03160
python
s749177333
s325075516
121
101
20,404
84,736
Accepted
Accepted
16.53
n = int(eval(input())) h = list(map(int, input().split())) dp = [float('inf')] * n dp[0] = 0 for i in range(1, n): if i == 1: dp[i] = dp[0] + abs(h[i]-h[i-1]) else: dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) print((dp[n-1]))
n=int(eval(input())) h=list(map(int,input().split())) dp=[0]*n dp[1]=abs(h[1]-h[0]) for i in range(2,n): dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) print((dp[n-1]))
13
7
266
182
n = int(eval(input())) h = list(map(int, input().split())) dp = [float("inf")] * n dp[0] = 0 for i in range(1, n): if i == 1: dp[i] = dp[0] + abs(h[i] - h[i - 1]) else: dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[n - 1]))
n = int(eval(input())) h = list(map(int, input().split())) dp = [0] * n dp[1] = abs(h[1] - h[0]) for i in range(2, n): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[n - 1]))
false
46.153846
[ "-dp = [float(\"inf\")] * n", "-dp[0] = 0", "-for i in range(1, n):", "- if i == 1:", "- dp[i] = dp[0] + abs(h[i] - h[i - 1])", "- else:", "- dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))", "+dp = [0] * n", "+dp[1] = abs(h[1] - h[0])", "+for i ...
false
0.04005
0.045795
0.874564
[ "s749177333", "s325075516" ]
u732061897
p02573
python
s072232638
s780360434
1,093
718
87,996
36,000
Accepted
Accepted
34.31
N, M = list(map(int, input().split())) friends = {i: set([]) for i in range(N)} for i in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 friends[a].add(b) friends[b].add(a) #print(friends) from collections import deque reached = [-1] * N ans = 1 for i in range(N): i...
N, M = list(map(int, input().split())) t = [-1] * N import sys sys.setrecursionlimit(10 ** 6) def find(e): if t[e] < 0: return e else: t[e] = find(t[e]) return t[e] def unite(a, b): a_root = find(a) b_root = find(b) if a_root == b_root: return ...
28
39
693
594
N, M = list(map(int, input().split())) friends = {i: set([]) for i in range(N)} for i in range(M): a, b = list(map(int, input().split())) a -= 1 b -= 1 friends[a].add(b) friends[b].add(a) # print(friends) from collections import deque reached = [-1] * N ans = 1 for i in range(N): if reached[i] ...
N, M = list(map(int, input().split())) t = [-1] * N import sys sys.setrecursionlimit(10**6) def find(e): if t[e] < 0: return e else: t[e] = find(t[e]) return t[e] def unite(a, b): a_root = find(a) b_root = find(b) if a_root == b_root: return t[a_root] += t[b_...
false
28.205128
[ "-friends = {i: set([]) for i in range(N)}", "+t = [-1] * N", "+import sys", "+", "+sys.setrecursionlimit(10**6)", "+", "+", "+def find(e):", "+ if t[e] < 0:", "+ return e", "+ else:", "+ t[e] = find(t[e])", "+ return t[e]", "+", "+", "+def unite(a, b):", "...
false
0.04041
0.042533
0.950078
[ "s072232638", "s780360434" ]
u896741788
p03497
python
s012791246
s550615956
212
101
39,348
32,572
Accepted
Accepted
52.36
n,k=list(map(int,input().split())) l=list(map(int,input().split())) from collections import Counter as co var=co(l).most_common() en=len(var) ans=0 while en>k : ans+=var[en-1][1] en-=1 print(ans)
n,k=list(map(int,input().split())) from collections import Counter as co var=sorted(list(co(list(map(int,input().split()))).values()),reverse=1) print((sum(var[k:])))
10
4
206
156
n, k = list(map(int, input().split())) l = list(map(int, input().split())) from collections import Counter as co var = co(l).most_common() en = len(var) ans = 0 while en > k: ans += var[en - 1][1] en -= 1 print(ans)
n, k = list(map(int, input().split())) from collections import Counter as co var = sorted(list(co(list(map(int, input().split()))).values()), reverse=1) print((sum(var[k:])))
false
60
[ "-l = list(map(int, input().split()))", "-var = co(l).most_common()", "-en = len(var)", "-ans = 0", "-while en > k:", "- ans += var[en - 1][1]", "- en -= 1", "-print(ans)", "+var = sorted(list(co(list(map(int, input().split()))).values()), reverse=1)", "+print((sum(var[k:])))" ]
false
0.089363
0.038175
2.340866
[ "s012791246", "s550615956" ]
u982896977
p03163
python
s204602657
s788383029
677
461
171,656
119,916
Accepted
Accepted
31.91
N, W = list(map(int, input().split())) w_list = [] v_list = [] for i in range(N): w, v = list(map(int, input().split())) w_list.append(w) v_list.append(v) dp = [[0 for i in range(W+1)] for i in range(N)] for i in range(N): w = w_list[i] v = v_list[i] for j in range(W+1): if j...
N,W = list(map(int,input().split())) w_list = [] v_list = [] for _ in range(N): w,v = list(map(int,input().split())) w_list.append(w) v_list.append(v) dp = [[0]*(W+1) for i in range(N+1)] for i in range(1,N+1): w = w_list[i-1] v = v_list[i-1] for j in range(1,W+1): if j-w >= ...
17
17
441
432
N, W = list(map(int, input().split())) w_list = [] v_list = [] for i in range(N): w, v = list(map(int, input().split())) w_list.append(w) v_list.append(v) dp = [[0 for i in range(W + 1)] for i in range(N)] for i in range(N): w = w_list[i] v = v_list[i] for j in range(W + 1): if j - w >= ...
N, W = list(map(int, input().split())) w_list = [] v_list = [] for _ in range(N): w, v = list(map(int, input().split())) w_list.append(w) v_list.append(v) dp = [[0] * (W + 1) for i in range(N + 1)] for i in range(1, N + 1): w = w_list[i - 1] v = v_list[i - 1] for j in range(1, W + 1): if...
false
0
[ "-for i in range(N):", "+for _ in range(N):", "-dp = [[0 for i in range(W + 1)] for i in range(N)]", "-for i in range(N):", "- w = w_list[i]", "- v = v_list[i]", "- for j in range(W + 1):", "+dp = [[0] * (W + 1) for i in range(N + 1)]", "+for i in range(1, N + 1):", "+ w = w_list[i - 1...
false
0.042343
0.122588
0.345412
[ "s204602657", "s788383029" ]
u623349537
p03005
python
s778181805
s660027758
19
17
2,940
2,940
Accepted
Accepted
10.53
N, K = list(map(int, input().split())) if K == 1: print((0)) else: print((N - K + 1 - 1))
N, K = list(map(int, input().split())) if K == 1: print((0)) else: print((N - K))
5
5
91
83
N, K = list(map(int, input().split())) if K == 1: print((0)) else: print((N - K + 1 - 1))
N, K = list(map(int, input().split())) if K == 1: print((0)) else: print((N - K))
false
0
[ "- print((N - K + 1 - 1))", "+ print((N - K))" ]
false
0.04549
0.045937
0.990267
[ "s778181805", "s660027758" ]
u349449706
p03804
python
s632990822
s938533807
77
71
74,160
70,320
Accepted
Accepted
7.79
N, M = list(map(int, input().split())) A = [list(eval(input())) for _ in range(N)] B = [list(eval(input())) for _ in range(M)] for i in range(N-M+1): for j in range(N-M+1): c = 1 for k in range(M): if A[i+k][j:j+M] != B[k]: c = 0 if c: print(...
N,M = list(map(int,input().split())) A=[eval(input())for _ in range(N)] B=[eval(input())for _ in range(M)] print(('Yes'if any([A[i+k][j:j+M]for k in range(M)]==B for i in range(N-M+1)for j in range(N-M+1)) else'No'))
13
4
342
200
N, M = list(map(int, input().split())) A = [list(eval(input())) for _ in range(N)] B = [list(eval(input())) for _ in range(M)] for i in range(N - M + 1): for j in range(N - M + 1): c = 1 for k in range(M): if A[i + k][j : j + M] != B[k]: c = 0 if c: pr...
N, M = list(map(int, input().split())) A = [eval(input()) for _ in range(N)] B = [eval(input()) for _ in range(M)] print( ( "Yes" if any( [A[i + k][j : j + M] for k in range(M)] == B for i in range(N - M + 1) for j in range(N - M + 1) ) else "No" ...
false
69.230769
[ "-A = [list(eval(input())) for _ in range(N)]", "-B = [list(eval(input())) for _ in range(M)]", "-for i in range(N - M + 1):", "- for j in range(N - M + 1):", "- c = 1", "- for k in range(M):", "- if A[i + k][j : j + M] != B[k]:", "- c = 0", "- if c:...
false
0.069714
0.037201
1.873969
[ "s632990822", "s938533807" ]
u761320129
p03043
python
s744704052
s665032070
41
34
3,188
3,188
Accepted
Accepted
17.07
from math import log2,ceil N,K = list(map(int,input().split())) r = [0.5] for i in range(50): r.append(r[-1] / 2) ans = 0 for n in range(1,N+1): if n > K-1: ans += 1 continue c = ceil(log2(K/n)) ans += r[c-1] print((ans/N))
N,K = list(map(int,input().split())) ans = 0 for n in range(1,N+1): if n >= K: ans += 1 continue k = 0 m = n while m < K: m *= 2 k += 1 ans += 2**-k print((ans/N))
15
13
263
219
from math import log2, ceil N, K = list(map(int, input().split())) r = [0.5] for i in range(50): r.append(r[-1] / 2) ans = 0 for n in range(1, N + 1): if n > K - 1: ans += 1 continue c = ceil(log2(K / n)) ans += r[c - 1] print((ans / N))
N, K = list(map(int, input().split())) ans = 0 for n in range(1, N + 1): if n >= K: ans += 1 continue k = 0 m = n while m < K: m *= 2 k += 1 ans += 2**-k print((ans / N))
false
13.333333
[ "-from math import log2, ceil", "-", "-r = [0.5]", "-for i in range(50):", "- r.append(r[-1] / 2)", "- if n > K - 1:", "+ if n >= K:", "- c = ceil(log2(K / n))", "- ans += r[c - 1]", "+ k = 0", "+ m = n", "+ while m < K:", "+ m *= 2", "+ k += 1", "+ ...
false
0.058896
0.048526
1.213702
[ "s744704052", "s665032070" ]
u633068244
p00070
python
s615646264
s364720985
4,300
3,800
4,268
4,260
Accepted
Accepted
11.63
def mx(ls,m): global n sum = 0 for i in range(m): sum += (n-i)*ls[-i-1] return sum def mn(ls,m): global n sum = 0 for i in range(m): sum += (n-i)*ls[i] return sum def f(ls,m,s): global n count = 0 if m > 0: vmx,vmn = mx(ls,m),mn(ls,m) if vmx < s or vmn > s: return 0 elif vmx ...
def mxmn(ls,m): global n s1,s2 = 0, 0 for i in range(m): s1 += (n-i)*ls[-i-1] s2 += (n-i)*ls[i] return s1,s2 def f(ls,m,s): global n count = 0 if m > 0: mx,mn = mxmn(ls,m) if mx < s or mn > s: return 0 elif mx == s or mn == s: return 1 for i in range(len(ls)): lls = ls[:] a = ...
37
31
657
578
def mx(ls, m): global n sum = 0 for i in range(m): sum += (n - i) * ls[-i - 1] return sum def mn(ls, m): global n sum = 0 for i in range(m): sum += (n - i) * ls[i] return sum def f(ls, m, s): global n count = 0 if m > 0: vmx, vmn = mx(ls, m), mn(ls...
def mxmn(ls, m): global n s1, s2 = 0, 0 for i in range(m): s1 += (n - i) * ls[-i - 1] s2 += (n - i) * ls[i] return s1, s2 def f(ls, m, s): global n count = 0 if m > 0: mx, mn = mxmn(ls, m) if mx < s or mn > s: return 0 elif mx == s or mn ...
false
16.216216
[ "-def mx(ls, m):", "+def mxmn(ls, m):", "- sum = 0", "+ s1, s2 = 0, 0", "- sum += (n - i) * ls[-i - 1]", "- return sum", "-", "-", "-def mn(ls, m):", "- global n", "- sum = 0", "- for i in range(m):", "- sum += (n - i) * ls[i]", "- return sum", "+ ...
false
0.035098
0.070366
0.498788
[ "s615646264", "s364720985" ]
u155251346
p03555
python
s216029740
s915803881
29
26
9,072
9,008
Accepted
Accepted
10.34
a=eval(input()) b=eval(input()) if [a[2],a[1],a[0]]==[b[0],b[1],b[2]]: print("YES") else: print("NO")
#入力例は合うがWAになる A = eval(input()) B = eval(input()) if A[0]==B[2] and A[1]==B[1] and A[2]==B[0]: print("YES") else: print("NO") #YESとNOにしないといけないところをYes、Noになっていた
6
12
102
169
a = eval(input()) b = eval(input()) if [a[2], a[1], a[0]] == [b[0], b[1], b[2]]: print("YES") else: print("NO")
# 入力例は合うがWAになる A = eval(input()) B = eval(input()) if A[0] == B[2] and A[1] == B[1] and A[2] == B[0]: print("YES") else: print("NO") # YESとNOにしないといけないところをYes、Noになっていた
false
50
[ "-a = eval(input())", "-b = eval(input())", "-if [a[2], a[1], a[0]] == [b[0], b[1], b[2]]:", "+# 入力例は合うがWAになる", "+A = eval(input())", "+B = eval(input())", "+if A[0] == B[2] and A[1] == B[1] and A[2] == B[0]:", "+# YESとNOにしないといけないところをYes、Noになっていた" ]
false
0.072574
0.036849
1.969471
[ "s216029740", "s915803881" ]
u390694622
p03546
python
s778629657
s723020591
1,087
33
3,444
3,444
Accepted
Accepted
96.96
def rec_cost(x,acc,plist,clist): if x == 1: return acc else: minimum = -1 for next in plist: nextplist = plist.copy() nextplist.remove(next) candidate = rec_cost(next,acc+clist[x][next],nextplist,clist) if minimum == -1: minimum = candidate elif candidate...
def cost(n,clist): k = 0 while k < 10: i = 0 while i < 10: j = 0 while j < 10: clist[i][j] = min(clist[i][j],clist[i][k]+clist[k][j]) j += 1 i += 1 k += 1 return clist[n][1] def joisino(a,clist): note = [-1,0,-1,-1,-1,-1,-1,-1,-1,-1] answer = 0 ...
53
46
1,184
930
def rec_cost(x, acc, plist, clist): if x == 1: return acc else: minimum = -1 for next in plist: nextplist = plist.copy() nextplist.remove(next) candidate = rec_cost(next, acc + clist[x][next], nextplist, clist) if minimum == -1: ...
def cost(n, clist): k = 0 while k < 10: i = 0 while i < 10: j = 0 while j < 10: clist[i][j] = min(clist[i][j], clist[i][k] + clist[k][j]) j += 1 i += 1 k += 1 return clist[n][1] def joisino(a, clist): note = [-...
false
13.207547
[ "-def rec_cost(x, acc, plist, clist):", "- if x == 1:", "- return acc", "- else:", "- minimum = -1", "- for next in plist:", "- nextplist = plist.copy()", "- nextplist.remove(next)", "- candidate = rec_cost(next, acc + clist[x][next], nextp...
false
0.968266
0.036282
26.687121
[ "s778629657", "s723020591" ]
u573754721
p02881
python
s993833068
s056663662
136
116
3,060
3,268
Accepted
Accepted
14.71
import math n=int(eval(input())) num=math.ceil(math.sqrt(n)) L=max([i for i in range(1,num+1) if n%i==0]) print((L+n//L-2))
n=int(eval(input())) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors L=make_divisors(n) s=float('inf') for i...
5
21
119
359
import math n = int(eval(input())) num = math.ceil(math.sqrt(n)) L = max([i for i in range(1, num + 1) if n % i == 0]) print((L + n // L - 2))
n = int(eval(input())) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) divisors.sort() return divisors L = make_divisors(n) s = float("inf") for i in L: ...
false
76.190476
[ "-import math", "+n = int(eval(input()))", "-n = int(eval(input()))", "-num = math.ceil(math.sqrt(n))", "-L = max([i for i in range(1, num + 1) if n % i == 0])", "-print((L + n // L - 2))", "+", "+def make_divisors(n):", "+ divisors = []", "+ for i in range(1, int(n**0.5) + 1):", "+ ...
false
0.092769
0.085704
1.082436
[ "s993833068", "s056663662" ]
u156896646
p03854
python
s400985362
s526299544
64
41
21,348
3,188
Accepted
Accepted
35.94
import sys sys.setrecursionlimit(1000000) S = eval(input()) T = ['dream', 'dreamer', 'erase', 'eraser'] lenT = [len(i) for i in T] def dayDream(pin): global isGoal #;print('dayDream: ', pin, S[pin:]) for i, d in enumerate(T): if isGoal: return #print('i,...
S = eval(input()) Srev = S[::-1] T = ['dream', 'dreamer', 'erase', 'eraser'] lenT = [len(i) for i in T] Trev = [t[::-1] for t in T] i = 0 while i < len(S): for j, t in enumerate(Trev): if Srev[i:i+lenT[j]] == t: i += lenT[j] #; print(i, j, t) break else: ...
30
18
735
370
import sys sys.setrecursionlimit(1000000) S = eval(input()) T = ["dream", "dreamer", "erase", "eraser"] lenT = [len(i) for i in T] def dayDream(pin): global isGoal # ;print('dayDream: ', pin, S[pin:]) for i, d in enumerate(T): if isGoal: return # print('i, d:', i, d) if S...
S = eval(input()) Srev = S[::-1] T = ["dream", "dreamer", "erase", "eraser"] lenT = [len(i) for i in T] Trev = [t[::-1] for t in T] i = 0 while i < len(S): for j, t in enumerate(Trev): if Srev[i : i + lenT[j]] == t: i += lenT[j] # ; print(i, j, t) break else: print("NO")...
false
40
[ "-import sys", "-", "-sys.setrecursionlimit(1000000)", "+Srev = S[::-1]", "-", "-", "-def dayDream(pin):", "- global isGoal # ;print('dayDream: ', pin, S[pin:])", "- for i, d in enumerate(T):", "- if isGoal:", "- return", "- # print('i, d:', i, d)", "- ...
false
0.038389
0.066853
0.574234
[ "s400985362", "s526299544" ]
u471214054
p02579
python
s611474662
s858674988
1,132
1,004
215,032
224,036
Accepted
Accepted
11.31
import sys from collections import deque, defaultdict sys.setrecursionlimit(10000) H, W = list(map(int, input().split())) C = tuple(map(int, input().split())) D = tuple(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] d = [(0, 1), (1, 0), (0, -1), (-1, 0)] def dfs(h, w, i): S[...
import sys from collections import deque, defaultdict sys.setrecursionlimit(10000) H, W = list(map(int, input().split())) C = tuple(map(int, input().split())) D = tuple(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] d = [(0, 1), (1, 0), (0, -1), (-1, 0)] def dfs(h, w, i): ...
75
77
1,754
1,806
import sys from collections import deque, defaultdict sys.setrecursionlimit(10000) H, W = list(map(int, input().split())) C = tuple(map(int, input().split())) D = tuple(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] d = [(0, 1), (1, 0), (0, -1), (-1, 0)] def dfs(h, w, i): S[h][w] = i ...
import sys from collections import deque, defaultdict sys.setrecursionlimit(10000) H, W = list(map(int, input().split())) C = tuple(map(int, input().split())) D = tuple(map(int, input().split())) S = [list(eval(input())) for _ in range(H)] d = [(0, 1), (1, 0), (0, -1), (-1, 0)] def dfs(h, w, i): S[h][w] = i ...
false
2.597403
[ "-# 番号を振る", "+# 領域毎に番号を振る", "-# グラフを構築", "-graph = {}", "-for i in range(1, count):", "- graph[i] = set()", "+# 各領域をノードとしてグラフを構築", "+graph = defaultdict(set)", "-# 最短経路を求める", "-def bfs(start, goal):", "+", "+", "+def shortest_dist(graph, start, goal):", "+ if current_vertex == go...
false
0.038771
0.046155
0.840014
[ "s611474662", "s858674988" ]
u198881450
p00474
python
s336604708
s944214771
330
270
15,544
15,612
Accepted
Accepted
18.18
def orderN(N,L,ices): upPeak = L - ices[0] downPeak = L - ices[0] peaks = [] for i in range(len(ices)): if i < N-1: if ices[i] < ices[i+1]: peaks.append(downPeak) downPeak = L - ices[i+1] upPeak += L - ices[i+1] el...
def orderN(N,L,ices): upPeak = L - ices[0] downPeak = L - ices[0] peaks = [] for i in range(len(ices)): if i < N-1: if ices[i] < ices[i+1]: peaks.append(downPeak) downPeak = L - ices[i+1] upPeak += L - ices[i+1] el...
28
24
731
694
def orderN(N, L, ices): upPeak = L - ices[0] downPeak = L - ices[0] peaks = [] for i in range(len(ices)): if i < N - 1: if ices[i] < ices[i + 1]: peaks.append(downPeak) downPeak = L - ices[i + 1] upPeak += L - ices[i + 1] el...
def orderN(N, L, ices): upPeak = L - ices[0] downPeak = L - ices[0] peaks = [] for i in range(len(ices)): if i < N - 1: if ices[i] < ices[i + 1]: peaks.append(downPeak) downPeak = L - ices[i + 1] upPeak += L - ices[i + 1] el...
false
14.285714
[ "- else:", "+ elif ices[i] > ices[i + 1]:", "- else:", "+ elif i == N - 1:", "-ices = []", "-while True:", "- ice = int(input().strip())", "- ices.append(ice)", "- if len(ices) == N:", "- break", "+ices = [int(input().strip()) for _ in range(N)...
false
0.03473
0.037628
0.922992
[ "s336604708", "s944214771" ]
u967062796
p02958
python
s819514237
s763097776
27
17
3,188
3,064
Accepted
Accepted
37.04
n = int(eval(input())) P = [int(x) for x in input().split()] flag = True for i in range(n): for j in range(n): if i == j: continue else: copy_P = P[:] copy_P[i], copy_P[j] = copy_P[j], copy_P[i] if copy_P == sorted(P): print(...
n = int(eval(input())) p = [int(x) for x in input().split()] p_copy = p[:] p.sort() count = 0 for i in range(n): if p[i] != p_copy[i]: count += 1 if count == 0 or count == 2: print("YES") else: print("NO")
24
15
504
236
n = int(eval(input())) P = [int(x) for x in input().split()] flag = True for i in range(n): for j in range(n): if i == j: continue else: copy_P = P[:] copy_P[i], copy_P[j] = copy_P[j], copy_P[i] if copy_P == sorted(P): print("YES") ...
n = int(eval(input())) p = [int(x) for x in input().split()] p_copy = p[:] p.sort() count = 0 for i in range(n): if p[i] != p_copy[i]: count += 1 if count == 0 or count == 2: print("YES") else: print("NO")
false
37.5
[ "-P = [int(x) for x in input().split()]", "-flag = True", "+p = [int(x) for x in input().split()]", "+p_copy = p[:]", "+p.sort()", "+count = 0", "- for j in range(n):", "- if i == j:", "- continue", "- else:", "- copy_P = P[:]", "- copy_P[i], c...
false
0.104856
0.120484
0.870292
[ "s819514237", "s763097776" ]
u941753895
p03032
python
s538911583
s306807829
78
52
5,432
5,204
Accepted
Accepted
33.33
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] de...
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=1000000007 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.std...
44
41
977
896
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) ...
import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 1000000007 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().sp...
false
6.818182
[ "-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy", "+import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy", "-mod = 10**9 + 7", "+mod = 1000000007", "-", "-", "-def LI_():", "- return [int(x) - 1 for x in s...
false
0.049712
0.047781
1.040408
[ "s538911583", "s306807829" ]
u646110634
p02700
python
s241165585
s003485769
22
18
9,120
9,164
Accepted
Accepted
18.18
A, B, C, D = list(map(int, input().split())) T_time = C // B if not C % B == 0 : T_time += 1 A_time = A // D if not A % D == 0 : A_time += 1 if T_time <= A_time : print("Yes") else : print("No")
A, B, C, D = list(map(int, input().split())) T_time = C // B if C % B == 0 else C // B + 1 A_time = A // D if A % D == 0 else A // D + 1 if T_time <= A_time : print("Yes") else : print("No")
14
9
212
199
A, B, C, D = list(map(int, input().split())) T_time = C // B if not C % B == 0: T_time += 1 A_time = A // D if not A % D == 0: A_time += 1 if T_time <= A_time: print("Yes") else: print("No")
A, B, C, D = list(map(int, input().split())) T_time = C // B if C % B == 0 else C // B + 1 A_time = A // D if A % D == 0 else A // D + 1 if T_time <= A_time: print("Yes") else: print("No")
false
35.714286
[ "-T_time = C // B", "-if not C % B == 0:", "- T_time += 1", "-A_time = A // D", "-if not A % D == 0:", "- A_time += 1", "+T_time = C // B if C % B == 0 else C // B + 1", "+A_time = A // D if A % D == 0 else A // D + 1" ]
false
0.178173
0.105888
1.682656
[ "s241165585", "s003485769" ]
u698919163
p02862
python
s122061480
s822439183
914
138
82,464
3,064
Accepted
Accepted
84.9
X,Y = list(map(int,input().split())) n = (-X+2*Y)//3 m = (2*X-Y)//3 mod = 10**9+7 #出力の制限 N = max(n+m,n) g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod fo...
X,Y = list(map(int,input().split())) n = (-X+2*Y)//3 m = (2*X-Y)//3 MOD = 10**9+7 def comb(n,r,MOD): x = n+1 y = min(r,n-r) numer = 1 denom = 1 for i in range(1,r+1): numer = numer*(x-i)%MOD denom = denom*(i)%MOD return numer * pow(denom,MOD-...
26
29
587
478
X, Y = list(map(int, input().split())) n = (-X + 2 * Y) // 3 m = (2 * X - Y) // 3 mod = 10**9 + 7 # 出力の制限 N = max(n + m, n) g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] # 逆元テーブル計算用テーブル def cmb(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - ...
X, Y = list(map(int, input().split())) n = (-X + 2 * Y) // 3 m = (2 * X - Y) // 3 MOD = 10**9 + 7 def comb(n, r, MOD): x = n + 1 y = min(r, n - r) numer = 1 denom = 1 for i in range(1, r + 1): numer = numer * (x - i) % MOD denom = denom * (i) % MOD return numer * pow(denom, MOD...
false
10.344828
[ "-mod = 10**9 + 7 # 出力の制限", "-N = max(n + m, n)", "-g1 = [1, 1] # 元テーブル", "-g2 = [1, 1] # 逆元テーブル", "-inverse = [0, 1] # 逆元テーブル計算用テーブル", "+MOD = 10**9 + 7", "-def cmb(n, r, mod):", "- if r < 0 or r > n:", "- return 0", "- r = min(r, n - r)", "- return g1[n] * g2[r] * g2[n - r]...
false
0.454716
0.076076
5.977131
[ "s122061480", "s822439183" ]
u864013199
p03212
python
s710940722
s175832808
338
90
3,988
2,940
Accepted
Accepted
73.37
# editorial N = int(eval(input())) from functools import lru_cache @lru_cache(maxsize=1000) def dfs(s): if int(s) > N: return 0 ret = 1 if all(s.count(c) for c in "753") else 0 for c in "753": #文字列数値をforで回すときの書き方! 覚える ret += dfs(s+c) #pythonなのでそのまま+できる return ret print((d...
# editorial N = int(eval(input())) #from functools import lru_cache #@lru_cache(maxsize=1000) def dfs(s): if int(s) > N: return 0 ret = 1 if all(s.count(c) for c in "753") else 0 for c in "753": #文字列数値をforで回すときの書き方! 覚える ret += dfs(s+c) #pythonなのでそのまま+できる return ret print(...
14
14
321
323
# editorial N = int(eval(input())) from functools import lru_cache @lru_cache(maxsize=1000) def dfs(s): if int(s) > N: return 0 ret = 1 if all(s.count(c) for c in "753") else 0 for c in "753": # 文字列数値をforで回すときの書き方! 覚える ret += dfs(s + c) # pythonなのでそのまま+できる return ret print((dfs("0"...
# editorial N = int(eval(input())) # from functools import lru_cache # @lru_cache(maxsize=1000) def dfs(s): if int(s) > N: return 0 ret = 1 if all(s.count(c) for c in "753") else 0 for c in "753": # 文字列数値をforで回すときの書き方! 覚える ret += dfs(s + c) # pythonなのでそのまま+できる return ret print((dfs("...
false
0
[ "-from functools import lru_cache", "-", "-", "-@lru_cache(maxsize=1000)", "+# from functools import lru_cache", "+# @lru_cache(maxsize=1000)" ]
false
0.085468
0.045525
1.877377
[ "s710940722", "s175832808" ]
u498575211
p02725
python
s527820521
s740634277
204
131
26,444
26,004
Accepted
Accepted
35.78
(K, N) = list(map(int, input().split())) A = list(map(int, input().split())) A.append(A[0]+K) A_next = [] max = 0 result = 0 j = 0 k = 0 #print(A) for x in range(1, len(A)): #print(x) #print(A[x]-A[x-1]) #print(A[x-1]) #print(A_next) A_next.append(abs(A[x] - A[x-1])) if max < A_next[j]: ...
N, K = list(map(int, input().split())) a = list(map(int, input().split())) a.append(N+a[0]) #print(a) max = 0 for i in range(len(a)-1): p = abs(a[i]-a[i+1]) max = p if max < p else max print((N-max))
32
9
515
204
(K, N) = list(map(int, input().split())) A = list(map(int, input().split())) A.append(A[0] + K) A_next = [] max = 0 result = 0 j = 0 k = 0 # print(A) for x in range(1, len(A)): # print(x) # print(A[x]-A[x-1]) # print(A[x-1]) # print(A_next) A_next.append(abs(A[x] - A[x - 1])) if max < A_next[j]:...
N, K = list(map(int, input().split())) a = list(map(int, input().split())) a.append(N + a[0]) # print(a) max = 0 for i in range(len(a) - 1): p = abs(a[i] - a[i + 1]) max = p if max < p else max print((N - max))
false
71.875
[ "-(K, N) = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-A.append(A[0] + K)", "-A_next = []", "+N, K = list(map(int, input().split()))", "+a = list(map(int, input().split()))", "+a.append(N + a[0])", "+# print(a)", "-result = 0", "-j = 0", "-k = 0", "-# print(A)",...
false
0.037054
0.03673
1.008823
[ "s527820521", "s740634277" ]
u537722973
p02675
python
s141430874
s973400965
289
61
80,076
61,736
Accepted
Accepted
78.89
N = eval(input()) if N[-1] in ['2','4','5','7','9']: print('hon') elif N[-1] in ['0','1','6','8']: print('pon') else: print('bon')
n = input()[-1] print(((n in '24579')*'hon' + (n in '0168')*'pon' + (n in '3')*'bon'))
7
3
136
87
N = eval(input()) if N[-1] in ["2", "4", "5", "7", "9"]: print("hon") elif N[-1] in ["0", "1", "6", "8"]: print("pon") else: print("bon")
n = input()[-1] print(((n in "24579") * "hon" + (n in "0168") * "pon" + (n in "3") * "bon"))
false
57.142857
[ "-N = eval(input())", "-if N[-1] in [\"2\", \"4\", \"5\", \"7\", \"9\"]:", "- print(\"hon\")", "-elif N[-1] in [\"0\", \"1\", \"6\", \"8\"]:", "- print(\"pon\")", "-else:", "- print(\"bon\")", "+n = input()[-1]", "+print(((n in \"24579\") * \"hon\" + (n in \"0168\") * \"pon\" + (n in \"3\")...
false
0.06561
0.040013
1.639726
[ "s141430874", "s973400965" ]
u380995377
p03162
python
s922456917
s128251073
691
481
45,664
90,968
Accepted
Accepted
30.39
n = int(eval(input())) vv = [] for i in range(n): v = [int(x) for x in input().split()] vv.append(v) dp = [[0 for i in range(3)] for j in range(n+1)] for i in range(n): for h in range(3): dp[i+1][h] = max(dp[i][(h+1)%3],dp[i][(h+2)%3]) + vv[i][h] print((max(dp[n])))
import sys import math from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN from collections import deque from bisect import bisect_left from itertools import product def I(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys...
13
37
293
1,479
n = int(eval(input())) vv = [] for i in range(n): v = [int(x) for x in input().split()] vv.append(v) dp = [[0 for i in range(3)] for j in range(n + 1)] for i in range(n): for h in range(3): dp[i + 1][h] = max(dp[i][(h + 1) % 3], dp[i][(h + 2) % 3]) + vv[i][h] print((max(dp[n])))
import sys import math from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN from collections import deque from bisect import bisect_left from itertools import product def I(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(ma...
false
64.864865
[ "-n = int(eval(input()))", "-vv = []", "-for i in range(n):", "- v = [int(x) for x in input().split()]", "- vv.append(v)", "-dp = [[0 for i in range(3)] for j in range(n + 1)]", "-for i in range(n):", "- for h in range(3):", "- dp[i + 1][h] = max(dp[i][(h + 1) % 3], dp[i][(h + 2) % 3...
false
0.041467
0.045864
0.904118
[ "s922456917", "s128251073" ]
u790710233
p03786
python
s055629821
s695739445
234
108
14,320
14,320
Accepted
Accepted
53.85
import heapq n = int(eval(input())) A = list(map(int, input().split())) heapq.heapify(A) cnt = 1 prev = heapq.heappop(A) while A: x = heapq.heappop(A) if prev > x: heapq.heappush(A, prev) prev = x continue if 2*prev < x: cnt = 1 else: cnt += 1 ...
n = int(eval(input())) A = sorted(map(int, input().split())) t = 0 s = A[0] for i in range(1, n): if 2*s < A[i]: t = i s += A[i] print((n-t))
20
11
340
161
import heapq n = int(eval(input())) A = list(map(int, input().split())) heapq.heapify(A) cnt = 1 prev = heapq.heappop(A) while A: x = heapq.heappop(A) if prev > x: heapq.heappush(A, prev) prev = x continue if 2 * prev < x: cnt = 1 else: cnt += 1 prev += x pri...
n = int(eval(input())) A = sorted(map(int, input().split())) t = 0 s = A[0] for i in range(1, n): if 2 * s < A[i]: t = i s += A[i] print((n - t))
false
45
[ "-import heapq", "-", "-A = list(map(int, input().split()))", "-heapq.heapify(A)", "-cnt = 1", "-prev = heapq.heappop(A)", "-while A:", "- x = heapq.heappop(A)", "- if prev > x:", "- heapq.heappush(A, prev)", "- prev = x", "- continue", "- if 2 * prev < x:", "...
false
0.037992
0.038378
0.989927
[ "s055629821", "s695739445" ]
u917432951
p02264
python
s113541601
s637411784
810
300
21,276
18,456
Accepted
Accepted
62.96
n, q = list(map(int, input().split())) data = [] for i in range(n): tmp = input().split() tmp[1] = int(tmp[1]) data.append(tmp) dt_out = [] time_count = 0 while len(data) > 0 : tmp = data.pop(0) if(tmp[1] <= q): time_count += tmp[1] dt_out.append([tmp[0],time_count]) ...
from collections import deque def doRoundRobin(nt,q): result = [] countTime = 0 while len(nt) > 0: tmp = nt.popleft() if tmp[1] <= q: countTime += tmp[1] result.append([tmp[0],countTime]) else: tmp[1] -= q countTime += ...
22
31
453
670
n, q = list(map(int, input().split())) data = [] for i in range(n): tmp = input().split() tmp[1] = int(tmp[1]) data.append(tmp) dt_out = [] time_count = 0 while len(data) > 0: tmp = data.pop(0) if tmp[1] <= q: time_count += tmp[1] dt_out.append([tmp[0], time_count]) else: ...
from collections import deque def doRoundRobin(nt, q): result = [] countTime = 0 while len(nt) > 0: tmp = nt.popleft() if tmp[1] <= q: countTime += tmp[1] result.append([tmp[0], countTime]) else: tmp[1] -= q countTime += q ...
false
29.032258
[ "-n, q = list(map(int, input().split()))", "-data = []", "-for i in range(n):", "- tmp = input().split()", "- tmp[1] = int(tmp[1])", "- data.append(tmp)", "-dt_out = []", "-time_count = 0", "-while len(data) > 0:", "- tmp = data.pop(0)", "- if tmp[1] <= q:", "- time_count...
false
0.171671
0.037533
4.573917
[ "s113541601", "s637411784" ]
u048238198
p02571
python
s741212999
s715569898
146
56
9,152
9,144
Accepted
Accepted
61.64
import sys import math #https://atcoder.jp/contests/agc008/submissions/15248942 sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033...
import sys import math #https://atcoder.jp/contests/agc008/submissions/15248942 sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033...
26
25
694
614
import sys import math # https://atcoder.jp/contests/agc008/submissions/15248942 sys.setrecursionlimit(10**8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a,...
import sys import math # https://atcoder.jp/contests/agc008/submissions/15248942 sys.setrecursionlimit(10**8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a,...
false
3.846154
[ "-ans = 0", "-for i in range(len(S)):", "- for j in range(i + 1, len(S) + 1):", "- if (j - i) == len(T):", "- match = 0", "- for k, l in enumerate(range(i, j)):", "- if S[l] == T[k]:", "- match += 1", "- ans = max(ans, matc...
false
0.037066
0.037563
0.986753
[ "s741212999", "s715569898" ]
u860002137
p02924
python
s644506756
s424798866
303
17
21,652
2,940
Accepted
Accepted
94.39
import numpy as np N = int(eval(input())) print((N*(N-1)//2))
N = int(eval(input())) print((N*(N-1)//2))
3
2
55
35
import numpy as np N = int(eval(input())) print((N * (N - 1) // 2))
N = int(eval(input())) print((N * (N - 1) // 2))
false
33.333333
[ "-import numpy as np", "-" ]
false
0.072816
0.035626
2.043875
[ "s644506756", "s424798866" ]
u777283665
p02947
python
s547487707
s653038542
703
462
62,168
17,848
Accepted
Accepted
34.28
n = int(eval(input())) d = dict() for i in range(n): s = "".join(sorted(list(eval(input())))) d[s] = d.get(s, 0) + 1 count = 0 for i in list(d.items()): count += (i[1] * (i[1] - 1)) // 2 print(count)
import math n = int(eval(input())) d = dict() for _ in range(n): s = "".join(sorted([x for x in eval(input())])) d[s] = d.get(s, 0) + 1 ans = 0 for v in list(d.values()): if v >= 2: ans += (v * (v-1)) // 2 print(ans)
14
16
205
238
n = int(eval(input())) d = dict() for i in range(n): s = "".join(sorted(list(eval(input())))) d[s] = d.get(s, 0) + 1 count = 0 for i in list(d.items()): count += (i[1] * (i[1] - 1)) // 2 print(count)
import math n = int(eval(input())) d = dict() for _ in range(n): s = "".join(sorted([x for x in eval(input())])) d[s] = d.get(s, 0) + 1 ans = 0 for v in list(d.values()): if v >= 2: ans += (v * (v - 1)) // 2 print(ans)
false
12.5
[ "+import math", "+", "-for i in range(n):", "- s = \"\".join(sorted(list(eval(input()))))", "+for _ in range(n):", "+ s = \"\".join(sorted([x for x in eval(input())]))", "-count = 0", "-for i in list(d.items()):", "- count += (i[1] * (i[1] - 1)) // 2", "-print(count)", "+ans = 0", "+f...
false
0.037058
0.03782
0.979858
[ "s547487707", "s653038542" ]