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
u588794534
p02960
python
s454786414
s688787013
733
294
66,012
95,608
Accepted
Accepted
59.89
s=eval(input()) #i桁以下の数字でmodがjの数 #dp[i][j]= dp=[[0 for _ in range(13)] for _ in range(len(s))] MOD=10**9+7 if s[0]!="?": dp[0][int(s[0])]=1 else: for i in range(10): dp[0][i]=1 for i in range(1,len(s)): si=s[i] if s[i]!="?": #数字,300のmodをtempに for j i...
s=eval(input()) mod=10**9+7 ans=[[0]*13 for _ in range(len(s))] if s[-1]=="?": for i in range(10): ans[-1][i%13]+=1 else: ans[-1][int(s[-1])%13]+=1 #print(ans) ten=1 for ii in range(1,len(s)): ten=(ten*10)%13 i=len(s)-ii-1 if s[i]!="?": tmp=(int(s[i])*...
39
34
590
588
s = eval(input()) # i桁以下の数字でmodがjの数 # dp[i][j]= dp = [[0 for _ in range(13)] for _ in range(len(s))] MOD = 10**9 + 7 if s[0] != "?": dp[0][int(s[0])] = 1 else: for i in range(10): dp[0][i] = 1 for i in range(1, len(s)): si = s[i] if s[i] != "?": # 数字,300のmodをtempに for j in range(...
s = eval(input()) mod = 10**9 + 7 ans = [[0] * 13 for _ in range(len(s))] if s[-1] == "?": for i in range(10): ans[-1][i % 13] += 1 else: ans[-1][int(s[-1]) % 13] += 1 # print(ans) ten = 1 for ii in range(1, len(s)): ten = (ten * 10) % 13 i = len(s) - ii - 1 if s[i] != "?": tmp = (in...
false
12.820513
[ "-# i桁以下の数字でmodがjの数", "-# dp[i][j]=", "-dp = [[0 for _ in range(13)] for _ in range(len(s))]", "-MOD = 10**9 + 7", "-if s[0] != \"?\":", "- dp[0][int(s[0])] = 1", "+mod = 10**9 + 7", "+ans = [[0] * 13 for _ in range(len(s))]", "+if s[-1] == \"?\":", "+ for i in range(10):", "+ ans[-...
false
0.035389
0.044188
0.800875
[ "s454786414", "s688787013" ]
u175590965
p02773
python
s972859485
s281682447
612
463
35,952
35,288
Accepted
Accepted
24.35
from collections import Counter n = int(eval(input())) a = [eval(input()) for i in range(n)] cnt = Counter(a) l = max(cnt.values()) ans = [s for s,c in list(cnt.items())if c ==l] ans.sort() print(('\n'.join(ans)))
n = int(eval(input())) s = dict() for i in range(n): si = eval(input()) if si in s: s[si] +=1 else: s[si] = 0 l = max(s.values()) ans = [] for i in s: if s[i] ==l: ans.append(i) ans.sort() for i in ans: print(i)
8
16
202
258
from collections import Counter n = int(eval(input())) a = [eval(input()) for i in range(n)] cnt = Counter(a) l = max(cnt.values()) ans = [s for s, c in list(cnt.items()) if c == l] ans.sort() print(("\n".join(ans)))
n = int(eval(input())) s = dict() for i in range(n): si = eval(input()) if si in s: s[si] += 1 else: s[si] = 0 l = max(s.values()) ans = [] for i in s: if s[i] == l: ans.append(i) ans.sort() for i in ans: print(i)
false
50
[ "-from collections import Counter", "-", "-a = [eval(input()) for i in range(n)]", "-cnt = Counter(a)", "-l = max(cnt.values())", "-ans = [s for s, c in list(cnt.items()) if c == l]", "+s = dict()", "+for i in range(n):", "+ si = eval(input())", "+ if si in s:", "+ s[si] += 1", "+...
false
0.04496
0.007831
5.741285
[ "s972859485", "s281682447" ]
u318427318
p02959
python
s052133972
s218760407
417
302
39,708
39,692
Accepted
Accepted
27.58
#-*-coding:utf-8-*- import sys input=sys.stdin.readline import numpy as np def main(): n = int(eval(input())) mob=np.array(list(map(int,input().split())),dtype=int) bra=np.array(list(map(int,input().split())),dtype=int) ans=0 for i in range(n): ans += min(mob[i],bra[i]) ...
#-*-coding:utf-8-*- import sys input=sys.stdin.readline import numpy as np def main(): n = int(eval(input())) mob=np.array(list(map(int,input().split())),dtype=int) bra=np.array(list(map(int,input().split())),dtype=int) ans=0 for i in range(n): tmp1=min(mob[i],bra[i]) ...
20
22
479
468
# -*-coding:utf-8-*- import sys input = sys.stdin.readline import numpy as np def main(): n = int(eval(input())) mob = np.array(list(map(int, input().split())), dtype=int) bra = np.array(list(map(int, input().split())), dtype=int) ans = 0 for i in range(n): ans += min(mob[i], bra[i]) ...
# -*-coding:utf-8-*- import sys input = sys.stdin.readline import numpy as np def main(): n = int(eval(input())) mob = np.array(list(map(int, input().split())), dtype=int) bra = np.array(list(map(int, input().split())), dtype=int) ans = 0 for i in range(n): tmp1 = min(mob[i], bra[i]) ...
false
9.090909
[ "- ans += min(mob[i], bra[i])", "- ans += min(mob[i + 1], bra[i] - min(mob[i], bra[i]))", "- mob[i + 1] -= min(mob[i + 1], bra[i] - min(mob[i], bra[i]))", "+ tmp1 = min(mob[i], bra[i])", "+ ans += tmp1", "+ tmp2 = min(mob[i + 1], bra[i] - tmp1)", "+ ans +...
false
1.227681
0.725719
1.691676
[ "s052133972", "s218760407" ]
u411203878
p02988
python
s424629368
s812062719
175
65
38,384
61,768
Accepted
Accepted
62.86
n=int(eval(input())) t = list(map(int,input().split())) count = 0 for i in range(n-2): if t[i] <= t[i+1] and t[i+1] <= t[i+2] or t[i] >= t[i+1] and t[i+1] >= t[i+2]: count += 1 print(count)
n = int(eval(input())) t = list(map(int,input().split())) ans = 0 for i in range(1,n-1): if t[i-1] < t[i] < t[i+1] or t[i-1] > t[i] > t[i+1]: ans += 1 print(ans)
10
10
214
179
n = int(eval(input())) t = list(map(int, input().split())) count = 0 for i in range(n - 2): if ( t[i] <= t[i + 1] and t[i + 1] <= t[i + 2] or t[i] >= t[i + 1] and t[i + 1] >= t[i + 2] ): count += 1 print(count)
n = int(eval(input())) t = list(map(int, input().split())) ans = 0 for i in range(1, n - 1): if t[i - 1] < t[i] < t[i + 1] or t[i - 1] > t[i] > t[i + 1]: ans += 1 print(ans)
false
0
[ "-count = 0", "-for i in range(n - 2):", "- if (", "- t[i] <= t[i + 1]", "- and t[i + 1] <= t[i + 2]", "- or t[i] >= t[i + 1]", "- and t[i + 1] >= t[i + 2]", "- ):", "- count += 1", "-print(count)", "+ans = 0", "+for i in range(1, n - 1):", "+ if t...
false
0.045303
0.044022
1.029099
[ "s424629368", "s812062719" ]
u612721349
p03276
python
s741107792
s565539304
259
237
62,576
62,800
Accepted
Accepted
8.49
#!/usr/bin/env python # -*- coding: utf-8 -*- import bisect def solve(): n, k = list(map(int, input().split())) al = [int(i) for i in input().split()] ans = sum(abs(i) for i in al) flag0 = 0 in al if flag0: k -= 1 n -= 1 if k == 0: print((0)) ...
#!/usr/bin/env python # -*- coding: utf-8 -*- import bisect def solve(): n, k = list(map(int, input().split())) al = [int(i) for i in input().split()] ans = sum(abs(i) for i in al) flag0 = 0 in al if flag0: k -= 1 n -= 1 if k == 0: print((0)) ...
55
40
1,570
1,004
#!/usr/bin/env python # -*- coding: utf-8 -*- import bisect def solve(): n, k = list(map(int, input().split())) al = [int(i) for i in input().split()] ans = sum(abs(i) for i in al) flag0 = 0 in al if flag0: k -= 1 n -= 1 if k == 0: print((0)) return ...
#!/usr/bin/env python # -*- coding: utf-8 -*- import bisect def solve(): n, k = list(map(int, input().split())) al = [int(i) for i in input().split()] ans = sum(abs(i) for i in al) flag0 = 0 in al if flag0: k -= 1 n -= 1 if k == 0: print((0)) return ...
false
27.272727
[ "- for i in range(n - 1, -1, -1):", "- if i - k + 1 < 0 or i >= n:", "- break", "- if al[i] < 0 and al[i - k + 1] < 0:", "- t1 = abs(al[i - k + 1])", "- else:", "- t1 = min(", "- abs(al[i - k + 1]) * 2 + abs(al[i]), abs(al[i - k +...
false
0.049541
0.089352
0.554449
[ "s741107792", "s565539304" ]
u763249708
p02689
python
s062251314
s327551456
279
256
20,948
20,080
Accepted
Accepted
8.24
n, m = list(map(int, input().split())) h = list(map(int, input().split())) roads = [] for i in range(n): roads.append([]) is_good_peak_arr = [True] * n for i in range(m): a, b = list(map(int, input().split())) a, b = a-1, b-1 if h[a] >= h[b]: is_good_peak_arr[b] = False if h[b] >= h[a]: i...
n, m = list(map(int, input().split())) h = list(map(int, input().split())) is_good_peak_arr = [True] * n for i in range(m): a, b = list(map(int, input().split())) a, b = a-1, b-1 if h[a] >= h[b]: is_good_peak_arr[b] = False if h[b] >= h[a]: is_good_peak_arr[a] = False print((is_good_...
14
12
374
328
n, m = list(map(int, input().split())) h = list(map(int, input().split())) roads = [] for i in range(n): roads.append([]) is_good_peak_arr = [True] * n for i in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 if h[a] >= h[b]: is_good_peak_arr[b] = False if h[b] >= h[a]: ...
n, m = list(map(int, input().split())) h = list(map(int, input().split())) is_good_peak_arr = [True] * n for i in range(m): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 if h[a] >= h[b]: is_good_peak_arr[b] = False if h[b] >= h[a]: is_good_peak_arr[a] = False print((is_good_...
false
14.285714
[ "-roads = []", "-for i in range(n):", "- roads.append([])" ]
false
0.037546
0.048844
0.768691
[ "s062251314", "s327551456" ]
u102461423
p03008
python
s769333753
s503991996
186
21
39,664
3,316
Accepted
Accepted
88.71
import sys input = sys.stdin.readline def F(N,A,B): AB = list(zip(A,B)) AB = [(a,b) for a,b in AB if a < b] # 有用なやつだけ AB.sort(key = lambda x: x[1]/x[0], reverse = True) if len(AB) == 0: return N if len(AB) == 1: a,b = AB[0] x = N//a return N + (b-a) * x ...
import sys input = sys.stdin.readline def F(N,A,B): AB = list(zip(A,B)) AB = [(a,b) for a,b in AB if a < b] # 有用なやつだけ AB.sort(key = lambda x: x[1]/x[0], reverse = True) if len(AB) == 0: return N if len(AB) == 1: a,b = AB[0] x = N//a return N + (b-a) * x ...
39
31
928
808
import sys input = sys.stdin.readline def F(N, A, B): AB = list(zip(A, B)) AB = [(a, b) for a, b in AB if a < b] # 有用なやつだけ AB.sort(key=lambda x: x[1] / x[0], reverse=True) if len(AB) == 0: return N if len(AB) == 1: a, b = AB[0] x = N // a return N + (b - a) * x ...
import sys input = sys.stdin.readline def F(N, A, B): AB = list(zip(A, B)) AB = [(a, b) for a, b in AB if a < b] # 有用なやつだけ AB.sort(key=lambda x: x[1] / x[0], reverse=True) if len(AB) == 0: return N if len(AB) == 1: a, b = AB[0] x = N // a return N + (b - a) * x ...
false
20.512821
[ "- # 効率の良いものから並んでいる", "- dp = [0] * (N + 1)", "- for n in range(N + 1):", "- x = n", "- for a, b in AB:", "- if n >= a:", "- y = dp[n - a] + b", "- if x < y:", "- x = y", "- dp[n] = x", "+ dp = list(rang...
false
0.060962
0.037914
1.607903
[ "s769333753", "s503991996" ]
u929569377
p03557
python
s018030321
s519949168
1,533
948
23,640
23,292
Accepted
Accepted
38.16
N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] A.sort() B.sort() C.sort() ans = 0 for i in B: OK = -1 NG = N while NG - OK > 1: mid = (OK + NG) // 2 if A[mid] < i: OK = m...
N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] A.sort() C.sort() ans = 0 def bisect(array, threshold, equal=False): OK = -1 NG = N while NG - OK > 1: mid = (OK + NG) // 2 if array[mid]...
34
27
609
565
N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] A.sort() B.sort() C.sort() ans = 0 for i in B: OK = -1 NG = N while NG - OK > 1: mid = (OK + NG) // 2 if A[mid] < i: OK = mid else: ...
N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] A.sort() C.sort() ans = 0 def bisect(array, threshold, equal=False): OK = -1 NG = N while NG - OK > 1: mid = (OK + NG) // 2 if array[mid] < threshold: ...
false
20.588235
[ "-B.sort()", "-for i in B:", "+", "+", "+def bisect(array, threshold, equal=False):", "- if A[mid] < i:", "+ if array[mid] < threshold:", "+ OK = mid", "+ elif equal == True and array[mid] == threshold:", "- countA = OK + 1", "- OK = N", "- NG = -1", ...
false
0.059859
0.058689
1.019923
[ "s018030321", "s519949168" ]
u102461423
p02956
python
s654842799
s127794922
979
658
178,216
133,768
Accepted
Accepted
32.79
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 998244353 N = int(eval(input())) XY = [[int(x) for x in input().split()] for _ in range(N)] XY.sort() # X ascending X,Y = list(zip(*XY)) Y_rank = {x:i for i,x in enumerate(sorted(Y),1)} def BIT_update(tree,x): while x <= N: ...
import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 998_244_353 @njit((i8[:], ), cache=True) def build(raw_data): bit = raw_data.copy() for i in range(l...
57
93
1,077
1,929
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) MOD = 998244353 N = int(eval(input())) XY = [[int(x) for x in input().split()] for _ in range(N)] XY.sort() # X ascending X, Y = list(zip(*XY)) Y_rank = {x: i for i, x in enumerate(sorted(Y), 1)} def BIT_update(tree, x): while x <= N: tr...
import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 998_244_353 @njit((i8[:],), cache=True) def build(raw_data): bit = raw_data.copy() for i in range(len(bit)): ...
false
38.709677
[ "+import numpy as np", "+import numba", "+from numba import njit", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-MOD = 998244353", "-N = int(eval(input()))", "-XY = [[int(x) for x in input().split()] for _ in range(N)]", "-XY.sort() # X ascending", "-X, Y = list(zip(*XY))", ...
false
0.037911
0.94302
0.040201
[ "s654842799", "s127794922" ]
u691018832
p03599
python
s107233549
s803744614
457
355
3,188
3,188
Accepted
Accepted
22.32
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) a, b, c, d, e, f = list(map(int, readline().split())) ans = [0, 0] check = 0 S = set() W = set() for i in range(31): for j in range(31): if 100 * a...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) a, b, c, d, e, f = list(map(int, readline().split())) A = 100 * a B = 100 * b E = 100 * e / (100 + e) ans = [0, 0] check = 0 for i in range(f // A + 2): fo...
35
30
852
856
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) a, b, c, d, e, f = list(map(int, readline().split())) ans = [0, 0] check = 0 S = set() W = set() for i in range(31): for j in range(31): if 100 * a * i + 100 * b ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) a, b, c, d, e, f = list(map(int, readline().split())) A = 100 * a B = 100 * b E = 100 * e / (100 + e) ans = [0, 0] check = 0 for i in range(f // A + 2): for j in range(f ...
false
14.285714
[ "+A = 100 * a", "+B = 100 * b", "+E = 100 * e / (100 + e)", "-S = set()", "-W = set()", "-for i in range(31):", "- for j in range(31):", "- if 100 * a * i + 100 * b * j <= f:", "- W.add(100 * a * i + 100 * b * j)", "-for i in range(1501):", "- for j in range(1501):", "-...
false
2.091878
0.120247
17.396483
[ "s107233549", "s803744614" ]
u633068244
p01268
python
s604000967
s286473016
260
240
9,024
9,024
Accepted
Accepted
7.69
import itertools r = 110000 s = int(r*0.5) p = [1] * r p[0] = 0 for i in range(1,s): if p[i]: p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)] while 1: N,P = list(map(int,input().split())) if N == -1: break i = N + 1 prime = [0]*23 j = 0 while j < 23: if p[i-1] == 1: prime[j] = i j ...
import itertools r = 110000 s = int(r*0.5) p = [1] * r p[0] = 0 for i in range(1,s): if p[i]: p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)] while 1: N,P = list(map(int,input().split())) if N == -1: break i = N + 1 prime = [0]*22 j = 0 while j < 22: if p[i-1] == 1: prime[j] = i j ...
22
22
442
442
import itertools r = 110000 s = int(r * 0.5) p = [1] * r p[0] = 0 for i in range(1, s): if p[i]: p[2 * i + 1 :: i + 1] = [0 for x in range(2 * i + 1, r, i + 1)] while 1: N, P = list(map(int, input().split())) if N == -1: break i = N + 1 prime = [0] * 23 j = 0 while j < 23: ...
import itertools r = 110000 s = int(r * 0.5) p = [1] * r p[0] = 0 for i in range(1, s): if p[i]: p[2 * i + 1 :: i + 1] = [0 for x in range(2 * i + 1, r, i + 1)] while 1: N, P = list(map(int, input().split())) if N == -1: break i = N + 1 prime = [0] * 22 j = 0 while j < 22: ...
false
0
[ "- prime = [0] * 23", "+ prime = [0] * 22", "- while j < 23:", "+ while j < 22:" ]
false
0.082866
0.090259
0.918096
[ "s604000967", "s286473016" ]
u753803401
p02924
python
s521128107
s119148394
1,464
176
40,624
38,384
Accepted
Accepted
87.98
def slove(): import sys input = sys.stdin.readline n = int(input().rstrip('\n')) t = 0 for i in range(1, n): t += i print(t) if __name__ == '__main__': slove()
import sys def solve(): input = sys.stdin.readline mod = 10 ** 9 + 7 n = int(input().rstrip('\n')) print(((n-1) * (1 + n - 1) // 2)) if __name__ == '__main__': solve()
12
12
209
201
def slove(): import sys input = sys.stdin.readline n = int(input().rstrip("\n")) t = 0 for i in range(1, n): t += i print(t) if __name__ == "__main__": slove()
import sys def solve(): input = sys.stdin.readline mod = 10**9 + 7 n = int(input().rstrip("\n")) print(((n - 1) * (1 + n - 1) // 2)) if __name__ == "__main__": solve()
false
0
[ "-def slove():", "- import sys", "+import sys", "+", "+def solve():", "+ mod = 10**9 + 7", "- t = 0", "- for i in range(1, n):", "- t += i", "- print(t)", "+ print(((n - 1) * (1 + n - 1) // 2))", "- slove()", "+ solve()" ]
false
0.045162
0.172095
0.262427
[ "s521128107", "s119148394" ]
u363995337
p03493
python
s654196254
s402122097
170
17
38,384
2,940
Accepted
Accepted
90
s = eval(input()) print((s.count('1')))
MarbleList = list(eval(input())) num=MarbleList.count('1') print(num)
2
4
32
68
s = eval(input()) print((s.count("1")))
MarbleList = list(eval(input())) num = MarbleList.count("1") print(num)
false
50
[ "-s = eval(input())", "-print((s.count(\"1\")))", "+MarbleList = list(eval(input()))", "+num = MarbleList.count(\"1\")", "+print(num)" ]
false
0.048247
0.046383
1.04018
[ "s654196254", "s402122097" ]
u077291787
p03013
python
s277796221
s400377044
91
67
18,332
18,336
Accepted
Accepted
26.37
# ABC129C - Typical Stairs import sys input = sys.stdin.readline def main(): N, M = tuple(map(int, input().rstrip().split())) A = set(map(int, [input().rstrip() for _ in range(M)])) MOD = 10 ** 9 + 7 dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if i in A: ...
# ABC129C - Typical Stairs import sys input = sys.stdin.readline def main(): N, M = tuple(map(int, input().rstrip().split())) A = set(map(int, [input().rstrip() for _ in range(M)])) MOD = 10 ** 9 + 7 dp = [0] * (N + 1) dp[:2] = 1, 1 if 1 not in A else 0 for i in range(2, N + 1): ...
22
20
531
485
# ABC129C - Typical Stairs import sys input = sys.stdin.readline def main(): N, M = tuple(map(int, input().rstrip().split())) A = set(map(int, [input().rstrip() for _ in range(M)])) MOD = 10**9 + 7 dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if i in A: continue ...
# ABC129C - Typical Stairs import sys input = sys.stdin.readline def main(): N, M = tuple(map(int, input().rstrip().split())) A = set(map(int, [input().rstrip() for _ in range(M)])) MOD = 10**9 + 7 dp = [0] * (N + 1) dp[:2] = 1, 1 if 1 not in A else 0 for i in range(2, N + 1): if i in...
false
9.090909
[ "- dp[0] = 1", "- for i in range(1, N + 1):", "+ dp[:2] = 1, 1 if 1 not in A else 0", "+ for i in range(2, N + 1):", "- for j in range(1, 3):", "- if i - j >= 0:", "- dp[i] = (dp[i] + dp[i - j]) % MOD", "+ dp[i] = (dp[i - 1] + dp[i - ...
false
0.041685
0.041857
0.995877
[ "s277796221", "s400377044" ]
u597374218
p02646
python
s827669104
s661979251
24
21
9,176
9,176
Accepted
Accepted
12.5
import math A,V=list(map(int,input().split())) B,W=list(map(int,input().split())) T=int(eval(input())) if V!=W: if V>W and math.ceil(abs(B-A)/(V-W))<=T: print("YES") exit() print("NO")
A,V=list(map(int,input().split())) B,W=list(map(int,input().split())) T=int(eval(input())) print(("NO" if V==W or V<W or abs(A-B)/(V-W)>T else "YES"))
9
4
194
133
import math A, V = list(map(int, input().split())) B, W = list(map(int, input().split())) T = int(eval(input())) if V != W: if V > W and math.ceil(abs(B - A) / (V - W)) <= T: print("YES") exit() print("NO")
A, V = list(map(int, input().split())) B, W = list(map(int, input().split())) T = int(eval(input())) print(("NO" if V == W or V < W or abs(A - B) / (V - W) > T else "YES"))
false
55.555556
[ "-import math", "-", "-if V != W:", "- if V > W and math.ceil(abs(B - A) / (V - W)) <= T:", "- print(\"YES\")", "- exit()", "-print(\"NO\")", "+print((\"NO\" if V == W or V < W or abs(A - B) / (V - W) > T else \"YES\"))" ]
false
0.036922
0.038342
0.962977
[ "s827669104", "s661979251" ]
u186838327
p02804
python
s589888538
s906386894
492
132
127,788
84,664
Accepted
Accepted
73.17
def cmb1(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = 10**6 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.a...
n, k =list(map(int, input().split())) A = list(map(int, input().split())) mod = 10**9+7 N = 10**5+50 fac = [1]*(N+1) finv = [1]*(N+1) for i in range(N): fac[i+1] = fac[i] * (i+1) % mod finv[-1] = pow(fac[-1], mod-2, mod) for i in reversed(list(range(N))): finv[i] = finv[i+1] * (i+1) % mod def cmb...
35
31
746
635
def cmb1(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod mod = 10**9 + 7 # 出力の制限 N = 10**6 g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] # 逆元テーブル計算用テーブル for i in range(2, N + 1): g1.append((g1[-1] * i) % mod) inverse.append((...
n, k = list(map(int, input().split())) A = list(map(int, input().split())) mod = 10**9 + 7 N = 10**5 + 50 fac = [1] * (N + 1) finv = [1] * (N + 1) for i in range(N): fac[i + 1] = fac[i] * (i + 1) % mod finv[-1] = pow(fac[-1], mod - 2, mod) for i in reversed(list(range(N))): finv[i] = finv[i + 1] * (i + 1) % mod...
false
11.428571
[ "+n, k = list(map(int, input().split()))", "+A = list(map(int, input().split()))", "+mod = 10**9 + 7", "+N = 10**5 + 50", "+fac = [1] * (N + 1)", "+finv = [1] * (N + 1)", "+for i in range(N):", "+ fac[i + 1] = fac[i] * (i + 1) % mod", "+finv[-1] = pow(fac[-1], mod - 2, mod)", "+for i in reverse...
false
1.547444
0.528048
2.930497
[ "s589888538", "s906386894" ]
u013756322
p03208
python
s336489845
s085219478
239
116
8,280
14,092
Accepted
Accepted
51.46
N, K = list(map(int, input().split())) h = sorted([int(eval(input())) for _ in range(N)]) ans = float("inf") for i in range(N - K + 1): ans = min(ans, h[i+K-1]-h[i]) print(ans)
N, K, *H = list(map(int, open(0).read().split())) H.sort() a = float('inf') for i in range(N-K+1): a = min(a, H[i+K-1]-H[i]) print(a)
6
6
174
136
N, K = list(map(int, input().split())) h = sorted([int(eval(input())) for _ in range(N)]) ans = float("inf") for i in range(N - K + 1): ans = min(ans, h[i + K - 1] - h[i]) print(ans)
N, K, *H = list(map(int, open(0).read().split())) H.sort() a = float("inf") for i in range(N - K + 1): a = min(a, H[i + K - 1] - H[i]) print(a)
false
0
[ "-N, K = list(map(int, input().split()))", "-h = sorted([int(eval(input())) for _ in range(N)])", "-ans = float(\"inf\")", "+N, K, *H = list(map(int, open(0).read().split()))", "+H.sort()", "+a = float(\"inf\")", "- ans = min(ans, h[i + K - 1] - h[i])", "-print(ans)", "+ a = min(a, H[i + K - 1...
false
0.067262
0.042747
1.573469
[ "s336489845", "s085219478" ]
u277091362
p03478
python
s262966617
s927909893
47
37
3,060
3,060
Accepted
Accepted
21.28
n, a, b = list(map(int, input().split())) tmp = 0 for i in range(1, n+1): x = 0 for j in range(len(str(i))): x += int(str(i)[j]) if x >= a and x <= b: tmp += i print(tmp)
n, a, b = list(map(int, input().split())) def calc(x): return int(x / 10), x % 10 def func(x, ans): a, b = calc(x) ans += b if a == 0: return ans return func(a, ans) ans = 0 for i in range(1, n+1): if a <= func(i, 0) <= b: ans += i print(ans)
11
18
204
297
n, a, b = list(map(int, input().split())) tmp = 0 for i in range(1, n + 1): x = 0 for j in range(len(str(i))): x += int(str(i)[j]) if x >= a and x <= b: tmp += i print(tmp)
n, a, b = list(map(int, input().split())) def calc(x): return int(x / 10), x % 10 def func(x, ans): a, b = calc(x) ans += b if a == 0: return ans return func(a, ans) ans = 0 for i in range(1, n + 1): if a <= func(i, 0) <= b: ans += i print(ans)
false
38.888889
[ "-tmp = 0", "+", "+", "+def calc(x):", "+ return int(x / 10), x % 10", "+", "+", "+def func(x, ans):", "+ a, b = calc(x)", "+ ans += b", "+ if a == 0:", "+ return ans", "+ return func(a, ans)", "+", "+", "+ans = 0", "- x = 0", "- for j in range(len(str(i...
false
0.048876
0.04646
1.051998
[ "s262966617", "s927909893" ]
u243312682
p02755
python
s483160119
s302597256
32
27
9,192
9,124
Accepted
Accepted
15.62
from math import ceil, floor def main(): a, b = list(map(int, input().split())) p8_l = ceil(a / 0.08) p8_h = int((a+1) // 0.08) p10_l = int(b / 0.10) p10_h = int((b+1) / 0.10) - 1 if p8_h >= p10_h >= p8_l and p8_l >= p10_l: print(p8_l) elif p8_l <= p10_l <= p8_h and p8_l <...
def main(): a, b = list(map(int, input().split())) maxv = int((101 / 0.1) - 1) for i in range(maxv+1): if (i*8//100 == a) and (i*10//100 == b): print(i) exit() print((-1)) if __name__ == '__main__': main()
17
11
420
261
from math import ceil, floor def main(): a, b = list(map(int, input().split())) p8_l = ceil(a / 0.08) p8_h = int((a + 1) // 0.08) p10_l = int(b / 0.10) p10_h = int((b + 1) / 0.10) - 1 if p8_h >= p10_h >= p8_l and p8_l >= p10_l: print(p8_l) elif p8_l <= p10_l <= p8_h and p8_l <= p10...
def main(): a, b = list(map(int, input().split())) maxv = int((101 / 0.1) - 1) for i in range(maxv + 1): if (i * 8 // 100 == a) and (i * 10 // 100 == b): print(i) exit() print((-1)) if __name__ == "__main__": main()
false
35.294118
[ "-from math import ceil, floor", "-", "-", "- p8_l = ceil(a / 0.08)", "- p8_h = int((a + 1) // 0.08)", "- p10_l = int(b / 0.10)", "- p10_h = int((b + 1) / 0.10) - 1", "- if p8_h >= p10_h >= p8_l and p8_l >= p10_l:", "- print(p8_l)", "- elif p8_l <= p10_l <= p8_h and p8_l <...
false
0.109292
0.055206
1.979718
[ "s483160119", "s302597256" ]
u908763441
p02574
python
s912549656
s664765505
1,312
1,206
189,912
193,060
Accepted
Accepted
8.08
import bisect import math n = int(eval(input())) As = list(map(int, input().split())) As.sort() cons = 10 ** 6 is_prime = [True] * (cons + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(cons**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, cons + 1, i): ...
import math def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return [i for i in range(n + 1) if ...
58
50
1,316
1,041
import bisect import math n = int(eval(input())) As = list(map(int, input().split())) As.sort() cons = 10**6 is_prime = [True] * (cons + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(cons**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, cons + 1, i): is_prime[j]...
import math def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False return [i for i in range(n + 1) if is_prime[i...
false
13.793103
[ "-import bisect", "-n = int(eval(input()))", "-As = list(map(int, input().split()))", "-As.sort()", "-cons = 10**6", "-is_prime = [True] * (cons + 1)", "-is_prime[0] = False", "-is_prime[1] = False", "-for i in range(2, int(cons**0.5) + 1):", "- if not is_prime[i]:", "- continue", "-...
false
0.664285
0.42709
1.555374
[ "s912549656", "s664765505" ]
u297574184
p02762
python
s246562201
s837032854
903
480
48,704
23,020
Accepted
Accepted
46.84
def solve(): from collections import Counter import sys input = sys.stdin.readline N, M, K = list(map(int, input().split())) ABs = [tuple(map(int, input().split())) for _ in range(M)] CDs = [tuple(map(int, input().split())) for _ in range(K)] # Union-Findデータ構造 class UnionFind...
import sys input = sys.stdin.readline class UnionFind: def __init__(self, numV): self.pars = list(range(numV)) self.ranks = [0] * numV self.sizes = [1] * numV def getRoot(self, x): par = self.pars[x] if par != x: self.pars[x] = par = self.getRoot(p...
60
55
1,613
1,490
def solve(): from collections import Counter import sys input = sys.stdin.readline N, M, K = list(map(int, input().split())) ABs = [tuple(map(int, input().split())) for _ in range(M)] CDs = [tuple(map(int, input().split())) for _ in range(K)] # Union-Findデータ構造 class UnionFind: d...
import sys input = sys.stdin.readline class UnionFind: def __init__(self, numV): self.pars = list(range(numV)) self.ranks = [0] * numV self.sizes = [1] * numV def getRoot(self, x): par = self.pars[x] if par != x: self.pars[x] = par = self.getRoot(par) ...
false
8.333333
[ "-def solve():", "- from collections import Counter", "- import sys", "+import sys", "- input = sys.stdin.readline", "- N, M, K = list(map(int, input().split()))", "- ABs = [tuple(map(int, input().split())) for _ in range(M)]", "- CDs = [tuple(map(int, input().split())) for _ in rang...
false
0.036789
0.037502
0.980984
[ "s246562201", "s837032854" ]
u271176141
p02706
python
s010667951
s084513991
30
25
10,112
9,860
Accepted
Accepted
16.67
n,m = list(map(int,input().split())) # 受け取った文字をスペースで分けてリスト化 a = list(input().split()) # 文字列のリストの値を整数化 a_int = [int(i) for i in a] # 夏休みの日数がリスト内の日数の合計より多ければ残日数を表示 if n >= sum(a_int): print((n - sum(a_int))) # リスト内の日数の合計が夏休みの日数より多ければ-1を表示 else: print("-1")
n,m = list(map(int,input().split())) # 整数の入力値をスペースで受け取ってリスト化 a = list(map(int,input().split())) # 夏休みの日数がリスト内の日数の合計より多ければ残日数を表示 if n >= sum(a): print((n - sum(a))) # リスト内の日数の合計が夏休みの日数より多ければ-1を表示 else: print("-1")
11
10
265
222
n, m = list(map(int, input().split())) # 受け取った文字をスペースで分けてリスト化 a = list(input().split()) # 文字列のリストの値を整数化 a_int = [int(i) for i in a] # 夏休みの日数がリスト内の日数の合計より多ければ残日数を表示 if n >= sum(a_int): print((n - sum(a_int))) # リスト内の日数の合計が夏休みの日数より多ければ-1を表示 else: print("-1")
n, m = list(map(int, input().split())) # 整数の入力値をスペースで受け取ってリスト化 a = list(map(int, input().split())) # 夏休みの日数がリスト内の日数の合計より多ければ残日数を表示 if n >= sum(a): print((n - sum(a))) # リスト内の日数の合計が夏休みの日数より多ければ-1を表示 else: print("-1")
false
9.090909
[ "-# 受け取った文字をスペースで分けてリスト化", "-a = list(input().split())", "-# 文字列のリストの値を整数化", "-a_int = [int(i) for i in a]", "+# 整数の入力値をスペースで受け取ってリスト化", "+a = list(map(int, input().split()))", "-if n >= sum(a_int):", "- print((n - sum(a_int)))", "+if n >= sum(a):", "+ print((n - sum(a)))" ]
false
0.048547
0.047131
1.030028
[ "s010667951", "s084513991" ]
u788337030
p02726
python
s797964217
s204643506
1,927
1,418
3,444
3,444
Accepted
Accepted
26.41
n, x, y = list(map(int, input().split())) ans = [0 for i in range(n-1)] for i in range(n-1): k = i + 1 b_1 = k - x c_1 = k - y if b_1 < 0: b_1 = - b_1 if c_1 < 0: c_1 = - c_1 for j in range(i+1, n): l = j + 1 a = l - k b_2 = l - y c_2 = l - x if b_2 < 0: ...
n, x, y = list(map(int, input().split())) ans = [0 for i in range(n-1)] for i in range(n-1): k = i + 1 b_1 = k - x if b_1 < 0: b_1 = - b_1 for j in range(i+1, n): l = j + 1 a = l - k b_2 = l - y if b_2 < 0: b_2 = - b_2 b = b_1 + b_2 + 1 if b < a: a = b ...
28
19
522
369
n, x, y = list(map(int, input().split())) ans = [0 for i in range(n - 1)] for i in range(n - 1): k = i + 1 b_1 = k - x c_1 = k - y if b_1 < 0: b_1 = -b_1 if c_1 < 0: c_1 = -c_1 for j in range(i + 1, n): l = j + 1 a = l - k b_2 = l - y c_2 = l - x ...
n, x, y = list(map(int, input().split())) ans = [0 for i in range(n - 1)] for i in range(n - 1): k = i + 1 b_1 = k - x if b_1 < 0: b_1 = -b_1 for j in range(i + 1, n): l = j + 1 a = l - k b_2 = l - y if b_2 < 0: b_2 = -b_2 b = b_1 + b_2 + 1 ...
false
32.142857
[ "- c_1 = k - y", "- if c_1 < 0:", "- c_1 = -c_1", "- c_2 = l - x", "- if c_2 < 0:", "- c_2 = -c_2", "- c = c_1 + c_2 + 1", "- if c < a:", "- a = c" ]
false
0.04349
0.03638
1.195427
[ "s797964217", "s204643506" ]
u759412327
p03607
python
s758979815
s349425386
201
75
16,636
19,088
Accepted
Accepted
62.69
from collections import * N = int(eval(input())) C = Counter([int(eval(input())) for n in range(N)]) A = [1 for v in list(C.values()) if v%2==1] print((sum(A)))
N,*A = open(0) S = set() for a in A: S^={int(a)} print((len(S)))
5
7
145
72
from collections import * N = int(eval(input())) C = Counter([int(eval(input())) for n in range(N)]) A = [1 for v in list(C.values()) if v % 2 == 1] print((sum(A)))
N, *A = open(0) S = set() for a in A: S ^= {int(a)} print((len(S)))
false
28.571429
[ "-from collections import *", "-", "-N = int(eval(input()))", "-C = Counter([int(eval(input())) for n in range(N)])", "-A = [1 for v in list(C.values()) if v % 2 == 1]", "-print((sum(A)))", "+N, *A = open(0)", "+S = set()", "+for a in A:", "+ S ^= {int(a)}", "+print((len(S)))" ]
false
0.054487
0.036601
1.488654
[ "s758979815", "s349425386" ]
u256464928
p03294
python
s082973575
s884303977
171
18
5,344
3,316
Accepted
Accepted
89.47
from fractions import gcd N = int(eval(input())) A = list(map(int,input().split())) def lcm(a, b): return a * b // gcd (a, b) x = A[0] for i in range(1,N): x = lcm(x,A[i]) x -= 1 ans = 0 for i in range(N): ans += x % A[i] print(ans)
N = int(eval(input())) A = list(map(int,input().split())) ans = 0 for i in range(N): ans += A[i] - 1 print(ans)
16
7
251
115
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) def lcm(a, b): return a * b // gcd(a, b) x = A[0] for i in range(1, N): x = lcm(x, A[i]) x -= 1 ans = 0 for i in range(N): ans += x % A[i] print(ans)
N = int(eval(input())) A = list(map(int, input().split())) ans = 0 for i in range(N): ans += A[i] - 1 print(ans)
false
56.25
[ "-from fractions import gcd", "-", "-", "-", "-def lcm(a, b):", "- return a * b // gcd(a, b)", "-", "-", "-x = A[0]", "-for i in range(1, N):", "- x = lcm(x, A[i])", "-x -= 1", "- ans += x % A[i]", "+ ans += A[i] - 1" ]
false
0.153566
0.04292
3.577913
[ "s082973575", "s884303977" ]
u226108478
p02850
python
s350421476
s020933883
792
554
108,516
87,468
Accepted
Accepted
30.05
# -*- coding: utf-8 -*- def main(): from sys import setrecursionlimit setrecursionlimit(10 ** 7) n = int(eval(input())) graph = [list() for _ in range(n)] ans = [0 for _ in range(n - 1)] # KeyInsight: # 木の問題と再帰関数は相性がいい # See: # https://www.youtube.com/watch?v=7IlBVS...
# -*- coding: utf-8 -*- def main(): # 再帰の上限回数のデフォルトを変更 from sys import setrecursionlimit setrecursionlimit(10 ** 7) n = int(eval(input())) graph = [list() for _ in range(n)] ans = [0 for _ in range(n - 1)] # KeyInsight: # 木の問題と再帰関数は相性がいい # See: # https://www.yo...
49
61
1,052
1,336
# -*- coding: utf-8 -*- def main(): from sys import setrecursionlimit setrecursionlimit(10**7) n = int(eval(input())) graph = [list() for _ in range(n)] ans = [0 for _ in range(n - 1)] # KeyInsight: # 木の問題と再帰関数は相性がいい # See: # https://www.youtube.com/watch?v=7IlBVSglZqc for i in ...
# -*- coding: utf-8 -*- def main(): # 再帰の上限回数のデフォルトを変更 from sys import setrecursionlimit setrecursionlimit(10**7) n = int(eval(input())) graph = [list() for _ in range(n)] ans = [0 for _ in range(n - 1)] # KeyInsight: # 木の問題と再帰関数は相性がいい # See: # https://www.youtube.com/watch?v=7I...
false
19.672131
[ "+ # 再帰の上限回数のデフォルトを変更", "-", "+ # 実装できなかったところ", "+ # 1. 色のカウントをどう管理するか?", "+ # 2. 辺のidをどう管理するか?", "+ # 親方向からの色番号を引数に持つ", "+ # 一般的なポイント: 頂点に関する処理を書く", "+ # 基本形: 親の頂点周りを探索", "+ # 一般的なポイント: 辺に関する処理を書く", "+ # 一般的なポイント: 辺に関する処理を書く", "+ # 一般的なポ...
false
0.061153
0.03576
1.710064
[ "s350421476", "s020933883" ]
u729133443
p02610
python
s515898649
s035633928
1,493
1,242
121,240
122,008
Accepted
Accepted
16.81
from heapq import* i=input s=sorted def f(x): s,n,*h=0,len(x) while n: while x and x[-1][0]>=n:k,l,r=x.pop();heappush(h,(r-l,l,r)) if h:s+=heappop(h)[1] n-=1 return s+sum(r for _,_,r in x+h) for _ in'_'*int(i()): n,x,*y=int(i()),[] for _ in'_'*n: k,l,r=list(map(int,i().split())) if l>r:x+=(...
from heapq import* i=input s=sorted def f(x): s,n,*h=0,len(x) while n: while x and x[-1][0]>=n:k,l,r=x.pop();heappush(h,(r-l,l,r)) if h:s+=heappop(h)[1] n-=1 return s+sum(r for*_,r in x+h) for _ in'_'*int(i()): n,x,*y=int(i()),[] for _ in'_'*n: k,l,r=list(map(int,i().split())) if l>r:x+=(k,...
17
17
368
366
from heapq import * i = input s = sorted def f(x): s, n, *h = 0, len(x) while n: while x and x[-1][0] >= n: k, l, r = x.pop() heappush(h, (r - l, l, r)) if h: s += heappop(h)[1] n -= 1 return s + sum(r for _, _, r in x + h) for _ in "_" * int(...
from heapq import * i = input s = sorted def f(x): s, n, *h = 0, len(x) while n: while x and x[-1][0] >= n: k, l, r = x.pop() heappush(h, (r - l, l, r)) if h: s += heappop(h)[1] n -= 1 return s + sum(r for *_, r in x + h) for _ in "_" * int(i(...
false
0
[ "- return s + sum(r for _, _, r in x + h)", "+ return s + sum(r for *_, r in x + h)" ]
false
0.037424
0.058576
0.638884
[ "s515898649", "s035633928" ]
u963128036
p02802
python
s531371727
s287272389
305
130
12,780
12,780
Accepted
Accepted
57.38
n, m = list(map(int, input().split())) ac_set = set() penalty = 0 wa_count = [0] * (n+1) for i in range(m): p, s = input().split() p = int(p) if s == "AC": if not p in ac_set: penalty += wa_count[p] ac_set.add(p) elif s == "WA": wa_count[p] += 1 ...
# coding: utf-8 import sys input = sys.stdin.readline n, m = list(map(int, input().split())) ac_set = set() penalty = 0 wa_count = [0] * (n+1) for i in range(m): p, s = input().split() p = int(p) if s == "AC": if not p in ac_set: penalty += wa_count[p] ...
19
24
346
407
n, m = list(map(int, input().split())) ac_set = set() penalty = 0 wa_count = [0] * (n + 1) for i in range(m): p, s = input().split() p = int(p) if s == "AC": if not p in ac_set: penalty += wa_count[p] ac_set.add(p) elif s == "WA": wa_count[p] += 1 print((len(ac_se...
# coding: utf-8 import sys input = sys.stdin.readline n, m = list(map(int, input().split())) ac_set = set() penalty = 0 wa_count = [0] * (n + 1) for i in range(m): p, s = input().split() p = int(p) if s == "AC": if not p in ac_set: penalty += wa_count[p] ac_set.add(p) el...
false
20.833333
[ "+# coding: utf-8", "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.035677
0.036734
0.971225
[ "s531371727", "s287272389" ]
u433424442
p02642
python
s077232200
s602816615
649
149
218,368
116,704
Accepted
Accepted
77.04
import sys def input(): return sys.stdin.readline()[:-1] from itertools import count from collections import Counter def test(): n = int(eval(input())) a = sorted([int(i) for i in input().split()]) mxn = a[-1] c = Counter(a) a = sorted(list(set(a))) r = dict() for i in a:...
# https://qiita.com/HUVEC/items/97739696ab51cacd10f2 N = int(eval(input())) A = list(map(int, input().split())) A.sort() #エラトステネスの篩にかけるためソート Amax = A[-1] dp = [1]*(Amax+1) #Aの最大値までのエラトステネスの篩を作る。 ans = 0 for i in range(len(A)-1): p = A[i] if dp[p] == 1: #A[i]がA[j]の倍数でないかをエラ...
22
17
492
557
import sys def input(): return sys.stdin.readline()[:-1] from itertools import count from collections import Counter def test(): n = int(eval(input())) a = sorted([int(i) for i in input().split()]) mxn = a[-1] c = Counter(a) a = sorted(list(set(a))) r = dict() for i in a: f...
# https://qiita.com/HUVEC/items/97739696ab51cacd10f2 N = int(eval(input())) A = list(map(int, input().split())) A.sort() # エラトステネスの篩にかけるためソート Amax = A[-1] dp = [1] * (Amax + 1) # Aの最大値までのエラトステネスの篩を作る。 ans = 0 for i in range(len(A) - 1): p = A[i] if dp[p] == 1: # A[i]がA[j]の倍数でないかをエラトステネスの篩でチェック for q ...
false
22.727273
[ "-import sys", "-", "-", "-def input():", "- return sys.stdin.readline()[:-1]", "-", "-", "-from itertools import count", "-from collections import Counter", "-", "-", "-def test():", "- n = int(eval(input()))", "- a = sorted([int(i) for i in input().split()])", "- mxn = a[-1...
false
0.035978
0.03654
0.984626
[ "s077232200", "s602816615" ]
u936985471
p02832
python
s803645881
s928042062
128
101
24,920
24,744
Accepted
Accepted
21.09
N=int(eval(input())) a=list(map(int,input().split())) tar=1 found=0 for i in range(len(a)): if a[i]==tar: tar+=1 found+=1 if found==0: print((-1)) else: print((N-found))
N=int(eval(input())) A=list(map(int,input().split())) t=0 for i in range(N): if A[i]==t+1: t+=1 print(((-1,N-t)[t>0]))
12
7
184
122
N = int(eval(input())) a = list(map(int, input().split())) tar = 1 found = 0 for i in range(len(a)): if a[i] == tar: tar += 1 found += 1 if found == 0: print((-1)) else: print((N - found))
N = int(eval(input())) A = list(map(int, input().split())) t = 0 for i in range(N): if A[i] == t + 1: t += 1 print(((-1, N - t)[t > 0]))
false
41.666667
[ "-a = list(map(int, input().split()))", "-tar = 1", "-found = 0", "-for i in range(len(a)):", "- if a[i] == tar:", "- tar += 1", "- found += 1", "-if found == 0:", "- print((-1))", "-else:", "- print((N - found))", "+A = list(map(int, input().split()))", "+t = 0", "+...
false
0.038636
0.036896
1.047147
[ "s803645881", "s928042062" ]
u906501980
p02724
python
s813816295
s704670946
19
17
2,940
2,940
Accepted
Accepted
10.53
def main(): n = int(eval(input())) print((n//500*1000+(n%500)//5*5)) if __name__ == "__main__": main()
x = int(eval(input())) print((x//500*1000+(x%500//5)*5))
6
2
112
50
def main(): n = int(eval(input())) print((n // 500 * 1000 + (n % 500) // 5 * 5)) if __name__ == "__main__": main()
x = int(eval(input())) print((x // 500 * 1000 + (x % 500 // 5) * 5))
false
66.666667
[ "-def main():", "- n = int(eval(input()))", "- print((n // 500 * 1000 + (n % 500) // 5 * 5))", "-", "-", "-if __name__ == \"__main__\":", "- main()", "+x = int(eval(input()))", "+print((x // 500 * 1000 + (x % 500 // 5) * 5))" ]
false
0.098494
0.037979
2.593364
[ "s813816295", "s704670946" ]
u136090046
p04031
python
s905187931
s500344046
25
17
2,940
3,064
Accepted
Accepted
32
n = int(eval(input())) a_array = [int(x) for x in input().split()] ans = float("inf") for i in range(-100, 101): tmp = 0 for a in a_array: tmp += abs(a-i)**2 ans = min(ans, tmp) print(ans)
n = int(eval(input())) a_array = [int(x) for x in input().split()] sum_a = sum(a_array) if sum_a % n == 0: sum_a = int(sum_a/len(a_array)) ans = 0 for a in a_array: ans += abs(sum_a-a)**2 print((int(ans))) else: sum_a1 = int(sum_a/len(a_array)) sum_a2 = int(sum_a/len(a_array))...
9
18
211
467
n = int(eval(input())) a_array = [int(x) for x in input().split()] ans = float("inf") for i in range(-100, 101): tmp = 0 for a in a_array: tmp += abs(a - i) ** 2 ans = min(ans, tmp) print(ans)
n = int(eval(input())) a_array = [int(x) for x in input().split()] sum_a = sum(a_array) if sum_a % n == 0: sum_a = int(sum_a / len(a_array)) ans = 0 for a in a_array: ans += abs(sum_a - a) ** 2 print((int(ans))) else: sum_a1 = int(sum_a / len(a_array)) sum_a2 = int(sum_a / len(a_array)) ...
false
50
[ "-ans = float(\"inf\")", "-for i in range(-100, 101):", "- tmp = 0", "+sum_a = sum(a_array)", "+if sum_a % n == 0:", "+ sum_a = int(sum_a / len(a_array))", "+ ans = 0", "- tmp += abs(a - i) ** 2", "- ans = min(ans, tmp)", "-print(ans)", "+ ans += abs(sum_a - a) ** 2", ...
false
0.037887
0.0389
0.973969
[ "s905187931", "s500344046" ]
u614314290
p03167
python
s847827005
s529609094
1,181
855
43,692
43,692
Accepted
Accepted
27.6
H, W = list(map(int, input().split())) STAGE = [eval(input()) for _ in range(H)] dp = [[0] * W for _ in range(H)] dp[0][0] = 1 MOD = 10 ** 9 + 7 for y in range(H): for x in range(W): if y + 1 < H and STAGE[y + 1][x] == ".": dp[y + 1][x] += dp[y][x] % MOD if x + 1 < W and STAGE[y][x + 1] == ".": ...
def main(): H, W = list(map(int, input().split())) STAGE = [eval(input()) for _ in range(H)] dp = [[0] * W for _ in range(H)] dp[0][0] = 1 MOD = 10 ** 9 + 7 for y in range(H): for x in range(W): if y + 1 < H and STAGE[y + 1][x] == ".": dp[y + 1][x] += dp[y][x] % MOD if x + 1 < W and ST...
16
19
369
404
H, W = list(map(int, input().split())) STAGE = [eval(input()) for _ in range(H)] dp = [[0] * W for _ in range(H)] dp[0][0] = 1 MOD = 10**9 + 7 for y in range(H): for x in range(W): if y + 1 < H and STAGE[y + 1][x] == ".": dp[y + 1][x] += dp[y][x] % MOD if x + 1 < W and STAGE[y][x + 1] ==...
def main(): H, W = list(map(int, input().split())) STAGE = [eval(input()) for _ in range(H)] dp = [[0] * W for _ in range(H)] dp[0][0] = 1 MOD = 10**9 + 7 for y in range(H): for x in range(W): if y + 1 < H and STAGE[y + 1][x] == ".": dp[y + 1][x] += dp[y][x] %...
false
15.789474
[ "-H, W = list(map(int, input().split()))", "-STAGE = [eval(input()) for _ in range(H)]", "-dp = [[0] * W for _ in range(H)]", "-dp[0][0] = 1", "-MOD = 10**9 + 7", "-for y in range(H):", "- for x in range(W):", "- if y + 1 < H and STAGE[y + 1][x] == \".\":", "- dp[y + 1][x] += dp...
false
0.03489
0.039415
0.885194
[ "s847827005", "s529609094" ]
u189427183
p03060
python
s432558575
s138199702
189
172
38,384
38,384
Accepted
Accepted
8.99
N = int(eval(input())) V=list(map(int,input().split())) C= list(map(int,input().split())) a=[] for i in range(0,N): if V[i]>=C[i]: a.append(V[i]-C[i]) else: continue print((sum(a)))
import heapq N = int(eval(input())) V=list(map(int,input().split())) C= list(map(int,input().split())) a=[] for i in range(0,N): if V[i]>=C[i]: heapq.heappush(a,(V[i]-C[i])) else: continue print((sum(a)))
10
11
194
225
N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) a = [] for i in range(0, N): if V[i] >= C[i]: a.append(V[i] - C[i]) else: continue print((sum(a)))
import heapq N = int(eval(input())) V = list(map(int, input().split())) C = list(map(int, input().split())) a = [] for i in range(0, N): if V[i] >= C[i]: heapq.heappush(a, (V[i] - C[i])) else: continue print((sum(a)))
false
9.090909
[ "+import heapq", "+", "- a.append(V[i] - C[i])", "+ heapq.heappush(a, (V[i] - C[i]))" ]
false
0.046889
0.043785
1.070869
[ "s432558575", "s138199702" ]
u093500767
p04044
python
s807884239
s628402783
21
19
3,316
3,316
Accepted
Accepted
9.52
n, l = list(map(int, input().split())) list = [] for _ in range(n): list.append(eval(input())) list.sort() str = "" for s in list: str += s print(str)
n, l = list(map(int, input().split())) list = [] for _ in range(n): list.append(eval(input())) list.sort() string = "" for s in list: string += s print(("".join(string)))
12
12
160
178
n, l = list(map(int, input().split())) list = [] for _ in range(n): list.append(eval(input())) list.sort() str = "" for s in list: str += s print(str)
n, l = list(map(int, input().split())) list = [] for _ in range(n): list.append(eval(input())) list.sort() string = "" for s in list: string += s print(("".join(string)))
false
0
[ "-str = \"\"", "+string = \"\"", "- str += s", "-print(str)", "+ string += s", "+print((\"\".join(string)))" ]
false
0.048138
0.007948
6.057056
[ "s807884239", "s628402783" ]
u183422236
p03076
python
s038599154
s807805132
19
17
3,188
3,060
Accepted
Accepted
10.53
from itertools import permutations foods = [int(eval(input())) for i in range(5)] ans = 1230 for i in permutations(foods): tmp = 0 for j in range(4): tmp += -(-i[j] // 10) tmp *= 10 tmp += i[4] ans = min(ans, tmp) print(ans)
foods = [int(eval(input())) for i in range(5)] amari = [i % 10 for i in foods] kiriage = [-(-i//10) for i in foods] min_amari = 10 for i in amari: if 1 <= i < min_amari: min_amari = i print((sum(kiriage) * 10 - (10 - (10 if max(amari) == 0 else min_amari))))
11
8
256
269
from itertools import permutations foods = [int(eval(input())) for i in range(5)] ans = 1230 for i in permutations(foods): tmp = 0 for j in range(4): tmp += -(-i[j] // 10) tmp *= 10 tmp += i[4] ans = min(ans, tmp) print(ans)
foods = [int(eval(input())) for i in range(5)] amari = [i % 10 for i in foods] kiriage = [-(-i // 10) for i in foods] min_amari = 10 for i in amari: if 1 <= i < min_amari: min_amari = i print((sum(kiriage) * 10 - (10 - (10 if max(amari) == 0 else min_amari))))
false
27.272727
[ "-from itertools import permutations", "-", "-ans = 1230", "-for i in permutations(foods):", "- tmp = 0", "- for j in range(4):", "- tmp += -(-i[j] // 10)", "- tmp *= 10", "- tmp += i[4]", "- ans = min(ans, tmp)", "-print(ans)", "+amari = [i % 10 for i in foods]", "+kir...
false
0.046891
0.045741
1.025143
[ "s038599154", "s807805132" ]
u867826040
p03425
python
s803137793
s670338122
143
59
9,192
9,180
Accepted
Accepted
58.74
from itertools import combinations as cmbs c = {"M":0,"A":0,"R":0,"C":0,"H":0} for i in range(int(eval(input()))): si = eval(input()) if si[0] in c: c[si[0]] += 1 ans = 0 for i,j,k in cmbs(list(c.values()),r=3): t = i*j*k ans += t print(ans)
from itertools import combinations as cmbs import sys c = {"M":0,"A":0,"R":0,"C":0,"H":0} for i in range(int(eval(input()))): si = sys.stdin.readline() if si[0] in c: c[si[0]] += 1 ans = 0 for i,j,k in cmbs(list(c.values()),r=3): t = i*j*k ans += t print(ans)
11
12
245
271
from itertools import combinations as cmbs c = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for i in range(int(eval(input()))): si = eval(input()) if si[0] in c: c[si[0]] += 1 ans = 0 for i, j, k in cmbs(list(c.values()), r=3): t = i * j * k ans += t print(ans)
from itertools import combinations as cmbs import sys c = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0} for i in range(int(eval(input()))): si = sys.stdin.readline() if si[0] in c: c[si[0]] += 1 ans = 0 for i, j, k in cmbs(list(c.values()), r=3): t = i * j * k ans += t print(ans)
false
8.333333
[ "+import sys", "- si = eval(input())", "+ si = sys.stdin.readline()" ]
false
0.046475
0.036363
1.278073
[ "s803137793", "s670338122" ]
u883621917
p02678
python
s532223192
s707587422
467
275
34,896
95,504
Accepted
Accepted
41.11
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n, m = list(map(int, input().split())) graph = [0] + [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) from collections import deque def bfs(graph, queue,...
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n, m = list(map(int, input().split())) graph = [0] + [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) from collections import deque def bfs(graph, queue,...
34
37
711
814
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) n, m = list(map(int, input().split())) graph = [0] + [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) from collections import deque def bfs(graph, queue, prev): whi...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) n, m = list(map(int, input().split())) graph = [0] + [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) graph[a].append(b) graph[b].append(a) from collections import deque def bfs(graph, queue, dist, prev): ...
false
8.108108
[ "-def bfs(graph, queue, prev):", "+def bfs(graph, queue, dist, prev):", "- if prev[n] != -1:", "+ if dist[n] != -1:", "- prev[n] = current", "- queue.append(n)", "+ else:", "+ dist[n] = dist[current] + 1", "+ prev[n...
false
0.039825
0.039843
0.999554
[ "s532223192", "s707587422" ]
u994935583
p02899
python
s476828201
s287972792
619
521
23,368
23,372
Accepted
Accepted
15.83
import numpy as np def resolve(): N = int(input()) A = np.array(list(map(int,input().split()))) ans = (np.argsort(A) + 1) for i in ans: print(i, end =" ") resolve()
import numpy as np def resolve(): N = int(eval(input())) A = np.array(list(map(int,input().split()))) ans = (np.argsort(A) + 1) print((*ans)) resolve()
8
7
195
165
import numpy as np def resolve(): N = int(input()) A = np.array(list(map(int, input().split()))) ans = np.argsort(A) + 1 for i in ans: print(i, end=" ") resolve()
import numpy as np def resolve(): N = int(eval(input())) A = np.array(list(map(int, input().split()))) ans = np.argsort(A) + 1 print((*ans)) resolve()
false
12.5
[ "- N = int(input())", "+ N = int(eval(input()))", "- for i in ans:", "- print(i, end=\" \")", "+ print((*ans))" ]
false
0.668471
0.247109
2.70517
[ "s476828201", "s287972792" ]
u620084012
p04030
python
s709547672
s116519893
164
17
38,256
2,940
Accepted
Accepted
89.63
s = eval(input()) ans = "" for e in s: if e == "0": ans += "0" elif e == "1": ans += "1" else: if len(ans) > 0: ans = ans[:-1] print(ans)
import sys, math def input(): return sys.stdin.readline()[:-1] def main(): S = eval(input()) ans = "" for e in S: if e == "B": ans = ans[:-1] else: ans += e print(ans) if __name__ == '__main__': main()
11
16
190
277
s = eval(input()) ans = "" for e in s: if e == "0": ans += "0" elif e == "1": ans += "1" else: if len(ans) > 0: ans = ans[:-1] print(ans)
import sys, math def input(): return sys.stdin.readline()[:-1] def main(): S = eval(input()) ans = "" for e in S: if e == "B": ans = ans[:-1] else: ans += e print(ans) if __name__ == "__main__": main()
false
31.25
[ "-s = eval(input())", "-ans = \"\"", "-for e in s:", "- if e == \"0\":", "- ans += \"0\"", "- elif e == \"1\":", "- ans += \"1\"", "- else:", "- if len(ans) > 0:", "+import sys, math", "+", "+", "+def input():", "+ return sys.stdin.readline()[:-1]", "+", ...
false
0.042855
0.036983
1.158789
[ "s709547672", "s116519893" ]
u411203878
p02767
python
s753184958
s488401062
182
68
38,896
63,660
Accepted
Accepted
62.64
n=int(eval(input())) t = list(map(int,input().split())) res = 100000000000000000000000000000000 t.sort() #print(t) for i in range(t[0], t[-1]+1): memo = 0 for j in t: memo += (j-i)**2 res = min(memo, res) print(res)
N = int(eval(input())) X = list(map(int,input().split())) ans = 10000000000000000 for i in range(101): tmp = 0 for x in X: tmp += (i-x)**2 ans = min(ans, tmp) print(ans)
15
12
247
197
n = int(eval(input())) t = list(map(int, input().split())) res = 100000000000000000000000000000000 t.sort() # print(t) for i in range(t[0], t[-1] + 1): memo = 0 for j in t: memo += (j - i) ** 2 res = min(memo, res) print(res)
N = int(eval(input())) X = list(map(int, input().split())) ans = 10000000000000000 for i in range(101): tmp = 0 for x in X: tmp += (i - x) ** 2 ans = min(ans, tmp) print(ans)
false
20
[ "-n = int(eval(input()))", "-t = list(map(int, input().split()))", "-res = 100000000000000000000000000000000", "-t.sort()", "-# print(t)", "-for i in range(t[0], t[-1] + 1):", "- memo = 0", "- for j in t:", "- memo += (j - i) ** 2", "- res = min(memo, res)", "-print(res)", "+N ...
false
0.034501
0.032993
1.045726
[ "s753184958", "s488401062" ]
u254871849
p02937
python
s742390122
s063175608
418
128
3,444
12,200
Accepted
Accepted
69.38
# 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 a...
from collections import defaultdict from bisect import bisect_left def main(): s = eval(input()) n = len(s) s = s + s t = eval(input()) if set(t) - set(s): print((-1)) exit() d = defaultdict(list) for i in range(2 * n): d[s[i]] += [i] cur = ncnt = 0 for c in t: x = d[c][bisect_left...
51
29
1,174
454
# 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 # fro...
from collections import defaultdict from bisect import bisect_left def main(): s = eval(input()) n = len(s) s = s + s t = eval(input()) if set(t) - set(s): print((-1)) exit() d = defaultdict(list) for i in range(2 * n): d[s[i]] += [i] cur = ncnt = 0 for c in...
false
43.137255
[ "-# 2019-11-17 10:52:21(JST)", "-import sys", "+from collections import defaultdict", "+from bisect import bisect_left", "-# 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", "-#...
false
0.046543
0.037146
1.252954
[ "s742390122", "s063175608" ]
u912237403
p02421
python
s703689199
s569366435
20
10
4,264
4,240
Accepted
Accepted
50
def judge(w1, w2): la = len(w1) lb = len(w2) for i in range(min(la,lb)): if w1[i] > w2[i]: return 1 elif w1[i] < w2[i]: return 2 if la > lb: return 1 elif la < lb: return 2 else: return 0 s = [0, 0, 0] loop = int(input()) for i in range(loop): w = input().split(...
s = [0, 0, 0] loop = int(input()) for i in range(loop): w1, w2 = input().split() tmp = 1 - cmp(w1, w2) if tmp == 1: s[0] += 1 s[2] += 1 else: s[tmp] += 3 print(s[0], s[2])
21
11
456
228
def judge(w1, w2): la = len(w1) lb = len(w2) for i in range(min(la, lb)): if w1[i] > w2[i]: return 1 elif w1[i] < w2[i]: return 2 if la > lb: return 1 elif la < lb: return 2 else: return 0 s = [0, 0, 0] loop = int(input()) for i i...
s = [0, 0, 0] loop = int(input()) for i in range(loop): w1, w2 = input().split() tmp = 1 - cmp(w1, w2) if tmp == 1: s[0] += 1 s[2] += 1 else: s[tmp] += 3 print(s[0], s[2])
false
47.619048
[ "-def judge(w1, w2):", "- la = len(w1)", "- lb = len(w2)", "- for i in range(min(la, lb)):", "- if w1[i] > w2[i]:", "- return 1", "- elif w1[i] < w2[i]:", "- return 2", "- if la > lb:", "- return 1", "- elif la < lb:", "- return ...
false
0.069936
0.067357
1.038293
[ "s703689199", "s569366435" ]
u626337957
p02579
python
s002616356
s148630492
718
634
163,396
141,484
Accepted
Accepted
11.7
from collections import deque H, W = list(map(int, input().split())) cy, cx = list(map(int, input().split())) sy, sx = list(map(int, input().split())) tiles = [list(eval(input())) for _ in range(H)] # initialization INF = 10**4 arrived = [[INF for _ in range(W)] for __ in range(H)] paths = deque() warps = ...
H,W = map(int,input().split()) Ch, Cw = map(int,input().split()) Dh, Dw = map(int,input().split()) S = [list(input()) for _ in range(H)] INF = H * W dx = [1, 0, -1, 0] dy = [0, -1, 0, 1] # def steppable(h,w): # if not (h in range(H)) or not (w in range(W)): # return False # if S[h][w]...
41
63
1,194
1,829
from collections import deque H, W = list(map(int, input().split())) cy, cx = list(map(int, input().split())) sy, sx = list(map(int, input().split())) tiles = [list(eval(input())) for _ in range(H)] # initialization INF = 10**4 arrived = [[INF for _ in range(W)] for __ in range(H)] paths = deque() warps = deque() dx =...
H, W = map(int, input().split()) Ch, Cw = map(int, input().split()) Dh, Dw = map(int, input().split()) S = [list(input()) for _ in range(H)] INF = H * W dx = [1, 0, -1, 0] dy = [0, -1, 0, 1] # def steppable(h,w): # if not (h in range(H)) or not (w in range(W)): # return False # if S[h][w] == '#': # ...
false
34.920635
[ "-from collections import deque", "-", "-H, W = list(map(int, input().split()))", "-cy, cx = list(map(int, input().split()))", "-sy, sx = list(map(int, input().split()))", "-tiles = [list(eval(input())) for _ in range(H)]", "-# initialization", "-INF = 10**4", "-arrived = [[INF for _ in range(W)] fo...
false
0.102255
0.046383
2.204588
[ "s002616356", "s148630492" ]
u608088992
p03994
python
s134937255
s934755620
129
49
4,152
4,792
Accepted
Accepted
62.02
s = list(eval(input())) K = int(eval(input())) AB = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"\ , "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] L = len(s) Ans = "" for i in range(L-1): if s[i] == "a": Ans += "a" else: move = 26 - AB.index(s[i]) ...
import sys class alphabet(): #Trueなら大文字 def __init__(self, capitalize): self.num = dict() #あるアルファベットが最初から何番目か、0-indexed self.index = dict() #i番目のアルファベット self.abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"\ ,"o", "p", "q", "r", "s", "t", "u", "...
24
36
604
1,101
s = list(eval(input())) K = int(eval(input())) AB = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ] L = len(s) Ans = "" for i in r...
import sys class alphabet: # Trueなら大文字 def __init__(self, capitalize): self.num = dict() # あるアルファベットが最初から何番目か、0-indexed self.index = dict() # i番目のアルファベット self.abc = [ "a", "b", "c", "d", "e", "f", "g", ...
false
33.333333
[ "-s = list(eval(input()))", "-K = int(eval(input()))", "-AB = [", "- \"a\",", "- \"b\",", "- \"c\",", "- \"d\",", "- \"e\",", "- \"f\",", "- \"g\",", "- \"h\",", "- \"i\",", "- \"j\",", "- \"k\",", "- \"l\",", "- \"m\",", "- \"n\",", "- ...
false
0.037266
0.007031
5.300285
[ "s134937255", "s934755620" ]
u416758623
p03331
python
s451709064
s590758760
221
141
3,060
9,164
Accepted
Accepted
36.2
n = int(eval(input())) def find(a): global total total = 0 while a > 0: total += a % 10 a //= 10 return total ans = float('inf') for i in range(1,n): tmp = find(i) + find(n-i) ans = min(ans, tmp) print(ans)
def findSumOfDigits(n): sum = 0 while n > 0: sum += n % 10 n //= 10 return sum n = int(eval(input())) minTotal = float('inf') for i in range(1,n+1): if 0 < n - i < n: a = findSumOfDigits(i) b = findSumOfDigits(n-i) if a + b < minTotal: m...
15
16
256
346
n = int(eval(input())) def find(a): global total total = 0 while a > 0: total += a % 10 a //= 10 return total ans = float("inf") for i in range(1, n): tmp = find(i) + find(n - i) ans = min(ans, tmp) print(ans)
def findSumOfDigits(n): sum = 0 while n > 0: sum += n % 10 n //= 10 return sum n = int(eval(input())) minTotal = float("inf") for i in range(1, n + 1): if 0 < n - i < n: a = findSumOfDigits(i) b = findSumOfDigits(n - i) if a + b < minTotal: minTotal ...
false
6.25
[ "-n = int(eval(input()))", "+def findSumOfDigits(n):", "+ sum = 0", "+ while n > 0:", "+ sum += n % 10", "+ n //= 10", "+ return sum", "-def find(a):", "- global total", "- total = 0", "- while a > 0:", "- total += a % 10", "- a //= 10", "- ...
false
0.186925
0.19757
0.946122
[ "s451709064", "s590758760" ]
u991567869
p03457
python
s220668945
s691042369
244
216
17,312
17,324
Accepted
Accepted
11.48
import sys input = sys.stdin.readline n = int(eval(input())) t = 0 x = 0 y = 0 l = [tuple(map(int, input().split())) for _ in range(n)] for t1, x1, y1 in l: if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1: print("No") exit() if (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2: p...
import sys input = sys.stdin.readline def main(): n = int(eval(input())) t = 0 x = 0 y = 0 l = [tuple(map(int, input().split())) for _ in range(n)] for t1, x1, y1 in l: if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1: print("No") exit() if (a...
22
24
392
477
import sys input = sys.stdin.readline n = int(eval(input())) t = 0 x = 0 y = 0 l = [tuple(map(int, input().split())) for _ in range(n)] for t1, x1, y1 in l: if (abs(x1 - x) + abs(y1 - y)) / (t1 - t) > 1: print("No") exit() if (abs(x1 - x) + abs(y1 - y)) % 2 != (t1 - t) % 2: print("No") ...
import sys input = sys.stdin.readline def main(): n = int(eval(input())) t = 0 x = 0 y = 0 l = [tuple(map(int, input().split())) for _ in range(n)] for t1, x1, y1 in l: if (abs(x1 - x) + abs(y1 - y)) / (t1 - t) > 1: print("No") exit() if (abs(x1 - x) + ...
false
8.333333
[ "-n = int(eval(input()))", "-t = 0", "-x = 0", "-y = 0", "-l = [tuple(map(int, input().split())) for _ in range(n)]", "-for t1, x1, y1 in l:", "- if (abs(x1 - x) + abs(y1 - y)) / (t1 - t) > 1:", "- print(\"No\")", "- exit()", "- if (abs(x1 - x) + abs(y1 - y)) % 2 != (t1 - t) % ...
false
0.115841
0.088779
1.304821
[ "s220668945", "s691042369" ]
u167681750
p03128
python
s836275476
s093606109
190
153
14,836
14,836
Accepted
Accepted
19.47
n, m = list(map(int, input().split())) a = list(map(int, input().split())) needs = [10,2,5,5,4,5,6,3,7,6] table = [-1] * (n + 10) table[0] = 0 for i in range(n): if table[i] != -1: for number in sorted(a, reverse = True): matchs = needs[number] if table[i+matchs] == 0: ...
n, m = list(map(int, input().split())) *a, = list(map(int, input().split())) sorted_a = sorted(a, reverse=True) needs = [9,2,5,5,4,5,6,3,7,6] table = [-1] * (n+10) table[0] = 0 for i in range(n): if table[i] != -1: for j in sorted_a: table[i + needs[j]] = max(table[i]*10 + j, table[...
17
14
488
341
n, m = list(map(int, input().split())) a = list(map(int, input().split())) needs = [10, 2, 5, 5, 4, 5, 6, 3, 7, 6] table = [-1] * (n + 10) table[0] = 0 for i in range(n): if table[i] != -1: for number in sorted(a, reverse=True): matchs = needs[number] if table[i + matchs] == 0: ...
n, m = list(map(int, input().split())) (*a,) = list(map(int, input().split())) sorted_a = sorted(a, reverse=True) needs = [9, 2, 5, 5, 4, 5, 6, 3, 7, 6] table = [-1] * (n + 10) table[0] = 0 for i in range(n): if table[i] != -1: for j in sorted_a: table[i + needs[j]] = max(table[i] * 10 + j, tabl...
false
17.647059
[ "-a = list(map(int, input().split()))", "-needs = [10, 2, 5, 5, 4, 5, 6, 3, 7, 6]", "+(*a,) = list(map(int, input().split()))", "+sorted_a = sorted(a, reverse=True)", "+needs = [9, 2, 5, 5, 4, 5, 6, 3, 7, 6]", "- for number in sorted(a, reverse=True):", "- matchs = needs[number]", "-...
false
0.102353
0.033061
3.095869
[ "s836275476", "s093606109" ]
u247922466
p04045
python
s820461848
s449258984
57
22
3,064
3,064
Accepted
Accepted
61.4
def C_IrohasObsession(): N, K = list(map(int, input().split())) D = list(map(int, input().split())) ans = 0 for x in range(N, 100000): for y in str(x): if int(y) in D: break else: ans = int(x) break print(ans) if __nam...
def C_IrohasObsession(): N, K = list(map(int, input().split())) D = list(map(int, input().split())) ans = 0 for x in range(N, 10000): for y in str(x): if int(y) in D: break else: ans = int(x) break if N > ans: fo...
15
22
357
576
def C_IrohasObsession(): N, K = list(map(int, input().split())) D = list(map(int, input().split())) ans = 0 for x in range(N, 100000): for y in str(x): if int(y) in D: break else: ans = int(x) break print(ans) if __name__ == "__ma...
def C_IrohasObsession(): N, K = list(map(int, input().split())) D = list(map(int, input().split())) ans = 0 for x in range(N, 10000): for y in str(x): if int(y) in D: break else: ans = int(x) break if N > ans: for x in range...
false
31.818182
[ "- for x in range(N, 100000):", "+ for x in range(N, 10000):", "+ if N > ans:", "+ for x in range(1, 10):", "+ if x not in D:", "+ ans = x * 10000", "+ if 0 in D:", "+ ans += x * 1000 + x * 100 + x * 10 + x", "+ ...
false
0.045779
0.039721
1.152523
[ "s820461848", "s449258984" ]
u759949288
p00012
python
s790347556
s038693780
20
10
5,300
5,300
Accepted
Accepted
50
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a; cr = cross(x, y) if cr != 0: return cr if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 def solve(l, p): x = cmp(ccw(l[0][0], l...
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a; cr = cross(x, y) if cr != 0: return cr if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 def solve(l, p): x = cmp(ccw(l[0][0], l...
27
28
614
596
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a cr = cross(x, y) if cr != 0: return cr if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 de...
import sys def cross(a, b): return (a.conjugate() * b).imag def dot(a, b): return (a.conjugate() * b).real def ccw(a, b, c): x = b - a y = c - a cr = cross(x, y) if cr != 0: return cr if dot(x, y) < 0: return 2 if abs(x) < abs(y): return -2 return 0 de...
false
3.571429
[ "- if any([x != cmp(ccw(i[0], i[1], p), 0) for i in l[1:]]):", "+ if all(cmp(ccw(i[0], i[1], p), 0) == x for i in l[1:]):", "+ print(\"YES\")", "+ else:", "- else:", "- print(\"YES\")", "- a, b, c, p = list(map(lambda x, y: complex(x, y), t[0::2], t[1::2]))", "+ a, b, c...
false
0.036527
0.040681
0.897886
[ "s790347556", "s038693780" ]
u375695365
p03043
python
s858057019
s227369521
44
40
2,940
3,188
Accepted
Accepted
9.09
n,k=list(map(int,input().split())) ans=0 a=0 for i in range(1,n+1): count=0 while i<k: i*=2 count+=1 ans+=(0.5)**count/n print(ans)
n,k=list(map(int,input().split())) ans=0 for i in range(1,n+1): count=0 now=i if i<k: while now<k: now*=2 count+=1 ans+=0.5**count else: ans+=1 print((ans/n))
10
16
162
232
n, k = list(map(int, input().split())) ans = 0 a = 0 for i in range(1, n + 1): count = 0 while i < k: i *= 2 count += 1 ans += (0.5) ** count / n print(ans)
n, k = list(map(int, input().split())) ans = 0 for i in range(1, n + 1): count = 0 now = i if i < k: while now < k: now *= 2 count += 1 ans += 0.5**count else: ans += 1 print((ans / n))
false
37.5
[ "-a = 0", "- while i < k:", "- i *= 2", "- count += 1", "- ans += (0.5) ** count / n", "-print(ans)", "+ now = i", "+ if i < k:", "+ while now < k:", "+ now *= 2", "+ count += 1", "+ ans += 0.5**count", "+ else:", "+ a...
false
0.138647
0.092572
1.497716
[ "s858057019", "s227369521" ]
u176445062
p02971
python
s333182930
s750886672
1,414
1,266
66,768
93,016
Accepted
Accepted
10.47
# n = 3 n = int(eval(input())) arr = [0]*n for i in range(n): arr[i] = (int(eval(input())), i) sorted_arr = sorted(arr, reverse=True) lg, slg = sorted_arr[0][1], sorted_arr[1][1] for i in range(n): if i==lg: print((arr[slg][0])) else: print((arr[lg][0]))
import heapq n = int(eval(input())) # n = 3 arr = [0]*n pq = [] for i in range(n): arr[i] = int(eval(input())) heapq.heappush(pq, (-arr[i], i)) heapq.heapify(pq) lg = heapq.heappop(pq) slg = heapq.heappop(pq) lg, slg = lg[1], slg[1] for i in range(n): if i==lg: print((arr[slg])) else: pr...
15
21
262
318
# n = 3 n = int(eval(input())) arr = [0] * n for i in range(n): arr[i] = (int(eval(input())), i) sorted_arr = sorted(arr, reverse=True) lg, slg = sorted_arr[0][1], sorted_arr[1][1] for i in range(n): if i == lg: print((arr[slg][0])) else: print((arr[lg][0]))
import heapq n = int(eval(input())) # n = 3 arr = [0] * n pq = [] for i in range(n): arr[i] = int(eval(input())) heapq.heappush(pq, (-arr[i], i)) heapq.heapify(pq) lg = heapq.heappop(pq) slg = heapq.heappop(pq) lg, slg = lg[1], slg[1] for i in range(n): if i == lg: print((arr[slg])) else: ...
false
28.571429
[ "+import heapq", "+", "+n = int(eval(input()))", "-n = int(eval(input()))", "+pq = []", "- arr[i] = (int(eval(input())), i)", "-sorted_arr = sorted(arr, reverse=True)", "-lg, slg = sorted_arr[0][1], sorted_arr[1][1]", "+ arr[i] = int(eval(input()))", "+ heapq.heappush(pq, (-arr[i], i))", ...
false
0.072686
0.075903
0.957618
[ "s333182930", "s750886672" ]
u837673618
p02709
python
s120542336
s250942576
1,215
838
9,760
9,960
Accepted
Accepted
31.03
from operator import itemgetter as get N = int(eval(input())) A = list(map(int, input().split())) SA = SB = 0 ABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True) def solve(a, i, prev, th, tha): pl, pr, ps = 0, -1, 0 for l, r, s in prev: if...
N = int(eval(input())) A = list(map(int, input().split())) AI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True) def solve(a, i, prev): pl, pr, ps = i, 0, 0 for l, r, s in prev: yield l, r-1, max(s+abs(r-i)*a, ps+abs(i-pl)*a) pl, pr, ps = l, r, s yield pl+1, pr, ps+abs(i-pl)*a p...
31
18
782
409
from operator import itemgetter as get N = int(eval(input())) A = list(map(int, input().split())) SA = SB = 0 ABI = sorted( ( (b := max(N - i, i - 1) * a, SA := SA + a, SB := SB + b) and (a, b, i) for i, a in enumerate(A, 1) ), reverse=True, ) def solve(a, i, prev, th, tha): pl, pr, p...
N = int(eval(input())) A = list(map(int, input().split())) AI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True) def solve(a, i, prev): pl, pr, ps = i, 0, 0 for l, r, s in prev: yield l, r - 1, max(s + abs(r - i) * a, ps + abs(i - pl) * a) pl, pr, ps = l, r, s yield pl + 1, pr, p...
false
41.935484
[ "-from operator import itemgetter as get", "-", "-SA = SB = 0", "-ABI = sorted(", "- (", "- (b := max(N - i, i - 1) * a, SA := SA + a, SB := SB + b) and (a, b, i)", "- for i, a in enumerate(A, 1)", "- ),", "- reverse=True,", "-)", "+AI = sorted(((a, i) for i, a in enumerat...
false
0.034475
0.037537
0.918415
[ "s120542336", "s250942576" ]
u193264896
p03546
python
s579804541
s106847427
273
192
17,060
38,264
Accepted
Accepted
29.67
import sys from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): H, W = list(map(int, readline().split())) L = list(list(map(int, readline().split())) for _ in ...
import sys from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix import numpy as np read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): H, W = list(map(int, readline().split())) L = li...
23
31
616
701
import sys from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): H, W = list(map(int, readline().split())) L = list(list(map(int, readline().split())) for _ in range(10)) ...
import sys from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix import numpy as np read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10**8) INF = float("inf") MOD = 10**9 + 7 def main(): H, W = list(map(int, readline().split())) L = list(list(map(int, r...
false
25.806452
[ "+import numpy as np", "+read = sys.stdin.read", "- path = dijkstra(csr_matrix(L))", "+ A = list(list(map(int, readline().split())) for _ in range(H))", "+ dist = dijkstra(csr_matrix(L))", "- for i in range(H):", "- A = list(map(int, readline().split()))", "- for j in range(W...
false
0.282151
0.48122
0.586324
[ "s579804541", "s106847427" ]
u784022244
p02791
python
s991859728
s849237412
129
112
24,744
24,744
Accepted
Accepted
13.18
n=int(eval(input())) p=list(map(int, input().split())) ans=1 l=[p[0]] buf=p[0] for i in range(1,n): l.append(p[i]) if p[i]<=buf: ans+=1 buf=p[i] print(ans)
n=int(eval(input())) p=list(map(int, input().split())) ans=1 now=p[0] for i in range(1,n): if p[i]<now: now=p[i] ans+=1 print(ans)
11
9
184
142
n = int(eval(input())) p = list(map(int, input().split())) ans = 1 l = [p[0]] buf = p[0] for i in range(1, n): l.append(p[i]) if p[i] <= buf: ans += 1 buf = p[i] print(ans)
n = int(eval(input())) p = list(map(int, input().split())) ans = 1 now = p[0] for i in range(1, n): if p[i] < now: now = p[i] ans += 1 print(ans)
false
18.181818
[ "-l = [p[0]]", "-buf = p[0]", "+now = p[0]", "- l.append(p[i])", "- if p[i] <= buf:", "+ if p[i] < now:", "+ now = p[i]", "- buf = p[i]" ]
false
0.038829
0.125979
0.30822
[ "s991859728", "s849237412" ]
u672475305
p02690
python
s277172339
s012406107
173
32
9,428
9,140
Accepted
Accepted
81.5
x = int(eval(input())) def f(a,b): return pow(a,4) + b*pow(a,3) + pow(a*b,2) + a*pow(b,3) + pow(b,4) def divisor(n): tank = [] for i in range(1, int(n**0.5)+1): if n%i==0: tank.append(i) if i!=n//i: tank.append(n//i) tank.sort() return tan...
x = int(eval(input())) lst = [(pow(i, 5), i) for i in range(-200, 200)] for i in range(len(lst)): for j in range(len(lst)): if lst[j][0] - lst[i][0] == x: print((lst[j][1], lst[i][1])) exit()
28
7
609
225
x = int(eval(input())) def f(a, b): return pow(a, 4) + b * pow(a, 3) + pow(a * b, 2) + a * pow(b, 3) + pow(b, 4) def divisor(n): tank = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: tank.append(i) if i != n // i: tank.append(n // i) tank.sort()...
x = int(eval(input())) lst = [(pow(i, 5), i) for i in range(-200, 200)] for i in range(len(lst)): for j in range(len(lst)): if lst[j][0] - lst[i][0] == x: print((lst[j][1], lst[i][1])) exit()
false
75
[ "-", "-", "-def f(a, b):", "- return pow(a, 4) + b * pow(a, 3) + pow(a * b, 2) + a * pow(b, 3) + pow(b, 4)", "-", "-", "-def divisor(n):", "- tank = []", "- for i in range(1, int(n**0.5) + 1):", "- if n % i == 0:", "- tank.append(i)", "- if i != n // i:", ...
false
0.182917
0.052124
3.509282
[ "s277172339", "s012406107" ]
u926657458
p00001
python
s430217941
s592900341
40
20
7,760
7,684
Accepted
Accepted
50
def main(): N=10 l = list() for i in range(N): l.append(int(eval(input()))) l.sort(reverse=True) for x in l[:3]: print(x) if __name__=='__main__': main()
import sys data = sys.stdin.readline() l = list() while data: l.append(int(data)) data = sys.stdin.readline() for x in sorted(l,reverse=True)[:3]: print(x)
11
10
198
178
def main(): N = 10 l = list() for i in range(N): l.append(int(eval(input()))) l.sort(reverse=True) for x in l[:3]: print(x) if __name__ == "__main__": main()
import sys data = sys.stdin.readline() l = list() while data: l.append(int(data)) data = sys.stdin.readline() for x in sorted(l, reverse=True)[:3]: print(x)
false
9.090909
[ "-def main():", "- N = 10", "- l = list()", "- for i in range(N):", "- l.append(int(eval(input())))", "- l.sort(reverse=True)", "- for x in l[:3]:", "- print(x)", "+import sys", "-", "-if __name__ == \"__main__\":", "- main()", "+data = sys.stdin.readline()", ...
false
0.052194
0.071624
0.728729
[ "s430217941", "s592900341" ]
u217627525
p03548
python
s755499219
s746654505
32
17
2,940
2,940
Accepted
Accepted
46.88
x,y,z=list(map(int,input().split())) w=y+2*z ans=1 while w<=x-(y+z): w+=y+z ans+=1 print(ans)
x,y,z=list(map(int,input().split())) ans=(x-z)//(y+z) print(ans)
7
3
101
60
x, y, z = list(map(int, input().split())) w = y + 2 * z ans = 1 while w <= x - (y + z): w += y + z ans += 1 print(ans)
x, y, z = list(map(int, input().split())) ans = (x - z) // (y + z) print(ans)
false
57.142857
[ "-w = y + 2 * z", "-ans = 1", "-while w <= x - (y + z):", "- w += y + z", "- ans += 1", "+ans = (x - z) // (y + z)" ]
false
0.043322
0.038196
1.134194
[ "s755499219", "s746654505" ]
u088552457
p03487
python
s934959854
s664802457
112
76
21,620
18,304
Accepted
Accepted
32.14
n = int(eval(input())) a = list(map(int, input().split())) import collections ac = collections.Counter(a) common = ac.most_common() operation_count = 0 for num, num_count in common: if num < num_count: operation_count += num_count - num elif num_count < num: operation_count += num_count p...
n = int(eval(input())) import collections a = list(map(int, input().split())) ac = collections.Counter(a) la = len(a) ans = 0 for k, c in list(ac.items()): if c < k: ans += c else: ans += c - k print(ans)
17
15
341
226
n = int(eval(input())) a = list(map(int, input().split())) import collections ac = collections.Counter(a) common = ac.most_common() operation_count = 0 for num, num_count in common: if num < num_count: operation_count += num_count - num elif num_count < num: operation_count += num_count print(o...
n = int(eval(input())) import collections a = list(map(int, input().split())) ac = collections.Counter(a) la = len(a) ans = 0 for k, c in list(ac.items()): if c < k: ans += c else: ans += c - k print(ans)
false
11.764706
[ "-a = list(map(int, input().split()))", "+a = list(map(int, input().split()))", "-common = ac.most_common()", "-operation_count = 0", "-for num, num_count in common:", "- if num < num_count:", "- operation_count += num_count - num", "- elif num_count < num:", "- operation_count +...
false
0.119601
0.123858
0.965633
[ "s934959854", "s664802457" ]
u597455618
p02559
python
s424864156
s984452006
2,382
1,569
73,512
148,296
Accepted
Accepted
34.13
import sys def sum(tree, i): s = 0 while i > 0: s += tree[i] i -= i & -i return s def add(tree, size, i, x): while i <= size: tree[i] += x i += i & -i def range_sum(tree, l, r): return sum(tree, r) - sum(tree, l) def main(): n, q = l...
from numba import njit, b1, i4, i8, f8 import numpy as np import sys @njit((i8[:], i8), cache=True) def sum(tree, i): s = 0 while i > 0: s += tree[i] i -= i & -i return s @njit((i8[:], i8, i8, i8), cache=True) def add(tree, size, i, x): while i <= size: tree...
39
44
772
945
import sys def sum(tree, i): s = 0 while i > 0: s += tree[i] i -= i & -i return s def add(tree, size, i, x): while i <= size: tree[i] += x i += i & -i def range_sum(tree, l, r): return sum(tree, r) - sum(tree, l) def main(): n, q = list(map(int, sys.stdin....
from numba import njit, b1, i4, i8, f8 import numpy as np import sys @njit((i8[:], i8), cache=True) def sum(tree, i): s = 0 while i > 0: s += tree[i] i -= i & -i return s @njit((i8[:], i8, i8, i8), cache=True) def add(tree, size, i, x): while i <= size: tree[i] += x i...
false
11.363636
[ "+from numba import njit, b1, i4, i8, f8", "+import numpy as np", "+@njit((i8[:], i8), cache=True)", "+@njit((i8[:], i8, i8, i8), cache=True)", "+@njit((i8[:], i8, i8), cache=True)", "- bit = [0] + list(map(int, sys.stdin.buffer.readline().split()))", "+ bit = np.array([0] + sys.stdin.buffer.readl...
false
0.047651
0.04704
1.012993
[ "s424864156", "s984452006" ]
u489959379
p02900
python
s646929048
s381262732
139
109
3,060
3,064
Accepted
Accepted
21.58
import math def gcd(n, m): while m != 0: n, m = m, n % m return n a, b = list(map(int, input().split())) g = gcd(a, b) g_2 = int(math.sqrt(g)) cnt = 1 for i in range(2, g_2+1): if g % i == 0: while g % i == 0: g //= i cnt += 1 if g > 1: cnt += 1 ...
def gcd(a, b): while b != 0: a, b = b, a % b return a def prime_factorization(n): res = [] for i in range(2, int(pow(n, 0.5)) + 1): if n % i == 0: ex = 0 while n % i == 0: ex += 1 n //= i res.append([i, e...
21
24
327
488
import math def gcd(n, m): while m != 0: n, m = m, n % m return n a, b = list(map(int, input().split())) g = gcd(a, b) g_2 = int(math.sqrt(g)) cnt = 1 for i in range(2, g_2 + 1): if g % i == 0: while g % i == 0: g //= i cnt += 1 if g > 1: cnt += 1 print(cnt)
def gcd(a, b): while b != 0: a, b = b, a % b return a def prime_factorization(n): res = [] for i in range(2, int(pow(n, 0.5)) + 1): if n % i == 0: ex = 0 while n % i == 0: ex += 1 n //= i res.append([i, ex]) if n !...
false
12.5
[ "-import math", "+def gcd(a, b):", "+ while b != 0:", "+ a, b = b, a % b", "+ return a", "-def gcd(n, m):", "- while m != 0:", "- n, m = m, n % m", "- return n", "+def prime_factorization(n):", "+ res = []", "+ for i in range(2, int(pow(n, 0.5)) + 1):", "+ ...
false
0.048472
0.045249
1.07122
[ "s646929048", "s381262732" ]
u961674365
p03448
python
s287082403
s684533628
51
43
3,064
3,064
Accepted
Accepted
15.69
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) cnt = 0 for k in range(a+1): for j in range(b+1): for i in range(c+1): if 50*i+100*j+500*k==x: cnt += 1 print(cnt)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) cnt = 0 aa=min(a,(x+a+1)//500)+1 bb=min(b,(x+b+1)//100)+1 cc=min(c,(x+c+1)//50)+1 for k in range(aa): for j in range(bb): for i in range(cc): if 50*i+100*j+500*k==x: cnt += 1 print(cnt)
11
14
212
286
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) cnt = 0 for k in range(a + 1): for j in range(b + 1): for i in range(c + 1): if 50 * i + 100 * j + 500 * k == x: cnt += 1 print(cnt)
a = int(eval(input())) b = int(eval(input())) c = int(eval(input())) x = int(eval(input())) cnt = 0 aa = min(a, (x + a + 1) // 500) + 1 bb = min(b, (x + b + 1) // 100) + 1 cc = min(c, (x + c + 1) // 50) + 1 for k in range(aa): for j in range(bb): for i in range(cc): if 50 * i + 100 * j + 500 * k...
false
21.428571
[ "-for k in range(a + 1):", "- for j in range(b + 1):", "- for i in range(c + 1):", "+aa = min(a, (x + a + 1) // 500) + 1", "+bb = min(b, (x + b + 1) // 100) + 1", "+cc = min(c, (x + c + 1) // 50) + 1", "+for k in range(aa):", "+ for j in range(bb):", "+ for i in range(cc):" ]
false
0.158272
0.042097
3.759696
[ "s287082403", "s684533628" ]
u020373088
p03556
python
s565861743
s853260737
29
17
2,940
2,940
Accepted
Accepted
41.38
n = int(eval(input())) for i in range(n+1): m = (i+1) ** 2 if m > n: print((i**2)) break
n = int(eval(input())) print((int(n**0.5) ** 2))
6
2
97
41
n = int(eval(input())) for i in range(n + 1): m = (i + 1) ** 2 if m > n: print((i**2)) break
n = int(eval(input())) print((int(n**0.5) ** 2))
false
66.666667
[ "-for i in range(n + 1):", "- m = (i + 1) ** 2", "- if m > n:", "- print((i**2))", "- break", "+print((int(n**0.5) ** 2))" ]
false
0.040683
0.044162
0.92122
[ "s565861743", "s853260737" ]
u729133443
p02779
python
s647586116
s749696609
83
70
31,572
30,160
Accepted
Accepted
15.66
n,a=open(0);print(('YNEOS'[int(n)>len(set(a.split()))::2]))
print(('YNEOS'[int(eval(input()))>len(set(input().split()))::2]))
1
1
57
57
n, a = open(0) print(("YNEOS"[int(n) > len(set(a.split())) :: 2]))
print(("YNEOS"[int(eval(input())) > len(set(input().split())) :: 2]))
false
0
[ "-n, a = open(0)", "-print((\"YNEOS\"[int(n) > len(set(a.split())) :: 2]))", "+print((\"YNEOS\"[int(eval(input())) > len(set(input().split())) :: 2]))" ]
false
0.037834
0.062815
0.602305
[ "s647586116", "s749696609" ]
u977193988
p02725
python
s892381314
s716228882
124
84
26,444
26,444
Accepted
Accepted
32.26
import sys def input(): return sys.stdin.readline().strip() K, N = list(map(int, input().split())) A = list(map(int, input().split())) Diff = [] for i in range(N - 1): Diff.append(A[i + 1] - A[i]) Diff.append(K - A[-1] + A[0]) print((K - max(Diff)))
import sys def input(): return sys.stdin.readline().strip() K, N = list(map(int, input().split())) A = list(map(int, input().split())) A.append(K + A[0]) Diff = [y - x for x, y in zip(A, A[1:])] answer = K - max(Diff) print(answer)
14
13
267
246
import sys def input(): return sys.stdin.readline().strip() K, N = list(map(int, input().split())) A = list(map(int, input().split())) Diff = [] for i in range(N - 1): Diff.append(A[i + 1] - A[i]) Diff.append(K - A[-1] + A[0]) print((K - max(Diff)))
import sys def input(): return sys.stdin.readline().strip() K, N = list(map(int, input().split())) A = list(map(int, input().split())) A.append(K + A[0]) Diff = [y - x for x, y in zip(A, A[1:])] answer = K - max(Diff) print(answer)
false
7.142857
[ "-Diff = []", "-for i in range(N - 1):", "- Diff.append(A[i + 1] - A[i])", "-Diff.append(K - A[-1] + A[0])", "-print((K - max(Diff)))", "+A.append(K + A[0])", "+Diff = [y - x for x, y in zip(A, A[1:])]", "+answer = K - max(Diff)", "+print(answer)" ]
false
0.052611
0.051908
1.013532
[ "s892381314", "s716228882" ]
u380524497
p03290
python
s691494308
s895142042
46
22
3,064
3,064
Accepted
Accepted
52.17
d, g = list(map(int, input().split())) dic = {} ans = 9999999 for i in range(1, d+1): dic[i] = list(map(int, input().split())) for i in range(2**d): total = 0 count = 0 select_list = list(range(1, d+1)) for j in range(d): if (i >> j) & 1: num = dic[j+1][0] ...
d, goal = list(map(int, input().split())) problems = [] for i in range(1, d+1): num, bonus = list(map(int, input().split())) point = i * 100 problems.append([point, num, bonus]) ans = [] for mask in range(2**d): score = 0 count = 0 target = 0 for bit in range(d): if...
39
34
922
791
d, g = list(map(int, input().split())) dic = {} ans = 9999999 for i in range(1, d + 1): dic[i] = list(map(int, input().split())) for i in range(2**d): total = 0 count = 0 select_list = list(range(1, d + 1)) for j in range(d): if (i >> j) & 1: num = dic[j + 1][0] total...
d, goal = list(map(int, input().split())) problems = [] for i in range(1, d + 1): num, bonus = list(map(int, input().split())) point = i * 100 problems.append([point, num, bonus]) ans = [] for mask in range(2**d): score = 0 count = 0 target = 0 for bit in range(d): if (mask >> bit) &...
false
12.820513
[ "-d, g = list(map(int, input().split()))", "-dic = {}", "-ans = 9999999", "+d, goal = list(map(int, input().split()))", "+problems = []", "- dic[i] = list(map(int, input().split()))", "-for i in range(2**d):", "- total = 0", "+ num, bonus = list(map(int, input().split()))", "+ point = ...
false
0.042423
0.058724
0.722407
[ "s691494308", "s895142042" ]
u678167152
p03549
python
s858031022
s982650226
62
28
61,532
9,152
Accepted
Accepted
54.84
N, M = list(map(int, input().split())) ans = (100*(N-M)+1900*M)*pow(2,M) print(ans)
def solve(): ans = 0 N, M = list(map(int, input().split())) ans = (100*(N-M)+1900*M)*pow(2,M) return ans print((solve()))
3
6
79
126
N, M = list(map(int, input().split())) ans = (100 * (N - M) + 1900 * M) * pow(2, M) print(ans)
def solve(): ans = 0 N, M = list(map(int, input().split())) ans = (100 * (N - M) + 1900 * M) * pow(2, M) return ans print((solve()))
false
50
[ "-N, M = list(map(int, input().split()))", "-ans = (100 * (N - M) + 1900 * M) * pow(2, M)", "-print(ans)", "+def solve():", "+ ans = 0", "+ N, M = list(map(int, input().split()))", "+ ans = (100 * (N - M) + 1900 * M) * pow(2, M)", "+ return ans", "+", "+", "+print((solve()))" ]
false
0.037829
0.037876
0.998768
[ "s858031022", "s982650226" ]
u427344224
p03164
python
s772036803
s182361258
1,196
490
315,316
95,136
Accepted
Accepted
59.03
N, W = list(map(int, input().split())) items = [list(map(int, input().split())) for _ in range(N)] sum_v = sum([item[1] for item in items]) inf = float("inf") dp = [[inf for _ in range(sum_v+1)] for _ in range(N+1)] dp[0][0] = 0 for i in range(N): for j in range(sum_v+1): if j - items[i][1] >= 0...
N, W = list(map(int, input().split())) items = [list(map(int, input().split())) for _ in range(N)] sum_v = sum([item[1] for item in items]) inf = float("inf") dp = [inf for _ in range(sum_v+1)] dp[0] = 0 for i in range(N): for j in range(sum_v, -1, -1): if j - items[i][1] >= 0: dp[j] ...
19
17
535
452
N, W = list(map(int, input().split())) items = [list(map(int, input().split())) for _ in range(N)] sum_v = sum([item[1] for item in items]) inf = float("inf") dp = [[inf for _ in range(sum_v + 1)] for _ in range(N + 1)] dp[0][0] = 0 for i in range(N): for j in range(sum_v + 1): if j - items[i][1] >= 0: ...
N, W = list(map(int, input().split())) items = [list(map(int, input().split())) for _ in range(N)] sum_v = sum([item[1] for item in items]) inf = float("inf") dp = [inf for _ in range(sum_v + 1)] dp[0] = 0 for i in range(N): for j in range(sum_v, -1, -1): if j - items[i][1] >= 0: dp[j] = min(dp[...
false
10.526316
[ "-dp = [[inf for _ in range(sum_v + 1)] for _ in range(N + 1)]", "-dp[0][0] = 0", "+dp = [inf for _ in range(sum_v + 1)]", "+dp[0] = 0", "- for j in range(sum_v + 1):", "+ for j in range(sum_v, -1, -1):", "- dp[i + 1][j] = min(dp[i][j], dp[i][j - items[i][1]] + items[i][0])", "- ...
false
0.038714
0.075884
0.51017
[ "s772036803", "s182361258" ]
u588341295
p02861
python
s928004868
s969075783
232
18
3,188
3,064
Accepted
Accepted
92.24
# -*- coding: utf-8 -*- import sys from itertools import permutations from math import hypot def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): retur...
# -*- coding: utf-8 -*- import sys from math import hypot def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for ...
41
34
1,129
957
# -*- coding: utf-8 -*- import sys from itertools import permutations from math import hypot def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, ...
# -*- coding: utf-8 -*- import sys from math import hypot def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in ...
false
17.073171
[ "-from itertools import permutations", "-sm = cnt = 0", "-for perm in permutations(XY):", "- dist = 0", "- prev = (0, 0)", "- for i, (x, y) in enumerate(perm):", "- if i == 0:", "- prev = (x, y)", "- else:", "- x2, y2 = prev", "- dist += hy...
false
0.067833
0.008093
8.38137
[ "s928004868", "s969075783" ]
u379959788
p03476
python
s327508367
s714605393
1,715
489
28,628
31,984
Accepted
Accepted
71.49
import bisect def Get_Sieve_of_Eratosthenes(N): prime_list = [2] limit = int(N ** 0.5) numeric_data = [i for i in range(3, N, 2)] while True: prime = numeric_data[0] if prime >= limit: return prime_list + numeric_data prime_list.append(prime) numer...
N = 10**5 prime_list = [True] * (N+1) # True が素数 count_list = [0] * (N+1) for i in range(2, N+1, 1): if prime_list[i]: for j in range(i+i, N+1, i): prime_list[j] = False for i in range(3, N+1, 2): if prime_list[i] and prime_list[(i+1)//2]: count_list[i] += 1 for ...
38
20
997
536
import bisect def Get_Sieve_of_Eratosthenes(N): prime_list = [2] limit = int(N**0.5) numeric_data = [i for i in range(3, N, 2)] while True: prime = numeric_data[0] if prime >= limit: return prime_list + numeric_data prime_list.append(prime) numeric_data = [x...
N = 10**5 prime_list = [True] * (N + 1) # True が素数 count_list = [0] * (N + 1) for i in range(2, N + 1, 1): if prime_list[i]: for j in range(i + i, N + 1, i): prime_list[j] = False for i in range(3, N + 1, 2): if prime_list[i] and prime_list[(i + 1) // 2]: count_list[i] += 1 for i in...
false
47.368421
[ "-import bisect", "-", "-", "-def Get_Sieve_of_Eratosthenes(N):", "- prime_list = [2]", "- limit = int(N**0.5)", "- numeric_data = [i for i in range(3, N, 2)]", "- while True:", "- prime = numeric_data[0]", "- if prime >= limit:", "- return prime_list + numer...
false
2.000118
0.23543
8.495581
[ "s327508367", "s714605393" ]
u747515887
p03775
python
s003935480
s990338567
37
27
3,060
3,060
Accepted
Accepted
27.03
n = int(eval(input())) min_digits = 100 for i in range(int(n ** 0.5) + 1): a = i + 1 if n % a != 0: continue b = n // a x = max([a, b]) digits = len(str(x)) if digits < min_digits: min_digits = digits print(min_digits)
def main(): n = int(eval(input())) m = int(n ** 0.5) if n < 4: m += 1 min_f = len(str(n)) for i in reversed(list(range(1, m + 1))): if n % i == 0: b = n // i db = len(str(b)) di = len(str(i)) f = max(db, di) ...
14
23
268
415
n = int(eval(input())) min_digits = 100 for i in range(int(n**0.5) + 1): a = i + 1 if n % a != 0: continue b = n // a x = max([a, b]) digits = len(str(x)) if digits < min_digits: min_digits = digits print(min_digits)
def main(): n = int(eval(input())) m = int(n**0.5) if n < 4: m += 1 min_f = len(str(n)) for i in reversed(list(range(1, m + 1))): if n % i == 0: b = n // i db = len(str(b)) di = len(str(i)) f = max(db, di) if f < min_f: ...
false
39.130435
[ "-n = int(eval(input()))", "-min_digits = 100", "-for i in range(int(n**0.5) + 1):", "- a = i + 1", "- if n % a != 0:", "- continue", "- b = n // a", "- x = max([a, b])", "- digits = len(str(x))", "- if digits < min_digits:", "- min_digits = digits", "-print(min...
false
0.050772
0.037252
1.362944
[ "s003935480", "s990338567" ]
u618002097
p03281
python
s310778266
s637127212
166
66
38,384
61,484
Accepted
Accepted
60.24
def make_divisors(n): divisors = [] for i in range(1, int(n ** 0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) # divisors.sort() return divisors N = int(eval(input())) count = 0 for i in range(1, N+1): ...
N = int(eval(input())) def make_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i * i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n // i) i += 1 return lower_divisors + upper_divi...
20
19
454
486
def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) # divisors.sort() return divisors N = int(eval(input())) count = 0 for i in range(1, N + 1): # print(len...
N = int(eval(input())) def make_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i * i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n // i) i += 1 return lower_divisors + upper_divisors[::-1]...
false
5
[ "-def make_divisors(n):", "- divisors = []", "- for i in range(1, int(n**0.5) + 1):", "- if n % i == 0:", "- divisors.append(i)", "- if i != n // i:", "- divisors.append(n // i)", "- # divisors.sort()", "- return divisors", "+N = int(eval(inp...
false
0.047264
0.102684
0.460283
[ "s310778266", "s637127212" ]
u681444474
p02861
python
s755955185
s416378493
483
281
7,972
13,988
Accepted
Accepted
41.82
import itertools import math N=int(eval(input())) T=[None]*N for i in range(N): T[i] = list(map(int,input().split())) seq=[i for i in range(N)] kumi=list(itertools.permutations(seq)) L_sum=0 for i in range(len(kumi)): for j in range(N-1): L_sum+=math.sqrt((T[kumi[i][j]-1][0]-T[kumi[i][j+1]-...
# coding: utf-8 import math import itertools N = int(eval(input())) R =[] for i in range(N): x, y = list(map(int,input().split())) R.append([x, y]) #print(R[0][0]) #L = copy.deepcopy(R) l = [i for i in range(N)] p = list(itertools.permutations(l,N)) S = 0 #print(p) for v in p: for i in range...
20
20
559
429
import itertools import math N = int(eval(input())) T = [None] * N for i in range(N): T[i] = list(map(int, input().split())) seq = [i for i in range(N)] kumi = list(itertools.permutations(seq)) L_sum = 0 for i in range(len(kumi)): for j in range(N - 1): L_sum += math.sqrt( (T[kumi[i][j] - 1...
# coding: utf-8 import math import itertools N = int(eval(input())) R = [] for i in range(N): x, y = list(map(int, input().split())) R.append([x, y]) # print(R[0][0]) # L = copy.deepcopy(R) l = [i for i in range(N)] p = list(itertools.permutations(l, N)) S = 0 # print(p) for v in p: for i in range(N - 1): ...
false
0
[ "+# coding: utf-8", "+import math", "-import math", "-T = [None] * N", "+R = []", "- T[i] = list(map(int, input().split()))", "-seq = [i for i in range(N)]", "-kumi = list(itertools.permutations(seq))", "-L_sum = 0", "-for i in range(len(kumi)):", "- for j in range(N - 1):", "- L_...
false
0.041962
0.042166
0.995164
[ "s755955185", "s416378493" ]
u791527495
p03835
python
s424459329
s575478909
1,633
1,496
2,940
3,060
Accepted
Accepted
8.39
K,S = list(map(int,input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - x - y if 0 <= z and z <= K: count += 1 print(count)
K,S = list(map(int,input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - x - y if 0 <= z <= K: count += 1 print(count)
8
8
169
163
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - x - y if 0 <= z and z <= K: count += 1 print(count)
K, S = list(map(int, input().split())) count = 0 for x in range(K + 1): for y in range(K + 1): z = S - x - y if 0 <= z <= K: count += 1 print(count)
false
0
[ "- if 0 <= z and z <= K:", "+ if 0 <= z <= K:" ]
false
0.032375
0.033707
0.960466
[ "s424459329", "s575478909" ]
u879870653
p03495
python
s972221178
s964219001
227
183
38,964
32,184
Accepted
Accepted
19.38
N,K = list(map(int,input().split())) A = list(map(int,input().split())) D = {} for i in A : if i in D : D[i] += 1 else : D[i] = 1 D = sorted(list(D.items()),key=lambda x:x[1]) counter = 0 answer = 0 for j in range(len(D)) : if len(D) - counter > K : counter += 1 ...
N,K = list(map(int,input().split())) A = list(map(int,input().split())) D = {} for i in A : if i in D : D[i] += 1 else : D[i] = 1 L = list(D.values()) L = sorted(L) ans = 0 counter = 0 for i in range(len(L)) : if len(L) - counter > K : ans += L[i] counter += 1 ...
18
19
377
361
N, K = list(map(int, input().split())) A = list(map(int, input().split())) D = {} for i in A: if i in D: D[i] += 1 else: D[i] = 1 D = sorted(list(D.items()), key=lambda x: x[1]) counter = 0 answer = 0 for j in range(len(D)): if len(D) - counter > K: counter += 1 answer += D[j...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) D = {} for i in A: if i in D: D[i] += 1 else: D[i] = 1 L = list(D.values()) L = sorted(L) ans = 0 counter = 0 for i in range(len(L)): if len(L) - counter > K: ans += L[i] counter += 1 else: ...
false
5.263158
[ "-D = sorted(list(D.items()), key=lambda x: x[1])", "+L = list(D.values())", "+L = sorted(L)", "+ans = 0", "-answer = 0", "-for j in range(len(D)):", "- if len(D) - counter > K:", "+for i in range(len(L)):", "+ if len(L) - counter > K:", "+ ans += L[i]", "- answer += D[j][1]"...
false
0.046925
0.045744
1.02583
[ "s972221178", "s964219001" ]
u506858457
p02684
python
s641975590
s883526957
153
132
32,368
32,368
Accepted
Accepted
13.73
n, k = list(map(int, input().split())) a = list(map(int, input().split())) num = 1 li = [1] flag = [True] * n flag[0] = False for i in range(k): num = a[num-1] if flag[num-1]: li.append(num) flag[num-1] = False else: break d = li.index(num) ans = (k-d)%(len(li)-d)...
n, k = list(map(int, input().split())) a = [0]+list(map(int, input().split())) num = 1 li = [1] flag = [True] * n flag[0] = False for i in range(k): num = a[num] if flag[num-1]: li.append(num) flag[num-1] = False else: break d = li.index(num) ans = (k-d)%(len(li)-...
20
20
334
336
n, k = list(map(int, input().split())) a = list(map(int, input().split())) num = 1 li = [1] flag = [True] * n flag[0] = False for i in range(k): num = a[num - 1] if flag[num - 1]: li.append(num) flag[num - 1] = False else: break d = li.index(num) ans = (k - d) % (len(li) - d) + d pri...
n, k = list(map(int, input().split())) a = [0] + list(map(int, input().split())) num = 1 li = [1] flag = [True] * n flag[0] = False for i in range(k): num = a[num] if flag[num - 1]: li.append(num) flag[num - 1] = False else: break d = li.index(num) ans = (k - d) % (len(li) - d) + d p...
false
0
[ "-a = list(map(int, input().split()))", "+a = [0] + list(map(int, input().split()))", "- num = a[num - 1]", "+ num = a[num]" ]
false
0.092179
0.073345
1.256791
[ "s641975590", "s883526957" ]
u327466606
p03682
python
s884891360
s996327205
1,468
1,138
81,828
86,156
Accepted
Accepted
22.48
class DisjointSet: def __init__(self, size): self.parent = list(range(size)) self.rank = [0]*size def find(self, x): if self.parent[x] == x: return x else: self.parent[x] = self.find(self.parent[x]) return self.parent[x] d...
class DisjointSet: def __init__(self, size): self.parent = list(range(size)) self.rank = [0]*size def find(self, x): stack = [] parent = self.parent while parent[x] != x: stack.append(x) x = parent[x] for y in stack: ...
61
65
1,518
1,588
class DisjointSet: def __init__(self, size): self.parent = list(range(size)) self.rank = [0] * size def find(self, x): if self.parent[x] == x: return x else: self.parent[x] = self.find(self.parent[x]) return self.parent[x] def union(self,...
class DisjointSet: def __init__(self, size): self.parent = list(range(size)) self.rank = [0] * size def find(self, x): stack = [] parent = self.parent while parent[x] != x: stack.append(x) x = parent[x] for y in stack: parent[y...
false
6.153846
[ "- if self.parent[x] == x:", "- return x", "- else:", "- self.parent[x] = self.find(self.parent[x])", "- return self.parent[x]", "+ stack = []", "+ parent = self.parent", "+ while parent[x] != x:", "+ stack.append(x)", ...
false
0.045842
0.046099
0.994435
[ "s884891360", "s996327205" ]
u843175622
p04021
python
s197337632
s328970346
278
150
17,120
23,528
Accepted
Accepted
46.04
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] b = sorted(a) c = dict() for i in range(n): c[b[i]] = i&1 d = 0 for i in range(n): d += c[a[i]]^i&1 print((d>>1))
n, *a = list(map(int, open(0).read().split())) b = [] for i in range(n): b.append((a[i], i)) b.sort() ans = 0 for i in range(n): if b[i][1] % 2 != i % 2: ans += 1 print((ans // 2))
13
12
188
202
n = int(eval(input())) a = [int(eval(input())) for _ in range(n)] b = sorted(a) c = dict() for i in range(n): c[b[i]] = i & 1 d = 0 for i in range(n): d += c[a[i]] ^ i & 1 print((d >> 1))
n, *a = list(map(int, open(0).read().split())) b = [] for i in range(n): b.append((a[i], i)) b.sort() ans = 0 for i in range(n): if b[i][1] % 2 != i % 2: ans += 1 print((ans // 2))
false
7.692308
[ "-n = int(eval(input()))", "-a = [int(eval(input())) for _ in range(n)]", "-b = sorted(a)", "-c = dict()", "+n, *a = list(map(int, open(0).read().split()))", "+b = []", "- c[b[i]] = i & 1", "-d = 0", "+ b.append((a[i], i))", "+b.sort()", "+ans = 0", "- d += c[a[i]] ^ i & 1", "-print...
false
0.055814
0.053146
1.050202
[ "s197337632", "s328970346" ]
u565711859
p03126
python
s232040870
s932707772
25
18
3,684
2,940
Accepted
Accepted
28
from functools import reduce n, m = list(map(int, input().split())) k = [list(map(int, input().split()))[1:] for _ in range(n)] print((len(reduce(lambda a,b: a&b, [set(kk) for kk in k]))))
n, m = list(map(int, input().split())) s = [0] * m for i in range(n): a = list(map(int, input().split()))[1:] for x in a: s[x-1] += 1 ans = 0 for x in s: if x == n: ans += 1 print(ans)
6
14
188
223
from functools import reduce n, m = list(map(int, input().split())) k = [list(map(int, input().split()))[1:] for _ in range(n)] print((len(reduce(lambda a, b: a & b, [set(kk) for kk in k]))))
n, m = list(map(int, input().split())) s = [0] * m for i in range(n): a = list(map(int, input().split()))[1:] for x in a: s[x - 1] += 1 ans = 0 for x in s: if x == n: ans += 1 print(ans)
false
57.142857
[ "-from functools import reduce", "-", "-k = [list(map(int, input().split()))[1:] for _ in range(n)]", "-print((len(reduce(lambda a, b: a & b, [set(kk) for kk in k]))))", "+s = [0] * m", "+for i in range(n):", "+ a = list(map(int, input().split()))[1:]", "+ for x in a:", "+ s[x - 1] += 1...
false
0.043045
0.04261
1.010196
[ "s232040870", "s932707772" ]
u707498674
p03855
python
s693474260
s066279173
1,576
1,333
125,572
66,400
Accepted
Accepted
15.42
from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def root(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.root(self.parents[x]) return sel...
from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def root(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.root(self.parents[x]) return sel...
71
74
1,902
1,900
from collections import defaultdict class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def root(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.root(self.parents[x]) return self.parents[x] ...
from collections import defaultdict class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def root(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.root(self.parents[x]) return self.parents[x] ...
false
4.054054
[ "- for p, q in pq:", "- uf_road.unite(p - 1, q - 1)", "+ [uf_road.unite(p - 1, q - 1) for p, q in pq]", "- for r, s in rs:", "- uf_railway.unite(r - 1, s - 1)", "+ [uf_railway.unite(r - 1, s - 1) for r, s in rs]" ]
false
0.050587
0.052048
0.97193
[ "s693474260", "s066279173" ]
u729133443
p02701
python
s514225935
s708534094
112
65
84,104
31,008
Accepted
Accepted
41.96
print((len(set(open(0)))-1))
print((len({*open(0)})-1))
1
1
26
24
print((len(set(open(0))) - 1))
print((len({*open(0)}) - 1))
false
0
[ "-print((len(set(open(0))) - 1))", "+print((len({*open(0)}) - 1))" ]
false
0.037687
0.052765
0.714241
[ "s514225935", "s708534094" ]
u440566786
p02695
python
s208104054
s495687909
255
143
73,568
67,828
Accepted
Accepted
43.92
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # 998244353 input=lambda:sys.stdin.readline().rstrip() def resolve(): n, m, q = list(map(int,input().split())) ABCD = [None] * q for i in range(q): a, b, c, d = list(map(int,input().split())) ABCD[i] = (a, b,...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda:sys.stdin.readline().rstrip() from itertools import combinations_with_replacement def resolve(): n, m, q = list(map(int, input().split())) ABCD = [tuple(map(int, input().split())) for _ in range(q)] ...
29
18
753
561
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 # 998244353 input = lambda: sys.stdin.readline().rstrip() def resolve(): n, m, q = list(map(int, input().split())) ABCD = [None] * q for i in range(q): a, b, c, d = list(map(int, input().split())) ABCD[i] = (...
import sys INF = 1 << 60 MOD = 10**9 + 7 # 998244353 sys.setrecursionlimit(2147483647) input = lambda: sys.stdin.readline().rstrip() from itertools import combinations_with_replacement def resolve(): n, m, q = list(map(int, input().split())) ABCD = [tuple(map(int, input().split())) for _ in range(q)] an...
false
37.931034
[ "+INF = 1 << 60", "+MOD = 10**9 + 7 # 998244353", "-INF = float(\"inf\")", "-MOD = 10**9 + 7 # 998244353", "+from itertools import combinations_with_replacement", "- ABCD = [None] * q", "- for i in range(q):", "- a, b, c, d = list(map(int, input().split()))", "- ABCD[i] = (a, b...
false
0.053281
0.046518
1.145378
[ "s208104054", "s495687909" ]
u707124227
p02573
python
s885348915
s006920789
491
434
110,344
110,924
Accepted
Accepted
11.61
import sys sys.setrecursionlimit(10**7) N,Q = list(map(int,input().split())) class UF(): def __init__(self,par,rank): self.par = par self.rank = rank def find(self,x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) #経路圧縮 retur...
import sys sys.setrecursionlimit(10**7) N,Q = list(map(int,input().split())) class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return se...
40
55
948
1,385
import sys sys.setrecursionlimit(10**7) N, Q = list(map(int, input().split())) class UF: def __init__(self, par, rank): self.par = par self.rank = rank def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) # 経路圧縮 ...
import sys sys.setrecursionlimit(10**7) N, Q = list(map(int, input().split())) class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents...
false
27.272727
[ "-class UF:", "- def __init__(self, par, rank):", "- self.par = par", "- self.rank = rank", "+class UnionFind:", "+ def __init__(self, n):", "+ self.n = n", "+ self.parents = [-1] * n", "- if self.par[x] == x:", "+ if self.parents[x] < 0:", "- ...
false
0.045541
0.037029
1.22987
[ "s885348915", "s006920789" ]
u525065967
p03309
python
s824815109
s925729301
246
178
25,196
26,708
Accepted
Accepted
27.64
n = int(eval(input())) B = list(a-i for i,a in zip(list(range(1,n+1)), list(map(int,input().split())))) B.sort() l = r = B[n//2] # median left, right if n%2 == 0: l -= 1 # left fix ans_l, ans_r = 0, 0 for bi in B: ans_l += abs(bi-l) ans_r += abs(bi-r) print((min([ans_l, ans_r])))
n = int(eval(input())) B = list(a-i-1 for i,a in zip(list(range(n)), list(map(int,input().split())))) B.sort() ans = sum(B[n//2 + (n%2) :]) - sum(B[: n//2]) # sum(median left) - sum(median right) print(ans)
10
5
278
193
n = int(eval(input())) B = list(a - i for i, a in zip(list(range(1, n + 1)), list(map(int, input().split())))) B.sort() l = r = B[n // 2] # median left, right if n % 2 == 0: l -= 1 # left fix ans_l, ans_r = 0, 0 for bi in B: ans_l += abs(bi - l) ans_r += abs(bi - r) print((min([ans_l, ans_r])))
n = int(eval(input())) B = list(a - i - 1 for i, a in zip(list(range(n)), list(map(int, input().split())))) B.sort() ans = sum(B[n // 2 + (n % 2) :]) - sum( B[: n // 2] ) # sum(median left) - sum(median right) print(ans)
false
50
[ "-B = list(a - i for i, a in zip(list(range(1, n + 1)), list(map(int, input().split()))))", "+B = list(a - i - 1 for i, a in zip(list(range(n)), list(map(int, input().split()))))", "-l = r = B[n // 2] # median left, right", "-if n % 2 == 0:", "- l -= 1 # left fix", "-ans_l, ans_r = 0, 0", "-for bi ...
false
0.097943
0.034702
2.82239
[ "s824815109", "s925729301" ]
u020390084
p03031
python
s942340668
s780992521
40
26
3,188
3,064
Accepted
Accepted
35
n, m = list(map(int, input().split())) k = [list(map(int, input().split()))[1:] for _ in range(m)] p = list(map(int, input().split())) answer = 0 ## k = sorted(k, reverse=True, key=lambda x: len(x)) all = [] # 全てのスイッチの状態 for i in range(0, 2**n): all.append(list(str(format(i, 'b').zfill(n)))) for a in all:...
#!/usr/bin/env python3 def main(): N,M = list(map(int,input().split())) K = [] s = [] answer = 0 for _ in range(M): ks = list(map(int,input().split())) K.append(ks[0]) s.append(ks[1:]) p = list(map(int,input().split())) for switch in range(0,2**N): ...
24
33
604
677
n, m = list(map(int, input().split())) k = [list(map(int, input().split()))[1:] for _ in range(m)] p = list(map(int, input().split())) answer = 0 ## k = sorted(k, reverse=True, key=lambda x: len(x)) all = [] # 全てのスイッチの状態 for i in range(0, 2**n): all.append(list(str(format(i, "b").zfill(n)))) for a in all: for ...
#!/usr/bin/env python3 def main(): N, M = list(map(int, input().split())) K = [] s = [] answer = 0 for _ in range(M): ks = list(map(int, input().split())) K.append(ks[0]) s.append(ks[1:]) p = list(map(int, input().split())) for switch in range(0, 2**N): for j ...
false
27.272727
[ "-n, m = list(map(int, input().split()))", "-k = [list(map(int, input().split()))[1:] for _ in range(m)]", "-p = list(map(int, input().split()))", "-answer = 0", "-## k = sorted(k, reverse=True, key=lambda x: len(x))", "-all = [] # 全てのスイッチの状態", "-for i in range(0, 2**n):", "- all.append(list(str(f...
false
0.056499
0.036342
1.554632
[ "s942340668", "s780992521" ]
u562935282
p02659
python
s608061261
s614253463
25
22
9,096
9,136
Accepted
Accepted
12
def main(): A, B = input().split() A = int(A) B_spl = B.split('.') L = len(B_spl[1]) # 小数部分の桁数, int化前に桁を調べる必要がある(末尾に0が続くケース) B_int, B_frac = list(map(int, B_spl)) # 整数部分, 小数部分 ans = (A * B_int) + (A * B_frac) // pow(10, L) print(ans) if __name__ == '__main__': main...
def main(): A, B = input().split() A = int(A) B = float(B) B100 = int(B * 100 + 0.001) print((A * B100 // 100)) if __name__ == '__main__': main()
16
13
317
185
def main(): A, B = input().split() A = int(A) B_spl = B.split(".") L = len(B_spl[1]) # 小数部分の桁数, int化前に桁を調べる必要がある(末尾に0が続くケース) B_int, B_frac = list(map(int, B_spl)) # 整数部分, 小数部分 ans = (A * B_int) + (A * B_frac) // pow(10, L) print(ans) if __name__ == "__main__": main()
def main(): A, B = input().split() A = int(A) B = float(B) B100 = int(B * 100 + 0.001) print((A * B100 // 100)) if __name__ == "__main__": main()
false
18.75
[ "- B_spl = B.split(\".\")", "- L = len(B_spl[1]) # 小数部分の桁数, int化前に桁を調べる必要がある(末尾に0が続くケース)", "- B_int, B_frac = list(map(int, B_spl)) # 整数部分, 小数部分", "- ans = (A * B_int) + (A * B_frac) // pow(10, L)", "- print(ans)", "+ B = float(B)", "+ B100 = int(B * 100 + 0.001)", "+ print((...
false
0.035827
0.046713
0.766968
[ "s608061261", "s614253463" ]
u547167033
p03503
python
s608323585
s645267200
364
300
3,064
3,064
Accepted
Accepted
17.58
n=int(eval(input())) f=[list(map(int,input().split())) for i in range(n)] p=[list(map(int,input().split())) for i in range(n)] ans=-10**18 for i in range(1,2**10): d=0 for j in range(n): cnt=0 for k in range(10): if i>>k&1==f[j][k]==1: cnt+=1 d+=p[j][cnt] ans=max(ans,d) prin...
n=int(eval(input())) f=[list(map(int,input().split())) for i in range(n)] p=[list(map(int,input().split())) for i in range(n)] ans=-10**18 for i in range(1,2**10): op=[0]*10 res=0 for j in range(10): if i>>j&1: op[j]=1 for j in range(n): cnt=0 for k in range(10): if op[k]&f[...
14
18
320
389
n = int(eval(input())) f = [list(map(int, input().split())) for i in range(n)] p = [list(map(int, input().split())) for i in range(n)] ans = -(10**18) for i in range(1, 2**10): d = 0 for j in range(n): cnt = 0 for k in range(10): if i >> k & 1 == f[j][k] == 1: cnt += ...
n = int(eval(input())) f = [list(map(int, input().split())) for i in range(n)] p = [list(map(int, input().split())) for i in range(n)] ans = -(10**18) for i in range(1, 2**10): op = [0] * 10 res = 0 for j in range(10): if i >> j & 1: op[j] = 1 for j in range(n): cnt = 0 ...
false
22.222222
[ "- d = 0", "+ op = [0] * 10", "+ res = 0", "+ for j in range(10):", "+ if i >> j & 1:", "+ op[j] = 1", "- if i >> k & 1 == f[j][k] == 1:", "+ if op[k] & f[j][k]:", "- d += p[j][cnt]", "- ans = max(ans, d)", "+ res += p[j][cnt]"...
false
0.043727
0.054689
0.799551
[ "s608323585", "s645267200" ]
u102461423
p03181
python
s048258935
s457430786
1,811
993
228,140
41,420
Accepted
Accepted
45.17
import itertools import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) N,MOD = list(map(int,input().split())) if N == 1: print((1)) exit() graph = [set() for _ in range(N)] for row in sys.stdin.readlines(): x,y = list(map(int,row.split())) graph[x-1].add(y-1) graph[y-1]....
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools N,MOD = list(map(int,readline().split())) m = list(map(int,read().split())) XY = list(zip(m,m)) mult = lambda x,y: x*y%MOD graph = [[] for _ in range(N+1)] for x,y in XY...
41
57
980
1,254
import itertools import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) N, MOD = list(map(int, input().split())) if N == 1: print((1)) exit() graph = [set() for _ in range(N)] for row in sys.stdin.readlines(): x, y = list(map(int, row.split())) graph[x - 1].add(y - 1) graph[y - 1].add(x...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools N, MOD = list(map(int, readline().split())) m = list(map(int, read().split())) XY = list(zip(m, m)) mult = lambda x, y: x * y % MOD graph = [[] for _ in range(N + 1)] for x, y in XY: ...
false
28.070175
[ "-import itertools", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-N, MOD = list(map(int, input().split()))", "-if N == 1:", "- print((1))", "- exit()", "-graph = [set() for _ in range(N)]", "-for row in sys.stdin.readlines():", "- x, y = list(map(int, row.split()))", ...
false
0.035474
0.037387
0.948837
[ "s048258935", "s457430786" ]
u645250356
p02660
python
s903938300
s885486513
382
108
77,344
10,448
Accepted
Accepted
71.73
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,copy sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) ...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush from bisect import bisect_left,bisect_right import sys,math,itertools,fractions sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.std...
42
41
919
934
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, copy sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readli...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush from bisect import bisect_left, bisect_right import sys, math, itertools, fractions sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map...
false
2.380952
[ "-from heapq import heappop, heappush, heapify", "-import sys, bisect, math, itertools, fractions, copy", "+from heapq import heappop, heappush", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools, fractions", "-if n == 1:", "- print((0))", "- quit()", "-for key in ...
false
0.133611
0.041428
3.22515
[ "s903938300", "s885486513" ]
u163320134
p03457
python
s931004764
s330474825
381
289
3,064
27,800
Accepted
Accepted
24.15
n=int(eval(input())) flag=True ts=0 xs=0 ys=0 for i in range(n): te,xe,ye=list(map(int,input().split())) if (te-ts)%2 == ((xe+ye)-(xs+ys))%2 and ((xe+ye)-(xs+ys))<=(te-ts): flag = True else: flag = False break; ts,xs,ys=te,xe,ye if flag: print('Yes') else: print('No')
n=int(eval(input())) arr=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)] for i in range(n): t1,x1,y1=arr[i] t2,x2,y2=arr[i+1] if abs(x1-x2)+abs(y1-y2)>t2-t1: print('No') exit() if (abs(x1-x2)+abs(y1-y2))%2!=(t2-t1)%2: print('No') exit() print('Yes')
17
12
296
291
n = int(eval(input())) flag = True ts = 0 xs = 0 ys = 0 for i in range(n): te, xe, ye = list(map(int, input().split())) if (te - ts) % 2 == ((xe + ye) - (xs + ys)) % 2 and ((xe + ye) - (xs + ys)) <= ( te - ts ): flag = True else: flag = False break ts, xs, ys = te, xe...
n = int(eval(input())) arr = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)] for i in range(n): t1, x1, y1 = arr[i] t2, x2, y2 = arr[i + 1] if abs(x1 - x2) + abs(y1 - y2) > t2 - t1: print("No") exit() if (abs(x1 - x2) + abs(y1 - y2)) % 2 != (t2 - t1) % 2: print(...
false
29.411765
[ "-flag = True", "-ts = 0", "-xs = 0", "-ys = 0", "+arr = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]", "- te, xe, ye = list(map(int, input().split()))", "- if (te - ts) % 2 == ((xe + ye) - (xs + ys)) % 2 and ((xe + ye) - (xs + ys)) <= (", "- te - ts", "- ):", ...
false
0.035539
0.041954
0.84709
[ "s931004764", "s330474825" ]
u214404619
p02394
python
s317758815
s184576096
30
20
7,708
5,600
Accepted
Accepted
33.33
[w, h, x, y, r] = [int(number) for number in input().split()]; if (r <= x) & (x + r <= w) & (r <= y) & (r + y <= h): print('Yes'); else: print('No');
x = input().split() W, H, x, y, r = int(x[0]), int(x[1]), int(x[2]), int(x[3]), int(x[4]) if r <= x and r <= y and x + r <= W and y + r <= H: print('Yes') else: print('No')
5
7
155
188
[w, h, x, y, r] = [int(number) for number in input().split()] if (r <= x) & (x + r <= w) & (r <= y) & (r + y <= h): print("Yes") else: print("No")
x = input().split() W, H, x, y, r = int(x[0]), int(x[1]), int(x[2]), int(x[3]), int(x[4]) if r <= x and r <= y and x + r <= W and y + r <= H: print("Yes") else: print("No")
false
28.571429
[ "-[w, h, x, y, r] = [int(number) for number in input().split()]", "-if (r <= x) & (x + r <= w) & (r <= y) & (r + y <= h):", "+x = input().split()", "+W, H, x, y, r = int(x[0]), int(x[1]), int(x[2]), int(x[3]), int(x[4])", "+if r <= x and r <= y and x + r <= W and y + r <= H:" ]
false
0.039902
0.044099
0.904834
[ "s317758815", "s184576096" ]
u258647915
p03762
python
s989176448
s512245691
153
113
18,624
18,624
Accepted
Accepted
26.14
def read(): return list(map(int, input().split())) MOD = 10 ** 9 + 7 n, m = read() x = read() y = read() xs, ys = 0, 0 for i in range(n): xs += x[i] * (2 * i + 1 - n) xs %= MOD for i in range(m): ys += y[i] * (2 * i + 1 - m) ys %= MOD print(((xs * ys) % MOD))
def read(): return list(map(int, input().split())) n, m = read() x = read() y = read() xs, ys = 0, 0 xs = sum([x[i] * (2 * i + 1 - n) for i in range(n)]) ys = sum([y[i] * (2 * i + 1 - m) for i in range(m)]) print(((xs * ys) % 1000000007))
18
11
295
249
def read(): return list(map(int, input().split())) MOD = 10**9 + 7 n, m = read() x = read() y = read() xs, ys = 0, 0 for i in range(n): xs += x[i] * (2 * i + 1 - n) xs %= MOD for i in range(m): ys += y[i] * (2 * i + 1 - m) ys %= MOD print(((xs * ys) % MOD))
def read(): return list(map(int, input().split())) n, m = read() x = read() y = read() xs, ys = 0, 0 xs = sum([x[i] * (2 * i + 1 - n) for i in range(n)]) ys = sum([y[i] * (2 * i + 1 - m) for i in range(m)]) print(((xs * ys) % 1000000007))
false
38.888889
[ "-MOD = 10**9 + 7", "-for i in range(n):", "- xs += x[i] * (2 * i + 1 - n)", "- xs %= MOD", "-for i in range(m):", "- ys += y[i] * (2 * i + 1 - m)", "- ys %= MOD", "-print(((xs * ys) % MOD))", "+xs = sum([x[i] * (2 * i + 1 - n) for i in range(n)])", "+ys = sum([y[i] * (2 * i + 1 - m) f...
false
0.065711
0.065367
1.005277
[ "s989176448", "s512245691" ]
u576917603
p03163
python
s392945825
s347243079
1,062
665
300,728
171,656
Accepted
Accepted
37.38
def knapsack(N,W,weight,value): #初期化 inf=float("inf") dp=[[-inf for i in range(W+1)] for j in range(N+1)] for i in range(W+1): dp[0][i]=0 #DP for i in range(N): for w in range(W+1): if weight[i]<=w: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある dp[i...
n,w=list(map(int,input().split())) weight=[] value=[] for i in range(n): x,v=list(map(int,input().split())) weight.append(x) value.append(v) dp=[[0 for i in range(w+1)]for i in range(n+1)] for i in range(n): for j in range(w+1): if j+weight[i]<=w : dp[i+1...
22
19
621
442
def knapsack(N, W, weight, value): # 初期化 inf = float("inf") dp = [[-inf for i in range(W + 1)] for j in range(N + 1)] for i in range(W + 1): dp[0][i] = 0 # DP for i in range(N): for w in range(W + 1): if weight[i] <= w: # dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある ...
n, w = list(map(int, input().split())) weight = [] value = [] for i in range(n): x, v = list(map(int, input().split())) weight.append(x) value.append(v) dp = [[0 for i in range(w + 1)] for i in range(n + 1)] for i in range(n): for j in range(w + 1): if j + weight[i] <= w: dp[i + 1][j...
false
13.636364
[ "-def knapsack(N, W, weight, value):", "- # 初期化", "- inf = float(\"inf\")", "- dp = [[-inf for i in range(W + 1)] for j in range(N + 1)]", "- for i in range(W + 1):", "- dp[0][i] = 0", "- # DP", "- for i in range(N):", "- for w in range(W + 1):", "- if we...
false
0.040528
0.045732
0.886216
[ "s392945825", "s347243079" ]
u729133443
p03147
python
s450142595
s076856338
192
18
38,640
2,940
Accepted
Accepted
90.62
def solve(h): if len(h)<2: return h[0] s=[i for i in range(len(h))if h[i]<1] s=[-1]+s+[len(h)] a=0 for l in[h[i+1:j]for i,j in zip(s,s[1:])]: if not l:continue v=min(l) l=[t-v for t in l] a+=v+solve(l) return a eval(input()) print((solve(list(...
_,h=open(0);s=p=0 for x in map(int,h.split()):s+=max(x-p,0);p=x print(s)
14
3
340
74
def solve(h): if len(h) < 2: return h[0] s = [i for i in range(len(h)) if h[i] < 1] s = [-1] + s + [len(h)] a = 0 for l in [h[i + 1 : j] for i, j in zip(s, s[1:])]: if not l: continue v = min(l) l = [t - v for t in l] a += v + solve(l) return a...
_, h = open(0) s = p = 0 for x in map(int, h.split()): s += max(x - p, 0) p = x print(s)
false
78.571429
[ "-def solve(h):", "- if len(h) < 2:", "- return h[0]", "- s = [i for i in range(len(h)) if h[i] < 1]", "- s = [-1] + s + [len(h)]", "- a = 0", "- for l in [h[i + 1 : j] for i, j in zip(s, s[1:])]:", "- if not l:", "- continue", "- v = min(l)", "- ...
false
0.047426
0.082176
0.577132
[ "s450142595", "s076856338" ]
u337626942
p02621
python
s556456511
s472742844
64
27
61,612
9,060
Accepted
Accepted
57.81
a=int(eval(input())) print((a + a**2 + a**3))
a=int(eval(input())) print((a + a*a + a*a*a))
2
2
38
38
a = int(eval(input())) print((a + a**2 + a**3))
a = int(eval(input())) print((a + a * a + a * a * a))
false
0
[ "-print((a + a**2 + a**3))", "+print((a + a * a + a * a * a))" ]
false
0.035794
0.035586
1.005839
[ "s556456511", "s472742844" ]
u729133443
p02763
python
s363388223
s736618005
658
530
43,576
46,876
Accepted
Accepted
19.45
n=int(eval(input()))+1 d=[0]*n*2 def update(i,x): i+=n d[i]=x while i//2: i//=2 d[i]=d[i+i]|d[i-~i] def query(l,r): l+=n r+=n s=0 while l<r: if l&1: s|=d[l] l+=1 if r&1: r-=1 s|=d[r] l//=2 r//=2 return bin(s).count('1') for i,c in enu...
n,s,_,*t=open(0).read().split() n=int(n) d=[0]*n+[1<<ord(c)-97for c in s] for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i] for q,a,b in zip(*[iter(t)]*3): i,s=int(a)+n-1,0 if'2'>q: d[i]=1<<ord(b)-97 while i>1: i//=2 d[i]=d[i+i]|d[i-~i] continue j=int(b)+n while i<j: if i&1:...
28
23
531
437
n = int(eval(input())) + 1 d = [0] * n * 2 def update(i, x): i += n d[i] = x while i // 2: i //= 2 d[i] = d[i + i] | d[i - ~i] def query(l, r): l += n r += n s = 0 while l < r: if l & 1: s |= d[l] l += 1 if r & 1: r -= 1...
n, s, _, *t = open(0).read().split() n = int(n) d = [0] * n + [1 << ord(c) - 97 for c in s] for i in range(n - 1, 0, -1): d[i] = d[i + i] | d[i - ~i] for q, a, b in zip(*[iter(t)] * 3): i, s = int(a) + n - 1, 0 if "2" > q: d[i] = 1 << ord(b) - 97 while i > 1: i //= 2 ...
false
17.857143
[ "-n = int(eval(input())) + 1", "-d = [0] * n * 2", "-", "-", "-def update(i, x):", "- i += n", "- d[i] = x", "- while i // 2:", "- i //= 2", "- d[i] = d[i + i] | d[i - ~i]", "-", "-", "-def query(l, r):", "- l += n", "- r += n", "- s = 0", "- while ...
false
0.038505
0.044343
0.868342
[ "s363388223", "s736618005" ]
u747602774
p03311
python
s384562388
s069667759
259
216
26,020
26,020
Accepted
Accepted
16.6
N = int(eval(input())) A = list(map(int,input().split())) B = [A[i]-i-1 for i in range(N)] B.sort() ave1,ave2 = B[N//2],B[N//2-1] ans1,ans2 = 0,0 for i in range(N): ans1 += abs(B[i]-ave1) ans2 += abs(B[i]-ave2) print(ans1)
N = int(eval(input())) A = list(map(int,input().split())) B = [A[i]-i-1 for i in range(N)] B.sort() ave = B[N//2] ans = 0 for i in range(N): ans += abs(B[i]-ave) print(ans)
11
10
235
180
N = int(eval(input())) A = list(map(int, input().split())) B = [A[i] - i - 1 for i in range(N)] B.sort() ave1, ave2 = B[N // 2], B[N // 2 - 1] ans1, ans2 = 0, 0 for i in range(N): ans1 += abs(B[i] - ave1) ans2 += abs(B[i] - ave2) print(ans1)
N = int(eval(input())) A = list(map(int, input().split())) B = [A[i] - i - 1 for i in range(N)] B.sort() ave = B[N // 2] ans = 0 for i in range(N): ans += abs(B[i] - ave) print(ans)
false
9.090909
[ "-ave1, ave2 = B[N // 2], B[N // 2 - 1]", "-ans1, ans2 = 0, 0", "+ave = B[N // 2]", "+ans = 0", "- ans1 += abs(B[i] - ave1)", "- ans2 += abs(B[i] - ave2)", "-print(ans1)", "+ ans += abs(B[i] - ave)", "+print(ans)" ]
false
0.038557
0.039319
0.980624
[ "s384562388", "s069667759" ]
u328755070
p02859
python
s050475785
s165491925
19
17
2,940
2,940
Accepted
Accepted
10.53
print(((int(eval(input())))**2))
print((int(eval(input()))**2))
1
1
24
22
print(((int(eval(input()))) ** 2))
print((int(eval(input())) ** 2))
false
0
[ "-print(((int(eval(input()))) ** 2))", "+print((int(eval(input())) ** 2))" ]
false
0.076316
0.04669
1.634523
[ "s050475785", "s165491925" ]
u989345508
p03713
python
s690956393
s217550697
541
421
18,924
18,968
Accepted
Accepted
22.18
h,w=list(map(int,input().split())) if h%3==0 or w%3==0: print((0)) else: x=[] for i in range(1,w): sub=[] sub.append([h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)]) #sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)]) sub.append([h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)]) ...
h,w=list(map(int,input().split())) x=[] for i in range(1,w): x1=[h*i,h*((w-i)//2),h*(w-i)-h*((w-i)//2)] x1.sort() x.append(x1[-1]-x1[0]) x2=[h*i,(w-i)*(h//2),h*(w-i)-(w-i)*(h//2)] x2.sort() x.append(x2[-1]-x2[0]) for i in range(1,h): x1=[w*i,w*((h-i)//2),w*(h-i)-w*((h-i)//2)] ...
22
17
813
458
h, w = list(map(int, input().split())) if h % 3 == 0 or w % 3 == 0: print((0)) else: x = [] for i in range(1, w): sub = [] sub.append([h * i, h * ((w - i) // 2), h * (w - i) - h * ((w - i) // 2)]) # sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)]) sub.append([h * i, (w...
h, w = list(map(int, input().split())) x = [] for i in range(1, w): x1 = [h * i, h * ((w - i) // 2), h * (w - i) - h * ((w - i) // 2)] x1.sort() x.append(x1[-1] - x1[0]) x2 = [h * i, (w - i) * (h // 2), h * (w - i) - (w - i) * (h // 2)] x2.sort() x.append(x2[-1] - x2[0]) for i in range(1, h): ...
false
22.727273
[ "-if h % 3 == 0 or w % 3 == 0:", "- print((0))", "-else:", "- x = []", "- for i in range(1, w):", "- sub = []", "- sub.append([h * i, h * ((w - i) // 2), h * (w - i) - h * ((w - i) // 2)])", "- # sub.append([h*i,h*((w-i)//2+1),h*(w-i)-h*((w-i)//2+1)])", "- sub.ap...
false
0.524644
0.23282
2.253429
[ "s690956393", "s217550697" ]
u334712262
p03576
python
s088062836
s259409931
1,476
135
63,464
78,608
Accepted
Accepted
90.85
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, produc...
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutati...
95
108
1,899
2,276
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permut...
# -*- coding: utf-8 -*- import bisect import heapq import math import random from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from...
false
12.037037
[ "-import sys", "-from operator import add, mul", "+from operator import add, mul, sub, itemgetter, attrgetter", "+import sys", "-sys.setrecursionlimit(10000)", "+# sys.setrecursionlimit(10**6)", "+# buff_readline = sys.stdin.buffer.readline", "+buff_readline = sys.stdin.readline", "+readline = sys.s...
false
0.085391
0.044991
1.897973
[ "s088062836", "s259409931" ]