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
u505420467
p03061
python
s545503877
s183604231
379
232
85,228
16,120
Accepted
Accepted
38.79
from operator import itemgetter from functools import reduce import fractions as f import sys input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) rev_a = list(reversed(a)) ans = 0 accumulation_gcd = [0] * n rev_accumulation_gcd = [0] * n accumulation_gcd[0] = a[0] rev_acc...
import fractions n = int(eval(input())) a = list(map(int, input().split())) gcd_from_left = [a[0]] gcd_from_right = [a[-1]] for i in range(1, n): gcd_from_left.append(fractions.gcd(gcd_from_left[i - 1], a[i])) gcd_from_right.append(fractions.gcd(gcd_from_right[i - 1], a[n - 1 - i])) gcd_from_right...
31
22
803
590
from operator import itemgetter from functools import reduce import fractions as f import sys input = sys.stdin.readline n = int(eval(input())) a = list(map(int, input().split())) rev_a = list(reversed(a)) ans = 0 accumulation_gcd = [0] * n rev_accumulation_gcd = [0] * n accumulation_gcd[0] = a[0] rev_accumulation_gcd...
import fractions n = int(eval(input())) a = list(map(int, input().split())) gcd_from_left = [a[0]] gcd_from_right = [a[-1]] for i in range(1, n): gcd_from_left.append(fractions.gcd(gcd_from_left[i - 1], a[i])) gcd_from_right.append(fractions.gcd(gcd_from_right[i - 1], a[n - 1 - i])) gcd_from_right.reverse() an...
false
29.032258
[ "-from operator import itemgetter", "-from functools import reduce", "-import fractions as f", "-import sys", "+import fractions", "-input = sys.stdin.readline", "-rev_a = list(reversed(a))", "+gcd_from_left = [a[0]]", "+gcd_from_right = [a[-1]]", "+for i in range(1, n):", "+ gcd_from_left.ap...
false
0.044381
0.044568
0.995799
[ "s545503877", "s183604231" ]
u525065967
p02642
python
s587898839
s164794170
523
471
32,304
32,248
Accepted
Accepted
9.94
n = int(eval(input())) A = [*list(map(int, input().split()))] mx = max(A) c = [0]*(1000000+1) for a in A: for i in range(a, mx+1, a): c[i] += 1 ans = 0 for a in A: if c[a] == 1: ans += 1 print(ans)
n = int(eval(input())) A = [*list(map(int, input().split()))] mx = max(A) c = [0]*(mx+1) for a in A: for i in range(a, mx+1, a): c[i] += 1 ans = 0 for a in A: if c[a] == 1: ans += 1 print(ans)
10
10
203
198
n = int(eval(input())) A = [*list(map(int, input().split()))] mx = max(A) c = [0] * (1000000 + 1) for a in A: for i in range(a, mx + 1, a): c[i] += 1 ans = 0 for a in A: if c[a] == 1: ans += 1 print(ans)
n = int(eval(input())) A = [*list(map(int, input().split()))] mx = max(A) c = [0] * (mx + 1) for a in A: for i in range(a, mx + 1, a): c[i] += 1 ans = 0 for a in A: if c[a] == 1: ans += 1 print(ans)
false
0
[ "-c = [0] * (1000000 + 1)", "+c = [0] * (mx + 1)" ]
false
0.061697
0.073524
0.839139
[ "s587898839", "s164794170" ]
u788703383
p02971
python
s947376009
s159569554
315
266
25,156
25,036
Accepted
Accepted
15.56
n,*a = list(map(int,open(0).read().split())) b = sorted(a) max = b[-1] maxs= b[-2] for i in range(n): if a[i] == max: print(maxs) else: print(max)
def main(): n,*a = list(map(int,open(0).read().split())) b = sorted(a) max = b[-1] maxs= b[-2] for i in range(n): if a[i] == max: print(maxs) else: print(max) return() if __name__=='__main__': main()
10
16
175
279
n, *a = list(map(int, open(0).read().split())) b = sorted(a) max = b[-1] maxs = b[-2] for i in range(n): if a[i] == max: print(maxs) else: print(max)
def main(): n, *a = list(map(int, open(0).read().split())) b = sorted(a) max = b[-1] maxs = b[-2] for i in range(n): if a[i] == max: print(maxs) else: print(max) return () if __name__ == "__main__": main()
false
37.5
[ "-n, *a = list(map(int, open(0).read().split()))", "-b = sorted(a)", "-max = b[-1]", "-maxs = b[-2]", "-for i in range(n):", "- if a[i] == max:", "- print(maxs)", "- else:", "- print(max)", "+def main():", "+ n, *a = list(map(int, open(0).read().split()))", "+ b = sor...
false
0.036426
0.036366
1.001665
[ "s947376009", "s159569554" ]
u392319141
p02744
python
s592039576
s694317959
1,060
113
66,476
5,232
Accepted
Accepted
89.34
from collections import defaultdict import string import sys sys.setrecursionlimit(10 ** 7) from functools import lru_cache N = int(input()) alph = string.ascii_lowercase ans = defaultdict(int) @lru_cache(maxsize=None) def search(S, nums): if nums in ans: return if len(nums) == N: ...
from collections import defaultdict import string import sys sys.setrecursionlimit(10 ** 7) from functools import lru_cache N = int(eval(input())) alph = string.ascii_lowercase def search(S, mx): if len(S) == N: print(S) else: for s in alph[: mx + 1]: search(S + s, mx...
34
18
733
376
from collections import defaultdict import string import sys sys.setrecursionlimit(10**7) from functools import lru_cache N = int(input()) alph = string.ascii_lowercase ans = defaultdict(int) @lru_cache(maxsize=None) def search(S, nums): if nums in ans: return if len(nums) == N: ans[nums] = ...
from collections import defaultdict import string import sys sys.setrecursionlimit(10**7) from functools import lru_cache N = int(eval(input())) alph = string.ascii_lowercase def search(S, mx): if len(S) == N: print(S) else: for s in alph[: mx + 1]: search(S + s, mx) sear...
false
47.058824
[ "-N = int(input())", "+N = int(eval(input()))", "-ans = defaultdict(int)", "-@lru_cache(maxsize=None)", "-def search(S, nums):", "- if nums in ans:", "- return", "- if len(nums) == N:", "- ans[nums] = S", "- return", "- for i in range(len(nums)):", "- for s...
false
0.057135
0.053973
1.058583
[ "s592039576", "s694317959" ]
u724687935
p03003
python
s569964011
s071590838
413
330
104,540
72,668
Accepted
Accepted
20.1
MOD = 10 ** 9 + 7 N, M = list(map(int, input().split())) S = list(map(int, input().split())) T = list(map(int, input().split())) dp = [[0] * (M + 1) for _ in range(N + 1)] dp[0][0] = 1 sm = [[0] * (M + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, M + 1): if S[i - 1] =...
MOD = 10 ** 9 + 7 N, M = list(map(int, input().split())) S = list(map(int, input().split())) T = list(map(int, input().split())) sm = [[0] * (M + 1) for _ in range(N + 1)] for i in range(N + 1): sm[i][0] = 1 for j in range(M + 1): sm[0][j] = 1 for i in range(1, N + 1): for j in range(1, M + 1)...
19
17
529
479
MOD = 10**9 + 7 N, M = list(map(int, input().split())) S = list(map(int, input().split())) T = list(map(int, input().split())) dp = [[0] * (M + 1) for _ in range(N + 1)] dp[0][0] = 1 sm = [[0] * (M + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, M + 1): if S[i - 1] == T[j - 1]: ...
MOD = 10**9 + 7 N, M = list(map(int, input().split())) S = list(map(int, input().split())) T = list(map(int, input().split())) sm = [[0] * (M + 1) for _ in range(N + 1)] for i in range(N + 1): sm[i][0] = 1 for j in range(M + 1): sm[0][j] = 1 for i in range(1, N + 1): for j in range(1, M + 1): tmp = ...
false
10.526316
[ "-dp = [[0] * (M + 1) for _ in range(N + 1)]", "-dp[0][0] = 1", "+for i in range(N + 1):", "+ sm[i][0] = 1", "+for j in range(M + 1):", "+ sm[0][j] = 1", "- if S[i - 1] == T[j - 1]:", "- dp[i][j] = (sm[i - 1][j - 1] + 1) % MOD", "- else:", "- dp[i][j] = 0"...
false
0.03794
0.038
0.998428
[ "s569964011", "s071590838" ]
u992910889
p03273
python
s494213701
s575123096
159
21
14,704
4,596
Accepted
Accepted
86.79
import bisect import copy import fractions import math import numpy as np from collections import Counter, deque from itertools import accumulate, permutations, combinations, combinations_with_replacement, product def resolve(): h, w = map(int, input().split()) A = [[_ for _ in input()] for _ in ra...
def resolve(): h, w = map(int, input().split()) A = [[_ for _ in input()] for _ in range(h)] B = [i for i in A if '#' in i] C = zip(*[i for i in zip(*B) if '#' in i]) for i in C: print(*i, sep='') # print(*C,sep='') resolve()
20
12
476
275
import bisect import copy import fractions import math import numpy as np from collections import Counter, deque from itertools import ( accumulate, permutations, combinations, combinations_with_replacement, product, ) def resolve(): h, w = map(int, input().split()) A = [[_ for _ in input(...
def resolve(): h, w = map(int, input().split()) A = [[_ for _ in input()] for _ in range(h)] B = [i for i in A if "#" in i] C = zip(*[i for i in zip(*B) if "#" in i]) for i in C: print(*i, sep="") # print(*C,sep='') resolve()
false
40
[ "-import bisect", "-import copy", "-import fractions", "-import math", "-import numpy as np", "-from collections import Counter, deque", "-from itertools import (", "- accumulate,", "- permutations,", "- combinations,", "- combinations_with_replacement,", "- product,", "-)", ...
false
0.063559
0.065479
0.97067
[ "s494213701", "s575123096" ]
u459419927
p03752
python
s597953364
s915792713
339
73
3,192
3,064
Accepted
Accepted
78.47
N, K = list(map(int, input().split())) height = list(map(int, input().split())) ans = 10 ** 10 if N==K: cost=0 for i in range(1,N): if height[i-1]>=height[i]: cost+=height[i-1]-height[i]+1 height[i]+=height[i-1]-height[i]+1 print(cost) exit() for i in range(2 *...
N, K = list(map(int, input().split())) height = list(map(int, input().split())) height2=height.copy() ans = 10 ** 10 if N==K: cost=0 for i in range(1,N): tarou=max(height2[:i]) if tarou>=height2[i]: cost+=tarou-height2[i]+1 height2[i]=tarou+1 print(cost) ...
33
33
896
957
N, K = list(map(int, input().split())) height = list(map(int, input().split())) ans = 10**10 if N == K: cost = 0 for i in range(1, N): if height[i - 1] >= height[i]: cost += height[i - 1] - height[i] + 1 height[i] += height[i - 1] - height[i] + 1 print(cost) exit() for i ...
N, K = list(map(int, input().split())) height = list(map(int, input().split())) height2 = height.copy() ans = 10**10 if N == K: cost = 0 for i in range(1, N): tarou = max(height2[:i]) if tarou >= height2[i]: cost += tarou - height2[i] + 1 height2[i] = tarou + 1 print(...
false
0
[ "+height2 = height.copy()", "- if height[i - 1] >= height[i]:", "- cost += height[i - 1] - height[i] + 1", "- height[i] += height[i - 1] - height[i] + 1", "+ tarou = max(height2[:i])", "+ if tarou >= height2[i]:", "+ cost += tarou - height2[i] + 1", ...
false
0.043298
0.079022
0.547922
[ "s597953364", "s915792713" ]
u391731808
p03026
python
s835220927
s456847317
350
71
53,208
7,800
Accepted
Accepted
79.71
N = int(eval(input())) AB = [list(map(int,input().split())) for _ in [0]*(N-1)] *C, = list(map(int,input().split())) connect = [[] for _ in [0]*N] for a,b in AB: connect[a-1].append(b-1) connect[b-1].append(a-1) d = [-1]*N d[0] = 0 q = [0] while q: qq = [] for i in q: for j in con...
N = int(eval(input())) AB = [list(map(int,input().split())) for _ in [0]*(N-1)] *C, = sorted(map(int,input().split())) print((sum(C[:-1]))) E = [[] for _ in [0]*N] d = [0]*N for a,b in AB: E[a-1].append(b-1) E[b-1].append(a-1) for i in range(N): if len(E[i])>1:break q = [i] while q: i = q...
28
20
587
421
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in [0] * (N - 1)] (*C,) = list(map(int, input().split())) connect = [[] for _ in [0] * N] for a, b in AB: connect[a - 1].append(b - 1) connect[b - 1].append(a - 1) d = [-1] * N d[0] = 0 q = [0] while q: qq = [] for i in q: for j ...
N = int(eval(input())) AB = [list(map(int, input().split())) for _ in [0] * (N - 1)] (*C,) = sorted(map(int, input().split())) print((sum(C[:-1]))) E = [[] for _ in [0] * N] d = [0] * N for a, b in AB: E[a - 1].append(b - 1) E[b - 1].append(a - 1) for i in range(N): if len(E[i]) > 1: break q = [i] w...
false
28.571429
[ "-(*C,) = list(map(int, input().split()))", "-connect = [[] for _ in [0] * N]", "+(*C,) = sorted(map(int, input().split()))", "+print((sum(C[:-1])))", "+E = [[] for _ in [0] * N]", "+d = [0] * N", "- connect[a - 1].append(b - 1)", "- connect[b - 1].append(a - 1)", "-d = [-1] * N", "-d[0] = 0...
false
0.038219
0.091189
0.419115
[ "s835220927", "s456847317" ]
u445624660
p02928
python
s407816129
s592943800
810
539
3,188
9,272
Accepted
Accepted
33.46
# つよいさんすう # 最初のAを単独で考えたらいける 等差数列の和の公式はググった # ex) k = 3, a = [1, 3, 2] # 1 3 2 1 3 2 1 3 2 # 最初の1 3 2 # 3...[2,1,2,1,2]で5 # 2...[1.1]で2 # 二番目の1 3 2 # 3...[2,1,2] # 2...[1] # 三番目の1 3 2 # 3...[2]で1 # 3だけでみると初項1 末項5 公差2で n(2*a1 +(n-1)*2)/2 = 3*(2*1 + (3-1)*2)/2 = 3*6/2 = 9 # n*(a1+an)/2 = 3*(1+5)/2 = 9 # これ...
# A内で完結するものと、連結したときに変わるものがある # # 3 4 2 1 2 -> 3+3+1+0+0 = 7 # 3 4 2 1 2 | 3 4 2 1 2 -> (3*2)+(1*1+3*2)+(1*2)+0+(1*1) + 7 = 16 + 7 # 3 4 2 1 2 | 3 4 2 1 2 | 3 4 2 1 2 -> (3*3)+(2*1+3*3)+(1*3)+0+(2*1) + 16+7 = 25+16+7 # Aについて、i<jなるjでAi>Ajになるものがk個、Ai<Ajになるものがk-1個ある # k=3で考えると # 順方向: (m*3)+(m*3)+(m*1)+(0)+(0), m=1~...
54
31
1,359
874
# つよいさんすう # 最初のAを単独で考えたらいける 等差数列の和の公式はググった # ex) k = 3, a = [1, 3, 2] # 1 3 2 1 3 2 1 3 2 # 最初の1 3 2 # 3...[2,1,2,1,2]で5 # 2...[1.1]で2 # 二番目の1 3 2 # 3...[2,1,2] # 2...[1] # 三番目の1 3 2 # 3...[2]で1 # 3だけでみると初項1 末項5 公差2で n(2*a1 +(n-1)*2)/2 = 3*(2*1 + (3-1)*2)/2 = 3*6/2 = 9 # n*(a1+an)/2 = 3*(1+5)/2 = 9 # これを一般化すればいけそう # ex...
# A内で完結するものと、連結したときに変わるものがある # # 3 4 2 1 2 -> 3+3+1+0+0 = 7 # 3 4 2 1 2 | 3 4 2 1 2 -> (3*2)+(1*1+3*2)+(1*2)+0+(1*1) + 7 = 16 + 7 # 3 4 2 1 2 | 3 4 2 1 2 | 3 4 2 1 2 -> (3*3)+(2*1+3*3)+(1*3)+0+(2*1) + 16+7 = 25+16+7 # Aについて、i<jなるjでAi>Ajになるものがk個、Ai<Ajになるものがk-1個ある # k=3で考えると # 順方向: (m*3)+(m*3)+(m*1)+(0)+(0), m=1~3 = 7+1...
false
42.592593
[ "-# つよいさんすう", "-# 最初のAを単独で考えたらいける 等差数列の和の公式はググった", "-# ex) k = 3, a = [1, 3, 2]", "-# 1 3 2 1 3 2 1 3 2", "-# 最初の1 3 2", "-# 3...[2,1,2,1,2]で5", "-# 2...[1.1]で2", "-# 二番目の1 3 2", "-# 3...[2,1,2]", "-# 2...[1]", "-# 三番目の1 3 2", "-# 3...[2]で1", "-# 3だけでみると初項1 末項5 公差2で n(2*a1 +(n-1)*2)/2 = 3*(2...
false
0.038858
0.06819
0.569845
[ "s407816129", "s592943800" ]
u525065967
p02617
python
s565680096
s012172163
433
380
9,184
9,192
Accepted
Accepted
12.24
n = int(eval(input())) V = E = 0 for i in range(1, n+1): V += i * (n - i + 1) for _ in range(n-1): a, b = list(map(int, input().split())) if a > b: a, b = b, a E += a * (n - b + 1) print((V - E))
n = int(eval(input())) V = n*(n+1)*(n+2)//6; E = 0 for _ in range(n-1): a, b = list(map(int, input().split())) if a > b: a, b = b, a E += a * (n - b + 1) print((V - E))
8
7
201
173
n = int(eval(input())) V = E = 0 for i in range(1, n + 1): V += i * (n - i + 1) for _ in range(n - 1): a, b = list(map(int, input().split())) if a > b: a, b = b, a E += a * (n - b + 1) print((V - E))
n = int(eval(input())) V = n * (n + 1) * (n + 2) // 6 E = 0 for _ in range(n - 1): a, b = list(map(int, input().split())) if a > b: a, b = b, a E += a * (n - b + 1) print((V - E))
false
12.5
[ "-V = E = 0", "-for i in range(1, n + 1):", "- V += i * (n - i + 1)", "+V = n * (n + 1) * (n + 2) // 6", "+E = 0" ]
false
0.096727
0.05299
1.825385
[ "s565680096", "s012172163" ]
u995004106
p02603
python
s657326917
s407434482
80
70
64,896
64,984
Accepted
Accepted
12.5
import collections N=int(eval(input())) A=list(map(int,input().split())) i=0 A.insert(0,float("inf")) #print(A) buy=[0]*N sell=[0]*N for i in range(N-1): if (A[i]>=A[i+1])and(A[i+2]>=A[i+1]): buy[i]=1 if (A[i]<=A[i+1])and(A[i+2]<=A[i+1]): sell[i]=1 kabu=0 money=1000 #print(buy,sel...
import collections N=int(eval(input())) A=list(map(int,input().split())) i=0 A.insert(0,float("inf")) #print(A) buy=[0]*N sell=[0]*N for i in range(N-1): if (A[i]>=A[i+1])and(A[i+2]>=A[i+1]): buy[i]=1 if (A[i]<=A[i+1])and(A[i+2]<=A[i+1]): sell[i]=1 kabu=0 money=1000 #print(buy,sel...
33
35
640
644
import collections N = int(eval(input())) A = list(map(int, input().split())) i = 0 A.insert(0, float("inf")) # print(A) buy = [0] * N sell = [0] * N for i in range(N - 1): if (A[i] >= A[i + 1]) and (A[i + 2] >= A[i + 1]): buy[i] = 1 if (A[i] <= A[i + 1]) and (A[i + 2] <= A[i + 1]): sell[i] = 1...
import collections N = int(eval(input())) A = list(map(int, input().split())) i = 0 A.insert(0, float("inf")) # print(A) buy = [0] * N sell = [0] * N for i in range(N - 1): if (A[i] >= A[i + 1]) and (A[i + 2] >= A[i + 1]): buy[i] = 1 if (A[i] <= A[i + 1]) and (A[i + 2] <= A[i + 1]): sell[i] = 1...
false
5.714286
[ "+ if buy[i] == 1:", "+ kabu = kabu + money // A[i]", "+ money = money - (money // A[i]) * A[i]", "- if buy[i] == 1:", "- kabu = kabu + money // A[i]", "- money = money - (money // A[i]) * A[i]" ]
false
0.04381
0.046653
0.939065
[ "s657326917", "s407434482" ]
u040298438
p03943
python
s455321840
s317517929
31
24
9,120
9,052
Accepted
Accepted
22.58
a = list(map(int, input().split())) print(("Yes" if sum(a) == max(a) * 2 else "No"))
a, b, c = sorted(map(int, input().split())) print((("No", "Yes")[a + b == c]))
2
2
84
77
a = list(map(int, input().split())) print(("Yes" if sum(a) == max(a) * 2 else "No"))
a, b, c = sorted(map(int, input().split())) print((("No", "Yes")[a + b == c]))
false
0
[ "-a = list(map(int, input().split()))", "-print((\"Yes\" if sum(a) == max(a) * 2 else \"No\"))", "+a, b, c = sorted(map(int, input().split()))", "+print(((\"No\", \"Yes\")[a + b == c]))" ]
false
0.04812
0.048484
0.992484
[ "s455321840", "s317517929" ]
u022407960
p02378
python
s071216115
s077655269
70
50
8,428
9,260
Accepted
Accepted
28.57
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 3 4 6 0 0 0 2 0 3 1 1 2 1 2 3 output: 3 """ import sys def generate_adj_table(_edges): for edge in _edges: vx, vy = list(map(int, edge)) init_adj_table[vx].append(vy) return init_adj_table def graph_dfs(...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 3 4 6 0 0 0 2 0 3 1 1 2 1 2 3 output: 3 """ import sys def generate_adj_table(_edges): for edge in _edges: vx, vy = list(map(int, edge)) init_adj_table[vx].add(vy) return init_adj_table def graph_dfs(cur...
57
60
1,153
1,378
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 3 4 6 0 0 0 2 0 3 1 1 2 1 2 3 output: 3 """ import sys def generate_adj_table(_edges): for edge in _edges: vx, vy = list(map(int, edge)) init_adj_table[vx].append(vy) return init_adj_table def graph_dfs(current, matching, visited): ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 3 4 6 0 0 0 2 0 3 1 1 2 1 2 3 output: 3 """ import sys def generate_adj_table(_edges): for edge in _edges: vx, vy = list(map(int, edge)) init_adj_table[vx].add(vy) return init_adj_table def graph_dfs(current, matching, visited): fo...
false
5
[ "- init_adj_table[vx].append(vy)", "+ init_adj_table[vx].add(vy)", "+ # matching[adj] = -1: target in y not assigned to any of x", "+ # matching[adj] -> an assigned source in x", "+ # graph_dfs(matching[adj], matching, visited) = True indicates that source has ...
false
0.048785
0.076718
0.635896
[ "s071216115", "s077655269" ]
u279266699
p02614
python
s849516757
s009536294
237
60
27,024
9,116
Accepted
Accepted
74.68
import copy import numpy as np def count_black(c): count = 0 for row in c: count += row.count('#') return count h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] ans = 0 for h_p in range(2 ** h): for w_p in range(2 ** w): c_cp = n...
h, w, k = list(map(int, input().split())) c = [eval(input()) for _ in range(h)] ans = 0 for h_p in range(2 ** h): for w_p in range(2 ** w): cnt = 0 for i in range(h): for j in range(w): if (h_p >> i) & 1 and (w_p >> j) & 1 and c[i][j] == '#': ...
29
13
605
372
import copy import numpy as np def count_black(c): count = 0 for row in c: count += row.count("#") return count h, w, k = list(map(int, input().split())) c = [list(eval(input())) for _ in range(h)] ans = 0 for h_p in range(2**h): for w_p in range(2**w): c_cp = np.array(copy.deepcopy(...
h, w, k = list(map(int, input().split())) c = [eval(input()) for _ in range(h)] ans = 0 for h_p in range(2**h): for w_p in range(2**w): cnt = 0 for i in range(h): for j in range(w): if (h_p >> i) & 1 and (w_p >> j) & 1 and c[i][j] == "#": cnt += 1 ...
false
55.172414
[ "-import copy", "-import numpy as np", "-", "-", "-def count_black(c):", "- count = 0", "- for row in c:", "- count += row.count(\"#\")", "- return count", "-", "-", "-c = [list(eval(input())) for _ in range(h)]", "+c = [eval(input()) for _ in range(h)]", "- c_cp = n...
false
0.283339
0.045382
6.243409
[ "s849516757", "s009536294" ]
u750990077
p02691
python
s602340774
s279831533
904
171
139,580
149,920
Accepted
Accepted
81.08
from collections import Counter def main(): n = int(eval(input())) a = list(map(int, input().split())) bigger = [None]*n smaller = [None]*n for i, ai in enumerate(a): bigger[i] = i - ai smaller[i] = i + ai b = sorted(Counter(bigger).items()) s = sorted(Counter(sma...
from collections import defaultdict def main(): n = int(eval(input())) a = list(map(int, input().split())) d = defaultdict(lambda : 0) ans = 0 for i, ai in enumerate(a): sa = i - ai ans += d[sa] wa = i + ai d[wa] += 1 print(ans) if __name...
34
17
759
343
from collections import Counter def main(): n = int(eval(input())) a = list(map(int, input().split())) bigger = [None] * n smaller = [None] * n for i, ai in enumerate(a): bigger[i] = i - ai smaller[i] = i + ai b = sorted(Counter(bigger).items()) s = sorted(Counter(smaller)....
from collections import defaultdict def main(): n = int(eval(input())) a = list(map(int, input().split())) d = defaultdict(lambda: 0) ans = 0 for i, ai in enumerate(a): sa = i - ai ans += d[sa] wa = i + ai d[wa] += 1 print(ans) if __name__ == "__main__": m...
false
50
[ "-from collections import Counter", "+from collections import defaultdict", "- bigger = [None] * n", "- smaller = [None] * n", "+ d = defaultdict(lambda: 0)", "+ ans = 0", "- bigger[i] = i - ai", "- smaller[i] = i + ai", "- b = sorted(Counter(bigger).items())", "- s...
false
0.04267
0.03637
1.173231
[ "s602340774", "s279831533" ]
u150984829
p00086
python
s141884066
s296401853
30
20
5,616
5,608
Accepted
Accepted
33.33
import sys v=[0]*101 for e in sys.stdin: a,b=list(map(int,e.split())) v[a]+=1;v[b]+=1 if a==0: print((['NG','OK'][1&v[1]and 1&v[2]and sum(x&1 for x in v)==2])) v=[0]*101
import sys v=[0]*101 for e in sys.stdin: a,b=list(map(int,e.split())) v[a]+=1;v[b]+=1 if a==0: print((['NG','OK'][(v[1]&1)*(v[2]&1)*sum(x&1 for x in v)==2])) v=[0]*101
8
8
176
174
import sys v = [0] * 101 for e in sys.stdin: a, b = list(map(int, e.split())) v[a] += 1 v[b] += 1 if a == 0: print((["NG", "OK"][1 & v[1] and 1 & v[2] and sum(x & 1 for x in v) == 2])) v = [0] * 101
import sys v = [0] * 101 for e in sys.stdin: a, b = list(map(int, e.split())) v[a] += 1 v[b] += 1 if a == 0: print((["NG", "OK"][(v[1] & 1) * (v[2] & 1) * sum(x & 1 for x in v) == 2])) v = [0] * 101
false
0
[ "- print(([\"NG\", \"OK\"][1 & v[1] and 1 & v[2] and sum(x & 1 for x in v) == 2]))", "+ print(([\"NG\", \"OK\"][(v[1] & 1) * (v[2] & 1) * sum(x & 1 for x in v) == 2]))" ]
false
0.045905
0.07162
0.640952
[ "s141884066", "s296401853" ]
u434428594
p00494
python
s437673115
s606756278
1,280
430
5,320
49,564
Accepted
Accepted
66.41
s = input() p = 0 ans = 0 while p < len(s): joi = 'JOI' cnt = [0] * 3 for i in range(3): while p < len(s) and s[p] == joi[i]: cnt[i] += 1 p += 1 if cnt[0] >= cnt[1] and cnt[1] <= cnt[2]: ans = max(ans, cnt[1]) print(ans)
import re s = input() ans = 0 for joi_str in re.findall('(J*)(O*)(I*)', s): j = len(joi_str[0]) o = len(joi_str[1]) i = len(joi_str[2]) if j >= o and o <= i: ans = max(ans, o) print(ans)
15
12
296
226
s = input() p = 0 ans = 0 while p < len(s): joi = "JOI" cnt = [0] * 3 for i in range(3): while p < len(s) and s[p] == joi[i]: cnt[i] += 1 p += 1 if cnt[0] >= cnt[1] and cnt[1] <= cnt[2]: ans = max(ans, cnt[1]) print(ans)
import re s = input() ans = 0 for joi_str in re.findall("(J*)(O*)(I*)", s): j = len(joi_str[0]) o = len(joi_str[1]) i = len(joi_str[2]) if j >= o and o <= i: ans = max(ans, o) print(ans)
false
20
[ "+import re", "+", "-p = 0", "-while p < len(s):", "- joi = \"JOI\"", "- cnt = [0] * 3", "- for i in range(3):", "- while p < len(s) and s[p] == joi[i]:", "- cnt[i] += 1", "- p += 1", "- if cnt[0] >= cnt[1] and cnt[1] <= cnt[2]:", "- ans = max(an...
false
0.043382
0.135745
0.319585
[ "s437673115", "s606756278" ]
u714225686
p03013
python
s347633613
s443937083
384
91
461,736
8,744
Accepted
Accepted
76.3
# n = int(sys.stdin.readline()) # a, b = map(int, sys.stdin.readline().split()) # c = list(map(int, sys.stdin.readline().split())) # s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)] # 二次元配列入力 二次元マップみたいな入力のとき # a = 100 # b = 0.987654321 # print('{0:06d}-{1:6f}'.format(a,b)) # 0埋め, 小数点出力桁指定時のとき...
# n = int(sys.stdin.readline()) # a, b = map(int, sys.stdin.readline().split()) # c = list(map(int, sys.stdin.readline().split())) # s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)] # 二次元配列入力 二次元マップみたいな入力のとき # a = 100 # b = 0.987654321 # print('{0:06d}-{1:6f}'.format(a,b)) # 0埋め, 小数点出力桁指定時のとき...
30
30
802
804
# n = int(sys.stdin.readline()) # a, b = map(int, sys.stdin.readline().split()) # c = list(map(int, sys.stdin.readline().split())) # s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)] # 二次元配列入力 二次元マップみたいな入力のとき # a = 100 # b = 0.987654321 # print('{0:06d}-{1:6f}'.format(a,b)) # 0埋め, 小数点出力桁指定時のときの出力 # 00...
# n = int(sys.stdin.readline()) # a, b = map(int, sys.stdin.readline().split()) # c = list(map(int, sys.stdin.readline().split())) # s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)] # 二次元配列入力 二次元マップみたいな入力のとき # a = 100 # b = 0.987654321 # print('{0:06d}-{1:6f}'.format(a,b)) # 0埋め, 小数点出力桁指定時のときの出力 # 00...
false
0
[ "- dp[i] = dp[i + 1] + dp[i + 2]", "- print((dp[0] % mod))", "+ dp[i] = (dp[i + 1] + dp[i + 2]) % mod", "+ print((dp[0]))" ]
false
0.043984
0.045723
0.961983
[ "s347633613", "s443937083" ]
u505830998
p02642
python
s160587586
s353565744
517
227
165,396
122,084
Accepted
Accepted
56.09
import sys import collections input_methods=['clipboard','file','key'] using_method=0 input_method=input_methods[using_method] tin=lambda : list(map(int, input().split())) lin=lambda : list(tin()) mod=1000000007 #+++++ def main(): n = int(eval(input())) #b , c = tin() al = lin() al.sort() ...
import sys input_methods=['clipboard','file','key'] using_method=0 input_method=input_methods[using_method] tin=lambda : list(map(int, input().split())) lin=lambda : list(tin()) mod=1000000007 #+++++ def main(): n = int(eval(input())) #b , c = tin() #s = input() al=lin() vm=10**6+1 rr = [0]*...
69
59
1,235
1,016
import sys import collections input_methods = ["clipboard", "file", "key"] using_method = 0 input_method = input_methods[using_method] tin = lambda: list(map(int, input().split())) lin = lambda: list(tin()) mod = 1000000007 # +++++ def main(): n = int(eval(input())) # b , c = tin() al = lin() al.sort()...
import sys input_methods = ["clipboard", "file", "key"] using_method = 0 input_method = input_methods[using_method] tin = lambda: list(map(int, input().split())) lin = lambda: list(tin()) mod = 1000000007 # +++++ def main(): n = int(eval(input())) # b , c = tin() # s = input() al = lin() vm = 10**6...
false
14.492754
[ "-import collections", "+ # s = input()", "- al.sort()", "- unique_al = list(set(al))", "- unique_al.sort()", "- al_counter = collections.Counter(al)", "- ok = [v for v in list(al_counter.keys()) if al_counter[v] == 1]", "- d = {v: i for i, v in enumerate(ok)}", "- max_v = 10...
false
0.085292
0.109391
0.779698
[ "s160587586", "s353565744" ]
u373499377
p03853
python
s150606828
s847333842
22
17
3,316
3,060
Accepted
Accepted
22.73
def main(): h, w = list(map(int, input().split())) px = [[0 for j in range(w)] for i in range(h)] px_stretch = [[0 for j in range(w)] for i in range(2 * h)] for row in range(h): px[row] = list(eval(input())) for row in range(2 * h): px_stretch[row] = [px[row // 2][i] for...
def main(): h, w = map(int, input().split()) px = [input() for i in range(h)] for row in range(h): print(px[row], px[row], sep='\n') # px = [[0 for j in range(w)] for i in range(h)] # px_stretch = [[0 for j in range(w)] for i in range(2 * h)] # # for row in range(h): ...
17
21
411
546
def main(): h, w = list(map(int, input().split())) px = [[0 for j in range(w)] for i in range(h)] px_stretch = [[0 for j in range(w)] for i in range(2 * h)] for row in range(h): px[row] = list(eval(input())) for row in range(2 * h): px_stretch[row] = [px[row // 2][i] for i in range(w...
def main(): h, w = map(int, input().split()) px = [input() for i in range(h)] for row in range(h): print(px[row], px[row], sep="\n") # px = [[0 for j in range(w)] for i in range(h)] # px_stretch = [[0 for j in range(w)] for i in range(2 * h)] # # for row in range(h): # px[row...
false
19.047619
[ "- h, w = list(map(int, input().split()))", "- px = [[0 for j in range(w)] for i in range(h)]", "- px_stretch = [[0 for j in range(w)] for i in range(2 * h)]", "+ h, w = map(int, input().split())", "+ px = [input() for i in range(h)]", "- px[row] = list(eval(input()))", "- for r...
false
0.049375
0.0467
1.057268
[ "s150606828", "s847333842" ]
u371350984
p03494
python
s825859201
s365134552
31
28
9,128
9,084
Accepted
Accepted
9.68
n = int(eval(input())) a = list(map(int, input().split())) i = 0 per = True while per == True: for index in range(n): num = a[index] ans = divmod(num, 2) if num == 0 or ans[1] != 0: per = False break a[index] = ans[0] if per == True: ...
import math n = eval(input()) a = list(map(int, input().split())) ans = float("inf") for i in a: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print((round(ans)))
16
7
331
170
n = int(eval(input())) a = list(map(int, input().split())) i = 0 per = True while per == True: for index in range(n): num = a[index] ans = divmod(num, 2) if num == 0 or ans[1] != 0: per = False break a[index] = ans[0] if per == True: i += 1 print(i...
import math n = eval(input()) a = list(map(int, input().split())) ans = float("inf") for i in a: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print((round(ans)))
false
56.25
[ "-n = int(eval(input()))", "+import math", "+", "+n = eval(input())", "-i = 0", "-per = True", "-while per == True:", "- for index in range(n):", "- num = a[index]", "- ans = divmod(num, 2)", "- if num == 0 or ans[1] != 0:", "- per = False", "- b...
false
0.038217
0.037546
1.017875
[ "s825859201", "s365134552" ]
u968166680
p02960
python
s000689872
s182208561
271
248
80,368
73,756
Accepted
Accepted
8.49
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): S = readline().strip() N = len(S) power = [0] * N power[0] = 1 for i in range(N - 1): power[i + 1] = 10 ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): S = readline().strip() S = S[::-1] dp = [0] * 13 dp[0] = 1 p = 1 for i, c in enumerate(S): dp, ...
45
35
897
735
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): S = readline().strip() N = len(S) power = [0] * N power[0] = 1 for i in range(N - 1): power[i + 1] = 10 * power[i] % 13 ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): S = readline().strip() S = S[::-1] dp = [0] * 13 dp[0] = 1 p = 1 for i, c in enumerate(S): dp, dp_prev = [0] * 13, dp ...
false
22.222222
[ "- N = len(S)", "- power = [0] * N", "- power[0] = 1", "- for i in range(N - 1):", "- power[i + 1] = 10 * power[i] % 13", "- Q = []", "- const = 0", "+ dp = [0] * 13", "+ dp[0] = 1", "+ p = 1", "- if c == \"?\":", "- Q.append(i)", "- ...
false
0.072046
0.080143
0.898965
[ "s000689872", "s182208561" ]
u222668979
p02579
python
s324525120
s522865461
1,493
1,377
99,728
99,736
Accepted
Accepted
7.77
from collections import deque from itertools import product def bfs(x, y): dist = [[10 ** 9] * w for _ in range(h)] dist[y][x] = 0 que = deque([(x,y)]) while len(que) > 0: x, y = que.popleft() near_a = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)] num = product(...
from collections import deque from itertools import product def bfs(x, y): dist = [[10 ** 9] * w for _ in range(h)] dist[y][x] = 0 for i, si in enumerate(s): for j, sij in enumerate(si): if sij == '#': dist[i][j] = -1 que = deque([(x, y)]) while le...
34
38
1,069
1,201
from collections import deque from itertools import product def bfs(x, y): dist = [[10**9] * w for _ in range(h)] dist[y][x] = 0 que = deque([(x, y)]) while len(que) > 0: x, y = que.popleft() near_a = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)] num = product([-2, -1, 0, 1,...
from collections import deque from itertools import product def bfs(x, y): dist = [[10**9] * w for _ in range(h)] dist[y][x] = 0 for i, si in enumerate(s): for j, sij in enumerate(si): if sij == "#": dist[i][j] = -1 que = deque([(x, y)]) while len(que) > 0: ...
false
10.526316
[ "+ for i, si in enumerate(s):", "+ for j, sij in enumerate(si):", "+ if sij == \"#\":", "+ dist[i][j] = -1" ]
false
0.043111
0.038414
1.122279
[ "s324525120", "s522865461" ]
u633068244
p00116
python
s092585220
s063283905
2,430
2,050
10,316
10,308
Accepted
Accepted
15.64
while 1: H,W = list(map(int,input().split())) if H == 0: break M = [input() for i in range(H)] A = [[0]*W for i in range(H)] B = [[0]*W for i in range(H)] ans = 0 for h in range(H): L = 0 for w in range(W): if M[h][w] == ".": L += 1 else: L = 0 A[h][w] = L B[h][w] = (B[h-1]...
while 1: H,W = list(map(int,input().split())) if H == 0: break M = [input() for i in range(H)] A = [[0]*W for i in range(H)] B = [[0]*W for i in range(H)] ans = 0 for h in range(H): L = 0 for w in range(W): if M[h][w] == ".": L += 1 else: L = 0 A[h][w] = L B[h][w] = (B[h-1]...
24
24
577
538
while 1: H, W = list(map(int, input().split())) if H == 0: break M = [input() for i in range(H)] A = [[0] * W for i in range(H)] B = [[0] * W for i in range(H)] ans = 0 for h in range(H): L = 0 for w in range(W): if M[h][w] == ".": L += 1 ...
while 1: H, W = list(map(int, input().split())) if H == 0: break M = [input() for i in range(H)] A = [[0] * W for i in range(H)] B = [[0] * W for i in range(H)] ans = 0 for h in range(H): L = 0 for w in range(W): if M[h][w] == ".": L += 1 ...
false
0
[ "- a = min([A[h - i][w] for i in range(ans / L + 1)])", "+ a = L" ]
false
0.035684
0.054863
0.65042
[ "s092585220", "s063283905" ]
u465699806
p03111
python
s063846553
s703036074
485
60
3,828
3,188
Accepted
Accepted
87.63
import random as rng import itertools as it import collections as col import heapq as hq import sys import copy as cp sys.setrecursionlimit(10**9) def dump_impl(*objects): print(*objects, file=sys.stderr) def dump_dummy(*objects): pass dump = dump_impl if "DEBUG" in sys.argv else dump_dum...
n, a, b, c = [int(it) for it in input().split()] ls = [int(eval(input())) for it in range(n)] def dfs(cur, tmpA, tmpB, tmpC): if cur == n: return abs(a - tmpA) + abs(b - tmpB) + abs(c - tmpC) if tmpA > 0 and tmpB > 0 and tmpC else 10**20 return min( dfs(cur + 1, tmpA + ls[cur], tmpB, tmpC)...
32
13
811
569
import random as rng import itertools as it import collections as col import heapq as hq import sys import copy as cp sys.setrecursionlimit(10**9) def dump_impl(*objects): print(*objects, file=sys.stderr) def dump_dummy(*objects): pass dump = dump_impl if "DEBUG" in sys.argv else dump_dummy N, A, B, C = ...
n, a, b, c = [int(it) for it in input().split()] ls = [int(eval(input())) for it in range(n)] def dfs(cur, tmpA, tmpB, tmpC): if cur == n: return ( abs(a - tmpA) + abs(b - tmpB) + abs(c - tmpC) if tmpA > 0 and tmpB > 0 and tmpC else 10**20 ) return min( ...
false
59.375
[ "-import random as rng", "-import itertools as it", "-import collections as col", "-import heapq as hq", "-import sys", "-import copy as cp", "-", "-sys.setrecursionlimit(10**9)", "+n, a, b, c = [int(it) for it in input().split()]", "+ls = [int(eval(input())) for it in range(n)]", "-def dump_imp...
false
0.367132
0.134578
2.728019
[ "s063846553", "s703036074" ]
u887207211
p03307
python
s184852002
s178773130
19
17
3,064
2,940
Accepted
Accepted
10.53
N = int(eval(input())) def gcd(m, n): while n: m, n = n, m%n return m def lcm(m, n): return int((m * n) / gcd(m, n)) print((lcm(N,2)))
N = int(eval(input())) def gcd(m, n): while n: m, n = n, m%n return m def lcm(m, n): print((m * n // gcd(m, n))) lcm(N,2)
11
11
149
136
N = int(eval(input())) def gcd(m, n): while n: m, n = n, m % n return m def lcm(m, n): return int((m * n) / gcd(m, n)) print((lcm(N, 2)))
N = int(eval(input())) def gcd(m, n): while n: m, n = n, m % n return m def lcm(m, n): print((m * n // gcd(m, n))) lcm(N, 2)
false
0
[ "- return int((m * n) / gcd(m, n))", "+ print((m * n // gcd(m, n)))", "-print((lcm(N, 2)))", "+lcm(N, 2)" ]
false
0.051334
0.050814
1.010238
[ "s184852002", "s178773130" ]
u614181788
p03329
python
s287014635
s635911655
1,218
1,003
9,616
9,592
Accepted
Accepted
17.65
n = int(eval(input())) dp = [float("Inf")]*(n+1) dp[0] = 0 for i in range(n): for j in range(1,6): if i + j > n: break dp[i+j] = min(dp[i+j], dp[i] + j) for j in range(1,n//6+1): if i + 6**j > n: break dp[i+6**j] = min(dp[i+6**j], dp[i] + 1) ...
n = int(eval(input())) dp = [float("Inf")]*(n+1) for i in range(min(6, n+1)): dp[i] = i for i in range(n): for j in range(1,n//6+1): if i + 6**j > n: break dp[i+6**j] = min(dp[i+6**j], dp[i] + 1) for j in range(1,n//9+1): if i + 9**j > n: break ...
17
14
450
373
n = int(eval(input())) dp = [float("Inf")] * (n + 1) dp[0] = 0 for i in range(n): for j in range(1, 6): if i + j > n: break dp[i + j] = min(dp[i + j], dp[i] + j) for j in range(1, n // 6 + 1): if i + 6**j > n: break dp[i + 6**j] = min(dp[i + 6**j], dp[i] +...
n = int(eval(input())) dp = [float("Inf")] * (n + 1) for i in range(min(6, n + 1)): dp[i] = i for i in range(n): for j in range(1, n // 6 + 1): if i + 6**j > n: break dp[i + 6**j] = min(dp[i + 6**j], dp[i] + 1) for j in range(1, n // 9 + 1): if i + 9**j > n: b...
false
17.647059
[ "-dp[0] = 0", "+for i in range(min(6, n + 1)):", "+ dp[i] = i", "- for j in range(1, 6):", "- if i + j > n:", "- break", "- dp[i + j] = min(dp[i + j], dp[i] + j)" ]
false
0.427141
0.250294
1.706557
[ "s287014635", "s635911655" ]
u968166680
p04013
python
s283997454
s309894581
102
87
70,268
67,276
Accepted
Accepted
14.71
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) dp = [[0] * (N * 50 + 1) for j in range(N + 1)] dp[0][0] = 1 for i in ra...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) dp = [[0] * (N * 50 + 1) for j in range(N + 1)] dp[0][0] = 1 for i in ra...
32
31
646
602
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) dp = [[0] * (N * 50 + 1) for j in range(N + 1)] dp[0][0] = 1 for i in range(N): for ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): N, A, *X = list(map(int, read().split())) dp = [[0] * (N * 50 + 1) for j in range(N + 1)] dp[0][0] = 1 for i in range(N): for ...
false
3.125
[ "- for j in range(N, -1, -1):", "- for k in range(N * 50 + 1):", "- if k - X[i] >= 0 and j > 0:", "- dp[j][k] += dp[j - 1][k - X[i]]", "+ for j in range(N, 0, -1):", "+ for k in range(X[i], N * 50 + 1):", "+ dp[j][k] +=...
false
0.046325
0.033187
1.39586
[ "s283997454", "s309894581" ]
u951814007
p02714
python
s714496235
s130843323
768
135
75,532
68,280
Accepted
Accepted
82.42
n = int(eval(input())) s = eval(input()) count = {"R":0,"G":0,"B":0} for c in s: count[c] += 1 r,g,b = list(count.values()) ans = r*g*b for i in range(1,(n-1)//2+1): #1から for rgb in zip(s,s[i:],s[i*2:]): #rgbに連続した三つのリストの要素を入れ込む if len(set(rgb)) == 3: #リストrgbをセットにまとめ、長さが ans...
n = int(eval(input())) s = eval(input()) r_cnt = s.count('R') g_cnt = s.count('G') b_cnt = s.count('B') ans = r_cnt * g_cnt * b_cnt for i in range(n): #s[i] for d in range(n): j = i + d #s[j] s[i]etcこれらは等間隔となるが k = j + d #s[k] この時点でi!=j, j!=k, i!=k if k >= n:...
14
18
318
454
n = int(eval(input())) s = eval(input()) count = {"R": 0, "G": 0, "B": 0} for c in s: count[c] += 1 r, g, b = list(count.values()) ans = r * g * b for i in range(1, (n - 1) // 2 + 1): # 1から for rgb in zip(s, s[i:], s[i * 2 :]): # rgbに連続した三つのリストの要素を入れ込む if len(set(rgb)) == 3: # リストrgbをセットにまとめ、長さが ...
n = int(eval(input())) s = eval(input()) r_cnt = s.count("R") g_cnt = s.count("G") b_cnt = s.count("B") ans = r_cnt * g_cnt * b_cnt for i in range(n): # s[i] for d in range(n): j = i + d # s[j] s[i]etcこれらは等間隔となるが k = j + d # s[k] この時点でi!=j, j!=k, i!=k if k >= n: break # kが一番大...
false
22.222222
[ "-count = {\"R\": 0, \"G\": 0, \"B\": 0}", "-for c in s:", "- count[c] += 1", "-r, g, b = list(count.values())", "-ans = r * g * b", "-for i in range(1, (n - 1) // 2 + 1): # 1から", "- for rgb in zip(s, s[i:], s[i * 2 :]): # rgbに連続した三つのリストの要素を入れ込む", "- if len(set(rgb)) == 3: # リストrgbをセット...
false
0.038754
0.047264
0.819945
[ "s714496235", "s130843323" ]
u103902792
p03295
python
s026578427
s393148452
444
379
17,468
18,204
Accepted
Accepted
14.64
n,m = list(map(int,input().split())) cut = [] for _ in range(m): a,b = list(map(int,input().split())) cut.append((a,b)) cut.sort() b_min = cut[0][1] count = 0 for a,b in cut[1:]: if b_min > b: b_min = b continue if b_min <= a: count += 1 b_min = b print((count+1))
n,m = list(map(int,input().split())) cut = [] for _ in range(m): a,b = list(map(int,input().split())) cut.append((a,b)) cut.sort(key = lambda x:x[1]) ex_b = cut[0][1] count = 0 for a,b in cut[1:]: if a >= ex_b: count += 1 ex_b = b print((count+1))
22
15
303
265
n, m = list(map(int, input().split())) cut = [] for _ in range(m): a, b = list(map(int, input().split())) cut.append((a, b)) cut.sort() b_min = cut[0][1] count = 0 for a, b in cut[1:]: if b_min > b: b_min = b continue if b_min <= a: count += 1 b_min = b print((count + 1))...
n, m = list(map(int, input().split())) cut = [] for _ in range(m): a, b = list(map(int, input().split())) cut.append((a, b)) cut.sort(key=lambda x: x[1]) ex_b = cut[0][1] count = 0 for a, b in cut[1:]: if a >= ex_b: count += 1 ex_b = b print((count + 1))
false
31.818182
[ "-cut.sort()", "-b_min = cut[0][1]", "+cut.sort(key=lambda x: x[1])", "+ex_b = cut[0][1]", "- if b_min > b:", "- b_min = b", "- continue", "- if b_min <= a:", "+ if a >= ex_b:", "- b_min = b", "+ ex_b = b" ]
false
0.0407
0.037349
1.089722
[ "s026578427", "s393148452" ]
u135847648
p03339
python
s281558813
s119361640
499
355
43,852
4,084
Accepted
Accepted
28.86
import collections n = int(eval(input())) s = eval(input()) dic = dict(collections.Counter(s)) #W,Eどちらかしか無い場合 if len(dic)==1: print((0)) exit() left_w = 0 right_e = dic["E"] cnt = [[] for _ in range(n)] #(左にあるWの数+右にあるEの数)の最小値が答え ans = n for i in range(n): if s[i] == "W": cnt[i] = [left_w,ri...
import collections n = int(eval(input())) s = eval(input()) dic = dict(collections.Counter(s)) #W,Eどちらかしか無い場合 if len(dic)==1: print((0)) exit() left_w = 0 right_e = dic["E"] #(左にあるWの数+右にあるEの数)の最小値が答え ans = n for i in range(n): if s[i] == "W": ans = min(ans,left_w+right_e) left_w += 1 e...
39
35
731
637
import collections n = int(eval(input())) s = eval(input()) dic = dict(collections.Counter(s)) # W,Eどちらかしか無い場合 if len(dic) == 1: print((0)) exit() left_w = 0 right_e = dic["E"] cnt = [[] for _ in range(n)] # (左にあるWの数+右にあるEの数)の最小値が答え ans = n for i in range(n): if s[i] == "W": cnt[i] = [left_w, right...
import collections n = int(eval(input())) s = eval(input()) dic = dict(collections.Counter(s)) # W,Eどちらかしか無い場合 if len(dic) == 1: print((0)) exit() left_w = 0 right_e = dic["E"] # (左にあるWの数+右にあるEの数)の最小値が答え ans = n for i in range(n): if s[i] == "W": ans = min(ans, left_w + right_e) left_w += 1...
false
10.25641
[ "-cnt = [[] for _ in range(n)]", "- cnt[i] = [left_w, right_e]", "- cnt[i] = [left_w, right_e]" ]
false
0.045946
0.045664
1.00618
[ "s281558813", "s119361640" ]
u131811591
p02329
python
s912345391
s647350387
1,120
1,020
179,080
179,044
Accepted
Accepted
8.93
import sys from collections import defaultdict if __name__ == '__main__': n, v = list(map(int, sys.stdin.readline().split())) a = list(map(int, sys.stdin.readline().split())) b = list(map(int, sys.stdin.readline().split())) c = list(map(int, sys.stdin.readline().split())) d = list(map(int, ...
import sys from collections import defaultdict if __name__ == '__main__': n, v = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) b = tuple(map(int, sys.stdin.readline().split())) c = tuple(map(int, sys.stdin.readline().split())) d = tuple(map(i...
20
20
571
575
import sys from collections import defaultdict if __name__ == "__main__": n, v = list(map(int, sys.stdin.readline().split())) a = list(map(int, sys.stdin.readline().split())) b = list(map(int, sys.stdin.readline().split())) c = list(map(int, sys.stdin.readline().split())) d = list(map(int, sys.stdi...
import sys from collections import defaultdict if __name__ == "__main__": n, v = list(map(int, sys.stdin.readline().split())) a = tuple(map(int, sys.stdin.readline().split())) b = tuple(map(int, sys.stdin.readline().split())) c = tuple(map(int, sys.stdin.readline().split())) d = tuple(map(int, sys....
false
0
[ "- a = list(map(int, sys.stdin.readline().split()))", "- b = list(map(int, sys.stdin.readline().split()))", "- c = list(map(int, sys.stdin.readline().split()))", "- d = list(map(int, sys.stdin.readline().split()))", "+ a = tuple(map(int, sys.stdin.readline().split()))", "+ b = tuple(map(...
false
0.04179
0.086562
0.482776
[ "s912345391", "s647350387" ]
u119148115
p03311
python
s779472868
s365607907
142
130
94,456
104,448
Accepted
Accepted
8.45
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり N = I() A = LI() for i in range(N): A[i] -= i+1 A.sort() def f(x): return sum(abs(A[i]-x) for i in range(N)) print((f((A[(N-1)//2]+A[N//2])//2))) # 中間...
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 ...
18
23
320
648
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり N = I() A = LI() for i in range(N): A[i] -= i + 1 A.sort() def f(x): return sum(abs(A[i] - x) for i in range(N)) print((f((A[(N - 1) // 2] + A[N // 2]) /...
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) # 空白あり def LI2(): return list(map(int, sys.stdin.readline().r...
false
21.73913
[ "+", "+sys.setrecursionlimit(10**7)", "+def MI():", "+ return list(map(int, sys.stdin.readline().rstrip().split()))", "+", "+", "+", "+", "+def LI2():", "+ return list(map(int, sys.stdin.readline().rstrip())) # 空白なし", "+", "+", "+def S():", "+ return sys.stdin.readline().rstrip()...
false
0.086456
0.087471
0.988396
[ "s779472868", "s365607907" ]
u919633157
p03107
python
s228176656
s662821856
34
18
3,188
3,188
Accepted
Accepted
47.06
# 2019/07/25 s=eval(input()) cnt=0 for e in s: if e=='1':cnt+=1 else:cnt-=1 print((len(s)-abs(cnt)))
s=eval(input()) z=s.count('0') o=s.count('1') print((len(s)-abs(z-o)))
9
4
110
65
# 2019/07/25 s = eval(input()) cnt = 0 for e in s: if e == "1": cnt += 1 else: cnt -= 1 print((len(s) - abs(cnt)))
s = eval(input()) z = s.count("0") o = s.count("1") print((len(s) - abs(z - o)))
false
55.555556
[ "-# 2019/07/25", "-cnt = 0", "-for e in s:", "- if e == \"1\":", "- cnt += 1", "- else:", "- cnt -= 1", "-print((len(s) - abs(cnt)))", "+z = s.count(\"0\")", "+o = s.count(\"1\")", "+print((len(s) - abs(z - o)))" ]
false
0.04462
0.043597
1.023467
[ "s228176656", "s662821856" ]
u546285759
p00011
python
s660766099
s257798072
30
20
7,604
5,600
Accepted
Accepted
33.33
w = int(input()) n = int(input()) am = [i for i in range(w+1)] for _ in range(n): a, b = map(int, input().split(',')) am[a], am[b] = am[b], am[a] print(*am[1:], sep="\n")
w = int(input()) n = int(input()) kuji = [i+1 for i in range(w)] for _ in range(n): a, b = map(int, input().split(',')) kuji[a-1], kuji[b-1] = kuji[b-1], kuji[a-1] print(*kuji, sep="\n")
7
8
184
203
w = int(input()) n = int(input()) am = [i for i in range(w + 1)] for _ in range(n): a, b = map(int, input().split(",")) am[a], am[b] = am[b], am[a] print(*am[1:], sep="\n")
w = int(input()) n = int(input()) kuji = [i + 1 for i in range(w)] for _ in range(n): a, b = map(int, input().split(",")) kuji[a - 1], kuji[b - 1] = kuji[b - 1], kuji[a - 1] print(*kuji, sep="\n")
false
12.5
[ "-am = [i for i in range(w + 1)]", "+kuji = [i + 1 for i in range(w)]", "- am[a], am[b] = am[b], am[a]", "-print(*am[1:], sep=\"\\n\")", "+ kuji[a - 1], kuji[b - 1] = kuji[b - 1], kuji[a - 1]", "+print(*kuji, sep=\"\\n\")" ]
false
0.153163
0.056361
2.717528
[ "s660766099", "s257798072" ]
u436807165
p02388
python
s322614691
s723950792
30
10
6,424
6,424
Accepted
Accepted
66.67
input = input() print(int(input) ** 3)
x = eval(input()) print(x**3)
2
2
42
23
input = input() print(int(input) ** 3)
x = eval(input()) print(x**3)
false
0
[ "-input = input()", "-print(int(input) ** 3)", "+x = eval(input())", "+print(x**3)" ]
false
0.078395
0.045304
1.730416
[ "s322614691", "s723950792" ]
u670180528
p03295
python
s691112087
s041176321
141
127
25,132
25,132
Accepted
Accepted
9.93
n,m,*t=list(map(int,open(0).read().split()));r=[n+1]*(n+1) for a,b in zip(*[iter(t)]*2): r[a]=min(r[a],b) a=0;cur=n+1 for i in range(n+1): cur=min(cur, r[i]) if i==cur: cur=r[i] a+=1 print(a)
def solve(): n,_,*t=list(map(int,open(0).read().split()));r=[n+1]*(n+1) for a,b in zip(*[iter(t)]*2): r[a]=min(r[a],b) a=0;cur=n+1 for i in range(n+1): cur=min(cur, r[i]) if i==cur: #追いついた cur=r[i] a+=1 print(a) if __name__=="__main__": solve()
10
14
201
272
n, m, *t = list(map(int, open(0).read().split())) r = [n + 1] * (n + 1) for a, b in zip(*[iter(t)] * 2): r[a] = min(r[a], b) a = 0 cur = n + 1 for i in range(n + 1): cur = min(cur, r[i]) if i == cur: cur = r[i] a += 1 print(a)
def solve(): n, _, *t = list(map(int, open(0).read().split())) r = [n + 1] * (n + 1) for a, b in zip(*[iter(t)] * 2): r[a] = min(r[a], b) a = 0 cur = n + 1 for i in range(n + 1): cur = min(cur, r[i]) if i == cur: # 追いついた cur = r[i] a +=...
false
28.571429
[ "-n, m, *t = list(map(int, open(0).read().split()))", "-r = [n + 1] * (n + 1)", "-for a, b in zip(*[iter(t)] * 2):", "- r[a] = min(r[a], b)", "-a = 0", "-cur = n + 1", "-for i in range(n + 1):", "- cur = min(cur, r[i])", "- if i == cur:", "- cur = r[i]", "- a += 1", "-pr...
false
0.035886
0.041625
0.862128
[ "s691112087", "s041176321" ]
u952708174
p03472
python
s739247466
s974530419
615
360
36,624
22,284
Accepted
Accepted
41.46
def d_Katana_Thrower(N, H, S): import numpy import math swing = numpy.asarray([x[0] for x in S]) throw = numpy.asarray([x[1] for x in S]) swing_max = numpy.max(swing) throw_t = throw[throw >= swing_max] throw_t = sorted(throw_t, reverse=True) hp = H ans = 0 for d in...
def d_katana_thrower(N, H, Swords): import math # 振ったとき最もダメージが大きい刀以上に投げたときのダメージが大きな刀 # について、ダメージが大きなものから投げていく。そのダメージの総和が # 敵の体力より大きければ投げて倒せばいいし、足りなければ刀を降って倒せばいい。 # ただし、振る刀の投げダメージが振るより高ければ、投げる前に振らなければならないが、 # 計算時には「投げてから振る」とみなしても問題ない。 swing_damage_max = max([s[0] for s in Swords]) ...
25
24
614
875
def d_Katana_Thrower(N, H, S): import numpy import math swing = numpy.asarray([x[0] for x in S]) throw = numpy.asarray([x[1] for x in S]) swing_max = numpy.max(swing) throw_t = throw[throw >= swing_max] throw_t = sorted(throw_t, reverse=True) hp = H ans = 0 for d in throw_t: ...
def d_katana_thrower(N, H, Swords): import math # 振ったとき最もダメージが大きい刀以上に投げたときのダメージが大きな刀 # について、ダメージが大きなものから投げていく。そのダメージの総和が # 敵の体力より大きければ投げて倒せばいいし、足りなければ刀を降って倒せばいい。 # ただし、振る刀の投げダメージが振るより高ければ、投げる前に振らなければならないが、 # 計算時には「投げてから振る」とみなしても問題ない。 swing_damage_max = max([s[0] for s in Swords]) throw_...
false
4
[ "-def d_Katana_Thrower(N, H, S):", "- import numpy", "+def d_katana_thrower(N, H, Swords):", "- swing = numpy.asarray([x[0] for x in S])", "- throw = numpy.asarray([x[1] for x in S])", "- swing_max = numpy.max(swing)", "- throw_t = throw[throw >= swing_max]", "- throw_t = sorted(thro...
false
0.241095
0.045371
5.313838
[ "s739247466", "s974530419" ]
u620084012
p02835
python
s760035256
s741996088
205
17
38,384
2,940
Accepted
Accepted
91.71
A, B, C = list(map(int,input().split())) if A+B+C >= 22: print("bust") else: print("win")
import sys def input(): return sys.stdin.readline()[:-1] def main(): # N = int(input()) A, B, C = list(map(int,input().split())) # S = input() print(("bust" if (A+B+C) >= 22 else "win")) if __name__ == '__main__': main()
5
10
96
244
A, B, C = list(map(int, input().split())) if A + B + C >= 22: print("bust") else: print("win")
import sys def input(): return sys.stdin.readline()[:-1] def main(): # N = int(input()) A, B, C = list(map(int, input().split())) # S = input() print(("bust" if (A + B + C) >= 22 else "win")) if __name__ == "__main__": main()
false
50
[ "-A, B, C = list(map(int, input().split()))", "-if A + B + C >= 22:", "- print(\"bust\")", "-else:", "- print(\"win\")", "+import sys", "+", "+", "+def input():", "+ return sys.stdin.readline()[:-1]", "+", "+", "+def main():", "+ # N = int(input())", "+ A, B, C = list(m...
false
0.066831
0.037386
1.787564
[ "s760035256", "s741996088" ]
u746419473
p02813
python
s993618348
s037488834
29
26
8,052
8,052
Accepted
Accepted
10.34
import itertools import bisect n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) *per, = itertools.permutations(list(range(1, n+1))) a = bisect.bisect_right(per, p) b = bisect.bisect_right(per, q) print((abs(a-b)))
import bisect import itertools n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) *perm, = itertools.permutations(list(range(1, n+1)), n) a = bisect.bisect_right(perm, p) b = bisect.bisect_right(perm, q) print((abs(a-b)))
12
10
262
270
import itertools import bisect n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) (*per,) = itertools.permutations(list(range(1, n + 1))) a = bisect.bisect_right(per, p) b = bisect.bisect_right(per, q) print((abs(a - b)))
import bisect import itertools n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) (*perm,) = itertools.permutations(list(range(1, n + 1)), n) a = bisect.bisect_right(perm, p) b = bisect.bisect_right(perm, q) print((abs(a - b)))
false
16.666667
[ "+import bisect", "-import bisect", "-(*per,) = itertools.permutations(list(range(1, n + 1)))", "-a = bisect.bisect_right(per, p)", "-b = bisect.bisect_right(per, q)", "+(*perm,) = itertools.permutations(list(range(1, n + 1)), n)", "+a = bisect.bisect_right(perm, p)", "+b = bisect.bisect_right(perm, q...
false
0.047882
0.090238
0.530622
[ "s993618348", "s037488834" ]
u513081876
p03252
python
s325974456
s537079097
258
121
6,832
3,888
Accepted
Accepted
53.1
S = eval(input()) T = eval(input()) used = [] res = [] for i in range(len(S)): if S[i] not in used: used.append(S[i]) res.append(used.index(S[i])) #print(used) #print(res) used = [] ret = [] for i in range(len(T)): if T[i] not in used: used.append(T[i]) ret.append...
import sys from collections import defaultdict S = eval(input()) T = eval(input()) L = len(S) dcts = defaultdict(int) dctt = defaultdict(int) for i in range(L): s = S[i] t = T[i] if dcts[s] == 0: dcts[s] = t else: if dcts[s] != t: print('No') sy...
25
25
386
459
S = eval(input()) T = eval(input()) used = [] res = [] for i in range(len(S)): if S[i] not in used: used.append(S[i]) res.append(used.index(S[i])) # print(used) # print(res) used = [] ret = [] for i in range(len(T)): if T[i] not in used: used.append(T[i]) ret.append(used.index(T[i])) if ...
import sys from collections import defaultdict S = eval(input()) T = eval(input()) L = len(S) dcts = defaultdict(int) dctt = defaultdict(int) for i in range(L): s = S[i] t = T[i] if dcts[s] == 0: dcts[s] = t else: if dcts[s] != t: print("No") sys.exit() if dc...
false
0
[ "+import sys", "+from collections import defaultdict", "+", "-used = []", "-res = []", "-for i in range(len(S)):", "- if S[i] not in used:", "- used.append(S[i])", "- res.append(used.index(S[i]))", "-# print(used)", "-# print(res)", "-used = []", "-ret = []", "-for i in range(...
false
0.042795
0.043999
0.972618
[ "s325974456", "s537079097" ]
u506549878
p03835
python
s211252062
s207832943
1,476
1,358
2,940
2,940
Accepted
Accepted
7.99
k, s = list(map(int, input().split())) flg = 0 for x in range(k+1): for y in range(k+1): z = s-x-y if 0<= z <= k: flg += 1 print(flg)
k, s =list(map(int,input().split())) cnt = 0 for i in range(k+1): for j in range(k+1): if 0<=s-i-j<=k: cnt += 1 print(cnt)
8
7
178
152
k, s = list(map(int, input().split())) flg = 0 for x in range(k + 1): for y in range(k + 1): z = s - x - y if 0 <= z <= k: flg += 1 print(flg)
k, s = list(map(int, input().split())) cnt = 0 for i in range(k + 1): for j in range(k + 1): if 0 <= s - i - j <= k: cnt += 1 print(cnt)
false
12.5
[ "-flg = 0", "-for x in range(k + 1):", "- for y in range(k + 1):", "- z = s - x - y", "- if 0 <= z <= k:", "- flg += 1", "-print(flg)", "+cnt = 0", "+for i in range(k + 1):", "+ for j in range(k + 1):", "+ if 0 <= s - i - j <= k:", "+ cnt += 1",...
false
0.044741
0.110405
0.405244
[ "s211252062", "s207832943" ]
u914797917
p03814
python
s117393340
s428496228
36
18
3,512
3,516
Accepted
Accepted
50
S=eval(input()) for i in range(len(S)): if S[i]=='A': S=S[i:] break for i in range(len(S)-1,0,-1): if S[i]=='Z': S=S[:i+1] break print((len(S)))
S=eval(input()) S=S[S.find('A'):S.rfind('Z')+1] print((len(S)))
13
3
175
57
S = eval(input()) for i in range(len(S)): if S[i] == "A": S = S[i:] break for i in range(len(S) - 1, 0, -1): if S[i] == "Z": S = S[: i + 1] break print((len(S)))
S = eval(input()) S = S[S.find("A") : S.rfind("Z") + 1] print((len(S)))
false
76.923077
[ "-for i in range(len(S)):", "- if S[i] == \"A\":", "- S = S[i:]", "- break", "-for i in range(len(S) - 1, 0, -1):", "- if S[i] == \"Z\":", "- S = S[: i + 1]", "- break", "+S = S[S.find(\"A\") : S.rfind(\"Z\") + 1]" ]
false
0.034903
0.036724
0.950412
[ "s117393340", "s428496228" ]
u346812984
p02939
python
s727939591
s793575356
435
335
22,064
19,108
Accepted
Accepted
22.99
S = list(eval(input())) N = len(S) # n文字まで見て最後が1文字か2文字化 dp_1 = [0] * N dp_2 = [0] * N dp_1[0] = 1 dp_2[1] = 1 if S[0] != S[1]: dp_1[1] = 2 for i, s in enumerate(S[2:], 2): # dp_1 # 2 -> 1 tmp = dp_2[i - 1] + 1 # 1 -> 1 if S[i - 1] != S[i]: tmp = max(tmp, dp_1[i - 1] ...
import sys sys.setrecursionlimit(10 ** 6) INF = float("inf") MOD = 10 ** 9 + 7 def input(): return sys.stdin.readline().strip() def main(): S = eval(input()) N = len(S) # n文字まで見て最後が1文字か2文字か dp_1 = [0] * N dp_2 = [0] * N dp_1[0] = 1 dp_2[1] = 1 if S[0] != S[1...
30
44
543
818
S = list(eval(input())) N = len(S) # n文字まで見て最後が1文字か2文字化 dp_1 = [0] * N dp_2 = [0] * N dp_1[0] = 1 dp_2[1] = 1 if S[0] != S[1]: dp_1[1] = 2 for i, s in enumerate(S[2:], 2): # dp_1 # 2 -> 1 tmp = dp_2[i - 1] + 1 # 1 -> 1 if S[i - 1] != S[i]: tmp = max(tmp, dp_1[i - 1] + 1) dp_1[i] = tm...
import sys sys.setrecursionlimit(10**6) INF = float("inf") MOD = 10**9 + 7 def input(): return sys.stdin.readline().strip() def main(): S = eval(input()) N = len(S) # n文字まで見て最後が1文字か2文字か dp_1 = [0] * N dp_2 = [0] * N dp_1[0] = 1 dp_2[1] = 1 if S[0] != S[1]: dp_1[1] = 2 ...
false
31.818182
[ "-S = list(eval(input()))", "-N = len(S)", "-# n文字まで見て最後が1文字か2文字化", "-dp_1 = [0] * N", "-dp_2 = [0] * N", "-dp_1[0] = 1", "-dp_2[1] = 1", "-if S[0] != S[1]:", "- dp_1[1] = 2", "-for i, s in enumerate(S[2:], 2):", "- # dp_1", "- # 2 -> 1", "- tmp = dp_2[i - 1] + 1", "- # 1 ->...
false
0.045595
0.085546
0.532995
[ "s727939591", "s793575356" ]
u498487134
p02755
python
s499349093
s916222635
189
70
39,536
63,976
Accepted
Accepted
62.96
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 a,b=MI() ans=-1 for i in range(10000): aa=int(i*0.08) bb=i//10 if a==...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 ans=-1 A,B=MI() for i in range(10000): a=int(i*0.08) b=int(i*0.1) ...
20
24
386
415
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 a, b = MI() ans = -1 for i in range(10000): aa = int(i * 0.08) bb = ...
import sys input = sys.stdin.readline def I(): return int(eval(input())) def MI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) def main(): mod = 10**9 + 7 ans = -1 A, B = MI() for i in range(10000): a = int(i * 0.08) b = in...
false
16.666667
[ "- a, b = MI()", "+ A, B = MI()", "- aa = int(i * 0.08)", "- bb = i // 10", "- if a == aa and b == bb:", "+ a = int(i * 0.08)", "+ b = int(i * 0.1)", "+ if a == A and b == B:" ]
false
0.050121
0.145563
0.344325
[ "s499349093", "s916222635" ]
u562935282
p03055
python
s742596075
s295555535
1,471
994
49,212
47,616
Accepted
Accepted
32.43
from collections import deque N = int(eval(input())) e = [[] for _ in range(N)] # 隣接リスト for _ in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 e[a].append(b) e[b].append(a) # BFS*2で直径を求める dist = [-1 for _ in range(N)] dist[0] = 0 q = deque() q.append(0) ...
from collections import deque import sys input = sys.stdin.readline N = int(eval(input())) e = [[] for _ in range(N)] # 隣接リスト for _ in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 e[a].append(b) e[b].append(a) # BFS*2で直径を求める def bfs(i): """ :par...
45
40
814
721
from collections import deque N = int(eval(input())) e = [[] for _ in range(N)] # 隣接リスト for _ in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 e[a].append(b) e[b].append(a) # BFS*2で直径を求める dist = [-1 for _ in range(N)] dist[0] = 0 q = deque() q.append(0) while q: v = q.pople...
from collections import deque import sys input = sys.stdin.readline N = int(eval(input())) e = [[] for _ in range(N)] # 隣接リスト for _ in range(N - 1): a, b = list(map(int, input().split())) a -= 1 b -= 1 e[a].append(b) e[b].append(a) # BFS*2で直径を求める def bfs(i): """ :param i: bfsの始点, 0-indexed ...
false
11.111111
[ "+import sys", "+input = sys.stdin.readline", "-dist = [-1 for _ in range(N)]", "-dist[0] = 0", "-q = deque()", "-q.append(0)", "-while q:", "- v = q.popleft()", "- d = dist[v]", "- for nv in [x for x in e[v] if dist[x] == -1]:", "- dist[nv] = d + 1", "- q.append(nv)", ...
false
0.040697
0.036312
1.12077
[ "s742596075", "s295555535" ]
u492605584
p03164
python
s107163941
s667284909
1,125
1,021
310,808
308,296
Accepted
Accepted
9.24
n,w=list(map(int, input().split())) m=10**5+1 x=[list(map(int, input().split())) for i in range(n)] dp=[[float('inf')]*m for i in range(n+1)] dp[0][0]=0 for i in range(n): for j in range(m): if j>=x[i][1]: dp[i+1][j]=min(dp[i][j],dp[i][j-x[i][1]]+x[i][0]) else: dp[i...
N, W = list(map(int, input().split())) L = [list(map(int, input().split())) for i in range(N)] V = 0 for i in range(N): V += L[i][1] dp = [[float('inf')] * (V + 1) for i in range(N+1)] dp[0][0] = 0 for i in range(N): for j in range(V+1): if j - L[i][1] >= 0: dp[i+1][j] = min(dp[i][j]...
15
19
404
486
n, w = list(map(int, input().split())) m = 10**5 + 1 x = [list(map(int, input().split())) for i in range(n)] dp = [[float("inf")] * m for i in range(n + 1)] dp[0][0] = 0 for i in range(n): for j in range(m): if j >= x[i][1]: dp[i + 1][j] = min(dp[i][j], dp[i][j - x[i][1]] + x[i][0]) else...
N, W = list(map(int, input().split())) L = [list(map(int, input().split())) for i in range(N)] V = 0 for i in range(N): V += L[i][1] dp = [[float("inf")] * (V + 1) for i in range(N + 1)] dp[0][0] = 0 for i in range(N): for j in range(V + 1): if j - L[i][1] >= 0: dp[i + 1][j] = min(dp[i][j], ...
false
21.052632
[ "-n, w = list(map(int, input().split()))", "-m = 10**5 + 1", "-x = [list(map(int, input().split())) for i in range(n)]", "-dp = [[float(\"inf\")] * m for i in range(n + 1)]", "+N, W = list(map(int, input().split()))", "+L = [list(map(int, input().split())) for i in range(N)]", "+V = 0", "+for i in ran...
false
0.381087
0.060143
6.336334
[ "s107163941", "s667284909" ]
u970197315
p02756
python
s276083392
s911388304
722
407
46,936
13,908
Accepted
Accepted
43.63
# ABC158 D from collections import deque s=eval(input()) q=int(eval(input())) l=[] for i in range(q): l.append(list(map(str,input().split()))) cnt=0 front_str='' end_str='' t_str=deque(s) front_str=deque(front_str) end_str=deque(end_str) for ll in l: if ll[0]=='1': cnt+=1 eli...
s=eval(input()) q=int(eval(input())) m=0 from collections import deque s=deque(s) for i in range(q): l=list(map(str,input().split())) if l[0]=="1": m+=1 m%=2 else: if m==0: if l[1]=="1": s.appendleft(l[2]) else: s.append(l[2]) else: if l[1]=="1": ...
40
26
799
428
# ABC158 D from collections import deque s = eval(input()) q = int(eval(input())) l = [] for i in range(q): l.append(list(map(str, input().split()))) cnt = 0 front_str = "" end_str = "" t_str = deque(s) front_str = deque(front_str) end_str = deque(end_str) for ll in l: if ll[0] == "1": cnt += 1 eli...
s = eval(input()) q = int(eval(input())) m = 0 from collections import deque s = deque(s) for i in range(q): l = list(map(str, input().split())) if l[0] == "1": m += 1 m %= 2 else: if m == 0: if l[1] == "1": s.appendleft(l[2]) else: ...
false
35
[ "-# ABC158 D", "+s = eval(input())", "+q = int(eval(input()))", "+m = 0", "-s = eval(input())", "-q = int(eval(input()))", "-l = []", "+s = deque(s)", "- l.append(list(map(str, input().split())))", "-cnt = 0", "-front_str = \"\"", "-end_str = \"\"", "-t_str = deque(s)", "-front_str = de...
false
0.038849
0.03821
1.016736
[ "s276083392", "s911388304" ]
u367130284
p04039
python
s833194681
s908224081
123
87
2,940
3,864
Accepted
Accepted
29.27
n,k,*a=open(0).read().split();n=int(n) while any(s in set(a)for s in str(n)):n+=1 print(n)
n,_=input().split();s=set(list(eval(input())));n=int(n);print((n+[len(s&set(str(b)))for b in range(n,99999)].index(0)))
3
1
92
111
n, k, *a = open(0).read().split() n = int(n) while any(s in set(a) for s in str(n)): n += 1 print(n)
n, _ = input().split() s = set(list(eval(input()))) n = int(n) print((n + [len(s & set(str(b))) for b in range(n, 99999)].index(0)))
false
66.666667
[ "-n, k, *a = open(0).read().split()", "+n, _ = input().split()", "+s = set(list(eval(input())))", "-while any(s in set(a) for s in str(n)):", "- n += 1", "-print(n)", "+print((n + [len(s & set(str(b))) for b in range(n, 99999)].index(0)))" ]
false
0.095253
0.036526
2.60782
[ "s833194681", "s908224081" ]
u585482323
p03229
python
s139938152
s126509361
812
535
67,932
53,212
Accepted
Accepted
34.11
#!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 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()...
103
69
2,353
1,524
#!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 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...
false
33.009709
[ "- if i & 1:", "+ if i & 2:", "- if abs(x - ai) < abs(y - ai):", "+ if i & 1:", "- if i & 1:", "+ if i & 2:", "- x = q[0]", "- y = q[-1]", "- if abs(x - ai) < abs(y - ai):", "+ if i & 1:", "- a = deque(b)", "- q = dequ...
false
0.04951
0.085644
0.578093
[ "s139938152", "s126509361" ]
u094191970
p03006
python
s039276250
s316611747
757
106
9,316
9,280
Accepted
Accepted
86
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) n=int(eval(input())) xy=[lnii() for i in range(n)] xy.sort(key=lambda x:x[0]) ans=n pq=[] for i in range(n-1): for j in range(i+1,n): t_p=xy[j][0]-xy[i][0] t_q=xy[j][1]...
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) n=int(eval(input())) xy=[lnii() for i in range(n)] xy.sort(key=lambda x:x[0]) pq=[] for i in range(n-1): for j in range(i+1,n): t_p=xy[j][0]-xy[i][0] t_q=xy[j][1]-xy[i][1]...
32
34
635
646
from sys import stdin nii = lambda: list(map(int, stdin.readline().split())) lnii = lambda: list(map(int, stdin.readline().split())) n = int(eval(input())) xy = [lnii() for i in range(n)] xy.sort(key=lambda x: x[0]) ans = n pq = [] for i in range(n - 1): for j in range(i + 1, n): t_p = xy[j][0] - xy[i][0] ...
from sys import stdin nii = lambda: list(map(int, stdin.readline().split())) lnii = lambda: list(map(int, stdin.readline().split())) n = int(eval(input())) xy = [lnii() for i in range(n)] xy.sort(key=lambda x: x[0]) pq = [] for i in range(n - 1): for j in range(i + 1, n): t_p = xy[j][0] - xy[i][0] ...
false
5.882353
[ "-ans = n", "+ans = n", "- # for x,y in xy:", "- # if [x+p,y+q] in xy:", "- # cnt+=1", "- for i in range(n):", "- for j in range(n):", "- if i == j:", "- continue", "- x1, y1 = xy[i]", "- x2, y2 = xy[j]", "- ...
false
0.074264
0.072438
1.025213
[ "s039276250", "s316611747" ]
u380524497
p03739
python
s686549689
s789813279
109
75
14,468
20,460
Accepted
Accepted
31.19
n = int(eval(input())) a_list = list(map(int, input().split())) total = 0 count = 0 pos_or_neg = True # True = +, False = - for a in a_list: total += a if pos_or_neg: if total <= 0: count += -total + 1 total += -total + 1 pos_or_neg = False else: ...
def main(): n = int(eval(input())) A = list(map(int, input().split())) ans1 = 0 total = 0 is_plus = True for a in A: total += a if is_plus: if total <= 0: ans1 += -total + 1 total = 1 else: if total ...
41
43
827
832
n = int(eval(input())) a_list = list(map(int, input().split())) total = 0 count = 0 pos_or_neg = True # True = +, False = - for a in a_list: total += a if pos_or_neg: if total <= 0: count += -total + 1 total += -total + 1 pos_or_neg = False else: if total >= ...
def main(): n = int(eval(input())) A = list(map(int, input().split())) ans1 = 0 total = 0 is_plus = True for a in A: total += a if is_plus: if total <= 0: ans1 += -total + 1 total = 1 else: if total >= 0: ...
false
4.651163
[ "-n = int(eval(input()))", "-a_list = list(map(int, input().split()))", "-total = 0", "-count = 0", "-pos_or_neg = True # True = +, False = -", "-for a in a_list:", "- total += a", "- if pos_or_neg:", "- if total <= 0:", "- count += -total + 1", "- total += -t...
false
0.112768
0.1672
0.67445
[ "s686549689", "s789813279" ]
u624475441
p03285
python
s068024900
s593785868
20
18
2,940
2,940
Accepted
Accepted
10
N = int(eval(input())) for i in range(101): if N - 7 * i < 0: break if (N - 7 * i) % 4 == 0: print('Yes') exit() print('No')
if int(eval(input())) in [1, 2, 3, 5, 6, 9, 10, 13, 17]: print('No') else: print('Yes')
8
4
157
92
N = int(eval(input())) for i in range(101): if N - 7 * i < 0: break if (N - 7 * i) % 4 == 0: print("Yes") exit() print("No")
if int(eval(input())) in [1, 2, 3, 5, 6, 9, 10, 13, 17]: print("No") else: print("Yes")
false
50
[ "-N = int(eval(input()))", "-for i in range(101):", "- if N - 7 * i < 0:", "- break", "- if (N - 7 * i) % 4 == 0:", "- print(\"Yes\")", "- exit()", "-print(\"No\")", "+if int(eval(input())) in [1, 2, 3, 5, 6, 9, 10, 13, 17]:", "+ print(\"No\")", "+else:", "+ pr...
false
0.036091
0.038172
0.945486
[ "s068024900", "s593785868" ]
u731896389
p02410
python
s694941631
s577138881
30
20
7,976
8,072
Accepted
Accepted
33.33
n,m = list(map(int,input().split())) A = [] b = [] for i in range(n): A.append([int(j) for j in input().split()]) for i in range(m): b.append(int(eval(input()))) for i in range(n): sum = 0 for j in range(m): sum += A[i][j]*b[j] print(sum)
n,m=list(map(int,input().split())) A =[[int(i) for i in input().split()] for j in range(n)] b = [] for i in range(m): b.append(int(eval(input()))) ans = [0 for i in range(n)] for i in range(n): for j in range(m): ans[i] += A[i][j]*b[j] for i in ans: print(i)
12
11
265
276
n, m = list(map(int, input().split())) A = [] b = [] for i in range(n): A.append([int(j) for j in input().split()]) for i in range(m): b.append(int(eval(input()))) for i in range(n): sum = 0 for j in range(m): sum += A[i][j] * b[j] print(sum)
n, m = list(map(int, input().split())) A = [[int(i) for i in input().split()] for j in range(n)] b = [] for i in range(m): b.append(int(eval(input()))) ans = [0 for i in range(n)] for i in range(n): for j in range(m): ans[i] += A[i][j] * b[j] for i in ans: print(i)
false
8.333333
[ "-A = []", "+A = [[int(i) for i in input().split()] for j in range(n)]", "-for i in range(n):", "- A.append([int(j) for j in input().split()])", "+ans = [0 for i in range(n)]", "- sum = 0", "- sum += A[i][j] * b[j]", "- print(sum)", "+ ans[i] += A[i][j] * b[j]", "+for i in a...
false
0.042558
0.043872
0.970068
[ "s694941631", "s577138881" ]
u489959379
p03696
python
s632552495
s634684891
162
25
38,256
9,192
Accepted
Accepted
84.57
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) S = eval(input()) insert_L = 0 cnt_L = 0 for s in S: if s == '(': cnt_L += 1 else: if cnt_L: cnt_L -=...
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(eval(input())) S = eval(input()) right = 0 left = 0 for i in range(n): if S[i] == "(": left += 1 else: if left: left -...
31
27
497
462
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) S = eval(input()) insert_L = 0 cnt_L = 0 for s in S: if s == "(": cnt_L += 1 else: if cnt_L: cnt_L -= 1 else: ...
import sys sys.setrecursionlimit(10**7) f_inf = float("inf") mod = 10**9 + 7 def resolve(): n = int(eval(input())) S = eval(input()) right = 0 left = 0 for i in range(n): if S[i] == "(": left += 1 else: if left: left -= 1 else: ...
false
12.903226
[ "- insert_L = 0", "- cnt_L = 0", "- for s in S:", "- if s == \"(\":", "- cnt_L += 1", "+ right = 0", "+ left = 0", "+ for i in range(n):", "+ if S[i] == \"(\":", "+ left += 1", "- if cnt_L:", "- cnt_L -= 1", "+ ...
false
0.037461
0.056965
0.657621
[ "s632552495", "s634684891" ]
u062691227
p04046
python
s539781020
s811976266
376
173
88,692
73,692
Accepted
Accepted
53.99
H, W, A, B = list(map(int, open(0).read().split())) MOD = 10**9+7 factorials = [1] * (H + W + 1) inv_factorials = [1] * (H + W + 1) tmp = 1 for i in range(H + W): tmp = tmp * (i + 1) % MOD factorials[i+1] = tmp inv_factorials = list([pow(n, MOD - 2, MOD) for n in factorials]) def modcomb(m, n, ...
H, W, A, B = list(map(int, open(0).read().split())) MOD = 10**9+7 factorials = [1] * (H + W + 1) inv_factorials = [1] * (H + W + 1) for i in range(H + W): factorials[i+1] = factorials[i] * (i + 1) % MOD for i in range(H + W): inv_factorials[i+1] = inv_factorials[i] * pow(i + 1, MOD - 2, MOD) % MO...
25
24
641
658
H, W, A, B = list(map(int, open(0).read().split())) MOD = 10**9 + 7 factorials = [1] * (H + W + 1) inv_factorials = [1] * (H + W + 1) tmp = 1 for i in range(H + W): tmp = tmp * (i + 1) % MOD factorials[i + 1] = tmp inv_factorials = list([pow(n, MOD - 2, MOD) for n in factorials]) def modcomb(m, n, mod): r...
H, W, A, B = list(map(int, open(0).read().split())) MOD = 10**9 + 7 factorials = [1] * (H + W + 1) inv_factorials = [1] * (H + W + 1) for i in range(H + W): factorials[i + 1] = factorials[i] * (i + 1) % MOD for i in range(H + W): inv_factorials[i + 1] = inv_factorials[i] * pow(i + 1, MOD - 2, MOD) % MOD def m...
false
4
[ "-tmp = 1", "- tmp = tmp * (i + 1) % MOD", "- factorials[i + 1] = tmp", "-inv_factorials = list([pow(n, MOD - 2, MOD) for n in factorials])", "+ factorials[i + 1] = factorials[i] * (i + 1) % MOD", "+for i in range(H + W):", "+ inv_factorials[i + 1] = inv_factorials[i] * pow(i + 1, MOD - 2, M...
false
0.040502
0.041577
0.974146
[ "s539781020", "s811976266" ]
u935558307
p03716
python
s917352118
s468289416
671
291
120,080
125,988
Accepted
Accepted
56.63
import heapq N = int(eval(input())) A = list(map(int,input().split())) #前半部分の最適化辞書作成 SUM = sum(A[:N]) firstDic = {N-1:SUM} que = A[:N] heapq.heapify(que) for i in range(N,2*N): SUM += A[i] heapq.heappush(que,A[i]) SUM -= heapq.heappop(que) firstDic[i] = SUM #後半部分の最適化辞書作成 SUM = sum(A[...
N = int(eval(input())) A = list(map(int,input().split())) B = [] for i in range(3*N-1,-1,-1): B.append(A[i]*-1) """ 前半をできるだけおおきく、後半をできるだけ小さくする。 前半はpriority queにぶっこんでいって、最小値を除去していく """ import heapq frontSum = sum(A[:N]) frontQue = A[:N] heapq.heapify(frontQue) front = [frontSum] for i in range(N,2*N): ...
31
35
658
790
import heapq N = int(eval(input())) A = list(map(int, input().split())) # 前半部分の最適化辞書作成 SUM = sum(A[:N]) firstDic = {N - 1: SUM} que = A[:N] heapq.heapify(que) for i in range(N, 2 * N): SUM += A[i] heapq.heappush(que, A[i]) SUM -= heapq.heappop(que) firstDic[i] = SUM # 後半部分の最適化辞書作成 SUM = sum(A[2 * N :])...
N = int(eval(input())) A = list(map(int, input().split())) B = [] for i in range(3 * N - 1, -1, -1): B.append(A[i] * -1) """ 前半をできるだけおおきく、後半をできるだけ小さくする。 前半はpriority queにぶっこんでいって、最小値を除去していく """ import heapq frontSum = sum(A[:N]) frontQue = A[:N] heapq.heapify(frontQue) front = [frontSum] for i in range(N, 2 * N): ...
false
11.428571
[ "+N = int(eval(input()))", "+A = list(map(int, input().split()))", "+B = []", "+for i in range(3 * N - 1, -1, -1):", "+ B.append(A[i] * -1)", "+\"\"\"", "+前半をできるだけおおきく、後半をできるだけ小さくする。", "+前半はpriority queにぶっこんでいって、最小値を除去していく", "+\"\"\"", "-N = int(eval(input()))", "-A = list(map(int, input().sp...
false
0.044663
0.090408
0.494018
[ "s917352118", "s468289416" ]
u673361376
p03380
python
s704394686
s613426752
236
137
62,704
14,052
Accepted
Accepted
41.95
from operator import mul from functools import reduce import bisect def cmb(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1,r + 1))) return over // under N = int(eval(input())) A = sorted(list(map(int,input().split...
N = int(eval(input())) A = sorted(list(map(int, input().split()))) n = A[-1] r_val = -float('inf') r_row = None for idx in range(N - 1): if r_val < min(n - A[idx], A[idx]): r_val = min(n - A[idx], A[idx]) r_row = A[idx] print((n, r_row))
26
11
569
261
from operator import mul from functools import reduce import bisect def cmb(n, r): r = min(n - r, r) if r == 0: return 1 over = reduce(mul, list(range(n, n - r, -1))) under = reduce(mul, list(range(1, r + 1))) return over // under N = int(eval(input())) A = sorted(list(map(int, input().s...
N = int(eval(input())) A = sorted(list(map(int, input().split()))) n = A[-1] r_val = -float("inf") r_row = None for idx in range(N - 1): if r_val < min(n - A[idx], A[idx]): r_val = min(n - A[idx], A[idx]) r_row = A[idx] print((n, r_row))
false
57.692308
[ "-from operator import mul", "-from functools import reduce", "-import bisect", "-", "-", "-def cmb(n, r):", "- r = min(n - r, r)", "- if r == 0:", "- return 1", "- over = reduce(mul, list(range(n, n - r, -1)))", "- under = reduce(mul, list(range(1, r + 1)))", "- return o...
false
0.038397
0.038094
1.00795
[ "s704394686", "s613426752" ]
u579699847
p03993
python
s540750439
s532012152
228
202
29,596
23,464
Accepted
Accepted
11.4
import bisect,collections,copy,heapq,itertools,math,numpy,string import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N = I() a = LI() count = 0 a_dict = {} for i,x in enumerate(a,1): a_dict[i] = x for k,v in list(a_dict.items(...
import bisect,collections,copy,heapq,itertools,math,numpy,string import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N = I() a = LI() ans = 0 for i,x in enumerate(a,1): if x=='*': continue if a[x-1]==i: an...
14
14
380
361
import bisect, collections, copy, heapq, itertools, math, numpy, string import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) N = I() a = LI() count = 0 a_dict = {} for i, x in enumerate(a, 1): a_dict[i] = x for k, v in lis...
import bisect, collections, copy, heapq, itertools, math, numpy, string import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) N = I() a = LI() ans = 0 for i, x in enumerate(a, 1): if x == "*": continue if a[x - ...
false
0
[ "-count = 0", "-a_dict = {}", "+ans = 0", "- a_dict[i] = x", "-for k, v in list(a_dict.items()):", "- if k in [a_dict[v]]:", "- count += 1", "-print((count // 2))", "+ if x == \"*\":", "+ continue", "+ if a[x - 1] == i:", "+ ans += 1", "+ a[x - 1] = \"...
false
0.034524
0.034779
0.992676
[ "s540750439", "s532012152" ]
u707808519
p03854
python
s814675348
s228476961
86
71
3,188
3,236
Accepted
Accepted
17.44
S = eval(input()) divide = ["dream", "dreamer", "erase", "eraser"] S = S[::-1] divide = [divide[i][::-1] for i in range(4)] while len(S) > 0: for i in range(4): if S[:len(divide[i])] == divide[i]: flag = "YES" S = S[len(divide[i]):] break else: ...
S = eval(input()) buff = ['dream', 'dreamer', 'erase', 'eraser'] for i in range(4): buff[i] = buff[i][::-1] S = S[::-1] while len(S) > 0: if S[:7] == buff[1]: S = S[7:] elif S[:6] == buff[3]: S = S[6:] elif S[:5] == buff[0] or S[:5] == buff[2]: S = S[5:] else: ...
17
16
384
364
S = eval(input()) divide = ["dream", "dreamer", "erase", "eraser"] S = S[::-1] divide = [divide[i][::-1] for i in range(4)] while len(S) > 0: for i in range(4): if S[: len(divide[i])] == divide[i]: flag = "YES" S = S[len(divide[i]) :] break else: flag ...
S = eval(input()) buff = ["dream", "dreamer", "erase", "eraser"] for i in range(4): buff[i] = buff[i][::-1] S = S[::-1] while len(S) > 0: if S[:7] == buff[1]: S = S[7:] elif S[:6] == buff[3]: S = S[6:] elif S[:5] == buff[0] or S[:5] == buff[2]: S = S[5:] else: break i...
false
5.882353
[ "-divide = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "+buff = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]", "+for i in range(4):", "+ buff[i] = buff[i][::-1]", "-divide = [divide[i][::-1] for i in range(4)]", "- for i in range(4):", "- if S[: len(divide[i])] == divide[i]:", "-...
false
0.041757
0.044179
0.945195
[ "s814675348", "s228476961" ]
u753803401
p03565
python
s359584852
s856106269
166
17
38,384
3,192
Accepted
Accepted
89.76
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 s = str(readline().rstrip().decode('utf-8')) t = str(readline().rstrip().decode('utf-8')) k = len(t) for i in range(len(s) - k, -1, -1): ts = s[i:i+k] b = True for j in range(k): ...
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10 ** 9 + 7 s = str(readline().rstrip().decode('utf-8')) t = str(readline().rstrip().decode('utf-8')) lt = len(t) for i in range(len(s) - lt, -1, -1): ts = s[i:i+lt] b = True for j in range(l...
36
33
945
873
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 s = str(readline().rstrip().decode("utf-8")) t = str(readline().rstrip().decode("utf-8")) k = len(t) for i in range(len(s) - k, -1, -1): ts = s[i : i + k] b = True for j in range(k): ...
import sys def solve(): readline = sys.stdin.buffer.readline mod = 10**9 + 7 s = str(readline().rstrip().decode("utf-8")) t = str(readline().rstrip().decode("utf-8")) lt = len(t) for i in range(len(s) - lt, -1, -1): ts = s[i : i + lt] b = True for j in range(len(ts)): ...
false
8.333333
[ "- k = len(t)", "- for i in range(len(s) - k, -1, -1):", "- ts = s[i : i + k]", "+ lt = len(t)", "+ for i in range(len(s) - lt, -1, -1):", "+ ts = s[i : i + lt]", "- for j in range(k):", "+ for j in range(len(ts)):", "- a = []", "- f = ...
false
0.044397
0.043722
1.015446
[ "s359584852", "s856106269" ]
u487252913
p03108
python
s295638294
s048514460
712
655
62,600
15,768
Accepted
Accepted
8.01
import sys sys.setrecursionlimit(10 ** 7) class UnionFind: def __init__(self, size: int): self.parent = [-1 for _ in range(size)] self.size = [1 for _ in range(size)] def unite(self, x, y): px = self.find(x) py = self.find(y) if px != py: if se...
class UnionFind: def __init__(self, size: int): self.parent = [-1 for _ in range(size)] def unite(self, x, y): px = self.find(x) py = self.find(y) if px == py: return if self.size(px) > self.size(py): px, py = py, px self.parent...
59
55
1,666
1,433
import sys sys.setrecursionlimit(10**7) class UnionFind: def __init__(self, size: int): self.parent = [-1 for _ in range(size)] self.size = [1 for _ in range(size)] def unite(self, x, y): px = self.find(x) py = self.find(y) if px != py: if self.parent[px] ...
class UnionFind: def __init__(self, size: int): self.parent = [-1 for _ in range(size)] def unite(self, x, y): px = self.find(x) py = self.find(y) if px == py: return if self.size(px) > self.size(py): px, py = py, px self.parent[py] += sel...
false
6.779661
[ "-import sys", "-", "-sys.setrecursionlimit(10**7)", "-", "-", "- self.size = [1 for _ in range(size)]", "- if px != py:", "- if self.parent[px] > self.parent[py]:", "- self.parent[py] = px", "- self.parent[px] -= 1", "- self....
false
0.039998
0.0388
1.030886
[ "s295638294", "s048514460" ]
u922172470
p03448
python
s126200966
s116381067
43
17
3,064
3,060
Accepted
Accepted
60.47
def resolve(): A,B,C,X = [int(eval(input())) for i in range(4)] res = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): total = 500*a + 100*b + 50*c if total == X: res += 1 print(res) resolve()
def resolve(): A,B,C,X = [int(eval(input())) for i in range(4)] res = 0 mA = min(X//500, A) for i in range(mA+1): Y = X - 500 * i mB = min(Y//100, B) for j in range(mB+1): Z = Y - 100 * j if Z <= 50*C: res += 1 print(res)...
14
16
310
331
def resolve(): A, B, C, X = [int(eval(input())) for i in range(4)] res = 0 for a in range(A + 1): for b in range(B + 1): for c in range(C + 1): total = 500 * a + 100 * b + 50 * c if total == X: res += 1 print(res) resolve()
def resolve(): A, B, C, X = [int(eval(input())) for i in range(4)] res = 0 mA = min(X // 500, A) for i in range(mA + 1): Y = X - 500 * i mB = min(Y // 100, B) for j in range(mB + 1): Z = Y - 100 * j if Z <= 50 * C: res += 1 print(res) ...
false
12.5
[ "- for a in range(A + 1):", "- for b in range(B + 1):", "- for c in range(C + 1):", "- total = 500 * a + 100 * b + 50 * c", "- if total == X:", "- res += 1", "+ mA = min(X // 500, A)", "+ for i in range(mA + 1):", "+ ...
false
0.061363
0.036613
1.67599
[ "s126200966", "s116381067" ]
u595289165
p02629
python
s815030426
s024515678
32
29
9,216
9,092
Accepted
Accepted
9.38
def base_k(n, k=26): ret = [] ny = n while ny: ret.append(ny % k) ny //= k return ret[::-1] def letter(i): return chr(i+97) def solve(n): check = 26 cnt = 1 k = n while True: if n <= check: break check *= 26 ...
def answer(n): if n <= 26: return chr(n-1 + 97) r = n % 26 - 1 if r == -1: r += 26 return answer((n-r) // 26) + chr(r + 97) n = int(eval(input())) print((answer(n)))
41
11
669
201
def base_k(n, k=26): ret = [] ny = n while ny: ret.append(ny % k) ny //= k return ret[::-1] def letter(i): return chr(i + 97) def solve(n): check = 26 cnt = 1 k = n while True: if n <= check: break check *= 26 check += 26 ...
def answer(n): if n <= 26: return chr(n - 1 + 97) r = n % 26 - 1 if r == -1: r += 26 return answer((n - r) // 26) + chr(r + 97) n = int(eval(input())) print((answer(n)))
false
73.170732
[ "-def base_k(n, k=26):", "- ret = []", "- ny = n", "- while ny:", "- ret.append(ny % k)", "- ny //= k", "- return ret[::-1]", "-", "-", "-def letter(i):", "- return chr(i + 97)", "-", "-", "-def solve(n):", "- check = 26", "- cnt = 1", "- k = n",...
false
0.038125
0.090343
0.421997
[ "s815030426", "s024515678" ]
u609061751
p03033
python
s254876951
s854231952
1,499
1,227
129,784
112,348
Accepted
Accepted
18.15
import sys input = lambda : sys.stdin.readline().rstrip() def segfun(x, y): return min(x, y) ide_ele = float("inf") class SegmentTree: def __init__(self, n, ele, segfun): self.ide_ele = ele self.segfun = segfun self.n = n self.N0 = 1 << n.bit_length() sel...
import sys input = lambda : sys.stdin.readline().rstrip() def segfun(x, y): return min(x, y) ide_ele = 10**9 + 1 class SegmentTree: def __init__(self, n, ele, segfun): self.ide_ele = ele self.segfun = segfun self.n = n self.N0 = 1 << n.bit_length() self.d...
63
63
1,472
1,464
import sys input = lambda: sys.stdin.readline().rstrip() def segfun(x, y): return min(x, y) ide_ele = float("inf") class SegmentTree: def __init__(self, n, ele, segfun): self.ide_ele = ele self.segfun = segfun self.n = n self.N0 = 1 << n.bit_length() self.data = [s...
import sys input = lambda: sys.stdin.readline().rstrip() def segfun(x, y): return min(x, y) ide_ele = 10**9 + 1 class SegmentTree: def __init__(self, n, ele, segfun): self.ide_ele = ele self.segfun = segfun self.n = n self.N0 = 1 << n.bit_length() self.data = [self...
false
0
[ "-ide_ele = float(\"inf\")", "+ide_ele = 10**9 + 1", "- if res == float(\"inf\"):", "+ if res == ide_ele:" ]
false
0.050664
0.050425
1.004752
[ "s254876951", "s854231952" ]
u116038906
p02678
python
s738822544
s262303927
791
539
82,668
54,076
Accepted
Accepted
31.86
from collections import deque import sys input = sys.stdin.readline N,M = (int(x) for x in input().split()) connection ={i:set() for i in range(1,N+1)} #構造入力 for i in range(1,M+1): a,b = (int(x) for x in input().split()) connection[a].add(b) connection[b].add(a) #幅優先探索 dq =deque() dq.appen...
from collections import deque from copy import copy import sys input = sys.stdin.readline N,M = (int(x) for x in input().split()) connection ={i:[] for i in range(0,N+1)} connection[0] =[1] #connection[1] =[0] #構造入力 for i in range(M): a,b = (int(x) for x in input().split()) connection[a].append(b) ...
30
35
692
793
from collections import deque import sys input = sys.stdin.readline N, M = (int(x) for x in input().split()) connection = {i: set() for i in range(1, N + 1)} # 構造入力 for i in range(1, M + 1): a, b = (int(x) for x in input().split()) connection[a].add(b) connection[b].add(a) # 幅優先探索 dq = deque() dq.append(1)...
from collections import deque from copy import copy import sys input = sys.stdin.readline N, M = (int(x) for x in input().split()) connection = {i: [] for i in range(0, N + 1)} connection[0] = [1] # connection[1] =[0] # 構造入力 for i in range(M): a, b = (int(x) for x in input().split()) connection[a].append(b) ...
false
14.285714
[ "+from copy import copy", "-connection = {i: set() for i in range(1, N + 1)}", "+connection = {i: [] for i in range(0, N + 1)}", "+connection[0] = [1]", "+# connection[1] =[0]", "-for i in range(1, M + 1):", "+for i in range(M):", "- connection[a].add(b)", "- connection[b].add(a)", "+ con...
false
0.037134
0.037241
0.997124
[ "s738822544", "s262303927" ]
u816587940
p02713
python
s051144224
s050721066
241
125
68,528
67,764
Accepted
Accepted
48.13
k = int(eval(input())) def gcd(a, b): if a < b: a, b = b, a c = a % b if c == 0: return b while c!=0: c = a % b a, b = b, c return a ans = 0 for a in range(1, k+1): for b in range(1, k+1): t = gcd(a, b) if t == 1: ans += k ...
from math import gcd k = int(eval(input())) ans = 0 for a in range(1, k+1): for b in range(1, k+1): t = gcd(a, b) if t == 1: ans += k continue for c in range(1, k+1): ans += gcd(t, c) print(ans)
21
11
400
250
k = int(eval(input())) def gcd(a, b): if a < b: a, b = b, a c = a % b if c == 0: return b while c != 0: c = a % b a, b = b, c return a ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): t = gcd(a, b) if t == 1: ans += k ...
from math import gcd k = int(eval(input())) ans = 0 for a in range(1, k + 1): for b in range(1, k + 1): t = gcd(a, b) if t == 1: ans += k continue for c in range(1, k + 1): ans += gcd(t, c) print(ans)
false
47.619048
[ "+from math import gcd", "+", "-", "-", "-def gcd(a, b):", "- if a < b:", "- a, b = b, a", "- c = a % b", "- if c == 0:", "- return b", "- while c != 0:", "- c = a % b", "- a, b = b, c", "- return a", "-", "-" ]
false
0.118687
0.090338
1.313809
[ "s051144224", "s050721066" ]
u978313283
p03160
python
s937136917
s460568070
209
144
51,236
13,980
Accepted
Accepted
31.1
import sys INF=100000000 def frog(i,h,dp): global INF if dp[i]!=INF: return dp[i] else: if i==1: dp[i]=0 return dp[i] elif i==2: dp[i]=abs(h[1]-h[0]) return dp[i] else: dp[i]=min(frog(i-2,h,dp)+abs(h[i-...
INF=10**15 N=int(eval(input())) h=list(map(int,input().split())) dp=[INF for i in range(N)] dp[0]=0 for i in range(1,N): if i>1: dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])) else: dp[i]=dp[i-1]+abs(h[i]-h[i-1]) print((dp[N-1]))
21
11
521
269
import sys INF = 100000000 def frog(i, h, dp): global INF if dp[i] != INF: return dp[i] else: if i == 1: dp[i] = 0 return dp[i] elif i == 2: dp[i] = abs(h[1] - h[0]) return dp[i] else: dp[i] = min( ...
INF = 10**15 N = int(eval(input())) h = list(map(int, input().split())) dp = [INF for i in range(N)] dp[0] = 0 for i in range(1, N): if i > 1: dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])) else: dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]) print((dp[N - 1]))
false
47.619048
[ "-import sys", "-", "-INF = 100000000", "-", "-", "-def frog(i, h, dp):", "- global INF", "- if dp[i] != INF:", "- return dp[i]", "- else:", "- if i == 1:", "- dp[i] = 0", "- return dp[i]", "- elif i == 2:", "- dp[i] = abs(h[...
false
0.06012
0.041336
1.454426
[ "s937136917", "s460568070" ]
u017810624
p03152
python
s419901655
s105093027
777
716
12,404
3,188
Accepted
Accepted
7.85
n,m=list(map(int,input().split())) a=list(map(int,input().split())) b=list(map(int,input().split())) A=set(a);B=set(b) if len(A)!=len(a) or len(B)!=len(b): print((0)) else: L=[] for i in range(n): l=[] for j in range(m): l.append(0) L.append(l) ct=1;ctn=0;ctm=0 for k in range(m...
n,m=list(map(int,input().split())) a=list(map(int,input().split())) b=list(map(int,input().split())) A=set(a);B=set(b) if len(A)!=len(a) or len(B)!=len(b): print((0)) else: L=[] l=[0 for j in range(m)] for i in range(n): L.append(l) ct=1;ctn=0;ctm=0 for k in range(m*n,0,-1): if k in A a...
28
26
578
552
n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) A = set(a) B = set(b) if len(A) != len(a) or len(B) != len(b): print((0)) else: L = [] for i in range(n): l = [] for j in range(m): l.append(0) L.append(l) c...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) b = list(map(int, input().split())) A = set(a) B = set(b) if len(A) != len(a) or len(B) != len(b): print((0)) else: L = [] l = [0 for j in range(m)] for i in range(n): L.append(l) ct = 1 ctn = 0 ctm = 0 fo...
false
7.142857
[ "+ l = [0 for j in range(m)]", "- l = []", "- for j in range(m):", "- l.append(0)" ]
false
0.03991
0.047482
0.84052
[ "s419901655", "s105093027" ]
u441064181
p02701
python
s672999419
s521073361
137
121
38,396
38,468
Accepted
Accepted
11.68
#import bisect,collections,copy,heapq,itertools,math,numpy,string #from operator import itemgetter import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readl...
#import bisect,collections,copy,heapq,itertools,math,numpy,string #from operator import itemgetter import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readl...
15
14
461
440
# import bisect,collections,copy,heapq,itertools,math,numpy,string # from operator import itemgetter import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return...
# import bisect,collections,copy,heapq,itertools,math,numpy,string # from operator import itemgetter import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return...
false
6.666667
[ "- if s not in dict:", "- dict[s] = 1", "+ dict[s] = 1" ]
false
0.068402
0.048767
1.402626
[ "s672999419", "s521073361" ]
u059210959
p03377
python
s342559056
s411786859
156
39
13,124
10,820
Accepted
Accepted
75
# encoding:utf-8 import copy import numpy as np import random a,b,x = list(map(int,input().split())) if a<= x <= a+b: ans = True else: ans = False if ans: print("YES") else: print("NO")
#!/usr/bin/env python3 # encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import sys import collections from decimal import Decimal # 10進数で考慮できる mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.de...
17
23
216
471
# encoding:utf-8 import copy import numpy as np import random a, b, x = list(map(int, input().split())) if a <= x <= a + b: ans = True else: ans = False if ans: print("YES") else: print("NO")
#!/usr/bin/env python3 # encoding:utf-8 import copy import random import bisect # bisect_left これで二部探索の大小検索が行える import fractions # 最小公倍数などはこっち import math import sys import collections from decimal import Decimal # 10進数で考慮できる mod = 10**9 + 7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() ...
false
26.086957
[ "+#!/usr/bin/env python3", "-import numpy as np", "+import bisect # bisect_left これで二部探索の大小検索が行える", "+import fractions # 最小公倍数などはこっち", "+import math", "+import sys", "+import collections", "+from decimal import Decimal # 10進数で考慮できる", "-a, b, x = list(map(int, input().split()))", "-if a <= x <= a...
false
0.076095
0.045497
1.672546
[ "s342559056", "s411786859" ]
u186838327
p03695
python
s471432108
s934392177
163
18
38,256
3,064
Accepted
Accepted
88.96
n = int(eval(input())) l = list(map(int, input().split())) d = {} for i in range(n): if 1<=l[i]<=399: a = 0 elif 400<=l[i]<=799: a = 1 elif 800<=l[i]<=1199: a = 2 elif 1200<=l[i]<=1599: a = 3 elif 1600<=l[i]<=1999: a = 4 elif 2000<=l[i]<=2399: a = 5 elif 2400<=l[i]<...
n = int(eval(input())) A =list(map(int, input().split())) cnt = 0 B = [] for i in range(n): if 1 <= A[i] <= 399: B.append(0) elif 400 <= A[i] <= 799: B.append(1) elif 800 <= A[i] <= 1199: B.append(2) elif 1200 <= A[i] <= 1599: B.append(3) elif 1600 <= A[i...
34
29
640
675
n = int(eval(input())) l = list(map(int, input().split())) d = {} for i in range(n): if 1 <= l[i] <= 399: a = 0 elif 400 <= l[i] <= 799: a = 1 elif 800 <= l[i] <= 1199: a = 2 elif 1200 <= l[i] <= 1599: a = 3 elif 1600 <= l[i] <= 1999: a = 4 elif 2000 <= l[...
n = int(eval(input())) A = list(map(int, input().split())) cnt = 0 B = [] for i in range(n): if 1 <= A[i] <= 399: B.append(0) elif 400 <= A[i] <= 799: B.append(1) elif 800 <= A[i] <= 1199: B.append(2) elif 1200 <= A[i] <= 1599: B.append(3) elif 1600 <= A[i] <= 1999: ...
false
14.705882
[ "-l = list(map(int, input().split()))", "-d = {}", "+A = list(map(int, input().split()))", "+cnt = 0", "+B = []", "- if 1 <= l[i] <= 399:", "- a = 0", "- elif 400 <= l[i] <= 799:", "- a = 1", "- elif 800 <= l[i] <= 1199:", "- a = 2", "- elif 1200 <= l[i] <= 159...
false
0.08229
0.153426
0.536348
[ "s471432108", "s934392177" ]
u094191970
p03730
python
s379446548
s106693637
180
17
2,940
2,940
Accepted
Accepted
90.56
a,b,c=list(map(int,input().split())) for i in range(1,10**6): if (a*i)%b==c: print('YES') exit() print('NO')
a,b,c=list(map(int,input().split())) for i in range(1,b): if (i*a)%b==c: print('YES') exit() print('NO')
8
7
121
115
a, b, c = list(map(int, input().split())) for i in range(1, 10**6): if (a * i) % b == c: print("YES") exit() print("NO")
a, b, c = list(map(int, input().split())) for i in range(1, b): if (i * a) % b == c: print("YES") exit() print("NO")
false
12.5
[ "-for i in range(1, 10**6):", "- if (a * i) % b == c:", "+for i in range(1, b):", "+ if (i * a) % b == c:" ]
false
0.098002
0.042255
2.319315
[ "s379446548", "s106693637" ]
u970197315
p02762
python
s713218119
s526391499
1,622
972
63,988
37,944
Accepted
Accepted
40.07
# D - Friend Suggestions from collections import Counter N,M,K = list(map(int,input().split())) AB = [tuple(map(int,input().split())) for i in range(M)] CD = [tuple(map(int,input().split())) for i in range(K)] class UnionFind: def __init__(self,N): self.parent = [i for i in range(N)] self....
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) n, m, k = list(map(int, input().split())) class UnionFind: def __init__(self, n): self.p = [-1]*n # union by rank self.r = [1]*n def find(self, x): if self.p[x] < 0: return x el...
60
62
1,525
1,345
# D - Friend Suggestions from collections import Counter N, M, K = list(map(int, input().split())) AB = [tuple(map(int, input().split())) for i in range(M)] CD = [tuple(map(int, input().split())) for i in range(K)] class UnionFind: def __init__(self, N): self.parent = [i for i in range(N)] self.r...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) n, m, k = list(map(int, input().split())) class UnionFind: def __init__(self, n): self.p = [-1] * n # union by rank self.r = [1] * n def find(self, x): if self.p[x] < 0: return x else: ...
false
3.225806
[ "-# D - Friend Suggestions", "-from collections import Counter", "+import sys", "-N, M, K = list(map(int, input().split()))", "-AB = [tuple(map(int, input().split())) for i in range(M)]", "-CD = [tuple(map(int, input().split())) for i in range(K)]", "+input = sys.stdin.readline", "+sys.setrecursionlim...
false
0.039947
0.110907
0.360183
[ "s713218119", "s526391499" ]
u906428167
p02821
python
s466439957
s228028161
1,050
305
57,220
55,448
Accepted
Accepted
70.95
from bisect import bisect_left from bisect import bisect_right n,m = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) a_count = [0]*110000 a_sum = [0]*110000 for i in range(n): a_count[a[i]] += 1 a_sum[a[i]] += a[i] for i in range(100005,0,-1): a_count[i] ...
from bisect import bisect_left from bisect import bisect_right n,m = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) a_count = [0]*100010 a_sum = [0]*100010 for i in range(n): a_count[a[i]] += 1 a_sum[a[i]] += a[i] for i in range(100005,-1,-1): a_count[i]...
53
55
855
930
from bisect import bisect_left from bisect import bisect_right n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) a_count = [0] * 110000 a_sum = [0] * 110000 for i in range(n): a_count[a[i]] += 1 a_sum[a[i]] += a[i] for i in range(100005, 0, -1): a_count[i] += a_count[...
from bisect import bisect_left from bisect import bisect_right n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = sorted(a) a_count = [0] * 100010 a_sum = [0] * 100010 for i in range(n): a_count[a[i]] += 1 a_sum[a[i]] += a[i] for i in range(100005, -1, -1): a_count[i] += a_count...
false
3.636364
[ "-a_count = [0] * 110000", "-a_sum = [0] * 110000", "+a_count = [0] * 100010", "+a_sum = [0] * 100010", "-for i in range(100005, 0, -1):", "+for i in range(100005, -1, -1):", "- case += n - bisect_right(a, x - a[i] - 1)", "+ if 0 <= x - a[i] <= 10**5 + 5:", "+ case += a_coun...
false
0.099495
0.092737
1.072877
[ "s466439957", "s228028161" ]
u811733736
p02271
python
s445190921
s804921818
6,150
830
7,756
135,424
Accepted
Accepted
86.5
from itertools import combinations if __name__ == '__main__': # ??????????????\??? num1 = int(eval(input())) A = [int(x) for x in input().split(' ')] num2 = int(eval(input())) M = [int(x) for x in input().split(' ')] #A = [1, 5, 7, 10, 21] #pick = 4 #M = [2, 4, 17, 8] #...
from functools import lru_cache @lru_cache(maxsize=None) def is_possible(n, target, total): if n == 0: return total == target return is_possible(n-1, target, total) or is_possible(n-1, target, total + A[n-1]) n = int(eval(input())) A = [int(i) for i in input().split()] _ = int(eval(input()...
27
17
935
415
from itertools import combinations if __name__ == "__main__": # ??????????????\??? num1 = int(eval(input())) A = [int(x) for x in input().split(" ")] num2 = int(eval(input())) M = [int(x) for x in input().split(" ")] # A = [1, 5, 7, 10, 21] # pick = 4 # M = [2, 4, 17, 8] # ?????????...
from functools import lru_cache @lru_cache(maxsize=None) def is_possible(n, target, total): if n == 0: return total == target return is_possible(n - 1, target, total) or is_possible( n - 1, target, total + A[n - 1] ) n = int(eval(input())) A = [int(i) for i in input().split()] _ = int(ev...
false
37.037037
[ "-from itertools import combinations", "+from functools import lru_cache", "-if __name__ == \"__main__\":", "- # ??????????????\\???", "- num1 = int(eval(input()))", "- A = [int(x) for x in input().split(\" \")]", "- num2 = int(eval(input()))", "- M = [int(x) for x in input().split(\" \...
false
0.036723
0.036594
1.003527
[ "s445190921", "s804921818" ]
u910288980
p03416
python
s828545791
s091411646
104
53
2,940
2,940
Accepted
Accepted
49.04
a, b = list(map(int, input().split())) ans = 0 for x in range(a,b+1): s = str(x) if s == ''.join(reversed(s)): ans += 1 print(ans)
a, b = list(map(int, input().split())) ans = 0 for x in range(a,b+1): s = str(x) # if s == ''.join(reversed(s)): if s == s[::-1] : ans += 1 print(ans)
9
10
151
176
a, b = list(map(int, input().split())) ans = 0 for x in range(a, b + 1): s = str(x) if s == "".join(reversed(s)): ans += 1 print(ans)
a, b = list(map(int, input().split())) ans = 0 for x in range(a, b + 1): s = str(x) # if s == ''.join(reversed(s)): if s == s[::-1]: ans += 1 print(ans)
false
10
[ "- if s == \"\".join(reversed(s)):", "+ # if s == ''.join(reversed(s)):", "+ if s == s[::-1]:" ]
false
0.050231
0.04443
1.130563
[ "s828545791", "s091411646" ]
u698868214
p02898
python
s790087177
s024333140
63
58
18,532
18,652
Accepted
Accepted
7.94
N,K = list(map(int,input().split())) h = list(map(int,input().split())) h = sorted(h) line = 0 bool1 = False for i in range(N): if h[i] >= K: line = i bool1 = True break if bool1: print((N-i)) else: print((0))
N,K = list(map(int,input().split())) h = list(map(int,input().split())) ans = 0 for i in h: if i >= K: ans += 1 print(ans)
16
8
234
130
N, K = list(map(int, input().split())) h = list(map(int, input().split())) h = sorted(h) line = 0 bool1 = False for i in range(N): if h[i] >= K: line = i bool1 = True break if bool1: print((N - i)) else: print((0))
N, K = list(map(int, input().split())) h = list(map(int, input().split())) ans = 0 for i in h: if i >= K: ans += 1 print(ans)
false
50
[ "-h = sorted(h)", "-line = 0", "-bool1 = False", "-for i in range(N):", "- if h[i] >= K:", "- line = i", "- bool1 = True", "- break", "-if bool1:", "- print((N - i))", "-else:", "- print((0))", "+ans = 0", "+for i in h:", "+ if i >= K:", "+ ans +...
false
0.048011
0.044964
1.067773
[ "s790087177", "s024333140" ]
u401452016
p02936
python
s227915521
s991455134
1,897
1,660
351,060
328,172
Accepted
Accepted
12.49
import sys sys.setrecursionlimit(1000000) L = sys.stdin.readlines() for i in range(len(L)): L[i] = list(map(int, L[i].split())) n =L[0][0] rin = [[] for _ in range(n)] for v in L[1:n]: rin[v[0]-1].append(v[1]-1) rin[v[1]-1].append(v[0]-1) score = [0 for _ in range(n)] for ele in L[n:]: ...
#ABC138D #node:節 edge:枝 def main(): import sys sys.setrecursionlimit(200005) N, Q = list(map(int, sys.stdin.readline().split())) edge = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N-1)] #1:ノードのリストを作る nodeL = [[] for _ in range(N)] for a, b in edge: nodeL[a...
26
35
533
834
import sys sys.setrecursionlimit(1000000) L = sys.stdin.readlines() for i in range(len(L)): L[i] = list(map(int, L[i].split())) n = L[0][0] rin = [[] for _ in range(n)] for v in L[1:n]: rin[v[0] - 1].append(v[1] - 1) rin[v[1] - 1].append(v[0] - 1) score = [0 for _ in range(n)] for ele in L[n:]: score[e...
# ABC138D # node:節 edge:枝 def main(): import sys sys.setrecursionlimit(200005) N, Q = list(map(int, sys.stdin.readline().split())) edge = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N - 1)] # 1:ノードのリストを作る nodeL = [[] for _ in range(N)] for a, b in edge: nodeL[a - 1...
false
25.714286
[ "-import sys", "+# ABC138D", "+# node:節 edge:枝", "+def main():", "+ import sys", "-sys.setrecursionlimit(1000000)", "-L = sys.stdin.readlines()", "-for i in range(len(L)):", "- L[i] = list(map(int, L[i].split()))", "-n = L[0][0]", "-rin = [[] for _ in range(n)]", "-for v in L[1:n]:", "...
false
0.040481
0.040663
0.995509
[ "s227915521", "s991455134" ]
u102242691
p03658
python
s615073701
s316258470
20
17
2,940
2,940
Accepted
Accepted
15
N,K = list(map(int,input().split())) l = list(map(int,input().split())) k = sorted(l) ans = 0 for i in range(K): ans += k.pop() print(ans)
n,k = list(map(int,input().split())) l = list(map(int,input().split())) l.sort(reverse = True) ans = 0 for i in range(k): ans += l[i] print(ans)
12
9
153
153
N, K = list(map(int, input().split())) l = list(map(int, input().split())) k = sorted(l) ans = 0 for i in range(K): ans += k.pop() print(ans)
n, k = list(map(int, input().split())) l = list(map(int, input().split())) l.sort(reverse=True) ans = 0 for i in range(k): ans += l[i] print(ans)
false
25
[ "-N, K = list(map(int, input().split()))", "+n, k = list(map(int, input().split()))", "-k = sorted(l)", "+l.sort(reverse=True)", "-for i in range(K):", "- ans += k.pop()", "+for i in range(k):", "+ ans += l[i]" ]
false
0.0468
0.044821
1.044139
[ "s615073701", "s316258470" ]
u229973939
p02388
python
s636003275
s963204137
20
10
5,576
5,576
Accepted
Accepted
50
x = eval(input()) print((int(x) ** 3))
x = int(eval(input())) print((x*x*x))
3
3
34
33
x = eval(input()) print((int(x) ** 3))
x = int(eval(input())) print((x * x * x))
false
0
[ "-x = eval(input())", "-print((int(x) ** 3))", "+x = int(eval(input()))", "+print((x * x * x))" ]
false
0.039025
0.074343
0.524936
[ "s636003275", "s963204137" ]
u425762225
p03971
python
s011244473
s826927679
407
69
4,000
9,780
Accepted
Accepted
83.05
N, A, B = list(map(int,input().split())) S = eval(input()) a_counter = 0 b_counter = 0 for i in range(N): s = S[0] if s == "a" and a_counter + b_counter <A+B: a_counter += 1 print("Yes") elif s == "b" and b_counter < B and a_counter + b_counter <A+B: b_counter += 1 print("Yes") e...
#!/usr/bin/env python3 # from numba import njit # from collections import Counter # from itertools import accumulate # import numpy as np # from heapq import heappop,heappush # from bisect import bisect_left # @njit def solve(n,a,b,s): ans = [""]*n japaneseStudents = 0 foreignStudents = 0 for ...
18
38
346
825
N, A, B = list(map(int, input().split())) S = eval(input()) a_counter = 0 b_counter = 0 for i in range(N): s = S[0] if s == "a" and a_counter + b_counter < A + B: a_counter += 1 print("Yes") elif s == "b" and b_counter < B and a_counter + b_counter < A + B: b_counter += 1 pri...
#!/usr/bin/env python3 # from numba import njit # from collections import Counter # from itertools import accumulate # import numpy as np # from heapq import heappop,heappush # from bisect import bisect_left # @njit def solve(n, a, b, s): ans = [""] * n japaneseStudents = 0 foreignStudents = 0 for i in ...
false
52.631579
[ "-N, A, B = list(map(int, input().split()))", "-S = eval(input())", "-a_counter = 0", "-b_counter = 0", "-for i in range(N):", "- s = S[0]", "- if s == \"a\" and a_counter + b_counter < A + B:", "- a_counter += 1", "- print(\"Yes\")", "- elif s == \"b\" and b_counter < B and...
false
0.11444
0.036171
3.163887
[ "s011244473", "s826927679" ]
u761529120
p02949
python
s963096695
s873243156
1,635
717
54,748
48,876
Accepted
Accepted
56.15
from collections import deque import sys input = sys.stdin.readline def main(): N, M, P = list(map(int, input().split())) edge = [[] for _ in range(N)] redge = [[] for _ in range(N)] for _ in range(M): A, B, C = list(map(int, input().split())) A -= 1 B -= 1 ...
from collections import deque import sys input = sys.stdin.readline def main(): N, M, P = list(map(int, input().split())) edge = [] g = [[] for _ in range(N)] rg = [[] for _ in range(N)] for _ in range(M): A, B, C = list(map(int, input().split())) A -= 1 B -= 1...
70
73
1,668
1,626
from collections import deque import sys input = sys.stdin.readline def main(): N, M, P = list(map(int, input().split())) edge = [[] for _ in range(N)] redge = [[] for _ in range(N)] for _ in range(M): A, B, C = list(map(int, input().split())) A -= 1 B -= 1 C -= P ...
from collections import deque import sys input = sys.stdin.readline def main(): N, M, P = list(map(int, input().split())) edge = [] g = [[] for _ in range(N)] rg = [[] for _ in range(N)] for _ in range(M): A, B, C = list(map(int, input().split())) A -= 1 B -= 1 C -...
false
4.109589
[ "- edge = [[] for _ in range(N)]", "- redge = [[] for _ in range(N)]", "+ edge = []", "+ g = [[] for _ in range(N)]", "+ rg = [[] for _ in range(N)]", "- edge[A].append((B, C))", "- redge[B].append(A)", "+ edge.append((A, B, C))", "+ g[A].append(B)", "+ ...
false
0.081132
0.099846
0.812568
[ "s963096695", "s873243156" ]
u633068244
p01225
python
s787475387
s286757113
20
10
4,280
4,276
Accepted
Accepted
50
def rm_123(A): if len(A) == 0: return 1 for a in set(A): if set([a,a+1,a+2]) <= set(A): if len(A) == 3: return 1 A1 = A[:] for i in range(3): A1.remove(a+i) return judge(A1) def rm_111(A): if len(A) == 0: return 1 for a in set(A): if A.count(a) >= 3: if len(A) == 3: return 1 A1 ...
def rm_123(A): if len(A) == 0: return 1 for a in set(A): if set([a,a+1,a+2]) <= set(A): A1 = A[:] for i in range(3): A1.remove(a+i) return judge(A1) def rm_111(A): if len(A) == 0: return 1 for a in set(A): if A.count(a) >= 3: A1 = A[:] for i in range(3): A1.remove(a) return judg...
31
29
739
681
def rm_123(A): if len(A) == 0: return 1 for a in set(A): if set([a, a + 1, a + 2]) <= set(A): if len(A) == 3: return 1 A1 = A[:] for i in range(3): A1.remove(a + i) return judge(A1) def rm_111(A): if len(A) == ...
def rm_123(A): if len(A) == 0: return 1 for a in set(A): if set([a, a + 1, a + 2]) <= set(A): A1 = A[:] for i in range(3): A1.remove(a + i) return judge(A1) def rm_111(A): if len(A) == 0: return 1 for a in set(A): if A...
false
6.451613
[ "- if len(A) == 3:", "- return 1", "- if len(A) == 3:", "- return 1" ]
false
0.036398
0.042036
0.865881
[ "s787475387", "s286757113" ]
u347184682
p02947
python
s732045366
s024886464
461
288
44,800
28,048
Accepted
Accepted
37.53
n=int(eval(input())) ans=0 s=[[x for x in eval(input())] for i in range(n)] dic={} for i in s: temp=tuple(sorted(i)) if temp in dic: ans+=dic[temp] dic[temp]+=1 else: dic[temp]=1 print(ans)
import collections ans=0 dic={} n=int(eval(input())) for i in range(n): s=eval(input()) sl=[i for i in s] sl.sort() ss=tuple(sl) if ss not in dic: dic[ss]=1 else: ans+=dic[ss] dic[ss]+=1 print(ans)
13
18
208
229
n = int(eval(input())) ans = 0 s = [[x for x in eval(input())] for i in range(n)] dic = {} for i in s: temp = tuple(sorted(i)) if temp in dic: ans += dic[temp] dic[temp] += 1 else: dic[temp] = 1 print(ans)
import collections ans = 0 dic = {} n = int(eval(input())) for i in range(n): s = eval(input()) sl = [i for i in s] sl.sort() ss = tuple(sl) if ss not in dic: dic[ss] = 1 else: ans += dic[ss] dic[ss] += 1 print(ans)
false
27.777778
[ "+import collections", "+", "+ans = 0", "+dic = {}", "-ans = 0", "-s = [[x for x in eval(input())] for i in range(n)]", "-dic = {}", "-for i in s:", "- temp = tuple(sorted(i))", "- if temp in dic:", "- ans += dic[temp]", "- dic[temp] += 1", "+for i in range(n):", "+ ...
false
0.07756
0.04317
1.796627
[ "s732045366", "s024886464" ]
u347640436
p03295
python
s479933886
s901028856
1,059
310
32,272
23,368
Accepted
Accepted
70.73
# Segment tree class SegmentTree(): _data = [] _offset = 0 _size = 0 def __init__(self, size): _size = size t = 1 while t < size: t *= 2 self._offset = t - 1 self._data = [0 for _ in range(t * 2 - 1)] def update(self, index, value):...
N, M = list(map(int, input().split())) ab = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, input().split())) ab[a].append(b) dp = [0] * (N + 1) for i in range(1, N + 1): dp[i] = max(dp[i], dp[i - 1]) for j in ab[i]: dp[j] = max(dp[j], dp[i] + 1) print((dp[N]))...
49
14
1,207
307
# Segment tree class SegmentTree: _data = [] _offset = 0 _size = 0 def __init__(self, size): _size = size t = 1 while t < size: t *= 2 self._offset = t - 1 self._data = [0 for _ in range(t * 2 - 1)] def update(self, index, value): i = sel...
N, M = list(map(int, input().split())) ab = [[] for _ in range(N + 1)] for _ in range(M): a, b = list(map(int, input().split())) ab[a].append(b) dp = [0] * (N + 1) for i in range(1, N + 1): dp[i] = max(dp[i], dp[i - 1]) for j in ab[i]: dp[j] = max(dp[j], dp[i] + 1) print((dp[N]))
false
71.428571
[ "-# Segment tree", "-class SegmentTree:", "- _data = []", "- _offset = 0", "- _size = 0", "-", "- def __init__(self, size):", "- _size = size", "- t = 1", "- while t < size:", "- t *= 2", "- self._offset = t - 1", "- self._data = [0 f...
false
0.085413
0.119762
0.713188
[ "s479933886", "s901028856" ]
u182765930
p02909
python
s148687581
s751990326
20
17
2,940
2,940
Accepted
Accepted
15
l=["Sunny","Cloudy","Rainy"] print((l[(l.index(eval(input()))+1)%3]))
l=["Rainy","Cloudy","Sunny"] print((l[l.index(eval(input()))-1]))
2
2
63
58
l = ["Sunny", "Cloudy", "Rainy"] print((l[(l.index(eval(input())) + 1) % 3]))
l = ["Rainy", "Cloudy", "Sunny"] print((l[l.index(eval(input())) - 1]))
false
0
[ "-l = [\"Sunny\", \"Cloudy\", \"Rainy\"]", "-print((l[(l.index(eval(input())) + 1) % 3]))", "+l = [\"Rainy\", \"Cloudy\", \"Sunny\"]", "+print((l[l.index(eval(input())) - 1]))" ]
false
0.041914
0.040708
1.029623
[ "s148687581", "s751990326" ]
u743164083
p03106
python
s803555823
s496907768
28
25
8,968
8,992
Accepted
Accepted
10.71
def com_div(x, y): dv = [] m = min(x, y) for i in range(1, m + 1): if x % i == 0 and y % i == 0: dv.append(i) dv.sort() return dv[::-1] a, b, k = list(map(int, input().split())) print((com_div(a, b)[k - 1]))
def com_div(x, y): dv = [] for i in range(min(x, y), 0, -1): if x % i == 0 and y % i == 0: dv.append(i) return dv a, b, k = list(map(int, input().split())) print((com_div(a, b)[k - 1]))
12
10
258
227
def com_div(x, y): dv = [] m = min(x, y) for i in range(1, m + 1): if x % i == 0 and y % i == 0: dv.append(i) dv.sort() return dv[::-1] a, b, k = list(map(int, input().split())) print((com_div(a, b)[k - 1]))
def com_div(x, y): dv = [] for i in range(min(x, y), 0, -1): if x % i == 0 and y % i == 0: dv.append(i) return dv a, b, k = list(map(int, input().split())) print((com_div(a, b)[k - 1]))
false
16.666667
[ "- m = min(x, y)", "- for i in range(1, m + 1):", "+ for i in range(min(x, y), 0, -1):", "- dv.sort()", "- return dv[::-1]", "+ return dv" ]
false
0.047383
0.04742
0.999218
[ "s803555823", "s496907768" ]
u784022244
p02897
python
s930165673
s028661612
19
17
2,940
2,940
Accepted
Accepted
10.53
N=int(eval(input())) if N%2==0: print(((N/2)/N)) else: print(((N//2+1)/N))
N=int(eval(input())) if N%2==0: print((0.5)) else: print(((N//2+1)/N))
7
6
78
70
N = int(eval(input())) if N % 2 == 0: print(((N / 2) / N)) else: print(((N // 2 + 1) / N))
N = int(eval(input())) if N % 2 == 0: print((0.5)) else: print(((N // 2 + 1) / N))
false
14.285714
[ "- print(((N / 2) / N))", "+ print((0.5))" ]
false
0.042899
0.04592
0.934214
[ "s930165673", "s028661612" ]
u309977459
p03682
python
s845983461
s153301268
1,798
1,137
122,968
54,488
Accepted
Accepted
36.76
from operator import itemgetter import heapq N = int(eval(input())) X = [] Y = [] for i in range(N): x, y = list(map(int, input().split())) X.append((x, i)) Y.append((y, i)) X.sort(key=itemgetter(0)) Y.sort(key=itemgetter(0)) G = [[] for _ in range(N)] for i in range(N-1): G[X[i][1]].append...
from operator import itemgetter import heapq N = int(eval(input())) X = [] Y = [] for i in range(N): x, y = list(map(int, input().split())) X.append((x, i)) Y.append((y, i)) X.sort(key=itemgetter(0)) Y.sort(key=itemgetter(0)) import sys sys.setrecursionlimit(10**6) class UnionFind(object)...
34
53
830
1,277
from operator import itemgetter import heapq N = int(eval(input())) X = [] Y = [] for i in range(N): x, y = list(map(int, input().split())) X.append((x, i)) Y.append((y, i)) X.sort(key=itemgetter(0)) Y.sort(key=itemgetter(0)) G = [[] for _ in range(N)] for i in range(N - 1): G[X[i][1]].append((X[i + 1]...
from operator import itemgetter import heapq N = int(eval(input())) X = [] Y = [] for i in range(N): x, y = list(map(int, input().split())) X.append((x, i)) Y.append((y, i)) X.sort(key=itemgetter(0)) Y.sort(key=itemgetter(0)) import sys sys.setrecursionlimit(10**6) class UnionFind(object): def __ini...
false
35.849057
[ "-G = [[] for _ in range(N)]", "+import sys", "+", "+sys.setrecursionlimit(10**6)", "+", "+", "+class UnionFind(object):", "+ def __init__(self, size):", "+ self.table = [-1 for _ in range(size)]", "+", "+ def find(self, x):", "+ if self.table[x] < 0:", "+ retu...
false
0.170722
0.088064
1.938624
[ "s845983461", "s153301268" ]
u606878291
p03208
python
s500959832
s148271409
233
214
11,628
8,280
Accepted
Accepted
8.15
N, K = list(map(int, input().split(' '))) heights = sorted([int(eval(input())) for _ in range(N)]) print((min([_max - _min for _min, _max in zip(heights, heights[K - 1:])])))
N, K = list(map(int, input().split(' '))) heights = sorted([int(eval(input())) for _ in range(N)]) print((min((_max - _min for _min, _max in zip(heights, heights[K - 1:])))))
3
3
163
163
N, K = list(map(int, input().split(" "))) heights = sorted([int(eval(input())) for _ in range(N)]) print((min([_max - _min for _min, _max in zip(heights, heights[K - 1 :])])))
N, K = list(map(int, input().split(" "))) heights = sorted([int(eval(input())) for _ in range(N)]) print((min((_max - _min for _min, _max in zip(heights, heights[K - 1 :])))))
false
0
[ "-print((min([_max - _min for _min, _max in zip(heights, heights[K - 1 :])])))", "+print((min((_max - _min for _min, _max in zip(heights, heights[K - 1 :])))))" ]
false
0.046896
0.040987
1.144174
[ "s500959832", "s148271409" ]
u333945892
p02845
python
s039444088
s283610645
97
76
15,412
15,164
Accepted
Accepted
21.65
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,copy,time sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return ...
c = [0]*(int(eval(input()))+1) c[-1] = 3 ans = 1 for a in list(map(int, input().split())): ans = (ans * (c[a-1] - c[a]))%(10**9+7) c[a] += 1 print(ans)
25
7
524
160
from collections import defaultdict, deque import sys, heapq, bisect, math, itertools, string, queue, copy, time sys.setrecursionlimit(10**8) INF = float("inf") mod = 10**9 + 7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inp...
c = [0] * (int(eval(input())) + 1) c[-1] = 3 ans = 1 for a in list(map(int, input().split())): ans = (ans * (c[a - 1] - c[a])) % (10**9 + 7) c[a] += 1 print(ans)
false
72
[ "-from collections import defaultdict, deque", "-import sys, heapq, bisect, math, itertools, string, queue, copy, time", "-", "-sys.setrecursionlimit(10**8)", "-INF = float(\"inf\")", "-mod = 10**9 + 7", "-eps = 10**-7", "-", "-", "-def inp():", "- return int(sys.stdin.readline())", "-", ...
false
0.095322
0.120956
0.788072
[ "s039444088", "s283610645" ]
u509739538
p02708
python
s659151314
s719878584
162
140
9,648
9,188
Accepted
Accepted
13.58
import math import queue def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChars(): return input().split() x = readInts() n = x[0] k = x[1] def ts(l): return int((l*(l-1))/2) def ts2(l): return int(l*(n+n-(l-1))/2) s = 0 for i...
x=list(map(int,input().split())) n,k=x s=0 for i in range(k,n+2): s+=int(i*(n+n-(i-1))/2)+1-int((i*(i-1))/2) print((s%(1000000007)))
28
6
378
136
import math import queue def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChars(): return input().split() x = readInts() n = x[0] k = x[1] def ts(l): return int((l * (l - 1)) / 2) def ts2(l): return int(l * (n + n - (l - 1)) / 2) s...
x = list(map(int, input().split())) n, k = x s = 0 for i in range(k, n + 2): s += int(i * (n + n - (i - 1)) / 2) + 1 - int((i * (i - 1)) / 2) print((s % (1000000007)))
false
78.571429
[ "-import math", "-import queue", "-", "-", "-def readInt():", "- return int(eval(input()))", "-", "-", "-def readInts():", "- return list(map(int, input().split()))", "-", "-", "-def readChars():", "- return input().split()", "-", "-", "-x = readInts()", "-n = x[0]", "-k...
false
0.071888
0.062141
1.156843
[ "s659151314", "s719878584" ]
u761529120
p03286
python
s895046572
s508938357
165
64
38,256
61,864
Accepted
Accepted
61.21
def main(): N = int(eval(input())) ans = '' while N != 0: if N % 2 != 0: N -= 1 ans = '1' + ans else: ans = "0" + ans N = N // (-2) if ans == "": ans = "0" print(ans) main()
def main(): N = int(eval(input())) if N == 0: print((0)) ans = '' base = 1 while N != 0: if N % (base * -2) == 0: ans += '0' else: ans += "1" N -= base base *= -2 ans = list(ans) ans.reverse() print((''.jo...
19
19
294
361
def main(): N = int(eval(input())) ans = "" while N != 0: if N % 2 != 0: N -= 1 ans = "1" + ans else: ans = "0" + ans N = N // (-2) if ans == "": ans = "0" print(ans) main()
def main(): N = int(eval(input())) if N == 0: print((0)) ans = "" base = 1 while N != 0: if N % (base * -2) == 0: ans += "0" else: ans += "1" N -= base base *= -2 ans = list(ans) ans.reverse() print(("".join(ans))) if ...
false
0
[ "+ if N == 0:", "+ print((0))", "+ base = 1", "- if N % 2 != 0:", "- N -= 1", "- ans = \"1\" + ans", "+ if N % (base * -2) == 0:", "+ ans += \"0\"", "- ans = \"0\" + ans", "- N = N // (-2)", "- if ans == \"\":", "...
false
0.058838
0.037227
1.580516
[ "s895046572", "s508938357" ]
u072717685
p02819
python
s557886135
s066756729
98
71
86,600
62,744
Accepted
Accepted
27.55
from bisect import bisect def main(): maxa2 = 200000 maxa2 = max(6, maxa2) # maxa2が6未満だとエラーになる p = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)] p[0] = p[1] = False p[2] = p[3] = p[5] = True for is1 in range(3, maxa2, 2): for is2 in range(is1 ...
from math import sqrt, ceil def main(): x = int(eval(input())) while True: for i1 in range(2, ceil(sqrt(x))): if x % i1 == 0: x += 1 break else: break print(x) if __name__ == '__main__': main()
22
14
620
290
from bisect import bisect def main(): maxa2 = 200000 maxa2 = max(6, maxa2) # maxa2が6未満だとエラーになる p = [ False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2) ] p[0] = p[1] = False p[2] = p[3] = p[5] = True for is1 in range(3, maxa2, 2): for is2 in ra...
from math import sqrt, ceil def main(): x = int(eval(input())) while True: for i1 in range(2, ceil(sqrt(x))): if x % i1 == 0: x += 1 break else: break print(x) if __name__ == "__main__": main()
false
36.363636
[ "-from bisect import bisect", "+from math import sqrt, ceil", "- maxa2 = 200000", "- maxa2 = max(6, maxa2) # maxa2が6未満だとエラーになる", "- p = [", "- False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(maxa2)", "- ]", "- p[0] = p[1] = False", "- p[2] = p[3] = ...
false
0.651809
0.039674
16.429013
[ "s557886135", "s066756729" ]
u326609687
p03108
python
s596927420
s824053492
598
423
23,252
23,224
Accepted
Accepted
29.26
N, M = list(map(int, input().split())) ab = [tuple([int(x)-1 for x in input().split()]) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1 for _ in range(size)] self.number = [1 for _ in range(size)] def find(self, x): while self.rank[x] >= 0: ...
import sys N, M = list(map(int, input().split())) ab = [tuple([int(x)-1 for x in sys.stdin.readline().split()]) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1 for _ in range(size)] self.number = [1 for _ in range(size)] def find(self, x): wh...
46
48
1,161
1,188
N, M = list(map(int, input().split())) ab = [tuple([int(x) - 1 for x in input().split()]) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1 for _ in range(size)] self.number = [1 for _ in range(size)] def find(self, x): while self.rank[x] >= 0: ...
import sys N, M = list(map(int, input().split())) ab = [tuple([int(x) - 1 for x in sys.stdin.readline().split()]) for _ in range(M)] class UnionFind: def __init__(self, size): self.rank = [-1 for _ in range(size)] self.number = [1 for _ in range(size)] def find(self, x): while self.r...
false
4.166667
[ "+import sys", "+", "-ab = [tuple([int(x) - 1 for x in input().split()]) for _ in range(M)]", "+ab = [tuple([int(x) - 1 for x in sys.stdin.readline().split()]) for _ in range(M)]" ]
false
0.079896
0.03372
2.369378
[ "s596927420", "s824053492" ]
u532966492
p03766
python
s241458769
s374508116
742
490
2,940
10,740
Accepted
Accepted
33.96
n=int(eval(input()));a,b,c,p=1,1,n,n-1 for i in range(n-1): p+=a-1;a,b,c=b,c,((n-1)**2+p+c)%(10**9+7) print(c)
n=int(eval(input()))-1;a,b,c,p=1,1,n+1,n for _ in[0]*n:p+=a-1;a,b,c=b,c,(n*n+p+c)%(10**9+7) print(c)
4
3
108
96
n = int(eval(input())) a, b, c, p = 1, 1, n, n - 1 for i in range(n - 1): p += a - 1 a, b, c = b, c, ((n - 1) ** 2 + p + c) % (10**9 + 7) print(c)
n = int(eval(input())) - 1 a, b, c, p = 1, 1, n + 1, n for _ in [0] * n: p += a - 1 a, b, c = b, c, (n * n + p + c) % (10**9 + 7) print(c)
false
25
[ "-n = int(eval(input()))", "-a, b, c, p = 1, 1, n, n - 1", "-for i in range(n - 1):", "+n = int(eval(input())) - 1", "+a, b, c, p = 1, 1, n + 1, n", "+for _ in [0] * n:", "- a, b, c = b, c, ((n - 1) ** 2 + p + c) % (10**9 + 7)", "+ a, b, c = b, c, (n * n + p + c) % (10**9 + 7)" ]
false
0.182729
0.139388
1.310933
[ "s241458769", "s374508116" ]
u711693740
p02733
python
s312762237
s383524023
417
360
3,188
3,188
Accepted
Accepted
13.67
from itertools import product H, W, K = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] S_T = [[int(s[w]) for s in S] for w in range(W)] sumS = sum(map(sum, S_T)) ans = (H - 1) * (W - 1) if sumS <= K: print((0)) else: for i in product([True, False], repeat=H-1): cnt =...
def main(): from itertools import product H, W, K = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] S_T = [[int(s[w]) for s in S] for w in range(W)] sumS = sum(map(sum, S_T)) ans = (H - 1) * (W - 1) if sumS <= K: print((0)) else: for i ...
34
38
963
1,145
from itertools import product H, W, K = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] S_T = [[int(s[w]) for s in S] for w in range(W)] sumS = sum(map(sum, S_T)) ans = (H - 1) * (W - 1) if sumS <= K: print((0)) else: for i in product([True, False], repeat=H - 1): cnt = sum(i) ...
def main(): from itertools import product H, W, K = list(map(int, input().split())) S = [eval(input()) for _ in range(H)] S_T = [[int(s[w]) for s in S] for w in range(W)] sumS = sum(map(sum, S_T)) ans = (H - 1) * (W - 1) if sumS <= K: print((0)) else: for i in product([T...
false
10.526316
[ "-from itertools import product", "+def main():", "+ from itertools import product", "-H, W, K = list(map(int, input().split()))", "-S = [eval(input()) for _ in range(H)]", "-S_T = [[int(s[w]) for s in S] for w in range(W)]", "-sumS = sum(map(sum, S_T))", "-ans = (H - 1) * (W - 1)", "-if sumS <= ...
false
0.074642
0.034568
2.159309
[ "s312762237", "s383524023" ]
u957872856
p03273
python
s697756143
s532660600
30
18
4,468
3,188
Accepted
Accepted
40
h, w = map(int, input().split()) a = [''] * h for i in range(h): a[i] = input() row = [False] * h col = [False] * w for i in range(h): for j in range(w): if a[i][j] == '#': row[i] = True col[j] = True for i in range(h): if row[i]: for j in range(w): if col[j]: print(a[i][j], end = '')...
h,w = list(map(int,input().split())) a = [[j for j in eval(input())] for i in range(h)] b = [x for x in a if "#" in x] c = list(zip(*[y for y in zip(*b) if "#" in y])) for d in c: print(("".join(d)))
17
6
331
186
h, w = map(int, input().split()) a = [""] * h for i in range(h): a[i] = input() row = [False] * h col = [False] * w for i in range(h): for j in range(w): if a[i][j] == "#": row[i] = True col[j] = True for i in range(h): if row[i]: for j in range(w): if col...
h, w = list(map(int, input().split())) a = [[j for j in eval(input())] for i in range(h)] b = [x for x in a if "#" in x] c = list(zip(*[y for y in zip(*b) if "#" in y])) for d in c: print(("".join(d)))
false
64.705882
[ "-h, w = map(int, input().split())", "-a = [\"\"] * h", "-for i in range(h):", "- a[i] = input()", "-row = [False] * h", "-col = [False] * w", "-for i in range(h):", "- for j in range(w):", "- if a[i][j] == \"#\":", "- row[i] = True", "- col[j] = True", "-for...
false
0.046484
0.046372
1.002416
[ "s697756143", "s532660600" ]
u571281863
p02660
python
s704216152
s529504381
201
82
9,276
9,292
Accepted
Accepted
59.2
N=int(eval(input())) p=[] r=0 if N%2==0: c=0 while N%2==0: c+=1 N/=2 p.append([c]) i=3 while i<N**0.5+1: if N%i==0: c=0 while N%i==0: c+=1 N/=i p.append([c]) i+=2 if N!=1: p.append([1]) for i in range(len(p)): j=1 while p[i][0]>=j: ...
N=int(eval(input())) p=[] r=0 if N%2==0: c=0 while N%2==0: c+=1 N/=2 p.append(c) for i in range(3,int(N**0.5)+1,2): if N%i==0: c=0 while N%i==0: c+=1 N/=i p.append(c) if N!=1: p.append(1) for i in p: r+=int(((8*i+1)**0.5-1)/2) print(r)
32
25
361
307
N = int(eval(input())) p = [] r = 0 if N % 2 == 0: c = 0 while N % 2 == 0: c += 1 N /= 2 p.append([c]) i = 3 while i < N**0.5 + 1: if N % i == 0: c = 0 while N % i == 0: c += 1 N /= i p.append([c]) i += 2 if N != 1: p.append([1]) fo...
N = int(eval(input())) p = [] r = 0 if N % 2 == 0: c = 0 while N % 2 == 0: c += 1 N /= 2 p.append(c) for i in range(3, int(N**0.5) + 1, 2): if N % i == 0: c = 0 while N % i == 0: c += 1 N /= i p.append(c) if N != 1: p.append(1) for i in...
false
21.875
[ "- p.append([c])", "-i = 3", "-while i < N**0.5 + 1:", "+ p.append(c)", "+for i in range(3, int(N**0.5) + 1, 2):", "- p.append([c])", "- i += 2", "+ p.append(c)", "- p.append([1])", "-for i in range(len(p)):", "- j = 1", "- while p[i][0] >= j:", "- p[i]...
false
0.037475
0.04208
0.89058
[ "s704216152", "s529504381" ]