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
u422104747
p02609
python
s808016502
s334422150
353
282
82,376
81,008
Accepted
Accepted
20.11
def popcount(x): return bin(x)[2:].count("1") def f(x): cnt=0 while(x>0): x%=popcount(x) cnt+=1 return cnt n=int(eval(input())) s=eval(input()) d=s.count("1") if d==0: for i in range(n): print((1)) elif d==1: if s[-1]=="1": for i in range(n-1):...
def popcount(x): return bin(x)[2:].count("1") def f(x): cnt=0 while(x>0): x%=popcount(x) cnt+=1 return cnt n=int(eval(input())) s=eval(input()) d=s.count("1") if d==0: for i in range(n): print((1)) elif d==1: if s[-1]=="1": for i in range(n-1):...
59
48
1,136
932
def popcount(x): return bin(x)[2:].count("1") def f(x): cnt = 0 while x > 0: x %= popcount(x) cnt += 1 return cnt n = int(eval(input())) s = eval(input()) d = s.count("1") if d == 0: for i in range(n): print((1)) elif d == 1: if s[-1] == "1": for i in range(n ...
def popcount(x): return bin(x)[2:].count("1") def f(x): cnt = 0 while x > 0: x %= popcount(x) cnt += 1 return cnt n = int(eval(input())) s = eval(input()) d = s.count("1") if d == 0: for i in range(n): print((1)) elif d == 1: if s[-1] == "1": for i in range(n ...
false
18.644068
[ "+ ints = int(s, 2)", "+ m = ints % (d - 1)", "+ M = ints % (d + 1)", "- toaddm = 1", "- toaddM = 1", "- m = 0", "- M = 0", "- for i in range(n):", "- if s[i] == \"1\":", "- m += toaddm", "- M += toaddM", "- m %= d - 1", "- ...
false
0.040552
0.041972
0.96615
[ "s808016502", "s334422150" ]
u630511239
p02995
python
s459586394
s441468792
35
30
5,076
9,184
Accepted
Accepted
14.29
A, B, C, D = list(map(int, input().split())) import fractions g = fractions.gcd(C, D) ac = (A-1)//C bc = B//C c = bc-ac ad = (A-1)//D bd = B//D d = bd-ad cdg = (C*D)//g acd = (A-1)//cdg bcd = B//cdg cd = bcd-acd ans = B-A+1-c-d+cd print(ans)
A, B, C, D = list(map(int, input().split())) A -= 1 import math g = C*D//math.gcd(C, D) a = A//C + A//D - A//g b = B//C + B//D - B//g ans = B - A - b + a print(ans)
15
8
249
165
A, B, C, D = list(map(int, input().split())) import fractions g = fractions.gcd(C, D) ac = (A - 1) // C bc = B // C c = bc - ac ad = (A - 1) // D bd = B // D d = bd - ad cdg = (C * D) // g acd = (A - 1) // cdg bcd = B // cdg cd = bcd - acd ans = B - A + 1 - c - d + cd print(ans)
A, B, C, D = list(map(int, input().split())) A -= 1 import math g = C * D // math.gcd(C, D) a = A // C + A // D - A // g b = B // C + B // D - B // g ans = B - A - b + a print(ans)
false
46.666667
[ "-import fractions", "+A -= 1", "+import math", "-g = fractions.gcd(C, D)", "-ac = (A - 1) // C", "-bc = B // C", "-c = bc - ac", "-ad = (A - 1) // D", "-bd = B // D", "-d = bd - ad", "-cdg = (C * D) // g", "-acd = (A - 1) // cdg", "-bcd = B // cdg", "-cd = bcd - acd", "-ans = B - A + 1 ...
false
0.136314
0.090219
1.510921
[ "s459586394", "s441468792" ]
u047796752
p02722
python
s879302323
s000791510
233
208
39,152
39,024
Accepted
Accepted
10.73
def make_div(n): divs = [] for i in range(1, int(n**0.5)+1): if n%i==0: divs.append(i) if i!=n//i: divs.append(n//i) divs.sort() return divs N = int(eval(input())) d = make_div(N) d = d[1:] s = set() for di ...
def make_divs(n): divs = [] for i in range(1, int(n**0.5)+1): if n%i==0: divs.append(i) if i!=n//i: divs.append(n//i) return divs N = int(eval(input())) divs = make_divs(N) ans = 0 for d in divs: if d==1: ...
35
32
504
488
def make_div(n): divs = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divs.append(i) if i != n // i: divs.append(n // i) divs.sort() return divs N = int(eval(input())) d = make_div(N) d = d[1:] s = set() for di in d: N2 = N while N2 % di ...
def make_divs(n): divs = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divs.append(i) if i != n // i: divs.append(n // i) return divs N = int(eval(input())) divs = make_divs(N) ans = 0 for d in divs: if d == 1: continue N2 = N whi...
false
8.571429
[ "-def make_div(n):", "+def make_divs(n):", "- divs.sort()", "-d = make_div(N)", "-d = d[1:]", "-s = set()", "-for di in d:", "+divs = make_divs(N)", "+ans = 0", "+for d in divs:", "+ if d == 1:", "+ continue", "- while N2 % di == 0:", "- N2 //= di", "- if (N2 - ...
false
0.007929
0.054625
0.145161
[ "s879302323", "s000791510" ]
u790710233
p03546
python
s760551271
s399302858
260
33
17,364
3,064
Accepted
Accepted
87.31
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense from collections import defaultdict h, w = list(map(int, input().split())) table = [list(map(int, input().split())) for _ in range(10)] dd = defaultdict(int) for _ in range(h): for x in map(int, input().split()): if x == -1: c...
import heapq h, w = list(map(int, input().split())) graph = [list(map(int, input().split())) for _ in range(10)] trans_graph = list(zip(*graph)) next_nodes = [] for idx, d in enumerate(trans_graph[1]): next_nodes.append((d, idx)) heapq.heapify(next_nodes) INF = 10**9 decided = [0]*10 decided[1] = 1 ...
18
35
516
789
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense from collections import defaultdict h, w = list(map(int, input().split())) table = [list(map(int, input().split())) for _ in range(10)] dd = defaultdict(int) for _ in range(h): for x in map(int, input().split()): if x == -1: continue...
import heapq h, w = list(map(int, input().split())) graph = [list(map(int, input().split())) for _ in range(10)] trans_graph = list(zip(*graph)) next_nodes = [] for idx, d in enumerate(trans_graph[1]): next_nodes.append((d, idx)) heapq.heapify(next_nodes) INF = 10**9 decided = [0] * 10 decided[1] = 1 dist = [INF] ...
false
48.571429
[ "-from scipy.sparse.csgraph import dijkstra, csgraph_from_dense", "-from collections import defaultdict", "+import heapq", "-table = [list(map(int, input().split())) for _ in range(10)]", "-dd = defaultdict(int)", "+graph = [list(map(int, input().split())) for _ in range(10)]", "+trans_graph = list(zip(...
false
0.562601
0.037959
14.821453
[ "s760551271", "s399302858" ]
u618251217
p02862
python
s701566994
s619830753
1,027
558
9,220
93,156
Accepted
Accepted
45.67
mod = 10**9 + 7 def nCk(n,k,p): global mod k = min(k, n-k) X = 1 for i in range(k): X = X * (n - i) % p X = X * pow(i + 1, p - 2, p) % p return X X,Y = list(map(int, input().split())) ans = 0 if X <= 2*Y and Y <= 2*X and (X + Y) % 3 == 0: a = (2*Y-X) // 3 ...
X,Y = list(map(int, input().split())) mod = 10**9 + 7 def nCk(n,k,p): fact = [1,1] + [0]*(n-1) inv = [0,1] + [0]*(n-1) factinv = [1,1] + [0]*(n-1) for i in range(2, n+1): fact[i] = i * fact[i-1] % p inv[i] = - inv[p % i] * (p // i) % p factinv[i] = factinv...
20
21
377
537
mod = 10**9 + 7 def nCk(n, k, p): global mod k = min(k, n - k) X = 1 for i in range(k): X = X * (n - i) % p X = X * pow(i + 1, p - 2, p) % p return X X, Y = list(map(int, input().split())) ans = 0 if X <= 2 * Y and Y <= 2 * X and (X + Y) % 3 == 0: a = (2 * Y - X) // 3 b =...
X, Y = list(map(int, input().split())) mod = 10**9 + 7 def nCk(n, k, p): fact = [1, 1] + [0] * (n - 1) inv = [0, 1] + [0] * (n - 1) factinv = [1, 1] + [0] * (n - 1) for i in range(2, n + 1): fact[i] = i * fact[i - 1] % p inv[i] = -inv[p % i] * (p // i) % p factinv[i] = factinv[...
false
4.761905
[ "+X, Y = list(map(int, input().split()))", "- global mod", "- k = min(k, n - k)", "- X = 1", "- for i in range(k):", "- X = X * (n - i) % p", "- X = X * pow(i + 1, p - 2, p) % p", "- return X", "+ fact = [1, 1] + [0] * (n - 1)", "+ inv = [0, 1] + [0] * (n - 1)", ...
false
0.007092
0.39419
0.017991
[ "s701566994", "s619830753" ]
u094191970
p02912
python
s914933148
s113307058
171
154
14,180
14,180
Accepted
Accepted
9.94
import heapq n,m=list(map(int,input().split())) a=[-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): max=-heapq.heappop(a) heapq.heappush(a,-1*(max//2)) print((sum([-int(i) for i in a])))
import heapq n,m=list(map(int,input().split())) a=[-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): max=-heapq.heappop(a) heapq.heappush(a,-1*(max//2)) print((-sum(a)))
11
11
214
196
import heapq n, m = list(map(int, input().split())) a = [-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): max = -heapq.heappop(a) heapq.heappush(a, -1 * (max // 2)) print((sum([-int(i) for i in a])))
import heapq n, m = list(map(int, input().split())) a = [-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): max = -heapq.heappop(a) heapq.heappush(a, -1 * (max // 2)) print((-sum(a)))
false
0
[ "-print((sum([-int(i) for i in a])))", "+print((-sum(a)))" ]
false
0.050229
0.046035
1.091102
[ "s914933148", "s113307058" ]
u263830634
p03722
python
s045443928
s753640845
835
341
3,444
45,292
Accepted
Accepted
59.16
#単一始点最短経路問題 #負の辺があっても動作する #最短経路を求める #計算量O(N * M) INF = 10 ** 15 #入力 N, M = list(map(int, input().split())) # 入力は1-index # 内部で0-indexにして処理 G = [] for _ in range(M): #M個の辺の情報を受け取る l, r, s = list(map(int, input().split())) #lからrへ重みsの辺が存在 G += [[l-1, r-1, -s]] #有向グラフのときはここだけ #メイン文 d = [INF] ...
#単一始点最短経路問題 #負の辺があっても動作する #最短経路を求める #計算量O(N * M) INF = 10 ** 15 #入力 N, M = list(map(int, input().split())) # 入力は1-index # 内部で0-indexにして処理 G = [] for _ in range(M): #M個の辺の情報を受け取る l, r, s = list(map(int, input().split())) #lからrへ重みsの辺が存在 G += [[l-1, r-1, -s]] #有向グラフのときはここだけ #メイン文 d = [INF] ...
81
81
1,810
1,766
# 単一始点最短経路問題 # 負の辺があっても動作する # 最短経路を求める # 計算量O(N * M) INF = 10**15 # 入力 N, M = list(map(int, input().split())) # 入力は1-index # 内部で0-indexにして処理 G = [] for _ in range(M): # M個の辺の情報を受け取る l, r, s = list(map(int, input().split())) # lからrへ重みsの辺が存在 G += [[l - 1, r - 1, -s]] # 有向グラフのときはここだけ # メイン文 d = [INF] * N # 最短距...
# 単一始点最短経路問題 # 負の辺があっても動作する # 最短経路を求める # 計算量O(N * M) INF = 10**15 # 入力 N, M = list(map(int, input().split())) # 入力は1-index # 内部で0-indexにして処理 G = [] for _ in range(M): # M個の辺の情報を受け取る l, r, s = list(map(int, input().split())) # lからrへ重みsの辺が存在 G += [[l - 1, r - 1, -s]] # 有向グラフのときはここだけ # メイン文 d = [INF] * N # 最短距...
false
0
[ "-prev = [-1] * N", "+# prev = [-1] * N", "+negative = [False] * N", "- while True:", "- if count == N:", "- # print ('B')", "- path = restore(N)", "- # print (prev)", "- # print (path)", "- update = False", "- for i in ...
false
0.038242
0.039035
0.979703
[ "s045443928", "s753640845" ]
u462329577
p03013
python
s350287155
s949845142
493
449
51,032
460,020
Accepted
Accepted
8.92
n,m = list(map(int,input().split())) #a = [int(input()) for i in range(m)] a=set() for i in range(m): tmp=int(eval(input())) a.add(tmp) mod = 10**9+7 dp = [0]*(n+1) dp[0] = 1 j=0 for i in range(1,n+1): if i in a: #dp[a[j]] = 0 continue if i==1: dp[1] = dp[0] continue dp[i...
#!/usr/bin/env python3 n,m = list(map(int,input().split())) a = [int(eval(input())) for _ in range(m)] dp = [-1]*(n+2)#dp[k]はk-1段目に到達する方法 dp[0] = 0 dp[1] = 1 mod = 10**9+7 for i in a: dp[i+1] = 0 for i in range(n+2): if dp[i] == -1:#already visited or prepared dp[i] = (dp[i-1]+dp[i-2]) #prin...
20
14
355
333
n, m = list(map(int, input().split())) # a = [int(input()) for i in range(m)] a = set() for i in range(m): tmp = int(eval(input())) a.add(tmp) mod = 10**9 + 7 dp = [0] * (n + 1) dp[0] = 1 j = 0 for i in range(1, n + 1): if i in a: # dp[a[j]] = 0 continue if i == 1: dp[1] = dp[0] ...
#!/usr/bin/env python3 n, m = list(map(int, input().split())) a = [int(eval(input())) for _ in range(m)] dp = [-1] * (n + 2) # dp[k]はk-1段目に到達する方法 dp[0] = 0 dp[1] = 1 mod = 10**9 + 7 for i in a: dp[i + 1] = 0 for i in range(n + 2): if dp[i] == -1: # already visited or prepared dp[i] = dp[i - 1] + dp[i ...
false
30
[ "+#!/usr/bin/env python3", "-# a = [int(input()) for i in range(m)]", "-a = set()", "-for i in range(m):", "- tmp = int(eval(input()))", "- a.add(tmp)", "+a = [int(eval(input())) for _ in range(m)]", "+dp = [-1] * (n + 2) # dp[k]はk-1段目に到達する方法", "+dp[0] = 0", "+dp[1] = 1", "-dp = [0] * (n ...
false
0.04013
0.040398
0.993368
[ "s350287155", "s949845142" ]
u867826040
p02580
python
s246546231
s571223278
2,153
942
156,420
138,456
Accepted
Accepted
56.25
#from random import randint import numpy as np def f(h,w,m,ins): yp = np.zeros(h,dtype=np.int32) xp = np.zeros(w,dtype=np.int32) s = set() for hi,wi in ins: s.add((hi-1,wi-1)) yp[hi-1] += 1 xp[wi-1] += 1 ypm = yp.max() xpm = xp.max() yps = np.where(yp ...
#from random import randint def f(h,w,m,ins): yp = [0]*h xp = [0]*w s = set() for hi,wi in ins: s.add((hi-1,wi-1)) yp[hi-1] += 1 xp[wi-1] += 1 ypm = max(yp) xpm = max(xp) yps = [i for i in range(h) if yp[i] == ypm] xps = [i for i in range(w) if xp[i]...
35
33
991
923
# from random import randint import numpy as np def f(h, w, m, ins): yp = np.zeros(h, dtype=np.int32) xp = np.zeros(w, dtype=np.int32) s = set() for hi, wi in ins: s.add((hi - 1, wi - 1)) yp[hi - 1] += 1 xp[wi - 1] += 1 ypm = yp.max() xpm = xp.max() yps = np.where(y...
# from random import randint def f(h, w, m, ins): yp = [0] * h xp = [0] * w s = set() for hi, wi in ins: s.add((hi - 1, wi - 1)) yp[hi - 1] += 1 xp[wi - 1] += 1 ypm = max(yp) xpm = max(xp) yps = [i for i in range(h) if yp[i] == ypm] xps = [i for i in range(w) if x...
false
5.714286
[ "-import numpy as np", "-", "-", "- yp = np.zeros(h, dtype=np.int32)", "- xp = np.zeros(w, dtype=np.int32)", "+ yp = [0] * h", "+ xp = [0] * w", "- ypm = yp.max()", "- xpm = xp.max()", "- yps = np.where(yp == ypm)[0].tolist()", "- xps = np.where(xp == xpm)[0].tolist()", ...
false
0.276936
0.042963
6.445843
[ "s246546231", "s571223278" ]
u844005364
p03329
python
s540022218
s394660385
168
26
38,384
3,936
Accepted
Accepted
84.52
import bisect from functools import lru_cache six_list = [6 ** i for i in range(7)] nine_list = [9 ** i for i in range(6)] @lru_cache(maxsize=1000) def six_nine(n): if n < 6: return n else: six = six_list[bisect.bisect_right(six_list, n) - 1] nine = nine_list[bisect.bisec...
import bisect six_list = [6 ** i for i in range(7)] nine_list = [9 ** i for i in range(6)] from functools import lru_cache @lru_cache(maxsize=1000) def six_nine(n): if n < 6: return n else: six = six_list[bisect.bisect_right(six_list, n) - 1] nine = nine_list[bisect.bis...
20
21
498
500
import bisect from functools import lru_cache six_list = [6**i for i in range(7)] nine_list = [9**i for i in range(6)] @lru_cache(maxsize=1000) def six_nine(n): if n < 6: return n else: six = six_list[bisect.bisect_right(six_list, n) - 1] nine = nine_list[bisect.bisect_right(nine_list...
import bisect six_list = [6**i for i in range(7)] nine_list = [9**i for i in range(6)] from functools import lru_cache @lru_cache(maxsize=1000) def six_nine(n): if n < 6: return n else: six = six_list[bisect.bisect_right(six_list, n) - 1] nine = nine_list[bisect.bisect_right(nine_list...
false
4.761905
[ "-from functools import lru_cache", "+from functools import lru_cache" ]
false
0.04259
0.034043
1.25105
[ "s540022218", "s394660385" ]
u729133443
p02936
python
s265580012
s243159640
1,160
1,072
178,100
55,764
Accepted
Accepted
7.59
(n,q),*t=[list(map(int,t.split()))for t in open(0)] s=[0] d=s*n f=s*n e=[[]for _ in d] for a,b in t: if~-n:n-=1;e[a-1]+=b-1,;e[b-1]+=a-1, else:d[a-1]+=b while s: v=s.pop();f[v]=-1 for w in e[v]: if~f[w]:d[w]+=d[v];s+=w, print((*d))
def main(): import sys 入力 = sys.stdin.readline 範囲, 出力 = range, print 真, 偽 = True, False 何もしない = None 一行に複数個の入力 = lambda:map(int, 入力().split()) 頂点の数, 操作回数 = 一行に複数個の入力() 辺 = [[] for _ in 範囲(頂点の数)] カウンター = [0] * 頂点の数 辺の数 = 頂点の数-1 for _ in 範囲(辺の数): 頂点1, 頂点2 = ...
13
36
241
831
(n, q), *t = [list(map(int, t.split())) for t in open(0)] s = [0] d = s * n f = s * n e = [[] for _ in d] for a, b in t: if ~-n: n -= 1 e[a - 1] += (b - 1,) e[b - 1] += (a - 1,) else: d[a - 1] += b while s: v = s.pop() f[v] = -1 for w in e[v]: if ~f[w]: ...
def main(): import sys 入力 = sys.stdin.readline 範囲, 出力 = range, print 真, 偽 = True, False 何もしない = None 一行に複数個の入力 = lambda: map(int, 入力().split()) 頂点の数, 操作回数 = 一行に複数個の入力() 辺 = [[] for _ in 範囲(頂点の数)] カウンター = [0] * 頂点の数 辺の数 = 頂点の数 - 1 for _ in 範囲(辺の数): 頂点1, 頂点2 = 一行に複数個の入...
false
63.888889
[ "-(n, q), *t = [list(map(int, t.split())) for t in open(0)]", "-s = [0]", "-d = s * n", "-f = s * n", "-e = [[] for _ in d]", "-for a, b in t:", "- if ~-n:", "- n -= 1", "- e[a - 1] += (b - 1,)", "- e[b - 1] += (a - 1,)", "- else:", "- d[a - 1] += b", "-whil...
false
0.044215
0.070688
0.625502
[ "s265580012", "s243159640" ]
u413165887
p02913
python
s321166192
s730580805
1,658
1,507
42,296
3,188
Accepted
Accepted
9.11
n = int(eval(input())) s = eval(input()) j = 1 result = [0] for i in range(n): while (j < n-1) and (s[i:j] in s[:i]+"0"+s[j:]): j += 1 result.append(j-i-1) print((max(result)))
n = int(eval(input())) s = eval(input()) j = 1 result = [] for i in range(n): while (j < n-1) and (s[i:j] in s[:i]+"0"+s[j:]): j += 1 result.append(j-i-1) print((max(result)))
9
9
186
185
n = int(eval(input())) s = eval(input()) j = 1 result = [0] for i in range(n): while (j < n - 1) and (s[i:j] in s[:i] + "0" + s[j:]): j += 1 result.append(j - i - 1) print((max(result)))
n = int(eval(input())) s = eval(input()) j = 1 result = [] for i in range(n): while (j < n - 1) and (s[i:j] in s[:i] + "0" + s[j:]): j += 1 result.append(j - i - 1) print((max(result)))
false
0
[ "-result = [0]", "+result = []" ]
false
0.039673
0.037837
1.048541
[ "s321166192", "s730580805" ]
u380524497
p03426
python
s866568286
s958469562
1,134
996
27,100
20,724
Accepted
Accepted
12.17
h, w, d = list(map(int, input().split())) A = [] for _ in range(h): line = list(map(int, input().split())) A.append(line) num_to_xy = [[0, 0] for i in range(h*w + 1)] for y in range(h): for x in range(w): num = A[y][x] num_to_xy[num] = [x, y] costs = [[] for i in range(d+1)...
h, w, d = list(map(int, input().split())) A = [] for _ in range(h): line = list(map(int, input().split())) A.append(line) num_to_xy = [[0, 0] for i in range(h*w + 1)] for y in range(h): for x in range(w): num = A[y][x] num_to_xy[num] = [x, y] costs = [0] * (h*w+1) for st...
38
32
820
674
h, w, d = list(map(int, input().split())) A = [] for _ in range(h): line = list(map(int, input().split())) A.append(line) num_to_xy = [[0, 0] for i in range(h * w + 1)] for y in range(h): for x in range(w): num = A[y][x] num_to_xy[num] = [x, y] costs = [[] for i in range(d + 1)] for mod in r...
h, w, d = list(map(int, input().split())) A = [] for _ in range(h): line = list(map(int, input().split())) A.append(line) num_to_xy = [[0, 0] for i in range(h * w + 1)] for y in range(h): for x in range(w): num = A[y][x] num_to_xy[num] = [x, y] costs = [0] * (h * w + 1) for start in range(1,...
false
15.789474
[ "-costs = [[] for i in range(d + 1)]", "-for mod in range(1, d + 1):", "- num = mod", "+costs = [0] * (h * w + 1)", "+for start in range(1, d + 1):", "+ cost = 0", "+ num = start", "- cost = 0", "- costs[mod].append(cost)", "+ costs[num] = cost", "+ sx, sy = nx, ...
false
0.046538
0.045994
1.01183
[ "s866568286", "s958469562" ]
u054514819
p03786
python
s678904688
s034367711
126
109
14,320
92,544
Accepted
Accepted
13.49
N = int(eval(input())) As = list(map(int, input().split())) As.sort() from itertools import accumulate cum = list(accumulate(As)) cnt = 0 for n in range(N-1): if cum[n]*2>=As[n+1]: cnt += 1 else: cnt = 0 cnt += 1 print(cnt)
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) As = [0]+list(mapint()) As.sort() from itertools import accumulate cAs = list(accumulate(As)) cAs.sort(reverse=True) As.sort(reverse=True) a...
13
20
253
406
N = int(eval(input())) As = list(map(int, input().split())) As.sort() from itertools import accumulate cum = list(accumulate(As)) cnt = 0 for n in range(N - 1): if cum[n] * 2 >= As[n + 1]: cnt += 1 else: cnt = 0 cnt += 1 print(cnt)
import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) N = int(eval(input())) As = [0] + list(mapint()) As.sort() from itertools import accumulate cAs = list(accumulate(As)) cAs.sort(reverse=True) As.sort(reverse=True)...
false
35
[ "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline().strip()", "+", "+", "+def mapint():", "+ return list(map(int, input().split()))", "+", "+", "+sys.setrecursionlimit(10**9)", "-As = list(map(int, input().split()))", "+As = [0] + list(mapint())", "-cum = list(...
false
0.038861
0.038551
1.008035
[ "s678904688", "s034367711" ]
u607563136
p02675
python
s839678862
s788279691
29
26
9,148
9,160
Accepted
Accepted
10.34
n = eval(input()) hon = [2,4,5,7,9] pon = [0,1,6,8] bon = [3] if int(n[-1]) in hon: print("hon") elif int(n[-1]) in pon: print("pon") elif int(n[-1]) in bon: print("bon")
n = int(eval(input())) hon = [2,4,5,7,9] pon = [0,1,6,8] bon = [3] print(("hon" if n%10 in hon else "pon" if n%10 in pon else "bon"))
12
6
189
131
n = eval(input()) hon = [2, 4, 5, 7, 9] pon = [0, 1, 6, 8] bon = [3] if int(n[-1]) in hon: print("hon") elif int(n[-1]) in pon: print("pon") elif int(n[-1]) in bon: print("bon")
n = int(eval(input())) hon = [2, 4, 5, 7, 9] pon = [0, 1, 6, 8] bon = [3] print(("hon" if n % 10 in hon else "pon" if n % 10 in pon else "bon"))
false
50
[ "-n = eval(input())", "+n = int(eval(input()))", "-if int(n[-1]) in hon:", "- print(\"hon\")", "-elif int(n[-1]) in pon:", "- print(\"pon\")", "-elif int(n[-1]) in bon:", "- print(\"bon\")", "+print((\"hon\" if n % 10 in hon else \"pon\" if n % 10 in pon else \"bon\"))" ]
false
0.066878
0.048316
1.384173
[ "s839678862", "s788279691" ]
u635277286
p03661
python
s557498501
s810699179
240
196
24,832
23,800
Accepted
Accepted
18.33
N = int(eval(input())) a = list(map(int,input().split())) cum_sum = [0]*N cum_sum[0] = a[0] for i in range(1,N): cum_sum[i] = cum_sum[i-1] + a[i] res = 10**15 for i in range(N-1): x = cum_sum[i] y = cum_sum[N-1] - cum_sum[i] res = min(res, abs(x-y)) print(res)
N = int(eval(input())) a = list(map(int,input().split())) x = a[0] y = sum(a[1:]) res = abs(x - y) for i in range(1, N - 1): x += a[i] y -= a[i] res = min(res, abs(x - y)) print(res)
16
13
277
194
N = int(eval(input())) a = list(map(int, input().split())) cum_sum = [0] * N cum_sum[0] = a[0] for i in range(1, N): cum_sum[i] = cum_sum[i - 1] + a[i] res = 10**15 for i in range(N - 1): x = cum_sum[i] y = cum_sum[N - 1] - cum_sum[i] res = min(res, abs(x - y)) print(res)
N = int(eval(input())) a = list(map(int, input().split())) x = a[0] y = sum(a[1:]) res = abs(x - y) for i in range(1, N - 1): x += a[i] y -= a[i] res = min(res, abs(x - y)) print(res)
false
18.75
[ "-cum_sum = [0] * N", "-cum_sum[0] = a[0]", "-for i in range(1, N):", "- cum_sum[i] = cum_sum[i - 1] + a[i]", "-res = 10**15", "-for i in range(N - 1):", "- x = cum_sum[i]", "- y = cum_sum[N - 1] - cum_sum[i]", "+x = a[0]", "+y = sum(a[1:])", "+res = abs(x - y)", "+for i in range(1, N...
false
0.039536
0.043406
0.910851
[ "s557498501", "s810699179" ]
u754022296
p02863
python
s206477754
s965120566
393
170
114,652
97,576
Accepted
Accepted
56.74
import sys input = sys.stdin.readline read = sys.stdin.read n, t = list(map(int, input().split())) m = list(map(int, read().split())) AB = sorted(zip(m, m)) A, B = list(zip(*AB)) dp = [[0]*t for _ in range(n+1)] for i, a in enumerate(A[:-1]): for j in range(t): if j < a: dp[i+1][j] = dp[i][j] ...
import sys input = sys.stdin.readline read = sys.stdin.read import numpy as np n, t = list(map(int, input().split())) m = list(map(int, read().split())) AB = sorted(zip(m, m)) A, B = list(zip(*AB)) dp = np.zeros((n+1, t), dtype=np.int64) for i, (a, b) in enumerate(AB): np.maximum(dp[i, a:], dp[i, :-a]+b, ...
22
15
529
412
import sys input = sys.stdin.readline read = sys.stdin.read n, t = list(map(int, input().split())) m = list(map(int, read().split())) AB = sorted(zip(m, m)) A, B = list(zip(*AB)) dp = [[0] * t for _ in range(n + 1)] for i, a in enumerate(A[:-1]): for j in range(t): if j < a: dp[i + 1][j] = dp[i...
import sys input = sys.stdin.readline read = sys.stdin.read import numpy as np n, t = list(map(int, input().split())) m = list(map(int, read().split())) AB = sorted(zip(m, m)) A, B = list(zip(*AB)) dp = np.zeros((n + 1, t), dtype=np.int64) for i, (a, b) in enumerate(AB): np.maximum(dp[i, a:], dp[i, :-a] + b, out=...
false
31.818182
[ "+import numpy as np", "+", "-dp = [[0] * t for _ in range(n + 1)]", "-for i, a in enumerate(A[:-1]):", "- for j in range(t):", "- if j < a:", "- dp[i + 1][j] = dp[i][j]", "- else:", "- dp[i + 1][j] = max(dp[i][j - a] + B[i], dp[i][j])", "-ans = 0", "-maxB ...
false
0.1442
0.370917
0.388765
[ "s206477754", "s965120566" ]
u312025627
p02915
python
s749415730
s226452358
183
160
38,384
38,256
Accepted
Accepted
12.57
n = int(eval(input())) print((n**3))
def main(): N = int(eval(input())) print((N**3)) if __name__ == '__main__': main()
2
7
29
95
n = int(eval(input())) print((n**3))
def main(): N = int(eval(input())) print((N**3)) if __name__ == "__main__": main()
false
71.428571
[ "-n = int(eval(input()))", "-print((n**3))", "+def main():", "+ N = int(eval(input()))", "+ print((N**3))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.04589
0.045535
1.007809
[ "s749415730", "s226452358" ]
u378691508
p02711
python
s106583758
s450290223
22
19
8,988
9,116
Accepted
Accepted
13.64
N=eval(input()) if '7' in N: print('Yes') else: print('No')
N=eval(input()) print(("Yes" if "7" in N else "No"))
5
3
66
47
N = eval(input()) if "7" in N: print("Yes") else: print("No")
N = eval(input()) print(("Yes" if "7" in N else "No"))
false
40
[ "-if \"7\" in N:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+print((\"Yes\" if \"7\" in N else \"No\"))" ]
false
0.079375
0.040645
1.952894
[ "s106583758", "s450290223" ]
u920254817
p02990
python
s301968241
s890318407
997
60
98,388
3,444
Accepted
Accepted
93.98
N, K = list(map(int, input().split())) MOD = 10**9 + 7 kai = [] kai.append(1) for idx in range(1, N+5): kai.append((kai[idx-1] * idx) % MOD) #Mod pow #def modpow(ori, po, mod): # res = 1; # while(po > 0): # if(po&1): # res *= ori; # res %= mod; # ori *= ori; # ori %= mod; # po >>= 1; # return...
N, K = list(map(int, input().split())) MOD = 10**9 + 7 kai = [] kai.append(1) for idx in range(1, N+5): kai.append((kai[-1] * idx) % MOD) #Mod pow def modpow(ori, po): res = 1; while(po > 0): if(po&1): res *= ori res %= MOD ori *= ori ori %= MOD po >>= 1 return res def comb(n, k):...
43
35
754
600
N, K = list(map(int, input().split())) MOD = 10**9 + 7 kai = [] kai.append(1) for idx in range(1, N + 5): kai.append((kai[idx - 1] * idx) % MOD) # Mod pow # def modpow(ori, po, mod): # res = 1; # while(po > 0): # if(po&1): # res *= ori; # res %= mod; # ori *= ori; # ori %= mod; # po >>= 1; # return...
N, K = list(map(int, input().split())) MOD = 10**9 + 7 kai = [] kai.append(1) for idx in range(1, N + 5): kai.append((kai[-1] * idx) % MOD) # Mod pow def modpow(ori, po): res = 1 while po > 0: if po & 1: res *= ori res %= MOD ori *= ori ori %= MOD po >...
false
18.604651
[ "- kai.append((kai[idx - 1] * idx) % MOD)", "+ kai.append((kai[-1] * idx) % MOD)", "-# def modpow(ori, po, mod):", "-# \tres = 1;", "-# \twhile(po > 0):", "-# \t\tif(po&1):", "-# \t\t\tres *= ori;", "-# \t\t\tres %= mod;", "-# \t\tori *= ori;", "-# \t\tori %= mod;", "-# \t\tpo >>= 1;", "...
false
2.018003
0.037332
54.05499
[ "s301968241", "s890318407" ]
u585482323
p04034
python
s937091287
s912819450
313
277
43,868
44,464
Accepted
Accepted
11.5
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline()...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [lis...
78
48
1,269
1,091
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(x) for x in sys.stdin...
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): r...
false
38.461538
[ "+from itertools import permutations, accumulate", "-import random", "-# A", "-def A():", "- return", "-# B", "-def B():", "+def solve():", "- f = [1] * n", "- l = [0] * n", "- l[0] = 1", "- for i in range(m):", "- x, y = LI()", "- x -= 1", "- y -= 1",...
false
0.036498
0.041902
0.87103
[ "s937091287", "s912819450" ]
u137226361
p02832
python
s013916070
s831301520
94
85
32,248
31,480
Accepted
Accepted
9.57
n = int(eval(input())) an = list(map(int, input().split())) num = 1 for i in an: if i == num: num +=1 if num == 1: print((-1)) exit(0) ans = 1+n-num print(ans)
import sys n = int(eval(input())) a = list(map(int, sys.stdin.readline().split())) m = 1 for i in a: if i == m: m += 1 if m == 1: print((-1)) exit(0) print((1+n-m))
11
11
181
184
n = int(eval(input())) an = list(map(int, input().split())) num = 1 for i in an: if i == num: num += 1 if num == 1: print((-1)) exit(0) ans = 1 + n - num print(ans)
import sys n = int(eval(input())) a = list(map(int, sys.stdin.readline().split())) m = 1 for i in a: if i == m: m += 1 if m == 1: print((-1)) exit(0) print((1 + n - m))
false
0
[ "+import sys", "+", "-an = list(map(int, input().split()))", "-num = 1", "-for i in an:", "- if i == num:", "- num += 1", "-if num == 1:", "+a = list(map(int, sys.stdin.readline().split()))", "+m = 1", "+for i in a:", "+ if i == m:", "+ m += 1", "+if m == 1:", "-ans =...
false
0.04725
0.04906
0.963108
[ "s013916070", "s831301520" ]
u417365712
p02735
python
s231277678
s755356354
362
240
21,052
12,680
Accepted
Accepted
33.7
inputs = [s.strip() for s in open(0).readlines()] import numpy as np class Grid(): def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtype = type(function(grid[0][0])) self.grid = np.empty((h, w),...
inputs = [s.strip() for s in open(0).readlines()] import numpy as np class Grid(): def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtype = type(function(grid[0][0])) self.grid = np.empty((h, w),...
49
51
1,888
1,951
inputs = [s.strip() for s in open(0).readlines()] import numpy as np class Grid: def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtype = type(function(grid[0][0])) self.grid = np.empty((h, w), dtype=...
inputs = [s.strip() for s in open(0).readlines()] import numpy as np class Grid: def __init__(self, grid, w=0, h=0, function=lambda x: x): self.w = w = w if w else len(grid[0]) self.h = h = h if h else len(grid) dtype = type(function(grid[0][0])) self.grid = np.empty((h, w), dtype=...
false
3.921569
[ "-dp = np.zeros((h, w), np.int)", "-if grid[0][0] == \"#\":", "- dp[0, 0] = 1", "+h, w = list(map(int, inputs[0].split()))", "+grid = Grid(inputs[1:])", "+dp = Grid(np.zeros((h, w), np.int))", "+dp[0, 0] = int(grid[0, 0] == \"#\")" ]
false
0.251769
0.209617
1.201091
[ "s231277678", "s755356354" ]
u888092736
p03523
python
s149152171
s648767960
32
26
9,052
8,980
Accepted
Accepted
18.75
from itertools import product candidates = set() non_as = ["KIH", "B", "R", ""] for seps in product(["A", ""], repeat=4): candidates.add("".join(sep + non_a for sep, non_a in zip(seps, non_as))) print("YES") if input() in candidates else print("NO")
from itertools import product candidates = [] non_as = ["KIH", "B", "R", ""] for seps in product(["A", ""], repeat=4): candidates.append("".join(sep + non_a for sep, non_a in zip(seps, non_as))) print("YES") if input() in candidates else print("NO")
9
9
265
265
from itertools import product candidates = set() non_as = ["KIH", "B", "R", ""] for seps in product(["A", ""], repeat=4): candidates.add("".join(sep + non_a for sep, non_a in zip(seps, non_as))) print("YES") if input() in candidates else print("NO")
from itertools import product candidates = [] non_as = ["KIH", "B", "R", ""] for seps in product(["A", ""], repeat=4): candidates.append("".join(sep + non_a for sep, non_a in zip(seps, non_as))) print("YES") if input() in candidates else print("NO")
false
0
[ "-candidates = set()", "+candidates = []", "- candidates.add(\"\".join(sep + non_a for sep, non_a in zip(seps, non_as)))", "+ candidates.append(\"\".join(sep + non_a for sep, non_a in zip(seps, non_as)))" ]
false
0.035928
0.033776
1.06372
[ "s149152171", "s648767960" ]
u707124227
p02585
python
s461318973
s404731510
538
280
75,000
75,112
Accepted
Accepted
47.96
n,k=list(map(int,input().split())) p=list(map(int,input().split())) c=list(map(int,input().split())) root=[] mi=set(range(n)) while mi: v=mi.pop() r=[c[v]] while p[v]-1 in mi: r.append(c[p[v]-1]) mi.discard(p[v]-1) v=p[v]-1 root.append(r) inf=float('inf') ans=-inf for r in root: an...
n,k=list(map(int,input().split())) p=list(map(int,input().split())) c=list(map(int,input().split())) p=[x-1 for x in p] mi=set(range(n)) g={} # g[id]=[ary] while mi: x0=mi.pop() ary=[c[x0]] x=x0 while p[x]!=x0: x=p[x] mi.discard(x) ary.append(c[x]) cnt=len(ary) tmp=0 ary*=2 ...
42
42
840
841
n, k = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) root = [] mi = set(range(n)) while mi: v = mi.pop() r = [c[v]] while p[v] - 1 in mi: r.append(c[p[v] - 1]) mi.discard(p[v] - 1) v = p[v] - 1 root.append(r) inf = float("...
n, k = list(map(int, input().split())) p = list(map(int, input().split())) c = list(map(int, input().split())) p = [x - 1 for x in p] mi = set(range(n)) g = {} # g[id]=[ary] while mi: x0 = mi.pop() ary = [c[x0]] x = x0 while p[x] != x0: x = p[x] mi.discard(x) ary.append(c[x]) ...
false
0
[ "-root = []", "+p = [x - 1 for x in p]", "+g = {}", "+# g[id]=[ary]", "- v = mi.pop()", "- r = [c[v]]", "- while p[v] - 1 in mi:", "- r.append(c[p[v] - 1])", "- mi.discard(p[v] - 1)", "- v = p[v] - 1", "- root.append(r)", "-inf = float(\"inf\")", "-ans = -inf...
false
0.070658
0.047568
1.485403
[ "s461318973", "s404731510" ]
u600402037
p03074
python
s268398298
s990550280
1,880
424
16,760
14,136
Accepted
Accepted
77.45
import numpy as np N, K = list(map(int, input().split())) S = np.array([int(x) for x in eval(input())] + [2]) blocks = [] # 同じ数の塊 seq = 1 for i in range(N): if S[i+1] == S[i]: seq += 1 else: blocks.append(seq) seq = 1 blocks = np.array(blocks) answer = blocks[:2*K].sum(...
import numpy as np N, K = list(map(int, input().split())) S = [int(x) for x in eval(input())] cur = 1 # 最初は1が0人立っている blocks = np.zeros(10**5+1, dtype = np.int64) seq = 0 p = 0 for s in S: if s == cur: blocks[p] += 1 else: p += 1 blocks[p] += 1 cur = 1 - c...
22
25
452
566
import numpy as np N, K = list(map(int, input().split())) S = np.array([int(x) for x in eval(input())] + [2]) blocks = [] # 同じ数の塊 seq = 1 for i in range(N): if S[i + 1] == S[i]: seq += 1 else: blocks.append(seq) seq = 1 blocks = np.array(blocks) answer = blocks[: 2 * K].sum() start = 0...
import numpy as np N, K = list(map(int, input().split())) S = [int(x) for x in eval(input())] cur = 1 # 最初は1が0人立っている blocks = np.zeros(10**5 + 1, dtype=np.int64) seq = 0 p = 0 for s in S: if s == cur: blocks[p] += 1 else: p += 1 blocks[p] += 1 cur = 1 - cur W = min(2 * K, 10**5...
false
12
[ "-S = np.array([int(x) for x in eval(input())] + [2])", "-blocks = [] # 同じ数の塊", "-seq = 1", "-for i in range(N):", "- if S[i + 1] == S[i]:", "- seq += 1", "+S = [int(x) for x in eval(input())]", "+cur = 1 # 最初は1が0人立っている", "+blocks = np.zeros(10**5 + 1, dtype=np.int64)", "+seq = 0", "...
false
0.179907
0.17702
1.016308
[ "s268398298", "s990550280" ]
u156383602
p02729
python
s370195273
s693115311
19
17
3,444
2,940
Accepted
Accepted
10.53
a,b=list(map(int,input().split())) import itertools a1 = len(list(itertools.combinations(list(range(a)), 2))) b1 = len(list(itertools.combinations(list(range(b)), 2))) print((a1+b1))
a,b=list(map(int,input().split())) print((a*(a-1)//2+b*(b-1)//2))
5
2
166
58
a, b = list(map(int, input().split())) import itertools a1 = len(list(itertools.combinations(list(range(a)), 2))) b1 = len(list(itertools.combinations(list(range(b)), 2))) print((a1 + b1))
a, b = list(map(int, input().split())) print((a * (a - 1) // 2 + b * (b - 1) // 2))
false
60
[ "-import itertools", "-", "-a1 = len(list(itertools.combinations(list(range(a)), 2)))", "-b1 = len(list(itertools.combinations(list(range(b)), 2)))", "-print((a1 + b1))", "+print((a * (a - 1) // 2 + b * (b - 1) // 2))" ]
false
0.037231
0.061498
0.605392
[ "s370195273", "s693115311" ]
u363768711
p03556
python
s955712666
s167367886
67
17
3,444
3,060
Accepted
Accepted
74.63
N = int(eval(input())) if N < 4: print((1)) exit() for i in range(N,1,-1): if i**0.5 == int(i**0.5): print(i) exit()
N = int(eval(input())) print((int(N**0.5)**2))
8
2
129
39
N = int(eval(input())) if N < 4: print((1)) exit() for i in range(N, 1, -1): if i**0.5 == int(i**0.5): print(i) exit()
N = int(eval(input())) print((int(N**0.5) ** 2))
false
75
[ "-if N < 4:", "- print((1))", "- exit()", "-for i in range(N, 1, -1):", "- if i**0.5 == int(i**0.5):", "- print(i)", "- exit()", "+print((int(N**0.5) ** 2))" ]
false
0.076849
0.037887
2.028383
[ "s955712666", "s167367886" ]
u796942881
p03111
python
s648989770
s503219812
71
21
3,064
3,064
Accepted
Accepted
70.42
N, A, B, C = map(int, input().split()) L = [int(input()) for i in range(N)] def dfs(cur, a, b, c): if cur == N: return abs(a - A) + abs(b - B) + abs(c - C) - 30\ if 0 < min(a, b, c) else int(1e9+7) ret1 = dfs(cur + 1, a + L[cur], b, c) + 10 ret2 = dfs(cur + 1, a, b + L[cur],...
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = abs(x - min(lst)) min_lst = min(lst) tpl = None for v in range(len(lst) - rem + 1): for t in combinations(lst, v + 1): if abs(x - sum(t)) + 10 * v < d: d = abs(x...
22
37
510
864
N, A, B, C = map(int, input().split()) L = [int(input()) for i in range(N)] def dfs(cur, a, b, c): if cur == N: return ( abs(a - A) + abs(b - B) + abs(c - C) - 30 if 0 < min(a, b, c) else int(1e9 + 7) ) ret1 = dfs(cur + 1, a + L[cur], b, c) + 10 ret2 = d...
from itertools import combinations from itertools import permutations def f(x, lst, rem): d = abs(x - min(lst)) min_lst = min(lst) tpl = None for v in range(len(lst) - rem + 1): for t in combinations(lst, v + 1): if abs(x - sum(t)) + 10 * v < d: d = abs(x - sum(t)) ...
false
40.540541
[ "-N, A, B, C = map(int, input().split())", "-L = [int(input()) for i in range(N)]", "+from itertools import combinations", "+from itertools import permutations", "-def dfs(cur, a, b, c):", "- if cur == N:", "- return (", "- abs(a - A) + abs(b - B) + abs(c - C) - 30", "- ...
false
0.087752
0.090703
0.967468
[ "s648989770", "s503219812" ]
u325282913
p03244
python
s113382747
s760430447
176
120
20,572
23,764
Accepted
Accepted
31.82
from collections import Counter n = int(eval(input())) array = list(map(int,input().split())) if len(set(array)) == 1: print((n//2)) exit() gu = [] ki = [] for i in range(n): if i % 2 == 0: gu.append(array[i]) else: ki.append(array[i]) gu_c = Counter(gu) ki_c = Counter(ki) ...
from collections import Counter n = int(eval(input())) array = list(map(int,input().split())) if len(set(array)) == 1: print((n//2)) exit() gu = [] ki = [] for i in range(n): if i % 2 == 0: gu.append(array[i]) else: ki.append(array[i]) gu_c = Counter(gu) ki_c = Counter(ki) ...
23
25
788
632
from collections import Counter n = int(eval(input())) array = list(map(int, input().split())) if len(set(array)) == 1: print((n // 2)) exit() gu = [] ki = [] for i in range(n): if i % 2 == 0: gu.append(array[i]) else: ki.append(array[i]) gu_c = Counter(gu) ki_c = Counter(ki) if gu_c.mo...
from collections import Counter n = int(eval(input())) array = list(map(int, input().split())) if len(set(array)) == 1: print((n // 2)) exit() gu = [] ki = [] for i in range(n): if i % 2 == 0: gu.append(array[i]) else: ki.append(array[i]) gu_c = Counter(gu) ki_c = Counter(ki) gu_m = gu_...
false
8
[ "-if gu_c.most_common()[0][0] != ki_c.most_common()[0][0]:", "- print((n - (gu_c.most_common()[0][1] + ki_c.most_common()[0][1])))", "-elif gu_c.most_common()[0][1] < ki_c.most_common()[0][1]:", "- print((n - (gu_c.most_common()[1][1] + ki_c.most_common()[0][1])))", "-elif gu_c.most_common()[0][1] > k...
false
0.035047
0.031972
1.096194
[ "s113382747", "s760430447" ]
u392319141
p03017
python
s781816991
s214942340
20
18
3,700
3,636
Accepted
Accepted
10
N, A, B, C, D = list(map(int, input().split())) S = '$' + eval(input()) + '$' def isOk(fr, to): if S[fr: to + 1].count('##') > 0: return False return True if not (isOk(A, C) and isOk(C, D)): print('No') exit() def canSwitch(): if A + 1 == B and D < C and S[A: A + 3] == '...':...
N, A, B, C, D = list(map(int, input().split())) S = '$' + eval(input()) + '$' def isOk(fr, to): if S[fr: to + 1].count('##') > 0: return False return True if not (isOk(A, C) and isOk(C, D)): print('No') exit() def canSwitch(): if S[max(A, B) - 1: min(C, D) + 2].count('...'): ...
39
23
1,035
467
N, A, B, C, D = list(map(int, input().split())) S = "$" + eval(input()) + "$" def isOk(fr, to): if S[fr : to + 1].count("##") > 0: return False return True if not (isOk(A, C) and isOk(C, D)): print("No") exit() def canSwitch(): if A + 1 == B and D < C and S[A : A + 3] == "...": ...
N, A, B, C, D = list(map(int, input().split())) S = "$" + eval(input()) + "$" def isOk(fr, to): if S[fr : to + 1].count("##") > 0: return False return True if not (isOk(A, C) and isOk(C, D)): print("No") exit() def canSwitch(): if S[max(A, B) - 1 : min(C, D) + 2].count("..."): ...
false
41.025641
[ "- if A + 1 == B and D < C and S[A : A + 3] == \"...\":", "- return True", "- if B + 1 == A and C < D and S[B : B + 3] == \"...\":", "- return True", "- if C + 1 == D and B < A and S[C - 1 : D + 1] == \"...\":", "- return True", "- if D + 1 == C and A < B and S[D - 1 : C...
false
0.047867
0.081946
0.58413
[ "s781816991", "s214942340" ]
u263830634
p03221
python
s708565915
s519817516
1,158
1,008
42,528
38,520
Accepted
Accepted
12.95
N, M = list(map(int, input().split())) lst = [] for i in range(M): a = list(map(int, input().split())) a += [i] #i: 市の番号 lst += [a] #print (lst) lst.sort() #print (lst) ken = -1 x = 0 ans = [] for j in range(M): if ken != lst[j][0]: #1つ前と市の名前が違う x = 1 # ken = lst[j][0]...
N, M = map(int, input().split()) PY = [list(map(int, input().split())) + [i] for i in range(M)] PY.sort(key = lambda x: x[1]) PY.sort(key = lambda x: x[0]) ans_lst = [] x = 1 tmp_p = None for p, y, i in PY: if p == tmp_p: #属している県が同じ時 ans_lst.append([p, x, i]) x += 1 else: a...
32
27
633
627
N, M = list(map(int, input().split())) lst = [] for i in range(M): a = list(map(int, input().split())) a += [i] # i: 市の番号 lst += [a] # print (lst) lst.sort() # print (lst) ken = -1 x = 0 ans = [] for j in range(M): if ken != lst[j][0]: # 1つ前と市の名前が違う x = 1 # ken = lst[j][0] # ...
N, M = map(int, input().split()) PY = [list(map(int, input().split())) + [i] for i in range(M)] PY.sort(key=lambda x: x[1]) PY.sort(key=lambda x: x[0]) ans_lst = [] x = 1 tmp_p = None for p, y, i in PY: if p == tmp_p: # 属している県が同じ時 ans_lst.append([p, x, i]) x += 1 else: ans_lst.append([p...
false
15.625
[ "-N, M = list(map(int, input().split()))", "-lst = []", "-for i in range(M):", "- a = list(map(int, input().split()))", "- a += [i] # i: 市の番号", "- lst += [a]", "-# print (lst)", "-lst.sort()", "-# print (lst)", "-ken = -1", "-x = 0", "-ans = []", "-for j in range(M):", "- if k...
false
0.039522
0.080658
0.490001
[ "s708565915", "s519817516" ]
u912237403
p00170
python
s550547916
s264094851
4,620
290
100,444
4,288
Accepted
Accepted
93.72
def solve(placed, w1, w2): n = len(N) - len(placed) x = list(set(N) - set(placed)) if x == []: a = tuple(placed) D1[a] = w1 D2[a] = w2 return for e in x: w = Food[e][0] if w2 > Food[e][1]: return a = w1 + w * n b = w2 + w solve(placed+[e], a, b) return ...
def solve(placed, w1, w2): global weight, D n = len(N) - len(placed) x = list(set(N) - set(placed)) if x == []: if weight > w1: D = placed weight = w1 return for e in x: w = Food[0][e] if w2 > Food[1][e]: return a = w1 + w * n if a > weight: return b ...
35
33
657
638
def solve(placed, w1, w2): n = len(N) - len(placed) x = list(set(N) - set(placed)) if x == []: a = tuple(placed) D1[a] = w1 D2[a] = w2 return for e in x: w = Food[e][0] if w2 > Food[e][1]: return a = w1 + w * n b = w2 + w ...
def solve(placed, w1, w2): global weight, D n = len(N) - len(placed) x = list(set(N) - set(placed)) if x == []: if weight > w1: D = placed weight = w1 return for e in x: w = Food[0][e] if w2 > Food[1][e]: return a = w1 + w *...
false
5.714286
[ "+ global weight, D", "- a = tuple(placed)", "- D1[a] = w1", "- D2[a] = w2", "+ if weight > w1:", "+ D = placed", "+ weight = w1", "- w = Food[e][0]", "- if w2 > Food[e][1]:", "+ w = Food[0][e]", "+ if w2 > Food[1][...
false
0.042946
0.041431
1.036583
[ "s550547916", "s264094851" ]
u214617707
p03814
python
s580940025
s647777787
60
35
3,516
3,512
Accepted
Accepted
41.67
s = eval(input()) i = 0 while i < len(s) and s[i] != "A": i += 1 j = len(s) - 1 while j > 0 and s[j] != "Z": j -= 1 print((j - i + 1))
S = eval(input()) N = len(S) s, t = 0, 0 for i in range(N): if S[i] == "A": s = i break for i in range(N - 1, -1, -1): if S[i] == "Z": t = i break print((t - s + 1))
10
14
145
212
s = eval(input()) i = 0 while i < len(s) and s[i] != "A": i += 1 j = len(s) - 1 while j > 0 and s[j] != "Z": j -= 1 print((j - i + 1))
S = eval(input()) N = len(S) s, t = 0, 0 for i in range(N): if S[i] == "A": s = i break for i in range(N - 1, -1, -1): if S[i] == "Z": t = i break print((t - s + 1))
false
28.571429
[ "-s = eval(input())", "-i = 0", "-while i < len(s) and s[i] != \"A\":", "- i += 1", "-j = len(s) - 1", "-while j > 0 and s[j] != \"Z\":", "- j -= 1", "-print((j - i + 1))", "+S = eval(input())", "+N = len(S)", "+s, t = 0, 0", "+for i in range(N):", "+ if S[i] == \"A\":", "+ ...
false
0.008557
0.041886
0.204291
[ "s580940025", "s647777787" ]
u716530146
p02898
python
s137688523
s605111448
215
53
55,152
12,308
Accepted
Accepted
75.35
#!/usr/bin/env python3 import sys, math input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.setrecursionlimit(10**8) inf = float('inf') ans=count=0 n,k=list(map(int,input().split())) h=list(map(int,input().split())) for hi in h: if hi>=k: count+=1 print(count)
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.setrecursionlimit(10**8) inf = float('inf') ans = count = 0 n,k=list(map(int,input().split())) h=list(map(int,input().split())) for hi in h: if hi>=k: ...
14
13
302
339
#!/usr/bin/env python3 import sys, math input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") sys.setrecursionlimit(10**8) inf = float("inf") ans = count = 0 n, k = list(map(int, input().split())) h = list(map(int, input().split())) for hi in h: if hi >= k: count += 1 print(count)
#!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8") sys.setrecursionlimit(10**8) inf = float("inf") ans = count = 0 n, k = list(map(int, input().split())) h = list(map(int, input().split())) for hi in h: if hi >= k: ...
false
7.142857
[ "-import sys, math", "+import sys, math, itertools, heapq, collections, bisect", "- count += 1", "-print(count)", "+ ans += 1", "+print(ans)" ]
false
0.058903
0.076659
0.768377
[ "s137688523", "s605111448" ]
u543954314
p03805
python
s602724323
s144603699
44
27
3,064
3,064
Accepted
Accepted
38.64
n,m = list(map(int, input().split())) arr = [[0]*n for _ in range(n)] for _ in range(m): a,b = list(map(int, input().split())) arr[a-1][b-1] = 1 arr[b-1][a-1] = 1 d = [0]*n d[0] = 1 cnt = 0 def dfs(x): global cnt if all(d): cnt += 1 for i in range(1,n+1): if arr[x-1][i-1] and d[i-1] ==...
n,m = list(map(int, input().split())) arr = [list() for _ in range(n)] for _ in range(m): a,b = list(map(int, input().split())) arr[a-1].append(b) arr[b-1].append(a) d = [0]*n d[0] = 1 cnt = 0 def dfs(x): global cnt if all(d): cnt += 1 return for i in arr[x-1]: if d[i-1] == 0: ...
20
21
381
374
n, m = list(map(int, input().split())) arr = [[0] * n for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) arr[a - 1][b - 1] = 1 arr[b - 1][a - 1] = 1 d = [0] * n d[0] = 1 cnt = 0 def dfs(x): global cnt if all(d): cnt += 1 for i in range(1, n + 1): if ar...
n, m = list(map(int, input().split())) arr = [list() for _ in range(n)] for _ in range(m): a, b = list(map(int, input().split())) arr[a - 1].append(b) arr[b - 1].append(a) d = [0] * n d[0] = 1 cnt = 0 def dfs(x): global cnt if all(d): cnt += 1 return for i in arr[x - 1]: ...
false
4.761905
[ "-arr = [[0] * n for _ in range(n)]", "+arr = [list() for _ in range(n)]", "- arr[a - 1][b - 1] = 1", "- arr[b - 1][a - 1] = 1", "+ arr[a - 1].append(b)", "+ arr[b - 1].append(a)", "- for i in range(1, n + 1):", "- if arr[x - 1][i - 1] and d[i - 1] == 0:", "+ return", ...
false
0.035346
0.04528
0.7806
[ "s602724323", "s144603699" ]
u367130284
p03106
python
s268817166
s949954463
38
18
5,304
2,940
Accepted
Accepted
52.63
import fractions as f a,b,k=list(map(int,input().split())) g=f.gcd(a,b) count=0 for s in range(g,0,-1): if g%s==0: count+=1 if count==k: print(s) exit()
a,b,k=list(map(int,input().split())) l=[] for i in range(min(a,b),0,-1): if a%i==b%i==0: l.append(i) print((l[k-1]))
10
6
188
125
import fractions as f a, b, k = list(map(int, input().split())) g = f.gcd(a, b) count = 0 for s in range(g, 0, -1): if g % s == 0: count += 1 if count == k: print(s) exit()
a, b, k = list(map(int, input().split())) l = [] for i in range(min(a, b), 0, -1): if a % i == b % i == 0: l.append(i) print((l[k - 1]))
false
40
[ "-import fractions as f", "-", "-g = f.gcd(a, b)", "-count = 0", "-for s in range(g, 0, -1):", "- if g % s == 0:", "- count += 1", "- if count == k:", "- print(s)", "- exit()", "+l = []", "+for i in range(min(a, b), 0, -1):", "+ if a % i == b % i == 0:", "+ ...
false
0.053531
0.047181
1.134585
[ "s268817166", "s949954463" ]
u170201762
p03326
python
s325677995
s302344011
1,979
27
21,616
3,316
Accepted
Accepted
98.64
import numpy as np N,M = list(map(int,input().split())) a = np.zeros((8,N)) for i in range(N): x,y,z = list(map(int,input().split())) j=0 for j1 in range(2): for j2 in range(2): for j3 in range(2): a[j][i] = (-1)**j1*x+(-1)**j2*y+(-1)**j3*z j += ...
N,M = list(map(int,input().split())) xyz = [list(map(int,input().split())) for _ in range(N)] ans = 0 for n in range(8): n = bin(n)[2:] n = (3-len(n))*'0' + n n = [1-2*int(s) for s in n] S = [0]*N for i in range(N): S[i] = n[0]*xyz[i][0]+n[1]*xyz[i][1]+n[2]*xyz[i][2] S.sort()...
18
15
438
361
import numpy as np N, M = list(map(int, input().split())) a = np.zeros((8, N)) for i in range(N): x, y, z = list(map(int, input().split())) j = 0 for j1 in range(2): for j2 in range(2): for j3 in range(2): a[j][i] = (-1) ** j1 * x + (-1) ** j2 * y + (-1) ** j3 * z ...
N, M = list(map(int, input().split())) xyz = [list(map(int, input().split())) for _ in range(N)] ans = 0 for n in range(8): n = bin(n)[2:] n = (3 - len(n)) * "0" + n n = [1 - 2 * int(s) for s in n] S = [0] * N for i in range(N): S[i] = n[0] * xyz[i][0] + n[1] * xyz[i][1] + n[2] * xyz[i][2] ...
false
16.666667
[ "-import numpy as np", "-", "-a = np.zeros((8, N))", "-for i in range(N):", "- x, y, z = list(map(int, input().split()))", "- j = 0", "- for j1 in range(2):", "- for j2 in range(2):", "- for j3 in range(2):", "- a[j][i] = (-1) ** j1 * x + (-1) ** j2 * y + ...
false
0.641674
0.045028
14.250669
[ "s325677995", "s302344011" ]
u119148115
p03047
python
s522435664
s689183915
71
63
61,952
61,336
Accepted
Accepted
11.27
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 ...
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) N,K = MI() print((N-K+1))
14
6
517
106
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...
import sys def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) N, K = MI() print((N - K + 1))
false
57.142857
[ "-", "-sys.setrecursionlimit(10**7)", "-", "-", "-def I():", "- return int(sys.stdin.readline().rstrip())", "-def LI():", "- return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり", "-", "-", "-def LI2():", "- return list(map(int, sys.stdin.readline().rstrip())) # 空白なし"...
false
0.066728
0.033855
1.971002
[ "s522435664", "s689183915" ]
u316386814
p02998
python
s363798557
s865713702
539
491
102,488
114,524
Accepted
Accepted
8.91
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def YesNo(x): return 'Yes' if x else 'No' def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()]...
import sys sys.setrecursionlimit(10**7) INF = 10 ** 18 MOD = 10 ** 9 + 7 def YesNo(x): return 'Yes' if x else 'No' def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()]...
43
45
1,250
1,288
import sys sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 def YesNo(x): return "Yes" if x else "No" def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readl...
import sys sys.setrecursionlimit(10**7) INF = 10**18 MOD = 10**9 + 7 def YesNo(x): return "Yes" if x else "No" def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readl...
false
4.444444
[ "+ xy = []", "+ for _ in range(N):", "+ xy.append(LI())", "- for _ in range(N):", "- x, y = LI()", "+ for x, y in xy:" ]
false
0.040513
0.046217
0.876583
[ "s363798557", "s865713702" ]
u397638621
p02713
python
s426337313
s788708173
1,982
1,201
9,104
9,084
Accepted
Accepted
39.4
k = int(eval(input())) from math import gcd ans = 0 for a in range(1, k+1): for b in range(1, k+1): for c in range(1, k+1): ans += gcd(a, gcd(b, c)) print(ans)
k = int(eval(input())) from math import gcd ans = 0 for a in range(1, k+1): for b in range(1, k+1): ab = gcd(a, b) for c in range(1, k+1): ans += gcd(ab, c) print(ans)
9
10
186
206
k = int(eval(input())) from math import gcd ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): for c in range(1, k + 1): ans += gcd(a, gcd(b, c)) print(ans)
k = int(eval(input())) from math import gcd ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): ab = gcd(a, b) for c in range(1, k + 1): ans += gcd(ab, c) print(ans)
false
10
[ "+ ab = gcd(a, b)", "- ans += gcd(a, gcd(b, c))", "+ ans += gcd(ab, c)" ]
false
0.064646
0.062432
1.035457
[ "s426337313", "s788708173" ]
u863370423
p03323
python
s729578498
s921011465
17
10
2,940
2,568
Accepted
Accepted
41.18
a, b = list(map(int, input().split())) if a > 8 or b > 8: print(':(') else: print('Yay!')
parameters = list(map(int, input().split())) if(parameters[0] <= 8 and parameters[1] <= 8): print('Yay!') else: print(':(')
6
6
98
135
a, b = list(map(int, input().split())) if a > 8 or b > 8: print(":(") else: print("Yay!")
parameters = list(map(int, input().split())) if parameters[0] <= 8 and parameters[1] <= 8: print("Yay!") else: print(":(")
false
0
[ "-a, b = list(map(int, input().split()))", "-if a > 8 or b > 8:", "+parameters = list(map(int, input().split()))", "+if parameters[0] <= 8 and parameters[1] <= 8:", "+ print(\"Yay!\")", "+else:", "-else:", "- print(\"Yay!\")" ]
false
0.03627
0.035641
1.017628
[ "s729578498", "s921011465" ]
u389910364
p03325
python
s957511860
s011465485
338
86
23,660
3,956
Accepted
Accepted
74.56
import bisect import heapq import itertools import math import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter ...
import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 N = int(sys.stdin.buffer.readline()) A = list(map(int, sys.stdin.buffer.readline().split())) ans = 0 for a in A: ...
34
21
674
386
import bisect import heapq import itertools import math import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter import numpy as...
import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10**9) INF = float("inf") IINF = 10**18 MOD = 10**9 + 7 # MOD = 998244353 N = int(sys.stdin.buffer.readline()) A = list(map(int, sys.stdin.buffer.readline().split())) ans = 0 for a in A: while a % 2 == 0: ...
false
38.235294
[ "-import bisect", "-import heapq", "-import itertools", "-import math", "-import re", "-import string", "-from collections import Counter, deque, defaultdict", "-from copy import deepcopy", "-from decimal import Decimal", "-from fractions import gcd", "-from functools import lru_cache, reduce", ...
false
0.128397
0.069696
1.842253
[ "s957511860", "s011465485" ]
u654470292
p03053
python
s622635849
s506262034
602
445
140,892
87,004
Accepted
Accepted
26.08
import bisect import copy import heapq import math import sys from collections import * from itertools import accumulate, combinations, permutations, product # from math import gcd def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) mod=pow(10,9)+7 al=[c...
import bisect import copy import heapq import math import sys from collections import * from itertools import accumulate, combinations, permutations, product # from math import gcd def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) mod=pow(10,9)+7 al=[c...
48
48
1,054
1,054
import bisect import copy import heapq import math import sys from collections import * from itertools import accumulate, combinations, permutations, product # from math import gcd def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0] + list(accumulate(lst)) mod = pow(10, 9) + 7 al = [...
import bisect import copy import heapq import math import sys from collections import * from itertools import accumulate, combinations, permutations, product # from math import gcd def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0] + list(accumulate(lst)) mod = pow(10, 9) + 7 al = [...
false
0
[ "- d.append([i, j])", "+ d.append((i, j))", "- d.append([nh + d1, nw + d2])", "+ d.append((nh + d1, nw + d2))" ]
false
0.044537
0.047055
0.946469
[ "s622635849", "s506262034" ]
u477320129
p02550
python
s289348138
s552252380
172
122
17,520
9,180
Accepted
Accepted
29.07
#!/usr/bin/env python3 import sys # https://en.wikipedia.org/wiki/Cycle_detection def floyd_cycle_finding(f, x0): ''' 循環していない部分の長さをlam 循環部分の長さをmuとして (lam, mu) を返す >>> floyd_cycle_finding(lambda x: x**2 % 3, 2) (1, 1) >>> floyd_cycle_finding(lambda x: x**2 % 1001, 2) (2,...
#!/usr/bin/env python3 import sys # https://en.wikipedia.org/wiki/Cycle_detection def floyd_cycle_finding(f, x0): ''' 循環していない部分の長さをlam 循環部分の長さをmuとして (lam, mu) を返す >>> floyd_cycle_finding(lambda x: x**2 % 3, 2) (1, 1) >>> floyd_cycle_finding(lambda x: x**2 % 1001, 2) (2,...
92
92
2,193
2,194
#!/usr/bin/env python3 import sys # https://en.wikipedia.org/wiki/Cycle_detection def floyd_cycle_finding(f, x0): """ 循環していない部分の長さをlam 循環部分の長さをmuとして (lam, mu) を返す >>> floyd_cycle_finding(lambda x: x**2 % 3, 2) (1, 1) >>> floyd_cycle_finding(lambda x: x**2 % 1001, 2) (2, 4) >>> f...
#!/usr/bin/env python3 import sys # https://en.wikipedia.org/wiki/Cycle_detection def floyd_cycle_finding(f, x0): """ 循環していない部分の長さをlam 循環部分の長さをmuとして (lam, mu) を返す >>> floyd_cycle_finding(lambda x: x**2 % 3, 2) (1, 1) >>> floyd_cycle_finding(lambda x: x**2 % 1001, 2) (2, 4) >>> f...
false
0
[ "- test()", "+ # test()" ]
false
0.276917
0.05981
4.629963
[ "s289348138", "s552252380" ]
u075012704
p03472
python
s213606897
s058891832
1,864
370
11,692
11,764
Accepted
Accepted
80.15
import math N, H = list(map(int, input().split())) A = [] B = [] for i in range(N): a, b = list(map(int, input().split())) A.append(a) B.append(b) amax = max(A) # 最強の振り刀より強い攻撃力を持つものを抽出 B = list([x for x in B if x > amax]) B.sort(reverse=True) ans = 0 while H > 0: # まだ投げれる if not B...
import math N, H = list(map(int, input().split())) A = [] B = [] for i in range(N): a, b = list(map(int, input().split())) A.append(a) B.append(b) amax = max(A) # 最強の振り刀より強い攻撃力を持つものを抽出 B = list([x for x in B if x > amax]) B.sort() ans = 0 while H > 0: # まだ投げれる if B: H -= ...
27
26
459
422
import math N, H = list(map(int, input().split())) A = [] B = [] for i in range(N): a, b = list(map(int, input().split())) A.append(a) B.append(b) amax = max(A) # 最強の振り刀より強い攻撃力を持つものを抽出 B = list([x for x in B if x > amax]) B.sort(reverse=True) ans = 0 while H > 0: # まだ投げれる if not B == []: H ...
import math N, H = list(map(int, input().split())) A = [] B = [] for i in range(N): a, b = list(map(int, input().split())) A.append(a) B.append(b) amax = max(A) # 最強の振り刀より強い攻撃力を持つものを抽出 B = list([x for x in B if x > amax]) B.sort() ans = 0 while H > 0: # まだ投げれる if B: H -= B.pop() # もう投げれ...
false
3.703704
[ "-B.sort(reverse=True)", "+B.sort()", "- if not B == []:", "- H -= B[0]", "- del B[0]", "+ if B:", "+ H -= B.pop()" ]
false
0.195651
0.115688
1.691198
[ "s213606897", "s058891832" ]
u677121387
p02773
python
s748479559
s902653253
718
501
35,220
35,952
Accepted
Accepted
30.22
n = int(eval(input())) s = [eval(input()) for _ in range(n)] d = {} for i in range(n): d[s[i]] = d.get(s[i],0)+1 m = max(d.values()) lst = [] for key in d: if d[key] == m: lst.append(key) lst.sort() for i in lst: print(i)
from collections import Counter n = int(eval(input())) s = [eval(input()) for _ in range(n)] c = Counter(s) m = max(c.values()) ans = sorted(k for k,v in list(c.items()) if v == m) print(("\n".join(ans)))
17
7
250
190
n = int(eval(input())) s = [eval(input()) for _ in range(n)] d = {} for i in range(n): d[s[i]] = d.get(s[i], 0) + 1 m = max(d.values()) lst = [] for key in d: if d[key] == m: lst.append(key) lst.sort() for i in lst: print(i)
from collections import Counter n = int(eval(input())) s = [eval(input()) for _ in range(n)] c = Counter(s) m = max(c.values()) ans = sorted(k for k, v in list(c.items()) if v == m) print(("\n".join(ans)))
false
58.823529
[ "+from collections import Counter", "+", "-d = {}", "-for i in range(n):", "- d[s[i]] = d.get(s[i], 0) + 1", "-m = max(d.values())", "-lst = []", "-for key in d:", "- if d[key] == m:", "- lst.append(key)", "-lst.sort()", "-for i in lst:", "- print(i)", "+c = Counter(s)", ...
false
0.05993
0.072024
0.832081
[ "s748479559", "s902653253" ]
u724687935
p03798
python
s363926950
s435214579
180
163
4,988
5,116
Accepted
Accepted
9.44
def main(): # import sys # readline = sys.stdin.buffer.readline # readlines = sys.stdin.buffer.readlines N = int(eval(input())) L = eval(input()) A = [None] * (N + 1) for a0, a1 in [(0, 0), (0, 1), (1, 0), (1, 1)]: A[0] = a0 A[1] = a1 for i in range(2, N +...
def main(): # import sys # readline = sys.stdin.buffer.readline # readlines = sys.stdin.buffer.readlines N = int(eval(input())) L = eval(input()) A = [None] * (N + 2) for a0, a1 in [(0, 0), (0, 1), (1, 0), (1, 1)]: A[0] = a0 A[1] = a1 for i in range(2, N +...
44
34
1,167
827
def main(): # import sys # readline = sys.stdin.buffer.readline # readlines = sys.stdin.buffer.readlines N = int(eval(input())) L = eval(input()) A = [None] * (N + 1) for a0, a1 in [(0, 0), (0, 1), (1, 0), (1, 1)]: A[0] = a0 A[1] = a1 for i in range(2, N + 1): ...
def main(): # import sys # readline = sys.stdin.buffer.readline # readlines = sys.stdin.buffer.readlines N = int(eval(input())) L = eval(input()) A = [None] * (N + 2) for a0, a1 in [(0, 0), (0, 1), (1, 0), (1, 1)]: A[0] = a0 A[1] = a1 for i in range(2, N + 1): ...
false
22.727273
[ "- A = [None] * (N + 1)", "+ A = [None] * (N + 2)", "- s = 0 if L[i - 1] == \"o\" else 1", "- # if a == 0:", "- # if s == 0:", "- # A[i] = A[i - 2]", "- # elif s == 1:", "- # A[i] = A[i - 2] ^ 1", "- ...
false
0.047103
0.046633
1.010069
[ "s363926950", "s435214579" ]
u691018832
p03283
python
s414701090
s174119820
810
619
68,496
15,640
Accepted
Accepted
23.58
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) import numpy as np n, m, q = list(map(int, readline().split())) lr = [list(map(int, readline().split())) for _ in range(m)] cnt = [[0] * (n + 1) for _ in range(n...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) # da[i][j]:(0,0)~(i,j)の長方形の和 def da_generate(h, w, a): da = [[0] * w for j in range(h)] da[0][0] = a[0][0] for i in range(1, w): da[0][i] =...
20
43
568
1,133
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) import numpy as np n, m, q = list(map(int, readline().split())) lr = [list(map(int, readline().split())) for _ in range(m)] cnt = [[0] * (n + 1) for _ in range(n + 1)] for l...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) # da[i][j]:(0,0)~(i,j)の長方形の和 def da_generate(h, w, a): da = [[0] * w for j in range(h)] da[0][0] = a[0][0] for i in range(1, w): da[0][i] = da[0][i - 1] +...
false
53.488372
[ "-import numpy as np", "+# da[i][j]:(0,0)~(i,j)の長方形の和", "+def da_generate(h, w, a):", "+ da = [[0] * w for j in range(h)]", "+ da[0][0] = a[0][0]", "+ for i in range(1, w):", "+ da[0][i] = da[0][i - 1] + a[0][i]", "+ for i in range(1, h):", "+ cnt_w = 0", "+ for j ...
false
0.391675
0.106467
3.678854
[ "s414701090", "s174119820" ]
u223904637
p02781
python
s575431808
s643967041
1,031
183
43,356
38,256
Accepted
Accepted
82.25
n=int(eval(input())) k=int(eval(input())) s=len(list(str(n))) if k==1: ans=(s-1)*9 for i in range(9): if n>=(10**(s-1))*(i+1): ans+=1 elif k==2: ans=9*9*(s-1)*(s-2)//2 for i in range(9): for j in range(s-1): for p in range(9): if n>=(1...
n = int(eval(input())) N = len(str(n)) k = int(eval(input())) s = [int(i) for i in str(n)] dpi = [[0]*(k+1) for _ in range(N+1)] dpj = [[0]*(k+1) for _ in range(N+1)] dpi[0][0] = 1 for i in range(N): for j in range(k+1): dpi[i+1][j] += dpi[i][j]*(s[i]==0) dpj[i+1][j] += dpj[i][j]+dpi[i][j]...
27
15
744
476
n = int(eval(input())) k = int(eval(input())) s = len(list(str(n))) if k == 1: ans = (s - 1) * 9 for i in range(9): if n >= (10 ** (s - 1)) * (i + 1): ans += 1 elif k == 2: ans = 9 * 9 * (s - 1) * (s - 2) // 2 for i in range(9): for j in range(s - 1): for p in ran...
n = int(eval(input())) N = len(str(n)) k = int(eval(input())) s = [int(i) for i in str(n)] dpi = [[0] * (k + 1) for _ in range(N + 1)] dpj = [[0] * (k + 1) for _ in range(N + 1)] dpi[0][0] = 1 for i in range(N): for j in range(k + 1): dpi[i + 1][j] += dpi[i][j] * (s[i] == 0) dpj[i + 1][j] += dpj[i][...
false
44.444444
[ "+N = len(str(n))", "-s = len(list(str(n)))", "-if k == 1:", "- ans = (s - 1) * 9", "- for i in range(9):", "- if n >= (10 ** (s - 1)) * (i + 1):", "- ans += 1", "-elif k == 2:", "- ans = 9 * 9 * (s - 1) * (s - 2) // 2", "- for i in range(9):", "- for j in ra...
false
0.116247
0.035381
3.285588
[ "s575431808", "s643967041" ]
u515740713
p03163
python
s885706920
s437122588
657
210
171,400
15,480
Accepted
Accepted
68.04
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,W = list(map(int, readline().split())) w=[];v=[] for _ in range(N): a,b = list(map(int, readline().split())) w.append(a) v.append(b) dp = [[0 for _ in range(W+1)] for _ in range(N+1)]...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,W = list(map(int,readline().split())) WV = [list(map(int,readline().split())) for _ in range(N)] dp = np.zeros(W+1,np.int64) for w,v in WV: np.maximum(dp[w:],dp[:-w].copy...
19
12
481
348
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, W = list(map(int, readline().split())) w = [] v = [] for _ in range(N): a, b = list(map(int, readline().split())) w.append(a) v.append(b) dp = [[0 for _ in range(W + 1)] for _ in range(N +...
import sys import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, W = list(map(int, readline().split())) WV = [list(map(int, readline().split())) for _ in range(N)] dp = np.zeros(W + 1, np.int64) for w, v in WV: np.maximum(dp[w:], dp[:-w].copy...
false
36.842105
[ "+import numpy as np", "-w = []", "-v = []", "-for _ in range(N):", "- a, b = list(map(int, readline().split()))", "- w.append(a)", "- v.append(b)", "-dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]", "-for i in range(N):", "- for j in range(W + 1):", "- if j >= w[i]:",...
false
0.083676
0.22449
0.372738
[ "s885706920", "s437122588" ]
u631277801
p02990
python
s338167958
s910528866
128
24
15,276
3,828
Accepted
Accepted
81.25
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(): return stdin.r...
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(): return stdin.r...
76
73
2,043
2,017
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(): ...
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(): ...
false
3.947368
[ "- if r > n:", "- raise ValueError(\"n must be larger than r (n={}, r={})\".format(n, r))", "+ # if r > n:", "+ # raise ValueError(\"n must be larger than r (n={}, r={})\".format(n, r))", "-CAP = 10**5", "-MOD = 10**9 + 7", "-ct = CombTools(CAP, MOD)", "+mod = 10**9...
false
0.259354
0.037035
7.002924
[ "s338167958", "s910528866" ]
u945080461
p03198
python
s186533085
s956565834
1,754
463
36,168
42,696
Accepted
Accepted
73.6
from sys import stdin from itertools import repeat def f(a): n = len(a) l = [0] * (n + 1) st = [(a[0], a[0], 1)] pu = st.append po = st.pop for i in range(1, n): ad = 0 y = a[i] k = 1 while st and y > st[-1][0]: x, z, q = po() ...
from sys import stdin from itertools import repeat def f(a): n = len(a) l = [0] * (n + 1) st = [(0, 0, 0, 1)] pu = st.append po = st.pop for i in range(1, n): ad = 0 r = i u = 0 k = 1 while st: y = a[r] << u x = a[st[...
33
41
792
921
from sys import stdin from itertools import repeat def f(a): n = len(a) l = [0] * (n + 1) st = [(a[0], a[0], 1)] pu = st.append po = st.pop for i in range(1, n): ad = 0 y = a[i] k = 1 while st and y > st[-1][0]: x, z, q = po() c = (((y - ...
from sys import stdin from itertools import repeat def f(a): n = len(a) l = [0] * (n + 1) st = [(0, 0, 0, 1)] pu = st.append po = st.pop for i in range(1, n): ad = 0 r = i u = 0 k = 1 while st: y = a[r] << u x = a[st[-1][0]] ...
false
19.512195
[ "- st = [(a[0], a[0], 1)]", "+ st = [(0, 0, 0, 1)]", "- y = a[i]", "+ r = i", "+ u = 0", "- while st and y > st[-1][0]:", "- x, z, q = po()", "- c = (((y - 1) / x).bit_length() + 1) / 2 * 2", "+ while st:", "+ y = a[r] << u"...
false
0.035706
0.041318
0.86418
[ "s186533085", "s956565834" ]
u102902647
p03329
python
s207326237
s561010314
511
334
3,828
3,828
Accepted
Accepted
34.64
ans = [0] * 100100 ans[0] = 0 n = int(eval(input())) #n = 127 for i in range(1,n+1): cand1 = ans[i-1] cand2 = 100001 cand3 = 100001 x = 6 while (x<=i): cand2 = min(ans[i-x], cand2) x=6*x y = 9 while (y<=i): cand3 = min(ans[i-y], cand3) y=9*y ...
# -*- coding: utf-8 -*- """ Created on Mon Aug 6 17:34:40 2018 @author: Yuki """ ans = [0] * 100100 ans[0] = 0 n = int(eval(input())) #n = 127 for i in range(1,n+1): cand1 = ans[i-1] cand2 = 100001 cand3 = 100001 x = 6 while (x<=i): #cand2 = min(ans[i-x], cand2) ...
21
31
373
520
ans = [0] * 100100 ans[0] = 0 n = int(eval(input())) # n = 127 for i in range(1, n + 1): cand1 = ans[i - 1] cand2 = 100001 cand3 = 100001 x = 6 while x <= i: cand2 = min(ans[i - x], cand2) x = 6 * x y = 9 while y <= i: cand3 = min(ans[i - y], cand3) y = 9 * y ...
# -*- coding: utf-8 -*- """ Created on Mon Aug 6 17:34:40 2018 @author: Yuki """ ans = [0] * 100100 ans[0] = 0 n = int(eval(input())) # n = 127 for i in range(1, n + 1): cand1 = ans[i - 1] cand2 = 100001 cand3 = 100001 x = 6 while x <= i: # cand2 = min(ans[i-x], cand2) cand2 = ans[i...
false
32.258065
[ "+# -*- coding: utf-8 -*-", "+\"\"\"", "+Created on Mon Aug 6 17:34:40 2018", "+@author: Yuki", "+\"\"\"", "- cand2 = min(ans[i - x], cand2)", "+ # cand2 = min(ans[i-x], cand2)", "+ cand2 = ans[i - x]", "- cand3 = min(ans[i - y], cand3)", "+ # cand3 = min(ans[i-...
false
0.192411
0.067448
2.852707
[ "s207326237", "s561010314" ]
u086566114
p02412
python
s207975963
s567028339
200
130
6,420
6,420
Accepted
Accepted
35
def get_num(n, m): ans = 0 for x in range(n, 2, -1): if 3 * x - 2 < m: return ans for y in range(x - 1, 1, -1): if x + 2 * y - 1 < m: break for z in range(y - 1, 0, -1): s = x + y + z if s == m: ...
def get_num(n, m): ans = 0 for x in range(min(n, m), (m + 2) / 3, -1): for y in range(x - 1, 1, -1): if x + 2 * y - 1 < m: break for z in range(y - 1, 0, -1): s = x + y + z if s == m: ans += 1 ...
21
19
522
488
def get_num(n, m): ans = 0 for x in range(n, 2, -1): if 3 * x - 2 < m: return ans for y in range(x - 1, 1, -1): if x + 2 * y - 1 < m: break for z in range(y - 1, 0, -1): s = x + y + z if s == m: ...
def get_num(n, m): ans = 0 for x in range(min(n, m), (m + 2) / 3, -1): for y in range(x - 1, 1, -1): if x + 2 * y - 1 < m: break for z in range(y - 1, 0, -1): s = x + y + z if s == m: ans += 1 ...
false
9.52381
[ "- for x in range(n, 2, -1):", "- if 3 * x - 2 < m:", "- return ans", "+ for x in range(min(n, m), (m + 2) / 3, -1):", "- [n, m] = [int(x) for x in input().split()]", "- if [n, m] == [0, 0]:", "+ [n, x] = [int(m) for m in input().split()]", "+ if [n, x] == [0, 0]:",...
false
0.042454
0.082914
0.512028
[ "s207975963", "s567028339" ]
u144913062
p02892
python
s400140808
s516036523
428
351
55,772
54,236
Accepted
Accepted
17.99
import sys input = sys.stdin.readline def floyd_warshall(dist): for k in range(N): for i in range(N): for j in range(N): dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) def is_bipartite(u): for v in range(N): if u == v or dist[u][v] != 1: ...
def b(u,x): c[u]=x return all((c[u]!=c[v])&(c[v]or b(v,-x))for v in X if d[u][v]==1) N=int(eval(input())) X=list(range(N)) S=[eval(input())for _ in X] d=[[1 if S[i][j]=='1'else(N if i^j else 0)for j in X]for i in X] for k in X: for i in X: for j in X:d[i][j]=min(d[i][j],d[i][k]+d[k][j]) c=[0]*N print((m...
33
12
872
340
import sys input = sys.stdin.readline def floyd_warshall(dist): for k in range(N): for i in range(N): for j in range(N): dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) def is_bipartite(u): for v in range(N): if u == v or dist[u][v] != 1: contin...
def b(u, x): c[u] = x return all((c[u] != c[v]) & (c[v] or b(v, -x)) for v in X if d[u][v] == 1) N = int(eval(input())) X = list(range(N)) S = [eval(input()) for _ in X] d = [[1 if S[i][j] == "1" else (N if i ^ j else 0) for j in X] for i in X] for k in X: for i in X: for j in X: d[i][...
false
63.636364
[ "-import sys", "-", "-input = sys.stdin.readline", "-", "-", "-def floyd_warshall(dist):", "- for k in range(N):", "- for i in range(N):", "- for j in range(N):", "- dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])", "-", "-", "-def is_bipartite(u):",...
false
0.051662
0.105823
0.488196
[ "s400140808", "s516036523" ]
u256678932
p02397
python
s849025391
s840153579
60
50
5,608
5,608
Accepted
Accepted
16.67
while True: x, y = list(map(int, input().split())) if x == y == 0: break if x <= y: print(("{} {}".format(x, y))) else: print(("{} {}".format(y, x)))
while True: x, y = list(map(int, input().split())) if x == y == 0: break if x <= y: print((x, y)) else: print((y, x))
11
11
193
161
while True: x, y = list(map(int, input().split())) if x == y == 0: break if x <= y: print(("{} {}".format(x, y))) else: print(("{} {}".format(y, x)))
while True: x, y = list(map(int, input().split())) if x == y == 0: break if x <= y: print((x, y)) else: print((y, x))
false
0
[ "- print((\"{} {}\".format(x, y)))", "+ print((x, y))", "- print((\"{} {}\".format(y, x)))", "+ print((y, x))" ]
false
0.038725
0.090807
0.426451
[ "s849025391", "s840153579" ]
u802963389
p03160
python
s650985994
s808165138
163
131
13,908
13,976
Accepted
Accepted
19.63
n = int(eval(input())) h = list(map(int, input().split())) dp = [0] * n dp[1] = abs(h[0] - h[1]) for i in range(2, n): dp[i] = min(dp[i - k] + abs(h[i]-h[i-k]) for k in [1, 2]) print((dp[-1]))
n = int(eval(input())) H = list(map(int, input().split())) dp = [10 ** 12] * (n) dp[0] = 0 dp[1] = abs(H[1] - H[0]) for i in range(1, n-1): dp[i+1] = min(dp[i] + abs(H[i+1] - H[i]), dp[i-1] + abs(H[i+1] - H[i-1])) ans = dp[n-1] print(ans)
9
13
196
252
n = int(eval(input())) h = list(map(int, input().split())) dp = [0] * n dp[1] = abs(h[0] - h[1]) for i in range(2, n): dp[i] = min(dp[i - k] + abs(h[i] - h[i - k]) for k in [1, 2]) print((dp[-1]))
n = int(eval(input())) H = list(map(int, input().split())) dp = [10**12] * (n) dp[0] = 0 dp[1] = abs(H[1] - H[0]) for i in range(1, n - 1): dp[i + 1] = min(dp[i] + abs(H[i + 1] - H[i]), dp[i - 1] + abs(H[i + 1] - H[i - 1])) ans = dp[n - 1] print(ans)
false
30.769231
[ "-h = list(map(int, input().split()))", "-dp = [0] * n", "-dp[1] = abs(h[0] - h[1])", "-for i in range(2, n):", "- dp[i] = min(dp[i - k] + abs(h[i] - h[i - k]) for k in [1, 2])", "-print((dp[-1]))", "+H = list(map(int, input().split()))", "+dp = [10**12] * (n)", "+dp[0] = 0", "+dp[1] = abs(H[1]...
false
0.106569
0.007052
15.111935
[ "s650985994", "s808165138" ]
u380524497
p02803
python
s782166234
s624568907
727
215
57,308
3,316
Accepted
Accepted
70.43
import heapq h, w = list(map(int, input().split())) meiro = [] for i in range(h): line = eval(input()) meiro.append(line) def dfs(y, x): dist = [[-1]*w for _ in range(h)] if meiro[y][x] == '#': return 0 dist[y][x] = 0 pattern = [[-1, 0], [1, 0], [0, -1], [0, 1]] ...
from collections import deque h, w = list(map(int, input().split())) graph = '#' * (w+2) for _ in range(h): line = '#' + eval(input()) + '#' graph = graph + line graph = graph + '#' * (w+2) def bfs(x): if graph[x] == '#': return 0 seen = [-1] * ((h+2)*(w+2)) seen[x] = 0 ...
51
40
1,155
863
import heapq h, w = list(map(int, input().split())) meiro = [] for i in range(h): line = eval(input()) meiro.append(line) def dfs(y, x): dist = [[-1] * w for _ in range(h)] if meiro[y][x] == "#": return 0 dist[y][x] = 0 pattern = [[-1, 0], [1, 0], [0, -1], [0, 1]] todo = [] fo...
from collections import deque h, w = list(map(int, input().split())) graph = "#" * (w + 2) for _ in range(h): line = "#" + eval(input()) + "#" graph = graph + line graph = graph + "#" * (w + 2) def bfs(x): if graph[x] == "#": return 0 seen = [-1] * ((h + 2) * (w + 2)) seen[x] = 0 patt...
false
21.568627
[ "-import heapq", "+from collections import deque", "-meiro = []", "-for i in range(h):", "- line = eval(input())", "- meiro.append(line)", "+graph = \"#\" * (w + 2)", "+for _ in range(h):", "+ line = \"#\" + eval(input()) + \"#\"", "+ graph = graph + line", "+graph = graph + \"#\" * ...
false
0.078768
0.046491
1.694262
[ "s782166234", "s624568907" ]
u745087332
p03480
python
s671946286
s082477699
61
49
3,316
3,188
Accepted
Accepted
19.67
s = eval(input()) n = len(s) ans = n for i, (c1, c2) in enumerate(zip(s[:-1], s[1:])): if c1 == c2: continue ans = min(ans, max(i + 1, n - i - 1)) print(ans)
s = eval(input()) n = len(s) k = 0 tmp = set() while k * 2 < n and len(tmp) < 2: tmp.add(s[n // 2 + k]) tmp.add(s[(n - 1) // 2 - k]) k += 1 print((n // 2 + k - (len(tmp) == 2)))
10
9
179
189
s = eval(input()) n = len(s) ans = n for i, (c1, c2) in enumerate(zip(s[:-1], s[1:])): if c1 == c2: continue ans = min(ans, max(i + 1, n - i - 1)) print(ans)
s = eval(input()) n = len(s) k = 0 tmp = set() while k * 2 < n and len(tmp) < 2: tmp.add(s[n // 2 + k]) tmp.add(s[(n - 1) // 2 - k]) k += 1 print((n // 2 + k - (len(tmp) == 2)))
false
10
[ "-ans = n", "-for i, (c1, c2) in enumerate(zip(s[:-1], s[1:])):", "- if c1 == c2:", "- continue", "- ans = min(ans, max(i + 1, n - i - 1))", "-print(ans)", "+k = 0", "+tmp = set()", "+while k * 2 < n and len(tmp) < 2:", "+ tmp.add(s[n // 2 + k])", "+ tmp.add(s[(n - 1) // 2 - k...
false
0.043935
0.039253
1.119277
[ "s671946286", "s082477699" ]
u484229314
p03575
python
s918802741
s695240194
730
25
47,580
3,188
Accepted
Accepted
96.58
N, M = [int(_) for _ in input().split()] paths = [[0] * (N + 1) for _ in range(N + 1)] def has_path(c, t, arrived): if c == t: return True for i in range(1, N + 1): if i in arrived: continue if paths[c][i]: arrived.append(i) if has_path(i, t, arrived): ...
N, M = [int(_) for _ in input().split()] paths = [[0] * (N + 1) for _ in range(N + 1)] edges = [] for i in range(M): a, b = [int(_) for _ in input().split()] paths[a][b] = 1 paths[b][a] = 1 edges.append((a, b)) class UF: def __init__(self, v): self.parent = None se...
33
54
740
1,150
N, M = [int(_) for _ in input().split()] paths = [[0] * (N + 1) for _ in range(N + 1)] def has_path(c, t, arrived): if c == t: return True for i in range(1, N + 1): if i in arrived: continue if paths[c][i]: arrived.append(i) if has_path(i, t, arrived...
N, M = [int(_) for _ in input().split()] paths = [[0] * (N + 1) for _ in range(N + 1)] edges = [] for i in range(M): a, b = [int(_) for _ in input().split()] paths[a][b] = 1 paths[b][a] = 1 edges.append((a, b)) class UF: def __init__(self, v): self.parent = None self.val = v @...
false
38.888889
[ "-", "-", "-def has_path(c, t, arrived):", "- if c == t:", "- return True", "- for i in range(1, N + 1):", "- if i in arrived:", "- continue", "- if paths[c][i]:", "- arrived.append(i)", "- if has_path(i, t, arrived):", "- ...
false
0.040617
0.03454
1.175948
[ "s918802741", "s695240194" ]
u923573620
p00003
python
s901631192
s352834469
50
40
5,664
5,676
Accepted
Accepted
20
import math N = int(eval(input())) for i in range(N): side_len = list(map(int, input().split(" "))) side_len.sort() if int(math.pow(side_len[0], 2)) + int(math.pow(side_len[1], 2)) == int(math.pow(side_len[2], 2)): print("YES") else: print("NO")
import math num = int(eval(input())) for i in range(num): try: sides = list(map(int, input().split(" "))) sides.sort() if int(math.pow(sides[0], 2)) + int(math.pow(sides[1], 2)) == int(math.pow(sides[2], 2)): print("YES") else: print("NO") ...
11
16
268
339
import math N = int(eval(input())) for i in range(N): side_len = list(map(int, input().split(" "))) side_len.sort() if int(math.pow(side_len[0], 2)) + int(math.pow(side_len[1], 2)) == int( math.pow(side_len[2], 2) ): print("YES") else: print("NO")
import math num = int(eval(input())) for i in range(num): try: sides = list(map(int, input().split(" "))) sides.sort() if int(math.pow(sides[0], 2)) + int(math.pow(sides[1], 2)) == int( math.pow(sides[2], 2) ): print("YES") else: print("NO...
false
31.25
[ "-N = int(eval(input()))", "-for i in range(N):", "- side_len = list(map(int, input().split(\" \")))", "- side_len.sort()", "- if int(math.pow(side_len[0], 2)) + int(math.pow(side_len[1], 2)) == int(", "- math.pow(side_len[2], 2)", "- ):", "- print(\"YES\")", "- else:", ...
false
0.043133
0.047343
0.911088
[ "s901631192", "s352834469" ]
u886747123
p02838
python
s229104728
s719506124
1,291
1,052
122,808
122,928
Accepted
Accepted
18.51
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 bit = [0] * 61 for i in range(N): for x in range(61): if 2**x > A[i]: break elif (1<<x) & A[i] > 0: bit[x] += 1 ans = 0 for i in range(61): ans += 2**i * (bit[i] * (N-bit[i])) ...
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 bit = [0] * 61 for i in range(N): for x in range(61): if 2**x > A[i]: break else: bit[x] += (A[i]>>x)&1 ans = 0 for i in range(61): ans += 2**i * (bit[i] * (N-bit[i])) ans %= M...
18
18
338
330
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 bit = [0] * 61 for i in range(N): for x in range(61): if 2**x > A[i]: break elif (1 << x) & A[i] > 0: bit[x] += 1 ans = 0 for i in range(61): ans += 2**i * (bit[i] * (N - bit[i])) ans %= MOD pr...
N = int(eval(input())) A = list(map(int, input().split())) MOD = 10**9 + 7 bit = [0] * 61 for i in range(N): for x in range(61): if 2**x > A[i]: break else: bit[x] += (A[i] >> x) & 1 ans = 0 for i in range(61): ans += 2**i * (bit[i] * (N - bit[i])) ans %= MOD print(an...
false
0
[ "- elif (1 << x) & A[i] > 0:", "- bit[x] += 1", "+ else:", "+ bit[x] += (A[i] >> x) & 1" ]
false
0.038256
0.038146
1.002883
[ "s229104728", "s719506124" ]
u038024401
p03162
python
s916697496
s869133987
725
521
42,572
42,572
Accepted
Accepted
28.14
N = int(eval(input())) ABC = [[None]*3 for i in range(N)] for i in range(N): ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, input().split())) happiness = [[0] *3 for i in range(N+1)] for i in range(N): for j in range(3): happiness[i+1][j] = max(happiness[i][j-1] + ABC[i][j], happiness[i][j...
import sys N = int(sys.stdin.readline()) ABC = [[None]*3 for i in range(N)] for i in range(N): ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, sys.stdin.readline().split())) happiness = [[0] *3 for i in range(N+1)] for i in range(N): for j in range(3): happiness[i+1][j] = max(happiness[i...
13
15
352
392
N = int(eval(input())) ABC = [[None] * 3 for i in range(N)] for i in range(N): ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, input().split())) happiness = [[0] * 3 for i in range(N + 1)] for i in range(N): for j in range(3): happiness[i + 1][j] = max( happiness[i][j - 1] + ABC[i][j], happi...
import sys N = int(sys.stdin.readline()) ABC = [[None] * 3 for i in range(N)] for i in range(N): ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, sys.stdin.readline().split())) happiness = [[0] * 3 for i in range(N + 1)] for i in range(N): for j in range(3): happiness[i + 1][j] = max( happin...
false
13.333333
[ "-N = int(eval(input()))", "+import sys", "+", "+N = int(sys.stdin.readline())", "- ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, input().split()))", "+ ABC[i][0], ABC[i][1], ABC[i][2] = list(map(int, sys.stdin.readline().split()))" ]
false
0.094592
0.048094
1.966807
[ "s916697496", "s869133987" ]
u760794812
p03168
python
s901886280
s674359827
1,767
138
27,804
27,428
Accepted
Accepted
92.19
import numpy as np n= int(eval(input())) ppp = list(map(float,input().split())) dp = [0]*(n+1) dp[0]=1 for p in ppp: ndp = [item*(1-p) for item in dp] ndp = [ndp[i] if i == 0 else ndp[i]+dp[i-1]*p for i in range(n+1)] dp = ndp print((sum(dp[n//2+1:])))
import numpy as np n= int(eval(input())) ppp = list(map(float,input().split())) dp = np.array([0.0]*(n+1),dtype=np.float64) dp[0]=1 for p in ppp: ndp = dp*(1-p) ndp[1:] += dp[:-1]*p dp = ndp print((sum(dp[n//2+1:])))
10
10
259
223
import numpy as np n = int(eval(input())) ppp = list(map(float, input().split())) dp = [0] * (n + 1) dp[0] = 1 for p in ppp: ndp = [item * (1 - p) for item in dp] ndp = [ndp[i] if i == 0 else ndp[i] + dp[i - 1] * p for i in range(n + 1)] dp = ndp print((sum(dp[n // 2 + 1 :])))
import numpy as np n = int(eval(input())) ppp = list(map(float, input().split())) dp = np.array([0.0] * (n + 1), dtype=np.float64) dp[0] = 1 for p in ppp: ndp = dp * (1 - p) ndp[1:] += dp[:-1] * p dp = ndp print((sum(dp[n // 2 + 1 :])))
false
0
[ "-dp = [0] * (n + 1)", "+dp = np.array([0.0] * (n + 1), dtype=np.float64)", "- ndp = [item * (1 - p) for item in dp]", "- ndp = [ndp[i] if i == 0 else ndp[i] + dp[i - 1] * p for i in range(n + 1)]", "+ ndp = dp * (1 - p)", "+ ndp[1:] += dp[:-1] * p" ]
false
0.07617
0.214168
0.355657
[ "s901886280", "s674359827" ]
u707498674
p03197
python
s830883393
s897143120
379
161
22,016
14,548
Accepted
Accepted
57.52
import numpy as np def main(): stdin = np.fromstring(open(0).read(), dtype=np.int32, sep=' ') N = stdin[0] A = stdin[1:] A = np.mod(A, 2) print("first") if np.count_nonzero(A) else print("second") if __name__ == "__main__": main()
import numpy as np def main(): stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ') A = stdin[1:] A = np.mod(A, 2) print("first") if np.count_nonzero(A) else print("second") if __name__ == "__main__": main()
10
9
264
248
import numpy as np def main(): stdin = np.fromstring(open(0).read(), dtype=np.int32, sep=" ") N = stdin[0] A = stdin[1:] A = np.mod(A, 2) print("first") if np.count_nonzero(A) else print("second") if __name__ == "__main__": main()
import numpy as np def main(): stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=" ") A = stdin[1:] A = np.mod(A, 2) print("first") if np.count_nonzero(A) else print("second") if __name__ == "__main__": main()
false
10
[ "- stdin = np.fromstring(open(0).read(), dtype=np.int32, sep=\" \")", "- N = stdin[0]", "+ stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=\" \")" ]
false
0.201054
0.203597
0.98751
[ "s830883393", "s897143120" ]
u493520238
p03252
python
s307564589
s297369820
194
75
41,968
74,008
Accepted
Accepted
61.34
s = eval(input()) t = eval(input()) s_d = {} t_d = {} for i in range(len(s)): if s[i] not in s_d: new_num = len(s_d)+1 s_d[s[i]] = new_num s_valid = -1 else: s_valid = s_d[s[i]] if t[i] not in t_d: new_num = len(t_d)+1 t_d[t[i]] = new_num ...
s = eval(input()) t = eval(input()) d = {} for si,ti in zip(s,t): if not si in d: d[si] = ti else: if d[si] != ti: print('No') break else: sset = set() for v in list(d.values()): if v in sset: print('No') break ...
26
20
458
351
s = eval(input()) t = eval(input()) s_d = {} t_d = {} for i in range(len(s)): if s[i] not in s_d: new_num = len(s_d) + 1 s_d[s[i]] = new_num s_valid = -1 else: s_valid = s_d[s[i]] if t[i] not in t_d: new_num = len(t_d) + 1 t_d[t[i]] = new_num t_valid =...
s = eval(input()) t = eval(input()) d = {} for si, ti in zip(s, t): if not si in d: d[si] = ti else: if d[si] != ti: print("No") break else: sset = set() for v in list(d.values()): if v in sset: print("No") break sset.add(v)...
false
23.076923
[ "-s_d = {}", "-t_d = {}", "-for i in range(len(s)):", "- if s[i] not in s_d:", "- new_num = len(s_d) + 1", "- s_d[s[i]] = new_num", "- s_valid = -1", "+d = {}", "+for si, ti in zip(s, t):", "+ if not si in d:", "+ d[si] = ti", "- s_valid = s_d[s[i]]", ...
false
0.037467
0.043379
0.86372
[ "s307564589", "s297369820" ]
u163320134
p03612
python
s847003248
s479466185
80
73
14,008
14,008
Accepted
Accepted
8.75
n=int(eval(input())) arr=list(map(int,input().split())) ans=0 for i in range(n-2): if arr[i]==i+1: arr[i],arr[i+1]=arr[i+1],arr[i] ans+=1 elif arr[i+1]==i+1: arr[i+1],arr[i+2]=arr[i+2],arr[i+1] if arr[-1]==n or arr[-2]==n-1: ans+=1 print(ans)
n=int(eval(input())) arr=list(map(int,input().split())) ans=0 for i in range(n-1,-1,-1): if arr[i]==i+1: arr[i],arr[i-1]=arr[i-1],arr[i] ans+=1 print(ans)
12
8
266
165
n = int(eval(input())) arr = list(map(int, input().split())) ans = 0 for i in range(n - 2): if arr[i] == i + 1: arr[i], arr[i + 1] = arr[i + 1], arr[i] ans += 1 elif arr[i + 1] == i + 1: arr[i + 1], arr[i + 2] = arr[i + 2], arr[i + 1] if arr[-1] == n or arr[-2] == n - 1: ans += 1 pri...
n = int(eval(input())) arr = list(map(int, input().split())) ans = 0 for i in range(n - 1, -1, -1): if arr[i] == i + 1: arr[i], arr[i - 1] = arr[i - 1], arr[i] ans += 1 print(ans)
false
33.333333
[ "-for i in range(n - 2):", "+for i in range(n - 1, -1, -1):", "- arr[i], arr[i + 1] = arr[i + 1], arr[i]", "+ arr[i], arr[i - 1] = arr[i - 1], arr[i]", "- elif arr[i + 1] == i + 1:", "- arr[i + 1], arr[i + 2] = arr[i + 2], arr[i + 1]", "-if arr[-1] == n or arr[-2] == n - 1:", "...
false
0.043929
0.043676
1.005777
[ "s847003248", "s479466185" ]
u977193988
p03018
python
s593128942
s916500707
81
35
11,368
3,500
Accepted
Accepted
56.79
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) def main(): S = eval(input()) S = S.replace("BC", "X") S = S.replace("C", "B") S = S.split("B") answer = 0 for s in S: place = [] c = 0 n = len(s) ...
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) def main(): S = eval(input()) S = S.replace("BC", "X") cnt_a = 0 answer = 0 for s in S: if s == "A": cnt_a += 1 elif s == "X": answer += cnt...
32
27
568
418
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10**9) def main(): S = eval(input()) S = S.replace("BC", "X") S = S.replace("C", "B") S = S.split("B") answer = 0 for s in S: place = [] c = 0 n = len(s) for i in range(n):...
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10**9) def main(): S = eval(input()) S = S.replace("BC", "X") cnt_a = 0 answer = 0 for s in S: if s == "A": cnt_a += 1 elif s == "X": answer += cnt_a else: ...
false
15.625
[ "- S = S.replace(\"C\", \"B\")", "- S = S.split(\"B\")", "+ cnt_a = 0", "- place = []", "- c = 0", "- n = len(s)", "- for i in range(n):", "- if s[i] == \"A\":", "- c += 1", "- place.append(i + 1)", "- for p in ...
false
0.040974
0.038594
1.061671
[ "s593128942", "s916500707" ]
u683134447
p02947
python
s440983734
s094217115
1,799
1,059
101,848
117,508
Accepted
Accepted
41.13
# coding: utf-8 # Your code here! import collections n = int(eval(input())) sl = [] for _ in range(n): s = sorted(list(eval(input()))) sl.append(s) before_s = "" ans = 0 point = 1 for i in sorted(sl): if i == before_s: point += 1 else: before_s = i ans += in...
n = int(eval(input())) from collections import defaultdict dic = defaultdict(int) for _ in range(n): s = list(eval(input())) s = tuple(sorted(s)) dic[s] += 1 ans = 0 for s in dic: ans += dic[s] * (dic[s] - 1) // 2 print(ans)
24
18
409
253
# coding: utf-8 # Your code here! import collections n = int(eval(input())) sl = [] for _ in range(n): s = sorted(list(eval(input()))) sl.append(s) before_s = "" ans = 0 point = 1 for i in sorted(sl): if i == before_s: point += 1 else: before_s = i ans += int(point * (point - 1)...
n = int(eval(input())) from collections import defaultdict dic = defaultdict(int) for _ in range(n): s = list(eval(input())) s = tuple(sorted(s)) dic[s] += 1 ans = 0 for s in dic: ans += dic[s] * (dic[s] - 1) // 2 print(ans)
false
25
[ "-# coding: utf-8", "-# Your code here!", "-import collections", "+n = int(eval(input()))", "+from collections import defaultdict", "-n = int(eval(input()))", "-sl = []", "+dic = defaultdict(int)", "- s = sorted(list(eval(input())))", "- sl.append(s)", "-before_s = \"\"", "+ s = list(...
false
0.036934
0.034879
1.058907
[ "s440983734", "s094217115" ]
u057109575
p03074
python
s594607439
s847679107
227
159
59,000
88,104
Accepted
Accepted
29.96
N, K = list(map(int, input().split())) S = eval(input()) que = [(S[0], 0)] cur = S[0] for i in range(1, N): if cur != S[i]: que.append((S[i], i)) cur = S[i] ans = [] LEN = len(que) for i in range(LEN): if que[i][0] == '0': if i + 2 * K < LEN: ans.append(que[i...
N, K = list(map(int, input().split())) S = eval(input()) q = [(S[0], 0)] cur = S[0] for i in range(1, N): if S[i] != cur: q.append((S[i], i)) cur = S[i] lim = len(q) ans = [] for i in range(lim): if q[i][0] == "0": j = i + 2 * K else: j = i + 2 * K + 1 ...
25
25
576
426
N, K = list(map(int, input().split())) S = eval(input()) que = [(S[0], 0)] cur = S[0] for i in range(1, N): if cur != S[i]: que.append((S[i], i)) cur = S[i] ans = [] LEN = len(que) for i in range(LEN): if que[i][0] == "0": if i + 2 * K < LEN: ans.append(que[i + 2 * K][1] - qu...
N, K = list(map(int, input().split())) S = eval(input()) q = [(S[0], 0)] cur = S[0] for i in range(1, N): if S[i] != cur: q.append((S[i], i)) cur = S[i] lim = len(q) ans = [] for i in range(lim): if q[i][0] == "0": j = i + 2 * K else: j = i + 2 * K + 1 if j < lim: ...
false
0
[ "-que = [(S[0], 0)]", "+q = [(S[0], 0)]", "- if cur != S[i]:", "- que.append((S[i], i))", "+ if S[i] != cur:", "+ q.append((S[i], i))", "+lim = len(q)", "-LEN = len(que)", "-for i in range(LEN):", "- if que[i][0] == \"0\":", "- if i + 2 * K < LEN:", "- ...
false
0.047343
0.047135
1.004427
[ "s594607439", "s847679107" ]
u130900604
p02639
python
s977751089
s604539562
64
24
61,644
9,052
Accepted
Accepted
62.5
x=list(map(int,input().split())) print((x.index(0)+1))
print((15-sum(map(int,input().split()))))
2
1
53
39
x = list(map(int, input().split())) print((x.index(0) + 1))
print((15 - sum(map(int, input().split()))))
false
50
[ "-x = list(map(int, input().split()))", "-print((x.index(0) + 1))", "+print((15 - sum(map(int, input().split()))))" ]
false
0.045378
0.047068
0.964094
[ "s977751089", "s604539562" ]
u562016607
p04016
python
s471641011
s426551007
292
261
3,064
3,064
Accepted
Accepted
10.62
import math def f(b,n): if n<b: return n else: return f(b,n//b)+(n%b) N=int(eval(input())) S=int(eval(input())) if N==S: print((N+1)) else: for b in range(2,int(math.sqrt(N))+2): if f(b,N)==S: print(b) exit() ans=10**13 for p in ran...
import math 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) def abc(N,S): if N==S: return N+1 else: for b in range(2,int(math.sqrt(N))+2): if f(b,N)==S: return b t...
29
30
556
585
import math def f(b, n): if n < b: return n else: return f(b, n // b) + (n % b) N = int(eval(input())) S = int(eval(input())) if N == S: print((N + 1)) else: for b in range(2, int(math.sqrt(N)) + 2): if f(b, N) == S: print(b) exit() ans = 10**13 ...
import math 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) def abc(N, S): if N == S: return N + 1 else: for b in range(2, int(math.sqrt(N)) + 2): if f(b, N) == S: return b ...
false
3.333333
[ "+", "+n = int(eval(input()))", "+s = int(eval(input()))", "-N = int(eval(input()))", "-S = int(eval(input()))", "-if N == S:", "- print((N + 1))", "-else:", "- for b in range(2, int(math.sqrt(N)) + 2):", "- if f(b, N) == S:", "- print(b)", "- exit()", "- ...
false
0.046102
0.049027
0.940335
[ "s471641011", "s426551007" ]
u305366205
p03018
python
s029415347
s148760094
106
47
3,500
3,500
Accepted
Accepted
55.66
s = eval(input()) cnt = 0 ans = 0 flag = False for i in range(len(s) - 1): if flag: flag = False continue if s[i: i + 2] == 'BC': ans += cnt flag = True elif s[i] == 'A': cnt += 1 else: cnt = 0 print(ans)
s = input().replace('BC', 'D') cnt = 0 ans = 0 for c in s: if c == 'A': cnt += 1 elif c == 'D': ans += cnt else: cnt = 0 print(ans)
16
11
277
177
s = eval(input()) cnt = 0 ans = 0 flag = False for i in range(len(s) - 1): if flag: flag = False continue if s[i : i + 2] == "BC": ans += cnt flag = True elif s[i] == "A": cnt += 1 else: cnt = 0 print(ans)
s = input().replace("BC", "D") cnt = 0 ans = 0 for c in s: if c == "A": cnt += 1 elif c == "D": ans += cnt else: cnt = 0 print(ans)
false
31.25
[ "-s = eval(input())", "+s = input().replace(\"BC\", \"D\")", "-flag = False", "-for i in range(len(s) - 1):", "- if flag:", "- flag = False", "- continue", "- if s[i : i + 2] == \"BC\":", "+for c in s:", "+ if c == \"A\":", "+ cnt += 1", "+ elif c == \"D\":", ...
false
0.037476
0.064751
0.578766
[ "s029415347", "s148760094" ]
u761320129
p03157
python
s106499877
s082441306
914
586
22,248
35,504
Accepted
Accepted
35.89
from collections import Counter H,W = list(map(int,input().split())) S = [eval(input()) for i in range(H)] class UnionFind: def __init__(self,N): self.parent = [i for i in range(N)] self.rank = [0] * N self.count = 0 def root(self,a): if self.parent[a] == a: ...
H,W = list(map(int,input().split())) S = [eval(input()) for i in range(H)] class UnionFind: def __init__(self,N): self.parent = [i for i in range(N)] self._size = [1] * N self.count = 0 def root(self,a): if self.parent[a] == a: return a else: ...
55
53
1,382
1,413
from collections import Counter H, W = list(map(int, input().split())) S = [eval(input()) for i in range(H)] class UnionFind: def __init__(self, N): self.parent = [i for i in range(N)] self.rank = [0] * N self.count = 0 def root(self, a): if self.parent[a] == a: r...
H, W = list(map(int, input().split())) S = [eval(input()) for i in range(H)] class UnionFind: def __init__(self, N): self.parent = [i for i in range(N)] self._size = [1] * N self.count = 0 def root(self, a): if self.parent[a] == a: return a else: ...
false
3.636364
[ "-from collections import Counter", "-", "- self.rank = [0] * N", "+ self._size = [1] * N", "- if self.rank[ra] < self.rank[rb]:", "- self.parent[ra] = rb", "- else:", "- self.parent[rb] = ra", "- if self.rank[ra] == self.rank[rb]:", "- ...
false
0.043893
0.08299
0.528892
[ "s106499877", "s082441306" ]
u150984829
p02269
python
s524515862
s041055295
830
740
118,068
33,668
Accepted
Accepted
10.84
import sys def m(): d={} for e in sys.stdin.readlines()[1:]: if'f'==e[0]:print(('yes'if e[5:]in d else'no')) else:d[e[7:]]=0 if'__main__'==__name__:m()
import sys def m(): d={};eval(input()) for e in sys.stdin: if'f'==e[0]:print(('yes'if e[5:]in d else'no')) else:d[e[7:]]=0 if'__main__'==__name__:m()
7
7
162
154
import sys def m(): d = {} for e in sys.stdin.readlines()[1:]: if "f" == e[0]: print(("yes" if e[5:] in d else "no")) else: d[e[7:]] = 0 if "__main__" == __name__: m()
import sys def m(): d = {} eval(input()) for e in sys.stdin: if "f" == e[0]: print(("yes" if e[5:] in d else "no")) else: d[e[7:]] = 0 if "__main__" == __name__: m()
false
0
[ "- for e in sys.stdin.readlines()[1:]:", "+ eval(input())", "+ for e in sys.stdin:" ]
false
0.079274
0.042841
1.850412
[ "s524515862", "s041055295" ]
u576917603
p02917
python
s766976992
s738417613
182
20
38,384
3,060
Accepted
Accepted
89.01
n=int(eval(input())) a=[None]*n b=list(map(int,input().split())) a[0]=b[0] a[-1]=b[-1] for i in range(1,n-1): if b[i]>=b[i-1]: a[i]=b[i-1] else: a[i]=b[i] print((sum(a)))
n=int(eval(input())) b=list(map(int,input().split())) a=[0]*n a[0]=b[0] for i in range(n-2): a[i+1]=min(b[i],b[i+1]) a[-1]=b[-1] print((sum(a)))
11
8
196
147
n = int(eval(input())) a = [None] * n b = list(map(int, input().split())) a[0] = b[0] a[-1] = b[-1] for i in range(1, n - 1): if b[i] >= b[i - 1]: a[i] = b[i - 1] else: a[i] = b[i] print((sum(a)))
n = int(eval(input())) b = list(map(int, input().split())) a = [0] * n a[0] = b[0] for i in range(n - 2): a[i + 1] = min(b[i], b[i + 1]) a[-1] = b[-1] print((sum(a)))
false
27.272727
[ "-a = [None] * n", "+a = [0] * n", "+for i in range(n - 2):", "+ a[i + 1] = min(b[i], b[i + 1])", "-for i in range(1, n - 1):", "- if b[i] >= b[i - 1]:", "- a[i] = b[i - 1]", "- else:", "- a[i] = b[i]" ]
false
0.039031
0.035179
1.109482
[ "s766976992", "s738417613" ]
u500376440
p03355
python
s656329827
s334267549
481
70
69,544
69,576
Accepted
Accepted
85.45
import sys def input(): return sys.stdin.readline().rstrip() S=eval(input()) K=int(eval(input())) vec=[] for i in range(len(S)): for j in range(i+1,K+i+1): tmp=S[i:j] if not tmp in vec: vec.append(tmp) vec.sort() print((vec[K-1]))
import sys def input(): return sys.stdin.readline().rstrip() S=eval(input()) K=int(eval(input())) vec=set() for i in range(len(S)): for j in range(i+1,min(len(S)+1,K+i+1)): tmp=S[i:j] vec.add(tmp) vec=list(vec) vec.sort() print((vec[K-1]))
16
17
253
258
import sys def input(): return sys.stdin.readline().rstrip() S = eval(input()) K = int(eval(input())) vec = [] for i in range(len(S)): for j in range(i + 1, K + i + 1): tmp = S[i:j] if not tmp in vec: vec.append(tmp) vec.sort() print((vec[K - 1]))
import sys def input(): return sys.stdin.readline().rstrip() S = eval(input()) K = int(eval(input())) vec = set() for i in range(len(S)): for j in range(i + 1, min(len(S) + 1, K + i + 1)): tmp = S[i:j] vec.add(tmp) vec = list(vec) vec.sort() print((vec[K - 1]))
false
5.882353
[ "-vec = []", "+vec = set()", "- for j in range(i + 1, K + i + 1):", "+ for j in range(i + 1, min(len(S) + 1, K + i + 1)):", "- if not tmp in vec:", "- vec.append(tmp)", "+ vec.add(tmp)", "+vec = list(vec)" ]
false
0.079946
0.040416
1.978099
[ "s656329827", "s334267549" ]
u636683284
p03038
python
s234372578
s320015989
390
250
97,264
107,564
Accepted
Accepted
35.9
import sys import heapq input = sys.stdin.readline n,m = list(map(int,input().split())) A = list(map(int,input().split())) heapq.heapify(A) BC = [list(map(int, input().split())) for i in range(m)] BC = sorted(BC,key = lambda x:-x[1]) for b,c in BC: for i in range(b): a = heapq.heappop(A) ...
import sys input = sys.stdin.readline n,m = list(map(int,input().split())) A = list(map(int,input().split())) BC = [tuple(map(int,input().split())) for i in range(m)] BC = sorted(BC,key=lambda x:-x[1]) cnt = 0 flag = True while True: for b,c in BC: A += [c]*b cnt += b if cnt > ...
20
18
444
393
import sys import heapq input = sys.stdin.readline n, m = list(map(int, input().split())) A = list(map(int, input().split())) heapq.heapify(A) BC = [list(map(int, input().split())) for i in range(m)] BC = sorted(BC, key=lambda x: -x[1]) for b, c in BC: for i in range(b): a = heapq.heappop(A) if a <...
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) A = list(map(int, input().split())) BC = [tuple(map(int, input().split())) for i in range(m)] BC = sorted(BC, key=lambda x: -x[1]) cnt = 0 flag = True while True: for b, c in BC: A += [c] * b cnt += b if cnt > n: ...
false
10
[ "-import heapq", "-heapq.heapify(A)", "-BC = [list(map(int, input().split())) for i in range(m)]", "+BC = [tuple(map(int, input().split())) for i in range(m)]", "-for b, c in BC:", "- for i in range(b):", "- a = heapq.heappop(A)", "- if a < c:", "- heapq.heappush(A, c)", ...
false
0.035333
0.069191
0.510653
[ "s234372578", "s320015989" ]
u970899068
p02792
python
s002642543
s607073079
227
205
40,812
40,428
Accepted
Accepted
9.69
n=int(eval(input())) v=[0]*100 ans=0 for i in range(1,n+1): x=int(str(i)[0]) y=int(str(i)[-1]) v[x*10+y]+=1 for i in range(len(v)): x=int(str(i)[0]) y=int(str(i)[-1]) ans+=v[i]*v[10*y+x] print(ans)
n=int(eval(input())) x=[0]*101 ans=0 for i in range(1,n+1): v=str(i) w=int(v[0]+v[-1]) x[w]+=1 for i in range(101): if x[i]!=0: v=str(i) w=int(v[-1]+v[0]) ans+=x[i]*x[w] print(ans)
13
14
228
228
n = int(eval(input())) v = [0] * 100 ans = 0 for i in range(1, n + 1): x = int(str(i)[0]) y = int(str(i)[-1]) v[x * 10 + y] += 1 for i in range(len(v)): x = int(str(i)[0]) y = int(str(i)[-1]) ans += v[i] * v[10 * y + x] print(ans)
n = int(eval(input())) x = [0] * 101 ans = 0 for i in range(1, n + 1): v = str(i) w = int(v[0] + v[-1]) x[w] += 1 for i in range(101): if x[i] != 0: v = str(i) w = int(v[-1] + v[0]) ans += x[i] * x[w] print(ans)
false
7.142857
[ "-v = [0] * 100", "+x = [0] * 101", "- x = int(str(i)[0])", "- y = int(str(i)[-1])", "- v[x * 10 + y] += 1", "-for i in range(len(v)):", "- x = int(str(i)[0])", "- y = int(str(i)[-1])", "- ans += v[i] * v[10 * y + x]", "+ v = str(i)", "+ w = int(v[0] + v[-1])", "+ x[...
false
0.085251
0.073653
1.157471
[ "s002642543", "s607073079" ]
u198440493
p03128
python
s856220290
s004718964
39
18
14,452
3,064
Accepted
Accepted
53.85
INF = float('inf') n, m = list(map(int, input().split())) a = list(map(int, input().split())) cost = [2, 5, 5, 4, 5, 6, 3, 7, 6] l = [[x, cost[x-1]] for x in a] l = sorted(l, key = lambda x: x[1]*10-x[0]) r = l[0] _max = [0] + [-INF]*n for i in range(1, n+1): if 42 < i < n-42: _max[i] = max(_max[i], _ma...
INF = float('inf') n, m = list(map(int, input().split())) a = list(map(int, input().split())) cost = [2, 5, 5, 4, 5, 6, 3, 7, 6] l = [[x, cost[x-1]] for x in a] l = sorted(l, key = lambda x: x[1]*10-x[0]) r = l[0] k = max(n-200, 0)//r[1] n -= r[1]*k _max = [0] + [-INF]*n for i in range(1, n+1): if 50 < i <...
18
21
485
564
INF = float("inf") n, m = list(map(int, input().split())) a = list(map(int, input().split())) cost = [2, 5, 5, 4, 5, 6, 3, 7, 6] l = [[x, cost[x - 1]] for x in a] l = sorted(l, key=lambda x: x[1] * 10 - x[0]) r = l[0] _max = [0] + [-INF] * n for i in range(1, n + 1): if 42 < i < n - 42: _max[i] = max(_max[i...
INF = float("inf") n, m = list(map(int, input().split())) a = list(map(int, input().split())) cost = [2, 5, 5, 4, 5, 6, 3, 7, 6] l = [[x, cost[x - 1]] for x in a] l = sorted(l, key=lambda x: x[1] * 10 - x[0]) r = l[0] k = max(n - 200, 0) // r[1] n -= r[1] * k _max = [0] + [-INF] * n for i in range(1, n + 1): if 50 ...
false
14.285714
[ "+k = max(n - 200, 0) // r[1]", "+n -= r[1] * k", "- if 42 < i < n - 42:", "+ if 50 < i < n - 50:", "+ans = ans[:10] + str(r[0]) * k + ans[10:]" ]
false
0.039492
0.043077
0.916777
[ "s856220290", "s004718964" ]
u464032595
p03086
python
s644811629
s702681331
179
30
38,384
8,980
Accepted
Accepted
83.24
s = eval(input()) maxs = 0 cnt = 0 for i, x in enumerate(s): if x in ['A', 'C', 'G', 'T']: cnt += 1 else: if cnt > 0: maxs = max(maxs, cnt) cnt = 0 if cnt > 0: maxs = max(maxs, cnt) print(maxs)
s = eval(input()) max_cnt = 0 cnt = 0 for i in s: if i in ['A', 'C', 'G', 'T']: cnt += 1 else: max_cnt = max(cnt, max_cnt) cnt = 0 print((max(max_cnt, cnt)))
13
12
251
194
s = eval(input()) maxs = 0 cnt = 0 for i, x in enumerate(s): if x in ["A", "C", "G", "T"]: cnt += 1 else: if cnt > 0: maxs = max(maxs, cnt) cnt = 0 if cnt > 0: maxs = max(maxs, cnt) print(maxs)
s = eval(input()) max_cnt = 0 cnt = 0 for i in s: if i in ["A", "C", "G", "T"]: cnt += 1 else: max_cnt = max(cnt, max_cnt) cnt = 0 print((max(max_cnt, cnt)))
false
7.692308
[ "-maxs = 0", "+max_cnt = 0", "-for i, x in enumerate(s):", "- if x in [\"A\", \"C\", \"G\", \"T\"]:", "+for i in s:", "+ if i in [\"A\", \"C\", \"G\", \"T\"]:", "- if cnt > 0:", "- maxs = max(maxs, cnt)", "- cnt = 0", "-if cnt > 0:", "- maxs = max(maxs, cnt)...
false
0.081913
0.036972
2.215542
[ "s644811629", "s702681331" ]
u647999897
p03013
python
s114991749
s126342159
596
478
470,648
45,016
Accepted
Accepted
19.8
def solve(): N, M = list(map(int, input().split())) a = [] for _ in range(M): a.append(int(eval(input()))) dp = [0] * (N + 1) dp[0] = 1 a_ind = 0 for i in range(1, N+1): if a_ind < M and i == a[a_ind]: a_ind += 1 dp[i] = 0 ...
def solve(): mod = 10 ** 9 + 7 N, M = list(map(int, input().split())) isBreakable = [False] * (N+1) for i in range(M): a = int(eval(input())) isBreakable[a] = True dp = [0] * (N+1) dp[0] = 1 for i in range(1, N+1): if isBreakable[i]: continue ...
23
23
475
497
def solve(): N, M = list(map(int, input().split())) a = [] for _ in range(M): a.append(int(eval(input()))) dp = [0] * (N + 1) dp[0] = 1 a_ind = 0 for i in range(1, N + 1): if a_ind < M and i == a[a_ind]: a_ind += 1 dp[i] = 0 continue ...
def solve(): mod = 10**9 + 7 N, M = list(map(int, input().split())) isBreakable = [False] * (N + 1) for i in range(M): a = int(eval(input())) isBreakable[a] = True dp = [0] * (N + 1) dp[0] = 1 for i in range(1, N + 1): if isBreakable[i]: continue i...
false
0
[ "+ mod = 10**9 + 7", "- a = []", "- for _ in range(M):", "- a.append(int(eval(input())))", "+ isBreakable = [False] * (N + 1)", "+ for i in range(M):", "+ a = int(eval(input()))", "+ isBreakable[a] = True", "- a_ind = 0", "- if a_ind < M and i == a[a_i...
false
0.102417
0.041282
2.480905
[ "s114991749", "s126342159" ]
u744920373
p03111
python
s551980491
s627868227
706
197
3,316
3,064
Accepted
Accepted
72.1
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): ret...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): ret...
60
37
2,020
1,111
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] de...
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return list(map(int, sys.stdin.readline().split())) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] de...
false
38.333333
[ "-L_ = [L[i] for i in range(N)]", "-N_ = N", "-# sum_l = sum(L)", "-tmp = [0] * 3", "+sum_a = sum(A)", "+", "+", "+def dfs(i, a, b, c, use):", "+ if (0 not in [a, b, c]) and use > 2:", "+ global ans", "+ abc = sorted([a, b, c])", "+ ans = min(ans, (use - 3) * 10 + sum([...
false
0.385168
0.162134
2.37562
[ "s551980491", "s627868227" ]
u606045429
p03040
python
s132247186
s886955340
587
403
43,748
43,632
Accepted
Accepted
31.35
from heapq import heappush, heappop def main(): INF = 10 ** 18 sum_B = 0 L, R = [INF], [INF] sum_L = sum_R = 0 L_size = R_size = 0 A = list(map(int, open(0).read().split())) Q = next(A) for _ in range(Q): q = next(A) if q == 1: a, b = next(...
from heapq import heappush, heappushpop def main(): INF = 10 ** 18 sum_B = 0 L, R = [INF], [INF] sum_L = sum_R = 0 A = list(map(int, open(0).read().split())) Q = next(A) for _ in range(Q): q = next(A) if q == 1: a, b = next(A), next(A) ...
52
50
1,114
1,256
from heapq import heappush, heappop def main(): INF = 10**18 sum_B = 0 L, R = [INF], [INF] sum_L = sum_R = 0 L_size = R_size = 0 A = list(map(int, open(0).read().split())) Q = next(A) for _ in range(Q): q = next(A) if q == 1: a, b = next(A), next(A) ...
from heapq import heappush, heappushpop def main(): INF = 10**18 sum_B = 0 L, R = [INF], [INF] sum_L = sum_R = 0 A = list(map(int, open(0).read().split())) Q = next(A) for _ in range(Q): q = next(A) if q == 1: a, b = next(A), next(A) sum_B += b ...
false
3.846154
[ "-from heapq import heappush, heappop", "+from heapq import heappush, heappushpop", "- L_size = R_size = 0", "- max_L = -heappop(L)", "- min_R = heappop(R)", "- sum_L -= max_L", "- sum_R -= min_R", "- l, m, r = sorted((max_L, a, min_R))", "- ...
false
0.041075
0.040931
1.0035
[ "s132247186", "s886955340" ]
u780475861
p03475
python
s001664079
s585404104
102
73
3,688
3,188
Accepted
Accepted
28.43
import sys sys.setrecursionlimit(2000) n = int(eval(input())) lst = [] for _ in range(n - 1): lst.append([int(i) for i in input().split()]) def time_cost(i, now, lst): if i == n - 1: return now if now >= lst[i][1]: if now % lst[i][2] == 0: now += lst[i][0] else: now += lst...
n = int(eval(input())) lst = [] for _ in range(n - 1): lst.append([int(i) for i in input().split()]) for i in range(n): now = 0 for c, s, f in lst[i:]: if now < s: now = c + s else: mod = now % f if mod == 0: now += c else: now += c + f - mod prin...
22
17
481
321
import sys sys.setrecursionlimit(2000) n = int(eval(input())) lst = [] for _ in range(n - 1): lst.append([int(i) for i in input().split()]) def time_cost(i, now, lst): if i == n - 1: return now if now >= lst[i][1]: if now % lst[i][2] == 0: now += lst[i][0] else: ...
n = int(eval(input())) lst = [] for _ in range(n - 1): lst.append([int(i) for i in input().split()]) for i in range(n): now = 0 for c, s, f in lst[i:]: if now < s: now = c + s else: mod = now % f if mod == 0: now += c else: ...
false
22.727273
[ "-import sys", "-", "-sys.setrecursionlimit(2000)", "-", "-", "-def time_cost(i, now, lst):", "- if i == n - 1:", "- return now", "- if now >= lst[i][1]:", "- if now % lst[i][2] == 0:", "- now += lst[i][0]", "+for i in range(n):", "+ now = 0", "+ for c,...
false
0.04304
0.082382
0.52244
[ "s001664079", "s585404104" ]
u844646164
p03503
python
s039723488
s094475683
635
95
13,268
74,284
Accepted
Accepted
85.04
import itertools import numpy as np N = int(eval(input())) F = np.array([list(map(int, input().split())) for _ in range(N)]) P = [list(map(int, input().split())) for _ in range(N)] benefit = -float("inf") for i in itertools.product((0, 1), repeat=10): if sum(i) != 0: C = np.array(list(i)) + F ...
N = int(eval(input())) F = [list(map(int, input().split())) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] ans = -float('inf') for i in range(2**10): bag = [] for j in range(10): if (i>>j)&1: bag += [j] tmp = 0 is_cnt = False for n in ra...
17
34
535
594
import itertools import numpy as np N = int(eval(input())) F = np.array([list(map(int, input().split())) for _ in range(N)]) P = [list(map(int, input().split())) for _ in range(N)] benefit = -float("inf") for i in itertools.product((0, 1), repeat=10): if sum(i) != 0: C = np.array(list(i)) + F pre_b...
N = int(eval(input())) F = [list(map(int, input().split())) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] ans = -float("inf") for i in range(2**10): bag = [] for j in range(10): if (i >> j) & 1: bag += [j] tmp = 0 is_cnt = False for n in range(N): ...
false
50
[ "-import itertools", "-import numpy as np", "-", "-F = np.array([list(map(int, input().split())) for _ in range(N)])", "+F = [list(map(int, input().split())) for _ in range(N)]", "-benefit = -float(\"inf\")", "-for i in itertools.product((0, 1), repeat=10):", "- if sum(i) != 0:", "- C = np...
false
0.269607
0.065574
4.111489
[ "s039723488", "s094475683" ]
u929217794
p02628
python
s169753686
s822322986
30
26
9,164
9,132
Accepted
Accepted
13.33
inp1 = eval(input()) inp2 = eval(input()) lists1 = inp1.split() lists2 = inp2.split() N = int(lists1[0]) K = int(lists1[1]) values = sorted([int(i) for i in lists2]) result = sum(values[:K]) print(result)
n, k = list(map(int, input().split())) p = list(map(int, input().split())) p.sort() ans = 0 for i in range(k): ans += p.pop(0) print(ans)
13
10
209
147
inp1 = eval(input()) inp2 = eval(input()) lists1 = inp1.split() lists2 = inp2.split() N = int(lists1[0]) K = int(lists1[1]) values = sorted([int(i) for i in lists2]) result = sum(values[:K]) print(result)
n, k = list(map(int, input().split())) p = list(map(int, input().split())) p.sort() ans = 0 for i in range(k): ans += p.pop(0) print(ans)
false
23.076923
[ "-inp1 = eval(input())", "-inp2 = eval(input())", "-lists1 = inp1.split()", "-lists2 = inp2.split()", "-N = int(lists1[0])", "-K = int(lists1[1])", "-values = sorted([int(i) for i in lists2])", "-result = sum(values[:K])", "-print(result)", "+n, k = list(map(int, input().split()))", "+p = list(m...
false
0.03183
0.033708
0.944291
[ "s169753686", "s822322986" ]
u049979154
p02642
python
s543972696
s524707792
538
464
32,236
32,248
Accepted
Accepted
13.75
n = int(eval(input())) a = list(map(int, input().split())) m = 10 ** 6 + 7 count = [0] * m for x in a: if count[x] != 0: count[x] = 2 continue for i in range(x, m, x): count[i] += 1 ans = 0 for x in a: if count[x] == 1: ans += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) m = max(a) + 1 a = sorted(a) count = [0] * m for x in a: if count[x] != 0: count[x] = 2 continue for i in range(x, m, x): count[i] += 1 ans = 0 for x in a: if count[x] == 1: ans += 1 print(a...
21
22
303
317
n = int(eval(input())) a = list(map(int, input().split())) m = 10**6 + 7 count = [0] * m for x in a: if count[x] != 0: count[x] = 2 continue for i in range(x, m, x): count[i] += 1 ans = 0 for x in a: if count[x] == 1: ans += 1 print(ans)
n = int(eval(input())) a = list(map(int, input().split())) m = max(a) + 1 a = sorted(a) count = [0] * m for x in a: if count[x] != 0: count[x] = 2 continue for i in range(x, m, x): count[i] += 1 ans = 0 for x in a: if count[x] == 1: ans += 1 print(ans)
false
4.545455
[ "-m = 10**6 + 7", "+m = max(a) + 1", "+a = sorted(a)" ]
false
0.286877
0.044333
6.470954
[ "s543972696", "s524707792" ]
u137912513
p03031
python
s178319278
s210979881
50
43
3,064
3,064
Accepted
Accepted
14
n,m = list(map(int, input().split())) l = [list(map(int, input().split())) for i in range(m)]#2次元配列 p = list(map(int, input().split())) ans = 0 for i in range(2**n):#全てのスイッチの場合に対して check = True#全点灯かどうか調べる for j in range(m):#電球ごと light = 0#スイッチオンの数 for k in range(1,len(l[j])): ...
import math n,m = list(map(int, input().split())) switch = [list(map(int,input().split())) for _ in range(m)] p = list(map(int, input().split())) count = 0 for j in range(2**n):#スイッチ flag = True for i in range(m): on = 0 for k in switch[i][1:]: if (j >> k-1) & 1: ...
16
19
514
451
n, m = list(map(int, input().split())) l = [list(map(int, input().split())) for i in range(m)] # 2次元配列 p = list(map(int, input().split())) ans = 0 for i in range(2**n): # 全てのスイッチの場合に対して check = True # 全点灯かどうか調べる for j in range(m): # 電球ごと light = 0 # スイッチオンの数 for k in range(1, len(l[j])): ...
import math n, m = list(map(int, input().split())) switch = [list(map(int, input().split())) for _ in range(m)] p = list(map(int, input().split())) count = 0 for j in range(2**n): # スイッチ flag = True for i in range(m): on = 0 for k in switch[i][1:]: if (j >> k - 1) & 1: ...
false
15.789474
[ "+import math", "+", "-l = [list(map(int, input().split())) for i in range(m)] # 2次元配列", "+switch = [list(map(int, input().split())) for _ in range(m)]", "-ans = 0", "-for i in range(2**n): # 全てのスイッチの場合に対して", "- check = True # 全点灯かどうか調べる", "- for j in range(m): # 電球ごと", "- light = 0...
false
0.044855
0.039521
1.134963
[ "s178319278", "s210979881" ]
u857428111
p03733
python
s153502029
s874175663
214
188
29,804
29,932
Accepted
Accepted
12.15
# coding: utf-8 # Your code here! # coding: utf-8 from fractions import gcd from functools import reduce import sys sys.setrecursionlimit(200000000) from inspect import currentframe # my functions here! #標準エラー出力 def printargs2err(*args): names = {id(v):k for k,v in currentframe().f_back.f_locals.ite...
# coding: utf-8 # Your code here! # coding: utf-8 from fractions import gcd from functools import reduce import sys sys.setrecursionlimit(200000000) from inspect import currentframe # my functions here! #標準エラー出力 def printargs2err(*args): names = {id(v):k for k,v in currentframe().f_back.f_locals.ite...
52
52
1,240
1,241
# coding: utf-8 # Your code here! # coding: utf-8 from fractions import gcd from functools import reduce import sys sys.setrecursionlimit(200000000) from inspect import currentframe # my functions here! # 標準エラー出力 def printargs2err(*args): names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} p...
# coding: utf-8 # Your code here! # coding: utf-8 from fractions import gcd from functools import reduce import sys sys.setrecursionlimit(200000000) from inspect import currentframe # my functions here! # 標準エラー出力 def printargs2err(*args): names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} p...
false
0
[ "-timing = list(pin())", "+timing = tuple(pin())" ]
false
0.05464
0.053449
1.022284
[ "s153502029", "s874175663" ]
u201856486
p03145
python
s506826247
s759332571
28
19
3,316
3,192
Accepted
Accepted
32.14
import sys """テンプレ""" # 高速 input = sys.stdin.readline # 1行を空白でリストにする(int) def intline(): return list(map(int, input().split())) # 上のstrヴァージョン def strline(): return list(map(str, input().split())) # 1列に並んだ数 def intlines(n): return [int(eval(input()) for _ in range(n))] # 上の文字列ヴ...
import sys """テンプレ""" # 高速 input = sys.stdin.readline # 1行を空白でリストにする(int) def intline(): return list(map(int, input().split())) # 上のstrヴァージョン def strline(): return list(map(str, input().split())) # 1列に並んだ数 def intlines(n): return [int(eval(input()) for _ in range(n))] # 上の文字列ヴ...
31
108
442
2,466
import sys """テンプレ""" # 高速 input = sys.stdin.readline # 1行を空白でリストにする(int) def intline(): return list(map(int, input().split())) # 上のstrヴァージョン def strline(): return list(map(str, input().split())) # 1列に並んだ数 def intlines(n): return [int(eval(input()) for _ in range(n))] # 上の文字列ヴァージョン def lines(n): ...
import sys """テンプレ""" # 高速 input = sys.stdin.readline # 1行を空白でリストにする(int) def intline(): return list(map(int, input().split())) # 上のstrヴァージョン def strline(): return list(map(str, input().split())) # 1列に並んだ数 def intlines(n): return [int(eval(input()) for _ in range(n))] # 上の文字列ヴァージョン def lines(n): ...
false
71.296296
[ "+# Union-Find木 http://at274.hatenablog.com/entry/2018/02/02/173000", "+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:", "+ ...
false
0.040355
0.036906
1.093449
[ "s506826247", "s759332571" ]
u652057333
p02720
python
s226830419
s748456821
266
198
71,024
40,816
Accepted
Accepted
25.56
import sys sys.setrecursionlimit(20000000) k = int(eval(input())) def dfs(l, lim): if lim == 10: return l new_l = [] for num in l: last = num % 10 base = num * 10 if 1 <= last <= 8: for i in [last-1, last, last+1]: if base + i <= 3234...
from collections import deque k = int(eval(input())) que = deque([i for i in range(1, 10)]) i = 0 while True: i += 1 num = que.popleft() if i == k: print(num) exit() if num % 10 > 0: que.append(num * 10 + ((num % 10) - 1)) que.append(num * 10 + (num % 10)) ...
29
16
771
380
import sys sys.setrecursionlimit(20000000) k = int(eval(input())) def dfs(l, lim): if lim == 10: return l new_l = [] for num in l: last = num % 10 base = num * 10 if 1 <= last <= 8: for i in [last - 1, last, last + 1]: if base + i <= 3234566667:...
from collections import deque k = int(eval(input())) que = deque([i for i in range(1, 10)]) i = 0 while True: i += 1 num = que.popleft() if i == k: print(num) exit() if num % 10 > 0: que.append(num * 10 + ((num % 10) - 1)) que.append(num * 10 + (num % 10)) if num % 10 < ...
false
44.827586
[ "-import sys", "+from collections import deque", "-sys.setrecursionlimit(20000000)", "-", "-", "-def dfs(l, lim):", "- if lim == 10:", "- return l", "- new_l = []", "- for num in l:", "- last = num % 10", "- base = num * 10", "- if 1 <= last <= 8:", "- ...
false
0.731723
0.121523
6.021245
[ "s226830419", "s748456821" ]
u226155577
p03143
python
s065153614
s676729406
1,497
926
137,516
46,740
Accepted
Accepted
38.14
import sys sys.setrecursionlimit(10**6) N, M = list(map(int, input().split())) *X, = list(map(int, input().split())) E = [] for i in range(M): a, b, y = list(map(int, input().split())) E.append((y, a-1, b-1)) E.sort() *p, = list(range(N)) Z = [0]*M A = X[:] C = [-1]*N def root(x): if x == ...
from collections import deque import operator N, M = list(map(int, input().split())) *X, = list(map(int, input().split())) E = [] for i in range(M): a, b, y = list(map(int, input().split())) E.append((y, a-1, b-1)) E.sort() *Y, = list(map(operator.itemgetter(0), E)) *p, = list(range(N)) def root(...
74
61
1,488
1,208
import sys sys.setrecursionlimit(10**6) N, M = list(map(int, input().split())) (*X,) = list(map(int, input().split())) E = [] for i in range(M): a, b, y = list(map(int, input().split())) E.append((y, a - 1, b - 1)) E.sort() (*p,) = list(range(N)) Z = [0] * M A = X[:] C = [-1] * N def root(x): if x == p[x...
from collections import deque import operator N, M = list(map(int, input().split())) (*X,) = list(map(int, input().split())) E = [] for i in range(M): a, b, y = list(map(int, input().split())) E.append((y, a - 1, b - 1)) E.sort() (*Y,) = list(map(operator.itemgetter(0), E)) (*p,) = list(range(N)) def root(x)...
false
17.567568
[ "-import sys", "+from collections import deque", "+import operator", "-sys.setrecursionlimit(10**6)", "+(*Y,) = list(map(operator.itemgetter(0), E))", "-Z = [0] * M", "-A = X[:]", "-C = [-1] * N", "+", "+", "+A = X[:]", "-G = [None for i in range(M)]", "+G = [[] for i in range(M)]", "+B = ...
false
0.045592
0.045867
0.994018
[ "s065153614", "s676729406" ]
u423665486
p03633
python
s776064443
s945046919
178
17
38,256
3,060
Accepted
Accepted
90.45
def gcd(a, b): """Compute the greatest common divisor of a and b""" while b > 0: a, b = b, a % b return a def lcm(a, b): """Compute the lowest common multiple of a and b""" return a * b // gcd(a, b) def resolve(): n = int(eval(input())) t = [int(eval(input())) for _ in range(n)] ans = t[0] fo...
def resolve(): n = int(eval(input())) ans = int(eval(input())) for i in range(n-1): v = int(eval(input())) a = ans b = v r = a%b while r: a = b b = r r = a % b ans = ans * v // b print(ans) resolve()
18
15
366
220
def gcd(a, b): """Compute the greatest common divisor of a and b""" while b > 0: a, b = b, a % b return a def lcm(a, b): """Compute the lowest common multiple of a and b""" return a * b // gcd(a, b) def resolve(): n = int(eval(input())) t = [int(eval(input())) for _ in range(n)] ...
def resolve(): n = int(eval(input())) ans = int(eval(input())) for i in range(n - 1): v = int(eval(input())) a = ans b = v r = a % b while r: a = b b = r r = a % b ans = ans * v // b print(ans) resolve()
false
16.666667
[ "-def gcd(a, b):", "- \"\"\"Compute the greatest common divisor of a and b\"\"\"", "- while b > 0:", "- a, b = b, a % b", "- return a", "-", "-", "-def lcm(a, b):", "- \"\"\"Compute the lowest common multiple of a and b\"\"\"", "- return a * b // gcd(a, b)", "-", "-", "...
false
0.060929
0.042488
1.434034
[ "s776064443", "s945046919" ]
u021548497
p02862
python
s186304612
s060136465
899
702
45,580
44,148
Accepted
Accepted
21.91
inf = 10**9+7 import sys a = 0 def nCr(n, r): r = min(r, n - r) if r == 0: return 1; if r == 1: return n; numerator = [n - r + i + 1 for i in range(r)] denominator = [i + 1 for i in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: ...
import sys x, y = list(map(int, input().split())) inf = 10**9+7 if (x+y)%3 != 0: print((0)) sys.exit() a = (2*x-y)//3 b = (2*y-x)//3 if a<0 or b<0: print((0)) sys.exit() def nCr(n, r): r = min(r, n - r) if r == 0: return 1; if r == 1: return int(n%inf); num...
50
37
1,071
818
inf = 10**9 + 7 import sys a = 0 def nCr(n, r): r = min(r, n - r) if r == 0: return 1 if r == 1: return n numerator = [n - r + i + 1 for i in range(r)] denominator = [i + 1 for i in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: ...
import sys x, y = list(map(int, input().split())) inf = 10**9 + 7 if (x + y) % 3 != 0: print((0)) sys.exit() a = (2 * x - y) // 3 b = (2 * y - x) // 3 if a < 0 or b < 0: print((0)) sys.exit() def nCr(n, r): r = min(r, n - r) if r == 0: return 1 if r == 1: return int(n % in...
false
26
[ "-inf = 10**9 + 7", "-a = 0", "+x, y = list(map(int, input().split()))", "+inf = 10**9 + 7", "+if (x + y) % 3 != 0:", "+ print((0))", "+ sys.exit()", "+a = (2 * x - y) // 3", "+b = (2 * y - x) // 3", "+if a < 0 or b < 0:", "+ print((0))", "+ sys.exit()", "- return n", "+...
false
0.212653
0.172355
1.233812
[ "s186304612", "s060136465" ]
u237958405
p02773
python
s785216727
s934699128
770
658
45,788
32,096
Accepted
Accepted
14.55
n = int(eval(input())) mymap = {} for x in range(n): inp = eval(input()) if inp in mymap: mymap[inp] += 1 else: mymap[inp] = 0 sorted_map = sorted(list(mymap.items()), key=lambda kv: kv[1], reverse = True ) maxi = sorted_map[0][1] # print(maxi) answer = [] for x in sorted_map: if x[1] == ma...
n = int(eval(input())) mymap = {} maxi = 1 for x in range(n): inp = eval(input()) if inp in mymap: mymap[inp] += 1 if mymap[inp] > maxi: maxi = mymap[inp] else: mymap[inp] = 1 answer = [] for x in mymap: if mymap[x] == maxi: answer.append(x) answer.sort() for x in answer: print(...
26
22
393
310
n = int(eval(input())) mymap = {} for x in range(n): inp = eval(input()) if inp in mymap: mymap[inp] += 1 else: mymap[inp] = 0 sorted_map = sorted(list(mymap.items()), key=lambda kv: kv[1], reverse=True) maxi = sorted_map[0][1] # print(maxi) answer = [] for x in sorted_map: if x[1] == ma...
n = int(eval(input())) mymap = {} maxi = 1 for x in range(n): inp = eval(input()) if inp in mymap: mymap[inp] += 1 if mymap[inp] > maxi: maxi = mymap[inp] else: mymap[inp] = 1 answer = [] for x in mymap: if mymap[x] == maxi: answer.append(x) answer.sort() for ...
false
15.384615
[ "+maxi = 1", "+ if mymap[inp] > maxi:", "+ maxi = mymap[inp]", "- mymap[inp] = 0", "-sorted_map = sorted(list(mymap.items()), key=lambda kv: kv[1], reverse=True)", "-maxi = sorted_map[0][1]", "-# print(maxi)", "+ mymap[inp] = 1", "-for x in sorted_map:", "- if x[...
false
0.039162
0.039229
0.998312
[ "s785216727", "s934699128" ]
u667806071
p00761
python
s723292190
s716905260
50
30
7,680
5,596
Accepted
Accepted
40
while True: n, d = list(map(int, input().split())) if n == 0 and d == 0: break a = [n] cnt = 0 while True: t = list(map(int, list(("{:0%d}"%d).format(n)))) n = int("".join(map(str, sorted(t, reverse=True)))) - int("".join(map(str, sorted(t)))) if n in a: ...
def solve(n, l): results = [n] for i in range(20): s = list(("%0" + str(l) + "d") % n) s.sort() n = int("".join(s[::-1])) - int("".join(s)) if n in results: break results.append(n) j = results.index(n) print((j, n, i - j + 1)) while True: ...
15
18
410
411
while True: n, d = list(map(int, input().split())) if n == 0 and d == 0: break a = [n] cnt = 0 while True: t = list(map(int, list(("{:0%d}" % d).format(n)))) n = int("".join(map(str, sorted(t, reverse=True)))) - int( "".join(map(str, sorted(t))) ) ...
def solve(n, l): results = [n] for i in range(20): s = list(("%0" + str(l) + "d") % n) s.sort() n = int("".join(s[::-1])) - int("".join(s)) if n in results: break results.append(n) j = results.index(n) print((j, n, i - j + 1)) while True: n, l = ...
false
16.666667
[ "+def solve(n, l):", "+ results = [n]", "+ for i in range(20):", "+ s = list((\"%0\" + str(l) + \"d\") % n)", "+ s.sort()", "+ n = int(\"\".join(s[::-1])) - int(\"\".join(s))", "+ if n in results:", "+ break", "+ results.append(n)", "+ j = res...
false
0.046591
0.046395
1.004222
[ "s723292190", "s716905260" ]
u562935282
p03157
python
s269700117
s053143548
1,492
478
12,728
72,696
Accepted
Accepted
67.96
from collections import Counter class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] def find(self, x): if self.v[x] < 0: # (負)は根 return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self,...
from collections import Counter class UnionFind: def __init__(self, n): self.v = [-1] * n def find(self, x): if self.v[x] < 0: return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self, x, y): x = se...
93
96
2,261
2,318
from collections import Counter class UnionFind: def __init__(self, n): self.v = [-1 for _ in range(n)] def find(self, x): if self.v[x] < 0: # (負)は根 return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self, x, y): ...
from collections import Counter class UnionFind: def __init__(self, n): self.v = [-1] * n def find(self, x): if self.v[x] < 0: return x else: self.v[x] = self.find(self.v[x]) return self.v[x] def unite(self, x, y): x = self.find(x) ...
false
3.125
[ "- self.v = [-1 for _ in range(n)]", "+ self.v = [-1] * n", "- if self.v[x] < 0: # (負)は根", "+ if self.v[x] < 0:", "- return", "- if -self.v[x] < -self.v[y]:", "- x, y = y, x", "- self.v[x] += self.v[y]", "- self.v[y] = x", "+ ...
false
0.037613
0.041771
0.900462
[ "s269700117", "s053143548" ]
u945181840
p03682
python
s901004225
s151426315
1,404
1,201
71,516
35,556
Accepted
Accepted
14.46
import sys import numpy as np read = sys.stdin.read class UnionFind(): # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1]*(n+1) # 木をくっつける時にアンバランスにならないように調整する ...
import sys import numpy as np read = sys.stdin.read class UnionFind(): # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1]*(n+1) # 木をくっつける時にアンバランスにならないように調整する ...
83
83
2,062
2,044
import sys import numpy as np read = sys.stdin.read class UnionFind: # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1] * (n + 1) # 木をくっつける時にアンバランスにならないように調整する self.rnk...
import sys import numpy as np read = sys.stdin.read class UnionFind: # 作りたい要素数nで初期化 # 使用するインスタンス変数の初期化 def __init__(self, n): self.n = n # root[x]<0ならそのノードが根かつその値が木の要素数 # rootノードでその木の要素数を記録する self.root = [-1] * (n + 1) # 木をくっつける時にアンバランスにならないように調整する self.rnk...
false
0
[ "-town = np.arange(N)", "-arg_x = np.argsort(xy[:, 0])", "-arg_y = np.argsort(xy[:, 1])", "-edges_x = (xy[arg_x[1:], 0] - xy[arg_x[:-1], 0]).tolist()", "-town_x = town[arg_x].tolist()", "-town_x = list(zip(town_x[1:], town_x[:-1]))", "-edges_y = (xy[arg_y[1:], 1] - xy[arg_y[:-1], 1]).tolist()", "-town...
false
0.252352
0.288937
0.87338
[ "s901004225", "s151426315" ]