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
u297574184
p02793
python
s320364900
s695259946
1,309
1,009
148,356
44,072
Accepted
Accepted
22.92
from collections import Counter def solve(): MOD = 10**9 + 7 def getPrimeFactors(x): anss = [] for d in range(2, int(x**0.5)+1): while x%d == 0: anss.append(d) x //= d if x != 1: anss.append(x) return anss ...
from collections import Counter def solve(): MOD = 10**9 + 7 maxA = 10**6 def getPrimeFactors(x): anss = [] while x%2 == 0: anss.append(2) x //= 2 for d in range(3, int(x**0.5)+1, 2): while x%d == 0: anss.append(d) ...
52
49
1,105
1,065
from collections import Counter def solve(): MOD = 10**9 + 7 def getPrimeFactors(x): anss = [] for d in range(2, int(x**0.5) + 1): while x % d == 0: anss.append(d) x //= d if x != 1: anss.append(x) return anss N = in...
from collections import Counter def solve(): MOD = 10**9 + 7 maxA = 10**6 def getPrimeFactors(x): anss = [] while x % 2 == 0: anss.append(2) x //= 2 for d in range(3, int(x**0.5) + 1, 2): while x % d == 0: anss.append(d) ...
false
5.769231
[ "+ maxA = 10**6", "- for d in range(2, int(x**0.5) + 1):", "+ while x % 2 == 0:", "+ anss.append(2)", "+ x //= 2", "+ for d in range(3, int(x**0.5) + 1, 2):", "- PFss = []", "- Primes = set()", "+ cntP = Counter()", "- cnt = Counter(PFs...
false
0.070651
1.34716
0.052445
[ "s320364900", "s695259946" ]
u766393261
p02983
python
s003960352
s892594210
666
75
75,440
6,892
Accepted
Accepted
88.74
import sys L,R=list(map(int,input().split())) modifyed=[] flag=0 for i in range(L,R+1): modifyed.append(i%2019) if i%2019==0: print((0)) sys.exit() ans=[] for m in range(len(modifyed)): for j in range(m+1,len(modifyed)): ans.append(modifyed[m]*modifyed[j]%2019) print((mi...
import sys L,R=list(map(int,input().split())) modifyed=[] flag=0 for i in range(L,R+1): modifyed.append(i%2019) if i%2019==0: print((0)) sys.exit() ans=[] for m in range(len(modifyed)): for j in range(m+1,len(modifyed)): ans.append(modifyed[m]*modifyed[j]%2019) i...
15
17
332
405
import sys L, R = list(map(int, input().split())) modifyed = [] flag = 0 for i in range(L, R + 1): modifyed.append(i % 2019) if i % 2019 == 0: print((0)) sys.exit() ans = [] for m in range(len(modifyed)): for j in range(m + 1, len(modifyed)): ans.append(modifyed[m] * modifyed[j] % 2...
import sys L, R = list(map(int, input().split())) modifyed = [] flag = 0 for i in range(L, R + 1): modifyed.append(i % 2019) if i % 2019 == 0: print((0)) sys.exit() ans = [] for m in range(len(modifyed)): for j in range(m + 1, len(modifyed)): ans.append(modifyed[m] * modifyed[j] % 2...
false
11.764706
[ "+ if modifyed[m] * modifyed[j] % 2019 == 0:", "+ print((0))", "+ sys.exit()" ]
false
0.037854
0.0358
1.057394
[ "s003960352", "s892594210" ]
u124498235
p02744
python
s966819055
s002274386
102
81
17,088
9,016
Accepted
Accepted
20.59
n = int(eval(input())) v = 'abcdefghijk' w = [] def dfs(s,t): if len(s) == n: w.append(s) return u = len(set(s)) for i in range(u+1): dfs(s+v[i],u+1) dfs('a',1) for i in w: print (i)
n = int(eval(input())) v = 'abcdefghij' def dfs(s): if len(s) == n: print (s) return for i in range(len(set(s))+1): dfs(s+v[i]) dfs('a')
16
9
214
154
n = int(eval(input())) v = "abcdefghijk" w = [] def dfs(s, t): if len(s) == n: w.append(s) return u = len(set(s)) for i in range(u + 1): dfs(s + v[i], u + 1) dfs("a", 1) for i in w: print(i)
n = int(eval(input())) v = "abcdefghij" def dfs(s): if len(s) == n: print(s) return for i in range(len(set(s)) + 1): dfs(s + v[i]) dfs("a")
false
43.75
[ "-v = \"abcdefghijk\"", "-w = []", "+v = \"abcdefghij\"", "-def dfs(s, t):", "+def dfs(s):", "- w.append(s)", "+ print(s)", "- u = len(set(s))", "- for i in range(u + 1):", "- dfs(s + v[i], u + 1)", "+ for i in range(len(set(s)) + 1):", "+ dfs(s + v[i])", ...
false
0.040041
0.040608
0.98604
[ "s966819055", "s002274386" ]
u156815136
p03403
python
s020333758
s439954750
254
174
14,304
22,032
Accepted
Accepted
31.5
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] #from fractions import gcd #from itertools import combinations # (string,3) 3回 #from collections import deque from collections import deque,defaultdict #import bisect # # d =...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counte...
39
37
884
929
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] # from fractions import gcd # from itertools import combinations # (string,3) 3回 # from collections import deque from collections import deque, defaultdict # import bisect # # d =...
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Co...
false
5.128205
[ "-# from fractions import gcd", "-# from itertools import combinations # (string,3) 3回", "+from fractions import gcd", "+from itertools import combinations, permutations, accumulate # (string,3) 3回", "+", "-from collections import deque, defaultdict", "+from collections import deque, defaultdict, Count...
false
0.096306
0.04755
2.025352
[ "s020333758", "s439954750" ]
u777283665
p03645
python
s389177639
s136128928
756
694
29,092
29,092
Accepted
Accepted
8.2
n, m = list(map(int, input().split())) n -= 1 ab = [[] for i in range(n)] for _ in range(m): a, b = list(map(int, input().split())) ab[a-1].append(b-1) for i in ab[0]: for j in ab[i]: if j == n: print("POSSIBLE") exit() print("IMPOSSIBLE")
n, m = list(map(int, input().split())) x = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) x[a-1].append(b-1) if x[0] == []: print("IMPOSSIBLE") exit() for i in x[0]: for j in x[i]: if j == n-1: print("POSSIBLE") exit...
16
18
290
333
n, m = list(map(int, input().split())) n -= 1 ab = [[] for i in range(n)] for _ in range(m): a, b = list(map(int, input().split())) ab[a - 1].append(b - 1) for i in ab[0]: for j in ab[i]: if j == n: print("POSSIBLE") exit() print("IMPOSSIBLE")
n, m = list(map(int, input().split())) x = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) x[a - 1].append(b - 1) if x[0] == []: print("IMPOSSIBLE") exit() for i in x[0]: for j in x[i]: if j == n - 1: print("POSSIBLE") exit() print("IM...
false
11.111111
[ "-n -= 1", "-ab = [[] for i in range(n)]", "+x = [[] for _ in range(n)]", "- ab[a - 1].append(b - 1)", "-for i in ab[0]:", "- for j in ab[i]:", "- if j == n:", "+ x[a - 1].append(b - 1)", "+if x[0] == []:", "+ print(\"IMPOSSIBLE\")", "+ exit()", "+for i in x[0]:", "+ ...
false
0.124585
0.097009
1.284262
[ "s389177639", "s136128928" ]
u058781705
p03285
python
s526882341
s564960022
185
68
38,384
63,096
Accepted
Accepted
63.24
ans = float("inf") def solve(): N = int(eval(input())) for cake in range(100): for donuts in range(100): if cake*4 + donuts*7 == N: print("Yes") exit() print("No") if __name__ == "__main__": solve()
N = int(eval(input())) for i in range(100): for j in range(100): if i * 4+j*7 == N: print("Yes") exit() print("No")
19
9
287
156
ans = float("inf") def solve(): N = int(eval(input())) for cake in range(100): for donuts in range(100): if cake * 4 + donuts * 7 == N: print("Yes") exit() print("No") if __name__ == "__main__": solve()
N = int(eval(input())) for i in range(100): for j in range(100): if i * 4 + j * 7 == N: print("Yes") exit() print("No")
false
52.631579
[ "-ans = float(\"inf\")", "-", "-", "-def solve():", "- N = int(eval(input()))", "- for cake in range(100):", "- for donuts in range(100):", "- if cake * 4 + donuts * 7 == N:", "- print(\"Yes\")", "- exit()", "- print(\"No\")", "-", "-"...
false
0.062992
0.062359
1.010144
[ "s526882341", "s564960022" ]
u698868214
p02861
python
s852697244
s971998015
312
38
13,996
13,788
Accepted
Accepted
87.82
from itertools import permutations import math N = int(eval(input())) xy = [tuple(map(int,input().split())) for _ in range(N)] city = list(permutations(xy)) all_len = 0 for i in city: sum_len = 0 for j in range(1,N): sum_len += ((i[j][0]-i[j-1][0])**2 +(i[j][1]-i[j-1][1])**2)**0.5 all_len += sum_len...
import itertools n = int(eval(input())) town = [tuple(map(int,input().split())) for _ in range(n)] c_town = list(itertools.combinations(town,2)) lp = len(list(itertools.permutations(town))) sum_road = 0 for i in c_town: sum_road += ((i[0][0]-i[1][0])**2 + (i[0][1]-i[1][1])**2)**0.5 print((2*sum_road/n...
12
12
340
314
from itertools import permutations import math N = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(N)] city = list(permutations(xy)) all_len = 0 for i in city: sum_len = 0 for j in range(1, N): sum_len += ((i[j][0] - i[j - 1][0]) ** 2 + (i[j][1] - i[j - 1][1]) ** 2) ** 0.5 ...
import itertools n = int(eval(input())) town = [tuple(map(int, input().split())) for _ in range(n)] c_town = list(itertools.combinations(town, 2)) lp = len(list(itertools.permutations(town))) sum_road = 0 for i in c_town: sum_road += ((i[0][0] - i[1][0]) ** 2 + (i[0][1] - i[1][1]) ** 2) ** 0.5 print((2 * sum_road ...
false
0
[ "-from itertools import permutations", "-import math", "+import itertools", "-N = int(eval(input()))", "-xy = [tuple(map(int, input().split())) for _ in range(N)]", "-city = list(permutations(xy))", "-all_len = 0", "-for i in city:", "- sum_len = 0", "- for j in range(1, N):", "- su...
false
0.043264
0.040129
1.078124
[ "s852697244", "s971998015" ]
u343977188
p02597
python
s612061840
s617095264
40
30
11,920
9,192
Accepted
Accepted
25
N=int(eval(input())) c=list(str(eval(input()))) R=c.count('R') W=c.count('W') print((c[:R].count('W')))
N=int(eval(input())) c=str(eval(input())) R=c.count('R') W=c[:R].count('W') print(W)
5
5
94
76
N = int(eval(input())) c = list(str(eval(input()))) R = c.count("R") W = c.count("W") print((c[:R].count("W")))
N = int(eval(input())) c = str(eval(input())) R = c.count("R") W = c[:R].count("W") print(W)
false
0
[ "-c = list(str(eval(input())))", "+c = str(eval(input()))", "-W = c.count(\"W\")", "-print((c[:R].count(\"W\")))", "+W = c[:R].count(\"W\")", "+print(W)" ]
false
0.045606
0.047278
0.964628
[ "s612061840", "s617095264" ]
u241159583
p02732
python
s266065760
s845532264
534
289
26,780
34,036
Accepted
Accepted
45.88
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) A = Counter(a) X = 0 for x, y in list(A.items()): X += y * (y-1) // 2 for i in range(n): N = a[i] ans = X if A[N] >= 2: ans -= A[N] * (A[N]-1) // 2 ans += (A[N]-1) * (A[N]-2) // 2 ...
from collections import Counter n = int(eval(input())) A = list(map(int, input().split())) a = {} ANS = 0 for x,y in list(Counter(A).items()): if y >= 2: a[x] = [y, (y*(y-1))//2] ANS += (y*(y-1))//2 for i in range(n): ans = ANS if A[i] in a: x = a[A[i]][0]-1 ans...
16
16
323
367
from collections import Counter n = int(eval(input())) a = list(map(int, input().split())) A = Counter(a) X = 0 for x, y in list(A.items()): X += y * (y - 1) // 2 for i in range(n): N = a[i] ans = X if A[N] >= 2: ans -= A[N] * (A[N] - 1) // 2 ans += (A[N] - 1) * (A[N] - 2) // 2 prin...
from collections import Counter n = int(eval(input())) A = list(map(int, input().split())) a = {} ANS = 0 for x, y in list(Counter(A).items()): if y >= 2: a[x] = [y, (y * (y - 1)) // 2] ANS += (y * (y - 1)) // 2 for i in range(n): ans = ANS if A[i] in a: x = a[A[i]][0] - 1 a...
false
0
[ "-a = list(map(int, input().split()))", "-A = Counter(a)", "-X = 0", "-for x, y in list(A.items()):", "- X += y * (y - 1) // 2", "+A = list(map(int, input().split()))", "+a = {}", "+ANS = 0", "+for x, y in list(Counter(A).items()):", "+ if y >= 2:", "+ a[x] = [y, (y * (y - 1)) // 2]...
false
0.097166
0.042118
2.307012
[ "s266065760", "s845532264" ]
u759412327
p03470
python
s123953657
s305094789
20
17
2,940
2,940
Accepted
Accepted
15
a = int(eval(input())) b = [int(eval(input())) for i in range(a)] c = set(b) print((len(c)))
a = int(eval(input())) b = set(int(eval(input())) for i in range(a)) print((len(b)))
4
3
81
72
a = int(eval(input())) b = [int(eval(input())) for i in range(a)] c = set(b) print((len(c)))
a = int(eval(input())) b = set(int(eval(input())) for i in range(a)) print((len(b)))
false
25
[ "-b = [int(eval(input())) for i in range(a)]", "-c = set(b)", "-print((len(c)))", "+b = set(int(eval(input())) for i in range(a))", "+print((len(b)))" ]
false
0.038389
0.039687
0.9673
[ "s123953657", "s305094789" ]
u756439833
p03166
python
s335407700
s207767981
765
359
164,016
55,728
Accepted
Accepted
53.07
import sys sys.setrecursionlimit(10 ** 5 + 5) input = sys.stdin.readline ''' allinputs = iter(input().splitlines()) input = lambda : next(allinputs) #''' N, M = list(map(int, input().split())) x, y = [0] * M, [0] * M from_x = [[] for _ in range(N)] memo = [-1] * N ans = 0 def length(i): if memo[i] >= 0:...
import sys input = sys.stdin.readline ''' allinputs = iter(input().splitlines()) input = lambda : next(allinputs) #''' N, M = list(map(int, input().split())) to_y = [[] for _ in range(N)] deg = [0] * N stack = [] dp = [0] * N for _ in range(M): x, y = list(map(int, input().split())) to_y[x - 1].append(...
41
30
735
558
import sys sys.setrecursionlimit(10**5 + 5) input = sys.stdin.readline """ allinputs = iter(input().splitlines()) input = lambda : next(allinputs) #""" N, M = list(map(int, input().split())) x, y = [0] * M, [0] * M from_x = [[] for _ in range(N)] memo = [-1] * N ans = 0 def length(i): if memo[i] >= 0: re...
import sys input = sys.stdin.readline """ allinputs = iter(input().splitlines()) input = lambda : next(allinputs) #""" N, M = list(map(int, input().split())) to_y = [[] for _ in range(N)] deg = [0] * N stack = [] dp = [0] * N for _ in range(M): x, y = list(map(int, input().split())) to_y[x - 1].append(y - 1) ...
false
26.829268
[ "-sys.setrecursionlimit(10**5 + 5)", "-x, y = [0] * M, [0] * M", "-from_x = [[] for _ in range(N)]", "-memo = [-1] * N", "-ans = 0", "-", "-", "-def length(i):", "- if memo[i] >= 0:", "- return memo[i]", "- else:", "- if len(from_x[i]) == 0:", "- memo[i] = 0", ...
false
0.047473
0.046714
1.016251
[ "s335407700", "s207767981" ]
u631277801
p03828
python
s240441485
s955844194
38
29
3,700
3,552
Accepted
Accepted
23.68
from math import sqrt from collections import Counter # 半開区間[lower, upper)の素数のリストを作成する def make_prime_list(lower:int, upper:int) -> list: # 変数のバリデーション if lower < 0: raise ValueError("lowerは0以上でなければいけません。(lower:{})".format(lower)) elif upper <= lower: raise ValueError("upper...
from math import sqrt from collections import defaultdict # 半開区間[lower, upper)の素数のリストを作成する def make_prime_list(lower:int, upper:int) -> list: # 変数のバリデーション if lower < 0: raise ValueError("lowerは0以上でなければいけません。(lower:{})".format(lower)) elif upper <= lower: raise ValueError...
93
107
2,003
2,422
from math import sqrt from collections import Counter # 半開区間[lower, upper)の素数のリストを作成する def make_prime_list(lower: int, upper: int) -> list: # 変数のバリデーション if lower < 0: raise ValueError("lowerは0以上でなければいけません。(lower:{})".format(lower)) elif upper <= lower: raise ValueError( "upperはl...
from math import sqrt from collections import defaultdict # 半開区間[lower, upper)の素数のリストを作成する def make_prime_list(lower: int, upper: int) -> list: # 変数のバリデーション if lower < 0: raise ValueError("lowerは0以上でなければいけません。(lower:{})".format(lower)) elif upper <= lower: raise ValueError( "upp...
false
13.084112
[ "-from collections import Counter", "+from collections import defaultdict", "- cnt = Counter()", "+ dic = defaultdict(int)", "- cnt[prime_list[i]] += 1", "+ dic[prime_list[i]] += 1", "- cnt[res] += 1", "- return cnt", "+ dic[res] += 1", "+ return dic", "-n...
false
0.060322
0.042109
1.432534
[ "s240441485", "s955844194" ]
u489959379
p03861
python
s523531026
s971948561
182
20
38,384
3,060
Accepted
Accepted
89.01
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): a, b, x = list(map(int, input().split())) print((b // x + 1 - max(0, (a - 1) // x + 1))) if __name__ == '__main__': resolve()
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): a, b, x = list(map(int, input().split())) res_a = (a - 1) // x res_b = b // x print((res_b - res_a)) if __name__ == '__main__': resolve()
14
18
244
296
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): a, b, x = list(map(int, input().split())) print((b // x + 1 - max(0, (a - 1) // x + 1))) if __name__ == "__main__": resolve()
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline f_inf = float("inf") mod = 10**9 + 7 def resolve(): a, b, x = list(map(int, input().split())) res_a = (a - 1) // x res_b = b // x print((res_b - res_a)) if __name__ == "__main__": resolve()
false
22.222222
[ "+input = sys.stdin.readline", "- print((b // x + 1 - max(0, (a - 1) // x + 1)))", "+ res_a = (a - 1) // x", "+ res_b = b // x", "+ print((res_b - res_a))" ]
false
0.042135
0.03417
1.233083
[ "s523531026", "s971948561" ]
u185948224
p02873
python
s975354355
s823790326
429
369
27,548
28,060
Accepted
Accepted
13.99
S = eval(input()) lst = [1 if S[0]=='<' else -1] for i in range(1, len(S)): if S[i] == S[i - 1]: lst[-1] += 1 if S[i]=='<' else -1 else: lst.append(-1 if S[i]=='>' else 1) ans = [0] for i in lst: if i > 0: ans += list(range(1,i+1)) else: ans[-1] ...
S = eval(input()) lst = [1 if S[0]=='<' else -1] pre = S[0] for i in S[1:]: if i == pre: lst[-1] += 1 if i=='<' else -1 else: lst.append(-1 if i=='>' else 1) pre = i ans = [0] for i in lst: if i > 0: ans += list(range(1,i+1)) else: ans[-1] = max(...
20
20
394
386
S = eval(input()) lst = [1 if S[0] == "<" else -1] for i in range(1, len(S)): if S[i] == S[i - 1]: lst[-1] += 1 if S[i] == "<" else -1 else: lst.append(-1 if S[i] == ">" else 1) ans = [0] for i in lst: if i > 0: ans += list(range(1, i + 1)) else: ans[-1] = max(ans[-1], -i...
S = eval(input()) lst = [1 if S[0] == "<" else -1] pre = S[0] for i in S[1:]: if i == pre: lst[-1] += 1 if i == "<" else -1 else: lst.append(-1 if i == ">" else 1) pre = i ans = [0] for i in lst: if i > 0: ans += list(range(1, i + 1)) else: ans[-1] = max(ans[-1], -i) ...
false
0
[ "-for i in range(1, len(S)):", "- if S[i] == S[i - 1]:", "- lst[-1] += 1 if S[i] == \"<\" else -1", "+pre = S[0]", "+for i in S[1:]:", "+ if i == pre:", "+ lst[-1] += 1 if i == \"<\" else -1", "- lst.append(-1 if S[i] == \">\" else 1)", "+ lst.append(-1 if i == \">\...
false
0.112185
0.03692
3.03857
[ "s975354355", "s823790326" ]
u753386263
p03164
python
s665863573
s131142147
954
815
308,168
300,120
Accepted
Accepted
14.57
N, W = list(map(int, input().split())) w, v = [0] * N, [0] * N for i in range(N): w[i], v[i] = list(map(int, input().split())) V = sum(v) # dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値 dp = [[float("inf")] * (V + 1) for _ in range(N + 1)] dp[0][0] = 0 for i in range(N): for j in range(V + 1): ...
N, W = list(map(int, input().split())) w, v = [0] * N, [0] * N for i in range(N): w[i], v[i] = list(map(int, input().split())) V = sum(v) Vi=[0] * N for i in range(N): if i==0: Vi[i]=v[i] else: Vi[i]=Vi[i-1]+v[i] # dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値 dp = [[float("inf"...
25
32
617
728
N, W = list(map(int, input().split())) w, v = [0] * N, [0] * N for i in range(N): w[i], v[i] = list(map(int, input().split())) V = sum(v) # dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値 dp = [[float("inf")] * (V + 1) for _ in range(N + 1)] dp[0][0] = 0 for i in range(N): for j in range(V + 1): # i+1番目を入...
N, W = list(map(int, input().split())) w, v = [0] * N, [0] * N for i in range(N): w[i], v[i] = list(map(int, input().split())) V = sum(v) Vi = [0] * N for i in range(N): if i == 0: Vi[i] = v[i] else: Vi[i] = Vi[i - 1] + v[i] # dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値 dp = [[float("inf")...
false
21.875
[ "+Vi = [0] * N", "+for i in range(N):", "+ if i == 0:", "+ Vi[i] = v[i]", "+ else:", "+ Vi[i] = Vi[i - 1] + v[i]", "- for j in range(V + 1):", "+ for j in range(Vi[i] + 1):" ]
false
0.111877
0.046043
2.429819
[ "s665863573", "s131142147" ]
u947883560
p03039
python
s093145179
s680899620
208
118
11,576
11,540
Accepted
Accepted
43.27
#!/usr/bin/env python3 import sys INF = float("inf") MOD = 1000000007 # type: int def cmb(n, r): r = min(r, n-r) if r == 0: return 1 if r == 1: return n numer = [n - r + k + 1 for k in range(r)] denom = [k + 1 for k in range(r)] for p in range(2, r+1): ...
#!/usr/bin/env python3 import sys INF = float("inf") MOD = 1000000007 # type: int def cmb(n, r): r = min(r, n-r) if r == 0: return 1 if r == 1: return n numer = [n - r + k + 1 for k in range(r)] denom = [k + 1 for k in range(r)] for p in range(2, r+1): ...
70
62
1,370
1,289
#!/usr/bin/env python3 import sys INF = float("inf") MOD = 1000000007 # type: int def cmb(n, r): r = min(r, n - r) if r == 0: return 1 if r == 1: return n numer = [n - r + k + 1 for k in range(r)] denom = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = den...
#!/usr/bin/env python3 import sys INF = float("inf") MOD = 1000000007 # type: int def cmb(n, r): r = min(r, n - r) if r == 0: return 1 if r == 1: return n numer = [n - r + k + 1 for k in range(r)] denom = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = den...
false
11.428571
[ "+ result %= MOD", "- sx = 0", "- for x in range(1, M + 1):", "- sx += x * (x - 1) // 2", "- sx %= MOD", "- sx *= N * N", "- sx %= MOD", "- sy = 0", "- for y in range(1, N + 1):", "- sy += y * (y - 1) // 2", "- sy %= MOD", "- sy *= M ...
false
0.037747
0.038024
0.992726
[ "s093145179", "s680899620" ]
u389910364
p03283
python
s213617860
s654473927
2,640
2,098
18,592
102,620
Accepted
Accepted
20.53
import numpy as np N, M, Q = list(map(int, input().split())) # trains[L][r]: L から r まで行く電車の本数 (1 <= L <= r <= N) trains = [[0 for _ in range(N + 1)] for _ in range(N + 1)] for m in range(M): L, r = list(map(int, input().split())) trains[L][r] += 1 cumsum = np.cumsum(trains, axis=0).cumsum(axis=1) ...
import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 class BinaryIndexedTree: # http://hos.ac/slides/20140319_bit.pdf def __init__(self, size): """ ...
21
73
614
1,678
import numpy as np N, M, Q = list(map(int, input().split())) # trains[L][r]: L から r まで行く電車の本数 (1 <= L <= r <= N) trains = [[0 for _ in range(N + 1)] for _ in range(N + 1)] for m in range(M): L, r = list(map(int, input().split())) trains[L][r] += 1 cumsum = np.cumsum(trains, axis=0).cumsum(axis=1) def solve(L...
import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10**9) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 # MOD = 998244353 class BinaryIndexedTree: # http://hos.ac/slides/20140319_bit.pdf def __init__(self, size): """ :param int size: ...
false
71.232877
[ "-import numpy as np", "+import os", "+import sys", "-N, M, Q = list(map(int, input().split()))", "-# trains[L][r]: L から r まで行く電車の本数 (1 <= L <= r <= N)", "-trains = [[0 for _ in range(N + 1)] for _ in range(N + 1)]", "-for m in range(M):", "- L, r = list(map(int, input().split()))", "- trains[...
false
0.312474
0.042754
7.308693
[ "s213617860", "s654473927" ]
u499381410
p02851
python
s221719866
s330459260
300
204
86,300
124,564
Accepted
Accepted
32
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, ...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, ...
49
44
1,280
1,317
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor fro...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor, co...
false
10.204082
[ "-from math import factorial, ceil, floor", "+from math import factorial, ceil, floor, cos, radians, pi, sin", "+from operator import mul", "-INF = 10**20", "+INF = 10**13", "-mod = 1000000007", "+mod = 10**9 + 7", "+D = defaultdict(int)", "-D = defaultdict(int)", "-for j in range(n + 1):", "- ...
false
0.03784
0.082713
0.457488
[ "s221719866", "s330459260" ]
u411858517
p03633
python
s779188462
s015889333
173
18
38,256
3,060
Accepted
Accepted
89.6
N = int(eval(input())) L = [ int(eval(input())) for i in range(N)] def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) x = L[0] for i in range(len(L)-1): y = lcm(x, L[i+1]) x = y print(x)
#a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a #a,bの最小公倍数 def lcm(a, b): return a * b // gcd (a, b) N = int(eval(input())) L = [int(eval(input())) for _ in range(N)] tmp = L[0] for i in range(1, N): tmp = lcm(tmp, L[i]) print(tmp)
17
18
265
281
N = int(eval(input())) L = [int(eval(input())) for i in range(N)] def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) x = L[0] for i in range(len(L) - 1): y = lcm(x, L[i + 1]) x = y print(x)
# a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a # a,bの最小公倍数 def lcm(a, b): return a * b // gcd(a, b) N = int(eval(input())) L = [int(eval(input())) for _ in range(N)] tmp = L[0] for i in range(1, N): tmp = lcm(tmp, L[i]) print(tmp)
false
5.555556
[ "-N = int(eval(input()))", "-L = [int(eval(input())) for i in range(N)]", "-", "-", "+# a,bの最大公約数", "+# a,bの最小公倍数", "-x = L[0]", "-for i in range(len(L) - 1):", "- y = lcm(x, L[i + 1])", "- x = y", "-print(x)", "+N = int(eval(input()))", "+L = [int(eval(input())) for _ in range(N)]", ...
false
0.035398
0.036407
0.972292
[ "s779188462", "s015889333" ]
u476604182
p03805
python
s019576206
s408124781
201
30
40,432
3,064
Accepted
Accepted
85.07
from collections import defaultdict from itertools import permutations N, M = list(map(int, input().split())) dic = defaultdict(list) for i in range(M): a, b = list(map(int, input().split())) dic[a-1] += [b-1] dic[b-1] += [a-1] ans = 0 ls = permutations(list(range(1,N))) for l in ls: l = [0]+list(l...
from itertools import permutations N, M, *L = list(map(int, open(0).read().split())) dic = [[] for i in range(N+1)] for a, b in zip(*[iter(L)]*2): dic[a].append(b) dic[b].append(a) ans = 0 for l in permutations(list(range(2,N+1))): l = [1]+list(l) for i in range(N-1): if l[i+1] not in dic[l[i]]:...
19
16
417
356
from collections import defaultdict from itertools import permutations N, M = list(map(int, input().split())) dic = defaultdict(list) for i in range(M): a, b = list(map(int, input().split())) dic[a - 1] += [b - 1] dic[b - 1] += [a - 1] ans = 0 ls = permutations(list(range(1, N))) for l in ls: l = [0] +...
from itertools import permutations N, M, *L = list(map(int, open(0).read().split())) dic = [[] for i in range(N + 1)] for a, b in zip(*[iter(L)] * 2): dic[a].append(b) dic[b].append(a) ans = 0 for l in permutations(list(range(2, N + 1))): l = [1] + list(l) for i in range(N - 1): if l[i + 1] not...
false
15.789474
[ "-from collections import defaultdict", "-N, M = list(map(int, input().split()))", "-dic = defaultdict(list)", "-for i in range(M):", "- a, b = list(map(int, input().split()))", "- dic[a - 1] += [b - 1]", "- dic[b - 1] += [a - 1]", "+N, M, *L = list(map(int, open(0).read().split()))", "+dic...
false
0.101045
0.051137
1.975951
[ "s019576206", "s408124781" ]
u633068244
p02370
python
s447880395
s161876509
180
160
6,864
6,868
Accepted
Accepted
11.11
def bfs(s): que = [s] used[s] = True while que: u = que.pop(0) ans.append(u) for v in G[u]: indeg[v] -= 1 if indeg[v] == 0 and not used[v]: used[v] = True que.append(v) def tsort(): for u in range(V): ...
def tsort(G): def bfs(s): que = [s] used[s] = True while que: u = que.pop(0) res.append(u) for v in G[u]: indeg[v] -= 1 if indeg[v] == 0 and not used[v]: used[v] = True qu...
32
35
635
772
def bfs(s): que = [s] used[s] = True while que: u = que.pop(0) ans.append(u) for v in G[u]: indeg[v] -= 1 if indeg[v] == 0 and not used[v]: used[v] = True que.append(v) def tsort(): for u in range(V): if indeg[u] =...
def tsort(G): def bfs(s): que = [s] used[s] = True while que: u = que.pop(0) res.append(u) for v in G[u]: indeg[v] -= 1 if indeg[v] == 0 and not used[v]: used[v] = True que.append(v) ...
false
8.571429
[ "-def bfs(s):", "- que = [s]", "- used[s] = True", "- while que:", "- u = que.pop(0)", "- ans.append(u)", "+def tsort(G):", "+ def bfs(s):", "+ que = [s]", "+ used[s] = True", "+ while que:", "+ u = que.pop(0)", "+ res.appe...
false
0.040671
0.046363
0.877239
[ "s447880395", "s161876509" ]
u318345739
p02623
python
s073012132
s019642170
340
186
110,956
117,936
Accepted
Accepted
45.29
def main(): N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) total_T_in_A = [0] * (N+1) total_T_in_A[1] = A[0] total_T_in_B = [0] * M total_T_in_B[0] = B[0] for i in range(2, N+1): total_T_in_A[i] = tot...
def main(): N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) total_T_in_A = [0] * (N+1) total_T_in_A[1] = A[0] total_T_in_B = [0] * M total_T_in_B[0] = B[0] for i in range(1, N+1): total_T_in_A[i] = tot...
57
57
1,482
1,482
def main(): N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) total_T_in_A = [0] * (N + 1) total_T_in_A[1] = A[0] total_T_in_B = [0] * M total_T_in_B[0] = B[0] for i in range(2, N + 1): total_T_in_A[i] = total_T_in_A...
def main(): N, M, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) total_T_in_A = [0] * (N + 1) total_T_in_A[1] = A[0] total_T_in_B = [0] * M total_T_in_B[0] = B[0] for i in range(1, N + 1): total_T_in_A[i] = total_T_in_A...
false
0
[ "- for i in range(2, N + 1):", "+ for i in range(1, N + 1):" ]
false
0.03896
0.03846
1.013012
[ "s073012132", "s019642170" ]
u821432765
p03160
python
s317507812
s714695565
185
160
13,980
13,928
Accepted
Accepted
13.51
N = int(eval(input())) h = [int(i) for i in input().split()] dp = [float("inf")]*N dp[0] = 0 for i in range(N-1): dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1])) if i < N-2: dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2])) print((dp[-1]))
n = int(eval(input())) h = [int(i) for i in input().split()] INF = 10**12 dp = [INF]*100010 dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2, n): dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2])) dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1])) print((dp[n-1]))
11
15
256
283
N = int(eval(input())) h = [int(i) for i in input().split()] dp = [float("inf")] * N dp[0] = 0 for i in range(N - 1): dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1])) if i < N - 2: dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2])) print((dp[-1]))
n = int(eval(input())) h = [int(i) for i in input().split()] INF = 10**12 dp = [INF] * 100010 dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2, n): dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) print((dp[n - 1]))
false
26.666667
[ "-N = int(eval(input()))", "+n = int(eval(input()))", "-dp = [float(\"inf\")] * N", "+INF = 10**12", "+dp = [INF] * 100010", "-for i in range(N - 1):", "- dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))", "- if i < N - 2:", "- dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i +...
false
0.045461
0.048165
0.943871
[ "s317507812", "s714695565" ]
u094191970
p02780
python
s836507865
s500009100
200
166
26,236
25,060
Accepted
Accepted
17
from itertools import accumulate n,k=list(map(int,input().split())) p=list(map(int,input().split())) x=[] for i in p: x.append((i+1)/2) b=[0]+list(accumulate(x)) mm=0 inx=-1 for i in range(len(b)-k): if b[i+k]-b[i]>=mm: inx=i mm=b[i+k]-b[i] ans=0 for j in range(inx,inx+k): ans+=((p[j]...
n,k=list(map(int,input().split())) p=list(map(int,input().split())) b=[0] for i in range(1,n+1): b.append(b[i-1]+p[i-1]) max_i=-1 max_v=0 for i in range(1,n+1-k): if b[i+k]-b[i]>max_v: max_i=i max_v=b[i+k]-b[i] ans=0 for i in range(k): ans+=(p[max_i+i]+1)/2 print(ans)
24
17
352
294
from itertools import accumulate n, k = list(map(int, input().split())) p = list(map(int, input().split())) x = [] for i in p: x.append((i + 1) / 2) b = [0] + list(accumulate(x)) mm = 0 inx = -1 for i in range(len(b) - k): if b[i + k] - b[i] >= mm: inx = i mm = b[i + k] - b[i] ans = 0 for j in ...
n, k = list(map(int, input().split())) p = list(map(int, input().split())) b = [0] for i in range(1, n + 1): b.append(b[i - 1] + p[i - 1]) max_i = -1 max_v = 0 for i in range(1, n + 1 - k): if b[i + k] - b[i] > max_v: max_i = i max_v = b[i + k] - b[i] ans = 0 for i in range(k): ans += (p[max...
false
29.166667
[ "-from itertools import accumulate", "-", "-x = []", "-for i in p:", "- x.append((i + 1) / 2)", "-b = [0] + list(accumulate(x))", "-mm = 0", "-inx = -1", "-for i in range(len(b) - k):", "- if b[i + k] - b[i] >= mm:", "- inx = i", "- mm = b[i + k] - b[i]", "+b = [0]", "+...
false
0.039716
0.039056
1.016884
[ "s836507865", "s500009100" ]
u077291787
p03472
python
s647339557
s198491194
396
230
34,580
25,176
Accepted
Accepted
41.92
# ABC085D - Katana Thrower import sys input = sys.stdin.readline def main(): N, H = tuple(map(int, input().split())) AB = tuple(tuple(map(int, input().split())) for _ in range(N)) A, B = list(zip(*AB)) C = sorted([(i, 0) for i in A] + [(i, 1) for i in B], reverse=1) ans = 0 for i, t i...
# ABC085D - Katana Thrower import sys input = sys.stdin.readline def main(): N, H = tuple(map(int, input().split())) AB = tuple(tuple(map(int, input().split())) for _ in range(N)) A, B = list(zip(*AB)) x = max(A) B = sorted([i for i in B if i > x], reverse=1) ans = 0 for i in B: ...
24
23
558
490
# ABC085D - Katana Thrower import sys input = sys.stdin.readline def main(): N, H = tuple(map(int, input().split())) AB = tuple(tuple(map(int, input().split())) for _ in range(N)) A, B = list(zip(*AB)) C = sorted([(i, 0) for i in A] + [(i, 1) for i in B], reverse=1) ans = 0 for i, t in C: ...
# ABC085D - Katana Thrower import sys input = sys.stdin.readline def main(): N, H = tuple(map(int, input().split())) AB = tuple(tuple(map(int, input().split())) for _ in range(N)) A, B = list(zip(*AB)) x = max(A) B = sorted([i for i in B if i > x], reverse=1) ans = 0 for i in B: a...
false
4.166667
[ "- C = sorted([(i, 0) for i in A] + [(i, 1) for i in B], reverse=1)", "+ x = max(A)", "+ B = sorted([i for i in B if i > x], reverse=1)", "- for i, t in C:", "- if t == 0:", "- ans += (H + i - 1) // i", "+ for i in B:", "+ ans += 1", "+ H -= i", "+ ...
false
0.041029
0.040732
1.007307
[ "s647339557", "s198491194" ]
u434872492
p03089
python
s650089832
s582156361
178
30
39,024
9,084
Accepted
Accepted
83.15
N=int(eval(input())) b=list(map(int,input().split())) tmp=-1 idx=0 count=1 flag=True ans=[] while(len(b)): #print(idx) if idx<len(b): if b[idx]==count: tmp=idx idx+=1 count+=1 else: idx+=1 count+=1 if idx>(len(b)-...
N = int(eval(input())) b = list(map(int,input().split())) ans = [] for i in range(N): for j in range(len(b)-1,-1,-1): if b[j]==(j+1): ans += [b[j]] del b[j] break if len(b)!=0: print((-1)) exit() for i in range(N): print((ans[N-1-i]))
35
16
647
301
N = int(eval(input())) b = list(map(int, input().split())) tmp = -1 idx = 0 count = 1 flag = True ans = [] while len(b): # print(idx) if idx < len(b): if b[idx] == count: tmp = idx idx += 1 count += 1 else: idx += 1 count += 1 if id...
N = int(eval(input())) b = list(map(int, input().split())) ans = [] for i in range(N): for j in range(len(b) - 1, -1, -1): if b[j] == (j + 1): ans += [b[j]] del b[j] break if len(b) != 0: print((-1)) exit() for i in range(N): print((ans[N - 1 - i]))
false
54.285714
[ "-tmp = -1", "-idx = 0", "-count = 1", "-flag = True", "-while len(b):", "- # print(idx)", "- if idx < len(b):", "- if b[idx] == count:", "- tmp = idx", "- idx += 1", "- count += 1", "- else:", "- idx += 1", "- coun...
false
0.086781
0.035505
2.444207
[ "s650089832", "s582156361" ]
u537234062
p03576
python
s203976681
s951973887
1,569
1,248
66,684
55,388
Accepted
Accepted
20.46
import sys if __name__ == '__main__': N, K = list(map(int, input().split())) xy_list = [list(map(int, input().split())) for i in range(N)] all_x = sorted(list(set([xy[0] for xy in xy_list]))) all_y = sorted(list(set([xy[1] for xy in xy_list]))) answer = sys.maxsize for i in range(le...
import sys if __name__ == '__main__': N, K = list(map(int, input().split())) xy_list = [list(map(int, input().split())) for i in range(N)] all_x = sorted(list(set([xy[0] for xy in xy_list]))) all_y = sorted(list(set([xy[1] for xy in xy_list]))) answer = sys.maxsize for i in range(le...
22
22
782
783
import sys if __name__ == "__main__": N, K = list(map(int, input().split())) xy_list = [list(map(int, input().split())) for i in range(N)] all_x = sorted(list(set([xy[0] for xy in xy_list]))) all_y = sorted(list(set([xy[1] for xy in xy_list]))) answer = sys.maxsize for i in range(len(all_x)): ...
import sys if __name__ == "__main__": N, K = list(map(int, input().split())) xy_list = [list(map(int, input().split())) for i in range(N)] all_x = sorted(list(set([xy[0] for xy in xy_list]))) all_y = sorted(list(set([xy[1] for xy in xy_list]))) answer = sys.maxsize for i in range(len(all_x)): ...
false
0
[ "- if answer > (x2 - x1) * (y2 - y1) and K <= sum(", "- [(x1 <= xy[0] <= x2) and (y1 <= xy[1] <= y2) for xy in xy_list]", "- ):", "+ if K <= len(", "+ [", "+ xy", "+ ...
false
0.121961
0.041903
2.910588
[ "s203976681", "s951973887" ]
u350248178
p02889
python
s871239811
s385034397
1,046
836
29,060
29,012
Accepted
Accepted
20.08
import numpy as np from scipy.sparse.csgraph import floyd_warshall n,m,l=list(map(int,input().split())) ans=[[0]*n for i in range(n)] for i in range(m): a,b,c=[int(j) for j in input().split()] ans[a-1][b-1]=c ans[b-1][a-1]=c q=int(eval(input())) st=[] for i in range(q): st.append([int(j)-1 ...
import sys input = sys.stdin.readline import numpy as np from scipy.sparse.csgraph import floyd_warshall n,m,l=list(map(int,input().split())) ans=[[0]*n for i in range(n)] for i in range(m): a,b,c=[int(j) for j in input().split()] ans[a-1][b-1]=c ans[b-1][a-1]=c q=int(eval(input())) st=[] for ...
31
33
642
682
import numpy as np from scipy.sparse.csgraph import floyd_warshall n, m, l = list(map(int, input().split())) ans = [[0] * n for i in range(n)] for i in range(m): a, b, c = [int(j) for j in input().split()] ans[a - 1][b - 1] = c ans[b - 1][a - 1] = c q = int(eval(input())) st = [] for i in range(q): st....
import sys input = sys.stdin.readline import numpy as np from scipy.sparse.csgraph import floyd_warshall n, m, l = list(map(int, input().split())) ans = [[0] * n for i in range(n)] for i in range(m): a, b, c = [int(j) for j in input().split()] ans[a - 1][b - 1] = c ans[b - 1][a - 1] = c q = int(eval(input...
false
6.060606
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.370929
0.366608
1.011786
[ "s871239811", "s385034397" ]
u399721252
p03166
python
s636489662
s780605406
732
413
72,204
66,736
Accepted
Accepted
43.58
n, m = [ int(v) for v in input().split() ] edge = [] in_list = [0] * n out_list = [0] * n dp_list = [0] * n connect_list = [ [] for i in range(n) ] for i in range(m): s, t = [ int(v)-1 for v in input().split() ] edge.append((s,t)) in_list[t] += 1 out_list[s] += 1 connect_list[t].append...
import bisect, collections, copy, heapq, itertools, math, sys input = sys.stdin.readline n, m = [ int(v) for v in input().split() ] edge = [] in_list = [0] * n out_list = [0] * n dp_list = [0] * n connect_list = [ [] for i in range(n) ] for i in range(m): s, t = [ int(v)-1 for v in input().split() ] ...
27
29
752
842
n, m = [int(v) for v in input().split()] edge = [] in_list = [0] * n out_list = [0] * n dp_list = [0] * n connect_list = [[] for i in range(n)] for i in range(m): s, t = [int(v) - 1 for v in input().split()] edge.append((s, t)) in_list[t] += 1 out_list[s] += 1 connect_list[t].append(s) search_list =...
import bisect, collections, copy, heapq, itertools, math, sys input = sys.stdin.readline n, m = [int(v) for v in input().split()] edge = [] in_list = [0] * n out_list = [0] * n dp_list = [0] * n connect_list = [[] for i in range(n)] for i in range(m): s, t = [int(v) - 1 for v in input().split()] edge.append((s...
false
6.896552
[ "+import bisect, collections, copy, heapq, itertools, math, sys", "+", "+input = sys.stdin.readline" ]
false
0.035484
0.124611
0.284762
[ "s636489662", "s780605406" ]
u230621983
p03835
python
s158025654
s584835032
1,485
1,168
2,940
9,056
Accepted
Accepted
21.35
k, s = list(map(int, input().split())) cnt = 0 for x in range(k+1): for y in range(k+1): z = s-x-y if 0<=z<=k: cnt += 1 print(cnt)
k, s = list(map(int, input().split())) cnt = 0 for x in range(k+1): for y in range(k+1): z = s - x - y if k >= z >= 0: cnt += 1 print(cnt)
8
8
163
171
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if 0 <= z <= k: cnt += 1 print(cnt)
k, s = list(map(int, input().split())) cnt = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if k >= z >= 0: cnt += 1 print(cnt)
false
0
[ "- if 0 <= z <= k:", "+ if k >= z >= 0:" ]
false
0.060818
0.036654
1.659239
[ "s158025654", "s584835032" ]
u367130284
p03660
python
s322212846
s735192952
914
653
54,424
35,472
Accepted
Accepted
28.56
#高速化heapqダイクストラ from collections import * from heapq import* import sys input=lambda:sys.stdin.readline() def DIJKSTRA(point,d): cost = [float("inf")]*(n+1) Q = [] cost[point]=0 heappush(Q,(point,cost[point])) while Q: prefnd,tmpC=heappop(Q) if cost[prefn...
#高速化heapqダイクストラ from collections import * from heapq import* import sys input=lambda:sys.stdin.readline() def BFS(point,d): cost=[1e7]*(n+1) cost[point]=0 Q=[] heappush(Q,(0,point)) while Q: c,p=heappop(Q) for np in d[p]: if cost[np]==1e7: ...
51
52
1,002
833
# 高速化heapqダイクストラ from collections import * from heapq import * import sys input = lambda: sys.stdin.readline() def DIJKSTRA(point, d): cost = [float("inf")] * (n + 1) Q = [] cost[point] = 0 heappush(Q, (point, cost[point])) while Q: prefnd, tmpC = heappop(Q) if cost[prefnd] < tmpC...
# 高速化heapqダイクストラ from collections import * from heapq import * import sys input = lambda: sys.stdin.readline() def BFS(point, d): cost = [1e7] * (n + 1) cost[point] = 0 Q = [] heappush(Q, (0, point)) while Q: c, p = heappop(Q) for np in d[p]: if cost[np] == 1e7: ...
false
1.923077
[ "-def DIJKSTRA(point, d):", "- cost = [float(\"inf\")] * (n + 1)", "+def BFS(point, d):", "+ cost = [1e7] * (n + 1)", "+ cost[point] = 0", "- cost[point] = 0", "- heappush(Q, (point, cost[point]))", "+ heappush(Q, (0, point))", "- prefnd, tmpC = heappop(Q)", "- if c...
false
0.039174
0.040123
0.976342
[ "s322212846", "s735192952" ]
u360574092
p02924
python
s385758481
s503749812
1,466
63
62,128
61,788
Accepted
Accepted
95.7
N = int(eval(input())) print((sum(range(N))))
N = int(eval(input())) print(((N*(N-1))//2))
2
2
38
37
N = int(eval(input())) print((sum(range(N))))
N = int(eval(input())) print(((N * (N - 1)) // 2))
false
0
[ "-print((sum(range(N))))", "+print(((N * (N - 1)) // 2))" ]
false
0.09081
0.036747
2.471249
[ "s385758481", "s503749812" ]
u392029857
p03239
python
s488087979
s381657579
19
17
3,060
2,940
Accepted
Accepted
10.53
n, t = list(map(int,input().split())) ts = [] for i in range(n): c = list(map(int,input().split())) if c[1] <= t: ts.append(c[0]) if ts == []: print('TLE') else: print((min(ts)))
n, t = list(map(int, input().split())) stack = [] for i in range(n): c, ts = list(map(int, input().split())) if ts <= t: stack.append(c) print((min(stack) if stack != [] else 'TLE'))
10
7
203
191
n, t = list(map(int, input().split())) ts = [] for i in range(n): c = list(map(int, input().split())) if c[1] <= t: ts.append(c[0]) if ts == []: print("TLE") else: print((min(ts)))
n, t = list(map(int, input().split())) stack = [] for i in range(n): c, ts = list(map(int, input().split())) if ts <= t: stack.append(c) print((min(stack) if stack != [] else "TLE"))
false
30
[ "-ts = []", "+stack = []", "- c = list(map(int, input().split()))", "- if c[1] <= t:", "- ts.append(c[0])", "-if ts == []:", "- print(\"TLE\")", "-else:", "- print((min(ts)))", "+ c, ts = list(map(int, input().split()))", "+ if ts <= t:", "+ stack.append(c)", ...
false
0.04502
0.045276
0.994346
[ "s488087979", "s381657579" ]
u022745965
p03494
python
s529753732
s874263484
31
26
9,172
9,184
Accepted
Accepted
16.13
n = int(eval(input())) a = list(map(int, input().split())) # count = 0 # list a[i]が偶数かどうかをチェック。ループはとりあえず省略する exist_odd = False # in_if = 0 in_for = 0 # in_while = 0 while exist_odd == False: for i in range(n): if a[i] % 2 != 0: exist_odd = True if n != i: ...
n = int(eval(input())) a = list(map(int, input().split())) count = 0 # list a[i]が偶数かどうかをチェック。ループはとりあえず省略する exist_odd = False while exist_odd == False: for i in range(n): if a[i] % 2 != 0: exist_odd = True if n != i: count -= 1 break e...
22
18
469
397
n = int(eval(input())) a = list(map(int, input().split())) # count = 0 # list a[i]が偶数かどうかをチェック。ループはとりあえず省略する exist_odd = False # in_if = 0 in_for = 0 # in_while = 0 while exist_odd == False: for i in range(n): if a[i] % 2 != 0: exist_odd = True if n != i: in_for -= 1 ...
n = int(eval(input())) a = list(map(int, input().split())) count = 0 # list a[i]が偶数かどうかをチェック。ループはとりあえず省略する exist_odd = False while exist_odd == False: for i in range(n): if a[i] % 2 != 0: exist_odd = True if n != i: count -= 1 break else: ...
false
18.181818
[ "-# count = 0", "+count = 0", "-# in_if = 0", "-in_for = 0", "-# in_while = 0", "- in_for -= 1", "+ count -= 1", "- # in_if += 1", "- # print(in_if)", "- in_for += 1", "-print(in_for)", "+ count += 1", "+ # print(count)", "+print(count)"...
false
0.035163
0.037822
0.929683
[ "s529753732", "s874263484" ]
u498487134
p02767
python
s190988613
s071389909
180
69
39,152
65,100
Accepted
Accepted
61.67
N=int(eval(input())) X=list(map(int, input().split())) ans=10**10 for i in range(100): p=i+1 temp=0 for j in range(N): temp+=(X[j]-p)**2 ans=min(ans,temp) print(ans)
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() X=LI() ans=10**10 for i in range(1,101): temp=0 for j i...
14
24
212
427
N = int(eval(input())) X = list(map(int, input().split())) ans = 10**10 for i in range(100): p = i + 1 temp = 0 for j in range(N): temp += (X[j] - p) ** 2 ans = min(ans, temp) print(ans)
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 N = I() X = LI() ans = 10**10 for i in range(1, 101): temp = 0 f...
false
41.666667
[ "-N = int(eval(input()))", "-X = list(map(int, input().split()))", "-ans = 10**10", "-for i in range(100):", "- p = i + 1", "- temp = 0", "- for j in range(N):", "- temp += (X[j] - p) ** 2", "- ans = min(ans, temp)", "-print(ans)", "+import sys", "+", "+input = sys.stdin.r...
false
0.034348
0.036139
0.950442
[ "s190988613", "s071389909" ]
u934442292
p03807
python
s587582481
s635468299
52
43
14,052
14,048
Accepted
Accepted
17.31
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, input().split())) n_odd = 0 for a in A: n_odd += 1 if a % 2 == 1 else 0 if n_odd % 2 == 0: ans = "YES" else: ans = "NO" print(ans) if __name__ == "__m...
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, input().split())) if sum(A) % 2 == 0: ans = "YES" else: ans = "NO" print(ans) if __name__ == "__main__": main()
22
18
334
260
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, input().split())) n_odd = 0 for a in A: n_odd += 1 if a % 2 == 1 else 0 if n_odd % 2 == 0: ans = "YES" else: ans = "NO" print(ans) if __name__ == "__main__": main()
import sys input = sys.stdin.readline def main(): N = int(eval(input())) A = list(map(int, input().split())) if sum(A) % 2 == 0: ans = "YES" else: ans = "NO" print(ans) if __name__ == "__main__": main()
false
18.181818
[ "- n_odd = 0", "- for a in A:", "- n_odd += 1 if a % 2 == 1 else 0", "- if n_odd % 2 == 0:", "+ if sum(A) % 2 == 0:" ]
false
0.148427
0.037257
3.983906
[ "s587582481", "s635468299" ]
u228232845
p03151
python
s284594922
s080039044
294
265
39,776
39,648
Accepted
Accepted
9.86
# 13 import sys import numpy as np def input(): return sys.stdin.readline().strip() def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def S(): re...
# 13 import sys import numpy as np def input(): return sys.stdin.readline().strip() def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def S(): re...
42
42
858
864
# 13 import sys import numpy as np def input(): return sys.stdin.readline().strip() def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i i...
# 13 import sys import numpy as np def input(): return sys.stdin.readline().strip() def I(): return int(eval(input())) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i i...
false
0
[ "-if len(neg) == 0:", "- print((0))", "- exit()", "+# if len(neg) == 0:", "+# print(0)", "+# exit()" ]
false
0.326463
0.233015
1.401038
[ "s284594922", "s080039044" ]
u358254559
p02845
python
s463218132
s447407635
261
232
62,252
62,124
Accepted
Accepted
11.11
n = int(eval(input())) a = list(map(int, input().split())) from collections import defaultdict d = defaultdict(int) ans=1 for num in a: if num==0: last_cnt=3 else: last_cnt=d[num-1] tmp = last_cnt - d[num] if tmp < 0: tmp=1 ans*=tmp ans%=1000000007 ...
n = int(eval(input())) a = list(map(int, input().split())) from collections import defaultdict d = defaultdict(int) ans=1 for num in a: if num==0: last_cnt=3 tmp = last_cnt - d[num] else: last_cnt=d[num-1] tmp = last_cnt - d[num] if tmp == 0: # ...
20
22
337
403
n = int(eval(input())) a = list(map(int, input().split())) from collections import defaultdict d = defaultdict(int) ans = 1 for num in a: if num == 0: last_cnt = 3 else: last_cnt = d[num - 1] tmp = last_cnt - d[num] if tmp < 0: tmp = 1 ans *= tmp ans %= 1000000007 d[...
n = int(eval(input())) a = list(map(int, input().split())) from collections import defaultdict d = defaultdict(int) ans = 1 for num in a: if num == 0: last_cnt = 3 tmp = last_cnt - d[num] else: last_cnt = d[num - 1] tmp = last_cnt - d[num] if tmp == 0: # ...
false
9.090909
[ "+ tmp = last_cnt - d[num]", "- tmp = last_cnt - d[num]", "- if tmp < 0:", "- tmp = 1", "+ tmp = last_cnt - d[num]", "+ if tmp == 0:", "+ # tmp=1", "+ ans = 0" ]
false
0.090207
0.039075
2.308544
[ "s463218132", "s447407635" ]
u102461423
p03164
python
s649695696
s027749132
314
214
21,272
14,920
Accepted
Accepted
31.85
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) import numpy as np N,W = list(map(int,input().split())) # v に対する min(w) を持つ max_v = 0 INF = 10 ** 18 dp = np.full(1000 * N + 1, INF, dtype=np.int64) dp[0] = 0 for _ in range(N): w,v = list(map(int,input().split())) np.minimum...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N,W = list(map(int,readline().split())) m = list(map(int,read().split())) WV = list(zip(m,m)) # 価値 -> 最小重さ INF = 10**18 dp = np.full(10**5+10,INF,np.int64) dp[0] = 0 ...
20
21
444
421
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import numpy as np N, W = list(map(int, input().split())) # v に対する min(w) を持つ max_v = 0 INF = 10**18 dp = np.full(1000 * N + 1, INF, dtype=np.int64) dp[0] = 0 for _ in range(N): w, v = list(map(int, input().split())) np.minimum(dp[v : max_v + ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, W = list(map(int, readline().split())) m = list(map(int, read().split())) WV = list(zip(m, m)) # 価値 -> 最小重さ INF = 10**18 dp = np.full(10**5 + 10, INF, np.int64) dp[0] = 0 for w, v ...
false
4.761905
[ "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines", "-N, W = list(map(int, input().split()))", "-# v に対する min(w) を持つ", "-max_v = 0", "+N, W = list(map(int, readline().spli...
false
0.58345
0.282418
2.065908
[ "s649695696", "s027749132" ]
u673361376
p02912
python
s624168162
s244460587
313
178
64,112
14,536
Accepted
Accepted
43.13
import heapq N,M = list(map(int,input().split())) A = [] for a in map(int,input().split()): heapq.heappush(A,-a) cnt = 0 while cnt < M: a = heapq.heappop(A) heapq.heappush(A,-((-a)//2)) cnt += 1 print((-sum(A)))
import heapq import math N, M = list(map(int, input().split())) A = [] for a in map(int, input().split()): heapq.heappush(A, -a) for _ in range(M): neg_a = heapq.heappop(A) heapq.heappush(A, -math.floor(-neg_a/2)) print((-sum(A)))
13
13
225
249
import heapq N, M = list(map(int, input().split())) A = [] for a in map(int, input().split()): heapq.heappush(A, -a) cnt = 0 while cnt < M: a = heapq.heappop(A) heapq.heappush(A, -((-a) // 2)) cnt += 1 print((-sum(A)))
import heapq import math N, M = list(map(int, input().split())) A = [] for a in map(int, input().split()): heapq.heappush(A, -a) for _ in range(M): neg_a = heapq.heappop(A) heapq.heappush(A, -math.floor(-neg_a / 2)) print((-sum(A)))
false
0
[ "+import math", "-cnt = 0", "-while cnt < M:", "- a = heapq.heappop(A)", "- heapq.heappush(A, -((-a) // 2))", "- cnt += 1", "+for _ in range(M):", "+ neg_a = heapq.heappop(A)", "+ heapq.heappush(A, -math.floor(-neg_a / 2))" ]
false
0.041101
0.064602
0.636211
[ "s624168162", "s244460587" ]
u527993431
p02712
python
s590852130
s005410418
284
149
9,176
9,088
Accepted
Accepted
47.54
count=0 N=int(eval(input())) for i in range(N): if (i+1)%3==0 and (i+1)%5==0: continue elif (i+1)%3==0: continue elif (i+1)%5==0: continue else: count+=(i+1) print(count)
N=int(eval(input())) ans=0 for i in range(1,N+1): if i%3==0 or i%5==0:continue else: ans+=i print(ans)
12
7
187
106
count = 0 N = int(eval(input())) for i in range(N): if (i + 1) % 3 == 0 and (i + 1) % 5 == 0: continue elif (i + 1) % 3 == 0: continue elif (i + 1) % 5 == 0: continue else: count += i + 1 print(count)
N = int(eval(input())) ans = 0 for i in range(1, N + 1): if i % 3 == 0 or i % 5 == 0: continue else: ans += i print(ans)
false
41.666667
[ "-count = 0", "-for i in range(N):", "- if (i + 1) % 3 == 0 and (i + 1) % 5 == 0:", "- continue", "- elif (i + 1) % 3 == 0:", "- continue", "- elif (i + 1) % 5 == 0:", "+ans = 0", "+for i in range(1, N + 1):", "+ if i % 3 == 0 or i % 5 == 0:", "- count += i + 1",...
false
0.174217
0.191798
0.90834
[ "s590852130", "s005410418" ]
u856775981
p02947
python
s388985626
s179416107
370
319
38,540
38,540
Accepted
Accepted
13.78
N = int(eval(input())) s = [eval(input()) for i in range(N)] s_sorted = list(map(''.join, list(map(sorted, s)))) s_dict = dict() for k in s_sorted: if k in s_dict: s_dict[k] += 1 else: s_dict[k] = 1 #cnt = 0 # for k in s_dict: # cnt += sum(range(s_dict[k])) cnt = sum([sum(ra...
N = int(eval(input())) s = [eval(input()) for i in range(N)] s_sorted = list(map(''.join, list(map(sorted, s)))) s_dict = dict() cnt = 0 for k in s_sorted: if k in s_dict: cnt += s_dict[k] s_dict[k] += 1 else: s_dict[k] = 1 #cnt = 0 # for k in s_dict: # cnt += sum(r...
18
20
356
391
N = int(eval(input())) s = [eval(input()) for i in range(N)] s_sorted = list(map("".join, list(map(sorted, s)))) s_dict = dict() for k in s_sorted: if k in s_dict: s_dict[k] += 1 else: s_dict[k] = 1 # cnt = 0 # for k in s_dict: # cnt += sum(range(s_dict[k])) cnt = sum([sum(range(s_dict[k])) f...
N = int(eval(input())) s = [eval(input()) for i in range(N)] s_sorted = list(map("".join, list(map(sorted, s)))) s_dict = dict() cnt = 0 for k in s_sorted: if k in s_dict: cnt += s_dict[k] s_dict[k] += 1 else: s_dict[k] = 1 # cnt = 0 # for k in s_dict: # cnt += sum(range(s_dict[k])) #...
false
10
[ "+cnt = 0", "+ cnt += s_dict[k]", "-cnt = sum([sum(range(s_dict[k])) for k in s_dict])", "+# cnt = sum([sum(range(s_dict[k])) for k in s_dict])" ]
false
0.040535
0.105332
0.384831
[ "s388985626", "s179416107" ]
u298297089
p03338
python
s388180753
s127454718
23
17
3,444
3,060
Accepted
Accepted
26.09
from collections import Counter n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1,n-1): a = Counter(s[:i]) b = Counter(s[i:]) cnt = 0 for k in list(a.keys()): if k in b: cnt += 1 if cnt > ans: ans = cnt print(ans)
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1,n-1): a = set(s[:i]) b = set(s[i:]) if ans < len(a & b): ans = len(a & b) print(ans)
15
9
274
156
from collections import Counter n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1, n - 1): a = Counter(s[:i]) b = Counter(s[i:]) cnt = 0 for k in list(a.keys()): if k in b: cnt += 1 if cnt > ans: ans = cnt print(ans)
n = int(eval(input())) s = eval(input()) ans = 0 for i in range(1, n - 1): a = set(s[:i]) b = set(s[i:]) if ans < len(a & b): ans = len(a & b) print(ans)
false
40
[ "-from collections import Counter", "-", "- a = Counter(s[:i])", "- b = Counter(s[i:])", "- cnt = 0", "- for k in list(a.keys()):", "- if k in b:", "- cnt += 1", "- if cnt > ans:", "- ans = cnt", "+ a = set(s[:i])", "+ b = set(s[i:])", "+ if a...
false
0.035352
0.037154
0.951495
[ "s388180753", "s127454718" ]
u298520807
p02762
python
s723798471
s204911433
1,097
985
13,340
13,436
Accepted
Accepted
10.21
class UnionFindTree: __slots__ = ('__parents', ) def __init__(self, n): self.__parents = [-1] * n def find(self, x): p = self.__parents if p[x] < 0: return x parent = self.find(p[x]) p[x] = parent return parent def union(self, ...
class UnionFindTree: __slots__ = ('__parents', ) def __init__(self, n): self.__parents = [-1] * n def find(self, x): p = self.__parents if p[x] < 0: return x parent = self.find(p[x]) p[x] = parent return parent def union(self, ...
61
64
1,408
1,422
class UnionFindTree: __slots__ = ("__parents",) def __init__(self, n): self.__parents = [-1] * n def find(self, x): p = self.__parents if p[x] < 0: return x parent = self.find(p[x]) p[x] = parent return parent def union(self, x, y): ...
class UnionFindTree: __slots__ = ("__parents",) def __init__(self, n): self.__parents = [-1] * n def find(self, x): p = self.__parents if p[x] < 0: return x parent = self.find(p[x]) p[x] = parent return parent def union(self, x, y): ...
false
4.6875
[ "- kw = {\"func_\": lambda x: int(x) - 1}", "- a, b = spline(**kw)", "+ a, b = spline()", "+ a -= 1", "+ b -= 1", "- c, d = spline(**kw)", "+ c, d = spline()", "+ c -= 1", "+ d -= 1" ]
false
0.045817
0.007703
5.947916
[ "s723798471", "s204911433" ]
u906501980
p03363
python
s302186618
s203042500
363
316
52,624
52,496
Accepted
Accepted
12.95
from collections import Counter n = int(eval(input())) A = [int(i) for i in input().split()] S = [0]*(n+1) for i in range(n): S[i+1] = S[i] + A[i] def hello(data): dt = Counter() for i in data: dt[str(i)] += 1 return dt num = hello(S) out = [i*(i-1)//2 for i in list(num.values()) if ...
n = int(eval(input())) A = [int(i) for i in input().split()] S = [0]*(n+1) num={} for i in range(n): S[i+1] = S[i] + A[i] for i in S: if str(i) in list(num.keys()): num[str(i)] += 1 else: num[str(i)] = 1 out = [i*(i-1)//2 for i in list(num.values()) if i>1] print((sum(out)))
14
13
329
295
from collections import Counter n = int(eval(input())) A = [int(i) for i in input().split()] S = [0] * (n + 1) for i in range(n): S[i + 1] = S[i] + A[i] def hello(data): dt = Counter() for i in data: dt[str(i)] += 1 return dt num = hello(S) out = [i * (i - 1) // 2 for i in list(num.values()...
n = int(eval(input())) A = [int(i) for i in input().split()] S = [0] * (n + 1) num = {} for i in range(n): S[i + 1] = S[i] + A[i] for i in S: if str(i) in list(num.keys()): num[str(i)] += 1 else: num[str(i)] = 1 out = [i * (i - 1) // 2 for i in list(num.values()) if i > 1] print((sum(out)))
false
7.142857
[ "-from collections import Counter", "-", "+num = {}", "-", "-", "-def hello(data):", "- dt = Counter()", "- for i in data:", "- dt[str(i)] += 1", "- return dt", "-", "-", "-num = hello(S)", "+for i in S:", "+ if str(i) in list(num.keys()):", "+ num[str(i)] += ...
false
0.03884
0.04497
0.863698
[ "s302186618", "s203042500" ]
u562935282
p03030
python
s265857899
s292702616
164
21
38,384
3,316
Accepted
Accepted
87.2
N = int(eval(input())) a = [] for i in range(1, N + 1): s, p = input().split() a.append((s, int(p), i)) a.sort(key=lambda x: (x[0], -x[1])) # 市昇順, 点数降順 for _, _, i in a: print(i)
def main(): from collections import defaultdict book = defaultdict(list) N = int(eval(input())) for ind in range(1, N + 1): s, p = input().split() book[s].append((int(p), ind)) for s in sorted(book.keys()): book[s].sort(key=lambda x: x[0], reverse=True) f...
11
17
197
404
N = int(eval(input())) a = [] for i in range(1, N + 1): s, p = input().split() a.append((s, int(p), i)) a.sort(key=lambda x: (x[0], -x[1])) # 市昇順, 点数降順 for _, _, i in a: print(i)
def main(): from collections import defaultdict book = defaultdict(list) N = int(eval(input())) for ind in range(1, N + 1): s, p = input().split() book[s].append((int(p), ind)) for s in sorted(book.keys()): book[s].sort(key=lambda x: x[0], reverse=True) for _, ind in...
false
35.294118
[ "-N = int(eval(input()))", "-a = []", "-for i in range(1, N + 1):", "- s, p = input().split()", "- a.append((s, int(p), i))", "-a.sort(key=lambda x: (x[0], -x[1]))", "-# 市昇順, 点数降順", "-for _, _, i in a:", "- print(i)", "+def main():", "+ from collections import defaultdict", "+", ...
false
0.082882
0.040669
2.037974
[ "s265857899", "s292702616" ]
u690536347
p03633
python
s967086236
s167710118
57
42
5,160
5,160
Accepted
Accepted
26.32
from fractions import gcd from functools import reduce l = [int(input()) for _ in range(int(input()))] o = reduce(lambda x, y: int(x * y / gcd(x, y)), l) print(o)
from fractions import gcd from functools import reduce l = [int(eval(input())) for _ in range(int(eval(input())))] o = reduce(lambda x, y: int(x * y / gcd(x, y)), l) print(o)
4
5
143
166
from fractions import gcd from functools import reduce l = [int(input()) for _ in range(int(input()))] o = reduce(lambda x, y: int(x * y / gcd(x, y)), l) print(o)
from fractions import gcd from functools import reduce l = [int(eval(input())) for _ in range(int(eval(input())))] o = reduce(lambda x, y: int(x * y / gcd(x, y)), l) print(o)
false
20
[ "-l = [int(input()) for _ in range(int(input()))]", "+l = [int(eval(input())) for _ in range(int(eval(input())))]" ]
false
0.056107
0.049139
1.141802
[ "s967086236", "s167710118" ]
u677121387
p02683
python
s691567853
s781565386
95
82
9,236
9,216
Accepted
Accepted
13.68
n,m,x = list(map(int,input().split())) c = [[int(i) for i in input().split()] for _ in range(n)] ans = float("inf") for i in range(1<<n): cnt = [0]*m cost = 0 for j in range(n): if i >> j & 1: cost += c[j][0] for k in range(1,m+1): cnt[k-1] += c[j][k...
n,m,x = list(map(int,input().split())) c = [[int(i) for i in input().split()] for _ in range(n)] inf = float("inf") ans = inf for i in range(1<<n): cnt = [0]*m cost = 0 for j in range(n): if i >> j & 1: cost += c[j][0] for k in range(1,m+1): cnt[k-1...
17
17
467
455
n, m, x = list(map(int, input().split())) c = [[int(i) for i in input().split()] for _ in range(n)] ans = float("inf") for i in range(1 << n): cnt = [0] * m cost = 0 for j in range(n): if i >> j & 1: cost += c[j][0] for k in range(1, m + 1): cnt[k - 1] += c[j]...
n, m, x = list(map(int, input().split())) c = [[int(i) for i in input().split()] for _ in range(n)] inf = float("inf") ans = inf for i in range(1 << n): cnt = [0] * m cost = 0 for j in range(n): if i >> j & 1: cost += c[j][0] for k in range(1, m + 1): cnt[k - ...
false
0
[ "-ans = float(\"inf\")", "+inf = float(\"inf\")", "+ans = inf", "-print((ans if ans != float(\"inf\") else -1))", "+print((ans if ans != inf else -1))" ]
false
0.070991
0.040806
1.73972
[ "s691567853", "s781565386" ]
u761320129
p03807
python
s466848728
s358295699
54
49
14,104
14,104
Accepted
Accepted
9.26
N = int(eval(input())) src = list(map(int,input().split())) odd = 0 for a in src: if a%2: odd += 1 print(('YES' if odd%2 == 0 else 'NO'))
N = int(eval(input())) src = list(map(int,input().split())) odd = len([a for a in src if a%2]) even = N - odd if odd%2: print('NO') else: even += odd//2 print(('NO' if even < 1 else 'YES'))
6
10
138
203
N = int(eval(input())) src = list(map(int, input().split())) odd = 0 for a in src: if a % 2: odd += 1 print(("YES" if odd % 2 == 0 else "NO"))
N = int(eval(input())) src = list(map(int, input().split())) odd = len([a for a in src if a % 2]) even = N - odd if odd % 2: print("NO") else: even += odd // 2 print(("NO" if even < 1 else "YES"))
false
40
[ "-odd = 0", "-for a in src:", "- if a % 2:", "- odd += 1", "-print((\"YES\" if odd % 2 == 0 else \"NO\"))", "+odd = len([a for a in src if a % 2])", "+even = N - odd", "+if odd % 2:", "+ print(\"NO\")", "+else:", "+ even += odd // 2", "+ print((\"NO\" if even < 1 else \"YES\...
false
0.04834
0.047983
1.00744
[ "s466848728", "s358295699" ]
u888721916
p02726
python
s443612399
s627931607
292
269
47,964
46,428
Accepted
Accepted
7.88
N, X, Y = list(map(int, input().split())) X -= 1 Y -= 1 distances = [0]*N for i in range(N): for j in range(i+1,N): d = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)) distances[d] += 1 for i in range(1,N): print((distances[i]))
N, X, Y = list(map(int, input().split())) X -= 1 Y -= 1 distances = [0]*N for i in range(N): for j in range(i+1,N): # d = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)) d = min(abs(j-i), abs(X-i)+1+abs(j-Y)) distances[d] += 1 for i in range(1,N): print((distances[i...
12
13
265
315
N, X, Y = list(map(int, input().split())) X -= 1 Y -= 1 distances = [0] * N for i in range(N): for j in range(i + 1, N): d = min(abs(j - i), abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X)) distances[d] += 1 for i in range(1, N): print((distances[i]))
N, X, Y = list(map(int, input().split())) X -= 1 Y -= 1 distances = [0] * N for i in range(N): for j in range(i + 1, N): # d = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)) d = min(abs(j - i), abs(X - i) + 1 + abs(j - Y)) distances[d] += 1 for i in range(1, N): print((distances...
false
7.692308
[ "- d = min(abs(j - i), abs(X - i) + 1 + abs(j - Y), abs(Y - i) + 1 + abs(j - X))", "+ # d = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))", "+ d = min(abs(j - i), abs(X - i) + 1 + abs(j - Y))" ]
false
0.042596
0.043696
0.97482
[ "s443612399", "s627931607" ]
u450956662
p03013
python
s748780077
s730094079
223
186
6,900
7,668
Accepted
Accepted
16.59
N, M = list(map(int, input().split())) mod = 10 ** 9 + 7 dp = [0] * (N+1) dp[0] = 1 idx = 0 for m in range(M): a = int(eval(input())) for i in range(idx+1, a): dp[i] = dp[i-1] + dp[i-2] dp[i] %= mod idx = a for i in range(idx+1, N+1): dp[i] = dp[i-1] + dp[i-2] dp[i] %=...
N, M = list(map(int, input().split())) mod = 10 ** 9 + 7 A = [True] * (N+1) for _ in range(M): a = int(eval(input())) A[a] = False dp = [0] * (N+1) dp[:2] = 1, 1 if A[1] else 0 for i in range(2, N+1): if A[i]: dp[i] = dp[i-1] + dp[i-2] dp[i] %= mod print((dp[N]))
17
13
329
289
N, M = list(map(int, input().split())) mod = 10**9 + 7 dp = [0] * (N + 1) dp[0] = 1 idx = 0 for m in range(M): a = int(eval(input())) for i in range(idx + 1, a): dp[i] = dp[i - 1] + dp[i - 2] dp[i] %= mod idx = a for i in range(idx + 1, N + 1): dp[i] = dp[i - 1] + dp[i - 2] dp[i] %= ...
N, M = list(map(int, input().split())) mod = 10**9 + 7 A = [True] * (N + 1) for _ in range(M): a = int(eval(input())) A[a] = False dp = [0] * (N + 1) dp[:2] = 1, 1 if A[1] else 0 for i in range(2, N + 1): if A[i]: dp[i] = dp[i - 1] + dp[i - 2] dp[i] %= mod print((dp[N]))
false
23.529412
[ "+A = [True] * (N + 1)", "+for _ in range(M):", "+ a = int(eval(input()))", "+ A[a] = False", "-dp[0] = 1", "-idx = 0", "-for m in range(M):", "- a = int(eval(input()))", "- for i in range(idx + 1, a):", "+dp[:2] = 1, 1 if A[1] else 0", "+for i in range(2, N + 1):", "+ if A[i]:"...
false
0.036899
0.037073
0.995308
[ "s748780077", "s730094079" ]
u852690916
p03324
python
s041924138
s671435943
182
167
38,384
38,384
Accepted
Accepted
8.24
D,N = list(map(int, input().split())) ans = N if N <= 99 else 101 for i in range(D): ans *= 100 print(ans)
D,N=list(map(int, input().split())) c=0 if D==0: if N!=100: print(N) else: print((101)) exit() d=100**D for i in range(d,d*200+1,d): if (i//d)%100 != 0: c+=1 if c==N: print(i) exit()
6
14
110
252
D, N = list(map(int, input().split())) ans = N if N <= 99 else 101 for i in range(D): ans *= 100 print(ans)
D, N = list(map(int, input().split())) c = 0 if D == 0: if N != 100: print(N) else: print((101)) exit() d = 100**D for i in range(d, d * 200 + 1, d): if (i // d) % 100 != 0: c += 1 if c == N: print(i) exit()
false
57.142857
[ "-ans = N if N <= 99 else 101", "-for i in range(D):", "- ans *= 100", "-print(ans)", "+c = 0", "+if D == 0:", "+ if N != 100:", "+ print(N)", "+ else:", "+ print((101))", "+ exit()", "+d = 100**D", "+for i in range(d, d * 200 + 1, d):", "+ if (i // d) % 100 !=...
false
0.035956
0.037017
0.971325
[ "s041924138", "s671435943" ]
u581022379
p03611
python
s022695828
s362038759
162
106
33,588
21,816
Accepted
Accepted
34.57
import copy import collections N = int(eval(input())) seq = [int(i) for i in input().split()] seqP1 = [i + 1 for i in copy.copy(seq)] seqM1 = [i - 1 for i in copy.copy(seq)] mixed = seq + seqM1 + seqP1 print((mixed.count(collections.Counter(mixed).most_common()[0][0])))
N = int(eval(input())) numbers = [0] * (10 ** 6) seq = list(map(int, input().split())) for i in seq: numbers[i - 1] += 1 numbers[i] += 1 numbers[i + 1] += 1 print((max(numbers)))
8
8
270
190
import copy import collections N = int(eval(input())) seq = [int(i) for i in input().split()] seqP1 = [i + 1 for i in copy.copy(seq)] seqM1 = [i - 1 for i in copy.copy(seq)] mixed = seq + seqM1 + seqP1 print((mixed.count(collections.Counter(mixed).most_common()[0][0])))
N = int(eval(input())) numbers = [0] * (10**6) seq = list(map(int, input().split())) for i in seq: numbers[i - 1] += 1 numbers[i] += 1 numbers[i + 1] += 1 print((max(numbers)))
false
0
[ "-import copy", "-import collections", "-", "-seq = [int(i) for i in input().split()]", "-seqP1 = [i + 1 for i in copy.copy(seq)]", "-seqM1 = [i - 1 for i in copy.copy(seq)]", "-mixed = seq + seqM1 + seqP1", "-print((mixed.count(collections.Counter(mixed).most_common()[0][0])))", "+numbers = [0] * (...
false
0.038379
0.175142
0.219128
[ "s022695828", "s362038759" ]
u275685840
p03456
python
s972629280
s112124732
30
26
9,408
9,196
Accepted
Accepted
13.33
a, b = list(map(int,input().split())) if str(int(str(a) + str(b))**0.5).split(".")[1:][0] == "0": print("Yes") else: print("No")
a, b = list(map(int,input().split())) if int(str(a) + str(b))**0.5 % 1 == 0: print("Yes") else: print("No")
5
5
134
113
a, b = list(map(int, input().split())) if str(int(str(a) + str(b)) ** 0.5).split(".")[1:][0] == "0": print("Yes") else: print("No")
a, b = list(map(int, input().split())) if int(str(a) + str(b)) ** 0.5 % 1 == 0: print("Yes") else: print("No")
false
0
[ "-if str(int(str(a) + str(b)) ** 0.5).split(\".\")[1:][0] == \"0\":", "+if int(str(a) + str(b)) ** 0.5 % 1 == 0:" ]
false
0.06229
0.086832
0.717359
[ "s972629280", "s112124732" ]
u936985471
p02549
python
s229097696
s564878041
1,032
102
24,396
77,024
Accepted
Accepted
90.12
import sys readline = sys.stdin.readline N,K = list(map(int,readline().split())) DIV = 998244353 L = [None] * K R = [None] * K for i in range(K): L[i],R[i] = list(map(int,readline().split())) dp = [0] * (N + 1) sdp = [0] * (N + 1) dp[1] = 1 sdp[1] = 1 for i in range(2, len(dp)): for j in rang...
import sys readline = sys.stdin.readline N,K = list(map(int,readline().split())) LR = [tuple(map(int,readline().split())) for i in range(K)] DIV = 998244353 dp = [0] * (N + 1) dp[1] = 1 sdp = [0] * (N + 1) sdp[1] = 1 for i in range(2, N + 1): for j in range(K): l_ind = i - LR[j][1] - 1 r_ind =...
28
25
513
518
import sys readline = sys.stdin.readline N, K = list(map(int, readline().split())) DIV = 998244353 L = [None] * K R = [None] * K for i in range(K): L[i], R[i] = list(map(int, readline().split())) dp = [0] * (N + 1) sdp = [0] * (N + 1) dp[1] = 1 sdp[1] = 1 for i in range(2, len(dp)): for j in range(K): ...
import sys readline = sys.stdin.readline N, K = list(map(int, readline().split())) LR = [tuple(map(int, readline().split())) for i in range(K)] DIV = 998244353 dp = [0] * (N + 1) dp[1] = 1 sdp = [0] * (N + 1) sdp[1] = 1 for i in range(2, N + 1): for j in range(K): l_ind = i - LR[j][1] - 1 r_ind = i...
false
10.714286
[ "+LR = [tuple(map(int, readline().split())) for i in range(K)]", "-L = [None] * K", "-R = [None] * K", "-for i in range(K):", "- L[i], R[i] = list(map(int, readline().split()))", "+dp[1] = 1", "-dp[1] = 1", "-for i in range(2, len(dp)):", "+for i in range(2, N + 1):", "- li = max(i - R[j...
false
0.106036
0.036595
2.897553
[ "s229097696", "s564878041" ]
u347640436
p02619
python
s585019609
s354860444
38
31
9,276
9,332
Accepted
Accepted
18.42
D = int(eval(input())) c = [None] + list(map(int, input().split())) s = [None] + [[None] + list(map(int, input().split())) for _ in range(D)] t = [None] + [int(eval(input())) for _ in range(D)] S = 0 last = [0] * 27 score = 0 for d in range(1, D + 1): S += s[d][t[d]] last[t[d]] = d for i in rang...
D = int(eval(input())) c = list(map(int, input().split())) s = [list(map(int, input().split())) for _ in range(D)] t = [int(eval(input())) - 1 for _ in range(D)] S = 0 last = [-1] * 26 score = 0 for d in range(D): S += s[d][t[d]] last[t[d]] = d for i in range(26): S -= c[i] * (d - last[...
15
15
401
360
D = int(eval(input())) c = [None] + list(map(int, input().split())) s = [None] + [[None] + list(map(int, input().split())) for _ in range(D)] t = [None] + [int(eval(input())) for _ in range(D)] S = 0 last = [0] * 27 score = 0 for d in range(1, D + 1): S += s[d][t[d]] last[t[d]] = d for i in range(1, 27): ...
D = int(eval(input())) c = list(map(int, input().split())) s = [list(map(int, input().split())) for _ in range(D)] t = [int(eval(input())) - 1 for _ in range(D)] S = 0 last = [-1] * 26 score = 0 for d in range(D): S += s[d][t[d]] last[t[d]] = d for i in range(26): S -= c[i] * (d - last[i]) score...
false
0
[ "-c = [None] + list(map(int, input().split()))", "-s = [None] + [[None] + list(map(int, input().split())) for _ in range(D)]", "-t = [None] + [int(eval(input())) for _ in range(D)]", "+c = list(map(int, input().split()))", "+s = [list(map(int, input().split())) for _ in range(D)]", "+t = [int(eval(input()...
false
0.072351
0.071074
1.017961
[ "s585019609", "s354860444" ]
u577170763
p03161
python
s120522968
s576710755
363
322
53,600
52,448
Accepted
Accepted
11.29
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict geta = lambda fn: list(map(fn, input().split())) gete = lambda fn: fn(eval(input())) def main(): N, K = geta(int) h = geta(int) INF = 10 << 60 dp = [INF]*N dp[0], dp[1] = 0, abs(h[0] - h[1]) for i ...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict geta = lambda fn: list(map(fn, input().split())) gete = lambda fn: fn(eval(input())) def main(): N, K = geta(int) h = geta(int) INF = 1 << 60 dp = [INF]*N dp[0], dp[1] = 0, abs(h[0] - h[1]) for ...
27
25
614
566
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict geta = lambda fn: list(map(fn, input().split())) gete = lambda fn: fn(eval(input())) def main(): N, K = geta(int) h = geta(int) INF = 10 << 60 dp = [INF] * N dp[0], dp[1] = 0, abs(h[0] - h[1]) for i in range(2, N...
# import sys # sys.setrecursionlimit(10**5) # from collections import defaultdict geta = lambda fn: list(map(fn, input().split())) gete = lambda fn: fn(eval(input())) def main(): N, K = geta(int) h = geta(int) INF = 1 << 60 dp = [INF] * N dp[0], dp[1] = 0, abs(h[0] - h[1]) for i in range(2, N)...
false
7.407407
[ "- INF = 10 << 60", "+ INF = 1 << 60", "- tmp, hi = INF, h[i]", "- for dpj, hj in zip(dp[lb:i], h[lb:i]):", "- upd = dpj + abs(hi - hj)", "- if tmp > upd:", "- tmp = upd", "- dp[i] = tmp", "+ for j in range(lb, i):", "+ ...
false
0.041077
0.036507
1.125198
[ "s120522968", "s576710755" ]
u525065967
p02609
python
s730664945
s524415841
1,132
800
29,312
25,160
Accepted
Accepted
29.33
from logging import * basicConfig(level=DEBUG, format='%(levelname)s: %(message)s') disable(CRITICAL) n = int(eval(input())) X = eval(input()) debug('n {}'.format(n)) debug('X {}'.format(X)) po = X.count('1') # if po == 0: # print(0) # exit() pp = po + 1 pm = max(1, po - 1) rp = 0 rm = 0 ...
def popcount(x): c = 0 while x > 0: if x & 1: c += 1 x //= 2 return c def f(x): if x==0: return 0 return f(x % popcount(x)) + 1 n = int(eval(input())) X = eval(input()) po = X.count('1') pp = po + 1 pm = max(1, po - 1) rp = rm = 0 for x in X: rp = (rp*2 + int(...
64
35
1,242
729
from logging import * basicConfig(level=DEBUG, format="%(levelname)s: %(message)s") disable(CRITICAL) n = int(eval(input())) X = eval(input()) debug("n {}".format(n)) debug("X {}".format(X)) po = X.count("1") # if po == 0: # print(0) # exit() pp = po + 1 pm = max(1, po - 1) rp = 0 rm = 0 for x in X: rp = (...
def popcount(x): c = 0 while x > 0: if x & 1: c += 1 x //= 2 return c def f(x): if x == 0: return 0 return f(x % popcount(x)) + 1 n = int(eval(input())) X = eval(input()) po = X.count("1") pp = po + 1 pm = max(1, po - 1) rp = rm = 0 for x in X: rp = (rp * ...
false
45.3125
[ "-from logging import *", "-", "-basicConfig(level=DEBUG, format=\"%(levelname)s: %(message)s\")", "-disable(CRITICAL)", "-n = int(eval(input()))", "-X = eval(input())", "-debug(\"n {}\".format(n))", "-debug(\"X {}\".format(X))", "-po = X.count(\"1\")", "-# if po == 0:", "-# print(0)", "-#...
false
0.122285
0.038219
3.199555
[ "s730664945", "s524415841" ]
u903005414
p03244
python
s236032013
s156357120
121
101
25,536
21,184
Accepted
Accepted
16.53
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) c1 = Counter(V[::2]) c2 = Counter(V[1::2]) # print('c1, c2', c1, c2) c1_items = sorted(list(c1.items()), key=lambda x: -x[1]) c2_items = sorted(list(c2.items()), key=lambda x: -x[1]) c1_max = c1_items[0][1] c2_max = ...
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) c1 = Counter(V[::2]) c2 = Counter(V[1::2]) c1_items = sorted(list(c1.items()), key=lambda x: -x[1]) c2_items = sorted(list(c2.items()), key=lambda x: -x[1]) if c1_items[0][0] == c2_items[0][0]: if len(c1_items) ==...
40
23
1,001
717
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) c1 = Counter(V[::2]) c2 = Counter(V[1::2]) # print('c1, c2', c1, c2) c1_items = sorted(list(c1.items()), key=lambda x: -x[1]) c2_items = sorted(list(c2.items()), key=lambda x: -x[1]) c1_max = c1_items[0][1] c2_max = c2_items[0][...
from collections import Counter n = int(eval(input())) V = list(map(int, input().split())) c1 = Counter(V[::2]) c2 = Counter(V[1::2]) c1_items = sorted(list(c1.items()), key=lambda x: -x[1]) c2_items = sorted(list(c2.items()), key=lambda x: -x[1]) if c1_items[0][0] == c2_items[0][0]: if len(c1_items) == 1 and len(...
false
42.5
[ "-# print('c1, c2', c1, c2)", "-c1_max = c1_items[0][1]", "-c2_max = c2_items[0][1]", "-c1_second = 0", "-c2_second = 0", "-c1_max_group = set()", "-for key, value in c1_items:", "- if value == c1_max:", "- c1_max_group.add(key)", "+if c1_items[0][0] == c2_items[0][0]:", "+ if len(c...
false
0.041185
0.049559
0.831024
[ "s236032013", "s156357120" ]
u077291787
p02983
python
s755466033
s446527299
784
547
3,060
3,064
Accepted
Accepted
30.23
# ABC133C - Remainder Minimization 2019 def main(): L, R = list(map(int, input().rstrip().split())) MOD = 2019 if (R // MOD) - (L // MOD) > 0: # L <= 2019n <= R print((0)) else: # R - L <= 2018 -> max: 2018 * 2017 patterns ans = float("inf") for i in range(L, R): ...
# ABC133C - Remainder Minimization 2019 def main(): L, R = list(map(int, input().rstrip().split())) MOD = 2019 if (R // MOD) - (L // MOD) > 0: # L <= 2019n <= R print((0)) else: # R - L <= 2018 -> max: 2018 * 2017 patterns ans = float("inf") L, R = L % MOD, R % MOD ...
17
17
506
498
# ABC133C - Remainder Minimization 2019 def main(): L, R = list(map(int, input().rstrip().split())) MOD = 2019 if (R // MOD) - (L // MOD) > 0: # L <= 2019n <= R print((0)) else: # R - L <= 2018 -> max: 2018 * 2017 patterns ans = float("inf") for i in range(L, R): fo...
# ABC133C - Remainder Minimization 2019 def main(): L, R = list(map(int, input().rstrip().split())) MOD = 2019 if (R // MOD) - (L // MOD) > 0: # L <= 2019n <= R print((0)) else: # R - L <= 2018 -> max: 2018 * 2017 patterns ans = float("inf") L, R = L % MOD, R % MOD for ...
false
0
[ "+ L, R = L % MOD, R % MOD", "- i, j = i % MOD, j % MOD" ]
false
0.042973
0.037796
1.13696
[ "s755466033", "s446527299" ]
u191874006
p03107
python
s849139197
s554254097
190
173
49,648
39,152
Accepted
Accepted
8.95
#!/usr/bin/env python3 #ABC120 C import sys import math import bisect sys.setrecursionlimit(1000000000) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import ite...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
32
23
766
626
#!/usr/bin/env python3 # ABC120 C import sys import math import bisect sys.setrecursionlimit(1000000000) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter fr...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop, heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collectio...
false
28.125
[ "-# ABC120 C", "-import bisect", "+from bisect import bisect_right as br", "+from bisect import bisect_left as bl", "-sys.setrecursionlimit(1000000000)", "+sys.setrecursionlimit(2147483647)", "-s = list(eval(input()))", "-stack = deque()", "-ans = 0", "-for i in range(len(s)):", "- if len(sta...
false
0.047022
0.046738
1.006082
[ "s849139197", "s554254097" ]
u991567869
p02785
python
s035222765
s159846940
175
153
26,360
26,180
Accepted
Accepted
12.57
n, k = list(map(int, input().split())) h = sorted(list(map(int, input().split()))) for i in range(min(n, k)): del h[n - i - 1] HP = sum(h) print(HP)
n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort(reverse = True) HP = sum(h[min(n,k):n]) print(HP)
8
6
159
131
n, k = list(map(int, input().split())) h = sorted(list(map(int, input().split()))) for i in range(min(n, k)): del h[n - i - 1] HP = sum(h) print(HP)
n, k = list(map(int, input().split())) h = list(map(int, input().split())) h.sort(reverse=True) HP = sum(h[min(n, k) : n]) print(HP)
false
25
[ "-h = sorted(list(map(int, input().split())))", "-for i in range(min(n, k)):", "- del h[n - i - 1]", "-HP = sum(h)", "+h = list(map(int, input().split()))", "+h.sort(reverse=True)", "+HP = sum(h[min(n, k) : n])" ]
false
0.041143
0.04084
1.007436
[ "s035222765", "s159846940" ]
u941753895
p03805
python
s486324319
s082564631
66
54
6,612
5,428
Accepted
Accepted
18.18
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...
# https://atcoder.jp/contests/abc054/tasks/abc054_c import math,itertools,fractions,heapq,bisect,sys,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...
52
53
1,168
1,074
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) ...
# https://atcoder.jp/contests/abc054/tasks/abc054_c import math, itertools, fractions, heapq, bisect, sys, 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 [i...
false
1.886792
[ "-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy", "+# https://atcoder.jp/contests/abc054/tasks/abc054_c", "+import math, itertools, fractions, heapq, bisect, sys, queue, copy", "-", "-", "-def LI_():", "- return [int(x) - 1 for x in s...
false
0.04692
0.046287
1.013665
[ "s486324319", "s082564631" ]
u367130284
p03126
python
s161628850
s948513263
181
18
38,768
3,060
Accepted
Accepted
90.06
q=set(map(str,list(range(31)))) for s in open(0).readlines()[1:]: t=set(s.split()[1:]) q&=t print((len(q)))
a,b=list(map(int,input().split())) for i in range(a): n,*a=list(map(int,input().split())) if i==0: l=a else: l=set(a)&set(l) print((len(l)))
5
8
111
161
q = set(map(str, list(range(31)))) for s in open(0).readlines()[1:]: t = set(s.split()[1:]) q &= t print((len(q)))
a, b = list(map(int, input().split())) for i in range(a): n, *a = list(map(int, input().split())) if i == 0: l = a else: l = set(a) & set(l) print((len(l)))
false
37.5
[ "-q = set(map(str, list(range(31))))", "-for s in open(0).readlines()[1:]:", "- t = set(s.split()[1:])", "- q &= t", "-print((len(q)))", "+a, b = list(map(int, input().split()))", "+for i in range(a):", "+ n, *a = list(map(int, input().split()))", "+ if i == 0:", "+ l = a", "+...
false
0.11744
0.034778
3.376886
[ "s161628850", "s948513263" ]
u225388820
p02606
python
s880379505
s698403582
79
26
61,588
9,088
Accepted
Accepted
67.09
l, r, d = list(map(int, input().split())) cnt = 0 for i in range(l, r + 1): if i % d == 0: cnt += 1 print(cnt)
l, r, d = list(map(int, input().split())) l-=1 print((r // d - l // d))
6
3
121
65
l, r, d = list(map(int, input().split())) cnt = 0 for i in range(l, r + 1): if i % d == 0: cnt += 1 print(cnt)
l, r, d = list(map(int, input().split())) l -= 1 print((r // d - l // d))
false
50
[ "-cnt = 0", "-for i in range(l, r + 1):", "- if i % d == 0:", "- cnt += 1", "-print(cnt)", "+l -= 1", "+print((r // d - l // d))" ]
false
0.037629
0.037075
1.014941
[ "s880379505", "s698403582" ]
u813098295
p03828
python
s698328975
s180732489
25
23
3,064
3,064
Accepted
Accepted
8
n = int(eval(input())) exps = [0] * 1003 for i in range(2, n+1): t = i div = 2 while div*div <= n: if t % div == 0: exps[div] += 1 t //= div else: div += 1 if t != 1: exps[t] += 1 ans = 1 mod = int(1e9) + 7 for i in range(2...
n = int(eval(input())) exps = [0] * 1003 for i in range(2, n+1): t = i div = 2 while div*div <= i: if t % div == 0: exps[div] += 1 t //= div else: div += 1 if t != 1: exps[t] += 1 ans = 1 mod = int(1e9) + 7 for i in range(2...
23
23
377
377
n = int(eval(input())) exps = [0] * 1003 for i in range(2, n + 1): t = i div = 2 while div * div <= n: if t % div == 0: exps[div] += 1 t //= div else: div += 1 if t != 1: exps[t] += 1 ans = 1 mod = int(1e9) + 7 for i in range(2, n + 1): ans...
n = int(eval(input())) exps = [0] * 1003 for i in range(2, n + 1): t = i div = 2 while div * div <= i: if t % div == 0: exps[div] += 1 t //= div else: div += 1 if t != 1: exps[t] += 1 ans = 1 mod = int(1e9) + 7 for i in range(2, n + 1): ans...
false
0
[ "- while div * div <= n:", "+ while div * div <= i:" ]
false
0.050258
0.036733
1.368189
[ "s698328975", "s180732489" ]
u682672120
p03682
python
s381087361
s934978305
1,364
1,173
145,180
136,616
Accepted
Accepted
14
from heapq import heappop, heappush def prim(adjacent:list, root=0): n = len(adjacent) visited = [False] * n min_cost = 0 q = [(0, root)] count = 0 while q and count < n: weight, vi = heappop(q) if visited[vi]: continue visited[vi] = True ...
from heapq import heappop, heappush def prim(adjacent:list, root=0): ''' Prim法。最小全域木のコストを求める。負の閉路も可 -------- adjacent : 隣接リスト root : 探索開始頂点 -------- min_cost : 最小コスト ''' n = len(adjacent) visited = [False] * n min_cost = 0 q = [(0, root)] ...
44
52
1,116
1,264
from heapq import heappop, heappush def prim(adjacent: list, root=0): n = len(adjacent) visited = [False] * n min_cost = 0 q = [(0, root)] count = 0 while q and count < n: weight, vi = heappop(q) if visited[vi]: continue visited[vi] = True min_cost +...
from heapq import heappop, heappush def prim(adjacent: list, root=0): """ Prim法。最小全域木のコストを求める。負の閉路も可 -------- adjacent : 隣接リスト root : 探索開始頂点 -------- min_cost : 最小コスト """ n = len(adjacent) visited = [False] * n min_cost = 0 q = [(0, root)] while q: ...
false
15.384615
[ "+ \"\"\"", "+ Prim法。最小全域木のコストを求める。負の閉路も可", "+ adjacent : 隣接リスト", "+ root : 探索開始頂点", "+ min_cost : 最小コスト", "+ \"\"\"", "- count = 0", "- while q and count < n:", "+ while q:", "- count += 1", "- heappush(q, (weight, vj))", "+ ...
false
0.040346
0.072148
0.559215
[ "s381087361", "s934978305" ]
u560867850
p03038
python
s034371323
s921133012
338
253
22,844
23,672
Accepted
Accepted
25.15
import heapq import sys input = sys.stdin.buffer.readline from operator import itemgetter def readlines(n): for _ in range(n): b, c = list(map(int, input().split())) yield b, c def main(): _, M = list(map(int, input().split())) A = list(map(int, input().split())) total = s...
import heapq import sys input = sys.stdin.readline from operator import itemgetter def readlines(n): for _ in range(n): b, c = list(map(int, input().split())) yield b, c def main(): N, M = list(map(int, input().split())) A = list(map(int, input().split())) change = [] ...
27
26
617
540
import heapq import sys input = sys.stdin.buffer.readline from operator import itemgetter def readlines(n): for _ in range(n): b, c = list(map(int, input().split())) yield b, c def main(): _, M = list(map(int, input().split())) A = list(map(int, input().split())) total = sum(A) ...
import heapq import sys input = sys.stdin.readline from operator import itemgetter def readlines(n): for _ in range(n): b, c = list(map(int, input().split())) yield b, c def main(): N, M = list(map(int, input().split())) A = list(map(int, input().split())) change = [] for b, c i...
false
3.703704
[ "-input = sys.stdin.buffer.readline", "+input = sys.stdin.readline", "- _, M = list(map(int, input().split()))", "+ N, M = list(map(int, input().split()))", "- total = sum(A)", "- heapq.heapify(A)", "+ change = []", "- for _ in range(b):", "- o = heapq.heappushpop(A,...
false
0.037502
0.038025
0.986242
[ "s034371323", "s921133012" ]
u952708174
p03546
python
s202924506
s916180041
238
202
40,432
40,432
Accepted
Accepted
15.13
def d_wall(H, W, C, A): cost=C for k in range(10): for i in range(10): for j in range(10): cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]) ans = 0 for i in range(H): for j in range(W): if A[i][j] != -1: ans += cost[A...
def d_wall(H, W, C, A): # cost[i][j]には最終的に数字iからjに移行するための最小コストが格納される cost = [x[:] for x in C] # ワーシャルフロイド法で最小コストを計算 for k in range(10): for i in range(10): for j in range(10): cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]) ans = 0 # 壁の各数字ごとにコス...
17
21
535
684
def d_wall(H, W, C, A): cost = C for k in range(10): for i in range(10): for j in range(10): cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]) ans = 0 for i in range(H): for j in range(W): if A[i][j] != -1: ans += cost[A[i][j]][...
def d_wall(H, W, C, A): # cost[i][j]には最終的に数字iからjに移行するための最小コストが格納される cost = [x[:] for x in C] # ワーシャルフロイド法で最小コストを計算 for k in range(10): for i in range(10): for j in range(10): cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]) ans = 0 # 壁の各数字ごとにコストの値を参照、和を取る...
false
19.047619
[ "- cost = C", "+ # cost[i][j]には最終的に数字iからjに移行するための最小コストが格納される", "+ cost = [x[:] for x in C]", "+ # ワーシャルフロイド法で最小コストを計算", "+ # 壁の各数字ごとにコストの値を参照、和を取る", "- ans += cost[A[i][j]][1]", "+ ans += cost[A[i][j]][1] # 壁の数字から1へ移行するための最小コスト" ]
false
0.038212
0.039074
0.977922
[ "s202924506", "s916180041" ]
u527993431
p02802
python
s245106262
s019122187
334
299
29,096
4,596
Accepted
Accepted
10.48
from collections import defaultdict N,M=list(map(int,input().split())) P=[] S=[] for i in range (M): A,B=input().split() P.append(int(A)) S.append(B) Q=defaultdict(lambda:0) R=defaultdict(lambda:0) count=0 for i,j in zip(P,S): if Q[i]==0: if j=="AC": Q[i]=1 count+=R[i] elif j=...
N,M=list(map(int,input().split())) L=[0]*N A=0 W=0 tmp=[0]*N for i in range(M): x,y=input().split() t=int(x) if L[t-1]==0: if y=="WA": tmp[t-1]+=1 else: A+=1 W+=tmp[t-1] L[t-1]=1 print((A,W))
20
16
365
217
from collections import defaultdict N, M = list(map(int, input().split())) P = [] S = [] for i in range(M): A, B = input().split() P.append(int(A)) S.append(B) Q = defaultdict(lambda: 0) R = defaultdict(lambda: 0) count = 0 for i, j in zip(P, S): if Q[i] == 0: if j == "AC": Q[i] = 1...
N, M = list(map(int, input().split())) L = [0] * N A = 0 W = 0 tmp = [0] * N for i in range(M): x, y = input().split() t = int(x) if L[t - 1] == 0: if y == "WA": tmp[t - 1] += 1 else: A += 1 W += tmp[t - 1] L[t - 1] = 1 print((A, W))
false
20
[ "-from collections import defaultdict", "-", "-P = []", "-S = []", "+L = [0] * N", "+A = 0", "+W = 0", "+tmp = [0] * N", "- A, B = input().split()", "- P.append(int(A))", "- S.append(B)", "-Q = defaultdict(lambda: 0)", "-R = defaultdict(lambda: 0)", "-count = 0", "-for i, j in z...
false
0.047745
0.046186
1.033751
[ "s245106262", "s019122187" ]
u034782764
p03494
python
s322420909
s401822428
154
18
12,504
2,940
Accepted
Accepted
88.31
import numpy as np def how_many_times_divisibles(j): counter=0 while j%2==0: j/=2 counter+=1 return counter n=int(eval(input())) a=list(map(int,input().split())) ans=min(list(map(how_many_times_divisibles,a))) print(ans)
def howmanytimes(j): counter=0 while j%2==0: j/=2 counter+=1 return counter n=int(eval(input())) a=list(map(int,input().split())) ans=min(list(map(howmanytimes,a))) print(ans)
13
13
223
195
import numpy as np def how_many_times_divisibles(j): counter = 0 while j % 2 == 0: j /= 2 counter += 1 return counter n = int(eval(input())) a = list(map(int, input().split())) ans = min(list(map(how_many_times_divisibles, a))) print(ans)
def howmanytimes(j): counter = 0 while j % 2 == 0: j /= 2 counter += 1 return counter n = int(eval(input())) a = list(map(int, input().split())) ans = min(list(map(howmanytimes, a))) print(ans)
false
0
[ "-import numpy as np", "-", "-", "-def how_many_times_divisibles(j):", "+def howmanytimes(j):", "-ans = min(list(map(how_many_times_divisibles, a)))", "+ans = min(list(map(howmanytimes, a)))" ]
false
0.035866
0.038229
0.938185
[ "s322420909", "s401822428" ]
u141610915
p03846
python
s922114728
s775523482
314
93
53,100
14,008
Accepted
Accepted
70.38
N = int(eval(input())) A = list(map(int, input().split())) A.sort() mod = 10 ** 9 + 7 i = 0 res = 0 if N == 1: if A[0] == 0: print((1)) else: print((0)) exit(0) if N % 2 == 1: res = 1 i = 1 if A[0] == A[1]: print((0)) exit(0) if A[0] == 1: print((0)) exit(0) ...
N = int(eval(input())) A = sorted(map(int,input().split())) B = [] if N%2: B = [0] for i in range(N//2): B += [(i + 1)*2]*2 else: for i in range(N//2): B += [i*2 + 1]*2 #print(A, B) #print(B) if A==B: print((2**(N//2)%((10**9) + 7))) else: print((0))
47
19
711
272
N = int(eval(input())) A = list(map(int, input().split())) A.sort() mod = 10**9 + 7 i = 0 res = 0 if N == 1: if A[0] == 0: print((1)) else: print((0)) exit(0) if N % 2 == 1: res = 1 i = 1 if A[0] == A[1]: print((0)) exit(0) if A[0] == 1: print((0)) ...
N = int(eval(input())) A = sorted(map(int, input().split())) B = [] if N % 2: B = [0] for i in range(N // 2): B += [(i + 1) * 2] * 2 else: for i in range(N // 2): B += [i * 2 + 1] * 2 # print(A, B) # print(B) if A == B: print((2 ** (N // 2) % ((10**9) + 7))) else: print((0))
false
59.574468
[ "-A = list(map(int, input().split()))", "-A.sort()", "-mod = 10**9 + 7", "-i = 0", "-res = 0", "-if N == 1:", "- if A[0] == 0:", "- print((1))", "- else:", "- print((0))", "- exit(0)", "-if N % 2 == 1:", "- res = 1", "- i = 1", "- if A[0] == A[1]:", "- ...
false
0.007731
0.055511
0.139265
[ "s922114728", "s775523482" ]
u272028993
p03839
python
s712783324
s902874245
185
168
12,236
12,240
Accepted
Accepted
9.19
n,k=list(map(int,input().split())) a=list(map(int,input().split())) total=[0]*(n+1) asum=[0]*(n+1) for i in range(n): asum[i+1]=asum[i]+a[i] if a[i]>0: total[i+1]=total[i]+a[i] else: total[i+1]=total[i] ans=0 for i in range(n-k+1): tmp=asum[i+k]-asum[i] ans=max(ans,tmp+t...
n,k=list(map(int,input().split())) a=list(map(int,input().split())) s1=[0]*n s1[0]=a[0] s2=[0]*n if a[0]>0: s2[0]=a[0] for i in range(1,n): s1[i]+=s1[i-1]+a[i] s2[i]+=s2[i-1] if a[i]>0: s2[i]+=a[i] ans=-float("inf") for i in range(n-k+1): if i==0: tmp1=s1[i+k-1] ...
16
22
390
473
n, k = list(map(int, input().split())) a = list(map(int, input().split())) total = [0] * (n + 1) asum = [0] * (n + 1) for i in range(n): asum[i + 1] = asum[i] + a[i] if a[i] > 0: total[i + 1] = total[i] + a[i] else: total[i + 1] = total[i] ans = 0 for i in range(n - k + 1): tmp = asum[i ...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) s1 = [0] * n s1[0] = a[0] s2 = [0] * n if a[0] > 0: s2[0] = a[0] for i in range(1, n): s1[i] += s1[i - 1] + a[i] s2[i] += s2[i - 1] if a[i] > 0: s2[i] += a[i] ans = -float("inf") for i in range(n - k + 1): if i == 0: ...
false
27.272727
[ "-total = [0] * (n + 1)", "-asum = [0] * (n + 1)", "-for i in range(n):", "- asum[i + 1] = asum[i] + a[i]", "+s1 = [0] * n", "+s1[0] = a[0]", "+s2 = [0] * n", "+if a[0] > 0:", "+ s2[0] = a[0]", "+for i in range(1, n):", "+ s1[i] += s1[i - 1] + a[i]", "+ s2[i] += s2[i - 1]", "- ...
false
0.044845
0.048426
0.926048
[ "s712783324", "s902874245" ]
u714587753
p03324
python
s286618764
s574318938
248
100
3,060
30,572
Accepted
Accepted
59.68
s = input().strip() ss = s.split() d = int(ss[0]) n = int(ss[1]) i = 1 while 1: x = i c = 0 while x % 100 == 0: x //= 100 c += 1 if c == d: n -= 1 if n == 0: print(i) break i += 1
s = input() ss = s.split() d = int(ss[0]) n = int(ss[1]) i = 1 while 1: x = i c = 0 while x % 100 == 0: x //= 100 c += 1 if c == d: n -= 1 if n == 0: print(i) break i += 1
17
17
215
210
s = input().strip() ss = s.split() d = int(ss[0]) n = int(ss[1]) i = 1 while 1: x = i c = 0 while x % 100 == 0: x //= 100 c += 1 if c == d: n -= 1 if n == 0: print(i) break i += 1
s = input() ss = s.split() d = int(ss[0]) n = int(ss[1]) i = 1 while 1: x = i c = 0 while x % 100 == 0: x //= 100 c += 1 if c == d: n -= 1 if n == 0: print(i) break i += 1
false
0
[ "-s = input().strip()", "+s = input()" ]
false
0.16393
0.006459
25.38025
[ "s286618764", "s574318938" ]
u562935282
p03103
python
s028153283
s228673189
478
426
21,972
16,984
Accepted
Accepted
10.88
N, M = list(map(int, input().split())) e = [] for _ in range(N): a, b = list(map(int, input().split())) e.append([a, b]) e = list(sorted(e, key=lambda x: x[0])) # 安値から cost = 0 cnt = M e_i = 0 while cnt > 0: can_buy = min(cnt, e[e_i][1]) # 必要本数か売っている本数のうち少ない方 cost += can_buy * e[e...
n, m = list(map(int, input().split())) e = [tuple(map(int, input().split())) for _ in range(n)] e.sort() # 金額昇順 ans = 0 rest = m for a, b in e: use = min(rest, b) ans += use * a rest -= use if rest == 0: break print(ans)
23
12
418
251
N, M = list(map(int, input().split())) e = [] for _ in range(N): a, b = list(map(int, input().split())) e.append([a, b]) e = list(sorted(e, key=lambda x: x[0])) # 安値から cost = 0 cnt = M e_i = 0 while cnt > 0: can_buy = min(cnt, e[e_i][1]) # 必要本数か売っている本数のうち少ない方 cost += can_buy * e[e_i][0] e[e_i][1...
n, m = list(map(int, input().split())) e = [tuple(map(int, input().split())) for _ in range(n)] e.sort() # 金額昇順 ans = 0 rest = m for a, b in e: use = min(rest, b) ans += use * a rest -= use if rest == 0: break print(ans)
false
47.826087
[ "-N, M = list(map(int, input().split()))", "-e = []", "-for _ in range(N):", "- a, b = list(map(int, input().split()))", "- e.append([a, b])", "-e = list(sorted(e, key=lambda x: x[0]))", "-# 安値から", "-cost = 0", "-cnt = M", "-e_i = 0", "-while cnt > 0:", "- can_buy = min(cnt, e[e_i][1]...
false
0.043597
0.037151
1.173522
[ "s028153283", "s228673189" ]
u046592970
p03208
python
s573671204
s782428442
294
254
8,628
8,280
Accepted
Accepted
13.61
from collections import deque n,k = list(map(int,input().split())) h = sorted([int(eval(input())) for _ in range(n)]) x = deque([]) mn = 10**9 for i in h: x.append(i) if len(x) >= k: mn = min(mn,x[k-1]-x[0]) x.popleft() print(mn)
n,k = list(map(int,input().split())) h = sorted([int(eval(input())) for _ in range(n)]) mn = 10**9 for i in range(n-k+1): mn = min(mn,h[i+k-1] - h[i]) print(mn)
11
6
251
157
from collections import deque n, k = list(map(int, input().split())) h = sorted([int(eval(input())) for _ in range(n)]) x = deque([]) mn = 10**9 for i in h: x.append(i) if len(x) >= k: mn = min(mn, x[k - 1] - x[0]) x.popleft() print(mn)
n, k = list(map(int, input().split())) h = sorted([int(eval(input())) for _ in range(n)]) mn = 10**9 for i in range(n - k + 1): mn = min(mn, h[i + k - 1] - h[i]) print(mn)
false
45.454545
[ "-from collections import deque", "-", "-x = deque([])", "-for i in h:", "- x.append(i)", "- if len(x) >= k:", "- mn = min(mn, x[k - 1] - x[0])", "- x.popleft()", "+for i in range(n - k + 1):", "+ mn = min(mn, h[i + k - 1] - h[i])" ]
false
0.040469
0.043536
0.929547
[ "s573671204", "s782428442" ]
u844005364
p03274
python
s359234751
s094078577
173
91
14,568
14,224
Accepted
Accepted
47.4
n, k = list(map(int, input().split())) x = list(map(int, input().split())) min_t = 10 ** 9 import bisect snuke = bisect.bisect_left(x, 0) if snuke < n and x[snuke] == 0: k -= 1 n -= 1 del x[snuke] for i in range(k+1): if i == 0: left = 0 elif snuke - i >= 0: left...
n,k=list(map(int,input().split())) x=sorted(list(map(int,input().split()))) a=[] for i in range(n-k+1): l=x[i] r=x[i+k-1] a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r))) print((min(a)))
31
8
610
195
n, k = list(map(int, input().split())) x = list(map(int, input().split())) min_t = 10**9 import bisect snuke = bisect.bisect_left(x, 0) if snuke < n and x[snuke] == 0: k -= 1 n -= 1 del x[snuke] for i in range(k + 1): if i == 0: left = 0 elif snuke - i >= 0: left = abs(x[snuke - i])...
n, k = list(map(int, input().split())) x = sorted(list(map(int, input().split()))) a = [] for i in range(n - k + 1): l = x[i] r = x[i + k - 1] a.append(min(abs(l) + abs(r - l), abs(r) + abs(l - r))) print((min(a)))
false
74.193548
[ "-x = list(map(int, input().split()))", "-min_t = 10**9", "-import bisect", "-", "-snuke = bisect.bisect_left(x, 0)", "-if snuke < n and x[snuke] == 0:", "- k -= 1", "- n -= 1", "- del x[snuke]", "-for i in range(k + 1):", "- if i == 0:", "- left = 0", "- elif snuke - i...
false
0.045874
0.04507
1.017841
[ "s359234751", "s094078577" ]
u691018832
p02688
python
s623506091
s061310205
61
26
67,536
9,244
Accepted
Accepted
57.38
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, k = list(map(int, readline().split())) ans = set() cnt = 0 for _ in range(k): d = int(readline()) a = list(map(int, readline().split())) ans |= s...
def main(): import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, k = list(map(int, readline().split())) memo = set() cnt = 0 for _ in range(k): d = int(readline()) ...
17
21
398
502
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) n, k = list(map(int, readline().split())) ans = set() cnt = 0 for _ in range(k): d = int(readline()) a = list(map(int, readline().split())) ans |= set(a) for i in...
def main(): import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) n, k = list(map(int, readline().split())) memo = set() cnt = 0 for _ in range(k): d = int(readline()) memo |= ...
false
19.047619
[ "-import sys", "+def main():", "+ import sys", "-read = sys.stdin.buffer.read", "-readline = sys.stdin.buffer.readline", "-readlines = sys.stdin.buffer.readlines", "-sys.setrecursionlimit(10**7)", "-n, k = list(map(int, readline().split()))", "-ans = set()", "-cnt = 0", "-for _ in range(k):",...
false
0.038824
0.03702
1.048718
[ "s623506091", "s061310205" ]
u614314290
p03043
python
s831508771
s704130968
45
29
2,940
3,060
Accepted
Accepted
35.56
N, K = list(map(int, input().split())) result = 0 for n in range(1, N + 1): d, x = 0, n while x < K: d += 1 x *= 2 result += (1 / N) * (1 / 2)**d print(result)
from math import ceil # 定数 INF = float("inf") MOD = int(1e9 + 7) # エントリーポイント def main(): N, K = list(map(int, input().split())) r = 0 for n in range(1, N + 1): c = 0 while n < K: n *= 2 c += 1 r += 0.5 ** c print((r / N)) main()
10
19
171
306
N, K = list(map(int, input().split())) result = 0 for n in range(1, N + 1): d, x = 0, n while x < K: d += 1 x *= 2 result += (1 / N) * (1 / 2) ** d print(result)
from math import ceil # 定数 INF = float("inf") MOD = int(1e9 + 7) # エントリーポイント def main(): N, K = list(map(int, input().split())) r = 0 for n in range(1, N + 1): c = 0 while n < K: n *= 2 c += 1 r += 0.5**c print((r / N)) main()
false
47.368421
[ "-N, K = list(map(int, input().split()))", "-result = 0", "-for n in range(1, N + 1):", "- d, x = 0, n", "- while x < K:", "- d += 1", "- x *= 2", "- result += (1 / N) * (1 / 2) ** d", "-print(result)", "+from math import ceil", "+", "+# 定数", "+INF = float(\"inf\")", ...
false
0.202994
0.042735
4.750107
[ "s831508771", "s704130968" ]
u645250356
p03937
python
s561519096
s738437193
267
39
46,812
5,080
Accepted
Accepted
85.39
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools sys.setrecursionlimit(10**8) mod = 10**9+7 mod2 = 998244353 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split()))...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,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, sys.stdin.readline().split())) ...
52
33
1,297
880
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools sys.setrecursionlimit(10**8) mod = 10**9 + 7 mod2 = 998244353 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readli...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, 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, sys.stdin.read...
false
36.538462
[ "-import sys, bisect, math, itertools", "+import sys, bisect, math, itertools, fractions, pprint", "-mod2 = 998244353", "-if s[0][0] != \"#\":", "+cnt = 0", "+for i in s:", "+ cnt += i.count(\"#\")", "+if cnt != h + w - 1:", "-s[0][0] = \".\"", "-for i in itertools.combinations(list(range(h + w...
false
0.046171
0.042933
1.075433
[ "s561519096", "s738437193" ]
u432251613
p02724
python
s108830631
s725145487
1,108
18
2,940
2,940
Accepted
Accepted
98.38
def main(): X = int(eval(input())) # 500円をp個、5円をq個とすると。500p+5q=Xが成り立ち、ansは1000p+5qになる pmax = int(X/500) ans = 0 tmp = 0 for p in range(pmax+1): q = int((X-500*p)/5) tmp = 1000*p + 5*q ans = max(ans,tmp) print(ans) main()
def main(): X = int(eval(input())) # 500円をp個、5円をq個とすると。500p+5q=Xが成り立ち、ansは1000p+5qになる p = int(X/500) q = int((X-p*500)/5) ans = 1000*p + 5*q print(ans) main()
13
9
280
186
def main(): X = int(eval(input())) # 500円をp個、5円をq個とすると。500p+5q=Xが成り立ち、ansは1000p+5qになる pmax = int(X / 500) ans = 0 tmp = 0 for p in range(pmax + 1): q = int((X - 500 * p) / 5) tmp = 1000 * p + 5 * q ans = max(ans, tmp) print(ans) main()
def main(): X = int(eval(input())) # 500円をp個、5円をq個とすると。500p+5q=Xが成り立ち、ansは1000p+5qになる p = int(X / 500) q = int((X - p * 500) / 5) ans = 1000 * p + 5 * q print(ans) main()
false
30.769231
[ "- pmax = int(X / 500)", "- ans = 0", "- tmp = 0", "- for p in range(pmax + 1):", "- q = int((X - 500 * p) / 5)", "- tmp = 1000 * p + 5 * q", "- ans = max(ans, tmp)", "+ p = int(X / 500)", "+ q = int((X - p * 500) / 5)", "+ ans = 1000 * p + 5 * q" ]
false
0.573093
0.048266
11.873544
[ "s108830631", "s725145487" ]
u796942881
p03680
python
s254371350
s175876992
92
81
11,808
8,736
Accepted
Accepted
11.96
import sys l = [int(i) for i in sys.stdin] N = l[0] a = [int(i) - 1 for i in l[1:]] done = [False] * N i = 0 ans = 0 while True: if done[i] == False: done[i] = True ans += 1 if a[i] == 1: break i = a[i] else: ans = -1 brea...
import sys l = [int(i) - 1 for i in sys.stdin] N = l[0] + 1 a = l[1:] done = [False] * N i = 0 ans = 0 while True: if done[i] == False: done[i] = True ans += 1 if a[i] == 1: break i = a[i] else: ans = -1 break print(ans...
26
26
336
322
import sys l = [int(i) for i in sys.stdin] N = l[0] a = [int(i) - 1 for i in l[1:]] done = [False] * N i = 0 ans = 0 while True: if done[i] == False: done[i] = True ans += 1 if a[i] == 1: break i = a[i] else: ans = -1 break print(ans)
import sys l = [int(i) - 1 for i in sys.stdin] N = l[0] + 1 a = l[1:] done = [False] * N i = 0 ans = 0 while True: if done[i] == False: done[i] = True ans += 1 if a[i] == 1: break i = a[i] else: ans = -1 break print(ans)
false
0
[ "-l = [int(i) for i in sys.stdin]", "-N = l[0]", "-a = [int(i) - 1 for i in l[1:]]", "+l = [int(i) - 1 for i in sys.stdin]", "+N = l[0] + 1", "+a = l[1:]" ]
false
0.091829
0.047902
1.917003
[ "s254371350", "s175876992" ]
u971091945
p02756
python
s995675325
s717376518
1,997
662
40,520
44,660
Accepted
Accepted
66.85
s = eval(input()) q = int(eval(input())) li=[list(map(str,input().split())) for _ in range(q)] moji = "0" frag = True for i in range(q): que = li[i] if que[0] == "1": if frag: frag = False else: frag = True else: f = que[1] c = que[2]...
from collections import deque s = deque(eval(input())) q = int(eval(input())) li = [list(map(str, input().split())) for _ in range(q)] frag = True for i in range(q): que = li[i] if que[0] == "1": if frag: frag = False else: frag = True else: f...
34
33
669
666
s = eval(input()) q = int(eval(input())) li = [list(map(str, input().split())) for _ in range(q)] moji = "0" frag = True for i in range(q): que = li[i] if que[0] == "1": if frag: frag = False else: frag = True else: f = que[1] c = que[2] if fra...
from collections import deque s = deque(eval(input())) q = int(eval(input())) li = [list(map(str, input().split())) for _ in range(q)] frag = True for i in range(q): que = li[i] if que[0] == "1": if frag: frag = False else: frag = True else: f = que[1] ...
false
2.941176
[ "-s = eval(input())", "+from collections import deque", "+", "+s = deque(eval(input()))", "-moji = \"0\"", "- moji = c + moji", "+ s.appendleft(c)", "- moji = moji + c", "+ s.append(c)", "- moji = moji + c", "+ ...
false
0.073992
0.110423
0.670075
[ "s995675325", "s717376518" ]
u272028993
p03988
python
s223096936
s051294377
18
10
2,696
2,696
Accepted
Accepted
44.44
n=int(input()) a=list(map(int,input().split())) maxa=max(a) cmaxa=a.count(maxa) ca=[0]*(maxa+1) for i in range(n): ca[a[i]]+=1 if maxa%2==1: l=maxa/2+1 if a.count(l)==2: for i in range(n): if a[i]<l: print("Impossible") exit() for i i...
p = "Possible" imp = "Impossible" n = int(input()) a = list(map(int, input().split())) mx = max(a) mn = min(a) if mx == 1 and mn == 1: if n == 2: print(p) exit() else: print(imp) exit() cnt = [0] * 100 for i in range(n): cnt[a[i]] += 1 if mx % 2 == 0: ...
35
41
847
776
n = int(input()) a = list(map(int, input().split())) maxa = max(a) cmaxa = a.count(maxa) ca = [0] * (maxa + 1) for i in range(n): ca[a[i]] += 1 if maxa % 2 == 1: l = maxa / 2 + 1 if a.count(l) == 2: for i in range(n): if a[i] < l: print("Impossible") exit(...
p = "Possible" imp = "Impossible" n = int(input()) a = list(map(int, input().split())) mx = max(a) mn = min(a) if mx == 1 and mn == 1: if n == 2: print(p) exit() else: print(imp) exit() cnt = [0] * 100 for i in range(n): cnt[a[i]] += 1 if mx % 2 == 0: if mx / 2 != mn: ...
false
14.634146
[ "+p = \"Possible\"", "+imp = \"Impossible\"", "-maxa = max(a)", "-cmaxa = a.count(maxa)", "-ca = [0] * (maxa + 1)", "+mx = max(a)", "+mn = min(a)", "+if mx == 1 and mn == 1:", "+ if n == 2:", "+ print(p)", "+ exit()", "+ else:", "+ print(imp)", "+ exit()",...
false
0.034839
0.042594
0.81793
[ "s223096936", "s051294377" ]
u508732591
p02258
python
s745658513
s223794550
210
160
21,916
21,832
Accepted
Accepted
23.81
import sys n = int(eval(input())) minv = int(eval(input())) maxv = -1000000000 for r in map(int,sys.stdin.readlines()): if maxv < r-minv < 0: maxv = r-minv minv = r elif maxv < r-minv: maxv = r-minv elif r-minv < 0: minv = r print(maxv)
import sys n = int(eval(input())) minv = int(eval(input())) maxv = -1000000000 for r in map(int,sys.stdin.readlines()): m = r-minv if maxv < m: maxv = m if m < 0: minv = r elif m < 0: minv = r print(maxv)
16
14
264
226
import sys n = int(eval(input())) minv = int(eval(input())) maxv = -1000000000 for r in map(int, sys.stdin.readlines()): if maxv < r - minv < 0: maxv = r - minv minv = r elif maxv < r - minv: maxv = r - minv elif r - minv < 0: minv = r print(maxv)
import sys n = int(eval(input())) minv = int(eval(input())) maxv = -1000000000 for r in map(int, sys.stdin.readlines()): m = r - minv if maxv < m: maxv = m if m < 0: minv = r elif m < 0: minv = r print(maxv)
false
12.5
[ "- if maxv < r - minv < 0:", "- maxv = r - minv", "- minv = r", "- elif maxv < r - minv:", "- maxv = r - minv", "- elif r - minv < 0:", "+ m = r - minv", "+ if maxv < m:", "+ maxv = m", "+ if m < 0:", "+ minv = r", "+ elif m < 0:"...
false
0.036152
0.126351
0.286126
[ "s745658513", "s223794550" ]
u867848444
p02780
python
s715251115
s018882440
205
144
25,060
25,060
Accepted
Accepted
29.76
n,k=list(map(int,input().split())) p=list(map(int,input().split())) maxim=[0]*(n-k+1) cnt=0 s=0 for i in range(n): cnt+=1 s+=p[i] if cnt==k: maxim[i-(k-1)]=s cnt=k-1 s+=-p[i-(k-1)] ans=(max(maxim)+k)/2 print(ans)
n, k = list(map(int,input().split())) p = list(map(int,input().split())) ranges = 0 temp = 0 for i in range(n - k + 1): if ranges == 0: ranges = sum(p[:k]) temp = ranges else: temp = temp - p[i - 1] + p[i - 1 + k] if temp > ranges: ranges = temp ans = ...
15
16
258
342
n, k = list(map(int, input().split())) p = list(map(int, input().split())) maxim = [0] * (n - k + 1) cnt = 0 s = 0 for i in range(n): cnt += 1 s += p[i] if cnt == k: maxim[i - (k - 1)] = s cnt = k - 1 s += -p[i - (k - 1)] ans = (max(maxim) + k) / 2 print(ans)
n, k = list(map(int, input().split())) p = list(map(int, input().split())) ranges = 0 temp = 0 for i in range(n - k + 1): if ranges == 0: ranges = sum(p[:k]) temp = ranges else: temp = temp - p[i - 1] + p[i - 1 + k] if temp > ranges: ranges = temp ans = (ranges + k) /...
false
6.25
[ "-maxim = [0] * (n - k + 1)", "-cnt = 0", "-s = 0", "-for i in range(n):", "- cnt += 1", "- s += p[i]", "- if cnt == k:", "- maxim[i - (k - 1)] = s", "- cnt = k - 1", "- s += -p[i - (k - 1)]", "-ans = (max(maxim) + k) / 2", "+ranges = 0", "+temp = 0", "+for i ...
false
0.042819
0.036423
1.175605
[ "s715251115", "s018882440" ]
u190178779
p02817
python
s700851859
s365056158
28
24
9,104
8,988
Accepted
Accepted
14.29
import sys S,T = input().split() if not ( S.islower() and T.islower() ): sys.exit() if not ( 1 <= len(S) <= 100 and 1 <= len(S) <= 100 ): sys.exit() print(T,end='') print(S)
import sys S,T = input().split() if not ( S.islower() and T.islower() ): sys.exit() if not ( 1 <= len(S) <= 100 and 1 <= len(S) <= 100 ): sys.exit() print(T,S,sep='')
8
7
182
174
import sys S, T = input().split() if not (S.islower() and T.islower()): sys.exit() if not (1 <= len(S) <= 100 and 1 <= len(S) <= 100): sys.exit() print(T, end="") print(S)
import sys S, T = input().split() if not (S.islower() and T.islower()): sys.exit() if not (1 <= len(S) <= 100 and 1 <= len(S) <= 100): sys.exit() print(T, S, sep="")
false
12.5
[ "-print(T, end=\"\")", "-print(S)", "+print(T, S, sep=\"\")" ]
false
0.037543
0.043395
0.865143
[ "s700851859", "s365056158" ]
u347184682
p02881
python
s230279893
s812785808
160
144
2,940
9,416
Accepted
Accepted
10
n=int(eval(input())) ans=float('inf') for i in range(1,int(n**0.5)+2): if n%i==0: ans=min(ans,n//i-1+i-1) print(ans)
n=int(eval(input())) ans=float('inf') for i in range(1,int(n**0.5)+1): if n%i==0: ans=min(ans,i-1+n//i-1) print(ans)
6
7
122
133
n = int(eval(input())) ans = float("inf") for i in range(1, int(n**0.5) + 2): if n % i == 0: ans = min(ans, n // i - 1 + i - 1) print(ans)
n = int(eval(input())) ans = float("inf") for i in range(1, int(n**0.5) + 1): if n % i == 0: ans = min(ans, i - 1 + n // i - 1) print(ans)
false
14.285714
[ "-for i in range(1, int(n**0.5) + 2):", "+for i in range(1, int(n**0.5) + 1):", "- ans = min(ans, n // i - 1 + i - 1)", "+ ans = min(ans, i - 1 + n // i - 1)" ]
false
0.042288
0.043957
0.962028
[ "s230279893", "s812785808" ]
u935984175
p02659
python
s946046119
s624608749
409
24
77,220
9,152
Accepted
Accepted
94.13
import decimal import sys from decimal import Decimal sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): A, B = rl().split() ans = Decimal(A) * Decimal(B) ans = ans.quantize(Decimal('0'), rounding=decimal.ROUND_FLOOR) print(ans) if __name__ == '__main__': solve(...
import sys sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): A, B = rl().split() A = int(A) B = B.split('.') B = int(B[0] + B[1]) ans = A * B // 100 print(ans) if __name__ == '__main__': solve()
17
17
322
262
import decimal import sys from decimal import Decimal sys.setrecursionlimit(10**7) rl = sys.stdin.readline def solve(): A, B = rl().split() ans = Decimal(A) * Decimal(B) ans = ans.quantize(Decimal("0"), rounding=decimal.ROUND_FLOOR) print(ans) if __name__ == "__main__": solve()
import sys sys.setrecursionlimit(10**7) rl = sys.stdin.readline def solve(): A, B = rl().split() A = int(A) B = B.split(".") B = int(B[0] + B[1]) ans = A * B // 100 print(ans) if __name__ == "__main__": solve()
false
0
[ "-import decimal", "-from decimal import Decimal", "- ans = Decimal(A) * Decimal(B)", "- ans = ans.quantize(Decimal(\"0\"), rounding=decimal.ROUND_FLOOR)", "+ A = int(A)", "+ B = B.split(\".\")", "+ B = int(B[0] + B[1])", "+ ans = A * B // 100" ]
false
0.063516
0.04196
1.513724
[ "s946046119", "s624608749" ]
u334712262
p02579
python
s126901228
s639663326
1,847
1,676
204,676
270,500
Accepted
Accepted
9.26
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutati...
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutati...
100
98
2,195
2,099
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from...
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from...
false
2
[ "- if (nx, ny) not in memo:", "- q.appendleft((c, (nx, ny)))", "+ q.appendleft((c, (nx, ny)))", "- if (nx, ny) not in memo:", "- q.append((c + 1, (nx, ny)))", "+ q.append((c + 1, (nx, ny)))" ]
false
0.151824
0.03632
4.18015
[ "s126901228", "s639663326" ]
u726285999
p02574
python
s568443044
s088263269
1,706
1,081
134,560
133,072
Accepted
Accepted
36.64
import sys import math N_MAX = 200000 + 5 INF = 10**9 + 7 sys.setrecursionlimit(N_MAX) MOD = 10**9 + 7 def main(): N = int(sys.stdin.readline().rstrip()) A = [int(x) for x in sys.stdin.readline().rstrip().split()] maxA = max(A) # 1 <= a <= maxA までの、要素の登場回数 C = [0] * (maxA + 1)...
import sys import math N_MAX = 200000 + 5 INF = 10**9 + 7 sys.setrecursionlimit(N_MAX) MOD = 10**9 + 7 def eatosthenes(N): prime = [] D = [1] * (N + 1) for i in range(2, N + 1): if D[i] != 1: continue for j in range(N // i + 1): if D[i * j] == 1...
49
65
878
1,189
import sys import math N_MAX = 200000 + 5 INF = 10**9 + 7 sys.setrecursionlimit(N_MAX) MOD = 10**9 + 7 def main(): N = int(sys.stdin.readline().rstrip()) A = [int(x) for x in sys.stdin.readline().rstrip().split()] maxA = max(A) # 1 <= a <= maxA までの、要素の登場回数 C = [0] * (maxA + 1) for a in A: ...
import sys import math N_MAX = 200000 + 5 INF = 10**9 + 7 sys.setrecursionlimit(N_MAX) MOD = 10**9 + 7 def eatosthenes(N): prime = [] D = [1] * (N + 1) for i in range(2, N + 1): if D[i] != 1: continue for j in range(N // i + 1): if D[i * j] == 1: D[...
false
24.615385
[ "+def eatosthenes(N):", "+ prime = []", "+ D = [1] * (N + 1)", "+ for i in range(2, N + 1):", "+ if D[i] != 1:", "+ continue", "+ for j in range(N // i + 1):", "+ if D[i * j] == 1:", "+ D[i * j] = i", "+ prime.append(i)", "+ r...
false
0.035822
0.035747
1.002093
[ "s568443044", "s088263269" ]
u489108157
p03837
python
s857972277
s213895071
785
162
3,188
3,444
Accepted
Accepted
79.36
n, m = [int(x) for x in input().split()] a = [0] * m b = [0] * m c = [0] * m for i in range(m): a[i], b[i], c[i] = [int(x) for x in input().split()] def dijkstra(graph, start, end): cost = [1000*100 for _ in range(n+1)] fixed = [False for _ in range(n+1)] cost[start] = 0 fixed[start] = T...
n, m = [int(x) for x in input().split()] a = [0] * m b = [0] * m c = [0] * m for i in range(m): a[i], b[i], c[i] = [int(x) for x in input().split()] def dijkstra(graph, start): cost = [1000*100 for _ in range(n+1)] fixed = [False for _ in range(n+1)] cost[start] = 0 fixed[start] = True ...
38
42
1,022
1,087
n, m = [int(x) for x in input().split()] a = [0] * m b = [0] * m c = [0] * m for i in range(m): a[i], b[i], c[i] = [int(x) for x in input().split()] def dijkstra(graph, start, end): cost = [1000 * 100 for _ in range(n + 1)] fixed = [False for _ in range(n + 1)] cost[start] = 0 fixed[start] = True ...
n, m = [int(x) for x in input().split()] a = [0] * m b = [0] * m c = [0] * m for i in range(m): a[i], b[i], c[i] = [int(x) for x in input().split()] def dijkstra(graph, start): cost = [1000 * 100 for _ in range(n + 1)] fixed = [False for _ in range(n + 1)] cost[start] = 0 fixed[start] = True t...
false
9.52381
[ "-def dijkstra(graph, start, end):", "+def dijkstra(graph, start):", "- if tmp_sta == end:", "- return tmp_min", "+ if tmp_min == 1000 * 100:", "+ return cost", "+cost2d = [[]]", "+for i in range(1, n + 1):", "+ cost2d.append(dijkstra(graph, i))", "- if c[...
false
0.045108
0.045444
0.992608
[ "s857972277", "s213895071" ]
u374146618
p03012
python
s304112658
s168223643
20
18
3,060
3,188
Accepted
Accepted
10
N = int(eval(input())) W = [int(x) for x in input().split()] dif = [] for T in range(N): S1 = sum(W[:T]) S2 = sum(W[T:]) dif.append(abs(S1-S2)) print((min(dif)))
import itertools N = int(eval(input())) W = [int(x) for x in input().split()] accum_W = list(itertools.accumulate(W)) sm = accum_W[-1] ans = min(abs(sm - 2*x) for x in accum_W) print(ans)
10
10
176
193
N = int(eval(input())) W = [int(x) for x in input().split()] dif = [] for T in range(N): S1 = sum(W[:T]) S2 = sum(W[T:]) dif.append(abs(S1 - S2)) print((min(dif)))
import itertools N = int(eval(input())) W = [int(x) for x in input().split()] accum_W = list(itertools.accumulate(W)) sm = accum_W[-1] ans = min(abs(sm - 2 * x) for x in accum_W) print(ans)
false
0
[ "+import itertools", "+", "-dif = []", "-for T in range(N):", "- S1 = sum(W[:T])", "- S2 = sum(W[T:])", "- dif.append(abs(S1 - S2))", "-print((min(dif)))", "+accum_W = list(itertools.accumulate(W))", "+sm = accum_W[-1]", "+ans = min(abs(sm - 2 * x) for x in accum_W)", "+print(ans)" ]
false
0.047392
0.28155
0.168326
[ "s304112658", "s168223643" ]
u200887663
p02725
python
s357736040
s321096572
183
122
26,444
26,444
Accepted
Accepted
33.33
#n=int(input()) k,n=list(map(int,input().split())) al=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] mn=min(al) mx=max(al) dis=[] for i in range(n-1): dis.append(al[i+1]-al[i]) dis.append(mn+(k-mx)) dis.sort(reverse=False) ans=0 for i in range(n-1): ans+=di...
#n=int(input()) k,n=list(map(int,input().split())) al=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] difl=[] for i in range(n-1): difl.append(al[i+1]-al[i]) difl.append(al[0]+k-al[n-1]) print((k-max(difl)))
17
12
331
254
# n=int(input()) k, n = list(map(int, input().split())) al = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] mn = min(al) mx = max(al) dis = [] for i in range(n - 1): dis.append(al[i + 1] - al[i]) dis.append(mn + (k - mx)) dis.sort(reverse=False) ans = 0 for i in range(n - 1):...
# n=int(input()) k, n = list(map(int, input().split())) al = list(map(int, input().split())) # l=[list(map(int,input().split())) for i in range(n)] difl = [] for i in range(n - 1): difl.append(al[i + 1] - al[i]) difl.append(al[0] + k - al[n - 1]) print((k - max(difl)))
false
29.411765
[ "-mn = min(al)", "-mx = max(al)", "-dis = []", "+difl = []", "- dis.append(al[i + 1] - al[i])", "-dis.append(mn + (k - mx))", "-dis.sort(reverse=False)", "-ans = 0", "-for i in range(n - 1):", "- ans += dis[i]", "-print(ans)", "+ difl.append(al[i + 1] - al[i])", "+difl.append(al[0] ...
false
0.04241
0.041723
1.016461
[ "s357736040", "s321096572" ]
u699296734
p03835
python
s159543938
s423998375
984
600
9,060
9,176
Accepted
Accepted
39.02
k, s = list(map(int, input().split())) counter = 0 for x in range(k + 1): for y in range(k + 1): if 0 <= s - x - y <= k: counter += 1 print(counter)
k, s = list(map(int, input().split())) counter = 0 for x in range(k + 1): for y in range(x, k + 1): z = s - x - y if y <= z <= k: if x == y == z: counter += 1 elif x == y or y == z: counter += 3 else: coun...
8
14
175
341
k, s = list(map(int, input().split())) counter = 0 for x in range(k + 1): for y in range(k + 1): if 0 <= s - x - y <= k: counter += 1 print(counter)
k, s = list(map(int, input().split())) counter = 0 for x in range(k + 1): for y in range(x, k + 1): z = s - x - y if y <= z <= k: if x == y == z: counter += 1 elif x == y or y == z: counter += 3 else: counter += 6 pr...
false
42.857143
[ "- for y in range(k + 1):", "- if 0 <= s - x - y <= k:", "- counter += 1", "+ for y in range(x, k + 1):", "+ z = s - x - y", "+ if y <= z <= k:", "+ if x == y == z:", "+ counter += 1", "+ elif x == y or y == z:", "+ ...
false
0.031407
0.035897
0.874909
[ "s159543938", "s423998375" ]
u923279197
p03125
python
s048217916
s782957954
165
17
38,384
2,940
Accepted
Accepted
89.7
a,b = list(map(int,input().split())) if b%a == 0: print((b+a)) else: print((b-a))
a,b = list(map(int,input().split())) if b%a==0:print((a+b)) else:print((b-a))
5
3
83
69
a, b = list(map(int, input().split())) if b % a == 0: print((b + a)) else: print((b - a))
a, b = list(map(int, input().split())) if b % a == 0: print((a + b)) else: print((b - a))
false
40
[ "- print((b + a))", "+ print((a + b))" ]
false
0.042919
0.035365
1.213587
[ "s048217916", "s782957954" ]
u130900604
p02580
python
s609669745
s731837480
952
580
85,748
174,512
Accepted
Accepted
39.08
from collections import* h,w,m=list(map(int,input().split())) d=defaultdict(int) a=[0]*h b=[0]*w for _ in range(m): x,y=list(map(int,input().split())) x-=1 y-=1 a[x]+=1 b[y]+=1 d[(x,y)]+=1 ma=max(a) mb=max(b) ind_x=[i for i,j in enumerate(a) if j==ma] ind_y=[i for i,j in enumerate(b) if j...
from collections import* h,w,m=list(map(int,input().split())) d=defaultdict(int) a=[0]*h b=[0]*w for _ in range(m): x,y=list(map(int,input().split())) x-=1 y-=1 a[x]+=1 b[y]+=1 d[x*10**6+y]+=1 ma=max(a) mb=max(b) ind_x=[i for i,j in enumerate(a) if j==ma] ind_y=[i for i,j in enumerate(b) ...
26
26
425
433
from collections import * h, w, m = list(map(int, input().split())) d = defaultdict(int) a = [0] * h b = [0] * w for _ in range(m): x, y = list(map(int, input().split())) x -= 1 y -= 1 a[x] += 1 b[y] += 1 d[(x, y)] += 1 ma = max(a) mb = max(b) ind_x = [i for i, j in enumerate(a) if j == ma] ind...
from collections import * h, w, m = list(map(int, input().split())) d = defaultdict(int) a = [0] * h b = [0] * w for _ in range(m): x, y = list(map(int, input().split())) x -= 1 y -= 1 a[x] += 1 b[y] += 1 d[x * 10**6 + y] += 1 ma = max(a) mb = max(b) ind_x = [i for i, j in enumerate(a) if j == ...
false
0
[ "- d[(x, y)] += 1", "+ d[x * 10**6 + y] += 1", "- if d[(x, y)] == 0:", "+ if d[x * 10**6 + y] == 0:" ]
false
0.036383
0.036794
0.988846
[ "s609669745", "s731837480" ]
u867848444
p02792
python
s218677327
s589142661
227
168
3,316
9,256
Accepted
Accepted
25.99
from collections import defaultdict n = eval(input()) first_n = n[0] finish_n = n[-1] digit = len(n) cnt = defaultdict(lambda :0) for i in range(1,int(n) + 1): temp = str(i) temp_tuple = (int(temp[0]), int(temp[-1])) cnt[temp_tuple] += 1 ans = 0 for i in range(1, 10): for j in range(1, 1...
n = int(eval(input())) hort = [[0] * 9 for i in range(9)] #hort[i][j] := i~j for i in range(1, n + 1): temp = str(i) if temp[0] == '0' or temp[-1] == '0':continue hort[int(temp[0]) - 1][int(temp[-1]) - 1] += 1 res = 0 for i in range(9): for j in range(9): if i != j: tem...
18
20
384
514
from collections import defaultdict n = eval(input()) first_n = n[0] finish_n = n[-1] digit = len(n) cnt = defaultdict(lambda: 0) for i in range(1, int(n) + 1): temp = str(i) temp_tuple = (int(temp[0]), int(temp[-1])) cnt[temp_tuple] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): an...
n = int(eval(input())) hort = [[0] * 9 for i in range(9)] # hort[i][j] := i~j for i in range(1, n + 1): temp = str(i) if temp[0] == "0" or temp[-1] == "0": continue hort[int(temp[0]) - 1][int(temp[-1]) - 1] += 1 res = 0 for i in range(9): for j in range(9): if i != j: temp = ...
false
10
[ "-from collections import defaultdict", "-", "-n = eval(input())", "-first_n = n[0]", "-finish_n = n[-1]", "-digit = len(n)", "-cnt = defaultdict(lambda: 0)", "-for i in range(1, int(n) + 1):", "+n = int(eval(input()))", "+hort = [[0] * 9 for i in range(9)]", "+# hort[i][j] := i~j", "+for i in...
false
0.157591
0.279105
0.564628
[ "s218677327", "s589142661" ]
u923668099
p02317
python
s339008050
s231143023
290
190
12,536
12,464
Accepted
Accepted
34.48
import sys from bisect import bisect_left def solve(): n = int(input()) A = [int(input()) for i in range(n)] inf = 10**9 + 1 dp = [inf] * n for a in A: j = bisect_left(dp, a) dp[j] = a for i, v in enumerate(dp): if v == inf: print(i) ...
from sys import stdin from bisect import bisect_left def solve(): n = int(stdin.readline()) A = [int(stdin.readline()) for i in range(n)] inf = 10**9 + 1 dp = [inf] * n for a in A: j = bisect_left(dp, a) dp[j] = a for i, v in enumerate(dp): if v == inf:...
29
29
572
601
import sys from bisect import bisect_left def solve(): n = int(input()) A = [int(input()) for i in range(n)] inf = 10**9 + 1 dp = [inf] * n for a in A: j = bisect_left(dp, a) dp[j] = a for i, v in enumerate(dp): if v == inf: print(i) return p...
from sys import stdin from bisect import bisect_left def solve(): n = int(stdin.readline()) A = [int(stdin.readline()) for i in range(n)] inf = 10**9 + 1 dp = [inf] * n for a in A: j = bisect_left(dp, a) dp[j] = a for i, v in enumerate(dp): if v == inf: prin...
false
0
[ "-import sys", "+from sys import stdin", "- n = int(input())", "- A = [int(input()) for i in range(n)]", "+ n = int(stdin.readline())", "+ A = [int(stdin.readline()) for i in range(n)]" ]
false
0.068947
0.046713
1.47595
[ "s339008050", "s231143023" ]
u237362582
p03033
python
s548386470
s290226716
1,713
1,144
54,024
54,020
Accepted
Accepted
33.22
from bisect import bisect_left from operator import itemgetter N, Q = list(map(int, input().split(" "))) check_points = [tuple(map(int, input().split(" "))) for _ in range(N)] querys = [int(eval(input())) for _ in range(Q)] time = [-1] * Q jump = [-1] * Q check_points = sorted(check_points, key=itemgetter(2)) ...
from bisect import bisect_left from operator import itemgetter import sys input = sys.stdin.readline N, Q = list(map(int, input().split(" "))) check_points = [tuple(map(int, input().split(" "))) for _ in range(N)] querys = [int(eval(input())) for _ in range(Q)] time = [-1] * Q jump = [-1] * Q check_points ...
27
30
694
736
from bisect import bisect_left from operator import itemgetter N, Q = list(map(int, input().split(" "))) check_points = [tuple(map(int, input().split(" "))) for _ in range(N)] querys = [int(eval(input())) for _ in range(Q)] time = [-1] * Q jump = [-1] * Q check_points = sorted(check_points, key=itemgetter(2)) b_left =...
from bisect import bisect_left from operator import itemgetter import sys input = sys.stdin.readline N, Q = list(map(int, input().split(" "))) check_points = [tuple(map(int, input().split(" "))) for _ in range(N)] querys = [int(eval(input())) for _ in range(Q)] time = [-1] * Q jump = [-1] * Q check_points = sorted(che...
false
10
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.051896
0.036888
1.406856
[ "s548386470", "s290226716" ]