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
u837673618
p02709
python
s081272143
s811407336
1,396
792
9,464
9,584
Accepted
Accepted
43.27
N = int(eval(input())) def left(a, i, prev): yield 0 for l, s in enumerate(prev, 1-i): yield s+abs(l)*a def right(a, i, prev): for r, s in enumerate(prev, N - len(prev) - i + 1): yield s+abs(r)*a yield 0 pd = [0] A = list(map(int, input().split())) for a,i in sorted(((a, i) for i, a...
N = int(eval(input())) def solve(a, i, prev): r = N - len(prev) - i + 1 p = -i*a for j, s in enumerate(prev): yield p+abs(j-i)*a, s+abs(j+r)*a p = s yield s+abs(len(prev)-i)*a, pd = [0] A = list(map(int, input().split())) for a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True...
18
16
419
365
N = int(eval(input())) def left(a, i, prev): yield 0 for l, s in enumerate(prev, 1 - i): yield s + abs(l) * a def right(a, i, prev): for r, s in enumerate(prev, N - len(prev) - i + 1): yield s + abs(r) * a yield 0 pd = [0] A = list(map(int, input().split())) for a, i in sorted(((a,...
N = int(eval(input())) def solve(a, i, prev): r = N - len(prev) - i + 1 p = -i * a for j, s in enumerate(prev): yield p + abs(j - i) * a, s + abs(j + r) * a p = s yield s + abs(len(prev) - i) * a, pd = [0] A = list(map(int, input().split())) for a, i in sorted(((a, i) for i, a in enu...
false
11.111111
[ "-def left(a, i, prev):", "- yield 0", "- for l, s in enumerate(prev, 1 - i):", "- yield s + abs(l) * a", "-", "-", "-def right(a, i, prev):", "- for r, s in enumerate(prev, N - len(prev) - i + 1):", "- yield s + abs(r) * a", "- yield 0", "+def solve(a, i, prev):", "+...
false
0.042033
0.037021
1.135374
[ "s081272143", "s811407336" ]
u394721319
p03545
python
s870767785
s106613401
173
17
38,768
3,064
Accepted
Accepted
90.17
S = list(eval(input())) for i in range(8): pq = str(S[0]) ans = int(S[0]) l = bin(i)[2:].zfill(3) for j in range(3): if l[j] == '1': ans += int(S[j+1]) pq += '+'+str(S[j+1]) else: ans -= int(S[j+1]) pq += '-'+str(S[j+1]) i...
S = list(eval(input())) S = [int(i) for i in S] for i in range(2 ** 3): p = S[0] for j in range(3): if ((i >> j) & 1): p -= S[j+1] else: p += S[j+1] if p == 7: ans = str(S[0]) for j in range(3): if ((i >> j) & 1): ...
17
20
381
457
S = list(eval(input())) for i in range(8): pq = str(S[0]) ans = int(S[0]) l = bin(i)[2:].zfill(3) for j in range(3): if l[j] == "1": ans += int(S[j + 1]) pq += "+" + str(S[j + 1]) else: ans -= int(S[j + 1]) pq += "-" + str(S[j + 1]) if ...
S = list(eval(input())) S = [int(i) for i in S] for i in range(2**3): p = S[0] for j in range(3): if (i >> j) & 1: p -= S[j + 1] else: p += S[j + 1] if p == 7: ans = str(S[0]) for j in range(3): if (i >> j) & 1: ans += "-" +...
false
15
[ "-for i in range(8):", "- pq = str(S[0])", "- ans = int(S[0])", "- l = bin(i)[2:].zfill(3)", "+S = [int(i) for i in S]", "+for i in range(2**3):", "+ p = S[0]", "- if l[j] == \"1\":", "- ans += int(S[j + 1])", "- pq += \"+\" + str(S[j + 1])", "+ if...
false
0.13428
0.037693
3.562474
[ "s870767785", "s106613401" ]
u629540524
p02831
python
s298333709
s847966963
31
25
9,156
9,160
Accepted
Accepted
19.35
import math a,b = list(map(int,input().split())) print(((a*b)//math.gcd(a,b)))
import math a,b = list(map(int,input().split())) def lcm(x,y): return (x*y)// math.gcd(x,y) print((lcm(a,b)))
3
5
72
109
import math a, b = list(map(int, input().split())) print(((a * b) // math.gcd(a, b)))
import math a, b = list(map(int, input().split())) def lcm(x, y): return (x * y) // math.gcd(x, y) print((lcm(a, b)))
false
40
[ "-print(((a * b) // math.gcd(a, b)))", "+", "+", "+def lcm(x, y):", "+ return (x * y) // math.gcd(x, y)", "+", "+", "+print((lcm(a, b)))" ]
false
0.050689
0.038371
1.321031
[ "s298333709", "s847966963" ]
u881668270
p00015
python
s176691991
s842481500
30
20
7,656
7,576
Accepted
Accepted
33.33
n = int(eval(input())) for i in range(0, n): a = int(eval(input())) b = int(eval(input())) if a + b >= 10 ** 80: print("overflow") elif a >= 10 ** 80: print("overflow") elif b >= 10 ** 80: print("overflow") else : print((a + b))
n = int(eval(input())) for i in range(0, n): a = int(eval(input())) b = int(eval(input())) if len(str(a + b)) > 80: print("overflow") elif len(str(a)) > 80: print("overflow") elif len(str(b)) > 80: print("overflow") else : print((a + b))
13
13
277
286
n = int(eval(input())) for i in range(0, n): a = int(eval(input())) b = int(eval(input())) if a + b >= 10**80: print("overflow") elif a >= 10**80: print("overflow") elif b >= 10**80: print("overflow") else: print((a + b))
n = int(eval(input())) for i in range(0, n): a = int(eval(input())) b = int(eval(input())) if len(str(a + b)) > 80: print("overflow") elif len(str(a)) > 80: print("overflow") elif len(str(b)) > 80: print("overflow") else: print((a + b))
false
0
[ "- if a + b >= 10**80:", "+ if len(str(a + b)) > 80:", "- elif a >= 10**80:", "+ elif len(str(a)) > 80:", "- elif b >= 10**80:", "+ elif len(str(b)) > 80:" ]
false
0.043075
0.085578
0.50334
[ "s176691991", "s842481500" ]
u131811591
p02329
python
s939570900
s055011467
1,020
910
179,180
179,244
Accepted
Accepted
10.78
import sys from collections import defaultdict n, v = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) b = tuple(map(int, sys.stdin.readline().split())) c = tuple(map(int, sys.stdin.readline().split())) d = tuple(map(int, sys.stdin.readline().split())) mp = default...
import sys from collections import defaultdict def main(): n, v = list(map(int, sys.stdin.readline().split())) a = list(map(int, sys.stdin.readline().split())) b = list(map(int, sys.stdin.readline().split())) c = list(map(int, sys.stdin.readline().split())) d = list(map(int, sys.stdin.rea...
13
19
451
546
import sys from collections import defaultdict n, v = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) b = tuple(map(int, sys.stdin.readline().split())) c = tuple(map(int, sys.stdin.readline().split())) d = tuple(map(int, sys.stdin.readline().split())) mp = defaultdict(int...
import sys from collections import defaultdict def main(): n, v = list(map(int, sys.stdin.readline().split())) a = list(map(int, sys.stdin.readline().split())) b = list(map(int, sys.stdin.readline().split())) c = list(map(int, sys.stdin.readline().split())) d = list(map(int, sys.stdin.readline().s...
false
31.578947
[ "-n, v = list(map(int, sys.stdin.readline().split()))", "-a = tuple(map(int, sys.stdin.readline().split()))", "-b = tuple(map(int, sys.stdin.readline().split()))", "-c = tuple(map(int, sys.stdin.readline().split()))", "-d = tuple(map(int, sys.stdin.readline().split()))", "-mp = defaultdict(int)", "-for ...
false
0.062108
0.044323
1.401241
[ "s939570900", "s055011467" ]
u130900604
p03211
python
s244544380
s909030357
168
17
38,256
2,940
Accepted
Accepted
89.88
ans=0 dif=1000 s=eval(input()) n=len(s) for i in range(n-2): tmp=int(s[i:i+3]) if abs(753-tmp)<dif: ans=tmp dif=abs(753-ans) print(dif)
S=eval(input()) ans=10**5 for i in range(len(S)-3+1): t=S[i:i+3] ans=min(ans,abs(753-int(t))) print(ans)
10
6
150
111
ans = 0 dif = 1000 s = eval(input()) n = len(s) for i in range(n - 2): tmp = int(s[i : i + 3]) if abs(753 - tmp) < dif: ans = tmp dif = abs(753 - ans) print(dif)
S = eval(input()) ans = 10**5 for i in range(len(S) - 3 + 1): t = S[i : i + 3] ans = min(ans, abs(753 - int(t))) print(ans)
false
40
[ "-ans = 0", "-dif = 1000", "-s = eval(input())", "-n = len(s)", "-for i in range(n - 2):", "- tmp = int(s[i : i + 3])", "- if abs(753 - tmp) < dif:", "- ans = tmp", "- dif = abs(753 - ans)", "-print(dif)", "+S = eval(input())", "+ans = 10**5", "+for i in range(len(S) - 3 ...
false
0.148437
0.041655
3.563487
[ "s244544380", "s909030357" ]
u729133443
p02735
python
s875964512
s454059021
22
20
3,188
3,064
Accepted
Accepted
9.09
def main(): import sys b=sys.stdin.buffer h,w=list(map(int,b.readline().split())) x=w+1 s=[c>>3for c in b.read()] dp=[10000]*h*x a=p=s[0] dp[0]=b=q=5-a for i in range(w): t=s[i] b+=a^t dp[i]=b a=t for i in range(x,h*x,x): t=s[i] q+=p^t dp[i]=b=q a=p=...
def main(): import sys input=sys.stdin.buffer.readline h,w=list(map(int,input().split())) t,*s,_=eval(input()) if t==46:c,f=0,False else:c,f=1,True p=[(c,f)] for t in s: g=t==35 if g!=f: c+=1 f=not f p+=(c,f), d=p for _ in range(h-1): t,*s,_=eval(input()) ...
30
38
493
631
def main(): import sys b = sys.stdin.buffer h, w = list(map(int, b.readline().split())) x = w + 1 s = [c >> 3 for c in b.read()] dp = [10000] * h * x a = p = s[0] dp[0] = b = q = 5 - a for i in range(w): t = s[i] b += a ^ t dp[i] = b a = t for i i...
def main(): import sys input = sys.stdin.buffer.readline h, w = list(map(int, input().split())) t, *s, _ = eval(input()) if t == 46: c, f = 0, False else: c, f = 1, True p = [(c, f)] for t in s: g = t == 35 if g != f: c += 1 f = no...
false
21.052632
[ "- b = sys.stdin.buffer", "- h, w = list(map(int, b.readline().split()))", "- x = w + 1", "- s = [c >> 3 for c in b.read()]", "- dp = [10000] * h * x", "- a = p = s[0]", "- dp[0] = b = q = 5 - a", "- for i in range(w):", "- t = s[i]", "- b += a ^ t", "- ...
false
0.049799
0.049979
0.996407
[ "s875964512", "s454059021" ]
u054514819
p03151
python
s955345339
s442854245
279
129
76,720
97,844
Accepted
Accepted
53.76
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) As = list(mapint()) Bs = list(mapint()) if sum(As)<sum(Bs): print((-1)) else: diff = [a-b for a, b in zip(As, Bs)] diff.sort() ...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) As = list(mapint()) Bs = list(mapint()) if sum(As)<sum(Bs): print((-1)) else: minus = 0 cnt = 0 lis = [] for a, b in z...
27
31
544
641
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) As = list(mapint()) Bs = list(mapint()) if sum(As) < sum(Bs): print((-1)) else: diff = [a - b for a, b in zip(As, Bs)] diff.sort(...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) As = list(mapint()) Bs = list(mapint()) if sum(As) < sum(Bs): print((-1)) else: minus = 0 cnt = 0 lis = [] for a, b in zi...
false
12.903226
[ "- diff = [a - b for a, b in zip(As, Bs)]", "- diff.sort()", "+ minus = 0", "- need = 0", "- for d in diff:", "- if d >= 0:", "- break", "- need += d", "- cnt += 1", "- for d in diff[::-1]:", "- if need >= 0:", "- break", "-...
false
0.037364
0.038061
0.98169
[ "s955345339", "s442854245" ]
u853185302
p03262
python
s782726253
s979135887
115
89
16,284
16,296
Accepted
Accepted
22.61
import fractions N,X = list(map(int,input().split())) x_ = list(map(int,input().split())) x_.append(X) x_.sort() d_ = list(set([x_[i+1]-x_[i] for i in range(N)])) gcd = d_[0] for i in d_[1:]: gcd = fractions.gcd(gcd,i) print(gcd)
from functools import reduce from fractions import gcd n,x = list(map(int,input().split())) x = [abs(int(i)-x) for i in input().split()] print((reduce(gcd,x)))
14
5
244
156
import fractions N, X = list(map(int, input().split())) x_ = list(map(int, input().split())) x_.append(X) x_.sort() d_ = list(set([x_[i + 1] - x_[i] for i in range(N)])) gcd = d_[0] for i in d_[1:]: gcd = fractions.gcd(gcd, i) print(gcd)
from functools import reduce from fractions import gcd n, x = list(map(int, input().split())) x = [abs(int(i) - x) for i in input().split()] print((reduce(gcd, x)))
false
64.285714
[ "-import fractions", "+from functools import reduce", "+from fractions import gcd", "-N, X = list(map(int, input().split()))", "-x_ = list(map(int, input().split()))", "-x_.append(X)", "-x_.sort()", "-d_ = list(set([x_[i + 1] - x_[i] for i in range(N)]))", "-gcd = d_[0]", "-for i in d_[1:]:", "-...
false
0.057355
0.056298
1.018778
[ "s782726253", "s979135887" ]
u127499732
p02789
python
s102305663
s101437270
170
17
38,256
2,940
Accepted
Accepted
90
a,b = list(map(int,input().split())) if a == b: print("Yes") else: print("No")
n,m=list(map(int,input().split())) print(("Yes" if n==m else "No"))
6
2
82
60
a, b = list(map(int, input().split())) if a == b: print("Yes") else: print("No")
n, m = list(map(int, input().split())) print(("Yes" if n == m else "No"))
false
66.666667
[ "-a, b = list(map(int, input().split()))", "-if a == b:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+n, m = list(map(int, input().split()))", "+print((\"Yes\" if n == m else \"No\"))" ]
false
0.04759
0.04276
1.112962
[ "s102305663", "s101437270" ]
u543954314
p02757
python
s558116620
s397640649
208
174
12,416
6,560
Accepted
Accepted
16.35
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: list(map(int, stdin.readline().split())) nl = lambda: list(map(int, stdin.readline().split())) n,p = nm() s = list(map(int, list(ns()))) ans = 0 if p == 2: for i in range(n): ...
n,p = list(map(int, input().split())) s = list(map(int, list(eval(input())))) if p in (2, 5): print((sum(i+1 for i in range(n) if s[i]%p == 0))) exit(0) ans = g = 0 d = [0]*p d[0] = 1 t = 1 for i in range(n-1,-1,-1): g = (g + s[i]*t)%p ans += d[g] d[g] += 1 t = (t*10)%p print(ans)
33
15
646
302
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: list(map(int, stdin.readline().split())) nl = lambda: list(map(int, stdin.readline().split())) n, p = nm() s = list(map(int, list(ns()))) ans = 0 if p == 2: for i in range(n): if s[i...
n, p = list(map(int, input().split())) s = list(map(int, list(eval(input())))) if p in (2, 5): print((sum(i + 1 for i in range(n) if s[i] % p == 0))) exit(0) ans = g = 0 d = [0] * p d[0] = 1 t = 1 for i in range(n - 1, -1, -1): g = (g + s[i] * t) % p ans += d[g] d[g] += 1 t = (t * 10) % p print(...
false
54.545455
[ "-import sys", "-", "-stdin = sys.stdin", "-ns = lambda: stdin.readline().rstrip()", "-ni = lambda: int(stdin.readline().rstrip())", "-nm = lambda: list(map(int, stdin.readline().split()))", "-nl = lambda: list(map(int, stdin.readline().split()))", "-n, p = nm()", "-s = list(map(int, list(ns())))", ...
false
0.063565
0.03564
1.783495
[ "s558116620", "s397640649" ]
u606045429
p03062
python
s583077271
s285527962
116
61
14,332
14,332
Accepted
Accepted
47.41
N = int(eval(input())) A = [int(i) for i in input().split()] a, b = 0, -1e10 for ai in A: a, b = max(a + ai, b - ai), max(a - ai, b + ai) print(a)
N = int(eval(input())) A = [int(i) for i in input().split()] B = [abs(a) for a in A] if len([a for a in A if a < 0]) % 2 == 1: print((sum(B) - 2 * min(B))) else: print((sum(B)))
8
8
153
184
N = int(eval(input())) A = [int(i) for i in input().split()] a, b = 0, -1e10 for ai in A: a, b = max(a + ai, b - ai), max(a - ai, b + ai) print(a)
N = int(eval(input())) A = [int(i) for i in input().split()] B = [abs(a) for a in A] if len([a for a in A if a < 0]) % 2 == 1: print((sum(B) - 2 * min(B))) else: print((sum(B)))
false
0
[ "-a, b = 0, -1e10", "-for ai in A:", "- a, b = max(a + ai, b - ai), max(a - ai, b + ai)", "-print(a)", "+B = [abs(a) for a in A]", "+if len([a for a in A if a < 0]) % 2 == 1:", "+ print((sum(B) - 2 * min(B)))", "+else:", "+ print((sum(B)))" ]
false
0.060871
0.043185
1.409536
[ "s583077271", "s285527962" ]
u906501980
p02744
python
s290776729
s055368633
295
227
36,944
21,848
Accepted
Accepted
23.05
n = int(eval(input())) s = "abcdefghij" class Node: # __slots__ = ["string", "index"] def __init__(self, string, index): self.string = string self.index = index def get_children(self): parent = self.string out = [None]*(self.index+2) for i, c in enumerat...
n = int(eval(input())) s = "abcdefghij" class Node: __slots__ = ["string", "index"] def __init__(self, string, index): self.string = string self.index = index def get_children(self): parent = self.string out = [None]*(self.index+1) for i, c in enumerate(...
24
25
645
687
n = int(eval(input())) s = "abcdefghij" class Node: # __slots__ = ["string", "index"] def __init__(self, string, index): self.string = string self.index = index def get_children(self): parent = self.string out = [None] * (self.index + 2) for i, c in enumerate(s...
n = int(eval(input())) s = "abcdefghij" class Node: __slots__ = ["string", "index"] def __init__(self, string, index): self.string = string self.index = index def get_children(self): parent = self.string out = [None] * (self.index + 1) for i, c in enumerate(s[: se...
false
4
[ "- # __slots__ = [\"string\", \"index\"]", "+ __slots__ = [\"string\", \"index\"]", "+", "- out = [None] * (self.index + 2)", "- for i, c in enumerate(s[: self.index + 1], 1):", "- out[i] = Node(parent + c, max(i, self.index))", "- return out[1:]", "+ o...
false
0.039476
0.045026
0.876734
[ "s290776729", "s055368633" ]
u188827677
p03387
python
s250371242
s690316175
30
26
9,224
9,120
Accepted
Accepted
13.33
abc = sorted(list(map(int, input().split()))) if (abc[0]%2==0 and abc[1]%2==0) or (abc[0]%2==1 and abc[1]%2==1): ans = 0 ans += abc[2]-abc[1] ans += (abc[1]-abc[0])//2 print(ans) else: count = 0 for i in abc: if i%2 == 0: count+=1 for i in range(len(abc)): if count == 2: if a...
abc = sorted(list(map(int, input().split()))) ans = 0 ans += abc[2]-abc[1] abc[0] += abc[2]-abc[1] abc[1] += abc[2]-abc[1] if (abc[2]-abc[0])%2 == 1: abc[1] += 1 abc[2] += 1 ans += 1 ans += (abc[2]-abc[0])//2 print(ans)
21
14
471
241
abc = sorted(list(map(int, input().split()))) if (abc[0] % 2 == 0 and abc[1] % 2 == 0) or (abc[0] % 2 == 1 and abc[1] % 2 == 1): ans = 0 ans += abc[2] - abc[1] ans += (abc[1] - abc[0]) // 2 print(ans) else: count = 0 for i in abc: if i % 2 == 0: count += 1 for i in range(...
abc = sorted(list(map(int, input().split()))) ans = 0 ans += abc[2] - abc[1] abc[0] += abc[2] - abc[1] abc[1] += abc[2] - abc[1] if (abc[2] - abc[0]) % 2 == 1: abc[1] += 1 abc[2] += 1 ans += 1 ans += (abc[2] - abc[0]) // 2 print(ans)
false
33.333333
[ "-if (abc[0] % 2 == 0 and abc[1] % 2 == 0) or (abc[0] % 2 == 1 and abc[1] % 2 == 1):", "- ans = 0", "- ans += abc[2] - abc[1]", "- ans += (abc[1] - abc[0]) // 2", "- print(ans)", "-else:", "- count = 0", "- for i in abc:", "- if i % 2 == 0:", "- count += 1", "...
false
0.035877
0.035822
1.001537
[ "s250371242", "s690316175" ]
u923668099
p02257
python
s497132852
s894948929
960
490
7,696
7,640
Accepted
Accepted
48.96
import sys def solve(): n = int(sys.stdin.readline()) ans = 0 for i in range(n): num = int(sys.stdin.readline()) ans += is_prime(num) print(ans) def is_prime(n): if n < 2: return False for p in range(2, n + 1): if p*p > n: brea...
import sys def solve(): n = int(sys.stdin.readline()) ans = 0 for i in range(n): num = int(sys.stdin.readline()) ans += is_prime(num) print(ans) def is_prime(n): if n < 2 or (n > 2 and n & 1 == 0): return False for p in range(3, n + 1, 2): ...
27
27
433
462
import sys def solve(): n = int(sys.stdin.readline()) ans = 0 for i in range(n): num = int(sys.stdin.readline()) ans += is_prime(num) print(ans) def is_prime(n): if n < 2: return False for p in range(2, n + 1): if p * p > n: break if n % p ...
import sys def solve(): n = int(sys.stdin.readline()) ans = 0 for i in range(n): num = int(sys.stdin.readline()) ans += is_prime(num) print(ans) def is_prime(n): if n < 2 or (n > 2 and n & 1 == 0): return False for p in range(3, n + 1, 2): if p * p > n: ...
false
0
[ "- if n < 2:", "+ if n < 2 or (n > 2 and n & 1 == 0):", "- for p in range(2, n + 1):", "+ for p in range(3, n + 1, 2):" ]
false
0.087326
0.068175
1.280899
[ "s497132852", "s894948929" ]
u064434060
p03645
python
s058574097
s010194021
1,018
923
89,816
58,328
Accepted
Accepted
9.33
n,m=list(map(int,input().split())) p=tuple(tuple(map(int,input().split())) for _ in range (m)) s=set() t=set() for i in range(m): if 1 in p[i]: s.add(p[i][0]) s.add(p[i][1]) if n in p[i]: t.add(p[i][0]) t.add(p[i][1]) res=s&t if res: print("POSSIBLE") else: ...
n,m=list(map(int,input().split())) s=set() t=set() for _ in range (m): a,b=(list(map(int,input().split()))) if a==1: s.add(b) if b==n: t.add(a) res=s&t if res: print("POSSIBLE") else: print("IMPOSSIBLE")
16
15
334
229
n, m = list(map(int, input().split())) p = tuple(tuple(map(int, input().split())) for _ in range(m)) s = set() t = set() for i in range(m): if 1 in p[i]: s.add(p[i][0]) s.add(p[i][1]) if n in p[i]: t.add(p[i][0]) t.add(p[i][1]) res = s & t if res: print("POSSIBLE") else: ...
n, m = list(map(int, input().split())) s = set() t = set() for _ in range(m): a, b = list(map(int, input().split())) if a == 1: s.add(b) if b == n: t.add(a) res = s & t if res: print("POSSIBLE") else: print("IMPOSSIBLE")
false
6.25
[ "-p = tuple(tuple(map(int, input().split())) for _ in range(m))", "-for i in range(m):", "- if 1 in p[i]:", "- s.add(p[i][0])", "- s.add(p[i][1])", "- if n in p[i]:", "- t.add(p[i][0])", "- t.add(p[i][1])", "+for _ in range(m):", "+ a, b = list(map(int, input()...
false
0.106219
0.18733
0.567019
[ "s058574097", "s010194021" ]
u022407960
p02282
python
s704722765
s237166940
50
30
7,784
7,788
Accepted
Accepted
40
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: preorder & inorder 5 1 2 3 4 5 3 2 4 1 5 9 1 2 3 4 5 6 7 8 9 3 2 5 4 6 1 8 7 9 output: postorder 3 4 2 5 1 """ import sys class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, No...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: preorder & inorder 5 1 2 3 4 5 3 2 4 1 5 9 1 2 3 4 5 6 7 8 9 3 2 5 4 6 1 8 7 9 output: postorder 3 4 2 5 1 """ import sys # recursively defines a binary tree # node.left or node.right may also be a binary tree class TreeNode: ...
51
53
1,190
1,280
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: preorder & inorder 5 1 2 3 4 5 3 2 4 1 5 9 1 2 3 4 5 6 7 8 9 3 2 5 4 6 1 8 7 9 output: postorder 3 4 2 5 1 """ import sys class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None def reconstruction(_pre_or...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: preorder & inorder 5 1 2 3 4 5 3 2 4 1 5 9 1 2 3 4 5 6 7 8 9 3 2 5 4 6 1 8 7 9 output: postorder 3 4 2 5 1 """ import sys # recursively defines a binary tree # node.left or node.right may also be a binary tree class TreeNode: def __init__(self, val): ...
false
3.773585
[ "-", "+# recursively defines a binary tree", "+# node.left or node.right may also be a binary tree" ]
false
0.044435
0.107184
0.414568
[ "s704722765", "s237166940" ]
u405110886
p03609
python
s853049814
s009506687
299
255
18,492
18,208
Accepted
Accepted
14.72
import numpy as np x, t = list(map(int, input().split())) print((max(x-t, 0)))
import numpy as np x, t = list(map(int, input().split())) print((np.max(np.array([x-t, 0]))))
3
3
72
87
import numpy as np x, t = list(map(int, input().split())) print((max(x - t, 0)))
import numpy as np x, t = list(map(int, input().split())) print((np.max(np.array([x - t, 0]))))
false
0
[ "-print((max(x - t, 0)))", "+print((np.max(np.array([x - t, 0]))))" ]
false
0.048317
0.342914
0.140901
[ "s853049814", "s009506687" ]
u935642171
p02608
python
s246456324
s416050700
921
824
9,440
9,568
Accepted
Accepted
10.53
n = int(eval(input())) cnt = [0]*(10**4+50) for i in range(1,105): for j in range(1,105): for k in range(1,105): v = (i**2)+(j**2)+(k**2)+i*j+j*k+k*i if v<10**4+50: cnt[v] += 1 for i in range(1,n+1): print((cnt[i]))
n = int(eval(input())) cnt = [0]*(n+1) for i in range(1,int(n**0.5)+1): for j in range(1,int(n**0.5)+1): for k in range(1,int(n**0.5)+1): v = (i**2)+(j**2)+(k**2)+i*j+j*k+k*i if v<=n: cnt[v] += 1 for i in range(1,n+1): print((cnt[i]))
11
11
246
266
n = int(eval(input())) cnt = [0] * (10**4 + 50) for i in range(1, 105): for j in range(1, 105): for k in range(1, 105): v = (i**2) + (j**2) + (k**2) + i * j + j * k + k * i if v < 10**4 + 50: cnt[v] += 1 for i in range(1, n + 1): print((cnt[i]))
n = int(eval(input())) cnt = [0] * (n + 1) for i in range(1, int(n**0.5) + 1): for j in range(1, int(n**0.5) + 1): for k in range(1, int(n**0.5) + 1): v = (i**2) + (j**2) + (k**2) + i * j + j * k + k * i if v <= n: cnt[v] += 1 for i in range(1, n + 1): print((cnt[...
false
0
[ "-cnt = [0] * (10**4 + 50)", "-for i in range(1, 105):", "- for j in range(1, 105):", "- for k in range(1, 105):", "+cnt = [0] * (n + 1)", "+for i in range(1, int(n**0.5) + 1):", "+ for j in range(1, int(n**0.5) + 1):", "+ for k in range(1, int(n**0.5) + 1):", "- if v ...
false
1.935747
0.047131
41.071978
[ "s246456324", "s416050700" ]
u137226361
p03044
python
s522438053
s461250755
605
536
58,872
45,548
Accepted
Accepted
11.4
n = int(input()) explored = set() next = [[]for _ in range(n)] from collections import deque ls = [] for i in range(n-1): u, v, w= map(int, input().split()) ls.append((u-1, v-1, w%2)) next[u-1].append((v-1, w%2)) next[v-1].append((u-1, w%2)) ans = [-1] * n exploring = deque() next_que ...
n = int(input()) explored = set() next = [[]for _ in range(n)] from collections import deque for i in range(n-1): u, v, w= map(int, input().split()) next[u-1].append((v-1, w%2)) next[v-1].append((u-1, w%2)) ans = [-1] * n exploring = deque() next_que = deque([0]) ans[0]=0 explored.add(0) whil...
31
25
663
592
n = int(input()) explored = set() next = [[] for _ in range(n)] from collections import deque ls = [] for i in range(n - 1): u, v, w = map(int, input().split()) ls.append((u - 1, v - 1, w % 2)) next[u - 1].append((v - 1, w % 2)) next[v - 1].append((u - 1, w % 2)) ans = [-1] * n exploring = deque() next...
n = int(input()) explored = set() next = [[] for _ in range(n)] from collections import deque for i in range(n - 1): u, v, w = map(int, input().split()) next[u - 1].append((v - 1, w % 2)) next[v - 1].append((u - 1, w % 2)) ans = [-1] * n exploring = deque() next_que = deque([0]) ans[0] = 0 explored.add(0) ...
false
19.354839
[ "-ls = []", "- ls.append((u - 1, v - 1, w % 2))", "- list = next[a]" ]
false
0.053594
0.03707
1.445751
[ "s522438053", "s461250755" ]
u844789719
p03157
python
s778296372
s906049555
848
696
6,040
54,364
Accepted
Accepted
17.92
import itertools H, W = [int(_) for _ in input().split()] S = [eval(input()) for _ in range(H)] is_searched = [[False for _ in range(W)] for _ in range(H)] def dfs(p, q): if is_searched[p][q] == 1: return 0 count = {'#': 0, '.': 0} que = [[p, q]] while que: x, y = que.pop(0...
import itertools H, W = [int(_) for _ in input().split()] S = [eval(input()) for _ in range(H)] is_searched = [[False for _ in range(W)] for _ in range(H)] def dfs(p, q): if is_searched[p][q] == 1: return 0 count = {'#': 0, '.': 0} stack = [[p, q]] while stack: x, y = stack...
25
25
775
782
import itertools H, W = [int(_) for _ in input().split()] S = [eval(input()) for _ in range(H)] is_searched = [[False for _ in range(W)] for _ in range(H)] def dfs(p, q): if is_searched[p][q] == 1: return 0 count = {"#": 0, ".": 0} que = [[p, q]] while que: x, y = que.pop(0) i...
import itertools H, W = [int(_) for _ in input().split()] S = [eval(input()) for _ in range(H)] is_searched = [[False for _ in range(W)] for _ in range(H)] def dfs(p, q): if is_searched[p][q] == 1: return 0 count = {"#": 0, ".": 0} stack = [[p, q]] while stack: x, y = stack.pop() ...
false
0
[ "- que = [[p, q]]", "- while que:", "- x, y = que.pop(0)", "+ stack = [[p, q]]", "+ while stack:", "+ x, y = stack.pop()", "- que += [[nx, ny]]", "+ stack += [[nx, ny]]" ]
false
0.176094
0.047279
3.724541
[ "s778296372", "s906049555" ]
u729133443
p04033
python
s423606308
s387135802
164
17
38,384
2,940
Accepted
Accepted
89.63
a,b=list(map(int,input().split()));print(('Zero'*(a+b==0or abs(a+b)<abs(a)+abs(b))or'NPeogsaittiivvee'[a>0or(b-a)%2::2]))
a,b=list(map(int,input().split()));print(('Zero'*(a*b<=0)or'PNoesgiattiivvee'[b<0and(b-a+1)%2::2]))
1
1
113
91
a, b = list(map(int, input().split())) print( ( "Zero" * (a + b == 0 or abs(a + b) < abs(a) + abs(b)) or "NPeogsaittiivvee"[a > 0 or (b - a) % 2 :: 2] ) )
a, b = list(map(int, input().split())) print(("Zero" * (a * b <= 0) or "PNoesgiattiivvee"[b < 0 and (b - a + 1) % 2 :: 2]))
false
0
[ "-print(", "- (", "- \"Zero\" * (a + b == 0 or abs(a + b) < abs(a) + abs(b))", "- or \"NPeogsaittiivvee\"[a > 0 or (b - a) % 2 :: 2]", "- )", "-)", "+print((\"Zero\" * (a * b <= 0) or \"PNoesgiattiivvee\"[b < 0 and (b - a + 1) % 2 :: 2]))" ]
false
0.118107
0.040347
2.927305
[ "s423606308", "s387135802" ]
u349724238
p03161
python
s977017140
s197556510
1,848
447
22,904
56,544
Accepted
Accepted
75.81
import numpy as np N,K = list(map(int, input().split())) A = list(map(int, input().split())) A = np.array(A) dp = np.zeros(N, dtype=int) dp[0] = 0 if N > K: for i in range(1,N): if i <= K: dp[i] = abs(A[i] - A[0]) else: j = max(i - K, 0) dp[i] = np.m...
N,K = list(map(int, input().split())) A = list(map(int, input().split())) dp = [0 for i in range(N)] dp[0] = 0 if N > K: for i in range(1,N): if i <= K: dp[i] = abs(A[i] - A[0]) else: L = [] for j in range(1,K+1): L.append(abs(A[i]-A[i...
17
17
405
413
import numpy as np N, K = list(map(int, input().split())) A = list(map(int, input().split())) A = np.array(A) dp = np.zeros(N, dtype=int) dp[0] = 0 if N > K: for i in range(1, N): if i <= K: dp[i] = abs(A[i] - A[0]) else: j = max(i - K, 0) dp[i] = np.min(np.abs(A...
N, K = list(map(int, input().split())) A = list(map(int, input().split())) dp = [0 for i in range(N)] dp[0] = 0 if N > K: for i in range(1, N): if i <= K: dp[i] = abs(A[i] - A[0]) else: L = [] for j in range(1, K + 1): L.append(abs(A[i] - A[i - j])...
false
0
[ "-import numpy as np", "-", "-A = np.array(A)", "-dp = np.zeros(N, dtype=int)", "+dp = [0 for i in range(N)]", "- j = max(i - K, 0)", "- dp[i] = np.min(np.abs(A[i] - A[j:i]) + dp[j:i])", "+ L = []", "+ for j in range(1, K + 1):", "+ L.appe...
false
0.174667
0.058571
2.982132
[ "s977017140", "s197556510" ]
u785578220
p03837
python
s902356851
s336985354
579
251
3,572
17,496
Accepted
Accepted
56.65
N, M = list(map(int, input().split())) inf = float("inf") dp = [[inf]*N for _ in [0]*N] for i in range(N):dp[i][i] = 0 d = [list(map(int, input().split())) for i in range(M)] ans = 0 for a,b,c in d: dp[a-1][b-1] = c dp[b-1][a-1] = c for k in range(N): for i in range(N): for j in range(...
N, M = list(map(int, input().split())) inf = float("inf") dp = [[inf]*N for _ in [0]*N] for i in range(N):dp[i][i] = 0 d = [list(map(int, input().split())) for i in range(M)] ans = 0 from scipy.sparse.csgraph import floyd_warshall for a,b,c in d: dp[a-1][b-1] = c dp[b-1][a-1] = c cost = floyd_warshal...
18
15
456
404
N, M = list(map(int, input().split())) inf = float("inf") dp = [[inf] * N for _ in [0] * N] for i in range(N): dp[i][i] = 0 d = [list(map(int, input().split())) for i in range(M)] ans = 0 for a, b, c in d: dp[a - 1][b - 1] = c dp[b - 1][a - 1] = c for k in range(N): for i in range(N): for j in r...
N, M = list(map(int, input().split())) inf = float("inf") dp = [[inf] * N for _ in [0] * N] for i in range(N): dp[i][i] = 0 d = [list(map(int, input().split())) for i in range(M)] ans = 0 from scipy.sparse.csgraph import floyd_warshall for a, b, c in d: dp[a - 1][b - 1] = c dp[b - 1][a - 1] = c cost = floy...
false
16.666667
[ "+from scipy.sparse.csgraph import floyd_warshall", "+", "-for k in range(N):", "- for i in range(N):", "- for j in range(N):", "- dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])", "+cost = floyd_warshall(dp)", "- if dp[a - 1][b - 1] != c:", "+ if cost[a - 1][b - 1] != c:" ]
false
0.040579
0.300862
0.134877
[ "s902356851", "s336985354" ]
u045091221
p03854
python
s237824000
s242122646
73
28
3,316
11,636
Accepted
Accepted
61.64
def solve(s, ws): while True: find_w = False for w in ws: if s.startswith(w): s = s[len(w):] find_w = True break if not s: return "YES" elif not find_w: return "NO" return None S ...
import re S = eval(input()) result = re.match(r'\A(dream(er)?|erase(r)?)+\Z', S) if result: print('YES') else: print('NO')
18
8
420
132
def solve(s, ws): while True: find_w = False for w in ws: if s.startswith(w): s = s[len(w) :] find_w = True break if not s: return "YES" elif not find_w: return "NO" return None S = input()[::-1...
import re S = eval(input()) result = re.match(r"\A(dream(er)?|erase(r)?)+\Z", S) if result: print("YES") else: print("NO")
false
55.555556
[ "-def solve(s, ws):", "- while True:", "- find_w = False", "- for w in ws:", "- if s.startswith(w):", "- s = s[len(w) :]", "- find_w = True", "- break", "- if not s:", "- return \"YES\"", "- elif no...
false
0.037124
0.082536
0.449791
[ "s237824000", "s242122646" ]
u794173881
p02936
python
s462443082
s876887533
1,922
947
136,360
135,524
Accepted
Accepted
50.73
from collections import deque n, q = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(n-1)] p = [list(map(int, input().split())) for i in range(q)] tree = [[] for i in range(n)] for i in range(n-1): tree[info[i][0] - 1].append(info[i][1] - 1) tree[info[i][1] - ...
from collections import deque import sys input = sys.stdin.readline n, q = list(map(int, input().split())) info = [tuple(map(int, input().split())) for i in range(n-1)] p = [tuple(map(int, input().split())) for i in range(q)] tree = [[] for i in range(n)] for i in range(n-1): tree[info[i][0] - 1].appe...
33
35
776
819
from collections import deque n, q = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(n - 1)] p = [list(map(int, input().split())) for i in range(q)] tree = [[] for i in range(n)] for i in range(n - 1): tree[info[i][0] - 1].append(info[i][1] - 1) tree[info[i][1] - 1].appen...
from collections import deque import sys input = sys.stdin.readline n, q = list(map(int, input().split())) info = [tuple(map(int, input().split())) for i in range(n - 1)] p = [tuple(map(int, input().split())) for i in range(q)] tree = [[] for i in range(n)] for i in range(n - 1): tree[info[i][0] - 1].append(info[i...
false
5.714286
[ "+import sys", "+input = sys.stdin.readline", "-info = [list(map(int, input().split())) for i in range(n - 1)]", "-p = [list(map(int, input().split())) for i in range(q)]", "+info = [tuple(map(int, input().split())) for i in range(n - 1)]", "+p = [tuple(map(int, input().split())) for i in range(q)]" ]
false
0.04603
0.069905
0.658457
[ "s462443082", "s876887533" ]
u596276291
p03798
python
s824274131
s430899009
289
247
7,872
5,612
Accepted
Accepted
14.53
from collections import defaultdict def solve(s, l): for now in range(1, len(s) + 1): now %= len(s) pre = now - 1 nex = (now + 1) % len(s) # 整合性のチェック if l[pre] is not None and l[nex] is not None: if l[now] == 1: if s[now] == "o": ...
from collections import defaultdict def ok(l, s): for i in range(len(s) * 2): now = i % len(l) pre = now - 1 nex = (now + 1) % len(l) if (l[now] == -1 and s[now] == 'x') or (l[now] == 1 and s[now] == 'o'): if l[nex] is None: l[nex] = l[pre] ...
66
39
1,647
943
from collections import defaultdict def solve(s, l): for now in range(1, len(s) + 1): now %= len(s) pre = now - 1 nex = (now + 1) % len(s) # 整合性のチェック if l[pre] is not None and l[nex] is not None: if l[now] == 1: if s[now] == "o": ...
from collections import defaultdict def ok(l, s): for i in range(len(s) * 2): now = i % len(l) pre = now - 1 nex = (now + 1) % len(l) if (l[now] == -1 and s[now] == "x") or (l[now] == 1 and s[now] == "o"): if l[nex] is None: l[nex] = l[pre] e...
false
40.909091
[ "-def solve(s, l):", "- for now in range(1, len(s) + 1):", "- now %= len(s)", "+def ok(l, s):", "+ for i in range(len(s) * 2):", "+ now = i % len(l)", "- nex = (now + 1) % len(s)", "- # 整合性のチェック", "- if l[pre] is not None and l[nex] is not None:", "- ...
false
0.036449
0.04581
0.795663
[ "s824274131", "s430899009" ]
u426683236
p03545
python
s202950992
s255235669
185
17
38,256
3,064
Accepted
Accepted
90.81
def solve(): S=list(eval(input())) for i in range(8): ans=int(S[0]) for j in range(3): if (i & (1 << j)) != 0: ans+=int(S[j+1]) else: ans-=int(S[j+1]) if ans==7: ans=S[0] for j in range(3): ...
def solve(): n = list(eval(input())) n = [ord(c) - ord('0') for c in n] sign = ['-', '+'] for i in range(2): for j in range(2): for k in range(2): t = n[0] t += n[1] * (i * 2 - 1) t += n[2] * (j * 2 - 1) t +=...
20
19
507
540
def solve(): S = list(eval(input())) for i in range(8): ans = int(S[0]) for j in range(3): if (i & (1 << j)) != 0: ans += int(S[j + 1]) else: ans -= int(S[j + 1]) if ans == 7: ans = S[0] for j in range(3): ...
def solve(): n = list(eval(input())) n = [ord(c) - ord("0") for c in n] sign = ["-", "+"] for i in range(2): for j in range(2): for k in range(2): t = n[0] t += n[1] * (i * 2 - 1) t += n[2] * (j * 2 - 1) t += n[3] * (k *...
false
5
[ "- S = list(eval(input()))", "- for i in range(8):", "- ans = int(S[0])", "- for j in range(3):", "- if (i & (1 << j)) != 0:", "- ans += int(S[j + 1])", "- else:", "- ans -= int(S[j + 1])", "- if ans == 7:", "- ...
false
0.039574
0.064819
0.610533
[ "s202950992", "s255235669" ]
u310678820
p03634
python
s804061489
s337099106
1,589
563
81,696
70,412
Accepted
Accepted
64.57
import collections N = int(eval(input())) List = [[] for _ in range(N)] ans = [-1]*N for i in range(N-1): a, b, c = list(map(int, input().split())) List[a-1].append((b-1, c)) List[b-1].append((a-1, c)) Q, K = list(map(int, input().split())) queue = collections.deque([K-1]) ans[K-1] = 0 while queu...
import sys input = sys.stdin.readline N = int(eval(input())) List = [[] for _ in range(N)] ans = [-1]*N for i in range(N-1): a, b, c = list(map(int, input().split())) List[a-1].append((b-1, c)) List[b-1].append((a-1, c)) Q, K = list(map(int, input().split())) queue = [K-1] ans[K-1] = 0 while que...
22
23
587
588
import collections N = int(eval(input())) List = [[] for _ in range(N)] ans = [-1] * N for i in range(N - 1): a, b, c = list(map(int, input().split())) List[a - 1].append((b - 1, c)) List[b - 1].append((a - 1, c)) Q, K = list(map(int, input().split())) queue = collections.deque([K - 1]) ans[K - 1] = 0 whil...
import sys input = sys.stdin.readline N = int(eval(input())) List = [[] for _ in range(N)] ans = [-1] * N for i in range(N - 1): a, b, c = list(map(int, input().split())) List[a - 1].append((b - 1, c)) List[b - 1].append((a - 1, c)) Q, K = list(map(int, input().split())) queue = [K - 1] ans[K - 1] = 0 whil...
false
4.347826
[ "-import collections", "+import sys", "+input = sys.stdin.readline", "-queue = collections.deque([K - 1])", "+queue = [K - 1]" ]
false
0.083922
0.075084
1.117697
[ "s804061489", "s337099106" ]
u700805562
p02762
python
s529370694
s396418584
1,962
1,363
83,600
50,040
Accepted
Accepted
30.53
from collections import deque import sys input = sys.stdin.readline n, m, k = list(map(int, input().split())) friend = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) friend[a-1].append(b-1) friend[b-1].append(a-1) check = [0]*n union = [-1]*n union[0] = 0 for i ...
def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] def unite(x,y): x = find(x) y = find(y) if x == y: return False #sizeの大きいほうがx if par[x] > par[y]: x,y = y,x par[x] += par[y] par[y] = x return True #xとy...
43
48
1,108
973
from collections import deque import sys input = sys.stdin.readline n, m, k = list(map(int, input().split())) friend = [[] for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) friend[a - 1].append(b - 1) friend[b - 1].append(a - 1) check = [0] * n union = [-1] * n union[0] = 0 for i...
def find(x): if par[x] < 0: return x else: par[x] = find(par[x]) return par[x] def unite(x, y): x = find(x) y = find(y) if x == y: return False # sizeの大きいほうがx if par[x] > par[y]: x, y = y, x par[x] += par[y] par[y] = x return True # xとy...
false
10.416667
[ "-from collections import deque", "-import sys", "+def find(x):", "+ if par[x] < 0:", "+ return x", "+ else:", "+ par[x] = find(par[x])", "+ return par[x]", "-input = sys.stdin.readline", "+", "+def unite(x, y):", "+ x = find(x)", "+ y = find(y)", "+ if ...
false
0.03813
0.133253
0.286149
[ "s529370694", "s396418584" ]
u285891772
p03013
python
s914748132
s808201205
167
126
11,576
10,768
Accepted
Accepted
24.55
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 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter...
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 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter...
36
39
1,126
1,135
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 from itertools import ( accumulate, permutations, combinations, combi...
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 from itertools import ( accumulate, permutations, combinations, combi...
false
7.692308
[ "+dp = [0] * (N + 1)", "+dp[0] = 1", "+dp[1] = 1", "-dp = [0] * (N + 1)", "-dp[0] = 1", "-dp[1] = 1", "+if check[1] == 1:", "+ dp[1] = 0", "- for j in range(1, 3):", "- if not check[i - j]:", "- dp[i] = (dp[i] + dp[i - j]) % mod", "+ if not check[i]:", "+ dp...
false
0.038657
0.038765
0.997225
[ "s914748132", "s808201205" ]
u708255304
p03087
python
s898831697
s776566056
840
254
6,100
13,456
Accepted
Accepted
69.76
N, Q = list(map(int, input().split())) S = str(eval(input())) ruisekiwa = [0] for i in range(len(S)): if S[i] == 'C' and S[i-1] == 'A': ruisekiwa.append(ruisekiwa[-1]+1) else: ruisekiwa.append(ruisekiwa[-1]) # print(ruisekiwa) for i in range(Q): l, r = list(map(int, input().s...
import sys N, Q = list(map(int, input().split())) S = str(eval(input())) ruisekiwa = [0] for i in range(len(S)): if S[i] == 'C' and S[i-1] == 'A': ruisekiwa.append(ruisekiwa[-1]+1) else: ruisekiwa.append(ruisekiwa[-1]) # print(ruisekiwa) for line in sys.stdin.readlines(): ...
15
17
349
384
N, Q = list(map(int, input().split())) S = str(eval(input())) ruisekiwa = [0] for i in range(len(S)): if S[i] == "C" and S[i - 1] == "A": ruisekiwa.append(ruisekiwa[-1] + 1) else: ruisekiwa.append(ruisekiwa[-1]) # print(ruisekiwa) for i in range(Q): l, r = list(map(int, input().split())) ...
import sys N, Q = list(map(int, input().split())) S = str(eval(input())) ruisekiwa = [0] for i in range(len(S)): if S[i] == "C" and S[i - 1] == "A": ruisekiwa.append(ruisekiwa[-1] + 1) else: ruisekiwa.append(ruisekiwa[-1]) # print(ruisekiwa) for line in sys.stdin.readlines(): l, r = list(ma...
false
11.764706
[ "+import sys", "+", "-for i in range(Q):", "- l, r = list(map(int, input().split()))", "+for line in sys.stdin.readlines():", "+ l, r = list(map(int, line.strip().split()))" ]
false
0.037772
0.037875
0.997291
[ "s898831697", "s776566056" ]
u357751375
p02571
python
s854158725
s949255776
80
58
9,016
9,028
Accepted
Accepted
27.5
s = eval(input()) t = eval(input()) n = len(s) m = len(t) ans = m for i in range(n-m+1): x = m for j in range(m): if s[i+j] == t[j]: x -= 1 ans = min(ans,x) print(ans)
s = eval(input()) t = eval(input()) n = len(s) m = len(t) ans = m for i in range(n-m+1): p = 0 for j in range(m): if s[i+j] != t[j]: p += 1 ans = min(ans,p) print(ans)
12
12
198
198
s = eval(input()) t = eval(input()) n = len(s) m = len(t) ans = m for i in range(n - m + 1): x = m for j in range(m): if s[i + j] == t[j]: x -= 1 ans = min(ans, x) print(ans)
s = eval(input()) t = eval(input()) n = len(s) m = len(t) ans = m for i in range(n - m + 1): p = 0 for j in range(m): if s[i + j] != t[j]: p += 1 ans = min(ans, p) print(ans)
false
0
[ "- x = m", "+ p = 0", "- if s[i + j] == t[j]:", "- x -= 1", "- ans = min(ans, x)", "+ if s[i + j] != t[j]:", "+ p += 1", "+ ans = min(ans, p)" ]
false
0.040597
0.09772
0.415441
[ "s854158725", "s949255776" ]
u627803856
p02761
python
s548856621
s782383018
184
19
38,384
3,064
Accepted
Accepted
89.67
n,m = list(map(int,input().split())) digit = [0]*(m) value = [0]*(m) for i in range(m): digit[i],value[i] = list(map(int,input().split())) #全探索 ans = 0 for i in range(10**3): s = str(i) if len(s)!=n: continue for j in range(m): if int(s[digit[j]-1]) != value[j]: break ...
n, m = list(map(int, input().split())) s, c = [], [] for i in range(m): a, b = list(map(int, input().split())) s.append(a - 1) c.append(b) for i in range(0, 1000): now = str(i) if len(now) != n: continue is_condition = True for j in range(m): if int(now[s[j]...
18
22
366
422
n, m = list(map(int, input().split())) digit = [0] * (m) value = [0] * (m) for i in range(m): digit[i], value[i] = list(map(int, input().split())) # 全探索 ans = 0 for i in range(10**3): s = str(i) if len(s) != n: continue for j in range(m): if int(s[digit[j] - 1]) != value[j]: ...
n, m = list(map(int, input().split())) s, c = [], [] for i in range(m): a, b = list(map(int, input().split())) s.append(a - 1) c.append(b) for i in range(0, 1000): now = str(i) if len(now) != n: continue is_condition = True for j in range(m): if int(now[s[j]]) != c[j]: ...
false
18.181818
[ "-digit = [0] * (m)", "-value = [0] * (m)", "+s, c = [], []", "- digit[i], value[i] = list(map(int, input().split()))", "-# 全探索", "-ans = 0", "-for i in range(10**3):", "- s = str(i)", "- if len(s) != n:", "+ a, b = list(map(int, input().split()))", "+ s.append(a - 1)", "+ c....
false
0.08662
0.045811
1.890835
[ "s548856621", "s782383018" ]
u979667682
p02689
python
s213497670
s348432482
291
182
116,636
101,276
Accepted
Accepted
37.46
from sys import stdin import math import fractions from collections import deque from collections import Counter import itertools INF = 10 ** 10 N, M = [int(x) for x in stdin.readline().rstrip().split()] # 展望台iの標高 H = [int(x) for x in stdin.readline().rstrip().split()] AB = [list(map(int, stdin.readline()...
from sys import stdin import math import fractions from collections import deque from collections import Counter import itertools INF = 10 ** 10 N, M = [int(x) for x in stdin.readline().rstrip().split()] # 展望台iの標高 H = [0] + [int(x) for x in stdin.readline().rstrip().split()] AB = [list(map(int, stdin.read...
36
27
727
603
from sys import stdin import math import fractions from collections import deque from collections import Counter import itertools INF = 10**10 N, M = [int(x) for x in stdin.readline().rstrip().split()] # 展望台iの標高 H = [int(x) for x in stdin.readline().rstrip().split()] AB = [list(map(int, stdin.readline().rstrip().split...
from sys import stdin import math import fractions from collections import deque from collections import Counter import itertools INF = 10**10 N, M = [int(x) for x in stdin.readline().rstrip().split()] # 展望台iの標高 H = [0] + [int(x) for x in stdin.readline().rstrip().split()] AB = [list(map(int, stdin.readline().rstrip()...
false
25
[ "-H = [int(x) for x in stdin.readline().rstrip().split()]", "+H = [0] + [int(x) for x in stdin.readline().rstrip().split()]", "-dic = {}", "-for i in range(N):", "- dic[i + 1] = []", "+near_max = [0 for _ in range(N + 1)]", "- dic[A].append(B)", "- dic[B].append(A)", "+ near_max[A] = max...
false
0.120983
0.042319
2.858862
[ "s213497670", "s348432482" ]
u627600101
p02609
python
s509743715
s247019003
418
196
20,564
109,752
Accepted
Accepted
53.11
N = int(eval(input())) X = eval(input()) ans = [1 for _ in range(N)] if N == 1: if X[0] == '1': print((0)) exit() else: print((1)) exit() l = X.count('1') if l == 0: for _ in range(N): print((1)) exit() if l == 1: if X[-1] == '1': for _ in range(N-1): an...
N = int(eval(input())) X = eval(input()) ans = [1 for _ in range(N)] if N == 1: if X[0] == '1': print((0)) exit() else: print((1)) exit() l = X.count('1') if l == 0: for _ in range(N): print((1)) exit() if l == 1: if X[-1] == '1': for _ in range(N-1): an...
87
74
1,464
1,250
N = int(eval(input())) X = eval(input()) ans = [1 for _ in range(N)] if N == 1: if X[0] == "1": print((0)) exit() else: print((1)) exit() l = X.count("1") if l == 0: for _ in range(N): print((1)) exit() if l == 1: if X[-1] == "1": for _ in range(N - 1)...
N = int(eval(input())) X = eval(input()) ans = [1 for _ in range(N)] if N == 1: if X[0] == "1": print((0)) exit() else: print((1)) exit() l = X.count("1") if l == 0: for _ in range(N): print((1)) exit() if l == 1: if X[-1] == "1": for _ in range(N - 1)...
false
14.942529
[ "-\"\"\"", "-poplist = [0 for _ in range(l+1)]", "-t = 1", "-while t < l + 2:", "- for k in range(t, l+1, 2*t):", "- for j in range(t):", "- if k+j>l:", "- break", "- poplist[k+j] += 1", "- t *= 2", "-\"\"\"", "-poplist = newpoplist", "- start[k] = start[k] %...
false
0.04012
0.141233
0.28407
[ "s509743715", "s247019003" ]
u298297089
p03739
python
s461348931
s896762608
123
92
14,468
15,868
Accepted
Accepted
25.2
N = int(eval(input())) A = list(map(int, input().split())) x = 0 tmp = 0 for i in range(N): tmp += A[i] if i & 1 == 0: if tmp < 1: x += 1-tmp tmp = 1 else: if tmp > -1: x += 1+tmp tmp = -1 y = 0 tmp = 0 for i in range(N): ...
n = int(eval(input())) a = list(map(int, input().split())) def check(flag): acc = 0 cnt = 0 flag = flag for i in a: acc += i if (flag == 1 and flag > acc) or (flag == -1 and flag < acc) or i == 0: cnt += abs(flag - acc) acc = flag flag *= -1...
28
18
503
368
N = int(eval(input())) A = list(map(int, input().split())) x = 0 tmp = 0 for i in range(N): tmp += A[i] if i & 1 == 0: if tmp < 1: x += 1 - tmp tmp = 1 else: if tmp > -1: x += 1 + tmp tmp = -1 y = 0 tmp = 0 for i in range(N): tmp += A[i] ...
n = int(eval(input())) a = list(map(int, input().split())) def check(flag): acc = 0 cnt = 0 flag = flag for i in a: acc += i if (flag == 1 and flag > acc) or (flag == -1 and flag < acc) or i == 0: cnt += abs(flag - acc) acc = flag flag *= -1 return c...
false
35.714286
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-x = 0", "-tmp = 0", "-for i in range(N):", "- tmp += A[i]", "- if i & 1 == 0:", "- if tmp < 1:", "- x += 1 - tmp", "- tmp = 1", "- else:", "- if tmp > -1:", "- x += 1 ...
false
0.037836
0.042029
0.900229
[ "s461348931", "s896762608" ]
u998741086
p02614
python
s883245299
s859430013
147
62
12,568
9,488
Accepted
Accepted
57.82
#!/usr/bin/env python3 import itertools import copy h, w, k = list(map(int, input().split())) c = [[] for _ in range(h)] for i in range(h): c[i] = list(eval(input())) ccs = [] hnum = list(range(h)) wnum = list(range(w)) def countBlack(cc): ans = 0 for i in range(h): ans += cc[...
#!/usr/bin/env python3 import itertools import copy H, W, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(H)] clist = list(itertools.product([0, 1], repeat=H+W)) #print(clist) ans = 0 for q in clist: black = 0 h = q[:H] w = q[H:] # print('h =', h) #...
58
28
1,484
528
#!/usr/bin/env python3 import itertools import copy h, w, k = list(map(int, input().split())) c = [[] for _ in range(h)] for i in range(h): c[i] = list(eval(input())) ccs = [] hnum = list(range(h)) wnum = list(range(w)) def countBlack(cc): ans = 0 for i in range(h): ans += cc[i].count("#") re...
#!/usr/bin/env python3 import itertools import copy H, W, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(H)] clist = list(itertools.product([0, 1], repeat=H + W)) # print(clist) ans = 0 for q in clist: black = 0 h = q[:H] w = q[H:] # print('h =', h) # print('w =', w) ...
false
51.724138
[ "-h, w, k = list(map(int, input().split()))", "-c = [[] for _ in range(h)]", "-for i in range(h):", "- c[i] = list(eval(input()))", "-ccs = []", "-hnum = list(range(h))", "-wnum = list(range(w))", "-", "-", "-def countBlack(cc):", "- ans = 0", "- for i in range(h):", "- ans +...
false
0.059224
0.073895
0.801458
[ "s883245299", "s859430013" ]
u402629484
p02684
python
s033373914
s637311645
145
124
34,016
32,324
Accepted
Accepted
14.48
import sys sys.setrecursionlimit(1000000000) import math from math import gcd def lcm(a, b): return a * b // gcd(a, b) from itertools import count, permutations, chain from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lam...
''' ・基本的には素直なシミュレーションを行う ・ループ分のシミュレーションを省略することでTLEを回避 ・Kは「残りのワープ数」と考える K回のワープ中にループが含まれる場合、 1. 素直なシミュレーションを行う。このとき、Kを減算していく。 2. ループを検出したら、Kからループ長をできるだけ多く引くことで、計算を省略する。 3. 残りのステップ数、再度シミュレーションを行う という手順で答えを求められる。 なお、ループが含まれない場合も1のみで答えを求められる。 ''' def main(): N, K = list(map(int, input().split())) A ...
101
32
2,391
826
import sys sys.setrecursionlimit(1000000000) import math from math import gcd def lcm(a, b): return a * b // gcd(a, b) from itertools import count, permutations, chain from functools import lru_cache from collections import deque, defaultdict from pprint import pprint ii = lambda: int(eval(input())) mis = lam...
""" ・基本的には素直なシミュレーションを行う ・ループ分のシミュレーションを省略することでTLEを回避 ・Kは「残りのワープ数」と考える K回のワープ中にループが含まれる場合、 1. 素直なシミュレーションを行う。このとき、Kを減算していく。 2. ループを検出したら、Kからループ長をできるだけ多く引くことで、計算を省略する。 3. 残りのステップ数、再度シミュレーションを行う という手順で答えを求められる。 なお、ループが含まれない場合も1のみで答えを求められる。 """ def main(): N, K = list(map(int, input().split())) A = [a - 1 for a ...
false
68.316832
[ "-import sys", "-", "-sys.setrecursionlimit(1000000000)", "-import math", "-from math import gcd", "-", "-", "-def lcm(a, b):", "- return a * b // gcd(a, b)", "-", "-", "-from itertools import count, permutations, chain", "-from functools import lru_cache", "-from collections import deq...
false
0.038196
0.036004
1.060881
[ "s033373914", "s637311645" ]
u318127926
p03435
python
s052218454
s767938564
20
17
3,188
3,064
Accepted
Accepted
15
c = [] for _ in range(3): c.append(list(map(int, input().split()))) a = [] for i in range(3): tmp = [] for j in range(3): tmp.append(c[i][j%3] - c[i][(j+1)%3]) a.append(tmp) for i in range(2): for j in range(3): if a[i][j]!=a[i+1][j]: print('No') ...
c = [] for _ in range(3): c.append(list(map(int, input().split()))) for i in range(2): if c[i][0]-c[i][1]!=c[i+1][0]-c[i+1][1]: print('No') break if c[i][1]-c[i][2]!=c[i+1][1]-c[i+1][2]: print('No') break if c[i][2]-c[i][0]!=c[i+1][2]-c[i+1][0]: print...
19
16
390
366
c = [] for _ in range(3): c.append(list(map(int, input().split()))) a = [] for i in range(3): tmp = [] for j in range(3): tmp.append(c[i][j % 3] - c[i][(j + 1) % 3]) a.append(tmp) for i in range(2): for j in range(3): if a[i][j] != a[i + 1][j]: print("No") bre...
c = [] for _ in range(3): c.append(list(map(int, input().split()))) for i in range(2): if c[i][0] - c[i][1] != c[i + 1][0] - c[i + 1][1]: print("No") break if c[i][1] - c[i][2] != c[i + 1][1] - c[i + 1][2]: print("No") break if c[i][2] - c[i][0] != c[i + 1][2] - c[i + 1][...
false
15.789474
[ "-a = []", "-for i in range(3):", "- tmp = []", "- for j in range(3):", "- tmp.append(c[i][j % 3] - c[i][(j + 1) % 3])", "- a.append(tmp)", "- for j in range(3):", "- if a[i][j] != a[i + 1][j]:", "- print(\"No\")", "- break", "- else:", "- ...
false
0.049247
0.047922
1.027655
[ "s052218454", "s767938564" ]
u729133443
p03089
python
s939381517
s955677683
172
18
38,768
3,060
Accepted
Accepted
89.53
n,*b=list(map(int,open(0).read().split())) a=[] while n: j=-1 for i in range(n): if b[i]==i+1: j=i if j+1: b=b[:j]+b[j+1:] a+=[j+1] else: a=[-1] break n-=1 print((*a[::-1]))
n,*b=list(map(int,open(0).read().split())) a=[] while b: j=max(i*(i==v)for i,v in enumerate(b,1)) if j: b=b[:j-1]+b[j:] a+=[j] else: a=[-1] break print((*a[::-1]))
15
11
215
187
n, *b = list(map(int, open(0).read().split())) a = [] while n: j = -1 for i in range(n): if b[i] == i + 1: j = i if j + 1: b = b[:j] + b[j + 1 :] a += [j + 1] else: a = [-1] break n -= 1 print((*a[::-1]))
n, *b = list(map(int, open(0).read().split())) a = [] while b: j = max(i * (i == v) for i, v in enumerate(b, 1)) if j: b = b[: j - 1] + b[j:] a += [j] else: a = [-1] break print((*a[::-1]))
false
26.666667
[ "-while n:", "- j = -1", "- for i in range(n):", "- if b[i] == i + 1:", "- j = i", "- if j + 1:", "- b = b[:j] + b[j + 1 :]", "- a += [j + 1]", "+while b:", "+ j = max(i * (i == v) for i, v in enumerate(b, 1))", "+ if j:", "+ b = b[: j - 1]...
false
0.105618
0.042258
2.499343
[ "s939381517", "s955677683" ]
u868600519
p03456
python
s962170469
s636507639
22
17
2,940
2,940
Accepted
Accepted
22.73
import math ab = int(input().replace(' ', '')) r = round(math.sqrt(ab)) print(('Yes' if r**2 == ab else 'No'))
import math ab = int(input().replace(' ', '')) print(('Yes' if math.sqrt(ab).is_integer() else 'No'))
6
5
116
106
import math ab = int(input().replace(" ", "")) r = round(math.sqrt(ab)) print(("Yes" if r**2 == ab else "No"))
import math ab = int(input().replace(" ", "")) print(("Yes" if math.sqrt(ab).is_integer() else "No"))
false
16.666667
[ "-r = round(math.sqrt(ab))", "-print((\"Yes\" if r**2 == ab else \"No\"))", "+print((\"Yes\" if math.sqrt(ab).is_integer() else \"No\"))" ]
false
0.044142
0.087142
0.506555
[ "s962170469", "s636507639" ]
u187516587
p02911
python
s513123883
s712252381
261
152
4,680
4,680
Accepted
Accepted
41.76
N,K,Q=list(map(int,input().split())) l=[0]*N for _ in range(Q): l[int(eval(input()))-1]+=1 for i in l: if Q-i<K: print("Yes") else: print("No")
import sys def input(): return sys.stdin.readline()[:-1] N,K,Q=list(map(int,input().split())) l=[0]*N for _ in range(Q): l[int(eval(input()))-1]+=1 for i in l: if Q-i<K: print("Yes") else: print("No")
9
13
168
234
N, K, Q = list(map(int, input().split())) l = [0] * N for _ in range(Q): l[int(eval(input())) - 1] += 1 for i in l: if Q - i < K: print("Yes") else: print("No")
import sys def input(): return sys.stdin.readline()[:-1] N, K, Q = list(map(int, input().split())) l = [0] * N for _ in range(Q): l[int(eval(input())) - 1] += 1 for i in l: if Q - i < K: print("Yes") else: print("No")
false
30.769231
[ "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline()[:-1]", "+", "+" ]
false
0.035174
0.036821
0.955269
[ "s513123883", "s712252381" ]
u028973125
p03044
python
s872509527
s808287971
465
415
55,724
49,732
Accepted
Accepted
10.75
import sys from collections import deque def solve(tree, u, v): colors = {} colors[u] = 0 stack = deque([u]) while stack: u = stack.pop() for v in tree[u]: if v in colors: continue stack.append(v) if tree[u][v] % 2 == ...
import sys from collections import deque input = sys.stdin.readline N = int(eval(input())) edges = [[] for _ in range(N)] for _ in range(N-1): u, v, w = list(map(int, input().split())) edges[u-1].append((v-1, w)) edges[v-1].append((u-1, w)) q = deque() q.append((0, 0)) color = {} while q: ...
38
27
870
584
import sys from collections import deque def solve(tree, u, v): colors = {} colors[u] = 0 stack = deque([u]) while stack: u = stack.pop() for v in tree[u]: if v in colors: continue stack.append(v) if tree[u][v] % 2 == 0: ...
import sys from collections import deque input = sys.stdin.readline N = int(eval(input())) edges = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) edges[u - 1].append((v - 1, w)) edges[v - 1].append((u - 1, w)) q = deque() q.append((0, 0)) color = {} while q: nod...
false
28.947368
[ "-", "-def solve(tree, u, v):", "- colors = {}", "- colors[u] = 0", "- stack = deque([u])", "- while stack:", "- u = stack.pop()", "- for v in tree[u]:", "- if v in colors:", "- continue", "- stack.append(v)", "- if tree...
false
0.038916
0.046089
0.844357
[ "s872509527", "s808287971" ]
u298297089
p02954
python
s374062359
s409032650
195
160
8,040
8,000
Accepted
Accepted
17.95
S = eval(input()) l = [] r = [] tmp = 0 for s in S: if s == 'L': r.append(tmp) tmp = 0 else: r.append(0) tmp += 1 tmp = 0 for s in S[::-1]: if s == 'R': l.append(tmp) tmp = 0 else: l.append(0) tmp += 1 l = l[::-1] ans ...
s = eval(input()) right, left = [], [] r,l = 0,0 for i in range(len(s)): if s[i] == 'R': r += 1 right.append(0) else: right.append(r) r = 0 if s[-i-1] == 'L': l += 1 left.append(0) else: left.append(l) l = 0 left = left[::...
26
29
487
584
S = eval(input()) l = [] r = [] tmp = 0 for s in S: if s == "L": r.append(tmp) tmp = 0 else: r.append(0) tmp += 1 tmp = 0 for s in S[::-1]: if s == "R": l.append(tmp) tmp = 0 else: l.append(0) tmp += 1 l = l[::-1] ans = [0 for i in range(le...
s = eval(input()) right, left = [], [] r, l = 0, 0 for i in range(len(s)): if s[i] == "R": r += 1 right.append(0) else: right.append(r) r = 0 if s[-i - 1] == "L": l += 1 left.append(0) else: left.append(l) l = 0 left = left[::-1] ans = [0] ...
false
10.344828
[ "-S = eval(input())", "-l = []", "-r = []", "-tmp = 0", "-for s in S:", "- if s == \"L\":", "- r.append(tmp)", "- tmp = 0", "+s = eval(input())", "+right, left = [], []", "+r, l = 0, 0", "+for i in range(len(s)):", "+ if s[i] == \"R\":", "+ r += 1", "+ r...
false
0.074091
0.049868
1.485749
[ "s374062359", "s409032650" ]
u729133443
p03221
python
s029668249
s258962680
677
613
31,172
31,172
Accepted
Accepted
9.45
I=lambda:list(map(int,input().split()))[::-1];m,n=I();c=[0]*-~n;a=[0]*m for y,p,i in sorted(I()+[i]for i in range(m)):c[p]+=1;a[i]='%06d'%p+'%06d'%c[p] for t in a:print(t)
I=lambda:list(map(int,input().split()))[::-1];m,n=I();c=[0]*-~n;a=[0]*m for y,p,i in sorted(I()+[i]for i in range(m)):c[p]+=1;a[i]='%06d%06d'%(p,c[p]) print(('\n'.join(a)))
3
3
173
172
I = lambda: list(map(int, input().split()))[::-1] m, n = I() c = [0] * -~n a = [0] * m for y, p, i in sorted(I() + [i] for i in range(m)): c[p] += 1 a[i] = "%06d" % p + "%06d" % c[p] for t in a: print(t)
I = lambda: list(map(int, input().split()))[::-1] m, n = I() c = [0] * -~n a = [0] * m for y, p, i in sorted(I() + [i] for i in range(m)): c[p] += 1 a[i] = "%06d%06d" % (p, c[p]) print(("\n".join(a)))
false
0
[ "- a[i] = \"%06d\" % p + \"%06d\" % c[p]", "-for t in a:", "- print(t)", "+ a[i] = \"%06d%06d\" % (p, c[p])", "+print((\"\\n\".join(a)))" ]
false
0.151366
0.042579
3.554977
[ "s029668249", "s258962680" ]
u513081876
p03835
python
s988577095
s692706538
1,690
1,426
2,940
3,188
Accepted
Accepted
15.62
k,s=list(map(int,input().split())) c=0 for i in range(k+1): for j in range(k+1): if s>=i+j and s-(i+j)<=k: c+=1 print(c)
K, S = list(map(int, input().split())) ans = 0 for x in list(range(K+1)): for y in list(range(K+1)): z = S-x-y if 0 <= z <= K: ans += 1 print(ans)
7
11
144
185
k, s = list(map(int, input().split())) c = 0 for i in range(k + 1): for j in range(k + 1): if s >= i + j and s - (i + j) <= k: c += 1 print(c)
K, S = list(map(int, input().split())) ans = 0 for x in list(range(K + 1)): for y in list(range(K + 1)): z = S - x - y if 0 <= z <= K: ans += 1 print(ans)
false
36.363636
[ "-k, s = list(map(int, input().split()))", "-c = 0", "-for i in range(k + 1):", "- for j in range(k + 1):", "- if s >= i + j and s - (i + j) <= k:", "- c += 1", "-print(c)", "+K, S = list(map(int, input().split()))", "+ans = 0", "+for x in list(range(K + 1)):", "+ for y i...
false
0.036144
0.036431
0.992128
[ "s988577095", "s692706538" ]
u790710233
p02726
python
s341042709
s492929772
1,746
1,379
34,932
34,932
Accepted
Accepted
21.02
n, x, y = map(int, input().split()) x -= 1 y -= 1 GRAPH = [[0]*n for _ in range(n)] def shortest_path(i, j): if i <= x <= y <= j: return min(j-i, x-i+j-y+1) elif x <= i <= y <= j: return min(j-i, i-x+j-y+1) elif x <= i <= j <= y: return min(j-i, i-x+y-j+1) elif i <= ...
n, x, y = map(int, input().split()) x -= 1 y -= 1 GRAPH = [[0]*n for _ in range(n)] def shortest_path(i, j): return min(j-i, abs(x-i)+abs(y-j)+1) ans = [0]*(n-1) for i in range(n): for j in range(i+1, n): path = shortest_path(i, j)-1 ans[path] += 1 print(*ans, sep="\n")
24
14
554
309
n, x, y = map(int, input().split()) x -= 1 y -= 1 GRAPH = [[0] * n for _ in range(n)] def shortest_path(i, j): if i <= x <= y <= j: return min(j - i, x - i + j - y + 1) elif x <= i <= y <= j: return min(j - i, i - x + j - y + 1) elif x <= i <= j <= y: return min(j - i, i - x + y - ...
n, x, y = map(int, input().split()) x -= 1 y -= 1 GRAPH = [[0] * n for _ in range(n)] def shortest_path(i, j): return min(j - i, abs(x - i) + abs(y - j) + 1) ans = [0] * (n - 1) for i in range(n): for j in range(i + 1, n): path = shortest_path(i, j) - 1 ans[path] += 1 print(*ans, sep="\n")
false
41.666667
[ "- if i <= x <= y <= j:", "- return min(j - i, x - i + j - y + 1)", "- elif x <= i <= y <= j:", "- return min(j - i, i - x + j - y + 1)", "- elif x <= i <= j <= y:", "- return min(j - i, i - x + y - j + 1)", "- elif i <= x <= j <= y:", "- return min(j - i, x - i...
false
0.03596
0.056205
0.639793
[ "s341042709", "s492929772" ]
u597374218
p03207
python
s546080051
s413685298
19
17
3,060
3,060
Accepted
Accepted
10.53
l=[int(eval(input())) for _ in range(int(eval(input())))] print((sum(l)-int(max(l)/2)))
n=int(eval(input())) p=sorted([int(eval(input())) for i in range(n)]) print((p[-1]//2+sum(p[:-1])))
2
3
74
87
l = [int(eval(input())) for _ in range(int(eval(input())))] print((sum(l) - int(max(l) / 2)))
n = int(eval(input())) p = sorted([int(eval(input())) for i in range(n)]) print((p[-1] // 2 + sum(p[:-1])))
false
33.333333
[ "-l = [int(eval(input())) for _ in range(int(eval(input())))]", "-print((sum(l) - int(max(l) / 2)))", "+n = int(eval(input()))", "+p = sorted([int(eval(input())) for i in range(n)])", "+print((p[-1] // 2 + sum(p[:-1])))" ]
false
0.047358
0.046601
1.016239
[ "s546080051", "s413685298" ]
u479638406
p03730
python
s276855135
s705433627
38
19
2,940
2,940
Accepted
Accepted
50
a, b, c = list(map(int, input().split())) ans = 'NO' if a < b and c%a == 0: ans = 'YES' else: for i in range(1, 100000): if (b*i + c)%a == 0: ans = 'YES' break print(ans)
a, b, c = list(map(int, input().split())) ans = 'NO' if a < b and c%a == 0: ans = 'YES' else: for i in range(1, 10000): if (b*i + c)%a == 0: ans = 'YES' break print(ans)
12
12
199
198
a, b, c = list(map(int, input().split())) ans = "NO" if a < b and c % a == 0: ans = "YES" else: for i in range(1, 100000): if (b * i + c) % a == 0: ans = "YES" break print(ans)
a, b, c = list(map(int, input().split())) ans = "NO" if a < b and c % a == 0: ans = "YES" else: for i in range(1, 10000): if (b * i + c) % a == 0: ans = "YES" break print(ans)
false
0
[ "- for i in range(1, 100000):", "+ for i in range(1, 10000):" ]
false
0.041027
0.035951
1.141189
[ "s276855135", "s705433627" ]
u077291787
p02900
python
s597024560
s122144978
98
77
5,048
3,064
Accepted
Accepted
21.43
# ABC142D - Disjoint Set of Common Divisors from fractions import gcd # cf. AtCoder ARC067C, Euler 012 def prime_factorization(x: int) -> dict: """ Prime factorization of a number (trial division) Args: x (int): a number to be resolved Return: ret (dict): {prime factor: power} ...
# ABC142D - Disjoint Set of Common Divisors def gcd(x: int, y: int) -> int: while y: x, y = y, x % y return x def prime_factorization(x: int) -> dict: max_prime, ret = 0, {} # Divide x by 2 as much as possible cnt = 0 while x % 2 == 0: x //= 2 cnt += 1 ...
53
46
1,180
1,030
# ABC142D - Disjoint Set of Common Divisors from fractions import gcd # cf. AtCoder ARC067C, Euler 012 def prime_factorization(x: int) -> dict: """ Prime factorization of a number (trial division) Args: x (int): a number to be resolved Return: ret (dict): {prime factor: power} e.g., n = 2^a * 3^b -...
# ABC142D - Disjoint Set of Common Divisors def gcd(x: int, y: int) -> int: while y: x, y = y, x % y return x def prime_factorization(x: int) -> dict: max_prime, ret = 0, {} # Divide x by 2 as much as possible cnt = 0 while x % 2 == 0: x //= 2 cnt += 1 if cnt > 0: ...
false
13.207547
[ "-from fractions import gcd", "+def gcd(x: int, y: int) -> int:", "+ while y:", "+ x, y = y, x % y", "+ return x", "-# cf. AtCoder ARC067C, Euler 012", "+", "- \"\"\"", "- Prime factorization of a number (trial division)", "- Args: x (int): a number to be resolved", "- R...
false
0.046508
0.054926
0.846741
[ "s597024560", "s122144978" ]
u852690916
p03672
python
s394973275
s426670686
179
17
38,256
2,940
Accepted
Accepted
90.5
S=eval(input()) for n in range(2-(len(S)&1), len(S), 2): m = (len(S)-n)//2 for i in range(m): if S[i] != S[i+m]: break else: print((m*2)) exit()
S=eval(input()) N=len(S) for d in range(1,N-1): if (N-d)&1: continue h=(N-d)//2 for i in range(h): if S[i]!=S[i+h]: break else: print((N-d)) exit()
9
10
182
189
S = eval(input()) for n in range(2 - (len(S) & 1), len(S), 2): m = (len(S) - n) // 2 for i in range(m): if S[i] != S[i + m]: break else: print((m * 2)) exit()
S = eval(input()) N = len(S) for d in range(1, N - 1): if (N - d) & 1: continue h = (N - d) // 2 for i in range(h): if S[i] != S[i + h]: break else: print((N - d)) exit()
false
10
[ "-for n in range(2 - (len(S) & 1), len(S), 2):", "- m = (len(S) - n) // 2", "- for i in range(m):", "- if S[i] != S[i + m]:", "+N = len(S)", "+for d in range(1, N - 1):", "+ if (N - d) & 1:", "+ continue", "+ h = (N - d) // 2", "+ for i in range(h):", "+ if S[...
false
0.046417
0.046929
0.989087
[ "s394973275", "s426670686" ]
u707498674
p03290
python
s423340919
s428217487
35
25
3,064
3,188
Accepted
Accepted
28.57
D, G = list(map(int, input().split())) p = [0 for i in range(D)] c = [0 for i in range(D)] for i in range(D): p[i], c[i] = list(map(int, input().split())) def dfs(s): if len(s) == D: ans = 1000 score = 0 times = 0 for i in range(D): if s[i] == "1": ...
def main(): D, G = list(map(int, input().split())) info = [tuple(map(int, input().split())) for _ in range(D)] ans = 100 * 10 for bit in range(1<<D): score = 0 num_problem = 0 # complete bonus for i in range(D): if (bit>>i) & 1: b...
28
41
737
1,129
D, G = list(map(int, input().split())) p = [0 for i in range(D)] c = [0 for i in range(D)] for i in range(D): p[i], c[i] = list(map(int, input().split())) def dfs(s): if len(s) == D: ans = 1000 score = 0 times = 0 for i in range(D): if s[i] == "1": s...
def main(): D, G = list(map(int, input().split())) info = [tuple(map(int, input().split())) for _ in range(D)] ans = 100 * 10 for bit in range(1 << D): score = 0 num_problem = 0 # complete bonus for i in range(D): if (bit >> i) & 1: base = 100 ...
false
31.707317
[ "-D, G = list(map(int, input().split()))", "-p = [0 for i in range(D)]", "-c = [0 for i in range(D)]", "-for i in range(D):", "- p[i], c[i] = list(map(int, input().split()))", "+def main():", "+ D, G = list(map(int, input().split()))", "+ info = [tuple(map(int, input().split())) for _ in rang...
false
0.070145
0.136847
0.512577
[ "s423340919", "s428217487" ]
u347640436
p03044
python
s079211691
s654738098
1,038
664
42,796
42,772
Accepted
Accepted
36.03
N = int(eval(input())) link = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) link[u - 1].append((v - 1, w)) link[v - 1].append((u - 1, w)) d = [-1] * N d[0] = 0 q = [0] while q: i = q.pop(0) for n, w in link[i]: if d[n] == -1: d[n] = d[...
N = int(eval(input())) link = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) link[u - 1].append((v - 1, w)) link[v - 1].append((u - 1, w)) d = [0] * N q = [0] while q: p = q.pop() for n, w in link[p]: if d[n] == 0: d[n] = d...
20
19
364
374
N = int(eval(input())) link = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) link[u - 1].append((v - 1, w)) link[v - 1].append((u - 1, w)) d = [-1] * N d[0] = 0 q = [0] while q: i = q.pop(0) for n, w in link[i]: if d[n] == -1: d[n] = d[i] ...
N = int(eval(input())) link = [[] for _ in range(N)] for _ in range(N - 1): u, v, w = list(map(int, input().split())) link[u - 1].append((v - 1, w)) link[v - 1].append((u - 1, w)) d = [0] * N q = [0] while q: p = q.pop() for n, w in link[p]: if d[n] == 0: d[n] = d[p] + w ...
false
5
[ "-d = [-1] * N", "-d[0] = 0", "+d = [0] * N", "- i = q.pop(0)", "- for n, w in link[i]:", "- if d[n] == -1:", "- d[n] = d[i] + w", "+ p = q.pop()", "+ for n, w in link[p]:", "+ if d[n] == 0:", "+ d[n] = d[p] + w" ]
false
0.040378
0.059314
0.680756
[ "s079211691", "s654738098" ]
u605917063
p03329
python
s075070399
s809788630
1,000
846
3,064
3,060
Accepted
Accepted
15.4
import sys six = [6,36,216,1296,7776,46656] nine = [9,81,729,6561,59049] def dfs(n): if n < 6: return n six_max, nine_max = (1, 1) for i in six: if n < i: break six_max = i for i in nine: if n < i: break nine_max = i...
def dfs(n): if n < 6: return n elif n < 9: return 1 + dfs(n - 6) six_max = 1 nine_max = 1 while six_max * 6 <= n: six_max *= 6 while nine_max * 9 <= n: nine_max *= 9 return min(dfs(n - nine_max), dfs(n - six_max)) + 1 print((dfs...
28
17
520
335
import sys six = [6, 36, 216, 1296, 7776, 46656] nine = [9, 81, 729, 6561, 59049] def dfs(n): if n < 6: return n six_max, nine_max = (1, 1) for i in six: if n < i: break six_max = i for i in nine: if n < i: break nine_max = i ans = 1...
def dfs(n): if n < 6: return n elif n < 9: return 1 + dfs(n - 6) six_max = 1 nine_max = 1 while six_max * 6 <= n: six_max *= 6 while nine_max * 9 <= n: nine_max *= 9 return min(dfs(n - nine_max), dfs(n - six_max)) + 1 print((dfs(int(eval(input())))))
false
39.285714
[ "-import sys", "-", "-six = [6, 36, 216, 1296, 7776, 46656]", "-nine = [9, 81, 729, 6561, 59049]", "-", "-", "- six_max, nine_max = (1, 1)", "- for i in six:", "- if n < i:", "- break", "- six_max = i", "- for i in nine:", "- if n < i:", "- ...
false
0.145058
0.12609
1.150435
[ "s075070399", "s809788630" ]
u307622233
p02683
python
s414699869
s551894201
73
64
9,324
9,224
Accepted
Accepted
12.33
import itertools n, m, x = list(map(int, input().split())) lst = [] for i in range(n): lst.append([int(i) for i in input().split()]) ans_list = [] for i in range(1, n + 1): for j in itertools.combinations(lst, i): under_list = [0] * m money = 0 for k in j: mo...
import sys input = sys.stdin.readline def main(): n, m, x = list(map(int, input().split())) MONEY = [] UNDERSTAND = [] for i in range(n): lst = [int(i) for i in input().split()] MONEY.append(lst[0]) UNDERSTAND.append(lst[1:]) ans = -1 for i in range(1 <...
26
34
564
793
import itertools n, m, x = list(map(int, input().split())) lst = [] for i in range(n): lst.append([int(i) for i in input().split()]) ans_list = [] for i in range(1, n + 1): for j in itertools.combinations(lst, i): under_list = [0] * m money = 0 for k in j: money += k[0] ...
import sys input = sys.stdin.readline def main(): n, m, x = list(map(int, input().split())) MONEY = [] UNDERSTAND = [] for i in range(n): lst = [int(i) for i in input().split()] MONEY.append(lst[0]) UNDERSTAND.append(lst[1:]) ans = -1 for i in range(1 << n): un...
false
23.529412
[ "-import itertools", "+import sys", "-n, m, x = list(map(int, input().split()))", "-lst = []", "-for i in range(n):", "- lst.append([int(i) for i in input().split()])", "-ans_list = []", "-for i in range(1, n + 1):", "- for j in itertools.combinations(lst, i):", "- under_list = [0] * ...
false
0.045275
0.046715
0.969178
[ "s414699869", "s551894201" ]
u761320129
p03141
python
s098138721
s426480679
402
286
21,364
27,056
Accepted
Accepted
28.86
N = int(eval(input())) AB = [tuple(map(int,input().split())) for i in range(N)] AB.sort(key=lambda x:x[1]+x[0]) ans = 0 for i,(a,b) in enumerate(AB[::-1]): if i%2: ans -= b else: ans += a print(ans)
N = int(eval(input())) AB = [tuple(map(int,input().split())) for i in range(N)] AB.sort(key=lambda x:sum(x)) x = y = 0 i = 0 while AB: a,b = AB.pop() if i%2: y += b else: x += a i += 1 print((x-y))
11
14
227
235
N = int(eval(input())) AB = [tuple(map(int, input().split())) for i in range(N)] AB.sort(key=lambda x: x[1] + x[0]) ans = 0 for i, (a, b) in enumerate(AB[::-1]): if i % 2: ans -= b else: ans += a print(ans)
N = int(eval(input())) AB = [tuple(map(int, input().split())) for i in range(N)] AB.sort(key=lambda x: sum(x)) x = y = 0 i = 0 while AB: a, b = AB.pop() if i % 2: y += b else: x += a i += 1 print((x - y))
false
21.428571
[ "-AB.sort(key=lambda x: x[1] + x[0])", "-ans = 0", "-for i, (a, b) in enumerate(AB[::-1]):", "+AB.sort(key=lambda x: sum(x))", "+x = y = 0", "+i = 0", "+while AB:", "+ a, b = AB.pop()", "- ans -= b", "+ y += b", "- ans += a", "-print(ans)", "+ x += a", "+ ...
false
0.044276
0.039064
1.133438
[ "s098138721", "s426480679" ]
u226191225
p02843
python
s796456460
s066795322
182
17
39,408
2,940
Accepted
Accepted
90.66
x = int(eval(input())) dp = [False] * (x+1) dp[0] = True for i in range(1,x+1): if i < 99: continue else: if dp[i-100]: dp[i] = True elif dp[i-101]: dp[i] = True elif dp[i-102]: dp[i] = True elif dp[i-103]: d...
a = int(eval(input())) tmp01 = a/100 tmp02 = a/105 n = a//100 #print(tmp01,n,tmp02) if tmp01 >= n >= tmp02: print((1)) else: print((0))
25
9
475
137
x = int(eval(input())) dp = [False] * (x + 1) dp[0] = True for i in range(1, x + 1): if i < 99: continue else: if dp[i - 100]: dp[i] = True elif dp[i - 101]: dp[i] = True elif dp[i - 102]: dp[i] = True elif dp[i - 103]: dp[i...
a = int(eval(input())) tmp01 = a / 100 tmp02 = a / 105 n = a // 100 # print(tmp01,n,tmp02) if tmp01 >= n >= tmp02: print((1)) else: print((0))
false
64
[ "-x = int(eval(input()))", "-dp = [False] * (x + 1)", "-dp[0] = True", "-for i in range(1, x + 1):", "- if i < 99:", "- continue", "- else:", "- if dp[i - 100]:", "- dp[i] = True", "- elif dp[i - 101]:", "- dp[i] = True", "- elif dp[i - 1...
false
0.0662
0.045695
1.448722
[ "s796456460", "s066795322" ]
u593934357
p03029
python
s807518933
s703447644
165
34
38,384
27,756
Accepted
Accepted
79.39
a,p=list(map(int,input().split()));print(((3*a+p)//2))
A,P=list(map(int,input().split()));sum=3*A+P;print(sum/2)
1
1
47
54
a, p = list(map(int, input().split())) print(((3 * a + p) // 2))
A, P = list(map(int, input().split())) sum = 3 * A + P print(sum / 2)
false
0
[ "-a, p = list(map(int, input().split()))", "-print(((3 * a + p) // 2))", "+A, P = list(map(int, input().split()))", "+sum = 3 * A + P", "+print(sum / 2)" ]
false
0.041848
0.03824
1.094345
[ "s807518933", "s703447644" ]
u446628914
p02983
python
s451074636
s867316040
459
367
3,060
3,060
Accepted
Accepted
20.04
l,r = list(map(int,input().split())) a = float("inf") for i in range(l,min(r+1,l+2019)): for j in range(i+1,min(r+1,l+2019)): if a > (i*j)%2019: a = (i*j)%2019 print(a)
import sys l, r = list(map(int,input().split())) if r-l>=2019: print((0)) sys.exit() a=l%2019 b=r%2019 if a>b: b+=2019 elif a==b: print((0)) sys.exit() m=2018 for i in range(a,b): for j in range(i+1,b+1): if m>(i*j)%2019: m=(i*j)%2019 print(m)
7
19
246
296
l, r = list(map(int, input().split())) a = float("inf") for i in range(l, min(r + 1, l + 2019)): for j in range(i + 1, min(r + 1, l + 2019)): if a > (i * j) % 2019: a = (i * j) % 2019 print(a)
import sys l, r = list(map(int, input().split())) if r - l >= 2019: print((0)) sys.exit() a = l % 2019 b = r % 2019 if a > b: b += 2019 elif a == b: print((0)) sys.exit() m = 2018 for i in range(a, b): for j in range(i + 1, b + 1): if m > (i * j) % 2019: m = (i * j) % 2019 p...
false
63.157895
[ "+import sys", "+", "-a = float(\"inf\")", "-for i in range(l, min(r + 1, l + 2019)):", "- for j in range(i + 1, min(r + 1, l + 2019)):", "- if a > (i * j) % 2019:", "- a = (i * j) % 2019", "-print(a)", "+if r - l >= 2019:", "+ print((0))", "+ sys.exit()", "+a = l % ...
false
0.074569
0.044272
1.684332
[ "s451074636", "s867316040" ]
u163907160
p03163
python
s896615685
s034094403
479
214
120,044
15,480
Accepted
Accepted
55.32
N,W=list(map(int,input().split())) k=[[0,0] for i in range(N)] dp=[[0]*(W+1) for j in range(N+1)] for i in range(N): k[i][0],k[i][1]=list(map(int,input().split())) for i in range(N): for w in range(W+1): if k[i][0]>w: dp[i+1][w]=dp[i][w] else: dp[i+1][w] =...
import numpy as np N, W = list(map(int, input().split())) w, v = [], [] for i in range(N): a, b = list(map(int, input().split())) w += [a] v += [b] DP = np.zeros(W + 1,dtype=int) for i in range(N): # print(DP[w[i]:]) # print(DP[:-w[i]]) # print(DP[:-w[i]] + v[i]) DP[w[i]:] ...
17
18
368
382
N, W = list(map(int, input().split())) k = [[0, 0] for i in range(N)] dp = [[0] * (W + 1) for j in range(N + 1)] for i in range(N): k[i][0], k[i][1] = list(map(int, input().split())) for i in range(N): for w in range(W + 1): if k[i][0] > w: dp[i + 1][w] = dp[i][w] else: d...
import numpy as np N, W = list(map(int, input().split())) w, v = [], [] for i in range(N): a, b = list(map(int, input().split())) w += [a] v += [b] DP = np.zeros(W + 1, dtype=int) for i in range(N): # print(DP[w[i]:]) # print(DP[:-w[i]]) # print(DP[:-w[i]] + v[i]) DP[w[i] :] = np.maximum(DP...
false
5.555556
[ "+import numpy as np", "+", "-k = [[0, 0] for i in range(N)]", "-dp = [[0] * (W + 1) for j in range(N + 1)]", "+w, v = [], []", "- k[i][0], k[i][1] = list(map(int, input().split()))", "+ a, b = list(map(int, input().split()))", "+ w += [a]", "+ v += [b]", "+DP = np.zeros(W + 1, dtype=i...
false
0.123272
0.654171
0.18844
[ "s896615685", "s034094403" ]
u562935282
p03291
python
s303784184
s845511059
518
456
27,532
27,628
Accepted
Accepted
11.97
def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)] s = eval(input()) ls = len(s) dp = ary(ls + 1, 4, 0) dp[0][0] = 1 mod = 10 ** 9 + 7 for i in range(1, ls + 1): for j in range(4): #'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍 dp[i][j] += dp[i - 1][j] * (3 if s[i - 1] == '?' else 1...
s = eval(input()) MOD = 10 ** 9 + 7 # dp[0 .. len(s)][0..3] = その状態の数 dp = [[0 for _ in range(3 + 1)] for _ in range(len(s) + 1)] dp[0][0] = 1 for i in range(1, len(s) + 1): # s[i]を取らない dp[i][0] += dp[i - 1][0] * (3 if s[i - 1] == '?' else 1) dp[i][1] += dp[i - 1][1] * (3 if s[i - 1] == '?' els...
19
31
526
848
def ary(r, c, v): return [[v for _ in range(c)] for _ in range(r)] s = eval(input()) ls = len(s) dp = ary(ls + 1, 4, 0) dp[0][0] = 1 mod = 10**9 + 7 for i in range(1, ls + 1): for j in range(4): #'?'のとき'ABC'の3通りに分岐させ、いずれも取らないので3倍 dp[i][j] += dp[i - 1][j] * (3 if s[i - 1] == "?" else 1) ...
s = eval(input()) MOD = 10**9 + 7 # dp[0 .. len(s)][0..3] = その状態の数 dp = [[0 for _ in range(3 + 1)] for _ in range(len(s) + 1)] dp[0][0] = 1 for i in range(1, len(s) + 1): # s[i]を取らない dp[i][0] += dp[i - 1][0] * (3 if s[i - 1] == "?" else 1) dp[i][1] += dp[i - 1][1] * (3 if s[i - 1] == "?" else 1) dp[i][2...
false
38.709677
[ "-def ary(r, c, v):", "- return [[v for _ in range(c)] for _ in range(r)]", "-", "-", "-ls = len(s)", "-dp = ary(ls + 1, 4, 0)", "+MOD = 10**9 + 7", "+# dp[0 .. len(s)][0..3] = その状態の数", "+dp = [[0 for _ in range(3 + 1)] for _ in range(len(s) + 1)]", "-mod = 10**9 + 7", "-for i in range(1, ls ...
false
0.046273
0.037224
1.243078
[ "s303784184", "s845511059" ]
u714300041
p03557
python
s350765902
s040893259
467
347
92,644
23,360
Accepted
Accepted
25.7
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for b in B: num_a = bisect.bisect_left(A, b) num_c = ...
import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for b in B: i = bisect.bisect_left(A, b) j = bisect.bisect_right(C, b) ans += i * (N - j) print(ans)
20
17
383
297
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for b in B: num_a = bisect.bisect_left(A, b) num_c = N - bisect.bisect_r...
import bisect N = int(eval(input())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() C.sort() ans = 0 for b in B: i = bisect.bisect_left(A, b) j = bisect.bisect_right(C, b) ans += i * (N - j) print(ans)
false
15
[ "-import sys", "-", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "- num_a = bisect.bisect_left(A, b)", "- num_c = N - bisect.bisect_right(C, b)", "- ans += num_a * num_c", "+ i = bisect.bisect_left(A, b)", "+ j = bisect.bisect_right(C, b)", "+ ans += i * (N - j...
false
0.106008
0.113522
0.933806
[ "s350765902", "s040893259" ]
u873269440
p03289
python
s466717994
s865752870
167
20
38,484
3,316
Accepted
Accepted
88.02
from collections import Counter def main(): S = list(eval(input())) head = S.pop(0) cList = [] flag = False flag1 = False flag2 = False if head == 'A': flag = True for i,j in enumerate(S[1:-1]): if j=='C': cList.append(i+1) if len...
from collections import Counter def main(): S = list(eval(input())) head = S.pop(0) count = 0 flag = False flag1 = False flag2 = False if head == 'A': flag = True for i in S[1:-1]: if i=='C': count += 1 if count == 1: fla...
42
42
594
574
from collections import Counter def main(): S = list(eval(input())) head = S.pop(0) cList = [] flag = False flag1 = False flag2 = False if head == "A": flag = True for i, j in enumerate(S[1:-1]): if j == "C": cList.append(i + 1) if len(cList) == 1: ...
from collections import Counter def main(): S = list(eval(input())) head = S.pop(0) count = 0 flag = False flag1 = False flag2 = False if head == "A": flag = True for i in S[1:-1]: if i == "C": count += 1 if count == 1: flag1 = True S.pop...
false
0
[ "- cList = []", "+ count = 0", "- for i, j in enumerate(S[1:-1]):", "- if j == \"C\":", "- cList.append(i + 1)", "- if len(cList) == 1:", "+ for i in S[1:-1]:", "+ if i == \"C\":", "+ count += 1", "+ if count == 1:", "- S.pop(cList[0])...
false
0.075349
0.044144
1.706905
[ "s466717994", "s865752870" ]
u852690916
p02794
python
s623982203
s549453237
2,229
1,542
43,936
43,484
Accepted
Accepted
30.82
import sys def main(): input = sys.stdin.readline N = int(eval(input())) E = [[] for _ in range(N)] for i in range(N-1): a, b = list(map(int, input().split())) a, b = a-1, b-1 E[a].append((b,i)) E[b].append((a,i)) def dfs(s, g): par = [(-1,-1)...
import sys def main(): input = sys.stdin.readline N = int(eval(input())) E = [[] for _ in range(N)] for i in range(N-1): a, b = list(map(int, input().split())) a, b = a-1, b-1 E[a].append((b,i)) E[b].append((a,i)) def dfs(s, g): par = [(-1,-1)...
54
54
1,288
1,291
import sys def main(): input = sys.stdin.readline N = int(eval(input())) E = [[] for _ in range(N)] for i in range(N - 1): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 E[a].append((b, i)) E[b].append((a, i)) def dfs(s, g): par = [(-1, -1)] * N...
import sys def main(): input = sys.stdin.readline N = int(eval(input())) E = [[] for _ in range(N)] for i in range(N - 1): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 E[a].append((b, i)) E[b].append((a, i)) def dfs(s, g): par = [(-1, -1)] * N...
false
0
[ "- r = set()", "+ r = 0", "- r.add(i)", "+ r |= 1 << i", "- path = [None] * M", "+ path = [0] * M", "- return 1 << (N - 1 - len(s))", "+ return 1 << (N - 1 - bin(s).count(\"1\"))", "- s = set()", "+ s = 0" ]
false
0.03585
0.037505
0.955868
[ "s623982203", "s549453237" ]
u091051505
p03136
python
s811932813
s162592650
24
17
2,940
2,940
Accepted
Accepted
29.17
n = int(eval(input())) l_list = [int(i) for i in input().split()] long = max(l_list) others = sum(l_list) - int if (others > int): print("Yes") else: print("No")
n = int(eval(input())) l_list = [int(i) for i in input().split()] max_l = max(l_list) sum_l = sum(l_list) - max_l*2 if sum_l > 0: print("Yes") else: print("No")
8
8
172
169
n = int(eval(input())) l_list = [int(i) for i in input().split()] long = max(l_list) others = sum(l_list) - int if others > int: print("Yes") else: print("No")
n = int(eval(input())) l_list = [int(i) for i in input().split()] max_l = max(l_list) sum_l = sum(l_list) - max_l * 2 if sum_l > 0: print("Yes") else: print("No")
false
0
[ "-long = max(l_list)", "-others = sum(l_list) - int", "-if others > int:", "+max_l = max(l_list)", "+sum_l = sum(l_list) - max_l * 2", "+if sum_l > 0:" ]
false
0.035753
0.076059
0.470072
[ "s811932813", "s162592650" ]
u251515715
p03416
python
s975768829
s328837143
215
130
3,060
2,940
Accepted
Accepted
39.53
a,b = list(map(int, input().split())) cnt = 0 for i in range(a,b+1): tmp = list(map(int,list(str(i)))) if tmp==list(reversed(tmp)): cnt+=1 print(cnt)
a,b = list(map(int, input().split())) cnt = 0 for i in range(a,b+1): tmp = list(str(i)) if tmp==list(reversed(tmp)): cnt+=1 print(cnt)
7
7
157
142
a, b = list(map(int, input().split())) cnt = 0 for i in range(a, b + 1): tmp = list(map(int, list(str(i)))) if tmp == list(reversed(tmp)): cnt += 1 print(cnt)
a, b = list(map(int, input().split())) cnt = 0 for i in range(a, b + 1): tmp = list(str(i)) if tmp == list(reversed(tmp)): cnt += 1 print(cnt)
false
0
[ "- tmp = list(map(int, list(str(i))))", "+ tmp = list(str(i))" ]
false
0.076474
0.069152
1.105887
[ "s975768829", "s328837143" ]
u028973125
p03393
python
s842181887
s677407196
32
28
9,172
9,084
Accepted
Accepted
12.5
import sys S = sys.stdin.readline().strip() ls = len(S) if ls == 26 and list(S) == sorted(S, reverse=True): print((-1)) sys.exit() alpha = "abcdefghijklmnopqrstuvwxyz" exists = set(S) if ls < 26: for a in alpha: if a not in exists: print((S + a)) sys.exit() ...
import sys S = sys.stdin.readline().strip() ls = len(S) if ls == 26 and list(S) == sorted(S, reverse=True): print((-1)) sys.exit() alpha = "abcdefghijklmnopqrstuvwxyz" exists = set(S) if ls < 26: for a in alpha: if a not in exists: print((S + a)) sys.exit() ...
33
27
749
622
import sys S = sys.stdin.readline().strip() ls = len(S) if ls == 26 and list(S) == sorted(S, reverse=True): print((-1)) sys.exit() alpha = "abcdefghijklmnopqrstuvwxyz" exists = set(S) if ls < 26: for a in alpha: if a not in exists: print((S + a)) sys.exit() else: for i i...
import sys S = sys.stdin.readline().strip() ls = len(S) if ls == 26 and list(S) == sorted(S, reverse=True): print((-1)) sys.exit() alpha = "abcdefghijklmnopqrstuvwxyz" exists = set(S) if ls < 26: for a in alpha: if a not in exists: print((S + a)) sys.exit() else: for i i...
false
18.181818
[ "- remain = []", "- exists = set(S[: ls - i - 1])", "- for a in alpha:", "- if a not in exists:", "- remain.append(a)", "- for r in sorted(remain, reverse=True):", "+ for r in sorted(S[ls - i :], reverse=True):" ]
false
0.036369
0.043072
0.844362
[ "s842181887", "s677407196" ]
u077291787
p03164
python
s221432573
s489463462
356
232
69,084
41,572
Accepted
Accepted
34.83
# E - Knapsack 2 from collections import defaultdict def main(): INF = 1 << 30 N, W, *WV = list(map(int, open(0).read().split())) dp = defaultdict(lambda: INF) # dp[i] := minimum weight at value i dp[0] = 0 for w, v in zip(*[iter(WV)] * 2): for cur_v, cur_w in tuple(dp.items()):...
# E - Knapsack 2 def knapsack_heavy(limit: int, weight: list, value: list) -> int: lim = sum(value) dp = [0] + [1 << 30] * lim # dp[i] := minimum weight at value i for w, v in zip(weight, value): for cur_v in range(lim, v - 1, -1): dp[cur_v] = min(dp[cur_v], dp[cur_v - v] + w) ...
18
18
481
551
# E - Knapsack 2 from collections import defaultdict def main(): INF = 1 << 30 N, W, *WV = list(map(int, open(0).read().split())) dp = defaultdict(lambda: INF) # dp[i] := minimum weight at value i dp[0] = 0 for w, v in zip(*[iter(WV)] * 2): for cur_v, cur_w in tuple(dp.items()): ...
# E - Knapsack 2 def knapsack_heavy(limit: int, weight: list, value: list) -> int: lim = sum(value) dp = [0] + [1 << 30] * lim # dp[i] := minimum weight at value i for w, v in zip(weight, value): for cur_v in range(lim, v - 1, -1): dp[cur_v] = min(dp[cur_v], dp[cur_v - v] + w) ret =...
false
0
[ "-from collections import defaultdict", "+def knapsack_heavy(limit: int, weight: list, value: list) -> int:", "+ lim = sum(value)", "+ dp = [0] + [1 << 30] * lim # dp[i] := minimum weight at value i", "+ for w, v in zip(weight, value):", "+ for cur_v in range(lim, v - 1, -1):", "+ ...
false
0.031754
0.036024
0.881478
[ "s221432573", "s489463462" ]
u729133443
p03652
python
s703294638
s168977759
488
177
62,972
28,536
Accepted
Accepted
63.73
from subprocess import* call(('python3','-c',""" from numpy import* a=loadtxt(open(0),'i',skiprows=1,ndmin=2) n=x=len(a) while a.any(): t=bincount(a[:,0]) x,a=min(x,max(t)),reshape(a[a!=argmax(t)],(n,-1)) print(x) """))
from numpy import* n=x=len(a:=loadtxt(open(0),"i",skiprows=1,ndmin=2)) while any(a):x=min(x,max(t:=bincount(a[:,0])));a=reshape(a[a!=argmax(t)],(n,-1)) print(x)
10
4
232
163
from subprocess import * call( ( "python3", "-c", """ from numpy import* a=loadtxt(open(0),'i',skiprows=1,ndmin=2) n=x=len(a) while a.any(): t=bincount(a[:,0]) x,a=min(x,max(t)),reshape(a[a!=argmax(t)],(n,-1)) print(x) """, ) )
from numpy import * n = x = len(a := loadtxt(open(0), "i", skiprows=1, ndmin=2)) while any(a): x = min(x, max(t := bincount(a[:, 0]))) a = reshape(a[a != argmax(t)], (n, -1)) print(x)
false
60
[ "-from subprocess import *", "+from numpy import *", "-call(", "- (", "- \"python3\",", "- \"-c\",", "- \"\"\"", "-from numpy import*", "-a=loadtxt(open(0),'i',skiprows=1,ndmin=2)", "-n=x=len(a)", "-while a.any():", "- t=bincount(a[:,0])", "- x,a=min(x,max(t)),resha...
false
0.868962
0.738872
1.176065
[ "s703294638", "s168977759" ]
u732061897
p03212
python
s489096924
s164903684
268
90
64,360
12,184
Accepted
Accepted
66.42
S = eval(input()) ''' 357 375 537 573 735 753 3357 3375 3537 3573 3735 3753 5357 5375 5537 5573 5735 5753 3357,3375,3537, 3けた 、4けた 5 ,6, 7, 8 6,18,54,162,486, 8 sum = [2 * 3,2 * 3 * 3,] ''' N = len(S) list375 =['3','5','7'] if N < 3: print((0)) exit(0) for i in range(N + 1): if i...
import itertools N = eval(input()) N_len = len(N) N_int = int(N) ans = 0 for i in range(3, 10): target = list(itertools.product([3, 5, 7], repeat=i)) for t in target: s = ''.join(map(str, t)) a = int(s) if a <= N_int and s.count('3') and s.count('5') and s.count('7'): ...
61
14
1,291
341
S = eval(input()) """ 357 375 537 573 735 753 3357 3375 3537 3573 3735 3753 5357 5375 5537 5573 5735 5753 3357,3375,3537, 3けた 、4けた 5 ,6, 7, 8 6,18,54,162,486, 8 sum = [2 * 3,2 * 3 * 3,] """ N = len(S) list375 = ["3", "5", "7"] if N < 3: print((0)) exit(0) for i in range(N + 1): if i == 0: continu...
import itertools N = eval(input()) N_len = len(N) N_int = int(N) ans = 0 for i in range(3, 10): target = list(itertools.product([3, 5, 7], repeat=i)) for t in target: s = "".join(map(str, t)) a = int(s) if a <= N_int and s.count("3") and s.count("5") and s.count("7"): ans +=...
false
77.04918
[ "-S = eval(input())", "-\"\"\"", "-357 375 537 573 735 753", "-3357 3375 3537 3573 3735 3753", "-5357 5375 5537 5573 5735 5753", "-3357,3375,3537,", "-3けた 、4けた 5 ,6, 7, 8", "-6,18,54,162,486, 8", "-sum = [2 * 3,2 * 3 * 3,]", "-\"\"\"", "-N = len(S)", "-list375 = [\"3\", \"5\", \"7\"]", "-if ...
false
0.044763
0.060486
0.740048
[ "s489096924", "s164903684" ]
u600402037
p03262
python
s821934391
s042364702
264
221
25,016
25,008
Accepted
Accepted
16.29
import numpy as np from functools import reduce from fractions import gcd N, X = list(map(int, input().split())) places = np.array(list(map(int, input().split()))) distances = abs(places - X) answer = reduce(gcd, distances) print(answer)
# coding: utf-8 import sys import numpy as np from fractions import gcd sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, X0 = lr() X = np.array(lr()) Xdiff = np.abs((X-X0)).tolist() g = Xdiff[0] for i in range(1, N): g = gcd(g, Xdiff[i]) ...
13
18
248
349
import numpy as np from functools import reduce from fractions import gcd N, X = list(map(int, input().split())) places = np.array(list(map(int, input().split()))) distances = abs(places - X) answer = reduce(gcd, distances) print(answer)
# coding: utf-8 import sys import numpy as np from fractions import gcd sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, X0 = lr() X = np.array(lr()) Xdiff = np.abs((X - X0)).tolist() g = Xdiff[0] for i in range(1, N): g = gcd(g, Xdiff[i]) answer = g pr...
false
27.777778
[ "+# coding: utf-8", "+import sys", "-from functools import reduce", "-N, X = list(map(int, input().split()))", "-places = np.array(list(map(int, input().split())))", "-distances = abs(places - X)", "-answer = reduce(gcd, distances)", "+sr = lambda: sys.stdin.readline().rstrip()", "+ir = lambda: int(...
false
0.436061
0.351417
1.240864
[ "s821934391", "s042364702" ]
u408620326
p02824
python
s858225460
s972253929
1,069
819
14,396
14,260
Accepted
Accepted
23.39
import sys from bisect import bisect_right, bisect_left input = sys.stdin.readline n, m, v, p = [int(x) for x in input().strip().split()] araw = sorted([int(x) for x in input().strip().split()]) a = list(reversed(araw)) def f(x, n, m, v, p, a, araw): c = p - (n - bisect_right(araw, a[x-1]+m)) - 1 if c...
import sys from bisect import bisect_right, bisect_left input = sys.stdin.readline n, m, v, p = [int(x) for x in input().strip().split()] araw = sorted([int(x) for x in input().strip().split()]) a = list(reversed(araw)) def f(x, n, m, v, p, a, araw): c = p - (n - bisect_right(araw, a[x-1]+m)) - 1 if c...
51
45
1,217
1,066
import sys from bisect import bisect_right, bisect_left input = sys.stdin.readline n, m, v, p = [int(x) for x in input().strip().split()] araw = sorted([int(x) for x in input().strip().split()]) a = list(reversed(araw)) def f(x, n, m, v, p, a, araw): c = p - (n - bisect_right(araw, a[x - 1] + m)) - 1 if c < ...
import sys from bisect import bisect_right, bisect_left input = sys.stdin.readline n, m, v, p = [int(x) for x in input().strip().split()] araw = sorted([int(x) for x in input().strip().split()]) a = list(reversed(araw)) def f(x, n, m, v, p, a, araw): c = p - (n - bisect_right(araw, a[x - 1] + m)) - 1 if c < ...
false
11.764706
[ "- a[x - 1] += m", "- thr = a[x - 1]", "+ thr = a[x - 1] + m", "- a[i - 1] += m", "- a[i - 1] += m", "- a[i - 1] += m", "- a[i - 1] += v_", "- a[i - 1] += m" ]
false
0.044208
0.043014
1.027762
[ "s858225460", "s972253929" ]
u694665829
p02844
python
s578330302
s278208211
1,906
964
9,484
9,536
Accepted
Accepted
49.42
import sys readline = sys.stdin.readline n = int(readline()) s = readline().rstrip() from collections import deque q = deque([]) ss = set(s) for i in ss: q.append(["",0,str(i)]) ans = 0 while q: num, ind, target = q.popleft() #print(num, ind, target) while ind < len(s): i...
import sys readline = sys.stdin.readline n = int(readline()) s = readline().rstrip() from collections import deque q = deque([]) ss = set(s) for i in ss: q.append(["",0,str(i)]) ans = 0 while q: num, ind, target = q.popleft() #print(num, ind, target) while ind < len(s): i...
32
33
615
635
import sys readline = sys.stdin.readline n = int(readline()) s = readline().rstrip() from collections import deque q = deque([]) ss = set(s) for i in ss: q.append(["", 0, str(i)]) ans = 0 while q: num, ind, target = q.popleft() # print(num, ind, target) while ind < len(s): if s[ind] == target:...
import sys readline = sys.stdin.readline n = int(readline()) s = readline().rstrip() from collections import deque q = deque([]) ss = set(s) for i in ss: q.append(["", 0, str(i)]) ans = 0 while q: num, ind, target = q.popleft() # print(num, ind, target) while ind < len(s): if s[ind] == target:...
false
3.030303
[ "- for i in range(10):", "+ sss = set(s[ind + 1 :])", "+ for i in sss:" ]
false
0.083106
0.091957
0.903752
[ "s578330302", "s278208211" ]
u960312159
p00114
python
s587258258
s632298124
660
340
7,712
7,660
Accepted
Accepted
48.48
def gcd(a, b): if b == 0: return a return gcd(b, a % b) while True: a = list(map(int, input().split())) if a.count(0) == 6: break x = a[0] % a[1] ix = 1 while x != 1: x = a[0] * x % a[1] ix += 1 y = a[2] % a[3] iy = 1 while y != 1: ...
def gcd(a, b): if b == 0: return a return gcd(b, a % b) def rooptimes(ai, mi): x = ai % mi i = 1 while x != 1: x = ai * x % mi i += 1 return(i) while True: a = list(map(int, input().split())) if a.count(0) == 6: break ix = rooptimes(a[0], a[1...
25
22
526
459
def gcd(a, b): if b == 0: return a return gcd(b, a % b) while True: a = list(map(int, input().split())) if a.count(0) == 6: break x = a[0] % a[1] ix = 1 while x != 1: x = a[0] * x % a[1] ix += 1 y = a[2] % a[3] iy = 1 while y != 1: y = a[...
def gcd(a, b): if b == 0: return a return gcd(b, a % b) def rooptimes(ai, mi): x = ai % mi i = 1 while x != 1: x = ai * x % mi i += 1 return i while True: a = list(map(int, input().split())) if a.count(0) == 6: break ix = rooptimes(a[0], a[1]) ...
false
12
[ "+def rooptimes(ai, mi):", "+ x = ai % mi", "+ i = 1", "+ while x != 1:", "+ x = ai * x % mi", "+ i += 1", "+ return i", "+", "+", "- x = a[0] % a[1]", "- ix = 1", "- while x != 1:", "- x = a[0] * x % a[1]", "- ix += 1", "- y = a[2] % a...
false
0.036967
0.038915
0.949957
[ "s587258258", "s632298124" ]
u070201429
p02574
python
s751210439
s199984088
625
273
126,760
189,412
Accepted
Accepted
56.32
class Prime(): def __init__(self, n): self.p = [] self.d = [0] * n for i in range(2, n): if self.d[i] == 0: self.p.append(i) for j in range(i, n, i): if self.d[j] == 0: self.d[j] = i ...
class Prime(): def __init__(self, n): self.p = [] # self.p[i] = i番目の素数 < n self.d = [0] * n # self.d[i] = iを割り切る最小の素数 # エラトステネスの篩 for i in range(2, n): if self.d[i] == 0: self.p.append(i) for j in range(i, n, i): ...
59
66
1,325
1,596
class Prime: def __init__(self, n): self.p = [] self.d = [0] * n for i in range(2, n): if self.d[i] == 0: self.p.append(i) for j in range(i, n, i): if self.d[j] == 0: self.d[j] = i self.ind = [-1]...
class Prime: def __init__(self, n): self.p = [] # self.p[i] = i番目の素数 < n self.d = [0] * n # self.d[i] = iを割り切る最小の素数 # エラトステネスの篩 for i in range(2, n): if self.d[i] == 0: self.p.append(i) for j in range(i, n, i): if self...
false
10.606061
[ "- self.p = []", "- self.d = [0] * n", "+ self.p = [] # self.p[i] = i番目の素数 < n", "+ self.d = [0] * n # self.d[i] = iを割り切る最小の素数", "+ # エラトステネスの篩", "- self.ind = [-1] * n", "+ self.ind = [-1] * n # self.ind[i] = self.p.index[i]", "- def prime_factor...
false
0.492548
0.871102
0.565431
[ "s751210439", "s199984088" ]
u970899068
p03031
python
s960117529
s412722745
53
34
3,188
3,064
Accepted
Accepted
35.85
n,m=list(map(int, input().split())) x = [list(map(int, input().split())) for i in range(m)] p = list(map(int, input().split())) v=[0]*n w=[] z=0 count=0 ans=0 for i in range(2**n): for j in range(n): if ((i >> j) & 1): v[j]=1 w.append(v) v=[0]*n for i in range(2**n): f...
n, m = list(map(int, input().split())) a = [list(map(int, input().split())) for i in range(m)] p = list(map(int, input().split())) ans=0 for i in range(2**n): s = [0] * n flag=True for j in range(n): if (i>>j)&1==1: s[j]=1 for k in range(m): count=0 ...
26
28
522
556
n, m = list(map(int, input().split())) x = [list(map(int, input().split())) for i in range(m)] p = list(map(int, input().split())) v = [0] * n w = [] z = 0 count = 0 ans = 0 for i in range(2**n): for j in range(n): if (i >> j) & 1: v[j] = 1 w.append(v) v = [0] * n for i in range(2**n): ...
n, m = list(map(int, input().split())) a = [list(map(int, input().split())) for i in range(m)] p = list(map(int, input().split())) ans = 0 for i in range(2**n): s = [0] * n flag = True for j in range(n): if (i >> j) & 1 == 1: s[j] = 1 for k in range(m): count = 0 for ...
false
7.142857
[ "-x = [list(map(int, input().split())) for i in range(m)]", "+a = [list(map(int, input().split())) for i in range(m)]", "-v = [0] * n", "-w = []", "-z = 0", "-count = 0", "+ s = [0] * n", "+ flag = True", "- if (i >> j) & 1:", "- v[j] = 1", "- w.append(v)", "- v =...
false
0.047651
0.037878
1.258026
[ "s960117529", "s412722745" ]
u057109575
p02972
python
s766955065
s914599697
343
165
73,472
102,488
Accepted
Accepted
51.9
N, *a = list(map(int, open(0).read().split())) dp = [0] * N for i in reversed(list(range(N))): cnt = sum(dp[i::i + 1]) if cnt % 2 == a[i]: dp[i] = 0 else: dp[i] = 1 if True: b_bin = [i + 1 for i in range(N) if dp[i] > 0] print((len(b_bin))) print((*b_bi...
N, *A = list(map(int, open(0).read().split())) x = [0] * (N + 1) ans = [] for i in reversed(list(range(1, N + 1))): tmp = 0 for j in range(i, N + 1, i): tmp += x[j] if tmp % 2 != A[i - 1]: x[i] += 1 ans.append(i) print((len(ans))) if ans: print((*ans))
16
17
329
297
N, *a = list(map(int, open(0).read().split())) dp = [0] * N for i in reversed(list(range(N))): cnt = sum(dp[i :: i + 1]) if cnt % 2 == a[i]: dp[i] = 0 else: dp[i] = 1 if True: b_bin = [i + 1 for i in range(N) if dp[i] > 0] print((len(b_bin))) print((*b_bin)) else: print((-1))...
N, *A = list(map(int, open(0).read().split())) x = [0] * (N + 1) ans = [] for i in reversed(list(range(1, N + 1))): tmp = 0 for j in range(i, N + 1, i): tmp += x[j] if tmp % 2 != A[i - 1]: x[i] += 1 ans.append(i) print((len(ans))) if ans: print((*ans))
false
5.882353
[ "-N, *a = list(map(int, open(0).read().split()))", "-dp = [0] * N", "-for i in reversed(list(range(N))):", "- cnt = sum(dp[i :: i + 1])", "- if cnt % 2 == a[i]:", "- dp[i] = 0", "- else:", "- dp[i] = 1", "-if True:", "- b_bin = [i + 1 for i in range(N) if dp[i] > 0]", "...
false
0.085028
0.083098
1.023219
[ "s766955065", "s914599697" ]
u745087332
p04048
python
s097083462
s373477549
19
17
3,188
3,060
Accepted
Accepted
10.53
n, x = list(map(int, input().split())) def func(a, b): if a < b: if b%a == 0: return (b//a*2 - 1)*a else: q, mod = divmod(b,a) return 2*q*a + func(a, mod) elif a > b: if a%b == 0: return (a//b*2 - 1)*b else: ...
# coding:utf-8 def inpl(): return list(map(int, input().split())) n, x = inpl() def func(a, b): if a < b: a, b = b, a if a == b: return a else: if a % b == 0: return (a // b * 2 - 1) * b else: q, mod = divmod(a, b) ...
22
27
477
506
n, x = list(map(int, input().split())) def func(a, b): if a < b: if b % a == 0: return (b // a * 2 - 1) * a else: q, mod = divmod(b, a) return 2 * q * a + func(a, mod) elif a > b: if a % b == 0: return (a // b * 2 - 1) * b else: ...
# coding:utf-8 def inpl(): return list(map(int, input().split())) n, x = inpl() def func(a, b): if a < b: a, b = b, a if a == b: return a else: if a % b == 0: return (a // b * 2 - 1) * b else: q, mod = divmod(a, b) return 2 * q * b ...
false
18.518519
[ "-n, x = list(map(int, input().split()))", "+# coding:utf-8", "+def inpl():", "+ return list(map(int, input().split()))", "+", "+", "+n, x = inpl()", "- if b % a == 0:", "- return (b // a * 2 - 1) * a", "- else:", "- q, mod = divmod(b, a)", "- ...
false
0.083597
0.075483
1.107493
[ "s097083462", "s373477549" ]
u883048396
p03855
python
s982273017
s123300401
822
722
84,652
95,404
Accepted
Accepted
12.17
#Union-Find木の構築 import sys def 解(): iN,iK,iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] def buildTree(a): aT = [0]*(iN+1) for p,q in a: rp = getRoot(aT,p) rq = getRoot(aT,q) thi...
#Union-Find木の構築 import sys def 解(): iN,iK,iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] def buildTree(a): #aT = [0]*(iN+1) aT = list(range(iN+1)) for p,q in a: rp = getRoot(aT,p) rq...
42
44
1,170
1,228
# Union-Find木の構築 import sys def 解(): iN, iK, iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] def buildTree(a): aT = [0] * (iN + 1) for p, q in a: rp = getRoot(aT, p) rq = getRoot(aT, q) th...
# Union-Find木の構築 import sys def 解(): iN, iK, iL = [int(_) for _ in input().split()] aD = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()] def buildTree(a): # aT = [0]*(iN+1) aT = list(range(iN + 1)) for p, q in a: rp = getRoot(aT, p) rq ...
false
4.545455
[ "- aT = [0] * (iN + 1)", "+ # aT = [0]*(iN+1)", "+ aT = list(range(iN + 1))", "- if a[i] == i or a[i] == 0:", "- if a[i] == 0:", "- a[i] = i", "+ # if a[i] == i or a[i] == 0:", "+ # if a[i] == 0 : a[i] = i", "+ if a[i] == i...
false
0.042964
0.041732
1.029514
[ "s982273017", "s123300401" ]
u923668099
p02267
python
s657392864
s041529479
60
50
8,524
8,560
Accepted
Accepted
16.67
def LinearSearch(n, S, t): """ ????????????????????¢????????? """ S.append(t) i = 0 while S[i] != t: i += 1 if i == n: return -1 else: return i n = int(eval(input())) S = [int(s) for s in input().split()] q = int(eval(input())) T = [int(t) for t in ...
def LinearSearch1(S, n, t): for i in range(n): if S[i] == t: return i break else: return -1 """ def LinearSearch2(S, n, t): S.append(t) i = 0 while S[i] != t: i += 1 S.pop() if i == n: return -1 else: ...
27
33
422
520
def LinearSearch(n, S, t): """????????????????????¢?????????""" S.append(t) i = 0 while S[i] != t: i += 1 if i == n: return -1 else: return i n = int(eval(input())) S = [int(s) for s in input().split()] q = int(eval(input())) T = [int(t) for t in input().split()] cnt = ...
def LinearSearch1(S, n, t): for i in range(n): if S[i] == t: return i break else: return -1 """ def LinearSearch2(S, n, t): S.append(t) i = 0 while S[i] != t: i += 1 S.pop() if i == n: return -1 else: return i """ n = int(...
false
18.181818
[ "-def LinearSearch(n, S, t):", "- \"\"\"????????????????????¢?????????\"\"\"", "+def LinearSearch1(S, n, t):", "+ for i in range(n):", "+ if S[i] == t:", "+ return i", "+ break", "+ else:", "+ return -1", "+", "+", "+\"\"\"", "+def LinearSearch2(S...
false
0.040628
0.041088
0.988791
[ "s657392864", "s041529479" ]
u968166680
p04013
python
s636131501
s125120729
74
63
67,136
66,356
Accepted
Accepted
14.86
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(): N, A, *X = list(map(int, read().split())) X = [x - A for x in X] base = 2500 dp = [[0] * 5001 for _ in range(N + 1)]...
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(): N, A, *X = list(map(int, read().split())) X = [x - A for x in X] neg = pos = 0 for x in X: if x > 0: ...
30
40
604
744
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(): N, A, *X = list(map(int, read().split())) X = [x - A for x in X] base = 2500 dp = [[0] * 5001 for _ in range(N + 1)] dp[0][base] =...
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(): N, A, *X = list(map(int, read().split())) X = [x - A for x in X] neg = pos = 0 for x in X: if x > 0: pos += x ...
false
25
[ "- base = 2500", "- dp = [[0] * 5001 for _ in range(N + 1)]", "+ neg = pos = 0", "+ for x in X:", "+ if x > 0:", "+ pos += x", "+ else:", "+ neg += x", "+ M = pos - neg", "+ base = -neg", "+ dp = [[0] * (M + 1) for _ in range(N + 1)]", "...
false
0.054148
0.104716
0.517089
[ "s636131501", "s125120729" ]
u597374218
p02819
python
s815679830
s180449303
42
30
2,940
9,096
Accepted
Accepted
28.57
X=int(eval(input())) num=2 while num<X: if X%num==0: X+=1 num=2 else: num+=1 print(X)
X=int(eval(input())) for x in range(X,2*X): for i in range(2,int(x**.5)+1): if x%i==0: break else: print(x) break
9
8
119
158
X = int(eval(input())) num = 2 while num < X: if X % num == 0: X += 1 num = 2 else: num += 1 print(X)
X = int(eval(input())) for x in range(X, 2 * X): for i in range(2, int(x**0.5) + 1): if x % i == 0: break else: print(x) break
false
11.111111
[ "-num = 2", "-while num < X:", "- if X % num == 0:", "- X += 1", "- num = 2", "+for x in range(X, 2 * X):", "+ for i in range(2, int(x**0.5) + 1):", "+ if x % i == 0:", "+ break", "- num += 1", "-print(X)", "+ print(x)", "+ break" ]
false
0.038838
0.036585
1.061587
[ "s815679830", "s180449303" ]
u057109575
p03107
python
s445590607
s157719110
32
18
3,956
3,188
Accepted
Accepted
43.75
s = eval(input()) print((2 * min([sum([v == '1' for v in s]), sum([v == '0' for v in s])])))
S = eval(input()) print((min(S.count('0'), S.count('1')) * 2))
2
2
85
55
s = eval(input()) print((2 * min([sum([v == "1" for v in s]), sum([v == "0" for v in s])])))
S = eval(input()) print((min(S.count("0"), S.count("1")) * 2))
false
0
[ "-s = eval(input())", "-print((2 * min([sum([v == \"1\" for v in s]), sum([v == \"0\" for v in s])])))", "+S = eval(input())", "+print((min(S.count(\"0\"), S.count(\"1\")) * 2))" ]
false
0.035627
0.036848
0.966859
[ "s445590607", "s157719110" ]
u581187895
p02713
python
s137156299
s271672925
949
204
9,196
89,664
Accepted
Accepted
78.5
import math def resolve(): N = int(input()) ans = 0 for i in range(1, N+1): for j in range(1, N + 1): g = math.gcd(i, j) for k in range(1, N + 1): ans += math.gcd(g,k) return print(ans) if __name__ == "__main__": resolve()
import numpy as np def resolve(): N = int(input()) A = np.arange(1, N+1) ans = np.gcd.outer(np.gcd.outer(A, A),A) return print((ans.sum())) if __name__ == "__main__": resolve()
15
10
307
207
import math def resolve(): N = int(input()) ans = 0 for i in range(1, N + 1): for j in range(1, N + 1): g = math.gcd(i, j) for k in range(1, N + 1): ans += math.gcd(g, k) return print(ans) if __name__ == "__main__": resolve()
import numpy as np def resolve(): N = int(input()) A = np.arange(1, N + 1) ans = np.gcd.outer(np.gcd.outer(A, A), A) return print((ans.sum())) if __name__ == "__main__": resolve()
false
33.333333
[ "-import math", "+import numpy as np", "- ans = 0", "- for i in range(1, N + 1):", "- for j in range(1, N + 1):", "- g = math.gcd(i, j)", "- for k in range(1, N + 1):", "- ans += math.gcd(g, k)", "- return print(ans)", "+ A = np.arange(1, N +...
false
0.197112
0.515742
0.382192
[ "s137156299", "s271672925" ]
u222643068
p02899
python
s645196697
s634201075
185
170
28,752
29,284
Accepted
Accepted
8.11
eval(input()) li=list(map(int,input().split())) enu_li=[[i,value] for i,value in enumerate(li,1)] enu_li=sorted(enu_li,key=lambda x:x[1]) result=[str(value[0]) for value in enu_li] print((' '.join(result)))
n=int(eval(input())) li=list(map(int,input().split())) mod_li=[[i,num] for i,num in enumerate(li,1)] result_li=sorted(mod_li, key=lambda x: x[1]) result=[str(num[0]) for num in result_li] print((" ".join(result)))
9
8
209
214
eval(input()) li = list(map(int, input().split())) enu_li = [[i, value] for i, value in enumerate(li, 1)] enu_li = sorted(enu_li, key=lambda x: x[1]) result = [str(value[0]) for value in enu_li] print((" ".join(result)))
n = int(eval(input())) li = list(map(int, input().split())) mod_li = [[i, num] for i, num in enumerate(li, 1)] result_li = sorted(mod_li, key=lambda x: x[1]) result = [str(num[0]) for num in result_li] print((" ".join(result)))
false
11.111111
[ "-eval(input())", "+n = int(eval(input()))", "-enu_li = [[i, value] for i, value in enumerate(li, 1)]", "-enu_li = sorted(enu_li, key=lambda x: x[1])", "-result = [str(value[0]) for value in enu_li]", "+mod_li = [[i, num] for i, num in enumerate(li, 1)]", "+result_li = sorted(mod_li, key=lambda x: x[1])...
false
0.100978
0.068471
1.474755
[ "s645196697", "s634201075" ]
u759412327
p02918
python
s929251304
s128542495
80
71
3,976
9,824
Accepted
Accepted
11.25
from itertools import groupby N,K = list(map(int,input().split())) S = eval(input()) A = [] for i,j in groupby(S): A.append(len(list(j))-1) print((min(N-1,sum(A)+2*K)))
from itertools import * N,K = list(map(int,input().split())) S = eval(input()) A = [] for i,j in groupby(S): A+=[len(list(j))-1] print((min(N-1,sum(A)+2*K)))
9
9
172
155
from itertools import groupby N, K = list(map(int, input().split())) S = eval(input()) A = [] for i, j in groupby(S): A.append(len(list(j)) - 1) print((min(N - 1, sum(A) + 2 * K)))
from itertools import * N, K = list(map(int, input().split())) S = eval(input()) A = [] for i, j in groupby(S): A += [len(list(j)) - 1] print((min(N - 1, sum(A) + 2 * K)))
false
0
[ "-from itertools import groupby", "+from itertools import *", "- A.append(len(list(j)) - 1)", "+ A += [len(list(j)) - 1]" ]
false
0.071245
0.038428
1.853997
[ "s929251304", "s128542495" ]
u865138391
p02419
python
s464092513
s947354963
30
20
7,484
7,484
Accepted
Accepted
33.33
import sys W = eval(input()) print((sum(line.lower().split().count(W) for line in sys.stdin.readlines())))
import sys W = input().casefold() print((sum(line.casefold().split().count(W) for line in sys.stdin.readlines())))
3
3
100
114
import sys W = eval(input()) print((sum(line.lower().split().count(W) for line in sys.stdin.readlines())))
import sys W = input().casefold() print((sum(line.casefold().split().count(W) for line in sys.stdin.readlines())))
false
0
[ "-W = eval(input())", "-print((sum(line.lower().split().count(W) for line in sys.stdin.readlines())))", "+W = input().casefold()", "+print((sum(line.casefold().split().count(W) for line in sys.stdin.readlines())))" ]
false
0.12687
0.044712
2.837472
[ "s464092513", "s947354963" ]
u600402037
p02901
python
s208527495
s818423904
922
223
3,188
43,372
Accepted
Accepted
75.81
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() bit_cnt = 2 ** N # 箱は最大で12個 INF = 10 ** 10 dp = [INF] * bit_cnt dp[0] = 0 for _ in range(M): price, b = lr() open = sum([2 ** (x-1) for x in lr()]) # 1と3の箱を開ける鍵なら101と...
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # dfs, dp, bit全探索 # 箱が12個以下 N, M = lr() keys = [None] * M for i in range(M): a, b = lr() C = lr() bit = 0 for c in C: bit += 1 << (c-1) keys[i] = (a, bit) ...
23
27
504
552
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() bit_cnt = 2**N # 箱は最大で12個 INF = 10**10 dp = [INF] * bit_cnt dp[0] = 0 for _ in range(M): price, b = lr() open = sum([2 ** (x - 1) for x in lr()]) # 1と3の箱を開ける鍵なら101となる for j i...
import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) # dfs, dp, bit全探索 # 箱が12個以下 N, M = lr() keys = [None] * M for i in range(M): a, b = lr() C = lr() bit = 0 for c in C: bit += 1 << (c - 1) keys[i] = (a, bit) INF = 10**9 dp ...
false
14.814815
[ "+# dfs, dp, bit全探索", "+# 箱が12個以下", "-bit_cnt = 2**N # 箱は最大で12個", "-INF = 10**10", "-dp = [INF] * bit_cnt", "+keys = [None] * M", "+for i in range(M):", "+ a, b = lr()", "+ C = lr()", "+ bit = 0", "+ for c in C:", "+ bit += 1 << (c - 1)", "+ keys[i] = (a, bit)", "+IN...
false
0.036011
0.112661
0.319643
[ "s208527495", "s818423904" ]
u332657092
p03645
python
s340661260
s617804897
1,096
910
87,264
57,944
Accepted
Accepted
16.97
n, m = list(map(int, input().split())) dic = {} for i in range(1, n+1): dic[i] = [] for i in range(m): a1, a2 = list(map(int, input().split())) dic[a1] += [a2] dic[a2] += [a1] Places_from1 = dic[1] for place in Places_from1: if n in dic[place]: print("POSSIBLE") break else: print("IM...
N,M=list(map(int,input().split())) sa=set() sb=set() for i in range(M): a,b=list(map(int,input().split())) if a==1:sb.add(b) if b==N:sa.add(a) print(("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE"))
16
8
318
202
n, m = list(map(int, input().split())) dic = {} for i in range(1, n + 1): dic[i] = [] for i in range(m): a1, a2 = list(map(int, input().split())) dic[a1] += [a2] dic[a2] += [a1] Places_from1 = dic[1] for place in Places_from1: if n in dic[place]: print("POSSIBLE") break else: pri...
N, M = list(map(int, input().split())) sa = set() sb = set() for i in range(M): a, b = list(map(int, input().split())) if a == 1: sb.add(b) if b == N: sa.add(a) print(("IMPOSSIBLE" if len(sa & sb) == 0 else "POSSIBLE"))
false
50
[ "-n, m = list(map(int, input().split()))", "-dic = {}", "-for i in range(1, n + 1):", "- dic[i] = []", "-for i in range(m):", "- a1, a2 = list(map(int, input().split()))", "- dic[a1] += [a2]", "- dic[a2] += [a1]", "-Places_from1 = dic[1]", "-for place in Places_from1:", "- if n in...
false
0.038359
0.038488
0.996651
[ "s340661260", "s617804897" ]
u820351940
p03400
python
s937091439
s222735525
22
18
3,316
3,060
Accepted
Accepted
18.18
from math import * n=int(eval(input())) d,x=list(map(int,input().split())) print((sum(ceil(d/int(eval(input())))for _ in range(n))+x))
from math import * i=input I=int n=I(i()) d,x=list(map(I,i().split())) print((sum(ceil(d/I(i()))for _ in range(n))+x))
4
6
117
115
from math import * n = int(eval(input())) d, x = list(map(int, input().split())) print((sum(ceil(d / int(eval(input()))) for _ in range(n)) + x))
from math import * i = input I = int n = I(i()) d, x = list(map(I, i().split())) print((sum(ceil(d / I(i())) for _ in range(n)) + x))
false
33.333333
[ "-n = int(eval(input()))", "-d, x = list(map(int, input().split()))", "-print((sum(ceil(d / int(eval(input()))) for _ in range(n)) + x))", "+i = input", "+I = int", "+n = I(i())", "+d, x = list(map(I, i().split()))", "+print((sum(ceil(d / I(i())) for _ in range(n)) + x))" ]
false
0.036326
0.038006
0.955789
[ "s937091439", "s222735525" ]
u390727364
p02713
python
s108733488
s050539553
1,726
136
108,504
70,380
Accepted
Accepted
92.12
from numba import njit from sys import stdin @njit(cache=True) def gcd(x, y): if x % y == 0: return y return gcd(y, x % y) @njit(cache=True) def fact(x): if x == 1: return x return x * fact(x - 1) def main(): k = int(stdin.readline()) ans = 0 fo...
from sys import stdin, setrecursionlimit def gcd(x, y): if x % y == 0: return y return gcd(y, x % y) def main(): input = stdin.buffer.readline k = int(eval(input())) g = [] for i in range(1, k + 1): gi = [] for j in range(1, k + 1): gi.appe...
35
30
611
606
from numba import njit from sys import stdin @njit(cache=True) def gcd(x, y): if x % y == 0: return y return gcd(y, x % y) @njit(cache=True) def fact(x): if x == 1: return x return x * fact(x - 1) def main(): k = int(stdin.readline()) ans = 0 for a in range(1, k + 1): ...
from sys import stdin, setrecursionlimit def gcd(x, y): if x % y == 0: return y return gcd(y, x % y) def main(): input = stdin.buffer.readline k = int(eval(input())) g = [] for i in range(1, k + 1): gi = [] for j in range(1, k + 1): gi.append(gcd(i, j)) ...
false
14.285714
[ "-from numba import njit", "-from sys import stdin", "+from sys import stdin, setrecursionlimit", "-@njit(cache=True)", "-@njit(cache=True)", "-def fact(x):", "- if x == 1:", "- return x", "- return x * fact(x - 1)", "-", "-", "- k = int(stdin.readline())", "+ input = stdi...
false
0.080021
0.076261
1.049302
[ "s108733488", "s050539553" ]
u687044304
p02659
python
s434205192
s490654725
27
23
10,112
9,184
Accepted
Accepted
14.81
# -*- coding:utf-8 -*- def solve(): A, B = input().split() # 2進浮動小数点数(float)にしたら誤差が発生するので、整数のまま計算する A = int(A) B = int(B.replace(".", "")) ans = A*B//100 print(ans) def solve2(): A, B = input().split() # 10進小数が扱えるdecimalモジュールを使う from decimal import Decimal ...
# -*- coding:utf-8 -*- def solve(): A, B = input().split() # 2進浮動小数点数(float)にしたら誤差が発生するので、整数のまま計算する A = int(A) B = int(B.replace(".", "")) ans = A*B//100 print(ans) def solve2(): A, B = input().split() # 10進小数が扱えるdecimalモジュールを使う from decimal import Decimal ...
27
27
436
435
# -*- coding:utf-8 -*- def solve(): A, B = input().split() # 2進浮動小数点数(float)にしたら誤差が発生するので、整数のまま計算する A = int(A) B = int(B.replace(".", "")) ans = A * B // 100 print(ans) def solve2(): A, B = input().split() # 10進小数が扱えるdecimalモジュールを使う from decimal import Decimal A = int(A) B...
# -*- coding:utf-8 -*- def solve(): A, B = input().split() # 2進浮動小数点数(float)にしたら誤差が発生するので、整数のまま計算する A = int(A) B = int(B.replace(".", "")) ans = A * B // 100 print(ans) def solve2(): A, B = input().split() # 10進小数が扱えるdecimalモジュールを使う from decimal import Decimal A = int(A) B...
false
0
[ "- solve2()", "+ solve()" ]
false
0.074736
0.05727
1.304963
[ "s434205192", "s490654725" ]
u794173881
p03161
python
s342301333
s821518784
439
364
52,448
52,592
Accepted
Accepted
17.08
N,K = list(map(int,input().split())) h = list(map(int,input().split())) dp = [100000000000]*N dp[0] = 0 dp[1] = abs(h[1]-h[0]) for i in range(2,N): for num in range(K): if num+1<=i: A = dp[i-num-1]+abs(h[i]-h[i-num-1]) if dp[i] >= A: dp[i] = A print((dp[N-1]))
n, k = list(map(int, input().split())) h = list(map(int, input().split())) INF = 10**18 dp = [INF] * (n) dp[0] = 0 for i in range(n): for j in range(1, k+1): if i+j < n: dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i])) else: break print((dp[-1]))
16
14
301
299
N, K = list(map(int, input().split())) h = list(map(int, input().split())) dp = [100000000000] * N dp[0] = 0 dp[1] = abs(h[1] - h[0]) for i in range(2, N): for num in range(K): if num + 1 <= i: A = dp[i - num - 1] + abs(h[i] - h[i - num - 1]) if dp[i] >= A: dp[i] = A ...
n, k = list(map(int, input().split())) h = list(map(int, input().split())) INF = 10**18 dp = [INF] * (n) dp[0] = 0 for i in range(n): for j in range(1, k + 1): if i + j < n: dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i])) else: break print((dp[-1]))
false
12.5
[ "-N, K = list(map(int, input().split()))", "+n, k = list(map(int, input().split()))", "-dp = [100000000000] * N", "+INF = 10**18", "+dp = [INF] * (n)", "-dp[1] = abs(h[1] - h[0])", "-for i in range(2, N):", "- for num in range(K):", "- if num + 1 <= i:", "- A = dp[i - num - 1]...
false
0.038962
0.039914
0.976159
[ "s342301333", "s821518784" ]
u801359367
p03287
python
s415259846
s035398655
322
222
24,004
23,808
Accepted
Accepted
31.06
from collections import defaultdict import numpy as np N,M = list(map(int,input().split())) A = input().split() A = np.array(A,dtype='int64') C = np.append([0],np.cumsum(A)) #累積和を算出して最初に0をつける。 L = [i%M for i in C] #Mで割ったあまりを求めてリスト化 d = defaultdict(int) for i in L: d[i] +=1 #各余りに対して、その数が何個あるかを求める。 ...
import collections import numpy as np N,M = list(map(int,input().split())) A = np.array(input().split(),dtype='int64') C = np.append([0],np.cumsum(A)) L = C % M L_c = collections.Counter(L) ans = 0 for i in list(L_c.values()): S = i * (i-1) / 2 ans+=S print((int(ans)))
22
16
408
294
from collections import defaultdict import numpy as np N, M = list(map(int, input().split())) A = input().split() A = np.array(A, dtype="int64") C = np.append([0], np.cumsum(A)) # 累積和を算出して最初に0をつける。 L = [i % M for i in C] # Mで割ったあまりを求めてリスト化 d = defaultdict(int) for i in L: d[i] += 1 # 各余りに対して、その数が何個あるかを求める。 ans = 0...
import collections import numpy as np N, M = list(map(int, input().split())) A = np.array(input().split(), dtype="int64") C = np.append([0], np.cumsum(A)) L = C % M L_c = collections.Counter(L) ans = 0 for i in list(L_c.values()): S = i * (i - 1) / 2 ans += S print((int(ans)))
false
27.272727
[ "-from collections import defaultdict", "+import collections", "-A = input().split()", "-A = np.array(A, dtype=\"int64\")", "+A = np.array(input().split(), dtype=\"int64\")", "-# 累積和を算出して最初に0をつける。", "-L = [i % M for i in C]", "-# Mで割ったあまりを求めてリスト化", "-d = defaultdict(int)", "-for i in L:", "- ...
false
0.219492
0.704261
0.311662
[ "s415259846", "s035398655" ]
u867826040
p02622
python
s506833884
s303378637
69
43
9,396
10,884
Accepted
Accepted
37.68
s = eval(input()) t = eval(input()) ans = 0 for i in range(len(s)): if s[i] != t[i]: ans+=1 print(ans)
s,t=eval(input()),eval(input()) print((sum([si!=ti for si,ti in zip(s,t)])))
7
2
108
63
s = eval(input()) t = eval(input()) ans = 0 for i in range(len(s)): if s[i] != t[i]: ans += 1 print(ans)
s, t = eval(input()), eval(input()) print((sum([si != ti for si, ti in zip(s, t)])))
false
71.428571
[ "-s = eval(input())", "-t = eval(input())", "-ans = 0", "-for i in range(len(s)):", "- if s[i] != t[i]:", "- ans += 1", "-print(ans)", "+s, t = eval(input()), eval(input())", "+print((sum([si != ti for si, ti in zip(s, t)])))" ]
false
0.039894
0.057516
0.693615
[ "s506833884", "s303378637" ]
u620084012
p02755
python
s600849555
s637892623
184
25
39,152
2,940
Accepted
Accepted
86.41
from math import floor A, B = list(map(int,input().split())) for k in range(1,20000): if floor(k*0.08) == A and floor(k*0.1) == B: print(k) exit(0) print((-1))
A, B = list(map(int,input().split())) for k in range(1,20000): if int(k*1.08) == A+k and int(k*1.10) == B+k: print(k) exit(0) print((-1))
7
6
178
155
from math import floor A, B = list(map(int, input().split())) for k in range(1, 20000): if floor(k * 0.08) == A and floor(k * 0.1) == B: print(k) exit(0) print((-1))
A, B = list(map(int, input().split())) for k in range(1, 20000): if int(k * 1.08) == A + k and int(k * 1.10) == B + k: print(k) exit(0) print((-1))
false
14.285714
[ "-from math import floor", "-", "- if floor(k * 0.08) == A and floor(k * 0.1) == B:", "+ if int(k * 1.08) == A + k and int(k * 1.10) == B + k:" ]
false
0.056823
0.039365
1.443494
[ "s600849555", "s637892623" ]
u454557108
p02837
python
s190545277
s684269768
537
441
3,064
48,860
Accepted
Accepted
17.88
n = int(eval(input())) ip = [] for i in range(n): a = int(eval(input())) ip.append(a) for j in range(a): x,y = list(map(int,input().split())) ip.append([x,y]) max = 0 for i in range(n) : max += 2**i ans = 0 for i in range(0,max+1) : s = [2 for _ in range(n)] bit = i count ...
n = int(eval(input())) ip = [] for i in range(n): a = int(eval(input())) ip.append(a) for j in range(a): x,y = list(map(int,input().split())) ip.append([x,y]) max = 0 for i in range(n) : max += 2**i ans = 0 for i in range(0,max+1) : s = [2 for _ in range(n)] bit = i count ...
52
46
1,059
957
n = int(eval(input())) ip = [] for i in range(n): a = int(eval(input())) ip.append(a) for j in range(a): x, y = list(map(int, input().split())) ip.append([x, y]) max = 0 for i in range(n): max += 2**i ans = 0 for i in range(0, max + 1): s = [2 for _ in range(n)] bit = i count...
n = int(eval(input())) ip = [] for i in range(n): a = int(eval(input())) ip.append(a) for j in range(a): x, y = list(map(int, input().split())) ip.append([x, y]) max = 0 for i in range(n): max += 2**i ans = 0 for i in range(0, max + 1): s = [2 for _ in range(n)] bit = i count...
false
11.538462
[ "- break", "- break", "- break", "- break", "- if check == 1:", "- break" ]
false
0.048083
0.048124
0.999143
[ "s190545277", "s684269768" ]
u490464064
p03457
python
s545646030
s076419899
399
324
11,636
3,064
Accepted
Accepted
18.8
N = int(eval(input())) t = [0] * (N+1) x = [0] * (N+1) y = [0] * (N+1) for i in range(N): t[i+1], x[i+1], y[i+1] = list(map(int, input().split())) f = True for i in range(N): dt = t[i+1] - t[i] dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]) if dt < dist: f = False if dist%2 != dt%2...
import sys def main(): N = int(eval(input())) t, x, y = 0, 0, 0 for _ in range(N): next_t, next_x, next_y = [int(__) for __ in input().split()] delta_t = next_t - t distance = abs(next_x - x) + abs(next_y - y) if distance > delta_t: print("No") ...
17
25
359
503
N = int(eval(input())) t = [0] * (N + 1) x = [0] * (N + 1) y = [0] * (N + 1) for i in range(N): t[i + 1], x[i + 1], y[i + 1] = list(map(int, input().split())) f = True for i in range(N): dt = t[i + 1] - t[i] dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) if dt < dist: f = False if dist %...
import sys def main(): N = int(eval(input())) t, x, y = 0, 0, 0 for _ in range(N): next_t, next_x, next_y = [int(__) for __ in input().split()] delta_t = next_t - t distance = abs(next_x - x) + abs(next_y - y) if distance > delta_t: print("No") sys.e...
false
32
[ "-N = int(eval(input()))", "-t = [0] * (N + 1)", "-x = [0] * (N + 1)", "-y = [0] * (N + 1)", "-for i in range(N):", "- t[i + 1], x[i + 1], y[i + 1] = list(map(int, input().split()))", "-f = True", "-for i in range(N):", "- dt = t[i + 1] - t[i]", "- dist = abs(x[i + 1] - x[i]) + abs(y[i + ...
false
0.043814
0.068567
0.638999
[ "s545646030", "s076419899" ]
u731896389
p02389
python
s672656479
s227047685
30
20
7,560
7,644
Accepted
Accepted
33.33
a,b=list(map(int,input().split())) print((a*b,2*(a+b)))
x,y = list(map(int,input().split())) print((x*y,(x+y)*2))
2
2
48
50
a, b = list(map(int, input().split())) print((a * b, 2 * (a + b)))
x, y = list(map(int, input().split())) print((x * y, (x + y) * 2))
false
0
[ "-a, b = list(map(int, input().split()))", "-print((a * b, 2 * (a + b)))", "+x, y = list(map(int, input().split()))", "+print((x * y, (x + y) * 2))" ]
false
0.043858
0.042825
1.024106
[ "s672656479", "s227047685" ]