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
u879870653
p03212
python
s783088217
s360955782
81
54
3,060
3,316
Accepted
Accepted
33.33
from itertools import product N = int(eval(input())) E = [3,5,7] ans = 0 for i in range(3, len(str(N))+1) : L = product(E, repeat=i) for l in L : if (3 not in l) or (5 not in l) or (7 not in l) : continue number = int("".join(list(map(str,l)))) if number <= N : ...
from itertools import * N = int(eval(input())) A = ["3", "5", "7"] ans = 0 length = len(str(N)) for i in range(3, length+1) : for prod in product(A, repeat=i) : if prod.count("3") == 0 or prod.count("5") == 0 or prod.count("7") == 0 : continue num = int("".jo...
14
22
346
415
from itertools import product N = int(eval(input())) E = [3, 5, 7] ans = 0 for i in range(3, len(str(N)) + 1): L = product(E, repeat=i) for l in L: if (3 not in l) or (5 not in l) or (7 not in l): continue number = int("".join(list(map(str, l)))) if number <= N: ...
from itertools import * N = int(eval(input())) A = ["3", "5", "7"] ans = 0 length = len(str(N)) for i in range(3, length + 1): for prod in product(A, repeat=i): if prod.count("3") == 0 or prod.count("5") == 0 or prod.count("7") == 0: continue num = int("".join(prod)) if num > N:...
false
36.363636
[ "-from itertools import product", "+from itertools import *", "-E = [3, 5, 7]", "+A = [\"3\", \"5\", \"7\"]", "-for i in range(3, len(str(N)) + 1):", "- L = product(E, repeat=i)", "- for l in L:", "- if (3 not in l) or (5 not in l) or (7 not in l):", "+length = len(str(N))", "+for i i...
false
0.218488
0.050429
4.332631
[ "s783088217", "s360955782" ]
u869790980
p02762
python
s350355731
s637179262
836
498
104,348
58,268
Accepted
Accepted
40.43
import collections n,m,k = list(map(int,input().split(' '))) friendships = [list(map(int, input().split(' '))) for _ in range(m)] disses = [list(map(int, input().split(' '))) for _ in range(k)] parent = [i for i in range(0, n+1)] sizes = [1 for i in range(0, n+1)] hd = collections.Counter() adj = collect...
import collections n,m,k = list(map(int,input().split(' '))) friendships = [list(map(int, input().split(' '))) for _ in range(m)] disses = [list(map(int, input().split(' '))) for _ in range(k)] parent = [i for i in range(0, n+1)] sizes = [1 for i in range(0, n+1)] hd = [1 for i in range(0, n + 1)] def ...
40
37
903
822
import collections n, m, k = list(map(int, input().split(" "))) friendships = [list(map(int, input().split(" "))) for _ in range(m)] disses = [list(map(int, input().split(" "))) for _ in range(k)] parent = [i for i in range(0, n + 1)] sizes = [1 for i in range(0, n + 1)] hd = collections.Counter() adj = collections.de...
import collections n, m, k = list(map(int, input().split(" "))) friendships = [list(map(int, input().split(" "))) for _ in range(m)] disses = [list(map(int, input().split(" "))) for _ in range(k)] parent = [i for i in range(0, n + 1)] sizes = [1 for i in range(0, n + 1)] hd = [1 for i in range(0, n + 1)] def f(paren...
false
7.5
[ "-hd = collections.Counter()", "-adj = collections.defaultdict(set)", "+hd = [1 for i in range(0, n + 1)]", "- adj[a].add(b)", "- adj[b].add(a)", "+ hd[a] += 1", "+ hd[b] += 1", "- if d not in adj[c] and (pc == pd):", "+ if pc == pd:", "-print(", "- \" \".join(", "- ...
false
0.037337
0.041213
0.905952
[ "s350355731", "s637179262" ]
u761320129
p02763
python
s412500669
s422982810
827
483
170,976
206,952
Accepted
Accepted
41.6
N = int(input()) S = input() Q = int(input()) qs = [input().split() for i in range(Q)] def ctoi(c): return ord(c) - ord('a') class BinaryIndexedTree: def __init__(self,size): self.N = size self.bit = [0]*(size+1) def add(self,x,w): # 0-indexed x += 1 while x <...
import sys input = sys.stdin.readline N = int(eval(input())) S = input().rstrip() Q = int(eval(input())) qs = [input().split() for i in range(Q)] class BinaryIndexedTree: def __init__(self,size): self.N = size self.bit = [0]*(size+1) def add(self,x,w): # 0-indexed x += 1 ...
50
48
1,206
1,245
N = int(input()) S = input() Q = int(input()) qs = [input().split() for i in range(Q)] def ctoi(c): return ord(c) - ord("a") class BinaryIndexedTree: def __init__(self, size): self.N = size self.bit = [0] * (size + 1) def add(self, x, w): # 0-indexed x += 1 while x <= s...
import sys input = sys.stdin.readline N = int(eval(input())) S = input().rstrip() Q = int(eval(input())) qs = [input().split() for i in range(Q)] class BinaryIndexedTree: def __init__(self, size): self.N = size self.bit = [0] * (size + 1) def add(self, x, w): # 0-indexed x += 1 ...
false
4
[ "-N = int(input())", "-S = input()", "-Q = int(input())", "+import sys", "+", "+input = sys.stdin.readline", "+N = int(eval(input()))", "+S = input().rstrip()", "+Q = int(eval(input()))", "-", "-", "-def ctoi(c):", "- return ord(c) - ord(\"a\")", "-bits = [BinaryIndexedTree(N) for i in ...
false
0.0371
0.036725
1.010213
[ "s412500669", "s422982810" ]
u252729807
p03774
python
s329050420
s318397926
202
29
44,420
9,080
Accepted
Accepted
85.64
from scipy.spatial.distance import cdist import numpy as np #%% n, m = list(map(int, input().split())) st = [list(map(int, input().split())) for _ in range(n)] cp = [list(map(int, input().split())) for _ in range(m)] #%% # for s in st: # print(cityblock(s, np.array(cp))) cd = cdist(st, cp, 'cityblock')...
# scipyなし n, m = list(map(int, input().split())) st = [list(map(int, input().split())) for _ in range(n)] cp = [list(map(int, input().split())) for _ in range(m)] for s in st: mandist = float('inf') for i, c in enumerate(cp): d = abs(s[0] - c[0]) + abs(s[1] - c[1]) if d < mandist: ...
15
14
374
389
from scipy.spatial.distance import cdist import numpy as np #%% n, m = list(map(int, input().split())) st = [list(map(int, input().split())) for _ in range(n)] cp = [list(map(int, input().split())) for _ in range(m)] #%% # for s in st: # print(cityblock(s, np.array(cp))) cd = cdist(st, cp, "cityblock") idx = np.ar...
# scipyなし n, m = list(map(int, input().split())) st = [list(map(int, input().split())) for _ in range(n)] cp = [list(map(int, input().split())) for _ in range(m)] for s in st: mandist = float("inf") for i, c in enumerate(cp): d = abs(s[0] - c[0]) + abs(s[1] - c[1]) if d < mandist: an...
false
6.666667
[ "-from scipy.spatial.distance import cdist", "-import numpy as np", "-", "-#%%", "+# scipyなし", "-#%%", "-# for s in st:", "-# print(cityblock(s, np.array(cp)))", "-cd = cdist(st, cp, \"cityblock\")", "-idx = np.argmin(cd, axis=1)", "-for i in idx:", "- print((i + 1))", "+for s in st:"...
false
0.390217
0.035143
11.103647
[ "s329050420", "s318397926" ]
u477977638
p02821
python
s660703820
s278926070
1,971
1,011
53,232
53,232
Accepted
Accepted
48.71
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines import bisect n,m=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() def hand(x): cnt=0 for i in range(n): p=x-A[i] cnt+=n-bisect.bisect_left(A,p) retur...
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines import bisect n,m=list(map(int,input().split())) A=list(map(int,input().split())) A.sort() def hand(x): cnt=0 for i in range(n): p=x-A[i] cnt+=n-bisect.bisect_left(A,p) retur...
60
60
842
843
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines import bisect n, m = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() def hand(x): cnt = 0 for i in range(n): p = x - A[i] cnt += n - bisect.bisect_left(A...
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines import bisect n, m = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() def hand(x): cnt = 0 for i in range(n): p = x - A[i] cnt += n - bisect.bisect_left(A...
false
0
[ "- h = 10**15 + 3", "+ h = 2 * 10**5 + 1" ]
false
0.037215
0.036068
1.031798
[ "s660703820", "s278926070" ]
u168578024
p03061
python
s595120584
s313733372
670
615
81,340
81,468
Accepted
Accepted
8.21
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline from fractions import gcd class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = I self.seg = [I]*(N*2) def assign(self, k, x): self.seg[k + self...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline from fractions import gcd class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = I self.seg = [I]*(N*2) def assign(self, k, x): self.seg[k + self...
54
54
1,321
1,321
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline from fractions import gcd class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = I self.seg = [I] * (N * 2) def assign(self, k, x): self.seg[k + self.sz] = x...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline from fractions import gcd class SegmentTree: def __init__(self, N, func, I): self.sz = N self.func = func self.I = I self.seg = [I] * (N * 2) def assign(self, k, x): self.seg[k + self.sz] = x...
false
0
[ "- a //= 2", "- b //= 2", "+ a >>= 1", "+ b >>= 1" ]
false
0.108457
0.061114
1.774666
[ "s595120584", "s313733372" ]
u471797506
p03666
python
s848261499
s486868733
113
92
4,392
4,392
Accepted
Accepted
18.58
# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll def solve(): N, A, B, C, D = list(map(int, input().split())) A, B = 0, B - A if B < 0: B *= -1 M = N - 1 for i in range(0, N, 2): if C*(M - i) <= B <= (D - C)*((i + 1)/2) +...
# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll def solve(): N, A, B, C, D = list(map(int, input().split())) A, B = 0, B - A if B < 0: B *= -1 M = N - 1 for i in range(N): if C*(M - i) - D*i <= B <= D*(M - i) - C*i: ...
21
17
519
398
# -*- coding: utf-8 -*- import sys, copy, math, heapq, itertools as it, fractions, re, bisect, collections as coll def solve(): N, A, B, C, D = list(map(int, input().split())) A, B = 0, B - A if B < 0: B *= -1 M = N - 1 for i in range(0, N, 2): if C * (M - i) <= B <= (D - C) * ((i ...
# -*- coding: utf-8 -*- import sys, copy, math, heapq, itertools as it, fractions, re, bisect, collections as coll def solve(): N, A, B, C, D = list(map(int, input().split())) A, B = 0, B - A if B < 0: B *= -1 M = N - 1 for i in range(N): if C * (M - i) - D * i <= B <= D * (M - i) ...
false
19.047619
[ "- for i in range(0, N, 2):", "- if C * (M - i) <= B <= (D - C) * ((i + 1) / 2) + D * (M - i):", "- return True" ]
false
0.093618
0.090692
1.032261
[ "s848261499", "s486868733" ]
u371385198
p02713
python
s235407686
s341743266
1,313
1,098
9,188
9,212
Accepted
Accepted
16.37
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): n = math.gcd(i, j) for l in range(1, K + 1): ans += math.gcd(n, l) print(ans)
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(i, K + 1): n = math.gcd(i, j) for l in range(j, K + 1): if len(set([i, j, l])) == 1: ans += math.gcd(n, l) elif len(set([i,...
14
19
252
452
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): n = math.gcd(i, j) for l in range(1, K + 1): ans += math.gcd(n, l) print(ans)
import sys import math input = sys.stdin.readline K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(i, K + 1): n = math.gcd(i, j) for l in range(j, K + 1): if len(set([i, j, l])) == 1: ans += math.gcd(n, l) elif len(set([i, j, l])) == 2:...
false
26.315789
[ "- for j in range(1, K + 1):", "+ for j in range(i, K + 1):", "- for l in range(1, K + 1):", "- ans += math.gcd(n, l)", "+ for l in range(j, K + 1):", "+ if len(set([i, j, l])) == 1:", "+ ans += math.gcd(n, l)", "+ elif len(set([i, j,...
false
0.123399
0.101314
1.217987
[ "s235407686", "s341743266" ]
u285891772
p02585
python
s908687186
s928057407
2,918
2,530
79,980
98,160
Accepted
Accepted
13.3
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemge...
66
75
1,678
1,931
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, ) from itertools import ( accumulate, permutations, combinations, ...
import sys, re from collections import deque, defaultdict, Counter from math import ( ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, ) from itertools import ( accumulate, permutations, combinations, ...
false
12
[ "- x_acc = list(accumulate([0] + x * 3))", "+ x_acc = list(accumulate([0] + x + x))", "- if x_acc[n] <= 0:", "- tmp_ans = 0", "- l = min(K, n)", "- else:", "- tmp_ans = x_acc[n] * (max(0, K // n - 1))", "- l = min(K % n + n, K)", "- for i, j in combinations...
false
0.196609
0.089313
2.201347
[ "s908687186", "s928057407" ]
u846150137
p03221
python
s614058890
s780995699
1,254
1,058
39,272
40,688
Accepted
Accepted
15.63
I=lambda:list(map(int,input().split())) n,m=I() a=[[i]+I() for i in range(m)] a=sorted(a,key=lambda x:(x[1],x[2])) b=[] j0=0 p=1 for i,j,k in a: if j!=j0: p=1 else: p+=1 b.append([i,j,p]) j0=j b=sorted(b,key=lambda x:x[0]) for i,j,k in b: print(("{:06d}{:06d}".format(j,k)))
I=lambda:list(map(int,input().split())) n,m=I() a=[[i]+I() for i in range(m)] a=sorted(a,key=lambda x:(x[1],x[2])) b=[] j0=0 p=1 for i,j,k in a: p=1 if j!=j0 else p+1 b.append([i,j,p]) j0=j for i,j,k in sorted(b): print(("{:06d}{:06d}".format(j,k)))
17
14
306
271
I = lambda: list(map(int, input().split())) n, m = I() a = [[i] + I() for i in range(m)] a = sorted(a, key=lambda x: (x[1], x[2])) b = [] j0 = 0 p = 1 for i, j, k in a: if j != j0: p = 1 else: p += 1 b.append([i, j, p]) j0 = j b = sorted(b, key=lambda x: x[0]) for i, j, k in b: print...
I = lambda: list(map(int, input().split())) n, m = I() a = [[i] + I() for i in range(m)] a = sorted(a, key=lambda x: (x[1], x[2])) b = [] j0 = 0 p = 1 for i, j, k in a: p = 1 if j != j0 else p + 1 b.append([i, j, p]) j0 = j for i, j, k in sorted(b): print(("{:06d}{:06d}".format(j, k)))
false
17.647059
[ "- if j != j0:", "- p = 1", "- else:", "- p += 1", "+ p = 1 if j != j0 else p + 1", "-b = sorted(b, key=lambda x: x[0])", "-for i, j, k in b:", "+for i, j, k in sorted(b):" ]
false
0.074101
0.03995
1.854837
[ "s614058890", "s780995699" ]
u285891772
p02838
python
s756865873
s351028927
944
774
132,112
131,716
Accepted
Accepted
18.01
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, asc...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, asc...
39
39
1,100
1,080
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upp...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_upp...
false
0
[ "-cnt = [[0, 0] for _ in range(n)]", "+cnt = [0] * n", "- x = \"{:b}\".format(x).zfill(n)", "- for i in range(n):", "- cnt[i][int(x[-(i + 1)])] += 1", "+ for i, y in enumerate(\"{:b}\".format(x).zfill(n)[::-1]):", "+ if y == \"1\":", "+ cnt[i] += 1", "-for i in rang...
false
0.097074
0.036953
2.626958
[ "s756865873", "s351028927" ]
u729133443
p02688
python
s363178327
s662877419
65
20
67,076
9,356
Accepted
Accepted
69.23
(n,_),*t=[t.split()for t in open(0)][::2] print((int(n)-len(set(sum(t,[])))))
n,_,*t=''.join([*open(0)][::2]).split() print((int(n)-len({*t})))
2
2
76
64
(n, _), *t = [t.split() for t in open(0)][::2] print((int(n) - len(set(sum(t, [])))))
n, _, *t = "".join([*open(0)][::2]).split() print((int(n) - len({*t})))
false
0
[ "-(n, _), *t = [t.split() for t in open(0)][::2]", "-print((int(n) - len(set(sum(t, [])))))", "+n, _, *t = \"\".join([*open(0)][::2]).split()", "+print((int(n) - len({*t})))" ]
false
0.059837
0.084236
0.710345
[ "s363178327", "s662877419" ]
u072053884
p02241
python
s922503345
s256022027
580
20
7,908
7,924
Accepted
Accepted
96.55
n = int(eval(input())) adj = [list(map(int, input().split())) for i in range(n)] def mst(): T = [0] gross_weight = 0 cnt = n - 1 while cnt: ew = 2001 for i in range(len(T)): for tv, tew in enumerate(adj[T[i]]): if (tv not in T) and (tew != -1): ...
n = int(eval(input())) adj = [list(map(int, input().split())) for i in range(n)] def prim_mst(vn): isVisited = [False] * vn d = [0] + [2001] * (vn - 1) p = [-1] * vn while True: mincost = 2001 for i in range(vn): if (not isVisited[i]) and (d[i] < mincost): ...
22
32
490
680
n = int(eval(input())) adj = [list(map(int, input().split())) for i in range(n)] def mst(): T = [0] gross_weight = 0 cnt = n - 1 while cnt: ew = 2001 for i in range(len(T)): for tv, tew in enumerate(adj[T[i]]): if (tv not in T) and (tew != -1): ...
n = int(eval(input())) adj = [list(map(int, input().split())) for i in range(n)] def prim_mst(vn): isVisited = [False] * vn d = [0] + [2001] * (vn - 1) p = [-1] * vn while True: mincost = 2001 for i in range(vn): if (not isVisited[i]) and (d[i] < mincost): m...
false
31.25
[ "-def mst():", "- T = [0]", "- gross_weight = 0", "- cnt = n - 1", "- while cnt:", "- ew = 2001", "- for i in range(len(T)):", "- for tv, tew in enumerate(adj[T[i]]):", "- if (tv not in T) and (tew != -1):", "- if tew < ew:", ...
false
0.065482
0.038405
1.705035
[ "s922503345", "s256022027" ]
u074220993
p03643
python
s535891906
s257031124
30
26
9,016
9,016
Accepted
Accepted
13.33
N = eval(input()) ans = "ABC" + N print(ans)
n = int(eval(input())) print(f'ABC{n:0>3}')
3
2
40
38
N = eval(input()) ans = "ABC" + N print(ans)
n = int(eval(input())) print(f"ABC{n:0>3}")
false
33.333333
[ "-N = eval(input())", "-ans = \"ABC\" + N", "-print(ans)", "+n = int(eval(input()))", "+print(f\"ABC{n:0>3}\")" ]
false
0.035547
0.034443
1.032049
[ "s535891906", "s257031124" ]
u141610915
p03162
python
s265933075
s924540917
717
372
79,064
70,620
Accepted
Accepted
48.12
N = int(eval(input())) act = list(list(map(int, input().split())) for _ in range(N)) dp = [[0 for _ in range(3)] for _ in range(N + 1)] for i in range(N): dp[i + 1][0] = max(dp[i + 1][0], act[i][0] + max(dp[i][1], dp[i][2])) dp[i + 1][1] = max(dp[i + 1][1], act[i][1] + max(dp[i][0], dp[i][2])) dp[i + 1][2] ...
import sys input = sys.stdin.readline N = int(eval(input())) act = [tuple(map(int, input().split())) for _ in range(N)] dp = [[0] * 3 for _ in range(N)] dp[0][0] = act[0][0] dp[0][1] = act[0][1] dp[0][2] = act[0][2] for i in range(N - 1): for j in range(3): dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(...
8
12
389
362
N = int(eval(input())) act = list(list(map(int, input().split())) for _ in range(N)) dp = [[0 for _ in range(3)] for _ in range(N + 1)] for i in range(N): dp[i + 1][0] = max(dp[i + 1][0], act[i][0] + max(dp[i][1], dp[i][2])) dp[i + 1][1] = max(dp[i + 1][1], act[i][1] + max(dp[i][0], dp[i][2])) dp[i + 1][2] ...
import sys input = sys.stdin.readline N = int(eval(input())) act = [tuple(map(int, input().split())) for _ in range(N)] dp = [[0] * 3 for _ in range(N)] dp[0][0] = act[0][0] dp[0][1] = act[0][1] dp[0][2] = act[0][2] for i in range(N - 1): for j in range(3): dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j +...
false
33.333333
[ "+import sys", "+", "+input = sys.stdin.readline", "-act = list(list(map(int, input().split())) for _ in range(N))", "-dp = [[0 for _ in range(3)] for _ in range(N + 1)]", "-for i in range(N):", "- dp[i + 1][0] = max(dp[i + 1][0], act[i][0] + max(dp[i][1], dp[i][2]))", "- dp[i + 1][1] = max(dp[i...
false
0.036472
0.056682
0.643462
[ "s265933075", "s924540917" ]
u397496203
p03162
python
s633457408
s727173166
706
337
76,376
44,148
Accepted
Accepted
52.27
class Solver(object): def __init__(self, N, happy): self.dp = [[99999999 for _ in range(3)] for _ in range(N)] self.N = N self.happy = happy def solve(self): happy_list = self.happy self.dp[0] = happy_list[0] for i in range(1, self.N): self....
import sys input = sys.stdin.readline # sys.setrecursionlimit(100000) def main(): N = int(input().strip()) happy_list = [[int(i) for i in input().strip().split()] for _ in range(N)] dp = [[None, None, None] for _ in range(N)] dp[0] = happy_list[0] for i in range(1, N): dp[i]...
28
22
958
596
class Solver(object): def __init__(self, N, happy): self.dp = [[99999999 for _ in range(3)] for _ in range(N)] self.N = N self.happy = happy def solve(self): happy_list = self.happy self.dp[0] = happy_list[0] for i in range(1, self.N): self.dp[i][0] =...
import sys input = sys.stdin.readline # sys.setrecursionlimit(100000) def main(): N = int(input().strip()) happy_list = [[int(i) for i in input().strip().split()] for _ in range(N)] dp = [[None, None, None] for _ in range(N)] dp[0] = happy_list[0] for i in range(1, N): dp[i][0] = happy_list...
false
21.428571
[ "-class Solver(object):", "- def __init__(self, N, happy):", "- self.dp = [[99999999 for _ in range(3)] for _ in range(N)]", "- self.N = N", "- self.happy = happy", "+import sys", "- def solve(self):", "- happy_list = self.happy", "- self.dp[0] = happy_list[0...
false
0.046837
0.041031
1.141498
[ "s633457408", "s727173166" ]
u583507988
p02578
python
s268522210
s105057068
132
115
32,364
32,136
Accepted
Accepted
12.88
n = int(eval(input())) a = list(map(int, input().split())) res = a[0] ans = 0 for i in range(1, n): if res>=a[i]: ans += res-a[i] else: res = a[i] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) res = a[0] ans = 0 for i in range(1, n): if res-a[i]>=0: ans += res-a[i] else: res = a[i] print(ans)
12
13
180
184
n = int(eval(input())) a = list(map(int, input().split())) res = a[0] ans = 0 for i in range(1, n): if res >= a[i]: ans += res - a[i] else: res = a[i] print(ans)
n = int(eval(input())) a = list(map(int, input().split())) res = a[0] ans = 0 for i in range(1, n): if res - a[i] >= 0: ans += res - a[i] else: res = a[i] print(ans)
false
7.692308
[ "- if res >= a[i]:", "+ if res - a[i] >= 0:" ]
false
0.039404
0.035203
1.119339
[ "s268522210", "s105057068" ]
u497952650
p03964
python
s511078385
s027463966
1,182
88
5,076
5,076
Accepted
Accepted
92.55
from decimal import Decimal,getcontext from math import ceil getcontext().prec = 1000 N = int(eval(input())) takahashi,aoki = 1,1 for _ in range(N): a,b = list(map(int,input().split())) c = max(ceil(Decimal(takahashi)/Decimal(a)),ceil(Decimal(aoki)/Decimal(b))) takahashi = c*a aoki = c*b ...
from decimal import Decimal,getcontext from math import ceil N = int(eval(input())) takahashi,aoki = 1,1 for _ in range(N): a,b = list(map(int,input().split())) c = max(ceil(takahashi/Decimal(a)),ceil(aoki/Decimal(b))) takahashi = c*a aoki = c*b print((takahashi+aoki))
14
14
330
288
from decimal import Decimal, getcontext from math import ceil getcontext().prec = 1000 N = int(eval(input())) takahashi, aoki = 1, 1 for _ in range(N): a, b = list(map(int, input().split())) c = max(ceil(Decimal(takahashi) / Decimal(a)), ceil(Decimal(aoki) / Decimal(b))) takahashi = c * a aoki = c * b ...
from decimal import Decimal, getcontext from math import ceil N = int(eval(input())) takahashi, aoki = 1, 1 for _ in range(N): a, b = list(map(int, input().split())) c = max(ceil(takahashi / Decimal(a)), ceil(aoki / Decimal(b))) takahashi = c * a aoki = c * b print((takahashi + aoki))
false
0
[ "-getcontext().prec = 1000", "- c = max(ceil(Decimal(takahashi) / Decimal(a)), ceil(Decimal(aoki) / Decimal(b)))", "+ c = max(ceil(takahashi / Decimal(a)), ceil(aoki / Decimal(b)))" ]
false
0.109382
0.037669
2.903781
[ "s511078385", "s027463966" ]
u941753895
p03031
python
s526728328
s870341640
71
65
6,820
6,828
Accepted
Accepted
8.45
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 def LI(): return list(map(int,input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval(input()) def main(): n,m=...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] de...
50
52
804
1,046
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return list(map(int, input().split())) def I(): return int(eval(input())) def LS(): return input().split() def S(): return eval...
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) ...
false
3.846154
[ "-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time", "+import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy", "+dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]", "+ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1...
false
0.036242
0.037372
0.969767
[ "s526728328", "s870341640" ]
u148551245
p03327
python
s022945488
s409180104
178
17
38,256
2,940
Accepted
Accepted
90.45
n = int(eval(input())) if n < 1000: print("ABC") else: print("ABD")
n = int(eval(input())) if n > 999: print("ABD") else: print("ABC")
5
5
73
72
n = int(eval(input())) if n < 1000: print("ABC") else: print("ABD")
n = int(eval(input())) if n > 999: print("ABD") else: print("ABC")
false
0
[ "-if n < 1000:", "+if n > 999:", "+ print(\"ABD\")", "+else:", "-else:", "- print(\"ABD\")" ]
false
0.137623
0.043006
3.20009
[ "s022945488", "s409180104" ]
u074220993
p03610
python
s749599960
s430865604
46
26
9,028
9,152
Accepted
Accepted
43.48
s = eval(input()) i = 1 ans = '' for x in s: if i & 1: ans += x i += 1 print(ans)
s = eval(input()) print((s[::2]))
9
2
100
26
s = eval(input()) i = 1 ans = "" for x in s: if i & 1: ans += x i += 1 print(ans)
s = eval(input()) print((s[::2]))
false
77.777778
[ "-i = 1", "-ans = \"\"", "-for x in s:", "- if i & 1:", "- ans += x", "- i += 1", "-print(ans)", "+print((s[::2]))" ]
false
0.083383
0.045764
1.82202
[ "s749599960", "s430865604" ]
u502389123
p03338
python
s511739355
s468438988
20
18
3,064
2,940
Accepted
Accepted
10
N = int(eval(input())) S = eval(input()) L = [] for i in range(1, N): a = set() b = set() for j in S[:i]: a.add(j) for k in S[i:]: b.add(k) count = len(a & b) L.append(count) print((max(L)))
N = int(eval(input())) S = eval(input()) cnt = 0 for i in range(N-1): a = S[:i+1] b = S[i+1:] a = set(a) b = set(b) cnt = max(cnt, len(a & b)) print(cnt)
14
14
231
182
N = int(eval(input())) S = eval(input()) L = [] for i in range(1, N): a = set() b = set() for j in S[:i]: a.add(j) for k in S[i:]: b.add(k) count = len(a & b) L.append(count) print((max(L)))
N = int(eval(input())) S = eval(input()) cnt = 0 for i in range(N - 1): a = S[: i + 1] b = S[i + 1 :] a = set(a) b = set(b) cnt = max(cnt, len(a & b)) print(cnt)
false
0
[ "-L = []", "-for i in range(1, N):", "- a = set()", "- b = set()", "- for j in S[:i]:", "- a.add(j)", "- for k in S[i:]:", "- b.add(k)", "- count = len(a & b)", "- L.append(count)", "-print((max(L)))", "+cnt = 0", "+for i in range(N - 1):", "+ a = S[: i +...
false
0.040288
0.045908
0.877575
[ "s511739355", "s468438988" ]
u170201762
p03700
python
s275116761
s176246953
1,335
934
7,068
50,648
Accepted
Accepted
30.04
from math import ceil N,A,B = list(map(int,input().split())) H = [int(eval(input())) for _ in range(N)] def attack(n): s = 0 for h in H: h -= B*n if h > 0: s += ceil(h/(A-B)) return s <= n l = 0 r = 0 for h in H: r = max(ceil(h/B),r) for _ in range(30): ...
from math import ceil N,A,B = list(map(int,input().split())) H = [int(eval(input())) for _ in range(N)] def attack(n): s = 0 for h in H: h -= B*n if h > 0: s += ceil(h/(A-B)) return s <= n l = 0 r = 0 for h in H: r = max(ceil(h/B),r) while l != r-1: m...
25
25
403
399
from math import ceil N, A, B = list(map(int, input().split())) H = [int(eval(input())) for _ in range(N)] def attack(n): s = 0 for h in H: h -= B * n if h > 0: s += ceil(h / (A - B)) return s <= n l = 0 r = 0 for h in H: r = max(ceil(h / B), r) for _ in range(30): m...
from math import ceil N, A, B = list(map(int, input().split())) H = [int(eval(input())) for _ in range(N)] def attack(n): s = 0 for h in H: h -= B * n if h > 0: s += ceil(h / (A - B)) return s <= n l = 0 r = 0 for h in H: r = max(ceil(h / B), r) while l != r - 1: mid...
false
0
[ "-for _ in range(30):", "+while l != r - 1:" ]
false
0.04618
0.086971
0.530982
[ "s275116761", "s176246953" ]
u926412290
p03043
python
s021724702
s702883434
31
27
3,188
2,940
Accepted
Accepted
12.9
import math as m N, K = list(map(int, input().split())) P = 0 for i in range(1, N+1): if i >= K: P += (N-i+1) / N break else: if m.log2(K/i).is_integer(): P += 1 / (N*2**(m.log10(K/i)/m.log10(2))) else: P += 1 / (N*2**int(m.log10(K/i)/m.lo...
N, K = list(map(int, input().split())) P = 0 for i in range(1, N+1): if i >= K: P += (N-i+1) / N break else: n = 1 while i*n < K: n *= 2 P += 1 / (N*n) print(P)
17
16
338
233
import math as m N, K = list(map(int, input().split())) P = 0 for i in range(1, N + 1): if i >= K: P += (N - i + 1) / N break else: if m.log2(K / i).is_integer(): P += 1 / (N * 2 ** (m.log10(K / i) / m.log10(2))) else: P += 1 / (N * 2 ** int(m.log10(K / i...
N, K = list(map(int, input().split())) P = 0 for i in range(1, N + 1): if i >= K: P += (N - i + 1) / N break else: n = 1 while i * n < K: n *= 2 P += 1 / (N * n) print(P)
false
5.882353
[ "-import math as m", "-", "- if m.log2(K / i).is_integer():", "- P += 1 / (N * 2 ** (m.log10(K / i) / m.log10(2)))", "- else:", "- P += 1 / (N * 2 ** int(m.log10(K / i) / m.log10(2) + 1))", "+ n = 1", "+ while i * n < K:", "+ n *= 2", "+...
false
0.088929
0.046496
1.912602
[ "s021724702", "s702883434" ]
u133936772
p03208
python
s300762462
s937605636
228
78
7,852
20,128
Accepted
Accepted
65.79
n,k=list(map(int,input().split())) l=sorted(int(eval(input())) for _ in [0]*n) print((min(l[i+k-1]-l[i] for i in range(n-k+1))))
n,k,*l=list(map(int,open(0).read().split())) l.sort() print((min(l[k+i-1]-l[i] for i in range(n-k+1))))
3
3
116
97
n, k = list(map(int, input().split())) l = sorted(int(eval(input())) for _ in [0] * n) print((min(l[i + k - 1] - l[i] for i in range(n - k + 1))))
n, k, *l = list(map(int, open(0).read().split())) l.sort() print((min(l[k + i - 1] - l[i] for i in range(n - k + 1))))
false
0
[ "-n, k = list(map(int, input().split()))", "-l = sorted(int(eval(input())) for _ in [0] * n)", "-print((min(l[i + k - 1] - l[i] for i in range(n - k + 1))))", "+n, k, *l = list(map(int, open(0).read().split()))", "+l.sort()", "+print((min(l[k + i - 1] - l[i] for i in range(n - k + 1))))" ]
false
0.038
0.041487
0.915953
[ "s300762462", "s937605636" ]
u279493135
p02713
python
s600385980
s222641817
1,232
194
85,092
74,864
Accepted
Accepted
84.25
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowerc...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowerc...
32
28
994
921
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, a...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, a...
false
12.5
[ "-", "-", "-@lru_cache(maxsize=None)", "-def memo_gcd(a, b):", "- return gcd(a, b)", "-", "-", "- ans += memo_gcd(a, k)", "+ ans += gcd(a, k)" ]
false
0.177913
0.223243
0.796945
[ "s600385980", "s222641817" ]
u607563136
p02548
python
s156218736
s965501814
323
128
9,108
9,156
Accepted
Accepted
60.37
def main(): n = int(eval(input())) ans = 0 cnt = 0 for i in range(1,n): if n%i==0: ans+=n//i-1 else: ans+=n//i if i**2<n: cnt+=1 print(ans) main()
def main(): n = int(eval(input())) ans = 0 for i in range(1,n): if n%i==0: ans+=n//i-1 else: ans+=n//i print(ans) main()
13
10
232
179
def main(): n = int(eval(input())) ans = 0 cnt = 0 for i in range(1, n): if n % i == 0: ans += n // i - 1 else: ans += n // i if i**2 < n: cnt += 1 print(ans) main()
def main(): n = int(eval(input())) ans = 0 for i in range(1, n): if n % i == 0: ans += n // i - 1 else: ans += n // i print(ans) main()
false
23.076923
[ "- cnt = 0", "- if i**2 < n:", "- cnt += 1" ]
false
0.127758
0.273611
0.466934
[ "s156218736", "s965501814" ]
u860002137
p03282
python
s008989296
s629389371
333
28
20,748
9,168
Accepted
Accepted
91.59
import numpy as np S = np.array(list(map(str, input().rstrip()))) K = int(eval(input())) cnt = 0 ans = 1 for i, s in enumerate(S): if s != "1": cnt = i+1 ans = s break if cnt > K: print((1)) else: print((int(ans)))
s = list(map(str, input().rstrip())) k = int(eval(input())) ans = 1 for x in s[:k]: if int(x) != 1: ans = int(x) break print(ans)
17
9
259
152
import numpy as np S = np.array(list(map(str, input().rstrip()))) K = int(eval(input())) cnt = 0 ans = 1 for i, s in enumerate(S): if s != "1": cnt = i + 1 ans = s break if cnt > K: print((1)) else: print((int(ans)))
s = list(map(str, input().rstrip())) k = int(eval(input())) ans = 1 for x in s[:k]: if int(x) != 1: ans = int(x) break print(ans)
false
47.058824
[ "-import numpy as np", "-", "-S = np.array(list(map(str, input().rstrip())))", "-K = int(eval(input()))", "-cnt = 0", "+s = list(map(str, input().rstrip()))", "+k = int(eval(input()))", "-for i, s in enumerate(S):", "- if s != \"1\":", "- cnt = i + 1", "- ans = s", "+for x in ...
false
0.41125
0.05635
7.298142
[ "s008989296", "s629389371" ]
u497952650
p03448
python
s905287321
s421363183
44
18
3,064
3,060
Accepted
Accepted
59.09
def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 for i in range(A+1): for j in range(B+1): for h in range(C+1): if 500*i + 100*j + 50*h == X: ans += 1 ...
def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 for i in range(A+1): for j in range(B+1): tmp = X - 500*i - 100*j if tmp >= 0 and tmp//50 <= C: ans += 1 print(a...
17
17
349
341
def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 for i in range(A + 1): for j in range(B + 1): for h in range(C + 1): if 500 * i + 100 * j + 50 * h == X: ans += 1 print(ans)...
def main(): A = int(eval(input())) B = int(eval(input())) C = int(eval(input())) X = int(eval(input())) ans = 0 for i in range(A + 1): for j in range(B + 1): tmp = X - 500 * i - 100 * j if tmp >= 0 and tmp // 50 <= C: ans += 1 print(ans) if _...
false
0
[ "- for h in range(C + 1):", "- if 500 * i + 100 * j + 50 * h == X:", "- ans += 1", "+ tmp = X - 500 * i - 100 * j", "+ if tmp >= 0 and tmp // 50 <= C:", "+ ans += 1" ]
false
0.054271
0.034749
1.561783
[ "s905287321", "s421363183" ]
u047796752
p03062
python
s546191888
s829803897
229
191
60,272
88,172
Accepted
Accepted
16.59
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 m = 10**18 for Ai in A: if Ai<0: cnt += 1 m = min(m, abs(Ai)) if cnt%2==0: print((sum(abs(Ai) for Ai in A))) else: print((sum(abs(Ai) for Ai in A)-2*m))
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 for Ai in A: if Ai<0: cnt += 1 if cnt%2==0: print((sum(abs(Ai) for Ai in A))) else: A.sort(key=lambda x: abs(x)) print((-abs(A[0])+sum(abs(Ai) for Ai in A[1:])))
18
16
296
298
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 m = 10**18 for Ai in A: if Ai < 0: cnt += 1 m = min(m, abs(Ai)) if cnt % 2 == 0: print((sum(abs(Ai) for Ai in A))) else: print((sum(abs(Ai) for Ai in A) - 2 * m))
import sys input = sys.stdin.readline N = int(eval(input())) A = list(map(int, input().split())) cnt = 0 for Ai in A: if Ai < 0: cnt += 1 if cnt % 2 == 0: print((sum(abs(Ai) for Ai in A))) else: A.sort(key=lambda x: abs(x)) print((-abs(A[0]) + sum(abs(Ai) for Ai in A[1:])))
false
11.111111
[ "-m = 10**18", "- m = min(m, abs(Ai))", "- print((sum(abs(Ai) for Ai in A) - 2 * m))", "+ A.sort(key=lambda x: abs(x))", "+ print((-abs(A[0]) + sum(abs(Ai) for Ai in A[1:])))" ]
false
0.043083
0.037656
1.144132
[ "s546191888", "s829803897" ]
u977389981
p03773
python
s942151789
s731071173
20
17
2,940
3,064
Accepted
Accepted
15
a, b = list(map(int, input().split())) print((a + b if a + b < 24 else (a + b - 24 if a + b > 24 else 0)))
A, B = list(map(int, input().split())) x = A + B print((x if x < 24 else (0 if x == 24 else x - 24)))
2
3
99
95
a, b = list(map(int, input().split())) print((a + b if a + b < 24 else (a + b - 24 if a + b > 24 else 0)))
A, B = list(map(int, input().split())) x = A + B print((x if x < 24 else (0 if x == 24 else x - 24)))
false
33.333333
[ "-a, b = list(map(int, input().split()))", "-print((a + b if a + b < 24 else (a + b - 24 if a + b > 24 else 0)))", "+A, B = list(map(int, input().split()))", "+x = A + B", "+print((x if x < 24 else (0 if x == 24 else x - 24)))" ]
false
0.038861
0.040236
0.965833
[ "s942151789", "s731071173" ]
u677121387
p03095
python
s879722118
s863353181
642
35
9,300
9,456
Accepted
Accepted
94.55
n = int(eval(input())) s = eval(input()) mod = 1000000007 alphacnt = [0]*26 ans = 0 for c in s: idx = ord(c)-ord("a") alphacnt[idx] += 1 cnt = 1 for i in range(26): if i == idx: continue cnt = (cnt*(alphacnt[i]+1))%mod ans = (ans+cnt)%mod print(ans)
from collections import Counter n = int(eval(input())) s = eval(input()) mod = 1000000007 ans = 1 cnt = Counter(s) for v in list(cnt.values()): ans = ans*(v+1)%mod ans = (ans-1)%mod print(ans)
14
9
286
182
n = int(eval(input())) s = eval(input()) mod = 1000000007 alphacnt = [0] * 26 ans = 0 for c in s: idx = ord(c) - ord("a") alphacnt[idx] += 1 cnt = 1 for i in range(26): if i == idx: continue cnt = (cnt * (alphacnt[i] + 1)) % mod ans = (ans + cnt) % mod print(ans)
from collections import Counter n = int(eval(input())) s = eval(input()) mod = 1000000007 ans = 1 cnt = Counter(s) for v in list(cnt.values()): ans = ans * (v + 1) % mod ans = (ans - 1) % mod print(ans)
false
35.714286
[ "+from collections import Counter", "+", "-alphacnt = [0] * 26", "-ans = 0", "-for c in s:", "- idx = ord(c) - ord(\"a\")", "- alphacnt[idx] += 1", "- cnt = 1", "- for i in range(26):", "- if i == idx:", "- continue", "- cnt = (cnt * (alphacnt[i] + 1)) % mo...
false
0.061918
0.034863
1.776065
[ "s879722118", "s863353181" ]
u808427016
p03209
python
s472438314
s206935261
20
18
3,188
3,064
Accepted
Accepted
10
N, X = [int(_) for _ in input().split()] def calc(n, x, cache = {}): #print("calc", n, x) key = (n, x) if key in cache: return cache[key] if n == 1: if x < 2: result = 0 elif x < 5: result = x - 1 else: result = 3 e...
N, X = [int(_) for _ in input().split()] def calc(n, x, cache = {}): if n == 1: return min(max(x - 1, 0), 3) else: plen = 2 * 2 ** n - 3 if x == 1: return 0 elif x >= 4 * 2 ** n - 3: return 2 * 2 ** n - 1 elif x < 2 + plen: ...
32
21
753
529
N, X = [int(_) for _ in input().split()] def calc(n, x, cache={}): # print("calc", n, x) key = (n, x) if key in cache: return cache[key] if n == 1: if x < 2: result = 0 elif x < 5: result = x - 1 else: result = 3 else: ple...
N, X = [int(_) for _ in input().split()] def calc(n, x, cache={}): if n == 1: return min(max(x - 1, 0), 3) else: plen = 2 * 2**n - 3 if x == 1: return 0 elif x >= 4 * 2**n - 3: return 2 * 2**n - 1 elif x < 2 + plen: return calc(n - 1,...
false
34.375
[ "- # print(\"calc\", n, x)", "- key = (n, x)", "- if key in cache:", "- return cache[key]", "- if x < 2:", "- result = 0", "- elif x < 5:", "- result = x - 1", "- else:", "- result = 3", "+ return min(max(x - 1, 0), 3)"...
false
0.033581
0.039157
0.857609
[ "s472438314", "s206935261" ]
u962718741
p03341
python
s187046059
s807967324
140
125
10,040
9,896
Accepted
Accepted
10.71
import collections def main(): N = int(eval(input())) S = eval(input()) cnt = collections.Counter(S) E_cnt = cnt['E'] W_cnt = cnt['W'] tmp = 0 if S[0] == 'E': E_cnt -= 1 ans = E_cnt for i in range(1, N): if S[i] == 'E': E_cnt -= 1 ...
import collections def main(): N = int(eval(input())) S = eval(input()) cnt = collections.Counter(S) E_cnt = cnt['E'] tmp = 0 if S[0] == 'E': E_cnt -= 1 ans = E_cnt for i in range(1, N): if S[i] == 'E': E_cnt -= 1 if S[i - 1] == 'W': ...
27
24
489
428
import collections def main(): N = int(eval(input())) S = eval(input()) cnt = collections.Counter(S) E_cnt = cnt["E"] W_cnt = cnt["W"] tmp = 0 if S[0] == "E": E_cnt -= 1 ans = E_cnt for i in range(1, N): if S[i] == "E": E_cnt -= 1 else: ...
import collections def main(): N = int(eval(input())) S = eval(input()) cnt = collections.Counter(S) E_cnt = cnt["E"] tmp = 0 if S[0] == "E": E_cnt -= 1 ans = E_cnt for i in range(1, N): if S[i] == "E": E_cnt -= 1 if S[i - 1] == "W": tmp ...
false
11.111111
[ "- W_cnt = cnt[\"W\"]", "- else:", "- W_cnt -= 1" ]
false
0.035431
0.07247
0.488914
[ "s187046059", "s807967324" ]
u905582793
p03133
python
s617571747
s311812827
231
58
42,588
3,064
Accepted
Accepted
74.89
n,m = list(map(int,input().split())) a = [int(input().replace(" ",""),2) for i in range(n)] mod = 998244353 cnt = 0 for j in range(m)[::-1]: for i in range(cnt,n): if a[i] & 1<<j: for k in range(n): if (i != k) and (a[k] & 1<<j): a[k] ^= a[i] a[i],a[cnt] = a[cnt],a[i] ...
n,m=list(map(int,input().split())) a=[int(input().replace(" ",""),2) for i in range(n)] o=998244353 c=0 for j in range(m)[::-1]: for i in range(c,n): if a[i]&1<<j: for k in range(n): if i!=k and a[k]&1<<j: a[k]^=a[i] a[i],a[c]=a[c],a[i] c+=1 p=lambda x:pow(2,x,o) print((p(n+m-c-1)*(p(c...
17
14
441
320
n, m = list(map(int, input().split())) a = [int(input().replace(" ", ""), 2) for i in range(n)] mod = 998244353 cnt = 0 for j in range(m)[::-1]: for i in range(cnt, n): if a[i] & 1 << j: for k in range(n): if (i != k) and (a[k] & 1 << j): a[k] ^= a[i] ...
n, m = list(map(int, input().split())) a = [int(input().replace(" ", ""), 2) for i in range(n)] o = 998244353 c = 0 for j in range(m)[::-1]: for i in range(c, n): if a[i] & 1 << j: for k in range(n): if i != k and a[k] & 1 << j: a[k] ^= a[i] a[i], ...
false
17.647059
[ "-mod = 998244353", "-cnt = 0", "+o = 998244353", "+c = 0", "- for i in range(cnt, n):", "+ for i in range(c, n):", "- if (i != k) and (a[k] & 1 << j):", "+ if i != k and a[k] & 1 << j:", "- a[i], a[cnt] = a[cnt], a[i]", "- cnt += 1", "-i...
false
0.047007
0.035255
1.333349
[ "s617571747", "s311812827" ]
u784022244
p03352
python
s904986684
s006844949
183
19
38,256
3,188
Accepted
Accepted
89.62
from math import sqrt X=int(eval(input())) ans=0 for i in range(1,int(sqrt(X))+1): now=i b=2 while i!=1 and X>=i**b: now=i**b b+=1 ans=max(ans, now) print(ans)
X=int(eval(input())) ans=0 for i in range(1,33): for j in range(2,11): now=i**j if ans<now and now<=X: ans=now print(ans)
11
9
195
157
from math import sqrt X = int(eval(input())) ans = 0 for i in range(1, int(sqrt(X)) + 1): now = i b = 2 while i != 1 and X >= i**b: now = i**b b += 1 ans = max(ans, now) print(ans)
X = int(eval(input())) ans = 0 for i in range(1, 33): for j in range(2, 11): now = i**j if ans < now and now <= X: ans = now print(ans)
false
18.181818
[ "-from math import sqrt", "-", "-for i in range(1, int(sqrt(X)) + 1):", "- now = i", "- b = 2", "- while i != 1 and X >= i**b:", "- now = i**b", "- b += 1", "- ans = max(ans, now)", "+for i in range(1, 33):", "+ for j in range(2, 11):", "+ now = i**j", "+ ...
false
0.041194
0.047081
0.874959
[ "s904986684", "s006844949" ]
u639104973
p03239
python
s242740048
s468347904
19
17
3,060
3,060
Accepted
Accepted
10.53
N,T=list(map(int,input().split())) C=[list(map(int, input().split())) for _ in range(N)] e=[] for i in C: if T>=i[1]: e.extend([i[0]]) print(('TLE' if len(e)==0 else min(e)))
N,T=list(map(int,input().split())) C=[list(map(int, input().split())) for _ in range(N)] e=10000 for i in C: if T>=i[1] and e>i[0]: e=i[0] print(('TLE' if e==10000 else e))
7
7
178
176
N, T = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(N)] e = [] for i in C: if T >= i[1]: e.extend([i[0]]) print(("TLE" if len(e) == 0 else min(e)))
N, T = list(map(int, input().split())) C = [list(map(int, input().split())) for _ in range(N)] e = 10000 for i in C: if T >= i[1] and e > i[0]: e = i[0] print(("TLE" if e == 10000 else e))
false
0
[ "-e = []", "+e = 10000", "- if T >= i[1]:", "- e.extend([i[0]])", "-print((\"TLE\" if len(e) == 0 else min(e)))", "+ if T >= i[1] and e > i[0]:", "+ e = i[0]", "+print((\"TLE\" if e == 10000 else e))" ]
false
0.079856
0.075957
1.05133
[ "s242740048", "s468347904" ]
u617515020
p03281
python
s805368253
s578129718
31
26
9,188
9,344
Accepted
Accepted
16.13
from math import sqrt N=int(eval(input())) ans=0 for i in range(1,N+1,2): d=[] for j in range(1,int(sqrt(i))+1): if i%j==0: d.append(j) d.append(N//j) d=list(set(d)) if len(d)==8: ans+=1 print(ans)
N=int(eval(input())) ans=0 for i in range(1,N+1,2): cnt=2 for j in range(3,int(i**0.5)+1,2): if i%j==0: cnt+=2 if cnt==8: ans+=1 print(ans)
13
10
231
162
from math import sqrt N = int(eval(input())) ans = 0 for i in range(1, N + 1, 2): d = [] for j in range(1, int(sqrt(i)) + 1): if i % j == 0: d.append(j) d.append(N // j) d = list(set(d)) if len(d) == 8: ans += 1 print(ans)
N = int(eval(input())) ans = 0 for i in range(1, N + 1, 2): cnt = 2 for j in range(3, int(i**0.5) + 1, 2): if i % j == 0: cnt += 2 if cnt == 8: ans += 1 print(ans)
false
23.076923
[ "-from math import sqrt", "-", "- d = []", "- for j in range(1, int(sqrt(i)) + 1):", "+ cnt = 2", "+ for j in range(3, int(i**0.5) + 1, 2):", "- d.append(j)", "- d.append(N // j)", "- d = list(set(d))", "- if len(d) == 8:", "+ cnt += 2", "+ ...
false
0.045494
0.042152
1.079283
[ "s805368253", "s578129718" ]
u079022693
p02624
python
s029424021
s572458467
672
621
339,660
339,924
Accepted
Accepted
7.59
from sys import stdin import numpy as np def main(): #入力 readline=stdin.readline n=int(readline()) ans=0 n_min=np.arange(1,n+1,dtype=np.int64) n_max=n//n_min*n_min kousu=n//n_min ans=(kousu*(n_min+n_max)//2).sum() print(ans) if __name__=="__main__": main()
import numpy as np n=int(eval(input())) n_min=np.arange(1,n+1,dtype=np.int64) n_max=n//n_min*n_min kousu=n//n_min print(((kousu*(n_min+n_max)//2).sum()))
17
8
315
154
from sys import stdin import numpy as np def main(): # 入力 readline = stdin.readline n = int(readline()) ans = 0 n_min = np.arange(1, n + 1, dtype=np.int64) n_max = n // n_min * n_min kousu = n // n_min ans = (kousu * (n_min + n_max) // 2).sum() print(ans) if __name__ == "__main__...
import numpy as np n = int(eval(input())) n_min = np.arange(1, n + 1, dtype=np.int64) n_max = n // n_min * n_min kousu = n // n_min print(((kousu * (n_min + n_max) // 2).sum()))
false
52.941176
[ "-from sys import stdin", "-", "-def main():", "- # 入力", "- readline = stdin.readline", "- n = int(readline())", "- ans = 0", "- n_min = np.arange(1, n + 1, dtype=np.int64)", "- n_max = n // n_min * n_min", "- kousu = n // n_min", "- ans = (kousu * (n_min + n_max) // 2).s...
false
0.40589
0.589422
0.688623
[ "s029424021", "s572458467" ]
u284854859
p02575
python
s572213825
s059851277
1,765
1,149
130,432
126,820
Accepted
Accepted
34.9
import sys,heapq input = sys.stdin.buffer.readline def main(): h,w = list(map(int,input().split())) #dp[i] : iの時の最小右移動回数 dp = [0]*(w+1) #解候補 res = [0]*w #解候補から消されるもの anti = [] #Ai = {1:dp[i]はvalid 0:invalid} #A1 ... AnのBIT(1-indexed) BIT = [0]*(w+1) ...
import sys,heapq input = sys.stdin.buffer.readline def main(): h,w = list(map(int,input().split())) class BIT: def __init__(self,len_A): self.N = len_A + 10 self.bit = [0]*(len_A+10) # sum(A0 ~ Ai) # O(log N) def query(s...
113
114
2,710
2,670
import sys, heapq input = sys.stdin.buffer.readline def main(): h, w = list(map(int, input().split())) # dp[i] : iの時の最小右移動回数 dp = [0] * (w + 1) # 解候補 res = [0] * w # 解候補から消されるもの anti = [] # Ai = {1:dp[i]はvalid 0:invalid} # A1 ... AnのBIT(1-indexed) BIT = [0] * (w + 1) # A1 ...
import sys, heapq input = sys.stdin.buffer.readline def main(): h, w = list(map(int, input().split())) class BIT: def __init__(self, len_A): self.N = len_A + 10 self.bit = [0] * (len_A + 10) # sum(A0 ~ Ai) # O(log N) def query(self, i): re...
false
0.877193
[ "+", "+ class BIT:", "+ def __init__(self, len_A):", "+ self.N = len_A + 10", "+ self.bit = [0] * (len_A + 10)", "+", "+ # sum(A0 ~ Ai)", "+ # O(log N)", "+ def query(self, i):", "+ res = 0", "+ idx = i + 1", "+ ...
false
0.040185
0.050857
0.79017
[ "s572213825", "s059851277" ]
u094191970
p03549
python
s046333310
s814953650
659
30
9,444
9,100
Accepted
Accepted
95.45
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) n,m=nii() ms=1900*m+100*(n-m) ans=0 for i in range(1,10**6): p1=0.5**m p2=(1-0.5**m)**(i-1) p=p1*p2 t_ms=ms*i ans+=p*t_ms ans=int(ans) q=ans%10 if q!=0: ans+=10...
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) n,m=nii() ms=1900*m+100*(n-m) ans=ms*(2**m) print(ans)
22
10
330
185
from sys import stdin nii = lambda: list(map(int, stdin.readline().split())) lnii = lambda: list(map(int, stdin.readline().split())) n, m = nii() ms = 1900 * m + 100 * (n - m) ans = 0 for i in range(1, 10**6): p1 = 0.5**m p2 = (1 - 0.5**m) ** (i - 1) p = p1 * p2 t_ms = ms * i ans += p * t_ms ans = ...
from sys import stdin nii = lambda: list(map(int, stdin.readline().split())) lnii = lambda: list(map(int, stdin.readline().split())) n, m = nii() ms = 1900 * m + 100 * (n - m) ans = ms * (2**m) print(ans)
false
54.545455
[ "-ans = 0", "-for i in range(1, 10**6):", "- p1 = 0.5**m", "- p2 = (1 - 0.5**m) ** (i - 1)", "- p = p1 * p2", "- t_ms = ms * i", "- ans += p * t_ms", "-ans = int(ans)", "-q = ans % 10", "-if q != 0:", "- ans += 10 - q", "+ans = ms * (2**m)" ]
false
1.24939
0.006605
189.163649
[ "s046333310", "s814953650" ]
u858523893
p03797
python
s580101595
s010838829
19
17
3,060
2,940
Accepted
Accepted
10.53
N, M = list(map(int, input().split())) if N >= M // 2: print((M // 2)) else : print((N + (M - N * 2) // 4))
N, M = list(map(int, input().split())) if M < 2 * N : print((M // 2)) else : print((N + (M - 2*N) // 4))
7
6
117
108
N, M = list(map(int, input().split())) if N >= M // 2: print((M // 2)) else: print((N + (M - N * 2) // 4))
N, M = list(map(int, input().split())) if M < 2 * N: print((M // 2)) else: print((N + (M - 2 * N) // 4))
false
14.285714
[ "-if N >= M // 2:", "+if M < 2 * N:", "- print((N + (M - N * 2) // 4))", "+ print((N + (M - 2 * N) // 4))" ]
false
0.084727
0.084636
1.001072
[ "s580101595", "s010838829" ]
u609061751
p02574
python
s899355926
s808466202
793
723
257,136
236,324
Accepted
Accepted
8.83
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") def max_gcd_pair(S): # Assumption 1: S is the list of numbers # Assumption 2: There are no duplicates in S s = set(S) m = max(S) res = 0 i = m while(i > 0): a = i cnt = 0 while (a<=m): ...
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") n = int(eval(input())) a = [int(x) for x in input().split()] # 1~aの最大値までの数の最小の素因数を前処理で求める(O(max_aloglog(max_a))) def smallest_prime_factors(a): max_a = max(a) smallest_prime_factors = [int(x) for x in range(max_a + 1)] for i in range...
56
59
1,040
1,471
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") def max_gcd_pair(S): # Assumption 1: S is the list of numbers # Assumption 2: There are no duplicates in S s = set(S) m = max(S) res = 0 i = m while i > 0: a = i cnt = 0 while a <= m: # a maxed at max ...
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") n = int(eval(input())) a = [int(x) for x in input().split()] # 1~aの最大値までの数の最小の素因数を前処理で求める(O(max_aloglog(max_a))) def smallest_prime_factors(a): max_a = max(a) smallest_prime_factors = [int(x) for x in range(max_a + 1)] for i in range(2, max_a +...
false
5.084746
[ "+n = int(eval(input()))", "+a = [int(x) for x in input().split()]", "+# 1~aの最大値までの数の最小の素因数を前処理で求める(O(max_aloglog(max_a)))", "+def smallest_prime_factors(a):", "+ max_a = max(a)", "+ smallest_prime_factors = [int(x) for x in range(max_a + 1)]", "+ for i in range(2, max_a + 1):", "+ if ...
false
0.038806
0.045822
0.846888
[ "s899355926", "s808466202" ]
u107077660
p03327
python
s570808495
s683121161
168
17
38,256
2,940
Accepted
Accepted
89.88
print(('AB'+'DC'[not input()[3:]]))
print(("AB"+"DC"[len(eval(input()))<4]))
1
1
34
32
print(("AB" + "DC"[not input()[3:]]))
print(("AB" + "DC"[len(eval(input())) < 4]))
false
0
[ "-print((\"AB\" + \"DC\"[not input()[3:]]))", "+print((\"AB\" + \"DC\"[len(eval(input())) < 4]))" ]
false
0.039328
0.03907
1.006594
[ "s570808495", "s683121161" ]
u941407962
p02788
python
s782446344
s084467219
1,780
1,174
130,624
89,944
Accepted
Accepted
34.04
class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] ...
from collections import deque N, D, A = list(map(int, input().split())) ys = [] hs = [] for i in range(N): X, H = list(map(int, input().split())) ys.append((X,i)) hs.append(-(-H//A)) ys = sorted(ys, key=lambda x : x[0]) l = ys[0][0] + 2*D li = 0 dmg = 0 r = 0 for y, i in ys: while (not...
55
25
1,037
478
class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x ...
from collections import deque N, D, A = list(map(int, input().split())) ys = [] hs = [] for i in range(N): X, H = list(map(int, input().split())) ys.append((X, i)) hs.append(-(-H // A)) ys = sorted(ys, key=lambda x: x[0]) l = ys[0][0] + 2 * D li = 0 dmg = 0 r = 0 for y, i in ys: while not l >= y: ...
false
54.545455
[ "-class Bit:", "- def __init__(self, n):", "- self.size = n", "- self.tree = [0] * (n + 1)", "-", "- def sum(self, i):", "- s = 0", "- while i > 0:", "- s += self.tree[i]", "- i -= i & -i", "- return s", "-", "- def add(self, ...
false
0.03985
0.036623
1.08812
[ "s782446344", "s084467219" ]
u745087332
p03108
python
s311592813
s086618242
956
648
110,940
29,076
Accepted
Accepted
32.22
# coding:utf-8 import sys from collections import deque, defaultdict INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(...
# coding:utf-8 import sys from collections import deque, defaultdict INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): return int(...
80
74
2,137
1,685
# coding:utf-8 import sys from collections import deque, defaultdict INF = float("inf") MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): re...
# coding:utf-8 import sys from collections import deque, defaultdict INF = float("inf") MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def II(): re...
false
7.5
[ "- # 負: ルートで値は木の深さを表す", "+ # 負: ルートで値は木のサイズを表す", "- def unite(self, x: int, y: int) -> None:", "- root_x, root_y = self.find(x), self.find(y)", "- if root_x != root_y:", "- if self.nodes[root_x] != self.nodes[root_y]: # グラフの高さが異なる場合", "- # 木のランクが高い方のルートに...
false
0.079785
0.090693
0.879726
[ "s311592813", "s086618242" ]
u638456847
p02679
python
s856363272
s524650998
678
618
72,960
72,812
Accepted
Accepted
8.85
from math import gcd from collections import Counter import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines MOD = 10**9+7 def main(): N,*ab = list(map(int, read().split())) ab_zero = 0 ratio = [] for a, b in zip(*[iter(ab)]*2): if a == 0 ...
from math import gcd from collections import Counter import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines MOD = 10**9+7 def main(): N,*ab = list(map(int, read().split())) ab_zero = 0 ratio = [] for a, b in zip(*[iter(ab)]*2): if a == 0 ...
54
54
1,111
1,256
from math import gcd from collections import Counter import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines MOD = 10**9 + 7 def main(): N, *ab = list(map(int, read().split())) ab_zero = 0 ratio = [] for a, b in zip(*[iter(ab)] * 2): if a == 0 and b == 0...
from math import gcd from collections import Counter import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines MOD = 10**9 + 7 def main(): N, *ab = list(map(int, read().split())) ab_zero = 0 ratio = [] for a, b in zip(*[iter(ab)] * 2): if a == 0 and b == 0...
false
0
[ "+ if b < 0:", "+ a, b = -a, -b", "+ if b == 0:", "+ a = 1", "- if (-a, -b) in s:", "- v += s[(-a, -b)]", "- s[(-a, -b)] = 0", "- inv = 0", "- inv += s[(-b, a)]", "+ bad *= (pow(2, v, MOD)...
false
0.048306
0.046135
1.047052
[ "s856363272", "s524650998" ]
u119148115
p03682
python
s557650076
s623162804
1,999
908
139,608
121,084
Accepted
Accepted
54.58
class Kruskal(): def __init__(self,n): self.e = [] self.par = [i for i in range(n+1)] #親のノード番号 self.rank = [0]*(n+1) def add(self,u,v,d): #クラスカル法で考えるのは無向グラフ self.e.append([u,v,d]) def find(self,x): #xの根のノード番号 if self.par[x] == x: return x ...
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
55
72
1,475
1,925
class Kruskal: def __init__(self, n): self.e = [] self.par = [i for i in range(n + 1)] # 親のノード番号 self.rank = [0] * (n + 1) def add(self, u, v, d): # クラスカル法で考えるのは無向グラフ self.e.append([u, v, d]) def find(self, x): # xの根のノード番号 if self.par[x] == x: return ...
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
false
23.611111
[ "+import sys", "+", "+sys.setrecursionlimit(10**7)", "+", "+", "+def I():", "+ return int(sys.stdin.readline().rstrip())", "+", "+", "+def MI():", "+ return list(map(int, sys.stdin.readline().rstrip().split()))", "+", "+", "+def LI():", "+ return list(map(int, sys.stdin.readline...
false
0.040682
0.060395
0.673605
[ "s557650076", "s623162804" ]
u747602774
p02793
python
s468475648
s714930446
1,315
965
17,448
4,084
Accepted
Accepted
26.62
#べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い) def modinv(a,m): return pow(a,m-2,m) #n以下の素数列挙(O(nlog(n)) def primes(n): ass = {} is_prime = [True for _ in range(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]: c...
#a,bの最大公約数 def gcd(a,b): while b: a,b = b,a%b return a #a,bの最小公倍数 def lcm(a,b): return a*b//gcd(a,b) #べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い) def modinv2(a,m): return pow(a,m-2,m) N = int(eval(input())) A = list(map(int,input().split())) P = 10**9+7 if N == 1: ...
57
44
1,195
729
# べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い) def modinv(a, m): return pow(a, m - 2, m) # n以下の素数列挙(O(nlog(n)) def primes(n): ass = {} is_prime = [True for _ in range(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]: ...
# a,bの最大公約数 def gcd(a, b): while b: a, b = b, a % b return a # a,bの最小公倍数 def lcm(a, b): return a * b // gcd(a, b) # べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い) def modinv2(a, m): return pow(a, m - 2, m) N = int(eval(input())) A = list(map(int, input().split())) P = 10**9 + 7 if N == 1:...
false
22.807018
[ "-# べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い)", "-def modinv(a, m):", "- return pow(a, m - 2, m)", "+# a,bの最大公約数", "+def gcd(a, b):", "+ while b:", "+ a, b = b, a % b", "+ return a", "-# n以下の素数列挙(O(nlog(n))", "-def primes(n):", "- ass = {}", "- is_prime = [True for ...
false
0.470857
0.105202
4.475739
[ "s468475648", "s714930446" ]
u864197622
p02794
python
s460839209
s856113782
1,352
290
58,844
56,668
Accepted
Accepted
78.55
N = int(eval(input())) X = [[] for i in range(N)] for i in range(N-1): x, y = list(map(int, input().split())) X[x-1].append(y-1) X[y-1].append(x-1) P = [-1] * N DE = [0] * N Q = [0] while Q: i = Q.pop() for a in X[i][::-1]: if a != P[i]: P[a] = i DE[a]...
N = int(eval(input())) X = [[] for i in range(N)] for i in range(N-1): x, y = list(map(int, input().split())) X[x-1].append(y-1) X[y-1].append(x-1) P = [-1] * N DE = [0] * N Q = [0] while Q: i = Q.pop() for a in X[i][::-1]: if a != P[i]: P[a] = i DE[a]...
64
70
1,316
1,418
N = int(eval(input())) X = [[] for i in range(N)] for i in range(N - 1): x, y = list(map(int, input().split())) X[x - 1].append(y - 1) X[y - 1].append(x - 1) P = [-1] * N DE = [0] * N Q = [0] while Q: i = Q.pop() for a in X[i][::-1]: if a != P[i]: P[a] = i DE[a] = DE[...
N = int(eval(input())) X = [[] for i in range(N)] for i in range(N - 1): x, y = list(map(int, input().split())) X[x - 1].append(y - 1) X[y - 1].append(x - 1) P = [-1] * N DE = [0] * N Q = [0] while Q: i = Q.pop() for a in X[i][::-1]: if a != P[i]: P[a] = i DE[a] = DE[...
false
8.571429
[ "-BC = [0] * (1 << M)", "-for m in range(1, 1 << M):", "+BC = [0] * (1 << 20)", "+for m in range(1, 1 << 20):", "- CC[N - 1 - bin(Z[m]).count(\"1\")] += 1 if BC[m] % 2 == 0 else -1", "+ aa = Z[m]", "+ bc = BC[aa % (1 << 10)]", "+ aa >>= 10", "+ bc += BC[aa % (1 << 20)]", "+ aa >>...
false
0.100784
0.400473
0.251664
[ "s460839209", "s856113782" ]
u163320134
p03721
python
s014599101
s296000188
460
321
29,912
5,736
Accepted
Accepted
30.22
n,k=list(map(int,input().split())) arr=[list(map(int,input().split())) for _ in range(n)] arr=sorted(arr, key=lambda x:x[0]) sum=0 for i in range(n): if sum<k<=sum+arr[i][1]: print((arr[i][0])) sum=sum+arr[i][1]
n,k=list(map(int,input().split())) cnt=[0]*(10**5+1) for _ in range(n): a,b=list(map(int,input().split())) cnt[a]+=b tmp=0 for i in range(10**5+1): tmp+=cnt[i] if tmp>=k: print(i) break
8
11
218
199
n, k = list(map(int, input().split())) arr = [list(map(int, input().split())) for _ in range(n)] arr = sorted(arr, key=lambda x: x[0]) sum = 0 for i in range(n): if sum < k <= sum + arr[i][1]: print((arr[i][0])) sum = sum + arr[i][1]
n, k = list(map(int, input().split())) cnt = [0] * (10**5 + 1) for _ in range(n): a, b = list(map(int, input().split())) cnt[a] += b tmp = 0 for i in range(10**5 + 1): tmp += cnt[i] if tmp >= k: print(i) break
false
27.272727
[ "-arr = [list(map(int, input().split())) for _ in range(n)]", "-arr = sorted(arr, key=lambda x: x[0])", "-sum = 0", "-for i in range(n):", "- if sum < k <= sum + arr[i][1]:", "- print((arr[i][0]))", "- sum = sum + arr[i][1]", "+cnt = [0] * (10**5 + 1)", "+for _ in range(n):", "+ a,...
false
0.155772
0.183603
0.848415
[ "s014599101", "s296000188" ]
u268822556
p02683
python
s364601666
s573247194
96
31
9,112
9,284
Accepted
Accepted
67.71
N, M, X = list(map(int, input().split())) book_lists = [list(map(int, input().split())) for i in range(N)] max_cost = 10**5*12+1 min_cost = max_cost for i in range(1, 2**N): score_list = [0 for _ in range(M)] cost = 0 for j in range(N): if i >> j & 1: cost += book_lists[j][0] ...
def saiki(i,cost,score_list): if i == N: if min(score_list) >= X: ans.append(cost) else: temp = [score_list[j]+book_lists[i][j+1] for j in range(M)] saiki(i+1,cost,score_list) saiki(i+1,cost+book_lists[i][0],temp) N,M,X = list(map(int,input().split())) boo...
17
14
523
441
N, M, X = list(map(int, input().split())) book_lists = [list(map(int, input().split())) for i in range(N)] max_cost = 10**5 * 12 + 1 min_cost = max_cost for i in range(1, 2**N): score_list = [0 for _ in range(M)] cost = 0 for j in range(N): if i >> j & 1: cost += book_lists[j][0] ...
def saiki(i, cost, score_list): if i == N: if min(score_list) >= X: ans.append(cost) else: temp = [score_list[j] + book_lists[i][j + 1] for j in range(M)] saiki(i + 1, cost, score_list) saiki(i + 1, cost + book_lists[i][0], temp) N, M, X = list(map(int, input().spli...
false
17.647059
[ "+def saiki(i, cost, score_list):", "+ if i == N:", "+ if min(score_list) >= X:", "+ ans.append(cost)", "+ else:", "+ temp = [score_list[j] + book_lists[i][j + 1] for j in range(M)]", "+ saiki(i + 1, cost, score_list)", "+ saiki(i + 1, cost + book_lists[i][...
false
0.037129
0.037039
1.002439
[ "s364601666", "s573247194" ]
u063052907
p03854
python
s946930153
s422736643
41
19
3,188
3,188
Accepted
Accepted
53.66
S = eval(input()) lst_str = ["maerd", "remaerd", "esare", "resare"] char = "" for c in S[::-1]: char += c if char in lst_str: char = "" if char: print("NO") else: print("YES")
S = eval(input()) char = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") if char: print("NO") else: print("YES")
12
7
206
162
S = eval(input()) lst_str = ["maerd", "remaerd", "esare", "resare"] char = "" for c in S[::-1]: char += c if char in lst_str: char = "" if char: print("NO") else: print("YES")
S = eval(input()) char = ( S.replace("eraser", "") .replace("erase", "") .replace("dreamer", "") .replace("dream", "") ) if char: print("NO") else: print("YES")
false
41.666667
[ "-lst_str = [\"maerd\", \"remaerd\", \"esare\", \"resare\"]", "-char = \"\"", "-for c in S[::-1]:", "- char += c", "- if char in lst_str:", "- char = \"\"", "+char = (", "+ S.replace(\"eraser\", \"\")", "+ .replace(\"erase\", \"\")", "+ .replace(\"dreamer\", \"\")", "+ ....
false
0.034616
0.041045
0.843371
[ "s946930153", "s422736643" ]
u044952145
p03854
python
s705937789
s519512242
30
19
3,188
3,188
Accepted
Accepted
36.67
S = input()[::-1] i = 0 ls = len(S) accept = True while ls > i: if S[i: i+5] == "maerd" or S[i: i+5] == "esare": i += 5 elif S[i: i+6] == "resare": i += 6 elif S[i: i+7] == "remaerd": i += 7 else: accept = False break if accept: print("YES")...
S = eval(input()) result = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") if len(result) == 0: print("YES") else: print("NO")
20
7
344
176
S = input()[::-1] i = 0 ls = len(S) accept = True while ls > i: if S[i : i + 5] == "maerd" or S[i : i + 5] == "esare": i += 5 elif S[i : i + 6] == "resare": i += 6 elif S[i : i + 7] == "remaerd": i += 7 else: accept = False break if accept: print("YES") else: ...
S = eval(input()) result = ( S.replace("eraser", "") .replace("erase", "") .replace("dreamer", "") .replace("dream", "") ) if len(result) == 0: print("YES") else: print("NO")
false
65
[ "-S = input()[::-1]", "-i = 0", "-ls = len(S)", "-accept = True", "-while ls > i:", "- if S[i : i + 5] == \"maerd\" or S[i : i + 5] == \"esare\":", "- i += 5", "- elif S[i : i + 6] == \"resare\":", "- i += 6", "- elif S[i : i + 7] == \"remaerd\":", "- i += 7", "- ...
false
0.035984
0.075692
0.475408
[ "s705937789", "s519512242" ]
u811733736
p00092
python
s576872602
s943457904
3,510
2,800
35,048
34,264
Accepted
Accepted
20.23
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092 """ import sys def find_square0(data): max_size = 0 dp = [] # dp??¨???2?¬?????????? # '.'????????????1??????'*'????????????0???????????? for row in data: temp = [] for c in row: ...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092 """ import sys def find_square0(data): max_size = 0 dp = [] # dp??¨???2?¬?????????? # '.'????????????1??????'*'????????????0???????????? for row in data: temp = [] for c in row: ...
105
105
3,266
3,266
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092 """ import sys def find_square0(data): max_size = 0 dp = [] # dp??¨???2?¬?????????? # '.'????????????1??????'*'????????????0???????????? for row in data: temp = [] for c in row: if c ...
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092 """ import sys def find_square0(data): max_size = 0 dp = [] # dp??¨???2?¬?????????? # '.'????????????1??????'*'????????????0???????????? for row in data: temp = [] for c in row: if c ...
false
0
[ "- result = find_square0(data)", "+ result = find_square2(data)" ]
false
0.098733
0.114531
0.862062
[ "s576872602", "s943457904" ]
u353919145
p03325
python
s378710938
s470721101
76
67
3,460
3,460
Accepted
Accepted
11.84
n = int(input()) a = list(map(int, input().split())) count = 0 for i in range(n): curr = a[i] while True: if curr % 2 == 0: curr /= 2 count += 1 else: break print(count)
c = eval(input()) m = list(map(int, input().split())) conte = 0 for i in m: while(i%2 == 0): conte += 1 i /= 2 print(conte)
14
14
246
139
n = int(input()) a = list(map(int, input().split())) count = 0 for i in range(n): curr = a[i] while True: if curr % 2 == 0: curr /= 2 count += 1 else: break print(count)
c = eval(input()) m = list(map(int, input().split())) conte = 0 for i in m: while i % 2 == 0: conte += 1 i /= 2 print(conte)
false
0
[ "-n = int(input())", "-a = list(map(int, input().split()))", "-count = 0", "-for i in range(n):", "- curr = a[i]", "- while True:", "- if curr % 2 == 0:", "- curr /= 2", "- count += 1", "- else:", "- break", "-print(count)", "+c = eval(inp...
false
0.037379
0.068704
0.544059
[ "s378710938", "s470721101" ]
u585819925
p02837
python
s516073669
s570429818
1,640
1,457
3,064
3,064
Accepted
Accepted
11.16
n = int(eval(input())) g = [[-1 for j in range(n)] for i in range(n)] for i in range(n): a = int(eval(input())) for _ in range(a): x, y = list(map(int, input().split())) g[i][x-1] = y ans = 0 for s in range(2**n): ok = True for i in range(n): if (s>>i&1) == 1: for j in range(n): if g...
n = int(eval(input())) g = [[-1]*n for i in range(n)] for i in range(n): a = int(eval(input())) for _ in range(a): x, y = list(map(int, input().split())) g[i][x-1] = y ans = 0 for s in range(2**n): ok = True for i in range(n): if (s>>i&1) == 1: for j in range(n): if g[i][j] == -1: co...
22
22
417
409
n = int(eval(input())) g = [[-1 for j in range(n)] for i in range(n)] for i in range(n): a = int(eval(input())) for _ in range(a): x, y = list(map(int, input().split())) g[i][x - 1] = y ans = 0 for s in range(2**n): ok = True for i in range(n): if (s >> i & 1) == 1: f...
n = int(eval(input())) g = [[-1] * n for i in range(n)] for i in range(n): a = int(eval(input())) for _ in range(a): x, y = list(map(int, input().split())) g[i][x - 1] = y ans = 0 for s in range(2**n): ok = True for i in range(n): if (s >> i & 1) == 1: for j in range(...
false
0
[ "-g = [[-1 for j in range(n)] for i in range(n)]", "+g = [[-1] * n for i in range(n)]", "- if g[i][j] != -1 and (s >> j & 1) != g[i][j]:", "+ if g[i][j] == -1:", "+ continue", "+ if (s >> j & 1) != g[i][j]:" ]
false
0.075713
0.03872
1.955397
[ "s516073669", "s570429818" ]
u821989875
p03557
python
s724805391
s215665327
854
347
24,264
22,720
Accepted
Accepted
59.37
# coding: utf-8 n = int(eval(input())) al = sorted(list(int(i) for i in input().split())) bl = sorted(list(int(i) for i in input().split())) cl = sorted(list(int(i) for i in input().split())) ans = 0 def low_left(a, key): left = -1 right = len(a) while right - left > 1: center = (left + ...
import bisect n = int(eval(input())) al, bl, cl = list(sorted(map(int, input().split())) for i in range(3)) ans = 0 for key in bl: top = bisect.bisect_left(al, key) btm = len(cl) - bisect.bisect_right(cl, key) ans += top * btm print(ans)
33
12
780
257
# coding: utf-8 n = int(eval(input())) al = sorted(list(int(i) for i in input().split())) bl = sorted(list(int(i) for i in input().split())) cl = sorted(list(int(i) for i in input().split())) ans = 0 def low_left(a, key): left = -1 right = len(a) while right - left > 1: center = (left + right) // ...
import bisect n = int(eval(input())) al, bl, cl = list(sorted(map(int, input().split())) for i in range(3)) ans = 0 for key in bl: top = bisect.bisect_left(al, key) btm = len(cl) - bisect.bisect_right(cl, key) ans += top * btm print(ans)
false
63.636364
[ "-# coding: utf-8", "+import bisect", "+", "-al = sorted(list(int(i) for i in input().split()))", "-bl = sorted(list(int(i) for i in input().split()))", "-cl = sorted(list(int(i) for i in input().split()))", "+al, bl, cl = list(sorted(map(int, input().split())) for i in range(3))", "-", "-", "-def...
false
0.040959
0.041302
0.991698
[ "s724805391", "s215665327" ]
u242580186
p03167
python
s898179682
s488640015
199
122
92,820
83,092
Accepted
Accepted
38.69
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) from heapq import heappush, heappop, heapify import math from math import gcd import itertools as it import collections from collections import deque def inp(): return int(input()) def inpl(): return list(map(int, input().split())...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) from heapq import heappush, heappop, heapify import math from math import gcd import itertools as it import collections from collections import deque def inp(): return int(input()) def inpl(): return list(map(int, input().split())...
49
38
1,210
797
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) from heapq import heappush, heappop, heapify import math from math import gcd import itertools as it import collections from collections import deque def inp(): return int(input()) def inpl(): return list(map(int, input().split())) def _d...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) from heapq import heappush, heappop, heapify import math from math import gcd import itertools as it import collections from collections import deque def inp(): return int(input()) def inpl(): return list(map(int, input().split())) def _d...
false
22.44898
[ "-flag = [[False] * W for i in range(H)]", "-_debug(a)", "-for i in range(max(H, W)):", "- if i < H:", "- for j in range(W):", "- if a[i][j] == \"#\" or flag[i][j]:", "- continue", "- flag[i][j] = True", "- for x, y in ((0, 1), (1, 0)):", "...
false
0.072993
0.126513
0.576965
[ "s898179682", "s488640015" ]
u312025627
p03700
python
s066345746
s519284327
1,451
632
53,172
122,840
Accepted
Accepted
56.44
def main(): N, A, B = (int(i) for i in input().split()) H = [int(eval(input())) for i in range(N)] def is_ok(x): y = 0 # 中心爆破必要回数 for i, h in enumerate(H): if h - x*B <= 0: continue le = 0 ri = 10**9 + 1 while ri - ...
def main(): N, A, B = (int(i) for i in input().split()) H = [int(eval(input())) for i in range(N)] def is_ok(H, mid): H = [h - mid*B for h in H] need = 0 for h in H: if h > 0: need += (h + (A - B) - 1)//(A - B) if need <= mid: ...
39
31
999
730
def main(): N, A, B = (int(i) for i in input().split()) H = [int(eval(input())) for i in range(N)] def is_ok(x): y = 0 # 中心爆破必要回数 for i, h in enumerate(H): if h - x * B <= 0: continue le = 0 ri = 10**9 + 1 while ri - le > 1: ...
def main(): N, A, B = (int(i) for i in input().split()) H = [int(eval(input())) for i in range(N)] def is_ok(H, mid): H = [h - mid * B for h in H] need = 0 for h in H: if h > 0: need += (h + (A - B) - 1) // (A - B) if need <= mid: retu...
false
20.512821
[ "- def is_ok(x):", "- y = 0 # 中心爆破必要回数", "- for i, h in enumerate(H):", "- if h - x * B <= 0:", "- continue", "- le = 0", "- ri = 10**9 + 1", "- while ri - le > 1:", "- mid = le + ((ri - le) // 2)", "- ...
false
0.038738
0.03732
1.037999
[ "s066345746", "s519284327" ]
u102126195
p03013
python
s410713796
s606480098
522
197
50,848
7,816
Accepted
Accepted
62.26
n, m = list(map(int, input().split())) a = [0 for _ in range(n + 1)] for i in range(m): A = int(eval(input())) a[A] = 1 tmp = [0 for _ in range(n + 1)] tmp[0] = 1 for i in range(1, n + 1): if a[i] == 1: tmp[i] = 0 else: if i - 2 >= 0: tmp[i] += tmp[i - 2] ...
n, m = list(map(int, input().split())) a = [0 for _ in range(n + 1)] for i in range(m): A = int(eval(input())) a[A] = 1 tmp = [0 for _ in range(n + 1)] tmp[0] = 1 for i in range(1, n + 1): if a[i] == 1: tmp[i] = 0 else: if i - 2 >= 0: tmp[i] += tmp[i - 2] ...
21
20
424
421
n, m = list(map(int, input().split())) a = [0 for _ in range(n + 1)] for i in range(m): A = int(eval(input())) a[A] = 1 tmp = [0 for _ in range(n + 1)] tmp[0] = 1 for i in range(1, n + 1): if a[i] == 1: tmp[i] = 0 else: if i - 2 >= 0: tmp[i] += tmp[i - 2] if i - 1 >= ...
n, m = list(map(int, input().split())) a = [0 for _ in range(n + 1)] for i in range(m): A = int(eval(input())) a[A] = 1 tmp = [0 for _ in range(n + 1)] tmp[0] = 1 for i in range(1, n + 1): if a[i] == 1: tmp[i] = 0 else: if i - 2 >= 0: tmp[i] += tmp[i - 2] if i - 1 >= ...
false
4.761905
[ "-print((tmp[-1] % 1000000007))", "+print((tmp[n] % 1000000007))" ]
false
0.037225
0.043347
0.858759
[ "s410713796", "s606480098" ]
u170201762
p03082
python
s832732147
s849939154
1,891
1,673
225,548
225,672
Accepted
Accepted
11.53
N,X = list(map(int,input().split())) S = list(map(int,input().split())) S.sort() mod = 10**9+7 dp = [[x]+[0]*N for x in range(X+1)] for x in range(X+1): for n in range(1,N+1): dp[x][n] = (dp[x%S[n-1]][n-1] + (n-1)*dp[x][n-1])%mod print((dp[X][N]))
N,X = list(map(int,input().split())) S = list(map(int,input().split())) S.sort() mod = 10**9+7 dp = [[x]+[0]*N for x in range(X+1)] for n in range(1,N+1): for x in range(X+1): dp[x][n] = (dp[x%S[n-1]][n-1] + (n-1)*dp[x][n-1])%mod print((dp[X][N]))
11
11
263
263
N, X = list(map(int, input().split())) S = list(map(int, input().split())) S.sort() mod = 10**9 + 7 dp = [[x] + [0] * N for x in range(X + 1)] for x in range(X + 1): for n in range(1, N + 1): dp[x][n] = (dp[x % S[n - 1]][n - 1] + (n - 1) * dp[x][n - 1]) % mod print((dp[X][N]))
N, X = list(map(int, input().split())) S = list(map(int, input().split())) S.sort() mod = 10**9 + 7 dp = [[x] + [0] * N for x in range(X + 1)] for n in range(1, N + 1): for x in range(X + 1): dp[x][n] = (dp[x % S[n - 1]][n - 1] + (n - 1) * dp[x][n - 1]) % mod print((dp[X][N]))
false
0
[ "-for x in range(X + 1):", "- for n in range(1, N + 1):", "+for n in range(1, N + 1):", "+ for x in range(X + 1):" ]
false
0.344266
0.676701
0.508742
[ "s832732147", "s849939154" ]
u997641430
p03076
python
s631767997
s248425029
19
17
3,060
3,064
Accepted
Accepted
10.53
A = [int(eval(input())) for i in range(5)] B = [(10 - a % 10) % 10 for a in A] print((sum(A) + sum(B) - max(B)))
A = [int(eval(input())) for i in range(5)] # A = [101, 86, 119, 108, 57] # A = [29, 20, 7, 35, 120] # A = [123, 123, 123, 123, 123] B = [(10-a % 10) % 10 for a in A] C = [-(-a//10)*10 for a in A] print((sum(C)-max(B)))
3
7
107
217
A = [int(eval(input())) for i in range(5)] B = [(10 - a % 10) % 10 for a in A] print((sum(A) + sum(B) - max(B)))
A = [int(eval(input())) for i in range(5)] # A = [101, 86, 119, 108, 57] # A = [29, 20, 7, 35, 120] # A = [123, 123, 123, 123, 123] B = [(10 - a % 10) % 10 for a in A] C = [-(-a // 10) * 10 for a in A] print((sum(C) - max(B)))
false
57.142857
[ "+# A = [101, 86, 119, 108, 57]", "+# A = [29, 20, 7, 35, 120]", "+# A = [123, 123, 123, 123, 123]", "-print((sum(A) + sum(B) - max(B)))", "+C = [-(-a // 10) * 10 for a in A]", "+print((sum(C) - max(B)))" ]
false
0.077638
0.177732
0.436825
[ "s631767997", "s248425029" ]
u063896676
p03240
python
s411810053
s025371384
112
65
3,064
3,064
Accepted
Accepted
41.96
# -*- coding: utf-8 -*- N = int(eval(input())) x = [None] * N y = [None] * N h = [None] * N for i in range(N): x[i], y[i], h[i] = list(map(int, input().split())) def distance(a,b): a_x = a[0] a_y = a[1] b_x = b[0] b_y = b[1] return abs(a_x - b_x) + abs(a_y - b_y) for cx ...
# coding: utf-8 # https://atcoder.jp/contests/abc112 def main(): N = int(eval(input())) x, y, h = [None] * N, [None] * N, [None] * N for i in range(N): x[i], y[i], h[i] = list(map(int, input().split())) for cx in range(0, 101): for cy in range(0, 101): fi...
38
43
854
1,108
# -*- coding: utf-8 -*- N = int(eval(input())) x = [None] * N y = [None] * N h = [None] * N for i in range(N): x[i], y[i], h[i] = list(map(int, input().split())) def distance(a, b): a_x = a[0] a_y = a[1] b_x = b[0] b_y = b[1] return abs(a_x - b_x) + abs(a_y - b_y) for cx in range(101): f...
# coding: utf-8 # https://atcoder.jp/contests/abc112 def main(): N = int(eval(input())) x, y, h = [None] * N, [None] * N, [None] * N for i in range(N): x[i], y[i], h[i] = list(map(int, input().split())) for cx in range(0, 101): for cy in range(0, 101): first = True ...
false
11.627907
[ "-# -*- coding: utf-8 -*-", "-N = int(eval(input()))", "-x = [None] * N", "-y = [None] * N", "-h = [None] * N", "-for i in range(N):", "- x[i], y[i], h[i] = list(map(int, input().split()))", "+# coding: utf-8", "+# https://atcoder.jp/contests/abc112", "+def main():", "+ N = int(eval(input(...
false
0.061734
0.046839
1.318018
[ "s411810053", "s025371384" ]
u773265208
p02897
python
s400413403
s654309131
182
17
38,384
2,940
Accepted
Accepted
90.66
n = int(eval(input())) if n % 2 == 0: print((0.5)) else: print(((n//2 + 1 )/ n))
n=int(eval(input())) if n % 2 == 0: print((0.5)) else: print((1-(n//2)/n))
6
6
79
73
n = int(eval(input())) if n % 2 == 0: print((0.5)) else: print(((n // 2 + 1) / n))
n = int(eval(input())) if n % 2 == 0: print((0.5)) else: print((1 - (n // 2) / n))
false
0
[ "- print(((n // 2 + 1) / n))", "+ print((1 - (n // 2) / n))" ]
false
0.03479
0.061949
0.561592
[ "s400413403", "s654309131" ]
u729133443
p03161
python
s574004608
s556543468
1,857
604
13,876
59,948
Accepted
Accepted
67.47
if __name__=='__main__': n,k,*h=list(map(int,open(0).read().split())) dp=[0] for i,t in enumerate(h): if i: j=max(0,i-k) dp.append(min(v+abs(t-w)for v,w in zip(dp[j:i],h[j:i]))) print((dp[-1]))
n,k,*h=list(map(int,open(0).read().split()));d=[0]*n for i in range(1,n):j=max(0,i-k);d[i]=(min(v+abs(h[i]-w)for v,w in zip(d[j:i],h[j:i]))) print((d[-1]))
8
3
240
149
if __name__ == "__main__": n, k, *h = list(map(int, open(0).read().split())) dp = [0] for i, t in enumerate(h): if i: j = max(0, i - k) dp.append(min(v + abs(t - w) for v, w in zip(dp[j:i], h[j:i]))) print((dp[-1]))
n, k, *h = list(map(int, open(0).read().split())) d = [0] * n for i in range(1, n): j = max(0, i - k) d[i] = min(v + abs(h[i] - w) for v, w in zip(d[j:i], h[j:i])) print((d[-1]))
false
62.5
[ "-if __name__ == \"__main__\":", "- n, k, *h = list(map(int, open(0).read().split()))", "- dp = [0]", "- for i, t in enumerate(h):", "- if i:", "- j = max(0, i - k)", "- dp.append(min(v + abs(t - w) for v, w in zip(dp[j:i], h[j:i])))", "- print((dp[-1]))", "+...
false
0.187495
0.042368
4.425438
[ "s574004608", "s556543468" ]
u958958520
p03479
python
s790336202
s130437535
29
26
8,964
9,160
Accepted
Accepted
10.34
X, Y = list(map(int, input().split())) ans = 0 math = X while(math <= Y): ans += 1 math = math * 2 print(ans)
X, Y = list(map(int, input().split())) ans = [] num = X while(num <= Y): ans.append(num) num *= 2 print((len(ans)))
9
9
123
128
X, Y = list(map(int, input().split())) ans = 0 math = X while math <= Y: ans += 1 math = math * 2 print(ans)
X, Y = list(map(int, input().split())) ans = [] num = X while num <= Y: ans.append(num) num *= 2 print((len(ans)))
false
0
[ "-ans = 0", "-math = X", "-while math <= Y:", "- ans += 1", "- math = math * 2", "-print(ans)", "+ans = []", "+num = X", "+while num <= Y:", "+ ans.append(num)", "+ num *= 2", "+print((len(ans)))" ]
false
0.113474
0.064133
1.769358
[ "s790336202", "s130437535" ]
u324197506
p02691
python
s279256842
s804344221
570
527
87,412
87,488
Accepted
Accepted
7.54
import sys input = sys.stdin.readline N = int(eval(input())) heights = list(map(int, input().split())) cnt_height_plus_ind = {} cnt_height_minus_ind = {} cnt_ind_minus_height = {} cnt_minus_height_minus_ind = {} for ind in range(N): height = heights[ind] if ind - height not in cnt_ind_minu...
import sys input = sys.stdin.readline N = int(eval(input())) heights = list(map(int, input().split())) cnt_height_plus_ind = {} cnt_height_minus_ind = {} cnt_ind_minus_height = {} cnt_minus_height_minus_ind = {} for ind in range(N): height = heights[ind] if ind - height not in cnt_ind_minu...
43
43
1,194
1,194
import sys input = sys.stdin.readline N = int(eval(input())) heights = list(map(int, input().split())) cnt_height_plus_ind = {} cnt_height_minus_ind = {} cnt_ind_minus_height = {} cnt_minus_height_minus_ind = {} for ind in range(N): height = heights[ind] if ind - height not in cnt_ind_minus_height: cnt...
import sys input = sys.stdin.readline N = int(eval(input())) heights = list(map(int, input().split())) cnt_height_plus_ind = {} cnt_height_minus_ind = {} cnt_ind_minus_height = {} cnt_minus_height_minus_ind = {} for ind in range(N): height = heights[ind] if ind - height not in cnt_ind_minus_height: cnt...
false
0
[ "-for val in cnt_height_minus_ind:", "- if val in cnt_minus_height_minus_ind:", "- ans += cnt_height_minus_ind[val] * cnt_minus_height_minus_ind[val]", "+# for val in cnt_height_minus_ind:", "+# if val in cnt_minus_height_minus_ind:", "+# ans += cnt_height_minus_ind[val] * cnt_minus_he...
false
0.04828
0.078406
0.615771
[ "s279256842", "s804344221" ]
u493813116
p03805
python
s321675358
s422744145
37
19
3,064
3,064
Accepted
Accepted
48.65
N, M = list(map(int, input().split())) E = [[] for _ in range(N)] dp = {} for _ in range(M): a, b = list(map(int, input().split())) E[a-1].append(b-1) E[b-1].append(a-1) S = 1 G = (1 << N) - 1 def is_visited(v: int, path: int): return path & (1 << v) def visit(v: int, path: int): ...
N, M = list(map(int, input().split())) E = [[] for _ in range(N)] dp = {} for _ in range(M): a, b = list(map(int, input().split())) E[a-1].append(b-1) E[b-1].append(a-1) S = 1 G = (1 << N) - 1 def is_visited(v: int, path: int): return path & (1 << v) def visit(v: int, path: int): ...
36
39
608
637
N, M = list(map(int, input().split())) E = [[] for _ in range(N)] dp = {} for _ in range(M): a, b = list(map(int, input().split())) E[a - 1].append(b - 1) E[b - 1].append(a - 1) S = 1 G = (1 << N) - 1 def is_visited(v: int, path: int): return path & (1 << v) def visit(v: int, path: int): return ...
N, M = list(map(int, input().split())) E = [[] for _ in range(N)] dp = {} for _ in range(M): a, b = list(map(int, input().split())) E[a - 1].append(b - 1) E[b - 1].append(a - 1) S = 1 G = (1 << N) - 1 def is_visited(v: int, path: int): return path & (1 << v) def visit(v: int, path: int): return ...
false
7.692308
[ "- if (u, path) in dp:", "- return dp[(u, path)]", "- return sum(count(v, visit(v, path)) for v in E[u] if not is_visited(v, path))", "+ k = (u, path)", "+ if k in dp:", "+ return dp[k]", "+ s = sum(count(v, visit(v, path)) for v in E[u] if not is_visited(v, path))", "+ ...
false
0.088672
0.062157
1.426571
[ "s321675358", "s422744145" ]
u445624660
p02866
python
s803534661
s428312164
247
191
68,140
23,752
Accepted
Accepted
22.67
# 最初dは与えられる距離だと思ってて「サンプルケース1は3じゃね?」とか思ってて2時間経過した # 落ち着いて読んだら最小の辺の数だった from collections import Counter n = int(eval(input())) arr = list(map(int, input().split())) if arr[0] != 0: print((0)) exit() arr = sorted(list(Counter(arr).items()), key=lambda x: x[0]) if arr[0][1] > 1: print((0)) ex...
n = int(eval(input())) d = {} mod = 998244353 max_v = 0 lis = list(map(int, input().split())) # 先頭はかならず0 if lis[0] != 0: print((0)) exit() for v in lis: if v not in d: d[v] = 1 else: d[v] += 1 max_v = max(max_v, v) # 0はひとつだけ if 0 not in d or d[0] > 1: print...
27
32
523
551
# 最初dは与えられる距離だと思ってて「サンプルケース1は3じゃね?」とか思ってて2時間経過した # 落ち着いて読んだら最小の辺の数だった from collections import Counter n = int(eval(input())) arr = list(map(int, input().split())) if arr[0] != 0: print((0)) exit() arr = sorted(list(Counter(arr).items()), key=lambda x: x[0]) if arr[0][1] > 1: print((0)) exit() mod = 998...
n = int(eval(input())) d = {} mod = 998244353 max_v = 0 lis = list(map(int, input().split())) # 先頭はかならず0 if lis[0] != 0: print((0)) exit() for v in lis: if v not in d: d[v] = 1 else: d[v] += 1 max_v = max(max_v, v) # 0はひとつだけ if 0 not in d or d[0] > 1: print((0)) exit() ans = ...
false
15.625
[ "-# 最初dは与えられる距離だと思ってて「サンプルケース1は3じゃね?」とか思ってて2時間経過した", "-# 落ち着いて読んだら最小の辺の数だった", "-from collections import Counter", "-", "-arr = list(map(int, input().split()))", "-if arr[0] != 0:", "+d = {}", "+mod = 998244353", "+max_v = 0", "+lis = list(map(int, input().split()))", "+# 先頭はかならず0", "+if lis[0]...
false
0.042954
0.042788
1.003899
[ "s803534661", "s428312164" ]
u102461423
p02624
python
s049861616
s276421978
548
206
106,232
27,408
Accepted
Accepted
62.41
import sys import numba read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @numba.njit('(i8,)', cache=True) def main(N): x = 0 for a in range(1, N+1): for b in range(1, N//a+1): x += a*b return x N = int(read()) pri...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(N): x = 0 for a in range(1, N+1): for b in range(a, N+1, a): x += b return x if sys.argv[-1] == 'ONLINE_JUDGE': import numba from numba.p...
17
30
332
614
import sys import numba read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @numba.njit("(i8,)", cache=True) def main(N): x = 0 for a in range(1, N + 1): for b in range(1, N // a + 1): x += a * b return x N = int(read()) print((ma...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(N): x = 0 for a in range(1, N + 1): for b in range(a, N + 1, a): x += b return x if sys.argv[-1] == "ONLINE_JUDGE": import numba from numba.pycc impor...
false
43.333333
[ "-import numba", "-@numba.njit(\"(i8,)\", cache=True)", "- for b in range(1, N // a + 1):", "- x += a * b", "+ for b in range(a, N + 1, a):", "+ x += b", "+if sys.argv[-1] == \"ONLINE_JUDGE\":", "+ import numba", "+ from numba.pycc import CC", "+", "+ ...
false
0.035117
0.035271
0.995643
[ "s049861616", "s276421978" ]
u952708174
p03031
python
s661237064
s880612924
266
153
17,712
12,260
Accepted
Accepted
42.48
def c_switches(N, M, Switches, P): import numpy as np def rank_matrix(matrix): """mod2 上で行列の階数を求める""" num_row, num_col = matrix.shape[0], matrix.shape[1] rank = 0 for col in range(num_col): # ピボット探し pivot = -1 max_element = 0 # 最大...
def c_switches(N, M, Switches, P): import numpy as np def rank_matrix(matrix): """mod2 上で行列の階数を求める""" num_row, num_col = matrix.shape[0], matrix.shape[1] rank = 0 for col in range(num_col): # ピボット探し pivot = -1 max_element = 0 # 最大...
47
47
1,753
1,753
def c_switches(N, M, Switches, P): import numpy as np def rank_matrix(matrix): """mod2 上で行列の階数を求める""" num_row, num_col = matrix.shape[0], matrix.shape[1] rank = 0 for col in range(num_col): # ピボット探し pivot = -1 max_element = 0 # 最大の要素(1しかないが)が...
def c_switches(N, M, Switches, P): import numpy as np def rank_matrix(matrix): """mod2 上で行列の階数を求める""" num_row, num_col = matrix.shape[0], matrix.shape[1] rank = 0 for col in range(num_col): # ピボット探し pivot = -1 max_element = 0 # 最大の要素(1しかないが)が...
false
0
[ "- matrix[row][col2] = (matrix[row][col2] + matrix[rank][col2]) % 2", "+ matrix[row][col2] = (matrix[row][col2] - matrix[rank][col2]) % 2" ]
false
0.280753
0.238388
1.177714
[ "s661237064", "s880612924" ]
u550279454
p02639
python
s648791878
s060328952
20
18
9,168
9,056
Accepted
Accepted
10
X_s = list(map(int, input().split())) for i in range(len(X_s)): num = X_s[i] if (num == 0): print((i + 1))
X_s = list(map(int, input().split())) for i in range(len(X_s)): num = X_s[i] if (num == 0): print((i + 1)) break
7
8
128
145
X_s = list(map(int, input().split())) for i in range(len(X_s)): num = X_s[i] if num == 0: print((i + 1))
X_s = list(map(int, input().split())) for i in range(len(X_s)): num = X_s[i] if num == 0: print((i + 1)) break
false
12.5
[ "+ break" ]
false
0.037222
0.041422
0.898619
[ "s648791878", "s060328952" ]
u408260374
p00775
python
s583633292
s654109422
140
110
7,652
7,684
Accepted
Accepted
21.43
while True: R, N = list(map(int, input().split())) if not (R | N): break geta = 20 buildings = [0] * (geta * 2) for _ in range(N): xl, xr, h = list(map(int, input().split())) for i in range(xl + geta, xr + geta): buildings[i] = max(buildings[i], h) ...
while True: R, N = list(map(int, input().split())) if not (R | N): break geta = 20 buildings = [0] * (geta * 2) for _ in range(N): xl, xr, h = list(map(int, input().split())) for i in range(xl + geta, xr + geta): buildings[i] = max(buildings[i], h) ...
27
34
863
1,045
while True: R, N = list(map(int, input().split())) if not (R | N): break geta = 20 buildings = [0] * (geta * 2) for _ in range(N): xl, xr, h = list(map(int, input().split())) for i in range(xl + geta, xr + geta): buildings[i] = max(buildings[i], h) left, right...
while True: R, N = list(map(int, input().split())) if not (R | N): break geta = 20 buildings = [0] * (geta * 2) for _ in range(N): xl, xr, h = list(map(int, input().split())) for i in range(xl + geta, xr + geta): buildings[i] = max(buildings[i], h) sun = [0] *...
false
20.588235
[ "+ sun = [0] * (geta * 2)", "+ for i in range(-R + geta, R + geta):", "+ if i < geta:", "+ buildings[i] -= pow(R * R - (i - geta + 1) * (i - geta + 1), 0.5) - R", "+ else:", "+ buildings[i] -= pow(R * R - (i - geta) * (i - geta), 0.5) - R", "- y =...
false
0.037329
0.048113
0.775875
[ "s583633292", "s654109422" ]
u150984829
p00056
python
s097378185
s849602268
1,760
1,440
7,800
8,448
Accepted
Accepted
18.18
from bisect import * from itertools import * n=list(range(50001));a=list(n);a[1]=0 for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i]) p=list(compress(n,a)) for x in iter(input,'0'):x=int(x);print((sum(1 for d in p[:bisect(p,x//2)]if a[x-d])))
import bisect,sys from itertools import * n=list(range(50001));a=list(n);a[1]=0 for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i]) p=list(compress(n,a)) for x in sys.stdin: x=int(x) if x:print((sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d])))
6
8
240
248
from bisect import * from itertools import * n = list(range(50001)) a = list(n) a[1] = 0 for i in range(2, 224): a[i * 2 :: i] = [0] * len(a[i * 2 :: i]) p = list(compress(n, a)) for x in iter(input, "0"): x = int(x) print((sum(1 for d in p[: bisect(p, x // 2)] if a[x - d])))
import bisect, sys from itertools import * n = list(range(50001)) a = list(n) a[1] = 0 for i in range(2, 224): a[i * 2 :: i] = [0] * len(a[i * 2 :: i]) p = list(compress(n, a)) for x in sys.stdin: x = int(x) if x: print((sum(1 for d in p[: bisect.bisect(p, x // 2)] if a[x - d])))
false
25
[ "-from bisect import *", "+import bisect, sys", "-for x in iter(input, \"0\"):", "+for x in sys.stdin:", "- print((sum(1 for d in p[: bisect(p, x // 2)] if a[x - d])))", "+ if x:", "+ print((sum(1 for d in p[: bisect.bisect(p, x // 2)] if a[x - d])))" ]
false
0.041986
0.046947
0.894327
[ "s097378185", "s849602268" ]
u057109575
p02713
python
s599950173
s447242683
541
499
67,604
68,348
Accepted
Accepted
7.76
from math import gcd K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): ans += gcd(i, gcd(k, j)) print(ans)
from math import gcd K = int(eval(input())) ans = 0 for a in range(1, K + 1): for b in range(1, K + 1): for c in range(1, K + 1): ans += gcd(gcd(a, b), c) print(ans)
9
12
192
199
from math import gcd K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(1, K + 1): for k in range(1, K + 1): ans += gcd(i, gcd(k, j)) print(ans)
from math import gcd K = int(eval(input())) ans = 0 for a in range(1, K + 1): for b in range(1, K + 1): for c in range(1, K + 1): ans += gcd(gcd(a, b), c) print(ans)
false
25
[ "-for i in range(1, K + 1):", "- for j in range(1, K + 1):", "- for k in range(1, K + 1):", "- ans += gcd(i, gcd(k, j))", "+for a in range(1, K + 1):", "+ for b in range(1, K + 1):", "+ for c in range(1, K + 1):", "+ ans += gcd(gcd(a, b), c)" ]
false
0.049676
0.051433
0.965832
[ "s599950173", "s447242683" ]
u009961299
p02388
python
s524871965
s719235032
30
20
6,720
5,576
Accepted
Accepted
33.33
print((eval(eval(input())) ** 3))
x = int(eval(input())) print(("%d" % (x ** 3)))
1
3
25
43
print((eval(eval(input())) ** 3))
x = int(eval(input())) print(("%d" % (x**3)))
false
66.666667
[ "-print((eval(eval(input())) ** 3))", "+x = int(eval(input()))", "+print((\"%d\" % (x**3)))" ]
false
0.043186
0.0423
1.020947
[ "s524871965", "s719235032" ]
u818349438
p02947
python
s640453500
s465343935
528
347
47,988
25,020
Accepted
Accepted
34.28
import numpy as np n =int(eval(input())) strl = [list(eval(input())) for i in range(n)] count =0 pt = {} for i in range(n): sal = strl[i] sal.sort() temp = "".join(sal) if temp in list(pt.keys()): tempc = pt[temp] count +=tempc pt[temp]= tempc+1 else: ...
n = int(eval(input())) s = [eval(input())for _ in range(n)] cnt = {} for x in s: p = list(x) p.sort() b = "".join(p) if "".join(p) not in cnt:cnt[b] = 1 else:cnt[b] +=1 ans = 0 for key in cnt: v = cnt[key] ans +=v*(v-1)//2 print(ans)
17
19
327
283
import numpy as np n = int(eval(input())) strl = [list(eval(input())) for i in range(n)] count = 0 pt = {} for i in range(n): sal = strl[i] sal.sort() temp = "".join(sal) if temp in list(pt.keys()): tempc = pt[temp] count += tempc pt[temp] = tempc + 1 else: pt[temp] ...
n = int(eval(input())) s = [eval(input()) for _ in range(n)] cnt = {} for x in s: p = list(x) p.sort() b = "".join(p) if "".join(p) not in cnt: cnt[b] = 1 else: cnt[b] += 1 ans = 0 for key in cnt: v = cnt[key] ans += v * (v - 1) // 2 print(ans)
false
10.526316
[ "-import numpy as np", "-", "-strl = [list(eval(input())) for i in range(n)]", "-count = 0", "-pt = {}", "-for i in range(n):", "- sal = strl[i]", "- sal.sort()", "- temp = \"\".join(sal)", "- if temp in list(pt.keys()):", "- tempc = pt[temp]", "- count += tempc", "...
false
0.112852
0.080714
1.398172
[ "s640453500", "s465343935" ]
u691018832
p03062
python
s591495998
s826817084
77
68
15,020
12,508
Accepted
Accepted
11.69
n = int(eval(input())) a = list(map(int, input().split())) b = 0 ans = 0 for i in range(n): if a[i] < 0: b += 1 a[i] = abs(a[i]) if (0 in a) or ((b % 2) == 0): pass else: ans -= min(a) * 2 ans += sum(a) print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, *a = list(map(int, read().split())) cnt = 0 for i, aa in enumerate(a): if aa < 0: a[i] = -aa cnt += 1 if cnt % 2 == 0: print((sum(a)...
17
16
262
354
n = int(eval(input())) a = list(map(int, input().split())) b = 0 ans = 0 for i in range(n): if a[i] < 0: b += 1 a[i] = abs(a[i]) if (0 in a) or ((b % 2) == 0): pass else: ans -= min(a) * 2 ans += sum(a) print(ans)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) n, *a = list(map(int, read().split())) cnt = 0 for i, aa in enumerate(a): if aa < 0: a[i] = -aa cnt += 1 if cnt % 2 == 0: print((sum(a))) else: pr...
false
5.882353
[ "-n = int(eval(input()))", "-a = list(map(int, input().split()))", "-b = 0", "-ans = 0", "-for i in range(n):", "- if a[i] < 0:", "- b += 1", "- a[i] = abs(a[i])", "-if (0 in a) or ((b % 2) == 0):", "- pass", "+import sys", "+", "+read = sys.stdin.buffer.read", "+readli...
false
0.007726
0.070959
0.108884
[ "s591495998", "s826817084" ]
u840310460
p02879
python
s430722503
s058536906
168
17
38,384
2,940
Accepted
Accepted
89.88
A, B = [int(i) for i in input().split()] if A < 10 and B < 10: print((A * B)) else: print((-1))
A, B = [int(i) for i in input().split()] if A <= 9 and B <= 9: print((A*B)) else: print((-1))
6
6
101
103
A, B = [int(i) for i in input().split()] if A < 10 and B < 10: print((A * B)) else: print((-1))
A, B = [int(i) for i in input().split()] if A <= 9 and B <= 9: print((A * B)) else: print((-1))
false
0
[ "-if A < 10 and B < 10:", "+if A <= 9 and B <= 9:" ]
false
0.119247
0.038844
3.069903
[ "s430722503", "s058536906" ]
u439396449
p03495
python
s081757085
s624214339
161
107
25,748
32,516
Accepted
Accepted
33.54
N, K = list(map(int, input().split())) A = [int(x) for x in input().split()] B = [0] * (N + 1) for i in range(N): B[A[i]] += 1 B = [x for x in sorted(B, reverse=True) if x > 0] ans = 0 while len(B) - K > 0: ans += B.pop() print(ans)
from collections import Counter from operator import itemgetter N, K = list(map(int, input().split())) A = [int(x) for x in input().split()] c = sorted(list(Counter(A).values()), reverse=True) print((sum([x for x in c[K:]])))
12
8
248
220
N, K = list(map(int, input().split())) A = [int(x) for x in input().split()] B = [0] * (N + 1) for i in range(N): B[A[i]] += 1 B = [x for x in sorted(B, reverse=True) if x > 0] ans = 0 while len(B) - K > 0: ans += B.pop() print(ans)
from collections import Counter from operator import itemgetter N, K = list(map(int, input().split())) A = [int(x) for x in input().split()] c = sorted(list(Counter(A).values()), reverse=True) print((sum([x for x in c[K:]])))
false
33.333333
[ "+from collections import Counter", "+from operator import itemgetter", "+", "-B = [0] * (N + 1)", "-for i in range(N):", "- B[A[i]] += 1", "-B = [x for x in sorted(B, reverse=True) if x > 0]", "-ans = 0", "-while len(B) - K > 0:", "- ans += B.pop()", "-print(ans)", "+c = sorted(list(Cou...
false
0.126795
0.048043
2.639198
[ "s081757085", "s624214339" ]
u463655976
p03048
python
s489706478
s247301781
1,856
746
3,060
2,940
Accepted
Accepted
59.81
R, G, B, N = list(map(int, input().split())) C = sorted([R, G, B], reverse=True) cnt = 0 for p0 in range(N//C[0]+1): p0v = p0*C[0] for p1 in range((N-p0v)//C[1]+1): p1v = p1*C[1] if (N - p0v - p1v)%C[2] == 0: cnt += 1 print(cnt)
R, G, B, N = list(map(int, input().split())) C = sorted([R, G, B], reverse=True) print((sum((1 for c1 in range(0, N+1, C[0]) for c12 in range(c1, N+1, C[1]) if (N - c12) % C[2] == 0 ))))
12
5
272
185
R, G, B, N = list(map(int, input().split())) C = sorted([R, G, B], reverse=True) cnt = 0 for p0 in range(N // C[0] + 1): p0v = p0 * C[0] for p1 in range((N - p0v) // C[1] + 1): p1v = p1 * C[1] if (N - p0v - p1v) % C[2] == 0: cnt += 1 print(cnt)
R, G, B, N = list(map(int, input().split())) C = sorted([R, G, B], reverse=True) print( ( sum( ( 1 for c1 in range(0, N + 1, C[0]) for c12 in range(c1, N + 1, C[1]) if (N - c12) % C[2] == 0 ) ) ) )
false
58.333333
[ "-cnt = 0", "-for p0 in range(N // C[0] + 1):", "- p0v = p0 * C[0]", "- for p1 in range((N - p0v) // C[1] + 1):", "- p1v = p1 * C[1]", "- if (N - p0v - p1v) % C[2] == 0:", "- cnt += 1", "-print(cnt)", "+print(", "+ (", "+ sum(", "+ (", "+ ...
false
0.045378
0.039068
1.161526
[ "s489706478", "s247301781" ]
u716660050
p02954
python
s995329617
s909366290
110
98
17,132
17,152
Accepted
Accepted
10.91
S=eval(input()) l=len(S) A=[0]*l c=0 for i in range(l-1): if S[i]=='R': c+=1 if S[i+1]=='L'or (i==l-1 and S[-1]=='R'): if i==l-1 and S[-1]=='R': c+=1 A[i]+=(c+1)//2 A[i+1]+=c//2 c=0 c=0 for i in range(l-1,0,-1): if S[i]=='L': c+=1 ...
S=eval(input())+'R' L=len(S) RL=0 l,r,f=0,0,0 a=[0]*(L-1) for i in range(1,L): if f:r+=1 else:l+=1 if S[i-1:i+1]=='LR': a[RL-1]=r//2+(l+1)//2 a[RL]=(r+1)//2+l//2 l,r,f=0,0,0 if S[i-1:i+1]=='RL':RL,f=i,1 print((' '.join(map(str,a))))
24
14
495
279
S = eval(input()) l = len(S) A = [0] * l c = 0 for i in range(l - 1): if S[i] == "R": c += 1 if S[i + 1] == "L" or (i == l - 1 and S[-1] == "R"): if i == l - 1 and S[-1] == "R": c += 1 A[i] += (c + 1) // 2 A[i + 1] += c // 2 c = 0 c = 0 for i in range(l - 1, 0...
S = eval(input()) + "R" L = len(S) RL = 0 l, r, f = 0, 0, 0 a = [0] * (L - 1) for i in range(1, L): if f: r += 1 else: l += 1 if S[i - 1 : i + 1] == "LR": a[RL - 1] = r // 2 + (l + 1) // 2 a[RL] = (r + 1) // 2 + l // 2 l, r, f = 0, 0, 0 if S[i - 1 : i + 1] == "RL"...
false
41.666667
[ "-S = eval(input())", "-l = len(S)", "-A = [0] * l", "-c = 0", "-for i in range(l - 1):", "- if S[i] == \"R\":", "- c += 1", "- if S[i + 1] == \"L\" or (i == l - 1 and S[-1] == \"R\"):", "- if i == l - 1 and S[-1] == \"R\":", "- c += 1", "- A[i] += (c + 1) /...
false
0.077989
0.037532
2.077941
[ "s995329617", "s909366290" ]
u994988729
p02761
python
s718834910
s886123582
25
18
3,444
3,064
Accepted
Accepted
28
from collections import defaultdict d = defaultdict(list) N, M = map(int, input().split()) for _ in range(M): s, c = map(int, input().split()) d[s].append(c) val = [-1] * N # とりあえず桁を確定させる for k, v in d.items(): if len(set(v)) > 1: print(-1) exit() val[k - 1] = v[0] i...
N, M = list(map(int, input().split())) sc = [list(map(int, input().split())) for _ in range(M)] ans = 10000 L = 10 ** (N - 1) if N == 1: L = 0 U = 10**N for i in range(L, U): x = str(i).zfill(N) for s, c in sc: if x[s - 1] == str(c): continue break else: ...
32
22
583
384
from collections import defaultdict d = defaultdict(list) N, M = map(int, input().split()) for _ in range(M): s, c = map(int, input().split()) d[s].append(c) val = [-1] * N # とりあえず桁を確定させる for k, v in d.items(): if len(set(v)) > 1: print(-1) exit() val[k - 1] = v[0] if N == 1: ans = ...
N, M = list(map(int, input().split())) sc = [list(map(int, input().split())) for _ in range(M)] ans = 10000 L = 10 ** (N - 1) if N == 1: L = 0 U = 10**N for i in range(L, U): x = str(i).zfill(N) for s, c in sc: if x[s - 1] == str(c): continue break else: ans = min(ans...
false
31.25
[ "-from collections import defaultdict", "-", "-d = defaultdict(list)", "-N, M = map(int, input().split())", "-for _ in range(M):", "- s, c = map(int, input().split())", "- d[s].append(c)", "-val = [-1] * N", "-# とりあえず桁を確定させる", "-for k, v in d.items():", "- if len(set(v)) > 1:", "- ...
false
0.041782
0.083446
0.50071
[ "s718834910", "s886123582" ]
u208713671
p03273
python
s457078917
s443295976
88
68
67,756
68,744
Accepted
Accepted
22.73
H,W= list(map(int,input().split())) M = [] for i in range(H): M.append(list(eval(input()))) Hs = [] for i in range(H): flag = 0 for j in range(W): if M[i][j]!=".": flag = 1 if flag==1: Hs.append(i) Ws = [] for j in range(W): flag = 0 for i in rang...
[H,W] = list(map(int,input().split())) a = [] for i in range(H): a.append(list(eval(input()))) line = [0]*H colu = [0]*W for i in range(H): for j in range(W): if a[i][j] == '#': line[i]=1 colu[j]=1 ans=[] for i in range(H): dammy=[] for j in range(W): ...
29
25
509
491
H, W = list(map(int, input().split())) M = [] for i in range(H): M.append(list(eval(input()))) Hs = [] for i in range(H): flag = 0 for j in range(W): if M[i][j] != ".": flag = 1 if flag == 1: Hs.append(i) Ws = [] for j in range(W): flag = 0 for i in range(H): ...
[H, W] = list(map(int, input().split())) a = [] for i in range(H): a.append(list(eval(input()))) line = [0] * H colu = [0] * W for i in range(H): for j in range(W): if a[i][j] == "#": line[i] = 1 colu[j] = 1 ans = [] for i in range(H): dammy = [] for j in range(W): ...
false
13.793103
[ "-H, W = list(map(int, input().split()))", "-M = []", "+[H, W] = list(map(int, input().split()))", "+a = []", "- M.append(list(eval(input())))", "-Hs = []", "+ a.append(list(eval(input())))", "+line = [0] * H", "+colu = [0] * W", "- flag = 0", "- if M[i][j] != \".\":", "- ...
false
0.034705
0.037529
0.924744
[ "s457078917", "s443295976" ]
u592547545
p03493
python
s647693479
s187062364
20
17
3,060
2,940
Accepted
Accepted
15
s=eval(input()) count=0 if(s[0]=='1'): count+=1 if(s[1]=='1'): count+=1 if(s[2]=='1'): count+=1 print(count)
s = eval(input()) count=0 for _ in s: if ( _ == '1'): count+=1 print(count)
9
6
117
81
s = eval(input()) count = 0 if s[0] == "1": count += 1 if s[1] == "1": count += 1 if s[2] == "1": count += 1 print(count)
s = eval(input()) count = 0 for _ in s: if _ == "1": count += 1 print(count)
false
33.333333
[ "-if s[0] == \"1\":", "- count += 1", "-if s[1] == \"1\":", "- count += 1", "-if s[2] == \"1\":", "- count += 1", "+for _ in s:", "+ if _ == \"1\":", "+ count += 1" ]
false
0.046707
0.100491
0.464788
[ "s647693479", "s187062364" ]
u644907318
p02843
python
s984001694
s197604105
258
184
11,672
38,384
Accepted
Accepted
28.68
X = int(eval(input())) A = [100,101,102,103,104,105] dp = [[-1 for _ in range(X+1)] for _ in range(7)] for i in range(1,7): dp[i][0] = 10**6 for i in range(1,7): for j in range(1,X+1): if dp[i-1][j]>=0: dp[i][j] = 10**6 elif j<A[i-1] or dp[i][j-A[i-1]]<=0: dp[i]...
X = int(eval(input())) x = X%100 cnt = 0 cnt += x//5 x = x%5 cnt += x//4 x = x%4 cnt += x//3 x = x%3 cnt += x//2 x = x%2 cnt += x X = X-X%100 if X>=100*cnt: print((1)) else: print((0))
17
17
431
198
X = int(eval(input())) A = [100, 101, 102, 103, 104, 105] dp = [[-1 for _ in range(X + 1)] for _ in range(7)] for i in range(1, 7): dp[i][0] = 10**6 for i in range(1, 7): for j in range(1, X + 1): if dp[i - 1][j] >= 0: dp[i][j] = 10**6 elif j < A[i - 1] or dp[i][j - A[i - 1]] <= 0: ...
X = int(eval(input())) x = X % 100 cnt = 0 cnt += x // 5 x = x % 5 cnt += x // 4 x = x % 4 cnt += x // 3 x = x % 3 cnt += x // 2 x = x % 2 cnt += x X = X - X % 100 if X >= 100 * cnt: print((1)) else: print((0))
false
0
[ "-A = [100, 101, 102, 103, 104, 105]", "-dp = [[-1 for _ in range(X + 1)] for _ in range(7)]", "-for i in range(1, 7):", "- dp[i][0] = 10**6", "-for i in range(1, 7):", "- for j in range(1, X + 1):", "- if dp[i - 1][j] >= 0:", "- dp[i][j] = 10**6", "- elif j < A[i - 1]...
false
0.045661
0.04718
0.967796
[ "s984001694", "s197604105" ]
u130860911
p02834
python
s687187077
s881525533
1,039
920
29,512
29,520
Accepted
Accepted
11.45
import heapq N,u,v = list(map(int,input().split())) u -= 1 v -= 1 du = [float('inf')]*N dv = [float('inf')]*N G = [[]]*N def calcDist(s, dist): q = [] heapq.heappush(q,[0, s]) dist[s] = int(0) while q!=[]: p = heapq.heappop(q) pv = p[1] if dist[pv] < p[0...
import heapq N,u,v = list(map(int,input().split())) u -= 1 v -= 1 du = [float('inf')]*N dv = [float('inf')]*N G = [[]]*N def calcDist(s, dist): q = [] heapq.heappush(q,[0, s]) dist[s] = int(0) while q!=[]: p = heapq.heappop(q) pv = p[1] if dist[pv] < p[0...
53
52
1,029
991
import heapq N, u, v = list(map(int, input().split())) u -= 1 v -= 1 du = [float("inf")] * N dv = [float("inf")] * N G = [[]] * N def calcDist(s, dist): q = [] heapq.heappush(q, [0, s]) dist[s] = int(0) while q != []: p = heapq.heappop(q) pv = p[1] if dist[pv] < p[0]: ...
import heapq N, u, v = list(map(int, input().split())) u -= 1 v -= 1 du = [float("inf")] * N dv = [float("inf")] * N G = [[]] * N def calcDist(s, dist): q = [] heapq.heappush(q, [0, s]) dist[s] = int(0) while q != []: p = heapq.heappop(q) pv = p[1] if dist[pv] < p[0]: ...
false
1.886792
[ "- for i in range(len(G[pv])):", "- eto = G[pv][i]", "+ for eto in G[pv]:" ]
false
0.030875
0.035852
0.861184
[ "s687187077", "s881525533" ]
u794173881
p02763
python
s773207862
s801873761
498
441
73,436
77,404
Accepted
Accepted
11.45
class SegmentTree(): """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する update: i番目をvalに変更する get_min: 区間[begin, end)の最小値を求める """ def __init__(self, n): self.n = n self.INF = 0 self.size = 1 while self.size < n: self.size *= 2 self.node = [self.IN...
class SegmentTree(): """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する。 built(array) := arrayを初期値とするセグメント木を構築する O(N)。 update(i, val) := i番目の要素をvalに変更する。 get_val(l, r) := 区間[l, r)に対する二項演算の畳み込みの結果を返す。 """ def __init__(self, n, op, e): """要素数、二項演算、単位元を引数として渡す 例) 区間最小値 SegmentTr...
57
71
1,511
2,067
class SegmentTree: """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する update: i番目をvalに変更する get_min: 区間[begin, end)の最小値を求める """ def __init__(self, n): self.n = n self.INF = 0 self.size = 1 while self.size < n: self.size *= 2 self.node = [self.INF] * (2 * se...
class SegmentTree: """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する。 built(array) := arrayを初期値とするセグメント木を構築する O(N)。 update(i, val) := i番目の要素をvalに変更する。 get_val(l, r) := 区間[l, r)に対する二項演算の畳み込みの結果を返す。 """ def __init__(self, n, op, e): """要素数、二項演算、単位元を引数として渡す 例) 区間最小値 SegmentTree(n, min, ...
false
19.71831
[ "- \"\"\"一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する", "- update: i番目をvalに変更する", "- get_min: 区間[begin, end)の最小値を求める", "+ \"\"\"一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する。", "+ built(array) := arrayを初期値とするセグメント木を構築する O(N)。", "+ update(i, val) := i番目の要素をvalに変更する。", "+ get_val(l, r) := 区間[l,...
false
0.039163
0.05562
0.704114
[ "s773207862", "s801873761" ]
u211236379
p03013
python
s852816615
s926877840
1,561
570
536,716
471,288
Accepted
Accepted
63.48
#N = int(input()) N, M = list(map(int,input().split())) #W =list(map(int,input().split())) a = [(int(eval(input()))) for i in range(M)] import sys sys.setrecursionlimit(100000) memo =[-1]*(N+2) def stair_count(n): if memo[n]!= -1: return memo[n] if n==0 or n==1: memo[n] =1 ...
#N = int(input()) N, M = list(map(int,input().split())) #W =list(map(int,input().split())) a = [(int(eval(input()))) for i in range(M)] import sys sys.setrecursionlimit(100000) memo =[-1]*(N+2) memo[0] = 1 memo[1] = 1 def stair_count(n): for j in range(2,n+1): memo[j] = memo[j-1] + memo[j-2...
31
32
693
614
# N = int(input()) N, M = list(map(int, input().split())) # W =list(map(int,input().split())) a = [(int(eval(input()))) for i in range(M)] import sys sys.setrecursionlimit(100000) memo = [-1] * (N + 2) def stair_count(n): if memo[n] != -1: return memo[n] if n == 0 or n == 1: memo[n] = 1 ...
# N = int(input()) N, M = list(map(int, input().split())) # W =list(map(int,input().split())) a = [(int(eval(input()))) for i in range(M)] import sys sys.setrecursionlimit(100000) memo = [-1] * (N + 2) memo[0] = 1 memo[1] = 1 def stair_count(n): for j in range(2, n + 1): memo[j] = memo[j - 1] + memo[j - ...
false
3.125
[ "+memo[0] = 1", "+memo[1] = 1", "- if memo[n] != -1:", "- return memo[n]", "- if n == 0 or n == 1:", "- memo[n] = 1", "- return memo[n]", "- memo[n] = stair_count(n - 1) + stair_count(n - 2)", "- return memo[n]", "+ for j in range(2, n + 1):", "+ memo[j...
false
0.03797
0.107489
0.353242
[ "s852816615", "s926877840" ]
u513081876
p03240
python
s480456713
s452445797
471
29
3,188
3,188
Accepted
Accepted
93.84
N = int(eval(input())) x, y, h = [0]*N, [0]*N, [0]*N for i in range(N): x[i], y[i], h[i] = list(map(int, input().split())) for cx in range(0, 101): for cy in range(0, 101): for i in range(N): if h[i] > 0: H = h[i] + abs(x[i]-cx)+abs(y[i]-cy) for i...
import sys N = int(eval(input())) xyh = [list(map(int, input().split())) for i in range(N)] xyh.sort(key=lambda x:x[2]) if N==1: print((xyh[0][0], xyh[0][1] , xyh[0][2])) else: for xc in range(101): for yc in range(101): H = xyh[-1][2] + abs(xyh[-1][0] - xc) + abs(xy...
17
20
470
539
N = int(eval(input())) x, y, h = [0] * N, [0] * N, [0] * N for i in range(N): x[i], y[i], h[i] = list(map(int, input().split())) for cx in range(0, 101): for cy in range(0, 101): for i in range(N): if h[i] > 0: H = h[i] + abs(x[i] - cx) + abs(y[i] - cy) for i in range...
import sys N = int(eval(input())) xyh = [list(map(int, input().split())) for i in range(N)] xyh.sort(key=lambda x: x[2]) if N == 1: print((xyh[0][0], xyh[0][1], xyh[0][2])) else: for xc in range(101): for yc in range(101): H = xyh[-1][2] + abs(xyh[-1][0] - xc) + abs(xyh[-1][1] - yc) ...
false
15
[ "+import sys", "+", "-x, y, h = [0] * N, [0] * N, [0] * N", "-for i in range(N):", "- x[i], y[i], h[i] = list(map(int, input().split()))", "-for cx in range(0, 101):", "- for cy in range(0, 101):", "- for i in range(N):", "- if h[i] > 0:", "- H = h[i] + abs(x...
false
0.066423
0.038692
1.716724
[ "s480456713", "s452445797" ]
u485319545
p02584
python
s198312827
s755109658
35
30
9,196
8,956
Accepted
Accepted
14.29
x,k,d=list(map(int,input().split())) if d>=abs(x): if k%2==0: p=abs(x) else: if x>=0: p=abs(x-d) else: p=abs(x+d) print(p) exit(0) else: cnt=abs(x)//d if cnt>=k: cnt=k if x>=0: p=x-d*cnt else: ...
x,k,d=list(map(int,input().split())) x=abs(x) cnt=abs(x)//d if cnt>=k: print((x-d*k)) else: k-=cnt if k%2==0: print((abs(x-d*cnt))) else: print((abs(x-d*(cnt+1))))
39
17
549
206
x, k, d = list(map(int, input().split())) if d >= abs(x): if k % 2 == 0: p = abs(x) else: if x >= 0: p = abs(x - d) else: p = abs(x + d) print(p) exit(0) else: cnt = abs(x) // d if cnt >= k: cnt = k if x >= 0: p = x - d * cnt ...
x, k, d = list(map(int, input().split())) x = abs(x) cnt = abs(x) // d if cnt >= k: print((x - d * k)) else: k -= cnt if k % 2 == 0: print((abs(x - d * cnt))) else: print((abs(x - d * (cnt + 1))))
false
56.410256
[ "-if d >= abs(x):", "+x = abs(x)", "+cnt = abs(x) // d", "+if cnt >= k:", "+ print((x - d * k))", "+else:", "+ k -= cnt", "- p = abs(x)", "+ print((abs(x - d * cnt)))", "- if x >= 0:", "- p = abs(x - d)", "- else:", "- p = abs(x + d)", ...
false
0.03788
0.043459
0.871617
[ "s198312827", "s755109658" ]
u017810624
p02838
python
s103665632
s810854343
1,420
1,046
125,624
125,624
Accepted
Accepted
26.34
def sumXOR( arr, n): sum = 0 for i in range(0, 100): zc = 0 oc = 0 idsum = 0 for j in range(0, n): if (arr[j] % 2 == 0): zc = zc + 1 else: oc = oc + 1 arr[j] = arr[j]//2 ...
n=int(eval(input())) a=list(map(int,input().split())) mod=10**9+7 ct0=[0]*64 ct1=[0]*64 for i in range(n): x=format(a[i],'0'+str(64)+'b') for j in range(64): if x[j]=='0': ct0[j]+=1 else: ct1[j]+=1 ct0.reverse() ct1.reverse() ans=0 for i in range(64): x=(ct0[i]*ct1[i])%mod a...
23
20
526
350
def sumXOR(arr, n): sum = 0 for i in range(0, 100): zc = 0 oc = 0 idsum = 0 for j in range(0, n): if arr[j] % 2 == 0: zc = zc + 1 else: oc = oc + 1 arr[j] = arr[j] // 2 idsum = oc * zc * (1 << i) ...
n = int(eval(input())) a = list(map(int, input().split())) mod = 10**9 + 7 ct0 = [0] * 64 ct1 = [0] * 64 for i in range(n): x = format(a[i], "0" + str(64) + "b") for j in range(64): if x[j] == "0": ct0[j] += 1 else: ct1[j] += 1 ct0.reverse() ct1.reverse() ans = 0 for i in...
false
13.043478
[ "-def sumXOR(arr, n):", "- sum = 0", "- for i in range(0, 100):", "- zc = 0", "- oc = 0", "- idsum = 0", "- for j in range(0, n):", "- if arr[j] % 2 == 0:", "- zc = zc + 1", "- else:", "- oc = oc + 1", "- ...
false
0.037465
0.039111
0.957911
[ "s103665632", "s810854343" ]
u968166680
p02787
python
s069996134
s724196265
244
132
152,636
70,556
Accepted
Accepted
45.9
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): H, N, *AB = list(map(int, read().split())) magic = [0] * N for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)): mag...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): H, N, *AB = list(map(int, read().split())) dp = [INF] * (H + 1) dp[0] = 0 for a, b in zip(*[iter(AB)] * 2): ...
32
26
665
471
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): H, N, *AB = list(map(int, read().split())) magic = [0] * N for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)): magic[i] = (a, b) ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): H, N, *AB = list(map(int, read().split())) dp = [INF] * (H + 1) dp[0] = 0 for a, b in zip(*[iter(AB)] * 2): for i in range(H +...
false
18.75
[ "- magic = [0] * N", "- for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):", "- magic[i] = (a, b)", "- dp = [[INF] * (H + 1) for _ in range(N + 1)]", "- for i in range(N + 1):", "- dp[i][0] = 0", "- for i in range(N):", "- a, b = magic[i]", "- for j in range...
false
0.064787
0.368846
0.175647
[ "s069996134", "s724196265" ]
u428132025
p02683
python
s178712607
s062953181
88
79
74,024
9,636
Accepted
Accepted
10.23
n, m, x = list(map(int, input().split())) c = [0] * n for i in range(n): c[i] = [int(_) for _ in input().split()] ans = 10**10 for i in range(2 ** n): state = [0] * n for j in range(n): state[j] = (i >> j) & 1 #print(state) num = [0] * m val = 0 for j in range(n): ...
from itertools import product n, m, x = list(map(int, input().split())) c = [0] * n a = [0] * n for i in range(n): inp = [int(_) for _ in input().split()] c[i] = inp[0] a[i] = inp[1:] INIT = 10**10 ans = INIT pat = list(product([0, 1], repeat=n)) for p in pat: a_val = [0] * m c_ye...
32
36
648
681
n, m, x = list(map(int, input().split())) c = [0] * n for i in range(n): c[i] = [int(_) for _ in input().split()] ans = 10**10 for i in range(2**n): state = [0] * n for j in range(n): state[j] = (i >> j) & 1 # print(state) num = [0] * m val = 0 for j in range(n): if state[j] ...
from itertools import product n, m, x = list(map(int, input().split())) c = [0] * n a = [0] * n for i in range(n): inp = [int(_) for _ in input().split()] c[i] = inp[0] a[i] = inp[1:] INIT = 10**10 ans = INIT pat = list(product([0, 1], repeat=n)) for p in pat: a_val = [0] * m c_yen = 0 for i in...
false
11.111111
[ "+from itertools import product", "+", "+a = [0] * n", "- c[i] = [int(_) for _ in input().split()]", "-ans = 10**10", "-for i in range(2**n):", "- state = [0] * n", "- for j in range(n):", "- state[j] = (i >> j) & 1", "- # print(state)", "- num = [0] * m", "- val = 0",...
false
0.051697
0.047635
1.085267
[ "s178712607", "s062953181" ]
u729133443
p02975
python
s632625266
s504912269
182
55
24,780
11,632
Accepted
Accepted
69.78
from numpy import*;_,a=open(0);print(('YNeos'[bitwise_xor.reduce(int32(a.split()))>0::2]))
from functools import*;_,a=open(0);print(('YNeos'[reduce(lambda x,y:x^y,list(map(int,a.split())))>0::2]))
1
1
88
97
from numpy import * _, a = open(0) print(("YNeos"[bitwise_xor.reduce(int32(a.split())) > 0 :: 2]))
from functools import * _, a = open(0) print(("YNeos"[reduce(lambda x, y: x ^ y, list(map(int, a.split()))) > 0 :: 2]))
false
0
[ "-from numpy import *", "+from functools import *", "-print((\"YNeos\"[bitwise_xor.reduce(int32(a.split())) > 0 :: 2]))", "+print((\"YNeos\"[reduce(lambda x, y: x ^ y, list(map(int, a.split()))) > 0 :: 2]))" ]
false
0.253822
0.043463
5.839944
[ "s632625266", "s504912269" ]
u227082700
p02988
python
s972022669
s222610696
21
18
3,316
3,060
Accepted
Accepted
14.29
n=int(eval(input())) #n,k=map(int,input().split()) a=list(map(int,input().split())) ans=0 for i in range(1,n-1): b=[a[i-1],a[i],a[i+1]] b.sort() if b[1]==a[i]:ans+=1 print(ans)
n=int(eval(input())) p=list(map(int,input().split())) ans=0 for i in range(1,n-1): if sorted([p[i-1],p[i],p[i+1]])[1]==p[i]:ans+=1 print(ans)
9
6
184
142
n = int(eval(input())) # n,k=map(int,input().split()) a = list(map(int, input().split())) ans = 0 for i in range(1, n - 1): b = [a[i - 1], a[i], a[i + 1]] b.sort() if b[1] == a[i]: ans += 1 print(ans)
n = int(eval(input())) p = list(map(int, input().split())) ans = 0 for i in range(1, n - 1): if sorted([p[i - 1], p[i], p[i + 1]])[1] == p[i]: ans += 1 print(ans)
false
33.333333
[ "-# n,k=map(int,input().split())", "-a = list(map(int, input().split()))", "+p = list(map(int, input().split()))", "- b = [a[i - 1], a[i], a[i + 1]]", "- b.sort()", "- if b[1] == a[i]:", "+ if sorted([p[i - 1], p[i], p[i + 1]])[1] == p[i]:" ]
false
0.046148
0.045675
1.010362
[ "s972022669", "s222610696" ]
u135454978
p02844
python
s257038787
s003383811
178
18
38,256
3,060
Accepted
Accepted
89.89
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN import sys N = int(eval(input())) S = eval(input()) ans = 0 for i in range(10): code1 = S.find(str(i)) if code1 == -1: continue for j in range(10): code2 = S.find(str(j), code1 + 1) if code2 == -1: continue ...
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN import sys N = int(eval(input())) S = eval(input()) ans = 0 for i in range(10): code1 = S.find(str(i)) if code1 == -1: continue for j in range(10): code2 = S.find(str(j), code1 + 1) if code2 == -1: continue ...
22
21
448
421
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN import sys N = int(eval(input())) S = eval(input()) ans = 0 for i in range(10): code1 = S.find(str(i)) if code1 == -1: continue for j in range(10): code2 = S.find(str(j), code1 + 1) if code2 == -1: continue for k in range...
# 三井住友信託銀行プログラミングコンテスト 2019 D - Lucky PIN import sys N = int(eval(input())) S = eval(input()) ans = 0 for i in range(10): code1 = S.find(str(i)) if code1 == -1: continue for j in range(10): code2 = S.find(str(j), code1 + 1) if code2 == -1: continue for k in range...
false
4.545455
[ "- code3 = S.find(str(k), code2 + 1)", "- if code3 != -1:", "+ if S.find(str(k), code2 + 1) != -1:" ]
false
0.044169
0.041566
1.062634
[ "s257038787", "s003383811" ]
u119456964
p02386
python
s889013990
s410941091
50
40
6,464
6,468
Accepted
Accepted
20
n = int(input()) dice = [[0 for i in range(6)] for j in range(n)] for i in range(n): dice[i] = list(map(int, input().split())) def rolling(inst, dice): if inst == 'E': dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5] elif inst == 'W': dice[5], dice[3], dic...
n = int(input()) dice = [[0 for i in range(6)] for j in range(n)] for i in range(n): dice[i] = list(map(int, input().split())) def rolling(inst, dice): if inst == 'E': dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5] elif inst == 'W': dice[5], dice[3], dic...
53
55
1,562
1,552
n = int(input()) dice = [[0 for i in range(6)] for j in range(n)] for i in range(n): dice[i] = list(map(int, input().split())) def rolling(inst, dice): if inst == "E": dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5] elif inst == "W": dice[5], dice[3], dice[0], dice[...
n = int(input()) dice = [[0 for i in range(6)] for j in range(n)] for i in range(n): dice[i] = list(map(int, input().split())) def rolling(inst, dice): if inst == "E": dice[5], dice[2], dice[0], dice[3] = dice[2], dice[0], dice[3], dice[5] elif inst == "W": dice[5], dice[3], dice[0], dice[...
false
3.636364
[ "+def alldice_matching(dice1, dice2):", "+ count = 0", "+ while 1:", "+ if dice_matching(dice1, dice2) == 1:", "+ return 1", "+ else:", "+ if count < 3:", "+ rolling(\"N\", dice2)", "+ count += 1", "+ elif 7 > count...
false
0.042259
0.042919
0.984629
[ "s889013990", "s410941091" ]
u638456847
p02888
python
s090397895
s008758872
980
871
3,184
3,188
Accepted
Accepted
11.12
import bisect import time def main(): N = int(eval(input())) L = [int(i) for i in input().split()] #N = 2000 #L = [int(i) for i in range(N)] L.sort() ans = 0 for i in range(N-2): for j in range(i+1,N-1): #ans += bisect.bisect_left(L[j+1:], L[i]+L[j]) ...
from bisect import bisect_left import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) L = [int(i) for i in readline().split()] L.sort() ans = 0 for i in range(N-1): L_i = L[i] for j in range(i+1, ...
25
23
591
466
import bisect import time def main(): N = int(eval(input())) L = [int(i) for i in input().split()] # N = 2000 # L = [int(i) for i in range(N)] L.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): # ans += bisect.bisect_left(L[j+1:], L[i]+L[j]) ...
from bisect import bisect_left import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines def main(): N = int(readline()) L = [int(i) for i in readline().split()] L.sort() ans = 0 for i in range(N - 1): L_i = L[i] for j in range(i + 1, N): ...
false
8
[ "-import bisect", "-import time", "+from bisect import bisect_left", "+import sys", "+", "+read = sys.stdin.read", "+readline = sys.stdin.readline", "+readlines = sys.stdin.readlines", "- N = int(eval(input()))", "- L = [int(i) for i in input().split()]", "- # N = 2000", "- # L = [...
false
0.045783
0.045592
1.00418
[ "s090397895", "s008758872" ]