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
u562935282
p02953
python
s484854769
s509155782
87
48
14,252
14,396
Accepted
Accepted
44.83
n = int(eval(input())) h = list(map(int, input().split())) cur = h[-1] i = n - 2 flg = True while i >= 0: if h[i] <= cur + 1: cur = min(cur, h[i]) else: flg = False break i -= 1 print(('Yes' if flg else 'No'))
def main(): N = int(eval(input())) *H, = list(map(int, input().split())) cond = True p = H[0] - 1 for h in H[1:]: if p < h: p = h - 1 elif p == h: pass else: cond = False break print(('Yes' if cond else 'No'...
15
20
254
353
n = int(eval(input())) h = list(map(int, input().split())) cur = h[-1] i = n - 2 flg = True while i >= 0: if h[i] <= cur + 1: cur = min(cur, h[i]) else: flg = False break i -= 1 print(("Yes" if flg else "No"))
def main(): N = int(eval(input())) (*H,) = list(map(int, input().split())) cond = True p = H[0] - 1 for h in H[1:]: if p < h: p = h - 1 elif p == h: pass else: cond = False break print(("Yes" if cond else "No")) if __name_...
false
25
[ "-n = int(eval(input()))", "-h = list(map(int, input().split()))", "-cur = h[-1]", "-i = n - 2", "-flg = True", "-while i >= 0:", "- if h[i] <= cur + 1:", "- cur = min(cur, h[i])", "- else:", "- flg = False", "- break", "- i -= 1", "-print((\"Yes\" if flg else \...
false
0.1014
0.082071
1.235525
[ "s484854769", "s509155782" ]
u724687935
p02537
python
s814855621
s249850911
1,097
714
142,888
140,088
Accepted
Accepted
34.91
class SegmentTree(): """ update, get を提供するSegmentTree Attributes ---------- __n : int 葉の数。2 ^ i - 1 __dot : Segment function __e: int 単位元 __node: list Segment Tree """ def __init__(self, A, dot, e): """ Parameters ...
class SegmentTree(): """ update, get を提供するSegmentTree Attributes ---------- __n : int 葉の数。2 ^ i - 1 __dot : Segment function __e: int 単位元 __node: list Segment Tree """ def __init__(self, A, dot, e): """ Parameters ...
75
72
1,850
1,742
class SegmentTree: """ update, get を提供するSegmentTree Attributes ---------- __n : int 葉の数。2 ^ i - 1 __dot : Segment function __e: int 単位元 __node: list Segment Tree """ def __init__(self, A, dot, e): """ Parameters ---------- ...
class SegmentTree: """ update, get を提供するSegmentTree Attributes ---------- __n : int 葉の数。2 ^ i - 1 __dot : Segment function __e: int 単位元 __node: list Segment Tree """ def __init__(self, A, dot, e): """ Parameters ---------- ...
false
4
[ "-st = SegmentTree([N] * (max_A + 1), min, N)", "-dp = [0] * (N + 1)", "-for i, a in enumerate(reversed(A)):", "- j = N - 1 - i", "- p1 = st.get(a, min(max_A + 1, a + K + 1))", "- dp[j] = max(dp[p1] + 1, dp[j])", "- p2 = st.get(max(0, a - K), a)", "- dp[j] = max(dp[p2] + 1, dp[j])", "...
false
0.036577
0.03692
0.990719
[ "s814855621", "s249850911" ]
u562935282
p02861
python
s051624200
s778342314
294
21
3,572
3,444
Accepted
Accepted
92.86
def main(): from collections import namedtuple from itertools import permutations from math import factorial City = namedtuple('City', 'x y') def dist(a: City, b: City) -> float: dx = a.x - b.x dy = a.y - b.y return (dx * dx + dy * dy) ** 0.5 N = int(eval(i...
def main(): from collections import namedtuple from itertools import combinations City = namedtuple('City', 'x y') def dist(a: City, b: City) -> float: dx = a.x - b.x dy = a.y - b.y return (dx * dx + dy * dy) ** 0.5 N = int(eval(input())) cities = [] ...
44
36
887
776
def main(): from collections import namedtuple from itertools import permutations from math import factorial City = namedtuple("City", "x y") def dist(a: City, b: City) -> float: dx = a.x - b.x dy = a.y - b.y return (dx * dx + dy * dy) ** 0.5 N = int(eval(input())) ...
def main(): from collections import namedtuple from itertools import combinations City = namedtuple("City", "x y") def dist(a: City, b: City) -> float: dx = a.x - b.x dy = a.y - b.y return (dx * dx + dy * dy) ** 0.5 N = int(eval(input())) cities = [] for _ in range...
false
18.181818
[ "- from itertools import permutations", "- from math import factorial", "+ from itertools import combinations", "- for perm in permutations(cities):", "- it = iter(perm)", "- p = next(it)", "- for city in it:", "- total += dist(p, city)", "- p =...
false
0.07196
0.040661
1.769773
[ "s051624200", "s778342314" ]
u848647227
p04025
python
s746820736
s102608021
25
23
3,060
2,940
Accepted
Accepted
8
a = int(eval(input())) ar = list(map(int,input().split(" "))) br = [] for i in range(min(ar),max(ar)+1): count = 0 for r in ar: count += (i - r) ** 2 br.append(count) print((min(br)))
a = int(eval(input())) ar = list(map(int,input().split(" "))) b = 10 ** 9 for i in range(min(ar),max(ar) + 1): count = 0 for r in ar: count += (r - i) ** 2 if b > count: b = count print(b)
9
10
203
219
a = int(eval(input())) ar = list(map(int, input().split(" "))) br = [] for i in range(min(ar), max(ar) + 1): count = 0 for r in ar: count += (i - r) ** 2 br.append(count) print((min(br)))
a = int(eval(input())) ar = list(map(int, input().split(" "))) b = 10**9 for i in range(min(ar), max(ar) + 1): count = 0 for r in ar: count += (r - i) ** 2 if b > count: b = count print(b)
false
10
[ "-br = []", "+b = 10**9", "- count += (i - r) ** 2", "- br.append(count)", "-print((min(br)))", "+ count += (r - i) ** 2", "+ if b > count:", "+ b = count", "+print(b)" ]
false
0.036224
0.035485
1.02083
[ "s746820736", "s102608021" ]
u743272507
p02861
python
s099096460
s834806712
311
102
3,064
9,184
Accepted
Accepted
67.2
import itertools n = int(eval(input())) point = [] for i in range(n): a,b = list(map(float,input().split())) point.append((a,b)) ans = 0.0 div = 0 for pm in itertools.permutations(point): div += 1 for j in range(n-1): ans += ((pm[j][0]-pm[j+1][0])**2 + (pm[j][1]-pm[j+1][1])**2) ** 0.5 print((ans...
from itertools import permutations from math import factorial n = int(eval(input())) town = [complex(*list(map(int,input().split()))) for _ in range(n)] d = 0 for l in permutations(town): for i in range(n-1): d += abs(l[i]-l[i+1]) print((d/factorial(n)))
13
9
314
254
import itertools n = int(eval(input())) point = [] for i in range(n): a, b = list(map(float, input().split())) point.append((a, b)) ans = 0.0 div = 0 for pm in itertools.permutations(point): div += 1 for j in range(n - 1): ans += ((pm[j][0] - pm[j + 1][0]) ** 2 + (pm[j][1] - pm[j + 1][1]) ** 2)...
from itertools import permutations from math import factorial n = int(eval(input())) town = [complex(*list(map(int, input().split()))) for _ in range(n)] d = 0 for l in permutations(town): for i in range(n - 1): d += abs(l[i] - l[i + 1]) print((d / factorial(n)))
false
30.769231
[ "-import itertools", "+from itertools import permutations", "+from math import factorial", "-point = []", "-for i in range(n):", "- a, b = list(map(float, input().split()))", "- point.append((a, b))", "-ans = 0.0", "-div = 0", "-for pm in itertools.permutations(point):", "- div += 1", ...
false
0.038713
0.184734
0.209561
[ "s099096460", "s834806712" ]
u254871849
p03325
python
s830339629
s696280742
73
65
4,084
4,212
Accepted
Accepted
10.96
# author: kagemeka # created: 2019-11-08 12:38:16(JST) ## internal modules import sys # import collections import math # import string # import bisect # import re # import itertools # import statistics # import functools # import operator ## external module...
# author: kagemeka # created: 2019-11-08 12:38:16(JST) ## internal modules import sys # import collections import math # import string # import bisect # import re # import itertools # import statistics # import functools # import operator ## external module...
37
38
950
971
# author: kagemeka # created: 2019-11-08 12:38:16(JST) ## internal modules import sys # import collections import math # import string # import bisect # import re # import itertools # import statistics # import functools # import operator ## external modules # import s...
# author: kagemeka # created: 2019-11-08 12:38:16(JST) ## internal modules import sys # import collections import math # import string # import bisect # import re # import itertools # import statistics # import functools # import operator ## external modules # import s...
false
2.631579
[ "+ atmost = math.floor(math.log(10**9, 2))", "- for _ in range(math.floor(math.log(10**9, 2)) + 1):", "+ for _ in range(atmost + 1):" ]
false
0.061974
0.061872
1.001652
[ "s830339629", "s696280742" ]
u861141787
p02784
python
s547724131
s847881321
64
41
13,964
13,964
Accepted
Accepted
35.94
#import sys h, n = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): h -= a[i] if h <= 0: print("Yes") exit() #sys.exit(0) print("No")
h, n = list(map(int, input().split())) a = list(map(int, input().split())) if h <= sum(a): print("Yes") else: print("No")
12
7
211
124
# import sys h, n = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): h -= a[i] if h <= 0: print("Yes") exit() # sys.exit(0) print("No")
h, n = list(map(int, input().split())) a = list(map(int, input().split())) if h <= sum(a): print("Yes") else: print("No")
false
41.666667
[ "-# import sys", "-for i in range(n):", "- h -= a[i]", "- if h <= 0:", "- print(\"Yes\")", "- exit()", "- # sys.exit(0)", "-print(\"No\")", "+if h <= sum(a):", "+ print(\"Yes\")", "+else:", "+ print(\"No\")" ]
false
0.03618
0.036894
0.980648
[ "s547724131", "s847881321" ]
u310678820
p03716
python
s423630732
s269665319
551
434
38,148
37,212
Accepted
Accepted
21.23
import heapq n= int(eval(input())) a=[int(i) for i in input().split()] heap1=[] heap2=[] a_max=[] b_max=[] s=0 for i in range(n): heapq.heappush(heap1, a[i]) s+=a[i] a_max.append(s) for i in range(n): heapq.heappush(heap1,a[n+i]) mini=heapq.heappop(heap1) s=s+a[n+i]-mini a_max.ap...
from heapq import heappush, heappop n=int(eval(input())) a=list(map(int, input().split())) q1=[] q2=[] s1=[] s2=[] for i in range(n): heappush(q1, a[i]) s1.append(sum(a[0:n])) for ai in a[n:2*n]: heappush(q1, ai) m=heappop(q1) s1.append(s1[-1]+ai-m) a=a[::-1] for i in range(n): heapp...
32
26
681
547
import heapq n = int(eval(input())) a = [int(i) for i in input().split()] heap1 = [] heap2 = [] a_max = [] b_max = [] s = 0 for i in range(n): heapq.heappush(heap1, a[i]) s += a[i] a_max.append(s) for i in range(n): heapq.heappush(heap1, a[n + i]) mini = heapq.heappop(heap1) s = s + a[n + i] - mini...
from heapq import heappush, heappop n = int(eval(input())) a = list(map(int, input().split())) q1 = [] q2 = [] s1 = [] s2 = [] for i in range(n): heappush(q1, a[i]) s1.append(sum(a[0:n])) for ai in a[n : 2 * n]: heappush(q1, ai) m = heappop(q1) s1.append(s1[-1] + ai - m) a = a[::-1] for i in range(n): ...
false
18.75
[ "-import heapq", "+from heapq import heappush, heappop", "-a = [int(i) for i in input().split()]", "-heap1 = []", "-heap2 = []", "-a_max = []", "-b_max = []", "-s = 0", "+a = list(map(int, input().split()))", "+q1 = []", "+q2 = []", "+s1 = []", "+s2 = []", "- heapq.heappush(heap1, a[i])...
false
0.060146
0.042019
1.431381
[ "s423630732", "s269665319" ]
u941753895
p02787
python
s738720781
s651309571
1,890
836
541,068
303,116
Accepted
Accepted
55.77
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=998244353 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] # def LF(): return [float(x)...
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=998244353 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] # def LF(): return [float(x)...
43
45
997
1,062
import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 998244353 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().spl...
import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 998244353 dd = [(-1, 0), (0, 1), (1, 0), (0, -1)] ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)] def LI(): return [int(x) for x in sys.stdin.readline().spl...
false
4.444444
[ "- p = 20010", "+ p = 10005", "- dp = [[inf] * p for _ in range(n + 1)]", "+ dp = [[inf] * (p + 1) for _ in range(n + 1)]", "- for j in range(p - 5):", "+ for j in range(p):", "+ else:", "+ dp[i + 1][p] = min(dp[i + 1][p], dp[i + 1][j] + b[i])", "-...
false
0.193811
0.379006
0.511366
[ "s738720781", "s651309571" ]
u191874006
p03076
python
s661164406
s628884797
22
17
3,188
3,064
Accepted
Accepted
22.73
#!/usr/bin/env python3 import re a = [] b = [] for i in range(5): x = int(eval(input())) a.append(x) x = x%10 b.append(x) count = 0 min = 123 k = 0 for i in range(5): if(b[i] != 0 and min > b[i]): min = b[i] k = i for i in range(5): if(i != k and b[i] != 0)...
#!/usr/bin/env python3 #ABC123 B LI = [int(eval(input())) for _ in range(5)] LI2 = [LI[i] % 10 for i in range(5)] x = [(LI[i],LI2[i]) for i in range(5)] #print(x) ans = 0 x = sorted(x, key = lambda x:x[1],reverse = True) for i in range(5): if x[i][1] == 0: t = x[i] x.remove(t) ...
25
25
420
490
#!/usr/bin/env python3 import re a = [] b = [] for i in range(5): x = int(eval(input())) a.append(x) x = x % 10 b.append(x) count = 0 min = 123 k = 0 for i in range(5): if b[i] != 0 and min > b[i]: min = b[i] k = i for i in range(5): if i != k and b[i] != 0: count += a[i...
#!/usr/bin/env python3 # ABC123 B LI = [int(eval(input())) for _ in range(5)] LI2 = [LI[i] % 10 for i in range(5)] x = [(LI[i], LI2[i]) for i in range(5)] # print(x) ans = 0 x = sorted(x, key=lambda x: x[1], reverse=True) for i in range(5): if x[i][1] == 0: t = x[i] x.remove(t) x.insert(0, t...
false
0
[ "-import re", "-", "-a = []", "-b = []", "+# ABC123 B", "+LI = [int(eval(input())) for _ in range(5)]", "+LI2 = [LI[i] % 10 for i in range(5)]", "+x = [(LI[i], LI2[i]) for i in range(5)]", "+# print(x)", "+ans = 0", "+x = sorted(x, key=lambda x: x[1], reverse=True)", "- x = int(eval(input()...
false
0.047694
0.2033
0.234597
[ "s661164406", "s628884797" ]
u489124637
p03012
python
s780503461
s611546412
169
18
38,512
3,064
Accepted
Accepted
89.35
N = int(eval(input())) W = list(map(int,input().split())) ans = sum(W) for i in range(1,N): A = sum(W[0:i]) B = sum(W[i:]) ans = min(ans,abs(A-B)) print(ans)
import itertools n = int(eval(input())) w = list(map(int,input().split())) acu = list(itertools.accumulate(w)) acu = [0] + acu #print(acu) ans = float("inf") for i in range(1,n+1): ans = min(ans, abs(acu[i]-(acu[n]-acu[i]))) #print(acu[i],acu[n]-acu[i]) print(ans)
8
12
170
278
N = int(eval(input())) W = list(map(int, input().split())) ans = sum(W) for i in range(1, N): A = sum(W[0:i]) B = sum(W[i:]) ans = min(ans, abs(A - B)) print(ans)
import itertools n = int(eval(input())) w = list(map(int, input().split())) acu = list(itertools.accumulate(w)) acu = [0] + acu # print(acu) ans = float("inf") for i in range(1, n + 1): ans = min(ans, abs(acu[i] - (acu[n] - acu[i]))) # print(acu[i],acu[n]-acu[i]) print(ans)
false
33.333333
[ "-N = int(eval(input()))", "-W = list(map(int, input().split()))", "-ans = sum(W)", "-for i in range(1, N):", "- A = sum(W[0:i])", "- B = sum(W[i:])", "- ans = min(ans, abs(A - B))", "+import itertools", "+", "+n = int(eval(input()))", "+w = list(map(int, input().split()))", "+acu = l...
false
0.039932
0.039709
1.00562
[ "s780503461", "s611546412" ]
u947883560
p02727
python
s459603459
s742917517
562
288
37,216
29,804
Accepted
Accepted
48.75
#!/usr/bin/env python3 import sys import heapq sys.setrecursionlimit(10**8) INF = float("inf") class MaxHeap(object): def __init__(self, x, default=-INF): self.heap = [-e for e in x] self.default = default heapq.heapify(self.heap) def push(self, value): heapq.hea...
#!/usr/bin/env python3 import sys import heapq sys.setrecursionlimit(10**8) INF = float("inf") class MaxHeap(object): def __init__(self, x, default=-INF): self.heap = [-e for e in x] self.default = default heapq.heapify(self.heap) def push(self, value): heapq.hea...
71
54
1,807
1,380
#!/usr/bin/env python3 import sys import heapq sys.setrecursionlimit(10**8) INF = float("inf") class MaxHeap(object): def __init__(self, x, default=-INF): self.heap = [-e for e in x] self.default = default heapq.heapify(self.heap) def push(self, value): heapq.heappush(self.he...
#!/usr/bin/env python3 import sys import heapq sys.setrecursionlimit(10**8) INF = float("inf") class MaxHeap(object): def __init__(self, x, default=-INF): self.heap = [-e for e in x] self.default = default heapq.heapify(self.heap) def push(self, value): heapq.heappush(self.he...
false
23.943662
[ "-def argmax(a):", "- value, n = -(1 << 31), -1", "- for i, v in enumerate(a):", "- if value < v:", "- n, value = i, v", "- return n, value", "-", "-", "- ABC = [MaxHeap(p), MaxHeap(q), MaxHeap(r)]", "- upper = [X, Y]", "- abc = [k.pop() for k in ABC]", "- ...
false
0.08821
0.090375
0.976038
[ "s459603459", "s742917517" ]
u343675824
p03740
python
s150078713
s016201018
20
17
3,060
2,940
Accepted
Accepted
15
X, Y = list(map(int, input().split())) if abs(X-Y) > 1: print('Alice') else: print('Brown')
X, Y = list(map(int, input().split())) if abs(X-Y) <= 1: print('Brown') else: print('Alice')
5
5
97
99
X, Y = list(map(int, input().split())) if abs(X - Y) > 1: print("Alice") else: print("Brown")
X, Y = list(map(int, input().split())) if abs(X - Y) <= 1: print("Brown") else: print("Alice")
false
0
[ "-if abs(X - Y) > 1:", "+if abs(X - Y) <= 1:", "+ print(\"Brown\")", "+else:", "-else:", "- print(\"Brown\")" ]
false
0.073093
0.072316
1.010739
[ "s150078713", "s016201018" ]
u062147869
p03364
python
s160756304
s520945853
1,504
1,376
47,020
44,892
Accepted
Accepted
8.51
N = int(eval(input())) S=[] for i in range(N): s =list(eval(input())) S.append(s) num=0 for a in range(N): t =1 #flag = True for i in range(N): #if not flag: # break for j in range(N): if i==j: continue #x = (i+a)%N ...
N = int(eval(input())) S=[] for i in range(N): s =list(eval(input())) S.append(s) num=0 for a in range(N): t =1 flag = True for i in range(N): if not flag: break for j in range(N): if i==j: continue #x = (i+a)%N ...
25
25
487
482
N = int(eval(input())) S = [] for i in range(N): s = list(eval(input())) S.append(s) num = 0 for a in range(N): t = 1 # flag = True for i in range(N): # if not flag: # break for j in range(N): if i == j: continue # x = (i+a)%N ...
N = int(eval(input())) S = [] for i in range(N): s = list(eval(input())) S.append(s) num = 0 for a in range(N): t = 1 flag = True for i in range(N): if not flag: break for j in range(N): if i == j: continue # x = (i+a)%N ...
false
0
[ "- # flag = True", "+ flag = True", "- # if not flag:", "- # break", "+ if not flag:", "+ break", "- # flag=False", "- # break", "+ flag = False", "+ break" ]
false
0.047242
0.047767
0.989003
[ "s160756304", "s520945853" ]
u970308980
p02780
python
s734664165
s062256987
221
177
25,152
26,368
Accepted
Accepted
19.91
from itertools import accumulate N, K = list(map(int, input().split())) P = list(map(int, input().split())) d = {} for i in range(1, 1001): d[i] = (i + 1) * (i / 2) / i E = [] for p in P: E.append((p+1)/2) cum = list(accumulate(E)) mx = 0 idx = 0 ans = 0 for i in range(N-K+1): if i =...
from itertools import accumulate N, K = list(map(int, input().split())) P = list(map(int, input().split())) E = [(p+1)/2 for p in P] cum = [0] cum.extend(list(accumulate(E))) ans = 0 for i in range(N-K+1): ans = max(ans, cum[i+K] - cum[i]) print(ans)
25
15
421
272
from itertools import accumulate N, K = list(map(int, input().split())) P = list(map(int, input().split())) d = {} for i in range(1, 1001): d[i] = (i + 1) * (i / 2) / i E = [] for p in P: E.append((p + 1) / 2) cum = list(accumulate(E)) mx = 0 idx = 0 ans = 0 for i in range(N - K + 1): if i == 0: mx...
from itertools import accumulate N, K = list(map(int, input().split())) P = list(map(int, input().split())) E = [(p + 1) / 2 for p in P] cum = [0] cum.extend(list(accumulate(E))) ans = 0 for i in range(N - K + 1): ans = max(ans, cum[i + K] - cum[i]) print(ans)
false
40
[ "-d = {}", "-for i in range(1, 1001):", "- d[i] = (i + 1) * (i / 2) / i", "-E = []", "-for p in P:", "- E.append((p + 1) / 2)", "-cum = list(accumulate(E))", "-mx = 0", "-idx = 0", "+E = [(p + 1) / 2 for p in P]", "+cum = [0]", "+cum.extend(list(accumulate(E)))", "- if i == 0:", "...
false
0.049229
0.049155
1.001507
[ "s734664165", "s062256987" ]
u340781749
p03208
python
s374464399
s092711202
251
224
7,384
7,928
Accepted
Accepted
10.76
n, k = list(map(int, input().split())) hhh = [int(eval(input())) for _ in range(n)] hhh.sort() ans = float('inf') for i in range(n - k + 1): ans = min(ans, hhh[i + k - 1] - hhh[i]) print(ans)
from itertools import starmap from operator import sub n, k = list(map(int, input().split())) hhh = sorted(int(eval(input())) for _ in range(n)) print((min(starmap(sub, list(zip(hhh[k - 1:], hhh))))))
7
6
190
187
n, k = list(map(int, input().split())) hhh = [int(eval(input())) for _ in range(n)] hhh.sort() ans = float("inf") for i in range(n - k + 1): ans = min(ans, hhh[i + k - 1] - hhh[i]) print(ans)
from itertools import starmap from operator import sub n, k = list(map(int, input().split())) hhh = sorted(int(eval(input())) for _ in range(n)) print((min(starmap(sub, list(zip(hhh[k - 1 :], hhh))))))
false
14.285714
[ "+from itertools import starmap", "+from operator import sub", "+", "-hhh = [int(eval(input())) for _ in range(n)]", "-hhh.sort()", "-ans = float(\"inf\")", "-for i in range(n - k + 1):", "- ans = min(ans, hhh[i + k - 1] - hhh[i])", "-print(ans)", "+hhh = sorted(int(eval(input())) for _ in rang...
false
0.087321
0.047884
1.823598
[ "s374464399", "s092711202" ]
u653837719
p03546
python
s278610212
s321821054
103
80
74,036
73,916
Accepted
Accepted
22.33
from heapq import heappush, heappop def dijkstra(s): ''' 始点sから各頂点への最短距離を求める ''' d = [float("inf")] * 10 d[s] = 0 used = [False] * 10 used[s] = True edgelist = [] for e in edge[s]: heappush(edgelist, e) while edgelist: cost, v = heappop(edgelis...
def warshall_floyd(): ''' すべての頂点間の最短距離を求める ''' for k in range(10): for i in range(10): for j in range(10): c[i][j] = min(c[i][j], c[i][k] + c[k][j]) h, w = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] a = [list...
50
23
1,048
509
from heapq import heappush, heappop def dijkstra(s): """ 始点sから各頂点への最短距離を求める """ d = [float("inf")] * 10 d[s] = 0 used = [False] * 10 used[s] = True edgelist = [] for e in edge[s]: heappush(edgelist, e) while edgelist: cost, v = heappop(edgelist) if used[...
def warshall_floyd(): """ すべての頂点間の最短距離を求める """ for k in range(10): for i in range(10): for j in range(10): c[i][j] = min(c[i][j], c[i][k] + c[k][j]) h, w = list(map(int, input().split())) c = [list(map(int, input().split())) for _ in range(10)] a = [list(map(int, in...
false
54
[ "-from heapq import heappush, heappop", "-", "-", "-def dijkstra(s):", "+def warshall_floyd():", "- 始点sから各頂点への最短距離を求める", "+ すべての頂点間の最短距離を求める", "- d = [float(\"inf\")] * 10", "- d[s] = 0", "- used = [False] * 10", "- used[s] = True", "- edgelist = []", "- for e in edge...
false
0.040814
0.145365
0.280769
[ "s278610212", "s321821054" ]
u156815136
p03775
python
s595112851
s841629844
60
51
10,484
10,432
Accepted
Accepted
15
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counte...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdi...
41
75
989
1,805
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate # (string,3) 3回 # from collections import deque from collections import deque, defaultdict, Co...
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations, permutations, accumulate, product # (string,3) 3回 # from collections import deque from collections import deque, defaul...
false
45.333333
[ "-from itertools import combinations, permutations, accumulate # (string,3) 3回", "+from itertools import combinations, permutations, accumulate, product # (string,3) 3回", "+import math", "-# 四捨五入", "+# 四捨五入g", "+import sys", "+", "+sys.setrecursionlimit(10000000)", "+# mod = 10**9 + 7", "+# mod ...
false
0.057195
0.052337
1.092818
[ "s595112851", "s841629844" ]
u509278866
p01753
python
s425449030
s940752386
60
20
9,112
5,720
Accepted
Accepted
66.67
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 dd = [(0,-1),(1,0),(0,1),(-1,0)] ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)] def LI(): return [int(x) for x in...
eps = 1.0 / 10**10 def LI(): return [int(x) for x in input().split()] def main(): n,q = LI() na = [LI() for _ in range(n)] qa = [LI() for _ in range(q)] rr = [] def k(a,b): return sum([(a[i]-b[i]) ** 2 for i in range(3)]) ** 0.5 def f(a,b,c,r): ab = k(a,b) ...
54
35
1,446
770
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 dd = [(0, -1), (1, 0), (0, 1), (-1, 0)] ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)] def LI...
eps = 1.0 / 10**10 def LI(): return [int(x) for x in input().split()] def main(): n, q = LI() na = [LI() for _ in range(n)] qa = [LI() for _ in range(q)] rr = [] def k(a, b): return sum([(a[i] - b[i]) ** 2 for i in range(3)]) ** 0.5 def f(a, b, c, r): ab = k(a, b) ...
false
35.185185
[ "-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools", "-", "-sys.setrecursionlimit(10**7)", "-inf = 10**20", "-mod = 998244353", "-dd = [(0, -1), (1, 0), (0, 1), (-1, 0)]", "-ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1...
false
0.043533
0.10028
0.434115
[ "s425449030", "s940752386" ]
u079022693
p02883
python
s536158112
s383829381
541
418
119,500
37,184
Accepted
Accepted
22.74
def main(): N,K=list(map(int,input().split())) A=list(map(int,input().split())) F=list(map(int,input().split())) A.sort(reverse=True) F.sort() l_score=-1 r_score=10**12 while l_score<r_score-1: t_score=(l_score+r_score)//2 count=0 for i in range(N): ...
from sys import stdin import numpy as np def main(): #入力 readline=stdin.readline n,k=list(map(int,readline().split())) A=np.array(list(map(int,readline().split())),dtype=np.int64) A=np.sort(A)[::-1] F=np.array(list(map(int,readline().split())),dtype=np.int64) F=np.sort(F) l=-...
21
24
511
533
def main(): N, K = list(map(int, input().split())) A = list(map(int, input().split())) F = list(map(int, input().split())) A.sort(reverse=True) F.sort() l_score = -1 r_score = 10**12 while l_score < r_score - 1: t_score = (l_score + r_score) // 2 count = 0 for i i...
from sys import stdin import numpy as np def main(): # 入力 readline = stdin.readline n, k = list(map(int, readline().split())) A = np.array(list(map(int, readline().split())), dtype=np.int64) A = np.sort(A)[::-1] F = np.array(list(map(int, readline().split())), dtype=np.int64) F = np.sort(F...
false
12.5
[ "+from sys import stdin", "+import numpy as np", "+", "+", "- N, K = list(map(int, input().split()))", "- A = list(map(int, input().split()))", "- F = list(map(int, input().split()))", "- A.sort(reverse=True)", "- F.sort()", "- l_score = -1", "- r_score = 10**12", "- wh...
false
0.138358
0.189628
0.72963
[ "s536158112", "s383829381" ]
u807772568
p03479
python
s755654801
s722686086
173
17
38,384
2,940
Accepted
Accepted
90.17
a = list(map(int,input().split())) k = a[1] i = 2 l = a[0] while True: l *= 2 if k < l: break i += 1 print((i-1))
a,b = list(map(int,input().split())) k = 0 while a <= b: k += 1 a *= 2 print(k)
11
8
133
86
a = list(map(int, input().split())) k = a[1] i = 2 l = a[0] while True: l *= 2 if k < l: break i += 1 print((i - 1))
a, b = list(map(int, input().split())) k = 0 while a <= b: k += 1 a *= 2 print(k)
false
27.272727
[ "-a = list(map(int, input().split()))", "-k = a[1]", "-i = 2", "-l = a[0]", "-while True:", "- l *= 2", "- if k < l:", "- break", "- i += 1", "-print((i - 1))", "+a, b = list(map(int, input().split()))", "+k = 0", "+while a <= b:", "+ k += 1", "+ a *= 2", "+print(...
false
0.038212
0.037187
1.027561
[ "s755654801", "s722686086" ]
u078349616
p02743
python
s117062010
s199613454
38
17
5,076
2,940
Accepted
Accepted
55.26
from decimal import * A, B, C = list(map(int,input().split())) a = Decimal(A) b = Decimal(B) c = Decimal(C) if a.sqrt() + b.sqrt() < c.sqrt(): print("Yes") else: print("No")
a, b, c = list(map(int, input().split())) if 4*a*b < pow(c-a-b, 2) and c-a-b > 0: print("Yes") else: print("No")
9
5
179
114
from decimal import * A, B, C = list(map(int, input().split())) a = Decimal(A) b = Decimal(B) c = Decimal(C) if a.sqrt() + b.sqrt() < c.sqrt(): print("Yes") else: print("No")
a, b, c = list(map(int, input().split())) if 4 * a * b < pow(c - a - b, 2) and c - a - b > 0: print("Yes") else: print("No")
false
44.444444
[ "-from decimal import *", "-", "-A, B, C = list(map(int, input().split()))", "-a = Decimal(A)", "-b = Decimal(B)", "-c = Decimal(C)", "-if a.sqrt() + b.sqrt() < c.sqrt():", "+a, b, c = list(map(int, input().split()))", "+if 4 * a * b < pow(c - a - b, 2) and c - a - b > 0:" ]
false
0.046726
0.128174
0.36455
[ "s117062010", "s199613454" ]
u477319617
p02658
python
s917807500
s151170946
66
61
21,648
21,632
Accepted
Accepted
7.58
n = int(eval(input())) a = list(map(int,input().split())) ans = 1 if 0 in a: ans = 0 else: a.sort(reverse=True) for i in a: if(i==0): ans = 0;break if ans>(10**18): ans = -1;break ans = ans*i print((-1 if ans>(10**18) else ans))
n = int(eval(input())) a = list(map(int,input().split())) ans = 1 if 0 in a: ans = 0 # print(a) else: a.sort(reverse=True) for i in a: ans = ans*i if ans>(10**18): ans = -1;break print(ans)
14
13
293
239
n = int(eval(input())) a = list(map(int, input().split())) ans = 1 if 0 in a: ans = 0 else: a.sort(reverse=True) for i in a: if i == 0: ans = 0 break if ans > (10**18): ans = -1 break ans = ans * i print((-1 if ans > (10**18) else ans))...
n = int(eval(input())) a = list(map(int, input().split())) ans = 1 if 0 in a: ans = 0 # print(a) else: a.sort(reverse=True) for i in a: ans = ans * i if ans > (10**18): ans = -1 break print(ans)
false
7.142857
[ "+ # print(a)", "- if i == 0:", "- ans = 0", "- break", "+ ans = ans * i", "- ans = ans * i", "-print((-1 if ans > (10**18) else ans))", "+print(ans)" ]
false
0.040583
0.039601
1.024786
[ "s917807500", "s151170946" ]
u506287026
p02953
python
s566264987
s758296162
85
63
14,252
14,396
Accepted
Accepted
25.88
N = int(eval(input())) Hs = [int(i) for i in input().split()] is_Yes = True for i in range(1, N): if Hs[i-1] == Hs[i]: continue elif Hs[i] > Hs[i-1]: Hs[i] -= 1 else: is_Yes = False break if is_Yes: print('Yes') else: print('No')
n = int(eval(input())) nums = [int(num) for num in input().split()] def solve(nums): nums[0] -= 1 for i in range(1, n): if nums[i] > nums[i-1]: nums[i] -= 1 continue if nums[i] < nums[i-1]: return 'No' return 'Yes' print((solve(nums)))
17
16
294
311
N = int(eval(input())) Hs = [int(i) for i in input().split()] is_Yes = True for i in range(1, N): if Hs[i - 1] == Hs[i]: continue elif Hs[i] > Hs[i - 1]: Hs[i] -= 1 else: is_Yes = False break if is_Yes: print("Yes") else: print("No")
n = int(eval(input())) nums = [int(num) for num in input().split()] def solve(nums): nums[0] -= 1 for i in range(1, n): if nums[i] > nums[i - 1]: nums[i] -= 1 continue if nums[i] < nums[i - 1]: return "No" return "Yes" print((solve(nums)))
false
5.882353
[ "-N = int(eval(input()))", "-Hs = [int(i) for i in input().split()]", "-is_Yes = True", "-for i in range(1, N):", "- if Hs[i - 1] == Hs[i]:", "- continue", "- elif Hs[i] > Hs[i - 1]:", "- Hs[i] -= 1", "- else:", "- is_Yes = False", "- break", "-if is_Yes:",...
false
0.143848
0.151404
0.950092
[ "s566264987", "s758296162" ]
u761320129
p03503
python
s182117606
s071299111
287
258
3,064
3,064
Accepted
Accepted
10.1
N = int(eval(input())) fs = [list(map(int,input().split())) for i in range(N)] ps = [list(map(int,input().split())) for i in range(N)] INF = float('inf') ans = -INF for b in range(1,2**10): tmp = 0 for f,p in zip(fs,ps): c = 0 for k in range(10): if b&(1<<k)==0: continue ...
N = int(eval(input())) F = [list(map(int,input().split())) for i in range(N)] P = [list(map(int,input().split())) for i in range(N)] ans = -float('inf') for k in range(1,1<<10): tmp = 0 for fs,ps in zip(F,P): cnt = 0 for b in range(10): if (k>>b)&1 and fs[b]: ...
16
15
400
387
N = int(eval(input())) fs = [list(map(int, input().split())) for i in range(N)] ps = [list(map(int, input().split())) for i in range(N)] INF = float("inf") ans = -INF for b in range(1, 2**10): tmp = 0 for f, p in zip(fs, ps): c = 0 for k in range(10): if b & (1 << k) == 0: ...
N = int(eval(input())) F = [list(map(int, input().split())) for i in range(N)] P = [list(map(int, input().split())) for i in range(N)] ans = -float("inf") for k in range(1, 1 << 10): tmp = 0 for fs, ps in zip(F, P): cnt = 0 for b in range(10): if (k >> b) & 1 and fs[b]: ...
false
6.25
[ "-fs = [list(map(int, input().split())) for i in range(N)]", "-ps = [list(map(int, input().split())) for i in range(N)]", "-INF = float(\"inf\")", "-ans = -INF", "-for b in range(1, 2**10):", "+F = [list(map(int, input().split())) for i in range(N)]", "+P = [list(map(int, input().split())) for i in rang...
false
0.067258
0.097557
0.689427
[ "s182117606", "s071299111" ]
u391875425
p03252
python
s365354252
s578696023
99
41
3,632
3,888
Accepted
Accepted
58.59
S, T = eval(input()), eval(input()) cnt1, cnt2, r1, r2 =[], [], [], [] for c in S: if not c in r1: cnt1.append(S.count(c)) r1.append(c) for c in T: if not c in r2: cnt2.append(T.count(c)) r2.append(c) #cnt1.sort() #cnt2.sort() if cnt1 == cnt2: print('Yes') else:...
from collections import Counter if sorted(Counter(eval(input())).values()) == sorted(Counter(eval(input())).values()): print('Yes') else: print('No')
16
5
325
149
S, T = eval(input()), eval(input()) cnt1, cnt2, r1, r2 = [], [], [], [] for c in S: if not c in r1: cnt1.append(S.count(c)) r1.append(c) for c in T: if not c in r2: cnt2.append(T.count(c)) r2.append(c) # cnt1.sort() # cnt2.sort() if cnt1 == cnt2: print("Yes") else: print(...
from collections import Counter if sorted(Counter(eval(input())).values()) == sorted(Counter(eval(input())).values()): print("Yes") else: print("No")
false
68.75
[ "-S, T = eval(input()), eval(input())", "-cnt1, cnt2, r1, r2 = [], [], [], []", "-for c in S:", "- if not c in r1:", "- cnt1.append(S.count(c))", "- r1.append(c)", "-for c in T:", "- if not c in r2:", "- cnt2.append(T.count(c))", "- r2.append(c)", "-# cnt1.sort(...
false
0.032133
0.039282
0.818011
[ "s365354252", "s578696023" ]
u969708690
p02603
python
s076013909
s186109846
36
33
9,188
9,152
Accepted
Accepted
8.33
import sys k=1000 N=int(eval(input())) L=list(map(int,input().split())) i=0 while i<N-1: if L[i]<L[i+1]: n=L[i] break i+=1 if i==N-1: print((1000)) sys.exit() n=0 for j in range(i,N): if j==N-1 and n!=0: m=max(L[s:]) c=k%n k=((k//n)*m)+c n=0 break if j=...
n = int(eval(input())) a = list(map(int, input().split())) money = 1000 kabu = 0 for i in range(n-1): if a[i] < a[i+1] and money != 0: kabu += money // a[i] money -= a[i] *(money // a[i]) elif a[i] > a[i+1] and kabu != 0: money += a[i] * kabu kabu = 0 print((money + a[...
32
12
476
324
import sys k = 1000 N = int(eval(input())) L = list(map(int, input().split())) i = 0 while i < N - 1: if L[i] < L[i + 1]: n = L[i] break i += 1 if i == N - 1: print((1000)) sys.exit() n = 0 for j in range(i, N): if j == N - 1 and n != 0: m = max(L[s:]) c ...
n = int(eval(input())) a = list(map(int, input().split())) money = 1000 kabu = 0 for i in range(n - 1): if a[i] < a[i + 1] and money != 0: kabu += money // a[i] money -= a[i] * (money // a[i]) elif a[i] > a[i + 1] and kabu != 0: money += a[i] * kabu kabu = 0 print((money + a[-1] ...
false
62.5
[ "-import sys", "-", "-k = 1000", "-N = int(eval(input()))", "-L = list(map(int, input().split()))", "-i = 0", "-while i < N - 1:", "- if L[i] < L[i + 1]:", "- n = L[i]", "- break", "- i += 1", "- if i == N - 1:", "- print((1000))", "- sys.exit()", "-n...
false
0.033583
0.033914
0.990235
[ "s076013909", "s186109846" ]
u971124021
p02757
python
s232994744
s858043336
171
148
3,560
3,500
Accepted
Accepted
13.45
n,p = list(map(int,input().split())) S = eval(input()) if p == 2 or p == 5: ans = 0 for i,s in enumerate(S): if int(s)%p == 0: ans += i+1 print(ans) exit() def MS(i,s,pre): return (int(s)*i+pre)%p M = [0]*p M[0] = 1 i = 1 pre = 0 for s in S[::-1]: #pre = MS(i,int(s),pre) ...
n,p = list(map(int,input().split())) S = eval(input()) if p == 2 or p == 5: ans = 0 for i,s in enumerate(S): if int(s)%p == 0: ans += i+1 print(ans) exit() def MS(i,s,pre): return (int(s)*i+pre)%p M = [0]*p M[0] = 1 i = 1 pre = 0 for s in S[::-1]: #pre = MS(i,int(s),pre) ...
28
28
429
437
n, p = list(map(int, input().split())) S = eval(input()) if p == 2 or p == 5: ans = 0 for i, s in enumerate(S): if int(s) % p == 0: ans += i + 1 print(ans) exit() def MS(i, s, pre): return (int(s) * i + pre) % p M = [0] * p M[0] = 1 i = 1 pre = 0 for s in S[::-1]: # pre =...
n, p = list(map(int, input().split())) S = eval(input()) if p == 2 or p == 5: ans = 0 for i, s in enumerate(S): if int(s) % p == 0: ans += i + 1 print(ans) exit() def MS(i, s, pre): return (int(s) * i + pre) % p M = [0] * p M[0] = 1 i = 1 pre = 0 for s in S[::-1]: # pre =...
false
0
[ "- pre += int(s) * i", "- pre %= p", "+ pre = pre + int(s) * i", "+ pre = pre % p" ]
false
0.103036
0.046891
2.197353
[ "s232994744", "s858043336" ]
u678167152
p03111
python
s035925987
s947960643
282
148
76,388
76,196
Accepted
Accepted
47.52
from itertools import groupby, accumulate, product, permutations, combinations def calc(x,X): n = len(x) ans = 10**10 for q in product([0,1],repeat=n): point = 0 cnt = 0 for i in range(n): if q[i]==1: if cnt>0: point += 10 cnt += x[i] if cnt>0: po...
from itertools import groupby, accumulate, product, permutations, combinations def calc(x,X): n = len(x) if n==0: return 10**10 ans = abs(sum(x)-X)+(n-1)*10 return ans def solve(): ans = 10**10 N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for _ in range(N)] for p...
37
26
867
642
from itertools import groupby, accumulate, product, permutations, combinations def calc(x, X): n = len(x) ans = 10**10 for q in product([0, 1], repeat=n): point = 0 cnt = 0 for i in range(n): if q[i] == 1: if cnt > 0: point += 10 ...
from itertools import groupby, accumulate, product, permutations, combinations def calc(x, X): n = len(x) if n == 0: return 10**10 ans = abs(sum(x) - X) + (n - 1) * 10 return ans def solve(): ans = 10**10 N, A, B, C = list(map(int, input().split())) L = [int(eval(input())) for _ ...
false
29.72973
[ "- ans = 10**10", "- for q in product([0, 1], repeat=n):", "- point = 0", "- cnt = 0", "- for i in range(n):", "- if q[i] == 1:", "- if cnt > 0:", "- point += 10", "- cnt += x[i]", "- if cnt > 0:", "- ...
false
1.954242
0.170059
11.491582
[ "s035925987", "s947960643" ]
u562935282
p03680
python
s541713701
s362392151
206
78
13,448
11,048
Accepted
Accepted
62.14
n = int(eval(input())) a = list(map(int, list(eval(input()) for _ in range(n)))) visited = list(False for _ in range(n)) if (2 in a) == False: print((-1)) exit() idx = 1 cnt = 0 while True: cnt += 1 if a[idx - 1] == 2: print(cnt) exit() else: if visited[...
def main(): import sys input = sys.stdin.readline N = int(eval(input())) a = [int(eval(input())) - 1 for _ in range(N)] cur = 0 cnt = [-1] * N cnt[0] = 0 while cur != 1: c = cnt[cur] cur = a[cur] if ~cnt[cur]: break cnt[cur] = c + 1 ...
22
22
456
387
n = int(eval(input())) a = list(map(int, list(eval(input()) for _ in range(n)))) visited = list(False for _ in range(n)) if (2 in a) == False: print((-1)) exit() idx = 1 cnt = 0 while True: cnt += 1 if a[idx - 1] == 2: print(cnt) exit() else: if visited[idx - 1] == True: ...
def main(): import sys input = sys.stdin.readline N = int(eval(input())) a = [int(eval(input())) - 1 for _ in range(N)] cur = 0 cnt = [-1] * N cnt[0] = 0 while cur != 1: c = cnt[cur] cur = a[cur] if ~cnt[cur]: break cnt[cur] = c + 1 print(...
false
0
[ "-n = int(eval(input()))", "-a = list(map(int, list(eval(input()) for _ in range(n))))", "-visited = list(False for _ in range(n))", "-if (2 in a) == False:", "- print((-1))", "- exit()", "-idx = 1", "-cnt = 0", "-while True:", "- cnt += 1", "- if a[idx - 1] == 2:", "- print...
false
0.091379
0.035881
2.546764
[ "s541713701", "s362392151" ]
u931462344
p03680
python
s238525758
s490100007
216
192
7,208
7,084
Accepted
Accepted
11.11
import sys n = int(eval(input())) a = [] for i in range(n): a.append(int(eval(input()))) cnt = 0 t = 1 for i in a: t = a[t-1] cnt += 1 if t == 2: print(cnt) sys.exit() print("-1")
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] cnt = 0 tmp = 1 for i in A: tmp = A[tmp-1] cnt += 1 if tmp == 2: print(cnt) exit() print("-1")
16
11
217
187
import sys n = int(eval(input())) a = [] for i in range(n): a.append(int(eval(input()))) cnt = 0 t = 1 for i in a: t = a[t - 1] cnt += 1 if t == 2: print(cnt) sys.exit() print("-1")
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] cnt = 0 tmp = 1 for i in A: tmp = A[tmp - 1] cnt += 1 if tmp == 2: print(cnt) exit() print("-1")
false
31.25
[ "-import sys", "-", "-n = int(eval(input()))", "-a = []", "-for i in range(n):", "- a.append(int(eval(input())))", "+N = int(eval(input()))", "+A = [int(eval(input())) for _ in range(N)]", "-t = 1", "-for i in a:", "- t = a[t - 1]", "+tmp = 1", "+for i in A:", "+ tmp = A[tmp - 1]"...
false
0.041143
0.043845
0.938363
[ "s238525758", "s490100007" ]
u547492399
p02258
python
s729406019
s031258016
510
450
15,324
17,204
Accepted
Accepted
11.76
debug = False if debug:import time if debug:start = time.time() n = int(eval(input())) R = [0]*n R_min = 10**9 for i in range(n): R[i] = int(eval(input())) maximum_profit = -10**9 for i in range(1, n): R_min = R[i-1] if R[i-1] < R_min else R_min profit = R[i] - R_min maximum_profit =...
debug = False if debug:import time if debug:start = time.time() n = int(eval(input())) R = [0]*n R_min = 10**9 R = [int(eval(input())) for i in range(n)] maximum_profit = -10**9 for i in range(1, n): R_min = R[i-1] if R[i-1] < R_min else R_min profit = R[i] - R_min maximum_profit = profit...
20
19
424
417
debug = False if debug: import time if debug: start = time.time() n = int(eval(input())) R = [0] * n R_min = 10**9 for i in range(n): R[i] = int(eval(input())) maximum_profit = -(10**9) for i in range(1, n): R_min = R[i - 1] if R[i - 1] < R_min else R_min profit = R[i] - R_min maximum_profit = p...
debug = False if debug: import time if debug: start = time.time() n = int(eval(input())) R = [0] * n R_min = 10**9 R = [int(eval(input())) for i in range(n)] maximum_profit = -(10**9) for i in range(1, n): R_min = R[i - 1] if R[i - 1] < R_min else R_min profit = R[i] - R_min maximum_profit = profit ...
false
5
[ "-for i in range(n):", "- R[i] = int(eval(input()))", "+R = [int(eval(input())) for i in range(n)]" ]
false
0.038097
0.043405
0.877713
[ "s729406019", "s031258016" ]
u145231176
p02554
python
s348237348
s977152349
804
187
83,580
83,784
Accepted
Accepted
76.74
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
54
90
1,459
2,291
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
def getN(): return int(eval(input())) def getNM(): return list(map(int, input().split())) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(eval(input())) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): ...
false
40
[ "-# 全て - 存在しない(1 ~ 8)まででできる", "-print(((pow(10, N, mod) - pow(9, N, mod) - pow(9, N, mod) + pow(8, N, mod)) % mod))", "+logk = N.bit_length()", "+# 一般項が出ない場合でも", "+# 漸化式にできるなら行列計算に落とし込める", "+dp = [[[0, 0, 0, 0] for i in range(4)] for i in range(logk)]", "+dp[0] = [[8, 1, 1, 0], [0, 9, 0, 1], [0, 0, 9, 1...
false
0.126342
0.11813
1.069519
[ "s348237348", "s977152349" ]
u496280557
p03543
python
s008114586
s853610813
26
24
8,876
9,088
Accepted
Accepted
7.69
N = eval(input('')) if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]: print('Yes') else: print('No')
N = eval(input()) if N[0] == N[1] == N[2] or N[1] == N[2] == N[3] : print('Yes') else: print('No')
5
6
105
107
N = eval(input("")) if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]: print("Yes") else: print("No")
N = eval(input()) if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]: print("Yes") else: print("No")
false
16.666667
[ "-N = eval(input(\"\"))", "+N = eval(input())" ]
false
0.079677
0.04252
1.87389
[ "s008114586", "s853610813" ]
u588341295
p02720
python
s115393655
s285575030
247
25
7,488
3,316
Accepted
Accepted
89.88
# -*- coding: utf-8 -*- import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in rang...
# -*- coding: utf-8 -*- import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in rang...
42
65
1,071
1,834
# -*- coding: utf-8 -*- import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d...
# -*- coding: utf-8 -*- import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d...
false
35.384615
[ "-MAX = 3234566667", "-ans = []", "-def rec(x):", "- if int(x) > MAX:", "- return", "- ans.append(int(x))", "- last = int(x[-1])", "- rec(x + str(last))", "- if last != 0:", "- rec(x + str(last - 1))", "- if last != 9:", "- rec(x + str(last + 1))", "- ...
false
0.954833
0.051413
18.571895
[ "s115393655", "s285575030" ]
u930705402
p03111
python
s718905300
s373560759
388
108
3,444
3,064
Accepted
Accepted
72.16
import itertools n,a,b,c=list(map(int,input().split())) x=[a,b,c] l=[int(eval(input())) for i in range(n)] ans=1000000 loop='012' for i in range(2**n): use=[] for j in range(n): if((i>>j)&1): use.append(l[j]) if(len(use)>=3): for j in (itertools.product(loop,repeat=le...
def check(s,e,t): global ans if(not s or not e or not t): return ans=min(ans,(len(s)-1)*10+abs(A-sum(s))+(len(e)-1)*10+abs(B-sum(e))+(len(t)-1)*10+abs(C-sum(t))) def dfs(s,e,t,i): if(i==N): check(s,e,t) return dfs(s,e,t,i+1) dfs(s+[l[i]],e,t,i+1) dfs(s,e+...
23
21
690
475
import itertools n, a, b, c = list(map(int, input().split())) x = [a, b, c] l = [int(eval(input())) for i in range(n)] ans = 1000000 loop = "012" for i in range(2**n): use = [] for j in range(n): if (i >> j) & 1: use.append(l[j]) if len(use) >= 3: for j in itertools.product(loop...
def check(s, e, t): global ans if not s or not e or not t: return ans = min( ans, (len(s) - 1) * 10 + abs(A - sum(s)) + (len(e) - 1) * 10 + abs(B - sum(e)) + (len(t) - 1) * 10 + abs(C - sum(t)), ) def dfs(s, e, t, i): if i == N: ...
false
8.695652
[ "-import itertools", "+def check(s, e, t):", "+ global ans", "+ if not s or not e or not t:", "+ return", "+ ans = min(", "+ ans,", "+ (len(s) - 1) * 10", "+ + abs(A - sum(s))", "+ + (len(e) - 1) * 10", "+ + abs(B - sum(e))", "+ + (len(...
false
0.922315
0.081886
11.26336
[ "s718905300", "s373560759" ]
u606045429
p02651
python
s033446897
s163759280
165
150
9,084
9,148
Accepted
Accepted
9.09
T = int(eval(input())) for _ in range(T): N = int(eval(input())) A = [int(i) for i in input().split()] S = eval(input()) B = [] ans = 0 for a, s in zip(reversed(A), reversed(S)): for b in B: a = min(a, a ^ b) if a: if s == "1": ...
T = int(eval(input())) for _ in range(T): N = int(eval(input())) A = [int(i) for i in input().split()] S = eval(input()) B = [] ans = 0 for a, s in zip(reversed(A), reversed(S)): for b in B: a = min(a, a ^ b) if a: if s == "1": ...
20
19
402
379
T = int(eval(input())) for _ in range(T): N = int(eval(input())) A = [int(i) for i in input().split()] S = eval(input()) B = [] ans = 0 for a, s in zip(reversed(A), reversed(S)): for b in B: a = min(a, a ^ b) if a: if s == "1": ans = 1 ...
T = int(eval(input())) for _ in range(T): N = int(eval(input())) A = [int(i) for i in input().split()] S = eval(input()) B = [] ans = 0 for a, s in zip(reversed(A), reversed(S)): for b in B: a = min(a, a ^ b) if a: if s == "1": ans = 1 ...
false
5
[ "- else:", "- B.append(a)", "+ B.append(a)" ]
false
0.131939
0.049257
2.678614
[ "s033446897", "s163759280" ]
u144913062
p02549
python
s921688059
s828784256
318
100
70,096
69,688
Accepted
Accepted
68.55
import sys input = sys.stdin.readline class FenwickTree: def __init__(self, size): self.bit = [0] * (size + 1) self.size = size def sum(self, i): i += 1 s = 0 while i > 0: s += self.bit[i] s %= mod i -= i & -i r...
import sys input = sys.stdin.readline mod = 998244353 N, K = list(map(int, input().split())) L, R = list(zip(*[list(map(int, input().split())) for _ in range(K)])) dp = [0] * (N + 1) dp[1] = 1 dp[2] = -1 x = 0 for i in range(1, N): x = (x + dp[i]) % mod for j in range(K): if i + L[j] > N: ...
37
20
844
503
import sys input = sys.stdin.readline class FenwickTree: def __init__(self, size): self.bit = [0] * (size + 1) self.size = size def sum(self, i): i += 1 s = 0 while i > 0: s += self.bit[i] s %= mod i -= i & -i return s ...
import sys input = sys.stdin.readline mod = 998244353 N, K = list(map(int, input().split())) L, R = list(zip(*[list(map(int, input().split())) for _ in range(K)])) dp = [0] * (N + 1) dp[1] = 1 dp[2] = -1 x = 0 for i in range(1, N): x = (x + dp[i]) % mod for j in range(K): if i + L[j] > N: c...
false
45.945946
[ "-", "-", "-class FenwickTree:", "- def __init__(self, size):", "- self.bit = [0] * (size + 1)", "- self.size = size", "-", "- def sum(self, i):", "- i += 1", "- s = 0", "- while i > 0:", "- s += self.bit[i]", "- s %= mod", "- ...
false
0.037064
0.036526
1.014734
[ "s921688059", "s828784256" ]
u926412290
p03645
python
s967688652
s227516165
503
419
112,736
108,776
Accepted
Accepted
16.7
from collections import deque N, M = list(map(int, input().split())) to = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 to[a].append(b) to[b].append(a) que = deque() que.append(0) dist = [-1] * N dist[0] = 0 while que: ...
N, M = list(map(int, input().split())) to = [[] for _ in range(N)] ans = 'IMPOSSIBLE' for _ in range(M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 to[a].append(b) to[b].append(a) for nxt in to[0]: if N - 1 in to[nxt]: ans = 'POSSIBLE' break ...
25
16
539
322
from collections import deque N, M = list(map(int, input().split())) to = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 to[a].append(b) to[b].append(a) que = deque() que.append(0) dist = [-1] * N dist[0] = 0 while que: island = que.popleft() ...
N, M = list(map(int, input().split())) to = [[] for _ in range(N)] ans = "IMPOSSIBLE" for _ in range(M): a, b = list(map(int, input().split())) a, b = a - 1, b - 1 to[a].append(b) to[b].append(a) for nxt in to[0]: if N - 1 in to[nxt]: ans = "POSSIBLE" break print(ans)
false
36
[ "-from collections import deque", "-", "+ans = \"IMPOSSIBLE\"", "-que = deque()", "-que.append(0)", "-dist = [-1] * N", "-dist[0] = 0", "-while que:", "- island = que.popleft()", "- for nxt in to[island]:", "- if dist[nxt] != -1:", "- continue", "- que.append(n...
false
0.038123
0.102899
0.370493
[ "s967688652", "s227516165" ]
u078042885
p00062
python
s364460417
s272220179
30
20
7,656
7,648
Accepted
Accepted
33.33
while 1: try:n=eval(input()) except:break n=list(map(int,n)) while len(n)>1: n= [(i+j)%10 for i,j in zip(n[:-1],n[1:])] print((*n))
while 1: try:n=eval(input()) except:break while len(n)>1: n= [(int(i)+int(j))%10 for i,j in zip(n[:-1],n[1:])] print((*n))
7
6
157
143
while 1: try: n = eval(input()) except: break n = list(map(int, n)) while len(n) > 1: n = [(i + j) % 10 for i, j in zip(n[:-1], n[1:])] print((*n))
while 1: try: n = eval(input()) except: break while len(n) > 1: n = [(int(i) + int(j)) % 10 for i, j in zip(n[:-1], n[1:])] print((*n))
false
14.285714
[ "- n = list(map(int, n))", "- n = [(i + j) % 10 for i, j in zip(n[:-1], n[1:])]", "+ n = [(int(i) + int(j)) % 10 for i, j in zip(n[:-1], n[1:])]" ]
false
0.033879
0.06453
0.525013
[ "s364460417", "s272220179" ]
u077291787
p03274
python
s822710845
s390637067
91
60
14,352
14,768
Accepted
Accepted
34.07
# ABC107C - Candles (ARC101C) def main(): n, k = tuple(map(int, input().rstrip().split())) x = tuple(map(int, input().rstrip().split())) ans = float("inf") for i in range(n - k + 1): a, b = x[i], x[i + k - 1] if a < b < 0 or 0 < a < b: ans = min(ans, max(abs(a), abs(b...
# ABC107C - Candles (ARC101C) def main(): _, k = list(map(int, input().split())) x = tuple(map(int, input().split())) print((min(r - l + min(abs(l), abs(r)) for l, r in zip(x, x[k - 1 :])))) if __name__ == "__main__": main()
16
9
473
242
# ABC107C - Candles (ARC101C) def main(): n, k = tuple(map(int, input().rstrip().split())) x = tuple(map(int, input().rstrip().split())) ans = float("inf") for i in range(n - k + 1): a, b = x[i], x[i + k - 1] if a < b < 0 or 0 < a < b: ans = min(ans, max(abs(a), abs(b))) ...
# ABC107C - Candles (ARC101C) def main(): _, k = list(map(int, input().split())) x = tuple(map(int, input().split())) print((min(r - l + min(abs(l), abs(r)) for l, r in zip(x, x[k - 1 :])))) if __name__ == "__main__": main()
false
43.75
[ "- n, k = tuple(map(int, input().rstrip().split()))", "- x = tuple(map(int, input().rstrip().split()))", "- ans = float(\"inf\")", "- for i in range(n - k + 1):", "- a, b = x[i], x[i + k - 1]", "- if a < b < 0 or 0 < a < b:", "- ans = min(ans, max(abs(a), abs(b)))", ...
false
0.044
0.081053
0.542855
[ "s822710845", "s390637067" ]
u966207392
p02607
python
s913803643
s571390000
31
26
9,052
9,080
Accepted
Accepted
16.13
N = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in range(0, N): if (i+1) % 2 != 0 and a[i] % 2 != 0: cnt += 1 print(cnt)
N = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in range(0, N, 2): if a[i] % 2 != 0: cnt += 1 print(cnt)
7
7
157
141
N = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in range(0, N): if (i + 1) % 2 != 0 and a[i] % 2 != 0: cnt += 1 print(cnt)
N = int(eval(input())) a = list(map(int, input().split())) cnt = 0 for i in range(0, N, 2): if a[i] % 2 != 0: cnt += 1 print(cnt)
false
0
[ "-for i in range(0, N):", "- if (i + 1) % 2 != 0 and a[i] % 2 != 0:", "+for i in range(0, N, 2):", "+ if a[i] % 2 != 0:" ]
false
0.040138
0.040586
0.988954
[ "s913803643", "s571390000" ]
u380524497
p03416
python
s399224869
s975883981
63
44
2,940
2,940
Accepted
Accepted
30.16
a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): if str(i) == str(i)[::-1]: count += 1 print(count)
a, b = list(map(int, input().split())) ans = 0 for num in range(a, b+1): s = str(num) if s[0] == s[4] and s[1] == s[3]: ans += 1 print(ans)
8
9
139
159
a, b = list(map(int, input().split())) count = 0 for i in range(a, b + 1): if str(i) == str(i)[::-1]: count += 1 print(count)
a, b = list(map(int, input().split())) ans = 0 for num in range(a, b + 1): s = str(num) if s[0] == s[4] and s[1] == s[3]: ans += 1 print(ans)
false
11.111111
[ "-count = 0", "-for i in range(a, b + 1):", "- if str(i) == str(i)[::-1]:", "- count += 1", "-print(count)", "+ans = 0", "+for num in range(a, b + 1):", "+ s = str(num)", "+ if s[0] == s[4] and s[1] == s[3]:", "+ ans += 1", "+print(ans)" ]
false
0.060407
0.053112
1.137349
[ "s399224869", "s975883981" ]
u347600233
p02952
python
s426081507
s290266892
58
52
2,940
9,100
Accepted
Accepted
10.34
n = int(eval(input())) cnt = 0 for i in range(1, n + 1): if len(str(i)) % 2: cnt += 1 print(cnt)
n = int(eval(input())) print((sum(len(str(i + 1)) % 2 for i in range(n))))
6
2
107
67
n = int(eval(input())) cnt = 0 for i in range(1, n + 1): if len(str(i)) % 2: cnt += 1 print(cnt)
n = int(eval(input())) print((sum(len(str(i + 1)) % 2 for i in range(n))))
false
66.666667
[ "-cnt = 0", "-for i in range(1, n + 1):", "- if len(str(i)) % 2:", "- cnt += 1", "-print(cnt)", "+print((sum(len(str(i + 1)) % 2 for i in range(n))))" ]
false
0.053585
0.04474
1.19771
[ "s426081507", "s290266892" ]
u133936772
p03013
python
s951059349
s323963688
1,668
187
7,080
3,828
Accepted
Accepted
88.79
mod = 10**9+7 n, m = list(map(int, input().split())) l = [int(eval(input())) for _ in range(m)] t2 = 0 t1 = 1 for i in range(1,n+1): if l == [] or i != l[0]: t0 = (t2+t1)%mod else: l.pop(0) t0 = 0 t2 = t1 t1 = t0 print(t0)
mod = 10**9+7 n, m = list(map(int, input().split())) l = [0]*n for _ in range(m): l[int(eval(input()))-1] = 1 s = 0 t = 1 for i in range(n): if l[i] > 0: t, s = 0, t else: t, s = (s+t)%mod, t print(t)
17
16
249
220
mod = 10**9 + 7 n, m = list(map(int, input().split())) l = [int(eval(input())) for _ in range(m)] t2 = 0 t1 = 1 for i in range(1, n + 1): if l == [] or i != l[0]: t0 = (t2 + t1) % mod else: l.pop(0) t0 = 0 t2 = t1 t1 = t0 print(t0)
mod = 10**9 + 7 n, m = list(map(int, input().split())) l = [0] * n for _ in range(m): l[int(eval(input())) - 1] = 1 s = 0 t = 1 for i in range(n): if l[i] > 0: t, s = 0, t else: t, s = (s + t) % mod, t print(t)
false
5.882353
[ "-l = [int(eval(input())) for _ in range(m)]", "-t2 = 0", "-t1 = 1", "-for i in range(1, n + 1):", "- if l == [] or i != l[0]:", "- t0 = (t2 + t1) % mod", "+l = [0] * n", "+for _ in range(m):", "+ l[int(eval(input())) - 1] = 1", "+s = 0", "+t = 1", "+for i in range(n):", "+ i...
false
0.03659
0.03503
1.044525
[ "s951059349", "s323963688" ]
u975771310
p02725
python
s310849709
s526981491
107
97
26,444
25,836
Accepted
Accepted
9.35
def main(): K, N = list(map(int, input().split())) A = list(map( int, input().split() )) dist = [] for i in range(N): if i!=N-1: dist.append(A[i+1]-A[i]) else: dist.append(K-A[i]+A[0]) ...
def main(): K, N = list(map(int, input().split())) A = list(map( int, input().split() )) dist = [] for i in range(N-1): dist.append(A[i+1]-A[i]) dist.append(K-A[N-1]+A[0]) ans = sum(dist) - max(dist) print(("{}".format(ans))) if ...
19
16
420
349
def main(): K, N = list(map(int, input().split())) A = list(map(int, input().split())) dist = [] for i in range(N): if i != N - 1: dist.append(A[i + 1] - A[i]) else: dist.append(K - A[i] + A[0]) ans = sum(dist) - max(dist) print(("{}".format(ans))) if __...
def main(): K, N = list(map(int, input().split())) A = list(map(int, input().split())) dist = [] for i in range(N - 1): dist.append(A[i + 1] - A[i]) dist.append(K - A[N - 1] + A[0]) ans = sum(dist) - max(dist) print(("{}".format(ans))) if __name__ == "__main__": main()
false
15.789474
[ "- for i in range(N):", "- if i != N - 1:", "- dist.append(A[i + 1] - A[i])", "- else:", "- dist.append(K - A[i] + A[0])", "+ for i in range(N - 1):", "+ dist.append(A[i + 1] - A[i])", "+ dist.append(K - A[N - 1] + A[0])" ]
false
0.048021
0.047904
1.002422
[ "s310849709", "s526981491" ]
u628335443
p02695
python
s603621567
s212292742
1,102
664
9,212
9,236
Accepted
Accepted
39.75
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) a = [0] * q b = [0] * q c = [0] * q d = [0] * q ans = 0 for i in range(q): a[i], b[i], c[i], d[i] = list(map(int, input().split())) for seq in combinations_with_replacement([i for i in range(1, m+1)], n): ...
def dfs(A): global ans if len(A) == n + 1: now = 0 for j in range(q): if A[b[j]] - A[a[j]] == c[j]: now += d[j] ans = max(ans, now) return B = list(A) B.append(A[-1]) while B[-1] <= m: dfs(tuple(B)) B[-1] += 1...
20
30
458
534
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) a = [0] * q b = [0] * q c = [0] * q d = [0] * q ans = 0 for i in range(q): a[i], b[i], c[i], d[i] = list(map(int, input().split())) for seq in combinations_with_replacement([i for i in range(1, m + 1)], n): now = 0 ...
def dfs(A): global ans if len(A) == n + 1: now = 0 for j in range(q): if A[b[j]] - A[a[j]] == c[j]: now += d[j] ans = max(ans, now) return B = list(A) B.append(A[-1]) while B[-1] <= m: dfs(tuple(B)) B[-1] += 1 n, m, q = li...
false
33.333333
[ "-from itertools import combinations_with_replacement", "+def dfs(A):", "+ global ans", "+ if len(A) == n + 1:", "+ now = 0", "+ for j in range(q):", "+ if A[b[j]] - A[a[j]] == c[j]:", "+ now += d[j]", "+ ans = max(ans, now)", "+ return",...
false
0.149795
0.073064
2.050189
[ "s603621567", "s212292742" ]
u968166680
p02814
python
s586346696
s882443062
404
113
96,824
16,148
Accepted
Accepted
72.03
import sys from fractions import gcd from functools import reduce read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def lcm(x, y): return x * y // gcd(x, y) def main(): N, M, *A = list(map(int, read().split())) ...
import sys from fractions import gcd read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def lcm(x, y): return x * y // gcd(x, y) def main(): N, M, *A = list(map(int, read().split())) A = [a // 2 for a in A] ...
32
31
622
582
import sys from fractions import gcd from functools import reduce read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def lcm(x, y): return x * y // gcd(x, y) def main(): N, M, *A = list(map(int, read().split())) A = [a // 2 for...
import sys from fractions import gcd read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def lcm(x, y): return x * y // gcd(x, y) def main(): N, M, *A = list(map(int, read().split())) A = [a // 2 for a in A] semi_lcm = A[0] ...
false
3.125
[ "-from functools import reduce", "- semi_lcm = reduce(lcm, A)", "+ semi_lcm = A[0]" ]
false
0.074044
0.0457
1.620237
[ "s586346696", "s882443062" ]
u836939578
p03043
python
s561227633
s162175282
352
66
153,000
72,088
Accepted
Accepted
81.25
import sys input = lambda: sys.stdin.readline().rstrip() from decimal import * N, K = list(map(int, input().split())) x = Decimal("0.5") ans = 0 for i in range(1, N+1): p = 1 while i < K: i *= 2 p *= x ans += p ans /= N print(ans)
N, K = list(map(int, input().split())) ans = 0 def calc(x, goal): res = 0 while x < goal: x *= 2 res += 1 return res for i in range(1, N+1): cnt = calc(i, K) ans += 1 / N * ((1 / 2) ** cnt) print(ans)
16
17
272
255
import sys input = lambda: sys.stdin.readline().rstrip() from decimal import * N, K = list(map(int, input().split())) x = Decimal("0.5") ans = 0 for i in range(1, N + 1): p = 1 while i < K: i *= 2 p *= x ans += p ans /= N print(ans)
N, K = list(map(int, input().split())) ans = 0 def calc(x, goal): res = 0 while x < goal: x *= 2 res += 1 return res for i in range(1, N + 1): cnt = calc(i, K) ans += 1 / N * ((1 / 2) ** cnt) print(ans)
false
5.882353
[ "-import sys", "+N, K = list(map(int, input().split()))", "+ans = 0", "-input = lambda: sys.stdin.readline().rstrip()", "-from decimal import *", "-N, K = list(map(int, input().split()))", "-x = Decimal(\"0.5\")", "-ans = 0", "+def calc(x, goal):", "+ res = 0", "+ while x < goal:", "+ ...
false
0.058049
0.057547
1.008724
[ "s561227633", "s162175282" ]
u133936772
p02630
python
s943160420
s142773143
531
479
21,640
18,536
Accepted
Accepted
9.79
f=lambda:[*list(map(int,input().split()))] f() s,*l=[0]*100002 for i in f(): s+=i; l[i]+=1 q=f()[0] for _ in range(q): b,c=f(); s+=(c-b)*l[b]; l[c]+=l[b]; l[b]=0; print(s)
f=lambda:list(map(int,input().split())) f() s,*l=[0]*100002 for i in f(): s+=i; l[i]+=1 q,=f() for _ in range(q): b,c=f(); s+=(c-b)*l[b]; l[c]+=l[b]; l[b]=0; print(s)
6
6
170
165
f = lambda: [*list(map(int, input().split()))] f() s, *l = [0] * 100002 for i in f(): s += i l[i] += 1 q = f()[0] for _ in range(q): b, c = f() s += (c - b) * l[b] l[c] += l[b] l[b] = 0 print(s)
f = lambda: list(map(int, input().split())) f() s, *l = [0] * 100002 for i in f(): s += i l[i] += 1 (q,) = f() for _ in range(q): b, c = f() s += (c - b) * l[b] l[c] += l[b] l[b] = 0 print(s)
false
0
[ "-f = lambda: [*list(map(int, input().split()))]", "+f = lambda: list(map(int, input().split()))", "-q = f()[0]", "+(q,) = f()" ]
false
0.091857
0.085098
1.079423
[ "s943160420", "s142773143" ]
u102461423
p02609
python
s680336079
s975869111
1,213
1,039
137,820
138,228
Accepted
Accepted
14.34
import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) X = np.array(list(read().rstrip()), np.int64) - ord('0') @njit((i8, ), cache=True) def popcount...
import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8, ), cache=True) def popcount(n): ret = 0 while n: ret += n & 1 n >>= 1 retur...
65
64
1,393
1,392
import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) X = np.array(list(read().rstrip()), np.int64) - ord("0") @njit((i8,), cache=True) def popcount(n): ret = ...
import sys import numpy as np import numba from numba import njit i8 = numba.int64 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8,), cache=True) def popcount(n): ret = 0 while n: ret += n & 1 n >>= 1 return ret @njit((i...
false
1.538462
[ "-N = int(readline())", "-X = np.array(list(read().rstrip()), np.int64) - ord(\"0\")", "+N = int(readline())", "+X = np.array(list(read().rstrip()), np.int64) - ord(\"0\")" ]
false
0.31625
0.173881
1.818768
[ "s680336079", "s975869111" ]
u794173881
p03165
python
s996091657
s723278533
450
315
113,372
144,424
Accepted
Accepted
30
s = eval(input()) t = eval(input()) dp = [[0]*(len(t)+1) for i in range(len(s)+1)] for i in range(len(s)): for j in range(len(t)): if s[i] == t[j]: dp[i+1][j+1] = max(dp[i][j] + 1, dp[i+1][j], dp[i][j+1]) else: dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]) ans = [...
def lcs(str1, str2): """文字列str1, str2の最長共通部分列(Longest Common Subsequence, LCS)を求める。 計算量 O(|str1||str2|) """ dp = [[0] * (len(str2) + 1) for _ in range(len(str1) + 1)] for i in range(len(str1)): for j in range(len(str2)): if str1[i] == str2[j]: dp[i + 1][j ...
28
31
626
789
s = eval(input()) t = eval(input()) dp = [[0] * (len(t) + 1) for i in range(len(s) + 1)] for i in range(len(s)): for j in range(len(t)): if s[i] == t[j]: dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1]) else: dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]) ...
def lcs(str1, str2): """文字列str1, str2の最長共通部分列(Longest Common Subsequence, LCS)を求める。 計算量 O(|str1||str2|) """ dp = [[0] * (len(str2) + 1) for _ in range(len(str1) + 1)] for i in range(len(str1)): for j in range(len(str2)): if str1[i] == str2[j]: dp[i + 1][j + 1] = d...
false
9.677419
[ "+def lcs(str1, str2):", "+ \"\"\"文字列str1, str2の最長共通部分列(Longest Common Subsequence, LCS)を求める。", "+ 計算量 O(|str1||str2|)", "+ \"\"\"", "+ dp = [[0] * (len(str2) + 1) for _ in range(len(str1) + 1)]", "+ for i in range(len(str1)):", "+ for j in range(len(str2)):", "+ if st...
false
0.040702
0.041546
0.979663
[ "s996091657", "s723278533" ]
u597374218
p02819
python
s663649923
s614263696
29
17
2,940
3,060
Accepted
Accepted
41.38
X=int(eval(input())) while True: for x in range(2,X): if X%x==0: break else: print(X) break X+=1
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
146
158
X = int(eval(input())) while True: for x in range(2, X): if X % x == 0: break else: print(X) break X += 1
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
[ "-while True:", "- for x in range(2, X):", "- if X % x == 0:", "+for x in range(X, 2 * X):", "+ for i in range(2, int(x**0.5) + 1):", "+ if x % i == 0:", "- print(X)", "+ print(x)", "- X += 1" ]
false
0.060823
0.044257
1.374314
[ "s663649923", "s614263696" ]
u384935968
p03826
python
s845733377
s899538999
30
24
9,152
9,044
Accepted
Accepted
20
a,b,c,d = list(map(int,input().split())) ans = a*b, c*d print((max(ans)))
A,B,C,D = list(map(int,input().split())) if A * B > C * D: print((A * B)) elif A * B < C * D: print((C * D)) else: print((A * B))
5
8
71
137
a, b, c, d = list(map(int, input().split())) ans = a * b, c * d print((max(ans)))
A, B, C, D = list(map(int, input().split())) if A * B > C * D: print((A * B)) elif A * B < C * D: print((C * D)) else: print((A * B))
false
37.5
[ "-a, b, c, d = list(map(int, input().split()))", "-ans = a * b, c * d", "-print((max(ans)))", "+A, B, C, D = list(map(int, input().split()))", "+if A * B > C * D:", "+ print((A * B))", "+elif A * B < C * D:", "+ print((C * D))", "+else:", "+ print((A * B))" ]
false
0.041791
0.10163
0.411204
[ "s845733377", "s899538999" ]
u112247039
p02783
python
s285355209
s538376535
21
17
3,316
2,940
Accepted
Accepted
19.05
a, b = list(map(int,input().strip().split())) print((a//b+1 if a%b else a//b))
a, b = list(map(int,input().split())) if a%b: print((a//b+1)) else: print((a//b))
2
5
77
84
a, b = list(map(int, input().strip().split())) print((a // b + 1 if a % b else a // b))
a, b = list(map(int, input().split())) if a % b: print((a // b + 1)) else: print((a // b))
false
60
[ "-a, b = list(map(int, input().strip().split()))", "-print((a // b + 1 if a % b else a // b))", "+a, b = list(map(int, input().split()))", "+if a % b:", "+ print((a // b + 1))", "+else:", "+ print((a // b))" ]
false
0.045069
0.04577
0.984665
[ "s285355209", "s538376535" ]
u853619096
p02418
python
s207808848
s710800688
30
20
7,460
7,472
Accepted
Accepted
33.33
s = eval(input()) p = eval(input()) if p in (s * 2): print("Yes") else: print("No")
z=eval(input())*2 x=eval(input()) a=z.count(x) if a>=1: print("Yes") else: print('No')
7
8
88
90
s = eval(input()) p = eval(input()) if p in (s * 2): print("Yes") else: print("No")
z = eval(input()) * 2 x = eval(input()) a = z.count(x) if a >= 1: print("Yes") else: print("No")
false
12.5
[ "-s = eval(input())", "-p = eval(input())", "-if p in (s * 2):", "+z = eval(input()) * 2", "+x = eval(input())", "+a = z.count(x)", "+if a >= 1:" ]
false
0.007337
0.086097
0.085219
[ "s207808848", "s710800688" ]
u668503853
p03095
python
s601438640
s707703590
28
22
3,820
3,188
Accepted
Accepted
21.43
import collections from functools import reduce N=int(eval(input())) S=eval(input()) c=collections.Counter(S) d=[x+1 for x in list(c.values())] print(((reduce(lambda x,y:x*y,d)-1)%1000000007))
N=int(eval(input())) S=eval(input()) C=set(S) m=1 for c in C: m*=S.count(c)+1 print(((m-1)%(10**9+7)))
7
7
187
96
import collections from functools import reduce N = int(eval(input())) S = eval(input()) c = collections.Counter(S) d = [x + 1 for x in list(c.values())] print(((reduce(lambda x, y: x * y, d) - 1) % 1000000007))
N = int(eval(input())) S = eval(input()) C = set(S) m = 1 for c in C: m *= S.count(c) + 1 print(((m - 1) % (10**9 + 7)))
false
0
[ "-import collections", "-from functools import reduce", "-", "-c = collections.Counter(S)", "-d = [x + 1 for x in list(c.values())]", "-print(((reduce(lambda x, y: x * y, d) - 1) % 1000000007))", "+C = set(S)", "+m = 1", "+for c in C:", "+ m *= S.count(c) + 1", "+print(((m - 1) % (10**9 + 7))...
false
0.047903
0.039691
1.206891
[ "s601438640", "s707703590" ]
u477977638
p02947
python
s381154637
s206959555
564
438
38,780
18,148
Accepted
Accepted
22.34
from operator import itemgetter n=int(eval(input())) s=[] li=[] ans=0 cnt=1 for i in range(n): s.append(sorted(eval(input()))) s.sort(key=itemgetter(9,8,7,6,5,4,3,2,1,0)) s=s+[''] for i in range(n): if s[i]==s[i+1]: cnt+=1 elif cnt>1: li.append(int(cnt*(cnt-1)/2)) cnt=1 else: ...
from collections import defaultdict n=int(eval(input())) dct=defaultdict(int) for i in range(n): s=eval(input()) sort_s="".join(sorted(s)) dct[sort_s]+=1 ans=0 for k,v in list(dct.items()): ans+= v*(v-1)//2 print(ans)
22
13
338
221
from operator import itemgetter n = int(eval(input())) s = [] li = [] ans = 0 cnt = 1 for i in range(n): s.append(sorted(eval(input()))) s.sort(key=itemgetter(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) s = s + [""] for i in range(n): if s[i] == s[i + 1]: cnt += 1 elif cnt > 1: li.append(int(cnt * (cnt ...
from collections import defaultdict n = int(eval(input())) dct = defaultdict(int) for i in range(n): s = eval(input()) sort_s = "".join(sorted(s)) dct[sort_s] += 1 ans = 0 for k, v in list(dct.items()): ans += v * (v - 1) // 2 print(ans)
false
40.909091
[ "-from operator import itemgetter", "+from collections import defaultdict", "-s = []", "-li = []", "+dct = defaultdict(int)", "+for i in range(n):", "+ s = eval(input())", "+ sort_s = \"\".join(sorted(s))", "+ dct[sort_s] += 1", "-cnt = 1", "-for i in range(n):", "- s.append(sorted...
false
0.036981
0.073628
0.502269
[ "s381154637", "s206959555" ]
u661977789
p02848
python
s739539107
s158836494
201
29
40,540
4,468
Accepted
Accepted
85.57
N = int(eval(input())) S = eval(input()) alphabet = 'ZABCDEFGHIJKLMNOPQRSTUVWXY' alphabet_num = {st: num for num, st in enumerate(alphabet)} alphabet_list = [st for st in alphabet] output = '' for s in S: num = (alphabet_num[s] + N) % 26 output += alphabet_list[num] print(output)
N = int(input()) S = input() alphabet = 'ZABCDEFGHIJKLMNOPQRSTUVWXY' alphabet_num = {st: num for num, st in enumerate(alphabet)} alphabet_list = [st for st in alphabet] for s in S: num = (alphabet_num[s] + N) % 26 print(alphabet_list[num], end='')
11
9
283
260
N = int(eval(input())) S = eval(input()) alphabet = "ZABCDEFGHIJKLMNOPQRSTUVWXY" alphabet_num = {st: num for num, st in enumerate(alphabet)} alphabet_list = [st for st in alphabet] output = "" for s in S: num = (alphabet_num[s] + N) % 26 output += alphabet_list[num] print(output)
N = int(input()) S = input() alphabet = "ZABCDEFGHIJKLMNOPQRSTUVWXY" alphabet_num = {st: num for num, st in enumerate(alphabet)} alphabet_list = [st for st in alphabet] for s in S: num = (alphabet_num[s] + N) % 26 print(alphabet_list[num], end="")
false
18.181818
[ "-N = int(eval(input()))", "-S = eval(input())", "+N = int(input())", "+S = input()", "-output = \"\"", "- output += alphabet_list[num]", "-print(output)", "+ print(alphabet_list[num], end=\"\")" ]
false
0.037348
0.037492
0.996151
[ "s739539107", "s158836494" ]
u887207211
p03290
python
s704742321
s234474797
22
18
3,064
3,064
Accepted
Accepted
18.18
D, G = list(map(int,input().split())) PC = [list(map(int,input().split())) for _ in range(D)] ans = 1e9 for i in range(1 << D): point = 0 cnt = 0 for j in range(D): if(((i >> j) & 1) == 1): point += PC[j][0]*(j+1)*100 + PC[j][1] cnt += PC[j][0] else: tmp = j if(point < G)...
D, G = list(map(int,input().split())) PC = [0]+[list(map(int,input().split())) for _ in range(D)] def dfs(d, g): if(d == 0): return 1e9 x = min(g//(100*d), PC[d][0]) point = x*100*d if(x == PC[d][0]): point += PC[d][1] if(point < g): x += dfs(d-1, g-point) return min(x, ...
20
18
459
344
D, G = list(map(int, input().split())) PC = [list(map(int, input().split())) for _ in range(D)] ans = 1e9 for i in range(1 << D): point = 0 cnt = 0 for j in range(D): if ((i >> j) & 1) == 1: point += PC[j][0] * (j + 1) * 100 + PC[j][1] cnt += PC[j][0] else: ...
D, G = list(map(int, input().split())) PC = [0] + [list(map(int, input().split())) for _ in range(D)] def dfs(d, g): if d == 0: return 1e9 x = min(g // (100 * d), PC[d][0]) point = x * 100 * d if x == PC[d][0]: point += PC[d][1] if point < g: x += dfs(d - 1, g - point) ...
false
10
[ "-PC = [list(map(int, input().split())) for _ in range(D)]", "-ans = 1e9", "-for i in range(1 << D):", "- point = 0", "- cnt = 0", "- for j in range(D):", "- if ((i >> j) & 1) == 1:", "- point += PC[j][0] * (j + 1) * 100 + PC[j][1]", "- cnt += PC[j][0]", "- ...
false
0.034813
0.03648
0.954308
[ "s704742321", "s234474797" ]
u188827677
p02695
python
s845910465
s345221427
1,049
923
21,548
9,128
Accepted
Accepted
12.01
from itertools import combinations_with_replacement n,m,q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for _ in range(q)] num = list(combinations_with_replacement(list(range(1,m+1)), n)) ans = 0 for i in num: t = 0 for j in abcd: if i[j[1]-1] - i[j[0]-1] == j[2]: ...
from itertools import combinations_with_replacement n,m,q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for _ in range(q)] ans = 0 for i in combinations_with_replacement(list(range(1,m+1)),n): t = 0 for j in abcd: if i[j[1]-1] - i[j[0]-1] == j[2]: t += j[3] ans = m...
15
12
354
330
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for _ in range(q)] num = list(combinations_with_replacement(list(range(1, m + 1)), n)) ans = 0 for i in num: t = 0 for j in abcd: if i[j[1] - 1] - i[j[0] - 1] == j[2]: ...
from itertools import combinations_with_replacement n, m, q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for _ in range(q)] ans = 0 for i in combinations_with_replacement(list(range(1, m + 1)), n): t = 0 for j in abcd: if i[j[1] - 1] - i[j[0] - 1] == j[2]: t += ...
false
20
[ "-num = list(combinations_with_replacement(list(range(1, m + 1)), n))", "-for i in num:", "+for i in combinations_with_replacement(list(range(1, m + 1)), n):" ]
false
0.052902
0.047732
1.108301
[ "s845910465", "s345221427" ]
u627600101
p02536
python
s029106978
s206514710
279
246
48,428
27,316
Accepted
Accepted
11.83
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def dfs(c...
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def bfs(c...
29
34
531
635
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def d...
import sys sys.setrecursionlimit(10**9) input = sys.stdin.buffer.readline N, M = list(map(int, input().split())) nextcity = [[] for _ in range(N)] sgn = [0 for _ in range(N)] while M: M -= 1 A, B = list(map(int, input().split())) A -= 1 B -= 1 nextcity[A].append(B) nextcity[B].append(A) def b...
false
14.705882
[ "-def dfs(cnt, city):", "- for item in nextcity[city]:", "- if sgn[item] == 0:", "- sgn[item] = cnt", "- dfs(cnt, item)", "- return None", "+def bfs(cnt, lis):", "+ nextvisit = []", "+ for j in lis:", "+ for item in nextcity[j]:", "+ if ...
false
0.03619
0.041559
0.870819
[ "s029106978", "s206514710" ]
u729133443
p03563
python
s975039362
s162659011
166
18
38,384
2,940
Accepted
Accepted
89.16
r,g=int(eval(input())),int(eval(input())) print((g+g-r))
print((eval(eval(input())+'*-1+2*'+eval(input()))))
2
1
43
37
r, g = int(eval(input())), int(eval(input())) print((g + g - r))
print((eval(eval(input()) + "*-1+2*" + eval(input()))))
false
50
[ "-r, g = int(eval(input())), int(eval(input()))", "-print((g + g - r))", "+print((eval(eval(input()) + \"*-1+2*\" + eval(input()))))" ]
false
0.076769
0.033696
2.278275
[ "s975039362", "s162659011" ]
u298297089
p03212
python
s762592924
s475647119
40
36
3,060
3,060
Accepted
Accepted
10
# https://atcoder.jp/contests/abc114/submissions/6262572 from itertools import product N = int(eval(input())) ans = 0 for i in range(3,10): for s in product(["3","5","7"],repeat=i): if int("".join(s)) <= N and "3" in s and "5" in s and "7" in s: ans += 1 print(ans)
def dfs(start, n, len_n): queue = [start] cnt = 0 while queue: parent = queue.pop() for c in '357': cc = parent+c if int(cc) <= n and '3' in cc and '5' in cc and '7' in cc: cnt += 1 if len(cc) < len_n: queue.app...
10
18
294
413
# https://atcoder.jp/contests/abc114/submissions/6262572 from itertools import product N = int(eval(input())) ans = 0 for i in range(3, 10): for s in product(["3", "5", "7"], repeat=i): if int("".join(s)) <= N and "3" in s and "5" in s and "7" in s: ans += 1 print(ans)
def dfs(start, n, len_n): queue = [start] cnt = 0 while queue: parent = queue.pop() for c in "357": cc = parent + c if int(cc) <= n and "3" in cc and "5" in cc and "7" in cc: cnt += 1 if len(cc) < len_n: queue.append(cc) ...
false
44.444444
[ "-# https://atcoder.jp/contests/abc114/submissions/6262572", "-from itertools import product", "+def dfs(start, n, len_n):", "+ queue = [start]", "+ cnt = 0", "+ while queue:", "+ parent = queue.pop()", "+ for c in \"357\":", "+ cc = parent + c", "+ if ...
false
0.058473
0.040726
1.435779
[ "s762592924", "s475647119" ]
u512212329
p02608
python
s702381469
s731162033
159
142
9,292
9,272
Accepted
Accepted
10.69
""" (x+y+z)^2 = (x^2+y^2+z^2) + 2(xy+yz+zx) """ def func(x, y, z): return (x + y + z) ** 2 - x * y - y * z - z * x def main(): num = int(eval(input())) counter = [0] * (num + 1) # func(41, 41, 41) = 10086 # func(99, 1, 1) = 10002 for x in range(1, 100): for y in range(1, 100): ...
def main(): num = int(eval(input())) counter = [0] * (num + 1) # func(41, 41, 41) = 10086 # func(99, 1, 1) = 10002 for x in range(1, 100): for y in range(1, 100): for z in range(1, 123 - x - y + 1): tmp = (x + y + z) ** 2 - x * y - y * z - z * x ...
22
17
550
472
""" (x+y+z)^2 = (x^2+y^2+z^2) + 2(xy+yz+zx) """ def func(x, y, z): return (x + y + z) ** 2 - x * y - y * z - z * x def main(): num = int(eval(input())) counter = [0] * (num + 1) # func(41, 41, 41) = 10086 # func(99, 1, 1) = 10002 for x in range(1, 100): for y in range(1, 100): ...
def main(): num = int(eval(input())) counter = [0] * (num + 1) # func(41, 41, 41) = 10086 # func(99, 1, 1) = 10002 for x in range(1, 100): for y in range(1, 100): for z in range(1, 123 - x - y + 1): tmp = (x + y + z) ** 2 - x * y - y * z - z * x if...
false
22.727273
[ "-\"\"\"", "-(x+y+z)^2 = (x^2+y^2+z^2) + 2(xy+yz+zx)", "-\"\"\"", "-", "-", "-def func(x, y, z):", "- return (x + y + z) ** 2 - x * y - y * z - z * x", "-", "-", "- if (tmp := func(x, y, z)) <= num:", "+ tmp = (x + y + z) ** 2 - x * y - y * z - z * x", "+ ...
false
0.263039
0.229975
1.14377
[ "s702381469", "s731162033" ]
u597374218
p02952
python
s350706070
s070375994
49
45
2,940
2,940
Accepted
Accepted
8.16
N=int(eval(input())) print((sum(len(str(i))%2==1 for i in range(1,N+1))))
N=int(eval(input())) print((sum(len(str(i))%2 for i in range(1,N+1))))
2
2
66
63
N = int(eval(input())) print((sum(len(str(i)) % 2 == 1 for i in range(1, N + 1))))
N = int(eval(input())) print((sum(len(str(i)) % 2 for i in range(1, N + 1))))
false
0
[ "-print((sum(len(str(i)) % 2 == 1 for i in range(1, N + 1))))", "+print((sum(len(str(i)) % 2 for i in range(1, N + 1))))" ]
false
0.047544
0.054353
0.874723
[ "s350706070", "s070375994" ]
u786020649
p03634
python
s382638611
s403295241
792
609
83,456
83,260
Accepted
Accepted
23.11
from collections import defaultdict,deque n=int(eval(input())) edges=[tuple(map(int,input().split())) for _ in range(n-1)] q,k=list(map(int,input().split())) xy=[tuple(map(int,input().split())) for _ in range(q)] stack=[-1]*(n+1) stack[k]=0 ed=defaultdict(list) wt=defaultdict(int) for e in edges: ed[e[0]]...
from collections import defaultdict,deque import sys finput=lambda: sys.stdin.readline().strip() def main(): n=int(finput()) edges=[tuple(map(int,finput().split())) for _ in range(n-1)] q,k=list(map(int,finput().split())) xy=[tuple(map(int,finput().split())) for _ in range(q)] stack=[-1]*(n+1)...
31
39
704
883
from collections import defaultdict, deque n = int(eval(input())) edges = [tuple(map(int, input().split())) for _ in range(n - 1)] q, k = list(map(int, input().split())) xy = [tuple(map(int, input().split())) for _ in range(q)] stack = [-1] * (n + 1) stack[k] = 0 ed = defaultdict(list) wt = defaultdict(int) for e in e...
from collections import defaultdict, deque import sys finput = lambda: sys.stdin.readline().strip() def main(): n = int(finput()) edges = [tuple(map(int, finput().split())) for _ in range(n - 1)] q, k = list(map(int, finput().split())) xy = [tuple(map(int, finput().split())) for _ in range(q)] st...
false
20.512821
[ "+import sys", "-n = int(eval(input()))", "-edges = [tuple(map(int, input().split())) for _ in range(n - 1)]", "-q, k = list(map(int, input().split()))", "-xy = [tuple(map(int, input().split())) for _ in range(q)]", "-stack = [-1] * (n + 1)", "-stack[k] = 0", "-ed = defaultdict(list)", "-wt = defaul...
false
0.044085
0.04227
1.042935
[ "s382638611", "s403295241" ]
u729133443
p02555
python
s017979379
s039277419
170
66
9,764
29,052
Accepted
Accepted
61.18
from functools import* M=10**9+7 @lru_cache(None) def f(s): if s<3:return 0 return(sum(map(f,list(range(s-2))))+1)%M print((f(int(eval(input())))))
a,b,c=1,0,0 exec('a,b,c=b,c,(a+c)%(10**9+7);'*(int(eval(input()))-2)) print(c)
7
3
147
74
from functools import * M = 10**9 + 7 @lru_cache(None) def f(s): if s < 3: return 0 return (sum(map(f, list(range(s - 2)))) + 1) % M print((f(int(eval(input())))))
a, b, c = 1, 0, 0 exec("a,b,c=b,c,(a+c)%(10**9+7);" * (int(eval(input())) - 2)) print(c)
false
57.142857
[ "-from functools import *", "-", "-M = 10**9 + 7", "-", "-", "-@lru_cache(None)", "-def f(s):", "- if s < 3:", "- return 0", "- return (sum(map(f, list(range(s - 2)))) + 1) % M", "-", "-", "-print((f(int(eval(input())))))", "+a, b, c = 1, 0, 0", "+exec(\"a,b,c=b,c,(a+c)%(10*...
false
0.04995
0.049647
1.006094
[ "s017979379", "s039277419" ]
u759412327
p02984
python
s373703522
s522001812
121
96
20,500
20,700
Accepted
Accepted
20.66
N = int(eval(input())) A = list(map(int,input().split())) B = N*[0] for n in range(N): if n%2==0: B[0]+=A[n] else: B[0]-=A[n] for n in range(N): if n==0: pass elif 1<=n<=N-1: B[n] = 2*A[n-1]-B[n-1] else: B[n] = 2*A[n]-B[0] print((*B))
N = int(eval(input())) A = list(map(int,input().split())) B = [2*sum(A[::2])-sum(A)] for n in range(N-1): B+=[2*A[n]-B[n]] print((*B))
19
8
277
137
N = int(eval(input())) A = list(map(int, input().split())) B = N * [0] for n in range(N): if n % 2 == 0: B[0] += A[n] else: B[0] -= A[n] for n in range(N): if n == 0: pass elif 1 <= n <= N - 1: B[n] = 2 * A[n - 1] - B[n - 1] else: B[n] = 2 * A[n] - B[0] print(...
N = int(eval(input())) A = list(map(int, input().split())) B = [2 * sum(A[::2]) - sum(A)] for n in range(N - 1): B += [2 * A[n] - B[n]] print((*B))
false
57.894737
[ "-B = N * [0]", "-for n in range(N):", "- if n % 2 == 0:", "- B[0] += A[n]", "- else:", "- B[0] -= A[n]", "-for n in range(N):", "- if n == 0:", "- pass", "- elif 1 <= n <= N - 1:", "- B[n] = 2 * A[n - 1] - B[n - 1]", "- else:", "- B[n] = 2 *...
false
0.035348
0.036657
0.964305
[ "s373703522", "s522001812" ]
u291628833
p03160
python
s753422109
s939376135
228
96
52,208
84,744
Accepted
Accepted
57.89
n = int(eval(input())) h_L = list(map(int,input().split())) #dp = [float("inf")] * (10**4 + 1) dp = [10**9] * n dp[0] = 0 dp[1] = abs(h_L[0]-h_L[1]) for i in range(2,n): #dp[i] # 1 tmp1 = dp[i-1] + abs(h_L[i-1] - h_L[i]) #dp[i] = min(dp[i],tmp1) # 2 tmp2 = dp[i-2] + abs(h_L[i-2...
n = int(eval(input())) h_L = list(map(int,input().split())) dp = [0] * (n+1) dp[1] = abs(h_L[1]-h_L[0]) for i in range(n-2): dp[i+2] = min(dp[i+1]+abs(h_L[i+2]-h_L[i+1]),dp[i] + abs(h_L[i+2]-h_L[i])) print((dp[n-1]))
19
10
387
224
n = int(eval(input())) h_L = list(map(int, input().split())) # dp = [float("inf")] * (10**4 + 1) dp = [10**9] * n dp[0] = 0 dp[1] = abs(h_L[0] - h_L[1]) for i in range(2, n): # dp[i] # 1 tmp1 = dp[i - 1] + abs(h_L[i - 1] - h_L[i]) # dp[i] = min(dp[i],tmp1) # 2 tmp2 = dp[i - 2] + abs(h_L[i - 2] -...
n = int(eval(input())) h_L = list(map(int, input().split())) dp = [0] * (n + 1) dp[1] = abs(h_L[1] - h_L[0]) for i in range(n - 2): dp[i + 2] = min( dp[i + 1] + abs(h_L[i + 2] - h_L[i + 1]), dp[i] + abs(h_L[i + 2] - h_L[i]) ) print((dp[n - 1]))
false
47.368421
[ "-# dp = [float(\"inf\")] * (10**4 + 1)", "-dp = [10**9] * n", "-dp[0] = 0", "-dp[1] = abs(h_L[0] - h_L[1])", "-for i in range(2, n):", "- # dp[i]", "- # 1", "- tmp1 = dp[i - 1] + abs(h_L[i - 1] - h_L[i])", "- # dp[i] = min(dp[i],tmp1)", "- # 2", "- tmp2 = dp[i - 2] + abs(h_L[i...
false
0.035974
0.035183
1.022469
[ "s753422109", "s939376135" ]
u230621983
p03633
python
s942454497
s700339503
36
28
5,076
9,068
Accepted
Accepted
22.22
from fractions import gcd from functools import reduce n = int(eval(input())) def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) t = set() for _ in range(n): t.add(int(eval(input()))) print((lcm_list(t)))
from math import gcd n = int(eval(input())) ans = 1 for _ in range(n): t = int(eval(input())) ans = t * ans // gcd(t, ans) print(ans)
16
8
278
137
from fractions import gcd from functools import reduce n = int(eval(input())) def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) t = set() for _ in range(n): t.add(int(eval(input()))) print((lcm_list(t)))
from math import gcd n = int(eval(input())) ans = 1 for _ in range(n): t = int(eval(input())) ans = t * ans // gcd(t, ans) print(ans)
false
50
[ "-from fractions import gcd", "-from functools import reduce", "+from math import gcd", "-", "-", "-def lcm_base(x, y):", "- return (x * y) // gcd(x, y)", "-", "-", "-def lcm_list(numbers):", "- return reduce(lcm_base, numbers, 1)", "-", "-", "-t = set()", "+ans = 1", "- t.add...
false
0.074408
0.055511
1.340409
[ "s942454497", "s700339503" ]
u827202523
p02929
python
s885064079
s888953096
205
86
41,580
80,460
Accepted
Accepted
58.05
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math MOD = 10**9 + 7 def factorial(n): ans = 1 for i in range(1, n+1): ans *= i ans %= MOD ...
import sys from collections import defaultdict, deque, Counter import math # import copy from bisect import bisect_left, bisect_right import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lam...
63
77
993
1,578
import sys input = sys.stdin.readline sys.setrecursionlimit(1000000) def getN(): return int(eval(input())) def getList(): return list(map(int, input().split())) import math MOD = 10**9 + 7 def factorial(n): ans = 1 for i in range(1, n + 1): ans *= i ans %= MOD return ans % ...
import sys from collections import defaultdict, deque, Counter import math # import copy from bisect import bisect_left, bisect_right import heapq # sys.setrecursionlimit(1000000) # input aliases input = sys.stdin.readline getS = lambda: input().strip() getN = lambda: int(eval(input())) getList = lambda: list(map(int...
false
18.181818
[ "+from collections import defaultdict, deque, Counter", "+import math", "+# import copy", "+from bisect import bisect_left, bisect_right", "+import heapq", "+", "+# sys.setrecursionlimit(1000000)", "+# input aliases", "-sys.setrecursionlimit(1000000)", "+getS = lambda: input().strip()", "+getN =...
false
0.034956
0.037213
0.939365
[ "s885064079", "s888953096" ]
u386819480
p02860
python
s378115011
s194809888
19
17
3,064
3,060
Accepted
Accepted
10.53
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1<<32 YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, S: str): if N%2 == 0: if S[:N//2] == S[N//2:]: print(YES) exit() print(NO) return def main(): ...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1<<32 YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, S: str): if S[:N//2] == S[N//2:]: print(YES) else: print(NO) return def main(): def iterate_tokens(): for line...
31
30
606
567
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1 << 32 YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, S: str): if N % 2 == 0: if S[: N // 2] == S[N // 2 :]: print(YES) exit() print(NO) return def main(): def iterate_tokens(...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10000000) INF = 1 << 32 YES = "Yes" # type: str NO = "No" # type: str def solve(N: int, S: str): if S[: N // 2] == S[N // 2 :]: print(YES) else: print(NO) return def main(): def iterate_tokens(): for line in sys.stdin...
false
3.225806
[ "- if N % 2 == 0:", "- if S[: N // 2] == S[N // 2 :]:", "- print(YES)", "- exit()", "- print(NO)", "+ if S[: N // 2] == S[N // 2 :]:", "+ print(YES)", "+ else:", "+ print(NO)" ]
false
0.043559
0.044101
0.987708
[ "s378115011", "s194809888" ]
u342869120
p03165
python
s130177240
s263360110
942
756
112,732
112,476
Accepted
Accepted
19.75
s = input().strip() t = input().strip() ls = len(s) lt = len(t) dp = [[0]*(lt+1) for i in range(ls+1)] for i in range(ls): for j in range(lt): v = dp[i][j]+1 if s[i] == t[j] else 0 dp[i+1][j+1] = max([v, dp[i+1][j], dp[i][j+1]]) ans = '' i, j = ls, lt while i > 0 and j > 0: if ...
s = input().strip() t = input().strip() ls = len(s) lt = len(t) dp = [[0]*(lt+1) for i in range(ls+1)] for i in range(ls): for j in range(lt): if s[i] == t[j]: dp[i+1][j+1] = dp[i][j]+1 else: dp[i+1][j+1] = max([dp[i+1][j], dp[i][j+1]]) ans = '' i, j = ls,...
25
28
492
528
s = input().strip() t = input().strip() ls = len(s) lt = len(t) dp = [[0] * (lt + 1) for i in range(ls + 1)] for i in range(ls): for j in range(lt): v = dp[i][j] + 1 if s[i] == t[j] else 0 dp[i + 1][j + 1] = max([v, dp[i + 1][j], dp[i][j + 1]]) ans = "" i, j = ls, lt while i > 0 and j > 0: if dp...
s = input().strip() t = input().strip() ls = len(s) lt = len(t) dp = [[0] * (lt + 1) for i in range(ls + 1)] for i in range(ls): for j in range(lt): if s[i] == t[j]: dp[i + 1][j + 1] = dp[i][j] + 1 else: dp[i + 1][j + 1] = max([dp[i + 1][j], dp[i][j + 1]]) ans = "" i, j = ls,...
false
10.714286
[ "- v = dp[i][j] + 1 if s[i] == t[j] else 0", "- dp[i + 1][j + 1] = max([v, dp[i + 1][j], dp[i][j + 1]])", "+ if s[i] == t[j]:", "+ dp[i + 1][j + 1] = dp[i][j] + 1", "+ else:", "+ dp[i + 1][j + 1] = max([dp[i + 1][j], dp[i][j + 1]])" ]
false
0.042323
0.041508
1.01963
[ "s130177240", "s263360110" ]
u432453907
p03434
python
s392806887
s867242636
29
26
9,048
9,088
Accepted
Accepted
10.34
n=int(eval(input())) a=list(map(int,input().split())) a.sort(reverse=True) a.append(0) Ali,Bob=0,0 for i in range(0,n,2): Ali +=a[i] Bob +=a[i+1] print((Ali-Bob))
n=int(eval(input())) a=list(map(int,input().split())) a.sort(reverse=True) Ali,Bob=0,0 for i in range(n): if i%2==0: Ali +=a[i] else: Bob +=a[i] print((Ali-Bob))
9
10
170
186
n = int(eval(input())) a = list(map(int, input().split())) a.sort(reverse=True) a.append(0) Ali, Bob = 0, 0 for i in range(0, n, 2): Ali += a[i] Bob += a[i + 1] print((Ali - Bob))
n = int(eval(input())) a = list(map(int, input().split())) a.sort(reverse=True) Ali, Bob = 0, 0 for i in range(n): if i % 2 == 0: Ali += a[i] else: Bob += a[i] print((Ali - Bob))
false
10
[ "-a.append(0)", "-for i in range(0, n, 2):", "- Ali += a[i]", "- Bob += a[i + 1]", "+for i in range(n):", "+ if i % 2 == 0:", "+ Ali += a[i]", "+ else:", "+ Bob += a[i]" ]
false
0.042489
0.0435
0.976772
[ "s392806887", "s867242636" ]
u729133443
p03679
python
s980951138
s774245911
164
27
38,256
9,148
Accepted
Accepted
83.54
x,a,b=list(map(int,input().split()));print((['delicious',['safe','dangerous'][b-a>x]][a-b<0]))
x,a,b=list(map(int,input().split())) print((('delicious',('safe','dangerous')[b-a>x])[a<b]))
1
2
86
85
x, a, b = list(map(int, input().split())) print((["delicious", ["safe", "dangerous"][b - a > x]][a - b < 0]))
x, a, b = list(map(int, input().split())) print((("delicious", ("safe", "dangerous")[b - a > x])[a < b]))
false
50
[ "-print(([\"delicious\", [\"safe\", \"dangerous\"][b - a > x]][a - b < 0]))", "+print(((\"delicious\", (\"safe\", \"dangerous\")[b - a > x])[a < b]))" ]
false
0.039065
0.034722
1.125085
[ "s980951138", "s774245911" ]
u366959492
p02861
python
s925920234
s337295797
213
194
40,812
74,512
Accepted
Accepted
8.92
n=int(eval(input())) xy=[list(map(int,input().split())) for _ in range(n)] import itertools as it ans=0 for i in it.permutations(list(range(n)),n): x=xy[i[0]][0] y=xy[i[0]][1] for k in range(1,n): j=i[k] ans+=((x-xy[j][0])**2+(y-xy[j][1])**2)**0.5 x=xy[j][0] y=xy[j...
n=int(eval(input())) xy=[list(map(int,input().split())) for _ in range(n)] from itertools import permutations ans=0 for i in permutations(list(range(n)),n): for j in range(1,n): ans+=((xy[i[j]][0]-xy[i[j-1]][0])**2+(xy[i[j]][1]-xy[i[j-1]][1])**2)**0.5 for i in range(1,n+1): ans/=i print(ans) ...
16
12
366
318
n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] import itertools as it ans = 0 for i in it.permutations(list(range(n)), n): x = xy[i[0]][0] y = xy[i[0]][1] for k in range(1, n): j = i[k] ans += ((x - xy[j][0]) ** 2 + (y - xy[j][1]) ** 2) ** 0.5 x = xy...
n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] from itertools import permutations ans = 0 for i in permutations(list(range(n)), n): for j in range(1, n): ans += ( (xy[i[j]][0] - xy[i[j - 1]][0]) ** 2 + (xy[i[j]][1] - xy[i[j - 1]][1]) ** 2 ) ** 0.5 for i ...
false
25
[ "-import itertools as it", "+from itertools import permutations", "-for i in it.permutations(list(range(n)), n):", "- x = xy[i[0]][0]", "- y = xy[i[0]][1]", "- for k in range(1, n):", "- j = i[k]", "- ans += ((x - xy[j][0]) ** 2 + (y - xy[j][1]) ** 2) ** 0.5", "- x = xy...
false
0.045499
0.045452
1.001034
[ "s925920234", "s337295797" ]
u072053884
p02243
python
s591350829
s774683209
1,180
520
121,748
70,692
Accepted
Accepted
55.93
import sys f_i = sys.stdin n = int(f_i.readline()) class VCost: def __init__(self, v, cost): self.v_n = v self.cost = cost def __lt__(self, other): return self.cost < other.cost def __gt__(self, other): return self.cost > other.cost adj = [[VCost(int(v), in...
import sys f_i = sys.stdin n = int(f_i.readline()) adj = [[(int(cost), int(v_n)) for v_n, cost in zip(x.split()[2::2], x.split()[3::2])] for x in f_i] import heapq def dijkstra(): PQ = [] isVisited = [False] * n distance = [999900001] * n distance[0] = 0 heapq.heappush(PQ, (0, ...
50
41
1,103
851
import sys f_i = sys.stdin n = int(f_i.readline()) class VCost: def __init__(self, v, cost): self.v_n = v self.cost = cost def __lt__(self, other): return self.cost < other.cost def __gt__(self, other): return self.cost > other.cost adj = [ [VCost(int(v), int(c)) f...
import sys f_i = sys.stdin n = int(f_i.readline()) adj = [ [(int(cost), int(v_n)) for v_n, cost in zip(x.split()[2::2], x.split()[3::2])] for x in f_i ] import heapq def dijkstra(): PQ = [] isVisited = [False] * n distance = [999900001] * n distance[0] = 0 heapq.heappush(PQ, (0, 0)) w...
false
18
[ "-", "-", "-class VCost:", "- def __init__(self, v, cost):", "- self.v_n = v", "- self.cost = cost", "-", "- def __lt__(self, other):", "- return self.cost < other.cost", "-", "- def __gt__(self, other):", "- return self.cost > other.cost", "-", "-", ...
false
0.113489
0.040525
2.800498
[ "s591350829", "s774683209" ]
u564589929
p03836
python
s647154150
s501583093
119
29
27,192
9,232
Accepted
Accepted
75.63
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return...
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return...
52
42
1,547
1,372
import sys sys.setrecursionlimit(10**9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())...
import sys sys.setrecursionlimit(10**9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())...
false
19.230769
[ "-from collections import deque", "-", "+# from collections import deque", "-import numpy as np # cumsum", "-", "+# import numpy as np # cumsum", "- ans = deque([])", "+ ans = \"\"", "- ans.extend([\"U\"] * abs(ty - sy))", "- ans.extend([\"R\"] * abs(tx - sx))", "+ ans += \"U\...
false
0.263811
0.04579
5.761379
[ "s647154150", "s501583093" ]
u281610856
p03274
python
s719330872
s129154158
98
76
14,384
14,168
Accepted
Accepted
22.45
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ans = 10 ** 10 for i in range(n-k+1): l, r = a[i], a[i + k -1] time = min(abs(l) + abs(l - r), abs(r) + abs(l - r)) ans = min(ans, time) print(ans)
import sys input = sys.stdin.readline INF = float("inf") def main(): n, k = list(map(int, input().split())) X = list(map(int, input().split())) if n == 1 and k == 1: print((0)) exit() ans = INF for i in range(n - k + 1): l, r = X[i], X[i + k - 1] tmp =...
8
25
235
525
n, k = list(map(int, input().split())) a = list(map(int, input().split())) ans = 10**10 for i in range(n - k + 1): l, r = a[i], a[i + k - 1] time = min(abs(l) + abs(l - r), abs(r) + abs(l - r)) ans = min(ans, time) print(ans)
import sys input = sys.stdin.readline INF = float("inf") def main(): n, k = list(map(int, input().split())) X = list(map(int, input().split())) if n == 1 and k == 1: print((0)) exit() ans = INF for i in range(n - k + 1): l, r = X[i], X[i + k - 1] tmp = r - l ...
false
68
[ "-n, k = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-ans = 10**10", "-for i in range(n - k + 1):", "- l, r = a[i], a[i + k - 1]", "- time = min(abs(l) + abs(l - r), abs(r) + abs(l - r))", "- ans = min(ans, time)", "-print(ans)", "+import sys", "+", "+inpu...
false
0.093041
0.090803
1.02465
[ "s719330872", "s129154158" ]
u844789719
p03343
python
s863063247
s286995150
1,847
1,323
3,444
67,164
Accepted
Accepted
28.37
import heapq N, K, Q = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] sA = sorted(set(A)) A += [-1] ans = float('inf') for amin in sA: cand = [] fr = 0 to = -1 for i in range(N + 1): a = A[i] if a >= amin: if fr == -1: ...
import heapq N, K, Q = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] sA = sorted(A) A += [-1] ans = float('inf') for amin in sA: cand = [] dp = [] for i in range(N + 1): a = A[i] if a >= amin: heapq.heappush(dp, a) if len(dp) and a <...
23
25
544
647
import heapq N, K, Q = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] sA = sorted(set(A)) A += [-1] ans = float("inf") for amin in sA: cand = [] fr = 0 to = -1 for i in range(N + 1): a = A[i] if a >= amin: if fr == -1: fr = i ...
import heapq N, K, Q = [int(_) for _ in input().split()] A = [int(_) for _ in input().split()] sA = sorted(A) A += [-1] ans = float("inf") for amin in sA: cand = [] dp = [] for i in range(N + 1): a = A[i] if a >= amin: heapq.heappush(dp, a) if len(dp) and a < amin: ...
false
8
[ "-sA = sorted(set(A))", "+sA = sorted(A)", "- fr = 0", "- to = -1", "+ dp = []", "- if fr == -1:", "- fr = i", "- elif a < amin and fr >= 0:", "- cand += sorted(A[fr:i])[: max(0, i - fr - K + 1)]", "- fr = -1", "+ heapq.h...
false
0.097971
0.079116
1.238324
[ "s863063247", "s286995150" ]
u876438858
p02687
python
s257558964
s532241903
26
24
9,356
9,020
Accepted
Accepted
7.69
import sys from math import sqrt from collections import Counter, defaultdict, deque input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(MI()) def LIN(n: int): re...
#!/usr/bin/env python3 import sys def solve(S: str): if S == "ABC": print("ARC") else: print("ABC") return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) ...
38
26
542
584
import sys from math import sqrt from collections import Counter, defaultdict, deque input = sys.stdin.readline sys.setrecursionlimit(10**6) def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(MI()) def LIN(n: int): return [I() for _ in rang...
#!/usr/bin/env python3 import sys def solve(S: str): if S == "ABC": print("ARC") else: print("ABC") return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): ...
false
31.578947
[ "+#!/usr/bin/env python3", "-from math import sqrt", "-from collections import Counter, defaultdict, deque", "-", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**6)", "-def I():", "- return int(eval(input()))", "-", "-", "-def MI():", "- return list(map(int, input().split()))"...
false
0.127505
0.047294
2.696023
[ "s257558964", "s532241903" ]
u442346200
p02396
python
s292523112
s618846123
140
110
6,724
6,720
Accepted
Accepted
21.43
c = 0 while True: x =int(eval(input())) if x == 0: break; c += 1 print(('Case', str(c) + ':', x))
count = 1 while True: x = input().strip() if x == '0': break print(('Case %s: %s' % (count, x))) count = count + 1
8
7
121
142
c = 0 while True: x = int(eval(input())) if x == 0: break c += 1 print(("Case", str(c) + ":", x))
count = 1 while True: x = input().strip() if x == "0": break print(("Case %s: %s" % (count, x))) count = count + 1
false
12.5
[ "-c = 0", "+count = 1", "- x = int(eval(input()))", "- if x == 0:", "+ x = input().strip()", "+ if x == \"0\":", "- c += 1", "- print((\"Case\", str(c) + \":\", x))", "+ print((\"Case %s: %s\" % (count, x)))", "+ count = count + 1" ]
false
0.115297
0.04621
2.495047
[ "s292523112", "s618846123" ]
u346812984
p02762
python
s038816831
s429758103
1,627
1,072
56,496
46,848
Accepted
Accepted
34.11
import sys sys.setrecursionlimit(10 ** 6) class UnionFind: def __init__(self, n_nodes): self.parent = [i for i in range(n_nodes)] self.rank = [0] * n_nodes self.size = [1] * n_nodes def find(self, x): if x == self.parent[x]: return x else: ...
import sys sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() class UnionFind: def __init__(self, n_nodes): self.n_nodes = n_nodes # self.parents[x] < 0 の時,xが根である. # また,xが根の時,(-1) * (同一グループの要素数) が格納され...
66
99
1,543
2,344
import sys sys.setrecursionlimit(10**6) class UnionFind: def __init__(self, n_nodes): self.parent = [i for i in range(n_nodes)] self.rank = [0] * n_nodes self.size = [1] * n_nodes def find(self, x): if x == self.parent[x]: return x else: self.p...
import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() class UnionFind: def __init__(self, n_nodes): self.n_nodes = n_nodes # self.parents[x] < 0 の時,xが根である. # また,xが根の時,(-1) * (同一グループの要素数) が格納されるようになる. self....
false
33.333333
[ "+INF = float(\"inf\")", "+MOD = 10**9 + 7", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "- self.parent = [i for i in range(n_nodes)]", "- self.rank = [0] * n_nodes", "- self.size = [1] * n_nodes", "+ self.n_nodes = n_nodes", "+ # sel...
false
0.04477
0.183014
0.244624
[ "s038816831", "s429758103" ]
u285891772
p02947
python
s648811419
s649138734
383
309
26,320
21,612
Accepted
Accepted
19.32
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2 from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy...
32
35
1,044
1,083
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2 from itertools import ( accumulate, permutations, combinations, combinations_with_replacement, product, groupby, ) from operator import itemgetter, mu...
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians # , log2 from itertools import ( accumulate, permutations, combinations, combinations_with_replacement, product, groupby, ) from operator import itemgetter, mu...
false
8.571429
[ "-s = [str(sorted(list(eval(input())))) for _ in range(N)]", "-dic = Counter(s)", "+s = [\"\".join(sorted(list(eval(input())))) for _ in range(N)]", "+dic = defaultdict(int)", "+for x in s:", "+ dic[x] += 1" ]
false
0.046927
0.043913
1.068645
[ "s648811419", "s649138734" ]
u588341295
p03150
python
s287335996
s887634883
39
21
5,220
3,188
Accepted
Accepted
46.15
# -*- coding: utf-8 -*- import sys, re from collections import deque, defaultdict, Counter from math import sqrt, hypot, factorial, pi, sin, cos, radians if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd from heapq import heappop, heappush, heapify, heappushpop from bisect i...
import sys import re def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def c...
42
32
1,494
892
# -*- coding: utf-8 -*- import sys, re from collections import deque, defaultdict, Counter from math import sqrt, hypot, factorial, pi, sin, cos, radians if sys.version_info.minor >= 5: from math import gcd else: from fractions import gcd from heapq import heappop, heappush, heapify, heappushpop from bisect im...
import sys import re def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in...
false
23.809524
[ "-# -*- coding: utf-8 -*-", "-import sys, re", "-from collections import deque, defaultdict, Counter", "-from math import sqrt, hypot, factorial, pi, sin, cos, radians", "-", "-if sys.version_info.minor >= 5:", "- from math import gcd", "-else:", "- from fractions import gcd", "-from heapq i...
false
0.121067
0.110555
1.095082
[ "s287335996", "s887634883" ]
u580697892
p02975
python
s996159534
s636131884
90
78
14,212
14,212
Accepted
Accepted
13.33
# coding: utf-8 N = int(eval(input())) A = list(map(int, input().split())) A.sort() d = {} for i in range(N): a = A[i] if a not in list(d.keys()): d[a] = 1 else: d[a] += 1 if len(list(d.keys())) == 1: if list(d.keys())[0] == 0: print("Yes") else: print(...
# coding: utf-8 N = int(eval(input())) A = list(map(int, input().split())) # A.sort() d = {} for i in range(N): a = A[i] if a not in list(d.keys()): d[a] = 1 else: d[a] += 1 flag = True if len(list(d.keys())) == 1: if list(d.keys())[0] == 0: flag = True else: ...
33
35
727
776
# coding: utf-8 N = int(eval(input())) A = list(map(int, input().split())) A.sort() d = {} for i in range(N): a = A[i] if a not in list(d.keys()): d[a] = 1 else: d[a] += 1 if len(list(d.keys())) == 1: if list(d.keys())[0] == 0: print("Yes") else: print("No") elif len(...
# coding: utf-8 N = int(eval(input())) A = list(map(int, input().split())) # A.sort() d = {} for i in range(N): a = A[i] if a not in list(d.keys()): d[a] = 1 else: d[a] += 1 flag = True if len(list(d.keys())) == 1: if list(d.keys())[0] == 0: flag = True else: flag = F...
false
5.714286
[ "-A.sort()", "+# A.sort()", "+flag = True", "- print(\"Yes\")", "+ flag = True", "- print(\"No\")", "+ flag = False", "- print(\"Yes\")", "+ flag = True", "- print(\"No\")", "+ flag = False", "- print(\"Yes\")", "+ ...
false
0.037489
0.038554
0.972372
[ "s996159534", "s636131884" ]
u620755587
p02713
python
s722847499
s741360827
1,306
741
9,900
9,960
Accepted
Accepted
43.26
#!/usr/bin/env python3 import sys import pprint from math import gcd sys.setrecursionlimit(10 ** 6) class Logger: def __init__(self, debug): self.debug = debug def print(self, *args): if self.debug: pprint.pprint(args) def main(): log = Logger(1) k = int(sys.stdin.readline()) s = 0...
#!/usr/bin/env pypy3 import sys import pprint from math import gcd sys.setrecursionlimit(10 ** 6) class Logger: def __init__(self, debug): self.debug = debug def print(self, *args): if self.debug: pprint.pprint(args) def main(): log = Logger(1) k = int(sys.stdin.readline()) s = 0 ...
30
31
455
463
#!/usr/bin/env python3 import sys import pprint from math import gcd sys.setrecursionlimit(10**6) class Logger: def __init__(self, debug): self.debug = debug def print(self, *args): if self.debug: pprint.pprint(args) def main(): log = Logger(1) k = int(sys.stdin.readlin...
#!/usr/bin/env pypy3 import sys import pprint from math import gcd sys.setrecursionlimit(10**6) class Logger: def __init__(self, debug): self.debug = debug def print(self, *args): if self.debug: pprint.pprint(args) def main(): log = Logger(1) k = int(sys.stdin.readline(...
false
3.225806
[ "-#!/usr/bin/env python3", "+#!/usr/bin/env pypy3", "+ x = gcd(a, b)", "- s += gcd(gcd(a, b), c)", "+ s += gcd(x, c)" ]
false
0.119452
0.071181
1.678157
[ "s722847499", "s741360827" ]
u123756661
p03030
python
s403385664
s886639476
192
167
38,384
38,256
Accepted
Accepted
13.02
n=int(eval(input())) c,m=[],[] d={} t={} for i in range(n): s,p=list(map(str,input().split())) m.append((s,int(p))) if s not in c: c.append(s) d[s]=[int(p)] else: d[s].append(int(p)) t[(s,int(p))]=i+1 c.sort() ans={} cnt=1 for i in c: d[i].sort(reverse=Tr...
n=int(eval(input())) ans=[] for i in range(n): s,p=list(map(str,input().split())) ans.append((s,int(p)*-1,i+1)) ans.sort() for i in ans: print((i[2]))
23
7
418
150
n = int(eval(input())) c, m = [], [] d = {} t = {} for i in range(n): s, p = list(map(str, input().split())) m.append((s, int(p))) if s not in c: c.append(s) d[s] = [int(p)] else: d[s].append(int(p)) t[(s, int(p))] = i + 1 c.sort() ans = {} cnt = 1 for i in c: d[i].sort(r...
n = int(eval(input())) ans = [] for i in range(n): s, p = list(map(str, input().split())) ans.append((s, int(p) * -1, i + 1)) ans.sort() for i in ans: print((i[2]))
false
69.565217
[ "-c, m = [], []", "-d = {}", "-t = {}", "+ans = []", "- m.append((s, int(p)))", "- if s not in c:", "- c.append(s)", "- d[s] = [int(p)]", "- else:", "- d[s].append(int(p))", "- t[(s, int(p))] = i + 1", "-c.sort()", "-ans = {}", "-cnt = 1", "-for i in c:",...
false
0.08227
0.089141
0.922921
[ "s403385664", "s886639476" ]
u186838327
p03700
python
s167208007
s536886875
573
461
51,928
80,816
Accepted
Accepted
19.55
n, a, b = list(map(int, input().split())) H = [int(eval(input())) for i in range(n)] def ok(x): t = 0 for i in range(n): h = H[i] res = h-b*x if res <= 0: continue else: if res%(a-b) == 0: t += res//(a-b) else: ...
n, a, b = list(map(int, input().split())) H = [int(eval(input())) for _ in range(n)] def is_ok(x): cnt = 0 for i in range(n): h = H[i] if h <= x*b: continue else: h -= x*b cnt += (h+(a-b-1))//(a-b) if cnt <= x: return True ...
29
26
530
463
n, a, b = list(map(int, input().split())) H = [int(eval(input())) for i in range(n)] def ok(x): t = 0 for i in range(n): h = H[i] res = h - b * x if res <= 0: continue else: if res % (a - b) == 0: t += res // (a - b) else: ...
n, a, b = list(map(int, input().split())) H = [int(eval(input())) for _ in range(n)] def is_ok(x): cnt = 0 for i in range(n): h = H[i] if h <= x * b: continue else: h -= x * b cnt += (h + (a - b - 1)) // (a - b) if cnt <= x: return True ...
false
10.344828
[ "-H = [int(eval(input())) for i in range(n)]", "+H = [int(eval(input())) for _ in range(n)]", "-def ok(x):", "- t = 0", "+def is_ok(x):", "+ cnt = 0", "- res = h - b * x", "- if res <= 0:", "+ if h <= x * b:", "- if res % (a - b) == 0:", "- t ...
false
0.044273
0.043898
1.00854
[ "s167208007", "s536886875" ]
u752907799
p02802
python
s133347545
s470031440
1,761
1,504
12,728
12,852
Accepted
Accepted
14.59
import numpy as np N, M = list(map(int, input().split())) d = np.zeros(N+1, dtype = 'int32') t = 0 f = 0 for i in range(M): tmp = input().split() p = int(tmp[0]) S = tmp[1] dp = d[p] if S == 'AC': if dp != -1: f += dp d[p] = -1 t += 1 el...
import numpy as np import sys input = sys.stdin.readline N, M = list(map(int, input().split())) d = np.zeros(N+1, dtype = 'int32') t = 0 f = 0 for i in range(M): tmp = input().split() p = int(tmp[0]) S = tmp[1] dp = d[p] if S == 'AC': if dp != -1: f += dp ...
18
21
359
401
import numpy as np N, M = list(map(int, input().split())) d = np.zeros(N + 1, dtype="int32") t = 0 f = 0 for i in range(M): tmp = input().split() p = int(tmp[0]) S = tmp[1] dp = d[p] if S == "AC": if dp != -1: f += dp d[p] = -1 t += 1 elif dp != -1: ...
import numpy as np import sys input = sys.stdin.readline N, M = list(map(int, input().split())) d = np.zeros(N + 1, dtype="int32") t = 0 f = 0 for i in range(M): tmp = input().split() p = int(tmp[0]) S = tmp[1] dp = d[p] if S == "AC": if dp != -1: f += dp d[p] = -1 ...
false
14.285714
[ "+import sys", "+input = sys.stdin.readline" ]
false
0.242723
0.245298
0.989503
[ "s133347545", "s470031440" ]
u227082700
p02695
python
s357198292
s462618178
984
550
9,188
9,032
Accepted
Accepted
44.11
import itertools n,m,q=list(map(int,input().split())) abcd=[list(map(int,input().split()))for _ in range(q)] ans=0 for i in itertools.combinations_with_replacement(list(range(m)),n): anss=0 for a,b,c,d in abcd: if i[b-1]-i[a-1]==c:anss+=d ans=max(ans,anss) print(ans)
import itertools n,m,q=list(map(int,input().split())) abcd=[list(map(int,input().split()))for _ in range(q)] print((max(sum(d for a,b,c,d in abcd if i[b-1]-i[a-1]==c)for i in itertools.combinations_with_replacement(list(range(m)),n))))
10
4
274
224
import itertools n, m, q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for _ in range(q)] ans = 0 for i in itertools.combinations_with_replacement(list(range(m)), n): anss = 0 for a, b, c, d in abcd: if i[b - 1] - i[a - 1] == c: anss += d ans = max(ans, anss)...
import itertools n, m, q = list(map(int, input().split())) abcd = [list(map(int, input().split())) for _ in range(q)] print( ( max( sum(d for a, b, c, d in abcd if i[b - 1] - i[a - 1] == c) for i in itertools.combinations_with_replacement(list(range(m)), n) ) ) )
false
60
[ "-ans = 0", "-for i in itertools.combinations_with_replacement(list(range(m)), n):", "- anss = 0", "- for a, b, c, d in abcd:", "- if i[b - 1] - i[a - 1] == c:", "- anss += d", "- ans = max(ans, anss)", "-print(ans)", "+print(", "+ (", "+ max(", "+ ...
false
0.054986
0.089696
0.613026
[ "s357198292", "s462618178" ]
u500376440
p02675
python
s089400845
s932931190
30
26
9,100
9,112
Accepted
Accepted
13.33
N=int(eval(input())) hon=[2,4,5,7,9] pon=[0,1,6,8] n=N%10 if n in hon: print("hon") elif n in pon: print("pon") else: print("bon")
N=eval(input()) if int(N[-1]) in (2,4,5,7,9): print("hon") elif int(N[-1]) in (0,1,6,8): print("pon") else: print("bon")
10
7
140
127
N = int(eval(input())) hon = [2, 4, 5, 7, 9] pon = [0, 1, 6, 8] n = N % 10 if n in hon: print("hon") elif n in pon: print("pon") else: print("bon")
N = eval(input()) if int(N[-1]) in (2, 4, 5, 7, 9): print("hon") elif int(N[-1]) in (0, 1, 6, 8): print("pon") else: print("bon")
false
30
[ "-N = int(eval(input()))", "-hon = [2, 4, 5, 7, 9]", "-pon = [0, 1, 6, 8]", "-n = N % 10", "-if n in hon:", "+N = eval(input())", "+if int(N[-1]) in (2, 4, 5, 7, 9):", "-elif n in pon:", "+elif int(N[-1]) in (0, 1, 6, 8):" ]
false
0.136025
0.095529
1.423911
[ "s089400845", "s932931190" ]
u120691615
p03835
python
s585163413
s506308799
1,373
1,240
2,940
2,940
Accepted
Accepted
9.69
K,S = list(map(int,input().split())) cnt = 0 for i in range(K+1): for j in range(K+1): if 0 <= S - (i + j) <= K: cnt += 1 print(cnt)
K,S = list(map(int,input().split())) cnt = 0 for i in range(K+1): for j in range(K+1): if 0<= S-i-j <= K: cnt += 1 print(cnt)
7
8
156
151
K, S = list(map(int, input().split())) cnt = 0 for i in range(K + 1): for j in range(K + 1): if 0 <= S - (i + j) <= K: cnt += 1 print(cnt)
K, S = list(map(int, input().split())) cnt = 0 for i in range(K + 1): for j in range(K + 1): if 0 <= S - i - j <= K: cnt += 1 print(cnt)
false
12.5
[ "- if 0 <= S - (i + j) <= K:", "+ if 0 <= S - i - j <= K:" ]
false
0.035531
0.042915
0.82794
[ "s585163413", "s506308799" ]
u562935282
p03252
python
s581308905
s963566005
130
84
3,632
3,632
Accepted
Accepted
35.38
s = eval(input()) t = eval(input()) s2t = dict() t2s = dict() flg = True for i, (ss, tt) in enumerate(zip(s, t)): a = s2t.get(ss, None) if a is None: s2t[ss] = tt else: if a != tt: flg = False break b = t2s.get(tt, None) if b is None: ...
def solve(): s = eval(input()) t = eval(input()) d = dict() for sc, tc in zip(s, t): if d.get(sc, None) is None: d[sc] = tc else: if d[sc] != tc: return False d = {value: key for key, value in list(d.items())} for sc, tc in zip...
24
23
432
533
s = eval(input()) t = eval(input()) s2t = dict() t2s = dict() flg = True for i, (ss, tt) in enumerate(zip(s, t)): a = s2t.get(ss, None) if a is None: s2t[ss] = tt else: if a != tt: flg = False break b = t2s.get(tt, None) if b is None: t2s[tt] = ss ...
def solve(): s = eval(input()) t = eval(input()) d = dict() for sc, tc in zip(s, t): if d.get(sc, None) is None: d[sc] = tc else: if d[sc] != tc: return False d = {value: key for key, value in list(d.items())} for sc, tc in zip(s, t): ...
false
4.166667
[ "-s = eval(input())", "-t = eval(input())", "-s2t = dict()", "-t2s = dict()", "-flg = True", "-for i, (ss, tt) in enumerate(zip(s, t)):", "- a = s2t.get(ss, None)", "- if a is None:", "- s2t[ss] = tt", "- else:", "- if a != tt:", "- flg = False", "- ...
false
0.038257
0.043122
0.887179
[ "s581308905", "s963566005" ]
u906501980
p02901
python
s536648395
s399317370
767
543
3,188
3,188
Accepted
Accepted
29.2
def main(): n, m = list(map(int, input().split())) p = 2**n inf = 10**7 dp = [inf]*p dp[0] = 0 for _ in range(m): a, _ = list(map(int, input().split())) c = sum([2**(int(i)-1) for i in input().split()]) for s in range(p): t = s|c ...
def main(): n, m = list(map(int, input().split())) p = 2**n inf = 10**7 dp = [inf]*p dp[0] = 0 for _ in range(m): a, _ = list(map(int, input().split())) c = sum([1<<(int(i)-1) for i in input().split()]) for s in range(p): if dp[s|c] > dp[s] + a: ...
21
19
504
462
def main(): n, m = list(map(int, input().split())) p = 2**n inf = 10**7 dp = [inf] * p dp[0] = 0 for _ in range(m): a, _ = list(map(int, input().split())) c = sum([2 ** (int(i) - 1) for i in input().split()]) for s in range(p): t = s | c new = dp[s...
def main(): n, m = list(map(int, input().split())) p = 2**n inf = 10**7 dp = [inf] * p dp[0] = 0 for _ in range(m): a, _ = list(map(int, input().split())) c = sum([1 << (int(i) - 1) for i in input().split()]) for s in range(p): if dp[s | c] > dp[s] + a: ...
false
9.52381
[ "- c = sum([2 ** (int(i) - 1) for i in input().split()])", "+ c = sum([1 << (int(i) - 1) for i in input().split()])", "- t = s | c", "- new = dp[s] + a", "- if dp[t] > new:", "- dp[t] = new", "+ if dp[s | c] > dp[s] + a:", "+ ...
false
0.038194
0.036911
1.034772
[ "s536648395", "s399317370" ]
u347640436
p02862
python
s894677966
s671809416
164
132
35,188
9,176
Accepted
Accepted
19.51
# フェルマーの小定理 X, Y = list(map(int, input().split())) m = 1000000007 def make_factorial_table(n): result = [0] * (n + 1) result[0] = 1 for i in range(1, n + 1): result[i] = result[i - 1] * i % m return result def mcomb(n, k): if n == 0 and k == 0: return 1 if n...
# フェルマーの小定理 X, Y = list(map(int, input().split())) m = 1000000007 def mcomb(n, k): a = 1 b = 1 for i in range(k): a *= n - i a %= m b *= i + 1 b %= m return a * pow(b, m - 2, m) % m if (X + Y) % 3 != 0: print((0)) exit() a = (2 * Y - X) // 3 b ...
36
26
632
412
# フェルマーの小定理 X, Y = list(map(int, input().split())) m = 1000000007 def make_factorial_table(n): result = [0] * (n + 1) result[0] = 1 for i in range(1, n + 1): result[i] = result[i - 1] * i % m return result def mcomb(n, k): if n == 0 and k == 0: return 1 if n < k or k < 0: ...
# フェルマーの小定理 X, Y = list(map(int, input().split())) m = 1000000007 def mcomb(n, k): a = 1 b = 1 for i in range(k): a *= n - i a %= m b *= i + 1 b %= m return a * pow(b, m - 2, m) % m if (X + Y) % 3 != 0: print((0)) exit() a = (2 * Y - X) // 3 b = (2 * X - Y) //...
false
27.777778
[ "-def make_factorial_table(n):", "- result = [0] * (n + 1)", "- result[0] = 1", "- for i in range(1, n + 1):", "- result[i] = result[i - 1] * i % m", "- return result", "-", "-", "- if n == 0 and k == 0:", "- return 1", "- if n < k or k < 0:", "- return 0...
false
0.065479
0.157702
0.415207
[ "s894677966", "s671809416" ]
u788703383
p03818
python
s986384690
s334351631
63
53
18,656
18,656
Accepted
Accepted
15.87
import collections n = int(eval(input())) c = collections.Counter(list(map(int,input().split()))) z = list(c.values()) ans = 0 for c in z: ans +=(1-c%2) print((len(z)-ans%2))
import collections n = int(eval(input())) c = len(collections.Counter(list(map(int,input().split())))) print((c-(1-c%2)))
11
4
184
117
import collections n = int(eval(input())) c = collections.Counter(list(map(int, input().split()))) z = list(c.values()) ans = 0 for c in z: ans += 1 - c % 2 print((len(z) - ans % 2))
import collections n = int(eval(input())) c = len(collections.Counter(list(map(int, input().split())))) print((c - (1 - c % 2)))
false
63.636364
[ "-c = collections.Counter(list(map(int, input().split())))", "-z = list(c.values())", "-ans = 0", "-for c in z:", "- ans += 1 - c % 2", "-print((len(z) - ans % 2))", "+c = len(collections.Counter(list(map(int, input().split()))))", "+print((c - (1 - c % 2)))" ]
false
0.038208
0.039152
0.975876
[ "s986384690", "s334351631" ]
u977661421
p03457
python
s550720441
s128435232
445
410
21,156
21,108
Accepted
Accepted
7.87
# -*- coding: utf-8 -*- n = int(eval(input())) txy = [] for i in range(n): txy.append([int(i) for i in input().split()]) ans = "Yes" tmp_x = 0 tmp_y = 0 tmp_t = 0 for i in range(n): #print((abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2]))) if (abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2])) % ...
# -*- coding: utf-8 -*- n = int(eval(input())) txy = [] for i in range(n): txy.append([int(i) for i in input().split()]) ans = "Yes" bx = 0 by = 0 bt = 0 for i in range(n): tmp = ((txy[i][1] - bx) + (txy[i][2] - by)) if tmp % 2 != (txy[i][0] - bt) % 2 or tmp > (txy[i][0] - bt): ans = "...
18
18
518
390
# -*- coding: utf-8 -*- n = int(eval(input())) txy = [] for i in range(n): txy.append([int(i) for i in input().split()]) ans = "Yes" tmp_x = 0 tmp_y = 0 tmp_t = 0 for i in range(n): # print((abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2]))) if (abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2])) % 2 != ( ...
# -*- coding: utf-8 -*- n = int(eval(input())) txy = [] for i in range(n): txy.append([int(i) for i in input().split()]) ans = "Yes" bx = 0 by = 0 bt = 0 for i in range(n): tmp = (txy[i][1] - bx) + (txy[i][2] - by) if tmp % 2 != (txy[i][0] - bt) % 2 or tmp > (txy[i][0] - bt): ans = "No" bx = txy...
false
0
[ "-tmp_x = 0", "-tmp_y = 0", "-tmp_t = 0", "+bx = 0", "+by = 0", "+bt = 0", "- # print((abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2])))", "- if (abs(tmp_x - txy[i][1]) + abs(tmp_y - txy[i][2])) % 2 != (", "- txy[i][0] - tmp_t", "- ) % 2 or (abs(tmp_x - txy[i][1]) + abs(tmp_y - txy...
false
0.042078
0.044862
0.937942
[ "s550720441", "s128435232" ]
u222668979
p02706
python
s963096407
s526894957
24
22
9,880
9,896
Accepted
Accepted
8.33
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) a = list(map(int, input().split())) if n < sum(a): print((-1)) else: print((n-sum(a)))
n, m = list(map(int, input().split())) a = list(map(int, input().split())) print((-1 if n < sum(a) else n - sum(a)))
10
4
173
112
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) a = list(map(int, input().split())) if n < sum(a): print((-1)) else: print((n - sum(a)))
n, m = list(map(int, input().split())) a = list(map(int, input().split())) print((-1 if n < sum(a) else n - sum(a)))
false
60
[ "-import sys", "-", "-input = sys.stdin.readline", "-if n < sum(a):", "- print((-1))", "-else:", "- print((n - sum(a)))", "+print((-1 if n < sum(a) else n - sum(a)))" ]
false
0.040486
0.043001
0.941516
[ "s963096407", "s526894957" ]