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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u790710233
|
p03665
|
python
|
s598490894
|
s402771360
| 98 | 30 | 9,008 | 9,200 |
Accepted
|
Accepted
| 69.39 |
n, p = list(map(int, input().split()))
A = list(map(int, input().split()))
U = n*100
dp = [0]*(U+1)
dp[0] = 1
for a in A:
for j in reversed(list(range(U+1))):
if 0 <= j-a:
dp[j] += dp[j-a]
print((sum(dp[p::2])))
|
n, p = list(map(int, input().split()))
A = list(map(int, input().split()))
if all(a % 2 == 0 for a in A):
if p:
print((0))
else:
print((pow(2, n)))
else:
print((pow(2, n-1)))
| 10 | 9 | 231 | 199 |
n, p = list(map(int, input().split()))
A = list(map(int, input().split()))
U = n * 100
dp = [0] * (U + 1)
dp[0] = 1
for a in A:
for j in reversed(list(range(U + 1))):
if 0 <= j - a:
dp[j] += dp[j - a]
print((sum(dp[p::2])))
|
n, p = list(map(int, input().split()))
A = list(map(int, input().split()))
if all(a % 2 == 0 for a in A):
if p:
print((0))
else:
print((pow(2, n)))
else:
print((pow(2, n - 1)))
| false | 10 |
[
"-U = n * 100",
"-dp = [0] * (U + 1)",
"-dp[0] = 1",
"-for a in A:",
"- for j in reversed(list(range(U + 1))):",
"- if 0 <= j - a:",
"- dp[j] += dp[j - a]",
"-print((sum(dp[p::2])))",
"+if all(a % 2 == 0 for a in A):",
"+ if p:",
"+ print((0))",
"+ else:",
"+ print((pow(2, n)))",
"+else:",
"+ print((pow(2, n - 1)))"
] | false | 0.151854 | 0.119889 | 1.266618 |
[
"s598490894",
"s402771360"
] |
u813098295
|
p02990
|
python
|
s990705325
|
s113714532
| 1,302 | 24 | 3,316 | 3,572 |
Accepted
|
Accepted
| 98.16 |
def mod_inverse(x, mod):
return pow(x, mod - 2, mod)
# return nCk % mod
# it takes O(k)
def mod_comb(n, k, mod):
numer, denom = 1, 1
for i in range(k):
numer = numer * ((n - i) % mod) % mod
denom = denom * ((i + 1) % mod) % mod
return numer * mod_inverse(denom, mod) % mod
mod = 10**9 + 7
N, K = list(map(int, input().split()))
for i in range(1, K + 1):
a = mod_comb(N - K + 1, i, mod)
b = mod_comb(K - 1, i - 1, mod)
print((a * b % mod))
|
class Combination:
def __init__(self, max_n, _mod):
self.mod = _mod
self.fac = [0 for _ in range(max_n + 10)]
self.finv = [0 for _ in range(max_n + 10)]
self.inv = [0 for _ in range(max_n + 10)]
self.fac[0], self.fac[1] = 1, 1
self.finv[0], self.finv[1] = 1, 1
self.inv[1] = 1
for i in range(2, max_n + 10):
self.fac[i] = self.fac[i - 1] * i % self.mod
self.inv[i] = self.mod
self.inv[i] -= self.inv[self.mod % i] * (self.mod // i) % self.mod
self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod
def mod_comb(self, n, k):
if n < k or n < 0 or k < 0:
return 0
res = self.fac[n] * (self.finv[k] * self.finv[n - k] % self.mod)
res %= self.mod
return res
def main():
max_n = 2000
mod = 10**9 + 7
comb = Combination(max_n, mod)
N, K = list(map(int, input().split()))
for i in range(1, K + 1):
a = comb.mod_comb(N - K + 1, i)
b = comb.mod_comb(K - 1, i - 1)
print((a * b % mod))
main()
| 22 | 41 | 501 | 1,134 |
def mod_inverse(x, mod):
return pow(x, mod - 2, mod)
# return nCk % mod
# it takes O(k)
def mod_comb(n, k, mod):
numer, denom = 1, 1
for i in range(k):
numer = numer * ((n - i) % mod) % mod
denom = denom * ((i + 1) % mod) % mod
return numer * mod_inverse(denom, mod) % mod
mod = 10**9 + 7
N, K = list(map(int, input().split()))
for i in range(1, K + 1):
a = mod_comb(N - K + 1, i, mod)
b = mod_comb(K - 1, i - 1, mod)
print((a * b % mod))
|
class Combination:
def __init__(self, max_n, _mod):
self.mod = _mod
self.fac = [0 for _ in range(max_n + 10)]
self.finv = [0 for _ in range(max_n + 10)]
self.inv = [0 for _ in range(max_n + 10)]
self.fac[0], self.fac[1] = 1, 1
self.finv[0], self.finv[1] = 1, 1
self.inv[1] = 1
for i in range(2, max_n + 10):
self.fac[i] = self.fac[i - 1] * i % self.mod
self.inv[i] = self.mod
self.inv[i] -= self.inv[self.mod % i] * (self.mod // i) % self.mod
self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod
def mod_comb(self, n, k):
if n < k or n < 0 or k < 0:
return 0
res = self.fac[n] * (self.finv[k] * self.finv[n - k] % self.mod)
res %= self.mod
return res
def main():
max_n = 2000
mod = 10**9 + 7
comb = Combination(max_n, mod)
N, K = list(map(int, input().split()))
for i in range(1, K + 1):
a = comb.mod_comb(N - K + 1, i)
b = comb.mod_comb(K - 1, i - 1)
print((a * b % mod))
main()
| false | 46.341463 |
[
"-def mod_inverse(x, mod):",
"- return pow(x, mod - 2, mod)",
"+class Combination:",
"+ def __init__(self, max_n, _mod):",
"+ self.mod = _mod",
"+ self.fac = [0 for _ in range(max_n + 10)]",
"+ self.finv = [0 for _ in range(max_n + 10)]",
"+ self.inv = [0 for _ in range(max_n + 10)]",
"+ self.fac[0], self.fac[1] = 1, 1",
"+ self.finv[0], self.finv[1] = 1, 1",
"+ self.inv[1] = 1",
"+ for i in range(2, max_n + 10):",
"+ self.fac[i] = self.fac[i - 1] * i % self.mod",
"+ self.inv[i] = self.mod",
"+ self.inv[i] -= self.inv[self.mod % i] * (self.mod // i) % self.mod",
"+ self.finv[i] = self.finv[i - 1] * self.inv[i] % self.mod",
"+",
"+ def mod_comb(self, n, k):",
"+ if n < k or n < 0 or k < 0:",
"+ return 0",
"+ res = self.fac[n] * (self.finv[k] * self.finv[n - k] % self.mod)",
"+ res %= self.mod",
"+ return res",
"-# return nCk % mod",
"-# it takes O(k)",
"-def mod_comb(n, k, mod):",
"- numer, denom = 1, 1",
"- for i in range(k):",
"- numer = numer * ((n - i) % mod) % mod",
"- denom = denom * ((i + 1) % mod) % mod",
"- return numer * mod_inverse(denom, mod) % mod",
"+def main():",
"+ max_n = 2000",
"+ mod = 10**9 + 7",
"+ comb = Combination(max_n, mod)",
"+ N, K = list(map(int, input().split()))",
"+ for i in range(1, K + 1):",
"+ a = comb.mod_comb(N - K + 1, i)",
"+ b = comb.mod_comb(K - 1, i - 1)",
"+ print((a * b % mod))",
"-mod = 10**9 + 7",
"-N, K = list(map(int, input().split()))",
"-for i in range(1, K + 1):",
"- a = mod_comb(N - K + 1, i, mod)",
"- b = mod_comb(K - 1, i - 1, mod)",
"- print((a * b % mod))",
"+main()"
] | false | 0.071755 | 0.042476 | 1.689325 |
[
"s990705325",
"s113714532"
] |
u129978636
|
p03861
|
python
|
s365691137
|
s882979252
| 21 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 19.05 |
a, b, x = list(map(int, input().split()))
c=a//x
d=b//x
e=a%x
if(e == 0):
print((d-c+1))
else:
print((d-c))
|
a,b,x=list(map(int, input().split()))
c=b//x-a//x
if(a%x==0):
print((c+1))
else:
print(c)
| 8 | 6 | 112 | 94 |
a, b, x = list(map(int, input().split()))
c = a // x
d = b // x
e = a % x
if e == 0:
print((d - c + 1))
else:
print((d - c))
|
a, b, x = list(map(int, input().split()))
c = b // x - a // x
if a % x == 0:
print((c + 1))
else:
print(c)
| false | 25 |
[
"-c = a // x",
"-d = b // x",
"-e = a % x",
"-if e == 0:",
"- print((d - c + 1))",
"+c = b // x - a // x",
"+if a % x == 0:",
"+ print((c + 1))",
"- print((d - c))",
"+ print(c)"
] | false | 0.08663 | 0.042561 | 2.035461 |
[
"s365691137",
"s882979252"
] |
u077291787
|
p03137
|
python
|
s079432507
|
s394983411
| 103 | 80 | 13,960 | 18,960 |
Accepted
|
Accepted
| 22.33 |
# ABC117C - Streamline
def main():
n, m = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())))
dis = []
for i, j in zip(lst, lst[1:]):
dis += [j - i]
print((sum(sorted(dis, reverse=True)[n - 1 :])))
if __name__ == "__main__":
main()
|
# ABC117C - Streamline
def main():
n, m = list(map(int, input().rstrip().split()))
lst = sorted(set(map(int, input().rstrip().split())))
dis = []
for i, j in zip(lst, lst[1:]):
dis += [j - i]
print((sum(sorted(dis, reverse=True)[n - 1 :])))
if __name__ == "__main__":
main()
| 12 | 12 | 318 | 317 |
# ABC117C - Streamline
def main():
n, m = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())))
dis = []
for i, j in zip(lst, lst[1:]):
dis += [j - i]
print((sum(sorted(dis, reverse=True)[n - 1 :])))
if __name__ == "__main__":
main()
|
# ABC117C - Streamline
def main():
n, m = list(map(int, input().rstrip().split()))
lst = sorted(set(map(int, input().rstrip().split())))
dis = []
for i, j in zip(lst, lst[1:]):
dis += [j - i]
print((sum(sorted(dis, reverse=True)[n - 1 :])))
if __name__ == "__main__":
main()
| false | 0 |
[
"- lst = sorted(list(map(int, input().rstrip().split())))",
"+ lst = sorted(set(map(int, input().rstrip().split())))"
] | false | 0.046719 | 0.091911 | 0.508309 |
[
"s079432507",
"s394983411"
] |
u788691282
|
p02659
|
python
|
s649182002
|
s844083151
| 23 | 20 | 9,168 | 9,164 |
Accepted
|
Accepted
| 13.04 |
a, b = input().split()
a = int(a)
b = int(float(b)*1000)
print(((a*b)//1000))
|
a, b = input().split()
a = int(a)
b = int(float(b)*100+0.5)
print(((a*b)//100))
| 6 | 6 | 82 | 86 |
a, b = input().split()
a = int(a)
b = int(float(b) * 1000)
print(((a * b) // 1000))
|
a, b = input().split()
a = int(a)
b = int(float(b) * 100 + 0.5)
print(((a * b) // 100))
| false | 0 |
[
"-b = int(float(b) * 1000)",
"-print(((a * b) // 1000))",
"+b = int(float(b) * 100 + 0.5)",
"+print(((a * b) // 100))"
] | false | 0.041272 | 0.042307 | 0.975533 |
[
"s649182002",
"s844083151"
] |
u562935282
|
p03250
|
python
|
s152607687
|
s196313004
| 19 | 17 | 3,316 | 2,940 |
Accepted
|
Accepted
| 10.53 |
def nl(): return list(map(int, input().split()))
# print('Yes' if a else 'No')
arr = nl()
print((max(arr) * 9 + sum(arr)))
|
ary = list(map(int, input().split()))
ans = sum(ary) + 9 * max(ary)
print(ans)
| 5 | 3 | 125 | 80 |
def nl():
return list(map(int, input().split()))
# print('Yes' if a else 'No')
arr = nl()
print((max(arr) * 9 + sum(arr)))
|
ary = list(map(int, input().split()))
ans = sum(ary) + 9 * max(ary)
print(ans)
| false | 40 |
[
"-def nl():",
"- return list(map(int, input().split()))",
"-",
"-",
"-# print('Yes' if a else 'No')",
"-arr = nl()",
"-print((max(arr) * 9 + sum(arr)))",
"+ary = list(map(int, input().split()))",
"+ans = sum(ary) + 9 * max(ary)",
"+print(ans)"
] | false | 0.066376 | 0.068422 | 0.970099 |
[
"s152607687",
"s196313004"
] |
u314050667
|
p03835
|
python
|
s257550082
|
s944311213
| 1,263 | 163 | 2,940 | 12,488 |
Accepted
|
Accepted
| 87.09 |
K, S = list(map(int, input().split()))
ans = 0
for i in range(K+1):
for j in range(K+1):
if 0 <= S-(i+j) <= K:
ans += 1
print(ans)
|
import numpy as np
K, S = list(map(int, input().split()))
x1 = np.ones(K+1, np.int32)
x2 = np.convolve(x1,x1)
x3 = np.convolve(x1,x2)
ans = x3[S]
print(ans)
| 8 | 8 | 138 | 158 |
K, S = list(map(int, input().split()))
ans = 0
for i in range(K + 1):
for j in range(K + 1):
if 0 <= S - (i + j) <= K:
ans += 1
print(ans)
|
import numpy as np
K, S = list(map(int, input().split()))
x1 = np.ones(K + 1, np.int32)
x2 = np.convolve(x1, x1)
x3 = np.convolve(x1, x2)
ans = x3[S]
print(ans)
| false | 0 |
[
"+import numpy as np",
"+",
"-ans = 0",
"-for i in range(K + 1):",
"- for j in range(K + 1):",
"- if 0 <= S - (i + j) <= K:",
"- ans += 1",
"+x1 = np.ones(K + 1, np.int32)",
"+x2 = np.convolve(x1, x1)",
"+x3 = np.convolve(x1, x2)",
"+ans = x3[S]"
] | false | 0.04211 | 0.189336 | 0.222407 |
[
"s257550082",
"s944311213"
] |
u994988729
|
p04020
|
python
|
s379131891
|
s988999886
| 316 | 127 | 7,068 | 7,840 |
Accepted
|
Accepted
| 59.81 |
n = int(eval(input()))
a = [0]
for _ in range(n):
a.append(int(eval(input())))
ans = 0
for i in range(n):
# (x,x)のペア
ans += a[i] // 2
a[i] -= a[i] // 2 * 2
# (x,x+1)のペア
ans += min(a[i], a[i + 1])
a[i + 1] -= min(a[i], a[i + 1])
else: # 最後にa[-1]でできるだけペアを作る
ans += a[-1] // 2
print(ans)
|
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)] + [0]
ans = 0
for i in range(N):
# できるだけ左でペアを作る
Lpair = A[i] // 2
ans += Lpair
A[i] -= 2 * Lpair
if A[i] > 0 and A[i + 1] > 0:
ans += 1
A[i] -= 1
A[i + 1] -= 1
print(ans)
| 20 | 20 | 330 | 331 |
n = int(eval(input()))
a = [0]
for _ in range(n):
a.append(int(eval(input())))
ans = 0
for i in range(n):
# (x,x)のペア
ans += a[i] // 2
a[i] -= a[i] // 2 * 2
# (x,x+1)のペア
ans += min(a[i], a[i + 1])
a[i + 1] -= min(a[i], a[i + 1])
else: # 最後にa[-1]でできるだけペアを作る
ans += a[-1] // 2
print(ans)
|
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)] + [0]
ans = 0
for i in range(N):
# できるだけ左でペアを作る
Lpair = A[i] // 2
ans += Lpair
A[i] -= 2 * Lpair
if A[i] > 0 and A[i + 1] > 0:
ans += 1
A[i] -= 1
A[i + 1] -= 1
print(ans)
| false | 0 |
[
"-n = int(eval(input()))",
"-a = [0]",
"-for _ in range(n):",
"- a.append(int(eval(input())))",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+N = int(eval(input()))",
"+A = [int(eval(input())) for _ in range(N)] + [0]",
"-for i in range(n):",
"- # (x,x)のペア",
"- ans += a[i] // 2",
"- a[i] -= a[i] // 2 * 2",
"- # (x,x+1)のペア",
"- ans += min(a[i], a[i + 1])",
"- a[i + 1] -= min(a[i], a[i + 1])",
"-else: # 最後にa[-1]でできるだけペアを作る",
"- ans += a[-1] // 2",
"+for i in range(N):",
"+ # できるだけ左でペアを作る",
"+ Lpair = A[i] // 2",
"+ ans += Lpair",
"+ A[i] -= 2 * Lpair",
"+ if A[i] > 0 and A[i + 1] > 0:",
"+ ans += 1",
"+ A[i] -= 1",
"+ A[i + 1] -= 1"
] | false | 0.080785 | 0.081769 | 0.987972 |
[
"s379131891",
"s988999886"
] |
u503228842
|
p03044
|
python
|
s607613827
|
s944364090
| 986 | 907 | 85,212 | 85,212 |
Accepted
|
Accepted
| 8.01 |
import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
adjacent_list = [[] for _ in range(N)]
for _ in range(N-1):
u, v, w = list(map(int,input().split()))
u -= 1
v -= 1
adjacent_list[u].append([v, w])
adjacent_list[v].append([u, w])
colors = [-1]*N
def dfs(v, color):
if colors[v] != -1:
return
colors[v] = color
for adjacent_v in adjacent_list[v]:
if adjacent_v[1] % 2 == 0:
dfs(adjacent_v[0], color)
else:
dfs(adjacent_v[0], 1-color)
dfs(0,0)
#print(*colors)
for i in range(N):
print((colors[i]))
|
import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
adjacent_list = [[] for _ in range(N)]
for _ in range(N-1):
u, v, w = list(map(int,input().split()))
u -= 1
v -= 1
adjacent_list[u].append([v, w])
adjacent_list[v].append([u, w])
colors = [-1]*N
def dfs(v, color):
if colors[v] != -1: # 探索済みでないかチェック。
return
colors[v] = color
for adjacent_v in adjacent_list[v]:
if adjacent_v[1] % 2 == 0:
dfs(adjacent_v[0], color)
else:
dfs(adjacent_v[0], 1-color)
dfs(0,0)
#print(*colors)
for i in range(N):
print((colors[i]))
| 30 | 30 | 613 | 629 |
import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
adjacent_list = [[] for _ in range(N)]
for _ in range(N - 1):
u, v, w = list(map(int, input().split()))
u -= 1
v -= 1
adjacent_list[u].append([v, w])
adjacent_list[v].append([u, w])
colors = [-1] * N
def dfs(v, color):
if colors[v] != -1:
return
colors[v] = color
for adjacent_v in adjacent_list[v]:
if adjacent_v[1] % 2 == 0:
dfs(adjacent_v[0], color)
else:
dfs(adjacent_v[0], 1 - color)
dfs(0, 0)
# print(*colors)
for i in range(N):
print((colors[i]))
|
import sys
sys.setrecursionlimit(10**9)
N = int(eval(input()))
adjacent_list = [[] for _ in range(N)]
for _ in range(N - 1):
u, v, w = list(map(int, input().split()))
u -= 1
v -= 1
adjacent_list[u].append([v, w])
adjacent_list[v].append([u, w])
colors = [-1] * N
def dfs(v, color):
if colors[v] != -1: # 探索済みでないかチェック。
return
colors[v] = color
for adjacent_v in adjacent_list[v]:
if adjacent_v[1] % 2 == 0:
dfs(adjacent_v[0], color)
else:
dfs(adjacent_v[0], 1 - color)
dfs(0, 0)
# print(*colors)
for i in range(N):
print((colors[i]))
| false | 0 |
[
"- if colors[v] != -1:",
"+ if colors[v] != -1: # 探索済みでないかチェック。"
] | false | 0.038653 | 0.03809 | 1.014763 |
[
"s607613827",
"s944364090"
] |
u181295070
|
p03012
|
python
|
s709245031
|
s432223694
| 20 | 17 | 3,316 | 3,060 |
Accepted
|
Accepted
| 15 |
N = int(eval(input()))
W = list(map(int, input().split()))
l = []
for T in range(N):
sum1 = sum(W[:T+1])
sum2 = sum(W[T+1:])
d = abs(sum1-sum2)
l.append(d)
print((min(l)))
|
N = int(eval(input()))
W = list(map(int, input().split()))
l = []
for T in range(N):
sum1 = sum(W[:T])
sum2 = sum(W[T:])
d = abs(sum1-sum2)
l.append(d)
print((min(l)))
| 9 | 9 | 187 | 183 |
N = int(eval(input()))
W = list(map(int, input().split()))
l = []
for T in range(N):
sum1 = sum(W[: T + 1])
sum2 = sum(W[T + 1 :])
d = abs(sum1 - sum2)
l.append(d)
print((min(l)))
|
N = int(eval(input()))
W = list(map(int, input().split()))
l = []
for T in range(N):
sum1 = sum(W[:T])
sum2 = sum(W[T:])
d = abs(sum1 - sum2)
l.append(d)
print((min(l)))
| false | 0 |
[
"- sum1 = sum(W[: T + 1])",
"- sum2 = sum(W[T + 1 :])",
"+ sum1 = sum(W[:T])",
"+ sum2 = sum(W[T:])"
] | false | 0.043206 | 0.04328 | 0.998291 |
[
"s709245031",
"s432223694"
] |
u059436995
|
p03739
|
python
|
s480737077
|
s427086109
| 221 | 81 | 14,464 | 14,332 |
Accepted
|
Accepted
| 63.35 |
n = int(eval(input()))
a = list(map(int,input().split()))
b = [a_ for a_ in a]
ans = 10**14
for a0 in [-1,a[0],1]:
if a0 == 0:
continue
ans_ = abs(a[0]-a0)
b[0] = a0
sign = b[0] > 0
for i in range(1,n):
b[i] = a[i]+b[i-1]
if sign:
if b[i] >= 0:
ans_ += b[i]+1
b[i] = -1
else:
if b[i] <= 0:
ans_ += 1-b[i]
b[i] = 1
sign = not sign
ans = min(ans, ans_)
print(ans)
|
n = int(eval(input()))
A = list(map(int, input().split()))
def adj(n, a ,flag):
na = 0
cnt = 0
for i in range(n):
na += a[i]
if flag == 1:
if na <= 0:
cnt += 1 - na
na = 1
flag = -1
elif flag == -1:
if na >= 0:
cnt += na + 1
na = -1
flag = 1
return cnt
print((min(adj(n, A, 1),adj(n, A, -1))))
| 24 | 22 | 532 | 482 |
n = int(eval(input()))
a = list(map(int, input().split()))
b = [a_ for a_ in a]
ans = 10**14
for a0 in [-1, a[0], 1]:
if a0 == 0:
continue
ans_ = abs(a[0] - a0)
b[0] = a0
sign = b[0] > 0
for i in range(1, n):
b[i] = a[i] + b[i - 1]
if sign:
if b[i] >= 0:
ans_ += b[i] + 1
b[i] = -1
else:
if b[i] <= 0:
ans_ += 1 - b[i]
b[i] = 1
sign = not sign
ans = min(ans, ans_)
print(ans)
|
n = int(eval(input()))
A = list(map(int, input().split()))
def adj(n, a, flag):
na = 0
cnt = 0
for i in range(n):
na += a[i]
if flag == 1:
if na <= 0:
cnt += 1 - na
na = 1
flag = -1
elif flag == -1:
if na >= 0:
cnt += na + 1
na = -1
flag = 1
return cnt
print((min(adj(n, A, 1), adj(n, A, -1))))
| false | 8.333333 |
[
"-a = list(map(int, input().split()))",
"-b = [a_ for a_ in a]",
"-ans = 10**14",
"-for a0 in [-1, a[0], 1]:",
"- if a0 == 0:",
"- continue",
"- ans_ = abs(a[0] - a0)",
"- b[0] = a0",
"- sign = b[0] > 0",
"- for i in range(1, n):",
"- b[i] = a[i] + b[i - 1]",
"- if sign:",
"- if b[i] >= 0:",
"- ans_ += b[i] + 1",
"- b[i] = -1",
"- else:",
"- if b[i] <= 0:",
"- ans_ += 1 - b[i]",
"- b[i] = 1",
"- sign = not sign",
"- ans = min(ans, ans_)",
"-print(ans)",
"+A = list(map(int, input().split()))",
"+",
"+",
"+def adj(n, a, flag):",
"+ na = 0",
"+ cnt = 0",
"+ for i in range(n):",
"+ na += a[i]",
"+ if flag == 1:",
"+ if na <= 0:",
"+ cnt += 1 - na",
"+ na = 1",
"+ flag = -1",
"+ elif flag == -1:",
"+ if na >= 0:",
"+ cnt += na + 1",
"+ na = -1",
"+ flag = 1",
"+ return cnt",
"+",
"+",
"+print((min(adj(n, A, 1), adj(n, A, -1))))"
] | false | 0.037227 | 0.03703 | 1.005323 |
[
"s480737077",
"s427086109"
] |
u148101999
|
p00030
|
python
|
s947735862
|
s082474550
| 20 | 10 | 6,408 | 6,428 |
Accepted
|
Accepted
| 50 |
#encoding=utf-8
while True:
x, num = list(map(int,input().split()))
if x == num == 0:
break
count = 0
for a in range(10):
if num == a and x == 1:
count += 1
if x > 1:
for b in range(a + 1,10):
if num == a+b and x == 2:
count += 1
if x > 2:
for c in range(b + 1,10):
if num == a+b+c and x == 3:
count += 1
if x > 3:
for d in range(c + 1,10):
if num == a+b+c+d and x == 4:
count += 1
if x > 4:
for e in range(d + 1,10):
if num == a+b+c+d+e and x == 5:
count += 1
if x > 5:
for f in range(e + 1,10):
if num == a+b+c+d+e+f and x == 6:
count += 1
if x > 6:
for g in range(f + 1,10):
if num == a+b+c+d+e+f+g and x == 7:
count += 1
if x > 7:
for h in range(g + 1,10):
if num == a+b+c+d+e+f+g+h and x == 8:
count += 1
if x > 8:
for i in range(h + 1,10):
if num == a+b+c+d+e+f+g+h+i and x == 9:
count += 1
print(count)
|
import itertools as iter
while True:
count = 0
x,y = list(map(int,input().split()))
if x == y == 0: break
for element in iter.combinations(list(range(10)),x):
if sum(element) == y:
count += 1
print(count)
| 44 | 9 | 1,227 | 213 |
# encoding=utf-8
while True:
x, num = list(map(int, input().split()))
if x == num == 0:
break
count = 0
for a in range(10):
if num == a and x == 1:
count += 1
if x > 1:
for b in range(a + 1, 10):
if num == a + b and x == 2:
count += 1
if x > 2:
for c in range(b + 1, 10):
if num == a + b + c and x == 3:
count += 1
if x > 3:
for d in range(c + 1, 10):
if num == a + b + c + d and x == 4:
count += 1
if x > 4:
for e in range(d + 1, 10):
if num == a + b + c + d + e and x == 5:
count += 1
if x > 5:
for f in range(e + 1, 10):
if (
num == a + b + c + d + e + f
and x == 6
):
count += 1
if x > 6:
for g in range(f + 1, 10):
if (
num
== a + b + c + d + e + f + g
and x == 7
):
count += 1
if x > 7:
for h in range(g + 1, 10):
if (
num
== a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
and x == 8
):
count += 1
if x > 8:
for i in range(
h + 1, 10
):
if (
num
== a
+ b
+ c
+ d
+ e
+ f
+ g
+ h
+ i
and x == 9
):
count += 1
print(count)
|
import itertools as iter
while True:
count = 0
x, y = list(map(int, input().split()))
if x == y == 0:
break
for element in iter.combinations(list(range(10)), x):
if sum(element) == y:
count += 1
print(count)
| false | 79.545455 |
[
"-# encoding=utf-8",
"+import itertools as iter",
"+",
"- x, num = list(map(int, input().split()))",
"- if x == num == 0:",
"+ count = 0",
"+ x, y = list(map(int, input().split()))",
"+ if x == y == 0:",
"- count = 0",
"- for a in range(10):",
"- if num == a and x == 1:",
"+ for element in iter.combinations(list(range(10)), x):",
"+ if sum(element) == y:",
"- if x > 1:",
"- for b in range(a + 1, 10):",
"- if num == a + b and x == 2:",
"- count += 1",
"- if x > 2:",
"- for c in range(b + 1, 10):",
"- if num == a + b + c and x == 3:",
"- count += 1",
"- if x > 3:",
"- for d in range(c + 1, 10):",
"- if num == a + b + c + d and x == 4:",
"- count += 1",
"- if x > 4:",
"- for e in range(d + 1, 10):",
"- if num == a + b + c + d + e and x == 5:",
"- count += 1",
"- if x > 5:",
"- for f in range(e + 1, 10):",
"- if (",
"- num == a + b + c + d + e + f",
"- and x == 6",
"- ):",
"- count += 1",
"- if x > 6:",
"- for g in range(f + 1, 10):",
"- if (",
"- num",
"- == a + b + c + d + e + f + g",
"- and x == 7",
"- ):",
"- count += 1",
"- if x > 7:",
"- for h in range(g + 1, 10):",
"- if (",
"- num",
"- == a",
"- + b",
"- + c",
"- + d",
"- + e",
"- + f",
"- + g",
"- + h",
"- and x == 8",
"- ):",
"- count += 1",
"- if x > 8:",
"- for i in range(",
"- h + 1, 10",
"- ):",
"- if (",
"- num",
"- == a",
"- + b",
"- + c",
"- + d",
"- + e",
"- + f",
"- + g",
"- + h",
"- + i",
"- and x == 9",
"- ):",
"- count += 1"
] | false | 0.039967 | 0.03831 | 1.043234 |
[
"s947735862",
"s082474550"
] |
u305366205
|
p03013
|
python
|
s906216418
|
s639520483
| 217 | 180 | 7,668 | 11,884 |
Accepted
|
Accepted
| 17.05 |
n,m = list(map(int, input().split()))
DIV = 10**9+7
a = [0]*(n+1)
dp = [0]*(n+1)
dp[0] = 1
for _ in range(m):
broken = int(eval(input()))
a[broken] = 1
for i in range(1,n+1):
dp[i]=(dp[i-1]+dp[i-2]) % DIV
if a[i] == 1:
dp[i] = 0
print((dp[n]))
|
n, m = list(map(int, input().split()))
# 壊れた場所を集合で持っておく
a = {int(eval(input())) for _ in range(m)}
route = [0] * (n + 1)
# route[2]のために初期値は1とする
route[0] = 1
for i in range(1, n + 1):
# 壊れた場所でないなら、そこまでのルート数を計算
if not (i in a):
if i == 1:
route[i] = 1
else:
route[i] = (route[i - 1] + route[i - 2]) % (10 ** 9 + 7)
print((route[n]))
| 13 | 14 | 266 | 377 |
n, m = list(map(int, input().split()))
DIV = 10**9 + 7
a = [0] * (n + 1)
dp = [0] * (n + 1)
dp[0] = 1
for _ in range(m):
broken = int(eval(input()))
a[broken] = 1
for i in range(1, n + 1):
dp[i] = (dp[i - 1] + dp[i - 2]) % DIV
if a[i] == 1:
dp[i] = 0
print((dp[n]))
|
n, m = list(map(int, input().split()))
# 壊れた場所を集合で持っておく
a = {int(eval(input())) for _ in range(m)}
route = [0] * (n + 1)
# route[2]のために初期値は1とする
route[0] = 1
for i in range(1, n + 1):
# 壊れた場所でないなら、そこまでのルート数を計算
if not (i in a):
if i == 1:
route[i] = 1
else:
route[i] = (route[i - 1] + route[i - 2]) % (10**9 + 7)
print((route[n]))
| false | 7.142857 |
[
"-DIV = 10**9 + 7",
"-a = [0] * (n + 1)",
"-dp = [0] * (n + 1)",
"-dp[0] = 1",
"-for _ in range(m):",
"- broken = int(eval(input()))",
"- a[broken] = 1",
"+# 壊れた場所を集合で持っておく",
"+a = {int(eval(input())) for _ in range(m)}",
"+route = [0] * (n + 1)",
"+# route[2]のために初期値は1とする",
"+route[0] = 1",
"- dp[i] = (dp[i - 1] + dp[i - 2]) % DIV",
"- if a[i] == 1:",
"- dp[i] = 0",
"-print((dp[n]))",
"+ # 壊れた場所でないなら、そこまでのルート数を計算",
"+ if not (i in a):",
"+ if i == 1:",
"+ route[i] = 1",
"+ else:",
"+ route[i] = (route[i - 1] + route[i - 2]) % (10**9 + 7)",
"+print((route[n]))"
] | false | 0.041838 | 0.043546 | 0.96079 |
[
"s906216418",
"s639520483"
] |
u759412327
|
p02818
|
python
|
s113441511
|
s511051261
| 29 | 26 | 9,164 | 9,160 |
Accepted
|
Accepted
| 10.34 |
A,B,K = list(map(int,input().split()))
if K<=A:
print((A-K,B))
elif K<=A+B:
print((0,A+B-K))
else:
print((0,0))
|
A,B,K = list(map(int, input().split()))
print((max(0,A-K),max(0,B-max(0,K-A))))
| 8 | 2 | 113 | 72 |
A, B, K = list(map(int, input().split()))
if K <= A:
print((A - K, B))
elif K <= A + B:
print((0, A + B - K))
else:
print((0, 0))
|
A, B, K = list(map(int, input().split()))
print((max(0, A - K), max(0, B - max(0, K - A))))
| false | 75 |
[
"-if K <= A:",
"- print((A - K, B))",
"-elif K <= A + B:",
"- print((0, A + B - K))",
"-else:",
"- print((0, 0))",
"+print((max(0, A - K), max(0, B - max(0, K - A))))"
] | false | 0.090214 | 0.074107 | 1.217341 |
[
"s113441511",
"s511051261"
] |
u905895868
|
p03041
|
python
|
s294421386
|
s936080974
| 27 | 23 | 9,140 | 8,996 |
Accepted
|
Accepted
| 14.81 |
def str_replace_to_lower() -> str:
len_str, target_index = list(map(int, input().split()))
word = eval(input())
list_of_word = list(word)
list_of_word[target_index - 1] = list_of_word[target_index - 1].lower()
return ''.join(list_of_word)
print((str_replace_to_lower()))
|
n, k = list(map(int, input().split()))
s = list(eval(input()))
tmp = s.pop(k - 1)
l = tmp.lower()
s.insert(k - 1, l)
print((''.join(s)))
| 10 | 7 | 288 | 130 |
def str_replace_to_lower() -> str:
len_str, target_index = list(map(int, input().split()))
word = eval(input())
list_of_word = list(word)
list_of_word[target_index - 1] = list_of_word[target_index - 1].lower()
return "".join(list_of_word)
print((str_replace_to_lower()))
|
n, k = list(map(int, input().split()))
s = list(eval(input()))
tmp = s.pop(k - 1)
l = tmp.lower()
s.insert(k - 1, l)
print(("".join(s)))
| false | 30 |
[
"-def str_replace_to_lower() -> str:",
"- len_str, target_index = list(map(int, input().split()))",
"- word = eval(input())",
"- list_of_word = list(word)",
"- list_of_word[target_index - 1] = list_of_word[target_index - 1].lower()",
"- return \"\".join(list_of_word)",
"-",
"-",
"-print((str_replace_to_lower()))",
"+n, k = list(map(int, input().split()))",
"+s = list(eval(input()))",
"+tmp = s.pop(k - 1)",
"+l = tmp.lower()",
"+s.insert(k - 1, l)",
"+print((\"\".join(s)))"
] | false | 0.094843 | 0.1009 | 0.939968 |
[
"s294421386",
"s936080974"
] |
u896791216
|
p02899
|
python
|
s571548091
|
s699090156
| 294 | 80 | 27,996 | 15,588 |
Accepted
|
Accepted
| 72.79 |
n = int(input())
a = list(map(int, input().split()))
mydict = {}
for i in range(n):
mydict[str(i+1)] = a[i]
mydict = sorted(mydict.items(), key= lambda x:x[1])
for j in range(n):
print(mydict[j][0], end=' ')
|
n = int(eval(input()))
a = list(map(int, input().split()))
anslist = [0] * n # 結果を収納するリスト。
for idx,elem in enumerate(a, start=1):
anslist[elem - 1] = str(idx)
print((' '.join(anslist)))
| 8 | 6 | 222 | 186 |
n = int(input())
a = list(map(int, input().split()))
mydict = {}
for i in range(n):
mydict[str(i + 1)] = a[i]
mydict = sorted(mydict.items(), key=lambda x: x[1])
for j in range(n):
print(mydict[j][0], end=" ")
|
n = int(eval(input()))
a = list(map(int, input().split()))
anslist = [0] * n # 結果を収納するリスト。
for idx, elem in enumerate(a, start=1):
anslist[elem - 1] = str(idx)
print((" ".join(anslist)))
| false | 25 |
[
"-n = int(input())",
"+n = int(eval(input()))",
"-mydict = {}",
"-for i in range(n):",
"- mydict[str(i + 1)] = a[i]",
"-mydict = sorted(mydict.items(), key=lambda x: x[1])",
"-for j in range(n):",
"- print(mydict[j][0], end=\" \")",
"+anslist = [0] * n # 結果を収納するリスト。",
"+for idx, elem in enumerate(a, start=1):",
"+ anslist[elem - 1] = str(idx)",
"+print((\" \".join(anslist)))"
] | false | 0.045083 | 0.086863 | 0.51901 |
[
"s571548091",
"s699090156"
] |
u879870653
|
p03448
|
python
|
s300828768
|
s584068145
| 79 | 50 | 8,276 | 3,060 |
Accepted
|
Accepted
| 36.71 |
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
L = []
answer = 0
for i in range(A+1) :
for j in range(B+1) :
for k in range(C+1) :
L.append(500*i+100*j+50*k)
for l in range(len(L)) :
if X-L[l] == 0 :
answer += 1
print(answer)
|
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
ans = 0
for a in range(A+1) :
for b in range(B+1) :
for c in range(C+1) :
if 500*a+100*b+50*c == X :
ans += 1
print(ans)
| 15 | 12 | 298 | 241 |
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
L = []
answer = 0
for i in range(A + 1):
for j in range(B + 1):
for k in range(C + 1):
L.append(500 * i + 100 * j + 50 * k)
for l in range(len(L)):
if X - L[l] == 0:
answer += 1
print(answer)
|
A = int(eval(input()))
B = int(eval(input()))
C = int(eval(input()))
X = int(eval(input()))
ans = 0
for a in range(A + 1):
for b in range(B + 1):
for c in range(C + 1):
if 500 * a + 100 * b + 50 * c == X:
ans += 1
print(ans)
| false | 20 |
[
"-L = []",
"-answer = 0",
"-for i in range(A + 1):",
"- for j in range(B + 1):",
"- for k in range(C + 1):",
"- L.append(500 * i + 100 * j + 50 * k)",
"-for l in range(len(L)):",
"- if X - L[l] == 0:",
"- answer += 1",
"-print(answer)",
"+ans = 0",
"+for a in range(A + 1):",
"+ for b in range(B + 1):",
"+ for c in range(C + 1):",
"+ if 500 * a + 100 * b + 50 * c == X:",
"+ ans += 1",
"+print(ans)"
] | false | 0.121226 | 0.077029 | 1.573779 |
[
"s300828768",
"s584068145"
] |
u503228842
|
p03503
|
python
|
s825789189
|
s551032033
| 318 | 261 | 3,064 | 3,064 |
Accepted
|
Accepted
| 17.92 |
# bit全探索
N = int(eval(input()))
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
ans = -float('inf')
for i in range(2**10):
if i == 0: # 全く営業しないパターン
continue
profit = 0
pattern = [0]*10
for j in range(10):
if 1 << j & i:
pattern[j] = 1
#print(pattern)
for k in range(N):
#l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])
l = 0
for m in range(10):
if pattern[m] == F[k][m] == 1:
l += 1
#print(l)
profit += P[k][l]
ans = max(ans,profit)
print(ans)
|
# bit全探索
N = int(eval(input()))
F = [list(map(int,input().split())) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
ans = -float('inf')
for i in range(2**10):
if i == 0: # 全く営業しないパターン
continue
profit = 0
pattern = [0]*10
for j in range(10):
if 1 << j & i:
pattern[j] = 1
#print(pattern)
for k in range(N):
l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])
# l = 0
# for m in range(10):
# if pattern[m] == F[k][m] == 1:
# l += 1
#print(l)
profit += P[k][l]
ans = max(ans,profit)
print(ans)
| 29 | 29 | 666 | 673 |
# bit全探索
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float("inf")
for i in range(2**10):
if i == 0: # 全く営業しないパターン
continue
profit = 0
pattern = [0] * 10
for j in range(10):
if 1 << j & i:
pattern[j] = 1
# print(pattern)
for k in range(N):
# l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])
l = 0
for m in range(10):
if pattern[m] == F[k][m] == 1:
l += 1
# print(l)
profit += P[k][l]
ans = max(ans, profit)
print(ans)
|
# bit全探索
N = int(eval(input()))
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float("inf")
for i in range(2**10):
if i == 0: # 全く営業しないパターン
continue
profit = 0
pattern = [0] * 10
for j in range(10):
if 1 << j & i:
pattern[j] = 1
# print(pattern)
for k in range(N):
l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])
# l = 0
# for m in range(10):
# if pattern[m] == F[k][m] == 1:
# l += 1
# print(l)
profit += P[k][l]
ans = max(ans, profit)
print(ans)
| false | 0 |
[
"- # l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])",
"- l = 0",
"- for m in range(10):",
"- if pattern[m] == F[k][m] == 1:",
"- l += 1",
"+ l = sum([pattern[m] == F[k][m] == 1 for m in range(10)])",
"+ # l = 0",
"+ # for m in range(10):",
"+ # if pattern[m] == F[k][m] == 1:",
"+ # l += 1"
] | false | 0.062132 | 0.045634 | 1.361517 |
[
"s825789189",
"s551032033"
] |
u546285759
|
p00018
|
python
|
s896699740
|
s652123613
| 30 | 20 | 7,652 | 7,548 |
Accepted
|
Accepted
| 33.33 |
print((' '.join(map(str, sorted(list(map(int, input().split())), reverse=True)))))
|
print((*sorted(list(map(int, input().split())))[::-1]))
| 1 | 1 | 80 | 53 |
print((" ".join(map(str, sorted(list(map(int, input().split())), reverse=True)))))
|
print((*sorted(list(map(int, input().split())))[::-1]))
| false | 0 |
[
"-print((\" \".join(map(str, sorted(list(map(int, input().split())), reverse=True)))))",
"+print((*sorted(list(map(int, input().split())))[::-1]))"
] | false | 0.04721 | 0.048064 | 0.982229 |
[
"s896699740",
"s652123613"
] |
u863370423
|
p02860
|
python
|
s111887361
|
s146806023
| 162 | 17 | 38,256 | 2,940 |
Accepted
|
Accepted
| 89.51 |
x = int(eval(input()))
s = eval(input())
if x%2 ==1 or s[:x//2] != s[x//2:]:
print('No')
else:
print('Yes')
|
l = int(eval(input()))
s = eval(input())
if s == s[:l//2] + s[:l//2]:
print('Yes')
else:
print('No')
| 6 | 7 | 102 | 97 |
x = int(eval(input()))
s = eval(input())
if x % 2 == 1 or s[: x // 2] != s[x // 2 :]:
print("No")
else:
print("Yes")
|
l = int(eval(input()))
s = eval(input())
if s == s[: l // 2] + s[: l // 2]:
print("Yes")
else:
print("No")
| false | 14.285714 |
[
"-x = int(eval(input()))",
"+l = int(eval(input()))",
"-if x % 2 == 1 or s[: x // 2] != s[x // 2 :]:",
"+if s == s[: l // 2] + s[: l // 2]:",
"+ print(\"Yes\")",
"+else:",
"-else:",
"- print(\"Yes\")"
] | false | 0.030383 | 0.035153 | 0.864323 |
[
"s111887361",
"s146806023"
] |
u071680334
|
p02599
|
python
|
s273418139
|
s843478933
| 1,991 | 1,820 | 229,732 | 225,464 |
Accepted
|
Accepted
| 8.59 |
from sys import stdin
input = stdin.readline
class SegTree():
def segfunc(self, x, y):
return x+y
def __init__(self, ide, n, init_val):
self.ide_ele = ide
self.num = 2**(n-1).bit_length()
self.seg = [self.ide_ele] * 2 * self.num
for i in range(n):
self.seg[i+self.num-1] = init_val[i]
for i in range(self.num-2,-1,-1):
self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2])
def update(self, k, x):
k += self.num-1
self.seg[k] = x
while k:
k = (k-1)//2
self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
def query(self, p, q):#p <= x < q
if q<=p:
return self.ide_ele
p += self.num-1
q += self.num-2
res = self.ide_ele
while q-p>1:
if p&1 == 0:
res = self.segfunc(res, self.seg[p])
if q&1 == 1:
res = self.segfunc(res, self.seg[q])
q -= 1
p = p//2
q = (q-1)//2
if p == q:
res = self.segfunc(res, self.seg[p])
else:
res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
return res
n, q = list(map(int, input().split()))
color = list(map(int, input().split()))
qry = [None]*q
ans = [0]*q
p = 0
for _ in ans:
l, r = list(map(int, input().split()))
qry[p] = [l-1, r, p]
p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 0
seg = SegTree(0, n, [0]*n)
for l, r, i in qry:
if last_update_idx < r:
st = set()
for j in range(last_update_idx, r):
if not color[j] in st and color[j] in dic:
seg.update(dic[color[j]], 0)
dic[color[j]] = j
st.add(color[j])
for v in st:
seg.update(dic[v], 1)
last_update_idx = r
ans[i] = seg.query(l, r)
for v in ans:
print(v)
|
from sys import stdin
input = stdin.readline
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
n, q = list(map(int, input().split()))
tmp = list(map(int, input().split()))
color = [-1]
for v in tmp:
color.append(v)
qry = [None]*q
ans = [0]*q
p = 0
for _ in ans:
l, r = list(map(int, input().split()))
qry[p] = [l-1, r, p]
p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 1
bit = Bit(n)
for l, r, i in qry:
if last_update_idx < r+1:
st = set()
for j in range(last_update_idx, r+1):
if not color[j] in st and color[j] in dic:
bit.add(dic[color[j]], -1)
dic[color[j]] = j
st.add(color[j])
for v in st:
bit.add(dic[v], 1)
last_update_idx = r+1
ans[i] = bit.sum(r) - bit.sum(l)
for v in ans:
print(v)
| 67 | 49 | 1,995 | 1,156 |
from sys import stdin
input = stdin.readline
class SegTree:
def segfunc(self, x, y):
return x + y
def __init__(self, ide, n, init_val):
self.ide_ele = ide
self.num = 2 ** (n - 1).bit_length()
self.seg = [self.ide_ele] * 2 * self.num
for i in range(n):
self.seg[i + self.num - 1] = init_val[i]
for i in range(self.num - 2, -1, -1):
self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])
def update(self, k, x):
k += self.num - 1
self.seg[k] = x
while k:
k = (k - 1) // 2
self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])
def query(self, p, q): # p <= x < q
if q <= p:
return self.ide_ele
p += self.num - 1
q += self.num - 2
res = self.ide_ele
while q - p > 1:
if p & 1 == 0:
res = self.segfunc(res, self.seg[p])
if q & 1 == 1:
res = self.segfunc(res, self.seg[q])
q -= 1
p = p // 2
q = (q - 1) // 2
if p == q:
res = self.segfunc(res, self.seg[p])
else:
res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
return res
n, q = list(map(int, input().split()))
color = list(map(int, input().split()))
qry = [None] * q
ans = [0] * q
p = 0
for _ in ans:
l, r = list(map(int, input().split()))
qry[p] = [l - 1, r, p]
p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 0
seg = SegTree(0, n, [0] * n)
for l, r, i in qry:
if last_update_idx < r:
st = set()
for j in range(last_update_idx, r):
if not color[j] in st and color[j] in dic:
seg.update(dic[color[j]], 0)
dic[color[j]] = j
st.add(color[j])
for v in st:
seg.update(dic[v], 1)
last_update_idx = r
ans[i] = seg.query(l, r)
for v in ans:
print(v)
|
from sys import stdin
input = stdin.readline
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
n, q = list(map(int, input().split()))
tmp = list(map(int, input().split()))
color = [-1]
for v in tmp:
color.append(v)
qry = [None] * q
ans = [0] * q
p = 0
for _ in ans:
l, r = list(map(int, input().split()))
qry[p] = [l - 1, r, p]
p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 1
bit = Bit(n)
for l, r, i in qry:
if last_update_idx < r + 1:
st = set()
for j in range(last_update_idx, r + 1):
if not color[j] in st and color[j] in dic:
bit.add(dic[color[j]], -1)
dic[color[j]] = j
st.add(color[j])
for v in st:
bit.add(dic[v], 1)
last_update_idx = r + 1
ans[i] = bit.sum(r) - bit.sum(l)
for v in ans:
print(v)
| false | 26.865672 |
[
"-class SegTree:",
"- def segfunc(self, x, y):",
"- return x + y",
"+class Bit:",
"+ def __init__(self, n):",
"+ self.size = n",
"+ self.tree = [0] * (n + 1)",
"- def __init__(self, ide, n, init_val):",
"- self.ide_ele = ide",
"- self.num = 2 ** (n - 1).bit_length()",
"- self.seg = [self.ide_ele] * 2 * self.num",
"- for i in range(n):",
"- self.seg[i + self.num - 1] = init_val[i]",
"- for i in range(self.num - 2, -1, -1):",
"- self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2])",
"+ def sum(self, i):",
"+ s = 0",
"+ while i > 0:",
"+ s += self.tree[i]",
"+ i -= i & -i",
"+ return s",
"- def update(self, k, x):",
"- k += self.num - 1",
"- self.seg[k] = x",
"- while k:",
"- k = (k - 1) // 2",
"- self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])",
"-",
"- def query(self, p, q): # p <= x < q",
"- if q <= p:",
"- return self.ide_ele",
"- p += self.num - 1",
"- q += self.num - 2",
"- res = self.ide_ele",
"- while q - p > 1:",
"- if p & 1 == 0:",
"- res = self.segfunc(res, self.seg[p])",
"- if q & 1 == 1:",
"- res = self.segfunc(res, self.seg[q])",
"- q -= 1",
"- p = p // 2",
"- q = (q - 1) // 2",
"- if p == q:",
"- res = self.segfunc(res, self.seg[p])",
"- else:",
"- res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])",
"- return res",
"+ def add(self, i, x):",
"+ while i <= self.size:",
"+ self.tree[i] += x",
"+ i += i & -i",
"-color = list(map(int, input().split()))",
"+tmp = list(map(int, input().split()))",
"+color = [-1]",
"+for v in tmp:",
"+ color.append(v)",
"-last_update_idx = 0",
"-seg = SegTree(0, n, [0] * n)",
"+last_update_idx = 1",
"+bit = Bit(n)",
"- if last_update_idx < r:",
"+ if last_update_idx < r + 1:",
"- for j in range(last_update_idx, r):",
"+ for j in range(last_update_idx, r + 1):",
"- seg.update(dic[color[j]], 0)",
"+ bit.add(dic[color[j]], -1)",
"- seg.update(dic[v], 1)",
"- last_update_idx = r",
"- ans[i] = seg.query(l, r)",
"+ bit.add(dic[v], 1)",
"+ last_update_idx = r + 1",
"+ ans[i] = bit.sum(r) - bit.sum(l)"
] | false | 0.037948 | 0.20251 | 0.187391 |
[
"s273418139",
"s843478933"
] |
u182004566
|
p02983
|
python
|
s837127189
|
s840757088
| 788 | 524 | 2,940 | 2,940 |
Accepted
|
Accepted
| 33.5 |
L, R = list(map(int, input().split()))
if R - L >= 2050:
print((0))
else:
ans = 20000000
for i in range(L, R):
for j in range(i+1, R+1):
ans = min(ans, (i * j) % 2019)
print(ans)
|
L, R = list(map(int, input().split()))
if R - L >= 2050:
print((0))
else:
ans = 20000000
for i in range(L, R):
for j in range(i+1, R+1):
x = (i*j)%2019
if x < ans:
ans = x
print(ans)
| 10 | 12 | 217 | 251 |
L, R = list(map(int, input().split()))
if R - L >= 2050:
print((0))
else:
ans = 20000000
for i in range(L, R):
for j in range(i + 1, R + 1):
ans = min(ans, (i * j) % 2019)
print(ans)
|
L, R = list(map(int, input().split()))
if R - L >= 2050:
print((0))
else:
ans = 20000000
for i in range(L, R):
for j in range(i + 1, R + 1):
x = (i * j) % 2019
if x < ans:
ans = x
print(ans)
| false | 16.666667 |
[
"- ans = min(ans, (i * j) % 2019)",
"+ x = (i * j) % 2019",
"+ if x < ans:",
"+ ans = x"
] | false | 0.043966 | 0.068703 | 0.639937 |
[
"s837127189",
"s840757088"
] |
u252828980
|
p03546
|
python
|
s168699274
|
s718121210
| 344 | 194 | 21,652 | 40,668 |
Accepted
|
Accepted
| 43.6 |
def main():
import numpy as np
h,w = list(map(int,input().split()))
d = np.zeros((10,10))
for i in range(10):
a = list(map(int,input().split()))
d[i] = a
def WF(b):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j],d[i][k] + d[k][j])
return d
WF(d)
L = []
for i in range(h):
b = list(map(int,input().split()))
L.append(b)
ans = 0
for i in range(h):
for j in range(w):
if L[i][j] == 1 or L[i][j] == -1:
continue
else:
ans += d[L[i][j]][1]
print((int(ans)))
if __name__ == '__main__':
main()
|
def main():
h,w = list(map(int,input().split()))
d = []
for i in range(10):
a = list(map(int,input().split()))
d.append(a)
def WF(d):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j],d[i][k] + d[k][j])
return d
WF(d)
L = []
for i in range(h):
b = list(map(int,input().split()))
L.append(b)
ans = 0
for i in range(h):
for j in range(w):
if L[i][j] == 1 or L[i][j] == -1:
continue
else:
ans += d[L[i][j]][1]
print((int(ans)))
if __name__ == '__main__':
main()
| 30 | 29 | 749 | 713 |
def main():
import numpy as np
h, w = list(map(int, input().split()))
d = np.zeros((10, 10))
for i in range(10):
a = list(map(int, input().split()))
d[i] = a
def WF(b):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
WF(d)
L = []
for i in range(h):
b = list(map(int, input().split()))
L.append(b)
ans = 0
for i in range(h):
for j in range(w):
if L[i][j] == 1 or L[i][j] == -1:
continue
else:
ans += d[L[i][j]][1]
print((int(ans)))
if __name__ == "__main__":
main()
|
def main():
h, w = list(map(int, input().split()))
d = []
for i in range(10):
a = list(map(int, input().split()))
d.append(a)
def WF(d):
for k in range(10):
for i in range(10):
for j in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
WF(d)
L = []
for i in range(h):
b = list(map(int, input().split()))
L.append(b)
ans = 0
for i in range(h):
for j in range(w):
if L[i][j] == 1 or L[i][j] == -1:
continue
else:
ans += d[L[i][j]][1]
print((int(ans)))
if __name__ == "__main__":
main()
| false | 3.333333 |
[
"- import numpy as np",
"-",
"- d = np.zeros((10, 10))",
"+ d = []",
"- d[i] = a",
"+ d.append(a)",
"- def WF(b):",
"+ def WF(d):"
] | false | 0.234171 | 0.060438 | 3.87455 |
[
"s168699274",
"s718121210"
] |
u969850098
|
p03854
|
python
|
s558909696
|
s265318688
| 76 | 20 | 3,188 | 3,188 |
Accepted
|
Accepted
| 73.68 |
import sys
S = eval(input())
while S:
if (S[-5:] == 'dream') or (S[-5:] == 'erase'):
S = S[:-5]
elif S[-6:] == 'eraser':
S = S[:-6]
elif S[-7:] == 'dreamer':
S = S[:-7]
else:
print('NO')
sys.exit()
print('YES')
|
S = eval(input())
S = S.replace('eraser', '')
S = S.replace('erase', '')
S = S.replace('dreamer', '')
S = S.replace('dream', '')
if len(S) == 0:
print('YES')
else:
print('NO')
| 13 | 11 | 272 | 189 |
import sys
S = eval(input())
while S:
if (S[-5:] == "dream") or (S[-5:] == "erase"):
S = S[:-5]
elif S[-6:] == "eraser":
S = S[:-6]
elif S[-7:] == "dreamer":
S = S[:-7]
else:
print("NO")
sys.exit()
print("YES")
|
S = eval(input())
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")
if len(S) == 0:
print("YES")
else:
print("NO")
| false | 15.384615 |
[
"-import sys",
"-",
"-while S:",
"- if (S[-5:] == \"dream\") or (S[-5:] == \"erase\"):",
"- S = S[:-5]",
"- elif S[-6:] == \"eraser\":",
"- S = S[:-6]",
"- elif S[-7:] == \"dreamer\":",
"- S = S[:-7]",
"- else:",
"- print(\"NO\")",
"- sys.exit()",
"-print(\"YES\")",
"+S = S.replace(\"eraser\", \"\")",
"+S = S.replace(\"erase\", \"\")",
"+S = S.replace(\"dreamer\", \"\")",
"+S = S.replace(\"dream\", \"\")",
"+if len(S) == 0:",
"+ print(\"YES\")",
"+else:",
"+ print(\"NO\")"
] | false | 0.043474 | 0.046034 | 0.944395 |
[
"s558909696",
"s265318688"
] |
u869519920
|
p03804
|
python
|
s813466605
|
s420099021
| 35 | 29 | 9,020 | 9,076 |
Accepted
|
Accepted
| 17.14 |
n,m = list(map(int,input().split()))
A = [eval(input()) for i in range(n)]
B = [eval(input()) for i in range(m)]
flag = False
for i in range(n-m+1):
for j in range(n-m+1):
flag = True
for k in range(m):
if B[k] != A[i+k][j:j+m]:
flag = False
if flag:
print("Yes")
exit()
print("No")
|
N,M=list(map(int, input().split()))
A = [eval(input()) for i in range(N)]
B = [eval(input()) for i in range(M)]
for i in range(N-M+1):
for j in range(N-M+1):
t = True
for k in range(M):
if B[k] != A[i+k][j:j+M]:
t = False
if t:
print("Yes")
exit()
print("No")
| 15 | 14 | 360 | 296 |
n, m = list(map(int, input().split()))
A = [eval(input()) for i in range(n)]
B = [eval(input()) for i in range(m)]
flag = False
for i in range(n - m + 1):
for j in range(n - m + 1):
flag = True
for k in range(m):
if B[k] != A[i + k][j : j + m]:
flag = False
if flag:
print("Yes")
exit()
print("No")
|
N, M = list(map(int, input().split()))
A = [eval(input()) for i in range(N)]
B = [eval(input()) for i in range(M)]
for i in range(N - M + 1):
for j in range(N - M + 1):
t = True
for k in range(M):
if B[k] != A[i + k][j : j + M]:
t = False
if t:
print("Yes")
exit()
print("No")
| false | 6.666667 |
[
"-n, m = list(map(int, input().split()))",
"-A = [eval(input()) for i in range(n)]",
"-B = [eval(input()) for i in range(m)]",
"-flag = False",
"-for i in range(n - m + 1):",
"- for j in range(n - m + 1):",
"- flag = True",
"- for k in range(m):",
"- if B[k] != A[i + k][j : j + m]:",
"- flag = False",
"- if flag:",
"+N, M = list(map(int, input().split()))",
"+A = [eval(input()) for i in range(N)]",
"+B = [eval(input()) for i in range(M)]",
"+for i in range(N - M + 1):",
"+ for j in range(N - M + 1):",
"+ t = True",
"+ for k in range(M):",
"+ if B[k] != A[i + k][j : j + M]:",
"+ t = False",
"+ if t:"
] | false | 0.095793 | 0.036869 | 2.59822 |
[
"s813466605",
"s420099021"
] |
u647766105
|
p00141
|
python
|
s497500632
|
s191719695
| 40 | 20 | 4,308 | 4,300 |
Accepted
|
Accepted
| 50 |
D = [[-1,0],[0,1],[1,0],[0,-1]]
def s(N):
used = [[False]*N+[True] for _ in range(N)]+[[True]*(N+1)]
ret = [[" "]*N for _ in range(N)]
q = [(0,N-1,0)]
used[N-1][0] = used[N-1][1] = True
while len(q) != 0:
d,y,x = q.pop(0)
ret[y][x] = "#"
sy,sx = D[d]
ry,rx = D[(d+1)%4]
if not used[y+sy][x+sx]:
q.append((d,y+sy,x+sx))
used[y+sy][x+sx] = used[y+ry][x+rx] = True
elif not used[y+ry][x+rx]:
q.append(((d+1)%4,y+ry,x+rx))
used[y+ry][x+rx] = True
return ret
n = eval(input())
while True:
n -= 1
N = eval(input())
print("\n".join(["".join(a) for a in s(N)]))
if n == 0:
break
print()
|
D = [[-1,0],[0,1],[1,0],[0,-1]]
def s(N):
used = [[False]*N+[True] for _ in range(N)]+[[True]*(N+1)]
ret = [[" "]*N for _ in range(N)]
d,y,x = 0,N-1,0
used[N-1][0] = used[N-1][1] = True
while True:
ret[y][x] = "#"
sy,sx = D[d]
ry,rx = D[(d+1)%4]
if not used[y+sy][x+sx]:
used[y+sy][x+sx] = used[y+ry][x+rx] = True
d,y,x = d,y+sy,x+sx
elif not used[y+ry][x+rx]:
used[y+ry][x+rx] = True
d,y,x = (d+1)%4,y+ry,x+rx
else:
break
return ret
n = eval(input())
while True:
n -= 1
N = eval(input())
print("\n".join(["".join(a) for a in s(N)]))
if n == 0:
break
print()
| 27 | 28 | 747 | 740 |
D = [[-1, 0], [0, 1], [1, 0], [0, -1]]
def s(N):
used = [[False] * N + [True] for _ in range(N)] + [[True] * (N + 1)]
ret = [[" "] * N for _ in range(N)]
q = [(0, N - 1, 0)]
used[N - 1][0] = used[N - 1][1] = True
while len(q) != 0:
d, y, x = q.pop(0)
ret[y][x] = "#"
sy, sx = D[d]
ry, rx = D[(d + 1) % 4]
if not used[y + sy][x + sx]:
q.append((d, y + sy, x + sx))
used[y + sy][x + sx] = used[y + ry][x + rx] = True
elif not used[y + ry][x + rx]:
q.append(((d + 1) % 4, y + ry, x + rx))
used[y + ry][x + rx] = True
return ret
n = eval(input())
while True:
n -= 1
N = eval(input())
print("\n".join(["".join(a) for a in s(N)]))
if n == 0:
break
print()
|
D = [[-1, 0], [0, 1], [1, 0], [0, -1]]
def s(N):
used = [[False] * N + [True] for _ in range(N)] + [[True] * (N + 1)]
ret = [[" "] * N for _ in range(N)]
d, y, x = 0, N - 1, 0
used[N - 1][0] = used[N - 1][1] = True
while True:
ret[y][x] = "#"
sy, sx = D[d]
ry, rx = D[(d + 1) % 4]
if not used[y + sy][x + sx]:
used[y + sy][x + sx] = used[y + ry][x + rx] = True
d, y, x = d, y + sy, x + sx
elif not used[y + ry][x + rx]:
used[y + ry][x + rx] = True
d, y, x = (d + 1) % 4, y + ry, x + rx
else:
break
return ret
n = eval(input())
while True:
n -= 1
N = eval(input())
print("\n".join(["".join(a) for a in s(N)]))
if n == 0:
break
print()
| false | 3.571429 |
[
"- q = [(0, N - 1, 0)]",
"+ d, y, x = 0, N - 1, 0",
"- while len(q) != 0:",
"- d, y, x = q.pop(0)",
"+ while True:",
"- q.append((d, y + sy, x + sx))",
"+ d, y, x = d, y + sy, x + sx",
"- q.append(((d + 1) % 4, y + ry, x + rx))",
"+ d, y, x = (d + 1) % 4, y + ry, x + rx",
"+ else:",
"+ break"
] | false | 0.036987 | 0.046094 | 0.80242 |
[
"s497500632",
"s191719695"
] |
u056277698
|
p03078
|
python
|
s861461964
|
s581139547
| 725 | 104 | 147,876 | 8,708 |
Accepted
|
Accepted
| 85.66 |
# -*- coding: utf-8 -*-
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
bc = [i + j for i in b for j in c]
bc.sort(reverse=True)
abc = [i + j for i in a for j in bc[:min(k, len(bc))]]
abc.sort(reverse=True)
for i in range(k):
print((abc[i]))
|
# -*- coding: utf-8 -*-
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
abc = []
for i, _a in enumerate(a):
for j, _b in enumerate(b):
if (i+1) * (j+1) > k:
break
for l, _c in enumerate(c):
if (i+1) * (j+1) * (l+1) > k:
break
abc.append(_a + _b + _c)
abc.sort(reverse=True)
for x in abc[:k]:
print(x)
| 14 | 24 | 359 | 566 |
# -*- coding: utf-8 -*-
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
bc = [i + j for i in b for j in c]
bc.sort(reverse=True)
abc = [i + j for i in a for j in bc[: min(k, len(bc))]]
abc.sort(reverse=True)
for i in range(k):
print((abc[i]))
|
# -*- coding: utf-8 -*-
x, y, z, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
abc = []
for i, _a in enumerate(a):
for j, _b in enumerate(b):
if (i + 1) * (j + 1) > k:
break
for l, _c in enumerate(c):
if (i + 1) * (j + 1) * (l + 1) > k:
break
abc.append(_a + _b + _c)
abc.sort(reverse=True)
for x in abc[:k]:
print(x)
| false | 41.666667 |
[
"-bc = [i + j for i in b for j in c]",
"-bc.sort(reverse=True)",
"-abc = [i + j for i in a for j in bc[: min(k, len(bc))]]",
"+a.sort(reverse=True)",
"+b.sort(reverse=True)",
"+c.sort(reverse=True)",
"+abc = []",
"+for i, _a in enumerate(a):",
"+ for j, _b in enumerate(b):",
"+ if (i + 1) * (j + 1) > k:",
"+ break",
"+ for l, _c in enumerate(c):",
"+ if (i + 1) * (j + 1) * (l + 1) > k:",
"+ break",
"+ abc.append(_a + _b + _c)",
"-for i in range(k):",
"- print((abc[i]))",
"+for x in abc[:k]:",
"+ print(x)"
] | false | 0.056216 | 0.03736 | 1.504699 |
[
"s861461964",
"s581139547"
] |
u218058474
|
p02847
|
python
|
s984141804
|
s242076668
| 19 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 10.53 |
mapping = {
'SUN': 7,
'MON': 6,
'TUE': 5,
'WED': 4,
'THU': 3,
'FRI': 2,
'SAT': 1,
}
print((mapping[eval(input())]))
|
mapping = {
'SUN': 7,
'MON': 6,
'TUE': 5,
'WED': 4,
'THU': 3,
'FRI': 2,
'SAT': 1,
}
day = eval(input())
print((mapping[day]))
| 11 | 12 | 133 | 143 |
mapping = {
"SUN": 7,
"MON": 6,
"TUE": 5,
"WED": 4,
"THU": 3,
"FRI": 2,
"SAT": 1,
}
print((mapping[eval(input())]))
|
mapping = {
"SUN": 7,
"MON": 6,
"TUE": 5,
"WED": 4,
"THU": 3,
"FRI": 2,
"SAT": 1,
}
day = eval(input())
print((mapping[day]))
| false | 8.333333 |
[
"-print((mapping[eval(input())]))",
"+day = eval(input())",
"+print((mapping[day]))"
] | false | 0.043826 | 0.046623 | 0.940008 |
[
"s984141804",
"s242076668"
] |
u562935282
|
p03472
|
python
|
s250384485
|
s923111504
| 355 | 183 | 12,084 | 7,840 |
Accepted
|
Accepted
| 48.45 |
from math import ceil
N, H = list(map(int, input().split()))
a, b = [], []
for _ in range(N):
ta, tb = list(map(int, input().split()))
a.append(ta)
b.append(tb)
Ma = max(a)
b = sorted([x for x in b if x > Ma], reverse=True)
lb = len(b)
t = 0
while t < lb:
H -= b[t]
t += 1
if H <= 0:
break
if H > 0:
t += ceil(H / Ma)
print(t)
|
def main():
import sys
input = sys.stdin.readline
N, H = list(map(int, input().split()))
bs = []
a_mx = -1
for _ in range(N):
a, b = list(map(int, input().split()))
a_mx = max(a_mx, a)
bs.append(b)
bs = [b for b in bs if b > a_mx]
bs.sort(reverse=True)
ans = 0
for b in bs:
H -= b
ans += 1
if H <= 0:
break
if H > 0:
ans += (H + a_mx - 1) // a_mx
print(ans)
if __name__ == '__main__':
main()
| 24 | 30 | 382 | 536 |
from math import ceil
N, H = list(map(int, input().split()))
a, b = [], []
for _ in range(N):
ta, tb = list(map(int, input().split()))
a.append(ta)
b.append(tb)
Ma = max(a)
b = sorted([x for x in b if x > Ma], reverse=True)
lb = len(b)
t = 0
while t < lb:
H -= b[t]
t += 1
if H <= 0:
break
if H > 0:
t += ceil(H / Ma)
print(t)
|
def main():
import sys
input = sys.stdin.readline
N, H = list(map(int, input().split()))
bs = []
a_mx = -1
for _ in range(N):
a, b = list(map(int, input().split()))
a_mx = max(a_mx, a)
bs.append(b)
bs = [b for b in bs if b > a_mx]
bs.sort(reverse=True)
ans = 0
for b in bs:
H -= b
ans += 1
if H <= 0:
break
if H > 0:
ans += (H + a_mx - 1) // a_mx
print(ans)
if __name__ == "__main__":
main()
| false | 20 |
[
"-from math import ceil",
"+def main():",
"+ import sys",
"-N, H = list(map(int, input().split()))",
"-a, b = [], []",
"-for _ in range(N):",
"- ta, tb = list(map(int, input().split()))",
"- a.append(ta)",
"- b.append(tb)",
"-Ma = max(a)",
"-b = sorted([x for x in b if x > Ma], reverse=True)",
"-lb = len(b)",
"-t = 0",
"-while t < lb:",
"- H -= b[t]",
"- t += 1",
"- if H <= 0:",
"- break",
"-if H > 0:",
"- t += ceil(H / Ma)",
"-print(t)",
"+ input = sys.stdin.readline",
"+ N, H = list(map(int, input().split()))",
"+ bs = []",
"+ a_mx = -1",
"+ for _ in range(N):",
"+ a, b = list(map(int, input().split()))",
"+ a_mx = max(a_mx, a)",
"+ bs.append(b)",
"+ bs = [b for b in bs if b > a_mx]",
"+ bs.sort(reverse=True)",
"+ ans = 0",
"+ for b in bs:",
"+ H -= b",
"+ ans += 1",
"+ if H <= 0:",
"+ break",
"+ if H > 0:",
"+ ans += (H + a_mx - 1) // a_mx",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.039954 | 0.038951 | 1.025738 |
[
"s250384485",
"s923111504"
] |
u497046426
|
p03163
|
python
|
s071616405
|
s966548837
| 1,303 | 643 | 170,820 | 171,656 |
Accepted
|
Accepted
| 50.65 |
import numpy as np
N, W = list(map(int, input().split()))
items = []
for _ in range(N):
items.append(tuple(map(int, input().split())))
dp = np.array([[0 for j in range(W+1)] for _ in range(N+1)])
for i in range(1, N+1):
w, v = items[i-1]
dp[i, :w] = dp[i-1, :w]
dp[i, w:] = np.maximum(dp[i-1, :-w] + v, dp[i-1, w:])
print((dp[N, W]))
|
N, W = list(map(int, input().split()))
items = []
for _ in range(N):
items.append(tuple(map(int, input().split())))
dp = [[0 for j in range(W+1)] for i in range(N+1)]
for i in range(1, N+1):
w, v = items[i-1]
for j in range(W+1):
if j - w >= 0:
dp[i][j] = max(dp[i-1][j-w] + v, dp[i-1][j])
else:
dp[i][j] = dp[i-1][j]
print((max(dp[N])))
| 12 | 13 | 353 | 394 |
import numpy as np
N, W = list(map(int, input().split()))
items = []
for _ in range(N):
items.append(tuple(map(int, input().split())))
dp = np.array([[0 for j in range(W + 1)] for _ in range(N + 1)])
for i in range(1, N + 1):
w, v = items[i - 1]
dp[i, :w] = dp[i - 1, :w]
dp[i, w:] = np.maximum(dp[i - 1, :-w] + v, dp[i - 1, w:])
print((dp[N, W]))
|
N, W = list(map(int, input().split()))
items = []
for _ in range(N):
items.append(tuple(map(int, input().split())))
dp = [[0 for j in range(W + 1)] for i in range(N + 1)]
for i in range(1, N + 1):
w, v = items[i - 1]
for j in range(W + 1):
if j - w >= 0:
dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j])
else:
dp[i][j] = dp[i - 1][j]
print((max(dp[N])))
| false | 7.692308 |
[
"-import numpy as np",
"-",
"-dp = np.array([[0 for j in range(W + 1)] for _ in range(N + 1)])",
"+dp = [[0 for j in range(W + 1)] for i in range(N + 1)]",
"- dp[i, :w] = dp[i - 1, :w]",
"- dp[i, w:] = np.maximum(dp[i - 1, :-w] + v, dp[i - 1, w:])",
"-print((dp[N, W]))",
"+ for j in range(W + 1):",
"+ if j - w >= 0:",
"+ dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j])",
"+ else:",
"+ dp[i][j] = dp[i - 1][j]",
"+print((max(dp[N])))"
] | false | 0.234099 | 0.039487 | 5.928496 |
[
"s071616405",
"s966548837"
] |
u983327168
|
p03434
|
python
|
s874230416
|
s767802865
| 19 | 17 | 2,940 | 2,940 |
Accepted
|
Accepted
| 10.53 |
alice=0
bob=0
n=int(eval(input()))
a=list(map(int,input().split()))
def delete():
del a[a.index(Max)]
while n>=1:
Max=max(a)
alice=alice+Max
n=n-1
delete()
if n>=1:
Max=max(a)
bob=bob+Max
n=n-1
delete()
else:
print((alice-bob))
|
n = eval(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print((sum(a[::2]) - sum(a[1::2])))
| 19 | 4 | 299 | 105 |
alice = 0
bob = 0
n = int(eval(input()))
a = list(map(int, input().split()))
def delete():
del a[a.index(Max)]
while n >= 1:
Max = max(a)
alice = alice + Max
n = n - 1
delete()
if n >= 1:
Max = max(a)
bob = bob + Max
n = n - 1
delete()
else:
print((alice - bob))
|
n = eval(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print((sum(a[::2]) - sum(a[1::2])))
| false | 78.947368 |
[
"-alice = 0",
"-bob = 0",
"-n = int(eval(input()))",
"+n = eval(input())",
"-",
"-",
"-def delete():",
"- del a[a.index(Max)]",
"-",
"-",
"-while n >= 1:",
"- Max = max(a)",
"- alice = alice + Max",
"- n = n - 1",
"- delete()",
"- if n >= 1:",
"- Max = max(a)",
"- bob = bob + Max",
"- n = n - 1",
"- delete()",
"-else:",
"- print((alice - bob))",
"+a.sort(reverse=True)",
"+print((sum(a[::2]) - sum(a[1::2])))"
] | false | 0.067041 | 0.067461 | 0.993777 |
[
"s874230416",
"s767802865"
] |
u723590269
|
p03944
|
python
|
s729409007
|
s718172650
| 42 | 17 | 3,064 | 3,064 |
Accepted
|
Accepted
| 59.52 |
w,h,n = list(map(int,input().split()))
#座標用配列
s = [[1 for i in range(w)] for j in range(h)]
#標準入力
for i in range(n):
x,y,a = list(map(int,input().split()))
if a == 1:
for j in range(h):
s[j][0:x] = [0 for k in range(x)]
elif a ==2:
for j in range(h):
s[j][x:w] = [0 for k in range(x,w)]
elif a ==3:
for j in range(y):
s[j] = [0 for k in range(w)]
elif a==4:
for j in range(y,h):
s[j] =[0 for k in range(w)]
cnt = 0
for i in s:
cnt += sum(i)
print(cnt)
|
w,h,n = list(map(int,input().split()))
x_min = 0
x_max = w
y_min = 0
y_max = h
for i in range(n):
x,y,a = list(map(int,input().split()))
if a == 1:
if x > x_min:
x_min = x
elif a == 2:
if x < x_max:
x_max = x
elif a == 3:
if y > y_min:
y_min = y
else:
if y < y_max:
y_max = y
if x_min > x_max or y_min > y_max:
print((0))
else:
print(((x_max-x_min)*(y_max-y_min)))
| 27 | 26 | 609 | 484 |
w, h, n = list(map(int, input().split()))
# 座標用配列
s = [[1 for i in range(w)] for j in range(h)]
# 標準入力
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
for j in range(h):
s[j][0:x] = [0 for k in range(x)]
elif a == 2:
for j in range(h):
s[j][x:w] = [0 for k in range(x, w)]
elif a == 3:
for j in range(y):
s[j] = [0 for k in range(w)]
elif a == 4:
for j in range(y, h):
s[j] = [0 for k in range(w)]
cnt = 0
for i in s:
cnt += sum(i)
print(cnt)
|
w, h, n = list(map(int, input().split()))
x_min = 0
x_max = w
y_min = 0
y_max = h
for i in range(n):
x, y, a = list(map(int, input().split()))
if a == 1:
if x > x_min:
x_min = x
elif a == 2:
if x < x_max:
x_max = x
elif a == 3:
if y > y_min:
y_min = y
else:
if y < y_max:
y_max = y
if x_min > x_max or y_min > y_max:
print((0))
else:
print(((x_max - x_min) * (y_max - y_min)))
| false | 3.703704 |
[
"-# 座標用配列",
"-s = [[1 for i in range(w)] for j in range(h)]",
"-# 標準入力",
"+x_min = 0",
"+x_max = w",
"+y_min = 0",
"+y_max = h",
"- for j in range(h):",
"- s[j][0:x] = [0 for k in range(x)]",
"+ if x > x_min:",
"+ x_min = x",
"- for j in range(h):",
"- s[j][x:w] = [0 for k in range(x, w)]",
"+ if x < x_max:",
"+ x_max = x",
"- for j in range(y):",
"- s[j] = [0 for k in range(w)]",
"- elif a == 4:",
"- for j in range(y, h):",
"- s[j] = [0 for k in range(w)]",
"-cnt = 0",
"-for i in s:",
"- cnt += sum(i)",
"-print(cnt)",
"+ if y > y_min:",
"+ y_min = y",
"+ else:",
"+ if y < y_max:",
"+ y_max = y",
"+if x_min > x_max or y_min > y_max:",
"+ print((0))",
"+else:",
"+ print(((x_max - x_min) * (y_max - y_min)))"
] | false | 0.037965 | 0.038258 | 0.992333 |
[
"s729409007",
"s718172650"
] |
u761989513
|
p03632
|
python
|
s980973616
|
s415223347
| 19 | 17 | 3,316 | 3,064 |
Accepted
|
Accepted
| 10.53 |
a, b, c, d = list(map(int, input().split()))
t = min(b, d) - max(a, c)
if t < 0:
print((0))
else:
print(t)
|
a, b, c, d = list(map(int, input().split()))
time = [0] * 101
for i in range(a, b + 1):
time[i] += 1
for i in range(c, d + 1):
time[i] += 1
ans = 0
for i in time:
if i == 2:
ans += 1
print((max(0, ans - 1)))
| 6 | 16 | 107 | 239 |
a, b, c, d = list(map(int, input().split()))
t = min(b, d) - max(a, c)
if t < 0:
print((0))
else:
print(t)
|
a, b, c, d = list(map(int, input().split()))
time = [0] * 101
for i in range(a, b + 1):
time[i] += 1
for i in range(c, d + 1):
time[i] += 1
ans = 0
for i in time:
if i == 2:
ans += 1
print((max(0, ans - 1)))
| false | 62.5 |
[
"-t = min(b, d) - max(a, c)",
"-if t < 0:",
"- print((0))",
"-else:",
"- print(t)",
"+time = [0] * 101",
"+for i in range(a, b + 1):",
"+ time[i] += 1",
"+for i in range(c, d + 1):",
"+ time[i] += 1",
"+ans = 0",
"+for i in time:",
"+ if i == 2:",
"+ ans += 1",
"+print((max(0, ans - 1)))"
] | false | 0.052094 | 0.051991 | 1.001986 |
[
"s980973616",
"s415223347"
] |
u445624660
|
p02983
|
python
|
s153844380
|
s578365203
| 933 | 652 | 3,060 | 9,120 |
Accepted
|
Accepted
| 30.12 |
# +2019までを調べれば十分
l, r = list(map(int, input().split()))
ans = 10**9
for i in range(l, min(r+1, l+2020)):
for j in range(i, min(r+1, l+2020)):
if i < j:
ans = min(ans, (i * j)%2019)
print(ans)
|
l, r = list(map(int, input().split()))
if r - l >= 2019:
print((0))
exit()
ans = 2019
for i in range(l, r + 1):
for j in range(i + 1, r + 1):
ans = min(ans, (i * j) % 2019)
print(ans)
| 11 | 10 | 211 | 205 |
# +2019までを調べれば十分
l, r = list(map(int, input().split()))
ans = 10**9
for i in range(l, min(r + 1, l + 2020)):
for j in range(i, min(r + 1, l + 2020)):
if i < j:
ans = min(ans, (i * j) % 2019)
print(ans)
|
l, r = list(map(int, input().split()))
if r - l >= 2019:
print((0))
exit()
ans = 2019
for i in range(l, r + 1):
for j in range(i + 1, r + 1):
ans = min(ans, (i * j) % 2019)
print(ans)
| false | 9.090909 |
[
"-# +2019までを調べれば十分",
"-ans = 10**9",
"-for i in range(l, min(r + 1, l + 2020)):",
"- for j in range(i, min(r + 1, l + 2020)):",
"- if i < j:",
"- ans = min(ans, (i * j) % 2019)",
"+if r - l >= 2019:",
"+ print((0))",
"+ exit()",
"+ans = 2019",
"+for i in range(l, r + 1):",
"+ for j in range(i + 1, r + 1):",
"+ ans = min(ans, (i * j) % 2019)"
] | false | 0.106461 | 0.044312 | 2.402517 |
[
"s153844380",
"s578365203"
] |
u934442292
|
p02695
|
python
|
s031074623
|
s281083516
| 544 | 393 | 9,008 | 9,112 |
Accepted
|
Accepted
| 27.76 |
import sys
from itertools import combinations_with_replacement
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
def main():
N, M, Q = list(map(int, input().split()))
abcd = [None] * Q
for i in range(Q):
abcd[i] = tuple(map(int, input().split()))
ans = 0
for A in combinations_with_replacement(list(range(1, M+1)), N):
score = 0
for q in abcd:
a, b, c, d = q
if A[b-1] - A[a-1] == c:
score += d
if score > ans:
ans = score
print(ans)
if __name__ == "__main__":
main()
|
import sys
from itertools import combinations_with_replacement
input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
abcd = [None] * Q
for i in range(Q):
abcd[i] = list(map(int, input().split()))
abcd[i][0] -= 1
abcd[i][1] -= 1
ans = 0
for A in combinations_with_replacement(list(range(1, M + 1)), N):
score = 0
for a, b, c, d in abcd:
if A[b] - A[a] == c:
score += d
if score > ans:
ans = score
print(ans)
if __name__ == "__main__":
main()
| 28 | 28 | 610 | 606 |
import sys
from itertools import combinations_with_replacement
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
def main():
N, M, Q = list(map(int, input().split()))
abcd = [None] * Q
for i in range(Q):
abcd[i] = tuple(map(int, input().split()))
ans = 0
for A in combinations_with_replacement(list(range(1, M + 1)), N):
score = 0
for q in abcd:
a, b, c, d = q
if A[b - 1] - A[a - 1] == c:
score += d
if score > ans:
ans = score
print(ans)
if __name__ == "__main__":
main()
|
import sys
from itertools import combinations_with_replacement
input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
abcd = [None] * Q
for i in range(Q):
abcd[i] = list(map(int, input().split()))
abcd[i][0] -= 1
abcd[i][1] -= 1
ans = 0
for A in combinations_with_replacement(list(range(1, M + 1)), N):
score = 0
for a, b, c, d in abcd:
if A[b] - A[a] == c:
score += d
if score > ans:
ans = score
print(ans)
if __name__ == "__main__":
main()
| false | 0 |
[
"-sys.setrecursionlimit(10**7)",
"- abcd[i] = tuple(map(int, input().split()))",
"+ abcd[i] = list(map(int, input().split()))",
"+ abcd[i][0] -= 1",
"+ abcd[i][1] -= 1",
"- for q in abcd:",
"- a, b, c, d = q",
"- if A[b - 1] - A[a - 1] == c:",
"+ for a, b, c, d in abcd:",
"+ if A[b] - A[a] == c:"
] | false | 0.053798 | 0.079626 | 0.675638 |
[
"s031074623",
"s281083516"
] |
u264304509
|
p02760
|
python
|
s296206716
|
s930734938
| 31 | 27 | 9,212 | 9,132 |
Accepted
|
Accepted
| 12.9 |
A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for _ in range(N)]
field = 0
for v in b:
for i in range(9):
if A[i // 3][i % 3] == v:
field = field | (1 << i)
ans = False
for v in sum([[273,84],sum([[73<<i,7<<i*3]for i in range(3)],[])],[]):
ans = ans or field&v==v;
print(('Yes' if ans else 'No'))
|
A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for _ in range(N)]
f=0
for v in b:
for i in range(9):
if A[i // 3][i % 3] == v:
f|=1<<i
ans = 0
for v in [7,56,73,84,146,273,292,448]:
ans |= f&v==v;
print(('Yes' if ans else 'No'))
| 13 | 13 | 361 | 292 |
A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for _ in range(N)]
field = 0
for v in b:
for i in range(9):
if A[i // 3][i % 3] == v:
field = field | (1 << i)
ans = False
for v in sum([[273, 84], sum([[73 << i, 7 << i * 3] for i in range(3)], [])], []):
ans = ans or field & v == v
print(("Yes" if ans else "No"))
|
A = [list(map(int, input().split())) for _ in range(3)]
N = int(eval(input()))
b = [int(eval(input())) for _ in range(N)]
f = 0
for v in b:
for i in range(9):
if A[i // 3][i % 3] == v:
f |= 1 << i
ans = 0
for v in [7, 56, 73, 84, 146, 273, 292, 448]:
ans |= f & v == v
print(("Yes" if ans else "No"))
| false | 0 |
[
"-field = 0",
"+f = 0",
"- field = field | (1 << i)",
"-ans = False",
"-for v in sum([[273, 84], sum([[73 << i, 7 << i * 3] for i in range(3)], [])], []):",
"- ans = ans or field & v == v",
"+ f |= 1 << i",
"+ans = 0",
"+for v in [7, 56, 73, 84, 146, 273, 292, 448]:",
"+ ans |= f & v == v"
] | false | 0.10424 | 0.044229 | 2.356853 |
[
"s296206716",
"s930734938"
] |
u707498674
|
p03062
|
python
|
s569987556
|
s853206652
| 323 | 263 | 24,816 | 25,644 |
Accepted
|
Accepted
| 18.58 |
N = int(eval(input()))
A = list(map(int, input().split()))
dp = [[0] * 2 for i in range(N)]
dp[0][0] = A[0] + A[1]
dp[0][1] = -A[0] - A[1]
for i in range(1, N - 1):
for j in range(2):
if j == 0:
dp[i][j] = max(dp[i-1][0] + A[i+1], dp[i-1][1] + A[i+1])
else:
dp[i][j] = max(dp[i-1][0] - 2 * A[i] - A[i+1], dp[i-1][1] + 2 * A[i] - A[i+1])
print((max(dp[N-2])))
|
N = int(eval(input()))
A = list(map(int, input().split()))
dp = [[0] * 2 for i in range(N+1)]
dp[0][1] = - 10 ** 18
for i in range(N):
for j in range(2):
if j == 0:
dp[i+1][j] = max(dp[i][0] + A[i], dp[i][1] - A[i])
else:
dp[i+1][j] = max(dp[i][0] - A[i], dp[i][1] + A[i])
print((dp[N][0]))
| 15 | 15 | 411 | 344 |
N = int(eval(input()))
A = list(map(int, input().split()))
dp = [[0] * 2 for i in range(N)]
dp[0][0] = A[0] + A[1]
dp[0][1] = -A[0] - A[1]
for i in range(1, N - 1):
for j in range(2):
if j == 0:
dp[i][j] = max(dp[i - 1][0] + A[i + 1], dp[i - 1][1] + A[i + 1])
else:
dp[i][j] = max(
dp[i - 1][0] - 2 * A[i] - A[i + 1], dp[i - 1][1] + 2 * A[i] - A[i + 1]
)
print((max(dp[N - 2])))
|
N = int(eval(input()))
A = list(map(int, input().split()))
dp = [[0] * 2 for i in range(N + 1)]
dp[0][1] = -(10**18)
for i in range(N):
for j in range(2):
if j == 0:
dp[i + 1][j] = max(dp[i][0] + A[i], dp[i][1] - A[i])
else:
dp[i + 1][j] = max(dp[i][0] - A[i], dp[i][1] + A[i])
print((dp[N][0]))
| false | 0 |
[
"-dp = [[0] * 2 for i in range(N)]",
"-dp[0][0] = A[0] + A[1]",
"-dp[0][1] = -A[0] - A[1]",
"-for i in range(1, N - 1):",
"+dp = [[0] * 2 for i in range(N + 1)]",
"+dp[0][1] = -(10**18)",
"+for i in range(N):",
"- dp[i][j] = max(dp[i - 1][0] + A[i + 1], dp[i - 1][1] + A[i + 1])",
"+ dp[i + 1][j] = max(dp[i][0] + A[i], dp[i][1] - A[i])",
"- dp[i][j] = max(",
"- dp[i - 1][0] - 2 * A[i] - A[i + 1], dp[i - 1][1] + 2 * A[i] - A[i + 1]",
"- )",
"-print((max(dp[N - 2])))",
"+ dp[i + 1][j] = max(dp[i][0] - A[i], dp[i][1] + A[i])",
"+print((dp[N][0]))"
] | false | 0.045924 | 0.046479 | 0.988057 |
[
"s569987556",
"s853206652"
] |
u855694108
|
p00137
|
python
|
s011276529
|
s899759078
| 50 | 30 | 7,664 | 7,624 |
Accepted
|
Accepted
| 40 |
def main():
d = int(input())
a = []
for _ in range(d):
a.append(int(input()))
ans = []
for x in range(d):
ansans = []
hoge = a[x]
for y in range(10):
hoge = list("{0:08d}".format(hoge ** 2))
s = ""
for z in range(2, 6):
s += hoge[z]
hoge = int(s)
ansans.append(hoge)
ans.append(ansans)
for x in range(1, d + 1):
print("Case", x,end= "")
print(":")
for y in ans[x - 1]:
print(y)
if __name__ == "__main__":
main()
|
def main():
d = int(input())
a = []
for _ in range(d):
a.append(int(input()))
for x in range(len(a)):
print("Case ",end = "")
print(x+1, end = "")
print(":")
for _ in range(10):
a[x] = str("{0:08d}".format(a[x] ** 2))
hoge = ""
for y in range(2, 6):
hoge += a[x][y]
hoge = int(hoge)
a[x] = hoge
print(a[x])
if __name__ == "__main__":
main()
| 28 | 22 | 622 | 512 |
def main():
d = int(input())
a = []
for _ in range(d):
a.append(int(input()))
ans = []
for x in range(d):
ansans = []
hoge = a[x]
for y in range(10):
hoge = list("{0:08d}".format(hoge**2))
s = ""
for z in range(2, 6):
s += hoge[z]
hoge = int(s)
ansans.append(hoge)
ans.append(ansans)
for x in range(1, d + 1):
print("Case", x, end="")
print(":")
for y in ans[x - 1]:
print(y)
if __name__ == "__main__":
main()
|
def main():
d = int(input())
a = []
for _ in range(d):
a.append(int(input()))
for x in range(len(a)):
print("Case ", end="")
print(x + 1, end="")
print(":")
for _ in range(10):
a[x] = str("{0:08d}".format(a[x] ** 2))
hoge = ""
for y in range(2, 6):
hoge += a[x][y]
hoge = int(hoge)
a[x] = hoge
print(a[x])
if __name__ == "__main__":
main()
| false | 21.428571 |
[
"- ans = []",
"- for x in range(d):",
"- ansans = []",
"- hoge = a[x]",
"- for y in range(10):",
"- hoge = list(\"{0:08d}\".format(hoge**2))",
"- s = \"\"",
"- for z in range(2, 6):",
"- s += hoge[z]",
"- hoge = int(s)",
"- ansans.append(hoge)",
"- ans.append(ansans)",
"- for x in range(1, d + 1):",
"- print(\"Case\", x, end=\"\")",
"+ for x in range(len(a)):",
"+ print(\"Case \", end=\"\")",
"+ print(x + 1, end=\"\")",
"- for y in ans[x - 1]:",
"- print(y)",
"+ for _ in range(10):",
"+ a[x] = str(\"{0:08d}\".format(a[x] ** 2))",
"+ hoge = \"\"",
"+ for y in range(2, 6):",
"+ hoge += a[x][y]",
"+ hoge = int(hoge)",
"+ a[x] = hoge",
"+ print(a[x])"
] | false | 0.120076 | 0.118889 | 1.009982 |
[
"s011276529",
"s899759078"
] |
u667084803
|
p03848
|
python
|
s129185507
|
s073204613
| 116 | 96 | 16,256 | 13,880 |
Accepted
|
Accepted
| 17.24 |
N=int(eval(input()))
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
n=int(N/2)
ans=2**n
print((ans%(10**9+7)))
else:
print((0))
else:
B+=[0]
C+=[1]
for i in range(0,int(N/2)):
B+=[2*i+2,2*i+2]
C+=[2*i+3,2*i+3]
if A==B or A==C:
n=int((N-1)/2)
ans=2**n
# ans=2**((N-1)/2)
print((ans%(10**9+7)))
else:
print((0))
|
def power_func(a,n,p):
bi=str(format(n,"b"))#2進表現に
res=1
for i in range(len(bi)):
res=(res*res) %p
if bi[i]=="1":
res=(res*a) %p
return res
MOD = 10**9+7
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
if N%2:
correct = [0]
for i in range(N//2):
correct += [(i+1)*2]*2
else:
correct = []
for i in range(N//2):
correct += [i*2+1]*2
if A == correct:
print((power_func(2, N//2, MOD)))
else:
print((0))
| 29 | 27 | 493 | 483 |
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
B = [] # 偶数だけ
C = [] # 奇数だけ
if N % 2 == 0:
for i in range(0, int(N / 2)):
B += [2 * i, 2 * i]
C += [2 * i + 1, 2 * i + 1]
if A == B or A == C:
n = int(N / 2)
ans = 2**n
print((ans % (10**9 + 7)))
else:
print((0))
else:
B += [0]
C += [1]
for i in range(0, int(N / 2)):
B += [2 * i + 2, 2 * i + 2]
C += [2 * i + 3, 2 * i + 3]
if A == B or A == C:
n = int((N - 1) / 2)
ans = 2**n
# ans=2**((N-1)/2)
print((ans % (10**9 + 7)))
else:
print((0))
|
def power_func(a, n, p):
bi = str(format(n, "b")) # 2進表現に
res = 1
for i in range(len(bi)):
res = (res * res) % p
if bi[i] == "1":
res = (res * a) % p
return res
MOD = 10**9 + 7
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
if N % 2:
correct = [0]
for i in range(N // 2):
correct += [(i + 1) * 2] * 2
else:
correct = []
for i in range(N // 2):
correct += [i * 2 + 1] * 2
if A == correct:
print((power_func(2, N // 2, MOD)))
else:
print((0))
| false | 6.896552 |
[
"+def power_func(a, n, p):",
"+ bi = str(format(n, \"b\")) # 2進表現に",
"+ res = 1",
"+ for i in range(len(bi)):",
"+ res = (res * res) % p",
"+ if bi[i] == \"1\":",
"+ res = (res * a) % p",
"+ return res",
"+",
"+",
"+MOD = 10**9 + 7",
"-B = [] # 偶数だけ",
"-C = [] # 奇数だけ",
"-if N % 2 == 0:",
"- for i in range(0, int(N / 2)):",
"- B += [2 * i, 2 * i]",
"- C += [2 * i + 1, 2 * i + 1]",
"- if A == B or A == C:",
"- n = int(N / 2)",
"- ans = 2**n",
"- print((ans % (10**9 + 7)))",
"- else:",
"- print((0))",
"+if N % 2:",
"+ correct = [0]",
"+ for i in range(N // 2):",
"+ correct += [(i + 1) * 2] * 2",
"- B += [0]",
"- C += [1]",
"- for i in range(0, int(N / 2)):",
"- B += [2 * i + 2, 2 * i + 2]",
"- C += [2 * i + 3, 2 * i + 3]",
"- if A == B or A == C:",
"- n = int((N - 1) / 2)",
"- ans = 2**n",
"- # ans=2**((N-1)/2)",
"- print((ans % (10**9 + 7)))",
"- else:",
"- print((0))",
"+ correct = []",
"+ for i in range(N // 2):",
"+ correct += [i * 2 + 1] * 2",
"+if A == correct:",
"+ print((power_func(2, N // 2, MOD)))",
"+else:",
"+ print((0))"
] | false | 0.077646 | 0.083032 | 0.935124 |
[
"s129185507",
"s073204613"
] |
u312237545
|
p02572
|
python
|
s310545482
|
s833447700
| 149 | 133 | 31,488 | 31,696 |
Accepted
|
Accepted
| 10.74 |
N = list(map(int, eval(input())))
An = list(map(int, input().split()))
mnum = 10 ** 9 + 7
CumSum = An[0] % mnum
answer = 0
for i in range(1, len(An)):
answer = (answer + CumSum * An[i]) % mnum
CumSum = (CumSum + An[i]) % mnum
print(answer)
|
N = list(map(int, eval(input())))
An = list(map(int, input().split()))
mnum = 10 ** 9 + 7
CumSum = An[0]
answer = 0
for i in range(1, len(An)):
answer = (answer + CumSum * An[i])
CumSum = (CumSum + An[i])
print((answer%mnum))
| 9 | 9 | 243 | 228 |
N = list(map(int, eval(input())))
An = list(map(int, input().split()))
mnum = 10**9 + 7
CumSum = An[0] % mnum
answer = 0
for i in range(1, len(An)):
answer = (answer + CumSum * An[i]) % mnum
CumSum = (CumSum + An[i]) % mnum
print(answer)
|
N = list(map(int, eval(input())))
An = list(map(int, input().split()))
mnum = 10**9 + 7
CumSum = An[0]
answer = 0
for i in range(1, len(An)):
answer = answer + CumSum * An[i]
CumSum = CumSum + An[i]
print((answer % mnum))
| false | 0 |
[
"-CumSum = An[0] % mnum",
"+CumSum = An[0]",
"- answer = (answer + CumSum * An[i]) % mnum",
"- CumSum = (CumSum + An[i]) % mnum",
"-print(answer)",
"+ answer = answer + CumSum * An[i]",
"+ CumSum = CumSum + An[i]",
"+print((answer % mnum))"
] | false | 0.060705 | 0.063346 | 0.958309 |
[
"s310545482",
"s833447700"
] |
u849029577
|
p02714
|
python
|
s567494364
|
s261141804
| 147 | 132 | 68,056 | 68,100 |
Accepted
|
Accepted
| 10.2 |
n = int(eval(input()))
s = eval(input())
ans = s.count("R")*s.count("G")*s.count("B")
for i in range(n):
for j in range(i+1, n):
k = 2*j-i
if k<n:
if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
ans -= 1
print(ans)
|
n = int(eval(input()))
s = eval(input())
ans = s.count("R")*s.count("G")*s.count("B")
for i in range(n-2):
for j in range(i+1, (n-1+i)//2+1):
k = 2*j-i
if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
ans -= 1
print(ans)
| 10 | 9 | 262 | 250 |
n = int(eval(input()))
s = eval(input())
ans = s.count("R") * s.count("G") * s.count("B")
for i in range(n):
for j in range(i + 1, n):
k = 2 * j - i
if k < n:
if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
ans -= 1
print(ans)
|
n = int(eval(input()))
s = eval(input())
ans = s.count("R") * s.count("G") * s.count("B")
for i in range(n - 2):
for j in range(i + 1, (n - 1 + i) // 2 + 1):
k = 2 * j - i
if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
ans -= 1
print(ans)
| false | 10 |
[
"-for i in range(n):",
"- for j in range(i + 1, n):",
"+for i in range(n - 2):",
"+ for j in range(i + 1, (n - 1 + i) // 2 + 1):",
"- if k < n:",
"- if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:",
"- ans -= 1",
"+ if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:",
"+ ans -= 1"
] | false | 0.037267 | 0.037571 | 0.991923 |
[
"s567494364",
"s261141804"
] |
u983918956
|
p03212
|
python
|
s133191940
|
s533727497
| 139 | 61 | 14,996 | 6,508 |
Accepted
|
Accepted
| 56.12 |
N = eval(input())
def rec(list1,initial,time):
empty = []
for e in list1:
for b in [0,1,2]:
if b == 0:
e_copy = e + "3"
empty.append(e_copy)
elif b == 1:
e_copy = e + "5"
empty.append(e_copy)
elif b == 2:
e_copy = e + "7"
empty.append(e_copy)
list1 = empty[:]
# initial + 1 がn回目のループ
if initial + 1 >= time :
return list1
else:
return rec(list1,initial + 1, time)
l1 = [""]
result = rec(l1,0,3)
for i in range(len(N)-3):
result += rec(result,0,1)
result = [int(e) for e in result if e.count("3")*e.count("5")*e.count("7") >= 1]
result = list(set(result))
result.sort()
count = 0
for e in result:
if int(N) < e:
break
count += 1
print(count)
|
from collections import Counter
N = eval(input())
def rec(list1,initial,time):
empty = []
for e in list1:
for b in [0,1,2]:
if b == 0:
e_copy = e + "3"
empty.append(e_copy)
elif b == 1:
e_copy = e + "5"
empty.append(e_copy)
elif b == 2:
e_copy = e + "7"
empty.append(e_copy)
list1 = empty[:]
# initial + 1 がn回目のループ
if initial + 1 >= time :
return list1
else:
return rec(list1,initial + 1, time)
l1 = [""]
result = [""]
for i in range(1,len(N)+1):
result += rec(l1,0,i)
result = [int(e) for e in result if e.count("3")*e.count("5")*e.count("7") >= 1]
#result = list(set(result))
count = 0
for e in result:
if int(N) < e:
break
count += 1
print(count)
| 33 | 33 | 865 | 875 |
N = eval(input())
def rec(list1, initial, time):
empty = []
for e in list1:
for b in [0, 1, 2]:
if b == 0:
e_copy = e + "3"
empty.append(e_copy)
elif b == 1:
e_copy = e + "5"
empty.append(e_copy)
elif b == 2:
e_copy = e + "7"
empty.append(e_copy)
list1 = empty[:]
# initial + 1 がn回目のループ
if initial + 1 >= time:
return list1
else:
return rec(list1, initial + 1, time)
l1 = [""]
result = rec(l1, 0, 3)
for i in range(len(N) - 3):
result += rec(result, 0, 1)
result = [int(e) for e in result if e.count("3") * e.count("5") * e.count("7") >= 1]
result = list(set(result))
result.sort()
count = 0
for e in result:
if int(N) < e:
break
count += 1
print(count)
|
from collections import Counter
N = eval(input())
def rec(list1, initial, time):
empty = []
for e in list1:
for b in [0, 1, 2]:
if b == 0:
e_copy = e + "3"
empty.append(e_copy)
elif b == 1:
e_copy = e + "5"
empty.append(e_copy)
elif b == 2:
e_copy = e + "7"
empty.append(e_copy)
list1 = empty[:]
# initial + 1 がn回目のループ
if initial + 1 >= time:
return list1
else:
return rec(list1, initial + 1, time)
l1 = [""]
result = [""]
for i in range(1, len(N) + 1):
result += rec(l1, 0, i)
result = [int(e) for e in result if e.count("3") * e.count("5") * e.count("7") >= 1]
# result = list(set(result))
count = 0
for e in result:
if int(N) < e:
break
count += 1
print(count)
| false | 0 |
[
"+from collections import Counter",
"+",
"-result = rec(l1, 0, 3)",
"-for i in range(len(N) - 3):",
"- result += rec(result, 0, 1)",
"+result = [\"\"]",
"+for i in range(1, len(N) + 1):",
"+ result += rec(l1, 0, i)",
"-result = list(set(result))",
"-result.sort()",
"+# result = list(set(result))"
] | false | 0.038644 | 0.038823 | 0.99538 |
[
"s133191940",
"s533727497"
] |
u113971909
|
p02732
|
python
|
s550843444
|
s274212567
| 423 | 357 | 26,268 | 25,916 |
Accepted
|
Accepted
| 15.6 |
N=int(eval(input()))
A=list(map(int,input().split()))
dic={}
for a in A:
if a in list(dic.keys()):
dic[a]+=1
else:
dic[a]=1
r=0
for a in list(dic.keys()):
c=dic[a]
r+=c*(c-1)//2
for i in range(N):
c=dic[A[i]]
print((r - c*(c-1)//2 + (c-1)*(c-2)//2 ))
|
#!/usr/bin python3
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
D = {}
for a in A:
if a in D:
D[a]+=1
else:
D[a]=1
ret = 0
for d in D:
ret += D[d]*(D[d]-1)//2
for a in A:
print((ret - D[a]*(D[a]-1)//2 + (D[a]-1)*(D[a]-2)//2 ))
if __name__ == '__main__':
main()
| 15 | 24 | 265 | 455 |
N = int(eval(input()))
A = list(map(int, input().split()))
dic = {}
for a in A:
if a in list(dic.keys()):
dic[a] += 1
else:
dic[a] = 1
r = 0
for a in list(dic.keys()):
c = dic[a]
r += c * (c - 1) // 2
for i in range(N):
c = dic[A[i]]
print((r - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2))
|
#!/usr/bin python3
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
D = {}
for a in A:
if a in D:
D[a] += 1
else:
D[a] = 1
ret = 0
for d in D:
ret += D[d] * (D[d] - 1) // 2
for a in A:
print((ret - D[a] * (D[a] - 1) // 2 + (D[a] - 1) * (D[a] - 2) // 2))
if __name__ == "__main__":
main()
| false | 37.5 |
[
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-dic = {}",
"-for a in A:",
"- if a in list(dic.keys()):",
"- dic[a] += 1",
"- else:",
"- dic[a] = 1",
"-r = 0",
"-for a in list(dic.keys()):",
"- c = dic[a]",
"- r += c * (c - 1) // 2",
"-for i in range(N):",
"- c = dic[A[i]]",
"- print((r - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2))",
"+#!/usr/bin python3",
"+# -*- coding: utf-8 -*-",
"+import sys",
"+",
"+input = sys.stdin.readline",
"+",
"+",
"+def main():",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ D = {}",
"+ for a in A:",
"+ if a in D:",
"+ D[a] += 1",
"+ else:",
"+ D[a] = 1",
"+ ret = 0",
"+ for d in D:",
"+ ret += D[d] * (D[d] - 1) // 2",
"+ for a in A:",
"+ print((ret - D[a] * (D[a] - 1) // 2 + (D[a] - 1) * (D[a] - 2) // 2))",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.085425 | 0.045894 | 1.861373 |
[
"s550843444",
"s274212567"
] |
u411203878
|
p03722
|
python
|
s230424491
|
s588063675
| 1,400 | 990 | 3,416 | 3,396 |
Accepted
|
Accepted
| 29.29 |
N, M = list(map(int, input().split()))
Edges = []
for i in range(M):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
c = -c
Edges.append([a, b, c])
dist = [float('inf')] * N
dist[0] = 0
for i in range(N):
for fr, to, cost in Edges:
if (dist[fr] != float('inf')) and (dist[to] > dist[fr] + cost):
dist[to] = dist[fr] + cost
if (i == N - 1) & (to == N - 1):
print('inf')
exit()
print((-dist[-1]))
|
def bell(edges, n):
count = 0
dist = [float('inf') for i in range(n)]
dist[0] = 0
for i in range(n):
for edge in edges:
if dist[edge[1]] > dist[edge[0]] + edge[2] and edge[0] != float('inf'):
dist[edge[1]] = dist[edge[0]] + edge[2]
if (i == n - 1) & (edge[1] == n - 1):
print('inf')
exit()
return dist
n,m = list(map(int,input().split()))
edges = []
for _ in range(m):
a, b, c = (int(x) for x in input().split())
edges.append([a-1, b-1, -c])
res = bell(edges, n)
print((-res[n-1]))
| 20 | 26 | 503 | 646 |
N, M = list(map(int, input().split()))
Edges = []
for i in range(M):
a, b, c = list(map(int, input().split()))
a, b = a - 1, b - 1
c = -c
Edges.append([a, b, c])
dist = [float("inf")] * N
dist[0] = 0
for i in range(N):
for fr, to, cost in Edges:
if (dist[fr] != float("inf")) and (dist[to] > dist[fr] + cost):
dist[to] = dist[fr] + cost
if (i == N - 1) & (to == N - 1):
print("inf")
exit()
print((-dist[-1]))
|
def bell(edges, n):
count = 0
dist = [float("inf") for i in range(n)]
dist[0] = 0
for i in range(n):
for edge in edges:
if dist[edge[1]] > dist[edge[0]] + edge[2] and edge[0] != float("inf"):
dist[edge[1]] = dist[edge[0]] + edge[2]
if (i == n - 1) & (edge[1] == n - 1):
print("inf")
exit()
return dist
n, m = list(map(int, input().split()))
edges = []
for _ in range(m):
a, b, c = (int(x) for x in input().split())
edges.append([a - 1, b - 1, -c])
res = bell(edges, n)
print((-res[n - 1]))
| false | 23.076923 |
[
"-N, M = list(map(int, input().split()))",
"-Edges = []",
"-for i in range(M):",
"- a, b, c = list(map(int, input().split()))",
"- a, b = a - 1, b - 1",
"- c = -c",
"- Edges.append([a, b, c])",
"-dist = [float(\"inf\")] * N",
"-dist[0] = 0",
"-for i in range(N):",
"- for fr, to, cost in Edges:",
"- if (dist[fr] != float(\"inf\")) and (dist[to] > dist[fr] + cost):",
"- dist[to] = dist[fr] + cost",
"- if (i == N - 1) & (to == N - 1):",
"- print(\"inf\")",
"- exit()",
"-print((-dist[-1]))",
"+def bell(edges, n):",
"+ count = 0",
"+ dist = [float(\"inf\") for i in range(n)]",
"+ dist[0] = 0",
"+ for i in range(n):",
"+ for edge in edges:",
"+ if dist[edge[1]] > dist[edge[0]] + edge[2] and edge[0] != float(\"inf\"):",
"+ dist[edge[1]] = dist[edge[0]] + edge[2]",
"+ if (i == n - 1) & (edge[1] == n - 1):",
"+ print(\"inf\")",
"+ exit()",
"+ return dist",
"+",
"+",
"+n, m = list(map(int, input().split()))",
"+edges = []",
"+for _ in range(m):",
"+ a, b, c = (int(x) for x in input().split())",
"+ edges.append([a - 1, b - 1, -c])",
"+res = bell(edges, n)",
"+print((-res[n - 1]))"
] | false | 0.042686 | 0.036722 | 1.162415 |
[
"s230424491",
"s588063675"
] |
u390727364
|
p02862
|
python
|
s771551122
|
s640105675
| 308 | 172 | 115,948 | 38,512 |
Accepted
|
Accepted
| 44.16 |
from sys import stdin, setrecursionlimit
def initialize_cmb(m, mod=10 ** 9 + 7):
fac = [1]
finv = [1]
inv = [0] * (m + 1)
if m >= 1:
fac.append(1)
finv.append(1)
inv[1] = 1
pre_fac = 1
pre_finv = 1
for i in range(2, m + 1):
pre_fac = pre_fac * i % mod
fac.append(pre_fac)
inv[i] = mod - inv[mod % i] * (mod // i) % mod
pre_finv = pre_finv * inv[i] % mod
finv.append(pre_finv)
return fac, finv
def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
if n < k:
return 0
if n < 0 or k < 0:
return 0
return fac[n] * (finv[k] * finv[n - k] % mod) % mod
def main():
mod = 10 ** 9 + 7
input = stdin.buffer.readline
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0 or 2 * x < y or 2 * y < x:
print((0))
else:
fac, finv = initialize_cmb((x + y) // 3, mod)
x_min = (x + y) // 3
print((cmb((x + y) // 3, x - x_min, fac, finv, mod)))
if __name__ == "__main__":
setrecursionlimit(10000)
main()
|
from sys import stdin, setrecursionlimit
def cmb(n, r, mod=10 ** 9 + 7):
r = min(r, n - r)
x = y = 1
for i in range(r):
x *= n - i
x %= mod
y *= i + 1
y %= mod
return x * pow(y, mod - 2, mod) % mod
def main():
mod = 10 ** 9 + 7
input = stdin.buffer.readline
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0 or 2 * x < y or 2 * y < x:
print((0))
else:
x_min = (x + y) // 3
print((cmb((x + y) // 3, x - x_min, mod)))
if __name__ == "__main__":
setrecursionlimit(10000)
main()
| 48 | 31 | 1,142 | 613 |
from sys import stdin, setrecursionlimit
def initialize_cmb(m, mod=10**9 + 7):
fac = [1]
finv = [1]
inv = [0] * (m + 1)
if m >= 1:
fac.append(1)
finv.append(1)
inv[1] = 1
pre_fac = 1
pre_finv = 1
for i in range(2, m + 1):
pre_fac = pre_fac * i % mod
fac.append(pre_fac)
inv[i] = mod - inv[mod % i] * (mod // i) % mod
pre_finv = pre_finv * inv[i] % mod
finv.append(pre_finv)
return fac, finv
def cmb(n, k, fac, finv, mod=10**9 + 7):
if n < k:
return 0
if n < 0 or k < 0:
return 0
return fac[n] * (finv[k] * finv[n - k] % mod) % mod
def main():
mod = 10**9 + 7
input = stdin.buffer.readline
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0 or 2 * x < y or 2 * y < x:
print((0))
else:
fac, finv = initialize_cmb((x + y) // 3, mod)
x_min = (x + y) // 3
print((cmb((x + y) // 3, x - x_min, fac, finv, mod)))
if __name__ == "__main__":
setrecursionlimit(10000)
main()
|
from sys import stdin, setrecursionlimit
def cmb(n, r, mod=10**9 + 7):
r = min(r, n - r)
x = y = 1
for i in range(r):
x *= n - i
x %= mod
y *= i + 1
y %= mod
return x * pow(y, mod - 2, mod) % mod
def main():
mod = 10**9 + 7
input = stdin.buffer.readline
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0 or 2 * x < y or 2 * y < x:
print((0))
else:
x_min = (x + y) // 3
print((cmb((x + y) // 3, x - x_min, mod)))
if __name__ == "__main__":
setrecursionlimit(10000)
main()
| false | 35.416667 |
[
"-def initialize_cmb(m, mod=10**9 + 7):",
"- fac = [1]",
"- finv = [1]",
"- inv = [0] * (m + 1)",
"- if m >= 1:",
"- fac.append(1)",
"- finv.append(1)",
"- inv[1] = 1",
"- pre_fac = 1",
"- pre_finv = 1",
"- for i in range(2, m + 1):",
"- pre_fac = pre_fac * i % mod",
"- fac.append(pre_fac)",
"- inv[i] = mod - inv[mod % i] * (mod // i) % mod",
"- pre_finv = pre_finv * inv[i] % mod",
"- finv.append(pre_finv)",
"- return fac, finv",
"-",
"-",
"-def cmb(n, k, fac, finv, mod=10**9 + 7):",
"- if n < k:",
"- return 0",
"- if n < 0 or k < 0:",
"- return 0",
"- return fac[n] * (finv[k] * finv[n - k] % mod) % mod",
"+def cmb(n, r, mod=10**9 + 7):",
"+ r = min(r, n - r)",
"+ x = y = 1",
"+ for i in range(r):",
"+ x *= n - i",
"+ x %= mod",
"+ y *= i + 1",
"+ y %= mod",
"+ return x * pow(y, mod - 2, mod) % mod",
"- fac, finv = initialize_cmb((x + y) // 3, mod)",
"- print((cmb((x + y) // 3, x - x_min, fac, finv, mod)))",
"+ print((cmb((x + y) // 3, x - x_min, mod)))"
] | false | 0.317318 | 0.164992 | 1.923228 |
[
"s771551122",
"s640105675"
] |
u617640347
|
p03073
|
python
|
s454683963
|
s537960312
| 72 | 56 | 6,300 | 6,300 |
Accepted
|
Accepted
| 22.22 |
# -*- coding: utf-8 -*-
s = [int(x) for x in eval(input())]
l1 = [i % 2 for i in range(len(s))]
l2 = [1] + l1[:len(l1) - 1]
d1 = len([x for i, x in enumerate(s) if s[i] != l1[i]])
d2 = len([x for i, x in enumerate(s) if s[i] != l2[i]])
print((d1 if d1 < d2 else d2))
|
# -*- coding: utf-8 -*-
s = [int(x) for x in eval(input())]
l1 = [i % 2 for i in range(len(s))]
l2 = [1] + l1[:len(l1) - 1]
d1 = len([sv for sv, lv in zip(s, l1) if sv != lv])
d2 = len([sv for sv, lv in zip(s, l2) if sv != lv])
print((d1 if d1 < d2 else d2))
| 7 | 7 | 264 | 257 |
# -*- coding: utf-8 -*-
s = [int(x) for x in eval(input())]
l1 = [i % 2 for i in range(len(s))]
l2 = [1] + l1[: len(l1) - 1]
d1 = len([x for i, x in enumerate(s) if s[i] != l1[i]])
d2 = len([x for i, x in enumerate(s) if s[i] != l2[i]])
print((d1 if d1 < d2 else d2))
|
# -*- coding: utf-8 -*-
s = [int(x) for x in eval(input())]
l1 = [i % 2 for i in range(len(s))]
l2 = [1] + l1[: len(l1) - 1]
d1 = len([sv for sv, lv in zip(s, l1) if sv != lv])
d2 = len([sv for sv, lv in zip(s, l2) if sv != lv])
print((d1 if d1 < d2 else d2))
| false | 0 |
[
"-d1 = len([x for i, x in enumerate(s) if s[i] != l1[i]])",
"-d2 = len([x for i, x in enumerate(s) if s[i] != l2[i]])",
"+d1 = len([sv for sv, lv in zip(s, l1) if sv != lv])",
"+d2 = len([sv for sv, lv in zip(s, l2) if sv != lv])"
] | false | 0.035501 | 0.040381 | 0.879168 |
[
"s454683963",
"s537960312"
] |
u294520705
|
p02837
|
python
|
s603336958
|
s929170101
| 115 | 88 | 3,064 | 3,064 |
Accepted
|
Accepted
| 23.48 |
import itertools
n = int(eval(input()))
data = []
for x in range(n):
for y in range(int(eval(input()))):
k, l = list(map(int, input().split()))
data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
s = sum(i)
for g in data:
if i[g[0]] == 1 and i[g[1]] != g[2]:
s = 0
break
ans = max(ans, s)
print(ans)
|
import itertools
n = int(eval(input()))
data = []
for x in range(n):
for y in range(int(eval(input()))):
k, l = list(map(int, input().split()))
data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1,0], repeat=n):
s = True
for g in data:
if i[g[0]] == 1 and i[g[1]] != g[2]:
s = False
break
if s:
ans = max(ans, sum(i))
print(ans)
| 16 | 17 | 388 | 410 |
import itertools
n = int(eval(input()))
data = []
for x in range(n):
for y in range(int(eval(input()))):
k, l = list(map(int, input().split()))
data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1, 0], repeat=n):
s = sum(i)
for g in data:
if i[g[0]] == 1 and i[g[1]] != g[2]:
s = 0
break
ans = max(ans, s)
print(ans)
|
import itertools
n = int(eval(input()))
data = []
for x in range(n):
for y in range(int(eval(input()))):
k, l = list(map(int, input().split()))
data.append((x, k - 1, l))
ans = 0
for i in itertools.product([1, 0], repeat=n):
s = True
for g in data:
if i[g[0]] == 1 and i[g[1]] != g[2]:
s = False
break
if s:
ans = max(ans, sum(i))
print(ans)
| false | 5.882353 |
[
"- s = sum(i)",
"+ s = True",
"- s = 0",
"+ s = False",
"- ans = max(ans, s)",
"+ if s:",
"+ ans = max(ans, sum(i))"
] | false | 0.037349 | 0.038182 | 0.978185 |
[
"s603336958",
"s929170101"
] |
u633068244
|
p00590
|
python
|
s283714029
|
s359520564
| 590 | 140 | 4,740 | 4,764 |
Accepted
|
Accepted
| 76.27 |
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
if p[i]:
p[2*i+1::i+1] = [0 for j in range(2*i+1,r,i+1)]
while True:
try:
n = int(input())
count = 0
for i in range(n):
if p[i]*p[n-i-1] == 1:
count += 1
print(count)
except:
break
|
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
if p[i]:
p[2*i+1::i+1] = [0 for j in range(2*i+1,r,i+1)]
prime = []
for i in range(r):
if p[i]:
prime.append(i)
while True:
try:
n = int(input())
count = 0
for i in prime:
if i > n-1:
break
if p[i]*p[n-i-1] == 1:
count += 1
print(count)
except:
break
| 19 | 25 | 394 | 510 |
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
if p[i]:
p[2 * i + 1 :: i + 1] = [0 for j in range(2 * i + 1, r, i + 1)]
while True:
try:
n = int(input())
count = 0
for i in range(n):
if p[i] * p[n - i - 1] == 1:
count += 1
print(count)
except:
break
|
import math
r = 10000
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
if p[i]:
p[2 * i + 1 :: i + 1] = [0 for j in range(2 * i + 1, r, i + 1)]
prime = []
for i in range(r):
if p[i]:
prime.append(i)
while True:
try:
n = int(input())
count = 0
for i in prime:
if i > n - 1:
break
if p[i] * p[n - i - 1] == 1:
count += 1
print(count)
except:
break
| false | 24 |
[
"+prime = []",
"+for i in range(r):",
"+ if p[i]:",
"+ prime.append(i)",
"- for i in range(n):",
"+ for i in prime:",
"+ if i > n - 1:",
"+ break"
] | false | 0.035664 | 0.088296 | 0.403913 |
[
"s283714029",
"s359520564"
] |
u102242691
|
p03556
|
python
|
s099946433
|
s330332490
| 38 | 30 | 2,940 | 2,940 |
Accepted
|
Accepted
| 21.05 |
n = int(eval(input()))
a = 1
ans = 0
while a ** 2 <= n:
ans = a ** 2
a += 1
print(ans)
|
n = int(eval(input()))
x = 1
while x ** 2 <= n:
x += 1
print(((x-1) ** 2))
| 10 | 7 | 101 | 79 |
n = int(eval(input()))
a = 1
ans = 0
while a**2 <= n:
ans = a**2
a += 1
print(ans)
|
n = int(eval(input()))
x = 1
while x**2 <= n:
x += 1
print(((x - 1) ** 2))
| false | 30 |
[
"-a = 1",
"-ans = 0",
"-while a**2 <= n:",
"- ans = a**2",
"- a += 1",
"-print(ans)",
"+x = 1",
"+while x**2 <= n:",
"+ x += 1",
"+print(((x - 1) ** 2))"
] | false | 0.045768 | 0.049787 | 0.919272 |
[
"s099946433",
"s330332490"
] |
u633068244
|
p02268
|
python
|
s854128560
|
s421561627
| 80 | 40 | 16,384 | 17,028 |
Accepted
|
Accepted
| 50 |
n = int(input())
T = set(map(int, input().split()))
n = int(input())
S = set(map(int, input().split()))
print(len(T&S))
|
n = int(input())
T = set(input().split())
n = int(input())
S = set(input().split())
print(len(T&S))
| 5 | 5 | 138 | 118 |
n = int(input())
T = set(map(int, input().split()))
n = int(input())
S = set(map(int, input().split()))
print(len(T & S))
|
n = int(input())
T = set(input().split())
n = int(input())
S = set(input().split())
print(len(T & S))
| false | 0 |
[
"-T = set(map(int, input().split()))",
"+T = set(input().split())",
"-S = set(map(int, input().split()))",
"+S = set(input().split())"
] | false | 0.035673 | 0.037048 | 0.962895 |
[
"s854128560",
"s421561627"
] |
u644907318
|
p02995
|
python
|
s263134980
|
s173421711
| 63 | 27 | 61,928 | 9,036 |
Accepted
|
Accepted
| 57.14 |
A,B,C,D =list(map(int,input().split()))
x = C
y = D
while y>0:
x,y = y,x%y
E = (C//x)*D
bc = B//C
bd = B//D
be = B//E
b = B-(bc+bd-be)
ac = (A-1)//C
ad = (A-1)//D
ae = (A-1)//E
a = A-1-(ac+ad-ae)
print((b-a))
|
def gcd(x,y):
while y>0:
x,y = y,x%y
return x
A,B,C,D = list(map(int,input().split()))
c1 = B//C-(A-1)//C
d1 = B//D-(A-1)//D
E = (C//gcd(C,D))*D
e1 = B//E-(A-1)//E
print((B-A+1-c1-d1+e1))
| 15 | 10 | 218 | 204 |
A, B, C, D = list(map(int, input().split()))
x = C
y = D
while y > 0:
x, y = y, x % y
E = (C // x) * D
bc = B // C
bd = B // D
be = B // E
b = B - (bc + bd - be)
ac = (A - 1) // C
ad = (A - 1) // D
ae = (A - 1) // E
a = A - 1 - (ac + ad - ae)
print((b - a))
|
def gcd(x, y):
while y > 0:
x, y = y, x % y
return x
A, B, C, D = list(map(int, input().split()))
c1 = B // C - (A - 1) // C
d1 = B // D - (A - 1) // D
E = (C // gcd(C, D)) * D
e1 = B // E - (A - 1) // E
print((B - A + 1 - c1 - d1 + e1))
| false | 33.333333 |
[
"+def gcd(x, y):",
"+ while y > 0:",
"+ x, y = y, x % y",
"+ return x",
"+",
"+",
"-x = C",
"-y = D",
"-while y > 0:",
"- x, y = y, x % y",
"-E = (C // x) * D",
"-bc = B // C",
"-bd = B // D",
"-be = B // E",
"-b = B - (bc + bd - be)",
"-ac = (A - 1) // C",
"-ad = (A - 1) // D",
"-ae = (A - 1) // E",
"-a = A - 1 - (ac + ad - ae)",
"-print((b - a))",
"+c1 = B // C - (A - 1) // C",
"+d1 = B // D - (A - 1) // D",
"+E = (C // gcd(C, D)) * D",
"+e1 = B // E - (A - 1) // E",
"+print((B - A + 1 - c1 - d1 + e1))"
] | false | 0.121293 | 0.046659 | 2.599586 |
[
"s263134980",
"s173421711"
] |
u119148115
|
p03610
|
python
|
s509548017
|
s031063899
| 167 | 61 | 80,896 | 62,552 |
Accepted
|
Accepted
| 63.47 |
import sys
def LS2(): return list(sys.stdin.readline().rstrip()) #空白なし
S = LS2()
ans = ''
for i in range(0,len(S),2):
ans += S[i]
print(ans)
|
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
print((S[::2]))
| 10 | 6 | 158 | 86 |
import sys
def LS2():
return list(sys.stdin.readline().rstrip()) # 空白なし
S = LS2()
ans = ""
for i in range(0, len(S), 2):
ans += S[i]
print(ans)
|
import sys
def S():
return sys.stdin.readline().rstrip()
S = S()
print((S[::2]))
| false | 40 |
[
"-def LS2():",
"- return list(sys.stdin.readline().rstrip()) # 空白なし",
"+def S():",
"+ return sys.stdin.readline().rstrip()",
"-S = LS2()",
"-ans = \"\"",
"-for i in range(0, len(S), 2):",
"- ans += S[i]",
"-print(ans)",
"+S = S()",
"+print((S[::2]))"
] | false | 0.039913 | 0.107555 | 0.371099 |
[
"s509548017",
"s031063899"
] |
u057586044
|
p03731
|
python
|
s263602974
|
s308821584
| 154 | 136 | 26,708 | 19,216 |
Accepted
|
Accepted
| 11.69 |
N,T = list(map(int,input().split()))
order = list(map(int,input().split()))
ov = 0
for i in range(N-1):
if (order[i+1]-order[i])<T:
ov += T-(order[i+1]-order[i])
print((N*T-ov))
|
N,T = list(map(int,input().split()))
last, time = 0,-T
for temp in map(int,input().split()):
if temp - last < T:
time += T - (temp - last)
last = temp
print((N*T-time))
| 7 | 7 | 187 | 182 |
N, T = list(map(int, input().split()))
order = list(map(int, input().split()))
ov = 0
for i in range(N - 1):
if (order[i + 1] - order[i]) < T:
ov += T - (order[i + 1] - order[i])
print((N * T - ov))
|
N, T = list(map(int, input().split()))
last, time = 0, -T
for temp in map(int, input().split()):
if temp - last < T:
time += T - (temp - last)
last = temp
print((N * T - time))
| false | 0 |
[
"-order = list(map(int, input().split()))",
"-ov = 0",
"-for i in range(N - 1):",
"- if (order[i + 1] - order[i]) < T:",
"- ov += T - (order[i + 1] - order[i])",
"-print((N * T - ov))",
"+last, time = 0, -T",
"+for temp in map(int, input().split()):",
"+ if temp - last < T:",
"+ time += T - (temp - last)",
"+ last = temp",
"+print((N * T - time))"
] | false | 0.120632 | 0.191325 | 0.630509 |
[
"s263602974",
"s308821584"
] |
u790710233
|
p03167
|
python
|
s323319954
|
s074804569
| 1,588 | 1,387 | 43,636 | 157,548 |
Accepted
|
Accepted
| 12.66 |
h, w = [int(x)+2 for x in input().split()]
MOD = 10**9+7
MAZE = ['#'*w]
for _ in range(h-2):
MAZE.append('#'+eval(input())+'#')
else:
MAZE.append('#'*w)
route = [[0]*w for _ in range(h)]
route[1][1] = 1
for i in range(1, h-1):
for j in range(1, w-1):
for x, y in [(i+1, j), (i, j+1)]:
if MAZE[x][y] == '#':
continue
route[x][y] += route[i][j]
route[x][y] %= MOD
print((route[-2][-2]))
|
h, w = [int(x)+2 for x in input().split()]
MOD = 10**9+7
MAZE = ['#'*w]
for _ in range(h-2):
MAZE.append('#'+eval(input())+'#')
else:
MAZE.append('#'*w)
route = [[0]*w for _ in range(h)]
route[1][1] = 1
for i in range(1, h-1):
for j in range(1, w-1):
for x, y in [(i+1, j), (i, j+1)]:
if MAZE[x][y] == '#':
continue
route[x][y] += route[i][j]
print((route[-2][-2] % MOD))
| 19 | 18 | 473 | 447 |
h, w = [int(x) + 2 for x in input().split()]
MOD = 10**9 + 7
MAZE = ["#" * w]
for _ in range(h - 2):
MAZE.append("#" + eval(input()) + "#")
else:
MAZE.append("#" * w)
route = [[0] * w for _ in range(h)]
route[1][1] = 1
for i in range(1, h - 1):
for j in range(1, w - 1):
for x, y in [(i + 1, j), (i, j + 1)]:
if MAZE[x][y] == "#":
continue
route[x][y] += route[i][j]
route[x][y] %= MOD
print((route[-2][-2]))
|
h, w = [int(x) + 2 for x in input().split()]
MOD = 10**9 + 7
MAZE = ["#" * w]
for _ in range(h - 2):
MAZE.append("#" + eval(input()) + "#")
else:
MAZE.append("#" * w)
route = [[0] * w for _ in range(h)]
route[1][1] = 1
for i in range(1, h - 1):
for j in range(1, w - 1):
for x, y in [(i + 1, j), (i, j + 1)]:
if MAZE[x][y] == "#":
continue
route[x][y] += route[i][j]
print((route[-2][-2] % MOD))
| false | 5.263158 |
[
"- route[x][y] %= MOD",
"-print((route[-2][-2]))",
"+print((route[-2][-2] % MOD))"
] | false | 0.041713 | 0.042915 | 0.972002 |
[
"s323319954",
"s074804569"
] |
u698176039
|
p02716
|
python
|
s215031587
|
s530798172
| 254 | 120 | 157,972 | 92,144 |
Accepted
|
Accepted
| 52.76 |
import sys
N = int(eval(input()))
A = list(map(int,input().split()))
INF = 10**20
dp = [[[-INF]*2 for _ in range(2)] for _ in range(N+1)]
if N&1:
dp[0][1][0] = 0
for i in range(N):
if i&1:
dp[i+1][0][0] = max(dp[i][0][0], dp[i][0][1])
dp[i+1][1][0] = max(dp[i][1][0], dp[i][1][1])
dp[i+1][1][1] = dp[i][0][0] + A[i]
else:
dp[i+1][0][0] = max(dp[i][1][0], dp[i][1][1])
dp[i+1][0][1] = dp[i][0][0] + A[i]
dp[i+1][1][1] = dp[i][1][0] + A[i]
ans = max(dp[N][0][0], dp[N][0][1])
else:
dp[0][1][0] = 0
for i in range(N):
if i&1:
dp[i+1][1][0] = dp[i][1][1]
dp[i+1][1][1] = dp[i][0][0] + A[i]
else:
dp[i+1][0][0] = max(dp[i][1][0], dp[i][1][1])
dp[i+1][1][1] = dp[i][1][0] + A[i]
ans = max(dp[N][1][0], dp[N][1][1])
print(ans)
|
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int,input().split()))
dp = [0]*n
c = a[0]
dp[1] = max(a[0],a[1])
for i in range(2,n):
if i%2 == 0:
c += a[i]
dp[i] = max(dp[i-2]+a[i],dp[i-1])
else:
dp[i] = max(dp[i-2]+a[i],c)
print((dp[-1]))
| 37 | 19 | 958 | 318 |
import sys
N = int(eval(input()))
A = list(map(int, input().split()))
INF = 10**20
dp = [[[-INF] * 2 for _ in range(2)] for _ in range(N + 1)]
if N & 1:
dp[0][1][0] = 0
for i in range(N):
if i & 1:
dp[i + 1][0][0] = max(dp[i][0][0], dp[i][0][1])
dp[i + 1][1][0] = max(dp[i][1][0], dp[i][1][1])
dp[i + 1][1][1] = dp[i][0][0] + A[i]
else:
dp[i + 1][0][0] = max(dp[i][1][0], dp[i][1][1])
dp[i + 1][0][1] = dp[i][0][0] + A[i]
dp[i + 1][1][1] = dp[i][1][0] + A[i]
ans = max(dp[N][0][0], dp[N][0][1])
else:
dp[0][1][0] = 0
for i in range(N):
if i & 1:
dp[i + 1][1][0] = dp[i][1][1]
dp[i + 1][1][1] = dp[i][0][0] + A[i]
else:
dp[i + 1][0][0] = max(dp[i][1][0], dp[i][1][1])
dp[i + 1][1][1] = dp[i][1][0] + A[i]
ans = max(dp[N][1][0], dp[N][1][1])
print(ans)
|
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
dp = [0] * n
c = a[0]
dp[1] = max(a[0], a[1])
for i in range(2, n):
if i % 2 == 0:
c += a[i]
dp[i] = max(dp[i - 2] + a[i], dp[i - 1])
else:
dp[i] = max(dp[i - 2] + a[i], c)
print((dp[-1]))
| false | 48.648649 |
[
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-INF = 10**20",
"-dp = [[[-INF] * 2 for _ in range(2)] for _ in range(N + 1)]",
"-if N & 1:",
"- dp[0][1][0] = 0",
"- for i in range(N):",
"- if i & 1:",
"- dp[i + 1][0][0] = max(dp[i][0][0], dp[i][0][1])",
"- dp[i + 1][1][0] = max(dp[i][1][0], dp[i][1][1])",
"- dp[i + 1][1][1] = dp[i][0][0] + A[i]",
"- else:",
"- dp[i + 1][0][0] = max(dp[i][1][0], dp[i][1][1])",
"- dp[i + 1][0][1] = dp[i][0][0] + A[i]",
"- dp[i + 1][1][1] = dp[i][1][0] + A[i]",
"- ans = max(dp[N][0][0], dp[N][0][1])",
"-else:",
"- dp[0][1][0] = 0",
"- for i in range(N):",
"- if i & 1:",
"- dp[i + 1][1][0] = dp[i][1][1]",
"- dp[i + 1][1][1] = dp[i][0][0] + A[i]",
"- else:",
"- dp[i + 1][0][0] = max(dp[i][1][0], dp[i][1][1])",
"- dp[i + 1][1][1] = dp[i][1][0] + A[i]",
"- ans = max(dp[N][1][0], dp[N][1][1])",
"-print(ans)",
"+input = sys.stdin.readline",
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"+dp = [0] * n",
"+c = a[0]",
"+dp[1] = max(a[0], a[1])",
"+for i in range(2, n):",
"+ if i % 2 == 0:",
"+ c += a[i]",
"+ dp[i] = max(dp[i - 2] + a[i], dp[i - 1])",
"+ else:",
"+ dp[i] = max(dp[i - 2] + a[i], c)",
"+print((dp[-1]))"
] | false | 0.036141 | 0.036397 | 0.992974 |
[
"s215031587",
"s530798172"
] |
u368249389
|
p03665
|
python
|
s810714401
|
s220649667
| 167 | 17 | 38,256 | 2,940 |
Accepted
|
Accepted
| 89.82 |
# Problem A - Biscuits
# input
N, P = list(map(int, input().split()))
a_list = list(map(int, input().split()))
# initialization
even_count = 0
odd_count = 0
# count
for a in a_list:
if a%2==0:
even_count += 1
else:
odd_count = 2 ** (N - 1)
if even_count==len(a_list):
if P==0:
print((2 ** N))
else:
print((0))
else:
print((2**(N-1)))
|
# Problem A - Biscuits
# 数の並びのパターンを意識する
# input
N, P = list(map(int, input().split()))
a_list = list(map(int, input().split()))
# initialization
even_count = 0
odd_count = 0
# count
for a in a_list:
if a%2==0:
even_count += 1
else:
odd_count += 1
if even_count==N:
if P==0:
print((2**N))
else:
print((0))
else:
print((2**(N-1)))
| 23 | 24 | 399 | 395 |
# Problem A - Biscuits
# input
N, P = list(map(int, input().split()))
a_list = list(map(int, input().split()))
# initialization
even_count = 0
odd_count = 0
# count
for a in a_list:
if a % 2 == 0:
even_count += 1
else:
odd_count = 2 ** (N - 1)
if even_count == len(a_list):
if P == 0:
print((2**N))
else:
print((0))
else:
print((2 ** (N - 1)))
|
# Problem A - Biscuits
# 数の並びのパターンを意識する
# input
N, P = list(map(int, input().split()))
a_list = list(map(int, input().split()))
# initialization
even_count = 0
odd_count = 0
# count
for a in a_list:
if a % 2 == 0:
even_count += 1
else:
odd_count += 1
if even_count == N:
if P == 0:
print((2**N))
else:
print((0))
else:
print((2 ** (N - 1)))
| false | 4.166667 |
[
"+# 数の並びのパターンを意識する",
"- odd_count = 2 ** (N - 1)",
"-if even_count == len(a_list):",
"+ odd_count += 1",
"+if even_count == N:"
] | false | 0.089212 | 0.035664 | 2.501467 |
[
"s810714401",
"s220649667"
] |
u562935282
|
p03039
|
python
|
s797132734
|
s691229821
| 101 | 81 | 3,572 | 3,684 |
Accepted
|
Accepted
| 19.8 |
# https://atcoder.jp/contests/abc127/submissions/5606400
from functools import reduce
def mod_mul(a, b):
return (a * b) % MOD
def mod_add(a, b):
return (a + b) % MOD
def cmb(n, r):
r = min(r, n - r)
if r == 0:
return 1
if r == 1:
return n
f = reduce(mod_mul, list(range(n - r + 1, n + 1))) # n!/(n-r)!
d = reduce(mod_mul, list(range(2, r + 1))) # r!
return (f * pow(d, MOD - 2, MOD)) % MOD
MOD = 10 ** 9 + 7
N, M, K = list(map(int, input().split()))
ans_x = reduce(mod_add, (i * (M - i) for i in range(M))) * N ** 2
ans_y = reduce(mod_add, (i * (N - i) for i in range(N))) * M ** 2
ans = ans_x + ans_y
pat = cmb(N * M - 2, K - 2)
ans = (ans * pat) % MOD
print(ans)
|
# https://atcoder.jp/contests/abc127/submissions/5606400
from functools import reduce
from operator import add
def mod_mul(a, b):
return (a * b) % MOD
def cmb(n, r):
r = min(r, n - r)
if r == 0:
return 1
if r == 1:
return n
f = reduce(mod_mul, list(range(n - r + 1, n + 1))) # n!/(n-r)!
d = reduce(mod_mul, list(range(2, r + 1))) # r!
return (f * pow(d, MOD - 2, MOD)) % MOD
MOD = 10 ** 9 + 7
N, M, K = list(map(int, input().split()))
ans_x = reduce(add, (i * (M - i) for i in range(M))) * N ** 2
ans_y = reduce(add, (i * (N - i) for i in range(N))) * M ** 2
ans = (ans_x + ans_y) % MOD
pat = cmb(N * M - 2, K - 2)
ans = (ans * pat) % MOD
print(ans)
| 36 | 32 | 745 | 719 |
# https://atcoder.jp/contests/abc127/submissions/5606400
from functools import reduce
def mod_mul(a, b):
return (a * b) % MOD
def mod_add(a, b):
return (a + b) % MOD
def cmb(n, r):
r = min(r, n - r)
if r == 0:
return 1
if r == 1:
return n
f = reduce(mod_mul, list(range(n - r + 1, n + 1))) # n!/(n-r)!
d = reduce(mod_mul, list(range(2, r + 1))) # r!
return (f * pow(d, MOD - 2, MOD)) % MOD
MOD = 10**9 + 7
N, M, K = list(map(int, input().split()))
ans_x = reduce(mod_add, (i * (M - i) for i in range(M))) * N**2
ans_y = reduce(mod_add, (i * (N - i) for i in range(N))) * M**2
ans = ans_x + ans_y
pat = cmb(N * M - 2, K - 2)
ans = (ans * pat) % MOD
print(ans)
|
# https://atcoder.jp/contests/abc127/submissions/5606400
from functools import reduce
from operator import add
def mod_mul(a, b):
return (a * b) % MOD
def cmb(n, r):
r = min(r, n - r)
if r == 0:
return 1
if r == 1:
return n
f = reduce(mod_mul, list(range(n - r + 1, n + 1))) # n!/(n-r)!
d = reduce(mod_mul, list(range(2, r + 1))) # r!
return (f * pow(d, MOD - 2, MOD)) % MOD
MOD = 10**9 + 7
N, M, K = list(map(int, input().split()))
ans_x = reduce(add, (i * (M - i) for i in range(M))) * N**2
ans_y = reduce(add, (i * (N - i) for i in range(N))) * M**2
ans = (ans_x + ans_y) % MOD
pat = cmb(N * M - 2, K - 2)
ans = (ans * pat) % MOD
print(ans)
| false | 11.111111 |
[
"+from operator import add",
"-",
"-",
"-def mod_add(a, b):",
"- return (a + b) % MOD",
"-ans_x = reduce(mod_add, (i * (M - i) for i in range(M))) * N**2",
"-ans_y = reduce(mod_add, (i * (N - i) for i in range(N))) * M**2",
"-ans = ans_x + ans_y",
"+ans_x = reduce(add, (i * (M - i) for i in range(M))) * N**2",
"+ans_y = reduce(add, (i * (N - i) for i in range(N))) * M**2",
"+ans = (ans_x + ans_y) % MOD"
] | false | 0.039086 | 0.041319 | 0.945966 |
[
"s797132734",
"s691229821"
] |
u644171993
|
p03168
|
python
|
s628738324
|
s007875588
| 240 | 115 | 213,972 | 68,756 |
Accepted
|
Accepted
| 52.08 |
#!/usr/bin/env python3
# from pprint import pprint
def recur(parr, curp, curi, heads):
# if dp[curi][heads] != -1:
# return dp[curi][heads]
if curi >= len(parr):
if heads >= len(parr)//2 + 1:
return curp
else:
return 0
return (recur(parr, curp*parr[curi], curi+1, heads+1)
+ recur(parr, curp*(1-parr[curi]), curi+1, heads))
n = int(eval(input()))
parr = [float(i) for i in input().split(' ')]
# print(recur(parr, 1, 0, 0))
dp = [[0]*(n+1) for i in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
for j in range(i, -1, -1):
# heads
heads = dp[i-1][j-1] if j > 0 else 0
# tails
tails = dp[i-1][j]
dp[i][j] = heads*parr[i-1] + tails*(1-parr[i-1])
print((sum(dp[n][n//2+1:])))
|
#!/usr/bin/env python3
# from pprint import pprint
def recur(parr, curp, curi, heads):
# if dp[curi][heads] != -1:
# return dp[curi][heads]
if curi >= len(parr):
if heads >= len(parr)//2 + 1:
return curp
else:
return 0
return (recur(parr, curp*parr[curi], curi+1, heads+1)
+ recur(parr, curp*(1-parr[curi]), curi+1, heads))
n = int(eval(input()))
parr = [float(i) for i in input().split(' ')]
# print(recur(parr, 1, 0, 0))
dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
for j in range(i+1, -1, -1):
# heads
heads = dp[j-1] if j > 0 else 0
# tails
tails = dp[j]
dp[j] = heads*parr[i-1] + tails*(1-parr[i-1])
print((sum(dp[n//2+1:])))
| 34 | 34 | 820 | 776 |
#!/usr/bin/env python3
# from pprint import pprint
def recur(parr, curp, curi, heads):
# if dp[curi][heads] != -1:
# return dp[curi][heads]
if curi >= len(parr):
if heads >= len(parr) // 2 + 1:
return curp
else:
return 0
return recur(parr, curp * parr[curi], curi + 1, heads + 1) + recur(
parr, curp * (1 - parr[curi]), curi + 1, heads
)
n = int(eval(input()))
parr = [float(i) for i in input().split(" ")]
# print(recur(parr, 1, 0, 0))
dp = [[0] * (n + 1) for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
for j in range(i, -1, -1):
# heads
heads = dp[i - 1][j - 1] if j > 0 else 0
# tails
tails = dp[i - 1][j]
dp[i][j] = heads * parr[i - 1] + tails * (1 - parr[i - 1])
print((sum(dp[n][n // 2 + 1 :])))
|
#!/usr/bin/env python3
# from pprint import pprint
def recur(parr, curp, curi, heads):
# if dp[curi][heads] != -1:
# return dp[curi][heads]
if curi >= len(parr):
if heads >= len(parr) // 2 + 1:
return curp
else:
return 0
return recur(parr, curp * parr[curi], curi + 1, heads + 1) + recur(
parr, curp * (1 - parr[curi]), curi + 1, heads
)
n = int(eval(input()))
parr = [float(i) for i in input().split(" ")]
# print(recur(parr, 1, 0, 0))
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
for j in range(i + 1, -1, -1):
# heads
heads = dp[j - 1] if j > 0 else 0
# tails
tails = dp[j]
dp[j] = heads * parr[i - 1] + tails * (1 - parr[i - 1])
print((sum(dp[n // 2 + 1 :])))
| false | 0 |
[
"-dp = [[0] * (n + 1) for i in range(n + 1)]",
"-dp[0][0] = 1",
"-for i in range(1, n + 1):",
"- for j in range(i, -1, -1):",
"+dp = [0] * (n + 1)",
"+dp[0] = 1",
"+for i in range(n):",
"+ for j in range(i + 1, -1, -1):",
"- heads = dp[i - 1][j - 1] if j > 0 else 0",
"+ heads = dp[j - 1] if j > 0 else 0",
"- tails = dp[i - 1][j]",
"- dp[i][j] = heads * parr[i - 1] + tails * (1 - parr[i - 1])",
"-print((sum(dp[n][n // 2 + 1 :])))",
"+ tails = dp[j]",
"+ dp[j] = heads * parr[i - 1] + tails * (1 - parr[i - 1])",
"+print((sum(dp[n // 2 + 1 :])))"
] | false | 0.10319 | 0.107237 | 0.962261 |
[
"s628738324",
"s007875588"
] |
u368780724
|
p03959
|
python
|
s704911900
|
s903441879
| 327 | 284 | 19,648 | 82,660 |
Accepted
|
Accepted
| 13.15 |
def inpl(): return [int(i) for i in input().split()]
mod = 10**9+7
N = int(eval(input()))
T = inpl()
A = inpl()
summit = T[-1]
S = [i == j == summit for i, j in zip(A, T)]
ans, pre = 1, 0
if A[0] != summit:
ans = 0
if not any(S):
ans = 0
k = sum([min(i, j) == summit for i, j in zip(A, T)])
for i in T:
if i == summit:
break
if i == pre:
ans = ans*pre %mod
else:
pre = i
pre = 0
for i in reversed(A):
if i == summit:
break
if i == pre:
ans = ans*pre %mod
else:
pre = i
print((ans*summit**max(k-2, 0)%mod))
|
import sys
mod = 10**9 + 7
def nai():
print((0))
sys.exit()
N = int(eval(input()))
T = list(map(int, input().split()))
A = list(map(int, input().split()))
M = max(A)
if M != max(T):
nai()
iT = T.index(M)
iA = N - 1 - A[::-1].index(M)
if iA < iT:
nai()
ans = pow(M, max(0, iA - iT - 1), mod)
pre = -1
for t in T[:iT]:
if pre == t:
ans = t*ans%mod
pre = t
pre = -1
for a in A[::-1]:
if a == M:
break
if pre == a:
ans = a*ans%mod
pre = a
print(ans)
| 30 | 33 | 609 | 533 |
def inpl():
return [int(i) for i in input().split()]
mod = 10**9 + 7
N = int(eval(input()))
T = inpl()
A = inpl()
summit = T[-1]
S = [i == j == summit for i, j in zip(A, T)]
ans, pre = 1, 0
if A[0] != summit:
ans = 0
if not any(S):
ans = 0
k = sum([min(i, j) == summit for i, j in zip(A, T)])
for i in T:
if i == summit:
break
if i == pre:
ans = ans * pre % mod
else:
pre = i
pre = 0
for i in reversed(A):
if i == summit:
break
if i == pre:
ans = ans * pre % mod
else:
pre = i
print((ans * summit ** max(k - 2, 0) % mod))
|
import sys
mod = 10**9 + 7
def nai():
print((0))
sys.exit()
N = int(eval(input()))
T = list(map(int, input().split()))
A = list(map(int, input().split()))
M = max(A)
if M != max(T):
nai()
iT = T.index(M)
iA = N - 1 - A[::-1].index(M)
if iA < iT:
nai()
ans = pow(M, max(0, iA - iT - 1), mod)
pre = -1
for t in T[:iT]:
if pre == t:
ans = t * ans % mod
pre = t
pre = -1
for a in A[::-1]:
if a == M:
break
if pre == a:
ans = a * ans % mod
pre = a
print(ans)
| false | 9.090909 |
[
"-def inpl():",
"- return [int(i) for i in input().split()]",
"+import sys",
"+",
"+mod = 10**9 + 7",
"-mod = 10**9 + 7",
"+def nai():",
"+ print((0))",
"+ sys.exit()",
"+",
"+",
"-T = inpl()",
"-A = inpl()",
"-summit = T[-1]",
"-S = [i == j == summit for i, j in zip(A, T)]",
"-ans, pre = 1, 0",
"-if A[0] != summit:",
"- ans = 0",
"-if not any(S):",
"- ans = 0",
"-k = sum([min(i, j) == summit for i, j in zip(A, T)])",
"-for i in T:",
"- if i == summit:",
"+T = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+M = max(A)",
"+if M != max(T):",
"+ nai()",
"+iT = T.index(M)",
"+iA = N - 1 - A[::-1].index(M)",
"+if iA < iT:",
"+ nai()",
"+ans = pow(M, max(0, iA - iT - 1), mod)",
"+pre = -1",
"+for t in T[:iT]:",
"+ if pre == t:",
"+ ans = t * ans % mod",
"+ pre = t",
"+pre = -1",
"+for a in A[::-1]:",
"+ if a == M:",
"- if i == pre:",
"- ans = ans * pre % mod",
"- else:",
"- pre = i",
"-pre = 0",
"-for i in reversed(A):",
"- if i == summit:",
"- break",
"- if i == pre:",
"- ans = ans * pre % mod",
"- else:",
"- pre = i",
"-print((ans * summit ** max(k - 2, 0) % mod))",
"+ if pre == a:",
"+ ans = a * ans % mod",
"+ pre = a",
"+print(ans)"
] | false | 0.071982 | 0.046737 | 1.540161 |
[
"s704911900",
"s903441879"
] |
u752802582
|
p02612
|
python
|
s430772320
|
s431730211
| 87 | 63 | 61,532 | 61,652 |
Accepted
|
Accepted
| 27.59 |
n = int(eval(input()))
if n%1000:
print((1000 - n % 1000))
else:
print((0))
|
"""
atcoder : 173A
auther : Jay Saha
handel : ponder2000
date : 15/07/2020
"""
n = int(eval(input()))
print(((1000 - n%1000)%1000))
| 5 | 9 | 77 | 132 |
n = int(eval(input()))
if n % 1000:
print((1000 - n % 1000))
else:
print((0))
|
"""
atcoder : 173A
auther : Jay Saha
handel : ponder2000
date : 15/07/2020
"""
n = int(eval(input()))
print(((1000 - n % 1000) % 1000))
| false | 44.444444 |
[
"+\"\"\"",
"+atcoder : 173A",
"+auther : Jay Saha",
"+handel : ponder2000",
"+date : 15/07/2020",
"+\"\"\"",
"-if n % 1000:",
"- print((1000 - n % 1000))",
"-else:",
"- print((0))",
"+print(((1000 - n % 1000) % 1000))"
] | false | 0.103624 | 0.040961 | 2.529812 |
[
"s430772320",
"s431730211"
] |
u678167152
|
p03167
|
python
|
s413320178
|
s787720335
| 547 | 101 | 43,740 | 74,356 |
Accepted
|
Accepted
| 81.54 |
H, W = list(map(int, input().split()))
S = [0]*(H+1)
S[0] = '*'*(W+1)
for h in range(1,H+1):
S[h] = '*' + eval(input())
dps = [[0]*(W+1) for _ in range(H+1)]
mod = 10**9+7
def dp(h,w):
if h==1 and w==1:
return 1
if S[h][w]=='.':
return (dps[h-1][w]+dps[h][w-1])%mod
return 0
def solve():
for h in range(1,H+1):
for w in range(1,W+1):
dps[h][w] = dp(h,w)
ans = dps[-1][-1]
return ans
print((solve()))
|
H, W = list(map(int, input().split()))
S = [0]*(H+2)
S[0] = '#'*(W+2)
S[H+1] = '#'*(W+2)
for h in range(1,H+1):
S[h] = '#' + eval(input()) + '#'
mod = 10**9+7
dp = [[0]*(W+1) for _ in range(H+1)]
dp[1][1] = 1
for h in range(1,H+1):
for w in range(1,W+1):
if h==1 and w==1:
continue
if S[h][w]=='#':
continue
dp[h][w] += dp[h][w-1]+dp[h-1][w]
dp[h][w] %= mod
print((dp[-1][-1]))
| 24 | 18 | 477 | 412 |
H, W = list(map(int, input().split()))
S = [0] * (H + 1)
S[0] = "*" * (W + 1)
for h in range(1, H + 1):
S[h] = "*" + eval(input())
dps = [[0] * (W + 1) for _ in range(H + 1)]
mod = 10**9 + 7
def dp(h, w):
if h == 1 and w == 1:
return 1
if S[h][w] == ".":
return (dps[h - 1][w] + dps[h][w - 1]) % mod
return 0
def solve():
for h in range(1, H + 1):
for w in range(1, W + 1):
dps[h][w] = dp(h, w)
ans = dps[-1][-1]
return ans
print((solve()))
|
H, W = list(map(int, input().split()))
S = [0] * (H + 2)
S[0] = "#" * (W + 2)
S[H + 1] = "#" * (W + 2)
for h in range(1, H + 1):
S[h] = "#" + eval(input()) + "#"
mod = 10**9 + 7
dp = [[0] * (W + 1) for _ in range(H + 1)]
dp[1][1] = 1
for h in range(1, H + 1):
for w in range(1, W + 1):
if h == 1 and w == 1:
continue
if S[h][w] == "#":
continue
dp[h][w] += dp[h][w - 1] + dp[h - 1][w]
dp[h][w] %= mod
print((dp[-1][-1]))
| false | 25 |
[
"-S = [0] * (H + 1)",
"-S[0] = \"*\" * (W + 1)",
"+S = [0] * (H + 2)",
"+S[0] = \"#\" * (W + 2)",
"+S[H + 1] = \"#\" * (W + 2)",
"- S[h] = \"*\" + eval(input())",
"-dps = [[0] * (W + 1) for _ in range(H + 1)]",
"+ S[h] = \"#\" + eval(input()) + \"#\"",
"-",
"-",
"-def dp(h, w):",
"- if h == 1 and w == 1:",
"- return 1",
"- if S[h][w] == \".\":",
"- return (dps[h - 1][w] + dps[h][w - 1]) % mod",
"- return 0",
"-",
"-",
"-def solve():",
"- for h in range(1, H + 1):",
"- for w in range(1, W + 1):",
"- dps[h][w] = dp(h, w)",
"- ans = dps[-1][-1]",
"- return ans",
"-",
"-",
"-print((solve()))",
"+dp = [[0] * (W + 1) for _ in range(H + 1)]",
"+dp[1][1] = 1",
"+for h in range(1, H + 1):",
"+ for w in range(1, W + 1):",
"+ if h == 1 and w == 1:",
"+ continue",
"+ if S[h][w] == \"#\":",
"+ continue",
"+ dp[h][w] += dp[h][w - 1] + dp[h - 1][w]",
"+ dp[h][w] %= mod",
"+print((dp[-1][-1]))"
] | false | 0.042963 | 0.042566 | 1.009308 |
[
"s413320178",
"s787720335"
] |
u969850098
|
p02702
|
python
|
s512239024
|
s786850494
| 119 | 103 | 17,912 | 18,056 |
Accepted
|
Accepted
| 13.45 |
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019
def main():
S = list(map(int, list(readline().rstrip())))
N = len(S)
T = [0] * (N+1)
e = 1
for i in range(N-1, -1, -1):
T[i] = (T[i+1] + int(S[i]) * e) % MOD
e = e * 10 % MOD
c = Counter(T)
ans = 0
for k, v in list(c.items()):
ans += (v * (v-1)) // 2
print(ans)
if __name__ == '__main__':
main()
|
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019
def main():
S = list(map(int, list(readline().rstrip())))
N = len(S)
T = [0] * (N+1)
e = 1
for i in range(N-1, -1, -1):
T[i] = (T[i+1] + S[i] * e) % MOD
e = e * 10 % MOD
c = Counter(T)
ans = 0
for k, v in list(c.items()):
ans += (v * (v-1)) // 2
print(ans)
if __name__ == '__main__':
main()
| 23 | 23 | 467 | 462 |
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019
def main():
S = list(map(int, list(readline().rstrip())))
N = len(S)
T = [0] * (N + 1)
e = 1
for i in range(N - 1, -1, -1):
T[i] = (T[i + 1] + int(S[i]) * e) % MOD
e = e * 10 % MOD
c = Counter(T)
ans = 0
for k, v in list(c.items()):
ans += (v * (v - 1)) // 2
print(ans)
if __name__ == "__main__":
main()
|
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 2019
def main():
S = list(map(int, list(readline().rstrip())))
N = len(S)
T = [0] * (N + 1)
e = 1
for i in range(N - 1, -1, -1):
T[i] = (T[i + 1] + S[i] * e) % MOD
e = e * 10 % MOD
c = Counter(T)
ans = 0
for k, v in list(c.items()):
ans += (v * (v - 1)) // 2
print(ans)
if __name__ == "__main__":
main()
| false | 0 |
[
"- T[i] = (T[i + 1] + int(S[i]) * e) % MOD",
"+ T[i] = (T[i + 1] + S[i] * e) % MOD"
] | false | 0.037952 | 0.07437 | 0.510317 |
[
"s512239024",
"s786850494"
] |
u077291787
|
p02984
|
python
|
s786135757
|
s003490076
| 109 | 82 | 14,156 | 19,140 |
Accepted
|
Accepted
| 24.77 |
# ABC133D - Rain Flows into Dams
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
X = [0] * N
cur = sum(A) - 2 * sum(A[1::2])
X[0] = cur
for i, a in enumerate(A[:-1], 1):
X[i] = a * 2 - cur
cur = X[i]
print((*X))
if __name__ == "__main__":
main()
|
# ABC133D - Rain Flows into Dams
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
X = [0] * N
cur = sum(A) - 2 * sum(A[1::2])
X[0] = cur
for i, a in enumerate(A[:-1], 1):
X[i] = a * 2 - cur
cur = X[i]
print((' '.join(map(str, X))))
if __name__ == "__main__":
main()
| 16 | 16 | 331 | 350 |
# ABC133D - Rain Flows into Dams
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
X = [0] * N
cur = sum(A) - 2 * sum(A[1::2])
X[0] = cur
for i, a in enumerate(A[:-1], 1):
X[i] = a * 2 - cur
cur = X[i]
print((*X))
if __name__ == "__main__":
main()
|
# ABC133D - Rain Flows into Dams
def main():
N = int(eval(input()))
A = tuple(map(int, input().split()))
X = [0] * N
cur = sum(A) - 2 * sum(A[1::2])
X[0] = cur
for i, a in enumerate(A[:-1], 1):
X[i] = a * 2 - cur
cur = X[i]
print((" ".join(map(str, X))))
if __name__ == "__main__":
main()
| false | 0 |
[
"- print((*X))",
"+ print((\" \".join(map(str, X))))"
] | false | 0.070886 | 0.115612 | 0.613139 |
[
"s786135757",
"s003490076"
] |
u643679148
|
p02596
|
python
|
s072745573
|
s228559494
| 250 | 230 | 8,980 | 9,168 |
Accepted
|
Accepted
| 8 |
k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
print((-1))
else:
n = 7
cnt = 1
for i in range(k):
if n % k == 0:
break
cnt += 1
n = (n * 10 + 7) % k
print(cnt)
|
# -*- coding: utf-8 -*-
k = int(eval(input()))
ans = 0
n = 7
if k % 2 == 0 or k % 5 == 0:
print((-1))
exit(0)
c = 1
while True:
if n % k == 0:
break
n = (n * 10 + 7) % k
c += 1
print(c)
| 14 | 16 | 228 | 223 |
k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
print((-1))
else:
n = 7
cnt = 1
for i in range(k):
if n % k == 0:
break
cnt += 1
n = (n * 10 + 7) % k
print(cnt)
|
# -*- coding: utf-8 -*-
k = int(eval(input()))
ans = 0
n = 7
if k % 2 == 0 or k % 5 == 0:
print((-1))
exit(0)
c = 1
while True:
if n % k == 0:
break
n = (n * 10 + 7) % k
c += 1
print(c)
| false | 12.5 |
[
"+# -*- coding: utf-8 -*-",
"+ans = 0",
"+n = 7",
"-else:",
"- n = 7",
"- cnt = 1",
"- for i in range(k):",
"- if n % k == 0:",
"- break",
"- cnt += 1",
"- n = (n * 10 + 7) % k",
"- print(cnt)",
"+ exit(0)",
"+c = 1",
"+while True:",
"+ if n % k == 0:",
"+ break",
"+ n = (n * 10 + 7) % k",
"+ c += 1",
"+print(c)"
] | false | 0.126365 | 0.310541 | 0.40692 |
[
"s072745573",
"s228559494"
] |
u633068244
|
p00447
|
python
|
s571226782
|
s514262019
| 1,490 | 760 | 4,484 | 4,424 |
Accepted
|
Accepted
| 48.99 |
while True:
try:
a,da, b = [], [], []
m = int(input())
for i in range(m):
a.append(list(map(int, input().split())))
a = sorted(a)
dax,day = [],[]
for i in range(m):
dax.append(a[i][0]-a[0][0])
day.append(a[i][1]-a[0][1])
n = int(input())
for i in range(n):
b.append(list(map(int, input().split())))
b = sorted(b)
bx,by = [],[]
for i in b:
bx.append(i[0])
by.append(i[1])
for i in range(n-m+1):
for j in range(m):
if bx.count(bx[i]+dax[j]) == 0 or by.count(by[i]+day[j]) == 0:
break
else:
print(bx[i]-a[0][0],by[i]-a[0][1])
break
except:
break
|
while True:
try:
a,da, b = [], [], []
m = int(input())
for i in range(m):
a.append(list(map(int, input().split())))
a = sorted(a)
dax = []
for i in range(m):
dax.append(a[i][0]-a[0][0])
n = int(input())
for i in range(n):
b.append(list(map(int, input().split())))
b = sorted(b)
bx = []
for i in b:
bx.append(i[0])
for i in range(n-m+1):
for j in range(m):
if bx.count(bx[i]+dax[j]) == 0:
break
else:
print(b[i][0]-a[0][0],b[i][1]-a[0][1])
break
except:
break
| 28 | 26 | 848 | 738 |
while True:
try:
a, da, b = [], [], []
m = int(input())
for i in range(m):
a.append(list(map(int, input().split())))
a = sorted(a)
dax, day = [], []
for i in range(m):
dax.append(a[i][0] - a[0][0])
day.append(a[i][1] - a[0][1])
n = int(input())
for i in range(n):
b.append(list(map(int, input().split())))
b = sorted(b)
bx, by = [], []
for i in b:
bx.append(i[0])
by.append(i[1])
for i in range(n - m + 1):
for j in range(m):
if bx.count(bx[i] + dax[j]) == 0 or by.count(by[i] + day[j]) == 0:
break
else:
print(bx[i] - a[0][0], by[i] - a[0][1])
break
except:
break
|
while True:
try:
a, da, b = [], [], []
m = int(input())
for i in range(m):
a.append(list(map(int, input().split())))
a = sorted(a)
dax = []
for i in range(m):
dax.append(a[i][0] - a[0][0])
n = int(input())
for i in range(n):
b.append(list(map(int, input().split())))
b = sorted(b)
bx = []
for i in b:
bx.append(i[0])
for i in range(n - m + 1):
for j in range(m):
if bx.count(bx[i] + dax[j]) == 0:
break
else:
print(b[i][0] - a[0][0], b[i][1] - a[0][1])
break
except:
break
| false | 7.142857 |
[
"- dax, day = [], []",
"+ dax = []",
"- day.append(a[i][1] - a[0][1])",
"- bx, by = [], []",
"+ bx = []",
"- by.append(i[1])",
"- if bx.count(bx[i] + dax[j]) == 0 or by.count(by[i] + day[j]) == 0:",
"+ if bx.count(bx[i] + dax[j]) == 0:",
"- print(bx[i] - a[0][0], by[i] - a[0][1])",
"+ print(b[i][0] - a[0][0], b[i][1] - a[0][1])"
] | false | 0.108892 | 0.039004 | 2.791834 |
[
"s571226782",
"s514262019"
] |
u539367121
|
p02820
|
python
|
s985039932
|
s934919515
| 98 | 69 | 18,252 | 10,000 |
Accepted
|
Accepted
| 29.59 |
N,K=list(map(int,input().split()))
R,S,P=list(map(int,input().split()))
T=eval(input())
G=[[] for n in range(K)]
for n in range(N):
G[n%K].append(T[n])
cnt=0
for g in G:
r,s,p=True,True,True
for g2 in g:
if g2=='r':
if p:
p=False
r,s=True,True
cnt+=P
else:
r,s,p=True,True,True
if g2=='s':
if r:
r=False
p,s=True,True
cnt+=R
else:
r,s,p=True,True,True
if g2=='p':
if s:
s=False
r,p=True,True
cnt+=S
else:
r,s,p=True,True,True
print(cnt)
|
N,K=list(map(int,input().split()))
R,S,P=list(map(int,input().split()))
T=eval(input())
ans=0
chk=[0]*N
for n in range(N):
c=T[n]
if n>=K and T[n-K]==c and chk[n-K]==0:
chk[n]=1 # not used
continue
if c=='r':
ans+=P
elif c=='s':
ans+=R
else:
ans+=S
print(ans)
| 35 | 19 | 605 | 291 |
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
G = [[] for n in range(K)]
for n in range(N):
G[n % K].append(T[n])
cnt = 0
for g in G:
r, s, p = True, True, True
for g2 in g:
if g2 == "r":
if p:
p = False
r, s = True, True
cnt += P
else:
r, s, p = True, True, True
if g2 == "s":
if r:
r = False
p, s = True, True
cnt += R
else:
r, s, p = True, True, True
if g2 == "p":
if s:
s = False
r, p = True, True
cnt += S
else:
r, s, p = True, True, True
print(cnt)
|
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
ans = 0
chk = [0] * N
for n in range(N):
c = T[n]
if n >= K and T[n - K] == c and chk[n - K] == 0:
chk[n] = 1 # not used
continue
if c == "r":
ans += P
elif c == "s":
ans += R
else:
ans += S
print(ans)
| false | 45.714286 |
[
"-G = [[] for n in range(K)]",
"+ans = 0",
"+chk = [0] * N",
"- G[n % K].append(T[n])",
"-cnt = 0",
"-for g in G:",
"- r, s, p = True, True, True",
"- for g2 in g:",
"- if g2 == \"r\":",
"- if p:",
"- p = False",
"- r, s = True, True",
"- cnt += P",
"- else:",
"- r, s, p = True, True, True",
"- if g2 == \"s\":",
"- if r:",
"- r = False",
"- p, s = True, True",
"- cnt += R",
"- else:",
"- r, s, p = True, True, True",
"- if g2 == \"p\":",
"- if s:",
"- s = False",
"- r, p = True, True",
"- cnt += S",
"- else:",
"- r, s, p = True, True, True",
"-print(cnt)",
"+ c = T[n]",
"+ if n >= K and T[n - K] == c and chk[n - K] == 0:",
"+ chk[n] = 1 # not used",
"+ continue",
"+ if c == \"r\":",
"+ ans += P",
"+ elif c == \"s\":",
"+ ans += R",
"+ else:",
"+ ans += S",
"+print(ans)"
] | false | 0.037579 | 0.03721 | 1.0099 |
[
"s985039932",
"s934919515"
] |
u028973125
|
p02936
|
python
|
s756625787
|
s936515343
| 1,891 | 815 | 129,392 | 121,796 |
Accepted
|
Accepted
| 56.9 |
from pprint import pprint
from collections import deque, defaultdict
n, q = list(map(int, input().strip().split(" ")))
edges = [[] for _ in range(n)]
for _ in range(n-1):
a_i, b_i = list(map(int, input().strip().split(" ")))
edges[a_i-1].append(b_i-1)
edges[b_i-1].append(a_i-1)
counter = [0] * n
p = [0] * n
for _ in range(q):
p_i, x_i = list(map(int, input().strip().split(" ")))
counter[p_i-1] += x_i
parents = deque()
parents.append(0)
visited = set()
while parents:
parent = parents.popleft()
if parent in visited:
continue
visited.add(parent)
for child in edges[parent]:
if child in visited:
continue
counter[child] += counter[parent]
# print("child")
# print(child, counter[child])
parents.append(child)
print((" ".join(list(map(str, counter)))))
|
from pprint import pprint
from collections import deque, defaultdict
import sys
# n, q = map(int, input().strip().split(" "))
n, q = list(map(int, sys.stdin.readline().strip().split(" ")))
edges = [[] for _ in range(n)]
for _ in range(n-1):
# a_i, b_i = map(int, input().strip().split(" "))
a_i, b_i = list(map(int, sys.stdin.readline().strip().split(" ")))
edges[a_i-1].append(b_i-1)
edges[b_i-1].append(a_i-1)
counter = [0] * n
p = [0] * n
for _ in range(q):
# p_i, x_i = map(int, input().strip().split(" "))
p_i, x_i = list(map(int, sys.stdin.readline().strip().split(" ")))
counter[p_i-1] += x_i
parents = deque()
parents.append(0)
visited = set()
while parents:
parent = parents.popleft()
if parent in visited:
continue
visited.add(parent)
for child in edges[parent]:
if child in visited:
continue
counter[child] += counter[parent]
# print("child")
# print(child, counter[child])
parents.append(child)
print((" ".join(list(map(str, counter)))))
| 34 | 39 | 867 | 1,077 |
from pprint import pprint
from collections import deque, defaultdict
n, q = list(map(int, input().strip().split(" ")))
edges = [[] for _ in range(n)]
for _ in range(n - 1):
a_i, b_i = list(map(int, input().strip().split(" ")))
edges[a_i - 1].append(b_i - 1)
edges[b_i - 1].append(a_i - 1)
counter = [0] * n
p = [0] * n
for _ in range(q):
p_i, x_i = list(map(int, input().strip().split(" ")))
counter[p_i - 1] += x_i
parents = deque()
parents.append(0)
visited = set()
while parents:
parent = parents.popleft()
if parent in visited:
continue
visited.add(parent)
for child in edges[parent]:
if child in visited:
continue
counter[child] += counter[parent]
# print("child")
# print(child, counter[child])
parents.append(child)
print((" ".join(list(map(str, counter)))))
|
from pprint import pprint
from collections import deque, defaultdict
import sys
# n, q = map(int, input().strip().split(" "))
n, q = list(map(int, sys.stdin.readline().strip().split(" ")))
edges = [[] for _ in range(n)]
for _ in range(n - 1):
# a_i, b_i = map(int, input().strip().split(" "))
a_i, b_i = list(map(int, sys.stdin.readline().strip().split(" ")))
edges[a_i - 1].append(b_i - 1)
edges[b_i - 1].append(a_i - 1)
counter = [0] * n
p = [0] * n
for _ in range(q):
# p_i, x_i = map(int, input().strip().split(" "))
p_i, x_i = list(map(int, sys.stdin.readline().strip().split(" ")))
counter[p_i - 1] += x_i
parents = deque()
parents.append(0)
visited = set()
while parents:
parent = parents.popleft()
if parent in visited:
continue
visited.add(parent)
for child in edges[parent]:
if child in visited:
continue
counter[child] += counter[parent]
# print("child")
# print(child, counter[child])
parents.append(child)
print((" ".join(list(map(str, counter)))))
| false | 12.820513 |
[
"+import sys",
"-n, q = list(map(int, input().strip().split(\" \")))",
"+# n, q = map(int, input().strip().split(\" \"))",
"+n, q = list(map(int, sys.stdin.readline().strip().split(\" \")))",
"- a_i, b_i = list(map(int, input().strip().split(\" \")))",
"+ # a_i, b_i = map(int, input().strip().split(\" \"))",
"+ a_i, b_i = list(map(int, sys.stdin.readline().strip().split(\" \")))",
"- p_i, x_i = list(map(int, input().strip().split(\" \")))",
"+ # p_i, x_i = map(int, input().strip().split(\" \"))",
"+ p_i, x_i = list(map(int, sys.stdin.readline().strip().split(\" \")))"
] | false | 0.037817 | 0.045697 | 0.827562 |
[
"s756625787",
"s936515343"
] |
u271934630
|
p02843
|
python
|
s988558816
|
s666327842
| 185 | 30 | 102,548 | 2,940 |
Accepted
|
Accepted
| 83.78 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
X = int(eval(input()))
l = []
for i in range(1001):
l.extend(list(range(i*100, 105*i+1)))
if X in l:
print((1))
else:
print((0))
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
X = int(eval(input()))
for i in range(100000):
if 100 * i <= X <= 100 * i + 5 * i:
print((1))
exit()
print((0))
| 15 | 12 | 218 | 205 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
X = int(eval(input()))
l = []
for i in range(1001):
l.extend(list(range(i * 100, 105 * i + 1)))
if X in l:
print((1))
else:
print((0))
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
X = int(eval(input()))
for i in range(100000):
if 100 * i <= X <= 100 * i + 5 * i:
print((1))
exit()
print((0))
| false | 20 |
[
"-l = []",
"-for i in range(1001):",
"- l.extend(list(range(i * 100, 105 * i + 1)))",
"-if X in l:",
"- print((1))",
"-else:",
"- print((0))",
"+for i in range(100000):",
"+ if 100 * i <= X <= 100 * i + 5 * i:",
"+ print((1))",
"+ exit()",
"+print((0))"
] | false | 0.738818 | 0.046677 | 15.828344 |
[
"s988558816",
"s666327842"
] |
u245870380
|
p03673
|
python
|
s896913764
|
s087500339
| 384 | 242 | 26,180 | 26,020 |
Accepted
|
Accepted
| 36.98 |
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
if i % 2 == 0:
b[n//2+i//2] = a[i]
else:
b[n//2-i//2-1] = a[i]
if n % 2 == 1:
b = b[::-1]
if len(b) == 1:
print(b[0])
else:
for i in range(len(b)-1):
print(b[i], end=" ")
print(b[i+1])
|
n = int(eval(input()))
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
if i % 2 == 0:
b[n//2+i//2] = a[i]
else:
b[n//2-i//2-1] = a[i]
if n % 2 == 1:
print((*b[::-1]))
else:
print((*b))
| 19 | 13 | 343 | 236 |
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n):
if i % 2 == 0:
b[n // 2 + i // 2] = a[i]
else:
b[n // 2 - i // 2 - 1] = a[i]
if n % 2 == 1:
b = b[::-1]
if len(b) == 1:
print(b[0])
else:
for i in range(len(b) - 1):
print(b[i], end=" ")
print(b[i + 1])
|
n = int(eval(input()))
a = list(map(int, input().split()))
b = [0] * n
for i in range(n):
if i % 2 == 0:
b[n // 2 + i // 2] = a[i]
else:
b[n // 2 - i // 2 - 1] = a[i]
if n % 2 == 1:
print((*b[::-1]))
else:
print((*b))
| false | 31.578947 |
[
"-n = int(input())",
"+n = int(eval(input()))",
"- b = b[::-1]",
"-if len(b) == 1:",
"- print(b[0])",
"+ print((*b[::-1]))",
"- for i in range(len(b) - 1):",
"- print(b[i], end=\" \")",
"- print(b[i + 1])",
"+ print((*b))"
] | false | 0.048188 | 0.086474 | 0.557255 |
[
"s896913764",
"s087500339"
] |
u440566786
|
p03576
|
python
|
s359024529
|
s605131776
| 1,409 | 318 | 47,068 | 46,428 |
Accepted
|
Accepted
| 77.43 |
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
n,k=list(map(int,input().split()))
X=[0]*n
Y=[0]*n
for i in range(n):
X[i],Y[i]=list(map(int,input().split()))
ans=INF
for a in range(n):
for b in range(n):
for c in range(a+1,n):
for d in range(b+1):
x0,x1=sorted([X[a],X[c]])
y0,y1=sorted([Y[b],Y[d]])
count=0
for i in range(n):
if x0<=X[i]<=x1 and y0<=Y[i]<=y1:
count+=1
if count>=k:
ans=min(ans,(x1-x0)*(y1-y0))
print(ans)
resolve()
|
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
from itertools import product
n,k=list(map(int,input().split()))
X=[0]*n
Y=[0]*n
XY=[0]*n
for i in range(n):
x,y=list(map(int,input().split()))
X[i]=x
Y[i]=y
XY[i]=(x,y)
# 2-dim cumsum (pivot=(-inf,-inf))
S=[[0]*n for _ in range(n)]
X.sort(); Y.sort()
for i,j in product(list(range(n)),repeat=2):
for x,y in XY:
if x<=X[i] and y<=Y[j]: S[i][j]+=1
# calculate
ans=INF
for i0,j0 in product(list(range(n)),repeat=2):
for i1,j1 in product(list(range(i0+1,n)),list(range(j0+1,n))):
count=S[i1][j1]
if i0>0: count-=S[i0-1][j1]
if j0>0: count-=S[i1][j0-1]
if i0>0 and j0>0: count+=S[i0-1][j0-1]
if count>=k:
ans=min(ans,(X[i1]-X[i0])*(Y[j1]-Y[j0]))
print(ans)
resolve()
| 26 | 34 | 760 | 965 |
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = sys.stdin.readline
def resolve():
n, k = list(map(int, input().split()))
X = [0] * n
Y = [0] * n
for i in range(n):
X[i], Y[i] = list(map(int, input().split()))
ans = INF
for a in range(n):
for b in range(n):
for c in range(a + 1, n):
for d in range(b + 1):
x0, x1 = sorted([X[a], X[c]])
y0, y1 = sorted([Y[b], Y[d]])
count = 0
for i in range(n):
if x0 <= X[i] <= x1 and y0 <= Y[i] <= y1:
count += 1
if count >= k:
ans = min(ans, (x1 - x0) * (y1 - y0))
print(ans)
resolve()
|
import sys
sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = sys.stdin.readline
def resolve():
from itertools import product
n, k = list(map(int, input().split()))
X = [0] * n
Y = [0] * n
XY = [0] * n
for i in range(n):
x, y = list(map(int, input().split()))
X[i] = x
Y[i] = y
XY[i] = (x, y)
# 2-dim cumsum (pivot=(-inf,-inf))
S = [[0] * n for _ in range(n)]
X.sort()
Y.sort()
for i, j in product(list(range(n)), repeat=2):
for x, y in XY:
if x <= X[i] and y <= Y[j]:
S[i][j] += 1
# calculate
ans = INF
for i0, j0 in product(list(range(n)), repeat=2):
for i1, j1 in product(list(range(i0 + 1, n)), list(range(j0 + 1, n))):
count = S[i1][j1]
if i0 > 0:
count -= S[i0 - 1][j1]
if j0 > 0:
count -= S[i1][j0 - 1]
if i0 > 0 and j0 > 0:
count += S[i0 - 1][j0 - 1]
if count >= k:
ans = min(ans, (X[i1] - X[i0]) * (Y[j1] - Y[j0]))
print(ans)
resolve()
| false | 23.529412 |
[
"+ from itertools import product",
"+",
"+ XY = [0] * n",
"- X[i], Y[i] = list(map(int, input().split()))",
"+ x, y = list(map(int, input().split()))",
"+ X[i] = x",
"+ Y[i] = y",
"+ XY[i] = (x, y)",
"+ # 2-dim cumsum (pivot=(-inf,-inf))",
"+ S = [[0] * n for _ in range(n)]",
"+ X.sort()",
"+ Y.sort()",
"+ for i, j in product(list(range(n)), repeat=2):",
"+ for x, y in XY:",
"+ if x <= X[i] and y <= Y[j]:",
"+ S[i][j] += 1",
"+ # calculate",
"- for a in range(n):",
"- for b in range(n):",
"- for c in range(a + 1, n):",
"- for d in range(b + 1):",
"- x0, x1 = sorted([X[a], X[c]])",
"- y0, y1 = sorted([Y[b], Y[d]])",
"- count = 0",
"- for i in range(n):",
"- if x0 <= X[i] <= x1 and y0 <= Y[i] <= y1:",
"- count += 1",
"- if count >= k:",
"- ans = min(ans, (x1 - x0) * (y1 - y0))",
"+ for i0, j0 in product(list(range(n)), repeat=2):",
"+ for i1, j1 in product(list(range(i0 + 1, n)), list(range(j0 + 1, n))):",
"+ count = S[i1][j1]",
"+ if i0 > 0:",
"+ count -= S[i0 - 1][j1]",
"+ if j0 > 0:",
"+ count -= S[i1][j0 - 1]",
"+ if i0 > 0 and j0 > 0:",
"+ count += S[i0 - 1][j0 - 1]",
"+ if count >= k:",
"+ ans = min(ans, (X[i1] - X[i0]) * (Y[j1] - Y[j0]))"
] | false | 0.041961 | 0.041968 | 0.999839 |
[
"s359024529",
"s605131776"
] |
u701513230
|
p02629
|
python
|
s160312225
|
s705875566
| 30 | 27 | 9,064 | 9,148 |
Accepted
|
Accepted
| 10 |
N = int(eval(input()))
ans = ""
while N>0:
N -= 1
num = N%26
ans += chr(ord("a")+num)
N //= 26
print((ans[::-1]))
|
N = int(eval(input()))
ans = ""
while N > 0:
N -= 1
ans += chr(ord("a")+(N%26))
N //= 26
print((ans[::-1]))
| 10 | 9 | 126 | 117 |
N = int(eval(input()))
ans = ""
while N > 0:
N -= 1
num = N % 26
ans += chr(ord("a") + num)
N //= 26
print((ans[::-1]))
|
N = int(eval(input()))
ans = ""
while N > 0:
N -= 1
ans += chr(ord("a") + (N % 26))
N //= 26
print((ans[::-1]))
| false | 10 |
[
"- num = N % 26",
"- ans += chr(ord(\"a\") + num)",
"+ ans += chr(ord(\"a\") + (N % 26))"
] | false | 0.042816 | 0.043144 | 0.992403 |
[
"s160312225",
"s705875566"
] |
u063052907
|
p03556
|
python
|
s462447589
|
s247315316
| 30 | 18 | 2,940 | 2,940 |
Accepted
|
Accepted
| 40 |
# coding: utf-8
N = int(eval(input()))
for i in range(1,N+1):
if N == 1:
print((1))
break
if i**2 > N:
print(((i-1)**2))
break
|
# coding: utf-8
import math
N = int(eval(input()))
n = int(math.sqrt(N))
print((n ** 2))
| 9 | 5 | 164 | 84 |
# coding: utf-8
N = int(eval(input()))
for i in range(1, N + 1):
if N == 1:
print((1))
break
if i**2 > N:
print(((i - 1) ** 2))
break
|
# coding: utf-8
import math
N = int(eval(input()))
n = int(math.sqrt(N))
print((n**2))
| false | 44.444444 |
[
"+import math",
"+",
"-for i in range(1, N + 1):",
"- if N == 1:",
"- print((1))",
"- break",
"- if i**2 > N:",
"- print(((i - 1) ** 2))",
"- break",
"+n = int(math.sqrt(N))",
"+print((n**2))"
] | false | 0.043005 | 0.104946 | 0.40978 |
[
"s462447589",
"s247315316"
] |
u488401358
|
p02936
|
python
|
s970136853
|
s209951192
| 1,917 | 910 | 111,308 | 103,684 |
Accepted
|
Accepted
| 52.53 |
import heapq as h
N,Q=list(map(int,input().split()))
a=[0 for i in range(0,N-1)]
b=[0 for i in range(0,N-1)]
for i in range(0,N-1):
a[i],b[i]=list(map(int,input().split()))
p=[0 for i in range(0,Q)]
x=[0 for i in range(0,Q)]
for i in range(0,Q):
p[i],x[i]=list(map(int,input().split()))
hen=[[] for i in range(0,N+1)]
for i in range(0,N-1):
hen[a[i]].append(b[i])
hen[b[i]].append(a[i])
subscore=[0 for i in range(0,N+1)]
for i in range(0,Q):
subscore[p[i]]+=x[i]
ans=[0 for i in range(0,N+1)]
flag=[0 for i in range(0,N+1)]
q=[]
q.append(1)
h.heapify(q)
sub=[]
h.heapify(sub)
while q!=[]:
while q!=[]:
x=h.heappop(q)
ans[x]+=subscore[x]
flag[x]=1
for p in hen[x]:
if flag[p]==0:
h.heappush(sub,p)
ans[p]=ans[x]
if q==[]:
q=sub
sub=[]
h.heapify(sub)
break
ans[0]=-1
ans.remove(-1)
print((*ans))
|
import heapq as h
import sys
input=sys.stdin.readline
N,Q=list(map(int,input().split()))
a=[0 for i in range(0,N-1)]
b=[0 for i in range(0,N-1)]
for i in range(0,N-1):
a[i],b[i]=list(map(int,input().split()))
p=[0 for i in range(0,Q)]
x=[0 for i in range(0,Q)]
for i in range(0,Q):
p[i],x[i]=list(map(int,input().split()))
hen=[[] for i in range(0,N+1)]
for i in range(0,N-1):
hen[a[i]].append(b[i])
hen[b[i]].append(a[i])
subscore=[0 for i in range(0,N+1)]
for i in range(0,Q):
subscore[p[i]]+=x[i]
ans=[0 for i in range(0,N+1)]
flag=[0 for i in range(0,N+1)]
q=[]
q.append(1)
h.heapify(q)
sub=[]
h.heapify(sub)
while q!=[]:
while q!=[]:
x=h.heappop(q)
ans[x]+=subscore[x]
flag[x]=1
for p in hen[x]:
if flag[p]==0:
h.heappush(sub,p)
ans[p]=ans[x]
if q==[]:
q=sub
sub=[]
h.heapify(sub)
break
ans[0]=-1
ans.remove(-1)
print((*ans))
| 43 | 46 | 975 | 1,014 |
import heapq as h
N, Q = list(map(int, input().split()))
a = [0 for i in range(0, N - 1)]
b = [0 for i in range(0, N - 1)]
for i in range(0, N - 1):
a[i], b[i] = list(map(int, input().split()))
p = [0 for i in range(0, Q)]
x = [0 for i in range(0, Q)]
for i in range(0, Q):
p[i], x[i] = list(map(int, input().split()))
hen = [[] for i in range(0, N + 1)]
for i in range(0, N - 1):
hen[a[i]].append(b[i])
hen[b[i]].append(a[i])
subscore = [0 for i in range(0, N + 1)]
for i in range(0, Q):
subscore[p[i]] += x[i]
ans = [0 for i in range(0, N + 1)]
flag = [0 for i in range(0, N + 1)]
q = []
q.append(1)
h.heapify(q)
sub = []
h.heapify(sub)
while q != []:
while q != []:
x = h.heappop(q)
ans[x] += subscore[x]
flag[x] = 1
for p in hen[x]:
if flag[p] == 0:
h.heappush(sub, p)
ans[p] = ans[x]
if q == []:
q = sub
sub = []
h.heapify(sub)
break
ans[0] = -1
ans.remove(-1)
print((*ans))
|
import heapq as h
import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
a = [0 for i in range(0, N - 1)]
b = [0 for i in range(0, N - 1)]
for i in range(0, N - 1):
a[i], b[i] = list(map(int, input().split()))
p = [0 for i in range(0, Q)]
x = [0 for i in range(0, Q)]
for i in range(0, Q):
p[i], x[i] = list(map(int, input().split()))
hen = [[] for i in range(0, N + 1)]
for i in range(0, N - 1):
hen[a[i]].append(b[i])
hen[b[i]].append(a[i])
subscore = [0 for i in range(0, N + 1)]
for i in range(0, Q):
subscore[p[i]] += x[i]
ans = [0 for i in range(0, N + 1)]
flag = [0 for i in range(0, N + 1)]
q = []
q.append(1)
h.heapify(q)
sub = []
h.heapify(sub)
while q != []:
while q != []:
x = h.heappop(q)
ans[x] += subscore[x]
flag[x] = 1
for p in hen[x]:
if flag[p] == 0:
h.heappush(sub, p)
ans[p] = ans[x]
if q == []:
q = sub
sub = []
h.heapify(sub)
break
ans[0] = -1
ans.remove(-1)
print((*ans))
| false | 6.521739 |
[
"+import sys",
"+input = sys.stdin.readline"
] | false | 0.076641 | 0.046102 | 1.662402 |
[
"s970136853",
"s209951192"
] |
u930705402
|
p03212
|
python
|
s798350925
|
s121042790
| 69 | 46 | 6,380 | 5,144 |
Accepted
|
Accepted
| 33.33 |
import itertools
N=int(eval(input()))
l=len(str(N))
s=set()
S='753'
for i in range(1,l+1):
for j in itertools.product(S,repeat=i):
s.add(int(''.join(j)))
li=sorted(s)
cnt=0
for i in range(len(li)):
if(li[i]>N):
break
if('7' in str(li[i]) and '5' in str(li[i]) and '3' in str(li[i])):
cnt+=1
print(cnt)
|
c='753'
def dfs(s,L):
global c
li.append(s)
if(len(s)==L):
return
for i in range(3):
dfs(s+c[i],L)
N=int(eval(input()))
L=len(str(N))
li=[]
dfs('',L)
ans=0
for x in li:
if(x==''):
continue
if(int(x)<=N and '7' in x and '5' in x and '3' in x):
ans+=1
print(ans)
| 16 | 20 | 346 | 330 |
import itertools
N = int(eval(input()))
l = len(str(N))
s = set()
S = "753"
for i in range(1, l + 1):
for j in itertools.product(S, repeat=i):
s.add(int("".join(j)))
li = sorted(s)
cnt = 0
for i in range(len(li)):
if li[i] > N:
break
if "7" in str(li[i]) and "5" in str(li[i]) and "3" in str(li[i]):
cnt += 1
print(cnt)
|
c = "753"
def dfs(s, L):
global c
li.append(s)
if len(s) == L:
return
for i in range(3):
dfs(s + c[i], L)
N = int(eval(input()))
L = len(str(N))
li = []
dfs("", L)
ans = 0
for x in li:
if x == "":
continue
if int(x) <= N and "7" in x and "5" in x and "3" in x:
ans += 1
print(ans)
| false | 20 |
[
"-import itertools",
"+c = \"753\"",
"+",
"+",
"+def dfs(s, L):",
"+ global c",
"+ li.append(s)",
"+ if len(s) == L:",
"+ return",
"+ for i in range(3):",
"+ dfs(s + c[i], L)",
"+",
"-l = len(str(N))",
"-s = set()",
"-S = \"753\"",
"-for i in range(1, l + 1):",
"- for j in itertools.product(S, repeat=i):",
"- s.add(int(\"\".join(j)))",
"-li = sorted(s)",
"-cnt = 0",
"-for i in range(len(li)):",
"- if li[i] > N:",
"- break",
"- if \"7\" in str(li[i]) and \"5\" in str(li[i]) and \"3\" in str(li[i]):",
"- cnt += 1",
"-print(cnt)",
"+L = len(str(N))",
"+li = []",
"+dfs(\"\", L)",
"+ans = 0",
"+for x in li:",
"+ if x == \"\":",
"+ continue",
"+ if int(x) <= N and \"7\" in x and \"5\" in x and \"3\" in x:",
"+ ans += 1",
"+print(ans)"
] | false | 0.060092 | 0.130914 | 0.459017 |
[
"s798350925",
"s121042790"
] |
u598296382
|
p02598
|
python
|
s693960840
|
s476042665
| 1,450 | 172 | 104,968 | 104,248 |
Accepted
|
Accepted
| 88.14 |
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
# xは求める長さ
def C(x):
num = 0
for i in range(n):
# (a[i]-1)//x 回切る必要がある
num += (l[i]-1)//x
# k回以内に収まるか
return num <= k
lb,ub = 0,max(l)
for i in range(100):
mid = (lb + ub) / 2
# 条件を満たすならxを小さくしていく
if C(mid):
ub = mid
else:
lb = mid
# print(lb,ub)
import math
ans = math.ceil(ub)
print(ans)
|
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
# xは求める長さ
def C(x):
num = 0
for i in range(n):
# (a[i]-1)//x 回切る必要がある
num += (l[i]-1)//x
# k回以内に収まるか
return num <= k
lb,ub = 0,max(l)
while ub-lb > 1:
mid = (lb + ub + 1) // 2
# 条件を満たすならxを小さくしていく
if C(mid):
ub = mid
else:
lb = mid
# print(lb,ub)
print(ub)
| 25 | 23 | 448 | 414 |
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
# xは求める長さ
def C(x):
num = 0
for i in range(n):
# (a[i]-1)//x 回切る必要がある
num += (l[i] - 1) // x
# k回以内に収まるか
return num <= k
lb, ub = 0, max(l)
for i in range(100):
mid = (lb + ub) / 2
# 条件を満たすならxを小さくしていく
if C(mid):
ub = mid
else:
lb = mid
# print(lb,ub)
import math
ans = math.ceil(ub)
print(ans)
|
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
# xは求める長さ
def C(x):
num = 0
for i in range(n):
# (a[i]-1)//x 回切る必要がある
num += (l[i] - 1) // x
# k回以内に収まるか
return num <= k
lb, ub = 0, max(l)
while ub - lb > 1:
mid = (lb + ub + 1) // 2
# 条件を満たすならxを小さくしていく
if C(mid):
ub = mid
else:
lb = mid
# print(lb,ub)
print(ub)
| false | 8 |
[
"-for i in range(100):",
"- mid = (lb + ub) / 2",
"+while ub - lb > 1:",
"+ mid = (lb + ub + 1) // 2",
"-import math",
"-",
"-ans = math.ceil(ub)",
"-print(ans)",
"+print(ub)"
] | false | 0.041304 | 0.05566 | 0.742069 |
[
"s693960840",
"s476042665"
] |
u998435601
|
p02396
|
python
|
s387196524
|
s673294606
| 140 | 50 | 6,268 | 6,632 |
Accepted
|
Accepted
| 64.29 |
i = 1
a = eval(input())
while a != 0:
print("Case %d: %d" % (i, a))
i = i + 1
a = eval(input())
|
lis = []
a = int(input())
while a != 0:
lis.append(a)
a = int(input())
for i,v in enumerate(lis):
print("Case %d: %d" % (i+1,v))
| 6 | 8 | 90 | 146 |
i = 1
a = eval(input())
while a != 0:
print("Case %d: %d" % (i, a))
i = i + 1
a = eval(input())
|
lis = []
a = int(input())
while a != 0:
lis.append(a)
a = int(input())
for i, v in enumerate(lis):
print("Case %d: %d" % (i + 1, v))
| false | 25 |
[
"-i = 1",
"-a = eval(input())",
"+lis = []",
"+a = int(input())",
"- print(\"Case %d: %d\" % (i, a))",
"- i = i + 1",
"- a = eval(input())",
"+ lis.append(a)",
"+ a = int(input())",
"+for i, v in enumerate(lis):",
"+ print(\"Case %d: %d\" % (i + 1, v))"
] | false | 0.039455 | 0.040255 | 0.98012 |
[
"s387196524",
"s673294606"
] |
u588341295
|
p03450
|
python
|
s618203631
|
s329555544
| 1,756 | 922 | 143,732 | 11,600 |
Accepted
|
Accepted
| 47.49 |
# -*- coding: utf-8 -*-
"""
参考:https://www.hamayanhamayan.com/entry/2018/01/28/231916
・深さ優先
・幅優先とほとんど一緒だけど練習用にこっちも書いた。
"""
import sys
# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)
N, M = list(map(int, input().split()))
l_edges = [[] for i in range(N)]
r_edges = [[] for i in range(N)]
for i in range(M):
l, r, d = list(map(int, input().split()))
l_edges[l-1].append((r-1, d))
r_edges[r-1].append((l-1, d))
# 訪問済メモ
visited = [0] * N
def dfs(cur):
visited[cur] = 1
# 左から見た右側を確認
for r, d in l_edges[cur]:
# 訪問済なら矛盾がないか検証する
if visited[r]:
if pos[r] - pos[cur] != d:
print('No')
exit()
# 未訪問なら今回の情報を記録する
else:
visited[r] = 1
pos[r] = pos[cur] + d
# 確認した位置を次の現在位置として見に行く
dfs(r)
# 右から見た左側を確認
for l, d in r_edges[cur]:
if visited[l]:
if pos[cur] - pos[l] != d:
print('No')
exit()
else:
visited[l] = 1
pos[l] = pos[cur] - d
dfs(l)
for i in range(N):
# 訪問済(確認済)でなければ走破しに行く
if not visited[i]:
# この開始位置を基準とした相対位置を記録する
pos = {i: 0}
dfs(i)
pos = {}
# 最後まで矛盾がなければOK
print('Yes')
|
# -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
class WeightedUnionFind:
""" 重み付きUnion-Find木 """
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
# 根への距離を管理
self.weight = [0] * (n+1)
def find(self, x):
""" 検索 """
if self.par[x] == x:
return x
else:
y = self.find(self.par[x])
# 親への重みを追加しながら根まで走査
self.weight[x] += self.weight[self.par[x]]
self.par[x] = y
return y
def union(self, x, y, w):
""" 併合 """
rx = self.find(x)
ry = self.find(y)
# xの木の高さ < yの木の高さ
if self.rank[rx] < self.rank[ry]:
self.par[rx] = ry
self.weight[rx] = w - self.weight[x] + self.weight[y]
# xの木の高さ ≧ yの木の高さ
else:
self.par[ry] = rx
self.weight[ry] = - w - self.weight[y] + self.weight[x]
# 木の高さが同じだった場合の処理
if self.rank[rx] == self.rank[ry]:
self.rank[rx] += 1
def same(self, x, y):
""" 同じ集合に属するか """
return self.find(x) == self.find(y)
def diff(self, x, y):
""" xからyへのコスト """
return self.weight[x] - self.weight[y]
N, M = MAP()
wuf = WeightedUnionFind(N)
for i in range(M):
l, r, d = MAP()
# 既に同じ集合にあるなら、距離が正しいか確認
if wuf.same(l, r):
if wuf.diff(l, r) != d:
No()
exit()
else:
wuf.union(l, r, d)
Yes()
| 60 | 76 | 1,321 | 2,198 |
# -*- coding: utf-8 -*-
"""
参考:https://www.hamayanhamayan.com/entry/2018/01/28/231916
・深さ優先
・幅優先とほとんど一緒だけど練習用にこっちも書いた。
"""
import sys
# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10**9)
N, M = list(map(int, input().split()))
l_edges = [[] for i in range(N)]
r_edges = [[] for i in range(N)]
for i in range(M):
l, r, d = list(map(int, input().split()))
l_edges[l - 1].append((r - 1, d))
r_edges[r - 1].append((l - 1, d))
# 訪問済メモ
visited = [0] * N
def dfs(cur):
visited[cur] = 1
# 左から見た右側を確認
for r, d in l_edges[cur]:
# 訪問済なら矛盾がないか検証する
if visited[r]:
if pos[r] - pos[cur] != d:
print("No")
exit()
# 未訪問なら今回の情報を記録する
else:
visited[r] = 1
pos[r] = pos[cur] + d
# 確認した位置を次の現在位置として見に行く
dfs(r)
# 右から見た左側を確認
for l, d in r_edges[cur]:
if visited[l]:
if pos[cur] - pos[l] != d:
print("No")
exit()
else:
visited[l] = 1
pos[l] = pos[cur] - d
dfs(l)
for i in range(N):
# 訪問済(確認済)でなければ走破しに行く
if not visited[i]:
# この開始位置を基準とした相対位置を記録する
pos = {i: 0}
dfs(i)
pos = {}
# 最後まで矛盾がなければOK
print("Yes")
|
# -*- coding: utf-8 -*-
import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7
class WeightedUnionFind:
"""重み付きUnion-Find木"""
def __init__(self, n):
self.par = [i for i in range(n + 1)]
self.rank = [0] * (n + 1)
# 根への距離を管理
self.weight = [0] * (n + 1)
def find(self, x):
"""検索"""
if self.par[x] == x:
return x
else:
y = self.find(self.par[x])
# 親への重みを追加しながら根まで走査
self.weight[x] += self.weight[self.par[x]]
self.par[x] = y
return y
def union(self, x, y, w):
"""併合"""
rx = self.find(x)
ry = self.find(y)
# xの木の高さ < yの木の高さ
if self.rank[rx] < self.rank[ry]:
self.par[rx] = ry
self.weight[rx] = w - self.weight[x] + self.weight[y]
# xの木の高さ ≧ yの木の高さ
else:
self.par[ry] = rx
self.weight[ry] = -w - self.weight[y] + self.weight[x]
# 木の高さが同じだった場合の処理
if self.rank[rx] == self.rank[ry]:
self.rank[rx] += 1
def same(self, x, y):
"""同じ集合に属するか"""
return self.find(x) == self.find(y)
def diff(self, x, y):
"""xからyへのコスト"""
return self.weight[x] - self.weight[y]
N, M = MAP()
wuf = WeightedUnionFind(N)
for i in range(M):
l, r, d = MAP()
# 既に同じ集合にあるなら、距離が正しいか確認
if wuf.same(l, r):
if wuf.diff(l, r) != d:
No()
exit()
else:
wuf.union(l, r, d)
Yes()
| false | 21.052632 |
[
"-\"\"\"",
"-参考:https://www.hamayanhamayan.com/entry/2018/01/28/231916",
"-・深さ優先",
"-・幅優先とほとんど一緒だけど練習用にこっちも書いた。",
"-\"\"\"",
"-# 再帰呼び出しの回数制限(デフォルト1000)",
"-sys.setrecursionlimit(10**9)",
"-N, M = list(map(int, input().split()))",
"-l_edges = [[] for i in range(N)]",
"-r_edges = [[] for i in range(N)]",
"-for i in range(M):",
"- l, r, d = list(map(int, input().split()))",
"- l_edges[l - 1].append((r - 1, d))",
"- r_edges[r - 1].append((l - 1, d))",
"-# 訪問済メモ",
"-visited = [0] * N",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"-def dfs(cur):",
"- visited[cur] = 1",
"- # 左から見た右側を確認",
"- for r, d in l_edges[cur]:",
"- # 訪問済なら矛盾がないか検証する",
"- if visited[r]:",
"- if pos[r] - pos[cur] != d:",
"- print(\"No\")",
"- exit()",
"- # 未訪問なら今回の情報を記録する",
"- else:",
"- visited[r] = 1",
"- pos[r] = pos[cur] + d",
"- # 確認した位置を次の現在位置として見に行く",
"- dfs(r)",
"- # 右から見た左側を確認",
"- for l, d in r_edges[cur]:",
"- if visited[l]:",
"- if pos[cur] - pos[l] != d:",
"- print(\"No\")",
"- exit()",
"- else:",
"- visited[l] = 1",
"- pos[l] = pos[cur] - d",
"- dfs(l)",
"+def list2d(a, b, c):",
"+ return [[c] * b for i in range(a)]",
"-for i in range(N):",
"- # 訪問済(確認済)でなければ走破しに行く",
"- if not visited[i]:",
"- # この開始位置を基準とした相対位置を記録する",
"- pos = {i: 0}",
"- dfs(i)",
"- pos = {}",
"-# 最後まで矛盾がなければOK",
"-print(\"Yes\")",
"+def list3d(a, b, c, d):",
"+ return [[[d] * c for j in range(b)] for i in range(a)]",
"+",
"+",
"+def list4d(a, b, c, d, e):",
"+ return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]",
"+",
"+",
"+def ceil(x, y=1):",
"+ return int(-(-x // y))",
"+",
"+",
"+def INT():",
"+ return int(eval(input()))",
"+",
"+",
"+def MAP():",
"+ return list(map(int, input().split()))",
"+",
"+",
"+def LIST(N=None):",
"+ return list(MAP()) if N is None else [INT() for i in range(N)]",
"+",
"+",
"+def Yes():",
"+ print(\"Yes\")",
"+",
"+",
"+def No():",
"+ print(\"No\")",
"+",
"+",
"+def YES():",
"+ print(\"YES\")",
"+",
"+",
"+def NO():",
"+ print(\"NO\")",
"+",
"+",
"+sys.setrecursionlimit(10**9)",
"+INF = 10**18",
"+MOD = 10**9 + 7",
"+",
"+",
"+class WeightedUnionFind:",
"+ \"\"\"重み付きUnion-Find木\"\"\"",
"+",
"+ def __init__(self, n):",
"+ self.par = [i for i in range(n + 1)]",
"+ self.rank = [0] * (n + 1)",
"+ # 根への距離を管理",
"+ self.weight = [0] * (n + 1)",
"+",
"+ def find(self, x):",
"+ \"\"\"検索\"\"\"",
"+ if self.par[x] == x:",
"+ return x",
"+ else:",
"+ y = self.find(self.par[x])",
"+ # 親への重みを追加しながら根まで走査",
"+ self.weight[x] += self.weight[self.par[x]]",
"+ self.par[x] = y",
"+ return y",
"+",
"+ def union(self, x, y, w):",
"+ \"\"\"併合\"\"\"",
"+ rx = self.find(x)",
"+ ry = self.find(y)",
"+ # xの木の高さ < yの木の高さ",
"+ if self.rank[rx] < self.rank[ry]:",
"+ self.par[rx] = ry",
"+ self.weight[rx] = w - self.weight[x] + self.weight[y]",
"+ # xの木の高さ ≧ yの木の高さ",
"+ else:",
"+ self.par[ry] = rx",
"+ self.weight[ry] = -w - self.weight[y] + self.weight[x]",
"+ # 木の高さが同じだった場合の処理",
"+ if self.rank[rx] == self.rank[ry]:",
"+ self.rank[rx] += 1",
"+",
"+ def same(self, x, y):",
"+ \"\"\"同じ集合に属するか\"\"\"",
"+ return self.find(x) == self.find(y)",
"+",
"+ def diff(self, x, y):",
"+ \"\"\"xからyへのコスト\"\"\"",
"+ return self.weight[x] - self.weight[y]",
"+",
"+",
"+N, M = MAP()",
"+wuf = WeightedUnionFind(N)",
"+for i in range(M):",
"+ l, r, d = MAP()",
"+ # 既に同じ集合にあるなら、距離が正しいか確認",
"+ if wuf.same(l, r):",
"+ if wuf.diff(l, r) != d:",
"+ No()",
"+ exit()",
"+ else:",
"+ wuf.union(l, r, d)",
"+Yes()"
] | false | 0.045332 | 0.085554 | 0.529858 |
[
"s618203631",
"s329555544"
] |
u810288681
|
p03254
|
python
|
s908984472
|
s077525048
| 20 | 17 | 3,060 | 2,940 |
Accepted
|
Accepted
| 15 |
n,x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
ans = 0
if x<min(a):
ans = 0
elif x>sum(a):
ans = n-1
else:
for i in range(1,n+1):
if x>=sum(a[:i]):
ans+=1
else:
break
print(ans)
|
n,x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
ans = 0
for i in a:
if x>=i:
ans+=1
x-=i
print((ans-1 if ans==n and x>0 else ans))
| 14 | 8 | 279 | 183 |
n, x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
ans = 0
if x < min(a):
ans = 0
elif x > sum(a):
ans = n - 1
else:
for i in range(1, n + 1):
if x >= sum(a[:i]):
ans += 1
else:
break
print(ans)
|
n, x = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
ans = 0
for i in a:
if x >= i:
ans += 1
x -= i
print((ans - 1 if ans == n and x > 0 else ans))
| false | 42.857143 |
[
"-if x < min(a):",
"- ans = 0",
"-elif x > sum(a):",
"- ans = n - 1",
"-else:",
"- for i in range(1, n + 1):",
"- if x >= sum(a[:i]):",
"- ans += 1",
"- else:",
"- break",
"-print(ans)",
"+for i in a:",
"+ if x >= i:",
"+ ans += 1",
"+ x -= i",
"+print((ans - 1 if ans == n and x > 0 else ans))"
] | false | 0.118522 | 0.126485 | 0.937043 |
[
"s908984472",
"s077525048"
] |
u630511239
|
p02959
|
python
|
s575117088
|
s275695839
| 175 | 137 | 18,752 | 24,016 |
Accepted
|
Accepted
| 21.71 |
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s = 0
for i in range(N):
if A[i]+A[i+1]<=B[i]:
s = s + A[i] + A[i+1]
A[i]=0
A[i+1] = 0
elif A[i] <= B[i] and A[i] + A[i+1] > B[i]:
s = s + B[i]
A[i+1] = A[i+1] + A[i] - B[i]
A[i] = 0
else:
s = s + B[i]
A[i] = B[i] - A[i]
print(s)
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
if A[i] < B[i]:
ans += A[i]
B[i] -= A[i]
if A[i + 1] < B[i]:
ans += A[i + 1]
A[i + 1] = 0
else:
ans += B[i]
A[i + 1] -= B[i]
else:
ans += B[i]
print(ans)
| 19 | 18 | 382 | 391 |
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s = 0
for i in range(N):
if A[i] + A[i + 1] <= B[i]:
s = s + A[i] + A[i + 1]
A[i] = 0
A[i + 1] = 0
elif A[i] <= B[i] and A[i] + A[i + 1] > B[i]:
s = s + B[i]
A[i + 1] = A[i + 1] + A[i] - B[i]
A[i] = 0
else:
s = s + B[i]
A[i] = B[i] - A[i]
print(s)
|
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
if A[i] < B[i]:
ans += A[i]
B[i] -= A[i]
if A[i + 1] < B[i]:
ans += A[i + 1]
A[i + 1] = 0
else:
ans += B[i]
A[i + 1] -= B[i]
else:
ans += B[i]
print(ans)
| false | 5.263158 |
[
"-s = 0",
"+ans = 0",
"- if A[i] + A[i + 1] <= B[i]:",
"- s = s + A[i] + A[i + 1]",
"- A[i] = 0",
"- A[i + 1] = 0",
"- elif A[i] <= B[i] and A[i] + A[i + 1] > B[i]:",
"- s = s + B[i]",
"- A[i + 1] = A[i + 1] + A[i] - B[i]",
"- A[i] = 0",
"+ if A[i] < B[i]:",
"+ ans += A[i]",
"+ B[i] -= A[i]",
"+ if A[i + 1] < B[i]:",
"+ ans += A[i + 1]",
"+ A[i + 1] = 0",
"+ else:",
"+ ans += B[i]",
"+ A[i + 1] -= B[i]",
"- s = s + B[i]",
"- A[i] = B[i] - A[i]",
"-print(s)",
"+ ans += B[i]",
"+print(ans)"
] | false | 0.035381 | 0.0367 | 0.964072 |
[
"s575117088",
"s275695839"
] |
u218843509
|
p02913
|
python
|
s448834707
|
s245448543
| 79 | 72 | 6,388 | 3,376 |
Accepted
|
Accepted
| 8.86 |
n = int(eval(input()))
s = eval(input())
ok, ng = 0, n//2+1
while ng-ok > 1:
x = (ok+ng)//2
possible = False
d = set()
for i in range(n-2*x+1):
d.add(s[i:i+x])
if s[i+x:i+2*x] in d:
possible = True
break
if possible:
ok = x
else:
ng = x
print(ok)
|
n = int(eval(input()))
s = eval(input())
ok, ng = 0, n//2+1
while ng-ok > 1:
x = (ok+ng)//2
possible = False
d = set()
for i in range(n-2*x+1):
d.add(hash(s[i:i+x]))
if hash(s[i+x:i+2*x]) in d:
possible = True
break
if possible:
ok = x
else:
ng = x
print(ok)
| 18 | 18 | 272 | 284 |
n = int(eval(input()))
s = eval(input())
ok, ng = 0, n // 2 + 1
while ng - ok > 1:
x = (ok + ng) // 2
possible = False
d = set()
for i in range(n - 2 * x + 1):
d.add(s[i : i + x])
if s[i + x : i + 2 * x] in d:
possible = True
break
if possible:
ok = x
else:
ng = x
print(ok)
|
n = int(eval(input()))
s = eval(input())
ok, ng = 0, n // 2 + 1
while ng - ok > 1:
x = (ok + ng) // 2
possible = False
d = set()
for i in range(n - 2 * x + 1):
d.add(hash(s[i : i + x]))
if hash(s[i + x : i + 2 * x]) in d:
possible = True
break
if possible:
ok = x
else:
ng = x
print(ok)
| false | 0 |
[
"- d.add(s[i : i + x])",
"- if s[i + x : i + 2 * x] in d:",
"+ d.add(hash(s[i : i + x]))",
"+ if hash(s[i + x : i + 2 * x]) in d:"
] | false | 0.042272 | 0.041469 | 1.019354 |
[
"s448834707",
"s245448543"
] |
u797673668
|
p02378
|
python
|
s248493967
|
s725522628
| 140 | 70 | 11,296 | 8,560 |
Accepted
|
Accepted
| 50 |
import sys
from queue import deque
sys.setrecursionlimit(200000)
def hierarchize(source):
global hierarchy
hierarchy = [-1] * n
queue = deque([(0, source)])
while queue:
h, v = queue.popleft()
if hierarchy[v] != -1:
continue
hierarchy[v] = h
if v == sink:
return True
queue.extend((h + 1, target)
for remain, target, _ in edges[v] if hierarchy[target] == -1 and remain)
return False
def augment(v, limit):
if v == sink:
return limit
res = 0
for e in edges[v]:
remain, target, idx = e
if remain == 0 or hierarchy[v] >= hierarchy[target]:
continue
aug = augment(target, min(limit, remain))
e[0] -= aug
edges[target][idx][0] += aug
res += aug
limit -= aug
if not limit:
break
return res
xn, yn, e = list(map(int, input().split()))
n = xn + yn + 2
sink = n - 1
edges = [[] for _ in range(n)]
hierarchy = [-1] * n
for x in range(xn):
xi = x + 1
edges[0].append([1, xi, 0])
edges[xi].append([0, 0, x])
for y in range(yn):
yi = xn + y + 1
edges[yi].append([1, sink, y])
edges[sink].append([0, yi, 0])
for _ in range(e):
x, y = list(map(int, input().split()))
xi, yi = x + 1, xn + y + 1
ex, ey = edges[xi], edges[yi]
lx, ly = len(ex), len(ey)
ex.append([1, yi, ly])
ey.append([0, xi, lx])
res = 0
while hierarchize(0):
res += augment(0, 100)
print(res)
|
def dfs(s):
return _dfs(s, set())
def _dfs(v, visited):
for u in edges[v]:
if u in visited:
continue
visited.add(u)
if matched[u] == -1 or _dfs(matched[u], visited):
matched[u] = v
return True
return False
xn, yn, e = list(map(int, input().split()))
edges = [set() for _ in range(xn)]
matched = [-1] * yn
for _ in range(e):
x, y = list(map(int, input().split()))
edges[x].add(y)
print((sum(map(dfs, list(range(xn))))))
| 68 | 24 | 1,579 | 507 |
import sys
from queue import deque
sys.setrecursionlimit(200000)
def hierarchize(source):
global hierarchy
hierarchy = [-1] * n
queue = deque([(0, source)])
while queue:
h, v = queue.popleft()
if hierarchy[v] != -1:
continue
hierarchy[v] = h
if v == sink:
return True
queue.extend(
(h + 1, target)
for remain, target, _ in edges[v]
if hierarchy[target] == -1 and remain
)
return False
def augment(v, limit):
if v == sink:
return limit
res = 0
for e in edges[v]:
remain, target, idx = e
if remain == 0 or hierarchy[v] >= hierarchy[target]:
continue
aug = augment(target, min(limit, remain))
e[0] -= aug
edges[target][idx][0] += aug
res += aug
limit -= aug
if not limit:
break
return res
xn, yn, e = list(map(int, input().split()))
n = xn + yn + 2
sink = n - 1
edges = [[] for _ in range(n)]
hierarchy = [-1] * n
for x in range(xn):
xi = x + 1
edges[0].append([1, xi, 0])
edges[xi].append([0, 0, x])
for y in range(yn):
yi = xn + y + 1
edges[yi].append([1, sink, y])
edges[sink].append([0, yi, 0])
for _ in range(e):
x, y = list(map(int, input().split()))
xi, yi = x + 1, xn + y + 1
ex, ey = edges[xi], edges[yi]
lx, ly = len(ex), len(ey)
ex.append([1, yi, ly])
ey.append([0, xi, lx])
res = 0
while hierarchize(0):
res += augment(0, 100)
print(res)
|
def dfs(s):
return _dfs(s, set())
def _dfs(v, visited):
for u in edges[v]:
if u in visited:
continue
visited.add(u)
if matched[u] == -1 or _dfs(matched[u], visited):
matched[u] = v
return True
return False
xn, yn, e = list(map(int, input().split()))
edges = [set() for _ in range(xn)]
matched = [-1] * yn
for _ in range(e):
x, y = list(map(int, input().split()))
edges[x].add(y)
print((sum(map(dfs, list(range(xn))))))
| false | 64.705882 |
[
"-import sys",
"-from queue import deque",
"-",
"-sys.setrecursionlimit(200000)",
"+def dfs(s):",
"+ return _dfs(s, set())",
"-def hierarchize(source):",
"- global hierarchy",
"- hierarchy = [-1] * n",
"- queue = deque([(0, source)])",
"- while queue:",
"- h, v = queue.popleft()",
"- if hierarchy[v] != -1:",
"+def _dfs(v, visited):",
"+ for u in edges[v]:",
"+ if u in visited:",
"- hierarchy[v] = h",
"- if v == sink:",
"+ visited.add(u)",
"+ if matched[u] == -1 or _dfs(matched[u], visited):",
"+ matched[u] = v",
"- queue.extend(",
"- (h + 1, target)",
"- for remain, target, _ in edges[v]",
"- if hierarchy[target] == -1 and remain",
"- )",
"-def augment(v, limit):",
"- if v == sink:",
"- return limit",
"- res = 0",
"- for e in edges[v]:",
"- remain, target, idx = e",
"- if remain == 0 or hierarchy[v] >= hierarchy[target]:",
"- continue",
"- aug = augment(target, min(limit, remain))",
"- e[0] -= aug",
"- edges[target][idx][0] += aug",
"- res += aug",
"- limit -= aug",
"- if not limit:",
"- break",
"- return res",
"-",
"-",
"-n = xn + yn + 2",
"-sink = n - 1",
"-edges = [[] for _ in range(n)]",
"-hierarchy = [-1] * n",
"-for x in range(xn):",
"- xi = x + 1",
"- edges[0].append([1, xi, 0])",
"- edges[xi].append([0, 0, x])",
"-for y in range(yn):",
"- yi = xn + y + 1",
"- edges[yi].append([1, sink, y])",
"- edges[sink].append([0, yi, 0])",
"+edges = [set() for _ in range(xn)]",
"+matched = [-1] * yn",
"- xi, yi = x + 1, xn + y + 1",
"- ex, ey = edges[xi], edges[yi]",
"- lx, ly = len(ex), len(ey)",
"- ex.append([1, yi, ly])",
"- ey.append([0, xi, lx])",
"-res = 0",
"-while hierarchize(0):",
"- res += augment(0, 100)",
"-print(res)",
"+ edges[x].add(y)",
"+print((sum(map(dfs, list(range(xn))))))"
] | false | 0.229247 | 0.118278 | 1.938212 |
[
"s248493967",
"s725522628"
] |
u561231954
|
p03550
|
python
|
s444282027
|
s930099565
| 1,037 | 21 | 110,556 | 3,572 |
Accepted
|
Accepted
| 97.97 |
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MAXN = 2005
dp0 = [[-1] * MAXN for _ in range(MAXN)]
dp1 = [[-1] * MAXN for _ in range(MAXN)]
def dfs(i,j,p,z,w,a,n):
if p == 0:
if dp0[i][j] != -1:
return dp0[i][j]
if i == n:
if j == 0:
return abs(w - a[-1])
return abs(a[j -1] - a[-1])
ans = 0
for k in range(i,n):
ans = max(ans,dfs(k + 1,k,1,z,w,a,n))
if i == 1:
ans = max(ans,abs(a[-1] - w))
else:
ans = max(ans,abs(a[-1]- a[i - 1]))
dp0[i][j] = ans
return ans
elif p == 1:
if dp1[i][j] != -1:
return dp1[i][j]
if i == n:
if j == 0:
return abs(z - a[-1])
return abs(a[j - 1] - a[-1])
ans = INF
for k in range(i,n):
ans = min(ans,dfs(k + 1,k,0,z,w,a,n))
if i == 1:
ans = min(ans,abs(a[-1] - z))
else:
ans = min(ans,abs(a[-1] - a[i - 1]))
dp1[i][j] = ans
return ans
def main():
n,z,w = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = dfs(1,0,0,z,w,a,n)
print(ans)
if __name__=='__main__':
main()
|
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
def main():
n,z,w = list(map(int,input().split()))
a = list(map(int,input().split()))
if n == 1:
ans = abs(w - a[0])
else:
ans = max(abs(w - a[-1]),abs(a[-1] - a[-2]))
print(ans)
if __name__=='__main__':
main()
| 54 | 18 | 1,388 | 396 |
import sys
INF = 10**9
MOD = 10**9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
MAXN = 2005
dp0 = [[-1] * MAXN for _ in range(MAXN)]
dp1 = [[-1] * MAXN for _ in range(MAXN)]
def dfs(i, j, p, z, w, a, n):
if p == 0:
if dp0[i][j] != -1:
return dp0[i][j]
if i == n:
if j == 0:
return abs(w - a[-1])
return abs(a[j - 1] - a[-1])
ans = 0
for k in range(i, n):
ans = max(ans, dfs(k + 1, k, 1, z, w, a, n))
if i == 1:
ans = max(ans, abs(a[-1] - w))
else:
ans = max(ans, abs(a[-1] - a[i - 1]))
dp0[i][j] = ans
return ans
elif p == 1:
if dp1[i][j] != -1:
return dp1[i][j]
if i == n:
if j == 0:
return abs(z - a[-1])
return abs(a[j - 1] - a[-1])
ans = INF
for k in range(i, n):
ans = min(ans, dfs(k + 1, k, 0, z, w, a, n))
if i == 1:
ans = min(ans, abs(a[-1] - z))
else:
ans = min(ans, abs(a[-1] - a[i - 1]))
dp1[i][j] = ans
return ans
def main():
n, z, w = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = dfs(1, 0, 0, z, w, a, n)
print(ans)
if __name__ == "__main__":
main()
|
import sys
INF = 10**9
MOD = 10**9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
def main():
n, z, w = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
ans = abs(w - a[0])
else:
ans = max(abs(w - a[-1]), abs(a[-1] - a[-2]))
print(ans)
if __name__ == "__main__":
main()
| false | 66.666667 |
[
"-MAXN = 2005",
"-dp0 = [[-1] * MAXN for _ in range(MAXN)]",
"-dp1 = [[-1] * MAXN for _ in range(MAXN)]",
"-",
"-",
"-def dfs(i, j, p, z, w, a, n):",
"- if p == 0:",
"- if dp0[i][j] != -1:",
"- return dp0[i][j]",
"- if i == n:",
"- if j == 0:",
"- return abs(w - a[-1])",
"- return abs(a[j - 1] - a[-1])",
"- ans = 0",
"- for k in range(i, n):",
"- ans = max(ans, dfs(k + 1, k, 1, z, w, a, n))",
"- if i == 1:",
"- ans = max(ans, abs(a[-1] - w))",
"- else:",
"- ans = max(ans, abs(a[-1] - a[i - 1]))",
"- dp0[i][j] = ans",
"- return ans",
"- elif p == 1:",
"- if dp1[i][j] != -1:",
"- return dp1[i][j]",
"- if i == n:",
"- if j == 0:",
"- return abs(z - a[-1])",
"- return abs(a[j - 1] - a[-1])",
"- ans = INF",
"- for k in range(i, n):",
"- ans = min(ans, dfs(k + 1, k, 0, z, w, a, n))",
"- if i == 1:",
"- ans = min(ans, abs(a[-1] - z))",
"- else:",
"- ans = min(ans, abs(a[-1] - a[i - 1]))",
"- dp1[i][j] = ans",
"- return ans",
"- ans = dfs(1, 0, 0, z, w, a, n)",
"+ if n == 1:",
"+ ans = abs(w - a[0])",
"+ else:",
"+ ans = max(abs(w - a[-1]), abs(a[-1] - a[-2]))"
] | false | 0.363292 | 0.074472 | 4.878225 |
[
"s444282027",
"s930099565"
] |
u139614630
|
p03013
|
python
|
s921498372
|
s825256907
| 583 | 483 | 464,040 | 460,020 |
Accepted
|
Accepted
| 17.15 |
#!/usr/bin/env python3
P_NUM = 1000000007
def solv(n, m, a):
no_hole = [1] * (n+1)
for i in range(2, n+1):
no_hole[i] = no_hole[i-1] + no_hole[i-2]
ans = 1
start = 0
for broken in a:
dist = broken-1-start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
start = broken+1
dist = n-start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
return ans % P_NUM
if __name__ == '__main__':
n, m = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(m)]
ans = solv(n, m, a)
print(ans)
|
#!/usr/bin/env python3
import sys
P_NUM = 1000000007
def solv(n, m, a):
no_hole = [1] * (n+1)
for i in range(2, n+1):
no_hole[i] = no_hole[i-1] + no_hole[i-2]
ans = 1
start = 0
for broken in a:
dist = broken-1-start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
start = broken+1
dist = n-start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
return ans % P_NUM
if __name__ == '__main__':
n, m = list(map(int, input().split()))
a = list(map(int, sys.stdin))
ans = solv(n, m, a)
print(ans)
| 35 | 37 | 643 | 644 |
#!/usr/bin/env python3
P_NUM = 1000000007
def solv(n, m, a):
no_hole = [1] * (n + 1)
for i in range(2, n + 1):
no_hole[i] = no_hole[i - 1] + no_hole[i - 2]
ans = 1
start = 0
for broken in a:
dist = broken - 1 - start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
start = broken + 1
dist = n - start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
return ans % P_NUM
if __name__ == "__main__":
n, m = list(map(int, input().split()))
a = [int(eval(input())) for _ in range(m)]
ans = solv(n, m, a)
print(ans)
|
#!/usr/bin/env python3
import sys
P_NUM = 1000000007
def solv(n, m, a):
no_hole = [1] * (n + 1)
for i in range(2, n + 1):
no_hole[i] = no_hole[i - 1] + no_hole[i - 2]
ans = 1
start = 0
for broken in a:
dist = broken - 1 - start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
start = broken + 1
dist = n - start
if dist < 0:
return 0
ans *= no_hole[dist] % P_NUM
return ans % P_NUM
if __name__ == "__main__":
n, m = list(map(int, input().split()))
a = list(map(int, sys.stdin))
ans = solv(n, m, a)
print(ans)
| false | 5.405405 |
[
"+import sys",
"+",
"- a = [int(eval(input())) for _ in range(m)]",
"+ a = list(map(int, sys.stdin))"
] | false | 0.044652 | 0.04432 | 1.007505 |
[
"s921498372",
"s825256907"
] |
u136090046
|
p03221
|
python
|
s569485047
|
s591693382
| 1,002 | 905 | 46,940 | 109,524 |
Accepted
|
Accepted
| 9.68 |
n, m =list(map(int, input().split()))
py_array = [[int(x) for x in input().split()]+[y] for x, y in enumerate(list(range(m)), 0)]
py_array = sorted(py_array, key=lambda x:(x[0], x[1]))
base = 1
base2 = 0
res_array = []
for i, j, k in py_array:
if base == i:
base2 += 1
else:
base = i
base2 = 1
res_array.append([str(base).zfill(6), str(base2).zfill(6), k])
res_array = sorted(res_array, key=lambda x:x[2])
for i, j, k in res_array:
print((i+j))
|
n, m = list(map(int, input().split()))
py_array = [[int(x) for x in input().split()] for y in range(m)]
py_dict = {x: y for x, y in enumerate(py_array, 1)}
py = sorted(list(py_dict.items()), key=lambda x: x[1][1])
ans = {}
now = min([x[0] for x in py_array])
index = 0
index_array = {x: 0 for x in [x[0] for x in py_array]}
for key, value in py:
index_array[value[0]] += 1
index = index_array[value[0]]
ken = str(value[0])
si = str(index)
ans[key] = ken.zfill(6) + si.zfill(6)
now = value[0]
for key, value in list(ans.items()):
print(value)
| 19 | 17 | 491 | 568 |
n, m = list(map(int, input().split()))
py_array = [
[int(x) for x in input().split()] + [y] for x, y in enumerate(list(range(m)), 0)
]
py_array = sorted(py_array, key=lambda x: (x[0], x[1]))
base = 1
base2 = 0
res_array = []
for i, j, k in py_array:
if base == i:
base2 += 1
else:
base = i
base2 = 1
res_array.append([str(base).zfill(6), str(base2).zfill(6), k])
res_array = sorted(res_array, key=lambda x: x[2])
for i, j, k in res_array:
print((i + j))
|
n, m = list(map(int, input().split()))
py_array = [[int(x) for x in input().split()] for y in range(m)]
py_dict = {x: y for x, y in enumerate(py_array, 1)}
py = sorted(list(py_dict.items()), key=lambda x: x[1][1])
ans = {}
now = min([x[0] for x in py_array])
index = 0
index_array = {x: 0 for x in [x[0] for x in py_array]}
for key, value in py:
index_array[value[0]] += 1
index = index_array[value[0]]
ken = str(value[0])
si = str(index)
ans[key] = ken.zfill(6) + si.zfill(6)
now = value[0]
for key, value in list(ans.items()):
print(value)
| false | 10.526316 |
[
"-py_array = [",
"- [int(x) for x in input().split()] + [y] for x, y in enumerate(list(range(m)), 0)",
"-]",
"-py_array = sorted(py_array, key=lambda x: (x[0], x[1]))",
"-base = 1",
"-base2 = 0",
"-res_array = []",
"-for i, j, k in py_array:",
"- if base == i:",
"- base2 += 1",
"- else:",
"- base = i",
"- base2 = 1",
"- res_array.append([str(base).zfill(6), str(base2).zfill(6), k])",
"-res_array = sorted(res_array, key=lambda x: x[2])",
"-for i, j, k in res_array:",
"- print((i + j))",
"+py_array = [[int(x) for x in input().split()] for y in range(m)]",
"+py_dict = {x: y for x, y in enumerate(py_array, 1)}",
"+py = sorted(list(py_dict.items()), key=lambda x: x[1][1])",
"+ans = {}",
"+now = min([x[0] for x in py_array])",
"+index = 0",
"+index_array = {x: 0 for x in [x[0] for x in py_array]}",
"+for key, value in py:",
"+ index_array[value[0]] += 1",
"+ index = index_array[value[0]]",
"+ ken = str(value[0])",
"+ si = str(index)",
"+ ans[key] = ken.zfill(6) + si.zfill(6)",
"+ now = value[0]",
"+for key, value in list(ans.items()):",
"+ print(value)"
] | false | 0.035718 | 0.039144 | 0.912494 |
[
"s569485047",
"s591693382"
] |
u496344397
|
p03295
|
python
|
s611444902
|
s934787647
| 1,030 | 423 | 22,944 | 22,952 |
Accepted
|
Accepted
| 58.93 |
break_offs = set()
N, M = list(map(int, input().split()))
for i in range(M):
a, b = list(map(int, input().split()))
if a > b:
a, b = b, a
break_offs.add((a, b))
covered = []
break_offs = sorted(list(break_offs), key=lambda x:x[1])
for a, b in break_offs:
found = False
for area in covered:
if not (area[0] >= b or area[1] <= a):
covered.remove(area)
covered.append((max(area[0], a), min(area[1], b)))
found = True
break
if not found:
covered.append((a, b))
answer = len(covered)
print(answer)
|
break_offs = set()
N, M = list(map(int, input().split()))
for i in range(M):
a, b = list(map(int, input().split()))
if a > b:
a, b = b, a
break_offs.add((a, b))
last_bridge = 0
count = 0
for a, b in sorted(list(break_offs), key=lambda x:x[1]):
if last_bridge <= a:
last_bridge = b
count += 1
print(count)
| 25 | 16 | 604 | 349 |
break_offs = set()
N, M = list(map(int, input().split()))
for i in range(M):
a, b = list(map(int, input().split()))
if a > b:
a, b = b, a
break_offs.add((a, b))
covered = []
break_offs = sorted(list(break_offs), key=lambda x: x[1])
for a, b in break_offs:
found = False
for area in covered:
if not (area[0] >= b or area[1] <= a):
covered.remove(area)
covered.append((max(area[0], a), min(area[1], b)))
found = True
break
if not found:
covered.append((a, b))
answer = len(covered)
print(answer)
|
break_offs = set()
N, M = list(map(int, input().split()))
for i in range(M):
a, b = list(map(int, input().split()))
if a > b:
a, b = b, a
break_offs.add((a, b))
last_bridge = 0
count = 0
for a, b in sorted(list(break_offs), key=lambda x: x[1]):
if last_bridge <= a:
last_bridge = b
count += 1
print(count)
| false | 36 |
[
"-covered = []",
"-break_offs = sorted(list(break_offs), key=lambda x: x[1])",
"-for a, b in break_offs:",
"- found = False",
"- for area in covered:",
"- if not (area[0] >= b or area[1] <= a):",
"- covered.remove(area)",
"- covered.append((max(area[0], a), min(area[1], b)))",
"- found = True",
"- break",
"- if not found:",
"- covered.append((a, b))",
"-answer = len(covered)",
"-print(answer)",
"+last_bridge = 0",
"+count = 0",
"+for a, b in sorted(list(break_offs), key=lambda x: x[1]):",
"+ if last_bridge <= a:",
"+ last_bridge = b",
"+ count += 1",
"+print(count)"
] | false | 0.039048 | 0.055462 | 0.704037 |
[
"s611444902",
"s934787647"
] |
u076917070
|
p03324
|
python
|
s994737203
|
s215374663
| 36 | 17 | 5,176 | 2,940 |
Accepted
|
Accepted
| 52.78 |
import sys
input=sys.stdin.readline
import fractions
d,n = list(map(int, input().split()))
ans = 100**d*n
if d == 0:
if ans == 100:
ans += 1
elif d == 1:
if ans == 10000:
ans += 100
elif d == 2:
if ans == 1000000:
ans += 10000
print(ans)
|
import sys
input=sys.stdin.readline
d,n = list(map(int, input().split()))
if n == 100:
n += 1
print((100**d*n))
| 17 | 7 | 286 | 119 |
import sys
input = sys.stdin.readline
import fractions
d, n = list(map(int, input().split()))
ans = 100**d * n
if d == 0:
if ans == 100:
ans += 1
elif d == 1:
if ans == 10000:
ans += 100
elif d == 2:
if ans == 1000000:
ans += 10000
print(ans)
|
import sys
input = sys.stdin.readline
d, n = list(map(int, input().split()))
if n == 100:
n += 1
print((100**d * n))
| false | 58.823529 |
[
"-import fractions",
"-",
"-ans = 100**d * n",
"-if d == 0:",
"- if ans == 100:",
"- ans += 1",
"-elif d == 1:",
"- if ans == 10000:",
"- ans += 100",
"-elif d == 2:",
"- if ans == 1000000:",
"- ans += 10000",
"-print(ans)",
"+if n == 100:",
"+ n += 1",
"+print((100**d * n))"
] | false | 0.036231 | 0.036902 | 0.981818 |
[
"s994737203",
"s215374663"
] |
u508355671
|
p03127
|
python
|
s509437283
|
s453055229
| 89 | 79 | 14,252 | 16,204 |
Accepted
|
Accepted
| 11.24 |
n = int(eval(input()))
aaa = list(map(int, input().split()))
def gcd(a,b):
if b==0:
return a
return gcd(b, a%b)
ans = gcd(aaa[0], aaa[1])
if n == 2:
print(ans)
else:
for i in range(2,n):
ans = gcd(ans, aaa[i])
print(ans)
|
from functools import reduce
from fractions import gcd
def gcd_list(numbers):
return reduce(gcd, numbers)
def resolve():
n = int(eval(input()))
aaa = list(map(int ,input().split()))
print((gcd_list(aaa)))
resolve()
| 15 | 10 | 250 | 232 |
n = int(eval(input()))
aaa = list(map(int, input().split()))
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
ans = gcd(aaa[0], aaa[1])
if n == 2:
print(ans)
else:
for i in range(2, n):
ans = gcd(ans, aaa[i])
print(ans)
|
from functools import reduce
from fractions import gcd
def gcd_list(numbers):
return reduce(gcd, numbers)
def resolve():
n = int(eval(input()))
aaa = list(map(int, input().split()))
print((gcd_list(aaa)))
resolve()
| false | 33.333333 |
[
"-n = int(eval(input()))",
"-aaa = list(map(int, input().split()))",
"+from functools import reduce",
"+from fractions import gcd",
"-def gcd(a, b):",
"- if b == 0:",
"- return a",
"- return gcd(b, a % b)",
"+def gcd_list(numbers):",
"+ return reduce(gcd, numbers)",
"-ans = gcd(aaa[0], aaa[1])",
"-if n == 2:",
"- print(ans)",
"-else:",
"- for i in range(2, n):",
"- ans = gcd(ans, aaa[i])",
"- print(ans)",
"+def resolve():",
"+ n = int(eval(input()))",
"+ aaa = list(map(int, input().split()))",
"+ print((gcd_list(aaa)))",
"+",
"+",
"+resolve()"
] | false | 0.075542 | 0.088345 | 0.855077 |
[
"s509437283",
"s453055229"
] |
u057109575
|
p02947
|
python
|
s480170007
|
s637441694
| 590 | 337 | 74,328 | 163,064 |
Accepted
|
Accepted
| 42.88 |
from collections import defaultdict
N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
d = defaultdict(int)
for s in S:
d[''.join(sorted(s))] += 1
ans = 0
for v in list(d.values()):
if v > 1:
ans += v * (v - 1) // 2
print(ans)
|
from collections import defaultdict
N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
ctr = defaultdict(int)
for i in range(N):
tmp = [0] * 26
for j in range(10):
tmp[ord(S[i][j]) - ord("a")] += 1
ctr[tuple(tmp)] += 1
ans = 0
for v in list(ctr.values()):
ans += v * (v - 1) // 2
print(ans)
| 13 | 17 | 253 | 327 |
from collections import defaultdict
N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
d = defaultdict(int)
for s in S:
d["".join(sorted(s))] += 1
ans = 0
for v in list(d.values()):
if v > 1:
ans += v * (v - 1) // 2
print(ans)
|
from collections import defaultdict
N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
ctr = defaultdict(int)
for i in range(N):
tmp = [0] * 26
for j in range(10):
tmp[ord(S[i][j]) - ord("a")] += 1
ctr[tuple(tmp)] += 1
ans = 0
for v in list(ctr.values()):
ans += v * (v - 1) // 2
print(ans)
| false | 23.529412 |
[
"-d = defaultdict(int)",
"-for s in S:",
"- d[\"\".join(sorted(s))] += 1",
"+ctr = defaultdict(int)",
"+for i in range(N):",
"+ tmp = [0] * 26",
"+ for j in range(10):",
"+ tmp[ord(S[i][j]) - ord(\"a\")] += 1",
"+ ctr[tuple(tmp)] += 1",
"-for v in list(d.values()):",
"- if v > 1:",
"- ans += v * (v - 1) // 2",
"+for v in list(ctr.values()):",
"+ ans += v * (v - 1) // 2"
] | false | 0.03826 | 0.037366 | 1.023914 |
[
"s480170007",
"s637441694"
] |
u600195339
|
p03030
|
python
|
s779792572
|
s206384720
| 22 | 17 | 3,064 | 3,060 |
Accepted
|
Accepted
| 22.73 |
n = int(eval(input()))
ss = []
ps = []
sps = []
for i in range(n):
temp = input().split()
ss.append(temp[0])
ps.append(temp[1])
sps.append(temp[0] + ' ' + temp[1] + ' ' + str(i))
def check(sps):
city = sps[0].split()[0]
score = int(sps[0].split()[1])
# score = sps[0].split()[1]
index = int(sps[0].split()[2])
target = 0
for i in range(1, len(sps)):
# print(sps[i].split()[1])
# print(score)
if sps[i].split()[0] == city and score < int(sps[i].split()[1]):
# if sps[i].split()[0] == city and score < sps[i].split()[1]:
city = sps[i].split()[0]
score = int(sps[i].split()[1])
index = int(sps[i].split()[2])
target = i
elif sps[i].split()[0] < city:
city = sps[i].split()[0]
score = int(sps[i].split()[1])
index = int(sps[i].split()[2])
target = i
# print(index + 1)
# del sps[i]
# return index
return target, index
for i in range(n):
target, index = check(sps)
print((index + 1))
del sps[target]
|
n = int(eval(input()))
sps = []
for i in range(n):
line = input().split()
sps.append([line[0], -(int(line[1])), i + 1])
sps.sort()
for i in range(n):
print((sps[i][2]))
| 45 | 11 | 1,138 | 186 |
n = int(eval(input()))
ss = []
ps = []
sps = []
for i in range(n):
temp = input().split()
ss.append(temp[0])
ps.append(temp[1])
sps.append(temp[0] + " " + temp[1] + " " + str(i))
def check(sps):
city = sps[0].split()[0]
score = int(sps[0].split()[1])
# score = sps[0].split()[1]
index = int(sps[0].split()[2])
target = 0
for i in range(1, len(sps)):
# print(sps[i].split()[1])
# print(score)
if sps[i].split()[0] == city and score < int(sps[i].split()[1]):
# if sps[i].split()[0] == city and score < sps[i].split()[1]:
city = sps[i].split()[0]
score = int(sps[i].split()[1])
index = int(sps[i].split()[2])
target = i
elif sps[i].split()[0] < city:
city = sps[i].split()[0]
score = int(sps[i].split()[1])
index = int(sps[i].split()[2])
target = i
# print(index + 1)
# del sps[i]
# return index
return target, index
for i in range(n):
target, index = check(sps)
print((index + 1))
del sps[target]
|
n = int(eval(input()))
sps = []
for i in range(n):
line = input().split()
sps.append([line[0], -(int(line[1])), i + 1])
sps.sort()
for i in range(n):
print((sps[i][2]))
| false | 75.555556 |
[
"-ss = []",
"-ps = []",
"- temp = input().split()",
"- ss.append(temp[0])",
"- ps.append(temp[1])",
"- sps.append(temp[0] + \" \" + temp[1] + \" \" + str(i))",
"-",
"-",
"-def check(sps):",
"- city = sps[0].split()[0]",
"- score = int(sps[0].split()[1])",
"- # score = sps[0].split()[1]",
"- index = int(sps[0].split()[2])",
"- target = 0",
"- for i in range(1, len(sps)):",
"- # print(sps[i].split()[1])",
"- # print(score)",
"- if sps[i].split()[0] == city and score < int(sps[i].split()[1]):",
"- # if sps[i].split()[0] == city and score < sps[i].split()[1]:",
"- city = sps[i].split()[0]",
"- score = int(sps[i].split()[1])",
"- index = int(sps[i].split()[2])",
"- target = i",
"- elif sps[i].split()[0] < city:",
"- city = sps[i].split()[0]",
"- score = int(sps[i].split()[1])",
"- index = int(sps[i].split()[2])",
"- target = i",
"- # print(index + 1)",
"- # del sps[i]",
"- # return index",
"- return target, index",
"-",
"-",
"+ line = input().split()",
"+ sps.append([line[0], -(int(line[1])), i + 1])",
"+sps.sort()",
"- target, index = check(sps)",
"- print((index + 1))",
"- del sps[target]",
"+ print((sps[i][2]))"
] | false | 0.043043 | 0.034472 | 1.248607 |
[
"s779792572",
"s206384720"
] |
u111365362
|
p03061
|
python
|
s382120226
|
s380837485
| 1,716 | 393 | 16,612 | 14,436 |
Accepted
|
Accepted
| 77.1 |
import fractions
N = int(eval(input()))
A = list(map(int,input().split()))
hard = fractions.gcd(A[0],A[1])
easy = [A[0],A[1]]
del A[0]
del A[0]
while len(A) != 0:
easyt1 = fractions.gcd(easy[0],A[0])
easyt2 = fractions.gcd(easy[1],A[0])
easyt3 = hard
easy = sorted([easyt1,easyt2,easyt3])[1:3]
hard = fractions.gcd(hard,A[0])
del A[0]
print((max(easy)))
|
n = int(eval(input()))
a = list(map(int,input().split()))
ans1 = a[1]
for i in range(1,n):
big,sml = a[i],ans1
while sml != 0:
big,sml = sml,big%sml
ans1 = big
ans2 = a[-2]
for i in range(n-1):
big,sml = a[i],ans2
while sml != 0:
big,sml = sml,big%sml
ans2 = big
l1 = [-1]
now = a[0]
for i in range(1,n):
big,sml = now,a[i]
while sml != 0:
big,sml = sml,big%sml
l1.append(now // big)
now = big
l2 = [-1]
now = a[-1]
for i in range(n-2,-1,-1):
big,sml = now,a[i]
while sml != 0:
big,sml = sml,big%sml
l2.append(now // big)
now = big
l2.reverse()
l3 = [-1]
for i in range(1,n-1):
big,sml = l1[i],l2[i]
while sml != 0:
big,sml = sml,big%sml
l3.append(big)
l3.append(-1)
now = a[0]
for i in range(n):
big,sml = now,a[i]
while sml != 0:
big,sml = sml,big%sml
now = big
ans3 = now * max(l3)
#print(now)
#print(l1)
#print(l2)
#print(l3)
#print(ans1,ans2,ans3)
print((max(ans1,ans2,ans3)))
| 15 | 51 | 371 | 987 |
import fractions
N = int(eval(input()))
A = list(map(int, input().split()))
hard = fractions.gcd(A[0], A[1])
easy = [A[0], A[1]]
del A[0]
del A[0]
while len(A) != 0:
easyt1 = fractions.gcd(easy[0], A[0])
easyt2 = fractions.gcd(easy[1], A[0])
easyt3 = hard
easy = sorted([easyt1, easyt2, easyt3])[1:3]
hard = fractions.gcd(hard, A[0])
del A[0]
print((max(easy)))
|
n = int(eval(input()))
a = list(map(int, input().split()))
ans1 = a[1]
for i in range(1, n):
big, sml = a[i], ans1
while sml != 0:
big, sml = sml, big % sml
ans1 = big
ans2 = a[-2]
for i in range(n - 1):
big, sml = a[i], ans2
while sml != 0:
big, sml = sml, big % sml
ans2 = big
l1 = [-1]
now = a[0]
for i in range(1, n):
big, sml = now, a[i]
while sml != 0:
big, sml = sml, big % sml
l1.append(now // big)
now = big
l2 = [-1]
now = a[-1]
for i in range(n - 2, -1, -1):
big, sml = now, a[i]
while sml != 0:
big, sml = sml, big % sml
l2.append(now // big)
now = big
l2.reverse()
l3 = [-1]
for i in range(1, n - 1):
big, sml = l1[i], l2[i]
while sml != 0:
big, sml = sml, big % sml
l3.append(big)
l3.append(-1)
now = a[0]
for i in range(n):
big, sml = now, a[i]
while sml != 0:
big, sml = sml, big % sml
now = big
ans3 = now * max(l3)
# print(now)
# print(l1)
# print(l2)
# print(l3)
# print(ans1,ans2,ans3)
print((max(ans1, ans2, ans3)))
| false | 70.588235 |
[
"-import fractions",
"-",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-hard = fractions.gcd(A[0], A[1])",
"-easy = [A[0], A[1]]",
"-del A[0]",
"-del A[0]",
"-while len(A) != 0:",
"- easyt1 = fractions.gcd(easy[0], A[0])",
"- easyt2 = fractions.gcd(easy[1], A[0])",
"- easyt3 = hard",
"- easy = sorted([easyt1, easyt2, easyt3])[1:3]",
"- hard = fractions.gcd(hard, A[0])",
"- del A[0]",
"-print((max(easy)))",
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"+ans1 = a[1]",
"+for i in range(1, n):",
"+ big, sml = a[i], ans1",
"+ while sml != 0:",
"+ big, sml = sml, big % sml",
"+ ans1 = big",
"+ans2 = a[-2]",
"+for i in range(n - 1):",
"+ big, sml = a[i], ans2",
"+ while sml != 0:",
"+ big, sml = sml, big % sml",
"+ ans2 = big",
"+l1 = [-1]",
"+now = a[0]",
"+for i in range(1, n):",
"+ big, sml = now, a[i]",
"+ while sml != 0:",
"+ big, sml = sml, big % sml",
"+ l1.append(now // big)",
"+ now = big",
"+l2 = [-1]",
"+now = a[-1]",
"+for i in range(n - 2, -1, -1):",
"+ big, sml = now, a[i]",
"+ while sml != 0:",
"+ big, sml = sml, big % sml",
"+ l2.append(now // big)",
"+ now = big",
"+l2.reverse()",
"+l3 = [-1]",
"+for i in range(1, n - 1):",
"+ big, sml = l1[i], l2[i]",
"+ while sml != 0:",
"+ big, sml = sml, big % sml",
"+ l3.append(big)",
"+l3.append(-1)",
"+now = a[0]",
"+for i in range(n):",
"+ big, sml = now, a[i]",
"+ while sml != 0:",
"+ big, sml = sml, big % sml",
"+ now = big",
"+ans3 = now * max(l3)",
"+# print(now)",
"+# print(l1)",
"+# print(l2)",
"+# print(l3)",
"+# print(ans1,ans2,ans3)",
"+print((max(ans1, ans2, ans3)))"
] | false | 0.059579 | 0.043512 | 1.369268 |
[
"s382120226",
"s380837485"
] |
u347640436
|
p02953
|
python
|
s129361225
|
s981488354
| 77 | 67 | 14,252 | 14,396 |
Accepted
|
Accepted
| 12.99 |
import sys
n = int(eval(input()))
h = [int(e) for e in input().split()]
for i in range(n - 2, 0, -1):
if h[i] > h[i + 1]:
h[i] -= 1
if h[i] > h[i + 1]:
print('No')
sys.exit()
print('Yes')
|
from sys import exit
N = int(eval(input()))
H = list(map(int, input().split()))
for i in range(N - 2, 0, -1):
if H[i] <= H[i + 1]:
continue
H[i] -= 1
if H[i] > H[i + 1]:
print('No')
exit()
print('Yes')
| 10 | 13 | 207 | 246 |
import sys
n = int(eval(input()))
h = [int(e) for e in input().split()]
for i in range(n - 2, 0, -1):
if h[i] > h[i + 1]:
h[i] -= 1
if h[i] > h[i + 1]:
print("No")
sys.exit()
print("Yes")
|
from sys import exit
N = int(eval(input()))
H = list(map(int, input().split()))
for i in range(N - 2, 0, -1):
if H[i] <= H[i + 1]:
continue
H[i] -= 1
if H[i] > H[i + 1]:
print("No")
exit()
print("Yes")
| false | 23.076923 |
[
"-import sys",
"+from sys import exit",
"-n = int(eval(input()))",
"-h = [int(e) for e in input().split()]",
"-for i in range(n - 2, 0, -1):",
"- if h[i] > h[i + 1]:",
"- h[i] -= 1",
"- if h[i] > h[i + 1]:",
"+N = int(eval(input()))",
"+H = list(map(int, input().split()))",
"+for i in range(N - 2, 0, -1):",
"+ if H[i] <= H[i + 1]:",
"+ continue",
"+ H[i] -= 1",
"+ if H[i] > H[i + 1]:",
"- sys.exit()",
"+ exit()"
] | false | 0.047962 | 0.103762 | 0.462232 |
[
"s129361225",
"s981488354"
] |
u540744789
|
p00092
|
python
|
s260084396
|
s349868587
| 4,410 | 3,540 | 33,788 | 33,776 |
Accepted
|
Accepted
| 19.73 |
while True:
n=eval(input())
if n==0:
break
dp=[[0 for i in range(n)]for j in range(n)]
for i in range(n):
j=0
for c in input():
if c == ".":
dp[i][j]=1
j+=1
for i in range(1,n):
for j in range(1,n):
if dp[i][j]==1:
dp[i][j]=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1
allmax=0
for i in range(n):
if allmax<max(dp[i]):
allmax=max(dp[i])
print(allmax)
|
while True:
n=eval(input())
if n==0:
break
dp=[[0 for i in range(n+1)]for j in range(n+1)]
for i in range(1,n+1):
j=0
line=" "+input()
for c in line:
if c == ".":
dp[i][j]=min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1
j+=1
allmax=0
for i in range(n+1):
if allmax<max(dp[i]):
allmax=max(dp[i])
print(allmax)
| 20 | 17 | 515 | 435 |
while True:
n = eval(input())
if n == 0:
break
dp = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
j = 0
for c in input():
if c == ".":
dp[i][j] = 1
j += 1
for i in range(1, n):
for j in range(1, n):
if dp[i][j] == 1:
dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1
allmax = 0
for i in range(n):
if allmax < max(dp[i]):
allmax = max(dp[i])
print(allmax)
|
while True:
n = eval(input())
if n == 0:
break
dp = [[0 for i in range(n + 1)] for j in range(n + 1)]
for i in range(1, n + 1):
j = 0
line = " " + input()
for c in line:
if c == ".":
dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1
j += 1
allmax = 0
for i in range(n + 1):
if allmax < max(dp[i]):
allmax = max(dp[i])
print(allmax)
| false | 15 |
[
"- dp = [[0 for i in range(n)] for j in range(n)]",
"- for i in range(n):",
"+ dp = [[0 for i in range(n + 1)] for j in range(n + 1)]",
"+ for i in range(1, n + 1):",
"- for c in input():",
"+ line = \" \" + input()",
"+ for c in line:",
"- dp[i][j] = 1",
"+ dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1",
"- for i in range(1, n):",
"- for j in range(1, n):",
"- if dp[i][j] == 1:",
"- dp[i][j] = min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]) + 1",
"- for i in range(n):",
"+ for i in range(n + 1):"
] | false | 0.037588 | 0.038153 | 0.985199 |
[
"s260084396",
"s349868587"
] |
u364862909
|
p02555
|
python
|
s756793820
|
s484620026
| 111 | 74 | 71,644 | 71,668 |
Accepted
|
Accepted
| 33.33 |
#事前に階乗を計算しておく maximにnの最大値をいれる
maxim = 10**6+1
MOD = 10**9+7
kaijou = [1]*(maxim)
for i in range(1,maxim):
kaijou[i]=(kaijou[i-1]*i)%MOD
#nCr
def nCr(n,r):
return ((kaijou[n]*pow(kaijou[r],MOD-2,MOD))%MOD*pow(kaijou[n-r],MOD-2,MOD))%MOD
#nHr
def nHr(n,r):
return ((kaijou[n+r-1]*pow(kaijou[n],MOD-2,MOD))%MOD*pow(kaijou[r-1],MOD-2,MOD))%MOD
N = int(eval(input()))
ans = 1 if N >=3 else 0
for i in range(2,(N//3)+1):
tmp = nHr(N-3*i,i)
ans = (ans+tmp)%MOD
print(ans)
|
#事前に階乗を計算しておく maximにnの最大値をいれる
maxim = 10**6+1
MOD = 10**9+7
kaijou = [1]*(maxim)
for i in range(1,maxim):
kaijou[i]=(kaijou[i-1]*i)%MOD
#nCr
def nCr(n,r):
if n < r:
return 0
return ((kaijou[n]*pow(kaijou[r],MOD-2,MOD))%MOD*pow(kaijou[n-r],MOD-2,MOD))%MOD
#nHr
def nHr(n,r):
if r == 0:
if n == 0:
return 1
return 0
return ((kaijou[n+r-1]*pow(kaijou[n],MOD-2,MOD))%MOD*pow(kaijou[r-1],MOD-2,MOD))%MOD
N = int(eval(input()))
ans = 0
for i in range(1,(N//3)+1):
tmp = nHr(N-3*i,i)
ans = (ans+tmp)%MOD
print(ans)
| 25 | 28 | 509 | 596 |
# 事前に階乗を計算しておく maximにnの最大値をいれる
maxim = 10**6 + 1
MOD = 10**9 + 7
kaijou = [1] * (maxim)
for i in range(1, maxim):
kaijou[i] = (kaijou[i - 1] * i) % MOD
# nCr
def nCr(n, r):
return (
(kaijou[n] * pow(kaijou[r], MOD - 2, MOD))
% MOD
* pow(kaijou[n - r], MOD - 2, MOD)
) % MOD
# nHr
def nHr(n, r):
return (
(kaijou[n + r - 1] * pow(kaijou[n], MOD - 2, MOD))
% MOD
* pow(kaijou[r - 1], MOD - 2, MOD)
) % MOD
N = int(eval(input()))
ans = 1 if N >= 3 else 0
for i in range(2, (N // 3) + 1):
tmp = nHr(N - 3 * i, i)
ans = (ans + tmp) % MOD
print(ans)
|
# 事前に階乗を計算しておく maximにnの最大値をいれる
maxim = 10**6 + 1
MOD = 10**9 + 7
kaijou = [1] * (maxim)
for i in range(1, maxim):
kaijou[i] = (kaijou[i - 1] * i) % MOD
# nCr
def nCr(n, r):
if n < r:
return 0
return (
(kaijou[n] * pow(kaijou[r], MOD - 2, MOD))
% MOD
* pow(kaijou[n - r], MOD - 2, MOD)
) % MOD
# nHr
def nHr(n, r):
if r == 0:
if n == 0:
return 1
return 0
return (
(kaijou[n + r - 1] * pow(kaijou[n], MOD - 2, MOD))
% MOD
* pow(kaijou[r - 1], MOD - 2, MOD)
) % MOD
N = int(eval(input()))
ans = 0
for i in range(1, (N // 3) + 1):
tmp = nHr(N - 3 * i, i)
ans = (ans + tmp) % MOD
print(ans)
| false | 10.714286 |
[
"+ if n < r:",
"+ return 0",
"+ if r == 0:",
"+ if n == 0:",
"+ return 1",
"+ return 0",
"-ans = 1 if N >= 3 else 0",
"-for i in range(2, (N // 3) + 1):",
"+ans = 0",
"+for i in range(1, (N // 3) + 1):"
] | false | 0.824882 | 0.885847 | 0.931178 |
[
"s756793820",
"s484620026"
] |
u883048396
|
p03625
|
python
|
s956303624
|
s534589794
| 88 | 60 | 14,480 | 14,480 |
Accepted
|
Accepted
| 31.82 |
def 解():
iN = int(eval(input()))
iNow = 0
iMem = 0
iC = 0
d = {}
for a in reversed(sorted([int(_) for _ in input().split()])):
if iNow == a:
iC += 1
else:
iC = 1
iNow = a
if iC == 2:
if iMem :
print((iMem * iNow))
exit()
else:
iMem = a
elif iC == 4:
print((iMem**2))
exit()
print((0))
解()
|
def 解():
iN = int(eval(input()))
m2_2 = 0 #複数あるものの二つ目
m2 = 0 #複数あるもので最大
m3 = 0 #3個あるもので最大
m4 = 0 #4個あるもので最大
d = set()
for a in [int(_) for _ in input().split()]:
if a in d:
if m2 < a :
m2_2 = m2
m2 = a
elif m2 == a :
if m3 < a :
m3 = a
elif m3 == a:
if m4 < a:
m4 = a
elif m2_2 < a:
m2_2 = a
else:
d.add(a)
print((max(m2*m2_2,m4**2)))
解()
| 23 | 24 | 491 | 599 |
def 解():
iN = int(eval(input()))
iNow = 0
iMem = 0
iC = 0
d = {}
for a in reversed(sorted([int(_) for _ in input().split()])):
if iNow == a:
iC += 1
else:
iC = 1
iNow = a
if iC == 2:
if iMem:
print((iMem * iNow))
exit()
else:
iMem = a
elif iC == 4:
print((iMem**2))
exit()
print((0))
解()
|
def 解():
iN = int(eval(input()))
m2_2 = 0 # 複数あるものの二つ目
m2 = 0 # 複数あるもので最大
m3 = 0 # 3個あるもので最大
m4 = 0 # 4個あるもので最大
d = set()
for a in [int(_) for _ in input().split()]:
if a in d:
if m2 < a:
m2_2 = m2
m2 = a
elif m2 == a:
if m3 < a:
m3 = a
elif m3 == a:
if m4 < a:
m4 = a
elif m2_2 < a:
m2_2 = a
else:
d.add(a)
print((max(m2 * m2_2, m4**2)))
解()
| false | 4.166667 |
[
"- iNow = 0",
"- iMem = 0",
"- iC = 0",
"- d = {}",
"- for a in reversed(sorted([int(_) for _ in input().split()])):",
"- if iNow == a:",
"- iC += 1",
"+ m2_2 = 0 # 複数あるものの二つ目",
"+ m2 = 0 # 複数あるもので最大",
"+ m3 = 0 # 3個あるもので最大",
"+ m4 = 0 # 4個あるもので最大",
"+ d = set()",
"+ for a in [int(_) for _ in input().split()]:",
"+ if a in d:",
"+ if m2 < a:",
"+ m2_2 = m2",
"+ m2 = a",
"+ elif m2 == a:",
"+ if m3 < a:",
"+ m3 = a",
"+ elif m3 == a:",
"+ if m4 < a:",
"+ m4 = a",
"+ elif m2_2 < a:",
"+ m2_2 = a",
"- iC = 1",
"- iNow = a",
"- if iC == 2:",
"- if iMem:",
"- print((iMem * iNow))",
"- exit()",
"- else:",
"- iMem = a",
"- elif iC == 4:",
"- print((iMem**2))",
"- exit()",
"- print((0))",
"+ d.add(a)",
"+ print((max(m2 * m2_2, m4**2)))"
] | false | 0.093208 | 0.04729 | 1.971016 |
[
"s956303624",
"s534589794"
] |
u440566786
|
p03485
|
python
|
s061807491
|
s679141265
| 173 | 62 | 38,384 | 61,736 |
Accepted
|
Accepted
| 64.16 |
a,b = list(map(int,input().split()))
print((-(-(a+b)//2)))
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
a, b = list(map(int, input().split()))
print(((a + b + 1) // 2))
resolve()
| 2 | 9 | 51 | 229 |
a, b = list(map(int, input().split()))
print((-(-(a + b) // 2)))
|
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()
def resolve():
a, b = list(map(int, input().split()))
print(((a + b + 1) // 2))
resolve()
| false | 77.777778 |
[
"-a, b = list(map(int, input().split()))",
"-print((-(-(a + b) // 2)))",
"+import sys",
"+",
"+INF = 1 << 60",
"+MOD = 10**9 + 7 # 998244353",
"+sys.setrecursionlimit(2147483647)",
"+input = lambda: sys.stdin.readline().rstrip()",
"+",
"+",
"+def resolve():",
"+ a, b = list(map(int, input().split()))",
"+ print(((a + b + 1) // 2))",
"+",
"+",
"+resolve()"
] | false | 0.043216 | 0.03891 | 1.110661 |
[
"s061807491",
"s679141265"
] |
u941753895
|
p03523
|
python
|
s563946979
|
s672205841
| 83 | 58 | 7,740 | 6,224 |
Accepted
|
Accepted
| 30.12 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
def LI(): return list(map(int,input().split()))
def II(): return int(eval(input()))
def LS(): return input().split()
def S(): return eval(input())
def main():
s=S()
if len(s)<5:
print('NO')
else:
if s[-4:]=='BARA':
if s.count('A')>4:
print('NO')
elif s.count('A')==4:
if s=='AKIHABARA':
print('YES')
else:
print('NO')
else:
if s.count('KIH')==1:
print('YES')
else:
print('NO')
elif s[-3:]=='BRA' or s[-3:]=='BAR':
if s.count('A')>3:
print('NO')
elif s.count('A')==3:
if s=='AKIHABRA' or s=='AKIHABAR':
print('YES')
else:
print('NO')
else:
if s.count('KIH')==1:
print('YES')
else:
print('NO')
elif s[-2:]=='BR':
if s.count('A')>2:
print('NO')
elif s.count('A')==2:
if s=='AKIHABR':
print('YES')
else:
print('NO')
else:
if s.count('KIH')==1:
print('YES')
else:
print('NO')
else:
print('NO')
main()
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return eval(input())
def main():
s=S()
if len(s)>9:
return 'NO'
if len(s)==9:
if s=='AKIHABARA':
return 'YES'
return 'NO'
if len(s)==8:
if s=='KIHABARA' or s=='AKIHBARA' or s=='AKIHABRA' or s=='AKIHABAR':
return 'YES'
return 'NO'
if len(s)==7:
if s=='KIHBARA' or s=='KIHABRA' or s=='KIHABAR' or s=='AKIHBRA' or s=='AKIHBAR' or s=='AKIHABR':
return 'YES'
return 'NO'
if len(s)==6:
if s=='KIHBRA' or s=='KIHABR' or s=='KIHBAR' or s=='AKIHBR':
return 'YES'
return 'NO'
if len(s)==5:
if s=='KIHBR':
return 'YES'
return 'NO'
else:
return 'NO'
# main()
print((main()))
| 62 | 44 | 1,319 | 1,168 |
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
def LI():
return list(map(int, input().split()))
def II():
return int(eval(input()))
def LS():
return input().split()
def S():
return eval(input())
def main():
s = S()
if len(s) < 5:
print("NO")
else:
if s[-4:] == "BARA":
if s.count("A") > 4:
print("NO")
elif s.count("A") == 4:
if s == "AKIHABARA":
print("YES")
else:
print("NO")
else:
if s.count("KIH") == 1:
print("YES")
else:
print("NO")
elif s[-3:] == "BRA" or s[-3:] == "BAR":
if s.count("A") > 3:
print("NO")
elif s.count("A") == 3:
if s == "AKIHABRA" or s == "AKIHABAR":
print("YES")
else:
print("NO")
else:
if s.count("KIH") == 1:
print("YES")
else:
print("NO")
elif s[-2:] == "BR":
if s.count("A") > 2:
print("NO")
elif s.count("A") == 2:
if s == "AKIHABR":
print("YES")
else:
print("NO")
else:
if s.count("KIH") == 1:
print("YES")
else:
print("NO")
else:
print("NO")
main()
|
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return sys.stdin.readline().split()
def S():
return eval(input())
def main():
s = S()
if len(s) > 9:
return "NO"
if len(s) == 9:
if s == "AKIHABARA":
return "YES"
return "NO"
if len(s) == 8:
if s == "KIHABARA" or s == "AKIHBARA" or s == "AKIHABRA" or s == "AKIHABAR":
return "YES"
return "NO"
if len(s) == 7:
if (
s == "KIHBARA"
or s == "KIHABRA"
or s == "KIHABAR"
or s == "AKIHBRA"
or s == "AKIHBAR"
or s == "AKIHABR"
):
return "YES"
return "NO"
if len(s) == 6:
if s == "KIHBRA" or s == "KIHABR" or s == "KIHBAR" or s == "AKIHBR":
return "YES"
return "NO"
if len(s) == 5:
if s == "KIHBR":
return "YES"
return "NO"
else:
return "NO"
# main()
print((main()))
| false | 29.032258 |
[
"-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time",
"+import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy",
"+dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]",
"+ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]",
"- return list(map(int, input().split()))",
"+ return [int(x) for x in sys.stdin.readline().split()]",
"-def II():",
"- return int(eval(input()))",
"+def LI_():",
"+ return [int(x) - 1 for x in sys.stdin.readline().split()]",
"+",
"+",
"+def I():",
"+ return int(sys.stdin.readline())",
"- return input().split()",
"+ return sys.stdin.readline().split()",
"- if len(s) < 5:",
"- print(\"NO\")",
"+ if len(s) > 9:",
"+ return \"NO\"",
"+ if len(s) == 9:",
"+ if s == \"AKIHABARA\":",
"+ return \"YES\"",
"+ return \"NO\"",
"+ if len(s) == 8:",
"+ if s == \"KIHABARA\" or s == \"AKIHBARA\" or s == \"AKIHABRA\" or s == \"AKIHABAR\":",
"+ return \"YES\"",
"+ return \"NO\"",
"+ if len(s) == 7:",
"+ if (",
"+ s == \"KIHBARA\"",
"+ or s == \"KIHABRA\"",
"+ or s == \"KIHABAR\"",
"+ or s == \"AKIHBRA\"",
"+ or s == \"AKIHBAR\"",
"+ or s == \"AKIHABR\"",
"+ ):",
"+ return \"YES\"",
"+ return \"NO\"",
"+ if len(s) == 6:",
"+ if s == \"KIHBRA\" or s == \"KIHABR\" or s == \"KIHBAR\" or s == \"AKIHBR\":",
"+ return \"YES\"",
"+ return \"NO\"",
"+ if len(s) == 5:",
"+ if s == \"KIHBR\":",
"+ return \"YES\"",
"+ return \"NO\"",
"- if s[-4:] == \"BARA\":",
"- if s.count(\"A\") > 4:",
"- print(\"NO\")",
"- elif s.count(\"A\") == 4:",
"- if s == \"AKIHABARA\":",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"- else:",
"- if s.count(\"KIH\") == 1:",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"- elif s[-3:] == \"BRA\" or s[-3:] == \"BAR\":",
"- if s.count(\"A\") > 3:",
"- print(\"NO\")",
"- elif s.count(\"A\") == 3:",
"- if s == \"AKIHABRA\" or s == \"AKIHABAR\":",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"- else:",
"- if s.count(\"KIH\") == 1:",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"- elif s[-2:] == \"BR\":",
"- if s.count(\"A\") > 2:",
"- print(\"NO\")",
"- elif s.count(\"A\") == 2:",
"- if s == \"AKIHABR\":",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"- else:",
"- if s.count(\"KIH\") == 1:",
"- print(\"YES\")",
"- else:",
"- print(\"NO\")",
"- else:",
"- print(\"NO\")",
"+ return \"NO\"",
"-main()",
"+# main()",
"+print((main()))"
] | false | 0.044975 | 0.044489 | 1.010929 |
[
"s563946979",
"s672205841"
] |
u671060652
|
p02953
|
python
|
s992443908
|
s568596663
| 238 | 73 | 63,984 | 85,008 |
Accepted
|
Accepted
| 69.33 |
n = int(eval(input()))
listH = list(map(int, input().split()))
for i in range(0, n-1):
if(listH[i+1] - listH[i] == -1):
listH[i+1] += 1
if(listH[i+1] - listH[i] < -1):
print("No")
quit()
print("Yes")
|
n = int(eval(input()))
h = list(map(int, input().split()))
for i in range(n-1):
if h[i+1] - h[i] == -1:
h[i+1] += 1
elif h[i+1] - h[i] < -1:
print("No")
quit()
print("Yes")
| 12 | 11 | 239 | 210 |
n = int(eval(input()))
listH = list(map(int, input().split()))
for i in range(0, n - 1):
if listH[i + 1] - listH[i] == -1:
listH[i + 1] += 1
if listH[i + 1] - listH[i] < -1:
print("No")
quit()
print("Yes")
|
n = int(eval(input()))
h = list(map(int, input().split()))
for i in range(n - 1):
if h[i + 1] - h[i] == -1:
h[i + 1] += 1
elif h[i + 1] - h[i] < -1:
print("No")
quit()
print("Yes")
| false | 8.333333 |
[
"-listH = list(map(int, input().split()))",
"-for i in range(0, n - 1):",
"- if listH[i + 1] - listH[i] == -1:",
"- listH[i + 1] += 1",
"- if listH[i + 1] - listH[i] < -1:",
"+h = list(map(int, input().split()))",
"+for i in range(n - 1):",
"+ if h[i + 1] - h[i] == -1:",
"+ h[i + 1] += 1",
"+ elif h[i + 1] - h[i] < -1:"
] | false | 0.045305 | 0.086203 | 0.525561 |
[
"s992443908",
"s568596663"
] |
u489959379
|
p03363
|
python
|
s889986893
|
s021753526
| 151 | 120 | 41,704 | 44,576 |
Accepted
|
Accepted
| 20.53 |
import sys
from collections import Counter
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
R = [0]
for i in range(n):
R.append(R[-1] + A[i])
D = Counter(R)
res = 0
for v in list(D.values()):
res += v * (v - 1) // 2
print(res)
if __name__ == '__main__':
resolve()
|
import sys
from itertools import accumulate
from collections import Counter
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
R = [0] + list(accumulate(A))
D = Counter(R)
res = 0
for v in list(D.values()):
if v >= 2:
res += v * (v - 1) // 2
print(res)
if __name__ == '__main__':
resolve()
| 26 | 25 | 432 | 454 |
import sys
from collections import Counter
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
R = [0]
for i in range(n):
R.append(R[-1] + A[i])
D = Counter(R)
res = 0
for v in list(D.values()):
res += v * (v - 1) // 2
print(res)
if __name__ == "__main__":
resolve()
|
import sys
from itertools import accumulate
from collections import Counter
sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
n = int(eval(input()))
A = list(map(int, input().split()))
R = [0] + list(accumulate(A))
D = Counter(R)
res = 0
for v in list(D.values()):
if v >= 2:
res += v * (v - 1) // 2
print(res)
if __name__ == "__main__":
resolve()
| false | 3.846154 |
[
"+from itertools import accumulate",
"- R = [0]",
"- for i in range(n):",
"- R.append(R[-1] + A[i])",
"+ R = [0] + list(accumulate(A))",
"- res += v * (v - 1) // 2",
"+ if v >= 2:",
"+ res += v * (v - 1) // 2"
] | false | 0.035715 | 0.044597 | 0.800833 |
[
"s889986893",
"s021753526"
] |
u089142196
|
p03244
|
python
|
s941597261
|
s667056988
| 185 | 97 | 17,544 | 19,040 |
Accepted
|
Accepted
| 47.57 |
from collections import Counter
n=int(eval(input()))
v=list(map(int,input().split()))
A=v[0::2]
B=v[1::2]
a=len(A)
b=len(B)
#print(Counter(A).most_common()[0][0])
#print(Counter(B).most_common()[0][0])
if Counter(A).most_common()[0][0] !=Counter(B).most_common()[0][0]:
s=Counter(A).most_common()[0][1]
t=Counter(B).most_common()[0][1]
print(( (a-s)+(b-t)))
else:
r=a
s=b
if Counter(A).most_common()[0][1]<a:
o=Counter(A).most_common()[1][1]
p=Counter(B).most_common()[0][1]
r= (a-o)+(b-p)
if Counter(B).most_common()[0][1]<b:
w=Counter(A).most_common()[0][1]
x=Counter(B).most_common()[1][1]
s= (a-w)+(b-x)
print((min( r, s)))
|
from collections import Counter
n=int(eval(input()))
a=list(map(int, input().split()))
b=[a[i] for i in range(n) if i%2==0]
c=[a[i] for i in range(n) if i%2==1]
b2=Counter(b)
c2=Counter(c)
b3=b2.most_common(2)
c3=c2.most_common(2)
ans=n
for i in b3:
for j in c3:
if i[0]!=j[0]:
ans=min(ans,n-i[1]-j[1])
else:
ans=min(ans,n-max(i[1],j[1]))
print(ans)
| 28 | 17 | 694 | 404 |
from collections import Counter
n = int(eval(input()))
v = list(map(int, input().split()))
A = v[0::2]
B = v[1::2]
a = len(A)
b = len(B)
# print(Counter(A).most_common()[0][0])
# print(Counter(B).most_common()[0][0])
if Counter(A).most_common()[0][0] != Counter(B).most_common()[0][0]:
s = Counter(A).most_common()[0][1]
t = Counter(B).most_common()[0][1]
print(((a - s) + (b - t)))
else:
r = a
s = b
if Counter(A).most_common()[0][1] < a:
o = Counter(A).most_common()[1][1]
p = Counter(B).most_common()[0][1]
r = (a - o) + (b - p)
if Counter(B).most_common()[0][1] < b:
w = Counter(A).most_common()[0][1]
x = Counter(B).most_common()[1][1]
s = (a - w) + (b - x)
print((min(r, s)))
|
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
b = [a[i] for i in range(n) if i % 2 == 0]
c = [a[i] for i in range(n) if i % 2 == 1]
b2 = Counter(b)
c2 = Counter(c)
b3 = b2.most_common(2)
c3 = c2.most_common(2)
ans = n
for i in b3:
for j in c3:
if i[0] != j[0]:
ans = min(ans, n - i[1] - j[1])
else:
ans = min(ans, n - max(i[1], j[1]))
print(ans)
| false | 39.285714 |
[
"-v = list(map(int, input().split()))",
"-A = v[0::2]",
"-B = v[1::2]",
"-a = len(A)",
"-b = len(B)",
"-# print(Counter(A).most_common()[0][0])",
"-# print(Counter(B).most_common()[0][0])",
"-if Counter(A).most_common()[0][0] != Counter(B).most_common()[0][0]:",
"- s = Counter(A).most_common()[0][1]",
"- t = Counter(B).most_common()[0][1]",
"- print(((a - s) + (b - t)))",
"-else:",
"- r = a",
"- s = b",
"- if Counter(A).most_common()[0][1] < a:",
"- o = Counter(A).most_common()[1][1]",
"- p = Counter(B).most_common()[0][1]",
"- r = (a - o) + (b - p)",
"- if Counter(B).most_common()[0][1] < b:",
"- w = Counter(A).most_common()[0][1]",
"- x = Counter(B).most_common()[1][1]",
"- s = (a - w) + (b - x)",
"- print((min(r, s)))",
"+a = list(map(int, input().split()))",
"+b = [a[i] for i in range(n) if i % 2 == 0]",
"+c = [a[i] for i in range(n) if i % 2 == 1]",
"+b2 = Counter(b)",
"+c2 = Counter(c)",
"+b3 = b2.most_common(2)",
"+c3 = c2.most_common(2)",
"+ans = n",
"+for i in b3:",
"+ for j in c3:",
"+ if i[0] != j[0]:",
"+ ans = min(ans, n - i[1] - j[1])",
"+ else:",
"+ ans = min(ans, n - max(i[1], j[1]))",
"+print(ans)"
] | false | 0.073431 | 0.03733 | 1.967069 |
[
"s941597261",
"s667056988"
] |
u901447859
|
p03556
|
python
|
s733182623
|
s830738362
| 47 | 40 | 2,940 | 2,940 |
Accepted
|
Accepted
| 14.89 |
n=int(eval(input()))
for i in range(n,0,-1):
if float(i**0.5).is_integer():
print(i)
break
|
n=int(eval(input()))
for i in range(n,0,-1):
if (i**0.5)%1==0:
print(i)
break
| 6 | 6 | 100 | 87 |
n = int(eval(input()))
for i in range(n, 0, -1):
if float(i**0.5).is_integer():
print(i)
break
|
n = int(eval(input()))
for i in range(n, 0, -1):
if (i**0.5) % 1 == 0:
print(i)
break
| false | 0 |
[
"- if float(i**0.5).is_integer():",
"+ if (i**0.5) % 1 == 0:"
] | false | 0.043947 | 0.077724 | 0.565416 |
[
"s733182623",
"s830738362"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.