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
u140251125
p03775
python
s934533747
s194529331
41
35
3,060
2,940
Accepted
Accepted
14.63
import math # input N = int(eval(input())) i = int(math.sqrt(N)) while i > 0: if N % i == 0: print((len(str(N // i)))) break else: i -= 1
import math # input N = int(eval(input())) i = int(math.sqrt(N)) while i: if N % i == 0: print((len(str(N // i)))) break else: i -= 1
13
13
176
172
import math # input N = int(eval(input())) i = int(math.sqrt(N)) while i > 0: if N % i == 0: print((len(str(N // i)))) break else: i -= 1
import math # input N = int(eval(input())) i = int(math.sqrt(N)) while i: if N % i == 0: print((len(str(N // i)))) break else: i -= 1
false
0
[ "-while i > 0:", "+while i:" ]
false
0.054094
0.056629
0.955239
[ "s934533747", "s194529331" ]
u844789719
p03718
python
s339840275
s286673530
673
188
40,808
40,712
Accepted
Accepted
72.07
from scipy.sparse.csgraph import *;from scipy.sparse import *;H,W,*S=open(0).read().split();H,W=int(H),int(W);m=H*W;A=[] for i in range(m): h,w=divmod(i,W);A=[m*2,h,m*2,w+m]+A if S[h][w]=='S' else [h,m*3,w+m,m*3]+A if S[h][w]=='T' else A+[h,w+m,w+m,h] if S[h][w]=='o' else A f=maximum_flow(csr_matrix(([9**9]*4+[1]*(...
from scipy.sparse.csgraph import *;from scipy.sparse import *;H,W,*S=open(0).read().split();H,W=int(H),int(W);m=H*W;A=[] for i in range(m): h,w=divmod(i,W) if S[h][w]=='S':A=[m*2,h,m*2,w+m]+A elif S[h][w]=='T':A=[h,m*3,w+m,m*3]+A elif S[h][w]=='o':A+=[h,w+m,w+m,h] f=maximum_flow(csr_matrix(([9**9]*4+[1]*(len(...
4
7
415
411
from scipy.sparse.csgraph import * from scipy.sparse import * H, W, *S = open(0).read().split() H, W = int(H), int(W) m = H * W A = [] for i in range(m): h, w = divmod(i, W) A = ( [m * 2, h, m * 2, w + m] + A if S[h][w] == "S" else [h, m * 3, w + m, m * 3] + A if S[h][w] == "T" ...
from scipy.sparse.csgraph import * from scipy.sparse import * H, W, *S = open(0).read().split() H, W = int(H), int(W) m = H * W A = [] for i in range(m): h, w = divmod(i, W) if S[h][w] == "S": A = [m * 2, h, m * 2, w + m] + A elif S[h][w] == "T": A = [h, m * 3, w + m, m * 3] + A elif S[...
false
42.857143
[ "- A = (", "- [m * 2, h, m * 2, w + m] + A", "- if S[h][w] == \"S\"", "- else [h, m * 3, w + m, m * 3] + A", "- if S[h][w] == \"T\"", "- else A + [h, w + m, w + m, h]", "- if S[h][w] == \"o\"", "- else A", "- )", "+ if S[h][w] == \"S\":", ...
false
0.744393
0.650944
1.143561
[ "s339840275", "s286673530" ]
u488127128
p03037
python
s859430124
s549949749
402
295
48,784
10,996
Accepted
Accepted
26.62
N,M = list(map(int, input().split())) l = 0 r = N D = [list(map(int, input().split())) for _ in range(M)] for d in D: L,R = d if L > l: l = L if R < r: r = R print((max(r-l+1,0)))
N,M = list(map(int, input().split())) L,R = [],[] for _ in range(M): l,r = list(map(int, input().split())) L.append(l) R.append(r) print((max(min(R)-max(L)+1,0)))
11
7
203
166
N, M = list(map(int, input().split())) l = 0 r = N D = [list(map(int, input().split())) for _ in range(M)] for d in D: L, R = d if L > l: l = L if R < r: r = R print((max(r - l + 1, 0)))
N, M = list(map(int, input().split())) L, R = [], [] for _ in range(M): l, r = list(map(int, input().split())) L.append(l) R.append(r) print((max(min(R) - max(L) + 1, 0)))
false
36.363636
[ "-l = 0", "-r = N", "-D = [list(map(int, input().split())) for _ in range(M)]", "-for d in D:", "- L, R = d", "- if L > l:", "- l = L", "- if R < r:", "- r = R", "-print((max(r - l + 1, 0)))", "+L, R = [], []", "+for _ in range(M):", "+ l, r = list(map(int, input()....
false
0.036155
0.047156
0.766722
[ "s859430124", "s549949749" ]
u021019433
p02744
python
s591373633
s077814131
135
121
14,816
14,772
Accepted
Accepted
10.37
from itertools import groupby n = int(input()) r = 'a', for _ in range(n - 1): r = [s + c for s in r for c, _ in groupby(sorted(s) + [chr(ord(max(s)) + 1)])] print(*r, sep='\n')
n = int(input()) r = 'a', for _ in range(n - 1): r = [s + c for s in r for c in set(s + chr(ord(max(s)) + 1))] print(*sorted(r), sep='\n')
7
5
187
144
from itertools import groupby n = int(input()) r = ("a",) for _ in range(n - 1): r = [s + c for s in r for c, _ in groupby(sorted(s) + [chr(ord(max(s)) + 1)])] print(*r, sep="\n")
n = int(input()) r = ("a",) for _ in range(n - 1): r = [s + c for s in r for c in set(s + chr(ord(max(s)) + 1))] print(*sorted(r), sep="\n")
false
28.571429
[ "-from itertools import groupby", "-", "- r = [s + c for s in r for c, _ in groupby(sorted(s) + [chr(ord(max(s)) + 1)])]", "-print(*r, sep=\"\\n\")", "+ r = [s + c for s in r for c in set(s + chr(ord(max(s)) + 1))]", "+print(*sorted(r), sep=\"\\n\")" ]
false
0.044859
0.04482
1.00087
[ "s591373633", "s077814131" ]
u436587708
p02257
python
s127330219
s320909592
290
180
6,756
6,788
Accepted
Accepted
37.93
def is_prime(x): if x == 2: return True if (x < 2) or (x%2 == 0): return False return all(x%i for i in range(3, int(x**(0.5) + 1), 2)) N = eval(input()) print(sum(is_prime(eval(input())) for i in range(N)))
def prime_numbers(n): cnds = [True] * n for x in range(2, int(n**0.5 + 1)): if cnds[x]: for m in range(2*x, n, x): cnds[m] = False return [i for i in range(2, n) if cnds[i]] def is_prime(n): return all(n % m for m in primes if m < n) primes = prime_number...
9
14
231
392
def is_prime(x): if x == 2: return True if (x < 2) or (x % 2 == 0): return False return all(x % i for i in range(3, int(x ** (0.5) + 1), 2)) N = eval(input()) print(sum(is_prime(eval(input())) for i in range(N)))
def prime_numbers(n): cnds = [True] * n for x in range(2, int(n**0.5 + 1)): if cnds[x]: for m in range(2 * x, n, x): cnds[m] = False return [i for i in range(2, n) if cnds[i]] def is_prime(n): return all(n % m for m in primes if m < n) primes = prime_numbers(10**4...
false
35.714286
[ "-def is_prime(x):", "- if x == 2:", "- return True", "- if (x < 2) or (x % 2 == 0):", "- return False", "- return all(x % i for i in range(3, int(x ** (0.5) + 1), 2))", "+def prime_numbers(n):", "+ cnds = [True] * n", "+ for x in range(2, int(n**0.5 + 1)):", "+ ...
false
0.04424
0.095137
0.465017
[ "s127330219", "s320909592" ]
u883048396
p03074
python
s902333931
s534744569
82
60
4,832
7,788
Accepted
Accepted
26.83
def 眠い(): N,K=[int(_) for _ in input().split()] aS = [0]*N iS = 0 iC = 0 for s in eval(input()): if s == '0' : if iS % 2: aS[iS] = iC iS += 1 iC = 1 else: iC += 1 else: if iS % 2: iC += 1 else: aS[iS] = iC iS += 1 iC = 1 if iC: if s == '0'...
#尺取を累積和にかえてみた def 眠い(): N,K=[int(_) for _ in input().split()] aS = [0]*N iS = 0 iC = 0 for s in eval(input()): if s == '0' : if iS % 2: aS[iS] = iC iS += 1 iC = 1 else: iC += 1 else: if iS % 2: iC += 1 else: aS[iS] = iC iS += 1 iC = 1 if iC: ...
93
70
1,376
976
def 眠い(): N, K = [int(_) for _ in input().split()] aS = [0] * N iS = 0 iC = 0 for s in eval(input()): if s == "0": if iS % 2: aS[iS] = iC iS += 1 iC = 1 else: iC += 1 else: if iS % 2: ...
# 尺取を累積和にかえてみた def 眠い(): N, K = [int(_) for _ in input().split()] aS = [0] * N iS = 0 iC = 0 for s in eval(input()): if s == "0": if iS % 2: aS[iS] = iC iS += 1 iC = 1 else: iC += 1 else: ...
false
24.731183
[ "+# 尺取を累積和にかえてみた", "+ accS = [0] * (iL + 3)", "+ for i in range(iL):", "+ accS[i + 1] = aS[i] + accS[i]", "+ accS[-2] = accS[-3]", "- else:", "- iD = sum(aS[: 2 * K])", "- iMax = iD", "- for i in range(1, iLP - K + 1):", "- if ...
false
0.037578
0.036414
1.031951
[ "s902333931", "s534744569" ]
u297574184
p03201
python
s498472176
s932398965
853
449
113,492
33,296
Accepted
Accepted
47.36
from collections import Counter N = int(eval(input())) As = list(map(int, input().split())) cnt = Counter(As) As.sort(reverse=True) Ps = [2] for i in range(58): Ps.append(Ps[-1] * 2) Ps = Ps[::-1] ans = 0 for A in As: if cnt[A] <= 0: continue cnt[A] -= 1 for P in Ps: if cnt...
from collections import Counter N = int(eval(input())) As = list(map(int, input().split())) cnt = Counter(As) As.sort(reverse=True) Ps = [2] for i in range(29): Ps.append(Ps[-1] * 2) ans = 0 for A in As: if cnt[A] <= 0: continue cnt[A] -= 1 while Ps[-1] > 2 * A: Ps.pop() ...
23
25
409
406
from collections import Counter N = int(eval(input())) As = list(map(int, input().split())) cnt = Counter(As) As.sort(reverse=True) Ps = [2] for i in range(58): Ps.append(Ps[-1] * 2) Ps = Ps[::-1] ans = 0 for A in As: if cnt[A] <= 0: continue cnt[A] -= 1 for P in Ps: if cnt[P - A] > 0: ...
from collections import Counter N = int(eval(input())) As = list(map(int, input().split())) cnt = Counter(As) As.sort(reverse=True) Ps = [2] for i in range(29): Ps.append(Ps[-1] * 2) ans = 0 for A in As: if cnt[A] <= 0: continue cnt[A] -= 1 while Ps[-1] > 2 * A: Ps.pop() if cnt[Ps[-...
false
8
[ "-for i in range(58):", "+for i in range(29):", "-Ps = Ps[::-1]", "- for P in Ps:", "- if cnt[P - A] > 0:", "- ans += 1", "- cnt[P - A] -= 1", "- break", "+ while Ps[-1] > 2 * A:", "+ Ps.pop()", "+ if cnt[Ps[-1] - A] > 0:", "+ ans ...
false
0.007227
0.039947
0.180929
[ "s498472176", "s932398965" ]
u803848678
p03649
python
s347899622
s009661032
209
182
40,556
39,664
Accepted
Accepted
12.92
n = int(eval(input())) a = list(map(int, input().split())) a.sort() ans = 0 while a[-1] >= n: k = -(-(a[-1]+1)//n)-1 ans += k for i in range(n-1): a[i] += k a[-1] -= n*k a.sort() print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 while True: tmp = 0 for i in range(n): k = -(-(a[i]+1)//n)-1 tmp += k a[i] -= k*n a[i] -= k for i in range(n): a[i] += tmp if not tmp: break ans += tmp print(ans)
14
18
226
310
n = int(eval(input())) a = list(map(int, input().split())) a.sort() ans = 0 while a[-1] >= n: k = -(-(a[-1] + 1) // n) - 1 ans += k for i in range(n - 1): a[i] += k a[-1] -= n * k a.sort() print(ans)
n = int(eval(input())) a = list(map(int, input().split())) ans = 0 while True: tmp = 0 for i in range(n): k = -(-(a[i] + 1) // n) - 1 tmp += k a[i] -= k * n a[i] -= k for i in range(n): a[i] += tmp if not tmp: break ans += tmp print(ans)
false
22.222222
[ "-a.sort()", "-while a[-1] >= n:", "- k = -(-(a[-1] + 1) // n) - 1", "- ans += k", "- for i in range(n - 1):", "- a[i] += k", "- a[-1] -= n * k", "- a.sort()", "+while True:", "+ tmp = 0", "+ for i in range(n):", "+ k = -(-(a[i] + 1) // n) - 1", "+ t...
false
0.037878
0.037354
1.01402
[ "s347899622", "s009661032" ]
u203843959
p02781
python
s502979154
s339762399
204
171
38,384
38,384
Accepted
Accepted
16.18
N_str=eval(input()) K=int(eval(input())) #print(N_str) digit_N=len(N_str) #dp[i][j][k] #i:eqflag, j:digit, k:K #dp=[[[0]*2 for _ in range(digit_N)] for _ in range(K+1)] dp=[[[0]*(K+1) for _ in range(digit_N)] for _ in range(2)] dp[0][0][0]=1 dp[0][0][1]=int(N_str[0])-1 dp[1][0][1]=1 #print(dp) for j i...
N_str=eval(input()) K=int(eval(input())) #print(N_str) digit_N=len(N_str) #dp[i][j]: j:digit, k:K dp_eq=[] dp_ne=[] for i in range(digit_N): dp_eq.append([0]*(K+1)) dp_ne.append([0]*(K+1)) #init dp_eq[0][1]=1 dp_ne[0][1]=int(N_str[0])-1 for i in range(digit_N): dp_ne[i][0]=1 for j in range(...
33
30
801
647
N_str = eval(input()) K = int(eval(input())) # print(N_str) digit_N = len(N_str) # dp[i][j][k] # i:eqflag, j:digit, k:K # dp=[[[0]*2 for _ in range(digit_N)] for _ in range(K+1)] dp = [[[0] * (K + 1) for _ in range(digit_N)] for _ in range(2)] dp[0][0][0] = 1 dp[0][0][1] = int(N_str[0]) - 1 dp[1][0][1] = 1 # print(dp) ...
N_str = eval(input()) K = int(eval(input())) # print(N_str) digit_N = len(N_str) # dp[i][j]: j:digit, k:K dp_eq = [] dp_ne = [] for i in range(digit_N): dp_eq.append([0] * (K + 1)) dp_ne.append([0] * (K + 1)) # init dp_eq[0][1] = 1 dp_ne[0][1] = int(N_str[0]) - 1 for i in range(digit_N): dp_ne[i][0] = 1 for...
false
9.090909
[ "-# dp[i][j][k]", "-# i:eqflag, j:digit, k:K", "-# dp=[[[0]*2 for _ in range(digit_N)] for _ in range(K+1)]", "-dp = [[[0] * (K + 1) for _ in range(digit_N)] for _ in range(2)]", "-dp[0][0][0] = 1", "-dp[0][0][1] = int(N_str[0]) - 1", "-dp[1][0][1] = 1", "-# print(dp)", "+# dp[i][j]: j:digit, k:K", ...
false
0.109368
0.047963
2.280272
[ "s502979154", "s339762399" ]
u729133443
p03042
python
s430395736
s137086905
21
17
3,064
2,940
Accepted
Accepted
19.05
s=eval(input());print((['NA','MMYY','YYMM','AMBIGUOUS'][(0<int(s[:2])<13)-(0<int(s[2:])<13)*2]))
s=eval(input());print((['NA','MMYY','YYMM','AMBIGUOUS'][('01'<s<'13')-('00'<s[2:]<'13')*2]))
1
1
88
84
s = eval(input()) print( ( ["NA", "MMYY", "YYMM", "AMBIGUOUS"][ (0 < int(s[:2]) < 13) - (0 < int(s[2:]) < 13) * 2 ] ) )
s = eval(input()) print( (["NA", "MMYY", "YYMM", "AMBIGUOUS"][("01" < s < "13") - ("00" < s[2:] < "13") * 2]) )
false
0
[ "- (", "- [\"NA\", \"MMYY\", \"YYMM\", \"AMBIGUOUS\"][", "- (0 < int(s[:2]) < 13) - (0 < int(s[2:]) < 13) * 2", "- ]", "- )", "+ ([\"NA\", \"MMYY\", \"YYMM\", \"AMBIGUOUS\"][(\"01\" < s < \"13\") - (\"00\" < s[2:] < \"13\") * 2])" ]
false
0.098633
0.041576
2.372368
[ "s430395736", "s137086905" ]
u045628053
p03031
python
s621623416
s524327216
378
88
92,836
74,404
Accepted
Accepted
76.72
n,m = list(map(int,input().split())) l_list = [list(map(int,input().split())) for i in range(m)] p = list(map(int,input().split())) output = 0 for i in range(2 ** n): lights = [] for j in range(n+1): if ((i >> j) & 1): lights.append(j+1) for inde, l in enumerate(l_list): if len(...
n,m = list(map(int,input().split())) l_list = [list(map(int,input().split())) for i in range(m)] p = list(map(int,input().split())) output = 0 for i in range(2 ** n): lights = [] for j in range(n+1): if ((i >> j) & 1): lights.append(j+1) for k, l in enumerate(l_list): if len(set...
17
17
415
409
n, m = list(map(int, input().split())) l_list = [list(map(int, input().split())) for i in range(m)] p = list(map(int, input().split())) output = 0 for i in range(2**n): lights = [] for j in range(n + 1): if (i >> j) & 1: lights.append(j + 1) for inde, l in enumerate(l_list): if l...
n, m = list(map(int, input().split())) l_list = [list(map(int, input().split())) for i in range(m)] p = list(map(int, input().split())) output = 0 for i in range(2**n): lights = [] for j in range(n + 1): if (i >> j) & 1: lights.append(j + 1) for k, l in enumerate(l_list): if len(...
false
0
[ "- for inde, l in enumerate(l_list):", "- if len(set(l[1:]) & set(lights)) % 2 != p[inde]:", "+ for k, l in enumerate(l_list):", "+ if len(set(l[1:]) & set(lights)) % 2 != p[k]:" ]
false
0.095848
0.037945
2.525966
[ "s621623416", "s524327216" ]
u699296734
p03307
python
s403629738
s686022614
32
29
9,008
9,148
Accepted
Accepted
9.38
import math n = int(eval(input())) gcd = math.gcd(2, n) lcm = 2 * n // gcd print(lcm)
n = int(eval(input())) if n % 2 == 0: print(n) else: print((2 * n))
5
5
84
71
import math n = int(eval(input())) gcd = math.gcd(2, n) lcm = 2 * n // gcd print(lcm)
n = int(eval(input())) if n % 2 == 0: print(n) else: print((2 * n))
false
0
[ "-import math", "-", "-gcd = math.gcd(2, n)", "-lcm = 2 * n // gcd", "-print(lcm)", "+if n % 2 == 0:", "+ print(n)", "+else:", "+ print((2 * n))" ]
false
0.046105
0.124686
0.369768
[ "s403629738", "s686022614" ]
u321035578
p02755
python
s413415991
s423850894
22
20
2,940
3,060
Accepted
Accepted
9.09
def main(): a,b = list(map(int,input().split())) for x in range(1,10001): x_a = int(x * 0.08) x_b = int(x * 0.1) if x_a == a and x_b == b: print(x) return print((-1)) if __name__=='__main__': main()
import math a,b = list(map(int,input().split())) for i in range(1,2000): tax8 = math.floor(i*0.08) tax1 = math.floor(i*0.1) if a == tax8 and b == tax1: print(i) exit() print((-1))
11
10
265
210
def main(): a, b = list(map(int, input().split())) for x in range(1, 10001): x_a = int(x * 0.08) x_b = int(x * 0.1) if x_a == a and x_b == b: print(x) return print((-1)) if __name__ == "__main__": main()
import math a, b = list(map(int, input().split())) for i in range(1, 2000): tax8 = math.floor(i * 0.08) tax1 = math.floor(i * 0.1) if a == tax8 and b == tax1: print(i) exit() print((-1))
false
9.090909
[ "-def main():", "- a, b = list(map(int, input().split()))", "- for x in range(1, 10001):", "- x_a = int(x * 0.08)", "- x_b = int(x * 0.1)", "- if x_a == a and x_b == b:", "- print(x)", "- return", "- print((-1))", "+import math", "-", "-if __...
false
0.07698
0.038639
1.992288
[ "s413415991", "s423850894" ]
u941407962
p03165
python
s849271692
s125821880
1,117
457
376,584
112,220
Accepted
Accepted
59.09
s = input().strip() t = input().strip() LS, LT = len(s), len(t) dp = [[0]*(LT+1) for _ in range(LS+1)] dp2 = [[(0, 0)]*(LT+1) for _ in range(LS+1)] for i in range(LS): for j in range(LT): if s[i] == t[j]: dp[i+1][j+1] = dp[i][j] + 1 dp2[i+1][j+1] = (i, j) else: ...
s = " " + input().strip() t = " " + input().strip() LS, LT = len(s), len(t) dp = [[0]*LT for _ in range(LS)] for i in range(1, LS): for j in range(1, LT): if s[i] == t[j]: dp[i][j] = dp[i-1][j-1] + 1 else: dp[i][j] = max(dp[i-1][j], dp[i][j-1]) a, b = (LS-1, LT-1) ...
25
22
671
510
s = input().strip() t = input().strip() LS, LT = len(s), len(t) dp = [[0] * (LT + 1) for _ in range(LS + 1)] dp2 = [[(0, 0)] * (LT + 1) for _ in range(LS + 1)] for i in range(LS): for j in range(LT): if s[i] == t[j]: dp[i + 1][j + 1] = dp[i][j] + 1 dp2[i + 1][j + 1] = (i, j) ...
s = " " + input().strip() t = " " + input().strip() LS, LT = len(s), len(t) dp = [[0] * LT for _ in range(LS)] for i in range(1, LS): for j in range(1, LT): if s[i] == t[j]: dp[i][j] = dp[i - 1][j - 1] + 1 else: dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) a, b = (LS - 1, LT - ...
false
12
[ "-s = input().strip()", "-t = input().strip()", "+s = \" \" + input().strip()", "+t = \" \" + input().strip()", "-dp = [[0] * (LT + 1) for _ in range(LS + 1)]", "-dp2 = [[(0, 0)] * (LT + 1) for _ in range(LS + 1)]", "-for i in range(LS):", "- for j in range(LT):", "+dp = [[0] * LT for _ in range(...
false
0.159479
0.16155
0.98718
[ "s849271692", "s125821880" ]
u525065967
p02888
python
s200162406
s862814340
1,996
1,802
3,188
3,188
Accepted
Accepted
9.72
from itertools import * N = int(eval(input())) csum = list(0 for _ in range(2000+1)) L = [] for l in map(int,input().split()): L.append(l) csum[l] += 1 csum = list(accumulate(csum)) ans = 0 for ia in range(N-1): for ib in range(ia+1,N): a, b = L[ia], L[ib] minL, maxL = abs(a-b), ...
N = int(eval(input())) csum = list(0 for _ in range(2000+1)) L = [] for l in map(int,input().split()): L.append(l) csum[l] += 1 for i in range(1,len(csum)): csum[i] += csum[i-1] ans = 0 for ib in range(N): b = L[ib] for ia in range(ib): a = L[ia] minL, maxL = abs(a-b), a+b ...
17
17
462
444
from itertools import * N = int(eval(input())) csum = list(0 for _ in range(2000 + 1)) L = [] for l in map(int, input().split()): L.append(l) csum[l] += 1 csum = list(accumulate(csum)) ans = 0 for ia in range(N - 1): for ib in range(ia + 1, N): a, b = L[ia], L[ib] minL, maxL = abs(a - b), a...
N = int(eval(input())) csum = list(0 for _ in range(2000 + 1)) L = [] for l in map(int, input().split()): L.append(l) csum[l] += 1 for i in range(1, len(csum)): csum[i] += csum[i - 1] ans = 0 for ib in range(N): b = L[ib] for ia in range(ib): a = L[ia] minL, maxL = abs(a - b), a + b ...
false
0
[ "-from itertools import *", "-", "-csum = list(accumulate(csum))", "+for i in range(1, len(csum)):", "+ csum[i] += csum[i - 1]", "-for ia in range(N - 1):", "- for ib in range(ia + 1, N):", "- a, b = L[ia], L[ib]", "+for ib in range(N):", "+ b = L[ib]", "+ for ia in range(ib):...
false
0.048708
0.049142
0.991171
[ "s200162406", "s862814340" ]
u156896646
p02856
python
s464270259
s485541086
490
370
9,112
9,184
Accepted
Accepted
24.49
def steps(c, s): # c: No. of elements, s: sum of elements q, r = divmod(s, 9) if r != 0: cnt = (c-1) + q else: cnt = (c-1) + q-1 r = 9 return cnt, r m = int(eval(input())) r0 = 0; ans = 0 for _ in range(m): d, c = list(map(int, input().split())) cnt...
def steps(c, s): # c: No. of elements, s: sum of elements q, r = divmod(s, 9) if r != 0: cnt = (c-1) + q else: cnt = (c-1) + q-1 r = 9 return cnt, r m = int(eval(input())) tot_c, tot_s = 0, 0 for _ in range(m): d, c = list(map(int, input().split())) to...
19
19
403
378
def steps(c, s): # c: No. of elements, s: sum of elements q, r = divmod(s, 9) if r != 0: cnt = (c - 1) + q else: cnt = (c - 1) + q - 1 r = 9 return cnt, r m = int(eval(input())) r0 = 0 ans = 0 for _ in range(m): d, c = list(map(int, input().split())) cnt, r = steps...
def steps(c, s): # c: No. of elements, s: sum of elements q, r = divmod(s, 9) if r != 0: cnt = (c - 1) + q else: cnt = (c - 1) + q - 1 r = 9 return cnt, r m = int(eval(input())) tot_c, tot_s = 0, 0 for _ in range(m): d, c = list(map(int, input().split())) tot_c += ...
false
0
[ "-r0 = 0", "-ans = 0", "+tot_c, tot_s = 0, 0", "- cnt, r = steps(c, d * c)", "- ans += cnt", "- cnt, r0 = steps(2, r0 + r)", "- ans += cnt", "-print((ans - 1))", "+ tot_c += c", "+ tot_s += c * d", "+ans, r = steps(tot_c, tot_s)", "+print(ans)" ]
false
0.046438
0.034764
1.335784
[ "s464270259", "s485541086" ]
u223133214
p02844
python
s894454601
s536737594
875
507
50,300
3,572
Accepted
Accepted
42.06
import sys input = sys.stdin.buffer.readline def canMakeNumber(k, s): k = str(k).zfill(3) dic = {0: False, 1: False, 2: False} for t in s: if dic[0] is False: if t == k[0]: dic[0] = True else: if dic[1] is False: if t == ...
N = int(eval(input())) S = list(eval(input())) species_S_list = set(S) ans = 0 for num in range(0, 1000): cnt = 0 num_str = str(num).zfill(3) n0, n1, n2 = list(num_str) if n0 in species_S_list and n1 in species_S_list and n2 in species_S_list: index0 = S.index(n0) index2 = N ...
32
16
736
443
import sys input = sys.stdin.buffer.readline def canMakeNumber(k, s): k = str(k).zfill(3) dic = {0: False, 1: False, 2: False} for t in s: if dic[0] is False: if t == k[0]: dic[0] = True else: if dic[1] is False: if t == k[1]: ...
N = int(eval(input())) S = list(eval(input())) species_S_list = set(S) ans = 0 for num in range(0, 1000): cnt = 0 num_str = str(num).zfill(3) n0, n1, n2 = list(num_str) if n0 in species_S_list and n1 in species_S_list and n2 in species_S_list: index0 = S.index(n0) index2 = N - S[::-1].in...
false
50
[ "-import sys", "-", "-input = sys.stdin.buffer.readline", "-", "-", "-def canMakeNumber(k, s):", "- k = str(k).zfill(3)", "- dic = {0: False, 1: False, 2: False}", "- for t in s:", "- if dic[0] is False:", "- if t == k[0]:", "- dic[0] = True", "- ...
false
0.045596
0.06985
0.652771
[ "s894454601", "s536737594" ]
u309977459
p03148
python
s848155983
s466488054
974
614
81,496
36,108
Accepted
Accepted
36.96
from operator import itemgetter N, K = list(map(int, input().split())) td = [list(map(int, input().split())) for _ in range(N)] td.sort(key=itemgetter(1, 0), reverse=True) t, d = list(zip(*td)) s = set() q = [] tmp = 0 now = 0 for i in range(K): if t[i] not in s: s.add(t[i]) else: ...
from operator import itemgetter N, K = list(map(int, input().split())) td = [list(map(int, input().split())) for _ in range(N)] td.sort(key=itemgetter(1), reverse=True) t, d = list(zip(*td)) s = set() q = [] tmp = 0 now = 0 for i in range(K): if t[i] not in s: s.add(t[i]) else: q....
42
33
902
676
from operator import itemgetter N, K = list(map(int, input().split())) td = [list(map(int, input().split())) for _ in range(N)] td.sort(key=itemgetter(1, 0), reverse=True) t, d = list(zip(*td)) s = set() q = [] tmp = 0 now = 0 for i in range(K): if t[i] not in s: s.add(t[i]) else: q.append(d[i]...
from operator import itemgetter N, K = list(map(int, input().split())) td = [list(map(int, input().split())) for _ in range(N)] td.sort(key=itemgetter(1), reverse=True) t, d = list(zip(*td)) s = set() q = [] tmp = 0 now = 0 for i in range(K): if t[i] not in s: s.add(t[i]) else: q.append(d[i]) ...
false
21.428571
[ "-td.sort(key=itemgetter(1, 0), reverse=True)", "+td.sort(key=itemgetter(1), reverse=True)", "-# while q:", "-# kind += 1", "-# tmp = q.pop()", "-# for i in range(now, N):", "-# now += 1", "-# if t[i] not in s:", "-# s.add(t[i])", "-# sums.append(sums[k...
false
0.037282
0.043346
0.860092
[ "s848155983", "s466488054" ]
u144913062
p02556
python
s384689775
s768039787
165
152
90,356
89,804
Accepted
Accepted
7.88
import sys input = sys.stdin.readline N = int(eval(input())) points = [0] * N rx = [] ry = [] for i in range(N): x, y = list(map(int, input().split())) rx.append(x - y) ry.append(x + y) xm = max(rx) xn = min(rx) ym = max(ry) yn = min(ry) ans = max(max(xm - x, x - xn, ym - y, y - yn) for x, y...
import sys input = sys.stdin.readline N = int(eval(input())) points = [0] * N rx = [] ry = [] for i in range(N): x, y = list(map(int, input().split())) rx.append(x - y) ry.append(x + y) print((max(max(rx) - min(rx), max(ry) - min(ry))))
19
12
341
246
import sys input = sys.stdin.readline N = int(eval(input())) points = [0] * N rx = [] ry = [] for i in range(N): x, y = list(map(int, input().split())) rx.append(x - y) ry.append(x + y) xm = max(rx) xn = min(rx) ym = max(ry) yn = min(ry) ans = max(max(xm - x, x - xn, ym - y, y - yn) for x, y in zip(rx, ry)...
import sys input = sys.stdin.readline N = int(eval(input())) points = [0] * N rx = [] ry = [] for i in range(N): x, y = list(map(int, input().split())) rx.append(x - y) ry.append(x + y) print((max(max(rx) - min(rx), max(ry) - min(ry))))
false
36.842105
[ "-xm = max(rx)", "-xn = min(rx)", "-ym = max(ry)", "-yn = min(ry)", "-ans = max(max(xm - x, x - xn, ym - y, y - yn) for x, y in zip(rx, ry))", "-print(ans)", "+print((max(max(rx) - min(rx), max(ry) - min(ry))))" ]
false
0.137829
0.084984
1.621825
[ "s384689775", "s768039787" ]
u362498687
p03478
python
s765173379
s905553233
208
179
41,064
39,536
Accepted
Accepted
13.94
""" 1以上N以下の整数の内、各桁の輪がA以上B以下であるものの全ての総和は? 20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、 2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。 """ N, A, B = list(map(int, input().strip().split(' '))) sum_list = [] for i in range(1, N + 1): # 1以上N以下の整数を1つずつ if len(str(i)) == 1: if A <= i <= B: sum_list.app...
""" 1以上N以下の整数の内、各桁の和がA以上B以下であるものの全ての総和は? 20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、 2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。 """ def summaker(n): sum1 = 0 while n > 0: sum1 += n % 10 n = n // 10 return sum1 N, A, B = list(map(int, input().strip().split(' '))) total = 0 for i in...
27
23
839
407
""" 1以上N以下の整数の内、各桁の輪がA以上B以下であるものの全ての総和は? 20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、 2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。 """ N, A, B = list(map(int, input().strip().split(" "))) sum_list = [] for i in range(1, N + 1): # 1以上N以下の整数を1つずつ if len(str(i)) == 1: if A <= i <= B: sum_list.appe...
""" 1以上N以下の整数の内、各桁の和がA以上B以下であるものの全ての総和は? 20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、 2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。 """ def summaker(n): sum1 = 0 while n > 0: sum1 += n % 10 n = n // 10 return sum1 N, A, B = list(map(int, input().strip().split(" "))) total = 0 for i in range(...
false
14.814815
[ "-1以上N以下の整数の内、各桁の輪がA以上B以下であるものの全ての総和は?", "+1以上N以下の整数の内、各桁の和がA以上B以下であるものの全ての総和は?", "+", "+", "+def summaker(n):", "+ sum1 = 0", "+ while n > 0:", "+ sum1 += n % 10", "+ n = n // 10", "+ return sum1", "+", "+", "-sum_list = []", "+total = 0", "- # 1以上N以下の整数を1つずつ",...
false
0.036081
0.07085
0.509259
[ "s765173379", "s905553233" ]
u175111751
p02410
python
s592540225
s908573934
40
30
8,196
8,248
Accepted
Accepted
25
n, m = list(map(int, input().split())) matrix = [] vector = [] for _ in range(n): matrix.append(list(map(int, input().split()))) for _ in range(m): vector.append(int(eval(input()))) for row in matrix: product = 0 for i, e in enumerate(row): product += e * vector[i] print(product)
n, m = list(map(int, input().split())) M = [list(map(int, input().split())) for _ in range(n)] V = [int(eval(input())) for _ in range(m)] for r in M: print((sum(x*y for x, y in zip(r, V))))
12
5
301
177
n, m = list(map(int, input().split())) matrix = [] vector = [] for _ in range(n): matrix.append(list(map(int, input().split()))) for _ in range(m): vector.append(int(eval(input()))) for row in matrix: product = 0 for i, e in enumerate(row): product += e * vector[i] print(product)
n, m = list(map(int, input().split())) M = [list(map(int, input().split())) for _ in range(n)] V = [int(eval(input())) for _ in range(m)] for r in M: print((sum(x * y for x, y in zip(r, V))))
false
58.333333
[ "-matrix = []", "-vector = []", "-for _ in range(n):", "- matrix.append(list(map(int, input().split())))", "-for _ in range(m):", "- vector.append(int(eval(input())))", "-for row in matrix:", "- product = 0", "- for i, e in enumerate(row):", "- product += e * vector[i]", "- ...
false
0.097821
0.038695
2.528035
[ "s592540225", "s908573934" ]
u562935282
p02947
python
s178453167
s234387269
701
569
36,188
22,372
Accepted
Accepted
18.83
from collections import defaultdict base = ord('a') d = defaultdict(int) ans = 0 n = int(eval(input())) for _ in range(n): s = eval(input()) lst = [0] * 26 for c in s: idx = ord(c) - base lst[idx] += 1 key = tuple(lst) ans += d[key] d[key] += 1 print(ans)
from collections import defaultdict n = int(eval(input())) d = defaultdict(int) ans = 0 for _ in range(n): s = eval(input()) s = str(sorted(s)) ans += d[s] d[s] += 1 print(ans)
20
12
308
194
from collections import defaultdict base = ord("a") d = defaultdict(int) ans = 0 n = int(eval(input())) for _ in range(n): s = eval(input()) lst = [0] * 26 for c in s: idx = ord(c) - base lst[idx] += 1 key = tuple(lst) ans += d[key] d[key] += 1 print(ans)
from collections import defaultdict n = int(eval(input())) d = defaultdict(int) ans = 0 for _ in range(n): s = eval(input()) s = str(sorted(s)) ans += d[s] d[s] += 1 print(ans)
false
40
[ "-base = ord(\"a\")", "+n = int(eval(input()))", "-n = int(eval(input()))", "- lst = [0] * 26", "- for c in s:", "- idx = ord(c) - base", "- lst[idx] += 1", "- key = tuple(lst)", "- ans += d[key]", "- d[key] += 1", "+ s = str(sorted(s))", "+ ans += d[s]", "...
false
0.042075
0.066434
0.633333
[ "s178453167", "s234387269" ]
u298297089
p03564
python
s632509612
s959715815
162
18
38,256
2,940
Accepted
Accepted
88.89
n = int(eval(input())) k = int(eval(input())) tmp = 1 for i in range(n): tmp += tmp if tmp <= k else k print(tmp)
n = int(eval(input())) k = int(eval(input())) ans = 1 for i in range(n): a = ans * 2 b = ans + k if a < b: ans = a else: ans = b print(ans)
7
11
112
154
n = int(eval(input())) k = int(eval(input())) tmp = 1 for i in range(n): tmp += tmp if tmp <= k else k print(tmp)
n = int(eval(input())) k = int(eval(input())) ans = 1 for i in range(n): a = ans * 2 b = ans + k if a < b: ans = a else: ans = b print(ans)
false
36.363636
[ "-tmp = 1", "+ans = 1", "- tmp += tmp if tmp <= k else k", "-print(tmp)", "+ a = ans * 2", "+ b = ans + k", "+ if a < b:", "+ ans = a", "+ else:", "+ ans = b", "+print(ans)" ]
false
0.052683
0.036023
1.462494
[ "s632509612", "s959715815" ]
u279546122
p02361
python
s318911087
s918825635
3,010
2,560
106,760
106,864
Accepted
Accepted
14.95
from collections import defaultdict from collections import deque from sys import stdin def sp(G,R,V): d = {} INF = float('inf') for i in range(V): d[i] = INF d[R] = 0 q = deque([(R)]) while q: u = q.popleft() for v in G[u]: if d[v[0]] > d[u] + ...
from collections import defaultdict from collections import deque from sys import stdin def sp(G,R,V): d = {} INF = float('inf') for i in range(V): d[i] = INF d[R] = 0 q = deque([(R)]) while q: u = q.popleft() for v in G[u]: if d[v[0]] > d[u] ...
31
32
749
741
from collections import defaultdict from collections import deque from sys import stdin def sp(G, R, V): d = {} INF = float("inf") for i in range(V): d[i] = INF d[R] = 0 q = deque([(R)]) while q: u = q.popleft() for v in G[u]: if d[v[0]] > d[u] + v[1]: ...
from collections import defaultdict from collections import deque from sys import stdin def sp(G, R, V): d = {} INF = float("inf") for i in range(V): d[i] = INF d[R] = 0 q = deque([(R)]) while q: u = q.popleft() for v in G[u]: if d[v[0]] > d[u] + v[1]: ...
false
3.125
[ "-V, E, R = tuple(int(x) for x in stdin.readline().split(\" \"))", "+V, E, R = [int(x) for x in stdin.readline().split(\" \")]", "- s, t, w = tuple(int(x) for x in stdin.readline().split(\" \"))", "+ s, t, w = [int(x) for x in stdin.readline().split(\" \")]" ]
false
0.072588
0.073085
0.993204
[ "s318911087", "s918825635" ]
u652057333
p03087
python
s024207979
s466649147
883
267
6,060
6,356
Accepted
Accepted
69.76
# C n, q = list(map(int, input().split())) s = str(eval(input())) s_flag = [0] * n v = 0 for i in range(n-1): if s[i:i+2] == 'AC': v += 1 s_flag[i+1] = v for i in range(q): l, r = list(map(int, input().split())) l -= 1 r -= 1 ans = s_flag[r] - s_flag[l] print(ans)
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) s = str(eval(input())) ac = [0] * n for i in range(1, n): ac[i] = ac[i-1] if(s[i-1] == "A" and s[i] == "C"): ac[i] += 1 for i in range(q): l, r = list(map(int, input().split())) print((ac[r-1] - ac[l-1]))
16
13
298
298
# C n, q = list(map(int, input().split())) s = str(eval(input())) s_flag = [0] * n v = 0 for i in range(n - 1): if s[i : i + 2] == "AC": v += 1 s_flag[i + 1] = v for i in range(q): l, r = list(map(int, input().split())) l -= 1 r -= 1 ans = s_flag[r] - s_flag[l] print(ans)
import sys input = sys.stdin.readline n, q = list(map(int, input().split())) s = str(eval(input())) ac = [0] * n for i in range(1, n): ac[i] = ac[i - 1] if s[i - 1] == "A" and s[i] == "C": ac[i] += 1 for i in range(q): l, r = list(map(int, input().split())) print((ac[r - 1] - ac[l - 1]))
false
18.75
[ "-# C", "+import sys", "+", "+input = sys.stdin.readline", "-s_flag = [0] * n", "-v = 0", "-for i in range(n - 1):", "- if s[i : i + 2] == \"AC\":", "- v += 1", "- s_flag[i + 1] = v", "+ac = [0] * n", "+for i in range(1, n):", "+ ac[i] = ac[i - 1]", "+ if s[i - 1] == \"A...
false
0.037832
0.037751
1.002156
[ "s024207979", "s466649147" ]
u724687935
p02620
python
s590405564
s665965873
954
818
96,860
100,572
Accepted
Accepted
14.26
import sys from bisect import bisect_right, bisect_left def checkScore(p): global D, last, S rst = 0 _last = last[p] for d in range(1, D + 1): down = C[p] * (d - _last[d]) up = S[d][p] if _last[d] == d else 0 rst += up - down return rst Z = 26 D = int(eval...
import sys from bisect import bisect_right, bisect_left def calculate_score(c): global D, last, S rst = 0 _last = last[c] for d in range(1, D + 1): down = C[c] * (d - _last[d]) up = S[d][c] if _last[d] == d else 0 rst += up - down return rst Z = 26 D = int...
58
65
1,265
1,479
import sys from bisect import bisect_right, bisect_left def checkScore(p): global D, last, S rst = 0 _last = last[p] for d in range(1, D + 1): down = C[p] * (d - _last[d]) up = S[d][p] if _last[d] == d else 0 rst += up - down return rst Z = 26 D = int(eval(input())) C = l...
import sys from bisect import bisect_right, bisect_left def calculate_score(c): global D, last, S rst = 0 _last = last[c] for d in range(1, D + 1): down = C[c] * (d - _last[d]) up = S[d][c] if _last[d] == d else 0 rst += up - down return rst Z = 26 D = int(eval(input())) ...
false
10.769231
[ "-def checkScore(p):", "+def calculate_score(c):", "- _last = last[p]", "+ _last = last[c]", "- down = C[p] * (d - _last[d])", "- up = S[d][p] if _last[d] == d else 0", "+ down = C[c] * (d - _last[d])", "+ up = S[d][c] if _last[d] == d else 0", "-T = [None] + [int(e...
false
0.044163
0.043629
1.012239
[ "s590405564", "s665965873" ]
u282676559
p03680
python
s750971589
s458966985
220
188
7,888
7,084
Accepted
Accepted
14.55
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] check = [True for _ in range(N)] ai = 1 count = 1 while check[ai-1]: if A[ai-1] == 2: print(count) exit() check[ai-1] = False ai = A[ai-1] count += 1 print((-1))
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] order = A[0] for i in range(1,N): if order == 2: print(i) exit() order = A[order-1] print((-1))
14
9
244
167
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] check = [True for _ in range(N)] ai = 1 count = 1 while check[ai - 1]: if A[ai - 1] == 2: print(count) exit() check[ai - 1] = False ai = A[ai - 1] count += 1 print((-1))
N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] order = A[0] for i in range(1, N): if order == 2: print(i) exit() order = A[order - 1] print((-1))
false
35.714286
[ "-check = [True for _ in range(N)]", "-ai = 1", "-count = 1", "-while check[ai - 1]:", "- if A[ai - 1] == 2:", "- print(count)", "+order = A[0]", "+for i in range(1, N):", "+ if order == 2:", "+ print(i)", "- check[ai - 1] = False", "- ai = A[ai - 1]", "- count +...
false
0.036187
0.047463
0.762436
[ "s750971589", "s458966985" ]
u758815106
p02603
python
s597097570
s882300843
30
26
9,200
9,100
Accepted
Accepted
13.33
N = int(eval(input())) A = list(map(int, input().split())) dp = [0] * N dp[0] = 1000 for i in range(1, N): dp[i] = dp[i - 1] for j in range(i): kabu = dp[j] // A[j] money = dp[j] + (A[i] - A[j]) * kabu dp[i] = max(dp[i], money) print((dp[-1]))
N = int(eval(input())) A = list(map(int, input().split())) money = 1000 for i in range(N-1): t = money + (A[i + 1] - A[i]) * (money // A[i]) money = max(money, t) print(money)
15
11
285
191
N = int(eval(input())) A = list(map(int, input().split())) dp = [0] * N dp[0] = 1000 for i in range(1, N): dp[i] = dp[i - 1] for j in range(i): kabu = dp[j] // A[j] money = dp[j] + (A[i] - A[j]) * kabu dp[i] = max(dp[i], money) print((dp[-1]))
N = int(eval(input())) A = list(map(int, input().split())) money = 1000 for i in range(N - 1): t = money + (A[i + 1] - A[i]) * (money // A[i]) money = max(money, t) print(money)
false
26.666667
[ "-dp = [0] * N", "-dp[0] = 1000", "-for i in range(1, N):", "- dp[i] = dp[i - 1]", "- for j in range(i):", "- kabu = dp[j] // A[j]", "- money = dp[j] + (A[i] - A[j]) * kabu", "- dp[i] = max(dp[i], money)", "-print((dp[-1]))", "+money = 1000", "+for i in range(N - 1):",...
false
0.08356
0.047466
1.760396
[ "s597097570", "s882300843" ]
u633068244
p00455
python
s908359315
s002934847
20
10
4,196
4,200
Accepted
Accepted
50
a,b=3600,60 for i in [1]*3: h,m,s,x,y,z=list(map(int,input().split())) s=(x-h)*a+(y-m)*b+(z-s) print(s//a,s%a//b,s%b)
b=60 a=b*b for i in [1]*3: h,m,s,x,y,z=list(map(int,input().split())) s=(x-h)*a+(y-m)*b+z-s print(s//a,s%a//b,s%b)
5
6
121
119
a, b = 3600, 60 for i in [1] * 3: h, m, s, x, y, z = list(map(int, input().split())) s = (x - h) * a + (y - m) * b + (z - s) print(s // a, s % a // b, s % b)
b = 60 a = b * b for i in [1] * 3: h, m, s, x, y, z = list(map(int, input().split())) s = (x - h) * a + (y - m) * b + z - s print(s // a, s % a // b, s % b)
false
16.666667
[ "-a, b = 3600, 60", "+b = 60", "+a = b * b", "- s = (x - h) * a + (y - m) * b + (z - s)", "+ s = (x - h) * a + (y - m) * b + z - s" ]
false
0.048531
0.049669
0.977098
[ "s908359315", "s002934847" ]
u497952650
p02813
python
s251347691
s678300212
135
27
3,064
8,052
Accepted
Accepted
80
import itertools N = int(eval(input())) PER = [] for i in range(N): PER.append(i+1) P = list(map(int,input().split())) Q = list(map(int,input().split())) a = 0 b = 0 tmp = 1 for x in itertools.permutations(PER): flag_a = 0 flag_b = 0 for i in range(N): if x[i] == P[...
from itertools import permutations N = int(eval(input())) P = tuple(map(int,input().split())) Q = tuple(map(int,input().split())) p = list(permutations(list(range(1,N+1)))) print((abs(p.index(P)-p.index(Q))))
35
9
555
205
import itertools N = int(eval(input())) PER = [] for i in range(N): PER.append(i + 1) P = list(map(int, input().split())) Q = list(map(int, input().split())) a = 0 b = 0 tmp = 1 for x in itertools.permutations(PER): flag_a = 0 flag_b = 0 for i in range(N): if x[i] == P[i]: flag_a +=...
from itertools import permutations N = int(eval(input())) P = tuple(map(int, input().split())) Q = tuple(map(int, input().split())) p = list(permutations(list(range(1, N + 1)))) print((abs(p.index(P) - p.index(Q))))
false
74.285714
[ "-import itertools", "+from itertools import permutations", "-PER = []", "-for i in range(N):", "- PER.append(i + 1)", "-P = list(map(int, input().split()))", "-Q = list(map(int, input().split()))", "-a = 0", "-b = 0", "-tmp = 1", "-for x in itertools.permutations(PER):", "- flag_a = 0",...
false
0.038539
0.090919
0.423881
[ "s251347691", "s678300212" ]
u614314290
p03240
python
s177217392
s525383553
777
126
3,064
3,064
Accepted
Accepted
83.78
N = int(eval(input())) XYH = [list(map(int, input().split())) for _ in range(N)] for cy in range(101): for cx in range(101): ch = None for x, y, h in XYH: if 0 == h: continue dy, dx = abs(y - cy), abs(x - cx) ch = h + dy + dx if all([h == max(0, ch - abs(y - cy) - abs(x - cx)) for x, y, ...
N = int(eval(input())) XYH = [list(map(int, input().split())) for _ in range(N)] for cx in range(101): for cy in range(101): ch = None for x, y, h in XYH: if 0 < h: ch = h + abs(x - cx) + abs(y - cy) if 0 < ch: break else: continue for x, y, h in XYH: th = max(0, ch - abs(x...
14
20
359
405
N = int(eval(input())) XYH = [list(map(int, input().split())) for _ in range(N)] for cy in range(101): for cx in range(101): ch = None for x, y, h in XYH: if 0 == h: continue dy, dx = abs(y - cy), abs(x - cx) ch = h + dy + dx if all([h == m...
N = int(eval(input())) XYH = [list(map(int, input().split())) for _ in range(N)] for cx in range(101): for cy in range(101): ch = None for x, y, h in XYH: if 0 < h: ch = h + abs(x - cx) + abs(y - cy) if 0 < ch: break else: ...
false
30
[ "-for cy in range(101):", "- for cx in range(101):", "+for cx in range(101):", "+ for cy in range(101):", "- if 0 == h:", "- continue", "- dy, dx = abs(y - cy), abs(x - cx)", "- ch = h + dy + dx", "- if all([h == max(0, ch - abs(y - cy) - ...
false
0.047498
0.05336
0.890144
[ "s177217392", "s525383553" ]
u790710233
p02713
python
s963140503
s653011703
632
22
71,604
9,192
Accepted
Accepted
96.52
from math import gcd k = int(eval(input())) double = [gcd(i, j) for i in range(1, k+1) for j in range(1, k+1)] triple = [gcd(i, j) for i in range(1, k+1) for j in double] print((sum(triple)))
k = int(eval(input())) d = [0]*(k+1) for i in range(1, k+1): d[i] = pow(k//i, 3) for i in reversed(list(range(1, k+1))): for j in range(2*i, k+1, i): d[i] -= d[j] ans = 0 for i in range(1, k+1): ans += i*d[i] print(ans)
5
14
188
244
from math import gcd k = int(eval(input())) double = [gcd(i, j) for i in range(1, k + 1) for j in range(1, k + 1)] triple = [gcd(i, j) for i in range(1, k + 1) for j in double] print((sum(triple)))
k = int(eval(input())) d = [0] * (k + 1) for i in range(1, k + 1): d[i] = pow(k // i, 3) for i in reversed(list(range(1, k + 1))): for j in range(2 * i, k + 1, i): d[i] -= d[j] ans = 0 for i in range(1, k + 1): ans += i * d[i] print(ans)
false
64.285714
[ "-from math import gcd", "-", "-double = [gcd(i, j) for i in range(1, k + 1) for j in range(1, k + 1)]", "-triple = [gcd(i, j) for i in range(1, k + 1) for j in double]", "-print((sum(triple)))", "+d = [0] * (k + 1)", "+for i in range(1, k + 1):", "+ d[i] = pow(k // i, 3)", "+for i in reversed(li...
false
0.199667
0.036191
5.516966
[ "s963140503", "s653011703" ]
u923270446
p03524
python
s624615631
s649675355
24
18
3,956
3,188
Accepted
Accepted
25
s = list(eval(input())) a, b, c = s.count("a"), s.count("b"), s.count("c") if abs(a - b) > 1 or abs(a - c) > 1 or abs(b - c) > 1: print("NO") else: print("YES")
s=eval(input()) a,b,c=s.count("a"),s.count("b"),s.count("c") print(("NO"if abs(a-b)>1 or abs(a-c)>1 or abs(b-c)>1else"YES"))
6
3
167
118
s = list(eval(input())) a, b, c = s.count("a"), s.count("b"), s.count("c") if abs(a - b) > 1 or abs(a - c) > 1 or abs(b - c) > 1: print("NO") else: print("YES")
s = eval(input()) a, b, c = s.count("a"), s.count("b"), s.count("c") print(("NO" if abs(a - b) > 1 or abs(a - c) > 1 or abs(b - c) > 1 else "YES"))
false
50
[ "-s = list(eval(input()))", "+s = eval(input())", "-if abs(a - b) > 1 or abs(a - c) > 1 or abs(b - c) > 1:", "- print(\"NO\")", "-else:", "- print(\"YES\")", "+print((\"NO\" if abs(a - b) > 1 or abs(a - c) > 1 or abs(b - c) > 1 else \"YES\"))" ]
false
0.047355
0.048062
0.985304
[ "s624615631", "s649675355" ]
u297574184
p03713
python
s240039365
s690896271
394
18
3,064
3,064
Accepted
Accepted
95.43
H, W = list(map(int, input().split())) def get_ans(A, B): ans = A * B for A1 in range(1, A): A2 = (A - A1) // 2 A3 = A - A1 - A2 S = [A1 * B, A2 * B, A3 * B] ans = min(ans, max(S) - min(S)) for A1 in range(1, A): B2 = B // 2 B3 = B - B2 ...
H, W = list(map(int, input().split())) def getMinDiff(A, B): if A % 3 == 0: return 0 elif B % 2 == 0: return B // 2 else: ans = B # 横3段に分ける場合の値 # T字型に分ける場合 for i in range(A % 3 + 1): A1 = A // 3 + i # 上半分の縦幅 B1, B2 = B // 2, (B +...
19
19
460
512
H, W = list(map(int, input().split())) def get_ans(A, B): ans = A * B for A1 in range(1, A): A2 = (A - A1) // 2 A3 = A - A1 - A2 S = [A1 * B, A2 * B, A3 * B] ans = min(ans, max(S) - min(S)) for A1 in range(1, A): B2 = B // 2 B3 = B - B2 S = [A1 * B, ...
H, W = list(map(int, input().split())) def getMinDiff(A, B): if A % 3 == 0: return 0 elif B % 2 == 0: return B // 2 else: ans = B # 横3段に分ける場合の値 # T字型に分ける場合 for i in range(A % 3 + 1): A1 = A // 3 + i # 上半分の縦幅 B1, B2 = B // 2, (B + 1) // 2 #...
false
0
[ "-def get_ans(A, B):", "- ans = A * B", "- for A1 in range(1, A):", "- A2 = (A - A1) // 2", "- A3 = A - A1 - A2", "- S = [A1 * B, A2 * B, A3 * B]", "- ans = min(ans, max(S) - min(S))", "- for A1 in range(1, A):", "- B2 = B // 2", "- B3 = B - B2", ...
false
1.106515
0.035597
31.084322
[ "s240039365", "s690896271" ]
u197968862
p03162
python
s392875776
s777479137
748
691
74,840
74,840
Accepted
Accepted
7.62
n = int(eval(input())) abc = [list(map(int,input().split())) for _ in range(n)] dp = [[0 for _ in range(3)] for _ in range(n+1)] for i in range(1,n+1): for j in range(3): for k in range(3): if j == k: continue dp[i][k] = max(dp[i][k],dp[i-1][j] + abc[i-1][...
n = int(eval(input())) abc = [list(map(int,input().split())) for _ in range(n)] dp = [[0 for _ in range(3)] for _ in range(n+1)] for i in range(1,n+1): for j in range(3): for k in range(3): if j == k: continue dp[i][k] = max(dp[i][k],dp[i-1][j] + abc[i-1][...
16
14
389
350
n = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(n)] dp = [[0 for _ in range(3)] for _ in range(n + 1)] for i in range(1, n + 1): for j in range(3): for k in range(3): if j == k: continue dp[i][k] = max(dp[i][k], dp[i - 1][j] + abc[i - 1][k...
n = int(eval(input())) abc = [list(map(int, input().split())) for _ in range(n)] dp = [[0 for _ in range(3)] for _ in range(n + 1)] for i in range(1, n + 1): for j in range(3): for k in range(3): if j == k: continue dp[i][k] = max(dp[i][k], dp[i - 1][j] + abc[i - 1][k...
false
12.5
[ "-ans = 0", "-for i in range(3):", "- ans = max(ans, dp[n][i])", "+ans = max(dp[-1])" ]
false
0.039372
0.036309
1.084359
[ "s392875776", "s777479137" ]
u156815136
p02777
python
s925730240
s925567244
42
17
5,304
2,940
Accepted
Accepted
59.52
import itertools import fractions def main(): s,t = list(map(str,input().split())) a,b = list(map(int,input().split())) u = eval(input()) if s == u: a -=1 else: b -=1 print((a,b)) if __name__ == '__main__': main()
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] #from itertools import combinations # (string,3) 3回 #from collections import deque #import collections.defaultdict(list) #import bisect # # d = m - k[i] - k[j] # if kk[bis...
13
32
227
672
import itertools import fractions def main(): s, t = list(map(str, input().split())) a, b = list(map(int, input().split())) u = eval(input()) if s == u: a -= 1 else: b -= 1 print((a, b)) if __name__ == "__main__": main()
# from statistics import median # import collections # aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] # from itertools import combinations # (string,3) 3回 # from collections import deque # import collections.defaultdict(list) # import bisect # # d = m - k[i] - k[j] # if kk[bisec...
false
59.375
[ "-import itertools", "-import fractions", "+# from statistics import median", "+# import collections", "+# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]", "+# from itertools import combinations # (string,3) 3回", "+# from collections import deque", "+# import collect...
false
0.038539
0.11377
0.338741
[ "s925730240", "s925567244" ]
u608088992
p03045
python
s583270624
s039492682
600
394
13,984
13,984
Accepted
Accepted
34.33
class UFT(): #Union-find tree class def __init__(self, N): self.tree = [int(i) for i in range(N)] self.rank = [0 for i in range(N)] def find(self, a): if self.tree[a] == a: return a else: self.tree[a] = self.find(self.tree[a]) return self.tree[...
import sys class UFT: #Union-find tree class def __init__(self, N): self.tree = [int(i) for i in range(N)] self.rank = [0 for i in range(N)] def find(self, a): if self.tree[a] == a: return a else: self.tree[a] = self.find(self.tree[a]) retur...
29
38
812
965
class UFT: # Union-find tree class def __init__(self, N): self.tree = [int(i) for i in range(N)] self.rank = [0 for i in range(N)] def find(self, a): if self.tree[a] == a: return a else: self.tree[a] = self.find(self.tree[a]) return self.tree...
import sys class UFT: # Union-find tree class def __init__(self, N): self.tree = [int(i) for i in range(N)] self.rank = [0 for i in range(N)] def find(self, a): if self.tree[a] == a: return a else: self.tree[a] = self.find(self.tree[a]) ret...
false
23.684211
[ "+import sys", "+", "+", "-N, M = list(map(int, input().split()))", "-parent = UFT(N)", "-for i in range(M):", "- x, y, z = list(map(int, input().split()))", "- parent.unite(x - 1, y - 1)", "-for i in range(N):", "- parent.find(i)", "-print((len(set(parent.tree))))", "+def solve():", ...
false
0.050726
0.05223
0.971203
[ "s583270624", "s039492682" ]
u816878803
p03135
python
s522666202
s638990808
34
17
5,076
2,940
Accepted
Accepted
50
import decimal T,X=list(map(int,input().split())) print(('{:.8f}'.format(T/X)))
T,X=list(map(float,input().split())) print((T/X))
3
2
73
42
import decimal T, X = list(map(int, input().split())) print(("{:.8f}".format(T / X)))
T, X = list(map(float, input().split())) print((T / X))
false
33.333333
[ "-import decimal", "-", "-T, X = list(map(int, input().split()))", "-print((\"{:.8f}\".format(T / X)))", "+T, X = list(map(float, input().split()))", "+print((T / X))" ]
false
0.040721
0.041132
0.989991
[ "s522666202", "s638990808" ]
u510829608
p02265
python
s441605383
s813510626
3,860
1,580
71,884
214,440
Accepted
Accepted
59.07
from collections import deque n = int(eval(input())) li = deque() for i in range(n): command = input().split() if command[0] == 'insert': li.appendleft(command[1]) elif command[0] == 'delete': try: li.remove(command[1]) except ValueError: pass ...
from collections import deque import sys dq = deque() num = int(sys.stdin.readline()) line = sys.stdin.readlines() for i in range(num): order = line[i].split() if order[0] == 'insert': dq.appendleft(order[1]) elif order[0] == 'deleteFirst': dq.popleft() elif order[...
17
22
414
453
from collections import deque n = int(eval(input())) li = deque() for i in range(n): command = input().split() if command[0] == "insert": li.appendleft(command[1]) elif command[0] == "delete": try: li.remove(command[1]) except ValueError: pass elif comman...
from collections import deque import sys dq = deque() num = int(sys.stdin.readline()) line = sys.stdin.readlines() for i in range(num): order = line[i].split() if order[0] == "insert": dq.appendleft(order[1]) elif order[0] == "deleteFirst": dq.popleft() elif order[0] == "deleteLast": ...
false
22.727273
[ "+import sys", "-n = int(eval(input()))", "-li = deque()", "-for i in range(n):", "- command = input().split()", "- if command[0] == \"insert\":", "- li.appendleft(command[1])", "- elif command[0] == \"delete\":", "- try:", "- li.remove(command[1])", "- e...
false
0.038948
0.045432
0.857273
[ "s441605383", "s813510626" ]
u391875425
p03141
python
s376016452
s261570000
521
424
32,224
32,296
Accepted
Accepted
18.62
n = int(eval(input())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(reverse = True, key = lambda x:x[0]+x[1]) ans = 0 for i in range(n): ans += (1-i%2)*ab[i][0] - (i%2)*ab[i][1] print(ans)
n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)] AB.sort(key=lambda x: - x[0] - x[1]) print((sum([a[0] for a in AB[::2]]) - sum([a[1] for a in AB[1::2]])))
7
4
212
181
n = int(eval(input())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(reverse=True, key=lambda x: x[0] + x[1]) ans = 0 for i in range(n): ans += (1 - i % 2) * ab[i][0] - (i % 2) * ab[i][1] print(ans)
n = int(eval(input())) AB = [list(map(int, input().split())) for _ in range(n)] AB.sort(key=lambda x: -x[0] - x[1]) print((sum([a[0] for a in AB[::2]]) - sum([a[1] for a in AB[1::2]])))
false
42.857143
[ "-ab = [list(map(int, input().split())) for _ in range(n)]", "-ab.sort(reverse=True, key=lambda x: x[0] + x[1])", "-ans = 0", "-for i in range(n):", "- ans += (1 - i % 2) * ab[i][0] - (i % 2) * ab[i][1]", "-print(ans)", "+AB = [list(map(int, input().split())) for _ in range(n)]", "+AB.sort(key=lamb...
false
0.037111
0.061451
0.603913
[ "s376016452", "s261570000" ]
u562935282
p03213
python
s769924351
s498624616
30
18
3,700
3,064
Accepted
Accepted
40
from copy import deepcopy def mk_array(init_val, *args): args = args[::-1] res = [init_val for _ in range(args[0])] for arg in args[1:]: res = [deepcopy(res) for _ in range(arg)] return res N = int(eval(input())) e = [0 for _ in range(N + 1)] for i in range(2, N + 1): for...
N = int(eval(input())) e = [0 for _ in range(N + 1)] for i in range(2, N + 1): for j in range(2, i + 1): while i % j == 0: e[j] += 1 i //= j def num(m): return len(tuple([x for x in e if x >= m - 1])) ans = 0 ans += num(75) ans += num(25) * (num(3) - 1) ans ...
32
21
778
407
from copy import deepcopy def mk_array(init_val, *args): args = args[::-1] res = [init_val for _ in range(args[0])] for arg in args[1:]: res = [deepcopy(res) for _ in range(arg)] return res N = int(eval(input())) e = [0 for _ in range(N + 1)] for i in range(2, N + 1): for j in range(2, i...
N = int(eval(input())) e = [0 for _ in range(N + 1)] for i in range(2, N + 1): for j in range(2, i + 1): while i % j == 0: e[j] += 1 i //= j def num(m): return len(tuple([x for x in e if x >= m - 1])) ans = 0 ans += num(75) ans += num(25) * (num(3) - 1) ans += num(15) * (num(...
false
34.375
[ "-from copy import deepcopy", "-", "-", "-def mk_array(init_val, *args):", "- args = args[::-1]", "- res = [init_val for _ in range(args[0])]", "- for arg in args[1:]:", "- res = [deepcopy(res) for _ in range(arg)]", "- return res", "-", "-", "-counts = list([x for x in e if...
false
0.047624
0.038211
1.246348
[ "s769924351", "s498624616" ]
u285681431
p02990
python
s490168877
s290226944
157
90
9,184
73,564
Accepted
Accepted
42.68
N, K = list(map(int, input().split())) # x_1 + x_2 + ... x_k = n # x_i >= 0 # k個の箱にn個のボールを入れる重複組み合わせ n+k-1_C_k-1 # n個の玉とk-1個の仕切りを並べる # x_1 + x_2 + ... x_k = n # x_i >= 1 # k個の箱にn個のボールを1個以上入れる重複組み合わせ n-1_C_k-1 # n個の玉の仕切りn-1個の中に、k-1箇所仕切りを入れる from math import factorial # k = 1,2,...,K for k in range(1, ...
from math import factorial N, K = list(map(int, input().split())) # 逆元を利用した組み合わせの計算 ############################################################# def cmb(n, r, mod): if (r < 0 or r > n): return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod mod = 10**9 + 7 NN = 2500 g1 =...
40
49
887
1,151
N, K = list(map(int, input().split())) # x_1 + x_2 + ... x_k = n # x_i >= 0 # k個の箱にn個のボールを入れる重複組み合わせ n+k-1_C_k-1 # n個の玉とk-1個の仕切りを並べる # x_1 + x_2 + ... x_k = n # x_i >= 1 # k個の箱にn個のボールを1個以上入れる重複組み合わせ n-1_C_k-1 # n個の玉の仕切りn-1個の中に、k-1箇所仕切りを入れる from math import factorial # k = 1,2,...,K for k in range(1, K + 1): if k >...
from math import factorial N, K = list(map(int, input().split())) # 逆元を利用した組み合わせの計算 ############################################################# def cmb(n, r, mod): if r < 0 or r > n: return 0 r = min(r, n - r) return g1[n] * g2[r] * g2[n - r] % mod mod = 10**9 + 7 NN = 2500 g1 = [1, 1] g2 = [1,...
false
18.367347
[ "-N, K = list(map(int, input().split()))", "-# x_1 + x_2 + ... x_k = n", "-# x_i >= 0", "-# k個の箱にn個のボールを入れる重複組み合わせ n+k-1_C_k-1", "-# n個の玉とk-1個の仕切りを並べる", "-# x_1 + x_2 + ... x_k = n", "-# x_i >= 1", "-# k個の箱にn個のボールを1個以上入れる重複組み合わせ n-1_C_k-1", "-# n個の玉の仕切りn-1個の中に、k-1箇所仕切りを入れる", "-# k = 1,2,...,K", ...
false
0.03917
0.042293
0.926147
[ "s490168877", "s290226944" ]
u394721319
p03162
python
s624750750
s270577017
718
636
58,972
74,072
Accepted
Accepted
11.42
N = int(eval(input())) dp = [[0 for _ in range(3)] for _ in range(N)] a,b,c = [int(i) for i in input().split()] dp[0][0] = a dp[0][1] = b dp[0][2] = c for i in range(1,N): li = [int(i) for i in input().split()] for j in range(3): tmp = [] for k in range(3): if j != k...
N = int(eval(input())) A = [[int(i) for i in input().split()] for _ in range(N)] dp = [[0]*3 for _ in range(N)] dp[0] = A[0] for i in range(1,N): for j in range(3): for k in range(3): if j != k: dp[i][k] = max(dp[i][k], dp[i-1][j]+A[i][k]) print((max(dp[-1])))
19
13
415
308
N = int(eval(input())) dp = [[0 for _ in range(3)] for _ in range(N)] a, b, c = [int(i) for i in input().split()] dp[0][0] = a dp[0][1] = b dp[0][2] = c for i in range(1, N): li = [int(i) for i in input().split()] for j in range(3): tmp = [] for k in range(3): if j != k: ...
N = int(eval(input())) A = [[int(i) for i in input().split()] for _ in range(N)] dp = [[0] * 3 for _ in range(N)] dp[0] = A[0] for i in range(1, N): for j in range(3): for k in range(3): if j != k: dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i][k]) print((max(dp[-1])))
false
31.578947
[ "-dp = [[0 for _ in range(3)] for _ in range(N)]", "-a, b, c = [int(i) for i in input().split()]", "-dp[0][0] = a", "-dp[0][1] = b", "-dp[0][2] = c", "+A = [[int(i) for i in input().split()] for _ in range(N)]", "+dp = [[0] * 3 for _ in range(N)]", "+dp[0] = A[0]", "- li = [int(i) for i in input(...
false
0.046664
0.047307
0.986413
[ "s624750750", "s270577017" ]
u638902622
p03730
python
s052361596
s477245492
24
22
3,316
3,444
Accepted
Accepted
8.33
import sys ## io ## def IS(): return sys.stdin.readline().rstrip() def II(): return int(IS()) def MII(): return list(map(int, IS().split())) def MIIZ(): return list([x-1 for x in MII()]) ## dp ## def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)] def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _...
import sys ## io ## def IS(): return sys.stdin.readline().rstrip() def II(): return int(IS()) def MII(): return list(map(int, IS().split())) def MIIZ(): return list([x-1 for x in MII()]) ## dp ## def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)] def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _...
59
49
1,943
1,757
import sys ## io ## def IS(): return sys.stdin.readline().rstrip() def II(): return int(IS()) def MII(): return list(map(int, IS().split())) def MIIZ(): return list([x - 1 for x in MII()]) ## dp ## def DD2(d1, d2, init=0): return [[init] * d2 for _ in range(d1)] def DD3(d1, d2, d3, init=0...
import sys ## io ## def IS(): return sys.stdin.readline().rstrip() def II(): return int(IS()) def MII(): return list(map(int, IS().split())) def MIIZ(): return list([x - 1 for x in MII()]) ## dp ## def DD2(d1, d2, init=0): return [[init] * d2 for _ in range(d1)] def DD3(d1, d2, d3, init=0...
false
16.949153
[ "- r = a % b", "- ri = r", "- if r == 0:", "- if r == c:", "+ for i in range(1, b):", "+ if (a * i) % b == c:", "- else:", "- print(\"NO\")", "- return None", "- while r < 10**5:", "- if r % b == c:", "- print(\"YES\")...
false
0.04213
0.103937
0.40534
[ "s052361596", "s477245492" ]
u745087332
p04020
python
s217695486
s386399785
240
93
7,072
7,072
Accepted
Accepted
61.25
# coding:utf-8 INF = float('inf') def inpl(): return list(map(int, input().split())) N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] ans = 0 prev = 0 for i in range(N): if prev == 1 and A[i] > 0: A[i] -= 1 ans += 1 q, mod = divmod(A[i], 2) ans += q ...
# coding:utf-8 import sys INF = float('inf') MOD = 10 ** 9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split()...
22
32
336
655
# coding:utf-8 INF = float("inf") def inpl(): return list(map(int, input().split())) N = int(eval(input())) A = [int(eval(input())) for _ in range(N)] ans = 0 prev = 0 for i in range(N): if prev == 1 and A[i] > 0: A[i] -= 1 ans += 1 q, mod = divmod(A[i], 2) ans += q prev = mod pr...
# coding:utf-8 import sys INF = float("inf") MOD = 10**9 + 7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline...
false
31.25
[ "+import sys", "+", "+MOD = 10**9 + 7", "-def inpl():", "- return list(map(int, input().split()))", "+def LI():", "+ return [int(x) for x in sys.stdin.readline().split()]", "-N = int(eval(input()))", "-A = [int(eval(input())) for _ in range(N)]", "-ans = 0", "-prev = 0", "-for i in range...
false
0.007015
0.068986
0.101684
[ "s217695486", "s386399785" ]
u987164499
p03424
python
s465560961
s085902264
150
17
12,396
2,940
Accepted
Accepted
88.67
from sys import stdin import numpy as np import math n = int(stdin.readline().rstrip()) s = stdin.readline().rstrip() s = [str(i) for i in s] if "Y" in s: print("Four") else: print("Three")
from sys import stdin,setrecursionlimit setrecursionlimit(10 ** 7) n = int(stdin.readline().rstrip()) s = input().split() li = set() for i in s: li.add(i) if len(li) == 3: print("Three") elif len(li) == 4: print("Four")
12
16
210
255
from sys import stdin import numpy as np import math n = int(stdin.readline().rstrip()) s = stdin.readline().rstrip() s = [str(i) for i in s] if "Y" in s: print("Four") else: print("Three")
from sys import stdin, setrecursionlimit setrecursionlimit(10**7) n = int(stdin.readline().rstrip()) s = input().split() li = set() for i in s: li.add(i) if len(li) == 3: print("Three") elif len(li) == 4: print("Four")
false
25
[ "-from sys import stdin", "-import numpy as np", "-import math", "+from sys import stdin, setrecursionlimit", "+setrecursionlimit(10**7)", "-s = stdin.readline().rstrip()", "-s = [str(i) for i in s]", "-if \"Y\" in s:", "+s = input().split()", "+li = set()", "+for i in s:", "+ li.add(i)", ...
false
0.084929
0.077991
1.088955
[ "s465560961", "s085902264" ]
u094191970
p02554
python
s643047562
s655955949
504
31
9,180
9,092
Accepted
Accepted
93.85
n=int(eval(input())) mod=10**9+7 a1=1 a2=1 a3=1 for i in range(n): a1*=10 a2*=9 a3*=8 a1%=mod a2%=mod a3%=mod ans=a1-a2-a2+a3 ans%=mod print(ans)
n=int(eval(input())) mod=10**9+7 ans=pow(10,n,mod) ans-=pow(9,n,mod)*2 ans+=pow(8,n,mod) print((ans%mod))
18
6
171
102
n = int(eval(input())) mod = 10**9 + 7 a1 = 1 a2 = 1 a3 = 1 for i in range(n): a1 *= 10 a2 *= 9 a3 *= 8 a1 %= mod a2 %= mod a3 %= mod ans = a1 - a2 - a2 + a3 ans %= mod print(ans)
n = int(eval(input())) mod = 10**9 + 7 ans = pow(10, n, mod) ans -= pow(9, n, mod) * 2 ans += pow(8, n, mod) print((ans % mod))
false
66.666667
[ "-a1 = 1", "-a2 = 1", "-a3 = 1", "-for i in range(n):", "- a1 *= 10", "- a2 *= 9", "- a3 *= 8", "- a1 %= mod", "- a2 %= mod", "- a3 %= mod", "-ans = a1 - a2 - a2 + a3", "-ans %= mod", "-print(ans)", "+ans = pow(10, n, mod)", "+ans -= pow(9, n, mod) * 2", "+ans += pow(...
false
0.335034
0.0362
9.255066
[ "s643047562", "s655955949" ]
u968166680
p03436
python
s680458909
s195150244
29
25
3,700
3,316
Accepted
Accepted
13.79
from sys import stdin, setrecursionlimit from collections import deque setrecursionlimit(10 ** 9) def input(): return stdin.readline().strip() def main(): H, W = list(map(int, input().split())) s = [eval(input()) for _ in range(H)] gx, gy = H - 1, W - 1 q = deque([(0, 0)]) ...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): H, W = list(map(int, readline().split())) G = [0] * H for i in range(H): G[i] = readline().strip() ...
38
41
915
1,030
from sys import stdin, setrecursionlimit from collections import deque setrecursionlimit(10**9) def input(): return stdin.readline().strip() def main(): H, W = list(map(int, input().split())) s = [eval(input()) for _ in range(H)] gx, gy = H - 1, W - 1 q = deque([(0, 0)]) dist = [[-1] * W fo...
import sys from collections import deque read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def main(): H, W = list(map(int, readline().split())) G = [0] * H for i in range(H): G[i] = readline().strip() dxdy4 = ((-1, ...
false
7.317073
[ "-from sys import stdin, setrecursionlimit", "+import sys", "-setrecursionlimit(10**9)", "-", "-", "-def input():", "- return stdin.readline().strip()", "+read = sys.stdin.read", "+readline = sys.stdin.readline", "+readlines = sys.stdin.readlines", "+sys.setrecursionlimit(10**9)", "+INF = 1...
false
0.038497
0.038393
1.002704
[ "s680458909", "s195150244" ]
u411203878
p02834
python
s469386070
s283476339
373
322
91,644
91,640
Accepted
Accepted
13.67
from collections import deque def bfs(s): stack=deque([s]) check = [-1]*n check[s] = 0 while len(stack)>0: v = stack.popleft() for i in root[v]: if check[i] == -1: check[i]=check[v]+1 stack.append(i) return check n,u,v = lis...
from collections import deque N,u,v = list(map(int,input().split())) root = [[] for i in range(N)] for _ in range(N-1): a, b = (int(x) for x in input().split()) root[b-1].append(a-1) root[a-1].append(b-1) def search(p): stack=deque([p]) check = [-1]*N check[p] = 0 while l...
31
30
674
647
from collections import deque def bfs(s): stack = deque([s]) check = [-1] * n check[s] = 0 while len(stack) > 0: v = stack.popleft() for i in root[v]: if check[i] == -1: check[i] = check[v] + 1 stack.append(i) return check n, u, v = lis...
from collections import deque N, u, v = list(map(int, input().split())) root = [[] for i in range(N)] for _ in range(N - 1): a, b = (int(x) for x in input().split()) root[b - 1].append(a - 1) root[a - 1].append(b - 1) def search(p): stack = deque([p]) check = [-1] * N check[p] = 0 while l...
false
3.225806
[ "+N, u, v = list(map(int, input().split()))", "+root = [[] for i in range(N)]", "+for _ in range(N - 1):", "+ a, b = (int(x) for x in input().split())", "+ root[b - 1].append(a - 1)", "+ root[a - 1].append(b - 1)", "-def bfs(s):", "- stack = deque([s])", "- check = [-1] * n", "- ...
false
0.036286
0.074055
0.489984
[ "s469386070", "s283476339" ]
u670567845
p02767
python
s368960453
s618190456
65
27
63,700
9,036
Accepted
Accepted
58.46
N = int(eval(input())) X = list(map(int, input().split())) al = [] for i in range(100): d = 0 p = i+1 for j in range(N): d += (X[j]-p)**2 al.append(d) print((min(al)))
N = int(eval(input())) X = list(map(int, input().split())) X = sorted(X) avg = sum(X)//N aa = [] for i in range(2): avg = avg + i a = 0 for j in range(N): a += (X[j] - avg)**2 aa.append(a) print((min(aa)))
11
12
182
220
N = int(eval(input())) X = list(map(int, input().split())) al = [] for i in range(100): d = 0 p = i + 1 for j in range(N): d += (X[j] - p) ** 2 al.append(d) print((min(al)))
N = int(eval(input())) X = list(map(int, input().split())) X = sorted(X) avg = sum(X) // N aa = [] for i in range(2): avg = avg + i a = 0 for j in range(N): a += (X[j] - avg) ** 2 aa.append(a) print((min(aa)))
false
8.333333
[ "-al = []", "-for i in range(100):", "- d = 0", "- p = i + 1", "+X = sorted(X)", "+avg = sum(X) // N", "+aa = []", "+for i in range(2):", "+ avg = avg + i", "+ a = 0", "- d += (X[j] - p) ** 2", "- al.append(d)", "-print((min(al)))", "+ a += (X[j] - avg) ** 2", ...
false
0.033935
0.033627
1.009156
[ "s368960453", "s618190456" ]
u535803878
p02902
python
s164498120
s578476611
195
85
40,432
75,264
Accepted
Accepted
56.41
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m = list(map(int, input().split())) from collections import defaultdict ns = defaultdict(set) for i in range(m): a,b = list(map(int, input().split())) ns[...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") from collections import defaultdict n,m = list(map(int, input().split())) ns = defaultdict(set) es = set() for _ in range(m): u,v = list(map(int, input().split())...
68
85
1,716
1,999
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") n, m = list(map(int, input().split())) from collections import defaultdict ns = defaultdict(set) for i in range(m): a, b = list(map(int, input().split())) ns[a - 1].add...
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x + "\n") from collections import defaultdict n, m = list(map(int, input().split())) ns = defaultdict(set) es = set() for _ in range(m): u, v = list(map(int, input().split())) u ...
false
20
[ "-n, m = list(map(int, input().split()))", "+n, m = list(map(int, input().split()))", "-for i in range(m):", "- a, b = list(map(int, input().split()))", "- ns[a - 1].add(b - 1)", "+es = set()", "+for _ in range(m):", "+ u, v = list(map(int, input().split()))", "+ u -= 1", "+ v -= 1"...
false
0.038013
0.038238
0.994105
[ "s164498120", "s578476611" ]
u477977638
p02824
python
s374298073
s557007365
213
117
56,944
12,992
Accepted
Accepted
45.07
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines # mod=10**9+7 # rstrip().decode('utf-8') # map(int,input().split()) #import numpy as np def main(): n,m,v,p=list(map(int,input().split())) A=list(map(int,input().split())) A.sort(rev...
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines # mod=10**9+7 # rstrip().decode('utf-8') # map(int,input().split()) #import numpy as np import bisect def main(): n,m,v,p=list(map(int,input().split())) A=list(map(int,input().split()))...
35
35
535
548
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines # mod=10**9+7 # rstrip().decode('utf-8') # map(int,input().split()) # import numpy as np def main(): n, m, v, p = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=...
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines # mod=10**9+7 # rstrip().decode('utf-8') # map(int,input().split()) # import numpy as np import bisect def main(): n, m, v, p = list(map(int, input().split())) A = list(map(int, input().split())) ...
false
0
[ "+import bisect", "+", "+" ]
false
0.053116
0.035552
1.494058
[ "s374298073", "s557007365" ]
u200887663
p03828
python
s670831922
s702908209
268
31
42,608
9,168
Accepted
Accepted
88.43
n=int(eval(input())) #w,h,x,y,r=map(int,input().split()) #al=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] #素因数分解した結果を2次元配列にして返す def prime_factorize(n): n_origin=n+0 primelist=[] a=2 while a*a<=n_origin: if n%a!=0: a+=1 c...
n=int(eval(input())) #a,b=map(int,input().split()) #l=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] def prime_factorize(n): n_origin=n+0 primelist=[] a=2 while a*a<=n_origin: if n%a!=0: a+=1 continue ex=0 ...
34
33
734
679
n = int(eval(input())) # w,h,x,y,r=map(int,input().split()) # al=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] # 素因数分解した結果を2次元配列にして返す def prime_factorize(n): n_origin = n + 0 primelist = [] a = 2 while a * a <= n_origin: if n % a != 0: a += 1 ...
n = int(eval(input())) # a,b=map(int,input().split()) # l=list(map(int,input().split())) # l=[list(map(int,input().split())) for i in range(n)] def prime_factorize(n): n_origin = n + 0 primelist = [] a = 2 while a * a <= n_origin: if n % a != 0: a += 1 continue ex...
false
2.941176
[ "-# w,h,x,y,r=map(int,input().split())", "-# al=list(map(int,input().split()))", "+# a,b=map(int,input().split())", "+# l=list(map(int,input().split()))", "-# 素因数分解した結果を2次元配列にして返す", "-dic = {}", "-for i in range(1, n + 1):", "- pfs = prime_factorize(i)", "- for pf in pfs:", "- dic[pf[...
false
0.039075
0.041937
0.931757
[ "s670831922", "s702908209" ]
u707808519
p02802
python
s419777652
s273005811
405
192
14,924
19,892
Accepted
Accepted
52.59
N, M = list(map(int, input().split())) p = [0] * M s = [0] * M for i in range(M): p[i], s[i] = list(map(str, input().split())) p[i] = int(p[i]) ''' a = [0] * M for i in range(M): a[i] = [p[i],s[i]] ''' maru = [0] * (N+1) batu = [0] * (N+1) for i in range(M): if s[i] == "AC" and maru[p[...
N, M = list(map(int, input().split())) wro = dict() cor = set() for _ in range(M): p, s = input().split() if s == 'AC': cor.add(p) elif s == 'WA' and p not in cor: wro[p] = wro.get(p, 0) + 1 wro_num = 0 for i in cor: wro_num += wro.get(i, 0) print((len(cor), wro_num))
31
16
658
310
N, M = list(map(int, input().split())) p = [0] * M s = [0] * M for i in range(M): p[i], s[i] = list(map(str, input().split())) p[i] = int(p[i]) """ a = [0] * M for i in range(M): a[i] = [p[i],s[i]] """ maru = [0] * (N + 1) batu = [0] * (N + 1) for i in range(M): if s[i] == "AC" and maru[p[i]] == 0: ...
N, M = list(map(int, input().split())) wro = dict() cor = set() for _ in range(M): p, s = input().split() if s == "AC": cor.add(p) elif s == "WA" and p not in cor: wro[p] = wro.get(p, 0) + 1 wro_num = 0 for i in cor: wro_num += wro.get(i, 0) print((len(cor), wro_num))
false
48.387097
[ "-p = [0] * M", "-s = [0] * M", "-for i in range(M):", "- p[i], s[i] = list(map(str, input().split()))", "- p[i] = int(p[i])", "-\"\"\"", "-a = [0] * M", "-for i in range(M):", "- a[i] = [p[i],s[i]]", "-\"\"\"", "-maru = [0] * (N + 1)", "-batu = [0] * (N + 1)", "-for i in range(M):"...
false
0.044307
0.066283
0.668452
[ "s419777652", "s273005811" ]
u086056891
p03112
python
s255801506
s061383448
1,151
805
45,000
45,048
Accepted
Accepted
30.06
a, b, q = list(map(int, input().split())) INF = 10 ** 11 s = [int(eval(input())) for _ in range(a)] + [INF] t = [int(eval(input())) for _ in range(b)] + [INF] x = [[int(eval(input())), int(i), INF, INF, INF, INF] for i in range(q)] x.sort(key=lambda x: x[0]) si = 0 ti = 0 for i in range(q): xi = x[i][0] ...
import sys input = sys.stdin.readline a, b, q = list(map(int, input().split())) INF = 10 ** 11 s = [int(eval(input())) for _ in range(a)] + [INF] t = [int(eval(input())) for _ in range(b)] + [INF] x = [[int(eval(input())), int(i), INF, INF, INF, INF] for i in range(q)] x.sort(key=lambda x: x[0]) si = 0 ti = ...
32
35
788
830
a, b, q = list(map(int, input().split())) INF = 10**11 s = [int(eval(input())) for _ in range(a)] + [INF] t = [int(eval(input())) for _ in range(b)] + [INF] x = [[int(eval(input())), int(i), INF, INF, INF, INF] for i in range(q)] x.sort(key=lambda x: x[0]) si = 0 ti = 0 for i in range(q): xi = x[i][0] while xi ...
import sys input = sys.stdin.readline a, b, q = list(map(int, input().split())) INF = 10**11 s = [int(eval(input())) for _ in range(a)] + [INF] t = [int(eval(input())) for _ in range(b)] + [INF] x = [[int(eval(input())), int(i), INF, INF, INF, INF] for i in range(q)] x.sort(key=lambda x: x[0]) si = 0 ti = 0 for i in r...
false
8.571429
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.06507
0.043035
1.512038
[ "s255801506", "s061383448" ]
u472065247
p03634
python
s745269927
s983252944
1,102
806
87,476
87,500
Accepted
Accepted
26.86
N = int(eval(input())) ABC = [list(map(int, input().split())) for _ in range(N - 1)] Q, K = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in range(Q)] G = [[] * N for _ in range(N)] for a, b, c in ABC: G[a - 1].append((b - 1, c)) G[b - 1].append((a - 1, c)) D = [-1] * N s ...
import sys input = sys.stdin.readline N = int(eval(input())) ABC = [list(map(int, input().split())) for _ in range(N - 1)] Q, K = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in range(Q)] G = [[] * N for _ in range(N)] for a, b, c in ABC: G[a - 1].append((b - 1, c)) G[b -...
21
24
485
527
N = int(eval(input())) ABC = [list(map(int, input().split())) for _ in range(N - 1)] Q, K = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in range(Q)] G = [[] * N for _ in range(N)] for a, b, c in ABC: G[a - 1].append((b - 1, c)) G[b - 1].append((a - 1, c)) D = [-1] * N s = [(K - 1...
import sys input = sys.stdin.readline N = int(eval(input())) ABC = [list(map(int, input().split())) for _ in range(N - 1)] Q, K = list(map(int, input().split())) XY = [list(map(int, input().split())) for _ in range(Q)] G = [[] * N for _ in range(N)] for a, b, c in ABC: G[a - 1].append((b - 1, c)) G[b - 1].appe...
false
12.5
[ "+import sys", "+", "+input = sys.stdin.readline" ]
false
0.033086
0.035855
0.922773
[ "s745269927", "s983252944" ]
u998733244
p02713
python
s701577854
s218651053
739
140
9,248
71,136
Accepted
Accepted
81.06
#!/usr/bin/env python3 import math MOD = 10**9 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors K = int(eval(input())) ans = 0 for i i...
import math K = int(eval(input())) ans = 0 for i in range(1, K+1): for j in range(i, K+1): for k in range(j, K+1): if i==j and i==k: g = i elif (i==j and i!=k): g = math.gcd(i,math.gcd(j,k))*3 elif (i==k and i!=j): g = math.gc...
28
18
768
505
#!/usr/bin/env python3 import math MOD = 10**9 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors K = int(eval(input())) ans = 0 for i in range(...
import math K = int(eval(input())) ans = 0 for i in range(1, K + 1): for j in range(i, K + 1): for k in range(j, K + 1): if i == j and i == k: g = i elif i == j and i != k: g = math.gcd(i, math.gcd(j, k)) * 3 elif i == k and i != j: ...
false
35.714286
[ "-#!/usr/bin/env python3", "-", "-MOD = 10**9", "-", "-", "-def make_divisors(n):", "- divisors = []", "- for i in range(1, int(n**0.5) + 1):", "- if n % i == 0:", "- divisors.append(i)", "- if i != n // i:", "- divisors.append(n // i)", "- ...
false
0.093684
0.08215
1.14041
[ "s701577854", "s218651053" ]
u739456942
p03137
python
s337815298
s366791494
118
106
13,968
13,964
Accepted
Accepted
10.17
n, m = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() if n < m: x_distance = [abs(x[i + 1] - x[i]) for i in range(m - 1)] x_distance.sort() ans = 0 for i in range (m - n): ans += x_distance[i] print(ans) else: print((0))
n, m = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() if n < m: x_distance = [x[i + 1] - x[i] for i in range(m - 1)] x_distance.sort() ans = 0 for i in range (m - n): ans += x_distance[i] print(ans) else: print((0))
13
13
288
283
n, m = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() if n < m: x_distance = [abs(x[i + 1] - x[i]) for i in range(m - 1)] x_distance.sort() ans = 0 for i in range(m - n): ans += x_distance[i] print(ans) else: print((0))
n, m = list(map(int, input().split())) x = list(map(int, input().split())) x.sort() if n < m: x_distance = [x[i + 1] - x[i] for i in range(m - 1)] x_distance.sort() ans = 0 for i in range(m - n): ans += x_distance[i] print(ans) else: print((0))
false
0
[ "- x_distance = [abs(x[i + 1] - x[i]) for i in range(m - 1)]", "+ x_distance = [x[i + 1] - x[i] for i in range(m - 1)]" ]
false
0.144764
0.039217
3.691395
[ "s337815298", "s366791494" ]
u724687935
p02839
python
s261848644
s005067817
675
448
55,516
53,052
Accepted
Accepted
33.63
def main(): # import sys # readline = sys.stdin.readline # readlines = sys.stdin.readlines H, W = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(H)] B = [list(map(int, input().split())) for _ in range(H)] M = 0 grid = [[0] * W for _ in range(H...
def main(): # import sys # readline = sys.stdin.readline # readlines = sys.stdin.readlines H, W = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(H)] B = [list(map(int, input().split())) for _ in range(H)] M = 0 grid = [[0] * W for _ in range(H...
46
45
1,349
1,150
def main(): # import sys # readline = sys.stdin.readline # readlines = sys.stdin.readlines H, W = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(H)] B = [list(map(int, input().split())) for _ in range(H)] M = 0 grid = [[0] * W for _ in range(H)] f...
def main(): # import sys # readline = sys.stdin.readline # readlines = sys.stdin.readlines H, W = list(map(int, input().split())) A = [list(map(int, input().split())) for _ in range(H)] B = [list(map(int, input().split())) for _ in range(H)] M = 0 grid = [[0] * W for _ in range(H)] f...
false
2.173913
[ "- dp[0][0] = 1 << grid[0][0]", "+ dp[0][0] = 1 << 0", "+ k = grid[i][j]", "+ dp[i][j] = (here << k) | (here >> k)", "+ for l in range(1, k + 1):", "+ if (here >> l) & 1:", "+ dp[i][j] |= 1 << (k - l)", "- nk = gri...
false
0.038811
0.107051
0.362545
[ "s261848644", "s005067817" ]
u919633157
p04030
python
s235719440
s762280483
22
17
2,940
2,940
Accepted
Accepted
22.73
s=list(eval(input())) ans=[] for i in s: if i=='B' : if ans: ans.pop() else:ans.append(i) print((''.join(ans)))
# https://atcoder.jp/contests/abc043/tasks/abc043_b s=input() res=[] for e in s: if e=='B': if res: res.pop() else:continue else: res.append(e) print(*res,sep='')
7
13
125
220
s = list(eval(input())) ans = [] for i in s: if i == "B": if ans: ans.pop() else: ans.append(i) print(("".join(ans)))
# https://atcoder.jp/contests/abc043/tasks/abc043_b s = input() res = [] for e in s: if e == "B": if res: res.pop() else: continue else: res.append(e) print(*res, sep="")
false
46.153846
[ "-s = list(eval(input()))", "-ans = []", "-for i in s:", "- if i == \"B\":", "- if ans:", "- ans.pop()", "+# https://atcoder.jp/contests/abc043/tasks/abc043_b", "+s = input()", "+res = []", "+for e in s:", "+ if e == \"B\":", "+ if res:", "+ res.pop(...
false
0.036843
0.037185
0.990792
[ "s235719440", "s762280483" ]
u831244171
p02264
python
s233678331
s510573614
1,210
350
11,284
16,068
Accepted
Accepted
71.07
n,q = list(map(int,input().split())) name = [] time = [] for i in range(n): a = input().split() name.append(a[0]) time.append(int(a[1])) s = 0 while name: if time[0]> q: time[0] -= q time.append(time.pop(0)) name.append(name.pop(0)) s += q else: ...
from collections import deque n,q = list(map(int,input().split())) Q = deque() for i in range(n): a = input().split() Q.append([a[0],int(a[1])]) s = 0 while Q: qt = Q.popleft() if qt[1] > q: Q.append([qt[0],qt[1]-q]) s += q else: s += qt[1] ...
18
19
379
328
n, q = list(map(int, input().split())) name = [] time = [] for i in range(n): a = input().split() name.append(a[0]) time.append(int(a[1])) s = 0 while name: if time[0] > q: time[0] -= q time.append(time.pop(0)) name.append(name.pop(0)) s += q else: s += time[0...
from collections import deque n, q = list(map(int, input().split())) Q = deque() for i in range(n): a = input().split() Q.append([a[0], int(a[1])]) s = 0 while Q: qt = Q.popleft() if qt[1] > q: Q.append([qt[0], qt[1] - q]) s += q else: s += qt[1] print((qt[0], s))
false
5.263158
[ "+from collections import deque", "+", "-name = []", "-time = []", "+Q = deque()", "- name.append(a[0])", "- time.append(int(a[1]))", "+ Q.append([a[0], int(a[1])])", "-while name:", "- if time[0] > q:", "- time[0] -= q", "- time.append(time.pop(0))", "- name...
false
0.036148
0.056653
0.638066
[ "s233678331", "s510573614" ]
u991567869
p02743
python
s227095706
s623349492
19
17
3,060
2,940
Accepted
Accepted
10.53
a, b, c = list(map(int, input().split())) ab = 4*a*b cab = c - a - b if cab <= 0: print("No") elif cab**2 - ab > 0: print("Yes") else: print("No")
a, b, c = list(map(int, input().split())) if c - a - b > 0: if 4*a*b < c*c + (a + b)*(a + b - 2*c): print("Yes") exit() print("No")
11
8
164
154
a, b, c = list(map(int, input().split())) ab = 4 * a * b cab = c - a - b if cab <= 0: print("No") elif cab**2 - ab > 0: print("Yes") else: print("No")
a, b, c = list(map(int, input().split())) if c - a - b > 0: if 4 * a * b < c * c + (a + b) * (a + b - 2 * c): print("Yes") exit() print("No")
false
27.272727
[ "-ab = 4 * a * b", "-cab = c - a - b", "-if cab <= 0:", "- print(\"No\")", "-elif cab**2 - ab > 0:", "- print(\"Yes\")", "-else:", "- print(\"No\")", "+if c - a - b > 0:", "+ if 4 * a * b < c * c + (a + b) * (a + b - 2 * c):", "+ print(\"Yes\")", "+ exit()", "+print...
false
0.045899
0.069591
0.659549
[ "s227095706", "s623349492" ]
u641460756
p02983
python
s077309388
s524742735
806
596
3,060
2,940
Accepted
Accepted
26.05
import sys l,r=list(map(int,input().split())) anslist=20000000000 for i in range(l,r): if r-i>=(2019-i%2019): print((0)) sys.exit() for u in range(i+1,r+1): ans=min(anslist,i*u%2019) anslist=ans print(ans)
l, r = list(map(int, input().split())) def mod2019(x, y): ans=2019 for i in range(x, y): for j in range(i + 1, y + 1): ans = min(ans, i * j % 2019) return ans if r - l >= 2019: print((0)) else: print((mod2019(l,r)))
11
12
247
258
import sys l, r = list(map(int, input().split())) anslist = 20000000000 for i in range(l, r): if r - i >= (2019 - i % 2019): print((0)) sys.exit() for u in range(i + 1, r + 1): ans = min(anslist, i * u % 2019) anslist = ans print(ans)
l, r = list(map(int, input().split())) def mod2019(x, y): ans = 2019 for i in range(x, y): for j in range(i + 1, y + 1): ans = min(ans, i * j % 2019) return ans if r - l >= 2019: print((0)) else: print((mod2019(l, r)))
false
8.333333
[ "-import sys", "+l, r = list(map(int, input().split()))", "-l, r = list(map(int, input().split()))", "-anslist = 20000000000", "-for i in range(l, r):", "- if r - i >= (2019 - i % 2019):", "- print((0))", "- sys.exit()", "- for u in range(i + 1, r + 1):", "- ans = min(an...
false
0.089543
0.095971
0.933028
[ "s077309388", "s524742735" ]
u347600233
p02757
python
s207273386
s759800195
155
119
3,500
9,500
Accepted
Accepted
23.23
n, p = list(map(int, input().split())) s = eval(input()) sum_count = 0 if p in {2, 5}: for right in range(n): if int(s[right]) % p == 0: sum_count += (right + 1) else: modp_count = [0] * p modp_count[0] = 1 subs_modp, pow = 0, 1 for si in s[::-1]: subs_modp +=...
n, p = list(map(int, input().split())) s = eval(input()) sum_cnt = 0 if p in {2, 5}: for r in range(n): if int(s[r]) % p == 0: sum_cnt += (r + 1) else: modp_cnt = [0] * p modp_cnt[0] = 1 subs_modp, pow = 0, 1 for si in s[::-1]: subs_modp += ((int(si)*pow) % p)...
20
20
519
489
n, p = list(map(int, input().split())) s = eval(input()) sum_count = 0 if p in {2, 5}: for right in range(n): if int(s[right]) % p == 0: sum_count += right + 1 else: modp_count = [0] * p modp_count[0] = 1 subs_modp, pow = 0, 1 for si in s[::-1]: subs_modp += (int(si) * po...
n, p = list(map(int, input().split())) s = eval(input()) sum_cnt = 0 if p in {2, 5}: for r in range(n): if int(s[r]) % p == 0: sum_cnt += r + 1 else: modp_cnt = [0] * p modp_cnt[0] = 1 subs_modp, pow = 0, 1 for si in s[::-1]: subs_modp += (int(si) * pow) % p subs_...
false
0
[ "-sum_count = 0", "+sum_cnt = 0", "- for right in range(n):", "- if int(s[right]) % p == 0:", "- sum_count += right + 1", "+ for r in range(n):", "+ if int(s[r]) % p == 0:", "+ sum_cnt += r + 1", "- modp_count = [0] * p", "- modp_count[0] = 1", "+ ...
false
0.039364
0.037883
1.039104
[ "s207273386", "s759800195" ]
u711340028
p02727
python
s636702017
s001892956
401
248
21,212
23,368
Accepted
Accepted
38.15
import sys import heapq read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X,Y,A,B,C = list(map(int, readline().split())) P = list(map(int, readline().split())) Q = list(map(int, readline().split())) R = list(map(int, readline().split())) P = sorted...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X,Y,A,B,C = list(map(int, readline().split())) P = sorted(list(map(int, readline().split())),reverse=True) Q = sorted(list(map(int, readline().split())),reverse=True) R = sorted(list(map(int, r...
35
14
757
420
import sys import heapq read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X, Y, A, B, C = list(map(int, readline().split())) P = list(map(int, readline().split())) Q = list(map(int, readline().split())) R = list(map(int, readline().split())) P = sorted(P, reverse=...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X, Y, A, B, C = list(map(int, readline().split())) P = sorted(list(map(int, readline().split())), reverse=True) Q = sorted(list(map(int, readline().split())), reverse=True) R = sorted(list(map(int, readl...
false
60
[ "-import heapq", "-P = list(map(int, readline().split()))", "-Q = list(map(int, readline().split()))", "-R = list(map(int, readline().split()))", "-P = sorted(P, reverse=True)[:X]", "-Q = sorted(Q, reverse=True)[:Y]", "-R.sort(reverse=True)", "-heapq.heapify(P)", "-heapq.heapify(Q)", "-for r in R:...
false
0.043912
0.043945
0.999241
[ "s636702017", "s001892956" ]
u730769327
p03001
python
s840987339
s097315646
172
65
38,384
61,712
Accepted
Accepted
62.21
w,h,x,y=list(map(int,input().split())) if (x,y)==(w/2,h/2): frag=1 else:frag=0 print((w*h/2,frag))
w,h,x,y=list(map(int,input().split())) if x*y:print((w*h/2,int(w/x==h/y==2))) else:print((w*h/2,0))
5
3
96
91
w, h, x, y = list(map(int, input().split())) if (x, y) == (w / 2, h / 2): frag = 1 else: frag = 0 print((w * h / 2, frag))
w, h, x, y = list(map(int, input().split())) if x * y: print((w * h / 2, int(w / x == h / y == 2))) else: print((w * h / 2, 0))
false
40
[ "-if (x, y) == (w / 2, h / 2):", "- frag = 1", "+if x * y:", "+ print((w * h / 2, int(w / x == h / y == 2)))", "- frag = 0", "-print((w * h / 2, frag))", "+ print((w * h / 2, 0))" ]
false
0.076092
0.07359
1.033996
[ "s840987339", "s097315646" ]
u952708174
p02837
python
s297126769
s857139646
196
170
3,064
3,064
Accepted
Accepted
13.27
def c_honest_or_unkind_2(): N = int(eval(input())) Answers = [] for _ in range(N): a = int(eval(input())) Answers.append([[int(i) for i in input().split()] for j in range(a)]) # print(Answers) ret = -1 for bits in range(1 << N): honests = set() unkinds...
def c_honest_or_unkind_2(): N = int(eval(input())) Answers = [] for _ in range(N): a = int(eval(input())) Answers.append([[int(i) for i in input().split()] for j in range(a)]) ret = -1 for bits in range(1 << N): honests = set() for k in range(N): ...
37
33
1,078
995
def c_honest_or_unkind_2(): N = int(eval(input())) Answers = [] for _ in range(N): a = int(eval(input())) Answers.append([[int(i) for i in input().split()] for j in range(a)]) # print(Answers) ret = -1 for bits in range(1 << N): honests = set() unkinds = set() ...
def c_honest_or_unkind_2(): N = int(eval(input())) Answers = [] for _ in range(N): a = int(eval(input())) Answers.append([[int(i) for i in input().split()] for j in range(a)]) ret = -1 for bits in range(1 << N): honests = set() for k in range(N): if (bits ...
false
10.810811
[ "- # print(Answers)", "- unkinds = set()", "- else:", "- unkinds.add(k)", "- # print(honests, unkinds, end=' ')", "- continue", "+ continue # k 人目は不親切な人としたので証言を調べない", "- if (y == 1 and x in unkinds) or (y == 0 and...
false
0.036966
0.04427
0.835011
[ "s297126769", "s857139646" ]
u647656433
p03160
python
s755341962
s613129844
228
134
55,528
13,928
Accepted
Accepted
41.23
n = int(eval(input())) h = [int(_) for _ in input().split()] mc = [0, abs(h[0]-h[1])] #足場1, 2に辿り着くまでに支払うコストの最小値 for i in range(2,n): mc.append(min(mc[i-2]+abs(h[i-2]-h[i]), mc[i-1]+abs(h[i-1]-h[i]))) print((mc[n-1]))
n=int(eval(input())) h=[int(_) for _ in input().split()] mc=[0,abs(h[0]-h[1])] for i in range(2,n):mc.append(min(mc[i-2]+abs(h[i-2]-h[i]),mc[i-1]+abs(h[i-1]-h[i]))) print((mc[n-1]))
6
5
218
177
n = int(eval(input())) h = [int(_) for _ in input().split()] mc = [0, abs(h[0] - h[1])] # 足場1, 2に辿り着くまでに支払うコストの最小値 for i in range(2, n): mc.append(min(mc[i - 2] + abs(h[i - 2] - h[i]), mc[i - 1] + abs(h[i - 1] - h[i]))) print((mc[n - 1]))
n = int(eval(input())) h = [int(_) for _ in input().split()] mc = [0, abs(h[0] - h[1])] for i in range(2, n): mc.append(min(mc[i - 2] + abs(h[i - 2] - h[i]), mc[i - 1] + abs(h[i - 1] - h[i]))) print((mc[n - 1]))
false
16.666667
[ "-mc = [0, abs(h[0] - h[1])] # 足場1, 2に辿り着くまでに支払うコストの最小値", "+mc = [0, abs(h[0] - h[1])]" ]
false
0.037023
0.044239
0.836888
[ "s755341962", "s613129844" ]
u075012704
p03388
python
s647242190
s674308252
22
20
3,064
3,064
Accepted
Accepted
9.09
Q = int(eval(input())) for q in range(Q): A, B = list(map(int, input().split())) A, B = min(A, B), max(A, B) # コーナーケース if A == B: print((2 * (A - 1))) continue # にぶたん: K組作れるか ok, ng = 0, A + B - 1 while abs(ok - ng) > 1: K = (ok + ng) // 2 ...
Q = int(eval(input())) for i in range(Q): A, B = list(map(int, input().split())) A, B = min(A, B), max(A, B) if A == B: print(((A - 1) + (B - 1))) continue ok, ng = 0, A + B - 1 while abs(ok - ng) > 1: K = (ok + ng) // 2 m = (K + 2) // 2 if ...
22
21
434
403
Q = int(eval(input())) for q in range(Q): A, B = list(map(int, input().split())) A, B = min(A, B), max(A, B) # コーナーケース if A == B: print((2 * (A - 1))) continue # にぶたん: K組作れるか ok, ng = 0, A + B - 1 while abs(ok - ng) > 1: K = (ok + ng) // 2 m = (K + 2) // 2 ...
Q = int(eval(input())) for i in range(Q): A, B = list(map(int, input().split())) A, B = min(A, B), max(A, B) if A == B: print(((A - 1) + (B - 1))) continue ok, ng = 0, A + B - 1 while abs(ok - ng) > 1: K = (ok + ng) // 2 m = (K + 2) // 2 if m * (K + 2 - m) < A...
false
4.545455
[ "-for q in range(Q):", "+for i in range(Q):", "- # コーナーケース", "- print((2 * (A - 1)))", "+ print(((A - 1) + (B - 1)))", "- # にぶたん: K組作れるか" ]
false
0.086438
0.076409
1.131253
[ "s647242190", "s674308252" ]
u815763296
p02954
python
s821170386
s906129933
112
96
14,704
17,160
Accepted
Accepted
14.29
from itertools import accumulate S = input() ans = [0]*len(S) RLgr = [] R = 0 L = 0 RL = "R" for i in range(len(S)): if S[i] == RL: if S[i] == "R": R += 1 else: L += 1 else: if RL == "R": RLgr.append(R) R = 0 RL...
S = eval(input())+"R" R = 0 L = 0 ans = [0]*(len(S)-1) for i in range(len(S)-1): if S[i] == "R": if S[i+1] == "L": R += 1 if R % 2 == 0: ans[i] += R//2 ans[i+1] += R//2 else: R -= 1 ans[i] += R//...
34
34
673
796
from itertools import accumulate S = input() ans = [0] * len(S) RLgr = [] R = 0 L = 0 RL = "R" for i in range(len(S)): if S[i] == RL: if S[i] == "R": R += 1 else: L += 1 else: if RL == "R": RLgr.append(R) R = 0 RL = "L" ...
S = eval(input()) + "R" R = 0 L = 0 ans = [0] * (len(S) - 1) for i in range(len(S) - 1): if S[i] == "R": if S[i + 1] == "L": R += 1 if R % 2 == 0: ans[i] += R // 2 ans[i + 1] += R // 2 else: R -= 1 ans[i] += ...
false
0
[ "-from itertools import accumulate", "-", "-S = input()", "-ans = [0] * len(S)", "-RLgr = []", "+S = eval(input()) + \"R\"", "-RL = \"R\"", "-for i in range(len(S)):", "- if S[i] == RL:", "- if S[i] == \"R\":", "+ans = [0] * (len(S) - 1)", "+for i in range(len(S) - 1):", "+ if S...
false
0.11897
0.042155
2.82224
[ "s821170386", "s906129933" ]
u298297089
p02989
python
s543395269
s119233897
115
78
17,632
13,992
Accepted
Accepted
32.17
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) cnt = Counter(D) lst = [] for key in sorted(cnt.keys()): lst.append([key, cnt[key]]) ans = 0 tmp = 0 for i, kv in enumerate(lst): key, value = kv tmp += value if tmp == N - tmp: if i + 1 <...
n = int(eval(input())) d = sorted(map(int, input().split())) a = d[n//2-1] b = d[n//2] print((b-a)) # print(d)
21
7
426
110
from collections import Counter N = int(eval(input())) D = list(map(int, input().split())) cnt = Counter(D) lst = [] for key in sorted(cnt.keys()): lst.append([key, cnt[key]]) ans = 0 tmp = 0 for i, kv in enumerate(lst): key, value = kv tmp += value if tmp == N - tmp: if i + 1 < len(lst): ...
n = int(eval(input())) d = sorted(map(int, input().split())) a = d[n // 2 - 1] b = d[n // 2] print((b - a)) # print(d)
false
66.666667
[ "-from collections import Counter", "-", "-N = int(eval(input()))", "-D = list(map(int, input().split()))", "-cnt = Counter(D)", "-lst = []", "-for key in sorted(cnt.keys()):", "- lst.append([key, cnt[key]])", "-ans = 0", "-tmp = 0", "-for i, kv in enumerate(lst):", "- key, value = kv", ...
false
0.131848
0.158385
0.832448
[ "s543395269", "s119233897" ]
u347640436
p02572
python
s638536581
s441554496
185
138
25,040
31,608
Accepted
Accepted
25.41
n = int(eval(input())) l = eval(input()) a = l.split(' ') tmp = 0 tmp2 = 0 for i in range(n): tmp += int(a[i]) for i in range(n): tmp2 += int(a[i])*int(a[i]) print(((tmp*tmp-tmp2)//2%1000000007))
m = 1000000007 N, *A = list(map(int, open(0).read().split())) result = 0 c = 0 for a in A: result += c * a result %= m c += a c %= m print(result)
14
12
206
170
n = int(eval(input())) l = eval(input()) a = l.split(" ") tmp = 0 tmp2 = 0 for i in range(n): tmp += int(a[i]) for i in range(n): tmp2 += int(a[i]) * int(a[i]) print(((tmp * tmp - tmp2) // 2 % 1000000007))
m = 1000000007 N, *A = list(map(int, open(0).read().split())) result = 0 c = 0 for a in A: result += c * a result %= m c += a c %= m print(result)
false
14.285714
[ "-n = int(eval(input()))", "-l = eval(input())", "-a = l.split(\" \")", "-tmp = 0", "-tmp2 = 0", "-for i in range(n):", "- tmp += int(a[i])", "-for i in range(n):", "- tmp2 += int(a[i]) * int(a[i])", "-print(((tmp * tmp - tmp2) // 2 % 1000000007))", "+m = 1000000007", "+N, *A = list(map(...
false
0.037191
0.042752
0.869933
[ "s638536581", "s441554496" ]
u231136358
p02257
python
s713548544
s766599665
1,530
1,020
7,720
7,724
Accepted
Accepted
33.33
import math def is_prime(num): i = 2 while i <= math.sqrt(num): if num % i == 0: return False i = i + 1 return True N = int(eval(input())) cnt = 0 for i in range(0, N): n = int(eval(input())) if (is_prime(n)): cnt = cnt + 1 print(cnt)
def is_prime(num): i = 2 while i*i <= num: if num % i == 0: return False i = i + 1 return True N = int(eval(input())) cnt = 0 for i in range(0, N): n = int(eval(input())) if (is_prime(n)): cnt = cnt + 1 print(cnt)
18
16
306
282
import math def is_prime(num): i = 2 while i <= math.sqrt(num): if num % i == 0: return False i = i + 1 return True N = int(eval(input())) cnt = 0 for i in range(0, N): n = int(eval(input())) if is_prime(n): cnt = cnt + 1 print(cnt)
def is_prime(num): i = 2 while i * i <= num: if num % i == 0: return False i = i + 1 return True N = int(eval(input())) cnt = 0 for i in range(0, N): n = int(eval(input())) if is_prime(n): cnt = cnt + 1 print(cnt)
false
11.111111
[ "-import math", "-", "-", "- while i <= math.sqrt(num):", "+ while i * i <= num:" ]
false
0.04409
0.044553
0.989613
[ "s713548544", "s766599665" ]
u983918956
p03157
python
s249153273
s717618768
1,224
602
232,556
150,728
Accepted
Accepted
50.82
import sys sys.setrecursionlimit(10**6) H,W = list(map(int,input().split())) grid = [["&"] * (W+2) for i in range(H+2)] visited = [[False] * (W+2) for i in range(H+2)] # debug: visited_count = [[0] * (W+2) for i in range(H+2)] start = [] for i in range(H): s = eval(input()) for j in range(W): ...
import sys sys.setrecursionlimit(10**6) around = [(0,1),(1,0),(0,-1),(-1,0)] H,W = list(map(int,input().split())) grid = [list(eval(input())) for _ in range(H)] checked = [[0]*W for _ in range(H)] def dfs(i,j): checked[i][j] = 1 for di,dj in around: ni = i + di; nj = j + dj if ...
52
37
1,270
853
import sys sys.setrecursionlimit(10**6) H, W = list(map(int, input().split())) grid = [["&"] * (W + 2) for i in range(H + 2)] visited = [[False] * (W + 2) for i in range(H + 2)] # debug: visited_count = [[0] * (W+2) for i in range(H+2)] start = [] for i in range(H): s = eval(input()) for j in range(W): ...
import sys sys.setrecursionlimit(10**6) around = [(0, 1), (1, 0), (0, -1), (-1, 0)] H, W = list(map(int, input().split())) grid = [list(eval(input())) for _ in range(H)] checked = [[0] * W for _ in range(H)] def dfs(i, j): checked[i][j] = 1 for di, dj in around: ni = i + di nj = j + dj ...
false
28.846154
[ "+around = [(0, 1), (1, 0), (0, -1), (-1, 0)]", "-grid = [[\"&\"] * (W + 2) for i in range(H + 2)]", "-visited = [[False] * (W + 2) for i in range(H + 2)]", "-# debug: visited_count = [[0] * (W+2) for i in range(H+2)]", "-start = []", "-for i in range(H):", "- s = eval(input())", "- for j in ran...
false
0.046903
0.04375
1.072065
[ "s249153273", "s717618768" ]
u531220228
p02982
python
s597961739
s424715120
1,613
149
21,616
12,500
Accepted
Accepted
90.76
import numpy as np N, D = list(map(int, input().split())) X = np.zeros((N,D)) for i in range(N): X[i][:] = list(map(int, input().split())) n = 0 for i in range(N): for j in range(i+1, N): dist = np.linalg.norm(X[i]-X[j]) if dist.is_integer(): n += 1 print(n)
import numpy as np _N, _D, *_X = open(0).read().split() N = int(_N) D = int(_D) X = np.array(list(zip(*[list(map(int, iter(_X)))]*D))) import itertools ans = 0 for x, y in itertools.combinations(X, 2): d = np.linalg.norm(x - y) if d%1 == 0: ans += 1 print(ans)
14
18
285
293
import numpy as np N, D = list(map(int, input().split())) X = np.zeros((N, D)) for i in range(N): X[i][:] = list(map(int, input().split())) n = 0 for i in range(N): for j in range(i + 1, N): dist = np.linalg.norm(X[i] - X[j]) if dist.is_integer(): n += 1 print(n)
import numpy as np _N, _D, *_X = open(0).read().split() N = int(_N) D = int(_D) X = np.array(list(zip(*[list(map(int, iter(_X)))] * D))) import itertools ans = 0 for x, y in itertools.combinations(X, 2): d = np.linalg.norm(x - y) if d % 1 == 0: ans += 1 print(ans)
false
22.222222
[ "-N, D = list(map(int, input().split()))", "-X = np.zeros((N, D))", "-for i in range(N):", "- X[i][:] = list(map(int, input().split()))", "-n = 0", "-for i in range(N):", "- for j in range(i + 1, N):", "- dist = np.linalg.norm(X[i] - X[j])", "- if dist.is_integer():", "- ...
false
0.841804
0.23491
3.583522
[ "s597961739", "s424715120" ]
u597622207
p02683
python
s046625163
s640998567
336
83
85,320
9,244
Accepted
Accepted
75.3
N, M, X = list(map(int, input().split())) C = []; A = []; T = [] for _ in range(N): s = list(map(int, input().split())) C.append(s[0]) A.append(s[1:]) INF = 10**9 ans = INF # シフトで2^nまで全探索 for s in range(0, 1 << N): # 習得度をいれるリストを定義 smart = [0] * M cost_sum = 0 # sには10進数が入る ...
N, M, X = list(map(int, input().split())) C = []; A = []; T = [] for _ in range(N): s = list(map(int, input().split())) C.append(s[0]) A.append(s[1:]) INF = 10**9 ans = INF # シフトで2^nまで全探索 # 全ての組み合わせに対してforを回す # 部分集合を全探索するならbit全探索 # 左シフト<< 桁を左にずらし,0を入れていく for s in range(0, 1 << N): # 習得度をい...
31
37
640
799
N, M, X = list(map(int, input().split())) C = [] A = [] T = [] for _ in range(N): s = list(map(int, input().split())) C.append(s[0]) A.append(s[1:]) INF = 10**9 ans = INF # シフトで2^nまで全探索 for s in range(0, 1 << N): # 習得度をいれるリストを定義 smart = [0] * M cost_sum = 0 # sには10進数が入る for i in range(N)...
N, M, X = list(map(int, input().split())) C = [] A = [] T = [] for _ in range(N): s = list(map(int, input().split())) C.append(s[0]) A.append(s[1:]) INF = 10**9 ans = INF # シフトで2^nまで全探索 # 全ての組み合わせに対してforを回す # 部分集合を全探索するならbit全探索 # 左シフト<< 桁を左にずらし,0を入れていく for s in range(0, 1 << N): # 習得度をいれるリストを定義 smar...
false
16.216216
[ "+# 全ての組み合わせに対してforを回す", "+# 部分集合を全探索するならbit全探索", "+# 左シフト<< 桁を左にずらし,0を入れていく", "- # sには10進数が入る", "+ # sには一旦10進数が入る", "+ # 得られた1組あわせに対して,2進数でそのitemを用いているかを (s >> i) & 1で確認する", "+ # これは,右シフト", "+ # 012のループ", "- # 買っていない時", "- if (s >> i) % 2 == 0:", "- conti...
false
0.040383
0.040249
1.003323
[ "s046625163", "s640998567" ]
u927220534
p02632
python
s587124684
s835989093
373
170
187,076
148,840
Accepted
Accepted
54.42
FAST_IO = 0 if FAST_IO: import io, sys, atexit rr = iter(sys.stdin.read().splitlines()).__next__ sys.stdout = _OUTPUT_BUFFER = io.BytesIO() @atexit.register def write(): sys.__stdout__.write(_OUTPUT_BUFFER.getvalue()) else: rr = raw_input rri = lambda: int(rr()) rrm = lambda: ...
MOD = 10 ** 9 + 7 K = int(eval(input())) M = len(eval(input())) N = M + K pow25 = [1] * (N + 1) fac = [1] * (N + 1) inv = [1] * (N + 1) for x in range(1, N + 1): fac[x] = fac[x - 1] * x % MOD pow25[x] = pow25[x - 1] * 25 % MOD inv[N] = pow(fac[N], MOD-2, MOD) for x in range(N - 1, -1, -1): inv...
50
23
1,142
525
FAST_IO = 0 if FAST_IO: import io, sys, atexit rr = iter(sys.stdin.read().splitlines()).__next__ sys.stdout = _OUTPUT_BUFFER = io.BytesIO() @atexit.register def write(): sys.__stdout__.write(_OUTPUT_BUFFER.getvalue()) else: rr = raw_input rri = lambda: int(rr()) rrm = lambda: list(map...
MOD = 10**9 + 7 K = int(eval(input())) M = len(eval(input())) N = M + K pow25 = [1] * (N + 1) fac = [1] * (N + 1) inv = [1] * (N + 1) for x in range(1, N + 1): fac[x] = fac[x - 1] * x % MOD pow25[x] = pow25[x - 1] * 25 % MOD inv[N] = pow(fac[N], MOD - 2, MOD) for x in range(N - 1, -1, -1): inv[x] = inv[x + ...
false
54
[ "-FAST_IO = 0", "-if FAST_IO:", "- import io, sys, atexit", "-", "- rr = iter(sys.stdin.read().splitlines()).__next__", "- sys.stdout = _OUTPUT_BUFFER = io.BytesIO()", "-", "- @atexit.register", "- def write():", "- sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())", "-", "...
false
0.008025
0.037013
0.216805
[ "s587124684", "s835989093" ]
u730769327
p02813
python
s136876367
s512984063
95
69
71,584
70,048
Accepted
Accepted
27.37
from itertools import permutations n=int(eval(input())) p=tuple(input().split()) q=tuple(input().split()) a=sorted(list(permutations(p))) print((abs(a.index(p)-a.index(q))))
from itertools import permutations n=int(eval(input())) p=tuple(map(int,input().split())) q=tuple(map(int,input().split())) a=list(permutations(list(range(1,n+1)))) print((abs(a.index(p)-a.index(q))))
6
6
170
191
from itertools import permutations n = int(eval(input())) p = tuple(input().split()) q = tuple(input().split()) a = sorted(list(permutations(p))) print((abs(a.index(p) - a.index(q))))
from itertools import permutations n = int(eval(input())) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) a = list(permutations(list(range(1, n + 1)))) print((abs(a.index(p) - a.index(q))))
false
0
[ "-p = tuple(input().split())", "-q = tuple(input().split())", "-a = sorted(list(permutations(p)))", "+p = tuple(map(int, input().split()))", "+q = tuple(map(int, input().split()))", "+a = list(permutations(list(range(1, n + 1))))" ]
false
0.040397
0.040231
1.004122
[ "s136876367", "s512984063" ]
u477977638
p02793
python
s087457189
s896746241
1,894
957
6,112
4,084
Accepted
Accepted
49.47
from fractions import gcd N = int(eval(input())) A = list(map(int,input().split())) lcm = 1 for i in A: lcm = (lcm*i)//gcd(lcm,i) ans = 0 for i in A: ans += lcm//i print((ans%(10**9+7)))
def gcd(x,y): if y==0: return x return gcd(y,x%y) MOD = 10**9+7 N = int(eval(input())) A = list(map(int,input().split())) lcm = 1 for i in A: lcm = (lcm*i)//gcd(lcm,i) lcm %= MOD ans = 0 for i in A: ans += lcm*pow(i,MOD-2,MOD) print((ans%MOD))
11
17
198
278
from fractions import gcd N = int(eval(input())) A = list(map(int, input().split())) lcm = 1 for i in A: lcm = (lcm * i) // gcd(lcm, i) ans = 0 for i in A: ans += lcm // i print((ans % (10**9 + 7)))
def gcd(x, y): if y == 0: return x return gcd(y, x % y) MOD = 10**9 + 7 N = int(eval(input())) A = list(map(int, input().split())) lcm = 1 for i in A: lcm = (lcm * i) // gcd(lcm, i) lcm %= MOD ans = 0 for i in A: ans += lcm * pow(i, MOD - 2, MOD) print((ans % MOD))
false
35.294118
[ "-from fractions import gcd", "+def gcd(x, y):", "+ if y == 0:", "+ return x", "+ return gcd(y, x % y)", "+", "+MOD = 10**9 + 7", "+lcm %= MOD", "- ans += lcm // i", "-print((ans % (10**9 + 7)))", "+ ans += lcm * pow(i, MOD - 2, MOD)", "+print((ans % MOD))" ]
false
0.060758
0.129419
0.469468
[ "s087457189", "s896746241" ]
u730769327
p02861
python
s821984347
s651271812
62
27
62,292
9,312
Accepted
Accepted
56.45
n=int(eval(input())) x=[] y=[] for i in range(n): a,b=list(map(int,input().split())) x.append(a) y.append(b) sm=0 for i in range(n): for j in range(n): sm+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5 print((sm/n))
n=int(eval(input())) x=[] y=[] for i in range(n): a,b=list(map(int,input().split())) x.append(a) y.append(b) ans=0 for i in range(n): for j in range(n): ans+=((x[i]-x[j])**2+(y[i]-y[j])**2)**.5 print((ans/n))
12
12
215
217
n = int(eval(input())) x = [] y = [] for i in range(n): a, b = list(map(int, input().split())) x.append(a) y.append(b) sm = 0 for i in range(n): for j in range(n): sm += ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5 print((sm / n))
n = int(eval(input())) x = [] y = [] for i in range(n): a, b = list(map(int, input().split())) x.append(a) y.append(b) ans = 0 for i in range(n): for j in range(n): ans += ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5 print((ans / n))
false
0
[ "-sm = 0", "+ans = 0", "- sm += ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5", "-print((sm / n))", "+ ans += ((x[i] - x[j]) ** 2 + (y[i] - y[j]) ** 2) ** 0.5", "+print((ans / n))" ]
false
0.040957
0.146934
0.278746
[ "s821984347", "s651271812" ]
u263830634
p03332
python
s349522414
s227539357
696
582
26,796
26,796
Accepted
Accepted
16.38
class Factorial: def __init__(self, n, mod): self.f = [1] self.mod = mod for j in range(1, n + 1): self.f.append(self.f[-1] * j % mod) self.i = [pow(self.f[-1], mod - 2, mod)] for j in range(n, 0, -1): self.i.append(self.i[-1] * j % mod) ...
def main(): class Factorial: def __init__(self, n, mod): self.f = [1] self.mod = mod for j in range(1, n + 1): self.f.append(self.f[-1] * j % mod) self.i = [pow(self.f[-1], mod - 2, mod)] for j in range(n, 0, -1): ...
34
34
892
1,006
class Factorial: def __init__(self, n, mod): self.f = [1] self.mod = mod for j in range(1, n + 1): self.f.append(self.f[-1] * j % mod) self.i = [pow(self.f[-1], mod - 2, mod)] for j in range(n, 0, -1): self.i.append(self.i[-1] * j % mod) self.i...
def main(): class Factorial: def __init__(self, n, mod): self.f = [1] self.mod = mod for j in range(1, n + 1): self.f.append(self.f[-1] * j % mod) self.i = [pow(self.f[-1], mod - 2, mod)] for j in range(n, 0, -1): se...
false
0
[ "-class Factorial:", "- def __init__(self, n, mod):", "- self.f = [1]", "- self.mod = mod", "- for j in range(1, n + 1):", "- self.f.append(self.f[-1] * j % mod)", "- self.i = [pow(self.f[-1], mod - 2, mod)]", "- for j in range(n, 0, -1):", "- ...
false
0.068631
0.054318
1.263497
[ "s349522414", "s227539357" ]
u802963389
p02708
python
s179061423
s719582010
135
99
9,192
9,180
Accepted
Accepted
26.67
n, k = list(map(int, input().split())) MOD = 10 ** 9 + 7 ans = 0 num = 0 for i in range(1, n + 2): num += (i - 1) if i >= k: # print(num, i, i * n - 2 * num + 1) ans += max(i * n - 2 * num + 1, 1) ans = ans % MOD print(ans)
n, k = list(map(int, input().split())) MOD = 10 ** 9 + 7 ans = 0 a = 1 for i in range(1, n + 2): a -= 2 * (i - 1) if i >= k: ans += (i * n + a) ans %= MOD print(ans)
15
12
252
184
n, k = list(map(int, input().split())) MOD = 10**9 + 7 ans = 0 num = 0 for i in range(1, n + 2): num += i - 1 if i >= k: # print(num, i, i * n - 2 * num + 1) ans += max(i * n - 2 * num + 1, 1) ans = ans % MOD print(ans)
n, k = list(map(int, input().split())) MOD = 10**9 + 7 ans = 0 a = 1 for i in range(1, n + 2): a -= 2 * (i - 1) if i >= k: ans += i * n + a ans %= MOD print(ans)
false
20
[ "-num = 0", "+a = 1", "- num += i - 1", "+ a -= 2 * (i - 1)", "- # print(num, i, i * n - 2 * num + 1)", "- ans += max(i * n - 2 * num + 1, 1)", "- ans = ans % MOD", "+ ans += i * n + a", "+ ans %= MOD" ]
false
0.054504
0.1547
0.352321
[ "s179061423", "s719582010" ]
u572144347
p03503
python
s708882678
s647534404
972
287
42,716
44,380
Accepted
Accepted
70.47
#!/mnt/c/Users/moiki/bash/env/bin/python # N,M = map(int, input().split()) N = int(eval(input())) F = [list(map(int, input().split())) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] ans = - 10**10 for i in range(1,1<<10): score = 0 for n in range(N): f = "".join(...
N = int(eval(input())) F = [ int(input().replace(" ", ""), 2) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] ans = - 10**10 for i in range(1,1<<10): ans = max(ans, sum(P[n][bin(i&F[n]).count('1')] for n in range(N))) print(ans)
18
8
536
262
#!/mnt/c/Users/moiki/bash/env/bin/python # N,M = map(int, input().split()) N = int(eval(input())) F = [list(map(int, input().split())) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] ans = -(10**10) for i in range(1, 1 << 10): score = 0 for n in range(N): f = "".join(map(str, ...
N = int(eval(input())) F = [int(input().replace(" ", ""), 2) for _ in range(N)] P = [list(map(int, input().split())) for _ in range(N)] ans = -(10**10) for i in range(1, 1 << 10): ans = max(ans, sum(P[n][bin(i & F[n]).count("1")] for n in range(N))) print(ans)
false
55.555556
[ "-#!/mnt/c/Users/moiki/bash/env/bin/python", "-# N,M = map(int, input().split())", "-F = [list(map(int, input().split())) for _ in range(N)]", "+F = [int(input().replace(\" \", \"\"), 2) for _ in range(N)]", "- score = 0", "- for n in range(N):", "- f = \"\".join(map(str, F[n]))", "- ...
false
0.106346
0.06051
1.757494
[ "s708882678", "s647534404" ]
u997521090
p03111
python
s539455401
s353560957
206
170
19,572
16,756
Accepted
Accepted
17.48
N,*A=list(map(int,input().split()));a=[[0]*4];r=[0,1,2] for i in range(N):l=int(eval(input()));a=[[p[j]+l*(i==j)for j in r]+[p[3]+(i<3)*10]for i in r+[3]for p in a] print((min(sum(abs(p[i]-A[i])for i in r)-30+p[3]for p in a if min(p[:3])>0)))
N,*A=list(map(int,input().split()));a=[[0]*4];r=[0,1,2] for i in range(N):l=int(eval(input()));a+=[[p[j]+l*(i==j)for j in r]+[p[3]+10]for i in r for p in a] print((min(sum(abs(p[i]-A[i])for i in r)-30+p[3]for p in a if min(p[:3])>0)))
3
3
230
222
N, *A = list(map(int, input().split())) a = [[0] * 4] r = [0, 1, 2] for i in range(N): l = int(eval(input())) a = [ [p[j] + l * (i == j) for j in r] + [p[3] + (i < 3) * 10] for i in r + [3] for p in a ] print((min(sum(abs(p[i] - A[i]) for i in r) - 30 + p[3] for p in a if min(p[:3]) ...
N, *A = list(map(int, input().split())) a = [[0] * 4] r = [0, 1, 2] for i in range(N): l = int(eval(input())) a += [[p[j] + l * (i == j) for j in r] + [p[3] + 10] for i in r for p in a] print((min(sum(abs(p[i] - A[i]) for i in r) - 30 + p[3] for p in a if min(p[:3]) > 0)))
false
0
[ "- a = [", "- [p[j] + l * (i == j) for j in r] + [p[3] + (i < 3) * 10]", "- for i in r + [3]", "- for p in a", "- ]", "+ a += [[p[j] + l * (i == j) for j in r] + [p[3] + 10] for i in r for p in a]" ]
false
0.218701
0.181451
1.205288
[ "s539455401", "s353560957" ]
u627803856
p02707
python
s397138576
s791512541
196
148
144,828
92,516
Accepted
Accepted
24.49
n = int(eval(input())) A = list(map(int, input().split())) # n-1 from collections import Counter c = dict(Counter(A)) for i in range(1, n + 1): print((c.get(i, 0)))
n = int(eval(input())) A = [-1, -1] + list(map(int, input().split())) # n-1 cnt = [0] * (n + 1) for i in range(2, n + 1): cnt[A[i]] += 1 for i in range(1, n + 1): print((cnt[i]))
9
10
168
184
n = int(eval(input())) A = list(map(int, input().split())) # n-1 from collections import Counter c = dict(Counter(A)) for i in range(1, n + 1): print((c.get(i, 0)))
n = int(eval(input())) A = [-1, -1] + list(map(int, input().split())) # n-1 cnt = [0] * (n + 1) for i in range(2, n + 1): cnt[A[i]] += 1 for i in range(1, n + 1): print((cnt[i]))
false
10
[ "-A = list(map(int, input().split())) # n-1", "-from collections import Counter", "-", "-c = dict(Counter(A))", "+A = [-1, -1] + list(map(int, input().split())) # n-1", "+cnt = [0] * (n + 1)", "+for i in range(2, n + 1):", "+ cnt[A[i]] += 1", "- print((c.get(i, 0)))", "+ print((cnt[i]))...
false
0.046423
0.047508
0.977155
[ "s397138576", "s791512541" ]
u321035578
p02642
python
s984194994
s567823011
598
454
38,576
38,736
Accepted
Accepted
24.08
from collections import Counter import bisect N = int(eval(input())) A = list(map(int,input().split())) cnt = Counter(A) A.sort() ans = 0 MX = 10**6 P = [0] * (MX+1) for a in A: if P[a]==0: for i in range(MX+1): x = a*i if x > MX: break P[x]...
def main(): n = int(eval(input())) a = list(map(int,input().split())) ans = 0 from collections import Counter cnt = Counter(a) lim = max(a) + 1 tmp = [0] * (lim) # set_a = list(set(a)) # set_a.sort() a.sort() for aa in a: if tmp[aa] == 0: ...
19
31
374
585
from collections import Counter import bisect N = int(eval(input())) A = list(map(int, input().split())) cnt = Counter(A) A.sort() ans = 0 MX = 10**6 P = [0] * (MX + 1) for a in A: if P[a] == 0: for i in range(MX + 1): x = a * i if x > MX: break P[x] = 1 ...
def main(): n = int(eval(input())) a = list(map(int, input().split())) ans = 0 from collections import Counter cnt = Counter(a) lim = max(a) + 1 tmp = [0] * (lim) # set_a = list(set(a)) # set_a.sort() a.sort() for aa in a: if tmp[aa] == 0: for j in range(...
false
38.709677
[ "-from collections import Counter", "-import bisect", "+def main():", "+ n = int(eval(input()))", "+ a = list(map(int, input().split()))", "+ ans = 0", "+ from collections import Counter", "-N = int(eval(input()))", "-A = list(map(int, input().split()))", "-cnt = Counter(A)", "-A.sor...
false
0.37222
0.040891
9.102685
[ "s984194994", "s567823011" ]
u377989038
p02780
python
s349575111
s488943162
408
208
33,996
33,980
Accepted
Accepted
49.02
from itertools import accumulate import numpy as np n, k = list(map(int, input().split())) p = np.array(list(map(int, input().split())), dtype=np.int64) p = (1 + p) / 2 p = [0] + list(accumulate(p)) ans = 0 for i in range(n - k + 1): ans = max(ans, p[i + k] - p[i]) print(ans)
import numpy as np n, k = list(map(int, input().split())) p = np.array(list(map(int, input().split())), dtype="i8") p = np.insert(np.cumsum((1 + p) / 2), 0, 0) print(((p[k:] - p[:n - k + 1]).max()))
12
6
288
196
from itertools import accumulate import numpy as np n, k = list(map(int, input().split())) p = np.array(list(map(int, input().split())), dtype=np.int64) p = (1 + p) / 2 p = [0] + list(accumulate(p)) ans = 0 for i in range(n - k + 1): ans = max(ans, p[i + k] - p[i]) print(ans)
import numpy as np n, k = list(map(int, input().split())) p = np.array(list(map(int, input().split())), dtype="i8") p = np.insert(np.cumsum((1 + p) / 2), 0, 0) print(((p[k:] - p[: n - k + 1]).max()))
false
50
[ "-from itertools import accumulate", "-p = np.array(list(map(int, input().split())), dtype=np.int64)", "-p = (1 + p) / 2", "-p = [0] + list(accumulate(p))", "-ans = 0", "-for i in range(n - k + 1):", "- ans = max(ans, p[i + k] - p[i])", "-print(ans)", "+p = np.array(list(map(int, input().split())...
false
1.061207
0.501057
2.117936
[ "s349575111", "s488943162" ]
u620480037
p02973
python
s951068325
s009468970
442
201
8,064
79,676
Accepted
Accepted
54.52
import bisect import sys input=sys.stdin.readline from collections import deque N=int(eval(input())) cnt=0 L=[] for i in range(N): n=int(eval(input())) L.append(n) #print(L) Q=[-1,10**10] Q=deque() #Q.appendleft(10**10) #print(Q) for i in range(N): if bisect.bisect_left(Q,L[i])==0: ...
N=int(eval(input())) L=[1 for i in range(N+1)] L[0]=-10**10 import bisect for i in range(N): n=int(eval(input())) L[bisect.bisect_right(L,-n)]=-n #print(L) ans=0 for i in range(1,N+1): if L[i]==1: break ans+=1 print(ans)
25
15
494
247
import bisect import sys input = sys.stdin.readline from collections import deque N = int(eval(input())) cnt = 0 L = [] for i in range(N): n = int(eval(input())) L.append(n) # print(L) Q = [-1, 10**10] Q = deque() # Q.appendleft(10**10) # print(Q) for i in range(N): if bisect.bisect_left(Q, L[i]) == 0: ...
N = int(eval(input())) L = [1 for i in range(N + 1)] L[0] = -(10**10) import bisect for i in range(N): n = int(eval(input())) L[bisect.bisect_right(L, -n)] = -n # print(L) ans = 0 for i in range(1, N + 1): if L[i] == 1: break ans += 1 print(ans)
false
40
[ "+N = int(eval(input()))", "+L = [1 for i in range(N + 1)]", "+L[0] = -(10**10)", "-import sys", "-input = sys.stdin.readline", "-from collections import deque", "-", "-N = int(eval(input()))", "-cnt = 0", "-L = []", "- L.append(n)", "+ L[bisect.bisect_right(L, -n)] = -n", "-Q = [-1, 1...
false
0.032942
0.033711
0.977195
[ "s951068325", "s009468970" ]
u983918956
p02948
python
s561371951
s460180780
1,299
778
29,276
82,656
Accepted
Accepted
40.11
from heapq import heappop, heappush from bisect import bisect from collections import deque inf = 10**5 N, M = list(map(int,input().split())) info = [list(map(int,input().split())) for _ in range(N)] info = deque(sorted(info)) ans = 0 hq = [] for i in range(M-1,-1,-1): index = bisect(info, [M-i,in...
from heapq import heappush, heappop N, M = list(map(int,input().split())) # works[i] : M-i日に報酬が得られるリスト works = [[] for _ in range(10**6)] for _ in range(N): A, B = list(map(int,input().split())) # 報酬が得られる日付に応じて格納 works[A].append(B) hq = [] ans = 0 for i in range(1,M+1): # M-i日から降順に仕...
23
25
472
483
from heapq import heappop, heappush from bisect import bisect from collections import deque inf = 10**5 N, M = list(map(int, input().split())) info = [list(map(int, input().split())) for _ in range(N)] info = deque(sorted(info)) ans = 0 hq = [] for i in range(M - 1, -1, -1): index = bisect(info, [M - i, inf]) ...
from heapq import heappush, heappop N, M = list(map(int, input().split())) # works[i] : M-i日に報酬が得られるリスト works = [[] for _ in range(10**6)] for _ in range(N): A, B = list(map(int, input().split())) # 報酬が得られる日付に応じて格納 works[A].append(B) hq = [] ans = 0 for i in range(1, M + 1): # M-i日から降順に仕事の候補リストを作る ...
false
8
[ "-from heapq import heappop, heappush", "-from bisect import bisect", "-from collections import deque", "+from heapq import heappush, heappop", "-inf = 10**5", "-info = [list(map(int, input().split())) for _ in range(N)]", "-info = deque(sorted(info))", "+# works[i] : M-i日に報酬が得られるリスト", "+works = [[]...
false
0.042507
0.695482
0.061119
[ "s561371951", "s460180780" ]
u657913472
p02768
python
s157194702
s472360220
1,511
824
3,060
3,060
Accepted
Accepted
45.47
n,a,b=list(map(int,input().split())) m=10**9+7 def c(x,r=1): for i in range(x):r=r*(n-i)*pow(i+1,m-2,m)%m return r print(((pow(2,n,m)-1-c(a)-c(b))%m))
n,a,b=list(map(int,input().split())) m=10**9+7 s=r=1 for i in range(b): r=r*(n-i)*pow(i+1,m-2,m)%m if i+1in[a,b]:s+=r print(((pow(2,n,m)-s)%m))
6
7
149
143
n, a, b = list(map(int, input().split())) m = 10**9 + 7 def c(x, r=1): for i in range(x): r = r * (n - i) * pow(i + 1, m - 2, m) % m return r print(((pow(2, n, m) - 1 - c(a) - c(b)) % m))
n, a, b = list(map(int, input().split())) m = 10**9 + 7 s = r = 1 for i in range(b): r = r * (n - i) * pow(i + 1, m - 2, m) % m if i + 1 in [a, b]: s += r print(((pow(2, n, m) - s) % m))
false
14.285714
[ "-", "-", "-def c(x, r=1):", "- for i in range(x):", "- r = r * (n - i) * pow(i + 1, m - 2, m) % m", "- return r", "-", "-", "-print(((pow(2, n, m) - 1 - c(a) - c(b)) % m))", "+s = r = 1", "+for i in range(b):", "+ r = r * (n - i) * pow(i + 1, m - 2, m) % m", "+ if i + 1 i...
false
1.023159
0.519179
1.970727
[ "s157194702", "s472360220" ]
u761529120
p02937
python
s332254430
s120740375
248
113
45,808
78,556
Accepted
Accepted
54.44
from collections import defaultdict from bisect import bisect_right def main(): S = eval(input()) T = eval(input()) d = defaultdict(list) for i, s in enumerate(S): d[s].append(i+1) pre = 0 cnt = 0 loop = 0 len_S = len(S) for t in T: if not d[t]: ...
from collections import defaultdict from bisect import bisect_right def main(): S = eval(input()) T = eval(input()) Ls = len(S) Lt = len(T) d = defaultdict(list) for i in range(Ls): d[S[i]].append(i+1) now = 0 ans = 0 for i in range(Lt): if not d[T[i]...
34
33
639
670
from collections import defaultdict from bisect import bisect_right def main(): S = eval(input()) T = eval(input()) d = defaultdict(list) for i, s in enumerate(S): d[s].append(i + 1) pre = 0 cnt = 0 loop = 0 len_S = len(S) for t in T: if not d[t]: print(...
from collections import defaultdict from bisect import bisect_right def main(): S = eval(input()) T = eval(input()) Ls = len(S) Lt = len(T) d = defaultdict(list) for i in range(Ls): d[S[i]].append(i + 1) now = 0 ans = 0 for i in range(Lt): if not d[T[i]]: ...
false
2.941176
[ "+ Ls = len(S)", "+ Lt = len(T)", "- for i, s in enumerate(S):", "- d[s].append(i + 1)", "- pre = 0", "- cnt = 0", "- loop = 0", "- len_S = len(S)", "- for t in T:", "- if not d[t]:", "+ for i in range(Ls):", "+ d[S[i]].append(i + 1)", "+ no...
false
0.041939
0.114374
0.366686
[ "s332254430", "s120740375" ]
u814387366
p02393
python
s290887608
s811881629
20
10
4,208
4,212
Accepted
Accepted
50
a,b,c=list(map(int,input().split())) if(a>b): tmp=a a=b b=tmp if(b>c): tmp=b b=c c=tmp if(a>b): tmp=a a=b b=tmp print(a,b,c)
a,b,c=list(map(int,input().split())) if(a>b): tmp=a a=b b=tmp if(b>c): tmp=b b=c c=tmp if(a>b): tmp=b b=a a=tmp print(str(a)+" "+str(b)+" "+str(c))
14
14
143
166
a, b, c = list(map(int, input().split())) if a > b: tmp = a a = b b = tmp if b > c: tmp = b b = c c = tmp if a > b: tmp = a a = b b = tmp print(a, b, c)
a, b, c = list(map(int, input().split())) if a > b: tmp = a a = b b = tmp if b > c: tmp = b b = c c = tmp if a > b: tmp = b b = a a = tmp print(str(a) + " " + str(b) + " " + str(c))
false
0
[ "- tmp = a", "- a = b", "- b = tmp", "-print(a, b, c)", "+ tmp = b", "+ b = a", "+ a = tmp", "+print(str(a) + \" \" + str(b) + \" \" + str(c))" ]
false
0.03762
0.046221
0.813907
[ "s290887608", "s811881629" ]
u645250356
p03998
python
s372532802
s908877984
161
40
38,256
5,324
Accepted
Accepted
75.16
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools sys.setrecursionlimit(10**8) mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpln(n): return list(int(sys.st...
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(m...
33
23
835
637
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools sys.setrecursionlimit(10**8) mod = 10**9 + 7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpln(n): r...
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify from bisect import bisect_left, bisect_right import sys, math, itertools, fractions, pprint sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): ...
false
30.30303
[ "-import sys, bisect, math, itertools", "+from bisect import bisect_left, bisect_right", "+import sys, math, itertools, fractions, pprint", "+INF = float(\"inf\")", "-def inpln(n):", "- return list(int(sys.stdin.readline()) for i in range(n))", "-", "-", "-s = [list(eval(input())) for i in range(...
false
0.036985
0.045582
0.811398
[ "s372532802", "s908877984" ]
u790710233
p02768
python
s304385875
s763636074
148
116
3,060
3,060
Accepted
Accepted
21.62
n, a, b = list(map(int, input().split())) MOD = 10**9+7 def COM(n, r): X = Y = 1 if n-r < r: r = n-r for i in range(1, r+1): Y = Y*i % MOD X = X*(n-i+1) % MOD Y = pow(Y, MOD-2, MOD) return X*Y ans = pow(2, n, MOD)-1 - COM(n, a)-COM(n, b) ans %= MOD print(...
n, a, b = list(map(int, input().split())) MOD = 10**9+7 ans = pow(2, n, MOD)-1 X = Y = 1 for i in range(1, b+1): Y = Y*i % MOD X = X*(n-i+1) % MOD if i == a or i == b: ans -= X*pow(Y, MOD-2, MOD) print((ans % MOD))
18
11
319
237
n, a, b = list(map(int, input().split())) MOD = 10**9 + 7 def COM(n, r): X = Y = 1 if n - r < r: r = n - r for i in range(1, r + 1): Y = Y * i % MOD X = X * (n - i + 1) % MOD Y = pow(Y, MOD - 2, MOD) return X * Y ans = pow(2, n, MOD) - 1 - COM(n, a) - COM(n, b) ans %= MOD...
n, a, b = list(map(int, input().split())) MOD = 10**9 + 7 ans = pow(2, n, MOD) - 1 X = Y = 1 for i in range(1, b + 1): Y = Y * i % MOD X = X * (n - i + 1) % MOD if i == a or i == b: ans -= X * pow(Y, MOD - 2, MOD) print((ans % MOD))
false
38.888889
[ "-", "-", "-def COM(n, r):", "- X = Y = 1", "- if n - r < r:", "- r = n - r", "- for i in range(1, r + 1):", "- Y = Y * i % MOD", "- X = X * (n - i + 1) % MOD", "- Y = pow(Y, MOD - 2, MOD)", "- return X * Y", "-", "-", "-ans = pow(2, n, MOD) - 1 - COM(n,...
false
0.322452
0.31466
1.024763
[ "s304385875", "s763636074" ]
u991567869
p02862
python
s404597687
s689374071
1,085
144
9,160
9,212
Accepted
Accepted
86.73
x, y = list(map(int, input().split())) diff = abs(x - y) ref = (min(x, y) - diff)//3 total = ref*2 + diff mod = 10**9 + 7 ans = 1 if (x + y)%3 != 0 or ref < 0: print((0)) exit() for i in range(min(ref, total - ref)): ans = ans*(total - i)%mod ie = pow((i + 1), (mod - 2), mod) ans =...
x, y = list(map(int, input().split())) diff = abs(x - y) ref = (min(x, y) - diff)//3 total = ref*2 + diff mod = 10**9 + 7 ans = 1 ie = 1 if (x + y)%3 != 0 or ref < 0: print((0)) exit() for i in range(min(ref, total - ref)): ans = ans*(total - i)%mod ie = ie*(i + 1)%mod ie = pow(ie, ...
18
20
337
355
x, y = list(map(int, input().split())) diff = abs(x - y) ref = (min(x, y) - diff) // 3 total = ref * 2 + diff mod = 10**9 + 7 ans = 1 if (x + y) % 3 != 0 or ref < 0: print((0)) exit() for i in range(min(ref, total - ref)): ans = ans * (total - i) % mod ie = pow((i + 1), (mod - 2), mod) ans = ans * i...
x, y = list(map(int, input().split())) diff = abs(x - y) ref = (min(x, y) - diff) // 3 total = ref * 2 + diff mod = 10**9 + 7 ans = 1 ie = 1 if (x + y) % 3 != 0 or ref < 0: print((0)) exit() for i in range(min(ref, total - ref)): ans = ans * (total - i) % mod ie = ie * (i + 1) % mod ie = pow(ie, mod - 2...
false
10
[ "+ie = 1", "- ie = pow((i + 1), (mod - 2), mod)", "- ans = ans * ie % mod", "+ ie = ie * (i + 1) % mod", "+ie = pow(ie, mod - 2, mod)", "+ans = ans * ie % mod" ]
false
0.290087
0.059186
4.901299
[ "s404597687", "s689374071" ]
u252828980
p02947
python
s506973311
s525463719
675
362
19,512
19,756
Accepted
Accepted
46.37
n = int(eval(input())) L = [] for i in range(n): s= "" l = sorted(list(eval(input()))) for j in range(len(l)): s += l[j] L.append(s) dic = {} for i in range(n): if L[i] not in dic: dic[L[i]] = 1 else: dic[L[i]] += 1 ans = 0 for v in list(dic.values()): ...
n = int(eval(input())) from collections import Counter cnt= 0 L = [] for i in range(n): s = sorted(eval(input())) L.append(("".join(s))) L = Counter(L) for v in list(L.values()): cnt +=(v-1)*v//2 print(cnt)
20
12
336
212
n = int(eval(input())) L = [] for i in range(n): s = "" l = sorted(list(eval(input()))) for j in range(len(l)): s += l[j] L.append(s) dic = {} for i in range(n): if L[i] not in dic: dic[L[i]] = 1 else: dic[L[i]] += 1 ans = 0 for v in list(dic.values()): ans += v * (v ...
n = int(eval(input())) from collections import Counter cnt = 0 L = [] for i in range(n): s = sorted(eval(input())) L.append(("".join(s))) L = Counter(L) for v in list(L.values()): cnt += (v - 1) * v // 2 print(cnt)
false
40
[ "+from collections import Counter", "+", "+cnt = 0", "- s = \"\"", "- l = sorted(list(eval(input())))", "- for j in range(len(l)):", "- s += l[j]", "- L.append(s)", "-dic = {}", "-for i in range(n):", "- if L[i] not in dic:", "- dic[L[i]] = 1", "- else:", "-...
false
0.037792
0.084907
0.4451
[ "s506973311", "s525463719" ]
u134302690
p02983
python
s708876011
s387073805
764
673
2,940
75,428
Accepted
Accepted
11.91
L, R = list(map(int, input().split())) mod = 2019 ans = mod + 1 if R - L >= 3000 or L == 0: print((0)) else: for i in range(L, R): for j in range(i + 1, R + 1): m = ((i%mod) * (j%mod)) % mod if m < ans: ans = m print(ans)
import sys L, R = list(map(int, input().split())) mod = 2019 ans = [] if R-L > 3000: print((0)) sys.exit() elif R-L <= 3000: for i in range(L, R + 1): for j in range(i + 1, R + 1): tmp = (i * j) % mod ans.append(tmp) print((min(ans)))
13
14
287
283
L, R = list(map(int, input().split())) mod = 2019 ans = mod + 1 if R - L >= 3000 or L == 0: print((0)) else: for i in range(L, R): for j in range(i + 1, R + 1): m = ((i % mod) * (j % mod)) % mod if m < ans: ans = m print(ans)
import sys L, R = list(map(int, input().split())) mod = 2019 ans = [] if R - L > 3000: print((0)) sys.exit() elif R - L <= 3000: for i in range(L, R + 1): for j in range(i + 1, R + 1): tmp = (i * j) % mod ans.append(tmp) print((min(ans)))
false
7.142857
[ "+import sys", "+", "-ans = mod + 1", "-if R - L >= 3000 or L == 0:", "+ans = []", "+if R - L > 3000:", "-else:", "- for i in range(L, R):", "+ sys.exit()", "+elif R - L <= 3000:", "+ for i in range(L, R + 1):", "- m = ((i % mod) * (j % mod)) % mod", "- if m < ...
false
0.048488
0.091835
0.527992
[ "s708876011", "s387073805" ]
u695857481
p03796
python
s391125970
s373492273
231
36
3,980
2,940
Accepted
Accepted
84.42
import math print((math.factorial(int(eval(input()))) % 1000000007))
n = int(eval(input())) power = 1 for i in range(1, n + 1): power = power * i % (1000000007) print(power)
2
5
61
104
import math print((math.factorial(int(eval(input()))) % 1000000007))
n = int(eval(input())) power = 1 for i in range(1, n + 1): power = power * i % (1000000007) print(power)
false
60
[ "-import math", "-", "-print((math.factorial(int(eval(input()))) % 1000000007))", "+n = int(eval(input()))", "+power = 1", "+for i in range(1, n + 1):", "+ power = power * i % (1000000007)", "+print(power)" ]
false
0.103405
0.040956
2.524771
[ "s391125970", "s373492273" ]
u982591663
p03013
python
s415716014
s664532863
637
187
462,708
6,964
Accepted
Accepted
70.64
N, M = list(map(int, input().split())) memo = [0]*(N+1) memo[0] = 1 mod = 10**9+7 for _ in range(M): ai = int(eval(input())) memo[ai] = None if memo[1] != None: memo[1] = 1 for i in range(2, N+1): tmp = 0 if memo[i] == None: continue if memo[i-1] != None: tmp ...
N, M = list(map(int, input().split())) memo = [0]*(N+1) memo[0] = 1 mod = 10**9+7 for _ in range(M): ai = int(eval(input())) memo[ai] = None if memo[1] != None: memo[1] = 1 for i in range(2, N+1): tmp = 0 if memo[i] == None: continue if memo[i-1] != None: tmp ...
26
26
461
467
N, M = list(map(int, input().split())) memo = [0] * (N + 1) memo[0] = 1 mod = 10**9 + 7 for _ in range(M): ai = int(eval(input())) memo[ai] = None if memo[1] != None: memo[1] = 1 for i in range(2, N + 1): tmp = 0 if memo[i] == None: continue if memo[i - 1] != None: tmp += memo[i ...
N, M = list(map(int, input().split())) memo = [0] * (N + 1) memo[0] = 1 mod = 10**9 + 7 for _ in range(M): ai = int(eval(input())) memo[ai] = None if memo[1] != None: memo[1] = 1 for i in range(2, N + 1): tmp = 0 if memo[i] == None: continue if memo[i - 1] != None: tmp += memo[i ...
false
0
[ "- memo[i] = tmp", "+ memo[i] = tmp % mod" ]
false
0.054684
0.036962
1.47946
[ "s415716014", "s664532863" ]
u332906195
p02781
python
s185310498
s466647466
1,499
20
49,592
3,064
Accepted
Accepted
98.67
from math import factorial def comb(n, r): return factorial(n) // factorial(r) // factorial(n - r) N = input() K = int(input()) ans = 0 if K == 1: for i in range(1, len(N)): ans += 9 ans += int(N[0]) elif K == 2: for i in range(K, len(N)): ans += 81 * comb(i - 1, 1) ...
def comb(n, k): nu, de = 1, 1 for i in range(k): de *= n - i nu *= i + 1 return de // nu def ans(N, K): if K == 0: return 1 N = str(int(N)) if len(N) < K or int(N) == 0: return 0 ret = sum([9 ** K * comb(max(dig - 1, 1), K - 1) ...
36
23
1,041
508
from math import factorial def comb(n, r): return factorial(n) // factorial(r) // factorial(n - r) N = input() K = int(input()) ans = 0 if K == 1: for i in range(1, len(N)): ans += 9 ans += int(N[0]) elif K == 2: for i in range(K, len(N)): ans += 81 * comb(i - 1, 1) for i1 in ran...
def comb(n, k): nu, de = 1, 1 for i in range(k): de *= n - i nu *= i + 1 return de // nu def ans(N, K): if K == 0: return 1 N = str(int(N)) if len(N) < K or int(N) == 0: return 0 ret = sum([9**K * comb(max(dig - 1, 1), K - 1) for dig in range(K, len(N))]) ...
false
36.111111
[ "-from math import factorial", "+def comb(n, k):", "+ nu, de = 1, 1", "+ for i in range(k):", "+ de *= n - i", "+ nu *= i + 1", "+ return de // nu", "-def comb(n, r):", "- return factorial(n) // factorial(r) // factorial(n - r)", "+def ans(N, K):", "+ if K == 0:", ...
false
0.087293
0.06493
1.344419
[ "s185310498", "s466647466" ]