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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u365364616 | p02603 | python | s943272056 | s774817768 | 38 | 33 | 9,216 | 9,100 | Accepted | Accepted | 13.16 | n = int(eval(input()))
a = list(map(int, input().split()))
# dp[buy][sell]
dp = [0 for j in range(n)]
dp[0] = 1000
for i in range(n):
ai = a[i]
m = dp[i]
s = m // ai
for j in range(i + 1, n):
dp[j] = max(dp[j], m + s * (a[j] - ai))
for j in range(n - 1):
dp[j + 1] = max(dp[j + 1], dp[j])
print((dp[-1]))
| n = int(eval(input()))
a = list(map(int, input().split()))
a_cur = a[0]
m = 1000
s = 0
for i in range(1, n):
a_next = a[i]
if a_cur < a_next:
# buy current and sell next
s = m // a_cur
m += s * (a_next - a_cur)
a_cur = a_next
print(m) | 16 | 15 | 350 | 280 | n = int(eval(input()))
a = list(map(int, input().split()))
# dp[buy][sell]
dp = [0 for j in range(n)]
dp[0] = 1000
for i in range(n):
ai = a[i]
m = dp[i]
s = m // ai
for j in range(i + 1, n):
dp[j] = max(dp[j], m + s * (a[j] - ai))
for j in range(n - 1):
dp[j + 1] = max(dp[j + 1], dp[j])
print((dp[-1]))
| n = int(eval(input()))
a = list(map(int, input().split()))
a_cur = a[0]
m = 1000
s = 0
for i in range(1, n):
a_next = a[i]
if a_cur < a_next:
# buy current and sell next
s = m // a_cur
m += s * (a_next - a_cur)
a_cur = a_next
print(m)
| false | 6.25 | [
"-# dp[buy][sell]",
"-dp = [0 for j in range(n)]",
"-dp[0] = 1000",
"-for i in range(n):",
"- ai = a[i]",
"- m = dp[i]",
"- s = m // ai",
"- for j in range(i + 1, n):",
"- dp[j] = max(dp[j], m + s * (a[j] - ai))",
"- for j in range(n - 1):",
"- dp[j + 1] = max(dp[j +... | false | 0.095695 | 0.064684 | 1.479424 | [
"s943272056",
"s774817768"
] |
u861141787 | p03503 | python | s177448312 | s784462255 | 317 | 101 | 3,064 | 3,064 | Accepted | Accepted | 68.14 | N = int(eval(input()))
Flists = [list(map(int, input().split())) for _ in range(N)]
Plists = [list(map(int, input().split())) for _ in range(N)]
ans = -10**9
for i in range(1, 2**10):
open = []
for j in range(10):
if ((i>>j) & 1):
open.append(1)
else:
open.append(0)
money = 0
for num in range(N):
Flist = Flists[num]
same = sum([int(open[_] and Flist[_]) for _ in range(10)])
money += Plists[num][same]
ans = max(ans, money)
print(ans)
| N = int(eval(input()))
F = [int("".join(input().split()), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
# for i in range(N):
# print(bin(F[i]))
ans = -10**9
for bit in range(1, 1<<10):
money = 0
for i in range(N):
cnt = format(bit&F[i], 'b').count('1')
money += P[i][cnt]
ans = max(money, ans)
print(ans)
| 20 | 16 | 536 | 382 | N = int(eval(input()))
Flists = [list(map(int, input().split())) for _ in range(N)]
Plists = [list(map(int, input().split())) for _ in range(N)]
ans = -(10**9)
for i in range(1, 2**10):
open = []
for j in range(10):
if (i >> j) & 1:
open.append(1)
else:
open.append(0)
money = 0
for num in range(N):
Flist = Flists[num]
same = sum([int(open[_] and Flist[_]) for _ in range(10)])
money += Plists[num][same]
ans = max(ans, money)
print(ans)
| N = int(eval(input()))
F = [int("".join(input().split()), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
# for i in range(N):
# print(bin(F[i]))
ans = -(10**9)
for bit in range(1, 1 << 10):
money = 0
for i in range(N):
cnt = format(bit & F[i], "b").count("1")
money += P[i][cnt]
ans = max(money, ans)
print(ans)
| false | 20 | [
"-Flists = [list(map(int, input().split())) for _ in range(N)]",
"-Plists = [list(map(int, input().split())) for _ in range(N)]",
"+F = [int(\"\".join(input().split()), 2) for _ in range(N)]",
"+P = [list(map(int, input().split())) for _ in range(N)]",
"+# for i in range(N):",
"+# print(bin(F[i]))",
... | false | 0.043991 | 0.044532 | 0.987847 | [
"s177448312",
"s784462255"
] |
u801247169 | p03610 | python | s394865373 | s640698906 | 43 | 27 | 9,208 | 9,048 | Accepted | Accepted | 37.21 | s = eval(input ())
odd_num = list()
for i in range(len(s)):
if i % 2 == 0:
odd_num.append(s[i])
answer = "".join(odd_num)
print(answer)
| s = eval(input())
print((s[::2])) | 9 | 2 | 152 | 26 | s = eval(input())
odd_num = list()
for i in range(len(s)):
if i % 2 == 0:
odd_num.append(s[i])
answer = "".join(odd_num)
print(answer)
| s = eval(input())
print((s[::2]))
| false | 77.777778 | [
"-odd_num = list()",
"-for i in range(len(s)):",
"- if i % 2 == 0:",
"- odd_num.append(s[i])",
"-answer = \"\".join(odd_num)",
"-print(answer)",
"+print((s[::2]))"
] | false | 0.041132 | 0.047135 | 0.872646 | [
"s394865373",
"s640698906"
] |
u485319545 | p03835 | python | s922901974 | s736925611 | 1,481 | 1,192 | 3,060 | 8,920 | Accepted | Accepted | 19.51 | import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5+10)
# input処理を高速化する
input = sys.stdin.readline
K,S = list(map(int,input().split()))
cnt = 0
for x in range(K+1):
for y in range(K+1):
z =S - x - y
if z <=K and z>=0:
cnt +=1
print(cnt) | k,s = list(map(int,input().split()))
cnt=0
for x in range(k+1):
for y in range(k+1):
z = s -x- y
if 0<=z and z<=k:
cnt+=1
print(cnt)
| 16 | 10 | 284 | 171 | import sys
# 許容する再帰処理の回数を変更
sys.setrecursionlimit(10**5 + 10)
# input処理を高速化する
input = sys.stdin.readline
K, S = list(map(int, input().split()))
cnt = 0
for x in range(K + 1):
for y in range(K + 1):
z = S - x - y
if z <= K and z >= 0:
cnt += 1
print(cnt)
| k, s = list(map(int, input().split()))
cnt = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 <= z and z <= k:
cnt += 1
print(cnt)
| false | 37.5 | [
"-import sys",
"-",
"-# 許容する再帰処理の回数を変更",
"-sys.setrecursionlimit(10**5 + 10)",
"-# input処理を高速化する",
"-input = sys.stdin.readline",
"-K, S = list(map(int, input().split()))",
"+k, s = list(map(int, input().split()))",
"-for x in range(K + 1):",
"- for y in range(K + 1):",
"- z = S - x - ... | false | 0.039215 | 0.037685 | 1.040599 | [
"s922901974",
"s736925611"
] |
u952708174 | p02614 | python | s981227283 | s772115446 | 101 | 37 | 68,932 | 8,996 | Accepted | Accepted | 63.37 | def c_h_and_v():
from itertools import combinations
H, W, K = [int(i) for i in input().split()]
C = [eval(input()) for _ in range(H)]
ans = 0
for row_num in range(H + 1):
for rows in combinations(list(range(H)), row_num):
for col_num in range(W + 1):
for cols in combinations(list(range(W)), col_num):
tmp = 0
for r in range(H):
for c in range(W):
if r in rows or c in cols:
continue
if C[r][c] == '#':
tmp += 1
if tmp == K:
ans += 1
return ans
print((c_h_and_v())) | def c_h_and_v():
from itertools import product
H, W, K = [int(i) for i in input().split()]
C = [eval(input()) for _ in range(H)]
ans = 0
for rows in product([True, False], repeat=H):
for cols in product([True, False], repeat=W):
remain = 0
for r, c in product(list(range(H)), list(range(W))):
if rows[r] and cols[c] and C[r][c] == '#':
remain += 1
if remain == K:
ans += 1
return ans
print((c_h_and_v())) | 23 | 17 | 758 | 522 | def c_h_and_v():
from itertools import combinations
H, W, K = [int(i) for i in input().split()]
C = [eval(input()) for _ in range(H)]
ans = 0
for row_num in range(H + 1):
for rows in combinations(list(range(H)), row_num):
for col_num in range(W + 1):
for cols in combinations(list(range(W)), col_num):
tmp = 0
for r in range(H):
for c in range(W):
if r in rows or c in cols:
continue
if C[r][c] == "#":
tmp += 1
if tmp == K:
ans += 1
return ans
print((c_h_and_v()))
| def c_h_and_v():
from itertools import product
H, W, K = [int(i) for i in input().split()]
C = [eval(input()) for _ in range(H)]
ans = 0
for rows in product([True, False], repeat=H):
for cols in product([True, False], repeat=W):
remain = 0
for r, c in product(list(range(H)), list(range(W))):
if rows[r] and cols[c] and C[r][c] == "#":
remain += 1
if remain == K:
ans += 1
return ans
print((c_h_and_v()))
| false | 26.086957 | [
"- from itertools import combinations",
"+ from itertools import product",
"- for row_num in range(H + 1):",
"- for rows in combinations(list(range(H)), row_num):",
"- for col_num in range(W + 1):",
"- for cols in combinations(list(range(W)), col_num):",
"- ... | false | 0.043819 | 0.045966 | 0.953282 | [
"s981227283",
"s772115446"
] |
u201234972 | p02973 | python | s337353567 | s339318888 | 819 | 557 | 54,212 | 47,068 | Accepted | Accepted | 31.99 | #import sys
#input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
N = int( eval(input()))
A = [ int( eval(input())) for _ in range(N)]
d = deque()
for a in A:
t = bisect_right(d, a)
if t == 0:
d.appendleft(a)
continue
if d[t-1] == a:
t = bisect_left(d, a)
if t == 0:
d.appendleft(a)
else:
d[t-1] = a
print((len(d)))
if __name__ == '__main__':
main()
| import sys
input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
N = int( eval(input()))
A = [ int( eval(input())) for _ in range(N)]
d = deque()
for a in A:
t = bisect_right(d, a)
if t == 0:
d.appendleft(a)
continue
if d[t-1] == a:
t = bisect_left(d, a)
if t == 0:
d.appendleft(a)
else:
d[t-1] = a
print((len(d)))
if __name__ == '__main__':
main()
| 22 | 23 | 542 | 542 | # import sys
# input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
d = deque()
for a in A:
t = bisect_right(d, a)
if t == 0:
d.appendleft(a)
continue
if d[t - 1] == a:
t = bisect_left(d, a)
if t == 0:
d.appendleft(a)
else:
d[t - 1] = a
print((len(d)))
if __name__ == "__main__":
main()
| import sys
input = sys.stdin.readline
from collections import deque
from bisect import bisect_right, bisect_left
def main():
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
d = deque()
for a in A:
t = bisect_right(d, a)
if t == 0:
d.appendleft(a)
continue
if d[t - 1] == a:
t = bisect_left(d, a)
if t == 0:
d.appendleft(a)
else:
d[t - 1] = a
print((len(d)))
if __name__ == "__main__":
main()
| false | 4.347826 | [
"-# import sys",
"-# input = sys.stdin.readline",
"+import sys",
"+",
"+input = sys.stdin.readline"
] | false | 0.037043 | 0.036915 | 1.003458 | [
"s337353567",
"s339318888"
] |
u652656291 | p03127 | python | s405714965 | s021368824 | 197 | 79 | 23,124 | 16,200 | Accepted | Accepted | 59.9 | import numpy as np
def gcd(a,b):
while b:
a,b = b,a%b
return a
N = int(eval(input()))
A = np.array([int(x) for x in input().split()],dtype=object)
gcd = np.frompyfunc(gcd,2,1)
print((gcd.reduce(A)))
| from functools import reduce
from fractions import gcd
eval(input())
a=list(map(int,input().split()))
print((reduce(gcd,a)))
| 12 | 6 | 213 | 123 | import numpy as np
def gcd(a, b):
while b:
a, b = b, a % b
return a
N = int(eval(input()))
A = np.array([int(x) for x in input().split()], dtype=object)
gcd = np.frompyfunc(gcd, 2, 1)
print((gcd.reduce(A)))
| from functools import reduce
from fractions import gcd
eval(input())
a = list(map(int, input().split()))
print((reduce(gcd, a)))
| false | 50 | [
"-import numpy as np",
"+from functools import reduce",
"+from fractions import gcd",
"-",
"-def gcd(a, b):",
"- while b:",
"- a, b = b, a % b",
"- return a",
"-",
"-",
"-N = int(eval(input()))",
"-A = np.array([int(x) for x in input().split()], dtype=object)",
"-gcd = np.frompy... | false | 0.275235 | 0.043998 | 6.255633 | [
"s405714965",
"s021368824"
] |
u358957649 | p02780 | python | s580376817 | s069233852 | 216 | 138 | 25,604 | 25,060 | Accepted | Accepted | 36.11 | def main(n,k,p):
res = 0
#期待値リスト
kitai = [0] * n
ruiseki = [0] * n
kitai[0] = (p[0] + 1) / 2
ruiseki[0] = kitai[0]
if n == 1:
return kitai[0]
else:
for i in range(1, len(p)):
kitai[i] = (p[i] + 1) / 2
ruiseki[i] = ruiseki[i-1] + kitai[i]
for i in range(k-1, len(ruiseki)):
res = max(res, ruiseki[i] - (ruiseki[i-k] if (i-k) >= 0 else 0))
return res
n,k = list(map(int, input().split()))
p = list(map(int,input().split()))
print((main(n,k,p))) | def main2(n,k,p):
maxVal = 0
#期待値リスト
kitai = [0] * n
for i in range(n):
kitai[i] = (p[i] + 1) / 2
#先頭からK個の合計
val = sum(kitai[:k])
#kとnが同じ場合return
if k == n:
return val
for i in range(k,n):
#次の値は現在のvalにkitai[i]を足して、kitai[i-k]を引いた値
val = val + kitai[i] - kitai[i-k]
maxVal = max(maxVal, val)
return maxVal
n,k = list(map(int, input().split()))
p = list(map(int,input().split()))
print((main2(n,k,p))) | 21 | 20 | 544 | 490 | def main(n, k, p):
res = 0
# 期待値リスト
kitai = [0] * n
ruiseki = [0] * n
kitai[0] = (p[0] + 1) / 2
ruiseki[0] = kitai[0]
if n == 1:
return kitai[0]
else:
for i in range(1, len(p)):
kitai[i] = (p[i] + 1) / 2
ruiseki[i] = ruiseki[i - 1] + kitai[i]
for i in range(k - 1, len(ruiseki)):
res = max(res, ruiseki[i] - (ruiseki[i - k] if (i - k) >= 0 else 0))
return res
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
print((main(n, k, p)))
| def main2(n, k, p):
maxVal = 0
# 期待値リスト
kitai = [0] * n
for i in range(n):
kitai[i] = (p[i] + 1) / 2
# 先頭からK個の合計
val = sum(kitai[:k])
# kとnが同じ場合return
if k == n:
return val
for i in range(k, n):
# 次の値は現在のvalにkitai[i]を足して、kitai[i-k]を引いた値
val = val + kitai[i] - kitai[i - k]
maxVal = max(maxVal, val)
return maxVal
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
print((main2(n, k, p)))
| false | 4.761905 | [
"-def main(n, k, p):",
"- res = 0",
"+def main2(n, k, p):",
"+ maxVal = 0",
"- ruiseki = [0] * n",
"- kitai[0] = (p[0] + 1) / 2",
"- ruiseki[0] = kitai[0]",
"- if n == 1:",
"- return kitai[0]",
"- else:",
"- for i in range(1, len(p)):",
"- kitai[i]... | false | 0.038283 | 0.038587 | 0.992131 | [
"s580376817",
"s069233852"
] |
u579699847 | p02887 | python | s392264203 | s262947761 | 178 | 54 | 49,904 | 15,860 | Accepted | Accepted | 69.66 | N = int(eval(input()))
S = list(eval(input()))
count = 1
for i in range(len(S)-1):
if S[i] != S[i+1]:
count += 1
print(count)
| import itertools
N = eval(input())
S = eval(input())
G = itertools.groupby(S)
print((len(list(G))))
| 8 | 5 | 137 | 90 | N = int(eval(input()))
S = list(eval(input()))
count = 1
for i in range(len(S) - 1):
if S[i] != S[i + 1]:
count += 1
print(count)
| import itertools
N = eval(input())
S = eval(input())
G = itertools.groupby(S)
print((len(list(G))))
| false | 37.5 | [
"-N = int(eval(input()))",
"-S = list(eval(input()))",
"-count = 1",
"-for i in range(len(S) - 1):",
"- if S[i] != S[i + 1]:",
"- count += 1",
"-print(count)",
"+import itertools",
"+",
"+N = eval(input())",
"+S = eval(input())",
"+G = itertools.groupby(S)",
"+print((len(list(G))))... | false | 0.046615 | 0.051581 | 0.90372 | [
"s392264203",
"s262947761"
] |
u888337853 | p03504 | python | s890058198 | s123330489 | 267 | 240 | 181,964 | 181,964 | Accepted | Accepted | 10.11 | import sys
import math
import collections
import bisect
import itertools
# import numpy as np
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353
ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])
# ===CODE===
def main():
n, c = ns()
l = 10 ** 5
table = [[0 for _ in range(l + 10)] for __ in range(c)]
for _ in range(n):
s, t, ci = ns()
ci -= 1
table[ci][s] += 1
table[ci][t] -= 1
ans = 0
tmp = 0
for i in range(l + 10):
fin = 0
for j in range(c):
if table[j][i] > 0:
tmp += table[j][i]
else:
fin += table[j][i]
ans = max(ans, tmp)
tmp += fin
print(ans)
if __name__ == '__main__':
main()
| import sys
import math
import collections
import bisect
import itertools
# import numpy as np
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353
ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])
# ===CODE===
def main():
n, c = ns()
l = 10 ** 5
table = [[0 for _ in range(l + 1)] for __ in range(c)]
for _ in range(n):
s, t, ci = ns()
ci -= 1
table[ci][s] += 1
table[ci][t] -= 1
ans = 0
tmp = 0
for i in range(l + 1):
fin = 0
for j in range(c):
if table[j][i] > 0:
tmp += table[j][i]
else:
fin += table[j][i]
ans = max(ans, tmp)
tmp += fin
print(ans)
if __name__ == '__main__':
main()
| 48 | 48 | 1,041 | 1,039 | import sys
import math
import collections
import bisect
import itertools
# import numpy as np
sys.setrecursionlimit(10**7)
INF = 10**16
MOD = 10**9 + 7
# MOD = 998244353
ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])
# ===CODE===
def main():
n, c = ns()
l = 10**5
table = [[0 for _ in range(l + 10)] for __ in range(c)]
for _ in range(n):
s, t, ci = ns()
ci -= 1
table[ci][s] += 1
table[ci][t] -= 1
ans = 0
tmp = 0
for i in range(l + 10):
fin = 0
for j in range(c):
if table[j][i] > 0:
tmp += table[j][i]
else:
fin += table[j][i]
ans = max(ans, tmp)
tmp += fin
print(ans)
if __name__ == "__main__":
main()
| import sys
import math
import collections
import bisect
import itertools
# import numpy as np
sys.setrecursionlimit(10**7)
INF = 10**16
MOD = 10**9 + 7
# MOD = 998244353
ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().rstrip().split()])
# ===CODE===
def main():
n, c = ns()
l = 10**5
table = [[0 for _ in range(l + 1)] for __ in range(c)]
for _ in range(n):
s, t, ci = ns()
ci -= 1
table[ci][s] += 1
table[ci][t] -= 1
ans = 0
tmp = 0
for i in range(l + 1):
fin = 0
for j in range(c):
if table[j][i] > 0:
tmp += table[j][i]
else:
fin += table[j][i]
ans = max(ans, tmp)
tmp += fin
print(ans)
if __name__ == "__main__":
main()
| false | 0 | [
"- table = [[0 for _ in range(l + 10)] for __ in range(c)]",
"+ table = [[0 for _ in range(l + 1)] for __ in range(c)]",
"- for i in range(l + 10):",
"+ for i in range(l + 1):"
] | false | 0.25974 | 0.270756 | 0.959314 | [
"s890058198",
"s123330489"
] |
u401452016 | p03371 | python | s603839400 | s474482883 | 114 | 18 | 3,060 | 3,060 | Accepted | Accepted | 84.21 | # 095C
import sys
A,B,C,x,y = list(map(int, sys.stdin.readline().split()))
ans = float('inf')
for i in range(0, 2*max(x, y)+1, 2):
tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0)
#print(tmp, i)
if ans > tmp:
ans = tmp
print(ans) | #ABC095C
def main():
import sys, math
A,B,C,X,Y = list(map(int, sys.stdin.readline().split()))
L =[]
#全部C
L.append(max(X, Y)*2*C)
#できるだけC 不足分A,B
if X <= Y:
L +=[X*2*C + (Y-X)*B]
else:
L +=[Y*2*C + (X-Y)*A]
#全部A,B
L.append(A*X+B*Y)
print((min(L)))
if __name__=='__main__':
main()
| 11 | 21 | 254 | 367 | # 095C
import sys
A, B, C, x, y = list(map(int, sys.stdin.readline().split()))
ans = float("inf")
for i in range(0, 2 * max(x, y) + 1, 2):
tmp = A * max(x - i // 2, 0) + C * i + B * max(y - i // 2, 0)
# print(tmp, i)
if ans > tmp:
ans = tmp
print(ans)
| # ABC095C
def main():
import sys, math
A, B, C, X, Y = list(map(int, sys.stdin.readline().split()))
L = []
# 全部C
L.append(max(X, Y) * 2 * C)
# できるだけC 不足分A,B
if X <= Y:
L += [X * 2 * C + (Y - X) * B]
else:
L += [Y * 2 * C + (X - Y) * A]
# 全部A,B
L.append(A * X + B * Y)
print((min(L)))
if __name__ == "__main__":
main()
| false | 47.619048 | [
"-# 095C",
"-import sys",
"+# ABC095C",
"+def main():",
"+ import sys, math",
"-A, B, C, x, y = list(map(int, sys.stdin.readline().split()))",
"-ans = float(\"inf\")",
"-for i in range(0, 2 * max(x, y) + 1, 2):",
"- tmp = A * max(x - i // 2, 0) + C * i + B * max(y - i // 2, 0)",
"- # pri... | false | 0.063744 | 0.036019 | 1.769736 | [
"s603839400",
"s474482883"
] |
u227082700 | p04034 | python | s813051275 | s868355904 | 347 | 233 | 4,596 | 10,276 | Accepted | Accepted | 32.85 | n,m=list(map(int,input().split()))
x=[0]*n
x[0]=1
y=[1]*n
for i in range(m):
a,b=list(map(int,input().split()))
if x[a-1]==1:x[b-1]=1
y[a-1]-=1
y[b-1]+=1
if y[a-1]==0:x[a-1]=0
print((sum(x))) | n,m=list(map(int,input().split()))
ans=[False]*n
ans[0]=True
co=[1]*n
for i in range(m):
x,y=list(map(int,input().split()))
ans[y-1]|=ans[x-1]
co[x-1]-=1
co[y-1]+=1
if co[x-1]==0:ans[x-1]=False
print((ans.count(True))) | 11 | 11 | 197 | 224 | n, m = list(map(int, input().split()))
x = [0] * n
x[0] = 1
y = [1] * n
for i in range(m):
a, b = list(map(int, input().split()))
if x[a - 1] == 1:
x[b - 1] = 1
y[a - 1] -= 1
y[b - 1] += 1
if y[a - 1] == 0:
x[a - 1] = 0
print((sum(x)))
| n, m = list(map(int, input().split()))
ans = [False] * n
ans[0] = True
co = [1] * n
for i in range(m):
x, y = list(map(int, input().split()))
ans[y - 1] |= ans[x - 1]
co[x - 1] -= 1
co[y - 1] += 1
if co[x - 1] == 0:
ans[x - 1] = False
print((ans.count(True)))
| false | 0 | [
"-x = [0] * n",
"-x[0] = 1",
"-y = [1] * n",
"+ans = [False] * n",
"+ans[0] = True",
"+co = [1] * n",
"- a, b = list(map(int, input().split()))",
"- if x[a - 1] == 1:",
"- x[b - 1] = 1",
"- y[a - 1] -= 1",
"- y[b - 1] += 1",
"- if y[a - 1] == 0:",
"- x[a - 1] = 0... | false | 0.075023 | 0.124999 | 0.600195 | [
"s813051275",
"s868355904"
] |
u530606147 | p02612 | python | s013240970 | s241360169 | 31 | 27 | 9,116 | 8,996 | Accepted | Accepted | 12.9 | import math
n = int(eval(input()))
print((math.ceil(n/1000)*1000-n))
| n = int(eval(input()))
p = 0
while p < n:
p += 1000
print((p - n))
| 5 | 6 | 67 | 67 | import math
n = int(eval(input()))
print((math.ceil(n / 1000) * 1000 - n))
| n = int(eval(input()))
p = 0
while p < n:
p += 1000
print((p - n))
| false | 16.666667 | [
"-import math",
"-",
"-print((math.ceil(n / 1000) * 1000 - n))",
"+p = 0",
"+while p < n:",
"+ p += 1000",
"+print((p - n))"
] | false | 0.10215 | 0.048754 | 2.095214 | [
"s013240970",
"s241360169"
] |
u761989513 | p03380 | python | s576211968 | s753554581 | 109 | 70 | 14,432 | 14,428 | Accepted | Accepted | 35.78 | n = int(eval(input()))
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
half = a[0] / 2
sa = float("inf")
ans = 0
for i in a[1:]:
if abs(half - i) < sa:
ans = i
sa = abs(half - i)
print((a[0], ans)) | n = int(eval(input()))
a = list(map(int, input().split()))
m = max(a)
half = m / 2
sa = float("inf")
ans = 0
for i in a:
if i != m:
if abs(half - i) < sa:
ans = i
sa = abs(half - i)
print((m, ans)) | 13 | 14 | 239 | 240 | n = int(eval(input()))
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
half = a[0] / 2
sa = float("inf")
ans = 0
for i in a[1:]:
if abs(half - i) < sa:
ans = i
sa = abs(half - i)
print((a[0], ans))
| n = int(eval(input()))
a = list(map(int, input().split()))
m = max(a)
half = m / 2
sa = float("inf")
ans = 0
for i in a:
if i != m:
if abs(half - i) < sa:
ans = i
sa = abs(half - i)
print((m, ans))
| false | 7.142857 | [
"-a = sorted(a, reverse=True)",
"-half = a[0] / 2",
"+m = max(a)",
"+half = m / 2",
"-for i in a[1:]:",
"- if abs(half - i) < sa:",
"- ans = i",
"- sa = abs(half - i)",
"-print((a[0], ans))",
"+for i in a:",
"+ if i != m:",
"+ if abs(half - i) < sa:",
"+ ... | false | 0.088149 | 0.061301 | 1.437977 | [
"s576211968",
"s753554581"
] |
u729133443 | p02837 | python | s872066253 | s136911029 | 1,030 | 114 | 3,064 | 3,060 | Accepted | Accepted | 88.93 | n=int(eval(input()))
a=[[list(map(int,input().split()))for _ in'_'*int(eval(input()))]for _ in'_'*n]
m=0
for i in range(2**n):
*s,=list(map(int,bin(i)[2:].zfill(n)))
f=1
for j,t in enumerate(a):
if s[~j]:
for x,y in t:f&=s[-x]==y
m=max(m,sum(s)*f)
print(m) | i=input
n=int(i())
a=eval('[list(map(int,i().split()))for _ in"_"*int(i())],'*n)
print((max(all(y==i>>x-1&1for j,t in enumerate(a)if i>>j&1for x,y in t)*bin(i).count('1')for i in range(2**n)))) | 11 | 4 | 266 | 194 | n = int(eval(input()))
a = [
[list(map(int, input().split())) for _ in "_" * int(eval(input()))] for _ in "_" * n
]
m = 0
for i in range(2**n):
(*s,) = list(map(int, bin(i)[2:].zfill(n)))
f = 1
for j, t in enumerate(a):
if s[~j]:
for x, y in t:
f &= s[-x] == y
m = max(m, sum(s) * f)
print(m)
| i = input
n = int(i())
a = eval('[list(map(int,i().split()))for _ in"_"*int(i())],' * n)
print(
(
max(
all(
y == i >> x - 1 & 1 for j, t in enumerate(a) if i >> j & 1 for x, y in t
)
* bin(i).count("1")
for i in range(2**n)
)
)
)
| false | 63.636364 | [
"-n = int(eval(input()))",
"-a = [",
"- [list(map(int, input().split())) for _ in \"_\" * int(eval(input()))] for _ in \"_\" * n",
"-]",
"-m = 0",
"-for i in range(2**n):",
"- (*s,) = list(map(int, bin(i)[2:].zfill(n)))",
"- f = 1",
"- for j, t in enumerate(a):",
"- if s[~j]:",
... | false | 0.045933 | 0.037007 | 1.24119 | [
"s872066253",
"s136911029"
] |
u966891144 | p02714 | python | s986129982 | s074608387 | 1,439 | 796 | 9,188 | 9,196 | Accepted | Accepted | 44.68 | N = int(eval(input()))
S = eval(input())
ans = S.count('R')*S.count('G')*S.count('B')
for i in range(N):
for d in range(N):
j = i+d
k = j+d
if k >= N:
break
if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
ans -= 1
print(ans)
| def main():
N=int(eval(input()))
S=eval(input())
ans=S.count('R')*S.count('G')*S.count('B')
for i in range(N):
for d in range(N):
j = i+d
k = j+d
if k >= N:
break
if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
ans-=1
print(ans)
main() | 12 | 14 | 287 | 341 | N = int(eval(input()))
S = eval(input())
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
for d in range(N):
j = i + d
k = j + d
if k >= N:
break
if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
ans -= 1
print(ans)
| def main():
N = int(eval(input()))
S = eval(input())
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N):
for d in range(N):
j = i + d
k = j + d
if k >= N:
break
if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
ans -= 1
print(ans)
main()
| false | 14.285714 | [
"-N = int(eval(input()))",
"-S = eval(input())",
"-ans = S.count(\"R\") * S.count(\"G\") * S.count(\"B\")",
"-for i in range(N):",
"- for d in range(N):",
"- j = i + d",
"- k = j + d",
"- if k >= N:",
"- break",
"- if S[i] != S[j] and S[j] != S[k] and S[k]... | false | 0.087589 | 0.007321 | 11.963933 | [
"s986129982",
"s074608387"
] |
u750822433 | p03087 | python | s282673652 | s574770816 | 1,019 | 629 | 51,344 | 54,416 | Accepted | Accepted | 38.27 | N,Q=list(map(int,input().split()))
S=eval(input())
l=0
r=0
s=[]
s.append(0)
for i in range(1,N):
if(S[i-1]=='A' and S[i]=='C'):
s.append(s[i-1]+1)
else:
s.append(s[i-1])
for i in range(Q):
l,r=list(map(int,input().split()))
print((s[r-1]-s[l-1]))
| N,Q=list(map(int,input().split()))
S=eval(input())
l=0
r=0
l=[0]*Q
r=[0]*Q
s=[]
s.append(0)
for i in range(1,N):
if(S[i-1]=='A' and S[i]=='C'):
s.append(s[i-1]+1)
else:
s.append(s[i-1])
for i in range(Q):
l[i],r[i]=list(map(int,input().split()))
for i in range(Q):
print((s[r[i]-1]-s[l[i]-1]))
| 21 | 23 | 286 | 334 | N, Q = list(map(int, input().split()))
S = eval(input())
l = 0
r = 0
s = []
s.append(0)
for i in range(1, N):
if S[i - 1] == "A" and S[i] == "C":
s.append(s[i - 1] + 1)
else:
s.append(s[i - 1])
for i in range(Q):
l, r = list(map(int, input().split()))
print((s[r - 1] - s[l - 1]))
| N, Q = list(map(int, input().split()))
S = eval(input())
l = 0
r = 0
l = [0] * Q
r = [0] * Q
s = []
s.append(0)
for i in range(1, N):
if S[i - 1] == "A" and S[i] == "C":
s.append(s[i - 1] + 1)
else:
s.append(s[i - 1])
for i in range(Q):
l[i], r[i] = list(map(int, input().split()))
for i in range(Q):
print((s[r[i] - 1] - s[l[i] - 1]))
| false | 8.695652 | [
"+l = [0] * Q",
"+r = [0] * Q",
"- l, r = list(map(int, input().split()))",
"- print((s[r - 1] - s[l - 1]))",
"+ l[i], r[i] = list(map(int, input().split()))",
"+for i in range(Q):",
"+ print((s[r[i] - 1] - s[l[i] - 1]))"
] | false | 0.040024 | 0.040003 | 1.000528 | [
"s282673652",
"s574770816"
] |
u014333473 | p03455 | python | s699301293 | s834253855 | 22 | 16 | 3,572 | 2,940 | Accepted | Accepted | 27.27 | import functools
import operator
print(('Even' if (functools.reduce(operator.mul,list(map(int,input().split()))))%2==0 else 'Odd')) | print(('Odd' if len([1 for i in list(map(int,input().split())) if i%2!=0])==2 else 'Even')) | 3 | 1 | 131 | 89 | import functools
import operator
print(
(
"Even"
if (functools.reduce(operator.mul, list(map(int, input().split())))) % 2 == 0
else "Odd"
)
)
| print(
(
"Odd"
if len([1 for i in list(map(int, input().split())) if i % 2 != 0]) == 2
else "Even"
)
)
| false | 66.666667 | [
"-import functools",
"-import operator",
"-",
"- \"Even\"",
"- if (functools.reduce(operator.mul, list(map(int, input().split())))) % 2 == 0",
"- else \"Odd\"",
"+ \"Odd\"",
"+ if len([1 for i in list(map(int, input().split())) if i % 2 != 0]) == 2",
"+ else... | false | 0.099209 | 0.14933 | 0.66436 | [
"s699301293",
"s834253855"
] |
u581187895 | p02873 | python | s002175350 | s462994839 | 396 | 345 | 35,488 | 23,336 | Accepted | Accepted | 12.88 | S = eval(input())
N = len(S)+1
from_left = [0]*N
from_right = [0]*N
ii = [0]*N
for i, s in enumerate(S, 1):
if s == '>':
from_left[i] = 0
else:
from_left[i] = from_left[i-1]+1
for i,s in enumerate(S[::-1]):
i = N-2-i
if s == '<':
from_right[i] = 0
else:
from_right[i] = from_right[i+1]+1
seq = [max(x,y) for x, y in zip(from_left, from_right)]
answer = sum(seq)
print(answer) | S = eval(input())
N = len(S)+1
A = [0]*N
for i in range(N-1):
if S[i] == '<':
A[i+1] = A[i]+1
for i in range(N-2, -1, -1):
if S[i] == '>':
A[i] = max(A[i], A[i+1]+1)
print((sum(A))) | 22 | 13 | 431 | 208 | S = eval(input())
N = len(S) + 1
from_left = [0] * N
from_right = [0] * N
ii = [0] * N
for i, s in enumerate(S, 1):
if s == ">":
from_left[i] = 0
else:
from_left[i] = from_left[i - 1] + 1
for i, s in enumerate(S[::-1]):
i = N - 2 - i
if s == "<":
from_right[i] = 0
else:
from_right[i] = from_right[i + 1] + 1
seq = [max(x, y) for x, y in zip(from_left, from_right)]
answer = sum(seq)
print(answer)
| S = eval(input())
N = len(S) + 1
A = [0] * N
for i in range(N - 1):
if S[i] == "<":
A[i + 1] = A[i] + 1
for i in range(N - 2, -1, -1):
if S[i] == ">":
A[i] = max(A[i], A[i + 1] + 1)
print((sum(A)))
| false | 40.909091 | [
"-from_left = [0] * N",
"-from_right = [0] * N",
"-ii = [0] * N",
"-for i, s in enumerate(S, 1):",
"- if s == \">\":",
"- from_left[i] = 0",
"- else:",
"- from_left[i] = from_left[i - 1] + 1",
"-for i, s in enumerate(S[::-1]):",
"- i = N - 2 - i",
"- if s == \"<\":",
... | false | 0.042699 | 0.047254 | 0.903606 | [
"s002175350",
"s462994839"
] |
u941438707 | p03680 | python | s833312258 | s081222736 | 201 | 71 | 7,084 | 20,204 | Accepted | Accepted | 64.68 | n=int(eval(input()))
a=[int(eval(input())) for _ in range(n)]
b=a[0]
c=1
ans=-1
for i in range(10**5):
if b==2:
ans=c
break
b=a[b-1]
c+=1
print(ans) | n,*a=list(map(int,open(0).read().split()))
i=ans=1
while a[i-1]!=2 and ans<=n:
ans+=1
i=a[i-1]
print((ans if ans<=n else -1)) | 12 | 6 | 178 | 130 | n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
b = a[0]
c = 1
ans = -1
for i in range(10**5):
if b == 2:
ans = c
break
b = a[b - 1]
c += 1
print(ans)
| n, *a = list(map(int, open(0).read().split()))
i = ans = 1
while a[i - 1] != 2 and ans <= n:
ans += 1
i = a[i - 1]
print((ans if ans <= n else -1))
| false | 50 | [
"-n = int(eval(input()))",
"-a = [int(eval(input())) for _ in range(n)]",
"-b = a[0]",
"-c = 1",
"-ans = -1",
"-for i in range(10**5):",
"- if b == 2:",
"- ans = c",
"- break",
"- b = a[b - 1]",
"- c += 1",
"-print(ans)",
"+n, *a = list(map(int, open(0).read().split())... | false | 0.057894 | 0.043316 | 1.336543 | [
"s833312258",
"s081222736"
] |
u142415823 | p03338 | python | s534457272 | s448251235 | 20 | 18 | 3,060 | 3,064 | Accepted | Accepted | 10 | N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1, N):
ans = max(ans, len(set(list(S[:i])) & set(list(S[i:]))))
print(ans) | N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1, N):
s1 = set(list(S[:i]))
s2 = set(list(S[i:]))
ans = max(ans, len(s1 & s2))
print(ans)
| 8 | 10 | 139 | 166 | N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1, N):
ans = max(ans, len(set(list(S[:i])) & set(list(S[i:]))))
print(ans)
| N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1, N):
s1 = set(list(S[:i]))
s2 = set(list(S[i:]))
ans = max(ans, len(s1 & s2))
print(ans)
| false | 20 | [
"- ans = max(ans, len(set(list(S[:i])) & set(list(S[i:]))))",
"+ s1 = set(list(S[:i]))",
"+ s2 = set(list(S[i:]))",
"+ ans = max(ans, len(s1 & s2))"
] | false | 0.047489 | 0.047087 | 1.008535 | [
"s534457272",
"s448251235"
] |
u123756661 | p02880 | python | s202241694 | s816399771 | 199 | 184 | 38,384 | 38,384 | Accepted | Accepted | 7.54 | n=int(eval(input()))
for i in range(1,10):
for j in range(1,10):
if n==i*j:
print("Yes")
exit()
print("No")
| n=int(eval(input()))
for i in range(1,10):
for j in range(1,i+1):
if n==i*j:
print("Yes")
exit()
print("No") | 7 | 7 | 144 | 144 | n = int(eval(input()))
for i in range(1, 10):
for j in range(1, 10):
if n == i * j:
print("Yes")
exit()
print("No")
| n = int(eval(input()))
for i in range(1, 10):
for j in range(1, i + 1):
if n == i * j:
print("Yes")
exit()
print("No")
| false | 0 | [
"- for j in range(1, 10):",
"+ for j in range(1, i + 1):"
] | false | 0.066236 | 0.04579 | 1.446515 | [
"s202241694",
"s816399771"
] |
u548545174 | p03212 | python | s117961795 | s125985199 | 88 | 64 | 3,060 | 3,064 | Accepted | Accepted | 27.27 | N = int(eval(input()))
ans = 0
def dfs(i):
global ans
if int(i) > N:
return
if all(i.count(c) for c in '753'):
ans += 1
dfs(i + '3')
dfs(i + '5')
dfs(i + '7')
dfs('0')
print(ans) | N = int(eval(input()))
ans = 0
def dfs(s):
global ans
if int(s) > N:
return
if s.count('7') and s.count('5') and s.count('3'):
ans += 1
dfs(s + '7')
dfs(s + '5')
dfs(s + '3')
dfs('0')
print(ans) | 16 | 18 | 234 | 254 | N = int(eval(input()))
ans = 0
def dfs(i):
global ans
if int(i) > N:
return
if all(i.count(c) for c in "753"):
ans += 1
dfs(i + "3")
dfs(i + "5")
dfs(i + "7")
dfs("0")
print(ans)
| N = int(eval(input()))
ans = 0
def dfs(s):
global ans
if int(s) > N:
return
if s.count("7") and s.count("5") and s.count("3"):
ans += 1
dfs(s + "7")
dfs(s + "5")
dfs(s + "3")
dfs("0")
print(ans)
| false | 11.111111 | [
"-def dfs(i):",
"+def dfs(s):",
"- if int(i) > N:",
"+ if int(s) > N:",
"- if all(i.count(c) for c in \"753\"):",
"+ if s.count(\"7\") and s.count(\"5\") and s.count(\"3\"):",
"- dfs(i + \"3\")",
"- dfs(i + \"5\")",
"- dfs(i + \"7\")",
"+ dfs(s + \"7\")",
"+ dfs(s + \"... | false | 0.047256 | 0.043882 | 1.0769 | [
"s117961795",
"s125985199"
] |
u497952650 | p03352 | python | s264597418 | s166070829 | 419 | 26 | 21,148 | 3,696 | Accepted | Accepted | 93.79 | import numpy as np
N = int(eval(input()))
expo = []
for i in range(1,10000):
if i == 1:
expo.append(i)
else:
for j in range(2,1000):
tmp = i**j
if tmp > N:
break
expo.append(tmp)
expo.sort()
expo = np.array(expo)
print((max(expo[expo<=N]))) | nums = []
for i in range(1,100):
for j in range(2,100):
nums.append(pow(i,j))
nums.sort(reverse=True)
X = int(eval(input()))
for i in nums:
if i <= X:
print(i)
break | 19 | 14 | 330 | 212 | import numpy as np
N = int(eval(input()))
expo = []
for i in range(1, 10000):
if i == 1:
expo.append(i)
else:
for j in range(2, 1000):
tmp = i**j
if tmp > N:
break
expo.append(tmp)
expo.sort()
expo = np.array(expo)
print((max(expo[expo <= N])))
| nums = []
for i in range(1, 100):
for j in range(2, 100):
nums.append(pow(i, j))
nums.sort(reverse=True)
X = int(eval(input()))
for i in nums:
if i <= X:
print(i)
break
| false | 26.315789 | [
"-import numpy as np",
"-",
"-N = int(eval(input()))",
"-expo = []",
"-for i in range(1, 10000):",
"- if i == 1:",
"- expo.append(i)",
"- else:",
"- for j in range(2, 1000):",
"- tmp = i**j",
"- if tmp > N:",
"- break",
"- e... | false | 0.503994 | 0.044913 | 11.221538 | [
"s264597418",
"s166070829"
] |
u678167152 | p03175 | python | s717731039 | s079296220 | 702 | 465 | 100,528 | 105,448 | Accepted | Accepted | 33.76 | N = int(eval(input()))
edge = [[] for _ in range(N)]
for i in range(N-1):
a,b = list(map(int, input().split()))
edge[a-1].append(b-1)
edge[b-1].append(a-1)
import sys
sys.setrecursionlimit(10**8)
mod = 10**9+7
def dfs(v):
white,black = 1,1
for u in edge[v]:
if visited[u]==False:
visited[u]=True
w,b = dfs(u)
white *= w+b
white %= mod
black *= w
black %= mod
return white,black
visited = [False]*N
visited[0]=True
print((sum(dfs(0))%mod)) | import sys
sys.setrecursionlimit(10**8)
N = int(eval(input()))
edge = [[] for _ in range(N)]
for i in range(N-1):
a,b = list(map(int, input().split()))
edge[a-1].append(b-1)
edge[b-1].append(a-1)
def dfs(v,mod):
black,white = 1,1
for u in edge[v]:
if visited[u]==False:
visited[u]=True
b,w = dfs(u,mod)
black *= w
white *= b+w
black %= mod
white %= mod
return black,white
mod = 10**9+7
visited = [False]*N
visited[0]=True
black,white = dfs(0,mod)
print(((black+white)%mod)) | 26 | 27 | 556 | 532 | N = int(eval(input()))
edge = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
import sys
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
def dfs(v):
white, black = 1, 1
for u in edge[v]:
if visited[u] == False:
visited[u] = True
w, b = dfs(u)
white *= w + b
white %= mod
black *= w
black %= mod
return white, black
visited = [False] * N
visited[0] = True
print((sum(dfs(0)) % mod))
| import sys
sys.setrecursionlimit(10**8)
N = int(eval(input()))
edge = [[] for _ in range(N)]
for i in range(N - 1):
a, b = list(map(int, input().split()))
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
def dfs(v, mod):
black, white = 1, 1
for u in edge[v]:
if visited[u] == False:
visited[u] = True
b, w = dfs(u, mod)
black *= w
white *= b + w
black %= mod
white %= mod
return black, white
mod = 10**9 + 7
visited = [False] * N
visited[0] = True
black, white = dfs(0, mod)
print(((black + white) % mod))
| false | 3.703704 | [
"+import sys",
"+",
"+sys.setrecursionlimit(10**8)",
"-import sys",
"-",
"-sys.setrecursionlimit(10**8)",
"-mod = 10**9 + 7",
"-def dfs(v):",
"- white, black = 1, 1",
"+def dfs(v, mod):",
"+ black, white = 1, 1",
"- w, b = dfs(u)",
"- white *= w + b",
"- ... | false | 0.04675 | 0.085545 | 0.546494 | [
"s717731039",
"s079296220"
] |
u663710122 | p03107 | python | s177530123 | s246987894 | 133 | 19 | 3,392 | 3,188 | Accepted | Accepted | 85.71 | S = eval(input())
tmp = ''
ret = 0
for s in S:
if len(tmp) and tmp[-1] != s:
ret += 1
tmp = tmp[:-1]
else:
tmp += s
print((ret * 2))
| S = eval(input())
print((2 * min(S.count('0'), S.count('1'))))
| 12 | 3 | 170 | 58 | S = eval(input())
tmp = ""
ret = 0
for s in S:
if len(tmp) and tmp[-1] != s:
ret += 1
tmp = tmp[:-1]
else:
tmp += s
print((ret * 2))
| S = eval(input())
print((2 * min(S.count("0"), S.count("1"))))
| false | 75 | [
"-tmp = \"\"",
"-ret = 0",
"-for s in S:",
"- if len(tmp) and tmp[-1] != s:",
"- ret += 1",
"- tmp = tmp[:-1]",
"- else:",
"- tmp += s",
"-print((ret * 2))",
"+print((2 * min(S.count(\"0\"), S.count(\"1\"))))"
] | false | 0.045916 | 0.104867 | 0.437856 | [
"s177530123",
"s246987894"
] |
u852517668 | p03053 | python | s787223202 | s004572905 | 551 | 431 | 111,084 | 84,700 | Accepted | Accepted | 21.78 | from collections import deque
import copy
def main():
H, W = list(map(int, input().split()))
field = [[i=='#' for i in eval(input())] for _ in range(H)]
count = 0
q = deque([(i, j) for i in range(H) for j in range(W) if field[i][j]])
while True:
nq = deque()
while q:
y, x = q.popleft()
if x > 0 and not field[y][x-1]:
field[y][x-1] = True
nq.append((y,x-1))
if y > 0 and not field[y-1][x]:
field[y-1][x] = True
nq.append((y-1,x))
if x<W-1 and not field[y][x+1]:
field[y][x+1] = True
nq.append((y,x+1))
if y<H-1 and not field[y+1][x]:
field[y+1][x] = True
nq.append((y+1, x))
if nq:
q = copy.copy(nq)
else:
break
count += 1
print(count)
if __name__ == "__main__":
main() | from collections import deque
H, W = list(map(int, input().split()))
field = [[i=='#' for i in eval(input())] for _ in range(H)]
count = 0
def bfs():
global count
q = deque()
for y in range(H):
for x in range(W):
if field[y][x]:
q.append((y, x))
while True:
nq = deque()
while len(q) > 0:
y, x = q.popleft()
for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
ny, nx = y + dy, x + dx
if ny < 0 or ny >= H or nx < 0 or nx >= W:
continue
if field[ny][nx]:
continue
field[ny][nx] = True
nq.append((ny, nx))
if len(nq) > 0:
q = nq
else:
break
count += 1
bfs()
print(count) | 33 | 33 | 844 | 731 | from collections import deque
import copy
def main():
H, W = list(map(int, input().split()))
field = [[i == "#" for i in eval(input())] for _ in range(H)]
count = 0
q = deque([(i, j) for i in range(H) for j in range(W) if field[i][j]])
while True:
nq = deque()
while q:
y, x = q.popleft()
if x > 0 and not field[y][x - 1]:
field[y][x - 1] = True
nq.append((y, x - 1))
if y > 0 and not field[y - 1][x]:
field[y - 1][x] = True
nq.append((y - 1, x))
if x < W - 1 and not field[y][x + 1]:
field[y][x + 1] = True
nq.append((y, x + 1))
if y < H - 1 and not field[y + 1][x]:
field[y + 1][x] = True
nq.append((y + 1, x))
if nq:
q = copy.copy(nq)
else:
break
count += 1
print(count)
if __name__ == "__main__":
main()
| from collections import deque
H, W = list(map(int, input().split()))
field = [[i == "#" for i in eval(input())] for _ in range(H)]
count = 0
def bfs():
global count
q = deque()
for y in range(H):
for x in range(W):
if field[y][x]:
q.append((y, x))
while True:
nq = deque()
while len(q) > 0:
y, x = q.popleft()
for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
ny, nx = y + dy, x + dx
if ny < 0 or ny >= H or nx < 0 or nx >= W:
continue
if field[ny][nx]:
continue
field[ny][nx] = True
nq.append((ny, nx))
if len(nq) > 0:
q = nq
else:
break
count += 1
bfs()
print(count)
| false | 0 | [
"-import copy",
"+",
"+H, W = list(map(int, input().split()))",
"+field = [[i == \"#\" for i in eval(input())] for _ in range(H)]",
"+count = 0",
"-def main():",
"- H, W = list(map(int, input().split()))",
"- field = [[i == \"#\" for i in eval(input())] for _ in range(H)]",
"- count = 0",
... | false | 0.049011 | 0.048956 | 1.001123 | [
"s787223202",
"s004572905"
] |
u979038517 | p02861 | python | s312923935 | s711635319 | 463 | 310 | 10,860 | 3,064 | Accepted | Accepted | 33.05 | import itertools
import math
def dist(s, g):
sx, sy = s
ex, ey = g
return math.sqrt((ex - sx)**2 + (ey - sy)**2)
# input
n = int(eval(input()))
points = [ [int(x) for x in input().split()] for _ in range(n) ]
# calculate roots
roots = set(itertools.permutations(list(range(n))))
distance = [0] * len(roots)
idn = 0
for root in roots:
for i in range(len(root) - 1):
tmp_dist = dist(points[root[i]], points[root[i + 1]])
distance[idn] += tmp_dist
idn += 1
print((sum(distance) / len(distance)))
| import itertools
import math
def main():
N = int(eval(input()))
xys = [[int(y) for y in input().split()] for _ in range(N)]
routes = itertools.permutations(xys, len(xys))
sumup = 0
count = 0 # cuz len(routes) doesn't work :(
for route in routes:
count += 1
for i in range(1, N):
xy_0 = route[i - 1]
xy_1 = route[i]
sumup += math.sqrt((xy_0[0] - xy_1[0]) ** 2 + (xy_0[1] - xy_1[1]) ** 2)
print((sumup / count))
if __name__ == "__main__":
main() | 26 | 23 | 551 | 547 | import itertools
import math
def dist(s, g):
sx, sy = s
ex, ey = g
return math.sqrt((ex - sx) ** 2 + (ey - sy) ** 2)
# input
n = int(eval(input()))
points = [[int(x) for x in input().split()] for _ in range(n)]
# calculate roots
roots = set(itertools.permutations(list(range(n))))
distance = [0] * len(roots)
idn = 0
for root in roots:
for i in range(len(root) - 1):
tmp_dist = dist(points[root[i]], points[root[i + 1]])
distance[idn] += tmp_dist
idn += 1
print((sum(distance) / len(distance)))
| import itertools
import math
def main():
N = int(eval(input()))
xys = [[int(y) for y in input().split()] for _ in range(N)]
routes = itertools.permutations(xys, len(xys))
sumup = 0
count = 0 # cuz len(routes) doesn't work :(
for route in routes:
count += 1
for i in range(1, N):
xy_0 = route[i - 1]
xy_1 = route[i]
sumup += math.sqrt((xy_0[0] - xy_1[0]) ** 2 + (xy_0[1] - xy_1[1]) ** 2)
print((sumup / count))
if __name__ == "__main__":
main()
| false | 11.538462 | [
"-def dist(s, g):",
"- sx, sy = s",
"- ex, ey = g",
"- return math.sqrt((ex - sx) ** 2 + (ey - sy) ** 2)",
"+def main():",
"+ N = int(eval(input()))",
"+ xys = [[int(y) for y in input().split()] for _ in range(N)]",
"+ routes = itertools.permutations(xys, len(xys))",
"+ sumup = ... | false | 0.046798 | 0.088635 | 0.52798 | [
"s312923935",
"s711635319"
] |
u735335967 | p03814 | python | s157198970 | s892909184 | 75 | 18 | 11,260 | 3,500 | Accepted | Accepted | 76 | s = eval(input())
ca = []
cz = []
ans = 0
for i in range(len(s)):
if s[i] == "A":
ca.append(i)
if s[i] == "Z":
cz.append(i)
ans = max(cz)-min(ca)+1
print(ans)
| s = eval(input())
print((s.rfind("Z")-s.find("A")+1))
| 11 | 3 | 187 | 49 | s = eval(input())
ca = []
cz = []
ans = 0
for i in range(len(s)):
if s[i] == "A":
ca.append(i)
if s[i] == "Z":
cz.append(i)
ans = max(cz) - min(ca) + 1
print(ans)
| s = eval(input())
print((s.rfind("Z") - s.find("A") + 1))
| false | 72.727273 | [
"-ca = []",
"-cz = []",
"-ans = 0",
"-for i in range(len(s)):",
"- if s[i] == \"A\":",
"- ca.append(i)",
"- if s[i] == \"Z\":",
"- cz.append(i)",
"-ans = max(cz) - min(ca) + 1",
"-print(ans)",
"+print((s.rfind(\"Z\") - s.find(\"A\") + 1))"
] | false | 0.051252 | 0.036335 | 1.410525 | [
"s157198970",
"s892909184"
] |
u077291787 | p02732 | python | s894246960 | s719316503 | 270 | 226 | 52,756 | 48,268 | Accepted | Accepted | 16.3 | # D - Banned K
from collections import Counter
def main():
N, *A = list(map(int, open(0).read().split()))
counter = Counter(A)
patterns, less_patterns = {}, {}
for k, v in list(counter.items()):
patterns[k] = max(0, v * (v - 1) // 2)
less_patterns[k] = max(0, (v - 1) * (v - 2) // 2)
total = sum(patterns.values())
ans = [total - patterns[a] + less_patterns[a] for a in A]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| # D - Banned K
from collections import Counter
def main():
N, *A = list(map(int, open(0).read().split()))
counter = Counter(A)
total = 0
dif = {}
for k, v in list(counter.items()):
total += max(0, v * (v - 1) // 2)
dif[k] = max(0, v - 1)
ans = [total - dif[a] for a in A]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| 18 | 18 | 496 | 395 | # D - Banned K
from collections import Counter
def main():
N, *A = list(map(int, open(0).read().split()))
counter = Counter(A)
patterns, less_patterns = {}, {}
for k, v in list(counter.items()):
patterns[k] = max(0, v * (v - 1) // 2)
less_patterns[k] = max(0, (v - 1) * (v - 2) // 2)
total = sum(patterns.values())
ans = [total - patterns[a] + less_patterns[a] for a in A]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| # D - Banned K
from collections import Counter
def main():
N, *A = list(map(int, open(0).read().split()))
counter = Counter(A)
total = 0
dif = {}
for k, v in list(counter.items()):
total += max(0, v * (v - 1) // 2)
dif[k] = max(0, v - 1)
ans = [total - dif[a] for a in A]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| false | 0 | [
"- patterns, less_patterns = {}, {}",
"+ total = 0",
"+ dif = {}",
"- patterns[k] = max(0, v * (v - 1) // 2)",
"- less_patterns[k] = max(0, (v - 1) * (v - 2) // 2)",
"- total = sum(patterns.values())",
"- ans = [total - patterns[a] + less_patterns[a] for a in A]",
"+ ... | false | 0.136723 | 0.041531 | 3.292091 | [
"s894246960",
"s719316503"
] |
u910756197 | p03573 | python | s054581513 | s814370369 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | a, b, c = list(map(int, input().split()))
if a == b:
print(c)
elif b == c:
print(a)
else:
print(b) | l1, l2, l3 = list(map(int, input().split()))
print((l1 ^ l2 ^ l3)) | 7 | 2 | 104 | 59 | a, b, c = list(map(int, input().split()))
if a == b:
print(c)
elif b == c:
print(a)
else:
print(b)
| l1, l2, l3 = list(map(int, input().split()))
print((l1 ^ l2 ^ l3))
| false | 71.428571 | [
"-a, b, c = list(map(int, input().split()))",
"-if a == b:",
"- print(c)",
"-elif b == c:",
"- print(a)",
"-else:",
"- print(b)",
"+l1, l2, l3 = list(map(int, input().split()))",
"+print((l1 ^ l2 ^ l3))"
] | false | 0.044209 | 0.041712 | 1.059865 | [
"s054581513",
"s814370369"
] |
u597374218 | p02700 | python | s819972271 | s824956345 | 34 | 29 | 9,148 | 8,964 | Accepted | Accepted | 14.71 | import math
A,B,C,D=list(map(int,input().split()))
print(("Yes" if math.ceil(A/D)>=math.ceil(C/B) else "No")) | A,B,C,D=list(map(int,input().split()))
print(("Yes" if (A+D-1)//D>=(C+B-1)//B else "No")) | 3 | 2 | 103 | 82 | import math
A, B, C, D = list(map(int, input().split()))
print(("Yes" if math.ceil(A / D) >= math.ceil(C / B) else "No"))
| A, B, C, D = list(map(int, input().split()))
print(("Yes" if (A + D - 1) // D >= (C + B - 1) // B else "No"))
| false | 33.333333 | [
"-import math",
"-",
"-print((\"Yes\" if math.ceil(A / D) >= math.ceil(C / B) else \"No\"))",
"+print((\"Yes\" if (A + D - 1) // D >= (C + B - 1) // B else \"No\"))"
] | false | 0.04309 | 0.042992 | 1.002291 | [
"s819972271",
"s824956345"
] |
u066413086 | p02615 | python | s753872739 | s334655433 | 402 | 126 | 113,672 | 31,424 | Accepted | Accepted | 68.66 | import heapq
class ErasableHeapq:
def __init__(self):
self.p = list()
self.q = list()
self.len = 0
def insert(self, x):
heapq.heappush(self.p, x)
self.len += 1
return
def erase(self, x):
heapq.heappush(self.q, x)
self.len -= 1
return
def minimum(self):
while self.q and self.p[0] == self.q[0]:
heapq.heappop(self.p)
heapq.heappop(self.q)
return self.p[0]
def __len__(self):
return self.len
def empty(self):
return self.len == 0
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
# 大きい順
A.sort()
sA = A[::-1]
ans = sA[0]
eq = ErasableHeapq()
eq.insert((-sA[1], -sA[0]))
eq.insert((-sA[1], -sA[0]))
for a in sA[2:]:
best_pair = eq.minimum()
eq.erase(best_pair)
# print(a, best_pair)
ans += -best_pair[0]
eq.insert((-a, best_pair[0]))
eq.insert((-a, best_pair[1]))
print(ans)
if __name__ == '__main__':
main() | def main():
N = int(eval(input()))
A = list(map(int, input().split()))
# 大きい順
A.sort()
A = A[::-1]
ans = 0
for i in range(1, N):
ans += A[i // 2]
print(ans)
if __name__ == '__main__':
main() | 56 | 16 | 1,136 | 247 | import heapq
class ErasableHeapq:
def __init__(self):
self.p = list()
self.q = list()
self.len = 0
def insert(self, x):
heapq.heappush(self.p, x)
self.len += 1
return
def erase(self, x):
heapq.heappush(self.q, x)
self.len -= 1
return
def minimum(self):
while self.q and self.p[0] == self.q[0]:
heapq.heappop(self.p)
heapq.heappop(self.q)
return self.p[0]
def __len__(self):
return self.len
def empty(self):
return self.len == 0
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
# 大きい順
A.sort()
sA = A[::-1]
ans = sA[0]
eq = ErasableHeapq()
eq.insert((-sA[1], -sA[0]))
eq.insert((-sA[1], -sA[0]))
for a in sA[2:]:
best_pair = eq.minimum()
eq.erase(best_pair)
# print(a, best_pair)
ans += -best_pair[0]
eq.insert((-a, best_pair[0]))
eq.insert((-a, best_pair[1]))
print(ans)
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
A = list(map(int, input().split()))
# 大きい順
A.sort()
A = A[::-1]
ans = 0
for i in range(1, N):
ans += A[i // 2]
print(ans)
if __name__ == "__main__":
main()
| false | 71.428571 | [
"-import heapq",
"-",
"-",
"-class ErasableHeapq:",
"- def __init__(self):",
"- self.p = list()",
"- self.q = list()",
"- self.len = 0",
"-",
"- def insert(self, x):",
"- heapq.heappush(self.p, x)",
"- self.len += 1",
"- return",
"-",
"- ... | false | 0.07728 | 0.053878 | 1.434368 | [
"s753872739",
"s334655433"
] |
u970308980 | p02727 | python | s607283204 | s298342518 | 313 | 245 | 23,360 | 22,548 | Accepted | Accepted | 21.73 | import heapq
X, Y, A, B, C = list(map(int, input().split()))
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()), reverse=True)
red = p[:X]
green = q[:Y]
nocolor = r
heapq.heapify(red)
heapq.heapify(green)
for nc in nocolor:
R = red[0]
G = green[0]
if R > nc and G > nc:
break
elif nc > R and nc > G:
if R > G:
q = heapq.heappop(green)
heapq.heappush(green, nc)
else:
q = heapq.heappop(red)
heapq.heappush(red, nc)
elif nc > R:
q = heapq.heappop(red)
heapq.heappush(red, nc)
elif nc > G:
q = heapq.heappop(green)
heapq.heappush(green, nc)
print((sum(red) + sum(green)))
| X, Y, A, B, C = list(map(int, input().split()))
p = sorted(map(int, input().split()), reverse=True)[:X]
q = sorted(map(int, input().split()), reverse=True)[:Y]
r = list(map(int, input().split()))
apples = p + q + r
apples.sort(reverse=True)
print((sum(apples[: X + Y])))
| 35 | 10 | 819 | 275 | import heapq
X, Y, A, B, C = list(map(int, input().split()))
p = sorted(map(int, input().split()), reverse=True)
q = sorted(map(int, input().split()), reverse=True)
r = sorted(map(int, input().split()), reverse=True)
red = p[:X]
green = q[:Y]
nocolor = r
heapq.heapify(red)
heapq.heapify(green)
for nc in nocolor:
R = red[0]
G = green[0]
if R > nc and G > nc:
break
elif nc > R and nc > G:
if R > G:
q = heapq.heappop(green)
heapq.heappush(green, nc)
else:
q = heapq.heappop(red)
heapq.heappush(red, nc)
elif nc > R:
q = heapq.heappop(red)
heapq.heappush(red, nc)
elif nc > G:
q = heapq.heappop(green)
heapq.heappush(green, nc)
print((sum(red) + sum(green)))
| X, Y, A, B, C = list(map(int, input().split()))
p = sorted(map(int, input().split()), reverse=True)[:X]
q = sorted(map(int, input().split()), reverse=True)[:Y]
r = list(map(int, input().split()))
apples = p + q + r
apples.sort(reverse=True)
print((sum(apples[: X + Y])))
| false | 71.428571 | [
"-import heapq",
"-",
"-p = sorted(map(int, input().split()), reverse=True)",
"-q = sorted(map(int, input().split()), reverse=True)",
"-r = sorted(map(int, input().split()), reverse=True)",
"-red = p[:X]",
"-green = q[:Y]",
"-nocolor = r",
"-heapq.heapify(red)",
"-heapq.heapify(green)",
"-for nc... | false | 0.047939 | 0.060857 | 0.787726 | [
"s607283204",
"s298342518"
] |
u480472958 | p03150 | python | s544890475 | s432917504 | 22 | 18 | 3,188 | 2,940 | Accepted | Accepted | 18.18 | import re
s = eval(input())
keyence = 'keyence'
for i in range(7):
fs, es = keyence[:i], keyence[i:]
# print(fs, es)
fsis = [m.start() for m in re.finditer(fs, s)]
esis = [m.start() for m in re.finditer(es, s)]
for fsi in fsis:
for esi in esis:
# print(fsi, esi)
if fsi + len(fs) <= esi:
if es == 'keyence' and (esi == 0 or esi + len(es) == len(s)):
print('YES')
exit()
elif fsi == 0 and esi + len(es) == len(s):
print('YES')
exit()
print('NO') | s = eval(input())
for i in range(7):
if s[:i] + s[-7+i:] == 'keyence':
print('YES')
exit()
print('NO') | 19 | 6 | 620 | 121 | import re
s = eval(input())
keyence = "keyence"
for i in range(7):
fs, es = keyence[:i], keyence[i:]
# print(fs, es)
fsis = [m.start() for m in re.finditer(fs, s)]
esis = [m.start() for m in re.finditer(es, s)]
for fsi in fsis:
for esi in esis:
# print(fsi, esi)
if fsi + len(fs) <= esi:
if es == "keyence" and (esi == 0 or esi + len(es) == len(s)):
print("YES")
exit()
elif fsi == 0 and esi + len(es) == len(s):
print("YES")
exit()
print("NO")
| s = eval(input())
for i in range(7):
if s[:i] + s[-7 + i :] == "keyence":
print("YES")
exit()
print("NO")
| false | 68.421053 | [
"-import re",
"-",
"-keyence = \"keyence\"",
"- fs, es = keyence[:i], keyence[i:]",
"- # print(fs, es)",
"- fsis = [m.start() for m in re.finditer(fs, s)]",
"- esis = [m.start() for m in re.finditer(es, s)]",
"- for fsi in fsis:",
"- for esi in esis:",
"- # print(f... | false | 0.046104 | 0.007934 | 5.810626 | [
"s544890475",
"s432917504"
] |
u353797797 | p03178 | python | s000375764 | s519953092 | 1,445 | 313 | 3,188 | 3,316 | Accepted | Accepted | 78.34 | def f(ks, d):
md = 10 ** 9 + 7
dp = [0] * d
just = 0
for k in ks:
ndp = [0] * d
for di, dk in enumerate(dp):
for ndi in range(di, di + 10):
ndp[ndi % d] += dk
for ndi in range(just, just + k):
ndp[ndi % d] += 1
ndp = [ndk % md for ndk in ndp]
just = (just + k) % d
dp = ndp
print(((dp[0] + (just == 0) - 1) % md))
ks = list(map(int, list(eval(input()))))
d = int(eval(input()))
f(ks, d)
| def f(ks, d):
md = 10 ** 9 + 7
dp = [0] * d
just = 0
for k in ks:
ndp = [0] * d
ndp[0] = s = sum(dp[i % d] for i in range(-9, 1))
for i in range(1, d):
ndp[i] = s = (s + dp[i % d] - dp[(i - 10) % d]) % md
for ndi in range(just, just + k):
ndp[ndi % d] += 1
just = (just + k) % d
dp = ndp
print(((dp[0] + (just == 0) - 1) % md))
ks = list(map(int, list(eval(input()))))
d = int(eval(input()))
f(ks, d)
| 26 | 24 | 514 | 509 | def f(ks, d):
md = 10**9 + 7
dp = [0] * d
just = 0
for k in ks:
ndp = [0] * d
for di, dk in enumerate(dp):
for ndi in range(di, di + 10):
ndp[ndi % d] += dk
for ndi in range(just, just + k):
ndp[ndi % d] += 1
ndp = [ndk % md for ndk in ndp]
just = (just + k) % d
dp = ndp
print(((dp[0] + (just == 0) - 1) % md))
ks = list(map(int, list(eval(input()))))
d = int(eval(input()))
f(ks, d)
| def f(ks, d):
md = 10**9 + 7
dp = [0] * d
just = 0
for k in ks:
ndp = [0] * d
ndp[0] = s = sum(dp[i % d] for i in range(-9, 1))
for i in range(1, d):
ndp[i] = s = (s + dp[i % d] - dp[(i - 10) % d]) % md
for ndi in range(just, just + k):
ndp[ndi % d] += 1
just = (just + k) % d
dp = ndp
print(((dp[0] + (just == 0) - 1) % md))
ks = list(map(int, list(eval(input()))))
d = int(eval(input()))
f(ks, d)
| false | 7.692308 | [
"- for di, dk in enumerate(dp):",
"- for ndi in range(di, di + 10):",
"- ndp[ndi % d] += dk",
"+ ndp[0] = s = sum(dp[i % d] for i in range(-9, 1))",
"+ for i in range(1, d):",
"+ ndp[i] = s = (s + dp[i % d] - dp[(i - 10) % d]) % md",
"- nd... | false | 0.036105 | 0.05362 | 0.673351 | [
"s000375764",
"s519953092"
] |
u652656291 | p02773 | python | s260395752 | s265995128 | 696 | 632 | 33,244 | 32,096 | Accepted | Accepted | 9.2 | n = int(eval(input()))
d = {}
for i in range(n):
s=eval(input())
if s not in d:
d[s] = 1
else:
d[s] += 1
max_d = max(d.values())
print((*sorted([kv[0] for kv in list(d.items()) if kv[1] == max_d])))
| n = int(eval(input()))
d = {}
for _ in range(n):
s = eval(input())
if s in d:
d[s] += 1
else:
d[s] = 1
m = max(d.values())
for i in sorted(k for k in d if d[k] == m):
print(i) | 10 | 12 | 216 | 207 | n = int(eval(input()))
d = {}
for i in range(n):
s = eval(input())
if s not in d:
d[s] = 1
else:
d[s] += 1
max_d = max(d.values())
print((*sorted([kv[0] for kv in list(d.items()) if kv[1] == max_d])))
| n = int(eval(input()))
d = {}
for _ in range(n):
s = eval(input())
if s in d:
d[s] += 1
else:
d[s] = 1
m = max(d.values())
for i in sorted(k for k in d if d[k] == m):
print(i)
| false | 16.666667 | [
"-for i in range(n):",
"+for _ in range(n):",
"- if s not in d:",
"+ if s in d:",
"+ d[s] += 1",
"+ else:",
"- else:",
"- d[s] += 1",
"-max_d = max(d.values())",
"-print((*sorted([kv[0] for kv in list(d.items()) if kv[1] == max_d])))",
"+m = max(d.values())",
"+for i ... | false | 0.117215 | 0.12812 | 0.914881 | [
"s260395752",
"s265995128"
] |
u729133443 | p02579 | python | s834290425 | s566637856 | 1,278 | 238 | 256,172 | 18,000 | Accepted | Accepted | 81.38 | from collections import*
(h,w),(s,t),(f,g)=eval('map(int,input().split()),'*3)
d=eval('[-1]*w,input(),'*h)
q=deque([(s-1,t-1,0)])
while q:
y,x,c=q.pop()
if d[y+y][x]<0:
for a in range(25):a,b=a//5-2,a%5-2;i=a+y;j=b+x;d[y+y][x]=c;h>i>-1<j<w!=d[i-~i][j]>'#'!=(abs(a)+abs(b)<2!=q.append((i,j,c)),q.appendleft((i,j,c+1)))
print((d[f+f-2][g-1])) | import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
import os, zlib, base64
open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c$}@2ZI7Zb5Xay1Ddw^{7GecmbIHXl_eBUX*cPeBL!m|CKK)G#x`?;gH&+u)XMQvD?@a3pFrjp(MWOakq}8cQPduWlmGd(9h>8{+;|C^M6@__S@{rb*=1QlP4uhhmX%QCU7|KECb+rqAhDvC@mMQ&>2~}8ir5rG(<>8de$=bREjG<Bnj5i$zDoR<m8tm@FA1K|5>U4LPyi{C2_?f8hZbj27BOozGXAWgN+dF^@w~!OK5>Ny*0c1`D1_C_+N<a`e6S!dDjgGgQ%_cG5+XPAi%sQ;N7~Kgp7~EiVL!D8R#|W&qSU~*Yb>=bOcdQ!k^*j6cyb^Fxh>J>Gl;WZm7sa?I-^uD01lEQYN5Q?^AEn=tP!oFbt<9k45A-^rpW$Yeu}I=`0ufxCW(Z`b^1~4)<SAIg)_0nIX48|6&TJdsx#ptaP}LewAMjG@!J8@%m=|q0mP&hLQB$Orhq<XYRR2izPZTv2eWd6UB{E>~ki>lgzp(FnFn3Z^cz5ieCRYUX-mqD32Rz>!&L38=oAqwd)_$b=1vOPSZOE~<u=U{`Bj4e=&~aN5m83^y3kx3;nvKbS_Lq4jrdb|m;eLA*GkI<k{uaUR$0#a_uoKq$9C4eG8SvOx;r|=z=g|2Rh|VGU2=PMk|1H_x$uAUJ<_p1=p*Rt|@8jQwd9e6+Se%(xki;kZ<2!!=vtwqq")))
os.system('cythonize -i -3 -b solve.pyx')
import solve | 9 | 6 | 350 | 895 | from collections import *
(h, w), (s, t), (f, g) = eval("map(int,input().split())," * 3)
d = eval("[-1]*w,input()," * h)
q = deque([(s - 1, t - 1, 0)])
while q:
y, x, c = q.pop()
if d[y + y][x] < 0:
for a in range(25):
a, b = a // 5 - 2, a % 5 - 2
i = a + y
j = b + x
d[y + y][x] = c
h > i > -1 < j < w != d[i - ~i][j] > "#" != (
abs(a) + abs(b) < 2 != q.append((i, j, c)),
q.appendleft((i, j, c + 1)),
)
print((d[f + f - 2][g - 1]))
| import sys
if sys.argv[-1] == "ONLINE_JUDGE":
import os, zlib, base64
open("solve.pyx", "wb").write(
zlib.decompress(
base64.b85decode(
"c$}@2ZI7Zb5Xay1Ddw^{7GecmbIHXl_eBUX*cPeBL!m|CKK)G#x`?;gH&+u)XMQvD?@a3pFrjp(MWOakq}8cQPduWlmGd(9h>8{+;|C^M6@__S@{rb*=1QlP4uhhmX%QCU7|KECb+rqAhDvC@mMQ&>2~}8ir5rG(<>8de$=bREjG<Bnj5i$zDoR<m8tm@FA1K|5>U4LPyi{C2_?f8hZbj27BOozGXAWgN+dF^@w~!OK5>Ny*0c1`D1_C_+N<a`e6S!dDjgGgQ%_cG5+XPAi%sQ;N7~Kgp7~EiVL!D8R#|W&qSU~*Yb>=bOcdQ!k^*j6cyb^Fxh>J>Gl;WZm7sa?I-^uD01lEQYN5Q?^AEn=tP!oFbt<9k45A-^rpW$Yeu}I=`0ufxCW(Z`b^1~4)<SAIg)_0nIX48|6&TJdsx#ptaP}LewAMjG@!J8@%m=|q0mP&hLQB$Orhq<XYRR2izPZTv2eWd6UB{E>~ki>lgzp(FnFn3Z^cz5ieCRYUX-mqD32Rz>!&L38=oAqwd)_$b=1vOPSZOE~<u=U{`Bj4e=&~aN5m83^y3kx3;nvKbS_Lq4jrdb|m;eLA*GkI<k{uaUR$0#a_uoKq$9C4eG8SvOx;r|=z=g|2Rh|VGU2=PMk|1H_x$uAUJ<_p1=p*Rt|@8jQwd9e6+Se%(xki;kZ<2!!=vtwqq"
)
)
)
os.system("cythonize -i -3 -b solve.pyx")
import solve
| false | 33.333333 | [
"-from collections import *",
"+import sys",
"-(h, w), (s, t), (f, g) = eval(\"map(int,input().split()),\" * 3)",
"-d = eval(\"[-1]*w,input(),\" * h)",
"-q = deque([(s - 1, t - 1, 0)])",
"-while q:",
"- y, x, c = q.pop()",
"- if d[y + y][x] < 0:",
"- for a in range(25):",
"- ... | false | 0.040624 | 0.062801 | 0.646874 | [
"s834290425",
"s566637856"
] |
u230621983 | p03339 | python | s569723378 | s530011254 | 206 | 184 | 3,668 | 3,668 | Accepted | Accepted | 10.68 | n = int(eval(input()))
s = eval(input())
all_w = s.count('W')
all_e = s.count('E')
left_w = 0
right_e = all_e
ans = left_w + right_e
for i in range(n):
if s[i] == 'E':
right_e -= 1
ans = min(ans, left_w + right_e)
if s[i] == 'W':
left_w += 1
print(ans) | n = int(eval(input()))
s = eval(input())
left_w = 0
right_e = s.count('E')
ans = left_w + right_e
for i in range(n):
if s[i] == 'E':
right_e -= 1
ans = min(ans, left_w + right_e)
if s[i] == 'W':
left_w += 1
print(ans) | 14 | 12 | 281 | 244 | n = int(eval(input()))
s = eval(input())
all_w = s.count("W")
all_e = s.count("E")
left_w = 0
right_e = all_e
ans = left_w + right_e
for i in range(n):
if s[i] == "E":
right_e -= 1
ans = min(ans, left_w + right_e)
if s[i] == "W":
left_w += 1
print(ans)
| n = int(eval(input()))
s = eval(input())
left_w = 0
right_e = s.count("E")
ans = left_w + right_e
for i in range(n):
if s[i] == "E":
right_e -= 1
ans = min(ans, left_w + right_e)
if s[i] == "W":
left_w += 1
print(ans)
| false | 14.285714 | [
"-all_w = s.count(\"W\")",
"-all_e = s.count(\"E\")",
"-right_e = all_e",
"+right_e = s.count(\"E\")"
] | false | 0.040243 | 0.041288 | 0.974684 | [
"s569723378",
"s530011254"
] |
u106971015 | p02743 | python | s389383086 | s426987337 | 34 | 17 | 5,076 | 2,940 | Accepted | Accepted | 50 | from decimal import Decimal
import math
a,b,c = list(map(int,input().split()))
d = c - a - b
if d >0 and pow(d,2) > 4 * a * b:
print('Yes')
else:print('No') | a,b,c = list(map(int,input().split()))
d = c - a - b
if d >0 and pow(d,2) > 4 * a * b:
print('Yes')
else:print('No') | 7 | 5 | 160 | 118 | from decimal import Decimal
import math
a, b, c = list(map(int, input().split()))
d = c - a - b
if d > 0 and pow(d, 2) > 4 * a * b:
print("Yes")
else:
print("No")
| a, b, c = list(map(int, input().split()))
d = c - a - b
if d > 0 and pow(d, 2) > 4 * a * b:
print("Yes")
else:
print("No")
| false | 28.571429 | [
"-from decimal import Decimal",
"-import math",
"-"
] | false | 0.035813 | 0.086149 | 0.415707 | [
"s389383086",
"s426987337"
] |
u046158516 | p02623 | python | s193512934 | s219007520 | 170 | 155 | 127,060 | 132,540 | Accepted | Accepted | 8.82 | n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
asum=[0]
bsum=[0]
current=0
for i in range(n):
current+=a[i]
asum.append(current)
current=0
pointer=0
for i in range(m):
current+=b[i]
bsum.append(current)
for i in range(n+1):
if asum[i]>k:
pointer=i-1
break
if i==n:
pointer=n
ans=pointer
bpointer=0
for i in range(pointer,-1,-1):
while bpointer<m+1 and bsum[bpointer]+asum[i]<=k:
bpointer+=1
if bpointer==m+1:
break
bpointer-=1
ans=max(ans,i+bpointer)
print(ans) | n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
asum=[0]
bsum=[0]
current=0
for i in range(n):
current+=a[i]
asum.append(current)
current=0
for i in range(m):
current+=b[i]
bsum.append(current)
pointer=0
for i in range(n+1):
if asum[i]>k:
pointer=i-1
break
if i==n:
pointer=n
ans=pointer
bpointer=0
for i in range(pointer,-1,-1):
while bpointer<m and bsum[bpointer+1]+asum[i]<=k:
bpointer+=1
ans=max(ans,i+bpointer)
print(ans)
| 30 | 27 | 584 | 534 | n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
asum = [0]
bsum = [0]
current = 0
for i in range(n):
current += a[i]
asum.append(current)
current = 0
pointer = 0
for i in range(m):
current += b[i]
bsum.append(current)
for i in range(n + 1):
if asum[i] > k:
pointer = i - 1
break
if i == n:
pointer = n
ans = pointer
bpointer = 0
for i in range(pointer, -1, -1):
while bpointer < m + 1 and bsum[bpointer] + asum[i] <= k:
bpointer += 1
if bpointer == m + 1:
break
bpointer -= 1
ans = max(ans, i + bpointer)
print(ans)
| n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
asum = [0]
bsum = [0]
current = 0
for i in range(n):
current += a[i]
asum.append(current)
current = 0
for i in range(m):
current += b[i]
bsum.append(current)
pointer = 0
for i in range(n + 1):
if asum[i] > k:
pointer = i - 1
break
if i == n:
pointer = n
ans = pointer
bpointer = 0
for i in range(pointer, -1, -1):
while bpointer < m and bsum[bpointer + 1] + asum[i] <= k:
bpointer += 1
ans = max(ans, i + bpointer)
print(ans)
| false | 10 | [
"-pointer = 0",
"+pointer = 0",
"- while bpointer < m + 1 and bsum[bpointer] + asum[i] <= k:",
"+ while bpointer < m and bsum[bpointer + 1] + asum[i] <= k:",
"- if bpointer == m + 1:",
"- break",
"- bpointer -= 1"
] | false | 0.036541 | 0.037197 | 0.982357 | [
"s193512934",
"s219007520"
] |
u852690916 | p03545 | python | s823243825 | s295156188 | 184 | 17 | 38,256 | 3,064 | Accepted | Accepted | 90.76 | l = list(map(int, eval(input())))
ans = [''] * 3
for p in range(1<<3):
t = l[0]
for i in range(1,4):
if p & 1:
t += l[i]
ans[i-1] = '+'
else:
t -= l[i]
ans[i-1] = '-'
p >>= 1
if t == 7:
break
print((str(l[0])+ans[0]+str(l[1])+ans[1]+str(l[2])+ans[2]+str(l[3])+'=7')) | s=eval(input())
N=list(map(int,s))
for p in range(1<<3):
t = N[0]
ans = str(t)
for i in range(1,4):
if p&1:
t+=N[i]
ans+='+'+str(N[i])
else:
t-=N[i]
ans+='-'+str(N[i])
p>>=1
if t==7:
print((ans+'=7'))
exit() | 17 | 16 | 368 | 318 | l = list(map(int, eval(input())))
ans = [""] * 3
for p in range(1 << 3):
t = l[0]
for i in range(1, 4):
if p & 1:
t += l[i]
ans[i - 1] = "+"
else:
t -= l[i]
ans[i - 1] = "-"
p >>= 1
if t == 7:
break
print((str(l[0]) + ans[0] + str(l[1]) + ans[1] + str(l[2]) + ans[2] + str(l[3]) + "=7"))
| s = eval(input())
N = list(map(int, s))
for p in range(1 << 3):
t = N[0]
ans = str(t)
for i in range(1, 4):
if p & 1:
t += N[i]
ans += "+" + str(N[i])
else:
t -= N[i]
ans += "-" + str(N[i])
p >>= 1
if t == 7:
print((ans + "=7"))
exit()
| false | 5.882353 | [
"-l = list(map(int, eval(input())))",
"-ans = [\"\"] * 3",
"+s = eval(input())",
"+N = list(map(int, s))",
"- t = l[0]",
"+ t = N[0]",
"+ ans = str(t)",
"- t += l[i]",
"- ans[i - 1] = \"+\"",
"+ t += N[i]",
"+ ans += \"+\" + str(N[i])",
"- ... | false | 0.099792 | 0.044845 | 2.225269 | [
"s823243825",
"s295156188"
] |
u668503853 | p03731 | python | s760624087 | s869555553 | 152 | 131 | 25,200 | 25,200 | Accepted | Accepted | 13.82 | N,T=list(map(int,input().split()))
t=list(map(int,input().split()))
a=T
for i in range(N-1):
a+=min(T,t[i+1]-t[i])
print(a) | N,T=list(map(int,input().split()))
t=list(map(int,input().split()))
a=[min(T,t[i+1]-t[i]) for i in range(N-1)]
print((sum(a)+T)) | 6 | 4 | 124 | 123 | N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
a = T
for i in range(N - 1):
a += min(T, t[i + 1] - t[i])
print(a)
| N, T = list(map(int, input().split()))
t = list(map(int, input().split()))
a = [min(T, t[i + 1] - t[i]) for i in range(N - 1)]
print((sum(a) + T))
| false | 33.333333 | [
"-a = T",
"-for i in range(N - 1):",
"- a += min(T, t[i + 1] - t[i])",
"-print(a)",
"+a = [min(T, t[i + 1] - t[i]) for i in range(N - 1)]",
"+print((sum(a) + T))"
] | false | 0.089478 | 0.126907 | 0.705063 | [
"s760624087",
"s869555553"
] |
u347640436 | p02720 | python | s831428838 | s752342976 | 1,613 | 1,063 | 3,064 | 3,064 | Accepted | Accepted | 34.1 | K = int(eval(input()))
def is_lunlun(i):
result = -1
n = [ord(c) -48 for c in str(i)]
for j in range(len(n) - 1):
if abs(n[j] - n[j + 1]) <= 1:
continue
if n[j] < n[j + 1]:
for k in range(j + 1, len(n)):
n[k] = 0
result = int(''.join(str(k) for k in n))
result += 10 ** (len(n) - (j + 1))
else:
result = int(''.join(str(k) for k in n))
result += 10 ** (len(n) - (j + 2))
break
return result
i = 1
while True:
#print(i)
t = is_lunlun(i)
if t == -1:
K -= 1
if K == 0:
print(i)
exit()
i += 1
else:
i = t
| K = int(eval(input()))
def is_lunlun(i):
result = -1
n = [ord(c) - 48 for c in str(i)]
for j in range(len(n) - 1):
if abs(n[j] - n[j + 1]) <= 1:
continue
if n[j] < n[j + 1]:
for k in range(j + 1, len(n)):
n[k] = max(n[k - 1] - 1, 0)
result = int(''.join(str(k) for k in n))
result += 10 ** (len(n) - (j + 1))
else:
result = int(''.join(str(k) for k in n))
result += 10 ** (len(n) - (j + 2))
break
return result
i = 1
while True:
# print(i)
t = is_lunlun(i)
if t == -1:
K -= 1
if K == 0:
print(i)
exit()
i += 1
else:
i = t
| 31 | 33 | 735 | 760 | K = int(eval(input()))
def is_lunlun(i):
result = -1
n = [ord(c) - 48 for c in str(i)]
for j in range(len(n) - 1):
if abs(n[j] - n[j + 1]) <= 1:
continue
if n[j] < n[j + 1]:
for k in range(j + 1, len(n)):
n[k] = 0
result = int("".join(str(k) for k in n))
result += 10 ** (len(n) - (j + 1))
else:
result = int("".join(str(k) for k in n))
result += 10 ** (len(n) - (j + 2))
break
return result
i = 1
while True:
# print(i)
t = is_lunlun(i)
if t == -1:
K -= 1
if K == 0:
print(i)
exit()
i += 1
else:
i = t
| K = int(eval(input()))
def is_lunlun(i):
result = -1
n = [ord(c) - 48 for c in str(i)]
for j in range(len(n) - 1):
if abs(n[j] - n[j + 1]) <= 1:
continue
if n[j] < n[j + 1]:
for k in range(j + 1, len(n)):
n[k] = max(n[k - 1] - 1, 0)
result = int("".join(str(k) for k in n))
result += 10 ** (len(n) - (j + 1))
else:
result = int("".join(str(k) for k in n))
result += 10 ** (len(n) - (j + 2))
break
return result
i = 1
while True:
# print(i)
t = is_lunlun(i)
if t == -1:
K -= 1
if K == 0:
print(i)
exit()
i += 1
else:
i = t
| false | 6.060606 | [
"- n[k] = 0",
"+ n[k] = max(n[k - 1] - 1, 0)"
] | false | 0.306694 | 0.216587 | 1.416033 | [
"s831428838",
"s752342976"
] |
u736729525 | p03999 | python | s419876996 | s872653144 | 22 | 19 | 3,064 | 3,060 | Accepted | Accepted | 13.64 | S = input().strip()
answer = 0
for n in range(2**(len(S)-1)):
A = [0]
for d in range(9):
if n & (1 << d):
A.append(d+1)
T = []
#print("A", A)
for l, r in zip(A, A[1:]):
T.append(int("".join(S[l:r])))
T.append(int("".join(S[A[-1]:])))
answer += sum(T)
print(answer)
| from itertools import combinations
S = input().strip()
N = len(S)
answer = int(S)
for c in range(1,N):
for t in combinations(list(range(1,N)), c):
i = 0
for j in t:
answer += int(S[i:j])
i = j
j = N
answer += int(S[i:j])
print(answer)
| 17 | 16 | 340 | 307 | S = input().strip()
answer = 0
for n in range(2 ** (len(S) - 1)):
A = [0]
for d in range(9):
if n & (1 << d):
A.append(d + 1)
T = []
# print("A", A)
for l, r in zip(A, A[1:]):
T.append(int("".join(S[l:r])))
T.append(int("".join(S[A[-1] :])))
answer += sum(T)
print(answer)
| from itertools import combinations
S = input().strip()
N = len(S)
answer = int(S)
for c in range(1, N):
for t in combinations(list(range(1, N)), c):
i = 0
for j in t:
answer += int(S[i:j])
i = j
j = N
answer += int(S[i:j])
print(answer)
| false | 5.882353 | [
"+from itertools import combinations",
"+",
"-answer = 0",
"-for n in range(2 ** (len(S) - 1)):",
"- A = [0]",
"- for d in range(9):",
"- if n & (1 << d):",
"- A.append(d + 1)",
"- T = []",
"- # print(\"A\", A)",
"- for l, r in zip(A, A[1:]):",
"- T.appe... | false | 0.045806 | 0.046822 | 0.978302 | [
"s419876996",
"s872653144"
] |
u997641430 | p03160 | python | s288714801 | s472574846 | 292 | 109 | 52,208 | 13,928 | Accepted | Accepted | 62.67 | N, K = int(eval(input())), 2
*h, = list(map(int, input().split()))
a = [abs(h[0] - h[k]) for k in range(K)]
for n in range(N - K):
a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])]
print((a[K - 1]))
| n = int(eval(input()))
*H, = list(map(int, input().split()))
a, b = 0, abs(H[0]-H[1])
for i in range(2, n):
a, b = b, min(a+abs(H[i]-H[i-2]), b+abs(H[i]-H[i-1]))
print(b)
| 6 | 6 | 215 | 168 | N, K = int(eval(input())), 2
(*h,) = list(map(int, input().split()))
a = [abs(h[0] - h[k]) for k in range(K)]
for n in range(N - K):
a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])]
print((a[K - 1]))
| n = int(eval(input()))
(*H,) = list(map(int, input().split()))
a, b = 0, abs(H[0] - H[1])
for i in range(2, n):
a, b = b, min(a + abs(H[i] - H[i - 2]), b + abs(H[i] - H[i - 1]))
print(b)
| false | 0 | [
"-N, K = int(eval(input())), 2",
"-(*h,) = list(map(int, input().split()))",
"-a = [abs(h[0] - h[k]) for k in range(K)]",
"-for n in range(N - K):",
"- a = a[1:] + [min([a[k] + abs(h[n + k] - h[n + K]) for k in range(K)])]",
"-print((a[K - 1]))",
"+n = int(eval(input()))",
"+(*H,) = list(map(int, i... | false | 0.071508 | 0.035155 | 2.034088 | [
"s288714801",
"s472574846"
] |
u596276291 | p03795 | python | s078900734 | s353238210 | 178 | 33 | 3,444 | 3,444 | Accepted | Accepted | 81.46 | from collections import defaultdict
def main():
n = int(eval(input()))
print((n * 800 - 200 * (n // 15)))
if __name__ == '__main__':
main()
| from collections import defaultdict
def main():
N = int(eval(input()))
print((800 * N - (N // 15) * 200))
if __name__ == '__main__':
main()
| 10 | 10 | 157 | 157 | from collections import defaultdict
def main():
n = int(eval(input()))
print((n * 800 - 200 * (n // 15)))
if __name__ == "__main__":
main()
| from collections import defaultdict
def main():
N = int(eval(input()))
print((800 * N - (N // 15) * 200))
if __name__ == "__main__":
main()
| false | 0 | [
"- n = int(eval(input()))",
"- print((n * 800 - 200 * (n // 15)))",
"+ N = int(eval(input()))",
"+ print((800 * N - (N // 15) * 200))"
] | false | 0.045398 | 0.045981 | 0.987336 | [
"s078900734",
"s353238210"
] |
u489959379 | p03044 | python | s077200163 | s350977280 | 787 | 491 | 82,300 | 104,444 | Accepted | Accepted | 37.61 | import sys
sys.setrecursionlimit(10**9)
def dfs(v, p, dist):
for u, w in tree[v]:
if u == p:
continue
else:
dist[u] = dist[v] + w
dfs(u, v, dist)
n = int(eval(input()))
tree = [[] for _ in range(n)]
for _ in range(n - 1):
u, v, w = list(map(int, input().split()))
tree[u - 1].append((v - 1, w))
tree[v - 1].append((u - 1, w))
dist = [0 for _ in range(n)]
dfs(0, -1, dist)
for i in dist:
if i % 2 == 0:
print((0))
else:
print((1))
| import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
def dfs(v, p):
for u, w in tree[v]:
if u == p:
continue
else:
dist[u] = dist[v] + w
dfs(u, v)
n = int(input())
tree = [[] for _ in range(n)]
for _ in range(n - 1):
u, v, w = map(int, input().split())
tree[u - 1].append([v - 1, w])
tree[v - 1].append([u - 1, w])
dist = [0] * n
dfs(0, -1)
res = []
for d in dist:
res.append(0 if d % 2 == 0 else 1)
print(*res, sep="\n")
if __name__ == '__main__':
resolve()
| 28 | 34 | 539 | 721 | import sys
sys.setrecursionlimit(10**9)
def dfs(v, p, dist):
for u, w in tree[v]:
if u == p:
continue
else:
dist[u] = dist[v] + w
dfs(u, v, dist)
n = int(eval(input()))
tree = [[] for _ in range(n)]
for _ in range(n - 1):
u, v, w = list(map(int, input().split()))
tree[u - 1].append((v - 1, w))
tree[v - 1].append((u - 1, w))
dist = [0 for _ in range(n)]
dfs(0, -1, dist)
for i in dist:
if i % 2 == 0:
print((0))
else:
print((1))
| import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7
def resolve():
def dfs(v, p):
for u, w in tree[v]:
if u == p:
continue
else:
dist[u] = dist[v] + w
dfs(u, v)
n = int(input())
tree = [[] for _ in range(n)]
for _ in range(n - 1):
u, v, w = map(int, input().split())
tree[u - 1].append([v - 1, w])
tree[v - 1].append([u - 1, w])
dist = [0] * n
dfs(0, -1)
res = []
for d in dist:
res.append(0 if d % 2 == 0 else 1)
print(*res, sep="\n")
if __name__ == "__main__":
resolve()
| false | 17.647059 | [
"-sys.setrecursionlimit(10**9)",
"+sys.setrecursionlimit(10**7)",
"+input = sys.stdin.readline",
"+f_inf = float(\"inf\")",
"+mod = 10**9 + 7",
"-def dfs(v, p, dist):",
"- for u, w in tree[v]:",
"- if u == p:",
"- continue",
"- else:",
"- dist[u] = dist[v] ... | false | 0.100741 | 0.044611 | 2.258212 | [
"s077200163",
"s350977280"
] |
u624696727 | p02842 | python | s795319706 | s069232252 | 178 | 28 | 38,256 | 3,064 | Accepted | Accepted | 84.27 | import sys
input = sys.stdin.readline
N = int(eval(input()))
p=N/1.08
if(p%1==0):
print((int(p)))
else:
if(int((int(p)+1)*1.08)!=N):
print(":(")
else:
print((int(p)+1)) | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def main():
n = II()
ch = False
for i in range(n+1):
if(n==int(i * 1.08)):
print(i)
ch = True
break
if ch==False:
print(":(")
if __name__ == '__main__':
main()
| 13 | 29 | 179 | 827 | import sys
input = sys.stdin.readline
N = int(eval(input()))
p = N / 1.08
if p % 1 == 0:
print((int(p)))
else:
if int((int(p) + 1) * 1.08) != N:
print(":(")
else:
print((int(p) + 1))
| import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str, x)))
def IS():
return sys.stdin.readline()[:-1]
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LI1():
return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number):
return [II() for _ in range(rows_number)]
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def LLI1(rows_number):
return [LI1() for _ in range(rows_number)]
def main():
n = II()
ch = False
for i in range(n + 1):
if n == int(i * 1.08):
print(i)
ch = True
break
if ch == False:
print(":(")
if __name__ == "__main__":
main()
| false | 55.172414 | [
"-input = sys.stdin.readline",
"-N = int(eval(input()))",
"-p = N / 1.08",
"-if p % 1 == 0:",
"- print((int(p)))",
"-else:",
"- if int((int(p) + 1) * 1.08) != N:",
"+sys.setrecursionlimit(10**6)",
"+int1 = lambda x: int(x) - 1",
"+printV = lambda x: print(*x, sep=\"\\n\")",
"+printH = lamb... | false | 0.059069 | 0.034717 | 1.701451 | [
"s795319706",
"s069232252"
] |
u522949850 | p03434 | python | s951737951 | s399675558 | 56 | 17 | 4,692 | 3,060 | Accepted | Accepted | 69.64 | import sys
import subprocess
import re
import datetime
import os
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(N):
if i%2 == 0:
Alice = Alice + A[i]
else:
Bob = Bob + A[i]
ans = (Alice - Bob)
print(ans) |
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(N):
if i%2 == 0:
Alice = Alice + A[i]
else:
Bob = Bob + A[i]
ans = (Alice - Bob)
print(ans) | 23 | 18 | 314 | 244 | import sys
import subprocess
import re
import datetime
import os
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(N):
if i % 2 == 0:
Alice = Alice + A[i]
else:
Bob = Bob + A[i]
ans = Alice - Bob
print(ans)
| N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(N):
if i % 2 == 0:
Alice = Alice + A[i]
else:
Bob = Bob + A[i]
ans = Alice - Bob
print(ans)
| false | 21.73913 | [
"-import sys",
"-import subprocess",
"-import re",
"-import datetime",
"-import os",
"-"
] | false | 0.043321 | 0.03783 | 1.145142 | [
"s951737951",
"s399675558"
] |
u750838232 | p02785 | python | s122943394 | s362643897 | 174 | 150 | 26,024 | 26,180 | Accepted | Accepted | 13.79 | n,k = list(map(int, input().split()))
h = list(map(int, input().split()))
h.sort(reverse=True)
ans = 0
for i in range(k, n):
ans += h[i]
print(ans) | n,k = list(map(int, input().split()))
h = list(map(int, input().split()))
h.sort(reverse=True)
print((sum(h[k:]))) | 10 | 6 | 157 | 115 | n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
h.sort(reverse=True)
ans = 0
for i in range(k, n):
ans += h[i]
print(ans)
| n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
h.sort(reverse=True)
print((sum(h[k:])))
| false | 40 | [
"-ans = 0",
"-for i in range(k, n):",
"- ans += h[i]",
"-print(ans)",
"+print((sum(h[k:])))"
] | false | 0.07382 | 0.103615 | 0.71244 | [
"s122943394",
"s362643897"
] |
u102461423 | p02974 | python | s090559341 | s851591182 | 403 | 333 | 15,024 | 14,284 | Accepted | Accepted | 17.37 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np
N,K = list(map(int,input().split()))
# ある線を、左にまたぐ数の集合、右にまたぐ数の集合など
MOD = 10 ** 9 + 7
dp = np.zeros((N+1,N*N+1), dtype = np.int64) # ある線をまたぐ(左右)個数、これまでの合計点、場合の数
dp[0,0] = 1
for n in range(1,N+1):
prev = dp
dp = np.zeros_like(prev)
for m in range(N):
dp[m,m:] += prev[m,:N*N+1-m] # その点を不動点にしてそのまま
dp[m,m:] += prev[m,:N*N+1-m] * m # どれかをそこに留めてのこりを右に
dp[m+1,m+1:] += (m+1) * prev[m,:N*N-m] # その点ごと全部右に。左に流す方をどれか残す
dp[m,m:] += prev[m,:N*N+1-m] * m # xを左に、左から来たのは全て右に
dp[m,m:] += (m+1) * prev[m+1,:N*N+1-m] # その点ごと全部右に。左に流す方をどれか残す
dp %= MOD
if K&1:
answer = 0
else:
answer = dp[0,K//2]
print(answer) | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10**9 + 7
N,K = list(map(int,read().split()))
# 左からの流入量、コスト
L = N*(N-1)//2+1
dp = np.zeros((N,L),dtype=np.int64)
dp[0,0] = 1
for _ in range(1,N+1):
prev = dp
dp = np.zeros_like(prev)
for n in range(N):
# 自身を不動点にしてそのまま左右に流す
dp[n,n:] += prev[n,:L-n]
# 左からのものを採用、自身は左に流す
if n > 0: dp[n-1,n-1:] += prev[n,:L-n+1] * n
# 左からのものを採用、自身は右に流す
dp[n,n:] += prev[n,:L-n] * n
# 右からのものを採用、自身は左に流す
dp[n,n:] += prev[n,:L-n] * n
# 右からのものを採用、自身は右に流す
if n+1 < N: dp[n+1,n+1:] += prev[n,:L-n-1] * (n+1)
dp %= MOD
x = dp[0]
if K&1:
answer = 0
elif K//2 < L:
answer = x[K//2]
else:
answer = 0
print(answer) | 30 | 40 | 771 | 871 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
import numpy as np
N, K = list(map(int, input().split()))
# ある線を、左にまたぐ数の集合、右にまたぐ数の集合など
MOD = 10**9 + 7
dp = np.zeros((N + 1, N * N + 1), dtype=np.int64) # ある線をまたぐ(左右)個数、これまでの合計点、場合の数
dp[0, 0] = 1
for n in range(1, N + 1):
prev = dp
dp = np.zeros_like(prev)
for m in range(N):
dp[m, m:] += prev[m, : N * N + 1 - m] # その点を不動点にしてそのまま
dp[m, m:] += prev[m, : N * N + 1 - m] * m # どれかをそこに留めてのこりを右に
dp[m + 1, m + 1 :] += (m + 1) * prev[m, : N * N - m] # その点ごと全部右に。左に流す方をどれか残す
dp[m, m:] += prev[m, : N * N + 1 - m] * m # xを左に、左から来たのは全て右に
dp[m, m:] += (m + 1) * prev[m + 1, : N * N + 1 - m] # その点ごと全部右に。左に流す方をどれか残す
dp %= MOD
if K & 1:
answer = 0
else:
answer = dp[0, K // 2]
print(answer)
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10**9 + 7
N, K = list(map(int, read().split()))
# 左からの流入量、コスト
L = N * (N - 1) // 2 + 1
dp = np.zeros((N, L), dtype=np.int64)
dp[0, 0] = 1
for _ in range(1, N + 1):
prev = dp
dp = np.zeros_like(prev)
for n in range(N):
# 自身を不動点にしてそのまま左右に流す
dp[n, n:] += prev[n, : L - n]
# 左からのものを採用、自身は左に流す
if n > 0:
dp[n - 1, n - 1 :] += prev[n, : L - n + 1] * n
# 左からのものを採用、自身は右に流す
dp[n, n:] += prev[n, : L - n] * n
# 右からのものを採用、自身は左に流す
dp[n, n:] += prev[n, : L - n] * n
# 右からのものを採用、自身は右に流す
if n + 1 < N:
dp[n + 1, n + 1 :] += prev[n, : L - n - 1] * (n + 1)
dp %= MOD
x = dp[0]
if K & 1:
answer = 0
elif K // 2 < L:
answer = x[K // 2]
else:
answer = 0
print(answer)
| false | 25 | [
"-input = sys.stdin.readline",
"-sys.setrecursionlimit(10**7)",
"+read = sys.stdin.buffer.read",
"+readline = sys.stdin.buffer.readline",
"+readlines = sys.stdin.buffer.readlines",
"-N, K = list(map(int, input().split()))",
"-# ある線を、左にまたぐ数の集合、右にまたぐ数の集合など",
"-dp = np.zeros((N + 1, N * N + 1), dtype=np.... | false | 0.231294 | 0.220092 | 1.050897 | [
"s090559341",
"s851591182"
] |
u677121387 | p02682 | python | s422983651 | s884450618 | 24 | 21 | 8,876 | 9,056 | Accepted | Accepted | 12.5 | a,b,c,k = list(map(int,input().split()))
if a + b >= k:
ans = min(a,k)
else:
ans = a - (k-a-b)
print(ans) | a,b,c,k = list(map(int,input().split()))
print((min(a,k)-max(k-a-b,0))) | 6 | 2 | 112 | 64 | a, b, c, k = list(map(int, input().split()))
if a + b >= k:
ans = min(a, k)
else:
ans = a - (k - a - b)
print(ans)
| a, b, c, k = list(map(int, input().split()))
print((min(a, k) - max(k - a - b, 0)))
| false | 66.666667 | [
"-if a + b >= k:",
"- ans = min(a, k)",
"-else:",
"- ans = a - (k - a - b)",
"-print(ans)",
"+print((min(a, k) - max(k - a - b, 0)))"
] | false | 0.038441 | 0.039209 | 0.980412 | [
"s422983651",
"s884450618"
] |
u127499732 | p03472 | python | s123307553 | s485971333 | 196 | 112 | 26,396 | 25,636 | Accepted | Accepted | 42.86 | def main():
from collections import deque
from math import ceil
n, h, *ab = list(map(int, open(0).read().split()))
a = ab[::2]
*b, = [-x for x in ab[1::2]]
c = a + b
c.sort(key=lambda x: abs(x), reverse=True)
q = deque(c)
cnt = 0
while h > 0:
cnt += 1
x = q.popleft()
h -= abs(x)
if x > 0:
cnt += ceil(h / x)
break
print(cnt)
if __name__ == '__main__':
main()
| def main():
from math import ceil
from itertools import accumulate
from bisect import bisect_left
n, h, *ab = list(map(int, open(0).read().split()))
x = max(ab[::2])
*y, = [i for i in ab[1::2] if i >= x]
y.sort(reverse=True)
*z, = accumulate(y)
if z[-1] <= h:
print((len(y) + ceil((h - z[-1]) / x)))
else:
print((bisect_left(z, h) + 1))
if __name__ == '__main__':
main()
| 24 | 19 | 490 | 446 | def main():
from collections import deque
from math import ceil
n, h, *ab = list(map(int, open(0).read().split()))
a = ab[::2]
(*b,) = [-x for x in ab[1::2]]
c = a + b
c.sort(key=lambda x: abs(x), reverse=True)
q = deque(c)
cnt = 0
while h > 0:
cnt += 1
x = q.popleft()
h -= abs(x)
if x > 0:
cnt += ceil(h / x)
break
print(cnt)
if __name__ == "__main__":
main()
| def main():
from math import ceil
from itertools import accumulate
from bisect import bisect_left
n, h, *ab = list(map(int, open(0).read().split()))
x = max(ab[::2])
(*y,) = [i for i in ab[1::2] if i >= x]
y.sort(reverse=True)
(*z,) = accumulate(y)
if z[-1] <= h:
print((len(y) + ceil((h - z[-1]) / x)))
else:
print((bisect_left(z, h) + 1))
if __name__ == "__main__":
main()
| false | 20.833333 | [
"- from collections import deque",
"+ from itertools import accumulate",
"+ from bisect import bisect_left",
"- a = ab[::2]",
"- (*b,) = [-x for x in ab[1::2]]",
"- c = a + b",
"- c.sort(key=lambda x: abs(x), reverse=True)",
"- q = deque(c)",
"- cnt = 0",
"- while h >... | false | 0.039149 | 0.143369 | 0.273062 | [
"s123307553",
"s485971333"
] |
u934442292 | p03283 | python | s164150859 | s294082483 | 927 | 501 | 119,548 | 113,128 | Accepted | Accepted | 45.95 | import sys
import numba as nb
import numpy as np
input = sys.stdin.readline
@nb.njit("i8[:](i8,i8,i8,i8[:,:],i8[:,:])", cache=True)
def solve(N, M, Q, LR, pq):
S = np.zeros(shape=(N + 1, N + 1), dtype=np.int64)
for i in range(M):
L, R = LR[i]
S[L][R] += 1
for i in range(N + 1):
S[i] = np.cumsum(S[i])
ans = np.zeros(shape=Q, dtype=np.int64)
for i in range(Q):
p, q = pq[i]
for j in range(p, q + 1):
ans[i] += S[j][q] - S[j][p - 1]
return ans
def main():
N, M, Q = list(map(int, input().split()))
LR = np.zeros(shape=(M, 2), dtype=np.int64)
for i in range(M):
LR[i] = input().split()
pq = np.zeros(shape=(Q, 2), dtype=np.int64)
for i in range(Q):
pq[i] = input().split()
ans = solve(N, M, Q, LR, pq)
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| import sys
from itertools import accumulate
input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
LR = [None] * M
for i in range(M):
LR[i] = tuple(map(int, input().split()))
pq = [None] * Q
for i in range(Q):
pq[i] = tuple(map(int, input().split()))
S = [[0] * (N + 1) for _ in range(N + 1)]
for L, R in LR:
S[L][R] += 1
for i in range(N + 1):
S[i] = list(accumulate(S[i]))
ans = [0] * Q
for i, (p, q) in enumerate(pq):
for j in range(p, q + 1):
ans[i] += S[j][q] - S[j][p - 1]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| 42 | 31 | 937 | 703 | import sys
import numba as nb
import numpy as np
input = sys.stdin.readline
@nb.njit("i8[:](i8,i8,i8,i8[:,:],i8[:,:])", cache=True)
def solve(N, M, Q, LR, pq):
S = np.zeros(shape=(N + 1, N + 1), dtype=np.int64)
for i in range(M):
L, R = LR[i]
S[L][R] += 1
for i in range(N + 1):
S[i] = np.cumsum(S[i])
ans = np.zeros(shape=Q, dtype=np.int64)
for i in range(Q):
p, q = pq[i]
for j in range(p, q + 1):
ans[i] += S[j][q] - S[j][p - 1]
return ans
def main():
N, M, Q = list(map(int, input().split()))
LR = np.zeros(shape=(M, 2), dtype=np.int64)
for i in range(M):
LR[i] = input().split()
pq = np.zeros(shape=(Q, 2), dtype=np.int64)
for i in range(Q):
pq[i] = input().split()
ans = solve(N, M, Q, LR, pq)
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| import sys
from itertools import accumulate
input = sys.stdin.readline
def main():
N, M, Q = list(map(int, input().split()))
LR = [None] * M
for i in range(M):
LR[i] = tuple(map(int, input().split()))
pq = [None] * Q
for i in range(Q):
pq[i] = tuple(map(int, input().split()))
S = [[0] * (N + 1) for _ in range(N + 1)]
for L, R in LR:
S[L][R] += 1
for i in range(N + 1):
S[i] = list(accumulate(S[i]))
ans = [0] * Q
for i, (p, q) in enumerate(pq):
for j in range(p, q + 1):
ans[i] += S[j][q] - S[j][p - 1]
print(("\n".join(map(str, ans))))
if __name__ == "__main__":
main()
| false | 26.190476 | [
"-import numba as nb",
"-import numpy as np",
"+from itertools import accumulate",
"-@nb.njit(\"i8[:](i8,i8,i8,i8[:,:],i8[:,:])\", cache=True)",
"-def solve(N, M, Q, LR, pq):",
"- S = np.zeros(shape=(N + 1, N + 1), dtype=np.int64)",
"+def main():",
"+ N, M, Q = list(map(int, input().split()))",
... | false | 0.035702 | 0.035219 | 1.013703 | [
"s164150859",
"s294082483"
] |
u902641880 | p02909 | python | s399050806 | s460923290 | 163 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.57 | weather = eval(input())
if weather == "Sunny":
print("Cloudy")
elif weather == "Cloudy":
print("Rainy")
else:
print("Sunny") | w = eval(input())
if w == "Sunny":
print("Cloudy")
elif w == "Cloudy":
print("Rainy")
else:
print("Sunny") | 8 | 8 | 131 | 120 | weather = eval(input())
if weather == "Sunny":
print("Cloudy")
elif weather == "Cloudy":
print("Rainy")
else:
print("Sunny")
| w = eval(input())
if w == "Sunny":
print("Cloudy")
elif w == "Cloudy":
print("Rainy")
else:
print("Sunny")
| false | 0 | [
"-weather = eval(input())",
"-if weather == \"Sunny\":",
"+w = eval(input())",
"+if w == \"Sunny\":",
"-elif weather == \"Cloudy\":",
"+elif w == \"Cloudy\":"
] | false | 0.04193 | 0.036285 | 1.155577 | [
"s399050806",
"s460923290"
] |
u548525760 | p02602 | python | s714371963 | s255532906 | 175 | 141 | 31,688 | 31,752 | Accepted | Accepted | 19.43 | N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
flag = 1
for i in range(N):
if a[i] < a[i + K]:
print('Yes')
else:
print("No")
flag += 1
if flag == N-K+1:
break | N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(N-K):
if a[i] < a[i + K]:
print('Yes')
else:
print("No") | 12 | 8 | 233 | 172 | N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
flag = 1
for i in range(N):
if a[i] < a[i + K]:
print("Yes")
else:
print("No")
flag += 1
if flag == N - K + 1:
break
| N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(N - K):
if a[i] < a[i + K]:
print("Yes")
else:
print("No")
| false | 33.333333 | [
"-flag = 1",
"-for i in range(N):",
"+for i in range(N - K):",
"- flag += 1",
"- if flag == N - K + 1:",
"- break"
] | false | 0.036658 | 0.04195 | 0.873858 | [
"s714371963",
"s255532906"
] |
u562935282 | p02697 | python | s920993353 | s706246025 | 119 | 83 | 102,356 | 21,168 | Accepted | Accepted | 30.25 | def main():
N, M = list(map(int, input().split()))
# i = 0
# cnt = 0
# while cnt < M:
# if (N - i * 2 - 1) * 2 != N:
# print(1 + i, N - i)
# cnt += 1
# i += 1
i = 0
j = 0
cnt = 0
d = set()
ans = []
while cnt < M:
d1 = N - i * 2 - j - 1
d2 = N - d1
if d1 in d or d2 in d or d1 * 2 == N or d2 * 2 == N:
j += 1
continue
ans.append((1 + i + j, N - i))
d.add(d1)
d.add(d2)
cnt += 1
i += 1
for row in ans:
print((*row))
if __name__ == '__main__':
main()
| def main():
N, M = list(map(int, input().split()))
pairs = []
a = 1
for d in range(M, 0, -2):
pairs.append((a, a + d))
a += 1
a = 1 + M + 1
for d in range(M - 1, 0, -2):
pairs.append((a, a + d))
a += 1
for pair in pairs:
print((*pair))
if __name__ == '__main__':
main()
| 35 | 20 | 664 | 358 | def main():
N, M = list(map(int, input().split()))
# i = 0
# cnt = 0
# while cnt < M:
# if (N - i * 2 - 1) * 2 != N:
# print(1 + i, N - i)
# cnt += 1
# i += 1
i = 0
j = 0
cnt = 0
d = set()
ans = []
while cnt < M:
d1 = N - i * 2 - j - 1
d2 = N - d1
if d1 in d or d2 in d or d1 * 2 == N or d2 * 2 == N:
j += 1
continue
ans.append((1 + i + j, N - i))
d.add(d1)
d.add(d2)
cnt += 1
i += 1
for row in ans:
print((*row))
if __name__ == "__main__":
main()
| def main():
N, M = list(map(int, input().split()))
pairs = []
a = 1
for d in range(M, 0, -2):
pairs.append((a, a + d))
a += 1
a = 1 + M + 1
for d in range(M - 1, 0, -2):
pairs.append((a, a + d))
a += 1
for pair in pairs:
print((*pair))
if __name__ == "__main__":
main()
| false | 42.857143 | [
"- # i = 0",
"- # cnt = 0",
"- # while cnt < M:",
"- # if (N - i * 2 - 1) * 2 != N:",
"- # print(1 + i, N - i)",
"- # cnt += 1",
"- # i += 1",
"- i = 0",
"- j = 0",
"- cnt = 0",
"- d = set()",
"- ans = []",
"- while cnt < M:",
... | false | 0.03738 | 0.041352 | 0.903942 | [
"s920993353",
"s706246025"
] |
u377989038 | p02678 | python | s796223828 | s787995264 | 885 | 757 | 74,368 | 39,192 | Accepted | Accepted | 14.46 | from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
g = [[] for _ in range(n)]
for a, b in ab:
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque()
q.append(0)
b = [0] * n
while q:
r = q.popleft()
for i in g[r]:
if b[i] != 0:
continue
if i == 0:
continue
b[i] = r + 1
q.append(i)
for i in b[1:]:
if i == 0:
print("No")
exit()
print("Yes")
print(*b[1:], sep="\n")
| from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
x = q.popleft()
for i in g[x]:
if b[i] != 0:
continue
b[i] = x + 1
q.append(i)
if 0 in b[1:]:
print("No")
else:
print("Yes")
print(*b[1:], sep="\n")
| 29 | 24 | 560 | 466 | from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
g = [[] for _ in range(n)]
for a, b in ab:
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque()
q.append(0)
b = [0] * n
while q:
r = q.popleft()
for i in g[r]:
if b[i] != 0:
continue
if i == 0:
continue
b[i] = r + 1
q.append(i)
for i in b[1:]:
if i == 0:
print("No")
exit()
print("Yes")
print(*b[1:], sep="\n")
| from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
a, b = map(int, input().split())
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
q = deque([0])
b = [0] * n
while q:
x = q.popleft()
for i in g[x]:
if b[i] != 0:
continue
b[i] = x + 1
q.append(i)
if 0 in b[1:]:
print("No")
else:
print("Yes")
print(*b[1:], sep="\n")
| false | 17.241379 | [
"-ab = [list(map(int, input().split())) for _ in range(m)]",
"-for a, b in ab:",
"+for i in range(m):",
"+ a, b = map(int, input().split())",
"-q = deque()",
"-q.append(0)",
"+q = deque([0])",
"- r = q.popleft()",
"- for i in g[r]:",
"+ x = q.popleft()",
"+ for i in g[x]:",
"- ... | false | 0.067633 | 0.034122 | 1.982092 | [
"s796223828",
"s787995264"
] |
u604839890 | p03371 | python | s929551171 | s789954502 | 31 | 28 | 9,160 | 9,116 | Accepted | Accepted | 9.68 | a, b, c, x, y = list(map(int, input().split()))
print((min(a*x+b*y, c*2*x+b*max(0,y-x), c*2*y+a*max(0,x-y)))) | a, b, c, x, y = list(map(int, input().split()))
print((min(a*x+b*y, a*max(x-y, 0)+b*max(y-x, 0)+c*2*min(x, y), c*2*max(x, y)))) | 2 | 2 | 102 | 120 | a, b, c, x, y = list(map(int, input().split()))
print(
(min(a * x + b * y, c * 2 * x + b * max(0, y - x), c * 2 * y + a * max(0, x - y)))
)
| a, b, c, x, y = list(map(int, input().split()))
print(
(
min(
a * x + b * y,
a * max(x - y, 0) + b * max(y - x, 0) + c * 2 * min(x, y),
c * 2 * max(x, y),
)
)
)
| false | 0 | [
"- (min(a * x + b * y, c * 2 * x + b * max(0, y - x), c * 2 * y + a * max(0, x - y)))",
"+ (",
"+ min(",
"+ a * x + b * y,",
"+ a * max(x - y, 0) + b * max(y - x, 0) + c * 2 * min(x, y),",
"+ c * 2 * max(x, y),",
"+ )",
"+ )"
] | false | 0.007551 | 0.096715 | 0.078074 | [
"s929551171",
"s789954502"
] |
u844646164 | p03472 | python | s133868688 | s241642974 | 1,255 | 714 | 85,336 | 122,860 | Accepted | Accepted | 43.11 | N, H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
a_featured = ab[:]
b_featured = ab[:]
a_featured = sorted(a_featured, key=lambda x: [x[0], x[1]], reverse=True)
b_featured = sorted(b_featured, key=lambda x: [x[1], x[0]], reverse=True)
a_max = a_featured[0]
ans = 0
for i in range(N):
if b_featured[i][1] >= a_max[0]:
H -= b_featured[i][1]
ans += 1
if H <= 0:
print(ans)
exit()
print((ans + (H-1)//a_max[0] + 1)) | N, H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
ans = 0
attack = []
for a, b in ab:
attack += [[a, 0]]
attack += [[b, 1]]
attack = sorted(attack, key=lambda x:(-x[0], x[1]))
for a, i in attack:
if i == 1:
H -= a
ans += 1
if H <= 0:
break
else:
cnt = (H-1)//a + 1
ans += cnt
break
print(ans) | 16 | 24 | 505 | 436 | N, H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
a_featured = ab[:]
b_featured = ab[:]
a_featured = sorted(a_featured, key=lambda x: [x[0], x[1]], reverse=True)
b_featured = sorted(b_featured, key=lambda x: [x[1], x[0]], reverse=True)
a_max = a_featured[0]
ans = 0
for i in range(N):
if b_featured[i][1] >= a_max[0]:
H -= b_featured[i][1]
ans += 1
if H <= 0:
print(ans)
exit()
print((ans + (H - 1) // a_max[0] + 1))
| N, H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N)]
ans = 0
attack = []
for a, b in ab:
attack += [[a, 0]]
attack += [[b, 1]]
attack = sorted(attack, key=lambda x: (-x[0], x[1]))
for a, i in attack:
if i == 1:
H -= a
ans += 1
if H <= 0:
break
else:
cnt = (H - 1) // a + 1
ans += cnt
break
print(ans)
| false | 33.333333 | [
"-a_featured = ab[:]",
"-b_featured = ab[:]",
"-a_featured = sorted(a_featured, key=lambda x: [x[0], x[1]], reverse=True)",
"-b_featured = sorted(b_featured, key=lambda x: [x[1], x[0]], reverse=True)",
"-a_max = a_featured[0]",
"-for i in range(N):",
"- if b_featured[i][1] >= a_max[0]:",
"- ... | false | 0.045395 | 0.04389 | 1.034292 | [
"s133868688",
"s241642974"
] |
u816631826 | p03417 | python | s707005272 | s611052840 | 21 | 17 | 3,316 | 3,060 | Accepted | Accepted | 19.05 | #!/usr/bin/env python3
from math import *
from itertools import *
from collections import *
from bisect import *
if __name__ == '__main__':
n,m = list(map(int, input().split()))
if n == 1:
if m == 1:
print((1))
else:
print((m-2))
elif m == 1:
print((n-2))
else:
center = n*m - 2*n - 2*m + 4
print(center)
| #!/usr/bin/env python
# Initially, all cards face up.
# Given that N,M >= 0.
# Let N <= M.
# Ultimately:
# if N,M==1: singular card will flip.
# elif N==1: interior cards will flip (interior to line).
# else N,M > 1: interior cards will flip (interior to area).
# Fetching input
N,M = list(map(int,input().split()))
# Ensuring N <= M
if N > M:
M,N = N,M
# Requires N <= M:
def numflips(N,M):
if N==0: return 0
if N==1:
if M==1: return 1
return (M-2)
return (N-2)*(M-2)
ans = numflips(N,M)
print(ans) | 22 | 27 | 399 | 574 | #!/usr/bin/env python3
from math import *
from itertools import *
from collections import *
from bisect import *
if __name__ == "__main__":
n, m = list(map(int, input().split()))
if n == 1:
if m == 1:
print((1))
else:
print((m - 2))
elif m == 1:
print((n - 2))
else:
center = n * m - 2 * n - 2 * m + 4
print(center)
| #!/usr/bin/env python
# Initially, all cards face up.
# Given that N,M >= 0.
# Let N <= M.
# Ultimately:
# if N,M==1: singular card will flip.
# elif N==1: interior cards will flip (interior to line).
# else N,M > 1: interior cards will flip (interior to area).
# Fetching input
N, M = list(map(int, input().split()))
# Ensuring N <= M
if N > M:
M, N = N, M
# Requires N <= M:
def numflips(N, M):
if N == 0:
return 0
if N == 1:
if M == 1:
return 1
return M - 2
return (N - 2) * (M - 2)
ans = numflips(N, M)
print(ans)
| false | 18.518519 | [
"-#!/usr/bin/env python3",
"-from math import *",
"-from itertools import *",
"-from collections import *",
"-from bisect import *",
"+#!/usr/bin/env python",
"+# Initially, all cards face up.",
"+# Given that N,M >= 0.",
"+# Let N <= M.",
"+# Ultimately:",
"+# if N,M==1: singular card wi... | false | 0.041311 | 0.046379 | 0.890709 | [
"s707005272",
"s611052840"
] |
u754022296 | p03053 | python | s107596100 | s331648272 | 569 | 507 | 87,644 | 87,644 | Accepted | Accepted | 10.9 | from collections import deque
h, w = list(map(int, input().split()))
A = [eval(input()) for _ in range(h)]
dist = [[-1]*w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
for j in range(w):
if A[i][j] == "#":
que.append((i, j))
dist[i][j] = 0
while que:
y, x = que.popleft()
for dy, dx in zip(di, dj):
ny, nx = y+dy, x+dx
if ny < 0 or ny >= h or nx < 0 or nx >= w:
continue
if dist[ny][nx] != -1:
continue
dist[ny][nx] = dist[y][x] + 1
que.append((ny, nx))
ans = 0
for i in dist:
ans = max(ans, max(i))
print(ans) | from collections import deque
h, w = list(map(int, input().split()))
A = [eval(input()) for _ in range(h)]
dist = [[-1]*w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
for j in range(w):
if A[i][j] == "#":
que.append((i, j))
dist[i][j] = 0
ans = 0
while que:
y, x = que.popleft()
for dy, dx in zip(di, dj):
ny, nx = y+dy, x+dx
if ny < 0 or ny >= h or nx < 0 or nx >= w:
continue
if dist[ny][nx] != -1:
continue
dist[ny][nx] = dist[y][x] + 1
ans = max(ans, dist[ny][nx])
que.append((ny, nx))
print(ans)
| 26 | 25 | 623 | 616 | from collections import deque
h, w = list(map(int, input().split()))
A = [eval(input()) for _ in range(h)]
dist = [[-1] * w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
for j in range(w):
if A[i][j] == "#":
que.append((i, j))
dist[i][j] = 0
while que:
y, x = que.popleft()
for dy, dx in zip(di, dj):
ny, nx = y + dy, x + dx
if ny < 0 or ny >= h or nx < 0 or nx >= w:
continue
if dist[ny][nx] != -1:
continue
dist[ny][nx] = dist[y][x] + 1
que.append((ny, nx))
ans = 0
for i in dist:
ans = max(ans, max(i))
print(ans)
| from collections import deque
h, w = list(map(int, input().split()))
A = [eval(input()) for _ in range(h)]
dist = [[-1] * w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
for j in range(w):
if A[i][j] == "#":
que.append((i, j))
dist[i][j] = 0
ans = 0
while que:
y, x = que.popleft()
for dy, dx in zip(di, dj):
ny, nx = y + dy, x + dx
if ny < 0 or ny >= h or nx < 0 or nx >= w:
continue
if dist[ny][nx] != -1:
continue
dist[ny][nx] = dist[y][x] + 1
ans = max(ans, dist[ny][nx])
que.append((ny, nx))
print(ans)
| false | 3.846154 | [
"+ans = 0",
"+ ans = max(ans, dist[ny][nx])",
"-ans = 0",
"-for i in dist:",
"- ans = max(ans, max(i))"
] | false | 0.045845 | 0.046534 | 0.985189 | [
"s107596100",
"s331648272"
] |
u723711163 | p02610 | python | s734047713 | s242118016 | 673 | 597 | 102,788 | 103,964 | Accepted | Accepted | 11.29 | import heapq
T = int(eval(input()))
for _ in range(T):
N = int(eval(input()))
res = 0
Ls,Rs = [[] for _ in range(N)], [[] for _ in range(N)]
for _ in range(N):
K,L,R = list(map(int,input().split()))
m = min(L,R)
res += m
L -= m
R -= m
if L>0:
Ls[K-1].append(L)
else:
if K != N:
Rs[K].append(R)
pq1 = []
for i in reversed(list(range(N))):
for l in Ls[i]:
heapq.heappush(pq1, -l)
if pq1:
p = -heapq.heappop(pq1)
res += p
pq2 = []
for i in range(N):
for r in Rs[i]:
heapq.heappush(pq2, -r)
if pq2:
p = -heapq.heappop(pq2)
res += p
print(res) | import heapq
def solve():
N = int(eval(input()))
ans = 0
left,right = [ [] for i in range(N) ],[ [] for i in range(N) ]
for _ in range(N):
k,l,r = list(map(int,input().split()))
ans += min(l,r)
if l>r:
left[k-1].append(l-r)
else:
if k >= N: continue
right[k].append(r-l)
# left
pq = []
for i in range(N-1,-1,-1):
for l in left[i]:
heapq.heappush(pq,-l)
if pq:
ans += -heapq.heappop(pq)
# right
pq = []
for i in range(N):
for r in right[i]:
heapq.heappush(pq,-r)
if pq:
ans += -heapq.heappop(pq)
print(ans)
for i in range(int(eval(input()))):
solve() | 38 | 34 | 675 | 666 | import heapq
T = int(eval(input()))
for _ in range(T):
N = int(eval(input()))
res = 0
Ls, Rs = [[] for _ in range(N)], [[] for _ in range(N)]
for _ in range(N):
K, L, R = list(map(int, input().split()))
m = min(L, R)
res += m
L -= m
R -= m
if L > 0:
Ls[K - 1].append(L)
else:
if K != N:
Rs[K].append(R)
pq1 = []
for i in reversed(list(range(N))):
for l in Ls[i]:
heapq.heappush(pq1, -l)
if pq1:
p = -heapq.heappop(pq1)
res += p
pq2 = []
for i in range(N):
for r in Rs[i]:
heapq.heappush(pq2, -r)
if pq2:
p = -heapq.heappop(pq2)
res += p
print(res)
| import heapq
def solve():
N = int(eval(input()))
ans = 0
left, right = [[] for i in range(N)], [[] for i in range(N)]
for _ in range(N):
k, l, r = list(map(int, input().split()))
ans += min(l, r)
if l > r:
left[k - 1].append(l - r)
else:
if k >= N:
continue
right[k].append(r - l)
# left
pq = []
for i in range(N - 1, -1, -1):
for l in left[i]:
heapq.heappush(pq, -l)
if pq:
ans += -heapq.heappop(pq)
# right
pq = []
for i in range(N):
for r in right[i]:
heapq.heappush(pq, -r)
if pq:
ans += -heapq.heappop(pq)
print(ans)
for i in range(int(eval(input()))):
solve()
| false | 10.526316 | [
"-T = int(eval(input()))",
"-for _ in range(T):",
"+",
"+def solve():",
"- res = 0",
"- Ls, Rs = [[] for _ in range(N)], [[] for _ in range(N)]",
"+ ans = 0",
"+ left, right = [[] for i in range(N)], [[] for i in range(N)]",
"- K, L, R = list(map(int, input().split()))",
"- ... | false | 0.034554 | 0.037355 | 0.925024 | [
"s734047713",
"s242118016"
] |
u596536048 | p02712 | python | s458382051 | s196109339 | 204 | 121 | 8,996 | 29,920 | Accepted | Accepted | 40.69 | N = int(eval(input()))
s = 0
i = 1
while i <= N:
if i % 3 != 0 and i % 5 != 0:
s += i
i += 1
print(s) | N = int(eval(input()))
l = [i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0]
s = sum(l)
print(s) | 8 | 4 | 118 | 101 | N = int(eval(input()))
s = 0
i = 1
while i <= N:
if i % 3 != 0 and i % 5 != 0:
s += i
i += 1
print(s)
| N = int(eval(input()))
l = [i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0]
s = sum(l)
print(s)
| false | 50 | [
"-s = 0",
"-i = 1",
"-while i <= N:",
"- if i % 3 != 0 and i % 5 != 0:",
"- s += i",
"- i += 1",
"+l = [i for i in range(1, N + 1) if i % 3 != 0 and i % 5 != 0]",
"+s = sum(l)"
] | false | 0.134665 | 0.081416 | 1.654044 | [
"s458382051",
"s196109339"
] |
u936985471 | p03044 | python | s266974726 | s571320926 | 850 | 748 | 41,892 | 45,396 | Accepted | Accepted | 12 | N=int(eval(input()))
E=[[] for i in range(N)]
for i in range(N-1):
a,b,w=list(map(int,input().split()))
a,b,w=a-1,b-1,w%2
E[a].append([b,w])
E[b].append([a,w])
stack=[]
C=[None]*N
# 番号,色,親
stack.append([0,0,-1])
while stack:
node=stack.pop()
v=node[0]
color=node[1]
parent=node[2]
C[v]=color
children=E[v]
for child in children:
child_v=child[0]
child_w=child[1]
if child_v==parent:
continue
child_color=abs(child_w-color)
stack.append([child_v,child_color,v])
for ans in C:
print(ans) | import sys
readline = sys.stdin.readline
# スタートを0で塗り、行先が奇数であれば違う色で塗る、を繰り返せばよい
N = int(readline())
G = [[] for i in range(N)]
for i in range(N - 1):
u,v,w = list(map(int,readline().split()))
G[u - 1].append([v - 1, w])
G[v - 1].append([u - 1, w])
ans = [-1] * N
stack = []
# 頂点, 色
stack.append([0,0])
while stack:
v,color = stack.pop()
if ans[v] != -1:
continue
ans[v] = color
for child in G[v]:
col = color
if child[1] % 2 == 1:
col ^= 1
stack.append([child[0], col])
for a in ans:
print(a) | 29 | 30 | 555 | 556 | N = int(eval(input()))
E = [[] for i in range(N)]
for i in range(N - 1):
a, b, w = list(map(int, input().split()))
a, b, w = a - 1, b - 1, w % 2
E[a].append([b, w])
E[b].append([a, w])
stack = []
C = [None] * N
# 番号,色,親
stack.append([0, 0, -1])
while stack:
node = stack.pop()
v = node[0]
color = node[1]
parent = node[2]
C[v] = color
children = E[v]
for child in children:
child_v = child[0]
child_w = child[1]
if child_v == parent:
continue
child_color = abs(child_w - color)
stack.append([child_v, child_color, v])
for ans in C:
print(ans)
| import sys
readline = sys.stdin.readline
# スタートを0で塗り、行先が奇数であれば違う色で塗る、を繰り返せばよい
N = int(readline())
G = [[] for i in range(N)]
for i in range(N - 1):
u, v, w = list(map(int, readline().split()))
G[u - 1].append([v - 1, w])
G[v - 1].append([u - 1, w])
ans = [-1] * N
stack = []
# 頂点, 色
stack.append([0, 0])
while stack:
v, color = stack.pop()
if ans[v] != -1:
continue
ans[v] = color
for child in G[v]:
col = color
if child[1] % 2 == 1:
col ^= 1
stack.append([child[0], col])
for a in ans:
print(a)
| false | 3.333333 | [
"-N = int(eval(input()))",
"-E = [[] for i in range(N)]",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+# スタートを0で塗り、行先が奇数であれば違う色で塗る、を繰り返せばよい",
"+N = int(readline())",
"+G = [[] for i in range(N)]",
"- a, b, w = list(map(int, input().split()))",
"- a, b, w = a - 1, b - 1, w % 2",
... | false | 0.045991 | 0.168455 | 0.273016 | [
"s266974726",
"s571320926"
] |
u622015302 | p00001 | python | s775917801 | s997254201 | 20 | 10 | 4,208 | 4,208 | Accepted | Accepted | 50 | firstMountainHeight = 0
secondMountainHeight = 0
thirdMountainHeight = 0
while 1:
try :
i = int(input())
if firstMountainHeight<i:
thirdMountainHeight=secondMountainHeight
secondMountainHeight=firstMountainHeight
firstMountainHeight=i
elif secondMountainHeight<i:
thirdMountainHeight=secondMountainHeight
secondMountainHeight=i
elif thirdMountainHeight<i:
thirdMountainHeight=i
except:
print("%d" % (firstMountainHeight))
print("%d" % (secondMountainHeight))
print("%d" % (thirdMountainHeight))
break | one = 0
two = 0
three = 0
while 1:
try :
i = int(input())
if one<i:
three=two
two=one
one=i
elif two<i:
three=two
two=i
elif three<i:
three=i
except:
print("%d" % (one))
print("%d" % (two))
print("%d" % (three))
break | 20 | 20 | 575 | 292 | firstMountainHeight = 0
secondMountainHeight = 0
thirdMountainHeight = 0
while 1:
try:
i = int(input())
if firstMountainHeight < i:
thirdMountainHeight = secondMountainHeight
secondMountainHeight = firstMountainHeight
firstMountainHeight = i
elif secondMountainHeight < i:
thirdMountainHeight = secondMountainHeight
secondMountainHeight = i
elif thirdMountainHeight < i:
thirdMountainHeight = i
except:
print("%d" % (firstMountainHeight))
print("%d" % (secondMountainHeight))
print("%d" % (thirdMountainHeight))
break
| one = 0
two = 0
three = 0
while 1:
try:
i = int(input())
if one < i:
three = two
two = one
one = i
elif two < i:
three = two
two = i
elif three < i:
three = i
except:
print("%d" % (one))
print("%d" % (two))
print("%d" % (three))
break
| false | 0 | [
"-firstMountainHeight = 0",
"-secondMountainHeight = 0",
"-thirdMountainHeight = 0",
"+one = 0",
"+two = 0",
"+three = 0",
"- if firstMountainHeight < i:",
"- thirdMountainHeight = secondMountainHeight",
"- secondMountainHeight = firstMountainHeight",
"- fir... | false | 0.131832 | 0.103522 | 1.273476 | [
"s775917801",
"s997254201"
] |
u754022296 | p03557 | python | s449944021 | s374380436 | 356 | 320 | 25,544 | 23,092 | Accepted | Accepted | 10.11 | import bisect
from itertools import accumulate
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
b_to_c = [0]*n
for i in range(n):
b_to_c[i] = n - bisect.bisect_right(C, B[i])
Q = list(accumulate(b_to_c[::-1]))[::-1]
for i in A:
t = bisect.bisect_right(B, i)
if t < n:
ans += Q[t]
print(ans) | import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in B:
ans += bisect.bisect_left(A, i) * (n - bisect.bisect_right(C, i))
print(ans) | 17 | 9 | 427 | 269 | import bisect
from itertools import accumulate
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
b_to_c = [0] * n
for i in range(n):
b_to_c[i] = n - bisect.bisect_right(C, B[i])
Q = list(accumulate(b_to_c[::-1]))[::-1]
for i in A:
t = bisect.bisect_right(B, i)
if t < n:
ans += Q[t]
print(ans)
| import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in B:
ans += bisect.bisect_left(A, i) * (n - bisect.bisect_right(C, i))
print(ans)
| false | 47.058824 | [
"-from itertools import accumulate",
"-b_to_c = [0] * n",
"-for i in range(n):",
"- b_to_c[i] = n - bisect.bisect_right(C, B[i])",
"-Q = list(accumulate(b_to_c[::-1]))[::-1]",
"-for i in A:",
"- t = bisect.bisect_right(B, i)",
"- if t < n:",
"- ans += Q[t]",
"+for i in B:",
"+ ... | false | 0.04695 | 0.04729 | 0.992806 | [
"s449944021",
"s374380436"
] |
u548684908 | p02984 | python | s924240820 | s729664932 | 218 | 129 | 14,092 | 20,500 | Accepted | Accepted | 40.83 | N=int(input())
a = list(map(int,input().split()))
S = sum(a)
S1 = 0
for i in range(N):
if i%2 == 1:
S1 += a[i]
b = [0 for i in range(N)]
b[0] = S - 2*S1
print(b[0],end=' ')
for j in range(1,N):
b[j] = 2*a[j-1] - b[j-1]
print(b[j],end=' ')
| N = int(input())
A = list(map(int,input().split()))
All = sum(A)
lim = len(A)//2
Exc1 = sum([A[2*i+1] for i in range(lim)])
one = All - Exc1*2
ans = [one]
for i in range(1,N):
print('{}'.format(ans[-1]),end=' ')
ans.append(A[i-1]*2 - ans[-1])
print('{}'.format(ans[-1]))
| 13 | 14 | 270 | 295 | N = int(input())
a = list(map(int, input().split()))
S = sum(a)
S1 = 0
for i in range(N):
if i % 2 == 1:
S1 += a[i]
b = [0 for i in range(N)]
b[0] = S - 2 * S1
print(b[0], end=" ")
for j in range(1, N):
b[j] = 2 * a[j - 1] - b[j - 1]
print(b[j], end=" ")
| N = int(input())
A = list(map(int, input().split()))
All = sum(A)
lim = len(A) // 2
Exc1 = sum([A[2 * i + 1] for i in range(lim)])
one = All - Exc1 * 2
ans = [one]
for i in range(1, N):
print("{}".format(ans[-1]), end=" ")
ans.append(A[i - 1] * 2 - ans[-1])
print("{}".format(ans[-1]))
| false | 7.142857 | [
"-a = list(map(int, input().split()))",
"-S = sum(a)",
"-S1 = 0",
"-for i in range(N):",
"- if i % 2 == 1:",
"- S1 += a[i]",
"-b = [0 for i in range(N)]",
"-b[0] = S - 2 * S1",
"-print(b[0], end=\" \")",
"-for j in range(1, N):",
"- b[j] = 2 * a[j - 1] - b[j - 1]",
"- print(b[j... | false | 0.131136 | 0.066153 | 1.982314 | [
"s924240820",
"s729664932"
] |
u493520238 | p02588 | python | s432440646 | s749797363 | 1,630 | 450 | 88,416 | 88,312 | Accepted | Accepted | 72.39 | n = int(eval(input()))
al = []
for _ in range(n):
s = eval(input())
if '.' not in s:
a = int(s)*(10**9)
al.append(a)
else:
syousu = s.split('.')[1]
rem0 = 9 - len(syousu)
a = int(s.replace('.',''))*(10**rem0)
al.append(a)
ans = 0
two_five_cnts = {}
for i in range(19):
for j in range(19):
two_five_cnts[(i,j)] = 0
for a in al:
num = a
two = 0
five = 0
for i in range(18):
if num%2 == 0:
num = num//2
two += 1
else:
break
for i in range(18):
if num%5 == 0:
num = num//5
five += 1
else:
break
for i in range(18-two,19):
for j in range(18-five,19):
ans += two_five_cnts[(i,j)]
two_five_cnts[(two,five)] += 1
print(ans) | n = int(eval(input()))
al = []
for _ in range(n):
s = eval(input())
if not '.' in s:
al.append(int(s)*(10**9))
else:
syosu_keta = len(s.split('.')[1])
rem = 9 - syosu_keta
a = int(s.replace('.',''))
a *= (10**rem)
al.append(a)
al25 = [ [0]*19 for _ in range(19) ]
ans = 0
for a in al:
cnt2 = 0
cnt5 = 0
curr_a = a
for i in range(18):
if curr_a%2 == 0:
cnt2 += 1
curr_a = curr_a//2
else:
break
curr_a = a
for i in range(18):
if curr_a%5 == 0:
cnt5 += 1
curr_a = curr_a//5
else:
break
for i in range(18-cnt2,19):
for j in range(18-cnt5,19):
ans += al25[i][j]
al25[cnt2][cnt5] += 1
print(ans) | 43 | 41 | 878 | 838 | n = int(eval(input()))
al = []
for _ in range(n):
s = eval(input())
if "." not in s:
a = int(s) * (10**9)
al.append(a)
else:
syousu = s.split(".")[1]
rem0 = 9 - len(syousu)
a = int(s.replace(".", "")) * (10**rem0)
al.append(a)
ans = 0
two_five_cnts = {}
for i in range(19):
for j in range(19):
two_five_cnts[(i, j)] = 0
for a in al:
num = a
two = 0
five = 0
for i in range(18):
if num % 2 == 0:
num = num // 2
two += 1
else:
break
for i in range(18):
if num % 5 == 0:
num = num // 5
five += 1
else:
break
for i in range(18 - two, 19):
for j in range(18 - five, 19):
ans += two_five_cnts[(i, j)]
two_five_cnts[(two, five)] += 1
print(ans)
| n = int(eval(input()))
al = []
for _ in range(n):
s = eval(input())
if not "." in s:
al.append(int(s) * (10**9))
else:
syosu_keta = len(s.split(".")[1])
rem = 9 - syosu_keta
a = int(s.replace(".", ""))
a *= 10**rem
al.append(a)
al25 = [[0] * 19 for _ in range(19)]
ans = 0
for a in al:
cnt2 = 0
cnt5 = 0
curr_a = a
for i in range(18):
if curr_a % 2 == 0:
cnt2 += 1
curr_a = curr_a // 2
else:
break
curr_a = a
for i in range(18):
if curr_a % 5 == 0:
cnt5 += 1
curr_a = curr_a // 5
else:
break
for i in range(18 - cnt2, 19):
for j in range(18 - cnt5, 19):
ans += al25[i][j]
al25[cnt2][cnt5] += 1
print(ans)
| false | 4.651163 | [
"- if \".\" not in s:",
"- a = int(s) * (10**9)",
"+ if not \".\" in s:",
"+ al.append(int(s) * (10**9))",
"+ else:",
"+ syosu_keta = len(s.split(\".\")[1])",
"+ rem = 9 - syosu_keta",
"+ a = int(s.replace(\".\", \"\"))",
"+ a *= 10**rem",
"- e... | false | 0.036664 | 0.035959 | 1.019611 | [
"s432440646",
"s749797363"
] |
u802963389 | p03361 | python | s087439977 | s241225773 | 276 | 21 | 20,120 | 3,064 | Accepted | Accepted | 92.39 | import numpy as np
h, w = list(map(int,input().split()))
hw = [eval(input()) for i in range(h)]
isPaintable = [[1]*w for _ in range(h)]
predList = [[0,1],[0,-1],[1,0],[-1,0]]
for i in range(h):
for j in range(w):
if hw[i][j] == "#":
for x, y in predList:
if i+y in range(h) and j+x in range(w):
# print(hw[i][j],hw[i+y][j+x],i,j,y,x)
if hw[i+y][j+x]=="#":
isPaintable[i][j] = 0
break
elif hw[i][j] == ".":
isPaintable[i][j] = 0
if np.array(isPaintable).sum() == 0:
print("Yes")
else:
print("No")
| h, w = list(map(int, input().split()))
S = [list(eval(input())) for _ in range(h)]
drc = [[0,1],[0,-1],[1,0],[-1,0]]
for i in range(h):
for j in range(w):
if S[i][j] == "#":
if all([S[i+y][j+x] == "." for x, y in drc if (0 <= j+x < w) and (0 <= i+y < h)]):
print("No")
exit()
print("Yes") | 25 | 10 | 590 | 313 | import numpy as np
h, w = list(map(int, input().split()))
hw = [eval(input()) for i in range(h)]
isPaintable = [[1] * w for _ in range(h)]
predList = [[0, 1], [0, -1], [1, 0], [-1, 0]]
for i in range(h):
for j in range(w):
if hw[i][j] == "#":
for x, y in predList:
if i + y in range(h) and j + x in range(w):
# print(hw[i][j],hw[i+y][j+x],i,j,y,x)
if hw[i + y][j + x] == "#":
isPaintable[i][j] = 0
break
elif hw[i][j] == ".":
isPaintable[i][j] = 0
if np.array(isPaintable).sum() == 0:
print("Yes")
else:
print("No")
| h, w = list(map(int, input().split()))
S = [list(eval(input())) for _ in range(h)]
drc = [[0, 1], [0, -1], [1, 0], [-1, 0]]
for i in range(h):
for j in range(w):
if S[i][j] == "#":
if all(
[
S[i + y][j + x] == "."
for x, y in drc
if (0 <= j + x < w) and (0 <= i + y < h)
]
):
print("No")
exit()
print("Yes")
| false | 60 | [
"-import numpy as np",
"-",
"-hw = [eval(input()) for i in range(h)]",
"-isPaintable = [[1] * w for _ in range(h)]",
"-predList = [[0, 1], [0, -1], [1, 0], [-1, 0]]",
"+S = [list(eval(input())) for _ in range(h)]",
"+drc = [[0, 1], [0, -1], [1, 0], [-1, 0]]",
"- if hw[i][j] == \"#\":",
"- ... | false | 0.169819 | 0.035203 | 4.823959 | [
"s087439977",
"s241225773"
] |
u019637926 | p03166 | python | s973829396 | s638893151 | 590 | 370 | 135,344 | 55,728 | Accepted | Accepted | 37.29 | import sys
sys.setrecursionlimit(10 ** 5 * 2)
input = sys.stdin.readline
N, M = list(map(int, input().split()))
Ps = [[] for _ in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
Ps[x - 1].append(y - 1)
mem = [-1] * N
def rec(n):
if mem[n] > -1:
return mem[n]
elif len(Ps[n]) == 0:
mem[n] = 0
return mem[n]
else:
mem[n] = max([rec(Ps[n][i]) for i in range(len(Ps[n]))]) + 1
return mem[n]
for i in range(N):
rec(i)
print((max(mem))) | import sys
sys.setrecursionlimit(10 ** 5 * 2)
input = sys.stdin.readline
N, M = list(map(int, input().split()))
Ps = [[] for _ in range(N)]
deg = [0] * N
for i in range(M):
x, y = list(map(int, input().split()))
Ps[x - 1].append(y - 1)
deg[y - 1] += 1
stack = []
for i in range(N):
if deg[i] == 0:
stack.append(i)
dp = [0] * N
while (stack):
n = stack.pop()
for p in Ps[n]:
dp[p] = max(dp[p], dp[n] + 1)
deg[p] -= 1
if deg[p] == 0:
stack.append(p)
print((max(dp)))
| 27 | 27 | 532 | 549 | import sys
sys.setrecursionlimit(10**5 * 2)
input = sys.stdin.readline
N, M = list(map(int, input().split()))
Ps = [[] for _ in range(N)]
for i in range(M):
x, y = list(map(int, input().split()))
Ps[x - 1].append(y - 1)
mem = [-1] * N
def rec(n):
if mem[n] > -1:
return mem[n]
elif len(Ps[n]) == 0:
mem[n] = 0
return mem[n]
else:
mem[n] = max([rec(Ps[n][i]) for i in range(len(Ps[n]))]) + 1
return mem[n]
for i in range(N):
rec(i)
print((max(mem)))
| import sys
sys.setrecursionlimit(10**5 * 2)
input = sys.stdin.readline
N, M = list(map(int, input().split()))
Ps = [[] for _ in range(N)]
deg = [0] * N
for i in range(M):
x, y = list(map(int, input().split()))
Ps[x - 1].append(y - 1)
deg[y - 1] += 1
stack = []
for i in range(N):
if deg[i] == 0:
stack.append(i)
dp = [0] * N
while stack:
n = stack.pop()
for p in Ps[n]:
dp[p] = max(dp[p], dp[n] + 1)
deg[p] -= 1
if deg[p] == 0:
stack.append(p)
print((max(dp)))
| false | 0 | [
"+deg = [0] * N",
"-mem = [-1] * N",
"-",
"-",
"-def rec(n):",
"- if mem[n] > -1:",
"- return mem[n]",
"- elif len(Ps[n]) == 0:",
"- mem[n] = 0",
"- return mem[n]",
"- else:",
"- mem[n] = max([rec(Ps[n][i]) for i in range(len(Ps[n]))]) + 1",
"- ret... | false | 0.036976 | 0.036086 | 1.024665 | [
"s973829396",
"s638893151"
] |
u785989355 | p02559 | python | s421634087 | s626853065 | 1,930 | 508 | 83,860 | 78,988 | Accepted | Accepted | 73.68 |
code = """
# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
cimport numpy as np
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
cdef cppclass fenwick_tree[T]:
fenwick_tree(int n)
void add(int p, T x)
T sum(int l, int r)
cdef class FenwickTree:
cdef fenwick_tree[long] *_thisptr
def __cinit__(self, np.ndarray[long, ndim=1] array):
cdef int N = array.size
self._thisptr = new fenwick_tree[long](N)
for i in range(N):
self.add(i, array[i])
cpdef void add(self, int p, long x):
self._thisptr.add(p, x)
cpdef long sum(self, int l, int r):
return self._thisptr.sum(l, r)
"""
import os, sys, getpass
if sys.argv[-1] == 'ONLINE_JUDGE':
code = code.replace("USERNAME", getpass.getuser())
open('atcoder.pyx','w').write(code)
os.system('cythonize -i -3 -b atcoder.pyx')
sys.exit(0)
from atcoder import FenwickTree
import numpy as np
N,Q = list(map(int,input().split()))
bit = FenwickTree(np.array(list(map(int,input().split())), dtype=np.int))
for i in range(Q):
a,b,c = list(map(int,input().split()))
if a==0:
bit.add(b,c)
else:
print((bit.sum(b,c))) |
code = """
# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libc.stdio cimport getchar, printf
from libcpp.vector cimport vector
cdef inline vector[int] readint(int n) nogil:
cdef int b, c
cdef vector[int] *v = new vector[int]()
for i in range(n):
c = 0
while 1:
b = getchar() - 48
if b < 0: break
c = c * 10 + b
v.push_back(c)
return v[0]
cpdef vector[int] readInt(int n):
return readint(n)
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
cdef cppclass fenwick_tree[T]:
fenwick_tree(int n)
void add(int p, T x)
T sum(int l, int r)
cdef class FenwickTree:
cdef fenwick_tree[long long] *_thisptr
def __cinit__(self, int n):
self._thisptr = new fenwick_tree[long long](n)
cpdef void add(self, int p, long long x):
self._thisptr.add(p, x)
cpdef long long sum(self, int l, int r):
return self._thisptr.sum(l, r)
"""
import os, sys, getpass
if sys.argv[-1] == 'ONLINE_JUDGE':
code.replace("USERNAME", getpass.getuser())
open('atcoder.pyx','w').write(code)
os.system('cythonize -i -3 -b atcoder.pyx')
sys.exit(0)
from atcoder import readInt, FenwickTree
n, q = readInt(2)
bit = FenwickTree(n)
*list(map(bit.add, list(range(n)), readInt(n))),
res = []
for i in range(q):
t, u, v = readInt(3)
if t: res.append(bit.sum(u, v))
else: bit.add(u, v)
print(('\n'.join(map(str, res)))) | 51 | 61 | 1,408 | 1,675 | code = """
# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
cimport numpy as np
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
cdef cppclass fenwick_tree[T]:
fenwick_tree(int n)
void add(int p, T x)
T sum(int l, int r)
cdef class FenwickTree:
cdef fenwick_tree[long] *_thisptr
def __cinit__(self, np.ndarray[long, ndim=1] array):
cdef int N = array.size
self._thisptr = new fenwick_tree[long](N)
for i in range(N):
self.add(i, array[i])
cpdef void add(self, int p, long x):
self._thisptr.add(p, x)
cpdef long sum(self, int l, int r):
return self._thisptr.sum(l, r)
"""
import os, sys, getpass
if sys.argv[-1] == "ONLINE_JUDGE":
code = code.replace("USERNAME", getpass.getuser())
open("atcoder.pyx", "w").write(code)
os.system("cythonize -i -3 -b atcoder.pyx")
sys.exit(0)
from atcoder import FenwickTree
import numpy as np
N, Q = list(map(int, input().split()))
bit = FenwickTree(np.array(list(map(int, input().split())), dtype=np.int))
for i in range(Q):
a, b, c = list(map(int, input().split()))
if a == 0:
bit.add(b, c)
else:
print((bit.sum(b, c)))
| code = """
# distutils: language=c++
# distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libc.stdio cimport getchar, printf
from libcpp.vector cimport vector
cdef inline vector[int] readint(int n) nogil:
cdef int b, c
cdef vector[int] *v = new vector[int]()
for i in range(n):
c = 0
while 1:
b = getchar() - 48
if b < 0: break
c = c * 10 + b
v.push_back(c)
return v[0]
cpdef vector[int] readInt(int n):
return readint(n)
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
cdef cppclass fenwick_tree[T]:
fenwick_tree(int n)
void add(int p, T x)
T sum(int l, int r)
cdef class FenwickTree:
cdef fenwick_tree[long long] *_thisptr
def __cinit__(self, int n):
self._thisptr = new fenwick_tree[long long](n)
cpdef void add(self, int p, long long x):
self._thisptr.add(p, x)
cpdef long long sum(self, int l, int r):
return self._thisptr.sum(l, r)
"""
import os, sys, getpass
if sys.argv[-1] == "ONLINE_JUDGE":
code.replace("USERNAME", getpass.getuser())
open("atcoder.pyx", "w").write(code)
os.system("cythonize -i -3 -b atcoder.pyx")
sys.exit(0)
from atcoder import readInt, FenwickTree
n, q = readInt(2)
bit = FenwickTree(n)
*list(map(bit.add, list(range(n)), readInt(n))),
res = []
for i in range(q):
t, u, v = readInt(3)
if t:
res.append(bit.sum(u, v))
else:
bit.add(u, v)
print(("\n".join(map(str, res))))
| false | 16.393443 | [
"-cimport numpy as np",
"+from libc.stdio cimport getchar, printf",
"+from libcpp.vector cimport vector",
"+cdef inline vector[int] readint(int n) nogil:",
"+ cdef int b, c",
"+ cdef vector[int] *v = new vector[int]()",
"+ for i in range(n):",
"+ c = 0",
"+ while 1:",
"+ ... | false | 0.038225 | 0.0397 | 0.962864 | [
"s421634087",
"s626853065"
] |
u227082700 | p03291 | python | s031513280 | s701736045 | 483 | 426 | 27,604 | 27,556 | Accepted | Accepted | 11.8 | s=eval(input())
n=len(s)
dp=[4*[0]for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
for j in range(4):
dp[i][j]+=dp[i-1][j]*((s[i-1]=="?")*2+1)
if s[i-1] in "A?":dp[i][1]+=dp[i-1][0]
if s[i-1] in "B?":dp[i][2]+=dp[i-1][1]
if s[i-1] in "C?":dp[i][3]+=dp[i-1][2]
for j in range(4):dp[i][j]%=10**9+7
#for i in range(n+1):print(dp[i],(" "+s)[i])
print((dp[-1][-1])) | s=eval(input())
l=len(s)
dp=[4*[0]for _ in range(l+1)]
dp[0][0]=1
for i in range(1,l+1):
si=s[i-1]
for j in range(4):dp[i][j]=dp[i-1][j]*((si=="?")*2+1)
if si=="A":dp[i][1]+=dp[i-1][0]
if si=="B":dp[i][2]+=dp[i-1][1]
if si=="C":dp[i][3]+=dp[i-1][2]
if si=="?":
dp[i][1]+=dp[i-1][0]
dp[i][2]+=dp[i-1][1]
dp[i][3]+=dp[i-1][2]
for j in range(4):dp[i][j]%=10**9+7
print((dp[-1][-1])) | 13 | 16 | 384 | 412 | s = eval(input())
n = len(s)
dp = [4 * [0] for i in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
for j in range(4):
dp[i][j] += dp[i - 1][j] * ((s[i - 1] == "?") * 2 + 1)
if s[i - 1] in "A?":
dp[i][1] += dp[i - 1][0]
if s[i - 1] in "B?":
dp[i][2] += dp[i - 1][1]
if s[i - 1] in "C?":
dp[i][3] += dp[i - 1][2]
for j in range(4):
dp[i][j] %= 10**9 + 7
# for i in range(n+1):print(dp[i],(" "+s)[i])
print((dp[-1][-1]))
| s = eval(input())
l = len(s)
dp = [4 * [0] for _ in range(l + 1)]
dp[0][0] = 1
for i in range(1, l + 1):
si = s[i - 1]
for j in range(4):
dp[i][j] = dp[i - 1][j] * ((si == "?") * 2 + 1)
if si == "A":
dp[i][1] += dp[i - 1][0]
if si == "B":
dp[i][2] += dp[i - 1][1]
if si == "C":
dp[i][3] += dp[i - 1][2]
if si == "?":
dp[i][1] += dp[i - 1][0]
dp[i][2] += dp[i - 1][1]
dp[i][3] += dp[i - 1][2]
for j in range(4):
dp[i][j] %= 10**9 + 7
print((dp[-1][-1]))
| false | 18.75 | [
"-n = len(s)",
"-dp = [4 * [0] for i in range(n + 1)]",
"+l = len(s)",
"+dp = [4 * [0] for _ in range(l + 1)]",
"-for i in range(1, n + 1):",
"+for i in range(1, l + 1):",
"+ si = s[i - 1]",
"- dp[i][j] += dp[i - 1][j] * ((s[i - 1] == \"?\") * 2 + 1)",
"- if s[i - 1] in \"A?\":",
"+ ... | false | 0.0362 | 0.041515 | 0.871967 | [
"s031513280",
"s701736045"
] |
u798129018 | p03161 | python | s407778103 | s715241736 | 398 | 361 | 52,448 | 57,200 | Accepted | Accepted | 9.3 | N,K = list(map(int,input().split()))
h = [0]+list(map(int,input().split()))
dp = [10**10]*(N+1)
dp[1] = 0
for i in range(1,N+1):
for j in range(1,K+1):
if i-j>0:
dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i])
else:
break
print((dp[N])) | from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
from functools import reduce
n,k = list(map(int,input().split()))
h = [inf]*(n+k)
high = list(map(int,input().split()))
for i in range(n):
h[i] = high[i]
dp = [inf]*(n+k)
dp[0] = 0
for i in range(n):
for j in range(1,k+1):
dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
print((dp[n-1]))
| 11 | 24 | 278 | 627 | N, K = list(map(int, input().split()))
h = [0] + list(map(int, input().split()))
dp = [10**10] * (N + 1)
dp[1] = 0
for i in range(1, N + 1):
for j in range(1, K + 1):
if i - j > 0:
dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])
else:
break
print((dp[N]))
| from itertools import accumulate
from math import *
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import *
from collections import Counter
from itertools import *
from bisect import bisect_left, bisect_right
from copy import deepcopy
inf = 10**18
from functools import reduce
n, k = list(map(int, input().split()))
h = [inf] * (n + k)
high = list(map(int, input().split()))
for i in range(n):
h[i] = high[i]
dp = [inf] * (n + k)
dp[0] = 0
for i in range(n):
for j in range(1, k + 1):
dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
print((dp[n - 1]))
| false | 54.166667 | [
"-N, K = list(map(int, input().split()))",
"-h = [0] + list(map(int, input().split()))",
"-dp = [10**10] * (N + 1)",
"-dp[1] = 0",
"-for i in range(1, N + 1):",
"- for j in range(1, K + 1):",
"- if i - j > 0:",
"- dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])",
"- ... | false | 0.048806 | 0.048367 | 1.009074 | [
"s407778103",
"s715241736"
] |
u408071652 | p02718 | python | s022787003 | s304123129 | 64 | 22 | 61,812 | 9,140 | Accepted | Accepted | 65.62 | n, m = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = 0
vote = sum(a)
for i in a:
if i >= vote/4/m:
ans +=1
if ans >=m:
print("Yes")
else:
print("No") | N, M = list(map(int,input().split()))
A = list(map(int, input().split()))
eligible = sum(A)/4/M
if len(list([x for x in A if x >=eligible]))>=M :
print("Yes")
else:
print("No")
| 11 | 9 | 199 | 192 | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
vote = sum(a)
for i in a:
if i >= vote / 4 / m:
ans += 1
if ans >= m:
print("Yes")
else:
print("No")
| N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
eligible = sum(A) / 4 / M
if len(list([x for x in A if x >= eligible])) >= M:
print("Yes")
else:
print("No")
| false | 18.181818 | [
"-n, m = list(map(int, input().split()))",
"-a = list(map(int, input().split()))",
"-ans = 0",
"-vote = sum(a)",
"-for i in a:",
"- if i >= vote / 4 / m:",
"- ans += 1",
"-if ans >= m:",
"+N, M = list(map(int, input().split()))",
"+A = list(map(int, input().split()))",
"+eligible = sum... | false | 0.039031 | 0.038361 | 1.017459 | [
"s022787003",
"s304123129"
] |
u375500286 | p03625 | python | s023612074 | s788723309 | 105 | 91 | 14,252 | 14,244 | Accepted | Accepted | 13.33 | n = int(eval(input()))
a = list(map(int,input().split()))
a.sort(reverse=True)
ans=[]
i=0
while i<n-1:
if a[i]==a[i+1]:
ans.append(a[i])
i+=1
i+=1
if len(ans) >= 2:
print((ans[0]*ans[1]))
else:
print((0)) | n = int(eval(input()))
a = list(map(int,input().split()))
a.sort(reverse=True)
flag=True
for i in range(0,n-4+1):
if a[i]==a[i+1]:
for j in range(i+2,n-1+1):
if a[j]==a[j+1]:
print((a[i]*a[j]))
flag=False
break
break
if flag:
print((0))
| 14 | 14 | 243 | 324 | n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = []
i = 0
while i < n - 1:
if a[i] == a[i + 1]:
ans.append(a[i])
i += 1
i += 1
if len(ans) >= 2:
print((ans[0] * ans[1]))
else:
print((0))
| n = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
flag = True
for i in range(0, n - 4 + 1):
if a[i] == a[i + 1]:
for j in range(i + 2, n - 1 + 1):
if a[j] == a[j + 1]:
print((a[i] * a[j]))
flag = False
break
break
if flag:
print((0))
| false | 0 | [
"-ans = []",
"-i = 0",
"-while i < n - 1:",
"+flag = True",
"+for i in range(0, n - 4 + 1):",
"- ans.append(a[i])",
"- i += 1",
"- i += 1",
"-if len(ans) >= 2:",
"- print((ans[0] * ans[1]))",
"-else:",
"+ for j in range(i + 2, n - 1 + 1):",
"+ if a[j] ==... | false | 0.047863 | 0.047447 | 1.008763 | [
"s023612074",
"s788723309"
] |
u745087332 | p03364 | python | s177127013 | s540590976 | 422 | 313 | 39,792 | 4,596 | Accepted | Accepted | 25.83 | # coding:utf-8
import sys
# from collections import Counter, defaultdict
INF = float('inf')
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())
def main():
n = II()
B = [SI() for _ in range(n)]
res = 0
for i in range(n):
is_good = 1
for h in range(n):
for w in range(h + 1, n):
if B[h][(w + i) % n] != B[w][(h + i) % n]:
is_good = 0
break
if not is_good:
break
if is_good:
res += n
return res
print((main()))
| # coding:utf-8
import sys
# from collections import Counter, defaultdict
INF = float('inf')
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())
def main():
n = II()
B = [tuple(SI()) for _ in range(n)]
BT = list(zip(*B))
res = 0
for a in range(n):
is_good = True
for i in range(n):
if B[i][n - a:] + B[i][:n - a] != BT[(i - a) % n]:
is_good = False
if is_good:
res += n
return res
print((main()))
| 38 | 34 | 820 | 738 | # coding:utf-8
import sys
# from collections import Counter, defaultdict
INF = float("inf")
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return eval(input())
def main():
n = II()
B = [SI() for _ in range(n)]
res = 0
for i in range(n):
is_good = 1
for h in range(n):
for w in range(h + 1, n):
if B[h][(w + i) % n] != B[w][(h + i) % n]:
is_good = 0
break
if not is_good:
break
if is_good:
res += n
return res
print((main()))
| # coding:utf-8
import sys
# from collections import Counter, defaultdict
INF = float("inf")
MOD = 10**9 + 7
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def II():
return int(sys.stdin.readline())
def SI():
return eval(input())
def main():
n = II()
B = [tuple(SI()) for _ in range(n)]
BT = list(zip(*B))
res = 0
for a in range(n):
is_good = True
for i in range(n):
if B[i][n - a :] + B[i][: n - a] != BT[(i - a) % n]:
is_good = False
if is_good:
res += n
return res
print((main()))
| false | 10.526316 | [
"- B = [SI() for _ in range(n)]",
"+ B = [tuple(SI()) for _ in range(n)]",
"+ BT = list(zip(*B))",
"- for i in range(n):",
"- is_good = 1",
"- for h in range(n):",
"- for w in range(h + 1, n):",
"- if B[h][(w + i) % n] != B[w][(h + i) % n]:",
"- ... | false | 0.043595 | 0.037966 | 1.148256 | [
"s177127013",
"s540590976"
] |
u762420987 | p03999 | python | s036105416 | s008964649 | 38 | 27 | 3,444 | 3,060 | Accepted | Accepted | 28.95 | S = list(eval(input()))
ls = len(S)
n = ls - 1
ans = 0
from copy import deepcopy
for i in range(2 ** n):
siki = deepcopy(S)
add = 1
for j in range(n):
if ((i >> j) & 1):
siki.insert(j+add, "+")
add += 1
# print("".join(siki))
ans += eval("".join(siki))
print(ans)
| S = eval(input())
n = len(S)-1
ans = 0
for i in range(2**n):
add = 1
expr = list(S)
for j in range(n):
if ((i >> j) & 1):
expr.insert(j+add, "+")
add += 1
ans += eval("".join(expr))
print(ans)
| 15 | 12 | 324 | 246 | S = list(eval(input()))
ls = len(S)
n = ls - 1
ans = 0
from copy import deepcopy
for i in range(2**n):
siki = deepcopy(S)
add = 1
for j in range(n):
if (i >> j) & 1:
siki.insert(j + add, "+")
add += 1
# print("".join(siki))
ans += eval("".join(siki))
print(ans)
| S = eval(input())
n = len(S) - 1
ans = 0
for i in range(2**n):
add = 1
expr = list(S)
for j in range(n):
if (i >> j) & 1:
expr.insert(j + add, "+")
add += 1
ans += eval("".join(expr))
print(ans)
| false | 20 | [
"-S = list(eval(input()))",
"-ls = len(S)",
"-n = ls - 1",
"+S = eval(input())",
"+n = len(S) - 1",
"-from copy import deepcopy",
"-",
"- siki = deepcopy(S)",
"+ expr = list(S)",
"- siki.insert(j + add, \"+\")",
"+ expr.insert(j + add, \"+\")",
"- # print(\"\".jo... | false | 0.060949 | 0.046944 | 1.298323 | [
"s036105416",
"s008964649"
] |
u853728588 | p02784 | python | s449684362 | s788006406 | 61 | 54 | 20,560 | 20,588 | Accepted | Accepted | 11.48 | h, n = list(map(int,input().split()))
a = list(map(int,input().split()))
total = 0
for i in range(n):
total += a[i]
if total >= h:
print("Yes")
else:
print("No") | h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
aa = sum(a)
if aa >= h:
print("Yes")
else:
print("No") | 9 | 9 | 169 | 137 | h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
total = 0
for i in range(n):
total += a[i]
if total >= h:
print("Yes")
else:
print("No")
| h, n = list(map(int, input().split()))
a = list(map(int, input().split()))
aa = sum(a)
if aa >= h:
print("Yes")
else:
print("No")
| false | 0 | [
"-total = 0",
"-for i in range(n):",
"- total += a[i]",
"-if total >= h:",
"+aa = sum(a)",
"+if aa >= h:"
] | false | 0.03505 | 0.062157 | 0.563901 | [
"s449684362",
"s788006406"
] |
u620480037 | p03369 | python | s978636411 | s191702531 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | toppingu = eval(input())
toppingu = toppingu.count("o")
print((700+int(100 * int(toppingu)))) | S=eval(input())
T=S.count("o")
print((700+T*100))
| 4 | 3 | 89 | 44 | toppingu = eval(input())
toppingu = toppingu.count("o")
print((700 + int(100 * int(toppingu))))
| S = eval(input())
T = S.count("o")
print((700 + T * 100))
| false | 25 | [
"-toppingu = eval(input())",
"-toppingu = toppingu.count(\"o\")",
"-print((700 + int(100 * int(toppingu))))",
"+S = eval(input())",
"+T = S.count(\"o\")",
"+print((700 + T * 100))"
] | false | 0.045168 | 0.045347 | 0.996066 | [
"s978636411",
"s191702531"
] |
u197955752 | p02882 | python | s150826358 | s500682089 | 169 | 28 | 38,256 | 9,372 | Accepted | Accepted | 83.43 | import math
a, b, x = [int(a) for a in input().split()]
if x >= a * a * b / 2:
ans = math.degrees(math.atan2(2 * a**2 * b - 2 * x, a**3))
else:
ans = math.degrees(math.asin( (a * b**2) / math.sqrt( 4 * x**2 + a**2 * b**4) ))
print(ans) | # 20-08-12 再トライ
from math import degrees, atan2
a, b, x = [int(x) for x in input().split()]
if x <= a ** 2 * b / 2:
ans = degrees(atan2(a * b ** 2, 2 * x))
else:
ans = degrees(atan2(2 * a ** 2 * b - 2 * x, a ** 3))
print(ans) | 10 | 10 | 255 | 244 | import math
a, b, x = [int(a) for a in input().split()]
if x >= a * a * b / 2:
ans = math.degrees(math.atan2(2 * a**2 * b - 2 * x, a**3))
else:
ans = math.degrees(
math.asin((a * b**2) / math.sqrt(4 * x**2 + a**2 * b**4))
)
print(ans)
| # 20-08-12 再トライ
from math import degrees, atan2
a, b, x = [int(x) for x in input().split()]
if x <= a**2 * b / 2:
ans = degrees(atan2(a * b**2, 2 * x))
else:
ans = degrees(atan2(2 * a**2 * b - 2 * x, a**3))
print(ans)
| false | 0 | [
"-import math",
"+# 20-08-12 再トライ",
"+from math import degrees, atan2",
"-a, b, x = [int(a) for a in input().split()]",
"-if x >= a * a * b / 2:",
"- ans = math.degrees(math.atan2(2 * a**2 * b - 2 * x, a**3))",
"+a, b, x = [int(x) for x in input().split()]",
"+if x <= a**2 * b / 2:",
"+ ans = ... | false | 0.045131 | 0.037851 | 1.192329 | [
"s150826358",
"s500682089"
] |
u969850098 | p02714 | python | s648569921 | s555764121 | 453 | 408 | 68,252 | 68,096 | Accepted | Accepted | 9.93 | def main():
N = int(eval(input()))
S = eval(input())
ans = S.count('R') * S.count('G') * S.count('B')
colors = set(list('RGB'))
for i in range(N-2):
for j in range(i+1, i+1+(N-1-i)//2):
k = j + (j - i)
if set([S[i], S[j], S[k]]) == colors:
ans -= 1
print(ans)
if __name__ == "__main__":
main() | def main():
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, i+1+(N-1-i)//2):
k = j + (j - i)
if len(set([S[i], S[j], S[k]])) == 3:
ans -= 1
print(ans)
if __name__ == "__main__":
main() | 18 | 17 | 395 | 364 | def main():
N = int(eval(input()))
S = eval(input())
ans = S.count("R") * S.count("G") * S.count("B")
colors = set(list("RGB"))
for i in range(N - 2):
for j in range(i + 1, i + 1 + (N - 1 - i) // 2):
k = j + (j - i)
if set([S[i], S[j], S[k]]) == colors:
ans -= 1
print(ans)
if __name__ == "__main__":
main()
| def main():
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, i + 1 + (N - 1 - i) // 2):
k = j + (j - i)
if len(set([S[i], S[j], S[k]])) == 3:
ans -= 1
print(ans)
if __name__ == "__main__":
main()
| false | 5.555556 | [
"- colors = set(list(\"RGB\"))",
"- if set([S[i], S[j], S[k]]) == colors:",
"+ if len(set([S[i], S[j], S[k]])) == 3:"
] | false | 0.045695 | 0.043787 | 1.043589 | [
"s648569921",
"s555764121"
] |
u067983636 | p02586 | python | s184988712 | s155483520 | 2,991 | 1,685 | 694,076 | 426,560 | Accepted | Accepted | 43.66 | import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7
def read_values(): return list(map(int, input().split()))
def read_index(): return [int(x) - 1 for x in input().split()]
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def main():
R, C, K = read_values()
V = [0] * (R * C)
for _ in range(K):
r, c, v = read_values()
r -= 1
c -= 1
V[r * C + c] = v
dp = [0 for _ in range(R * C * 4)]
for i in range(R * C):
r = i // C
c = i % C
if c + 1 < C:
# not take
for k in range(4):
dp[4 * (i + 1) + k] = max(dp[4 * (i + 1) + k], dp[4 * i + k])
# take
for k in range(3):
dp[4 * (i + 1) + k + 1] = max(dp[4 * (i + 1) + k + 1], dp[4 * i + k] + V[i])
# next r
if r + 1 < R:
for k in range(4):
dp[4 * (i + C)] = max(dp[4 * (i + C)], dp[4 * i + k] + (V[i] if k < 3 else 0))
res = 0
for k in range(4):
res = max(res, dp[4 * (R * C - 1) + k] + (V[-1] if k < 3 else 0))
print(res)
if __name__ == "__main__":
main()
| import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7
def read_values(): return list(map(int, input().split()))
def read_index(): return [int(x) - 1 for x in input().split()]
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
class V:
def __init__(self, f, v=None):
self.f = f
self.v = v
def __str__(self):
return str(self.v)
def ud(self, n):
if n is None:
return
if self.v is None:
self.v = n
return
self.v = self.f(self.v, n)
def main():
R, C, K = read_values()
V = [0] * (R * C)
for _ in range(K):
r, c, v = read_values()
r -= 1
c -= 1
V[r * C + c] = v
dp = [[0] * (R * C) for _ in range(4)]
for i in range(R * C):
r = i // C
c = i % C
if c + 1 < C:
# not take
for k in range(4):
dp[k][i + 1]= max(dp[k][i + 1], dp[k][i])
# take
for k in range(3):
dp[k + 1][i + 1] = max(dp[k + 1][i + 1], dp[k][i] + V[i])
# next r
if r + 1 < R:
for k in range(4):
dp[0][i + C] = max(dp[0][i + C], dp[k][i] + (V[i] if k < 3 else 0))
res = 0
for k in range(4):
res = max(res, dp[k][-1] + (V[-1] if k < 3 else 0))
print(res)
if __name__ == "__main__":
main()
| 53 | 71 | 1,373 | 1,637 | import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10**9 + 7
def read_values():
return list(map(int, input().split()))
def read_index():
return [int(x) - 1 for x in input().split()]
def read_list():
return list(read_values())
def read_lists(N):
return [read_list() for n in range(N)]
def main():
R, C, K = read_values()
V = [0] * (R * C)
for _ in range(K):
r, c, v = read_values()
r -= 1
c -= 1
V[r * C + c] = v
dp = [0 for _ in range(R * C * 4)]
for i in range(R * C):
r = i // C
c = i % C
if c + 1 < C:
# not take
for k in range(4):
dp[4 * (i + 1) + k] = max(dp[4 * (i + 1) + k], dp[4 * i + k])
# take
for k in range(3):
dp[4 * (i + 1) + k + 1] = max(
dp[4 * (i + 1) + k + 1], dp[4 * i + k] + V[i]
)
# next r
if r + 1 < R:
for k in range(4):
dp[4 * (i + C)] = max(
dp[4 * (i + C)], dp[4 * i + k] + (V[i] if k < 3 else 0)
)
res = 0
for k in range(4):
res = max(res, dp[4 * (R * C - 1) + k] + (V[-1] if k < 3 else 0))
print(res)
if __name__ == "__main__":
main()
| import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10**9 + 7
def read_values():
return list(map(int, input().split()))
def read_index():
return [int(x) - 1 for x in input().split()]
def read_list():
return list(read_values())
def read_lists(N):
return [read_list() for n in range(N)]
class V:
def __init__(self, f, v=None):
self.f = f
self.v = v
def __str__(self):
return str(self.v)
def ud(self, n):
if n is None:
return
if self.v is None:
self.v = n
return
self.v = self.f(self.v, n)
def main():
R, C, K = read_values()
V = [0] * (R * C)
for _ in range(K):
r, c, v = read_values()
r -= 1
c -= 1
V[r * C + c] = v
dp = [[0] * (R * C) for _ in range(4)]
for i in range(R * C):
r = i // C
c = i % C
if c + 1 < C:
# not take
for k in range(4):
dp[k][i + 1] = max(dp[k][i + 1], dp[k][i])
# take
for k in range(3):
dp[k + 1][i + 1] = max(dp[k + 1][i + 1], dp[k][i] + V[i])
# next r
if r + 1 < R:
for k in range(4):
dp[0][i + C] = max(dp[0][i + C], dp[k][i] + (V[i] if k < 3 else 0))
res = 0
for k in range(4):
res = max(res, dp[k][-1] + (V[-1] if k < 3 else 0))
print(res)
if __name__ == "__main__":
main()
| false | 25.352113 | [
"+class V:",
"+ def __init__(self, f, v=None):",
"+ self.f = f",
"+ self.v = v",
"+",
"+ def __str__(self):",
"+ return str(self.v)",
"+",
"+ def ud(self, n):",
"+ if n is None:",
"+ return",
"+ if self.v is None:",
"+ self.v ... | false | 0.042793 | 0.095595 | 0.447649 | [
"s184988712",
"s155483520"
] |
u413165887 | p03045 | python | s440878806 | s199855929 | 939 | 461 | 70,688 | 7,856 | Accepted | Accepted | 50.91 | n, m = list(map(int, input().split()))
tree = [-i for i in range(n+1)]
rank = [1 for _i in range(n+1)]
def search_root(num, tree=tree):
if tree[num] < 0:
return num
else:
tree[num] = search_root(tree[num])
return tree[num]
for _i in range(m):
x, y, z = list(map(int, input().split()))
x, y = sorted([search_root(x), search_root(y)])
if x==y:
continue
else:
if rank[x]<rank[y]:
rank[y] += 1
tree[x] = y
else:
rank[x] += 1
tree[y] = x
print((sum(1 for i in tree if i<0))) | n, m = list(map(int, input().split()))
tree = [-i for i in range(n+1)]
rank = [1 for _i in range(n+1)]
def search_root(num, tree=tree):
if tree[num] < 0:
return num
else:
tree[num] = search_root(tree[num])
return tree[num]
for _i in range(m):
x, y, z = list(map(int, input().split()))
x, y = [search_root(x), search_root(y)]
if x==y:
continue
else:
if rank[x]<rank[y]:
rank[y] += 1
tree[x] = y
else:
rank[x] += 1
tree[y] = x
print((sum(1 for i in tree if i<0))) | 23 | 23 | 598 | 590 | n, m = list(map(int, input().split()))
tree = [-i for i in range(n + 1)]
rank = [1 for _i in range(n + 1)]
def search_root(num, tree=tree):
if tree[num] < 0:
return num
else:
tree[num] = search_root(tree[num])
return tree[num]
for _i in range(m):
x, y, z = list(map(int, input().split()))
x, y = sorted([search_root(x), search_root(y)])
if x == y:
continue
else:
if rank[x] < rank[y]:
rank[y] += 1
tree[x] = y
else:
rank[x] += 1
tree[y] = x
print((sum(1 for i in tree if i < 0)))
| n, m = list(map(int, input().split()))
tree = [-i for i in range(n + 1)]
rank = [1 for _i in range(n + 1)]
def search_root(num, tree=tree):
if tree[num] < 0:
return num
else:
tree[num] = search_root(tree[num])
return tree[num]
for _i in range(m):
x, y, z = list(map(int, input().split()))
x, y = [search_root(x), search_root(y)]
if x == y:
continue
else:
if rank[x] < rank[y]:
rank[y] += 1
tree[x] = y
else:
rank[x] += 1
tree[y] = x
print((sum(1 for i in tree if i < 0)))
| false | 0 | [
"- x, y = sorted([search_root(x), search_root(y)])",
"+ x, y = [search_root(x), search_root(y)]"
] | false | 0.040931 | 0.041523 | 0.985738 | [
"s440878806",
"s199855929"
] |
u813098295 | p03575 | python | s679105276 | s779623240 | 26 | 18 | 3,064 | 3,064 | Accepted | Accepted | 30.77 | class uf_tree:
def __init__(self, n):
self.sizes = [0] * n
self.par = list(range(n))
def find(self, x):
if x == self.par[x]:
return x
self.par[x] = self.find(self.par[x])
return self.par[x]
def unite(self, x, y):
x, y = self.find(x), self.find(y)
if x == y:
return
if self.sizes[x] < self.sizes[y]:
x, y = y, x
self.par[y] = x
self.sizes[x] += self.sizes[y]
def same(self, x, y):
return self.find(x) == self.find(y)
N, M = list(map(int, input().split()))
a, b = [0] * M, [0] * M
for i in range(M):
a[i], b[i] = list(map(int, input().split()))
a[i] -= 1; b[i] -= 1
ans = 0
for i in range(M):
uf = uf_tree(N+1)
for j in range(M):
if i == j:
continue
uf.unite(a[j], b[j])
bridge = False
for i in range(N):
if not uf.same(0, i):
bridge = True
if bridge:
ans += 1
print(ans)
| #!/usr/bin/env python3
n, m = list(map(int, input().split()))
edges = []
graph = [ [] for _ in range(n) ]
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1; b -= 1;
edges.append( (a, b) )
graph[a].append(b)
graph[b].append(a)
def dfs(u, v):
is_visited = [ False ]*n
st = []
st.append(0)
while st:
cur = st.pop()
is_visited[cur] = True
for adj in graph[cur]:
if is_visited[adj]: continue
if cur == u and adj == v: continue
if cur == v and adj == u: continue
st.append(adj)
return all(is_visited)
ans = 0
for u, v in edges:
if not dfs(u, v):
ans += 1
print(ans)
| 46 | 37 | 1,035 | 732 | class uf_tree:
def __init__(self, n):
self.sizes = [0] * n
self.par = list(range(n))
def find(self, x):
if x == self.par[x]:
return x
self.par[x] = self.find(self.par[x])
return self.par[x]
def unite(self, x, y):
x, y = self.find(x), self.find(y)
if x == y:
return
if self.sizes[x] < self.sizes[y]:
x, y = y, x
self.par[y] = x
self.sizes[x] += self.sizes[y]
def same(self, x, y):
return self.find(x) == self.find(y)
N, M = list(map(int, input().split()))
a, b = [0] * M, [0] * M
for i in range(M):
a[i], b[i] = list(map(int, input().split()))
a[i] -= 1
b[i] -= 1
ans = 0
for i in range(M):
uf = uf_tree(N + 1)
for j in range(M):
if i == j:
continue
uf.unite(a[j], b[j])
bridge = False
for i in range(N):
if not uf.same(0, i):
bridge = True
if bridge:
ans += 1
print(ans)
| #!/usr/bin/env python3
n, m = list(map(int, input().split()))
edges = []
graph = [[] for _ in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edges.append((a, b))
graph[a].append(b)
graph[b].append(a)
def dfs(u, v):
is_visited = [False] * n
st = []
st.append(0)
while st:
cur = st.pop()
is_visited[cur] = True
for adj in graph[cur]:
if is_visited[adj]:
continue
if cur == u and adj == v:
continue
if cur == v and adj == u:
continue
st.append(adj)
return all(is_visited)
ans = 0
for u, v in edges:
if not dfs(u, v):
ans += 1
print(ans)
| false | 19.565217 | [
"-class uf_tree:",
"- def __init__(self, n):",
"- self.sizes = [0] * n",
"- self.par = list(range(n))",
"-",
"- def find(self, x):",
"- if x == self.par[x]:",
"- return x",
"- self.par[x] = self.find(self.par[x])",
"- return self.par[x]",
"-",
... | false | 0.032411 | 0.041707 | 0.777102 | [
"s679105276",
"s779623240"
] |
u804085889 | p03796 | python | s660925537 | s407333610 | 230 | 35 | 3,984 | 2,940 | Accepted | Accepted | 84.78 | import math
print((math.factorial(int(eval(input())))%(10**9+7))) | n=int(eval(input()))
ans=1
for i in range(2, n+1):
ans=(ans*i)%1000000007
print(ans) | 2 | 5 | 58 | 86 | import math
print((math.factorial(int(eval(input()))) % (10**9 + 7)))
| n = int(eval(input()))
ans = 1
for i in range(2, n + 1):
ans = (ans * i) % 1000000007
print(ans)
| false | 60 | [
"-import math",
"-",
"-print((math.factorial(int(eval(input()))) % (10**9 + 7)))",
"+n = int(eval(input()))",
"+ans = 1",
"+for i in range(2, n + 1):",
"+ ans = (ans * i) % 1000000007",
"+print(ans)"
] | false | 0.117092 | 0.047511 | 2.464498 | [
"s660925537",
"s407333610"
] |
u207241407 | p02844 | python | s671729115 | s433633417 | 186 | 31 | 9,544 | 9,204 | Accepted | Accepted | 83.33 | n = int(eval(input()))
s = list(map(int, eval(input())))
ans = []
for i in range(10):
if i in s:
a = s.index(i)
for j in range(10):
if j in s[a + 1 :]:
b = a + s[a + 1 :].index(j) + 1
for k in range(10):
if k in s[b + 1 :]:
ans.append(f"{i}{j}{k}")
print((len(ans))) | n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(10):
a = s.find(str(i))
if a == -1:
continue
for j in range(10):
b = s.find(str(j), a + 1)
if b == -1:
continue
for k in range(10):
c = s.find(str(k), b + 1)
if c == -1:
continue
ans += 1
print(ans) | 15 | 19 | 376 | 378 | n = int(eval(input()))
s = list(map(int, eval(input())))
ans = []
for i in range(10):
if i in s:
a = s.index(i)
for j in range(10):
if j in s[a + 1 :]:
b = a + s[a + 1 :].index(j) + 1
for k in range(10):
if k in s[b + 1 :]:
ans.append(f"{i}{j}{k}")
print((len(ans)))
| n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(10):
a = s.find(str(i))
if a == -1:
continue
for j in range(10):
b = s.find(str(j), a + 1)
if b == -1:
continue
for k in range(10):
c = s.find(str(k), b + 1)
if c == -1:
continue
ans += 1
print(ans)
| false | 21.052632 | [
"-s = list(map(int, eval(input())))",
"-ans = []",
"+s = eval(input())",
"+ans = 0",
"- if i in s:",
"- a = s.index(i)",
"- for j in range(10):",
"- if j in s[a + 1 :]:",
"- b = a + s[a + 1 :].index(j) + 1",
"- for k in range(10):",
"- ... | false | 0.060799 | 0.146689 | 0.414479 | [
"s671729115",
"s433633417"
] |
u876438858 | p02711 | python | s490710529 | s477256154 | 74 | 23 | 65,200 | 9,060 | Accepted | Accepted | 68.92 | import sys
from math import sqrt
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(MI())
def LIN(n: int):
return [I() for _ in range(n)]
inf = float("inf")
mod = 10 ** 9 + 7
def main():
s = eval(input())
for n in s:
if n == "7":
print("Yes")
exit()
print("No")
pass
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
import sys
input = sys.stdin.readline
def Y():
print("Yes")
def N():
print("No")
def S():
return input().rstrip()
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
if "7" in S():
Y()
else:
N()
| 40 | 30 | 570 | 308 | import sys
from math import sqrt
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(MI())
def LIN(n: int):
return [I() for _ in range(n)]
inf = float("inf")
mod = 10**9 + 7
def main():
s = eval(input())
for n in s:
if n == "7":
print("Yes")
exit()
print("No")
pass
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
import sys
input = sys.stdin.readline
def Y():
print("Yes")
def N():
print("No")
def S():
return input().rstrip()
def I():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
if "7" in S():
Y()
else:
N()
| false | 25 | [
"+#!/usr/bin/env python3",
"-from math import sqrt",
"-from collections import Counter, defaultdict, deque",
"-sys.setrecursionlimit(10**6)",
"+",
"+",
"+def Y():",
"+ print(\"Yes\")",
"+",
"+",
"+def N():",
"+ print(\"No\")",
"+",
"+",
"+def S():",
"+ return input().rstrip()"... | false | 0.096936 | 0.064403 | 1.505144 | [
"s490710529",
"s477256154"
] |
u049182844 | p03211 | python | s607652050 | s234887312 | 26 | 23 | 9,084 | 8,832 | Accepted | Accepted | 11.54 | def diff_number(runrun_num: int, master_num: int = 753) -> int:
return abs(753 - runrun_num)
def main():
s = eval(input())
min_diff = int(s[0:3])
for i in range(3, len(s) + 1):
runrun_num = int(s[(i - 3):i])
if diff_number(runrun_num) < diff_number(min_diff):
min_diff = runrun_num
print((diff_number(min_diff)))
if __name__ == '__main__':
main()
| def diff_number(runrun_num: int, master_num: int = 753) -> int:
return abs(master_num - runrun_num)
def main():
s = eval(input())
min_num = int(s[0:3])
for i in range(3, len(s) + 1):
runrun_num = int(s[(i - 3):i])
if diff_number(runrun_num) < diff_number(min_num):
min_num = runrun_num
print((diff_number(min_num)))
if __name__ == '__main__':
main()
| 17 | 17 | 420 | 415 | def diff_number(runrun_num: int, master_num: int = 753) -> int:
return abs(753 - runrun_num)
def main():
s = eval(input())
min_diff = int(s[0:3])
for i in range(3, len(s) + 1):
runrun_num = int(s[(i - 3) : i])
if diff_number(runrun_num) < diff_number(min_diff):
min_diff = runrun_num
print((diff_number(min_diff)))
if __name__ == "__main__":
main()
| def diff_number(runrun_num: int, master_num: int = 753) -> int:
return abs(master_num - runrun_num)
def main():
s = eval(input())
min_num = int(s[0:3])
for i in range(3, len(s) + 1):
runrun_num = int(s[(i - 3) : i])
if diff_number(runrun_num) < diff_number(min_num):
min_num = runrun_num
print((diff_number(min_num)))
if __name__ == "__main__":
main()
| false | 0 | [
"- return abs(753 - runrun_num)",
"+ return abs(master_num - runrun_num)",
"- min_diff = int(s[0:3])",
"+ min_num = int(s[0:3])",
"- if diff_number(runrun_num) < diff_number(min_diff):",
"- min_diff = runrun_num",
"- print((diff_number(min_diff)))",
"+ if diff_n... | false | 0.093653 | 0.066098 | 1.416879 | [
"s607652050",
"s234887312"
] |
u970197315 | p03062 | python | s074585403 | s572390211 | 74 | 65 | 15,020 | 14,412 | Accepted | Accepted | 12.16 | # ABC125 D - Flipping Signs
N = int(eval(input()))
A = list(map(int,input().split()))
cnt = 0
is_zero = False
for i in range(N):
if A[i] < 0:
cnt += 1
if A[i] == 0:
is_zero = True
A = [abs(a) for a in A]
if cnt%2 == 0 or is_zero == True:
print((sum(A)))
else:
print((sum(A)-2*min(A)))
| n=int(eval(input()))
a=list(map(int,input().split()))
c=0
is_zero=False
for aa in a:
if aa<0:c+=1
if aa==0:is_zero=True
a=[abs(aa) for aa in a]
if c%2==0 or is_zero==True:
print((sum(a)))
else:
print((sum(a)-2*min(a)))
| 19 | 14 | 333 | 240 | # ABC125 D - Flipping Signs
N = int(eval(input()))
A = list(map(int, input().split()))
cnt = 0
is_zero = False
for i in range(N):
if A[i] < 0:
cnt += 1
if A[i] == 0:
is_zero = True
A = [abs(a) for a in A]
if cnt % 2 == 0 or is_zero == True:
print((sum(A)))
else:
print((sum(A) - 2 * min(A)))
| n = int(eval(input()))
a = list(map(int, input().split()))
c = 0
is_zero = False
for aa in a:
if aa < 0:
c += 1
if aa == 0:
is_zero = True
a = [abs(aa) for aa in a]
if c % 2 == 0 or is_zero == True:
print((sum(a)))
else:
print((sum(a) - 2 * min(a)))
| false | 26.315789 | [
"-# ABC125 D - Flipping Signs",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-cnt = 0",
"+n = int(eval(input()))",
"+a = list(map(int, input().split()))",
"+c = 0",
"-for i in range(N):",
"- if A[i] < 0:",
"- cnt += 1",
"- if A[i] == 0:",
"+for aa in a:",
... | false | 0.040893 | 0.039323 | 1.039922 | [
"s074585403",
"s572390211"
] |
u352394527 | p00474 | python | s914794992 | s441282289 | 410 | 280 | 23,788 | 5,616 | Accepted | Accepted | 31.71 | def solve():
n,l = list(map(int,input().split()))
length = [int(eval(input())) for i in range(n)]
pare = [(length[i], i) for i in range(n)]
pare.sort(reverse=True)
dp = [0] * (n + 1)
for p in pare:
i = p[1]
if i == 0:
dp[i] = dp[i + 1] + (l - length[i])
else:
dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i])
print((max(dp)))
solve()
| n, l = list(map(int,input().split()))
ans = 0
pre = 0
up_acc = 0
down_acc = 0
for i in range(n):
length = int(eval(input()))
time = l - length
if length > pre:
up_acc += time
if down_acc > ans:
ans = down_acc
down_acc = time
else:
down_acc += time
if up_acc > ans:
ans = up_acc
up_acc = time
pre = length
else:
ans = max(ans, up_acc, down_acc)
print(ans)
| 15 | 22 | 378 | 412 | def solve():
n, l = list(map(int, input().split()))
length = [int(eval(input())) for i in range(n)]
pare = [(length[i], i) for i in range(n)]
pare.sort(reverse=True)
dp = [0] * (n + 1)
for p in pare:
i = p[1]
if i == 0:
dp[i] = dp[i + 1] + (l - length[i])
else:
dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i])
print((max(dp)))
solve()
| n, l = list(map(int, input().split()))
ans = 0
pre = 0
up_acc = 0
down_acc = 0
for i in range(n):
length = int(eval(input()))
time = l - length
if length > pre:
up_acc += time
if down_acc > ans:
ans = down_acc
down_acc = time
else:
down_acc += time
if up_acc > ans:
ans = up_acc
up_acc = time
pre = length
else:
ans = max(ans, up_acc, down_acc)
print(ans)
| false | 31.818182 | [
"-def solve():",
"- n, l = list(map(int, input().split()))",
"- length = [int(eval(input())) for i in range(n)]",
"- pare = [(length[i], i) for i in range(n)]",
"- pare.sort(reverse=True)",
"- dp = [0] * (n + 1)",
"- for p in pare:",
"- i = p[1]",
"- if i == 0:",
"-... | false | 0.037133 | 0.045597 | 0.81437 | [
"s914794992",
"s441282289"
] |
u597374218 | p03264 | python | s032007751 | s913446686 | 26 | 23 | 9,020 | 8,980 | Accepted | Accepted | 11.54 | K=int(eval(input()))
print((K**2//4)) | K=int(eval(input()))
print(((K//2)*((K+1)//2))) | 2 | 2 | 30 | 40 | K = int(eval(input()))
print((K**2 // 4))
| K = int(eval(input()))
print(((K // 2) * ((K + 1) // 2)))
| false | 0 | [
"-print((K**2 // 4))",
"+print(((K // 2) * ((K + 1) // 2)))"
] | false | 0.037867 | 0.041481 | 0.912876 | [
"s032007751",
"s913446686"
] |
u936985471 | p03287 | python | s031033772 | s590882932 | 118 | 106 | 14,368 | 14,168 | Accepted | Accepted | 10.17 | n,m=list(map(int,input().split()))
a=[0]+list(map(int,input().split()))
from collections import defaultdict
mods=defaultdict(int)
mods[0]=1
for i in range(1,len(a)):
a[i]=a[i-1]+a[i]%m
mods[a[i]%m]+=1
ans=0
for v in list(mods.values()):
if v>1:
ans+=v*(v-1)//2
print(ans) | # 頭に0を足して、累積和のmod Mを取る
# 各mod Mの個数に対して、個数C2を取って足し合わせる
import sys
readline = sys.stdin.readline
N,M = list(map(int,readline().split()))
A = [0] + list(map(int,readline().split()))
for i in range(1,len(A)):
A[i] = A[i - 1] + A[i]
A = list([x % M for x in A])
from collections import Counter
c = Counter(A)
ans = 0
for v in list(c.values()):
ans += (v * (v - 1)) // 2
print(ans) | 13 | 22 | 281 | 403 | n, m = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
from collections import defaultdict
mods = defaultdict(int)
mods[0] = 1
for i in range(1, len(a)):
a[i] = a[i - 1] + a[i] % m
mods[a[i] % m] += 1
ans = 0
for v in list(mods.values()):
if v > 1:
ans += v * (v - 1) // 2
print(ans)
| # 頭に0を足して、累積和のmod Mを取る
# 各mod Mの個数に対して、個数C2を取って足し合わせる
import sys
readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
A = [0] + list(map(int, readline().split()))
for i in range(1, len(A)):
A[i] = A[i - 1] + A[i]
A = list([x % M for x in A])
from collections import Counter
c = Counter(A)
ans = 0
for v in list(c.values()):
ans += (v * (v - 1)) // 2
print(ans)
| false | 40.909091 | [
"-n, m = list(map(int, input().split()))",
"-a = [0] + list(map(int, input().split()))",
"-from collections import defaultdict",
"+# 頭に0を足して、累積和のmod Mを取る",
"+# 各mod Mの個数に対して、個数C2を取って足し合わせる",
"+import sys",
"-mods = defaultdict(int)",
"-mods[0] = 1",
"-for i in range(1, len(a)):",
"- a[i] = a[i ... | false | 0.037884 | 0.042215 | 0.897419 | [
"s031033772",
"s590882932"
] |
u940395729 | p02276 | python | s931182118 | s855980945 | 100 | 80 | 16,388 | 16,388 | Accepted | Accepted | 20 | import sys
def partition(A, p, r):
# 要素の最後をxに代入
x = A[r]
i = p-1
ans = ""
for j in range(r):
if A[j] <= x:
i += 1
tmpA = A[i]
A[i] = A[j]
A[j] = tmpA
tmpB = A[i+1]
A[i+1] = A[r]
A[r] = tmpB
for j in range(n):
if j > 0:
ans += " "
if j == i+1:
ans += "["+str(A[j])+"]"
else:
ans += str(A[j])
print(ans)
n = int(eval(input()))
A = list(map(int, input().split()))
r = len(A)-1
p = 0
partition(A, p, r)
# for i in range(n):
# if A[i] == A[r]:
# sys.stdout.write('[' + str(A[i])+']' + ' ')
# else:
# sys.stdout.write(str(A[i]) + ' ')
# print()
| def partition(A, p, r):
x = A[r]
i = p-1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i+1], A[r] = A[r], A[i+1]
A[i+1] = "[{}]".format(A[i+1])
n = int(eval(input()))
A = list(map(int, input().split()))
partition(A, 0, n-1)
print((*A))
| 41 | 16 | 760 | 321 | import sys
def partition(A, p, r):
# 要素の最後をxに代入
x = A[r]
i = p - 1
ans = ""
for j in range(r):
if A[j] <= x:
i += 1
tmpA = A[i]
A[i] = A[j]
A[j] = tmpA
tmpB = A[i + 1]
A[i + 1] = A[r]
A[r] = tmpB
for j in range(n):
if j > 0:
ans += " "
if j == i + 1:
ans += "[" + str(A[j]) + "]"
else:
ans += str(A[j])
print(ans)
n = int(eval(input()))
A = list(map(int, input().split()))
r = len(A) - 1
p = 0
partition(A, p, r)
# for i in range(n):
# if A[i] == A[r]:
# sys.stdout.write('[' + str(A[i])+']' + ' ')
# else:
# sys.stdout.write(str(A[i]) + ' ')
# print()
| def partition(A, p, r):
x = A[r]
i = p - 1
for j in range(p, r):
if A[j] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
A[i + 1] = "[{}]".format(A[i + 1])
n = int(eval(input()))
A = list(map(int, input().split()))
partition(A, 0, n - 1)
print((*A))
| false | 60.97561 | [
"-import sys",
"-",
"-",
"- # 要素の最後をxに代入",
"- ans = \"\"",
"- for j in range(r):",
"+ for j in range(p, r):",
"- tmpA = A[i]",
"- A[i] = A[j]",
"- A[j] = tmpA",
"- tmpB = A[i + 1]",
"- A[i + 1] = A[r]",
"- A[r] = tmpB",
"- for j in r... | false | 0.045394 | 0.047411 | 0.957462 | [
"s931182118",
"s855980945"
] |
u600195339 | p03162 | python | s563174966 | s513354427 | 668 | 236 | 188,452 | 102,600 | Accepted | Accepted | 64.67 | import sys
sys.setrecursionlimit(10**6)
n = int(eval(input()))
a, b, c = [], [], []
# dp = [[None] * 3 for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
for i in range(n):
v1, v2, v3 = list(map(int, input().split()))
a.append(v1)
b.append(v2)
c.append(v3)
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
def solve(idx, ptn):
if dp[idx][ptn] > 0:
return dp[idx][ptn]
# Select A(0)
if ptn == 0:
if idx == 0:
return a[0]
a1 = solve(idx - 1, 1) + a[idx]
a2 = solve(idx - 1, 2) + a[idx]
dp[idx][0] = max(a1, a2)
return dp[idx][0]
# Select B(1)
if ptn == 1:
if idx == 0:
return b[0]
b1 = solve(idx - 1, 0) + b[idx]
b2 = solve(idx - 1, 2) + b[idx]
dp[idx][1] = max(b1, b2)
return dp[idx][1]
# Select C(2)
if ptn == 2:
if idx == 0:
return c[0]
c1 = solve(idx - 1, 0) + c[idx]
c2 = solve(idx - 1, 1) + c[idx]
dp[idx][2] = max(c1, c2)
return dp[idx][2]
ans1 = solve(n-1, 0)
ans2 = solve(n-1, 1)
ans3 = solve(n-1, 2)
print((max(ans1, ans2, ans3))) | import sys
sys.setrecursionlimit(10**6)
n = int(eval(input()))
a, b, c = [], [], []
# dp = [[None] * 3 for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
for i in range(n):
v1, v2, v3 = list(map(int, input().split()))
a.append(v1)
b.append(v2)
c.append(v3)
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for idx in range(1, n):
# Select A(0)
a1 = dp[idx - 1][1] + a[idx]
a2 = dp[idx - 1][2] + a[idx]
dp[idx][0] = max(a1, a2)
# Select B(1)
b1 = dp[idx - 1][0] + b[idx]
b2 = dp[idx - 1][2] + b[idx]
dp[idx][1] = max(b1, b2)
# Select C(2)
c1 = dp[idx - 1][0] + c[idx]
c2 = dp[idx - 1][1] + c[idx]
dp[idx][2] = max(c1, c2)
print((max(dp[n-1][0], dp[n-1][1], dp[n-1][2]))) | 53 | 35 | 1,192 | 760 | import sys
sys.setrecursionlimit(10**6)
n = int(eval(input()))
a, b, c = [], [], []
# dp = [[None] * 3 for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
for i in range(n):
v1, v2, v3 = list(map(int, input().split()))
a.append(v1)
b.append(v2)
c.append(v3)
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
def solve(idx, ptn):
if dp[idx][ptn] > 0:
return dp[idx][ptn]
# Select A(0)
if ptn == 0:
if idx == 0:
return a[0]
a1 = solve(idx - 1, 1) + a[idx]
a2 = solve(idx - 1, 2) + a[idx]
dp[idx][0] = max(a1, a2)
return dp[idx][0]
# Select B(1)
if ptn == 1:
if idx == 0:
return b[0]
b1 = solve(idx - 1, 0) + b[idx]
b2 = solve(idx - 1, 2) + b[idx]
dp[idx][1] = max(b1, b2)
return dp[idx][1]
# Select C(2)
if ptn == 2:
if idx == 0:
return c[0]
c1 = solve(idx - 1, 0) + c[idx]
c2 = solve(idx - 1, 1) + c[idx]
dp[idx][2] = max(c1, c2)
return dp[idx][2]
ans1 = solve(n - 1, 0)
ans2 = solve(n - 1, 1)
ans3 = solve(n - 1, 2)
print((max(ans1, ans2, ans3)))
| import sys
sys.setrecursionlimit(10**6)
n = int(eval(input()))
a, b, c = [], [], []
# dp = [[None] * 3 for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
for i in range(n):
v1, v2, v3 = list(map(int, input().split()))
a.append(v1)
b.append(v2)
c.append(v3)
dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]
for idx in range(1, n):
# Select A(0)
a1 = dp[idx - 1][1] + a[idx]
a2 = dp[idx - 1][2] + a[idx]
dp[idx][0] = max(a1, a2)
# Select B(1)
b1 = dp[idx - 1][0] + b[idx]
b2 = dp[idx - 1][2] + b[idx]
dp[idx][1] = max(b1, b2)
# Select C(2)
c1 = dp[idx - 1][0] + c[idx]
c2 = dp[idx - 1][1] + c[idx]
dp[idx][2] = max(c1, c2)
print((max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2])))
| false | 33.962264 | [
"-",
"-",
"-def solve(idx, ptn):",
"- if dp[idx][ptn] > 0:",
"- return dp[idx][ptn]",
"+for idx in range(1, n):",
"- if ptn == 0:",
"- if idx == 0:",
"- return a[0]",
"- a1 = solve(idx - 1, 1) + a[idx]",
"- a2 = solve(idx - 1, 2) + a[idx]",
"- ... | false | 0.034286 | 0.043712 | 0.784362 | [
"s563174966",
"s513354427"
] |
u281303342 | p03370 | python | s794451509 | s149981725 | 20 | 18 | 3,316 | 2,940 | Accepted | Accepted | 10 | N,X = list(map(int,input().split()))
M = []
for i in range(N):
M.append(int(eval(input())))
print(((X-sum(M))//min(M)+N)) | N,X = list(map(int,input().split()))
M = [int(eval(input())) for _ in range(N)]
print((N + (X-sum(M))//min(M))) | 5 | 3 | 115 | 99 | N, X = list(map(int, input().split()))
M = []
for i in range(N):
M.append(int(eval(input())))
print(((X - sum(M)) // min(M) + N))
| N, X = list(map(int, input().split()))
M = [int(eval(input())) for _ in range(N)]
print((N + (X - sum(M)) // min(M)))
| false | 40 | [
"-M = []",
"-for i in range(N):",
"- M.append(int(eval(input())))",
"-print(((X - sum(M)) // min(M) + N))",
"+M = [int(eval(input())) for _ in range(N)]",
"+print((N + (X - sum(M)) // min(M)))"
] | false | 0.090741 | 0.092001 | 0.986302 | [
"s794451509",
"s149981725"
] |
u998169143 | p02995 | python | s102842677 | s625773712 | 40 | 17 | 5,432 | 3,064 | Accepted | Accepted | 57.5 | import fractions
def lcm(a,b):
return a*b //fractions.gcd(a, b)
A, B,C,D = list(map(int, input().split()))
b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)
print(((B-(A-1))-(b_num-a_num))) | def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
A, B, C, D = list(map(int, input().split()))
b_num = B//C + B//D - B//lcm(C, D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C, D)
print(((B-A+1) -(b_num - a_num))) | 9 | 15 | 225 | 282 | import fractions
def lcm(a, b):
return a * b // fractions.gcd(a, b)
A, B, C, D = list(map(int, input().split()))
b_num = B // C + B // D - B // lcm(C, D)
a_num = (A - 1) // C + (A - 1) // D - (A - 1) // lcm(C, D)
print(((B - (A - 1)) - (b_num - a_num)))
| def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd(a, b)
A, B, C, D = list(map(int, input().split()))
b_num = B // C + B // D - B // lcm(C, D)
a_num = (A - 1) // C + (A - 1) // D - (A - 1) // lcm(C, D)
print(((B - A + 1) - (b_num - a_num)))
| false | 40 | [
"-import fractions",
"+def gcd(a, b):",
"+ while b:",
"+ a, b = b, a % b",
"+ return a",
"- return a * b // fractions.gcd(a, b)",
"+ return a * b // gcd(a, b)",
"-print(((B - (A - 1)) - (b_num - a_num)))",
"+print(((B - A + 1) - (b_num - a_num)))"
] | false | 0.126862 | 0.076001 | 1.669216 | [
"s102842677",
"s625773712"
] |
u828847847 | p03546 | python | s442791918 | s234931387 | 32 | 29 | 2,948 | 2,948 | Accepted | Accepted | 9.38 | h,w = list(map(int,input().split()))
d = [list(map(int,input().split())) for i in range(10)]
for t in range(10):
for i in range(10):
for j in range(10):
for k in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
arr = [list(map(int,input().split())) for i in range(h)]
print(sum(sum(d[a][1] if a>=0 else 0 for a in aa) for aa in arr)) | h,w = list(map(int,input().split()))
d = [list(map(int,input().split())) for i in range(10)]
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])
arr = [list(map(int,input().split())) for i in range(h)]
print(sum(sum(d[a][1] if a>=0 else 0 for a in aa) for aa in arr)) | 10 | 11 | 351 | 329 | h, w = list(map(int, input().split()))
d = [list(map(int, input().split())) for i in range(10)]
for t in range(10):
for i in range(10):
for j in range(10):
for k in range(10):
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
arr = [list(map(int, input().split())) for i in range(h)]
print(sum(sum(d[a][1] if a >= 0 else 0 for a in aa) for aa in arr))
| h, w = list(map(int, input().split()))
d = [list(map(int, input().split())) for i in range(10)]
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])
arr = [list(map(int, input().split())) for i in range(h)]
print(sum(sum(d[a][1] if a >= 0 else 0 for a in aa) for aa in arr))
| false | 9.090909 | [
"-for t in range(10):",
"+for k in range(10):",
"- for k in range(10):",
"- d[i][j] = min(d[i][j], d[i][k] + d[k][j])",
"+ d[i][j] = min(d[i][j], d[i][k] + d[k][j])"
] | false | 0.050809 | 0.11178 | 0.454548 | [
"s442791918",
"s234931387"
] |
u130900604 | p02881 | python | s739209091 | s964028828 | 397 | 171 | 3,060 | 2,940 | Accepted | Accepted | 56.93 | n=int(eval(input()))
a=-1
b=-1
for i in range(1,int(n**0.5)+1):
#print(i,n/i)
if n/i-int(n/i)==0:
a=i
b=int(n/i)
print((a+b-2)) | n=int(eval(input()))
#n=a*bのa+b-2のmin
ans=float("inf")
for i in range(1,int(n**0.5)+1):
if n%i==0:
ans=min(ans,n//i+i-2)
print(ans) | 11 | 7 | 151 | 137 | n = int(eval(input()))
a = -1
b = -1
for i in range(1, int(n**0.5) + 1):
# print(i,n/i)
if n / i - int(n / i) == 0:
a = i
b = int(n / i)
print((a + b - 2))
| n = int(eval(input()))
# n=a*bのa+b-2のmin
ans = float("inf")
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
ans = min(ans, n // i + i - 2)
print(ans)
| false | 36.363636 | [
"-a = -1",
"-b = -1",
"+# n=a*bのa+b-2のmin",
"+ans = float(\"inf\")",
"- # print(i,n/i)",
"- if n / i - int(n / i) == 0:",
"- a = i",
"- b = int(n / i)",
"-print((a + b - 2))",
"+ if n % i == 0:",
"+ ans = min(ans, n // i + i - 2)",
"+print(ans)"
] | false | 0.142808 | 0.085985 | 1.660841 | [
"s739209091",
"s964028828"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.