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
u627803856
p02594
python
s524875282
s530436894
86
64
61,516
61,768
Accepted
Accepted
25.58
x = int(eval(input())) if x >= 30: print('Yes') else: print('No')
x = int(input()) print('Yes') if x >= 30 else print('No')
6
2
73
58
x = int(eval(input())) if x >= 30: print("Yes") else: print("No")
x = int(input()) print("Yes") if x >= 30 else print("No")
false
66.666667
[ "-x = int(eval(input()))", "-if x >= 30:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+x = int(input())", "+print(\"Yes\") if x >= 30 else print(\"No\")" ]
false
0.037568
0.038342
0.979802
[ "s524875282", "s530436894" ]
u633068244
p00179
python
s095322411
s903376574
2,010
950
6,764
6,216
Accepted
Accepted
52.74
rgb = set(["r","g","b"]) while 1: worm = input() if worm == "0": break n = len(worm) L = 1 cnt = flag = 0 queset = set([worm]) ref = set() while 1: que = list(queset) queset = set() for Worm in que: if len(set(Worm)) == 1: flag = 1 break for i in range(n-1): if Worm[i] !...
dic = {"r":1,"g":2,"b":3} rgb = ["r","g","b"] while 1: worm = input() if worm == "0": break n = len(worm) ref = ["r"*n,"g"*n,"b"*n] cnt = flag = 0 queset = set([worm]) done = set() while 1: que = list(queset) queset = set() for Worm in que: if Worm in ref: flag = 1 break for...
28
26
598
582
rgb = set(["r", "g", "b"]) while 1: worm = input() if worm == "0": break n = len(worm) L = 1 cnt = flag = 0 queset = set([worm]) ref = set() while 1: que = list(queset) queset = set() for Worm in que: if len(set(Worm)) == 1: fla...
dic = {"r": 1, "g": 2, "b": 3} rgb = ["r", "g", "b"] while 1: worm = input() if worm == "0": break n = len(worm) ref = ["r" * n, "g" * n, "b" * n] cnt = flag = 0 queset = set([worm]) done = set() while 1: que = list(queset) queset = set() for Worm in que: ...
false
7.142857
[ "-rgb = set([\"r\", \"g\", \"b\"])", "+dic = {\"r\": 1, \"g\": 2, \"b\": 3}", "+rgb = [\"r\", \"g\", \"b\"]", "- L = 1", "+ ref = [\"r\" * n, \"g\" * n, \"b\" * n]", "- ref = set()", "+ done = set()", "- if len(set(Worm)) == 1:", "+ if Worm in ref:", "- ...
false
0.254494
0.106316
2.393759
[ "s095322411", "s903376574" ]
u994307795
p02779
python
s822685904
s566612284
139
82
44,336
25,172
Accepted
Accepted
41.01
n = int(eval(input())) a = list(map(int, input().split())) d = {} for i in a: if i in d: print("NO") exit() d[i] = i print("YES")
n = int(eval(input())) a = list(map(int, input().split())) print(('YES' if len(a) == len(set(a)) else 'NO'))
11
3
135
102
n = int(eval(input())) a = list(map(int, input().split())) d = {} for i in a: if i in d: print("NO") exit() d[i] = i print("YES")
n = int(eval(input())) a = list(map(int, input().split())) print(("YES" if len(a) == len(set(a)) else "NO"))
false
72.727273
[ "-d = {}", "-for i in a:", "- if i in d:", "- print(\"NO\")", "- exit()", "- d[i] = i", "-print(\"YES\")", "+print((\"YES\" if len(a) == len(set(a)) else \"NO\"))" ]
false
0.036887
0.036658
1.006244
[ "s822685904", "s566612284" ]
u982594421
p03830
python
s623902454
s608217091
295
111
3,316
3,316
Accepted
Accepted
62.37
from math import factorial from collections import Counter def primes(n): a = [0] * (n + 1) a[0] = 1 a[1] = 1 i = 2 while n // i >= i: if a[i] != 0: i += 1 continue j = 2 * i while j <= n: a[j] = 1 j += i ...
from math import factorial from collections import Counter def prime(n): a = [0] * (n + 1) a[0] = 1 a[1] = 1 i = 2 while n // i >= i: if a[i] != 0: i += 1 continue j = 2 * i while j <= n: a[j] = 1 j += i ...
37
36
672
666
from math import factorial from collections import Counter def primes(n): a = [0] * (n + 1) a[0] = 1 a[1] = 1 i = 2 while n // i >= i: if a[i] != 0: i += 1 continue j = 2 * i while j <= n: a[j] = 1 j += i i += 1 fo...
from math import factorial from collections import Counter def prime(n): a = [0] * (n + 1) a[0] = 1 a[1] = 1 i = 2 while n // i >= i: if a[i] != 0: i += 1 continue j = 2 * i while j <= n: a[j] = 1 j += i i += 1 ret...
false
2.702703
[ "-def primes(n):", "+def prime(n):", "- for i, ai in enumerate(a):", "- if ai == 0:", "- yield i", "+ return [i for i, ai in enumerate(a) if ai == 0]", "+primes = prime(n)", "- for p in primes(n):", "+ for p in primes:" ]
false
0.085666
0.165728
0.516906
[ "s623902454", "s608217091" ]
u823885866
p02881
python
s403389073
s088990063
400
296
12,584
21,244
Accepted
Accepted
26
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.buffer.readline().rstrip() rs = lambda: sys.stdin.buffer.readline().split() ri = lambda: int(sys.stdin.buffer.readline()) rm = lambda: list(map(int, sys.stdin.buffer.readline().split()...
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.buffer.readline().rstrip() rs = lambda: sys.stdin.buffer.readline().split() ri = lambda: int(sys.stdin.buffer.readline()) rm = lambda: list(map(int, sys.stdin.buffer.readline().split()...
25
21
535
498
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.buffer.readline().rstrip() rs = lambda: sys.stdin.buffer.readline().split() ri = lambda: int(sys.stdin.buffer.readline()) rm = lambda: list(map(int, sys.stdin.buffer.readline().split())) rl = lam...
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.buffer.readline().rstrip() rs = lambda: sys.stdin.buffer.readline().split() ri = lambda: int(sys.stdin.buffer.readline()) rm = lambda: list(map(int, sys.stdin.buffer.readline().split())) rl = lam...
false
16
[ "-m = float(\"inf\")", "-for i in range(1, int(n**0.5) + 1):", "- a = n // i", "- if a * i == n:", "- if m > a + i:", "- m = a + i", "-else:", "- print((m - 2))", "+for i in range(int(n**0.5), 0, -1):", "+ if not n % i:", "+ print((n // i + i - 2))", "+ ...
false
0.056986
0.052843
1.078406
[ "s403389073", "s088990063" ]
u204842730
p02613
python
s341955058
s991444401
147
49
16,224
17,504
Accepted
Accepted
66.67
import collections n=int(eval(input())) s=[None]*n for i in range(n): s[i]=eval(input()) c=collections.Counter(s) print(("AC x " + str(c["AC"]))) print(("WA x " + str(c["WA"]))) print(("TLE x " + str(c["TLE"]))) print(("RE x " + str(c["RE"])))
import collections import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline n=int(readline()) s=read().decode().splitlines() c=collections.Counter(s) print(("AC x " + str(c["AC"]))) print(("WA x " + str(c["WA"]))) print(("TLE x " + str(c["TLE"]))) print(("RE x " + str(c["RE"])))
10
11
236
301
import collections n = int(eval(input())) s = [None] * n for i in range(n): s[i] = eval(input()) c = collections.Counter(s) print(("AC x " + str(c["AC"]))) print(("WA x " + str(c["WA"]))) print(("TLE x " + str(c["TLE"]))) print(("RE x " + str(c["RE"])))
import collections import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline n = int(readline()) s = read().decode().splitlines() c = collections.Counter(s) print(("AC x " + str(c["AC"]))) print(("WA x " + str(c["WA"]))) print(("TLE x " + str(c["TLE"]))) print(("RE x " + str(c["RE"])))
false
9.090909
[ "+import sys", "-n = int(eval(input()))", "-s = [None] * n", "-for i in range(n):", "- s[i] = eval(input())", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+n = int(readline())", "+s = read().decode().splitlines()" ]
false
0.035135
0.039242
0.895345
[ "s341955058", "s991444401" ]
u281303342
p04014
python
s616880027
s950951884
587
475
3,064
3,064
Accepted
Accepted
19.08
N = int(eval(input())) S = int(eval(input())) def f(b,n): if n//b==0: return n else: return n%b + f(b,n//b) ans = -1 if S==N: ans = N+1 else: for b in range(2,int(N**.5)+1): if f(b,N)==S: ans = b break if ans == -1: for i in range...
# python3 (3.4.3) import sys input = sys.stdin.readline # main N = int(eval(input())) S = int(eval(input())) def f(b,n): if n < b: return n else: return f(b, n//b) + n%b ans = -1 if S==N: ans = N+1 else: # bをN^(1/2)まで全探索 for b in range(2, int(N**.5)+1): ...
27
37
460
720
N = int(eval(input())) S = int(eval(input())) def f(b, n): if n // b == 0: return n else: return n % b + f(b, n // b) ans = -1 if S == N: ans = N + 1 else: for b in range(2, int(N**0.5) + 1): if f(b, N) == S: ans = b break if ans == -1: for i in ra...
# python3 (3.4.3) import sys input = sys.stdin.readline # main N = int(eval(input())) S = int(eval(input())) def f(b, n): if n < b: return n else: return f(b, n // b) + n % b ans = -1 if S == N: ans = N + 1 else: # bをN^(1/2)まで全探索 for b in range(2, int(N**0.5) + 1): if f(...
false
27.027027
[ "+# python3 (3.4.3)", "+import sys", "+", "+input = sys.stdin.readline", "+# main", "- if n // b == 0:", "+ if n < b:", "- return n % b + f(b, n // b)", "+ return f(b, n // b) + n % b", "+ # bをN^(1/2)まで全探索", "+# まだ答えが見つからなければ", "- for i in range(int(N**0.5) + 1, 0, -1...
false
0.102359
0.348887
0.293389
[ "s616880027", "s950951884" ]
u260980560
p02373
python
s607379843
s604336117
2,150
1,300
49,660
70,388
Accepted
Accepted
39.53
from collections import deque n = eval(input()) C = [None]*n P = [None]*n for i in range(n): ipt = list(map(int, input().split())) C[i] = ipt[1:] for c in C[i]: P[c] = i LEV = (n+1).bit_length() parent = [[None]*(LEV + 1) for i in range(n)] for i in range(n): parent[i][0] = P[i] f...
import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline write = sys.stdout.write N = int(readline()) G = [None]*N for v in range(N): k, *G[v] = list(map(int, readline().split())) S = [] FS = [0]*N depth = [0]*N *it, = list(map(iter, G)) P = [-1]*N stk = [0] depth[0] = 0 FS[0...
47
65
1,122
1,258
from collections import deque n = eval(input()) C = [None] * n P = [None] * n for i in range(n): ipt = list(map(int, input().split())) C[i] = ipt[1:] for c in C[i]: P[c] = i LEV = (n + 1).bit_length() parent = [[None] * (LEV + 1) for i in range(n)] for i in range(n): parent[i][0] = P[i] for k i...
import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline write = sys.stdout.write N = int(readline()) G = [None] * N for v in range(N): k, *G[v] = list(map(int, readline().split())) S = [] FS = [0] * N depth = [0] * N (*it,) = list(map(iter, G)) P = [-1] * N stk = [0] depth[0] = 0 FS[0] = 0 while stk:...
false
27.692308
[ "-from collections import deque", "+import sys", "-n = eval(input())", "-C = [None] * n", "-P = [None] * n", "-for i in range(n):", "- ipt = list(map(int, input().split()))", "- C[i] = ipt[1:]", "- for c in C[i]:", "- P[c] = i", "-LEV = (n + 1).bit_length()", "-parent = [[None]...
false
0.042199
0.007318
5.76652
[ "s607379843", "s604336117" ]
u441175813
p02946
python
s750100884
s652217337
65
59
62,304
62,268
Accepted
Accepted
9.23
k, x = map(int, input().split()) ans = [x] for sign in [-1, 1]: for i in range(1, k): ans.append(x + sign*i) ans.sort() for i in range(len(ans)): print(ans[i], end=" ")
k, x = map(int, input().split()) for i in range(x-k+1, x+k): print(i, end=" ")
9
4
193
86
k, x = map(int, input().split()) ans = [x] for sign in [-1, 1]: for i in range(1, k): ans.append(x + sign * i) ans.sort() for i in range(len(ans)): print(ans[i], end=" ")
k, x = map(int, input().split()) for i in range(x - k + 1, x + k): print(i, end=" ")
false
55.555556
[ "-ans = [x]", "-for sign in [-1, 1]:", "- for i in range(1, k):", "- ans.append(x + sign * i)", "-ans.sort()", "-for i in range(len(ans)):", "- print(ans[i], end=\" \")", "+for i in range(x - k + 1, x + k):", "+ print(i, end=\" \")" ]
false
0.035879
0.030961
1.158853
[ "s750100884", "s652217337" ]
u426534722
p02290
python
s710495913
s748480352
30
20
7,984
7,968
Accepted
Accepted
33.33
import sys from itertools import starmap readline = sys.stdin.readline p0, p1 = starmap(complex, list(zip(*[list(map(int, readline().split()))] * 2))) n = int(readline()) def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def norm(base): ...
import sys from itertools import starmap readline = sys.stdin.readline class Segment(object): __slots__ = ('fi', 'se') def __init__(self, fi, se): self.fi = fi self.se = se def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag...
19
24
611
720
import sys from itertools import starmap readline = sys.stdin.readline p0, p1 = starmap(complex, list(zip(*[list(map(int, readline().split()))] * 2))) n = int(readline()) def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def norm(base): ...
import sys from itertools import starmap readline = sys.stdin.readline class Segment(object): __slots__ = ("fi", "se") def __init__(self, fi, se): self.fi = fi self.se = se def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * ...
false
20.833333
[ "-p0, p1 = starmap(complex, list(zip(*[list(map(int, readline().split()))] * 2)))", "-n = int(readline())", "+", "+", "+class Segment(object):", "+ __slots__ = (\"fi\", \"se\")", "+", "+ def __init__(self, fi, se):", "+ self.fi = fi", "+ self.se = se", "- return base.real ...
false
0.045395
0.042439
1.069668
[ "s710495913", "s748480352" ]
u819048695
p03816
python
s193204536
s326280409
101
44
14,396
14,564
Accepted
Accepted
56.44
n=int(eval(input())) a=list(map(int,input().split())) a.sort() k=1 lst=[] for i in range(1,n): if a[i]==a[i-1]: k+=1 else: lst.append(k) k=1 lst.append(k) m=len(lst) count=0 for i in range(m): if lst[i]%2==0: lst[i]=2 count+=1 else: lst[...
n=int(eval(input())) a=list(map(int,input().split())) a=len(set(a)) if a%2==0: print((a-1)) else: print(a)
24
7
371
112
n = int(eval(input())) a = list(map(int, input().split())) a.sort() k = 1 lst = [] for i in range(1, n): if a[i] == a[i - 1]: k += 1 else: lst.append(k) k = 1 lst.append(k) m = len(lst) count = 0 for i in range(m): if lst[i] % 2 == 0: lst[i] = 2 count += 1 else: ...
n = int(eval(input())) a = list(map(int, input().split())) a = len(set(a)) if a % 2 == 0: print((a - 1)) else: print(a)
false
70.833333
[ "-a.sort()", "-k = 1", "-lst = []", "-for i in range(1, n):", "- if a[i] == a[i - 1]:", "- k += 1", "- else:", "- lst.append(k)", "- k = 1", "-lst.append(k)", "-m = len(lst)", "-count = 0", "-for i in range(m):", "- if lst[i] % 2 == 0:", "- lst[i] = 2...
false
0.037292
0.062264
0.59894
[ "s193204536", "s326280409" ]
u225388820
p02913
python
s612001270
s987730676
478
377
270,188
264,852
Accepted
Accepted
21.13
n, s = int(eval(input())), eval(input()) dp = [[0] * (n + 1) for i in range(n + 1)] for i in range(n): for j in range(i + 1, n): if s[i] == s[j]: dp[i + 1][j + 1] = min(dp[i][j] + 1, j - i) from itertools import chain print((max(i for i in chain.from_iterable(dp))))
n, s = int(eval(input())), eval(input()) dp = [[0] * (n + 1) for i in range(n + 1)] for i in range(n): for j in range(i + 1, n): if s[i] == s[j]: dp[i + 1][j + 1] = min(dp[i][j] + 1, j - i) from itertools import chain # max(i for i in chain.from_iterable(dp)) print((max(chain.from_iterab...
8
9
284
316
n, s = int(eval(input())), eval(input()) dp = [[0] * (n + 1) for i in range(n + 1)] for i in range(n): for j in range(i + 1, n): if s[i] == s[j]: dp[i + 1][j + 1] = min(dp[i][j] + 1, j - i) from itertools import chain print((max(i for i in chain.from_iterable(dp))))
n, s = int(eval(input())), eval(input()) dp = [[0] * (n + 1) for i in range(n + 1)] for i in range(n): for j in range(i + 1, n): if s[i] == s[j]: dp[i + 1][j + 1] = min(dp[i][j] + 1, j - i) from itertools import chain # max(i for i in chain.from_iterable(dp)) print((max(chain.from_iterable(dp))...
false
11.111111
[ "-print((max(i for i in chain.from_iterable(dp))))", "+# max(i for i in chain.from_iterable(dp))", "+print((max(chain.from_iterable(dp))))" ]
false
0.04305
0.048387
0.889705
[ "s612001270", "s987730676" ]
u498487134
p02779
python
s553010102
s347914407
286
134
86,100
103,556
Accepted
Accepted
53.15
N=int(eval(input())) A=list(map(int,input().split())) A.sort() flag=1 for i in range(N-1): if A[i+1]==A[i]: flag=0 break if flag==1: print("YES") else: print("NO")
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N=I() A=LI() A.sort() flag=1 for i in range(N-1): if A[i]==A[i+1]: ...
14
24
208
425
N = int(eval(input())) A = list(map(int, input().split())) A.sort() flag = 1 for i in range(N - 1): if A[i + 1] == A[i]: flag = 0 break if flag == 1: print("YES") else: print("NO")
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 N = I() A = LI() A.sort() flag = 1 for i in range(N - 1): if A[i] ==...
false
41.666667
[ "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-A.sort()", "-flag = 1", "-for i in range(N - 1):", "- if A[i + 1] == A[i]:", "- flag = 0", "- break", "-if flag == 1:", "- print(\"YES\")", "-else:", "- print(\"NO\")", "+import sys", "+", "+input...
false
0.045333
0.048327
0.938038
[ "s553010102", "s347914407" ]
u638282348
p03379
python
s725866558
s732805157
1,360
1,131
35,708
35,712
Accepted
Accepted
16.84
import numpy as np N = int(eval(input())) X = np.array(input().split(), dtype=np.int64) argsort = X.argsort() argsort_argsort = argsort.argsort() X_sorted = X[argsort] m1, m2 = N // 2 - 1, N // 2 for idx in argsort_argsort: if idx <= m1: print((X_sorted[m2])) else: print((X_sorted[m1]...
import numpy as np N = int(eval(input())) X = np.array(input().split(), dtype=np.int64) argsort = X.argsort() argsort_argsort = argsort.argsort() X_sorted = X[argsort] m1, m2 = N // 2 - 1, N // 2 print(("\n".join(str(X_sorted[m2]) if idx <= m1 else str(X_sorted[m1]) for idx in argsort_argsort)))
12
8
313
296
import numpy as np N = int(eval(input())) X = np.array(input().split(), dtype=np.int64) argsort = X.argsort() argsort_argsort = argsort.argsort() X_sorted = X[argsort] m1, m2 = N // 2 - 1, N // 2 for idx in argsort_argsort: if idx <= m1: print((X_sorted[m2])) else: print((X_sorted[m1]))
import numpy as np N = int(eval(input())) X = np.array(input().split(), dtype=np.int64) argsort = X.argsort() argsort_argsort = argsort.argsort() X_sorted = X[argsort] m1, m2 = N // 2 - 1, N // 2 print( ( "\n".join( str(X_sorted[m2]) if idx <= m1 else str(X_sorted[m1]) for idx in ar...
false
33.333333
[ "-for idx in argsort_argsort:", "- if idx <= m1:", "- print((X_sorted[m2]))", "- else:", "- print((X_sorted[m1]))", "+print(", "+ (", "+ \"\\n\".join(", "+ str(X_sorted[m2]) if idx <= m1 else str(X_sorted[m1])", "+ for idx in argsort_argsort", ...
false
0.18345
0.229963
0.797736
[ "s725866558", "s732805157" ]
u796942881
p02923
python
s533899294
s527866147
63
54
14,092
14,092
Accepted
Accepted
14.29
def main(): H = [int(i) for i in open(0).read().split()[1:]] ans = 0 tmp = 0 for h1, h2 in zip(H[:-1], H[1:]): if h1 >= h2: tmp += 1 else: ans = max(ans, tmp) tmp = 0 ans = max(ans, tmp) print(ans) return main()
def main(): H = [int(i) for i in open(0).read().split()[1:]] ans = 0 tmp = 0 for h1, h2 in zip(H[:-1], H[1:]): if h1 >= h2: tmp += 1 else: if ans < tmp: ans = tmp tmp = 0 if ans < tmp: ans = tmp print(ans) ...
16
18
309
343
def main(): H = [int(i) for i in open(0).read().split()[1:]] ans = 0 tmp = 0 for h1, h2 in zip(H[:-1], H[1:]): if h1 >= h2: tmp += 1 else: ans = max(ans, tmp) tmp = 0 ans = max(ans, tmp) print(ans) return main()
def main(): H = [int(i) for i in open(0).read().split()[1:]] ans = 0 tmp = 0 for h1, h2 in zip(H[:-1], H[1:]): if h1 >= h2: tmp += 1 else: if ans < tmp: ans = tmp tmp = 0 if ans < tmp: ans = tmp print(ans) return m...
false
11.111111
[ "- ans = max(ans, tmp)", "+ if ans < tmp:", "+ ans = tmp", "- ans = max(ans, tmp)", "+ if ans < tmp:", "+ ans = tmp" ]
false
0.114895
0.066326
1.732277
[ "s533899294", "s527866147" ]
u020390084
p03013
python
s747419278
s057682473
520
217
460,020
7,848
Accepted
Accepted
58.27
n, m = list(map(int,input().split())) a = [int(eval(input())) for i in range(m)] dp = [float("inf")] * (n+1) dp[0] = 1 dp[1] = 1 for i in a: dp[i] = 0 for i in range(2, n+1): dp[i] = min(dp[i], (dp[i-1] + dp[i-2])) print((dp[n] % 1000000007))
n, m = list(map(int,input().split())) a = [int(eval(input())) for i in range(m)] dp = [float("inf")] * (n+1) dp[0] = 1 dp[1] = 1 for i in a: dp[i] = 0 for i in range(2, n+1): dp[i] = min(dp[i], (dp[i-1] + dp[i-2])%(10**9+7)) print((dp[n]))
10
10
245
243
n, m = list(map(int, input().split())) a = [int(eval(input())) for i in range(m)] dp = [float("inf")] * (n + 1) dp[0] = 1 dp[1] = 1 for i in a: dp[i] = 0 for i in range(2, n + 1): dp[i] = min(dp[i], (dp[i - 1] + dp[i - 2])) print((dp[n] % 1000000007))
n, m = list(map(int, input().split())) a = [int(eval(input())) for i in range(m)] dp = [float("inf")] * (n + 1) dp[0] = 1 dp[1] = 1 for i in a: dp[i] = 0 for i in range(2, n + 1): dp[i] = min(dp[i], (dp[i - 1] + dp[i - 2]) % (10**9 + 7)) print((dp[n]))
false
0
[ "- dp[i] = min(dp[i], (dp[i - 1] + dp[i - 2]))", "-print((dp[n] % 1000000007))", "+ dp[i] = min(dp[i], (dp[i - 1] + dp[i - 2]) % (10**9 + 7))", "+print((dp[n]))" ]
false
0.221812
0.043577
5.090131
[ "s747419278", "s057682473" ]
u701644092
p03212
python
s921570589
s148735269
58
51
3,064
9,176
Accepted
Accepted
12.07
import sys sys.setrecursionlimit(10 ** 5) N = int(eval(input())) def check(p): return ("3" in p and "5" in p and "7" in p) cnt = 0 def dfs(n): if int(n) > N: return global cnt if check(n): cnt += 1 for c in ("3","5","7"): dfs(n + c) dfs("0") print(cnt)
N = eval(input()) digit = len(N) N = int(N) import itertools ans = 0 for i in range(1, digit + 1): for prod in itertools.product(("3","5","7"), repeat = i): if int("".join(prod)) <= N and len(set(prod)) == 3: ans += 1 print(ans)
20
14
293
251
import sys sys.setrecursionlimit(10**5) N = int(eval(input())) def check(p): return "3" in p and "5" in p and "7" in p cnt = 0 def dfs(n): if int(n) > N: return global cnt if check(n): cnt += 1 for c in ("3", "5", "7"): dfs(n + c) dfs("0") print(cnt)
N = eval(input()) digit = len(N) N = int(N) import itertools ans = 0 for i in range(1, digit + 1): for prod in itertools.product(("3", "5", "7"), repeat=i): if int("".join(prod)) <= N and len(set(prod)) == 3: ans += 1 print(ans)
false
30
[ "-import sys", "+N = eval(input())", "+digit = len(N)", "+N = int(N)", "+import itertools", "-sys.setrecursionlimit(10**5)", "-N = int(eval(input()))", "-", "-", "-def check(p):", "- return \"3\" in p and \"5\" in p and \"7\" in p", "-", "-", "-cnt = 0", "-", "-", "-def dfs(n):", ...
false
0.05205
0.042292
1.230719
[ "s921570589", "s148735269" ]
u391731808
p03959
python
s409781473
s889358327
227
163
18,756
18,624
Accepted
Accepted
28.19
N=int(eval(input())) *T, = list(map(int,input().split())) *A, = list(map(int,input().split())) mod = 10**9+7 mT = [T[0]]*N MT = [T[0]]*N for i,t in enumerate(T[1:],1): if t>T[i-1]: mT[i] = t MT[i] = t else: mT[i] = 1 MT[i] = t mA = [A[-1]]*N MA = [A[-1]]*N for i,...
N=int(eval(input())) *T, = [0] + list(map(int,input().split())) + [0] *A, = [0] + list(map(int,input().split())) + [0] mod = 10**9+7 M = list(map(min,list(zip(A,T))))[1:-1] m = [max(T[i] if T[i]>T[i-1] else 1, A[i] if A[i]>A[i+1] else 1) for i in range(1,N+1)] ans = 1 for a,b in zip(m,M): ans = ans * max(0,b-a+1...
30
9
600
327
N = int(eval(input())) (*T,) = list(map(int, input().split())) (*A,) = list(map(int, input().split())) mod = 10**9 + 7 mT = [T[0]] * N MT = [T[0]] * N for i, t in enumerate(T[1:], 1): if t > T[i - 1]: mT[i] = t MT[i] = t else: mT[i] = 1 MT[i] = t mA = [A[-1]] * N MA = [A[-1]] * N...
N = int(eval(input())) (*T,) = [0] + list(map(int, input().split())) + [0] (*A,) = [0] + list(map(int, input().split())) + [0] mod = 10**9 + 7 M = list(map(min, list(zip(A, T))))[1:-1] m = [ max(T[i] if T[i] > T[i - 1] else 1, A[i] if A[i] > A[i + 1] else 1) for i in range(1, N + 1) ] ans = 1 for a, b in zip(m,...
false
70
[ "-(*T,) = list(map(int, input().split()))", "-(*A,) = list(map(int, input().split()))", "+(*T,) = [0] + list(map(int, input().split())) + [0]", "+(*A,) = [0] + list(map(int, input().split())) + [0]", "-mT = [T[0]] * N", "-MT = [T[0]] * N", "-for i, t in enumerate(T[1:], 1):", "- if t > T[i - 1]:", ...
false
0.086558
0.048427
1.78741
[ "s409781473", "s889358327" ]
u273345915
p02689
python
s933323805
s970014286
298
258
31,856
20,152
Accepted
Accepted
13.42
N,M=list(map(int,input().split())) H=list(map(int,input().split())) HL=[1]*N ML=[list(map(int, input().split())) for _ in range(M)] for m in ML: a=m[0] b=m[1] ah=H[a-1] bh=H[b-1] if ah > bh: HL[b-1]=0 elif bh > ah: HL[a-1]=0 else: HL[a-1]=0 HL[b...
N,M=list(map(int,input().split())) H=list(map(int,input().split())) OK=[True]*N for m in range(M): a,b=list(map(int, input().split())) if H[a-1] <= H[b-1]: OK[a-1] = False if H[b-1] <= H[a-1]: OK[b-1] = False print((OK.count(True)))
17
8
339
237
N, M = list(map(int, input().split())) H = list(map(int, input().split())) HL = [1] * N ML = [list(map(int, input().split())) for _ in range(M)] for m in ML: a = m[0] b = m[1] ah = H[a - 1] bh = H[b - 1] if ah > bh: HL[b - 1] = 0 elif bh > ah: HL[a - 1] = 0 else: HL[a...
N, M = list(map(int, input().split())) H = list(map(int, input().split())) OK = [True] * N for m in range(M): a, b = list(map(int, input().split())) if H[a - 1] <= H[b - 1]: OK[a - 1] = False if H[b - 1] <= H[a - 1]: OK[b - 1] = False print((OK.count(True)))
false
52.941176
[ "-HL = [1] * N", "-ML = [list(map(int, input().split())) for _ in range(M)]", "-for m in ML:", "- a = m[0]", "- b = m[1]", "- ah = H[a - 1]", "- bh = H[b - 1]", "- if ah > bh:", "- HL[b - 1] = 0", "- elif bh > ah:", "- HL[a - 1] = 0", "- else:", "- H...
false
0.045417
0.045148
1.005958
[ "s933323805", "s970014286" ]
u185424824
p03627
python
s724159412
s642896231
190
98
21,412
14,672
Accepted
Accepted
48.42
import collections s = set() N = int(eval(input())) count = []*(10**9+1) ma1 = 0 ma2 = 0 A = list(map(int,input().split())) a = collections.Counter(A) b = sorted(list(a.items()),reverse = True) for i in b: if ma1 == 0 and i[1] > 1: ma1 = i[0] if i[1] > 3: ma2 = i[0] elif ma1 != 0 and i...
N = int(eval(input())) ma1 = 0 ma2 = 0 A = list(map(int,input().split())) A.append(0) a = sorted(A,reverse = True) hold = 0 count = 0 for i in a: if i == hold: count += 1 else: if count > 3 and ma1 == 0: ma1 = hold ma2 = hold elif count > 1: if ma1 == 0: ma...
22
30
396
468
import collections s = set() N = int(eval(input())) count = [] * (10**9 + 1) ma1 = 0 ma2 = 0 A = list(map(int, input().split())) a = collections.Counter(A) b = sorted(list(a.items()), reverse=True) for i in b: if ma1 == 0 and i[1] > 1: ma1 = i[0] if i[1] > 3: ma2 = i[0] elif ma1 != ...
N = int(eval(input())) ma1 = 0 ma2 = 0 A = list(map(int, input().split())) A.append(0) a = sorted(A, reverse=True) hold = 0 count = 0 for i in a: if i == hold: count += 1 else: if count > 3 and ma1 == 0: ma1 = hold ma2 = hold elif count > 1: if ma1 == ...
false
26.666667
[ "-import collections", "-", "-s = set()", "-count = [] * (10**9 + 1)", "-a = collections.Counter(A)", "-b = sorted(list(a.items()), reverse=True)", "-for i in b:", "- if ma1 == 0 and i[1] > 1:", "- ma1 = i[0]", "- if i[1] > 3:", "- ma2 = i[0]", "- elif ma1 != 0 a...
false
0.043708
0.081308
0.537558
[ "s724159412", "s642896231" ]
u347640436
p03806
python
s786606956
s691346894
1,233
1,065
59,472
4,844
Accepted
Accepted
13.63
nmax, abmax, inf = 40, 10, 1000000 dp = [[[inf] * (nmax * abmax + 1) for _ in range(nmax * abmax + 1)] for _ in range(nmax + 1)] n, ma, mb = list(map(int, input().split())) dp[0][0][0] = 0 for i in range(n): a, b, c = list(map(int, input().split())) dpi = dp[i] dpi1 = dp[i + 1] for ca in range(0...
INF = float('inf') n, ma, mb = list(map(int, input().split())) t = [[INF] * 401 for _ in range(401)] t[0][0] = 0 for _ in range(n): a, b, c = list(map(int, input().split())) for aa in range(400, -1, -1): for bb in range(400, -1, -1): if t[aa][bb] == INF: continue if t[a + aa][b + b...
30
20
707
565
nmax, abmax, inf = 40, 10, 1000000 dp = [ [[inf] * (nmax * abmax + 1) for _ in range(nmax * abmax + 1)] for _ in range(nmax + 1) ] n, ma, mb = list(map(int, input().split())) dp[0][0][0] = 0 for i in range(n): a, b, c = list(map(int, input().split())) dpi = dp[i] dpi1 = dp[i + 1] for ca in range...
INF = float("inf") n, ma, mb = list(map(int, input().split())) t = [[INF] * 401 for _ in range(401)] t[0][0] = 0 for _ in range(n): a, b, c = list(map(int, input().split())) for aa in range(400, -1, -1): for bb in range(400, -1, -1): if t[aa][bb] == INF: continue ...
false
33.333333
[ "-nmax, abmax, inf = 40, 10, 1000000", "-dp = [", "- [[inf] * (nmax * abmax + 1) for _ in range(nmax * abmax + 1)]", "- for _ in range(nmax + 1)", "-]", "+INF = float(\"inf\")", "-dp[0][0][0] = 0", "-for i in range(n):", "+t = [[INF] * 401 for _ in range(401)]", "+t[0][0] = 0", "+for _ in ...
false
0.378789
0.151921
2.493325
[ "s786606956", "s691346894" ]
u489959379
p03282
python
s261029076
s054761114
183
17
38,384
3,064
Accepted
Accepted
90.71
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): s = eval(input()) k = int(eval(input())) for i in range(k): if s[i] != "1": res = s[i] break else: print((1)) exit() print(res) ...
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): s = eval(input()) k = int(eval(input())) if k >= len(s): for i in range(len(s)): if s[i] != "1": print((s[i])) break else: ...
24
28
349
521
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): s = eval(input()) k = int(eval(input())) for i in range(k): if s[i] != "1": res = s[i] break else: print((1)) exit() print(res) if __name__ == "__main__": ...
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): s = eval(input()) k = int(eval(input())) if k >= len(s): for i in range(len(s)): if s[i] != "1": print((s[i])) break else: print((1)) els...
false
14.285714
[ "- for i in range(k):", "- if s[i] != \"1\":", "- res = s[i]", "- break", "+ if k >= len(s):", "+ for i in range(len(s)):", "+ if s[i] != \"1\":", "+ print((s[i]))", "+ break", "+ else:", "+ prin...
false
0.035795
0.058915
0.607572
[ "s261029076", "s054761114" ]
u488401358
p02649
python
s238936379
s231020544
2,153
688
70,856
76,468
Accepted
Accepted
68.04
def cmb(n, r, mod):#コンビネーションの高速計算  if ( r<0 or r>n ): return 0 r = min(r, n-r) return (g1[n] * g2[r] * g2[n-r])%mod mod = 10**18+7 #出力の制限 N = 50 g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) ...
def popcount(x): x = x - ((x >> 1) & 0x55555555) x = (x & 0x33333333) + ((x >> 2) & 0x33333333) x = (x + (x >> 4)) & 0x0f0f0f0f x = x + (x >> 8) x = x + (x >> 16) return x & 0x0000007f cmb=[[0 for i in range(51)] for j in range(51)] cmb[0][0]=1 for i in range(51): for j in range(...
67
68
1,437
1,445
def cmb(n, r, mod): # コンビネーションの高速計算 if r < 0 or r > n: return 0 r = min(r, n - r) return (g1[n] * g2[r] * g2[n - r]) % mod mod = 10**18 + 7 # 出力の制限 N = 50 g1 = [1, 1] # 元テーブル g2 = [1, 1] # 逆元テーブル inverse = [0, 1] # 逆元テーブル計算用テーブル for i in range(2, N + 1): g1.append((g1[-1] * i) % mod) ...
def popcount(x): x = x - ((x >> 1) & 0x55555555) x = (x & 0x33333333) + ((x >> 2) & 0x33333333) x = (x + (x >> 4)) & 0x0F0F0F0F x = x + (x >> 8) x = x + (x >> 16) return x & 0x0000007F cmb = [[0 for i in range(51)] for j in range(51)] cmb[0][0] = 1 for i in range(51): for j in range(51): ...
false
1.470588
[ "-def cmb(n, r, mod): # コンビネーションの高速計算", "- if r < 0 or r > n:", "- return 0", "- r = min(r, n - r)", "- return (g1[n] * g2[r] * g2[n - r]) % mod", "+def popcount(x):", "+ x = x - ((x >> 1) & 0x55555555)", "+ x = (x & 0x33333333) + ((x >> 2) & 0x33333333)", "+ x = (x + (x >>...
false
0.039175
0.042122
0.930044
[ "s238936379", "s231020544" ]
u969850098
p03816
python
s886242225
s771170858
68
60
18,648
18,656
Accepted
Accepted
11.76
import sys readline = sys.stdin.readline from collections import Counter def main(): N = int(readline()) A = list(map(int, readline().rstrip().split())) c = Counter(A) for key, val in list(c.items()): if val > 2: if val % 2 == 0: c[key] = 2 el...
import sys readline = sys.stdin.readline from collections import Counter def main(): N = int(readline()) A = list(map(int, readline().rstrip().split())) c = Counter(A) cnt = 0 for key, val in list(c.items()): if val > 2: if val % 2 == 0: c[key] = 2 ...
23
27
526
563
import sys readline = sys.stdin.readline from collections import Counter def main(): N = int(readline()) A = list(map(int, readline().rstrip().split())) c = Counter(A) for key, val in list(c.items()): if val > 2: if val % 2 == 0: c[key] = 2 else: ...
import sys readline = sys.stdin.readline from collections import Counter def main(): N = int(readline()) A = list(map(int, readline().rstrip().split())) c = Counter(A) cnt = 0 for key, val in list(c.items()): if val > 2: if val % 2 == 0: c[key] = 2 ...
false
14.814815
[ "+ cnt = 0", "+ cnt += 1", "- if len([val for key, val in list(c.items()) if c[key] == 2]) % 2 == 0:", "+ elif val == 2:", "+ cnt += 1", "+ if cnt % 2 == 0:" ]
false
0.233845
0.090986
2.570109
[ "s886242225", "s771170858" ]
u923279197
p03059
python
s096117297
s191119563
173
17
38,384
2,940
Accepted
Accepted
90.17
a,b,t = list(map(int,input().split())) print((b*(t//a)))
a,b,t = list(map(int,input().split())) ans = t//a*b print(ans)
2
4
49
60
a, b, t = list(map(int, input().split())) print((b * (t // a)))
a, b, t = list(map(int, input().split())) ans = t // a * b print(ans)
false
50
[ "-print((b * (t // a)))", "+ans = t // a * b", "+print(ans)" ]
false
0.099543
0.033127
3.004851
[ "s096117297", "s191119563" ]
u401452016
p02780
python
s160866879
s492729303
217
134
25,632
24,404
Accepted
Accepted
38.25
#ABC154D import sys N, K = list(map(int, sys.stdin.readline().split())) P = list(map(int, sys.stdin.readline().split())) #print(P) #期待値L L = [0 for _ in range(N)] for i in range(N): L[i] = (1+P[i])/2 #print(L) #累積和S S = [0 for i in range(N)] S[0] = L[0] for i in range(1, N): S[i] = S[i-1] + ...
#ABC154D def main(): import sys N, K = list(map(int, sys.stdin.readline().split())) P = list(map(int, sys.stdin.readline().split())) L =[0 for _ in range(N)] #期待値 (初項+末項)/2 for i in range(N): L[i]=(1 +P[i])/2 #print(L) #累積和 for i in range(N-1): L[i+1] +=L[...
27
23
450
498
# ABC154D import sys N, K = list(map(int, sys.stdin.readline().split())) P = list(map(int, sys.stdin.readline().split())) # print(P) # 期待値L L = [0 for _ in range(N)] for i in range(N): L[i] = (1 + P[i]) / 2 # print(L) # 累積和S S = [0 for i in range(N)] S[0] = L[0] for i in range(1, N): S[i] = S[i - 1] + L[i] # p...
# ABC154D def main(): import sys N, K = list(map(int, sys.stdin.readline().split())) P = list(map(int, sys.stdin.readline().split())) L = [0 for _ in range(N)] # 期待値 (初項+末項)/2 for i in range(N): L[i] = (1 + P[i]) / 2 # print(L) # 累積和 for i in range(N - 1): L[i + 1] +...
false
14.814815
[ "-import sys", "+def main():", "+ import sys", "-N, K = list(map(int, sys.stdin.readline().split()))", "-P = list(map(int, sys.stdin.readline().split()))", "-# print(P)", "-# 期待値L", "-L = [0 for _ in range(N)]", "-for i in range(N):", "- L[i] = (1 + P[i]) / 2", "-# print(L)", "-# 累積和S", ...
false
0.036721
0.067176
0.546642
[ "s160866879", "s492729303" ]
u416011173
p03752
python
s318161173
s474306261
54
36
9,196
9,240
Accepted
Accepted
33.33
# -*- coding: utf-8 -*- # モジュールのインポート import sys import itertools # 標準入力を取得 N, K = list(map(int, input().split())) a = list(map(int, input().split())) # 求解処理 ans = sys.maxsize for buildings in itertools.combinations(list(range(N)), K): cost = 0 highest = a[0] - 1 for n in range(N): ...
# -*- coding: utf-8 -*- # モジュールのインポート import sys import itertools def get_input() -> tuple: """ 標準入力を取得する. Returns:\n tuple: 標準入力 """ N, K = list(map(int, input().split())) a = list(map(int, input().split())) return N, K, a def main(N: int, K: int, a: list) -...
25
52
539
1,033
# -*- coding: utf-8 -*- # モジュールのインポート import sys import itertools # 標準入力を取得 N, K = list(map(int, input().split())) a = list(map(int, input().split())) # 求解処理 ans = sys.maxsize for buildings in itertools.combinations(list(range(N)), K): cost = 0 highest = a[0] - 1 for n in range(N): a_n = a[n] ...
# -*- coding: utf-8 -*- # モジュールのインポート import sys import itertools def get_input() -> tuple: """ 標準入力を取得する. Returns:\n tuple: 標準入力 """ N, K = list(map(int, input().split())) a = list(map(int, input().split())) return N, K, a def main(N: int, K: int, a: list) -> None: """ メ...
false
51.923077
[ "-# 標準入力を取得", "-N, K = list(map(int, input().split()))", "-a = list(map(int, input().split()))", "-# 求解処理", "-ans = sys.maxsize", "-for buildings in itertools.combinations(list(range(N)), K):", "- cost = 0", "- highest = a[0] - 1", "- for n in range(N):", "- a_n = a[n]", "- ...
false
0.045318
0.046903
0.966203
[ "s318161173", "s474306261" ]
u144980750
p02975
python
s032395276
s710394870
79
65
14,212
14,116
Accepted
Accepted
17.72
n=int(eval(input())) a=[int(i) for i in input().split()] a.sort() ans=a[0] for i in range(1,n): ans=ans^a[i] if ans==0: print("Yes") else: print("No")
n=int(eval(input())) A=[int(i) for i in input().split()] A.sort() if n%3==0: n=int(n/3) if A[0]==A[n-1] and A[n]==A[2*n-1] and A[2*n]==A[3*n-1] and A[0]^A[n]^A[2*n]==0: ans=1 else: ans=0 else: if(A[n-1]==0): ans=1 else: ans=0 print(("Yes" if ans==1 else ...
10
15
165
319
n = int(eval(input())) a = [int(i) for i in input().split()] a.sort() ans = a[0] for i in range(1, n): ans = ans ^ a[i] if ans == 0: print("Yes") else: print("No")
n = int(eval(input())) A = [int(i) for i in input().split()] A.sort() if n % 3 == 0: n = int(n / 3) if ( A[0] == A[n - 1] and A[n] == A[2 * n - 1] and A[2 * n] == A[3 * n - 1] and A[0] ^ A[n] ^ A[2 * n] == 0 ): ans = 1 else: ans = 0 else: if A[n - 1] =...
false
33.333333
[ "-a = [int(i) for i in input().split()]", "-a.sort()", "-ans = a[0]", "-for i in range(1, n):", "- ans = ans ^ a[i]", "-if ans == 0:", "- print(\"Yes\")", "+A = [int(i) for i in input().split()]", "+A.sort()", "+if n % 3 == 0:", "+ n = int(n / 3)", "+ if (", "+ A[0] == A[n...
false
0.039247
0.039974
0.981792
[ "s032395276", "s710394870" ]
u441175813
p02754
python
s290219583
s639339359
72
66
61,276
61,544
Accepted
Accepted
8.33
n, a, b = list(map(int, input().split())) ans = n//(a+b) * a n %= (a+b) if n >= a: print((ans + a)) else: print((ans + n))
n, a, b = list(map(int, input().split())) ans = n//(a+b) * a n %= (a+b) print((ans + min([a, n])))
8
5
128
95
n, a, b = list(map(int, input().split())) ans = n // (a + b) * a n %= a + b if n >= a: print((ans + a)) else: print((ans + n))
n, a, b = list(map(int, input().split())) ans = n // (a + b) * a n %= a + b print((ans + min([a, n])))
false
37.5
[ "-if n >= a:", "- print((ans + a))", "-else:", "- print((ans + n))", "+print((ans + min([a, n])))" ]
false
0.042738
0.04869
0.877755
[ "s290219583", "s639339359" ]
u681444474
p03475
python
s085941058
s795077738
137
98
3,188
9,104
Accepted
Accepted
28.47
# coding: utf-8 import math N = int(eval(input())) sta_info = [] for i in range(N-1): l = list(map(int,input().split())) sta_info.append(l) for i in range(N-1): start = i t = 0 ans = 0 for j in range(i,N-1): c, s, f = sta_info[j][0], sta_info[j][1], sta_info[j][2] ...
#coding: utf-8 import math N = int(eval(input())) L = [] for i in range(N-1): l = list(map(int,input().split())) L.append(l) for i in range(N-1): t = 0 for j in range(i,N-1): l = L[j] c = l[0] s = l[1] f = l[2] if t <= s: t = s+c ...
26
23
574
410
# coding: utf-8 import math N = int(eval(input())) sta_info = [] for i in range(N - 1): l = list(map(int, input().split())) sta_info.append(l) for i in range(N - 1): start = i t = 0 ans = 0 for j in range(i, N - 1): c, s, f = sta_info[j][0], sta_info[j][1], sta_info[j][2] # prin...
# coding: utf-8 import math N = int(eval(input())) L = [] for i in range(N - 1): l = list(map(int, input().split())) L.append(l) for i in range(N - 1): t = 0 for j in range(i, N - 1): l = L[j] c = l[0] s = l[1] f = l[2] if t <= s: t = s + c el...
false
11.538462
[ "-sta_info = []", "+L = []", "- sta_info.append(l)", "+ L.append(l)", "- start = i", "- ans = 0", "- c, s, f = sta_info[j][0], sta_info[j][1], sta_info[j][2]", "- # print('到着時 ' + str(t))", "+ l = L[j]", "+ c = l[0]", "+ s = l[1]", "+ f = l...
false
0.081035
0.063469
1.276748
[ "s085941058", "s795077738" ]
u254871849
p03495
python
s947537872
s287756503
176
99
40,336
33,556
Accepted
Accepted
43.75
import sys from collections import Counter n, k, *a = list(map(int, sys.stdin.read().split())) def main(): c = Counter(a) l = len(c) if l <= k: return 0 c = sorted(list(c.items()), key=lambda x: x[1]) res = 0 for i in range(l - k): res += c[i][1] return re...
import sys from collections import Counter n, k, *a = list(map(int, sys.stdin.read().split())) def main(): c = Counter(a) res = sum(sorted(c.values())[:-k]) print(res) if __name__ == '__main__': main()
21
12
373
226
import sys from collections import Counter n, k, *a = list(map(int, sys.stdin.read().split())) def main(): c = Counter(a) l = len(c) if l <= k: return 0 c = sorted(list(c.items()), key=lambda x: x[1]) res = 0 for i in range(l - k): res += c[i][1] return res if __name__ =...
import sys from collections import Counter n, k, *a = list(map(int, sys.stdin.read().split())) def main(): c = Counter(a) res = sum(sorted(c.values())[:-k]) print(res) if __name__ == "__main__": main()
false
42.857143
[ "- l = len(c)", "- if l <= k:", "- return 0", "- c = sorted(list(c.items()), key=lambda x: x[1])", "- res = 0", "- for i in range(l - k):", "- res += c[i][1]", "- return res", "+ res = sum(sorted(c.values())[:-k])", "+ print(res)", "- ans = main()", "- ...
false
0.045082
0.045639
0.987808
[ "s947537872", "s287756503" ]
u425317134
p02678
python
s654898240
s571237805
704
537
36,864
36,916
Accepted
Accepted
23.72
from collections import deque def main(): n,m = list(map(int,input().split())) ab = [[] for i in range(n)] for _ in range(m): a,b = list(map(int,input().split())) ab[a-1].append(b-1) ab[b-1].append(a-1) q = deque() q.append(0) ans = [-1] * n ans[0] = 0 ...
from collections import deque def main(): n,m = list(map(int,input().split())) arr = [[] for i in range(n)] for _ in range(m): a,b = list(map(int,input().split())) arr[a-1].append(b-1) arr[b-1].append(a-1) q = deque() q.append(0) ans = [-1] * n ans[0] = 0...
29
29
646
624
from collections import deque def main(): n, m = list(map(int, input().split())) ab = [[] for i in range(n)] for _ in range(m): a, b = list(map(int, input().split())) ab[a - 1].append(b - 1) ab[b - 1].append(a - 1) q = deque() q.append(0) ans = [-1] * n ans[0] = 0 ...
from collections import deque def main(): n, m = list(map(int, input().split())) arr = [[] for i in range(n)] for _ in range(m): a, b = list(map(int, input().split())) arr[a - 1].append(b - 1) arr[b - 1].append(a - 1) q = deque() q.append(0) ans = [-1] * n ans[0] = ...
false
0
[ "- ab = [[] for i in range(n)]", "+ arr = [[] for i in range(n)]", "- ab[a - 1].append(b - 1)", "- ab[b - 1].append(a - 1)", "+ arr[a - 1].append(b - 1)", "+ arr[b - 1].append(a - 1)", "- for i, next in enumerate(ab[now]):", "- if ans[next] == -1:", ...
false
0.04157
0.041111
1.011167
[ "s654898240", "s571237805" ]
u840310460
p03644
python
s989779807
s134950649
172
17
38,384
2,940
Accepted
Accepted
90.12
n = int(eval(input())) list_n = [2 ** i for i in range(1, 8)] bag =[1] for i in list_n: if n >= i: bag.append(i) print((max(bag)))
N = int(eval(input())) x=1 cou=0 while x <= N: x *= 2 cou += 1 print((2**(cou-1)))
7
8
140
94
n = int(eval(input())) list_n = [2**i for i in range(1, 8)] bag = [1] for i in list_n: if n >= i: bag.append(i) print((max(bag)))
N = int(eval(input())) x = 1 cou = 0 while x <= N: x *= 2 cou += 1 print((2 ** (cou - 1)))
false
12.5
[ "-n = int(eval(input()))", "-list_n = [2**i for i in range(1, 8)]", "-bag = [1]", "-for i in list_n:", "- if n >= i:", "- bag.append(i)", "-print((max(bag)))", "+N = int(eval(input()))", "+x = 1", "+cou = 0", "+while x <= N:", "+ x *= 2", "+ cou += 1", "+print((2 ** (cou - ...
false
0.040285
0.04027
1.000389
[ "s989779807", "s134950649" ]
u571969099
p02983
python
s597163153
s067629693
805
221
3,060
40,812
Accepted
Accepted
72.55
l,r=[int(i) for i in input().split()] l2,r2=l%2019,r%2019 if l//2019<r//2019: print((0)) else: k=2019*2019 for i in range(l,r): for j in range(i+1,r+1): k=min(k,i*j%2019) print(k)
l, r = [int(i) for i in input().split()] if r - l > 2019: print((0)) else: ans = 10 ** 9 for i in range(l, r + 1): for j in range(i + 1, r + 1): ans = min(ans, i * j % 2019) print(ans)
10
9
204
227
l, r = [int(i) for i in input().split()] l2, r2 = l % 2019, r % 2019 if l // 2019 < r // 2019: print((0)) else: k = 2019 * 2019 for i in range(l, r): for j in range(i + 1, r + 1): k = min(k, i * j % 2019) print(k)
l, r = [int(i) for i in input().split()] if r - l > 2019: print((0)) else: ans = 10**9 for i in range(l, r + 1): for j in range(i + 1, r + 1): ans = min(ans, i * j % 2019) print(ans)
false
10
[ "-l2, r2 = l % 2019, r % 2019", "-if l // 2019 < r // 2019:", "+if r - l > 2019:", "- k = 2019 * 2019", "- for i in range(l, r):", "+ ans = 10**9", "+ for i in range(l, r + 1):", "- k = min(k, i * j % 2019)", "- print(k)", "+ ans = min(ans, i * j % 2019)", "+...
false
0.038116
0.041423
0.920151
[ "s597163153", "s067629693" ]
u858748695
p02939
python
s893156520
s908329396
1,552
1,192
90,092
36,392
Accepted
Accepted
23.2
#!/usr/bin/env python3 s = eval(input()) n = len(s) dp = {} dp[(0, 1)] = 1 dp[(0, 2)] = 1 dp[(1, 2)] = dp[(0, 1)] + (s[0] != s[1]) dp[(1, 3)] = dp[(0, 1)] + 1 for i in range(2, n): for j in [1, 2]: dp[(i, i + j)] = 0 for k in [1, 2]: now = s[i - k:i] nxt = s[i:i ...
#!/usr/bin/env python3 s = eval(input()) n = len(s) dp = [[0] * 2 for _ in range(n)] dp[0][0] = 1 dp[0][1] = 1 dp[1][0] = dp[0][1] + (s[0] != s[1]) dp[1][1] = dp[0][1] + 1 for i in range(2, n): for j in range(2): for k in range(2): now = s[i - k - 1:i] nxt = s[i:i + j + 1...
16
15
423
410
#!/usr/bin/env python3 s = eval(input()) n = len(s) dp = {} dp[(0, 1)] = 1 dp[(0, 2)] = 1 dp[(1, 2)] = dp[(0, 1)] + (s[0] != s[1]) dp[(1, 3)] = dp[(0, 1)] + 1 for i in range(2, n): for j in [1, 2]: dp[(i, i + j)] = 0 for k in [1, 2]: now = s[i - k : i] nxt = s[i : i + j] ...
#!/usr/bin/env python3 s = eval(input()) n = len(s) dp = [[0] * 2 for _ in range(n)] dp[0][0] = 1 dp[0][1] = 1 dp[1][0] = dp[0][1] + (s[0] != s[1]) dp[1][1] = dp[0][1] + 1 for i in range(2, n): for j in range(2): for k in range(2): now = s[i - k - 1 : i] nxt = s[i : i + j + 1] ...
false
6.25
[ "-dp = {}", "-dp[(0, 1)] = 1", "-dp[(0, 2)] = 1", "-dp[(1, 2)] = dp[(0, 1)] + (s[0] != s[1])", "-dp[(1, 3)] = dp[(0, 1)] + 1", "+dp = [[0] * 2 for _ in range(n)]", "+dp[0][0] = 1", "+dp[0][1] = 1", "+dp[1][0] = dp[0][1] + (s[0] != s[1])", "+dp[1][1] = dp[0][1] + 1", "- for j in [1, 2]:", "-...
false
0.043136
0.04401
0.980149
[ "s893156520", "s908329396" ]
u820839927
p03038
python
s720406818
s386757204
881
546
87,380
32,952
Accepted
Accepted
38.02
import os, sys, re, math, heapq N, M = [int(s) for s in input().split(' ')] dic = {} cards = [int(s) for s in input().split(' ')] for c in cards: if c in dic: dic[c] += 1 else: dic[c] = 1 for i in range(M): b,c = [int(s) for s in input().split(' ')] if c in dic: ...
import os, sys, re, math, queue N,M = list(map(int,input().split(' '))) A = list(map(int,input().split(' '))) memo = {} for a in A: if a in memo: memo[a] += 1 else: memo[a] = 1 for _ in range(M): B,C = list(map(int,input().split(' '))) if C in memo: memo[C] += B else: memo[C] = B ret...
29
35
537
549
import os, sys, re, math, heapq N, M = [int(s) for s in input().split(" ")] dic = {} cards = [int(s) for s in input().split(" ")] for c in cards: if c in dic: dic[c] += 1 else: dic[c] = 1 for i in range(M): b, c = [int(s) for s in input().split(" ")] if c in dic: dic[c] += b ...
import os, sys, re, math, queue N, M = list(map(int, input().split(" "))) A = list(map(int, input().split(" "))) memo = {} for a in A: if a in memo: memo[a] += 1 else: memo[a] = 1 for _ in range(M): B, C = list(map(int, input().split(" "))) if C in memo: memo[C] += B else: ...
false
17.142857
[ "-import os, sys, re, math, heapq", "+import os, sys, re, math, queue", "-N, M = [int(s) for s in input().split(\" \")]", "-dic = {}", "-cards = [int(s) for s in input().split(\" \")]", "-for c in cards:", "- if c in dic:", "- dic[c] += 1", "+N, M = list(map(int, input().split(\" \")))", ...
false
0.03846
0.038322
1.003603
[ "s720406818", "s386757204" ]
u609061751
p02947
python
s366892577
s234215509
685
375
64,344
58,844
Accepted
Accepted
45.26
N=int(eval(input())) dic={} cnt=0 for i in range(N): temp=' '.join(sorted(eval(input()))) if temp in dic: dic[temp]+=1 else: dic[temp]=1 for j in list(dic.values()): cnt+=j*(j-1)//2 print(cnt)
import sys input = sys.stdin.readline n = int(eval(input())) from collections import defaultdict d = defaultdict(int) for i in range(n): s = list(input().rstrip()) s.sort() d["".join(s)] += 1 ans = 0 for i in list(d.keys()): ans += d[i]*(d[i] - 1)//2 print(ans)
12
20
218
291
N = int(eval(input())) dic = {} cnt = 0 for i in range(N): temp = " ".join(sorted(eval(input()))) if temp in dic: dic[temp] += 1 else: dic[temp] = 1 for j in list(dic.values()): cnt += j * (j - 1) // 2 print(cnt)
import sys input = sys.stdin.readline n = int(eval(input())) from collections import defaultdict d = defaultdict(int) for i in range(n): s = list(input().rstrip()) s.sort() d["".join(s)] += 1 ans = 0 for i in list(d.keys()): ans += d[i] * (d[i] - 1) // 2 print(ans)
false
40
[ "-N = int(eval(input()))", "-dic = {}", "-cnt = 0", "-for i in range(N):", "- temp = \" \".join(sorted(eval(input())))", "- if temp in dic:", "- dic[temp] += 1", "- else:", "- dic[temp] = 1", "-for j in list(dic.values()):", "- cnt += j * (j - 1) // 2", "-print(cnt)",...
false
0.164121
0.110831
1.48083
[ "s366892577", "s234215509" ]
u163501259
p03835
python
s361215653
s196115169
1,516
921
2,940
8,864
Accepted
Accepted
39.25
k, s = list(map(int, input().split())) ans = 0 for x in range(k+1): for y in range(k+1): z = s-x-y if k >= z >= 0: ans += 1 print(ans)
import sys input = sys.stdin.readline def main(): K, S = list(map(int, input().split())) CNT = 0 for x in range(K+1): for y in range(K+1): if S - x -y >= 0 and S - x -y <= K: CNT += 1 print(CNT) if __name__ == '__main__': main()
8
13
167
303
k, s = list(map(int, input().split())) ans = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if k >= z >= 0: ans += 1 print(ans)
import sys input = sys.stdin.readline def main(): K, S = list(map(int, input().split())) CNT = 0 for x in range(K + 1): for y in range(K + 1): if S - x - y >= 0 and S - x - y <= K: CNT += 1 print(CNT) if __name__ == "__main__": main()
false
38.461538
[ "-k, s = list(map(int, input().split()))", "-ans = 0", "-for x in range(k + 1):", "- for y in range(k + 1):", "- z = s - x - y", "- if k >= z >= 0:", "- ans += 1", "-print(ans)", "+import sys", "+", "+input = sys.stdin.readline", "+", "+", "+def main():", "+ ...
false
0.037573
0.075069
0.500512
[ "s361215653", "s196115169" ]
u790710233
p02862
python
s822468800
s752106512
230
128
3,064
3,064
Accepted
Accepted
44.35
MOD = 10**9+7 X, Y = list(map(int, input().split())) x, y = X, Y while 0 <= y: if x == 2*y: break x += 1 y -= 1 else: print((0)) exit() def com(n, r): X = Y = 1 if r < 0 or n < r: return 0 if n-r < r: r = n-r for i in range(1, r+1): ...
MOD = 10**9+7 x, y = list(map(int, input().split())) n, r1 = divmod(2*y-x, 3) m, r2 = divmod(2*x-y, 3) def com(n, r): X = Y = 1 if r < 0 or n < r: return 0 if n-r < r: r = n-r for i in range(1, r+1): Y = Y*i % MOD X = X*(n-i+1) % MOD Y = pow(Y, MOD-2,...
27
23
435
404
MOD = 10**9 + 7 X, Y = list(map(int, input().split())) x, y = X, Y while 0 <= y: if x == 2 * y: break x += 1 y -= 1 else: print((0)) exit() def com(n, r): X = Y = 1 if r < 0 or n < r: return 0 if n - r < r: r = n - r for i in range(1, r + 1): Y = Y *...
MOD = 10**9 + 7 x, y = list(map(int, input().split())) n, r1 = divmod(2 * y - x, 3) m, r2 = divmod(2 * x - y, 3) def com(n, r): X = Y = 1 if r < 0 or n < r: return 0 if n - r < r: r = n - r for i in range(1, r + 1): Y = Y * i % MOD X = X * (n - i + 1) % MOD Y = pow(...
false
14.814815
[ "-X, Y = list(map(int, input().split()))", "-x, y = X, Y", "-while 0 <= y:", "- if x == 2 * y:", "- break", "- x += 1", "- y -= 1", "-else:", "- print((0))", "- exit()", "+x, y = list(map(int, input().split()))", "+n, r1 = divmod(2 * y - x, 3)", "+m, r2 = divmod(2 * x -...
false
0.08771
0.053194
1.648882
[ "s822468800", "s752106512" ]
u054825571
p03077
python
s033231397
s598841294
31
28
9,180
9,052
Accepted
Accepted
9.68
import math N=int(eval(input())) A=[int(eval(input())) for _ in range(5)] n=min(A) for i in range(5): if n==A[i]: p=i break k=math.ceil(N/n) print((k+4))
import math N=int(eval(input())) A=[int(eval(input())) for _ in range(5)] print((math.ceil(N/min(A))+4))
11
5
160
96
import math N = int(eval(input())) A = [int(eval(input())) for _ in range(5)] n = min(A) for i in range(5): if n == A[i]: p = i break k = math.ceil(N / n) print((k + 4))
import math N = int(eval(input())) A = [int(eval(input())) for _ in range(5)] print((math.ceil(N / min(A)) + 4))
false
54.545455
[ "-n = min(A)", "-for i in range(5):", "- if n == A[i]:", "- p = i", "- break", "-k = math.ceil(N / n)", "-print((k + 4))", "+print((math.ceil(N / min(A)) + 4))" ]
false
0.155876
0.119082
1.30898
[ "s033231397", "s598841294" ]
u600402037
p02888
python
s021725017
s136582700
1,743
883
51,548
3,188
Accepted
Accepted
49.34
from bisect import bisect_left N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N): for j in range(i+1, N): answer += bisect_left(L[j+1:], L[i]+L[j]) print(answer)
N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N-1, 1, -1): # iは辺の最大値 s = 0 # aは1番短い辺 l = i-1 while l > s: if L[s] + L[l] > L[i]: answer += l - s l -= 1 else: s += 1 print(answer)
10
14
225
298
from bisect import bisect_left N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N): for j in range(i + 1, N): answer += bisect_left(L[j + 1 :], L[i] + L[j]) print(answer)
N = int(eval(input())) L = list(map(int, input().split())) L.sort() answer = 0 for i in range(N - 1, 1, -1): # iは辺の最大値 s = 0 # aは1番短い辺 l = i - 1 while l > s: if L[s] + L[l] > L[i]: answer += l - s l -= 1 else: s += 1 print(answer)
false
28.571429
[ "-from bisect import bisect_left", "-", "-for i in range(N):", "- for j in range(i + 1, N):", "- answer += bisect_left(L[j + 1 :], L[i] + L[j])", "+for i in range(N - 1, 1, -1): # iは辺の最大値", "+ s = 0 # aは1番短い辺", "+ l = i - 1", "+ while l > s:", "+ if L[s] + L[l] > L[i]:"...
false
0.036244
0.035156
1.030946
[ "s021725017", "s136582700" ]
u761320129
p03320
python
s457760282
s909480443
437
57
9,128
3,696
Accepted
Accepted
86.96
K = int(input()) S = lambda n: sum(map(int,str(n))) R = lambda n: n/S(n) arr = [] for i in range(1,10000): for j in range(1,15): arr.append(int(str(i) + '9'*j)) arr.sort(reverse=True) min_r = arr[0] snukes = [] for a in arr: r = R(a) if r < min_r: min_r = r snukes.a...
K = int(input()) S = lambda n: sum(map(int,str(n))) R = lambda n: n/S(n) arr = [] for i in range(1,1000): for j in range(1,15): arr.append(int(str(i) + '9'*j)) arr.sort(reverse=True) min_r = arr[0] snukes = [] for a in arr: r = R(a) if r < min_r: min_r = r snukes.ap...
25
25
442
441
K = int(input()) S = lambda n: sum(map(int, str(n))) R = lambda n: n / S(n) arr = [] for i in range(1, 10000): for j in range(1, 15): arr.append(int(str(i) + "9" * j)) arr.sort(reverse=True) min_r = arr[0] snukes = [] for a in arr: r = R(a) if r < min_r: min_r = r snukes.append(a) fo...
K = int(input()) S = lambda n: sum(map(int, str(n))) R = lambda n: n / S(n) arr = [] for i in range(1, 1000): for j in range(1, 15): arr.append(int(str(i) + "9" * j)) arr.sort(reverse=True) min_r = arr[0] snukes = [] for a in arr: r = R(a) if r < min_r: min_r = r snukes.append(a) for...
false
0
[ "-for i in range(1, 10000):", "+for i in range(1, 1000):" ]
false
3.637729
0.084512
43.044056
[ "s457760282", "s909480443" ]
u108617242
p02935
python
s958223605
s171989787
190
170
38,256
38,512
Accepted
Accepted
10.53
N = int(eval(input())) V = list(map(int, input().split())) V = sorted(V) merged_v = (V[0]+ V[1]) / 2 for i in range(2, N): merged_v = (merged_v + V[i]) / 2 print(merged_v)
N = int(eval(input())) v = list(map(int, input().split())) sort_v = sorted(v) ans = sort_v[0] for i in range(1, N): ans = (ans + sort_v[i]) / 2 print(ans)
7
7
176
158
N = int(eval(input())) V = list(map(int, input().split())) V = sorted(V) merged_v = (V[0] + V[1]) / 2 for i in range(2, N): merged_v = (merged_v + V[i]) / 2 print(merged_v)
N = int(eval(input())) v = list(map(int, input().split())) sort_v = sorted(v) ans = sort_v[0] for i in range(1, N): ans = (ans + sort_v[i]) / 2 print(ans)
false
0
[ "-V = list(map(int, input().split()))", "-V = sorted(V)", "-merged_v = (V[0] + V[1]) / 2", "-for i in range(2, N):", "- merged_v = (merged_v + V[i]) / 2", "-print(merged_v)", "+v = list(map(int, input().split()))", "+sort_v = sorted(v)", "+ans = sort_v[0]", "+for i in range(1, N):", "+ ans...
false
0.051201
0.053823
0.951279
[ "s958223605", "s171989787" ]
u576917603
p03244
python
s860883891
s406072582
87
78
20,360
19,040
Accepted
Accepted
10.34
n=int(eval(input())) a=list(map(int,input().split())) a1=a[::2] a2=a[1::2] if a1==a2 and len(set(a1))==1: print((n//2)) exit() import collections as c c1=c.Counter(a1) c2=c.Counter(a2) c1=c1.most_common() c2=c2.most_common() ans=0 if c1[0][0]==c2[0][0]: ans=min((n//2-c1[0][1])+(n//2-c2[1][1]),...
n=int(eval(input())) a=list(map(int,input().split())) a1=a[::2] a2=a[1::2] import collections c1=collections.Counter(a1) c2=collections.Counter(a2) c1=c1.most_common(2) c2=c2.most_common(2) if a1==a2 and len(c1)==1 and len(c2)==1: print((len(a1))) exit() if len(c1)==1 and len(c2)==1 and c1[0][0]!=c2[0][...
18
26
404
599
n = int(eval(input())) a = list(map(int, input().split())) a1 = a[::2] a2 = a[1::2] if a1 == a2 and len(set(a1)) == 1: print((n // 2)) exit() import collections as c c1 = c.Counter(a1) c2 = c.Counter(a2) c1 = c1.most_common() c2 = c2.most_common() ans = 0 if c1[0][0] == c2[0][0]: ans = min( (n // 2...
n = int(eval(input())) a = list(map(int, input().split())) a1 = a[::2] a2 = a[1::2] import collections c1 = collections.Counter(a1) c2 = collections.Counter(a2) c1 = c1.most_common(2) c2 = c2.most_common(2) if a1 == a2 and len(c1) == 1 and len(c2) == 1: print((len(a1))) exit() if len(c1) == 1 and len(c2) == 1 ...
false
30.769231
[ "-if a1 == a2 and len(set(a1)) == 1:", "- print((n // 2))", "+import collections", "+", "+c1 = collections.Counter(a1)", "+c2 = collections.Counter(a2)", "+c1 = c1.most_common(2)", "+c2 = c2.most_common(2)", "+if a1 == a2 and len(c1) == 1 and len(c2) == 1:", "+ print((len(a1)))", "-import ...
false
0.039674
0.037573
1.055915
[ "s860883891", "s406072582" ]
u119148115
p02889
python
s580154334
s918407580
1,235
666
83,292
78,636
Accepted
Accepted
46.07
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
# ABC143-E import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) N,M,L = MI() inf = 10**12 cost = [[inf]*(N+1) for _ in range(N+1)] # cost[i][j] = 町iから町jへ移動するのにかかる燃料の総和 # WarshallFloyd法 for i in range(M): a,b,c = MI(...
57
45
1,687
988
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
# ABC143-E import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) N, M, L = MI() inf = 10**12 cost = [[inf] * (N + 1) for _ in range(N + 1)] # cost[i][j] = 町iから町jへ移動するのにかかる燃料の総和 # WarshallFloyd法 for i in range(M): a, b, c =...
false
21.052632
[ "+# ABC143-E", "-", "-sys.setrecursionlimit(10**7)", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-def LI2():", "- return list(map(int, sys.stdin.readline().rstrip())) # 空白なし", "-", "-", "-def S():", "- return sys.stdin.readline...
false
0.047785
0.038521
1.240475
[ "s580154334", "s918407580" ]
u401686269
p02763
python
s361875223
s265308095
1,069
861
373,504
526,348
Accepted
Accepted
19.46
class SegTree: """ segment tree with point modification and range product. """ # # https://yukicoder.me/submissions/452850 def __init__(self, N, data_f = min, data_unit=1<<30): self.N = N self.data_f = data_f self.data_unit = data_unit self.data = [self.data_unit] * (N...
class SegTree: """ segment tree with point modification and range product. """ # # https://yukicoder.me/submissions/452850 def __init__(self, N, data_f = min, data_unit=1<<30): self.N = N self.data_f = data_f self.data_unit = data_unit self.data = [self.data_unit] * (N...
58
71
1,549
1,805
class SegTree: """segment tree with point modification and range product.""" # # https://yukicoder.me/submissions/452850 def __init__(self, N, data_f=min, data_unit=1 << 30): self.N = N self.data_f = data_f self.data_unit = data_unit self.data = [self.data_unit] * (N + N) ...
class SegTree: """segment tree with point modification and range product.""" # # https://yukicoder.me/submissions/452850 def __init__(self, N, data_f=min, data_unit=1 << 30): self.N = N self.data_f = data_f self.data_unit = data_unit self.data = [self.data_unit] * (N + N) ...
false
18.309859
[ "-seg = SegTree(N, set.union, set())", "-S = [set(S[i]) for i in range(N)]", "-seg.build(S)", "+data = [[0] * N for _ in range(26)]", "+di = {}", "+for i in range(N):", "+ data[ord(S[i]) - 97][i] = 1", "+ di[i] = S[i]", "+seg = [SegTree(N, max, 0) for _ in range(26)]", "+for i in range(26):"...
false
0.05048
0.035792
1.410368
[ "s361875223", "s265308095" ]
u251515715
p03013
python
s079609868
s928783152
378
186
460,020
13,192
Accepted
Accepted
50.79
n,m=list(map(int,input().split())) a = [int(eval(input())) for i in range(m)] broken = set(a) dp=[0]*(n+1) mod = 10**9 + 7 for i in range(n,-1,-1): if i in broken: continue else: if i==n or i==n-1: dp[i]=1 else: dp[i]=dp[i+1]+dp[i+2] print((dp[0]%mod))
n,m=list(map(int,input().split())) a = [int(eval(input())) for i in range(m)] broken = set(a) dp=[0]*(n+1) mod = 10**9 + 7 for i in range(n,-1,-1): if i in broken: continue elif i==n or i==n-1: dp[i]=1 else: dp[i]=dp[i+1]+dp[i+2] dp[i]%=mod print((dp[0]))
14
15
279
278
n, m = list(map(int, input().split())) a = [int(eval(input())) for i in range(m)] broken = set(a) dp = [0] * (n + 1) mod = 10**9 + 7 for i in range(n, -1, -1): if i in broken: continue else: if i == n or i == n - 1: dp[i] = 1 else: dp[i] = dp[i + 1] + dp[i + 2] pr...
n, m = list(map(int, input().split())) a = [int(eval(input())) for i in range(m)] broken = set(a) dp = [0] * (n + 1) mod = 10**9 + 7 for i in range(n, -1, -1): if i in broken: continue elif i == n or i == n - 1: dp[i] = 1 else: dp[i] = dp[i + 1] + dp[i + 2] dp[i] %= mod print...
false
6.666667
[ "+ elif i == n or i == n - 1:", "+ dp[i] = 1", "- if i == n or i == n - 1:", "- dp[i] = 1", "- else:", "- dp[i] = dp[i + 1] + dp[i + 2]", "-print((dp[0] % mod))", "+ dp[i] = dp[i + 1] + dp[i + 2]", "+ dp[i] %= mod", "+print((dp[0]))" ]
false
0.036691
0.042583
0.861629
[ "s079609868", "s928783152" ]
u413165887
p03848
python
s904867037
s005804371
105
92
14,008
14,008
Accepted
Accepted
12.38
import sys n = int(eval(input())) a = list(map(int, input().split(' '))) a.sort() if n%2 == 0: for i in range(n-1): if i%2 == 0: if a[i] == a[i+1]: continue else: print((0)) sys.exit() else: if a[i]+2 ...
def main(): import sys n = int(eval(input())) a = list(map(int, input().split(' '))) if n%2 == 1: a.append(0) a.sort() for i in range(n-1): if i%2 == 0: if a[i] == a[i+1]: continue else: print((0)) ...
41
24
1,001
570
import sys n = int(eval(input())) a = list(map(int, input().split(" "))) a.sort() if n % 2 == 0: for i in range(n - 1): if i % 2 == 0: if a[i] == a[i + 1]: continue else: print((0)) sys.exit() else: if a[i] + 2 == a...
def main(): import sys n = int(eval(input())) a = list(map(int, input().split(" "))) if n % 2 == 1: a.append(0) a.sort() for i in range(n - 1): if i % 2 == 0: if a[i] == a[i + 1]: continue else: print((0)) s...
false
41.463415
[ "-import sys", "+def main():", "+ import sys", "-n = int(eval(input()))", "-a = list(map(int, input().split(\" \")))", "-a.sort()", "-if n % 2 == 0:", "+ n = int(eval(input()))", "+ a = list(map(int, input().split(\" \")))", "+ if n % 2 == 1:", "+ a.append(0)", "+ a.sort(...
false
0.04116
0.040045
1.027834
[ "s904867037", "s005804371" ]
u380524497
p03222
python
s382218903
s855236229
328
34
49,900
3,064
Accepted
Accepted
89.63
import itertools h, w, k = list(map(int, input().split())) if w == 1: print((1)) exit() mod = 10**9 + 7 path = [[i, i+1] for i in range(w-1)] DP = [[0]*(h+1) for _ in range(w)] DP[0][0] = 1 for height in range(h): for pos in range(w): down_unable = {pos} left_unable = {...
import itertools h, w, k = list(map(int, input().split())) DP = [0] * w DP[0] = 1 mod = 10**9 + 7 patterns = [] for line_count in range(w): candidates = itertools.combinations(list(range(w-1)), line_count) for pattern in candidates: usable = True prev = 10 for nu...
56
49
1,739
1,048
import itertools h, w, k = list(map(int, input().split())) if w == 1: print((1)) exit() mod = 10**9 + 7 path = [[i, i + 1] for i in range(w - 1)] DP = [[0] * (h + 1) for _ in range(w)] DP[0][0] = 1 for height in range(h): for pos in range(w): down_unable = {pos} left_unable = {pos - 1, pos}...
import itertools h, w, k = list(map(int, input().split())) DP = [0] * w DP[0] = 1 mod = 10**9 + 7 patterns = [] for line_count in range(w): candidates = itertools.combinations(list(range(w - 1)), line_count) for pattern in candidates: usable = True prev = 10 for num in pattern: ...
false
12.5
[ "-if w == 1:", "- print((1))", "- exit()", "+DP = [0] * w", "+DP[0] = 1", "-path = [[i, i + 1] for i in range(w - 1)]", "-DP = [[0] * (h + 1) for _ in range(w)]", "-DP[0][0] = 1", "-for height in range(h):", "- for pos in range(w):", "- down_unable = {pos}", "- left_unab...
false
0.125885
0.086751
1.45111
[ "s382218903", "s855236229" ]
u462329577
p03635
python
s621195269
s760377056
171
17
38,256
2,940
Accepted
Accepted
90.06
a,b = list(map(int,input().split())) print(((a-1)*(b-1)))
#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines a,b = list(map(int,input().split())) print(((a-1)*(b-1)))
2
7
52
194
a, b = list(map(int, input().split())) print(((a - 1) * (b - 1)))
#!/usr/bin/env python3 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines a, b = list(map(int, input().split())) print(((a - 1) * (b - 1)))
false
71.428571
[ "+#!/usr/bin/env python3", "+import sys", "+", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readlines" ]
false
0.038479
0.071784
0.536036
[ "s621195269", "s760377056" ]
u260216890
p02574
python
s487701573
s941349029
1,692
782
270,480
231,560
Accepted
Accepted
53.78
n = int(eval(input())) *a,=list(map(int, input().split())) mapa=[0]*(10**6+1) from bisect import bisect_left n0 = 10**6 primes = set(range(2, n0+1)) for i in range(2, int(n0**0.5+1)): primes.difference_update(list(range(i*2, n0+1, i))) primeind=[0]*(10**6+1) for p in primes: primeind[p]=1 def i...
n = int(eval(input())) *a,=list(map(int, input().split())) mapa=[0]*(10**6+1) n0 = 10**6 primes = [0]*(n0+1) for i in range(2, n0+1): if primes[i]==0: x=i multi=1 while x<=n0: if primes[x]==0: primes[x]=i x//=multi multi+=1 ...
41
35
776
630
n = int(eval(input())) (*a,) = list(map(int, input().split())) mapa = [0] * (10**6 + 1) from bisect import bisect_left n0 = 10**6 primes = set(range(2, n0 + 1)) for i in range(2, int(n0**0.5 + 1)): primes.difference_update(list(range(i * 2, n0 + 1, i))) primeind = [0] * (10**6 + 1) for p in primes: primeind[p]...
n = int(eval(input())) (*a,) = list(map(int, input().split())) mapa = [0] * (10**6 + 1) n0 = 10**6 primes = [0] * (n0 + 1) for i in range(2, n0 + 1): if primes[i] == 0: x = i multi = 1 while x <= n0: if primes[x] == 0: primes[x] = i x //= multi ...
false
14.634146
[ "-from bisect import bisect_left", "-", "-primes = set(range(2, n0 + 1))", "-for i in range(2, int(n0**0.5 + 1)):", "- primes.difference_update(list(range(i * 2, n0 + 1, i)))", "-primeind = [0] * (10**6 + 1)", "-for p in primes:", "- primeind[p] = 1", "-", "-", "-def isPrime(m):", "- ...
false
2.696457
1.41406
1.90689
[ "s487701573", "s941349029" ]
u215329188
p03855
python
s540037750
s926373208
1,515
1,282
63,636
66,712
Accepted
Accepted
15.38
import sys sys.setrecursionlimit(10000) N,K,L = list(map(int, input().split())) #print(N,K,L,D,T) class UnionFind: def __init__(self, n): self.par = [i for i in range(n+1)] #self.rank = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return ...
import sys sys.setrecursionlimit(10000) N,K,L = list(map(int, input().split())) #print(N,K,L,D,T) class UnionFind: def __init__(self, n: int) -> None: self.par = [i for i in range(n)] self.rank = [0] * n def find(self, x: int) -> int: if self.par[x] == x: ...
67
64
1,453
1,441
import sys sys.setrecursionlimit(10000) N, K, L = list(map(int, input().split())) # print(N,K,L,D,T) class UnionFind: def __init__(self, n): self.par = [i for i in range(n + 1)] # self.rank = [0] * (n+1) # 検索 def find(self, x): if self.par[x] == x: return x else...
import sys sys.setrecursionlimit(10000) N, K, L = list(map(int, input().split())) # print(N,K,L,D,T) class UnionFind: def __init__(self, n: int) -> None: self.par = [i for i in range(n)] self.rank = [0] * n def find(self, x: int) -> int: if self.par[x] == x: return x ...
false
4.477612
[ "- def __init__(self, n):", "- self.par = [i for i in range(n + 1)]", "- # self.rank = [0] * (n+1)", "+ def __init__(self, n: int) -> None:", "+ self.par = [i for i in range(n)]", "+ self.rank = [0] * n", "- # 検索", "- def find(self, x):", "+ def find(self, ...
false
0.041199
0.041614
0.990028
[ "s540037750", "s926373208" ]
u746428948
p02693
python
s537030175
s095488752
23
20
9,172
9,176
Accepted
Accepted
13.04
k = int(eval(input())) a,b = list(map(int,input().split())) ok = False for i in range(a,b+1): if i % k == 0: ok = True if ok == 0: print("NG") else : print("OK")
k = int(eval(input())) a,b = list(map(int,input().split())) r = (b // k) * k if a <= r: print('OK') else: print('NG')
7
5
159
109
k = int(eval(input())) a, b = list(map(int, input().split())) ok = False for i in range(a, b + 1): if i % k == 0: ok = True if ok == 0: print("NG") else: print("OK")
k = int(eval(input())) a, b = list(map(int, input().split())) r = (b // k) * k if a <= r: print("OK") else: print("NG")
false
28.571429
[ "-ok = False", "-for i in range(a, b + 1):", "- if i % k == 0:", "- ok = True", "-if ok == 0:", "+r = (b // k) * k", "+if a <= r:", "+ print(\"OK\")", "+else:", "-else:", "- print(\"OK\")" ]
false
0.037082
0.038204
0.970641
[ "s537030175", "s095488752" ]
u048238198
p03853
python
s071946019
s282038265
42
17
4,596
3,060
Accepted
Accepted
59.52
h,w = map(int,input().split()) m = list(list(input()) for i in range(h)) portrait = [] for i in range(2*h): for j in range(w): print(m[int(i/2)][j], end='') print()
h,w = list(map(int,input().split())) for i in range(h): s = eval(input()) print((s + "\n" + s + "\n"))
9
5
191
103
h, w = map(int, input().split()) m = list(list(input()) for i in range(h)) portrait = [] for i in range(2 * h): for j in range(w): print(m[int(i / 2)][j], end="") print()
h, w = list(map(int, input().split())) for i in range(h): s = eval(input()) print((s + "\n" + s + "\n"))
false
44.444444
[ "-h, w = map(int, input().split())", "-m = list(list(input()) for i in range(h))", "-portrait = []", "-for i in range(2 * h):", "- for j in range(w):", "- print(m[int(i / 2)][j], end=\"\")", "- print()", "+h, w = list(map(int, input().split()))", "+for i in range(h):", "+ s = eval(...
false
0.091854
0.037364
2.458374
[ "s071946019", "s282038265" ]
u261696185
p02657
python
s022212947
s139604318
30
27
9,136
9,112
Accepted
Accepted
10
# 169A # A × B を整数として出力せよ # 1.入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2.受け取った入力値を使って、適切に処理(計算)すること answer = a * b; # 3.計算した結果を出力すること print(answer)
a, b = list(map(int, input().split())) print((a * b))
12
3
191
48
# 169A # A × B を整数として出力せよ # 1.入力をプログラムで扱えるように受け取ること a, b = list(map(int, input().split())) # print(a, b) # 2.受け取った入力値を使って、適切に処理(計算)すること answer = a * b # 3.計算した結果を出力すること print(answer)
a, b = list(map(int, input().split())) print((a * b))
false
75
[ "-# 169A", "-# A × B を整数として出力せよ", "-# 1.入力をプログラムで扱えるように受け取ること", "-# print(a, b)", "-# 2.受け取った入力値を使って、適切に処理(計算)すること", "-answer = a * b", "-# 3.計算した結果を出力すること", "-print(answer)", "+print((a * b))" ]
false
0.007194
0.038091
0.188858
[ "s022212947", "s139604318" ]
u368249389
p02954
python
s481194826
s297452390
427
346
62,172
61,276
Accepted
Accepted
18.97
# Porblem D - Gathering Children import re # input process S = input() # initialization ans_list = [] in_list = re.findall(r"R+L+", S) # ["RRL", "RL"] # part of list process for p in in_list: p_r = re.findall(r"R+", p)[0] p_l = re.findall(r"L+", p)[0] l_count = 0 r_count = 0 # ...
# Problem D - Gathering Children import re # input S = eval(input()) # initialization rl_list = re.findall(r'R+L+', S) ans_list = [] # count for rl in rl_list: right_count = 0 left_count = 0 right = re.findall(r'R+', rl)[0] left = re.findall(r'L+', rl)[0] # right count ...
45
44
937
885
# Porblem D - Gathering Children import re # input process S = input() # initialization ans_list = [] in_list = re.findall(r"R+L+", S) # ["RRL", "RL"] # part of list process for p in in_list: p_r = re.findall(r"R+", p)[0] p_l = re.findall(r"L+", p)[0] l_count = 0 r_count = 0 # R to L process fo...
# Problem D - Gathering Children import re # input S = eval(input()) # initialization rl_list = re.findall(r"R+L+", S) ans_list = [] # count for rl in rl_list: right_count = 0 left_count = 0 right = re.findall(r"R+", rl)[0] left = re.findall(r"L+", rl)[0] # right count for i in range(1, len(rig...
false
2.222222
[ "-# Porblem D - Gathering Children", "+# Problem D - Gathering Children", "-# input process", "-S = input()", "+# input", "+S = eval(input())", "+rl_list = re.findall(r\"R+L+\", S)", "-in_list = re.findall(r\"R+L+\", S)", "-# [\"RRL\", \"RL\"]", "-# part of list process", "-for p in in_list:", ...
false
0.041417
0.041047
1.009002
[ "s481194826", "s297452390" ]
u098012509
p02898
python
s263169249
s536804646
59
52
18,528
16,476
Accepted
Accepted
11.86
N, K = [int(x) for x in input().split()] H = [int(x) for x in input().split()] ans = 0 for h in H: if h >= K: ans += 1 print(ans)
A, K = [int(x) for x in input().split()] print((sum(int(x) >= K for x in input().split())))
9
3
152
93
N, K = [int(x) for x in input().split()] H = [int(x) for x in input().split()] ans = 0 for h in H: if h >= K: ans += 1 print(ans)
A, K = [int(x) for x in input().split()] print((sum(int(x) >= K for x in input().split())))
false
66.666667
[ "-N, K = [int(x) for x in input().split()]", "-H = [int(x) for x in input().split()]", "-ans = 0", "-for h in H:", "- if h >= K:", "- ans += 1", "-print(ans)", "+A, K = [int(x) for x in input().split()]", "+print((sum(int(x) >= K for x in input().split())))" ]
false
0.036871
0.035125
1.049717
[ "s263169249", "s536804646" ]
u657913472
p03177
python
s224338051
s708509016
1,488
561
16,136
10,672
Accepted
Accepted
62.3
from numpy import* M=10**9+7 m=lambda*z:list(map(int,input().split())) n,k=m() b=eye(n,n,0,'O') a=matrix(list(map(m,b)),'O') while k:b=[b,b*a][k&1];a=a*a%M;k/=2 print(sum(b)%M)
from numpy import* M=10**9+7 m=lambda*z:list(map(int,input().split())) n,k=m() b=[1]*n a=matrix(list(map(m,b)),'O') while k:b*=[1,a][k&1];a=a*a%M;k/=2 print(sum(b)%M)
8
8
174
164
from numpy import * M = 10**9 + 7 m = lambda *z: list(map(int, input().split())) n, k = m() b = eye(n, n, 0, "O") a = matrix(list(map(m, b)), "O") while k: b = [b, b * a][k & 1] a = a * a % M k /= 2 print(sum(b) % M)
from numpy import * M = 10**9 + 7 m = lambda *z: list(map(int, input().split())) n, k = m() b = [1] * n a = matrix(list(map(m, b)), "O") while k: b *= [1, a][k & 1] a = a * a % M k /= 2 print(sum(b) % M)
false
0
[ "-b = eye(n, n, 0, \"O\")", "+b = [1] * n", "- b = [b, b * a][k & 1]", "+ b *= [1, a][k & 1]" ]
false
0.171562
0.171559
1.000015
[ "s224338051", "s708509016" ]
u604774382
p02264
python
s464677842
s910817329
2,220
1,330
13,216
16,132
Accepted
Accepted
40.09
from queue import Queue n, q = [ int( val ) for val in input( ).split( " " ) ] names = Queue( ) times = Queue( ) for i in range( n ): name, time = input( ).split( " " ) names.put( name ) times.put( int( time ) ) qsum = 0 output = [] while not times.empty( ): name = names.get( ) time = times.get( )...
from queue import Queue n, q = [ int( val ) for val in input( ).split( " " ) ] processes = Queue( ) for i in range( n ): name, time = input( ).split( " " ) processes.put( ( name, int( time ) ) ) qsum = 0 output = [] while not processes.empty( ): process = processes.get( ) if process[1] ...
24
20
512
545
from queue import Queue n, q = [int(val) for val in input().split(" ")] names = Queue() times = Queue() for i in range(n): name, time = input().split(" ") names.put(name) times.put(int(time)) qsum = 0 output = [] while not times.empty(): name = names.get() time = times.get() if time <= q: ...
from queue import Queue n, q = [int(val) for val in input().split(" ")] processes = Queue() for i in range(n): name, time = input().split(" ") processes.put((name, int(time))) qsum = 0 output = [] while not processes.empty(): process = processes.get() if process[1] <= q: qsum += process[1] ...
false
16.666667
[ "-names = Queue()", "-times = Queue()", "+processes = Queue()", "- names.put(name)", "- times.put(int(time))", "+ processes.put((name, int(time)))", "-while not times.empty():", "- name = names.get()", "- time = times.get()", "- if time <= q:", "- qsum += time", "- ...
false
0.049706
0.049138
1.011552
[ "s464677842", "s910817329" ]
u047796752
p03229
python
s645350344
s586536508
529
119
53,568
83,024
Accepted
Accepted
77.5
def calc(A): res = 0 for i in range(N-1): res += abs(A[i+1]-A[i]) return res N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] A.sort() if N%2==0: l1 = A[:N//2] l2 = A[N//2:] l1.reverse() l2.reverse() B = [-1]*N for i in ran...
import sys input = sys.stdin.readline N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] coef1, coef2 = [], [] for i in range(N): p = 1 if i in [0, N-1] else 2 coef1.append(p*(1 if i%2==0 else -1)) coef2.append(p*(-1 if i%2==0 else 1)) A.sort() coef1.sort() coef2.sort() ans ...
54
17
971
401
def calc(A): res = 0 for i in range(N - 1): res += abs(A[i + 1] - A[i]) return res N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] A.sort() if N % 2 == 0: l1 = A[: N // 2] l2 = A[N // 2 :] l1.reverse() l2.reverse() B = [-1] * N for i in range(N): i...
import sys input = sys.stdin.readline N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] coef1, coef2 = [], [] for i in range(N): p = 1 if i in [0, N - 1] else 2 coef1.append(p * (1 if i % 2 == 0 else -1)) coef2.append(p * (-1 if i % 2 == 0 else 1)) A.sort() coef1.sort() coef2.sort() ans = m...
false
68.518519
[ "-def calc(A):", "- res = 0", "- for i in range(N - 1):", "- res += abs(A[i + 1] - A[i])", "- return res", "+import sys", "-", "+input = sys.stdin.readline", "+coef1, coef2 = [], []", "+for i in range(N):", "+ p = 1 if i in [0, N - 1] else 2", "+ coef1.append(p * (1 if i ...
false
0.035413
0.034945
1.013399
[ "s645350344", "s586536508" ]
u057109575
p02775
python
s889452028
s406857433
585
265
150,452
189,924
Accepted
Accepted
54.7
N = [int(n) for n in eval(input())] dp = [[0] * 2 for _ in range(len(N) + 1)] dp[0][1] = 1 for i, n in enumerate(N): dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n)) dp[i + 1][1] = min(dp[i][0] + (n + 1), dp[i][1] + (10 - (n + 1))) print((dp[-1][0]))
N = eval(input()) dp = [[0] * 2 for _ in range(len(N) + 1)] dp[0][1] = 1 for i in range(len(N)): n = int(N[i]) dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + 10 - n) dp[i + 1][1] = min(dp[i][0] + n + 1, dp[i][1] + 10 - (n + 1)) print((dp[-1][0]))
10
11
272
261
N = [int(n) for n in eval(input())] dp = [[0] * 2 for _ in range(len(N) + 1)] dp[0][1] = 1 for i, n in enumerate(N): dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n)) dp[i + 1][1] = min(dp[i][0] + (n + 1), dp[i][1] + (10 - (n + 1))) print((dp[-1][0]))
N = eval(input()) dp = [[0] * 2 for _ in range(len(N) + 1)] dp[0][1] = 1 for i in range(len(N)): n = int(N[i]) dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + 10 - n) dp[i + 1][1] = min(dp[i][0] + n + 1, dp[i][1] + 10 - (n + 1)) print((dp[-1][0]))
false
9.090909
[ "-N = [int(n) for n in eval(input())]", "+N = eval(input())", "-for i, n in enumerate(N):", "- dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n))", "- dp[i + 1][1] = min(dp[i][0] + (n + 1), dp[i][1] + (10 - (n + 1)))", "+for i in range(len(N)):", "+ n = int(N[i])", "+ dp[i + 1][0] = min...
false
0.036036
0.085001
0.423954
[ "s889452028", "s406857433" ]
u883621917
p02695
python
s480807211
s402723287
1,244
312
68,212
79,940
Accepted
Accepted
74.92
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n, m, q = list(map(int, input().split())) pairs = [0] * q for i in range(q): pairs[i] = list(map(int, input().split())) from collections import deque def dfs(min_val, length): if length == 0: return list([deque()]) ...
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n, m, q = list(map(int, input().split())) abcd = [0] * q for i in range(q): abcd[i] = list(map(int, input().split())) def dfs(seq): if len(seq) == n: yield tuple(seq) return if len(seq) == 0: start =...
33
30
735
653
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) n, m, q = list(map(int, input().split())) pairs = [0] * q for i in range(q): pairs[i] = list(map(int, input().split())) from collections import deque def dfs(min_val, length): if length == 0: return list([deque()]) if min_val == m...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) n, m, q = list(map(int, input().split())) abcd = [0] * q for i in range(q): abcd[i] = list(map(int, input().split())) def dfs(seq): if len(seq) == n: yield tuple(seq) return if len(seq) == 0: start = 1 else: ...
false
9.090909
[ "-pairs = [0] * q", "+abcd = [0] * q", "- pairs[i] = list(map(int, input().split()))", "-from collections import deque", "+ abcd[i] = list(map(int, input().split()))", "-def dfs(min_val, length):", "- if length == 0:", "- return list([deque()])", "- if min_val == m:", "- ...
false
0.072368
0.06319
1.145232
[ "s480807211", "s402723287" ]
u334712262
p02816
python
s482987073
s152478031
1,815
655
277,572
125,712
Accepted
Accepted
63.91
# -*- coding: utf-8 -*- # import time import sys from collections import Counter, defaultdict buff_readline = sys.stdin.buffer.readline readline = sys.stdin.readline def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().split())) gpw = None c...
# -*- coding: utf-8 -*- import sys from collections import Counter, defaultdict buff_readline = sys.stdin.buffer.readline readline = sys.stdin.readline def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().split())) class RollingHash(): """ ...
93
106
2,117
2,585
# -*- coding: utf-8 -*- # import time import sys from collections import Counter, defaultdict buff_readline = sys.stdin.buffer.readline readline = sys.stdin.readline def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().split())) gpw = None class RH: def...
# -*- coding: utf-8 -*- import sys from collections import Counter, defaultdict buff_readline = sys.stdin.buffer.readline readline = sys.stdin.readline def read_int(): return int(buff_readline()) def read_int_n(): return list(map(int, buff_readline().split())) class RollingHash: """ Original code...
false
12.264151
[ "-# import time", "-gpw = None", "+class RollingHash:", "+ \"\"\"", "+ Original code is https://tjkendev.github.io/procon-library/python/string/rolling_hash.html", "+ \"\"\"", "-", "-class RH:", "- def __init__(self, s, base, mod):", "- self.base = base", "- self.mod = ...
false
0.037817
0.044915
0.841979
[ "s482987073", "s152478031" ]
u811169796
p03816
python
s159013334
s943214261
81
44
14,396
14,564
Accepted
Accepted
45.68
n = int(eval(input())) A = list(map(int,input().split())) A.sort() m = 0 cnt = 0 for i in A: if(m != i): m = i cnt += 1 if(cnt % 2 == 0): cnt -= 1 print(cnt)
n = eval(input()) A = list(map(int,input().split())) l = len(set(A)) if(l % 2 == 0): l -= 1 print(l)
15
6
185
101
n = int(eval(input())) A = list(map(int, input().split())) A.sort() m = 0 cnt = 0 for i in A: if m != i: m = i cnt += 1 if cnt % 2 == 0: cnt -= 1 print(cnt)
n = eval(input()) A = list(map(int, input().split())) l = len(set(A)) if l % 2 == 0: l -= 1 print(l)
false
60
[ "-n = int(eval(input()))", "+n = eval(input())", "-A.sort()", "-m = 0", "-cnt = 0", "-for i in A:", "- if m != i:", "- m = i", "- cnt += 1", "-if cnt % 2 == 0:", "- cnt -= 1", "-print(cnt)", "+l = len(set(A))", "+if l % 2 == 0:", "+ l -= 1", "+print(l)" ]
false
0.037844
0.080011
0.472984
[ "s159013334", "s943214261" ]
u563588763
p03485
python
s244133086
s966395451
20
18
2,940
2,940
Accepted
Accepted
10
a,b = list(map(int,input().split())) if (a + b) % 2 == 0: print((int((a +b)/2))) else: print((int(((a + b)/2) +1)))
a,b = list(map(int,input().split())) if int((a + b)%2) == 0: print((int((a + b)//2))) else: print((int((a + b) // 2 + 1)))
5
5
117
125
a, b = list(map(int, input().split())) if (a + b) % 2 == 0: print((int((a + b) / 2))) else: print((int(((a + b) / 2) + 1)))
a, b = list(map(int, input().split())) if int((a + b) % 2) == 0: print((int((a + b) // 2))) else: print((int((a + b) // 2 + 1)))
false
0
[ "-if (a + b) % 2 == 0:", "- print((int((a + b) / 2)))", "+if int((a + b) % 2) == 0:", "+ print((int((a + b) // 2)))", "- print((int(((a + b) / 2) + 1)))", "+ print((int((a + b) // 2 + 1)))" ]
false
0.036373
0.046142
0.788295
[ "s244133086", "s966395451" ]
u608088992
p03363
python
s738819718
s931389564
270
171
48,128
38,852
Accepted
Accepted
36.67
from collections import defaultdict N = int(eval(input())) A = [int(a) for a in input().split()] series = [0] * (N + 1) for i in range(1, N+1): series[i] = series[i-1] + i sumDict = defaultdict(int) sumDict[0] = 1 sum = 0 for a in A: sum += a sumDict[sum] += 1 total = 0 for key in sumDict: ...
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) A = [int(a) for a in input().split()] sumDict = dict() sumA = 0 sumDict[0] = 1 for i, a in enumerate(A): sumA += a if sumA in sumDict: sumDict[sumA] += 1 else: sumDict[sumA] = 1 ...
18
21
366
469
from collections import defaultdict N = int(eval(input())) A = [int(a) for a in input().split()] series = [0] * (N + 1) for i in range(1, N + 1): series[i] = series[i - 1] + i sumDict = defaultdict(int) sumDict[0] = 1 sum = 0 for a in A: sum += a sumDict[sum] += 1 total = 0 for key in sumDict: total +=...
import sys def solve(): input = sys.stdin.readline N = int(eval(input())) A = [int(a) for a in input().split()] sumDict = dict() sumA = 0 sumDict[0] = 1 for i, a in enumerate(A): sumA += a if sumA in sumDict: sumDict[sumA] += 1 else: sumDict[...
false
14.285714
[ "-from collections import defaultdict", "+import sys", "-N = int(eval(input()))", "-A = [int(a) for a in input().split()]", "-series = [0] * (N + 1)", "-for i in range(1, N + 1):", "- series[i] = series[i - 1] + i", "-sumDict = defaultdict(int)", "-sumDict[0] = 1", "-sum = 0", "-for a in A:",...
false
0.033063
0.077468
0.426788
[ "s738819718", "s931389564" ]
u255317651
p02264
python
s770021619
s231022932
750
460
10,912
15,668
Accepted
Accepted
38.67
# -*- coding: utf-8 -*- """ Created on Sun Apr 29 14:42:43 2018 @author: maezawa """ def print_array(g): ans = str(g[0]) if len(g) > 1: for i in range(1,len(g)): ans += ' '+str(g[i]) print(ans) name=[] time=[] current_time = 0 n, q = list(map(int, input().split()))...
# -*- coding: utf-8 -*- """ Created on Sun Apr 29 18:04:22 2018 ALDS1_3b_r リングバッファによる実装 @author: maezawa """ def fifo_enque(data): global tail global fifo fifo[tail] = data tail = (tail+1)%fifo_size def fifo_deque(): global head global fifo data = fifo[head] head =...
50
53
1,089
1,009
# -*- coding: utf-8 -*- """ Created on Sun Apr 29 14:42:43 2018 @author: maezawa """ def print_array(g): ans = str(g[0]) if len(g) > 1: for i in range(1, len(g)): ans += " " + str(g[i]) print(ans) name = [] time = [] current_time = 0 n, q = list(map(int, input().split())) for i in ra...
# -*- coding: utf-8 -*- """ Created on Sun Apr 29 18:04:22 2018 ALDS1_3b_r リングバッファによる実装 @author: maezawa """ def fifo_enque(data): global tail global fifo fifo[tail] = data tail = (tail + 1) % fifo_size def fifo_deque(): global head global fifo data = fifo[head] head = (head + 1) % f...
false
5.660377
[ "-Created on Sun Apr 29 14:42:43 2018", "+Created on Sun Apr 29 18:04:22 2018", "+ALDS1_3b_r リングバッファによる実装", "-def print_array(g):", "- ans = str(g[0])", "- if len(g) > 1:", "- for i in range(1, len(g)):", "- ans += \" \" + str(g[i])", "- print(ans)", "+def fifo_enque(dat...
false
0.036695
0.04202
0.873285
[ "s770021619", "s231022932" ]
u813387707
p02887
python
s758690404
s726482882
42
32
3,316
3,316
Accepted
Accepted
23.81
n = int(eval(input())) s = eval(input()) ans = 1 for i in range(n - 1): if s[i] != s[i + 1]: ans += 1 print(ans)
n = int(eval(input())) s = eval(input()) ans = 1 temp = s[0] for c in s: if c != temp: ans += 1 temp = c print(ans)
8
10
120
129
n = int(eval(input())) s = eval(input()) ans = 1 for i in range(n - 1): if s[i] != s[i + 1]: ans += 1 print(ans)
n = int(eval(input())) s = eval(input()) ans = 1 temp = s[0] for c in s: if c != temp: ans += 1 temp = c print(ans)
false
20
[ "-for i in range(n - 1):", "- if s[i] != s[i + 1]:", "+temp = s[0]", "+for c in s:", "+ if c != temp:", "+ temp = c" ]
false
0.04092
0.034919
1.171865
[ "s758690404", "s726482882" ]
u683968848
p00474
python
s242438200
s418966810
220
190
10,860
10,832
Accepted
Accepted
13.64
import sys sys.setrecursionlimit(100000000) line = input().rstrip().split() N, L = list(map(int, line)) def solve2(trr, hour=0): N = len(trr) if sum(trr) == 0: return hour elif N == 1: trr[0] += 1 elif N == 2: if trr[0] > trr[1]: trr[0] += 1 ...
import sys sys.setrecursionlimit(100000000) line = input().rstrip().split() N, L = list(map(int, line)) def solve(trr, N): if N == 1: return L - trr[0] elif N == 2: return (L - trr[0]) + (L - trr[1]) best_hour = -1 peaks = [] if trr[0] > trr[1]: peaks.append...
63
36
1,704
1,015
import sys sys.setrecursionlimit(100000000) line = input().rstrip().split() N, L = list(map(int, line)) def solve2(trr, hour=0): N = len(trr) if sum(trr) == 0: return hour elif N == 1: trr[0] += 1 elif N == 2: if trr[0] > trr[1]: trr[0] += 1 else: ...
import sys sys.setrecursionlimit(100000000) line = input().rstrip().split() N, L = list(map(int, line)) def solve(trr, N): if N == 1: return L - trr[0] elif N == 2: return (L - trr[0]) + (L - trr[1]) best_hour = -1 peaks = [] if trr[0] > trr[1]: peaks.append(0) if trr[...
false
42.857143
[ "-def solve2(trr, hour=0):", "- N = len(trr)", "- if sum(trr) == 0:", "- return hour", "- elif N == 1:", "- trr[0] += 1", "- elif N == 2:", "- if trr[0] > trr[1]:", "- trr[0] += 1", "- else:", "- trr[1] += 1", "- elif N > 2:", ...
false
0.044996
0.044837
1.00356
[ "s242438200", "s418966810" ]
u910632349
p03163
python
s951961950
s865156075
641
528
218,132
217,792
Accepted
Accepted
17.63
n,w=list(map(int,input().split())) a=[list(map(int,input().split())) for _ in range(n)] dp=[[0 for _ in range(w+1)] for _ in range(n+1)] for i in range(n): for j in range(w+1): weight,value=a[i] dp[i+1][j]=max(dp[i][j],dp[i+1][j]) if j+weight<=w: dp[i+1][j+weight]=max(dp[...
n,W=list(map(int,input().split())) a=[list(map(int,input().split())) for _ in range(n)] dp=[[0 for _ in range(W+1)] for _ in range(n+1)] for i in range(n): weight,value=a[i] for j in range(W+1): dp[i+1][j]=max(dp[i][j],dp[i+1][j]) if j+weight<=W: dp[i+1][j+weight]=max(dp[i][j...
10
10
361
357
n, w = list(map(int, input().split())) a = [list(map(int, input().split())) for _ in range(n)] dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)] for i in range(n): for j in range(w + 1): weight, value = a[i] dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]) if j + weight <= w: dp[i...
n, W = list(map(int, input().split())) a = [list(map(int, input().split())) for _ in range(n)] dp = [[0 for _ in range(W + 1)] for _ in range(n + 1)] for i in range(n): weight, value = a[i] for j in range(W + 1): dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]) if j + weight <= W: dp[i + 1...
false
0
[ "-n, w = list(map(int, input().split()))", "+n, W = list(map(int, input().split()))", "-dp = [[0 for _ in range(w + 1)] for _ in range(n + 1)]", "+dp = [[0 for _ in range(W + 1)] for _ in range(n + 1)]", "- for j in range(w + 1):", "- weight, value = a[i]", "+ weight, value = a[i]", "+ ...
false
0.037129
0.12285
0.302228
[ "s951961950", "s865156075" ]
u368796742
p02614
python
s329695592
s515596924
147
64
9,340
9,240
Accepted
Accepted
56.46
import copy h,w,k = list(map(int,input().split())) c = [list(eval(input())) for i in range(h)] count = 0 for i in range(2**h): for j in range(2**w): d = copy.deepcopy(c) for t in range(h): if (i >> t) & 1: for q in range(w): d[t][q] = "x" ...
H,W,K = list(map(int,input().split())) C = [list(eval(input())) for i in range(H)] ans = 0 for i in range(1<<H): for j in range(1<<W): count = 0 for h in range(H): for w in range(W): if ((i>>h)& 1) or ((j>>w)& 1) or C[h][w] == ".": continue ...
22
15
566
393
import copy h, w, k = list(map(int, input().split())) c = [list(eval(input())) for i in range(h)] count = 0 for i in range(2**h): for j in range(2**w): d = copy.deepcopy(c) for t in range(h): if (i >> t) & 1: for q in range(w): d[t][q] = "x" f...
H, W, K = list(map(int, input().split())) C = [list(eval(input())) for i in range(H)] ans = 0 for i in range(1 << H): for j in range(1 << W): count = 0 for h in range(H): for w in range(W): if ((i >> h) & 1) or ((j >> w) & 1) or C[h][w] == ".": continu...
false
31.818182
[ "-import copy", "-", "-h, w, k = list(map(int, input().split()))", "-c = [list(eval(input())) for i in range(h)]", "-count = 0", "-for i in range(2**h):", "- for j in range(2**w):", "- d = copy.deepcopy(c)", "- for t in range(h):", "- if (i >> t) & 1:", "- ...
false
0.078613
0.0402
1.955551
[ "s329695592", "s515596924" ]
u761989513
p03845
python
s751791053
s141746950
23
18
3,444
2,940
Accepted
Accepted
21.74
import copy n = int(eval(input())) t = list(map(int, input().split())) m = int(eval(input())) a = copy.copy(t) for i in range(m): p, x = list(map(int, input().split())) a[p - 1] = x print((sum(a))) a = copy.copy(t)
n = int(eval(input())) t = list(map(int, input().split())) m = int(eval(input())) s = sum(t) for i in range(m): p, x = list(map(int, input().split())) print((s - t[p - 1] + x))
10
7
211
167
import copy n = int(eval(input())) t = list(map(int, input().split())) m = int(eval(input())) a = copy.copy(t) for i in range(m): p, x = list(map(int, input().split())) a[p - 1] = x print((sum(a))) a = copy.copy(t)
n = int(eval(input())) t = list(map(int, input().split())) m = int(eval(input())) s = sum(t) for i in range(m): p, x = list(map(int, input().split())) print((s - t[p - 1] + x))
false
30
[ "-import copy", "-", "-a = copy.copy(t)", "+s = sum(t)", "- a[p - 1] = x", "- print((sum(a)))", "- a = copy.copy(t)", "+ print((s - t[p - 1] + x))" ]
false
0.043681
0.036027
1.212472
[ "s751791053", "s141746950" ]
u489959379
p02861
python
s594676339
s141846386
467
417
3,064
3,188
Accepted
Accepted
10.71
from itertools import permutations n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] dist = 0 cnt = 0 for pattern in permutations(xy): cnt += 1 for i in range(n - 1): x1, y1 = pattern[i] x2, y2 = pattern[i + 1] dist += pow(pow(x1 - x2, 2) + pow...
import sys from itertools import permutations sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) XY = [list(map(int, input().split())) for _ in range(n)] def calc(x1, y1, x2, y2): return pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), ...
15
29
364
639
from itertools import permutations n = int(eval(input())) xy = [list(map(int, input().split())) for _ in range(n)] dist = 0 cnt = 0 for pattern in permutations(xy): cnt += 1 for i in range(n - 1): x1, y1 = pattern[i] x2, y2 = pattern[i + 1] dist += pow(pow(x1 - x2, 2) + pow(y1 - y2, 2),...
import sys from itertools import permutations sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) XY = [list(map(int, input().split())) for _ in range(n)] def calc(x1, y1, x2, y2): return pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), 0.5) dist = ...
false
48.275862
[ "+import sys", "-n = int(eval(input()))", "-xy = [list(map(int, input().split())) for _ in range(n)]", "-dist = 0", "-cnt = 0", "-for pattern in permutations(xy):", "- cnt += 1", "- for i in range(n - 1):", "- x1, y1 = pattern[i]", "- x2, y2 = pattern[i + 1]", "- dist ...
false
0.07661
0.066024
1.160331
[ "s594676339", "s141846386" ]
u631277801
p03295
python
s183060474
s507487090
311
263
18,200
18,200
Accepted
Accepted
15.43
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x)-1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): return stdin.readl...
# Input import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): retur...
30
33
673
684
import sys stdin = sys.stdin sys.setrecursionlimit(10**5) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() def ns(): ...
# Input import sys stdin = sys.stdin sys.setrecursionlimit(10**7) def li(): return list(map(int, stdin.readline().split())) def li_(): return [int(x) - 1 for x in stdin.readline().split()] def lf(): return list(map(float, stdin.readline().split())) def ls(): return stdin.readline().split() de...
false
9.090909
[ "+# Input", "-sys.setrecursionlimit(10**5)", "+sys.setrecursionlimit(10**7)", "- a, b = li_()", "- ab.append(tuple([a, b]))", "+ ai, bi = li_()", "+ ab.append((ai, bi))", "-for a, b in ab:", "- if a >= cur:", "+for ai, bi in ab:", "+ if ai >= cur:", "- cur = b", "+ ...
false
0.038277
0.044501
0.860137
[ "s183060474", "s507487090" ]
u819048695
p03806
python
s288344143
s599103270
1,268
207
121,436
17,540
Accepted
Accepted
83.68
import copy n,ma,mb=list(map(int,input().split())) abc=[list(map(int,input().split())) for i in range(n)] l=10*n inf=float("inf") data=[[inf]*(l+1) for i in range(l+1)] data[0][0]=0 for u in abc: a,b,c=u h=copy.deepcopy(data) for i in range(l-a+1): for j in range(l-b+1): if d...
import numpy as np n,ma,mb=list(map(int,input().split())) L=10*n dp=np.zeros((L+1,L+1),dtype="int64") dq=np.zeros((L+1,L+1),dtype="int64") inf=10**18 dp+=inf dp[0][0]=0 for i in range(n): a,b,c=list(map(int,input().split())) dq=dp.copy() dq[a:,b:]=np.minimum(dq[a:,b:],dp[:-a,:-b]+c) ...
25
27
574
482
import copy n, ma, mb = list(map(int, input().split())) abc = [list(map(int, input().split())) for i in range(n)] l = 10 * n inf = float("inf") data = [[inf] * (l + 1) for i in range(l + 1)] data[0][0] = 0 for u in abc: a, b, c = u h = copy.deepcopy(data) for i in range(l - a + 1): for j in range(l...
import numpy as np n, ma, mb = list(map(int, input().split())) L = 10 * n dp = np.zeros((L + 1, L + 1), dtype="int64") dq = np.zeros((L + 1, L + 1), dtype="int64") inf = 10**18 dp += inf dp[0][0] = 0 for i in range(n): a, b, c = list(map(int, input().split())) dq = dp.copy() dq[a:, b:] = np.minimum(dq[a:, ...
false
7.407407
[ "-import copy", "+import numpy as np", "-abc = [list(map(int, input().split())) for i in range(n)]", "-l = 10 * n", "-inf = float(\"inf\")", "-data = [[inf] * (l + 1) for i in range(l + 1)]", "-data[0][0] = 0", "-for u in abc:", "- a, b, c = u", "- h = copy.deepcopy(data)", "- for i in ...
false
0.140017
0.213658
0.65533
[ "s288344143", "s599103270" ]
u367701763
p02973
python
s860951005
s562988260
134
103
79,404
83,716
Accepted
Accepted
23.13
def LIS(A): dp = deque([A[0]]) for a in A[1:]: if a <= dp[0]: dp.appendleft(a) else: dp[bisect_left(dp, a)-1] = a return len(dp) ################################################################################################################## import sys ...
def LIS(A): dp = [-A[0]] for a in A[1:]: if -a >= dp[-1]: dp.append(-a) else: dp[bisect_right(dp, -a)] = -a return len(dp) ################################################################################################################## import sys input...
21
20
487
440
def LIS(A): dp = deque([A[0]]) for a in A[1:]: if a <= dp[0]: dp.appendleft(a) else: dp[bisect_left(dp, a) - 1] = a return len(dp) ################################################################################################################## import sys input = ...
def LIS(A): dp = [-A[0]] for a in A[1:]: if -a >= dp[-1]: dp.append(-a) else: dp[bisect_right(dp, -a)] = -a return len(dp) ################################################################################################################## import sys input = sys.stdi...
false
4.761905
[ "- dp = deque([A[0]])", "+ dp = [-A[0]]", "- if a <= dp[0]:", "- dp.appendleft(a)", "+ if -a >= dp[-1]:", "+ dp.append(-a)", "- dp[bisect_left(dp, a) - 1] = a", "+ dp[bisect_right(dp, -a)] = -a", "-from collections import deque", "-fr...
false
0.036541
0.07299
0.500624
[ "s860951005", "s562988260" ]
u814265211
p02783
python
s908815633
s726542861
19
17
2,940
2,940
Accepted
Accepted
10.53
H, A = list(map(int, input().split())) cnt = 0 while H > 0: H -= A cnt += 1 print(cnt)
import math H, A = list(map(int, input().split())) print((math.ceil(H / A)))
8
4
98
73
H, A = list(map(int, input().split())) cnt = 0 while H > 0: H -= A cnt += 1 print(cnt)
import math H, A = list(map(int, input().split())) print((math.ceil(H / A)))
false
50
[ "+import math", "+", "-cnt = 0", "-while H > 0:", "- H -= A", "- cnt += 1", "-print(cnt)", "+print((math.ceil(H / A)))" ]
false
0.045008
0.087015
0.51725
[ "s908815633", "s726542861" ]
u892251744
p03491
python
s245667426
s435919789
669
243
135,008
59,612
Accepted
Accepted
63.68
def main(): import sys from collections import defaultdict input = sys.stdin.readline mod = 10**10+7 mod2 = 10**10+9 mod3 = 998244353 N, L = list(map(int, input().split())) dic = defaultdict(int) dic2 = defaultdict(int) dic3 = defaultdict(int) h_list = [] h2...
def main(): import sys input = sys.stdin.readline class TreiNode: def __init__(self, char_num, depth): self.end = False self.child = [None] * char_num self.depth = depth def __setitem__(self, i, x): self.child[i] = x def...
80
65
2,183
1,549
def main(): import sys from collections import defaultdict input = sys.stdin.readline mod = 10**10 + 7 mod2 = 10**10 + 9 mod3 = 998244353 N, L = list(map(int, input().split())) dic = defaultdict(int) dic2 = defaultdict(int) dic3 = defaultdict(int) h_list = [] h2_list = [...
def main(): import sys input = sys.stdin.readline class TreiNode: def __init__(self, char_num, depth): self.end = False self.child = [None] * char_num self.depth = depth def __setitem__(self, i, x): self.child[i] = x def __getitem__...
false
18.75
[ "- from collections import defaultdict", "- mod = 10**10 + 7", "- mod2 = 10**10 + 9", "- mod3 = 998244353", "+", "+ class TreiNode:", "+ def __init__(self, char_num, depth):", "+ self.end = False", "+ self.child = [None] * char_num", "+ self.d...
false
0.046658
0.036751
1.269563
[ "s245667426", "s435919789" ]
u268698968
p03447
python
s132970182
s118834422
19
17
3,060
2,940
Accepted
Accepted
10.53
import math X = int(eval(input())) price = [int(eval(input())) for i in range(2)] haveMoney = X haveMoney = X - price[0] numDonuts = math.floor(haveMoney/price[1]) haveMoney = haveMoney - price[1] * numDonuts print(haveMoney)
X = int(eval(input())) price = [int(eval(input())) for i in range(2)] print(((X-price[0])%price[1]))
11
3
226
88
import math X = int(eval(input())) price = [int(eval(input())) for i in range(2)] haveMoney = X haveMoney = X - price[0] numDonuts = math.floor(haveMoney / price[1]) haveMoney = haveMoney - price[1] * numDonuts print(haveMoney)
X = int(eval(input())) price = [int(eval(input())) for i in range(2)] print(((X - price[0]) % price[1]))
false
72.727273
[ "-import math", "-", "-haveMoney = X", "-haveMoney = X - price[0]", "-numDonuts = math.floor(haveMoney / price[1])", "-haveMoney = haveMoney - price[1] * numDonuts", "-print(haveMoney)", "+print(((X - price[0]) % price[1]))" ]
false
0.161912
0.157695
1.026737
[ "s132970182", "s118834422" ]
u652656291
p02702
python
s722761094
s979393144
352
112
9,200
11,972
Accepted
Accepted
68.18
s,l = (eval(input()),2019) m,a,r = ([1]+[0]*l,0,0) for i,e in enumerate(s[::-1]): a += int(e)*pow(10,i,l) r += m[a%l] m[a%l] += 1 print(r)
s = list(map(int,list(eval(input()))))[::-1] n = len(s) chk = [0]*2019 chk[0] = 1 t,m,ans = 1,0,0 for i in s: m = (m+t*i)%2019 ans += chk[m] chk[m] += 1 t = t*10%2019 print(ans)
7
11
151
198
s, l = (eval(input()), 2019) m, a, r = ([1] + [0] * l, 0, 0) for i, e in enumerate(s[::-1]): a += int(e) * pow(10, i, l) r += m[a % l] m[a % l] += 1 print(r)
s = list(map(int, list(eval(input()))))[::-1] n = len(s) chk = [0] * 2019 chk[0] = 1 t, m, ans = 1, 0, 0 for i in s: m = (m + t * i) % 2019 ans += chk[m] chk[m] += 1 t = t * 10 % 2019 print(ans)
false
36.363636
[ "-s, l = (eval(input()), 2019)", "-m, a, r = ([1] + [0] * l, 0, 0)", "-for i, e in enumerate(s[::-1]):", "- a += int(e) * pow(10, i, l)", "- r += m[a % l]", "- m[a % l] += 1", "-print(r)", "+s = list(map(int, list(eval(input()))))[::-1]", "+n = len(s)", "+chk = [0] * 2019", "+chk[0] = 1...
false
0.038958
0.079349
0.490979
[ "s722761094", "s979393144" ]
u391589398
p02574
python
s520416159
s210219152
772
376
220,364
224,668
Accepted
Accepted
51.3
N = int(eval(input())) A = tuple(map(int, input().split())) def p(n): """ """ min_facts = [0] * (n+1) is_prime = [True] * (n+1) is_prime[0] = False is_prime[1] = False for i in range(2, n+1): if not is_prime[i]: continue min_facts[i] = i ...
n = int(eval(input())) A = tuple(map(int, input().split())) maxa = max(A) cnt = [0] * (maxa + 1) for a in A: cnt[a] += 1 from math import gcd from functools import reduce if reduce(gcd, A) != 1: print('not coprime') else: for i in range(2, maxa+1): if sum(cnt[i::i]) > 1: p...
44
18
1,032
403
N = int(eval(input())) A = tuple(map(int, input().split())) def p(n): """ """ min_facts = [0] * (n + 1) is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, n + 1): if not is_prime[i]: continue min_facts[i] = i for j in range...
n = int(eval(input())) A = tuple(map(int, input().split())) maxa = max(A) cnt = [0] * (maxa + 1) for a in A: cnt[a] += 1 from math import gcd from functools import reduce if reduce(gcd, A) != 1: print("not coprime") else: for i in range(2, maxa + 1): if sum(cnt[i::i]) > 1: print("setwis...
false
59.090909
[ "-N = int(eval(input()))", "+n = int(eval(input()))", "+maxa = max(A)", "+cnt = [0] * (maxa + 1)", "+for a in A:", "+ cnt[a] += 1", "+from math import gcd", "+from functools import reduce", "-", "-def p(n):", "- \"\"\" \"\"\"", "- min_facts = [0] * (n + 1)", "- is_prime = [True] ...
false
0.100498
0.046283
2.17141
[ "s520416159", "s210219152" ]
u340781749
p03576
python
s325277183
s022712892
206
26
3,064
3,064
Accepted
Accepted
87.38
n, k = list(map(int, input().split())) sx, sy = [], [] for i in range(n): x, y = list(map(int, input().split())) sx.append((x, i)) sy.append((y, i)) sx.sort() sy.sort() px = [[0] for _ in range(n)] for cx, (x, i) in enumerate(sx): px[i] = cx acm = [[0] * (n + 1) for _ in range(n + 1)] for ...
n, k = list(map(int, input().split())) ps = [tuple(map(int, input().split())) for i in range(n)] sx = sorted(ps) nx = list(enumerate(sx)) ans = 5e18 for l, (x1, y1) in nx[:n - k + 1]: for r, (x2, y2) in nx[l + k - 1:]: dx = x2 - x1 sy = sorted(y for x, y in sx[l:r + 1]) for y3, y4...
27
14
885
438
n, k = list(map(int, input().split())) sx, sy = [], [] for i in range(n): x, y = list(map(int, input().split())) sx.append((x, i)) sy.append((y, i)) sx.sort() sy.sort() px = [[0] for _ in range(n)] for cx, (x, i) in enumerate(sx): px[i] = cx acm = [[0] * (n + 1) for _ in range(n + 1)] for cy, (y, i) in ...
n, k = list(map(int, input().split())) ps = [tuple(map(int, input().split())) for i in range(n)] sx = sorted(ps) nx = list(enumerate(sx)) ans = 5e18 for l, (x1, y1) in nx[: n - k + 1]: for r, (x2, y2) in nx[l + k - 1 :]: dx = x2 - x1 sy = sorted(y for x, y in sx[l : r + 1]) for y3, y4 in zip...
false
48.148148
[ "-sx, sy = [], []", "-for i in range(n):", "- x, y = list(map(int, input().split()))", "- sx.append((x, i))", "- sy.append((y, i))", "-sx.sort()", "-sy.sort()", "-px = [[0] for _ in range(n)]", "-for cx, (x, i) in enumerate(sx):", "- px[i] = cx", "-acm = [[0] * (n + 1) for _ in range...
false
0.046211
0.03824
1.208466
[ "s325277183", "s022712892" ]
u620084012
p04025
python
s228601044
s527087212
178
25
39,024
2,940
Accepted
Accepted
85.96
import sys def main(): def input(): return sys.stdin.readline()[:-1] N = int(eval(input())) a = list(map(int,input().split())) ans = 1000000 for k in range(-100,101): t = 0 for e in a: t += (e-k)**2 ans = min(ans,t) print(ans) if __name_...
N = int(eval(input())) a = list(map(int,input().split())) ans = 10**12 for k in range(-100,101): temp = 0 for e in a: temp += (k-e)**2 ans = min(ans,temp) print(ans)
16
9
343
188
import sys def main(): def input(): return sys.stdin.readline()[:-1] N = int(eval(input())) a = list(map(int, input().split())) ans = 1000000 for k in range(-100, 101): t = 0 for e in a: t += (e - k) ** 2 ans = min(ans, t) print(ans) if __name__ =...
N = int(eval(input())) a = list(map(int, input().split())) ans = 10**12 for k in range(-100, 101): temp = 0 for e in a: temp += (k - e) ** 2 ans = min(ans, temp) print(ans)
false
43.75
[ "-import sys", "-", "-", "-def main():", "- def input():", "- return sys.stdin.readline()[:-1]", "-", "- N = int(eval(input()))", "- a = list(map(int, input().split()))", "- ans = 1000000", "- for k in range(-100, 101):", "- t = 0", "- for e in a:", "- ...
false
0.044974
0.115975
0.387788
[ "s228601044", "s527087212" ]
u393512980
p03295
python
s317907778
s009018285
1,986
1,614
64,260
60,064
Accepted
Accepted
18.73
def main(): N, M = list(map(int, input().split())) a_b = sorted([list(map(int, input().split())) for _ in range(M)]) used = [0] * M ans = 0 for i in range(M): k = M - i - 1 if used[k]: continue used[k], c = 1, a_b[k][0] for j in range(k): ...
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) a_b = sorted([list(map(int, input().split())) for _ in range(M)]) used = [0] * M ans = 0 for i in range(M): k = M - i - 1 if used[k]: continue used[k], c = 1, a_b...
18
21
456
497
def main(): N, M = list(map(int, input().split())) a_b = sorted([list(map(int, input().split())) for _ in range(M)]) used = [0] * M ans = 0 for i in range(M): k = M - i - 1 if used[k]: continue used[k], c = 1, a_b[k][0] for j in range(k): if a_...
import sys input = sys.stdin.readline def main(): N, M = list(map(int, input().split())) a_b = sorted([list(map(int, input().split())) for _ in range(M)]) used = [0] * M ans = 0 for i in range(M): k = M - i - 1 if used[k]: continue used[k], c = 1, a_b[k][0] ...
false
14.285714
[ "+import sys", "+", "+input = sys.stdin.readline", "+", "+" ]
false
0.039291
0.037931
1.035844
[ "s317907778", "s009018285" ]
u071680334
p02821
python
s122406031
s343444401
1,198
819
14,268
20,560
Accepted
Accepted
31.64
from bisect import bisect_left def main(): n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() b = [0]*(n+1) for i in range(n): b[i+1] = a[i] + b[i] ok = 0; ng = 2 * 10**5 + 5 while ok+1 < ng: mid = (ok + 1 + ng) // 2 buf = 0...
from bisect import bisect_left def main(): n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() L, R = 0, 2 * 10**5 + 1 while L+1 < R: P = (L+R)//2 cnt = 0 for v in a: x = P - v cnt += n - bisect_left(a, x) ...
33
35
795
766
from bisect import bisect_left def main(): n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() b = [0] * (n + 1) for i in range(n): b[i + 1] = a[i] + b[i] ok = 0 ng = 2 * 10**5 + 5 while ok + 1 < ng: mid = (ok + 1 + ng) // 2 buf =...
from bisect import bisect_left def main(): n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() L, R = 0, 2 * 10**5 + 1 while L + 1 < R: P = (L + R) // 2 cnt = 0 for v in a: x = P - v cnt += n - bisect_left(a, x) ...
false
5.714286
[ "- b = [0] * (n + 1)", "+ L, R = 0, 2 * 10**5 + 1", "+ while L + 1 < R:", "+ P = (L + R) // 2", "+ cnt = 0", "+ for v in a:", "+ x = P - v", "+ cnt += n - bisect_left(a, x)", "+ if cnt >= m:", "+ L = P", "+ else:", "+...
false
0.035674
0.042537
0.83865
[ "s122406031", "s343444401" ]
u077291787
p03761
python
s863449199
s018483954
29
25
3,768
3,768
Accepted
Accepted
13.79
# ABC058C - 怪文書 / Dubious Document (ARC071C) import sys input = sys.stdin.readline from collections import OrderedDict from string import ascii_lowercase def main(): n = int(eval(input())) lst = [input().rstrip() for _ in range(n)] cnt = OrderedDict.fromkeys(ascii_lowercase, 0) for i in l...
# ABC058C - 怪文書 / Dubious Document (ARC071C) from collections import Counter from string import ascii_lowercase def main(): N = int(eval(input())) D = tuple(Counter(eval(input())) for _ in range(N)) ans = "" for s in ascii_lowercase: if all(s in d for d in D): ans += s *...
30
17
668
389
# ABC058C - 怪文書 / Dubious Document (ARC071C) import sys input = sys.stdin.readline from collections import OrderedDict from string import ascii_lowercase def main(): n = int(eval(input())) lst = [input().rstrip() for _ in range(n)] cnt = OrderedDict.fromkeys(ascii_lowercase, 0) for i in lst[0]: ...
# ABC058C - 怪文書 / Dubious Document (ARC071C) from collections import Counter from string import ascii_lowercase def main(): N = int(eval(input())) D = tuple(Counter(eval(input())) for _ in range(N)) ans = "" for s in ascii_lowercase: if all(s in d for d in D): ans += s * min(d[s] f...
false
43.333333
[ "-import sys", "-", "-input = sys.stdin.readline", "-from collections import OrderedDict", "+from collections import Counter", "- n = int(eval(input()))", "- lst = [input().rstrip() for _ in range(n)]", "- cnt = OrderedDict.fromkeys(ascii_lowercase, 0)", "- for i in lst[0]:", "- ...
false
0.098757
0.050101
1.971171
[ "s863449199", "s018483954" ]
u389910364
p03290
python
s636265444
s915615833
467
160
15,660
12,532
Accepted
Accepted
65.74
import bisect import heapq import itertools import math import os import re import string import sys from collections import Counter, deque, defaultdict from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter import numpy as np if o...
import itertools import os import sys import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 D, G = list(map(int, sys.stdin.readline().split())) P, C = list(zip(*[list(map(int, sys.stdin.rea...
46
52
1,209
1,488
import bisect import heapq import itertools import math import os import re import string import sys from collections import Counter, deque, defaultdict from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter import numpy as np if os.getenv("LOCAL")...
import itertools import os import sys import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 D, G = list(map(int, sys.stdin.readline().split())) P, C = list(zip(*[list(map(int, sys.stdin.readline().split())) for ...
false
11.538462
[ "-import bisect", "-import heapq", "-import math", "-import re", "-import string", "-from collections import Counter, deque, defaultdict", "-from decimal import Decimal", "-from fractions import gcd", "-from functools import lru_cache, reduce", "-from operator import itemgetter", "+# ans = P.sum...
false
0.251863
0.240221
1.048462
[ "s636265444", "s915615833" ]
u294922877
p02381
python
s496051290
s847487171
50
20
7,096
5,708
Accepted
Accepted
60
from math import sqrt from statistics import mean def standard_deviate(numbers): m = mean(numbers) b = sum([(n - m)**2 for n in numbers]) return sqrt(b/len(numbers)) if __name__ == '__main__': while True: n = int(eval(input())) if n == 0: break students...
from math import sqrt def standard_deviate(numbers): m = sum(numbers) / len(numbers) d = sqrt(sum([(n - m)**2 for n in numbers]) / len(numbers)) return d if __name__ == '__main__': while eval(input()) != '0': students = list(map(int, input().split())) print((standard_deviate(...
16
12
399
326
from math import sqrt from statistics import mean def standard_deviate(numbers): m = mean(numbers) b = sum([(n - m) ** 2 for n in numbers]) return sqrt(b / len(numbers)) if __name__ == "__main__": while True: n = int(eval(input())) if n == 0: break students = list...
from math import sqrt def standard_deviate(numbers): m = sum(numbers) / len(numbers) d = sqrt(sum([(n - m) ** 2 for n in numbers]) / len(numbers)) return d if __name__ == "__main__": while eval(input()) != "0": students = list(map(int, input().split())) print((standard_deviate(studen...
false
25
[ "-from statistics import mean", "- m = mean(numbers)", "- b = sum([(n - m) ** 2 for n in numbers])", "- return sqrt(b / len(numbers))", "+ m = sum(numbers) / len(numbers)", "+ d = sqrt(sum([(n - m) ** 2 for n in numbers]) / len(numbers))", "+ return d", "- while True:", "- ...
false
0.062942
0.0399
1.577501
[ "s496051290", "s847487171" ]
u729133443
p02552
python
s111066993
s415753795
32
26
9,204
9,152
Accepted
Accepted
18.75
print((1-int(eval(input()))))
print((+(eval(input())<'1')))
1
1
21
21
print((1 - int(eval(input()))))
print((+(eval(input()) < "1")))
false
0
[ "-print((1 - int(eval(input()))))", "+print((+(eval(input()) < \"1\")))" ]
false
0.113472
0.117234
0.967913
[ "s111066993", "s415753795" ]
u659712937
p03281
python
s753141897
s406742098
168
66
38,384
61,892
Accepted
Accepted
60.71
n=int(eval(input())) def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[...
n=int(eval(input())) def count_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return len(lower_divisors + upper_divi...
22
22
443
478
n = int(eval(input())) def make_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i * i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n // i) i += 1 return lower_divisors + upper_divisors[::-1]...
n = int(eval(input())) def count_divisors(n): lower_divisors, upper_divisors = [], [] i = 1 while i * i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n // i) i += 1 return len(lower_divisors + upper_divisors[...
false
0
[ "-def make_divisors(n):", "+def count_divisors(n):", "- return lower_divisors + upper_divisors[::-1]", "+ return len(lower_divisors + upper_divisors[::-1])", "- l = make_divisors(i)", "- if len(l) == 8:", "+ c = count_divisors(i)", "+ if c == 8:", "+ # pr...
false
0.068435
0.085048
0.804667
[ "s753141897", "s406742098" ]
u711539583
p02936
python
s364152547
s691174622
1,889
790
237,732
128,376
Accepted
Accepted
58.18
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n, q = list(map(int, input().split())) d = [[] for _ in range(n)] for _ in range(n-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 d[a].append(b) d[b].append(a) d2 = [0] * n for _ in range(q): p, x = list(ma...
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n, q = list(map(int, input().split())) d = [[] for _ in range(n)] for _ in range(n-1): a, b = list(map(int, input().split())) a -= 1 b -= 1 d[a].append(b) d[b].append(a) d2 = [0] * n for _ in range(q): p, x = list(ma...
26
32
558
721
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n, q = list(map(int, input().split())) d = [[] for _ in range(n)] for _ in range(n - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 d[a].append(b) d[b].append(a) d2 = [0] * n for _ in range(q): p, x = list(map(int, inp...
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n, q = list(map(int, input().split())) d = [[] for _ in range(n)] for _ in range(n - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 d[a].append(b) d[b].append(a) d2 = [0] * n for _ in range(q): p, x = list(map(int, inp...
false
18.75
[ "+from collections import deque", "- point += d2[cur]", "- ans[cur] = point", "- for e in d[cur]:", "- if e != pre:", "- dfs(e, cur, point)", "+ stack = deque([[cur, pre, point]])", "+ while stack:", "+ cur, pre, point = stack.pop()", "+ point += d2[c...
false
0.038203
0.038538
0.991308
[ "s364152547", "s691174622" ]
u513081876
p04012
python
s947937697
s002372400
20
17
3,316
2,940
Accepted
Accepted
15
import collections w = eval(input()) W = list(collections.Counter(w).values()) for i in W: if i % 2 != 0: print('No') break else: print('Yes')
w = eval(input()) s = set([i for i in w]) for i in s: if w.count(i) % 2 != 0: print('No') break else: print('Yes')
11
9
166
142
import collections w = eval(input()) W = list(collections.Counter(w).values()) for i in W: if i % 2 != 0: print("No") break else: print("Yes")
w = eval(input()) s = set([i for i in w]) for i in s: if w.count(i) % 2 != 0: print("No") break else: print("Yes")
false
18.181818
[ "-import collections", "-", "-W = list(collections.Counter(w).values())", "-for i in W:", "- if i % 2 != 0:", "+s = set([i for i in w])", "+for i in s:", "+ if w.count(i) % 2 != 0:" ]
false
0.05435
0.043621
1.245952
[ "s947937697", "s002372400" ]
u894258749
p03329
python
s614728863
s565675849
392
21
6,184
3,064
Accepted
Accepted
94.64
N = int(eval(input())) memo = [N]*(N+1) unit = [1] for b in [6,9]: u = b while u <= N: unit.append(u) u *= b unit.sort() cur = set({0}) for i in range(1,N+1): prev = cur cur = set() for p in prev: for u in unit: c = p + u if c == N: ...
from bisect import bisect_right N = int(eval(input())) unit = [1] for b in [6,9]: u = b while u <= N: unit.append(u) u *= b unit.sort() Nu = len(unit) ans = N state_pool = [(0, 0, Nu-1)] while state_pool: n, i, pk = state_pool.pop() if N - n >= (ans-i)*unit[pk]: ...
24
27
496
579
N = int(eval(input())) memo = [N] * (N + 1) unit = [1] for b in [6, 9]: u = b while u <= N: unit.append(u) u *= b unit.sort() cur = set({0}) for i in range(1, N + 1): prev = cur cur = set() for p in prev: for u in unit: c = p + u if c == N: ...
from bisect import bisect_right N = int(eval(input())) unit = [1] for b in [6, 9]: u = b while u <= N: unit.append(u) u *= b unit.sort() Nu = len(unit) ans = N state_pool = [(0, 0, Nu - 1)] while state_pool: n, i, pk = state_pool.pop() if N - n >= (ans - i) * unit[pk]: continue ...
false
11.111111
[ "+from bisect import bisect_right", "+", "-memo = [N] * (N + 1)", "-cur = set({0})", "-for i in range(1, N + 1):", "- prev = cur", "- cur = set()", "- for p in prev:", "- for u in unit:", "- c = p + u", "- if c == N:", "- print(i)", "- ...
false
0.14114
0.0379
3.724006
[ "s614728863", "s565675849" ]
u875291233
p02564
python
s317106328
s097131683
2,324
1,535
324,360
237,316
Accepted
Accepted
33.95
def StrongConnectedComponent(g,S): from collections import deque S = deque() #逆辺で帰りがけが遅い順にpopされるスタック #まず逆辺でDFS、帰りがけに S に積む q = deque() n = len(g) gp = [1]*n # 1 -> 0 -> -1 for i in range(n): if gp[i] == 1: q.append(i) while q: v = q....
def SCC_Tarjan(g): def dfs(v): nonlocal idx used[v] = 1 pre[v] = low[v] = idx idx += 1 S.append(v) onS[v] = 1 for c in g[v]: if not used[c]: dfs(c) low[v] = min(low[v], low[c]) elif onS[c]: ...
87
67
2,175
1,557
def StrongConnectedComponent(g, S): from collections import deque S = deque() # 逆辺で帰りがけが遅い順にpopされるスタック # まず逆辺でDFS、帰りがけに S に積む q = deque() n = len(g) gp = [1] * n # 1 -> 0 -> -1 for i in range(n): if gp[i] == 1: q.append(i) while q: v = q.pop...
def SCC_Tarjan(g): def dfs(v): nonlocal idx used[v] = 1 pre[v] = low[v] = idx idx += 1 S.append(v) onS[v] = 1 for c in g[v]: if not used[c]: dfs(c) low[v] = min(low[v], low[c]) elif onS[c]: ...
false
22.988506
[ "-def StrongConnectedComponent(g, S):", "- from collections import deque", "+def SCC_Tarjan(g):", "+ def dfs(v):", "+ nonlocal idx", "+ used[v] = 1", "+ pre[v] = low[v] = idx", "+ idx += 1", "+ S.append(v)", "+ onS[v] = 1", "+ for c in g[v]:...
false
0.048891
0.048215
1.014033
[ "s317106328", "s097131683" ]
u828706986
p03450
python
s735561556
s395051601
606
489
77,472
125,496
Accepted
Accepted
19.31
import sys def main(): n, m = list(map(int, sys.stdin.readline().split())) g = [[] for i in range(n)] for i in range(m): l, r, d = list(map(int, sys.stdin.readline().split())) g[l - 1].append((r - 1, d)) g[r - 1].append((l - 1, -d)) dis = [0] * n visited = [False...
import sys def main(): n, m = list(map(int, sys.stdin.readline().split())) g = [[] for i in range(n)] deg = [0] * n lines = sys.stdin.read().splitlines() for line in lines: l, r, d = list(map(int, line.split())) g[l - 1].append((r - 1, d)) deg[r - 1] += 1 di...
35
35
905
860
import sys def main(): n, m = list(map(int, sys.stdin.readline().split())) g = [[] for i in range(n)] for i in range(m): l, r, d = list(map(int, sys.stdin.readline().split())) g[l - 1].append((r - 1, d)) g[r - 1].append((l - 1, -d)) dis = [0] * n visited = [False] * n f...
import sys def main(): n, m = list(map(int, sys.stdin.readline().split())) g = [[] for i in range(n)] deg = [0] * n lines = sys.stdin.read().splitlines() for line in lines: l, r, d = list(map(int, line.split())) g[l - 1].append((r - 1, d)) deg[r - 1] += 1 dis = [-1] * n...
false
0
[ "- for i in range(m):", "- l, r, d = list(map(int, sys.stdin.readline().split()))", "+ deg = [0] * n", "+ lines = sys.stdin.read().splitlines()", "+ for line in lines:", "+ l, r, d = list(map(int, line.split()))", "- g[r - 1].append((l - 1, -d))", "- dis = [0] * n",...
false
0.111444
0.041454
2.688355
[ "s735561556", "s395051601" ]
u102461423
p02941
python
s751060057
s704898958
1,138
583
110,932
121,280
Accepted
Accepted
48.77
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) from heapq import heappop, heappush N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] q = [] push = lambda x,i: heappush(q, (-x<<30)+i) for i,x in enumerate(B): push(x,i) answer =...
import sys import numpy as np import numba from numba import njit, b1, i4, i8, f8 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8[:], i8[:]), cache=True) def main(A, B): N = len(A) st, p = np.arange(1 << 20), N ans = 0 wh...
38
34
731
840
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from heapq import heappop, heappush N = int(eval(input())) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] q = [] push = lambda x, i: heappush(q, (-x << 30) + i) for i, x in enumerate(B): push(x, i) answer = 0 mask = (1...
import sys import numpy as np import numba from numba import njit, b1, i4, i8, f8 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8[:], i8[:]), cache=True) def main(A, B): N = len(A) st, p = np.arange(1 << 20), N ans = 0 while p: ...
false
10.526316
[ "+import numpy as np", "+import numba", "+from numba import njit, b1, i4, i8, f8", "-input = sys.stdin.readline", "-sys.setrecursionlimit(10**7)", "-from heapq import heappop, heappush", "+read = sys.stdin.buffer.read", "+readline = sys.stdin.buffer.readline", "+readlines = sys.stdin.buffer.readline...
false
0.091405
0.207756
0.439966
[ "s751060057", "s704898958" ]
u147801965
p00201
python
s089242371
s576543664
20
10
4,260
4,260
Accepted
Accepted
50
while True: things = {} count = eval(input()) if count == 0: break for i in range(count): fuga = input().split() things[fuga[0]] = int(fuga[1]) for i in range(eval(input())): fuga = input().split() money =0 for j in range(int(fuga[1])): ...
while True: things = {} count = eval(input()) if count == 0: break for i in range(count): fuga = input().split() things[fuga[0]] = int(fuga[1]) for i in range(eval(input())): fuga = input().split() money =0 for j in range(int(fuga[1])): ...
17
16
562
556
while True: things = {} count = eval(input()) if count == 0: break for i in range(count): fuga = input().split() things[fuga[0]] = int(fuga[1]) for i in range(eval(input())): fuga = input().split() money = 0 for j in range(int(fuga[1])): ho...
while True: things = {} count = eval(input()) if count == 0: break for i in range(count): fuga = input().split() things[fuga[0]] = int(fuga[1]) for i in range(eval(input())): fuga = input().split() money = 0 for j in range(int(fuga[1])): ho...
false
5.882353
[ "- fin = things[ans] if ans in things else 0", "- print(fin)", "+ print(\"%s\" % (things[ans] if ans in things else \"0\"))" ]
false
0.046902
0.047018
0.997545
[ "s089242371", "s576543664" ]
u137038354
p02608
python
s197723014
s677792421
1,487
854
9,180
9,368
Accepted
Accepted
42.57
N = int(eval(input())) ls = [0]*(N+2) for i in range(1,151): for j in range(1,151): for k in range(1,151): t = i*i + j*j + k*k + i*j + j*k + k*i if t <= N : ls[t] += 1 for p in range(1,N+1): print((ls[p]))
N = int(eval(input())) ls = [0]*(N+2) for i in range(1,100): for j in range(1,100): for k in range(1,100): t = i**2 + j**2 + k**2 + i*j + j*k + k*i if t <= N : ls[t] += 1 for p in range(1,N+1): print((ls[p]))
12
12
267
270
N = int(eval(input())) ls = [0] * (N + 2) for i in range(1, 151): for j in range(1, 151): for k in range(1, 151): t = i * i + j * j + k * k + i * j + j * k + k * i if t <= N: ls[t] += 1 for p in range(1, N + 1): print((ls[p]))
N = int(eval(input())) ls = [0] * (N + 2) for i in range(1, 100): for j in range(1, 100): for k in range(1, 100): t = i**2 + j**2 + k**2 + i * j + j * k + k * i if t <= N: ls[t] += 1 for p in range(1, N + 1): print((ls[p]))
false
0
[ "-for i in range(1, 151):", "- for j in range(1, 151):", "- for k in range(1, 151):", "- t = i * i + j * j + k * k + i * j + j * k + k * i", "+for i in range(1, 100):", "+ for j in range(1, 100):", "+ for k in range(1, 100):", "+ t = i**2 + j**2 + k**2 + i * j...
false
2.344625
1.252834
1.871457
[ "s197723014", "s677792421" ]
u660106942
p02762
python
s079545870
s144107052
1,991
1,786
124,064
112,336
Accepted
Accepted
10.3
class UnionFind(object): "https://www.kumilog.net/entry/union-find" def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索 """ if ...
class UnionFind: "https://www.kumilog.net/entry/union-find" def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索 """ if self.par[x...
89
76
1,863
1,653
class UnionFind(object): "https://www.kumilog.net/entry/union-find" def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索 """ if self.par[x] ...
class UnionFind: "https://www.kumilog.net/entry/union-find" def __init__(self, n=1): self.par = [i for i in range(n)] self.rank = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def find(self, x): """ x が属するグループを探索 """ if self.par[x] == x: ...
false
14.606742
[ "-class UnionFind(object):", "+class UnionFind:", "- if fr.get(a) is not None:", "- fr[a] += 1", "- else:", "- fr[a] = 1", "- if fr.get(b) is not None:", "- fr[b] += 1", "- else:", "- fr[b] = 1", "+ fr[a] = fr.get(a, 0) + 1", "+ fr[b] = fr.get(b, 0...
false
0.051581
0.008247
6.254385
[ "s079545870", "s144107052" ]
u912862653
p03608
python
s742117616
s291782874
495
414
59,480
55,388
Accepted
Accepted
16.36
import itertools def warshall_floyd(D, n): for k in range(n): for i in range(n): for j in range(n): D[i][j] = min(D[i][j], D[i][k]+D[k][j]) N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) D = [[float('inf')]*N for _ in range(N)] for i ...
import itertools import sys input = sys.stdin.readline def warshall_floyd(D, n): for k in range(n): for i in range(n): for j in range(n): D[i][j] = min(D[i][j], D[i][k]+D[k][j]) def main(): N, M, R = list(map(int, input().split())) r = list(m...
29
35
646
825
import itertools def warshall_floyd(D, n): for k in range(n): for i in range(n): for j in range(n): D[i][j] = min(D[i][j], D[i][k] + D[k][j]) N, M, R = list(map(int, input().split())) r = list(map(int, input().split())) D = [[float("inf")] * N for _ in range(N)] for i in rang...
import itertools import sys input = sys.stdin.readline def warshall_floyd(D, n): for k in range(n): for i in range(n): for j in range(n): D[i][j] = min(D[i][j], D[i][k] + D[k][j]) def main(): N, M, R = list(map(int, input().split())) r = list(map(int, input().split()...
false
17.142857
[ "+import sys", "+", "+input = sys.stdin.readline", "-N, M, R = list(map(int, input().split()))", "-r = list(map(int, input().split()))", "-D = [[float(\"inf\")] * N for _ in range(N)]", "-for i in range(N):", "- D[i][i] = 0", "-for _ in range(M):", "- a, b, c = list(map(int, input().split())...
false
0.12791
0.048612
2.631269
[ "s742117616", "s291782874" ]