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
u146816547
p00009
python
s923367253
s351592258
860
550
61,684
75,976
Accepted
Accepted
36.05
era = [True]*1000001 for i in range(2, 1000001): if era[i-2]: for j in range(i*2, 1000001, i): era[j-2] = False while True: try: n = int(input()) print(era[:n-1].count(True)) except EOFError: break
IsPrimes = [True] * 1000002 IsPrimes[0], IsPrimes[1] = False, False for i in range(2, 1001): if IsPrimes[i]: for j in range(i*i, 1000001, i): IsPrimes[j]= False cnt = [0] * 1000001 for i in range(1000001): if IsPrimes[i]: cnt[i] += 1 for i in range(1, 1000001): ...
14
25
244
458
era = [True] * 1000001 for i in range(2, 1000001): if era[i - 2]: for j in range(i * 2, 1000001, i): era[j - 2] = False while True: try: n = int(input()) print(era[: n - 1].count(True)) except EOFError: break
IsPrimes = [True] * 1000002 IsPrimes[0], IsPrimes[1] = False, False for i in range(2, 1001): if IsPrimes[i]: for j in range(i * i, 1000001, i): IsPrimes[j] = False cnt = [0] * 1000001 for i in range(1000001): if IsPrimes[i]: cnt[i] += 1 for i in range(1, 1000001): cnt[i] += cnt[i...
false
44
[ "-era = [True] * 1000001", "-for i in range(2, 1000001):", "- if era[i - 2]:", "- for j in range(i * 2, 1000001, i):", "- era[j - 2] = False", "+IsPrimes = [True] * 1000002", "+IsPrimes[0], IsPrimes[1] = False, False", "+for i in range(2, 1001):", "+ if IsPrimes[i]:", "+ ...
false
1.054801
1.411396
0.747346
[ "s923367253", "s351592258" ]
u904331908
p02947
python
s199202335
s062214302
519
252
32,216
28,228
Accepted
Accepted
51.45
import itertools,math n = int(eval(input())) word = [eval(input()) for _ in range(n)] count = 0 def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) for i in range(n): word[i] = sorted(word[i]) new_word = list(sorted(word)) x = 1 for i in rang...
#他の人の回答 import collections N = int(eval(input())) s = ["".join(sorted(eval(input()))) for _ in range(N)] #sortedでリストになった文字列をjoinでもう一度文字列に c = collections.Counter(s) #cは辞書の形をとる ans = 0 # sから重複を無くす for si in set(s): n = c[si] ans += n * (n - 1) // 2 # n C 2を計算 print(ans)
25
16
511
288
import itertools, math n = int(eval(input())) word = [eval(input()) for _ in range(n)] count = 0 def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) for i in range(n): word[i] = sorted(word[i]) new_word = list(sorted(word)) x = 1 for i in range(n - 1): ...
# 他の人の回答 import collections N = int(eval(input())) s = ["".join(sorted(eval(input()))) for _ in range(N)] # sortedでリストになった文字列をjoinでもう一度文字列に c = collections.Counter(s) # cは辞書の形をとる ans = 0 # sから重複を無くす for si in set(s): n = c[si] ans += n * (n - 1) // 2 # n C 2を計算 print(ans)
false
36
[ "-import itertools, math", "+# 他の人の回答", "+import collections", "-n = int(eval(input()))", "-word = [eval(input()) for _ in range(n)]", "-count = 0", "-", "-", "-def combinations_count(n, r):", "- return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))", "-", "-", "-for i i...
false
0.086759
0.034206
2.536399
[ "s199202335", "s062214302" ]
u078042885
p00254
python
s009066415
s599691416
310
230
7,672
7,600
Accepted
Accepted
25.81
while 1: n,c=eval(input()),0 if int(n)==0:break if n.count(n[0])==4: print('NA') continue while n!='6174': n = str(int(''.join(reversed(sorted(list(n))))) - int(''.join(sorted(list(n))))).zfill(4) c+=1 print(c)
while 1: n,c=eval(input()),0 if int(n)==0:break if n.count(n[0])==4: print('NA') continue while n!='6174': n=''.join(sorted(n)) n = str(int(n[::-1]) - int(n)).zfill(4) c+=1 print(c)
10
11
265
245
while 1: n, c = eval(input()), 0 if int(n) == 0: break if n.count(n[0]) == 4: print("NA") continue while n != "6174": n = str( int("".join(reversed(sorted(list(n))))) - int("".join(sorted(list(n)))) ).zfill(4) c += 1 print(c)
while 1: n, c = eval(input()), 0 if int(n) == 0: break if n.count(n[0]) == 4: print("NA") continue while n != "6174": n = "".join(sorted(n)) n = str(int(n[::-1]) - int(n)).zfill(4) c += 1 print(c)
false
9.090909
[ "- n = str(", "- int(\"\".join(reversed(sorted(list(n))))) - int(\"\".join(sorted(list(n))))", "- ).zfill(4)", "+ n = \"\".join(sorted(n))", "+ n = str(int(n[::-1]) - int(n)).zfill(4)" ]
false
0.036869
0.035496
1.038699
[ "s009066415", "s599691416" ]
u909514237
p02580
python
s793398297
s190053262
1,046
579
83,332
176,548
Accepted
Accepted
44.65
H,W,M = list(map(int, input().split())) hs = [0] * H ws = [0] * W s = set() for i in range(M): h,w = list(map(int, input().split())) h -= 1 w -= 1 hs[h] += 1 ws[w] += 1 s.add((h,w)) mh = 0 mw = 0 for i in range(H): mh = max(mh, hs[i]) for j in range(W): mw = max(mw, ws[j]) l_s...
H,W,M = list(map(int, input().split())) hs = [0] * H ws = [0] * W s = set() for i in range(M): h,w = list(map(int, input().split())) h -= 1 w -= 1 hs[h] += 1 ws[w] += 1 s.add((h,w)) mh = 0 mw = 0 for i in range(H): mh = max(mh, hs[i]) for j in range(W): mw = max(mw, ws[j]) i_s...
39
38
584
586
H, W, M = list(map(int, input().split())) hs = [0] * H ws = [0] * W s = set() for i in range(M): h, w = list(map(int, input().split())) h -= 1 w -= 1 hs[h] += 1 ws[w] += 1 s.add((h, w)) mh = 0 mw = 0 for i in range(H): mh = max(mh, hs[i]) for j in range(W): mw = max(mw, ws[j]) l_s = list...
H, W, M = list(map(int, input().split())) hs = [0] * H ws = [0] * W s = set() for i in range(M): h, w = list(map(int, input().split())) h -= 1 w -= 1 hs[h] += 1 ws[w] += 1 s.add((h, w)) mh = 0 mw = 0 for i in range(H): mh = max(mh, hs[i]) for j in range(W): mw = max(mw, ws[j]) i_s = list...
false
2.564103
[ "-l_s = list()", "+i_s = list()", "- if mh == hs[i]:", "- l_s.append(i)", "+ if hs[i] == mh:", "+ i_s.append(i)", "- if mw == ws[j]:", "+ if ws[j] == mw:", "-for i in l_s:", "+for i in i_s:" ]
false
0.06663
0.074092
0.899278
[ "s793398297", "s190053262" ]
u554954744
p03645
python
s836359269
s441094154
1,089
1,001
87,244
66,508
Accepted
Accepted
8.08
N, M = list(map(int, input().split())) s = [[] for i in range(N+1)] e = [[] for i in range(N+1)] for i in range(M): a, b = list(map(int, input().split())) s[a].append(b) e[b].append(a) for i in s[1]: if N in s[i]: print('POSSIBLE') exit() print('IMPOSSIBLE')
N, M = list(map(int, input().split())) s = [[] for i in range(N+1)] for i in range(M): a, b = list(map(int, input().split())) s[a].append(b) for i in s[1]: if N in s[i]: print('POSSIBLE') exit() print('IMPOSSIBLE')
14
12
293
243
N, M = list(map(int, input().split())) s = [[] for i in range(N + 1)] e = [[] for i in range(N + 1)] for i in range(M): a, b = list(map(int, input().split())) s[a].append(b) e[b].append(a) for i in s[1]: if N in s[i]: print("POSSIBLE") exit() print("IMPOSSIBLE")
N, M = list(map(int, input().split())) s = [[] for i in range(N + 1)] for i in range(M): a, b = list(map(int, input().split())) s[a].append(b) for i in s[1]: if N in s[i]: print("POSSIBLE") exit() print("IMPOSSIBLE")
false
14.285714
[ "-e = [[] for i in range(N + 1)]", "- e[b].append(a)" ]
false
0.084128
0.161246
0.521738
[ "s836359269", "s441094154" ]
u347640436
p02820
python
s974795020
s873927245
146
79
4,212
3,956
Accepted
Accepted
45.89
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) hands = [None] * N d1 = {'r': 'p', 's': 'r', 'p': 's'} d2 = {'r': P, 's': R, 'p': S} result = 0 for i in range(len(T)): if i >= K and d1[T[i]] == hands[i - K]: if i + K < N: hands[i] = ...
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) draws = [True] * K d = {'r': P, 's': R, 'p': S} result = 0 for i in range(len(T)): if draws[i % K] or T[i] != T[i - K]: result += d[T[i]] draws[i % K] = False else: draws[i % K...
18
14
485
326
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) hands = [None] * N d1 = {"r": "p", "s": "r", "p": "s"} d2 = {"r": P, "s": R, "p": S} result = 0 for i in range(len(T)): if i >= K and d1[T[i]] == hands[i - K]: if i + K < N: hands[i] = list(set("rp...
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) T = eval(input()) draws = [True] * K d = {"r": P, "s": R, "p": S} result = 0 for i in range(len(T)): if draws[i % K] or T[i] != T[i - K]: result += d[T[i]] draws[i % K] = False else: draws[i % K] = True prin...
false
22.222222
[ "-hands = [None] * N", "-d1 = {\"r\": \"p\", \"s\": \"r\", \"p\": \"s\"}", "-d2 = {\"r\": P, \"s\": R, \"p\": S}", "+draws = [True] * K", "+d = {\"r\": P, \"s\": R, \"p\": S}", "- if i >= K and d1[T[i]] == hands[i - K]:", "- if i + K < N:", "- hands[i] = list(set(\"rps\") - set(d1...
false
0.054787
0.038471
1.424102
[ "s974795020", "s873927245" ]
u562935282
p03325
python
s612381376
s947931652
90
60
4,212
3,828
Accepted
Accepted
33.33
N = int(eval(input())) a = tuple(map(int, input().split())) ans = 0 for aa in a: while aa % 2 == 0: aa //= 2 ans += 1 print(ans)
def main(): def count(x): ret = 0 while x % 2 == 0: x //= 2 ret += 1 return ret N = int(eval(input())) a = list(map(int, input().split())) ans = sum(map(count, a)) print(ans) if __name__ == '__main__': main() # import sys # in...
9
24
152
426
N = int(eval(input())) a = tuple(map(int, input().split())) ans = 0 for aa in a: while aa % 2 == 0: aa //= 2 ans += 1 print(ans)
def main(): def count(x): ret = 0 while x % 2 == 0: x //= 2 ret += 1 return ret N = int(eval(input())) a = list(map(int, input().split())) ans = sum(map(count, a)) print(ans) if __name__ == "__main__": main() # import sys # input = sys.stdin.rea...
false
62.5
[ "-N = int(eval(input()))", "-a = tuple(map(int, input().split()))", "-ans = 0", "-for aa in a:", "- while aa % 2 == 0:", "- aa //= 2", "- ans += 1", "-print(ans)", "+def main():", "+ def count(x):", "+ ret = 0", "+ while x % 2 == 0:", "+ x //= 2",...
false
0.154638
0.04918
3.144347
[ "s612381376", "s947931652" ]
u449473917
p03835
python
s336322953
s663469309
1,767
267
3,060
40,684
Accepted
Accepted
84.89
K,S=input().split() K=int(K) S=int(S) ans=0 for l in range(K+1): for m in range(K+1): if l+m<=S and l+m+K>=S: ans=ans+1 print(ans)
k,s=list(map(int,input().split())) ans=0 for i in range(k+1): for j in range(k+1): z=s-(i+j) if z>=0 and z<=k: ans+=1 print(ans)
9
11
162
167
K, S = input().split() K = int(K) S = int(S) ans = 0 for l in range(K + 1): for m in range(K + 1): if l + m <= S and l + m + K >= S: ans = ans + 1 print(ans)
k, s = list(map(int, input().split())) ans = 0 for i in range(k + 1): for j in range(k + 1): z = s - (i + j) if z >= 0 and z <= k: ans += 1 print(ans)
false
18.181818
[ "-K, S = input().split()", "-K = int(K)", "-S = int(S)", "+k, s = list(map(int, input().split()))", "-for l in range(K + 1):", "- for m in range(K + 1):", "- if l + m <= S and l + m + K >= S:", "- ans = ans + 1", "+for i in range(k + 1):", "+ for j in range(k + 1):", "+ ...
false
0.040111
0.04116
0.974527
[ "s336322953", "s663469309" ]
u124498235
p03633
python
s048852116
s924243770
41
37
5,432
5,048
Accepted
Accepted
9.76
from fractions import gcd def lcm(a,b): return (a*b) // gcd(a,b) n = int(eval(input())) y = 1 for i in range(n): x = int(eval(input())) y = lcm(x,y) print (y)
from fractions import gcd n = int(eval(input())) t = [int(eval(input())) for i in range(n)] def lcm(x, y): return (x*y) // gcd(x,y) x = t[0] for i in t[1:]: x = lcm(i,x) print (x)
9
11
157
181
from fractions import gcd def lcm(a, b): return (a * b) // gcd(a, b) n = int(eval(input())) y = 1 for i in range(n): x = int(eval(input())) y = lcm(x, y) print(y)
from fractions import gcd n = int(eval(input())) t = [int(eval(input())) for i in range(n)] def lcm(x, y): return (x * y) // gcd(x, y) x = t[0] for i in t[1:]: x = lcm(i, x) print(x)
false
18.181818
[ "-", "-def lcm(a, b):", "- return (a * b) // gcd(a, b)", "+n = int(eval(input()))", "+t = [int(eval(input())) for i in range(n)]", "-n = int(eval(input()))", "-y = 1", "-for i in range(n):", "- x = int(eval(input()))", "- y = lcm(x, y)", "-print(y)", "+def lcm(x, y):", "+ return ...
false
0.043812
0.044888
0.976014
[ "s048852116", "s924243770" ]
u359372421
p02390
python
s272751790
s500590808
30
20
6,452
5,584
Accepted
Accepted
33.33
def conv(sec): h = sec // (60 * 60) m = (sec - h * (60 * 60)) // 60 s = sec - m * 60 - h * (60 * 60) return ":".join([str(h), str(m), str(s)]) # inp = list(map(int, input().split())) print((conv(int(eval(input())))))
x = int(eval(input())) s = x % 60 x //= 60 m = x % 60 x //= 60 print(("{}:{}:{}".format(x, m, s)))
8
6
233
96
def conv(sec): h = sec // (60 * 60) m = (sec - h * (60 * 60)) // 60 s = sec - m * 60 - h * (60 * 60) return ":".join([str(h), str(m), str(s)]) # inp = list(map(int, input().split())) print((conv(int(eval(input())))))
x = int(eval(input())) s = x % 60 x //= 60 m = x % 60 x //= 60 print(("{}:{}:{}".format(x, m, s)))
false
25
[ "-def conv(sec):", "- h = sec // (60 * 60)", "- m = (sec - h * (60 * 60)) // 60", "- s = sec - m * 60 - h * (60 * 60)", "- return \":\".join([str(h), str(m), str(s)])", "-", "-", "-# inp = list(map(int, input().split()))", "-print((conv(int(eval(input())))))", "+x = int(eval(input()))"...
false
0.057812
0.034973
1.653023
[ "s272751790", "s500590808" ]
u621643202
p03449
python
s465104232
s557042669
20
18
3,064
3,064
Accepted
Accepted
10
N = int(eval(input())) A1, A2 = [input().split() for _ in range(2)] ans = 0 sum = 0 for n in range(0, N): for i in range(0, n + 1): #print('i=', i) sum += int(A1[i]) for j in range(n, N): #print('j=', j) sum += int(A2[j]) if ans < sum: ans = sum sum...
N = int(eval(input())) A1, A2 = [list(map(int, input().split())) for _ in range(2)] ans = 0 sum = 0 for n in range(0, N): for i in range(0, n + 1): sum += A1[i] for j in range(n, N): sum += A2[j] if ans < sum: ans = sum sum = 0 print(ans)
17
15
332
288
N = int(eval(input())) A1, A2 = [input().split() for _ in range(2)] ans = 0 sum = 0 for n in range(0, N): for i in range(0, n + 1): # print('i=', i) sum += int(A1[i]) for j in range(n, N): # print('j=', j) sum += int(A2[j]) if ans < sum: ans = sum sum = 0 print(an...
N = int(eval(input())) A1, A2 = [list(map(int, input().split())) for _ in range(2)] ans = 0 sum = 0 for n in range(0, N): for i in range(0, n + 1): sum += A1[i] for j in range(n, N): sum += A2[j] if ans < sum: ans = sum sum = 0 print(ans)
false
11.764706
[ "-A1, A2 = [input().split() for _ in range(2)]", "+A1, A2 = [list(map(int, input().split())) for _ in range(2)]", "- # print('i=', i)", "- sum += int(A1[i])", "+ sum += A1[i]", "- # print('j=', j)", "- sum += int(A2[j])", "+ sum += A2[j]" ]
false
0.046101
0.045113
1.021907
[ "s465104232", "s557042669" ]
u753803401
p02948
python
s193804488
s014176209
932
810
75,740
75,484
Accepted
Accepted
13.09
def slove(): import sys import heapq input = sys.stdin.readline n, m = list(map(int, input().rstrip('\n').split())) ls =[] v = [] heapq.heapify(v) for i in range(n): a, b = list(map(int, input().rstrip('\n').split())) ls.append([a, b]) ls.sort(reverse=True)...
import sys import heapq def solve(): input = sys.stdin.readline mod = 10 ** 9 + 7 n, m = list(map(int, input().rstrip('\n').split())) ab = [list(map(int, input().rstrip('\n').split())) for _ in range(n)] ab.sort(reverse=True) ls = [] heapq.heapify(ls) t = 0 for i in ra...
31
29
769
689
def slove(): import sys import heapq input = sys.stdin.readline n, m = list(map(int, input().rstrip("\n").split())) ls = [] v = [] heapq.heapify(v) for i in range(n): a, b = list(map(int, input().rstrip("\n").split())) ls.append([a, b]) ls.sort(reverse=True) r = ...
import sys import heapq def solve(): input = sys.stdin.readline mod = 10**9 + 7 n, m = list(map(int, input().rstrip("\n").split())) ab = [list(map(int, input().rstrip("\n").split())) for _ in range(n)] ab.sort(reverse=True) ls = [] heapq.heapify(ls) t = 0 for i in range(1, m + 1): ...
false
6.451613
[ "-def slove():", "- import sys", "- import heapq", "+import sys", "+import heapq", "+", "+def solve():", "+ mod = 10**9 + 7", "+ ab = [list(map(int, input().rstrip(\"\\n\").split())) for _ in range(n)]", "+ ab.sort(reverse=True)", "- v = []", "- heapq.heapify(v)", "- ...
false
0.035049
0.037255
0.940773
[ "s193804488", "s014176209" ]
u094999522
p02585
python
s250815370
s605856484
1,650
522
68,764
28,036
Accepted
Accepted
68.36
#import sys #import numpy as np def main(n,k,p,c): ans = -10**9 for i in range(n): x = i t = k count = 0 l = True sub = 0 ln = 0 while True: x = p[x] - 1 if l: count += c[x] ln +=...
import sys import numpy as np def main(n,k,p,c): ans = -10**9 for i in range(n): x = i t = k count = 0 l = True sub = 0 ln = 0 while True: x = p[x] - 1 if l: count += c[x] ln += 1...
47
47
1,121
1,136
# import sys # import numpy as np def main(n, k, p, c): ans = -(10**9) for i in range(n): x = i t = k count = 0 l = True sub = 0 ln = 0 while True: x = p[x] - 1 if l: count += c[x] ln += 1 ...
import sys import numpy as np def main(n, k, p, c): ans = -(10**9) for i in range(n): x = i t = k count = 0 l = True sub = 0 ln = 0 while True: x = p[x] - 1 if l: count += c[x] ln += 1 ...
false
0
[ "-# import sys", "-# import numpy as np", "+import sys", "+import numpy as np", "+", "+", "-# if sys.argv[-1]=='ONLINE_JUDGE':", "-# from numba.pycc import CC", "-# cc=CC('my_module')", "-# cc.export('main','i8(i8,i8,i8[:],i8[:])')(main)", "-# cc.compile()", "-# exit()", "-# from my_mod...
false
0.118003
0.505734
0.233331
[ "s250815370", "s605856484" ]
u735008991
p03835
python
s692852463
s459274626
887
257
52,760
40,684
Accepted
Accepted
71.03
K, S = list(map(int, input().split())) print(([0 <= S - x - y <= K for x in range(K+1) for y in range(K+1)].count(True)))
K, S = list(map(int, input().split())) ans = 0 for x in range(K+1): for y in range(K+1): ans += 0 <= S - x - y <= K print(ans)
3
6
123
138
K, S = list(map(int, input().split())) print(([0 <= S - x - y <= K for x in range(K + 1) for y in range(K + 1)].count(True)))
K, S = list(map(int, input().split())) ans = 0 for x in range(K + 1): for y in range(K + 1): ans += 0 <= S - x - y <= K print(ans)
false
50
[ "-print(([0 <= S - x - y <= K for x in range(K + 1) for y in range(K + 1)].count(True)))", "+ans = 0", "+for x in range(K + 1):", "+ for y in range(K + 1):", "+ ans += 0 <= S - x - y <= K", "+print(ans)" ]
false
0.117096
0.044349
2.640352
[ "s692852463", "s459274626" ]
u694810977
p02837
python
s575873008
s739488769
729
658
3,188
3,064
Accepted
Accepted
9.74
#入力はn人のx,yに分けないといけない n = int(eval(input())) a = [] x = [[] for i in range(n)] y = [[] for i in range(n)] for i in range(n): a.append(int(eval(input()))) for j in range(a[i]): xx, yy = (int(i) for i in input().split()) x[i].append(xx) y[i].append(yy) testimony = [[2]*n for i ...
n = int(eval(input())) #2**n通りの正直者を全列挙してそれを矛盾が生じないか試していき最大値を求める 競合してる証言をピック True or False で判断する jud = [[-1 for i in range(n)] for j in range(n)] xy = [] ayasi = [] for i in range(n): a = int(eval(input())) for j in range(a): x,y = list(map(int,input().split())) jud[i][x-1] = y Max = 0 ...
42
32
1,216
764
# 入力はn人のx,yに分けないといけない n = int(eval(input())) a = [] x = [[] for i in range(n)] y = [[] for i in range(n)] for i in range(n): a.append(int(eval(input()))) for j in range(a[i]): xx, yy = (int(i) for i in input().split()) x[i].append(xx) y[i].append(yy) testimony = [[2] * n for i in range(n...
n = int(eval(input())) # 2**n通りの正直者を全列挙してそれを矛盾が生じないか試していき最大値を求める 競合してる証言をピック True or False で判断する jud = [[-1 for i in range(n)] for j in range(n)] xy = [] ayasi = [] for i in range(n): a = int(eval(input())) for j in range(a): x, y = list(map(int, input().split())) jud[i][x - 1] = y Max = 0 for i...
false
23.809524
[ "-# 入力はn人のx,yに分けないといけない", "-a = []", "-x = [[] for i in range(n)]", "-y = [[] for i in range(n)]", "+# 2**n通りの正直者を全列挙してそれを矛盾が生じないか試していき最大値を求める 競合してる証言をピック True or False で判断する", "+jud = [[-1 for i in range(n)] for j in range(n)]", "+xy = []", "+ayasi = []", "- a.append(int(eval(input())))", "- ...
false
0.046798
0.048062
0.973697
[ "s575873008", "s739488769" ]
u272028993
p03695
python
s853385241
s080981140
11
10
2,696
2,568
Accepted
Accepted
9.09
n=int(input()) a=list(map(int,input().split())) c=[0]*8 mx=0 for i in range(n): if 1<=a[i]<400: c[0]=1 elif 400<=a[i]<800: c[1]=1 elif 800<=a[i]<1200: c[2]=1 elif 1200<=a[i]<1600: c[3]=1 elif 1600<=a[i]<2000: c[4]=1 elif 2000<=a[i]<2400: ...
n=int(input()) a=list(map(int,input().split())) c=[0]*8 mx=0 for i in range(n): if a[i]/400<=7: c[a[i]/400]=1 else: mx+=1 print(max(1,sum(c)),sum(c)+mx)
24
10
478
187
n = int(input()) a = list(map(int, input().split())) c = [0] * 8 mx = 0 for i in range(n): if 1 <= a[i] < 400: c[0] = 1 elif 400 <= a[i] < 800: c[1] = 1 elif 800 <= a[i] < 1200: c[2] = 1 elif 1200 <= a[i] < 1600: c[3] = 1 elif 1600 <= a[i] < 2000: c[4] = 1 ...
n = int(input()) a = list(map(int, input().split())) c = [0] * 8 mx = 0 for i in range(n): if a[i] / 400 <= 7: c[a[i] / 400] = 1 else: mx += 1 print(max(1, sum(c)), sum(c) + mx)
false
58.333333
[ "- if 1 <= a[i] < 400:", "- c[0] = 1", "- elif 400 <= a[i] < 800:", "- c[1] = 1", "- elif 800 <= a[i] < 1200:", "- c[2] = 1", "- elif 1200 <= a[i] < 1600:", "- c[3] = 1", "- elif 1600 <= a[i] < 2000:", "- c[4] = 1", "- elif 2000 <= a[i] < 2400...
false
0.037538
0.036326
1.03334
[ "s853385241", "s080981140" ]
u328510800
p03160
python
s550464225
s299309932
186
172
15,032
13,976
Accepted
Accepted
7.53
n = int(eval(input())) dp = [10 ** 9 for _ in range(n + 2)] # ちょっと大きめに dp[0] = 0 h = [int(x) for x in input().split()] for i in range(1, n): total_cost = dp[i-1] + abs(h[i] - h[i-1]) dp[i] = min(dp[i], total_cost) if i > 1: total_cost = dp[i-2] + abs(h[i] - h[i - 2]) dp[i] = min(dp[i], total_...
n = int(eval(input())) h = list(map(int, input().split())) dp = [10 ** 9 for _ in range(n+1)] # スタート位置 dp[0] = 0 for i in range(n): dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1])) if i > 1: dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i-2])) print((dp[n-1]))
14
13
339
281
n = int(eval(input())) dp = [10**9 for _ in range(n + 2)] # ちょっと大きめに dp[0] = 0 h = [int(x) for x in input().split()] for i in range(1, n): total_cost = dp[i - 1] + abs(h[i] - h[i - 1]) dp[i] = min(dp[i], total_cost) if i > 1: total_cost = dp[i - 2] + abs(h[i] - h[i - 2]) dp[i] = min(dp[i], ...
n = int(eval(input())) h = list(map(int, input().split())) dp = [10**9 for _ in range(n + 1)] # スタート位置 dp[0] = 0 for i in range(n): dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])) if i > 1: dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[n - 1]))
false
7.142857
[ "-dp = [10**9 for _ in range(n + 2)] # ちょっと大きめに", "+h = list(map(int, input().split()))", "+dp = [10**9 for _ in range(n + 1)]", "+# スタート位置", "-h = [int(x) for x in input().split()]", "-for i in range(1, n):", "- total_cost = dp[i - 1] + abs(h[i] - h[i - 1])", "- dp[i] = min(dp[i], total_cost)"...
false
0.044018
0.044299
0.993664
[ "s550464225", "s299309932" ]
u241159583
p02989
python
s666485943
s240528946
75
66
14,428
20,728
Accepted
Accepted
12
N = int(eval(input())) d = list(map(int, input().split())) d.sort() n = N // 2 -1 print((d[n+1] - d[n]))
n = int(eval(input())) d = sorted(list(map(int, input().split()))) l,r = d[n//2-1], d[n//2] print((r-l))
5
4
100
99
N = int(eval(input())) d = list(map(int, input().split())) d.sort() n = N // 2 - 1 print((d[n + 1] - d[n]))
n = int(eval(input())) d = sorted(list(map(int, input().split()))) l, r = d[n // 2 - 1], d[n // 2] print((r - l))
false
20
[ "-N = int(eval(input()))", "-d = list(map(int, input().split()))", "-d.sort()", "-n = N // 2 - 1", "-print((d[n + 1] - d[n]))", "+n = int(eval(input()))", "+d = sorted(list(map(int, input().split())))", "+l, r = d[n // 2 - 1], d[n // 2]", "+print((r - l))" ]
false
0.076907
0.048425
1.588157
[ "s666485943", "s240528946" ]
u102461423
p02822
python
s201587178
s703064523
1,422
1,127
67,464
84,744
Accepted
Accepted
20.75
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int,read().split())) AB = list(zip(m,m)) MOD = 10 ** 9 + 7 graph = [[] for _ in range(N+1)] for a,b in AB: graph[a].append(b) graph[b].append(a) ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int,read().split())) AB = list(zip(m,m)) MOD = 10 ** 9 + 7 graph = [[] for _ in range(N+1)] for a,b in AB: graph[a].append(b) graph[b].append(a) ...
60
58
1,232
1,180
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int, read().split())) AB = list(zip(m, m)) MOD = 10**9 + 7 graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) root = 1 paren...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) m = list(map(int, read().split())) AB = list(zip(m, m)) MOD = 10**9 + 7 graph = [[] for _ in range(N + 1)] for a, b in AB: graph[a].append(b) graph[b].append(a) root = 1 paren...
false
3.333333
[ "+p_size = [N - 1] * (N + 1)", "+prod = [1] * (N + 1)", "+coef = [1] * (N + 1)", "- size[p] += size[v]", "- A = [size[w] for w in graph[v] if w != p] # 部分木のサイズ集合", "- if v != root:", "- A.append(N - 1 - sum(A))", "- if len(A) == 1:", "- continue", "- prod = 1", "- ...
false
0.044086
0.043646
1.010089
[ "s201587178", "s703064523" ]
u498487134
p02803
python
s502066516
s898699395
802
690
42,864
54,116
Accepted
Accepted
13.97
H,W=list(map(int,input().split())) S=[[] for _ in range(H)] for i in range(H): S[i]=eval(input()) def warshall_floyd(d): #d[i][j]: iからjへの最短距離 for k in range(n): for i in range(n): for j in range(n): d[i][j] = min(d[i][j],d[i][k] + d[k][j]) return d ...
import queue H,W=list(map(int,input().split())) S=[[] for _ in range(H)] dx=[0,0,-1,1] dy=[-1,1,0,0] for i in range(H): S[i]=eval(input()) def bfs(i,j): max_d=0 q=queue.Queue() q.put((i,j)) d=[[0]*W for _ in range(H)] while not q.empty(): loc=q.get() for k i...
44
36
979
816
H, W = list(map(int, input().split())) S = [[] for _ in range(H)] for i in range(H): S[i] = eval(input()) def warshall_floyd(d): # d[i][j]: iからjへの最短距離 for k in range(n): for i in range(n): for j in range(n): d[i][j] = min(d[i][j], d[i][k] + d[k][j]) return d n = H...
import queue H, W = list(map(int, input().split())) S = [[] for _ in range(H)] dx = [0, 0, -1, 1] dy = [-1, 1, 0, 0] for i in range(H): S[i] = eval(input()) def bfs(i, j): max_d = 0 q = queue.Queue() q.put((i, j)) d = [[0] * W for _ in range(H)] while not q.empty(): loc = q.get() ...
false
18.181818
[ "+import queue", "+", "+dx = [0, 0, -1, 1]", "+dy = [-1, 1, 0, 0]", "-def warshall_floyd(d):", "- # d[i][j]: iからjへの最短距離", "- for k in range(n):", "- for i in range(n):", "- for j in range(n):", "- d[i][j] = min(d[i][j], d[i][k] + d[k][j])", "- return d",...
false
0.038243
0.048885
0.782303
[ "s502066516", "s898699395" ]
u123756661
p02880
python
s816399771
s789528996
184
63
38,384
61,884
Accepted
Accepted
65.76
n=int(eval(input())) for i in range(1,10): for j in range(1,i+1): if n==i*j: print("Yes") exit() print("No")
n=int(eval(input())) d=set([i*j for i in range(1,10) for j in range(1,10)]) print(("Yes" if n in d else "No"))
7
3
144
104
n = int(eval(input())) for i in range(1, 10): for j in range(1, i + 1): if n == i * j: print("Yes") exit() print("No")
n = int(eval(input())) d = set([i * j for i in range(1, 10) for j in range(1, 10)]) print(("Yes" if n in d else "No"))
false
57.142857
[ "-for i in range(1, 10):", "- for j in range(1, i + 1):", "- if n == i * j:", "- print(\"Yes\")", "- exit()", "-print(\"No\")", "+d = set([i * j for i in range(1, 10) for j in range(1, 10)])", "+print((\"Yes\" if n in d else \"No\"))" ]
false
0.04579
0.104993
0.436123
[ "s816399771", "s789528996" ]
u361826811
p02911
python
s396001059
s011847019
92
65
12,392
11,624
Accepted
Accepted
29.35
""" author : halo2halo date : 4, Feb, 2020 """ import sys # import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K, Q, *A = map(int, read().split()) point =[K-Q]*(N+1) for i in A: point[i] += 1 print(*['Yes' if i > 0 else...
""" author : halo2halo date : 4, Feb, 2020 """ import sys # import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K, Q, *A = list(map(int, read().split())) point = [K - Q] * (N + 1) for i in A: point[i] += 1 ans = '\n'.j...
18
20
357
375
""" author : halo2halo date : 4, Feb, 2020 """ import sys # import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K, Q, *A = map(int, read().split()) point = [K - Q] * (N + 1) for i in A: point[i] += 1 print(*["Yes" if i > 0 else "No" for i i...
""" author : halo2halo date : 4, Feb, 2020 """ import sys # import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, K, Q, *A = list(map(int, read().split())) point = [K - Q] * (N + 1) for i in A: point[i] += 1 ans = "\n".join("Yes" if i > 0 els...
false
10
[ "-N, K, Q, *A = map(int, read().split())", "+N, K, Q, *A = list(map(int, read().split()))", "-print(*[\"Yes\" if i > 0 else \"No\" for i in point[1:]], sep=\"\\n\")", "+ans = \"\\n\".join(\"Yes\" if i > 0 else \"No\" for i in point[1:])", "+print(ans)" ]
false
0.038786
0.041789
0.928126
[ "s396001059", "s011847019" ]
u879870653
p03000
python
s477798484
s528735585
166
18
38,256
2,940
Accepted
Accepted
89.16
N,X = list(map(int,input().split())) L = list(map(int,input().split())) ans = 1 d = 0 for i in range(len(L)) : d += L[i] if d <= X : ans += 1 print(ans)
N,X = list(map(int,input().split())) L = list(map(int,input().split())) ans = 1 d = 0 for i in range(N) : d += L[i] if d > X : break ans += 1 print(ans)
11
14
174
188
N, X = list(map(int, input().split())) L = list(map(int, input().split())) ans = 1 d = 0 for i in range(len(L)): d += L[i] if d <= X: ans += 1 print(ans)
N, X = list(map(int, input().split())) L = list(map(int, input().split())) ans = 1 d = 0 for i in range(N): d += L[i] if d > X: break ans += 1 print(ans)
false
21.428571
[ "-for i in range(len(L)):", "+for i in range(N):", "- if d <= X:", "- ans += 1", "+ if d > X:", "+ break", "+ ans += 1" ]
false
0.040051
0.03803
1.053147
[ "s477798484", "s528735585" ]
u401452016
p03031
python
s786699302
s539471220
40
32
3,064
3,316
Accepted
Accepted
20
#ABC 128C def main(): import sys N, M = list(map(int, sys.stdin.readline().split())) Light = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)] P = list(map(int, sys.stdin.readline().split())) #print(Light) #print(P) ans = 0 for i in range(2**N): cnt = [0...
#ABC 128C def main(): import sys import itertools as ite N, M = list(map(int, sys.stdin.readline().split())) Light = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)] P = list(map(int, sys.stdin.readline().split())) S = list(ite.product([0,1], repeat=N)) #スイッチの状態 ans ...
21
21
579
656
# ABC 128C def main(): import sys N, M = list(map(int, sys.stdin.readline().split())) Light = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)] P = list(map(int, sys.stdin.readline().split())) # print(Light) # print(P) ans = 0 for i in range(2**N): cnt = [0 for _...
# ABC 128C def main(): import sys import itertools as ite N, M = list(map(int, sys.stdin.readline().split())) Light = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)] P = list(map(int, sys.stdin.readline().split())) S = list(ite.product([0, 1], repeat=N)) # スイッチの状態 ans = 0...
false
0
[ "+ import itertools as ite", "- # print(Light)", "- # print(P)", "+ S = list(ite.product([0, 1], repeat=N)) # スイッチの状態", "- for i in range(2**N):", "- cnt = [0 for _ in range(M)]", "+ for s_state in S:", "+ L_result = [0 for _ in range(M)]", "- for s in Lig...
false
0.035654
0.043472
0.82016
[ "s786699302", "s539471220" ]
u785989355
p03608
python
s064928904
s129027357
715
530
10,084
62,808
Accepted
Accepted
25.87
N,M,R = list(map(int,input().split())) r = list(map(int,input().split())) e_list = [[] for i in range(N)] for i in range(M): a,b,c = list(map(int,input().split())) a=a-1 b=b-1 e_list[a].append([b,c]) e_list[b].append([a,c]) #dijkstra #you need to prepare e_list = [[orient,dist]] imp...
N,M,R = list(map(int,input().split())) r = list(map(int,input().split())) e_list = [[] for i in range(N)] for i in range(M): a,b,c = list(map(int,input().split())) e_list[a-1].append((b-1,c)) e_list[b-1].append((a-1,c)) #dijkstra #you need to prepare e_list = [[orient,dist]] import heap...
45
51
1,123
1,092
N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) e_list = [[] for i in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) a = a - 1 b = b - 1 e_list[a].append([b, c]) e_list[b].append([a, c]) # dijkstra # you need to prepare e_list = [[orient,dist]] i...
N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) e_list = [[] for i in range(N)] for i in range(M): a, b, c = list(map(int, input().split())) e_list[a - 1].append((b - 1, c)) e_list[b - 1].append((a - 1, c)) # dijkstra # you need to prepare e_list = [[orient,dist]] import heapq ...
false
11.764706
[ "- a = a - 1", "- b = b - 1", "- e_list[a].append([b, c])", "- e_list[b].append([a, c])", "+ e_list[a - 1].append((b - 1, c))", "+ e_list[b - 1].append((a - 1, c))", "-r_dis_list = []", "-for i in range(len(r)):", "- vi = r[i] - 1", "+", "+def dijkstra(vi):", "- prev_li...
false
0.040755
0.038978
1.045587
[ "s064928904", "s129027357" ]
u279955105
p02397
python
s434025940
s422133633
80
50
7,628
7,660
Accepted
Accepted
37.5
while True: a,b = list(map(int, input().split())) if (a == 0) and (b == 0): break elif (a < b): print((str(a) + " " + str(b))) else : print((str(b) + " " + str(a)))
while True: a,b = list(map(int, input().split())) if (a == 0 and b == 0): break else: if (a < b): print((str(a) + " " + str(b))) else : print((str(b) +" "+ str(a)))
8
12
177
191
while True: a, b = list(map(int, input().split())) if (a == 0) and (b == 0): break elif a < b: print((str(a) + " " + str(b))) else: print((str(b) + " " + str(a)))
while True: a, b = list(map(int, input().split())) if a == 0 and b == 0: break else: if a < b: print((str(a) + " " + str(b))) else: print((str(b) + " " + str(a)))
false
33.333333
[ "- if (a == 0) and (b == 0):", "+ if a == 0 and b == 0:", "- elif a < b:", "- print((str(a) + \" \" + str(b)))", "- print((str(b) + \" \" + str(a)))", "+ if a < b:", "+ print((str(a) + \" \" + str(b)))", "+ else:", "+ print((str(b) + \" \" +...
false
0.043832
0.068086
0.643773
[ "s434025940", "s422133633" ]
u670180528
p03830
python
s132274343
s761506447
25
19
3,060
2,940
Accepted
Accepted
24
n=int(eval(input()));a=1;r=range for x in[i for i in r(2,n+1)if all(i%j for j in r(2,i))]:a*=sum(n//x**i for i in r(1,11))+1 print((a%(10**9+7)))
n=int(eval(input()));a=1;r=range for x in[i for i in r(2,n+1)if all(i%j for j in r(2,int(i**.5)+1))]:a*=sum(n//x**i for i in r(1,11))+1;a%=10**9+7 print(a)
3
3
139
151
n = int(eval(input())) a = 1 r = range for x in [i for i in r(2, n + 1) if all(i % j for j in r(2, i))]: a *= sum(n // x**i for i in r(1, 11)) + 1 print((a % (10**9 + 7)))
n = int(eval(input())) a = 1 r = range for x in [i for i in r(2, n + 1) if all(i % j for j in r(2, int(i**0.5) + 1))]: a *= sum(n // x**i for i in r(1, 11)) + 1 a %= 10**9 + 7 print(a)
false
0
[ "-for x in [i for i in r(2, n + 1) if all(i % j for j in r(2, i))]:", "+for x in [i for i in r(2, n + 1) if all(i % j for j in r(2, int(i**0.5) + 1))]:", "-print((a % (10**9 + 7)))", "+ a %= 10**9 + 7", "+print(a)" ]
false
0.045508
0.045765
0.994379
[ "s132274343", "s761506447" ]
u284854859
p03765
python
s371310171
s753493054
635
559
26,052
27,840
Accepted
Accepted
11.97
import sys input = sys.stdin.readline s = list(eval(input())) t = list(eval(input())) snum = [(0,0)] #snum[j]-snum[i-1]:i-j文字目に含まれる(A,B)の数 for i in range(len(s)): if s[i] == 'A': snum.append((snum[-1][0]+1,snum[-1][1])) else: snum.append((snum[-1][0],snum[-1][1]+1)) tnum = [(0,0)] ...
import sys input = sys.stdin.readline s = list(eval(input())) t = list(eval(input())) snum = [(0,0)] #snum[j]-snum[i-1]:i-j文字目に含まれる(A,B)の数 for i in range(len(s)): if s[i] == 'A': snum.append((snum[-1][0]+1,snum[-1][1])) else: snum.append((snum[-1][0],snum[-1][1]+1)) tnum = [(0,0)] ...
44
42
1,010
944
import sys input = sys.stdin.readline s = list(eval(input())) t = list(eval(input())) snum = [(0, 0)] # snum[j]-snum[i-1]:i-j文字目に含まれる(A,B)の数 for i in range(len(s)): if s[i] == "A": snum.append((snum[-1][0] + 1, snum[-1][1])) else: snum.append((snum[-1][0], snum[-1][1] + 1)) tnum = [(0, 0)] for...
import sys input = sys.stdin.readline s = list(eval(input())) t = list(eval(input())) snum = [(0, 0)] # snum[j]-snum[i-1]:i-j文字目に含まれる(A,B)の数 for i in range(len(s)): if s[i] == "A": snum.append((snum[-1][0] + 1, snum[-1][1])) else: snum.append((snum[-1][0], snum[-1][1] + 1)) tnum = [(0, 0)] for...
false
4.545455
[ "- b1 += max(tb - b1, 0) // 3 * 3 + 3", "- a1 = (b1 - tb) * 2", "- if abs(a1 - ta) % 3 == 0:", "+ b2 = tb + ta * 2", "+ if abs(b2 - b1) % 3 == 0:", "- a2 = sa + sb * 2", "- a2 += max(ta - a2, 0) // 3 * 3 + 3", "- b2 = (a2 - ta) * 2", "- if abs(b2 - tb) % 3 == 0:", "+ ...
false
0.037156
0.03719
0.999078
[ "s371310171", "s753493054" ]
u078932560
p03162
python
s663596561
s717007222
600
429
22,900
3,060
Accepted
Accepted
28.5
N = int(eval(input())) dp = [[0] * 3 for _ in range(N)] dp[0][0], dp[0][1], dp[0][2] = list(map(int, input().split())) for i in range(1,N): abc = list(map(int, input().split())) for j,k,l in ((0,1,2), (1,0,2), (2, 0, 1)): dp[i][j] = abc[j] + max(dp[i-1][k], dp[i-1][l]) print((max(dp[N-1])))
N = int(eval(input())) x, y, z = list(map(int, input().split())) for _ in range(N-1): a, b, c = list(map(int, input().split())) x, y, z = a + max(y, z), b + max(x, z), c + max(x, y) print((max(x,y,z)))
10
8
302
206
N = int(eval(input())) dp = [[0] * 3 for _ in range(N)] dp[0][0], dp[0][1], dp[0][2] = list(map(int, input().split())) for i in range(1, N): abc = list(map(int, input().split())) for j, k, l in ((0, 1, 2), (1, 0, 2), (2, 0, 1)): dp[i][j] = abc[j] + max(dp[i - 1][k], dp[i - 1][l]) print((max(dp[N - 1])))...
N = int(eval(input())) x, y, z = list(map(int, input().split())) for _ in range(N - 1): a, b, c = list(map(int, input().split())) x, y, z = a + max(y, z), b + max(x, z), c + max(x, y) print((max(x, y, z)))
false
20
[ "-dp = [[0] * 3 for _ in range(N)]", "-dp[0][0], dp[0][1], dp[0][2] = list(map(int, input().split()))", "-for i in range(1, N):", "- abc = list(map(int, input().split()))", "- for j, k, l in ((0, 1, 2), (1, 0, 2), (2, 0, 1)):", "- dp[i][j] = abc[j] + max(dp[i - 1][k], dp[i - 1][l])", "-prin...
false
0.036652
0.036401
1.006905
[ "s663596561", "s717007222" ]
u961945062
p02994
python
s350049653
s281772026
31
28
9,084
9,072
Accepted
Accepted
9.68
N, L = list(map(int, input().split())) ans = 0 min = L for i in range(1, N+1): a = L+i-1 ans += a if abs(a) < abs(min): min = a ans -= min print(ans)
N, L = list(map(int, input().split())) v = [L+i for i in range(N)] ans = sum(v) - min(v, key=abs) print(ans)
12
4
176
106
N, L = list(map(int, input().split())) ans = 0 min = L for i in range(1, N + 1): a = L + i - 1 ans += a if abs(a) < abs(min): min = a ans -= min print(ans)
N, L = list(map(int, input().split())) v = [L + i for i in range(N)] ans = sum(v) - min(v, key=abs) print(ans)
false
66.666667
[ "-ans = 0", "-min = L", "-for i in range(1, N + 1):", "- a = L + i - 1", "- ans += a", "- if abs(a) < abs(min):", "- min = a", "-ans -= min", "+v = [L + i for i in range(N)]", "+ans = sum(v) - min(v, key=abs)" ]
false
0.049306
0.046989
1.049315
[ "s350049653", "s281772026" ]
u186838327
p03715
python
s578025808
s740211253
263
113
43,100
73,788
Accepted
Accepted
57.03
h, w = list(map(int, input().split())) if h%3 == 0 or w%3 == 0: print((0)) exit() #print(h, w) min_ = float('inf') for i in range(1, h): s1 = w*i s2 = (h-i)*(w//2) s3 = (h-i)*(w-w//2) d = max([s1, s2, s3]) - min([s1, s2, s3]) #print(i, s1, s2, s3, d) min_ = min(min_, d) ...
h, w = list(map(int, input().split())) ans = 10**18 for i in range(1, h): S1 = i*w # tate if h-i >= 2: p = (h-i)//2 q = h-(h-i)//2-i S2 = p*w S3 = q*w M = max([S1, S2, S3]) m = min([S1, S2, S3]) ans = min(ans, M-m) #if i == 1: ...
39
40
845
876
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) exit() # print(h, w) min_ = float("inf") for i in range(1, h): s1 = w * i s2 = (h - i) * (w // 2) s3 = (h - i) * (w - w // 2) d = max([s1, s2, s3]) - min([s1, s2, s3]) # print(i, s1, s2, s3, d) min_ = min(min_...
h, w = list(map(int, input().split())) ans = 10**18 for i in range(1, h): S1 = i * w # tate if h - i >= 2: p = (h - i) // 2 q = h - (h - i) // 2 - i S2 = p * w S3 = q * w M = max([S1, S2, S3]) m = min([S1, S2, S3]) ans = min(ans, M - m) # if i ...
false
2.5
[ "-if h % 3 == 0 or w % 3 == 0:", "- print((0))", "- exit()", "-# print(h, w)", "-min_ = float(\"inf\")", "+ans = 10**18", "- s1 = w * i", "- s2 = (h - i) * (w // 2)", "- s3 = (h - i) * (w - w // 2)", "- d = max([s1, s2, s3]) - min([s1, s2, s3])", "- # print(i, s1, s2, s3, d)...
false
0.088093
0.10191
0.864414
[ "s578025808", "s740211253" ]
u062147869
p03223
python
s092601875
s819260723
689
521
59,224
52,952
Accepted
Accepted
24.38
from collections import deque N=int(eval(input())) A=[] for i in range(N): s=int(eval(input())) A.append(s) A.sort() H=deque() H.append(A[0]) s=1 t=N-1 i=0 while t-s!=-1: x=A[s] y=A[t] a=abs(H[0]-x) b=abs(H[-1]-x) c=abs(H[0]-y) d=abs(H[-1]-y) e=max(a,b,c,d) if...
import sys N=int(eval(input())) A=[int(eval(input())) for i in range(N)] B=sorted(A) if N%2==0: C=B[:(N//2)] D=B[(N//2):] print((2*sum(D)-2*sum(C)+C[-1]-D[0])) sys.exit() C=B[:(N//2)] D=B[((N//2)+1):] s=B[(N//2)] print((max(2*sum(D)-2*sum(C)+C[-1]-s,2*sum(D)-2*sum(C)+s-D[0])))
36
13
573
289
from collections import deque N = int(eval(input())) A = [] for i in range(N): s = int(eval(input())) A.append(s) A.sort() H = deque() H.append(A[0]) s = 1 t = N - 1 i = 0 while t - s != -1: x = A[s] y = A[t] a = abs(H[0] - x) b = abs(H[-1] - x) c = abs(H[0] - y) d = abs(H[-1] - y) ...
import sys N = int(eval(input())) A = [int(eval(input())) for i in range(N)] B = sorted(A) if N % 2 == 0: C = B[: (N // 2)] D = B[(N // 2) :] print((2 * sum(D) - 2 * sum(C) + C[-1] - D[0])) sys.exit() C = B[: (N // 2)] D = B[((N // 2) + 1) :] s = B[(N // 2)] print((max(2 * sum(D) - 2 * sum(C) + C[-1] -...
false
63.888889
[ "-from collections import deque", "+import sys", "-A = []", "-for i in range(N):", "- s = int(eval(input()))", "- A.append(s)", "-A.sort()", "-H = deque()", "-H.append(A[0])", "-s = 1", "-t = N - 1", "-i = 0", "-while t - s != -1:", "- x = A[s]", "- y = A[t]", "- a = abs...
false
0.03941
0.041219
0.956105
[ "s092601875", "s819260723" ]
u755116850
p03739
python
s746234668
s779724462
110
91
20,440
19,980
Accepted
Accepted
17.27
n = int(eval(input())) a = list(map(int, input().split(" "))) res1 = 0 sum = 0 # sei, hu, sei, hu.... # guu, ki, guu, ki for i in range(n): sum += a[i] if sum <= 0 and i%2 == 0: res1 += abs(sum) + 1 sum = 1 elif sum >= 0 and i%2 == 1: res1 += abs(sum) + 1 ...
n = int(eval(input())) a = list(map(int, input().split(" "))) def solve(s1, s2): "if start == true, assume the first of the sum is positive." res = 0 sum = 0 for i in range(n): sum += a[i] if sum <= 0 and i % 2 == s1: res += abs(sum) + 1 sum = 1 ...
36
21
651
465
n = int(eval(input())) a = list(map(int, input().split(" "))) res1 = 0 sum = 0 # sei, hu, sei, hu.... # guu, ki, guu, ki for i in range(n): sum += a[i] if sum <= 0 and i % 2 == 0: res1 += abs(sum) + 1 sum = 1 elif sum >= 0 and i % 2 == 1: res1 += abs(sum) + 1 sum = -1 # h...
n = int(eval(input())) a = list(map(int, input().split(" "))) def solve(s1, s2): "if start == true, assume the first of the sum is positive." res = 0 sum = 0 for i in range(n): sum += a[i] if sum <= 0 and i % 2 == s1: res += abs(sum) + 1 sum = 1 elif sum...
false
41.666667
[ "-res1 = 0", "-sum = 0", "-# sei, hu, sei, hu....", "-# guu, ki, guu, ki", "-for i in range(n):", "- sum += a[i]", "- if sum <= 0 and i % 2 == 0:", "- res1 += abs(sum) + 1", "- sum = 1", "- elif sum >= 0 and i % 2 == 1:", "- res1 += abs(sum) + 1", "- sum = ...
false
0.056615
0.078978
0.716836
[ "s746234668", "s779724462" ]
u588341295
p02868
python
s756646139
s279482592
1,010
530
83,036
68,000
Accepted
Accepted
47.52
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in range(b)] for i in ra...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in range(b)] for i in ra...
111
64
2,845
1,740
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in rang...
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in rang...
false
42.342342
[ "-class SegTree:", "- \"\"\"", "- セグメント木", "- 1.update: i番目の値をxに更新する", "- 2.query: 区間[l, r)の値を得る", "- \"\"\"", "+def dijkstra(N: int, nodes: list, src: int) -> list:", "+ \"\"\"ダイクストラ高速化版(頂点数, 隣接リスト(0-indexed), 始点)\"\"\"", "+ from heapq import heappush, heappop", "- def __...
false
0.045971
0.045852
1.002606
[ "s756646139", "s279482592" ]
u562935282
p03141
python
s246371542
s667868643
453
394
21,376
21,308
Accepted
Accepted
13.02
N = int(eval(input())) e = [tuple(map(int, input().split())) for _ in range(N)] e.sort(key=lambda x: x[0] + x[1], reverse=True) ans = 0 for i in range(N): if i % 2 == 0: ans += e[i][0] else: ans -= e[i][1] print(ans)
n = int(eval(input())) ab = [tuple(map(int, input().split())) for _ in range(n)] ab.sort(key=lambda x: sum(x), reverse=True) s = sum(a for a, _ in ab) s -= sum(sum(dish) for dish in ab[1::2]) print(s)
11
6
245
200
N = int(eval(input())) e = [tuple(map(int, input().split())) for _ in range(N)] e.sort(key=lambda x: x[0] + x[1], reverse=True) ans = 0 for i in range(N): if i % 2 == 0: ans += e[i][0] else: ans -= e[i][1] print(ans)
n = int(eval(input())) ab = [tuple(map(int, input().split())) for _ in range(n)] ab.sort(key=lambda x: sum(x), reverse=True) s = sum(a for a, _ in ab) s -= sum(sum(dish) for dish in ab[1::2]) print(s)
false
45.454545
[ "-N = int(eval(input()))", "-e = [tuple(map(int, input().split())) for _ in range(N)]", "-e.sort(key=lambda x: x[0] + x[1], reverse=True)", "-ans = 0", "-for i in range(N):", "- if i % 2 == 0:", "- ans += e[i][0]", "- else:", "- ans -= e[i][1]", "-print(ans)", "+n = int(eval(...
false
0.042186
0.040699
1.036531
[ "s246371542", "s667868643" ]
u854962015
p02820
python
s015063897
s226829930
162
70
10,580
9,968
Accepted
Accepted
56.79
N,K=list(map(int,input().split())) R,S,P=list(map(int,input().split())) L=eval(input()) T=[] for i in range(N): T.append(L[i]) for i in range(K,N): if T[i]==T[i-K]: T[i]="0" T=str(T) p=0 for i in T: if i=="r": p+=P elif i=="s": p+=R elif i=="p": p+=S ...
N,K=list(map(int,input().split())) R,S,P=list(map(int,input().split())) L=eval(input()) T=[] for i in range(N): T.append(L[i]) for i in range(K,N): if T[i]==T[i-K]: T[i]="0" p=0 for i in T: if i=="r": p+=P elif i=="s": p+=R elif i=="p": p+=S print(p)
19
18
311
301
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) L = eval(input()) T = [] for i in range(N): T.append(L[i]) for i in range(K, N): if T[i] == T[i - K]: T[i] = "0" T = str(T) p = 0 for i in T: if i == "r": p += P elif i == "s": p += R elif i == "...
N, K = list(map(int, input().split())) R, S, P = list(map(int, input().split())) L = eval(input()) T = [] for i in range(N): T.append(L[i]) for i in range(K, N): if T[i] == T[i - K]: T[i] = "0" p = 0 for i in T: if i == "r": p += P elif i == "s": p += R elif i == "p": ...
false
5.263158
[ "-T = str(T)" ]
false
0.048045
0.047578
1.00982
[ "s015063897", "s226829930" ]
u733814820
p03103
python
s196952748
s706071772
467
407
20,072
20,072
Accepted
Accepted
12.85
def resolve(): n, m = list(map(int, input().split())) l = [] for i in range(n): a, b = list(map(int, input().split())) l.append([a, b]) l.sort() ans = 0 for ab in l: if ab[1] < m: m -= ab[1] ans += ab[0] * ab[1] else: ans += ab[0] * m m = 0 break ...
def resolve(): n, m = list(map(int, input().split())) arr = [] for i in range(n): a, b = list(map(int, input().split())) arr.append([a, b]) arr.sort() ans = 0 for ab in arr: if ab[1] >= m: ans += m * ab[0] break else: ans += ab[0] * ab[1] m -= ab[1] p...
21
21
375
373
def resolve(): n, m = list(map(int, input().split())) l = [] for i in range(n): a, b = list(map(int, input().split())) l.append([a, b]) l.sort() ans = 0 for ab in l: if ab[1] < m: m -= ab[1] ans += ab[0] * ab[1] else: ans += ab[...
def resolve(): n, m = list(map(int, input().split())) arr = [] for i in range(n): a, b = list(map(int, input().split())) arr.append([a, b]) arr.sort() ans = 0 for ab in arr: if ab[1] >= m: ans += m * ab[0] break else: ans += ab[...
false
0
[ "- l = []", "+ arr = []", "- l.append([a, b])", "- l.sort()", "+ arr.append([a, b])", "+ arr.sort()", "- for ab in l:", "- if ab[1] < m:", "+ for ab in arr:", "+ if ab[1] >= m:", "+ ans += m * ab[0]", "+ break", "+ el...
false
0.040555
0.040465
1.002233
[ "s196952748", "s706071772" ]
u827202523
p02917
python
s671481679
s832329475
172
70
38,256
65,588
Accepted
Accepted
59.3
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) from collections import deque def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math n = getN() INF = 100000000000 nums = [INF] + getList() + [INF] ans = 0 for i, j in zip(nums, n...
import sys from collections import defaultdict, deque import math # import copy # from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda: ...
19
64
362
1,102
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) from collections import deque def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math n = getN() INF = 100000000000 nums = [INF] + getList() + [INF] ans = 0 for i, j in zip(nums, nums[1:]...
import sys from collections import defaultdict, deque import math # import copy # from bisect import bisect_left, bisect_right # import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda: list(map(int, inpu...
false
70.3125
[ "+from collections import defaultdict, deque", "+import math", "+# import copy", "+# from bisect import bisect_left, bisect_right", "+# import heapq", "+# sys.setrecursionlimit(1000000)", "+# input aliases", "-sys.setrecursionlimit(1000000)", "-from collections import deque", "+getS = lambda: inpu...
false
0.034728
0.034617
1.003184
[ "s671481679", "s832329475" ]
u293523199
p04031
python
s364306197
s963345499
25
22
3,064
3,060
Accepted
Accepted
12
N = int(eval(input())) A = list(map(int, input().split())) total_costs = {} if( len(set(A)) == 1 ): print((0)) else: for i in range(-100, 101): cost = 0 for a in A: cost += (a - i)**2 total_costs[i] = cost print((min(total_costs.values())))
N = int(eval(input())) A = list(map(int, input().split())) total_costs = {} if( len(set(A)) == 1 ): print((0)) else: for i in range(-100, 101): cost = 0 for a in A: cost += (a - i)*(a - i) total_costs[i] = cost print((min(total_costs.values())))
13
13
291
296
N = int(eval(input())) A = list(map(int, input().split())) total_costs = {} if len(set(A)) == 1: print((0)) else: for i in range(-100, 101): cost = 0 for a in A: cost += (a - i) ** 2 total_costs[i] = cost print((min(total_costs.values())))
N = int(eval(input())) A = list(map(int, input().split())) total_costs = {} if len(set(A)) == 1: print((0)) else: for i in range(-100, 101): cost = 0 for a in A: cost += (a - i) * (a - i) total_costs[i] = cost print((min(total_costs.values())))
false
0
[ "- cost += (a - i) ** 2", "+ cost += (a - i) * (a - i)" ]
false
0.041754
0.038058
1.097112
[ "s364306197", "s963345499" ]
u215315599
p03160
python
s946163119
s785487062
852
229
23,076
52,856
Accepted
Accepted
73.12
import numpy as np n = int(eval(input())) h = [int(i) for i in input().split()] dp = [1000000000]*n dp[0]=0 dp[1]=np.abs(h[1]-h[0]) for i in range(1,n-1): dp[i+1] = min(dp[i+1],dp[i]+np.abs(h[i]-h[i+1])) dp[i+1] = min(dp[i+1],dp[i-1]+np.abs(h[i-1]-h[i+1])) print((dp[n-1]))
def cost(a,b): return abs(a-b) INF = 10**9 N = int(eval(input())) H = list(map(int,input().split())) #dp[i][0]:V_iに行かない #dp[i][1]:V_iに行く dp = [ INF for __ in range(N)] dp[0] = 0 dp[1] = abs(H[1]-H[0]) for i in range(2,N): dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2])) print((dp[N-1...
10
14
286
315
import numpy as np n = int(eval(input())) h = [int(i) for i in input().split()] dp = [1000000000] * n dp[0] = 0 dp[1] = np.abs(h[1] - h[0]) for i in range(1, n - 1): dp[i + 1] = min(dp[i + 1], dp[i] + np.abs(h[i] - h[i + 1])) dp[i + 1] = min(dp[i + 1], dp[i - 1] + np.abs(h[i - 1] - h[i + 1])) print((dp[n - 1])...
def cost(a, b): return abs(a - b) INF = 10**9 N = int(eval(input())) H = list(map(int, input().split())) # dp[i][0]:V_iに行かない # dp[i][1]:V_iに行く dp = [INF for __ in range(N)] dp[0] = 0 dp[1] = abs(H[1] - H[0]) for i in range(2, N): dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2])) ...
false
28.571429
[ "-import numpy as np", "+def cost(a, b):", "+ return abs(a - b)", "-n = int(eval(input()))", "-h = [int(i) for i in input().split()]", "-dp = [1000000000] * n", "+", "+INF = 10**9", "+N = int(eval(input()))", "+H = list(map(int, input().split()))", "+# dp[i][0]:V_iに行かない", "+# dp[i][1]:V_iに行...
false
0.578304
0.043449
13.309922
[ "s946163119", "s785487062" ]
u193264896
p02972
python
s205769550
s301869680
195
175
17,696
17,192
Accepted
Accepted
10.26
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) INF = float('inf') MOD = 10**9+7 def main(): N = int(readline()) A = [None] + list(map(int, readline().split())) ans = [] choosen = [0] * (N+1) f...
import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): N = int(readline()) A = [0] + list(map(int, readline().split())) B = [0] * (N+1) ans = [] for i in range(N,0,-1): x = sum(B[i::i]) if x%2==A[i...
27
26
542
508
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): N = int(readline()) A = [None] + list(map(int, readline().split())) ans = [] choosen = [0] * (N + 1) for ...
import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): N = int(readline()) A = [0] + list(map(int, readline().split())) B = [0] * (N + 1) ans = [] for i in range(N, 0, -1): x = sum(B[i::i]) if x % 2 == A[i]: ...
false
3.703704
[ "-read = sys.stdin.buffer.read", "-readlines = sys.stdin.buffer.readlines", "- A = [None] + list(map(int, readline().split()))", "+ A = [0] + list(map(int, readline().split()))", "+ B = [0] * (N + 1)", "- choosen = [0] * (N + 1)", "- for n in range(N, 0, -1):", "- x = sum(choosen...
false
0.04256
0.040268
1.056918
[ "s205769550", "s301869680" ]
u411203878
p03424
python
s401867272
s018475660
165
71
38,256
61,596
Accepted
Accepted
56.97
n=int(eval(input())) t = input().split() count = [] memo = 0 for i in t: if i in count: continue count.append(i) memo += 1 if memo == 3: print('Three') else: print('Four')
n = int(eval(input())) s = list(map(str,input().split())) if "Y" in s: print("Four") else: print("Three")
14
8
207
116
n = int(eval(input())) t = input().split() count = [] memo = 0 for i in t: if i in count: continue count.append(i) memo += 1 if memo == 3: print("Three") else: print("Four")
n = int(eval(input())) s = list(map(str, input().split())) if "Y" in s: print("Four") else: print("Three")
false
42.857143
[ "-t = input().split()", "-count = []", "-memo = 0", "-for i in t:", "- if i in count:", "- continue", "- count.append(i)", "- memo += 1", "-if memo == 3:", "+s = list(map(str, input().split()))", "+if \"Y\" in s:", "+ print(\"Four\")", "+else:", "-else:", "- print(\...
false
0.056798
0.036639
1.550215
[ "s401867272", "s018475660" ]
u606045429
p02775
python
s589513841
s802414782
788
577
5,492
5,492
Accepted
Accepted
26.78
S = list(map(int, eval(input()))) a, b = 0, 1 for s in S: a, b = a + s if a + s < b + 10 - s else b + 10 - s, a + (s + 1) if a + (s + 1) < b + 10 - (s + 1) else b + 10 - (s + 1) print(a)
def main(): S = list(map(int, eval(input()))) a, b = 0, 1 for s in S: a, b = a + s if a + s < b + 10 - s else b + 10 - s, a + (s + 1) if a + (s + 1) < b + 10 - (s + 1) else b + 10 - (s + 1) print(a) main()
7
11
186
231
S = list(map(int, eval(input()))) a, b = 0, 1 for s in S: a, b = a + s if a + s < b + 10 - s else b + 10 - s, a + (s + 1) if a + ( s + 1 ) < b + 10 - (s + 1) else b + 10 - (s + 1) print(a)
def main(): S = list(map(int, eval(input()))) a, b = 0, 1 for s in S: a, b = a + s if a + s < b + 10 - s else b + 10 - s, a + (s + 1) if a + ( s + 1 ) < b + 10 - (s + 1) else b + 10 - (s + 1) print(a) main()
false
36.363636
[ "-S = list(map(int, eval(input())))", "-a, b = 0, 1", "-for s in S:", "- a, b = a + s if a + s < b + 10 - s else b + 10 - s, a + (s + 1) if a + (", "- s + 1", "- ) < b + 10 - (s + 1) else b + 10 - (s + 1)", "-print(a)", "+def main():", "+ S = list(map(int, eval(input())))", "+ a...
false
0.03422
0.045426
0.753321
[ "s589513841", "s802414782" ]
u108650331
p02695
python
s043964846
s972481944
668
313
23,320
9,104
Accepted
Accepted
53.14
#!/usr/bin/env python3 # スペース区切りの整数の入力 from collections import deque def calc(seq): score = 0 for a, b, c, d in data: if seq[b-1] - seq[a-1] == c: score += d return score # スペース区切りの整数の入力 N, M, Q = list(map(int, input().split())) #配列の入力 data = [list(map(int, input().spli...
#!/usr/bin/env python3 # スペース区切りの整数の入力 def dfs(seq): ans = 0 if len(seq) == N: score_ret = 0 for a, b, c, d in data: if seq[b-1] - seq[a-1] == c: score_ret += d return score_ret else: for i in range(seq[-1], M+1): seq_next...
37
28
672
616
#!/usr/bin/env python3 # スペース区切りの整数の入力 from collections import deque def calc(seq): score = 0 for a, b, c, d in data: if seq[b - 1] - seq[a - 1] == c: score += d return score # スペース区切りの整数の入力 N, M, Q = list(map(int, input().split())) # 配列の入力 data = [list(map(int, input().split())) for...
#!/usr/bin/env python3 # スペース区切りの整数の入力 def dfs(seq): ans = 0 if len(seq) == N: score_ret = 0 for a, b, c, d in data: if seq[b - 1] - seq[a - 1] == c: score_ret += d return score_ret else: for i in range(seq[-1], M + 1): seq_next = seq +...
false
24.324324
[ "-from collections import deque", "-", "-", "-def calc(seq):", "- score = 0", "- for a, b, c, d in data:", "- if seq[b - 1] - seq[a - 1] == c:", "- score += d", "- return score", "+def dfs(seq):", "+ ans = 0", "+ if len(seq) == N:", "+ score_ret = 0", ...
false
0.102315
0.119329
0.857416
[ "s043964846", "s972481944" ]
u875541136
p02755
python
s455822971
s007707531
202
177
38,384
38,384
Accepted
Accepted
12.38
isFound = False li = list(map(int,input().split())) min = int(li[0] / 0.08) max = int((li[0] + 1) / 0.08) - 1 for i in range(min, max): if((int(i * 0.1) == li[1]) and (int(i * 0.08) == li[0])): print(i) isFound = True break if(not(isFound)): print((-1))
import math A, B = list(map(int, input().split())) minV = math.ceil(A / 0.08) maxV = int((A + 1) / 0.08) for i in range(minV, maxV): if int(i * 0.1) == B: print(i) exit() print((-1))
11
9
293
202
isFound = False li = list(map(int, input().split())) min = int(li[0] / 0.08) max = int((li[0] + 1) / 0.08) - 1 for i in range(min, max): if (int(i * 0.1) == li[1]) and (int(i * 0.08) == li[0]): print(i) isFound = True break if not (isFound): print((-1))
import math A, B = list(map(int, input().split())) minV = math.ceil(A / 0.08) maxV = int((A + 1) / 0.08) for i in range(minV, maxV): if int(i * 0.1) == B: print(i) exit() print((-1))
false
18.181818
[ "-isFound = False", "-li = list(map(int, input().split()))", "-min = int(li[0] / 0.08)", "-max = int((li[0] + 1) / 0.08) - 1", "-for i in range(min, max):", "- if (int(i * 0.1) == li[1]) and (int(i * 0.08) == li[0]):", "+import math", "+", "+A, B = list(map(int, input().split()))", "+minV = mat...
false
0.036342
0.037695
0.964094
[ "s455822971", "s007707531" ]
u652057333
p02780
python
s095691067
s443758806
268
189
24,808
24,548
Accepted
Accepted
29.48
n, k = list(map(int, input().split())) p = list(map(int, input().split())) e = [] for v in p: if v % 2 == 0: e.append(((v+1)*(v//2)) / v) else: e.append(((v+1)*(v//2) + (v+1) // 2) / v) e_sum = [0] for i in range(len(e)): e_sum.append(e_sum[i] + e[i]) ans = 0 for i in r...
n, k = list(map(int, input().split())) p = list(map(int, input().split())) p = [(x+1) / 2 for x in p] # 累積和 def cumsum(a): r = [0] for v in a: r.append(r[-1] + v) return r cs = cumsum(p) ans = 0 for i in range(k, n+1): ans = max(ans, cs[i] - cs[i-k]) print(ans)
21
18
392
300
n, k = list(map(int, input().split())) p = list(map(int, input().split())) e = [] for v in p: if v % 2 == 0: e.append(((v + 1) * (v // 2)) / v) else: e.append(((v + 1) * (v // 2) + (v + 1) // 2) / v) e_sum = [0] for i in range(len(e)): e_sum.append(e_sum[i] + e[i]) ans = 0 for i in range(k, ...
n, k = list(map(int, input().split())) p = list(map(int, input().split())) p = [(x + 1) / 2 for x in p] # 累積和 def cumsum(a): r = [0] for v in a: r.append(r[-1] + v) return r cs = cumsum(p) ans = 0 for i in range(k, n + 1): ans = max(ans, cs[i] - cs[i - k]) print(ans)
false
14.285714
[ "-e = []", "-for v in p:", "- if v % 2 == 0:", "- e.append(((v + 1) * (v // 2)) / v)", "- else:", "- e.append(((v + 1) * (v // 2) + (v + 1) // 2) / v)", "-e_sum = [0]", "-for i in range(len(e)):", "- e_sum.append(e_sum[i] + e[i])", "+p = [(x + 1) / 2 for x in p]", "+# 累積和"...
false
0.035241
0.035309
0.998081
[ "s095691067", "s443758806" ]
u262525101
p02755
python
s288901194
s008313568
21
18
3,064
3,060
Accepted
Accepted
14.29
import math A ,B = list(map(int,input().split())) def problem_koganemaru(A,B): for price in range(10000): if math.floor(price*0.08) == A and math.floor(price*0.1) == B: return price return -1 print((problem_koganemaru(A,B)))
import math A,B = list(map(int,input().split())) def problem_gksn(A, B): x_min = math.ceil(A / (0.08)) x_max = math.floor((A+1)/0.08) y_min = math.ceil(B / (0.10)) y_max = math.floor((B+1) / (0.10)) # print(x_min,x_max,y_min,y_max) if max(x_min, y_min) < min(x_max, y_max): return max(x_min, y_m...
10
14
251
383
import math A, B = list(map(int, input().split())) def problem_koganemaru(A, B): for price in range(10000): if math.floor(price * 0.08) == A and math.floor(price * 0.1) == B: return price return -1 print((problem_koganemaru(A, B)))
import math A, B = list(map(int, input().split())) def problem_gksn(A, B): x_min = math.ceil(A / (0.08)) x_max = math.floor((A + 1) / 0.08) y_min = math.ceil(B / (0.10)) y_max = math.floor((B + 1) / (0.10)) # print(x_min,x_max,y_min,y_max) if max(x_min, y_min) < min(x_max, y_max): ret...
false
28.571429
[ "-def problem_koganemaru(A, B):", "- for price in range(10000):", "- if math.floor(price * 0.08) == A and math.floor(price * 0.1) == B:", "- return price", "- return -1", "+def problem_gksn(A, B):", "+ x_min = math.ceil(A / (0.08))", "+ x_max = math.floor((A + 1) / 0.08)"...
false
0.045971
0.048389
0.950016
[ "s288901194", "s008313568" ]
u219417113
p03160
python
s666434331
s330762501
160
127
13,928
13,980
Accepted
Accepted
20.62
inf = 10**9 + 7 n = int(eval(input())) nodes = list(map(int, input().split())) dp = [inf] * n dp[0] = 0 for i in range(1, n): dp[i] = min(dp[i], dp[i-1]+abs(nodes[i]-nodes[i-1])) if i > 1: dp[i] = min(dp[i], dp[i-2]+abs(nodes[i]-nodes[i-2])) print((dp[n-1]))
N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1]-h[0]) for i in range(2, N): dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2])) print((dp[N-1]))
14
10
284
210
inf = 10**9 + 7 n = int(eval(input())) nodes = list(map(int, input().split())) dp = [inf] * n dp[0] = 0 for i in range(1, n): dp[i] = min(dp[i], dp[i - 1] + abs(nodes[i] - nodes[i - 1])) if i > 1: dp[i] = min(dp[i], dp[i - 2] + abs(nodes[i] - nodes[i - 2])) print((dp[n - 1]))
N = int(eval(input())) h = list(map(int, input().split())) dp = [0] * N dp[1] = abs(h[1] - h[0]) for i in range(2, N): dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) print((dp[N - 1]))
false
28.571429
[ "-inf = 10**9 + 7", "-n = int(eval(input()))", "-nodes = list(map(int, input().split()))", "-dp = [inf] * n", "-dp[0] = 0", "-for i in range(1, n):", "- dp[i] = min(dp[i], dp[i - 1] + abs(nodes[i] - nodes[i - 1]))", "- if i > 1:", "- dp[i] = min(dp[i], dp[i - 2] + abs(nodes[i] - nodes[i...
false
0.04166
0.034344
1.213011
[ "s666434331", "s330762501" ]
u853185302
p03012
python
s520538943
s114150852
20
17
3,060
2,940
Accepted
Accepted
15
N = int(eval(input())) W = list(map(int,input().split())) min_w = 10000000 for i in range(N): T1 = W[:i] T2 = W[i:] if min_w > abs(sum(T1)-sum(T2)): min_w = abs(sum(T1)-sum(T2)) print(min_w)
N = int(eval(input())) W = list(map(int,input().split())) ans = [abs(sum(W[:i])-sum(W[i:])) for i in range(N)] print((min(ans)))
9
4
202
123
N = int(eval(input())) W = list(map(int, input().split())) min_w = 10000000 for i in range(N): T1 = W[:i] T2 = W[i:] if min_w > abs(sum(T1) - sum(T2)): min_w = abs(sum(T1) - sum(T2)) print(min_w)
N = int(eval(input())) W = list(map(int, input().split())) ans = [abs(sum(W[:i]) - sum(W[i:])) for i in range(N)] print((min(ans)))
false
55.555556
[ "-min_w = 10000000", "-for i in range(N):", "- T1 = W[:i]", "- T2 = W[i:]", "- if min_w > abs(sum(T1) - sum(T2)):", "- min_w = abs(sum(T1) - sum(T2))", "-print(min_w)", "+ans = [abs(sum(W[:i]) - sum(W[i:])) for i in range(N)]", "+print((min(ans)))" ]
false
0.048751
0.048977
0.995384
[ "s520538943", "s114150852" ]
u387774811
p02936
python
s780822467
s137852357
1,113
889
55,728
93,972
Accepted
Accepted
20.13
import sys input = sys.stdin.readline N,Q=list(map(int,input().split())) ans=[0]*N ki=[[] for _ in range(N)] for i in range(N-1): a,b=list(map(int,input().split())) ki[a-1].append(b-1) ki[b-1].append(a-1) for i in range(Q): p,q=list(map(int,input().split())) ans[p-1]+=q # dfs stack = [0] visited = ["...
import sys input = sys.stdin.readline N,Q=list(map(int,input().split())) ans=[0]*N ki=[[] for _ in range(N)] for i in range(N-1): a,b=list(map(int,input().split())) ki[a-1].append(b-1) ki[b-1].append(a-1) for i in range(Q): p,q=list(map(int,input().split())) ans[p-1]+=q # dfs from collections import d...
24
25
504
546
import sys input = sys.stdin.readline N, Q = list(map(int, input().split())) ans = [0] * N ki = [[] for _ in range(N)] for i in range(N - 1): a, b = list(map(int, input().split())) ki[a - 1].append(b - 1) ki[b - 1].append(a - 1) for i in range(Q): p, q = list(map(int, input().split())) ans[p - 1] +...
import sys input = sys.stdin.readline N, Q = list(map(int, input().split())) ans = [0] * N ki = [[] for _ in range(N)] for i in range(N - 1): a, b = list(map(int, input().split())) ki[a - 1].append(b - 1) ki[b - 1].append(a - 1) for i in range(Q): p, q = list(map(int, input().split())) ans[p - 1] +...
false
4
[ "-stack = [0]", "+from collections import deque", "+", "+stack = deque([0])", "- ne = stack.pop()", "+ ne = stack.popleft()" ]
false
0.04801
0.045016
1.066512
[ "s780822467", "s137852357" ]
u057109575
p02850
python
s551964215
s309141802
707
328
83,160
113,260
Accepted
Accepted
53.61
from collections import deque N = int(input()) X = [list(map(int, input().split())) for _ in range(N - 1)] tree = [[] for _ in range(N)] for n, (i, j) in enumerate(X): tree[i - 1].append((n, j - 1)) q = deque() q.append((0, 0)) ans = [0] * (N - 1) while len(q) > 0: # u: node number, c: color ...
from collections import deque N = int(input()) X = [list(map(int, input().split())) for _ in range(N - 1)] tree = [[] for _ in range(N + 1)] for i, (a, b) in enumerate(X): tree[a].append((b, i)) tree[b].append((a, i)) visited = [False] * (N + 1) visited[1] = True color = [0] * (N - 1) stack = de...
27
32
566
694
from collections import deque N = int(input()) X = [list(map(int, input().split())) for _ in range(N - 1)] tree = [[] for _ in range(N)] for n, (i, j) in enumerate(X): tree[i - 1].append((n, j - 1)) q = deque() q.append((0, 0)) ans = [0] * (N - 1) while len(q) > 0: # u: node number, c: color u, c = q.pople...
from collections import deque N = int(input()) X = [list(map(int, input().split())) for _ in range(N - 1)] tree = [[] for _ in range(N + 1)] for i, (a, b) in enumerate(X): tree[a].append((b, i)) tree[b].append((a, i)) visited = [False] * (N + 1) visited[1] = True color = [0] * (N - 1) stack = deque() stack.app...
false
15.625
[ "-tree = [[] for _ in range(N)]", "-for n, (i, j) in enumerate(X):", "- tree[i - 1].append((n, j - 1))", "-q = deque()", "-q.append((0, 0))", "-ans = [0] * (N - 1)", "-while len(q) > 0:", "- # u: node number, c: color", "- u, c = q.popleft()", "- cnt = 1", "- for i, (n, v) in enum...
false
0.082035
0.035603
2.30415
[ "s551964215", "s309141802" ]
u760794812
p03946
python
s218985589
s400659346
192
107
24,228
15,020
Accepted
Accepted
44.27
N,T = list(map(int,input().split())) List = list(map(int,input().split())) dic = {} min = List[0] for i in range(N): if List[i]<min: min = List[i] if List[i]-min not in dic: dic[List[i]-min] = 1 else: dic[List[i]-min] += 1 dic2 = sorted(list(dic.items()), reverse=True) Answer = dic2[0][1] ...
n, t = list(map(int, input().split())) *a, = list(map(int, input().split())) purchase = a[0] profit = [] for i in range(len(a)): profit.append(a[i] - purchase) if a[i] < purchase: purchase = a[i] profit.sort() Answer = profit.count(profit[-1]) print(Answer)
14
11
322
263
N, T = list(map(int, input().split())) List = list(map(int, input().split())) dic = {} min = List[0] for i in range(N): if List[i] < min: min = List[i] if List[i] - min not in dic: dic[List[i] - min] = 1 else: dic[List[i] - min] += 1 dic2 = sorted(list(dic.items()), reverse=True) Ans...
n, t = list(map(int, input().split())) (*a,) = list(map(int, input().split())) purchase = a[0] profit = [] for i in range(len(a)): profit.append(a[i] - purchase) if a[i] < purchase: purchase = a[i] profit.sort() Answer = profit.count(profit[-1]) print(Answer)
false
21.428571
[ "-N, T = list(map(int, input().split()))", "-List = list(map(int, input().split()))", "-dic = {}", "-min = List[0]", "-for i in range(N):", "- if List[i] < min:", "- min = List[i]", "- if List[i] - min not in dic:", "- dic[List[i] - min] = 1", "- else:", "- dic[List...
false
0.052994
0.07863
0.673969
[ "s218985589", "s400659346" ]
u945181840
p03137
python
s965575617
s457651013
1,086
113
13,968
13,960
Accepted
Accepted
89.59
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) d = [0] * (M - 1) ans = 0 if N >= M: print(ans) else: for i in range(M - 1): d[i] = abs(X[i + 1] - X[i]) d.sort(reverse=True) b = d[:N - 1] for i in range(M - 1): if d[i] in b: ...
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) d = [0] * (M - 1) if N >= M: print((0)) else: for i in range(M - 1): d[i] = abs(X[i + 1] - X[i]) d.sort(reverse=True) print((sum(d[N - 1:])))
18
11
387
249
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) d = [0] * (M - 1) ans = 0 if N >= M: print(ans) else: for i in range(M - 1): d[i] = abs(X[i + 1] - X[i]) d.sort(reverse=True) b = d[: N - 1] for i in range(M - 1): if d[i] in b: b.remove(d[...
N, M = list(map(int, input().split())) X = sorted(list(map(int, input().split()))) d = [0] * (M - 1) if N >= M: print((0)) else: for i in range(M - 1): d[i] = abs(X[i + 1] - X[i]) d.sort(reverse=True) print((sum(d[N - 1 :])))
false
38.888889
[ "-ans = 0", "- print(ans)", "+ print((0))", "- b = d[: N - 1]", "- for i in range(M - 1):", "- if d[i] in b:", "- b.remove(d[i])", "- else:", "- ans += d[i]", "- print(ans)", "+ print((sum(d[N - 1 :])))" ]
false
0.127078
0.113126
1.123334
[ "s965575617", "s457651013" ]
u072717685
p02683
python
s167590537
s985099430
105
72
10,036
9,152
Accepted
Accepted
31.43
import sys read = sys.stdin.read readlines = sys.stdin.readlines from itertools import product def main(): n, m, x = list(map(int, input().split())) books = [] for _ in range(n): book = tuple(map(int, input().split())) books.append(book) pro = product((1, 0),repeat=n) cost...
import sys read = sys.stdin.read readlines = sys.stdin.readlines from itertools import product def main(): n, m, x = list(map(int, input().split())) books = [] for _ in range(n): book = tuple(map(int, input().split())) books.append(book) pro = product((1, 0),repeat=n) cost...
30
30
782
775
import sys read = sys.stdin.read readlines = sys.stdin.readlines from itertools import product def main(): n, m, x = list(map(int, input().split())) books = [] for _ in range(n): book = tuple(map(int, input().split())) books.append(book) pro = product((1, 0), repeat=n) costs = [] ...
import sys read = sys.stdin.read readlines = sys.stdin.readlines from itertools import product def main(): n, m, x = list(map(int, input().split())) books = [] for _ in range(n): book = tuple(map(int, input().split())) books.append(book) pro = product((1, 0), repeat=n) costs = [] ...
false
0
[ "- if all([i >= x for i in algo]):", "- costs.append(cost)", "+ if all([i >= x for i in algo]):", "+ costs.append(cost)" ]
false
0.050198
0.00715
7.021094
[ "s167590537", "s985099430" ]
u604774382
p02392
python
s672902931
s152482423
30
20
6,720
4,196
Accepted
Accepted
33.33
#coding:utf-8 import sys abc=sys.stdin.readline() a,b,c=abc.split( ' ' ) a=int( a ) b=int( b ) c=int( c ) if a < b and b < c: print( "Yes" ) else: print( "No" )
import sys nums = [ int( val ) for val in sys.stdin.readline().split( " " ) ] if nums[0] < nums[1] and nums[1] < nums[2]: print( "Yes" ) else: print( "No" )
12
7
175
165
# coding:utf-8 import sys abc = sys.stdin.readline() a, b, c = abc.split(" ") a = int(a) b = int(b) c = int(c) if a < b and b < c: print("Yes") else: print("No")
import sys nums = [int(val) for val in sys.stdin.readline().split(" ")] if nums[0] < nums[1] and nums[1] < nums[2]: print("Yes") else: print("No")
false
41.666667
[ "-# coding:utf-8", "-abc = sys.stdin.readline()", "-a, b, c = abc.split(\" \")", "-a = int(a)", "-b = int(b)", "-c = int(c)", "-if a < b and b < c:", "+nums = [int(val) for val in sys.stdin.readline().split(\" \")]", "+if nums[0] < nums[1] and nums[1] < nums[2]:" ]
false
0.092472
0.07469
1.23808
[ "s672902931", "s152482423" ]
u546959066
p03241
python
s502579905
s982927645
1,736
21
2,940
3,060
Accepted
Accepted
98.79
N, M = list(map(int, input().split(" "))) def solv(N, M): d = M//N for i in range(d+1)[::-1]: if M%i == 0: return i print((solv(N, M)))
n, m = list(map(int, input().split(" "))) ds = [x for x in range(1, int(m**.5)+1) if m%x==0] ds = ds + [m//x for x in ds] ds = [x for x in ds if x<=m//n] print((max(ds)))
7
6
167
174
N, M = list(map(int, input().split(" "))) def solv(N, M): d = M // N for i in range(d + 1)[::-1]: if M % i == 0: return i print((solv(N, M)))
n, m = list(map(int, input().split(" "))) ds = [x for x in range(1, int(m**0.5) + 1) if m % x == 0] ds = ds + [m // x for x in ds] ds = [x for x in ds if x <= m // n] print((max(ds)))
false
14.285714
[ "-N, M = list(map(int, input().split(\" \")))", "-", "-", "-def solv(N, M):", "- d = M // N", "- for i in range(d + 1)[::-1]:", "- if M % i == 0:", "- return i", "-", "-", "-print((solv(N, M)))", "+n, m = list(map(int, input().split(\" \")))", "+ds = [x for x in range...
false
0.06678
0.049494
1.34924
[ "s502579905", "s982927645" ]
u072717685
p02615
python
s778794312
s227969284
148
135
97,440
31,720
Accepted
Accepted
8.78
import sys read = sys.stdin.read def main(): n, *a = list(map(int, read().split())) a.sort(reverse=True) r = a[0] end = int((n - 2) // 2) r += sum(a[1:end+1]) * 2 if n % 2 == 1: r += a[end+1] print(r) if __name__ == '__main__': main()
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines from collections import deque def main(): n, *a = list(map(int, read().split())) a.sort(reverse=True) a = deque(a) circle_joined = deque() next_score = a.popleft() r = 0 flag = False ...
14
26
283
617
import sys read = sys.stdin.read def main(): n, *a = list(map(int, read().split())) a.sort(reverse=True) r = a[0] end = int((n - 2) // 2) r += sum(a[1 : end + 1]) * 2 if n % 2 == 1: r += a[end + 1] print(r) if __name__ == "__main__": main()
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines from collections import deque def main(): n, *a = list(map(int, read().split())) a.sort(reverse=True) a = deque(a) circle_joined = deque() next_score = a.popleft() r = 0 flag = False while a...
false
46.153846
[ "+readline = sys.stdin.readline", "+readlines = sys.stdin.readlines", "+from collections import deque", "- r = a[0]", "- end = int((n - 2) // 2)", "- r += sum(a[1 : end + 1]) * 2", "- if n % 2 == 1:", "- r += a[end + 1]", "+ a = deque(a)", "+ circle_joined = deque()", "+...
false
0.04692
0.089983
0.521425
[ "s778794312", "s227969284" ]
u969080040
p02717
python
s780276749
s447889558
19
17
3,060
2,940
Accepted
Accepted
10.53
hello,y,z=input().split() hello=int(hello) y=int(y) z=int(z) print((z,hello,y))
X,Y,Z=list(map(int,input().split())) print((Z,X,Y))
5
2
81
44
hello, y, z = input().split() hello = int(hello) y = int(y) z = int(z) print((z, hello, y))
X, Y, Z = list(map(int, input().split())) print((Z, X, Y))
false
60
[ "-hello, y, z = input().split()", "-hello = int(hello)", "-y = int(y)", "-z = int(z)", "-print((z, hello, y))", "+X, Y, Z = list(map(int, input().split()))", "+print((Z, X, Y))" ]
false
0.071176
0.050074
1.421405
[ "s780276749", "s447889558" ]
u597374218
p03262
python
s729237066
s007954262
165
91
16,284
16,272
Accepted
Accepted
44.85
from fractions import gcd n,d=list(map(int,input().split())) x=sorted(list(map(int,input().split()))+[d]) r=x[1]-x[0] print((min(gcd(x[i+1]-x[i],r) for i in range(n))))
from functools import reduce from fractions import gcd N,X=list(map(int,input().split())) x=[abs(X-int(i)) for i in input().split()] print((reduce(gcd,x)))
5
5
164
151
from fractions import gcd n, d = list(map(int, input().split())) x = sorted(list(map(int, input().split())) + [d]) r = x[1] - x[0] print((min(gcd(x[i + 1] - x[i], r) for i in range(n))))
from functools import reduce from fractions import gcd N, X = list(map(int, input().split())) x = [abs(X - int(i)) for i in input().split()] print((reduce(gcd, x)))
false
0
[ "+from functools import reduce", "-n, d = list(map(int, input().split()))", "-x = sorted(list(map(int, input().split())) + [d])", "-r = x[1] - x[0]", "-print((min(gcd(x[i + 1] - x[i], r) for i in range(n))))", "+N, X = list(map(int, input().split()))", "+x = [abs(X - int(i)) for i in input().split()]", ...
false
0.086617
0.044091
1.964499
[ "s729237066", "s007954262" ]
u597374218
p03146
python
s339441408
s660142207
32
17
10,868
2,940
Accepted
Accepted
46.88
S=int(eval(input())) l=[0]*1000000 l[0]=0 l[1]=S for i in range(2,1000000): if l[i-1]%2==0: l[i]=l[i-1]//2 else: l[i]=3*l[i-1]+1 for j in range(1,i-1): if l[i]==l[j]: print(i) exit()
S=int(eval(input())) l=[] while (S not in l): l.append(S) if S%2==0:S//=2 else:S=3*S+1 print((len(l)+1))
13
7
247
114
S = int(eval(input())) l = [0] * 1000000 l[0] = 0 l[1] = S for i in range(2, 1000000): if l[i - 1] % 2 == 0: l[i] = l[i - 1] // 2 else: l[i] = 3 * l[i - 1] + 1 for j in range(1, i - 1): if l[i] == l[j]: print(i) exit()
S = int(eval(input())) l = [] while S not in l: l.append(S) if S % 2 == 0: S //= 2 else: S = 3 * S + 1 print((len(l) + 1))
false
46.153846
[ "-l = [0] * 1000000", "-l[0] = 0", "-l[1] = S", "-for i in range(2, 1000000):", "- if l[i - 1] % 2 == 0:", "- l[i] = l[i - 1] // 2", "+l = []", "+while S not in l:", "+ l.append(S)", "+ if S % 2 == 0:", "+ S //= 2", "- l[i] = 3 * l[i - 1] + 1", "- for j in ra...
false
0.130482
0.046125
2.828888
[ "s339441408", "s660142207" ]
u312025627
p03201
python
s236071264
s006122262
687
353
56,624
107,028
Accepted
Accepted
48.62
def main(): from collections import Counter import sys input = sys.stdin.buffer.readline _ = int(eval(input())) A = [int(i) for i in input().split()] ans = 0 A.sort(reverse=True) c = Counter(A) for b in A: if c[b] == 0: continue a = (2 **...
def main(): from collections import Counter import sys input = sys.stdin.buffer.readline _ = int(eval(input())) A = [int(i) for i in input().split()] ans = 0 c = Counter(A) B = sorted(list(c.keys()), reverse=True) for b in B: if c[b] == 0: continu...
30
29
587
572
def main(): from collections import Counter import sys input = sys.stdin.buffer.readline _ = int(eval(input())) A = [int(i) for i in input().split()] ans = 0 A.sort(reverse=True) c = Counter(A) for b in A: if c[b] == 0: continue a = (2 ** b.bit_length()) ...
def main(): from collections import Counter import sys input = sys.stdin.buffer.readline _ = int(eval(input())) A = [int(i) for i in input().split()] ans = 0 c = Counter(A) B = sorted(list(c.keys()), reverse=True) for b in B: if c[b] == 0: continue a = (2...
false
3.333333
[ "- A.sort(reverse=True)", "- for b in A:", "+ B = sorted(list(c.keys()), reverse=True)", "+ for b in B:", "- c[b] -= cur", "+ # c[b] -= cur", "- # print(a, b, c, ans)" ]
false
0.052877
0.050502
1.047018
[ "s236071264", "s006122262" ]
u923270446
p02536
python
s323639818
s456958199
425
335
48,184
13,628
Accepted
Accepted
21.18
import sys sys.setrecursionlimit(2 * (10 ** 6)) n, m = list(map(int, input().split())) edges = [[] for i in range(n)] visit = [False for i in range(n)] def dfs(v): visit[v] = True for i in edges[v]: if not visit[i]: dfs(i) for i in range(m): a, b = list(map(int, input().split(...
class UnionFind(): def __init__(self, n): self.n = n self.par = list(range(self.n)) self.rank = [1] * n self.cnt = n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return s...
20
34
476
919
import sys sys.setrecursionlimit(2 * (10**6)) n, m = list(map(int, input().split())) edges = [[] for i in range(n)] visit = [False for i in range(n)] def dfs(v): visit[v] = True for i in edges[v]: if not visit[i]: dfs(i) for i in range(m): a, b = list(map(int, input().split())) ...
class UnionFind: def __init__(self, n): self.n = n self.par = list(range(self.n)) self.rank = [1] * n self.cnt = n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] ...
false
41.176471
[ "-import sys", "+class UnionFind:", "+ def __init__(self, n):", "+ self.n = n", "+ self.par = list(range(self.n))", "+ self.rank = [1] * n", "+ self.cnt = n", "-sys.setrecursionlimit(2 * (10**6))", "-n, m = list(map(int, input().split()))", "-edges = [[] for i in ran...
false
0.040212
0.040621
0.989929
[ "s323639818", "s456958199" ]
u467736898
p02905
python
s928694955
s843400033
1,829
1,685
87,988
80,496
Accepted
Accepted
7.87
def main(): mod = 998244353 max_A = 10**6 N = int(eval(input())) A = list(map(int, input().split())) is_prime = [False, True, False, False, False, True] * (max_A//6+1) del is_prime[max_A+1:] is_prime[1:4] = False, True, True for i in range(5, int(max_A**0.5)+1): if is_...
# 解説 AC # 参考1: https://twitter.com/rickytheta/status/1175412019006074880 # 参考2: https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2019-09-21agc-038 def make_prime_checker(n): is_prime = [False, True, False, False, False, True] * (n//6+1) del is_prime[n+1:] is_prime[1:4] = False, Tru...
38
81
1,223
2,355
def main(): mod = 998244353 max_A = 10**6 N = int(eval(input())) A = list(map(int, input().split())) is_prime = [False, True, False, False, False, True] * (max_A // 6 + 1) del is_prime[max_A + 1 :] is_prime[1:4] = False, True, True for i in range(5, int(max_A**0.5) + 1): if is_pr...
# 解説 AC # 参考1: https://twitter.com/rickytheta/status/1175412019006074880 # 参考2: https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2019-09-21agc-038 def make_prime_checker(n): is_prime = [False, True, False, False, False, True] * (n // 6 + 1) del is_prime[n + 1 :] is_prime[1:4] = False, True, ...
false
53.08642
[ "+# 解説 AC", "+# 参考1: https://twitter.com/rickytheta/status/1175412019006074880", "+# 参考2: https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2019-09-21agc-038", "+def make_prime_checker(n):", "+ is_prime = [False, True, False, False, False, True] * (n // 6 + 1)", "+ del is_prime[n + 1 ...
false
2.357339
2.298982
1.025384
[ "s928694955", "s843400033" ]
u738898077
p03074
python
s703100137
s152302919
100
82
5,152
13,012
Accepted
Accepted
18
n,k = list(map(int,input().split())) s = list(map(int,eval(input()))) s_list = list() num = s[0] temp_streak = 0 # temp_max = 0 # temp_sum = 0 [s_list.append(0) for i in range(1+s[0])] for i in s: if i == num: temp_streak += 1 else: s_list.append(temp_streak) temp_streak =...
n,k = list(map(int,input().split())) s = eval(input()) ms = 0 ps = 0 temp = [0] if s[0] == "0": temp.append(0) for i in s: # print(i,ps,ms) if i == "0": ms += 1 if ps: temp.append(ps) ps = 0 else: ps += 1 if ms: temp.ap...
36
35
895
661
n, k = list(map(int, input().split())) s = list(map(int, eval(input()))) s_list = list() num = s[0] temp_streak = 0 # temp_max = 0 # temp_sum = 0 [s_list.append(0) for i in range(1 + s[0])] for i in s: if i == num: temp_streak += 1 else: s_list.append(temp_streak) temp_streak = 1 ...
n, k = list(map(int, input().split())) s = eval(input()) ms = 0 ps = 0 temp = [0] if s[0] == "0": temp.append(0) for i in s: # print(i,ps,ms) if i == "0": ms += 1 if ps: temp.append(ps) ps = 0 else: ps += 1 if ms: temp.append(ms) ...
false
2.777778
[ "-s = list(map(int, eval(input())))", "-s_list = list()", "-num = s[0]", "-temp_streak = 0", "-# temp_max = 0", "-# temp_sum = 0", "-[s_list.append(0) for i in range(1 + s[0])]", "+s = eval(input())", "+ms = 0", "+ps = 0", "+temp = [0]", "+if s[0] == \"0\":", "+ temp.append(0)", "- i...
false
0.034262
0.033497
1.022842
[ "s703100137", "s152302919" ]
u086566114
p02412
python
s729015938
s565257967
160
130
6,304
6,368
Accepted
Accepted
18.75
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, 1, -1): for n1 in range(n2 - 1, 0, -1): s = n1 + n2 + n3 if s == x: ans += 1 break return ans while True: ...
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): s = n1 + n2 + n3 if s == x: ans += 1 break return an...
20
20
487
506
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, 1, -1): for n1 in range(n2 - 1, 0, -1): s = n1 + n2 + n3 if s == x: ans += 1 break return ans while True: [n, x] =...
def get_num(n, x): ans = 0 for n3 in range(min(n, x), (x + 2) / 3, -1): for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1): for n1 in range(n2 - 1, 0, -1): s = n1 + n2 + n3 if s == x: ans += 1 break return ans while...
false
0
[ "- for n2 in range(n3 - 1, 1, -1):", "+ for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1):" ]
false
0.102994
0.065681
1.568101
[ "s729015938", "s565257967" ]
u254871849
p02934
python
s756118149
s816992509
32
17
3,828
2,940
Accepted
Accepted
46.88
# 2019-11-17 10:52:21(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools from functools import reduce # import operator as op # import re # import heapq # import arr...
import sys n, *A = list(map(int, sys.stdin.read().split())) def main(): prod = 1 for a in A: prod *= a numerator = prod denominator = 0 for a in A: denominator += prod // a return numerator / denominator if __name__ == '__main__': ans = main() ...
26
19
615
327
# 2019-11-17 10:52:21(JST) import sys # import collections # import math # from string import ascii_lowercase, ascii_uppercase, digits # from bisect import bisect_left as bi_l, bisect_right as bi_r # import itertools from functools import reduce # import operator as op # import re # import heapq # import array # from...
import sys n, *A = list(map(int, sys.stdin.read().split())) def main(): prod = 1 for a in A: prod *= a numerator = prod denominator = 0 for a in A: denominator += prod // a return numerator / denominator if __name__ == "__main__": ans = main() print(ans)
false
26.923077
[ "-# 2019-11-17 10:52:21(JST)", "-# import collections", "-# import math", "-# from string import ascii_lowercase, ascii_uppercase, digits", "-# from bisect import bisect_left as bi_l, bisect_right as bi_r", "-# import itertools", "-from functools import reduce", "-", "-# import operator as op", "-...
false
0.036157
0.036664
0.986176
[ "s756118149", "s816992509" ]
u102461423
p03718
python
s961575139
s836807314
312
57
4,724
7,540
Accepted
Accepted
81.73
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import defaultdict H,W = list(map(int,readline().split())) A = [line.rstrip().decode('utf-8') for line in readlines()] source = 0 sink = H+W+1 graph = [defaultdict(int) f...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque H,W = list(map(int,readline().split())) A = [line.rstrip().decode('utf-8') for line in readlines()] class Dinic: def __init__(self, N, source, sink): ...
108
110
3,016
2,942
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import defaultdict H, W = list(map(int, readline().split())) A = [line.rstrip().decode("utf-8") for line in readlines()] source = 0 sink = H + W + 1 graph = [defaultdict(int) for _ in r...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque H, W = list(map(int, readline().split())) A = [line.rstrip().decode("utf-8") for line in readlines()] class Dinic: def __init__(self, N, source, sink): self.N...
false
1.818182
[ "-from collections import defaultdict", "+from collections import deque", "-source = 0", "-sink = H + W + 1", "-graph = [defaultdict(int) for _ in range(H + W + 2)]", "-INF = 10**18", "-for h in range(1, H + 1):", "- for w, ox in enumerate(A[h - 1], 1):", "- if ox == \"x\":", "- ...
false
0.039268
0.09201
0.426778
[ "s961575139", "s836807314" ]
u222668979
p03497
python
s287628736
s211832613
172
157
38,964
39,804
Accepted
Accepted
8.72
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ball = {} for i in a: if i in list(ball.keys()): ball[i] += 1 else: ball[i] = 1 ball = sorted(list(ball.items()), key=lambda x: -x[1]) ans = 0 if len(ball) > k: for i in range(k): ans += ball...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ball = {} for i in a: if i in ball: ball[i] += 1 else: ball[i] = 1 ball = sorted(list(ball.items()), key=lambda x: -x[1]) ans = 0 if len(ball) > k: for i in range(k): ans += ball[i][1] a...
18
18
340
333
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ball = {} for i in a: if i in list(ball.keys()): ball[i] += 1 else: ball[i] = 1 ball = sorted(list(ball.items()), key=lambda x: -x[1]) ans = 0 if len(ball) > k: for i in range(k): ans += ball[i][1] ans = n...
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ball = {} for i in a: if i in ball: ball[i] += 1 else: ball[i] = 1 ball = sorted(list(ball.items()), key=lambda x: -x[1]) ans = 0 if len(ball) > k: for i in range(k): ans += ball[i][1] ans = n - ans print(...
false
0
[ "- if i in list(ball.keys()):", "+ if i in ball:" ]
false
0.043682
0.054637
0.799507
[ "s287628736", "s211832613" ]
u604839890
p02837
python
s756669910
s555834853
678
191
9,224
9,256
Accepted
Accepted
71.83
n = int(eval(input())) a, xy = [], [] for _ in range(n): a_t = int(eval(input())) xy_t = [list(map(int, input().split())) for _ in range(a_t)] a.append(a_t) xy.append(xy_t) ans = 0 for i in range(2**n): flag = True for j in range(n): if (i >> j) & 1: for k in xy...
n = int(eval(input())) a, xy = [], [] for _ in range(n): a_t = int(eval(input())) xy_t = [list(map(int, input().split())) for _ in range(a_t)] a.append(a_t) xy.append(xy_t) ans = 0 for i in range(2**n): flag = True for j in range(n): if (i >> j) & 1: for k in xy...
19
20
464
491
n = int(eval(input())) a, xy = [], [] for _ in range(n): a_t = int(eval(input())) xy_t = [list(map(int, input().split())) for _ in range(a_t)] a.append(a_t) xy.append(xy_t) ans = 0 for i in range(2**n): flag = True for j in range(n): if (i >> j) & 1: for k in xy[j]: ...
n = int(eval(input())) a, xy = [], [] for _ in range(n): a_t = int(eval(input())) xy_t = [list(map(int, input().split())) for _ in range(a_t)] a.append(a_t) xy.append(xy_t) ans = 0 for i in range(2**n): flag = True for j in range(n): if (i >> j) & 1: for k in xy[j]: ...
false
5
[ "+ break" ]
false
0.04089
0.116139
0.35208
[ "s756669910", "s555834853" ]
u620084012
p02854
python
s207543896
s385648625
276
113
88,272
104,980
Accepted
Accepted
59.06
N = int(eval(input())) A = list(map(int,input().split())) S = sum(A) l = S//2 ans = S s = 0 for k in range(N): s += A[k] ans = min(ans,abs(l-s)+abs(S-s-l)) print(ans)
N = int(eval(input())) A = list(map(int,input().split())) S = sum(A) T = 0 ans = float("inf") for e in A: T += e ans = min(ans,abs(T-(S-T))) print(ans)
10
9
178
162
N = int(eval(input())) A = list(map(int, input().split())) S = sum(A) l = S // 2 ans = S s = 0 for k in range(N): s += A[k] ans = min(ans, abs(l - s) + abs(S - s - l)) print(ans)
N = int(eval(input())) A = list(map(int, input().split())) S = sum(A) T = 0 ans = float("inf") for e in A: T += e ans = min(ans, abs(T - (S - T))) print(ans)
false
10
[ "-l = S // 2", "-ans = S", "-s = 0", "-for k in range(N):", "- s += A[k]", "- ans = min(ans, abs(l - s) + abs(S - s - l))", "+T = 0", "+ans = float(\"inf\")", "+for e in A:", "+ T += e", "+ ans = min(ans, abs(T - (S - T)))" ]
false
0.035893
0.036412
0.985743
[ "s207543896", "s385648625" ]
u729133443
p02811
python
s178971182
s210705584
175
19
38,384
3,188
Accepted
Accepted
89.14
print(('YNeos'[eval(input().replace(' ','*500<'))::2]))
import re;print((re.search('[12].*1',eval(input()))and'No'or'Yes'))
1
1
53
59
print(("YNeos"[eval(input().replace(" ", "*500<")) :: 2]))
import re print((re.search("[12].*1", eval(input())) and "No" or "Yes"))
false
0
[ "-print((\"YNeos\"[eval(input().replace(\" \", \"*500<\")) :: 2]))", "+import re", "+", "+print((re.search(\"[12].*1\", eval(input())) and \"No\" or \"Yes\"))" ]
false
0.150027
0.04394
3.414344
[ "s178971182", "s210705584" ]
u600402037
p03032
python
s681113066
s813991316
35
32
4,884
3,064
Accepted
Accepted
8.57
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, K = lr() V = lr() scores = [0] limit = min(N, K) for i in range(limit+1): # iは左から取り出す個数 for j in range(limit-i+1): # jは右から取り出す個数 stone = V[:i] + V[N-j:] ...
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, K = lr() V = lr() answer = 0 limit = min(N, K) for i in range(limit+1): # iは左から取り出す個数 for j in range(limit-i+1): # jは右から取り出す個数 stone = V[:i] + V[N-j:] ...
26
27
625
659
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, K = lr() V = lr() scores = [0] limit = min(N, K) for i in range(limit + 1): # iは左から取り出す個数 for j in range(limit - i + 1): # jは右から取り出す個数 stone = V[:i] + V[N - j :] ...
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, K = lr() V = lr() answer = 0 limit = min(N, K) for i in range(limit + 1): # iは左から取り出す個数 for j in range(limit - i + 1): # jは右から取り出す個数 stone = V[:i] + V[N - j :] ...
false
3.703704
[ "-scores = [0]", "+answer = 0", "- scores.append(result)", "+ if result > answer:", "+ answer = result", "- scores.append(result)", "-answer = max(scores)", "+ if result > answer:", "+ answer = result" ]
false
0.006908
0.05368
0.128689
[ "s681113066", "s813991316" ]
u706695185
p03262
python
s271466457
s648270777
88
76
16,304
14,596
Accepted
Accepted
13.64
from functools import reduce from fractions import gcd def gcd(a, b): while b: a, b = b, a%b return a def gcd_list(nums): return reduce(gcd, nums) N, X = list(map(int, input().split())) x = list(map(int, input().split())) diff = [abs(xi - X) for xi in x] print((gcd_list(diff)))
from functools import reduce def gcd(a, b): while b: a, b = b, a%b return a def gcd_list(nums): return reduce(gcd, nums) N, X = list(map(int, input().split())) x = list(map(int, input().split())) diff = [abs(xi - X) for xi in x] print((gcd_list(diff)))
15
16
314
291
from functools import reduce from fractions import gcd def gcd(a, b): while b: a, b = b, a % b return a def gcd_list(nums): return reduce(gcd, nums) N, X = list(map(int, input().split())) x = list(map(int, input().split())) diff = [abs(xi - X) for xi in x] print((gcd_list(diff)))
from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def gcd_list(nums): return reduce(gcd, nums) N, X = list(map(int, input().split())) x = list(map(int, input().split())) diff = [abs(xi - X) for xi in x] print((gcd_list(diff)))
false
6.25
[ "-from fractions import gcd" ]
false
0.056719
0.034804
1.629679
[ "s271466457", "s648270777" ]
u498487134
p02851
python
s846637653
s944011338
340
148
112,972
126,668
Accepted
Accepted
56.47
N, K = list(map(int,input().split())) A = list(map(int, input().split())) S = [0]*(N+1) S2 = [0]*(N+1) dict = {}#最新K件の度数分布の管理 for i in range(N): S[i+1]=S[i]+A[i] S2[i+1] =(S[i+1]-i-1)%K ans =0 for i in range(N+1): if dict.get(S2[i],0): ans += dict[S2[i]] dict[S2[i]]=dict.get(S2[i...
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())) """ N^2なので素直に計算は無理,部分和を使いたいのでとりあえず累積和 [i+1:j]が条件を満たすとはS[j]-S[i]とj-iが合同. 移行して,S[j]-jとS[i]-iが合同 基本は個数だけ見れば良い これだけだと,個数がKより大きい時にダメ 直近...
19
50
381
912
N, K = list(map(int, input().split())) A = list(map(int, input().split())) S = [0] * (N + 1) S2 = [0] * (N + 1) dict = {} # 最新K件の度数分布の管理 for i in range(N): S[i + 1] = S[i] + A[i] S2[i + 1] = (S[i + 1] - i - 1) % K ans = 0 for i in range(N + 1): if dict.get(S2[i], 0): ans += dict[S2[i]] dict[S2[...
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())) """ N^2なので素直に計算は無理,部分和を使いたいのでとりあえず累積和 [i+1:j]が条件を満たすとはS[j]-S[i]とj-iが合同. 移行して,S[j]-jとS[i]-iが合同 基本は個数だけ見れば良い これだけだと,個数がKより大きい時にダメ ...
false
62
[ "-N, K = list(map(int, input().split()))", "-A = list(map(int, input().split()))", "-S = [0] * (N + 1)", "-S2 = [0] * (N + 1)", "-dict = {} # 最新K件の度数分布の管理", "-for i in range(N):", "- S[i + 1] = S[i] + A[i]", "- S2[i + 1] = (S[i + 1] - i - 1) % K", "-ans = 0", "-for i in range(N + 1):", "-...
false
0.047412
0.047663
0.994721
[ "s846637653", "s944011338" ]
u077291787
p03588
python
s554791678
s111798430
181
69
25,940
25,812
Accepted
Accepted
61.88
# tenka1-2017-beginnerB - Different Distribution def main(): N, *AB = list(map(int, open(0).read().split())) A = [(i, j) for i, j in zip(*[iter(AB)] * 2)] A.sort() ans = sum(A[-1]) print(ans) if __name__ == "__main__": main()
# tenka1-2017-beginnerB - Different Distribution def main(): N, *AB = list(map(int, open(0).read().split())) A = max(list(zip(*[iter(AB)] * 2))) ans = sum(A) print(ans) if __name__ == "__main__": main()
11
10
255
221
# tenka1-2017-beginnerB - Different Distribution def main(): N, *AB = list(map(int, open(0).read().split())) A = [(i, j) for i, j in zip(*[iter(AB)] * 2)] A.sort() ans = sum(A[-1]) print(ans) if __name__ == "__main__": main()
# tenka1-2017-beginnerB - Different Distribution def main(): N, *AB = list(map(int, open(0).read().split())) A = max(list(zip(*[iter(AB)] * 2))) ans = sum(A) print(ans) if __name__ == "__main__": main()
false
9.090909
[ "- A = [(i, j) for i, j in zip(*[iter(AB)] * 2)]", "- A.sort()", "- ans = sum(A[-1])", "+ A = max(list(zip(*[iter(AB)] * 2)))", "+ ans = sum(A)" ]
false
0.036616
0.038465
0.951939
[ "s554791678", "s111798430" ]
u327125861
p02396
python
s022105294
s033486468
150
130
7,508
7,564
Accepted
Accepted
13.33
i = 1 while 1: x = int(eval(input())) if x == 0: break print(("Case " + str(i) + ": " + str(x))) i = i + 1
i = 0 while True: x = int(eval(input())) if x == 0: break i = i + 1 print(("Case " + str(i) + ": " + str(x)))
7
6
110
110
i = 1 while 1: x = int(eval(input())) if x == 0: break print(("Case " + str(i) + ": " + str(x))) i = i + 1
i = 0 while True: x = int(eval(input())) if x == 0: break i = i + 1 print(("Case " + str(i) + ": " + str(x)))
false
14.285714
[ "-i = 1", "-while 1:", "+i = 0", "+while True:", "+ i = i + 1", "- i = i + 1" ]
false
0.04324
0.045594
0.948364
[ "s022105294", "s033486468" ]
u235598818
p02699
python
s840295301
s435477353
66
23
61,584
9,172
Accepted
Accepted
65.15
def main(): S,W=list(map(int,input().split())) if S<=W: print("unsafe") else: print("safe") if __name__ == '__main__': main()
S,W=list(map(int,input().split())) answer="safe" if S<=W: answer="unsafe" print(answer)
13
5
174
89
def main(): S, W = list(map(int, input().split())) if S <= W: print("unsafe") else: print("safe") if __name__ == "__main__": main()
S, W = list(map(int, input().split())) answer = "safe" if S <= W: answer = "unsafe" print(answer)
false
61.538462
[ "-def main():", "- S, W = list(map(int, input().split()))", "- if S <= W:", "- print(\"unsafe\")", "- else:", "- print(\"safe\")", "-", "-", "-if __name__ == \"__main__\":", "- main()", "+S, W = list(map(int, input().split()))", "+answer = \"safe\"", "+if S <= W:", ...
false
0.074843
0.036807
2.033362
[ "s840295301", "s435477353" ]
u086566114
p02266
python
s481869817
s945138653
20
10
6,856
6,860
Accepted
Accepted
50
# -*- coding: utf-8 -*- def main(): down_positions = [] ponds = [] for index, value in enumerate(input()): if value == '\\': down_positions.append(index) elif value == '/' and down_positions: right = index left = down_positions.pop() ...
# -*- coding: utf-8 -*- def main(): down_positions = [] ponds = [] for index, value in enumerate(input()): if value == '\\': down_positions.append(index) elif value == '/' and down_positions: right = index left = down_positions.pop() ...
29
27
867
788
# -*- coding: utf-8 -*- def main(): down_positions = [] ponds = [] for index, value in enumerate(input()): if value == "\\": down_positions.append(index) elif value == "/" and down_positions: right = index left = down_positions.pop() area = rig...
# -*- coding: utf-8 -*- def main(): down_positions = [] ponds = [] for index, value in enumerate(input()): if value == "\\": down_positions.append(index) elif value == "/" and down_positions: right = index left = down_positions.pop() area = rig...
false
6.896552
[ "- # candidate_pond = []", "- area2 = 0", "+ candidate_area = 0", "- # candidate_pond.append(ponds.pop(-1))", "- area2 += ponds.pop(-1)[1]", "- # new_pond = (left, area + sum([x[1] for x in candidate_pond]))", "- new_po...
false
0.086754
0.085831
1.010755
[ "s481869817", "s945138653" ]
u546285759
p01223
python
s710522146
s557598045
40
30
7,544
7,572
Accepted
Accepted
25
for _ in range(int(eval(input()))): _= int(eval(input())) upv=dov=0 h= list(map(int, input().split())) for i in range(len(h)-1): upv= max(upv, h[i+1]-h[i]) dov= max(dov, h[i]-h[i+1]) print((upv, dov))
t = int(eval(input())) for _ in range(t): n = int(eval(input())) h = list(map(int, input().split())) maxv = minv = 0 for i in range(len(h)-1): maxv = max(maxv, h[i+1]-h[i]) minv = max(minv, h[i]-h[i+1]) print((maxv, minv))
8
9
229
252
for _ in range(int(eval(input()))): _ = int(eval(input())) upv = dov = 0 h = list(map(int, input().split())) for i in range(len(h) - 1): upv = max(upv, h[i + 1] - h[i]) dov = max(dov, h[i] - h[i + 1]) print((upv, dov))
t = int(eval(input())) for _ in range(t): n = int(eval(input())) h = list(map(int, input().split())) maxv = minv = 0 for i in range(len(h) - 1): maxv = max(maxv, h[i + 1] - h[i]) minv = max(minv, h[i] - h[i + 1]) print((maxv, minv))
false
11.111111
[ "-for _ in range(int(eval(input()))):", "- _ = int(eval(input()))", "- upv = dov = 0", "+t = int(eval(input()))", "+for _ in range(t):", "+ n = int(eval(input()))", "+ maxv = minv = 0", "- upv = max(upv, h[i + 1] - h[i])", "- dov = max(dov, h[i] - h[i + 1])", "- print(...
false
0.095969
0.173826
0.552099
[ "s710522146", "s557598045" ]
u678167152
p02684
python
s652602409
s782114379
438
296
236,944
184,216
Accepted
Accepted
32.42
N, K = list(map(int, input().split())) A = list([int(x)-1 for x in input().split()]) db = [[0]*N for _ in range(100)] db[0] = A[:] for i in range(1,100): for j in range(N): db[i][j] = db[i-1][db[i-1][j]] ans = p = 0 while K>0: if K%2==1: ans = db[p][ans] p += 1 K >>= 1 print((ans+1))
N, K = list(map(int, input().split())) A = list([int(x)-1 for x in input().split()]) db = [[0]*N for _ in range(60)] db[0] = A[:] for i in range(1,60): for j in range(N): db[i][j] = db[i-1][db[i-1][j]] ans = p = 0 while K>0: if K%2==1: ans = db[p][ans] p += 1 K >>= 1 print((ans+1))
14
14
310
308
N, K = list(map(int, input().split())) A = list([int(x) - 1 for x in input().split()]) db = [[0] * N for _ in range(100)] db[0] = A[:] for i in range(1, 100): for j in range(N): db[i][j] = db[i - 1][db[i - 1][j]] ans = p = 0 while K > 0: if K % 2 == 1: ans = db[p][ans] p += 1 K >>= 1 pri...
N, K = list(map(int, input().split())) A = list([int(x) - 1 for x in input().split()]) db = [[0] * N for _ in range(60)] db[0] = A[:] for i in range(1, 60): for j in range(N): db[i][j] = db[i - 1][db[i - 1][j]] ans = p = 0 while K > 0: if K % 2 == 1: ans = db[p][ans] p += 1 K >>= 1 print...
false
0
[ "-db = [[0] * N for _ in range(100)]", "+db = [[0] * N for _ in range(60)]", "-for i in range(1, 100):", "+for i in range(1, 60):" ]
false
0.036894
0.054412
0.678055
[ "s652602409", "s782114379" ]
u997641430
p03078
python
s367555466
s353299317
1,982
1,604
161,608
160,192
Accepted
Accepted
19.07
X, Y, Z, K = list(map(int, input().split())) *A, = sorted(map(int, input().split()), reverse=True) *B, = sorted(map(int, input().split()), reverse=True) *C, = sorted(map(int, input().split()), reverse=True) AB = [A[x] + B[y] for y in range(Y) for x in range(X)] AB.sort(reverse=True) AB = AB[:K] XY = len(AB) ABC...
X, Y, Z, K = list(map(int, input().split())) *A, = sorted(map(int, input().split()), reverse=True) *B, = sorted(map(int, input().split()), reverse=True) *C, = sorted(map(int, input().split()), reverse=True) AB = [a+b for a in A for b in B] AB.sort(reverse=True) AB = AB[:K] XY = len(AB) ABC = [ab+c for c in C fo...
12
13
434
398
X, Y, Z, K = list(map(int, input().split())) (*A,) = sorted(map(int, input().split()), reverse=True) (*B,) = sorted(map(int, input().split()), reverse=True) (*C,) = sorted(map(int, input().split()), reverse=True) AB = [A[x] + B[y] for y in range(Y) for x in range(X)] AB.sort(reverse=True) AB = AB[:K] XY = len(AB) ABC =...
X, Y, Z, K = list(map(int, input().split())) (*A,) = sorted(map(int, input().split()), reverse=True) (*B,) = sorted(map(int, input().split()), reverse=True) (*C,) = sorted(map(int, input().split()), reverse=True) AB = [a + b for a in A for b in B] AB.sort(reverse=True) AB = AB[:K] XY = len(AB) ABC = [ab + c for c in C ...
false
7.692308
[ "-AB = [A[x] + B[y] for y in range(Y) for x in range(X)]", "+AB = [a + b for a in A for b in B]", "-ABC = [AB[xy] + C[z] for z in range(Z) for xy in range(XY)]", "+ABC = [ab + c for c in C for ab in AB]", "-for k in range(K):", "- print((ABC[k]))", "+ABC = ABC[:K]", "+for abc in ABC:", "+ prin...
false
0.046019
0.03836
1.19967
[ "s367555466", "s353299317" ]
u619458041
p03361
python
s558706635
s817982475
21
19
3,064
3,064
Accepted
Accepted
9.52
import sys def main(): input = sys.stdin.readline H, W = list(map(int, input().split())) A = [[0 for _ in range(W+2)] for _ in range(H+2)] for i in range(H): a = [0] + [int(c == '#') for c in input().strip()] + [0] A[i+1] = a ans = 'Yes' for i in range(H): for j in range(W): ...
import sys def main(): input = sys.stdin.readline H, W = list(map(int, input().split())) A = [[0 for _ in range(W+2)] for _ in range(H+2)] for i in range(H): a = [0] + [c == '#' for c in input().strip()] + [0] A[i+1] = a ans = 'Yes' for i in range(H): for j in range(W): if...
25
25
585
563
import sys def main(): input = sys.stdin.readline H, W = list(map(int, input().split())) A = [[0 for _ in range(W + 2)] for _ in range(H + 2)] for i in range(H): a = [0] + [int(c == "#") for c in input().strip()] + [0] A[i + 1] = a ans = "Yes" for i in range(H): for j i...
import sys def main(): input = sys.stdin.readline H, W = list(map(int, input().split())) A = [[0 for _ in range(W + 2)] for _ in range(H + 2)] for i in range(H): a = [0] + [c == "#" for c in input().strip()] + [0] A[i + 1] = a ans = "Yes" for i in range(H): for j in ran...
false
0
[ "- a = [0] + [int(c == \"#\") for c in input().strip()] + [0]", "+ a = [0] + [c == \"#\" for c in input().strip()] + [0]", "- if any([a == 1 for a in [u, d, r, l]]):", "+ if any([u, d, r, l]):" ]
false
0.09761
0.068123
1.432859
[ "s558706635", "s817982475" ]
u040298438
p03681
python
s407523844
s671058657
418
290
11,096
10,004
Accepted
Accepted
30.62
from math import factorial n, m = list(map(int, input().split())) if n == m: print(((factorial(n) ** 2 * 2) % (10 ** 9 + 7))) elif abs(n - m) == 1: print(((factorial(n) * factorial(m)) % (10 ** 9 + 7))) else: print((0))
from math import factorial n, m = list(map(int, input().split())) if n == m: ans = factorial(n) % (10 ** 9 + 7) ans = ans ** 2 % (10 ** 9 + 7) print((ans * 2 % (10 ** 9 + 7))) elif abs(n - m) == 1: ans1 = factorial(n) % (10 ** 9 + 7) ans2 = factorial(m) % (10 ** 9 + 7) print((ans1 * a...
9
13
228
352
from math import factorial n, m = list(map(int, input().split())) if n == m: print(((factorial(n) ** 2 * 2) % (10**9 + 7))) elif abs(n - m) == 1: print(((factorial(n) * factorial(m)) % (10**9 + 7))) else: print((0))
from math import factorial n, m = list(map(int, input().split())) if n == m: ans = factorial(n) % (10**9 + 7) ans = ans**2 % (10**9 + 7) print((ans * 2 % (10**9 + 7))) elif abs(n - m) == 1: ans1 = factorial(n) % (10**9 + 7) ans2 = factorial(m) % (10**9 + 7) print((ans1 * ans2 % (10**9 + 7))) el...
false
30.769231
[ "- print(((factorial(n) ** 2 * 2) % (10**9 + 7)))", "+ ans = factorial(n) % (10**9 + 7)", "+ ans = ans**2 % (10**9 + 7)", "+ print((ans * 2 % (10**9 + 7)))", "- print(((factorial(n) * factorial(m)) % (10**9 + 7)))", "+ ans1 = factorial(n) % (10**9 + 7)", "+ ans2 = factorial(m) % (10...
false
0.119539
0.043748
2.732417
[ "s407523844", "s671058657" ]
u277104886
p02695
python
s263949235
s158890585
641
309
22,652
9,140
Accepted
Accepted
51.79
from _collections import deque def cacl(seq): score = 0 for a, b, c, d in req: if seq[b-1] - seq[a-1] == c: score += d return score n, m, q = list(map(int, input().split())) req = [list(map(int, input().split())) for _ in range(q)] ans = 0 que = deque() for i in range(...
def dfs(seq): ans = 0 if len(seq) == n: score = 0 for a, b, c, d in req: if seq[b-1] - seq[a-1] == c: score += d return score else: for i in range(seq[-1], m+1): next_seq = seq + (i,) score = dfs(next_seq) ...
29
20
603
490
from _collections import deque def cacl(seq): score = 0 for a, b, c, d in req: if seq[b - 1] - seq[a - 1] == c: score += d return score n, m, q = list(map(int, input().split())) req = [list(map(int, input().split())) for _ in range(q)] ans = 0 que = deque() for i in range(1, m + 1): ...
def dfs(seq): ans = 0 if len(seq) == n: score = 0 for a, b, c, d in req: if seq[b - 1] - seq[a - 1] == c: score += d return score else: for i in range(seq[-1], m + 1): next_seq = seq + (i,) score = dfs(next_seq) ...
false
31.034483
[ "-from _collections import deque", "-", "-", "-def cacl(seq):", "- score = 0", "- for a, b, c, d in req:", "- if seq[b - 1] - seq[a - 1] == c:", "- score += d", "- return score", "+def dfs(seq):", "+ ans = 0", "+ if len(seq) == n:", "+ score = 0", "+...
false
0.09233
0.055313
1.669228
[ "s263949235", "s158890585" ]
u736479342
p03760
python
s848603660
s556419996
28
25
8,984
8,912
Accepted
Accepted
10.71
O = list(eval(input())) E = list(eval(input()))+[""] o = len(O) x =[] for i in range(o): ans = O[i] + E[i] x.append(ans) print(("".join(x)))
O = list(input()) E = list(input())+[""] for o,e in zip(O,E):print(o+e, end="")
9
3
139
81
O = list(eval(input())) E = list(eval(input())) + [""] o = len(O) x = [] for i in range(o): ans = O[i] + E[i] x.append(ans) print(("".join(x)))
O = list(input()) E = list(input()) + [""] for o, e in zip(O, E): print(o + e, end="")
false
66.666667
[ "-O = list(eval(input()))", "-E = list(eval(input())) + [\"\"]", "-o = len(O)", "-x = []", "-for i in range(o):", "- ans = O[i] + E[i]", "- x.append(ans)", "-print((\"\".join(x)))", "+O = list(input())", "+E = list(input()) + [\"\"]", "+for o, e in zip(O, E):", "+ print(o + e, end=\"\...
false
0.042624
0.03386
1.258806
[ "s848603660", "s556419996" ]
u226082503
p02642
python
s088078041
s650062500
390
173
195,124
195,384
Accepted
Accepted
55.64
N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 2 cnt = [0 for _ in range(M)] A.sort() for i in A: if cnt[i] != 0: # cnt[i]がそれまでに出てきた数値で割り切れていたとき cnt[i] = 2 # cnt[i]の倍数はどうせすでに1か2になっているので考慮しなくていい continue j = i while j < M: cnt[j] += 1 j +=...
N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 5 cnt = [0 for _ in range(M)] for i in A: if cnt[i] != 0: cnt[i] = 2 continue j = i while j < M: cnt[j] += 1 j += i ans = 0 for i in A: if cnt[i] == 1: ans += 1 print(an...
19
19
389
316
N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 2 cnt = [0 for _ in range(M)] A.sort() for i in A: if cnt[i] != 0: # cnt[i]がそれまでに出てきた数値で割り切れていたとき cnt[i] = 2 # cnt[i]の倍数はどうせすでに1か2になっているので考慮しなくていい continue j = i while j < M: cnt[j] += 1 j += i ans = 0 f...
N = int(eval(input())) A = list(map(int, input().split())) M = 10**6 + 5 cnt = [0 for _ in range(M)] for i in A: if cnt[i] != 0: cnt[i] = 2 continue j = i while j < M: cnt[j] += 1 j += i ans = 0 for i in A: if cnt[i] == 1: ans += 1 print(ans)
false
0
[ "-M = 10**6 + 2", "+M = 10**6 + 5", "-A.sort()", "- if cnt[i] != 0: # cnt[i]がそれまでに出てきた数値で割り切れていたとき", "- cnt[i] = 2 # cnt[i]の倍数はどうせすでに1か2になっているので考慮しなくていい", "+ if cnt[i] != 0:", "+ cnt[i] = 2" ]
false
1.005838
0.583998
1.72233
[ "s088078041", "s650062500" ]
u261103969
p02699
python
s773800213
s847900296
60
20
61,584
9,072
Accepted
Accepted
66.67
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): s, w = list(map(int, readline().split())) if w >= s: print("unsafe") else: print("safe") if __name__ == '__main__': main()
s, w = list(map(int, input().split())) if w >= s: print("unsafe") else: print("safe")
19
6
300
99
import sys readline = sys.stdin.readline MOD = 10**9 + 7 INF = float("INF") sys.setrecursionlimit(10**5) def main(): s, w = list(map(int, readline().split())) if w >= s: print("unsafe") else: print("safe") if __name__ == "__main__": main()
s, w = list(map(int, input().split())) if w >= s: print("unsafe") else: print("safe")
false
68.421053
[ "-import sys", "-", "-readline = sys.stdin.readline", "-MOD = 10**9 + 7", "-INF = float(\"INF\")", "-sys.setrecursionlimit(10**5)", "-", "-", "-def main():", "- s, w = list(map(int, readline().split()))", "- if w >= s:", "- print(\"unsafe\")", "- else:", "- print(\"s...
false
0.15238
0.037105
4.106781
[ "s773800213", "s847900296" ]
u077291787
p02558
python
s139832963
s495190870
315
276
146,408
145,288
Accepted
Accepted
12.38
from typing import List class UnionFind: """Union Find (Disjoint Set): O(α(N)) References: https://github.com/atcoder/ac-library/blob/master/atcoder/dsu.hpp https://tumoiyorozu.github.io/single-file-ac-library/document_en/dsu.html """ __slots__ = ["_data_size", "_roots"] ...
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, N): self._data_size = N self._roots = [-1] * N def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def unite(self, x, y): ...
57
44
1,672
998
from typing import List class UnionFind: """Union Find (Disjoint Set): O(α(N)) References: https://github.com/atcoder/ac-library/blob/master/atcoder/dsu.hpp https://tumoiyorozu.github.io/single-file-ac-library/document_en/dsu.html """ __slots__ = ["_data_size", "_roots"] def __in...
class UnionFind: __slots__ = ["_data_size", "_roots"] def __init__(self, N): self._data_size = N self._roots = [-1] * N def __getitem__(self, x: int) -> int: while self._roots[x] >= 0: x = self._roots[x] return x def unite(self, x, y): x = self[x] ...
false
22.807018
[ "-from typing import List", "-", "-", "- \"\"\"Union Find (Disjoint Set): O(α(N))", "- References:", "- https://github.com/atcoder/ac-library/blob/master/atcoder/dsu.hpp", "- https://tumoiyorozu.github.io/single-file-ac-library/document_en/dsu.html", "- \"\"\"", "-", "- d...
false
0.034506
0.035028
0.985097
[ "s139832963", "s495190870" ]
u818283165
p03478
python
s124077424
s278897305
41
30
3,060
3,060
Accepted
Accepted
26.83
N,A,B = list(map(int,input().split())) ans = 0 for i in range(N+1): n = str(i) a = 0 for j in range(len(n)): a += int(n[j:j+1]) if a >= A and a <= B: ans += i print(ans)
N,A,B = list(map(int,input().split())) def digit_sum(n): sum = 0 while (n>0): sum += n%10 n = int(n/10) return(sum) ans = 0 for i in range(N+1): a = digit_sum(i) if A <= a <= B: ans += i # print(i) print(ans)
10
15
204
268
N, A, B = list(map(int, input().split())) ans = 0 for i in range(N + 1): n = str(i) a = 0 for j in range(len(n)): a += int(n[j : j + 1]) if a >= A and a <= B: ans += i print(ans)
N, A, B = list(map(int, input().split())) def digit_sum(n): sum = 0 while n > 0: sum += n % 10 n = int(n / 10) return sum ans = 0 for i in range(N + 1): a = digit_sum(i) if A <= a <= B: ans += i # print(i) print(ans)
false
33.333333
[ "+", "+", "+def digit_sum(n):", "+ sum = 0", "+ while n > 0:", "+ sum += n % 10", "+ n = int(n / 10)", "+ return sum", "+", "+", "- n = str(i)", "- a = 0", "- for j in range(len(n)):", "- a += int(n[j : j + 1])", "- if a >= A and a <= B:", "+ ...
false
0.042493
0.036255
1.17208
[ "s124077424", "s278897305" ]
u977661421
p03319
python
s353393180
s894493375
44
40
13,880
13,812
Accepted
Accepted
9.09
# -*- coding: utf-8 -*- n, k = list(map(int,input().split())) a = [int(i) for i in input().split()] ans = ((n - 1) + (k - 1) - 1) // (k - 1) print(ans)
import math n, k = list(map(int,input().split())) a = list(map(int, input().split())) ans = math.ceil((n - 1) / (k - 1)) print(ans)
6
6
152
131
# -*- coding: utf-8 -*- n, k = list(map(int, input().split())) a = [int(i) for i in input().split()] ans = ((n - 1) + (k - 1) - 1) // (k - 1) print(ans)
import math n, k = list(map(int, input().split())) a = list(map(int, input().split())) ans = math.ceil((n - 1) / (k - 1)) print(ans)
false
0
[ "-# -*- coding: utf-8 -*-", "+import math", "+", "-a = [int(i) for i in input().split()]", "-ans = ((n - 1) + (k - 1) - 1) // (k - 1)", "+a = list(map(int, input().split()))", "+ans = math.ceil((n - 1) / (k - 1))" ]
false
0.050438
0.051361
0.982029
[ "s353393180", "s894493375" ]
u652656291
p03625
python
s464892147
s447661699
162
103
17,424
14,252
Accepted
Accepted
36.42
n=int(eval(input())) a=sorted(list(map(int,input().split())),reverse=True) x,y=0,0 def groupby(a): a2=[[a[0],1]] for i in range(1,len(a)): if a2[-1][0]==a[i]: a2[-1][1]+=1 else: a2.append([a[i],1]) return a2 b=groupby(a) l=len(b) for i in range(l): i...
n =int(eval(input())) a = list(map(int,input().split())) a.sort() x,y,i = 0,0,0 while i<n: if a[i-1] == a[i]: x,y = y,a[i] i += 1 i += 1 print((x*y))
25
10
528
163
n = int(eval(input())) a = sorted(list(map(int, input().split())), reverse=True) x, y = 0, 0 def groupby(a): a2 = [[a[0], 1]] for i in range(1, len(a)): if a2[-1][0] == a[i]: a2[-1][1] += 1 else: a2.append([a[i], 1]) return a2 b = groupby(a) l = len(b) for i in ra...
n = int(eval(input())) a = list(map(int, input().split())) a.sort() x, y, i = 0, 0, 0 while i < n: if a[i - 1] == a[i]: x, y = y, a[i] i += 1 i += 1 print((x * y))
false
60
[ "-a = sorted(list(map(int, input().split())), reverse=True)", "-x, y = 0, 0", "-", "-", "-def groupby(a):", "- a2 = [[a[0], 1]]", "- for i in range(1, len(a)):", "- if a2[-1][0] == a[i]:", "- a2[-1][1] += 1", "- else:", "- a2.append([a[i], 1])", "- ...
false
0.03763
0.042919
0.876768
[ "s464892147", "s447661699" ]
u706414019
p02579
python
s357940273
s046373711
1,425
1,201
128,192
127,548
Accepted
Accepted
15.72
#abc176-d import sys,math,collections,itertools input = sys.stdin.readline H,W=list(map(int,input().split())) Ch,Cw=list(map(int,input().split())) Dh,Dw=list(map(int,input().split())) s=[ input().rstrip() for _ in range(H)] #DPで遷移が2種類 初期値をinf として、現在値より小さければ遷移可能とする dp = [ [float('inf') ]*W for _ in range(...
#abc176-d import sys,math,collections,itertools input = sys.stdin.readline H,W=list(map(int,input().split())) Ch,Cw=list(map(int,input().split())) Dh,Dw=list(map(int,input().split())) s=[ input().rstrip() for _ in range(H)] #DPで遷移が2種類 初期値をinf として、現在値より小さければ遷移可能とする dp = [ [float('inf') ]*W for _ in range(...
47
40
1,534
1,316
# abc176-d import sys, math, collections, itertools input = sys.stdin.readline H, W = list(map(int, input().split())) Ch, Cw = list(map(int, input().split())) Dh, Dw = list(map(int, input().split())) s = [input().rstrip() for _ in range(H)] # DPで遷移が2種類 初期値をinf として、現在値より小さければ遷移可能とする dp = [[float("inf")] * W for _ in ra...
# abc176-d import sys, math, collections, itertools input = sys.stdin.readline H, W = list(map(int, input().split())) Ch, Cw = list(map(int, input().split())) Dh, Dw = list(map(int, input().split())) s = [input().rstrip() for _ in range(H)] # DPで遷移が2種類 初期値をinf として、現在値より小さければ遷移可能とする dp = [[float("inf")] * W for _ in ra...
false
14.893617
[ "-while q:", "- visit = []", "- while q:", "+while q: # qがある間の遷移 BSF", "+ visit = [] # 徒歩で動いたところをメモする", "+ while q: # 徒歩用のq", "- if nh > 0 and s[nh - 1][nw] == \".\" and dp[nh - 1][nw] > dp[nh][nw]:", "- q.append((nh - 1, nw))", "- dp[nh - 1][nw] = dp[nh][...
false
0.047492
0.16254
0.292184
[ "s357940273", "s046373711" ]
u631277801
p03611
python
s023135566
s904267114
162
109
30,684
29,960
Accepted
Accepted
32.72
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) A_p1 = [a+1 for a in A] A_m1 = [a-1 for a in A] cnt = Counter(A_p1) cnt += Counter(A) cnt += Counter(A_m1) print((max(list(cnt.values()))))
import sys stdin = sys.stdin def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().rstrip() def lc(): return...
13
23
238
582
from collections import Counter N = int(eval(input())) A = list(map(int, input().split())) A_p1 = [a + 1 for a in A] A_m1 = [a - 1 for a in A] cnt = Counter(A_p1) cnt += Counter(A) cnt += Counter(A_m1) print((max(list(cnt.values()))))
import sys stdin = sys.stdin def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readline().r...
false
43.478261
[ "+import sys", "+", "+stdin = sys.stdin", "+", "+", "+def li():", "+ return list(map(int, stdin.readline().split()))", "+", "+", "+def li_():", "+ return [int(x) - 1 for x in stdin.readline().split()]", "+", "+", "+def lf():", "+ return list(map(float, stdin.readline().split()))...
false
0.044637
0.044159
1.010837
[ "s023135566", "s904267114" ]
u934442292
p03161
python
s053525925
s244709051
736
641
111,652
121,828
Accepted
Accepted
12.91
import sys import numba as nb import numpy as np input = sys.stdin.readline INF = float("inf") @nb.njit def solve(N, K, h): dp = [0] * N for i in range(1, N): min_cost = INF for k in range(1, min(K + 1, i + 1)): cost = dp[i - k] + abs(h[i] - h[i - k]) ...
import sys import numba as nb import numpy as np input = sys.stdin.readline INF = float("inf") @nb.njit("i8(i8,i8,i8[:])") def solve(N, K, h): dp = [0] * N for i in range(1, N): min_cost = INF for k in range(1, min(K + 1, i + 1)): cost = dp[i - k] + abs(h[i] - h[i ...
32
32
612
631
import sys import numba as nb import numpy as np input = sys.stdin.readline INF = float("inf") @nb.njit def solve(N, K, h): dp = [0] * N for i in range(1, N): min_cost = INF for k in range(1, min(K + 1, i + 1)): cost = dp[i - k] + abs(h[i] - h[i - k]) if cost < min_cos...
import sys import numba as nb import numpy as np input = sys.stdin.readline INF = float("inf") @nb.njit("i8(i8,i8,i8[:])") def solve(N, K, h): dp = [0] * N for i in range(1, N): min_cost = INF for k in range(1, min(K + 1, i + 1)): cost = dp[i - k] + abs(h[i] - h[i - k]) ...
false
0
[ "-@nb.njit", "+@nb.njit(\"i8(i8,i8,i8[:])\")" ]
false
0.056094
0.081351
0.689532
[ "s053525925", "s244709051" ]
u135389999
p02687
python
s242724143
s672921962
23
21
9,024
9,076
Accepted
Accepted
8.7
n = str(eval(input())) if n == "ABC": print("ARC") else: print("ABC")
S = eval(input()) if S == "ABC": print("ARC") else: print("ABC")
6
5
77
66
n = str(eval(input())) if n == "ABC": print("ARC") else: print("ABC")
S = eval(input()) if S == "ABC": print("ARC") else: print("ABC")
false
16.666667
[ "-n = str(eval(input()))", "-if n == \"ABC\":", "+S = eval(input())", "+if S == \"ABC\":" ]
false
0.047275
0.035862
1.318247
[ "s242724143", "s672921962" ]
u952708174
p03078
python
s125802808
s591592823
976
576
138,736
4,084
Accepted
Accepted
40.98
def d_cake_123_sort_modified(X, Y, Z, K, A, B, C): # editionalの解法1 ab = sorted([a + b for b in B for a in A], reverse=True)[:K] ans = sorted([e + c for e in ab for c in C], reverse=True)[:K] return ' '.join(map(str, ans)) X, Y, Z, K = [int(i) for i in input().split()] A = [int(i) for i in input(...
def d_cake_123_priority_queue(X, Y, Z, K, A, B, C): # editionalの解法3 import heapq # 数列A, B, Cを降順ソート a, b, c = sorted(A, reverse=True), sorted(B, reverse=True), sorted(C, reverse=True) def evaluation(x, y, z): # heapqは最小値を取り出す方式なので、符号を反転させないといけない return (-(a[x] + b[y] + c[z]),...
11
32
462
1,195
def d_cake_123_sort_modified(X, Y, Z, K, A, B, C): # editionalの解法1 ab = sorted([a + b for b in B for a in A], reverse=True)[:K] ans = sorted([e + c for e in ab for c in C], reverse=True)[:K] return " ".join(map(str, ans)) X, Y, Z, K = [int(i) for i in input().split()] A = [int(i) for i in input().spli...
def d_cake_123_priority_queue(X, Y, Z, K, A, B, C): # editionalの解法3 import heapq # 数列A, B, Cを降順ソート a, b, c = sorted(A, reverse=True), sorted(B, reverse=True), sorted(C, reverse=True) def evaluation(x, y, z): # heapqは最小値を取り出す方式なので、符号を反転させないといけない return (-(a[x] + b[y] + c[z]), x, y, ...
false
65.625
[ "-def d_cake_123_sort_modified(X, Y, Z, K, A, B, C):", "- # editionalの解法1", "- ab = sorted([a + b for b in B for a in A], reverse=True)[:K]", "- ans = sorted([e + c for e in ab for c in C], reverse=True)[:K]", "- return \" \".join(map(str, ans))", "+def d_cake_123_priority_queue(X, Y, Z, K, A,...
false
0.047813
0.042004
1.138302
[ "s125802808", "s591592823" ]
u888337853
p03112
python
s731153757
s296655255
983
579
19,184
19,140
Accepted
Accepted
41.1
import sys import re import math import collections import bisect import itertools import fractions import functools import copy import heapq import decimal import statistics import queue # import numpy as np sys.setrecursionlimit(10 ** 9) INF = 10 ** 16 MOD = 10 ** 9 + 7 # MOD = 998244353 ni = ...
import sys import re import math import collections import bisect import itertools import fractions import functools import copy import heapq import decimal import statistics import queue # import numpy as np sys.setrecursionlimit(10 ** 9) INF = 10 ** 16 MOD = 10 ** 9 + 7 # MOD = 998244353 ni = ...
69
62
1,722
1,265
import sys import re import math import collections import bisect import itertools import fractions import functools import copy import heapq import decimal import statistics import queue # import numpy as np sys.setrecursionlimit(10**9) INF = 10**16 MOD = 10**9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readlin...
import sys import re import math import collections import bisect import itertools import fractions import functools import copy import heapq import decimal import statistics import queue # import numpy as np sys.setrecursionlimit(10**9) INF = 10**16 MOD = 10**9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readlin...
false
10.144928
[ "- return small, large", "+ return [small, large]", "- tmpans = [0] * 4", "- sml, lrg = disLR(s, idxs)", "- tmpans[0] += abs(x - sml)", "- tmpans[1] += abs(x - lrg)", "- idxsml = bisect.bisect_left(t, sml)", "- tmpans[0] += min([abs(sml - i) for i in dis...
false
0.037112
0.044902
0.826506
[ "s731153757", "s296655255" ]
u646336881
p02707
python
s322856930
s384616426
336
187
132,496
124,988
Accepted
Accepted
44.35
#!/usr/bin/env python3 # Generated by https://github.com/kyuridenamida/atcoder-tools from typing import * import collections import itertools import math import sys INF = float('inf') def solve(N: int, A: "List[int]"): c = collections.Counter(A+[i+1 for i in range(N)]) return "\n".join([f'{c[i+1...
#!/usr/bin/env python3 # Generated by https://github.com/kyuridenamida/atcoder-tools from typing import * import collections import itertools import math import sys INF = float('inf') def solve(N: int, A: "List[int]"): c = collections.Counter(A) return "\n".join([f'{c[i+1]}' for i in range(N)]) ...
32
32
744
718
#!/usr/bin/env python3 # Generated by https://github.com/kyuridenamida/atcoder-tools from typing import * import collections import itertools import math import sys INF = float("inf") def solve(N: int, A: "List[int]"): c = collections.Counter(A + [i + 1 for i in range(N)]) return "\n".join([f"{c[i+1]-1}" for...
#!/usr/bin/env python3 # Generated by https://github.com/kyuridenamida/atcoder-tools from typing import * import collections import itertools import math import sys INF = float("inf") def solve(N: int, A: "List[int]"): c = collections.Counter(A) return "\n".join([f"{c[i+1]}" for i in range(N)]) def main():...
false
0
[ "- c = collections.Counter(A + [i + 1 for i in range(N)])", "- return \"\\n\".join([f\"{c[i+1]-1}\" for i in range(N)])", "+ c = collections.Counter(A)", "+ return \"\\n\".join([f\"{c[i+1]}\" for i in range(N)])" ]
false
0.040568
0.043392
0.934926
[ "s322856930", "s384616426" ]
u861471387
p02665
python
s490377650
s997026575
225
156
86,576
83,452
Accepted
Accepted
30.67
N = int(eval(input())) A = list(map(int,input().split())) P=[0]*(N+1) P[N]=A[N] Q=[0]*(N+1) Q[N]=A[N] for i in range(N,0,-1): mxp=P[i]+A[i-1] mnp=(P[i]//2) + (P[i]%2) +A[i-1] mxq=Q[i]+A[i-1] mnq=(Q[i]//2) + (Q[i]%2) +A[i-1] if mnp>2**i: print((-1)) exit() P[i-1]...
N = int(eval(input())) A = list(map(int,input().split())) P=[0]*(N+1) P[N]=A[N] Q=[0]*(N+1) Q[N]=A[N] for i in range(N,0,-1): mxp=P[i]+A[i-1] mnp=(P[i]//2) + (P[i]%2) +A[i-1] mxq=Q[i]+A[i-1] mnq=(Q[i]//2) + (Q[i]%2) +A[i-1] P[i-1]=mnp Q[i-1]=min(mxq,2**i) if P[0]!=1: p...
32
29
537
490
N = int(eval(input())) A = list(map(int, input().split())) P = [0] * (N + 1) P[N] = A[N] Q = [0] * (N + 1) Q[N] = A[N] for i in range(N, 0, -1): mxp = P[i] + A[i - 1] mnp = (P[i] // 2) + (P[i] % 2) + A[i - 1] mxq = Q[i] + A[i - 1] mnq = (Q[i] // 2) + (Q[i] % 2) + A[i - 1] if mnp > 2**i: prin...
N = int(eval(input())) A = list(map(int, input().split())) P = [0] * (N + 1) P[N] = A[N] Q = [0] * (N + 1) Q[N] = A[N] for i in range(N, 0, -1): mxp = P[i] + A[i - 1] mnp = (P[i] // 2) + (P[i] % 2) + A[i - 1] mxq = Q[i] + A[i - 1] mnq = (Q[i] // 2) + (Q[i] % 2) + A[i - 1] P[i - 1] = mnp Q[i - 1]...
false
9.375
[ "- if mnp > 2**i:", "- print((-1))", "- exit()" ]
false
0.0335
0.04184
0.800674
[ "s490377650", "s997026575" ]
u215334265
p02711
python
s577340780
s077720640
61
56
61,656
61,804
Accepted
Accepted
8.2
n = eval(input()) if n[0] == '7' or n[1] == '7' or n[2] == '7': print('Yes') else: print('No')
n = eval(input()) n = n.count('7') if n >= 1: print('Yes') else: print('No')
5
7
101
89
n = eval(input()) if n[0] == "7" or n[1] == "7" or n[2] == "7": print("Yes") else: print("No")
n = eval(input()) n = n.count("7") if n >= 1: print("Yes") else: print("No")
false
28.571429
[ "-if n[0] == \"7\" or n[1] == \"7\" or n[2] == \"7\":", "+n = n.count(\"7\")", "+if n >= 1:" ]
false
0.048268
0.055956
0.862618
[ "s577340780", "s077720640" ]