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
sequence | 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
sequence |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u517910772 | p02659 | python | s940505922 | s783239911 | 26 | 24 | 10,084 | 9,204 | Accepted | Accepted | 7.69 | def c():
from decimal import Decimal
import math
a, b = list(map(str, input().split()))
print((int(math.floor(Decimal(a) * Decimal(b)))))
if __name__ == "__main__":
c()
| def cc():
a, b = list(map(str, input().split()))
a2 = int(a)
b2 = int(b.replace('.', ''))
c = a2 * b2
ans = str(c)[0:-2] if len(str(c)) > 2 else 0
print(ans)
if __name__ == "__main__":
cc()
| 8 | 9 | 189 | 220 | def c():
from decimal import Decimal
import math
a, b = list(map(str, input().split()))
print((int(math.floor(Decimal(a) * Decimal(b)))))
if __name__ == "__main__":
c()
| def cc():
a, b = list(map(str, input().split()))
a2 = int(a)
b2 = int(b.replace(".", ""))
c = a2 * b2
ans = str(c)[0:-2] if len(str(c)) > 2 else 0
print(ans)
if __name__ == "__main__":
cc()
| false | 11.111111 | [
"-def c():",
"- from decimal import Decimal",
"- import math",
"-",
"+def cc():",
"- print((int(math.floor(Decimal(a) * Decimal(b)))))",
"+ a2 = int(a)",
"+ b2 = int(b.replace(\".\", \"\"))",
"+ c = a2 * b2",
"+ ans = str(c)[0:-2] if len(str(c)) > 2 else 0",
"+ print(ans)",
"- c()",
"+ cc()"
] | false | 0.130002 | 0.064813 | 2.005793 | [
"s940505922",
"s783239911"
] |
u312025627 | p03352 | python | s824567768 | s142937146 | 176 | 28 | 38,256 | 2,940 | Accepted | Accepted | 84.09 | def main():
X = int(eval(input()))
ans = []
for b in range(1, 100):
for p in range(2, 10):
if b**p <= X:
ans.append(b**p)
print((max(ans)))
if __name__ == '__main__':
main()
| def main():
N = int(eval(input()))
ans = set()
for a in range(N+1):
for b in range(2, 31):
if a**b > N:
continue
ans.add(a**b)
print((max(ans)))
if __name__ == '__main__':
main()
| 12 | 13 | 235 | 253 | def main():
X = int(eval(input()))
ans = []
for b in range(1, 100):
for p in range(2, 10):
if b**p <= X:
ans.append(b**p)
print((max(ans)))
if __name__ == "__main__":
main()
| def main():
N = int(eval(input()))
ans = set()
for a in range(N + 1):
for b in range(2, 31):
if a**b > N:
continue
ans.add(a**b)
print((max(ans)))
if __name__ == "__main__":
main()
| false | 7.692308 | [
"- X = int(eval(input()))",
"- ans = []",
"- for b in range(1, 100):",
"- for p in range(2, 10):",
"- if b**p <= X:",
"- ans.append(b**p)",
"+ N = int(eval(input()))",
"+ ans = set()",
"+ for a in range(N + 1):",
"+ for b in range(2, 31):",
"+ if a**b > N:",
"+ continue",
"+ ans.add(a**b)"
] | false | 0.057858 | 0.039687 | 1.457858 | [
"s824567768",
"s142937146"
] |
u077291787 | p03745 | python | s305370198 | s501742925 | 66 | 53 | 14,356 | 14,352 | Accepted | Accepted | 19.7 | # AGC013A - Sorted Arrays
def main():
n = int(eval(input()))
A = tuple(map(int, input().rstrip().split()))
# compress continuous parts of same numbers (e.g. 111 -> 1)
B, cur = [], 0
for i in A:
if i != cur:
B += [i]
cur = i
B += [0]
# check the modified sequence
ans, cur = 0, B[0]
flg = B[0] < B[1] # increasing (1) / decreasing (0)
for i, j in enumerate(B[1:-1], start=1):
if (flg and j < cur) or (not flg and j > cur):
ans += 1
flg = B[i] < B[i + 1]
cur = j
print((ans + 1))
if __name__ == "__main__":
main() | # AGC013A - Sorted Arrays
def main():
n = int(eval(input()))
A = tuple(map(int, input().split()))
ans, cur = 0, A[0]
flg = 0 # unknown (0), increasing (1), decreasing (2)
for i in A:
if (flg == 1 and i < cur) or (flg == 2 and i > cur): # end of trend
ans += 1
flg = 0
elif not flg and cur < i: # new increasing trend
flg = 1
elif not flg and cur > i: # new decreasing trend
flg = 2
cur = i
print((ans + 1))
if __name__ == "__main__":
main() | 26 | 20 | 653 | 565 | # AGC013A - Sorted Arrays
def main():
n = int(eval(input()))
A = tuple(map(int, input().rstrip().split()))
# compress continuous parts of same numbers (e.g. 111 -> 1)
B, cur = [], 0
for i in A:
if i != cur:
B += [i]
cur = i
B += [0]
# check the modified sequence
ans, cur = 0, B[0]
flg = B[0] < B[1] # increasing (1) / decreasing (0)
for i, j in enumerate(B[1:-1], start=1):
if (flg and j < cur) or (not flg and j > cur):
ans += 1
flg = B[i] < B[i + 1]
cur = j
print((ans + 1))
if __name__ == "__main__":
main()
| # AGC013A - Sorted Arrays
def main():
n = int(eval(input()))
A = tuple(map(int, input().split()))
ans, cur = 0, A[0]
flg = 0 # unknown (0), increasing (1), decreasing (2)
for i in A:
if (flg == 1 and i < cur) or (flg == 2 and i > cur): # end of trend
ans += 1
flg = 0
elif not flg and cur < i: # new increasing trend
flg = 1
elif not flg and cur > i: # new decreasing trend
flg = 2
cur = i
print((ans + 1))
if __name__ == "__main__":
main()
| false | 23.076923 | [
"- A = tuple(map(int, input().rstrip().split()))",
"- # compress continuous parts of same numbers (e.g. 111 -> 1)",
"- B, cur = [], 0",
"+ A = tuple(map(int, input().split()))",
"+ ans, cur = 0, A[0]",
"+ flg = 0 # unknown (0), increasing (1), decreasing (2)",
"- if i != cur:",
"- B += [i]",
"- cur = i",
"- B += [0]",
"- # check the modified sequence",
"- ans, cur = 0, B[0]",
"- flg = B[0] < B[1] # increasing (1) / decreasing (0)",
"- for i, j in enumerate(B[1:-1], start=1):",
"- if (flg and j < cur) or (not flg and j > cur):",
"+ if (flg == 1 and i < cur) or (flg == 2 and i > cur): # end of trend",
"- flg = B[i] < B[i + 1]",
"- cur = j",
"+ flg = 0",
"+ elif not flg and cur < i: # new increasing trend",
"+ flg = 1",
"+ elif not flg and cur > i: # new decreasing trend",
"+ flg = 2",
"+ cur = i"
] | false | 0.04418 | 0.04581 | 0.964407 | [
"s305370198",
"s501742925"
] |
u102461423 | p02702 | python | s815067088 | s803644718 | 591 | 325 | 29,148 | 29,192 | Accepted | Accepted | 45.01 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
def solve(S):
dp = np.zeros(2019, np.int64)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
x = x * pow10 % 2019
newdp = np.zeros_like(dp)
newdp[x:] += dp[:-x]
newdp[:x] += dp[-x:]
answer += newdp[0]
pow10 *= 10
pow10 %= 2019
dp = newdp
return answer
def cc_export():
from numba.pycc import CC
cc = CC('my_module')
cc.export('solve', '(i4[:],)')(solve)
cc.compile()
try:
from my_module import solve
except:
cc_export()
exit()
S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print((solve(S)))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 2019
def solve(S):
dp = np.zeros(MOD, np.int64)
temp = np.empty_like(dp)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
x = x * pow10 % MOD
temp[x:] = dp[:-x]
temp[:x] = dp[-x:]
dp, temp = temp, dp
answer += dp[0]
pow10 *= 10
pow10 %= MOD
return answer
def cc_export():
from numba.pycc import CC
cc = CC('my_module')
cc.export('solve', '(i4[:],)')(solve)
cc.compile()
try:
from my_module import solve
except:
cc_export()
exit()
S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print((solve(S)))
| 39 | 40 | 807 | 813 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
def solve(S):
dp = np.zeros(2019, np.int64)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
x = x * pow10 % 2019
newdp = np.zeros_like(dp)
newdp[x:] += dp[:-x]
newdp[:x] += dp[-x:]
answer += newdp[0]
pow10 *= 10
pow10 %= 2019
dp = newdp
return answer
def cc_export():
from numba.pycc import CC
cc = CC("my_module")
cc.export("solve", "(i4[:],)")(solve)
cc.compile()
try:
from my_module import solve
except:
cc_export()
exit()
S = np.array(list(read().rstrip()), dtype=np.int32) - ord("0")
print((solve(S)))
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 2019
def solve(S):
dp = np.zeros(MOD, np.int64)
temp = np.empty_like(dp)
pow10 = 1
answer = 0
for x in S[::-1]:
dp[0] += 1
x = x * pow10 % MOD
temp[x:] = dp[:-x]
temp[:x] = dp[-x:]
dp, temp = temp, dp
answer += dp[0]
pow10 *= 10
pow10 %= MOD
return answer
def cc_export():
from numba.pycc import CC
cc = CC("my_module")
cc.export("solve", "(i4[:],)")(solve)
cc.compile()
try:
from my_module import solve
except:
cc_export()
exit()
S = np.array(list(read().rstrip()), dtype=np.int32) - ord("0")
print((solve(S)))
| false | 2.5 | [
"+MOD = 2019",
"+",
"- dp = np.zeros(2019, np.int64)",
"+ dp = np.zeros(MOD, np.int64)",
"+ temp = np.empty_like(dp)",
"- x = x * pow10 % 2019",
"- newdp = np.zeros_like(dp)",
"- newdp[x:] += dp[:-x]",
"- newdp[:x] += dp[-x:]",
"- answer += newdp[0]",
"+ x = x * pow10 % MOD",
"+ temp[x:] = dp[:-x]",
"+ temp[:x] = dp[-x:]",
"+ dp, temp = temp, dp",
"+ answer += dp[0]",
"- pow10 %= 2019",
"- dp = newdp",
"+ pow10 %= MOD"
] | false | 0.203232 | 0.207878 | 0.977653 | [
"s815067088",
"s803644718"
] |
u883621917 | p02900 | python | s725534998 | s330175357 | 325 | 220 | 29,840 | 79,600 | Accepted | Accepted | 32.31 | a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)
import sys
if small == 1:
print((1))
sys.exit(0)
import math
import collections
# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
if num <= 1:
assert False
factors = []
# divisorsを使い回せるようにする。
# - 二度生成した場合にかかる時間が許容できない場合
# - エラトステネスの篩などで素数テーブルを既に持っている場合
if not divisors:
divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]
for d in divisors:
# divisorsを引数で与えた場合のみ起こりうる
if num < d:
break
while num % d == 0:
factors.append(d)
num //= d
if num != 1:
factors.append(num)
return factors
#divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
#small_factors = set(prime_factorization(small, divisors))
#big_factors = set(prime_factorization(big, divisors))
small_factors = set(prime_factorization(small))
big_factors = set(prime_factorization(big))
print((len(small_factors.intersection(big_factors)) + 1))
| a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)
import sys
if small == 1:
print((1))
sys.exit(0)
import math
import collections
# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
if num <= 1:
assert False
factors = []
# divisorsを使い回せるようにする。
# - 二度生成した場合にかかる時間が許容できない場合
# - エラトステネスの篩などで素数テーブルを既に持っている場合
if not divisors:
divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]
for d in divisors:
# divisorsを引数で与えた場合のみ起こりうる
if num < d:
break
while num % d == 0:
factors.append(d)
num //= d
if num != 1:
factors.append(num)
return factors
divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
small_factors = set(prime_factorization(small, divisors))
big_factors = set(prime_factorization(big, divisors))
print((len(small_factors.intersection(big_factors)) + 1))
| 44 | 42 | 1,184 | 1,087 | a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)
import sys
if small == 1:
print((1))
sys.exit(0)
import math
import collections
# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
if num <= 1:
assert False
factors = []
# divisorsを使い回せるようにする。
# - 二度生成した場合にかかる時間が許容できない場合
# - エラトステネスの篩などで素数テーブルを既に持っている場合
if not divisors:
divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]
for d in divisors:
# divisorsを引数で与えた場合のみ起こりうる
if num < d:
break
while num % d == 0:
factors.append(d)
num //= d
if num != 1:
factors.append(num)
return factors
# divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
# small_factors = set(prime_factorization(small, divisors))
# big_factors = set(prime_factorization(big, divisors))
small_factors = set(prime_factorization(small))
big_factors = set(prime_factorization(big))
print((len(small_factors.intersection(big_factors)) + 1))
| a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)
import sys
if small == 1:
print((1))
sys.exit(0)
import math
import collections
# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
if num <= 1:
assert False
factors = []
# divisorsを使い回せるようにする。
# - 二度生成した場合にかかる時間が許容できない場合
# - エラトステネスの篩などで素数テーブルを既に持っている場合
if not divisors:
divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]
for d in divisors:
# divisorsを引数で与えた場合のみ起こりうる
if num < d:
break
while num % d == 0:
factors.append(d)
num //= d
if num != 1:
factors.append(num)
return factors
divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
small_factors = set(prime_factorization(small, divisors))
big_factors = set(prime_factorization(big, divisors))
print((len(small_factors.intersection(big_factors)) + 1))
| false | 4.545455 | [
"-# divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]",
"-# small_factors = set(prime_factorization(small, divisors))",
"-# big_factors = set(prime_factorization(big, divisors))",
"-small_factors = set(prime_factorization(small))",
"-big_factors = set(prime_factorization(big))",
"+divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]",
"+small_factors = set(prime_factorization(small, divisors))",
"+big_factors = set(prime_factorization(big, divisors))"
] | false | 0.039279 | 0.038677 | 1.015543 | [
"s725534998",
"s330175357"
] |
u221898645 | p02813 | python | s758142971 | s002043459 | 35 | 27 | 8,052 | 8,052 | Accepted | Accepted | 22.86 | N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
import itertools
X = list(itertools.permutations(list(range(1,N+1)),N))
for i in range(len(X)):
x = X[i]
if P == x:
a = i
if Q == x:
b = i
print((abs(a-b))) | N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
import itertools
X = list(itertools.permutations(list(range(1,N+1)),N))
print((abs(X.index(Q)-X.index(P)))) | 14 | 8 | 269 | 199 | N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
import itertools
X = list(itertools.permutations(list(range(1, N + 1)), N))
for i in range(len(X)):
x = X[i]
if P == x:
a = i
if Q == x:
b = i
print((abs(a - b)))
| N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
import itertools
X = list(itertools.permutations(list(range(1, N + 1)), N))
print((abs(X.index(Q) - X.index(P))))
| false | 42.857143 | [
"-for i in range(len(X)):",
"- x = X[i]",
"- if P == x:",
"- a = i",
"- if Q == x:",
"- b = i",
"-print((abs(a - b)))",
"+print((abs(X.index(Q) - X.index(P))))"
] | false | 0.048392 | 0.090323 | 0.53576 | [
"s758142971",
"s002043459"
] |
u681444474 | p03160 | python | s310174701 | s772249887 | 237 | 141 | 52,464 | 13,900 | Accepted | Accepted | 40.51 | N = int(eval(input()))
H_ = list(map(int,input().split()))
def dp_solver(x):#x番の足場に行くための最小コスト
H = H_
dp = [0]*len(H)
dp[1] = abs(H[0]-H[1])
for i in range(len(H)-2):
dp[i+2] = min(dp[i]+abs(H[i+2]-H[i]),dp[i+1]+abs(H[i+2]-H[i+1]))
return dp[x]
print((dp_solver(N-1))) | N = int(eval(input()))
H_ = list(map(int,input().split()))
def dp_solver(x):
H = H_
dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])
for i in range(N-2):
dp[i+2] = min(dp[i+2],dp[i]+abs(H[i+2]-H[i]))
dp[i+2] = min(dp[i+2],dp[i+1]+abs(H[i+2]-H[i+1]))
return dp[x-1]
print((dp_solver(N))) | 11 | 12 | 302 | 329 | N = int(eval(input()))
H_ = list(map(int, input().split()))
def dp_solver(x): # x番の足場に行くための最小コスト
H = H_
dp = [0] * len(H)
dp[1] = abs(H[0] - H[1])
for i in range(len(H) - 2):
dp[i + 2] = min(
dp[i] + abs(H[i + 2] - H[i]), dp[i + 1] + abs(H[i + 2] - H[i + 1])
)
return dp[x]
print((dp_solver(N - 1)))
| N = int(eval(input()))
H_ = list(map(int, input().split()))
def dp_solver(x):
H = H_
dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(N - 2):
dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))
dp[i + 2] = min(dp[i + 2], dp[i + 1] + abs(H[i + 2] - H[i + 1]))
return dp[x - 1]
print((dp_solver(N)))
| false | 8.333333 | [
"-def dp_solver(x): # x番の足場に行くための最小コスト",
"+def dp_solver(x):",
"- dp = [0] * len(H)",
"- dp[1] = abs(H[0] - H[1])",
"- for i in range(len(H) - 2):",
"- dp[i + 2] = min(",
"- dp[i] + abs(H[i + 2] - H[i]), dp[i + 1] + abs(H[i + 2] - H[i + 1])",
"- )",
"- return dp[x]",
"+ dp = [float(\"inf\")] * N",
"+ dp[0] = 0",
"+ dp[1] = abs(H[1] - H[0])",
"+ for i in range(N - 2):",
"+ dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))",
"+ dp[i + 2] = min(dp[i + 2], dp[i + 1] + abs(H[i + 2] - H[i + 1]))",
"+ return dp[x - 1]",
"-print((dp_solver(N - 1)))",
"+print((dp_solver(N)))"
] | false | 0.05409 | 0.069583 | 0.777346 | [
"s310174701",
"s772249887"
] |
u912237403 | p00017 | python | s884482593 | s649990865 | 20 | 10 | 4,376 | 4,208 | Accepted | Accepted | 50 | import sys,string
A="abcdefghijklmnopqrstuvwxyz"
tbl=string.maketrans(A,A[1:]+A[0])
for s in sys.stdin.readlines():
while not("the" in s or "that" in s or "this" in s):
s=s.translate(tbl)
print(s[:-1]) | import sys
A="abcdefghijklmnopqrstuvwxyza"
def rot(s):
x=""
for c in s:
if c in A: x+=A[A.index(c)+1]
else: x+=c
return x
for s in sys.stdin.readlines():
while not("the" in s or "that" in s or "this" in s):
s=rot(s)
print(s[:-1]) | 7 | 13 | 222 | 287 | import sys, string
A = "abcdefghijklmnopqrstuvwxyz"
tbl = string.maketrans(A, A[1:] + A[0])
for s in sys.stdin.readlines():
while not ("the" in s or "that" in s or "this" in s):
s = s.translate(tbl)
print(s[:-1])
| import sys
A = "abcdefghijklmnopqrstuvwxyza"
def rot(s):
x = ""
for c in s:
if c in A:
x += A[A.index(c) + 1]
else:
x += c
return x
for s in sys.stdin.readlines():
while not ("the" in s or "that" in s or "this" in s):
s = rot(s)
print(s[:-1])
| false | 46.153846 | [
"-import sys, string",
"+import sys",
"-A = \"abcdefghijklmnopqrstuvwxyz\"",
"-tbl = string.maketrans(A, A[1:] + A[0])",
"+A = \"abcdefghijklmnopqrstuvwxyza\"",
"+",
"+",
"+def rot(s):",
"+ x = \"\"",
"+ for c in s:",
"+ if c in A:",
"+ x += A[A.index(c) + 1]",
"+ else:",
"+ x += c",
"+ return x",
"+",
"+",
"- s = s.translate(tbl)",
"+ s = rot(s)"
] | false | 0.04414 | 0.08903 | 0.495783 | [
"s884482593",
"s649990865"
] |
u017415492 | p03208 | python | s394724978 | s874239402 | 249 | 223 | 7,384 | 7,484 | Accepted | Accepted | 10.44 | n,k=list(map(int,input().split()))
h=[]
for i in range(n):
h.append(int(eval(input())))
h.sort()
S=10000000000000
for i in range(n-k+1):
if S>h[i+k-1]-h[i]:
S=h[i+k-1]-h[i]
print(S) | n,k=list(map(int,input().split()))
h=[int(eval(input())) for i in range(n)]
h.sort()
hantei=10**9+1
for i in range(len(h)-k+1):
if (h[i+k-1]-h[i])<hantei:
hantei=h[i+k-1]-h[i]
print(hantei) | 11 | 8 | 188 | 190 | n, k = list(map(int, input().split()))
h = []
for i in range(n):
h.append(int(eval(input())))
h.sort()
S = 10000000000000
for i in range(n - k + 1):
if S > h[i + k - 1] - h[i]:
S = h[i + k - 1] - h[i]
print(S)
| n, k = list(map(int, input().split()))
h = [int(eval(input())) for i in range(n)]
h.sort()
hantei = 10**9 + 1
for i in range(len(h) - k + 1):
if (h[i + k - 1] - h[i]) < hantei:
hantei = h[i + k - 1] - h[i]
print(hantei)
| false | 27.272727 | [
"-h = []",
"-for i in range(n):",
"- h.append(int(eval(input())))",
"+h = [int(eval(input())) for i in range(n)]",
"-S = 10000000000000",
"-for i in range(n - k + 1):",
"- if S > h[i + k - 1] - h[i]:",
"- S = h[i + k - 1] - h[i]",
"-print(S)",
"+hantei = 10**9 + 1",
"+for i in range(len(h) - k + 1):",
"+ if (h[i + k - 1] - h[i]) < hantei:",
"+ hantei = h[i + k - 1] - h[i]",
"+print(hantei)"
] | false | 0.049584 | 0.061875 | 0.80136 | [
"s394724978",
"s874239402"
] |
u998741086 | p02601 | python | s368759393 | s608785629 | 33 | 24 | 9,200 | 9,156 | Accepted | Accepted | 27.27 | #!/usr/bin/env python
ta, tb, tc = list(map(int, input().split()))
k = int(eval(input()))
def dfs(s):
a = ta
b = tb
c = tc
if len(s) == k:
#print(s)
for i in range(k):
if 'A' == s[i]:
a *= 2
elif 'B' == s[i]:
b *= 2
elif 'C' == s[i]:
c *= 2
if c > b > a:
print('Yes')
exit(0)
return
dfs(s+'A')
dfs(s+'B')
dfs(s+'C')
dfs('')
print('No')
| #!/usr/bin/env python
a, b, c = list(map(int, input().split()))
k = int(eval(input()))
t = 0
while a>=b:
b *= 2
t += 1
while b>=c:
c *= 2
t += 1
if t<=k:
print('Yes')
else:
print('No')
| 29 | 17 | 524 | 217 | #!/usr/bin/env python
ta, tb, tc = list(map(int, input().split()))
k = int(eval(input()))
def dfs(s):
a = ta
b = tb
c = tc
if len(s) == k:
# print(s)
for i in range(k):
if "A" == s[i]:
a *= 2
elif "B" == s[i]:
b *= 2
elif "C" == s[i]:
c *= 2
if c > b > a:
print("Yes")
exit(0)
return
dfs(s + "A")
dfs(s + "B")
dfs(s + "C")
dfs("")
print("No")
| #!/usr/bin/env python
a, b, c = list(map(int, input().split()))
k = int(eval(input()))
t = 0
while a >= b:
b *= 2
t += 1
while b >= c:
c *= 2
t += 1
if t <= k:
print("Yes")
else:
print("No")
| false | 41.37931 | [
"-ta, tb, tc = list(map(int, input().split()))",
"+a, b, c = list(map(int, input().split()))",
"-",
"-",
"-def dfs(s):",
"- a = ta",
"- b = tb",
"- c = tc",
"- if len(s) == k:",
"- # print(s)",
"- for i in range(k):",
"- if \"A\" == s[i]:",
"- a *= 2",
"- elif \"B\" == s[i]:",
"- b *= 2",
"- elif \"C\" == s[i]:",
"- c *= 2",
"- if c > b > a:",
"- print(\"Yes\")",
"- exit(0)",
"- return",
"- dfs(s + \"A\")",
"- dfs(s + \"B\")",
"- dfs(s + \"C\")",
"-",
"-",
"-dfs(\"\")",
"-print(\"No\")",
"+t = 0",
"+while a >= b:",
"+ b *= 2",
"+ t += 1",
"+while b >= c:",
"+ c *= 2",
"+ t += 1",
"+if t <= k:",
"+ print(\"Yes\")",
"+else:",
"+ print(\"No\")"
] | false | 0.086258 | 0.034559 | 2.495942 | [
"s368759393",
"s608785629"
] |
u639343026 | p02887 | python | s662795728 | s109018340 | 49 | 45 | 3,316 | 3,316 | Accepted | Accepted | 8.16 | n=int(eval(input()))
s=eval(input())
cnt=1
if n==1:
print(cnt)
else:
for i in range(n):
if i==0: memo=s[i]
else:
if memo==s[i]:
continue
else:
cnt+=1
memo=s[i]
print(cnt) | n=eval(input())
s=eval(input())
res=1
for i in range(1,int(n)):
if s[i-1]!=s[i]:
res+=1
print(res) | 16 | 7 | 278 | 104 | n = int(eval(input()))
s = eval(input())
cnt = 1
if n == 1:
print(cnt)
else:
for i in range(n):
if i == 0:
memo = s[i]
else:
if memo == s[i]:
continue
else:
cnt += 1
memo = s[i]
print(cnt)
| n = eval(input())
s = eval(input())
res = 1
for i in range(1, int(n)):
if s[i - 1] != s[i]:
res += 1
print(res)
| false | 56.25 | [
"-n = int(eval(input()))",
"+n = eval(input())",
"-cnt = 1",
"-if n == 1:",
"- print(cnt)",
"-else:",
"- for i in range(n):",
"- if i == 0:",
"- memo = s[i]",
"- else:",
"- if memo == s[i]:",
"- continue",
"- else:",
"- cnt += 1",
"- memo = s[i]",
"- print(cnt)",
"+res = 1",
"+for i in range(1, int(n)):",
"+ if s[i - 1] != s[i]:",
"+ res += 1",
"+print(res)"
] | false | 0.047292 | 0.048102 | 0.983169 | [
"s662795728",
"s109018340"
] |
u236127431 | p03575 | python | s221584743 | s434940155 | 33 | 25 | 3,060 | 3,064 | Accepted | Accepted | 24.24 | N,M=list(map(int,input().split()))
List=[[int(i) for i in input().split()] for i in range(M)]
S=0
for i in range(M):
new_List=list(List)
del new_List[i]
islands=[1]
for i in islands:
for j in new_List:
if i in j:
j=[item for item in j if item not in islands]
islands.extend(j)
if len(islands)<N:
S+=1
print(S)
| class Unionfind:
def __init__(self,n):
self.Tree=[i for i in range(n)]
def find(self,x):
if x==self.Tree[x]:
return x
else:
root=self.find(self.Tree[x])
self.Tree[x]=root
return root
def unite(self,x,y):
s1=self.find(x)
s2=self.find(y)
if s1==s2:
pass
else:
self.Tree[s1]=s2
N,M=list(map(int,input().split()))
Uf=Unionfind(N)
Flag=0
B=0
A=[]
Edge=[[int(i) for i in input().split()] for i in range(M)]
for m in range(M):
Edge_copy=list(Edge)
del Edge_copy[m]
for e in Edge_copy:
Uf.unite(e[0]-1,e[1]-1)
for a in range(N):
A.append(Uf.find(a))
for n in range(N-1):
if Uf.find(n)!=Uf.find(n+1):
Flag=1
break
if Flag==1:
B+=1
Flag=0
Uf=Unionfind(N)
A=[]
print(B) | 16 | 43 | 363 | 823 | N, M = list(map(int, input().split()))
List = [[int(i) for i in input().split()] for i in range(M)]
S = 0
for i in range(M):
new_List = list(List)
del new_List[i]
islands = [1]
for i in islands:
for j in new_List:
if i in j:
j = [item for item in j if item not in islands]
islands.extend(j)
if len(islands) < N:
S += 1
print(S)
| class Unionfind:
def __init__(self, n):
self.Tree = [i for i in range(n)]
def find(self, x):
if x == self.Tree[x]:
return x
else:
root = self.find(self.Tree[x])
self.Tree[x] = root
return root
def unite(self, x, y):
s1 = self.find(x)
s2 = self.find(y)
if s1 == s2:
pass
else:
self.Tree[s1] = s2
N, M = list(map(int, input().split()))
Uf = Unionfind(N)
Flag = 0
B = 0
A = []
Edge = [[int(i) for i in input().split()] for i in range(M)]
for m in range(M):
Edge_copy = list(Edge)
del Edge_copy[m]
for e in Edge_copy:
Uf.unite(e[0] - 1, e[1] - 1)
for a in range(N):
A.append(Uf.find(a))
for n in range(N - 1):
if Uf.find(n) != Uf.find(n + 1):
Flag = 1
break
if Flag == 1:
B += 1
Flag = 0
Uf = Unionfind(N)
A = []
print(B)
| false | 62.790698 | [
"+class Unionfind:",
"+ def __init__(self, n):",
"+ self.Tree = [i for i in range(n)]",
"+",
"+ def find(self, x):",
"+ if x == self.Tree[x]:",
"+ return x",
"+ else:",
"+ root = self.find(self.Tree[x])",
"+ self.Tree[x] = root",
"+ return root",
"+",
"+ def unite(self, x, y):",
"+ s1 = self.find(x)",
"+ s2 = self.find(y)",
"+ if s1 == s2:",
"+ pass",
"+ else:",
"+ self.Tree[s1] = s2",
"+",
"+",
"-List = [[int(i) for i in input().split()] for i in range(M)]",
"-S = 0",
"-for i in range(M):",
"- new_List = list(List)",
"- del new_List[i]",
"- islands = [1]",
"- for i in islands:",
"- for j in new_List:",
"- if i in j:",
"- j = [item for item in j if item not in islands]",
"- islands.extend(j)",
"- if len(islands) < N:",
"- S += 1",
"-print(S)",
"+Uf = Unionfind(N)",
"+Flag = 0",
"+B = 0",
"+A = []",
"+Edge = [[int(i) for i in input().split()] for i in range(M)]",
"+for m in range(M):",
"+ Edge_copy = list(Edge)",
"+ del Edge_copy[m]",
"+ for e in Edge_copy:",
"+ Uf.unite(e[0] - 1, e[1] - 1)",
"+ for a in range(N):",
"+ A.append(Uf.find(a))",
"+ for n in range(N - 1):",
"+ if Uf.find(n) != Uf.find(n + 1):",
"+ Flag = 1",
"+ break",
"+ if Flag == 1:",
"+ B += 1",
"+ Flag = 0",
"+ Uf = Unionfind(N)",
"+ A = []",
"+print(B)"
] | false | 0.046701 | 0.045724 | 1.021369 | [
"s221584743",
"s434940155"
] |
u376420711 | p03073 | python | s572478482 | s376539724 | 46 | 19 | 3,632 | 3,188 | Accepted | Accepted | 58.7 | zero = "01" * 10**5
one = "10" * 10**5
s = str(eval(input()))
ans1 = 0
ans2 = 0
for i, j in zip(s, zero):
if i != j:
ans1 += 1
for i, j in zip(s, one):
if i != j:
ans2 += 1
print((min(ans1, ans2)))
| s = str(eval(input()))
ans1 = s[::2].count("0") + s[1::2].count("1")
ans2 = s[::2].count("1") + s[1::2].count("0")
print((min(ans1, ans2))) | 12 | 4 | 225 | 134 | zero = "01" * 10**5
one = "10" * 10**5
s = str(eval(input()))
ans1 = 0
ans2 = 0
for i, j in zip(s, zero):
if i != j:
ans1 += 1
for i, j in zip(s, one):
if i != j:
ans2 += 1
print((min(ans1, ans2)))
| s = str(eval(input()))
ans1 = s[::2].count("0") + s[1::2].count("1")
ans2 = s[::2].count("1") + s[1::2].count("0")
print((min(ans1, ans2)))
| false | 66.666667 | [
"-zero = \"01\" * 10**5",
"-one = \"10\" * 10**5",
"-ans1 = 0",
"-ans2 = 0",
"-for i, j in zip(s, zero):",
"- if i != j:",
"- ans1 += 1",
"-for i, j in zip(s, one):",
"- if i != j:",
"- ans2 += 1",
"+ans1 = s[::2].count(\"0\") + s[1::2].count(\"1\")",
"+ans2 = s[::2].count(\"1\") + s[1::2].count(\"0\")"
] | false | 0.03734 | 0.036986 | 1.009592 | [
"s572478482",
"s376539724"
] |
u327179339 | p02863 | python | s250319356 | s848457685 | 886 | 565 | 178,948 | 116,184 | Accepted | Accepted | 36.23 | n, T = list(map(int, input().split()))
food = []
for _ in range(n):
a, b = list(map(int, input().split()))
food.append((a, b))
dp1 = [[0]*T for _ in range(1+n)]
dp2 = [[0]*T for _ in range(1+n)]
for i in range(n):
for j in range(T):
dp1[i+1][j] = dp1[i][j]
if j - food[i][0] >= 0:
dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j-food[i][0]] + food[i][1])
for i in range(n-1, -1, -1):
for j in range(T):
dp2[i][j] = dp2[i+1][j]
if j - food[i][0] >= 0:
dp2[i][j] = max(dp2[i][j], dp2[i+1][j-food[i][0]] + food[i][1])
res = 0
for i in range(n):
for j in range(T):
res = max(res, food[i][1] + dp1[i][j] + dp2[i+1][T-1-j])
print(res) | n, t = list(map(int, input().split()))
l = []
for i in range(n):
a, b = list(map(int, input().split()))
l.append((a, b))
l.sort()
ans = 0
dp = [[0]*t for _ in range(n+1)]
for i in range(n):
cur = dp[i][t-1] + l[i][1]
ans = max(ans, cur)
for j in range(t):
dp[i+1][j] = max(dp[i+1][j], dp[i][j])
nj = j+l[i][0]
if nj < t:
dp[i+1][nj] = max(dp[i+1][nj], dp[i][j]+l[i][1])
print(ans) | 26 | 20 | 721 | 421 | n, T = list(map(int, input().split()))
food = []
for _ in range(n):
a, b = list(map(int, input().split()))
food.append((a, b))
dp1 = [[0] * T for _ in range(1 + n)]
dp2 = [[0] * T for _ in range(1 + n)]
for i in range(n):
for j in range(T):
dp1[i + 1][j] = dp1[i][j]
if j - food[i][0] >= 0:
dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j - food[i][0]] + food[i][1])
for i in range(n - 1, -1, -1):
for j in range(T):
dp2[i][j] = dp2[i + 1][j]
if j - food[i][0] >= 0:
dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - food[i][0]] + food[i][1])
res = 0
for i in range(n):
for j in range(T):
res = max(res, food[i][1] + dp1[i][j] + dp2[i + 1][T - 1 - j])
print(res)
| n, t = list(map(int, input().split()))
l = []
for i in range(n):
a, b = list(map(int, input().split()))
l.append((a, b))
l.sort()
ans = 0
dp = [[0] * t for _ in range(n + 1)]
for i in range(n):
cur = dp[i][t - 1] + l[i][1]
ans = max(ans, cur)
for j in range(t):
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
nj = j + l[i][0]
if nj < t:
dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + l[i][1])
print(ans)
| false | 23.076923 | [
"-n, T = list(map(int, input().split()))",
"-food = []",
"-for _ in range(n):",
"+n, t = list(map(int, input().split()))",
"+l = []",
"+for i in range(n):",
"- food.append((a, b))",
"-dp1 = [[0] * T for _ in range(1 + n)]",
"-dp2 = [[0] * T for _ in range(1 + n)]",
"+ l.append((a, b))",
"+l.sort()",
"+ans = 0",
"+dp = [[0] * t for _ in range(n + 1)]",
"- for j in range(T):",
"- dp1[i + 1][j] = dp1[i][j]",
"- if j - food[i][0] >= 0:",
"- dp1[i + 1][j] = max(dp1[i + 1][j], dp1[i][j - food[i][0]] + food[i][1])",
"-for i in range(n - 1, -1, -1):",
"- for j in range(T):",
"- dp2[i][j] = dp2[i + 1][j]",
"- if j - food[i][0] >= 0:",
"- dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - food[i][0]] + food[i][1])",
"-res = 0",
"-for i in range(n):",
"- for j in range(T):",
"- res = max(res, food[i][1] + dp1[i][j] + dp2[i + 1][T - 1 - j])",
"-print(res)",
"+ cur = dp[i][t - 1] + l[i][1]",
"+ ans = max(ans, cur)",
"+ for j in range(t):",
"+ dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])",
"+ nj = j + l[i][0]",
"+ if nj < t:",
"+ dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + l[i][1])",
"+print(ans)"
] | false | 0.050529 | 0.113565 | 0.444934 | [
"s250319356",
"s848457685"
] |
u332793228 | p02881 | python | s212351493 | s233774207 | 183 | 150 | 2,940 | 2,940 | Accepted | Accepted | 18.03 | n=int(eval(input()))
move=10**12
for i in range(1,int(n**0.5)+1):
if n%i==0:
move=min(move,n//i+i-2)
print(move) | n=int(eval(input()))
num_i=0
for i in range(1,int(n**0.5)+1):
if n%i==0:
num_i=i
num_j=n//num_i
print((num_i+num_j-2)) | 6 | 7 | 123 | 130 | n = int(eval(input()))
move = 10**12
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
move = min(move, n // i + i - 2)
print(move)
| n = int(eval(input()))
num_i = 0
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
num_i = i
num_j = n // num_i
print((num_i + num_j - 2))
| false | 14.285714 | [
"-move = 10**12",
"+num_i = 0",
"- move = min(move, n // i + i - 2)",
"-print(move)",
"+ num_i = i",
"+num_j = n // num_i",
"+print((num_i + num_j - 2))"
] | false | 0.039549 | 0.044213 | 0.894518 | [
"s212351493",
"s233774207"
] |
u707498674 | p02694 | python | s918766193 | s604866126 | 24 | 19 | 9,168 | 9,168 | Accepted | Accepted | 20.83 | X = int(eval(input()))
now = 100
ans = 0
while now < X:
now *= (101)
now //= 100
ans += 1
print(ans) | X = int(eval(input()))
now = 100
ans = 0
while now < X:
now += now//100
ans += 1
print(ans) | 8 | 7 | 113 | 99 | X = int(eval(input()))
now = 100
ans = 0
while now < X:
now *= 101
now //= 100
ans += 1
print(ans)
| X = int(eval(input()))
now = 100
ans = 0
while now < X:
now += now // 100
ans += 1
print(ans)
| false | 12.5 | [
"- now *= 101",
"- now //= 100",
"+ now += now // 100"
] | false | 0.044155 | 0.046852 | 0.942432 | [
"s918766193",
"s604866126"
] |
u222207357 | p03200 | python | s796166162 | s697283205 | 126 | 48 | 3,500 | 3,500 | Accepted | Accepted | 61.9 | S = eval(input())
cntB = 0
cntW = 0
ans = 0
idx = 0
while idx < len(S):
#print(idx,cntB,cntW,ans)
if S[idx] == 'B':
cntB += 1
idx += 1
else:
while idx < len(S):
if S[idx] == 'W':
cntW += 1
idx += 1
#print(idx,cntW)
else:
ans += cntB*cntW
cntW = 0
break
ans += cntB*cntW
print(ans) | S = eval(input())
cntB = 0
ans = 0
for ch in S:
if ch == 'B':
cntB += 1
else:
ans += cntB
print(ans) | 26 | 11 | 475 | 130 | S = eval(input())
cntB = 0
cntW = 0
ans = 0
idx = 0
while idx < len(S):
# print(idx,cntB,cntW,ans)
if S[idx] == "B":
cntB += 1
idx += 1
else:
while idx < len(S):
if S[idx] == "W":
cntW += 1
idx += 1
# print(idx,cntW)
else:
ans += cntB * cntW
cntW = 0
break
ans += cntB * cntW
print(ans)
| S = eval(input())
cntB = 0
ans = 0
for ch in S:
if ch == "B":
cntB += 1
else:
ans += cntB
print(ans)
| false | 57.692308 | [
"-cntW = 0",
"-idx = 0",
"-while idx < len(S):",
"- # print(idx,cntB,cntW,ans)",
"- if S[idx] == \"B\":",
"+for ch in S:",
"+ if ch == \"B\":",
"- idx += 1",
"- while idx < len(S):",
"- if S[idx] == \"W\":",
"- cntW += 1",
"- idx += 1",
"- # print(idx,cntW)",
"- else:",
"- ans += cntB * cntW",
"- cntW = 0",
"- break",
"- ans += cntB * cntW",
"+ ans += cntB"
] | false | 0.036863 | 0.061528 | 0.599125 | [
"s796166162",
"s697283205"
] |
u039864635 | p02784 | python | s120702254 | s749043390 | 45 | 41 | 13,964 | 13,964 | Accepted | Accepted | 8.89 | h, n = list(map(int, input().split()))
a = [int(x) for x in input().split()]
h -= sum(a)
if h <= 0:
print('Yes')
else:
print('No')
| def can_win_without_repeated_move(health, special_moves_damages) -> str:
"""
Given a monster's health and a number of special moves with differ damages,
can we deplete the monster's health without repeating the same move twice?
:param health: int
:param special_moves_damages: list[int]
:return: str
"""
return 'Yes' if health - sum(special_moves_damages) <= 0 else 'No'
if __name__ == '__main__':
print((can_win_without_repeated_move(list(map(int, input().split()))[0], list(map(int, input().split())))))
| 9 | 13 | 143 | 556 | h, n = list(map(int, input().split()))
a = [int(x) for x in input().split()]
h -= sum(a)
if h <= 0:
print("Yes")
else:
print("No")
| def can_win_without_repeated_move(health, special_moves_damages) -> str:
"""
Given a monster's health and a number of special moves with differ damages,
can we deplete the monster's health without repeating the same move twice?
:param health: int
:param special_moves_damages: list[int]
:return: str
"""
return "Yes" if health - sum(special_moves_damages) <= 0 else "No"
if __name__ == "__main__":
print(
(
can_win_without_repeated_move(
list(map(int, input().split()))[0], list(map(int, input().split()))
)
)
)
| false | 30.769231 | [
"-h, n = list(map(int, input().split()))",
"-a = [int(x) for x in input().split()]",
"-h -= sum(a)",
"-if h <= 0:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+def can_win_without_repeated_move(health, special_moves_damages) -> str:",
"+ \"\"\"",
"+ Given a monster's health and a number of special moves with differ damages,",
"+ can we deplete the monster's health without repeating the same move twice?",
"+ :param health: int",
"+ :param special_moves_damages: list[int]",
"+ :return: str",
"+ \"\"\"",
"+ return \"Yes\" if health - sum(special_moves_damages) <= 0 else \"No\"",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ print(",
"+ (",
"+ can_win_without_repeated_move(",
"+ list(map(int, input().split()))[0], list(map(int, input().split()))",
"+ )",
"+ )",
"+ )"
] | false | 0.076519 | 0.037698 | 2.029809 | [
"s120702254",
"s749043390"
] |
u476199965 | p03355 | python | s457499879 | s049766447 | 89 | 66 | 6,972 | 3,060 | Accepted | Accepted | 25.84 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
s = S()
k = I()
n = len(s)
res = []
for i in range(n):
for j in range(i,n)[0:5]:
s1 = s[i:j+1]
if s1 not in res:
for m in range(len(res)):
if s1 < res[m]:
res.insert(m, s1)
break
res.append(s1)
res = res[0:k]
print(res[-1])
|
s = eval(input())
k = int(eval(input()))
n = len(s)
res = []
for i in range(n):
for j in range(i,n)[0:5]:
s1 = s[i:j+1]
if s1 not in res:
for m in range(len(res)):
if s1 < res[m]:
res.insert(m, s1)
break
res.append(s1)
res = res[0:k]
print((res[-1]))
| 36 | 19 | 1,041 | 367 | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0, -1), (1, 0), (0, 1), (-1, 0)]
ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)]
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def LI_():
return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF():
return [float(x) for x in sys.stdin.readline().split()]
def LS():
return sys.stdin.readline().split()
def I():
return int(sys.stdin.readline())
def F():
return float(sys.stdin.readline())
def S():
return input()
def pf(s):
return print(s, flush=True)
s = S()
k = I()
n = len(s)
res = []
for i in range(n):
for j in range(i, n)[0:5]:
s1 = s[i : j + 1]
if s1 not in res:
for m in range(len(res)):
if s1 < res[m]:
res.insert(m, s1)
break
res.append(s1)
res = res[0:k]
print(res[-1])
| s = eval(input())
k = int(eval(input()))
n = len(s)
res = []
for i in range(n):
for j in range(i, n)[0:5]:
s1 = s[i : j + 1]
if s1 not in res:
for m in range(len(res)):
if s1 < res[m]:
res.insert(m, s1)
break
res.append(s1)
res = res[0:k]
print((res[-1]))
| false | 47.222222 | [
"-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools",
"-",
"-sys.setrecursionlimit(10**7)",
"-inf = 10**20",
"-eps = 1.0 / 10**10",
"-mod = 998244353",
"-dd = [(0, -1), (1, 0), (0, 1), (-1, 0)]",
"-ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)]",
"-",
"-",
"-def LI():",
"- return [int(x) for x in sys.stdin.readline().split()]",
"-",
"-",
"-def LI_():",
"- return [int(x) - 1 for x in sys.stdin.readline().split()]",
"-",
"-",
"-def LF():",
"- return [float(x) for x in sys.stdin.readline().split()]",
"-",
"-",
"-def LS():",
"- return sys.stdin.readline().split()",
"-",
"-",
"-def I():",
"- return int(sys.stdin.readline())",
"-",
"-",
"-def F():",
"- return float(sys.stdin.readline())",
"-",
"-",
"-def S():",
"- return input()",
"-",
"-",
"-def pf(s):",
"- return print(s, flush=True)",
"-",
"-",
"-s = S()",
"-k = I()",
"+s = eval(input())",
"+k = int(eval(input()))",
"-print(res[-1])",
"+print((res[-1]))"
] | false | 0.04081 | 0.040687 | 1.003024 | [
"s457499879",
"s049766447"
] |
u761320129 | p03409 | python | s509262397 | s791132478 | 25 | 20 | 3,064 | 3,188 | Accepted | Accepted | 20 | N = int(eval(input()))
src = [tuple(map(int,input().split())) for i in range(2*N)]
es = [[] for i in range(2*N)]
for i,(x1,y1) in enumerate(src[:N]):
for j,(x2,y2) in enumerate(src[N:]):
if x1 < x2 and y1 < y2:
es[i].append(j+N)
es[j+N].append(i)
used = [False] * (2*N)
match = [-1] * (2*N)
def _dfs(v):
global used, match
used[v] = True
for u in es[v]:
w = match[u]
if w < 0 or not used[w] and _dfs(w):
match[v] = u
match[u] = v
return True
return False
def bipartite_matching():
global used, match
ret = 0
for v in range(2*N):
if match[v] < 0:
used = [False] * (2*N)
if _dfs(v):
ret += 1
return ret
print((bipartite_matching())) | N = int(eval(input()))
rs = [tuple(map(int,input().split())) for i in range(N)]
bs = [tuple(map(int,input().split())) for i in range(N)]
bs.sort()
rs.sort(key=lambda x:-x[1])
removed = [0]*N
ans = 0
for bx,by in bs:
for ri in range(N):
if removed[ri]: continue
rx,ry = rs[ri]
if rx < bx and ry < by:
removed[ri] = 1
ans += 1
break
print(ans) | 34 | 18 | 827 | 418 | N = int(eval(input()))
src = [tuple(map(int, input().split())) for i in range(2 * N)]
es = [[] for i in range(2 * N)]
for i, (x1, y1) in enumerate(src[:N]):
for j, (x2, y2) in enumerate(src[N:]):
if x1 < x2 and y1 < y2:
es[i].append(j + N)
es[j + N].append(i)
used = [False] * (2 * N)
match = [-1] * (2 * N)
def _dfs(v):
global used, match
used[v] = True
for u in es[v]:
w = match[u]
if w < 0 or not used[w] and _dfs(w):
match[v] = u
match[u] = v
return True
return False
def bipartite_matching():
global used, match
ret = 0
for v in range(2 * N):
if match[v] < 0:
used = [False] * (2 * N)
if _dfs(v):
ret += 1
return ret
print((bipartite_matching()))
| N = int(eval(input()))
rs = [tuple(map(int, input().split())) for i in range(N)]
bs = [tuple(map(int, input().split())) for i in range(N)]
bs.sort()
rs.sort(key=lambda x: -x[1])
removed = [0] * N
ans = 0
for bx, by in bs:
for ri in range(N):
if removed[ri]:
continue
rx, ry = rs[ri]
if rx < bx and ry < by:
removed[ri] = 1
ans += 1
break
print(ans)
| false | 47.058824 | [
"-src = [tuple(map(int, input().split())) for i in range(2 * N)]",
"-es = [[] for i in range(2 * N)]",
"-for i, (x1, y1) in enumerate(src[:N]):",
"- for j, (x2, y2) in enumerate(src[N:]):",
"- if x1 < x2 and y1 < y2:",
"- es[i].append(j + N)",
"- es[j + N].append(i)",
"-used = [False] * (2 * N)",
"-match = [-1] * (2 * N)",
"-",
"-",
"-def _dfs(v):",
"- global used, match",
"- used[v] = True",
"- for u in es[v]:",
"- w = match[u]",
"- if w < 0 or not used[w] and _dfs(w):",
"- match[v] = u",
"- match[u] = v",
"- return True",
"- return False",
"-",
"-",
"-def bipartite_matching():",
"- global used, match",
"- ret = 0",
"- for v in range(2 * N):",
"- if match[v] < 0:",
"- used = [False] * (2 * N)",
"- if _dfs(v):",
"- ret += 1",
"- return ret",
"-",
"-",
"-print((bipartite_matching()))",
"+rs = [tuple(map(int, input().split())) for i in range(N)]",
"+bs = [tuple(map(int, input().split())) for i in range(N)]",
"+bs.sort()",
"+rs.sort(key=lambda x: -x[1])",
"+removed = [0] * N",
"+ans = 0",
"+for bx, by in bs:",
"+ for ri in range(N):",
"+ if removed[ri]:",
"+ continue",
"+ rx, ry = rs[ri]",
"+ if rx < bx and ry < by:",
"+ removed[ri] = 1",
"+ ans += 1",
"+ break",
"+print(ans)"
] | false | 0.037974 | 0.038102 | 0.996642 | [
"s509262397",
"s791132478"
] |
u021019433 | p02574 | python | s081440929 | s334830719 | 729 | 654 | 211,732 | 179,224 | Accepted | Accepted | 10.29 | import math
eval(input())
a = *list(map(int, input().split())),
N = max(a) + 1
spf = [*list(range(N))]
i = 2
while i * i < N:
if spf[i] == i:
for j in range(i * i, N, i):
if spf[j] == j:
spf[j] = i
i += 1
r = 'pairwise'
d = None
u = set()
for x in a:
d = math.gcd(d or x, x)
s = set()
while x > 1:
p = spf[x]
if p in u:
r = 'setwise'
s.add(p)
x //= p
u |= s
print(((r, 'not')[d > 1], 'coprime'))
| import math
N = 1000001
spf = [*list(range(N))]
i = 2
while i * i < N:
if spf[i] == i:
for j in range(i * i, N, i):
if spf[j] == j:
spf[j] = i
i += 1
r = 'pairwise'
eval(input())
d = None
u = set()
for x in map(int, input().split()):
d = math.gcd(d or x, x)
s = set()
while x > 1:
p = spf[x]
if p in u:
r = 'setwise'
s.add(p)
x //= p
u |= s
print(((r, 'not')[d > 1], 'coprime'))
| 31 | 29 | 476 | 454 | import math
eval(input())
a = (*list(map(int, input().split())),)
N = max(a) + 1
spf = [*list(range(N))]
i = 2
while i * i < N:
if spf[i] == i:
for j in range(i * i, N, i):
if spf[j] == j:
spf[j] = i
i += 1
r = "pairwise"
d = None
u = set()
for x in a:
d = math.gcd(d or x, x)
s = set()
while x > 1:
p = spf[x]
if p in u:
r = "setwise"
s.add(p)
x //= p
u |= s
print(((r, "not")[d > 1], "coprime"))
| import math
N = 1000001
spf = [*list(range(N))]
i = 2
while i * i < N:
if spf[i] == i:
for j in range(i * i, N, i):
if spf[j] == j:
spf[j] = i
i += 1
r = "pairwise"
eval(input())
d = None
u = set()
for x in map(int, input().split()):
d = math.gcd(d or x, x)
s = set()
while x > 1:
p = spf[x]
if p in u:
r = "setwise"
s.add(p)
x //= p
u |= s
print(((r, "not")[d > 1], "coprime"))
| false | 6.451613 | [
"-eval(input())",
"-a = (*list(map(int, input().split())),)",
"-N = max(a) + 1",
"+N = 1000001",
"+eval(input())",
"-for x in a:",
"+for x in map(int, input().split()):"
] | false | 0.040071 | 1.189971 | 0.033674 | [
"s081440929",
"s334830719"
] |
u173148629 | p02820 | python | s760286174 | s855483968 | 128 | 63 | 4,084 | 4,084 | Accepted | Accepted | 50.78 | N,K=list(map(int,input().split()))
R,S,P=list(map(int,input().split())) #RSP グーチョキパー
T=list(eval(input()))
c=0
def jan(a):
if a=="r":
return P
elif a=="s":
return R
elif a=="p":
return S
else:
return 0
for i in range(K,N):
if T[i-K]==T[i]:
T[i]="o"
for i in range(1,K+1): #modK
for j in range(N//K+1):
if i+K*j>N:
continue
c+=jan(T[i+K*j-1])
print(c) | N,K=list(map(int,input().split()))
R,S,P=list(map(int,input().split())) #RSP グーチョキパー
T=list(eval(input()))
c=0
def jan(a):
if a=="r":
return P
elif a=="s":
return R
elif a=="p":
return S
else:
return 0
for i in range(K,N):
if T[i-K]==T[i]:
T[i]="o"
for i in T:
c+=jan(i)
print(c) | 27 | 24 | 455 | 353 | N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split())) # RSP グーチョキパー
T = list(eval(input()))
c = 0
def jan(a):
if a == "r":
return P
elif a == "s":
return R
elif a == "p":
return S
else:
return 0
for i in range(K, N):
if T[i - K] == T[i]:
T[i] = "o"
for i in range(1, K + 1): # modK
for j in range(N // K + 1):
if i + K * j > N:
continue
c += jan(T[i + K * j - 1])
print(c)
| N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split())) # RSP グーチョキパー
T = list(eval(input()))
c = 0
def jan(a):
if a == "r":
return P
elif a == "s":
return R
elif a == "p":
return S
else:
return 0
for i in range(K, N):
if T[i - K] == T[i]:
T[i] = "o"
for i in T:
c += jan(i)
print(c)
| false | 11.111111 | [
"-for i in range(1, K + 1): # modK",
"- for j in range(N // K + 1):",
"- if i + K * j > N:",
"- continue",
"- c += jan(T[i + K * j - 1])",
"+for i in T:",
"+ c += jan(i)"
] | false | 0.060041 | 0.045334 | 1.324406 | [
"s760286174",
"s855483968"
] |
u056358163 | p02819 | python | s184005503 | s583935544 | 22 | 18 | 3,060 | 3,060 | Accepted | Accepted | 18.18 | X = int(eval(input()))
def is_prime(x):
if x == 2:
return True
if x % 2 == 0:
return False
else:
for i in range(3, x, 2):
if x % i == 0:
return False
return True
a = X
if (X % 2 == 0) & (X > 2):
a += 1
while 1:
if is_prime(a):
print(a)
break
else:
a += 2
| import math
X = int(eval(input()))
def is_prime(x):
if x == 2:
return True
if x % 2 == 0:
return False
else:
for i in range(3, int(math.sqrt(x))+1, 2):
if x % i == 0:
return False
return True
a = X
if (X % 2 == 0) & (X > 2):
a += 1
while 1:
if is_prime(a):
print(a)
break
else:
a += 2
| 23 | 24 | 304 | 335 | X = int(eval(input()))
def is_prime(x):
if x == 2:
return True
if x % 2 == 0:
return False
else:
for i in range(3, x, 2):
if x % i == 0:
return False
return True
a = X
if (X % 2 == 0) & (X > 2):
a += 1
while 1:
if is_prime(a):
print(a)
break
else:
a += 2
| import math
X = int(eval(input()))
def is_prime(x):
if x == 2:
return True
if x % 2 == 0:
return False
else:
for i in range(3, int(math.sqrt(x)) + 1, 2):
if x % i == 0:
return False
return True
a = X
if (X % 2 == 0) & (X > 2):
a += 1
while 1:
if is_prime(a):
print(a)
break
else:
a += 2
| false | 4.166667 | [
"+import math",
"+",
"- for i in range(3, x, 2):",
"+ for i in range(3, int(math.sqrt(x)) + 1, 2):"
] | false | 0.049598 | 0.044645 | 1.110945 | [
"s184005503",
"s583935544"
] |
u477062848 | p02684 | python | s001308622 | s848033490 | 154 | 131 | 32,384 | 32,188 | Accepted | Accepted | 14.94 | N, K = list(map(int,input().split()))
A = [0] + list(map(int,input().split()))
T = {1:1}
current_town = 1
for i in range(2,K+1):
current_town = A[current_town]
K -= 1
if current_town in T:
loop_towns = list(T.keys())[T[current_town]-1:]
print((loop_towns[K%len(loop_towns)]))
break
else:
T[current_town] = i
else:
print((A[current_town])) | N,K=list(map(int,input().split()))
A=[0]+list(map(int,input().split()))
T={1:1}
c=1
for i in range(2,K+1):
c=A[c]
K-=1
if c in T:
l = list(T.keys())[T[c]-1:]
print((l[K%len(l)]))
break
else: T[c]=i
else: print((A[c])) | 15 | 13 | 394 | 259 | N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
T = {1: 1}
current_town = 1
for i in range(2, K + 1):
current_town = A[current_town]
K -= 1
if current_town in T:
loop_towns = list(T.keys())[T[current_town] - 1 :]
print((loop_towns[K % len(loop_towns)]))
break
else:
T[current_town] = i
else:
print((A[current_town]))
| N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
T = {1: 1}
c = 1
for i in range(2, K + 1):
c = A[c]
K -= 1
if c in T:
l = list(T.keys())[T[c] - 1 :]
print((l[K % len(l)]))
break
else:
T[c] = i
else:
print((A[c]))
| false | 13.333333 | [
"-current_town = 1",
"+c = 1",
"- current_town = A[current_town]",
"+ c = A[c]",
"- if current_town in T:",
"- loop_towns = list(T.keys())[T[current_town] - 1 :]",
"- print((loop_towns[K % len(loop_towns)]))",
"+ if c in T:",
"+ l = list(T.keys())[T[c] - 1 :]",
"+ print((l[K % len(l)]))",
"- T[current_town] = i",
"+ T[c] = i",
"- print((A[current_town]))",
"+ print((A[c]))"
] | false | 0.076409 | 0.075027 | 1.018414 | [
"s001308622",
"s848033490"
] |
u174434198 | p02793 | python | s481158884 | s437807520 | 1,953 | 963 | 4,084 | 4,084 | Accepted | Accepted | 50.69 |
def gcd(a, b):
if(a < b):
a, b = b, a
if(b == 0):
return a
return gcd(b, a % b)
def lcm(a, b):
return a // gcd(a, b) * b
N = int(eval(input()))
A = list(map(int, input().split()))
l = A[0]
for a in A:
l = lcm(l, a)
ans = 0
mod = 10**9+7
for a in A:
ans += (l * pow(a, mod-2, mod))%mod
ans %= mod
print(ans)
|
def gcd(a, b):
if(a < b):
a, b = b, a
if(b == 0):
return a
return gcd(b, a % b)
def lcm(a, b):
return a // gcd(a, b) * b
N = int(eval(input()))
A = list(map(int, input().split()))
l = 1
for a in A:
l = lcm(l, a)
ans = 0
mod = 10**9+7
l %= mod
for a in A:
ans += (l * pow(a, mod-2, mod))%mod
ans %= mod
print(ans)
| 22 | 23 | 369 | 376 | def gcd(a, b):
if a < b:
a, b = b, a
if b == 0:
return a
return gcd(b, a % b)
def lcm(a, b):
return a // gcd(a, b) * b
N = int(eval(input()))
A = list(map(int, input().split()))
l = A[0]
for a in A:
l = lcm(l, a)
ans = 0
mod = 10**9 + 7
for a in A:
ans += (l * pow(a, mod - 2, mod)) % mod
ans %= mod
print(ans)
| def gcd(a, b):
if a < b:
a, b = b, a
if b == 0:
return a
return gcd(b, a % b)
def lcm(a, b):
return a // gcd(a, b) * b
N = int(eval(input()))
A = list(map(int, input().split()))
l = 1
for a in A:
l = lcm(l, a)
ans = 0
mod = 10**9 + 7
l %= mod
for a in A:
ans += (l * pow(a, mod - 2, mod)) % mod
ans %= mod
print(ans)
| false | 4.347826 | [
"-l = A[0]",
"+l = 1",
"+l %= mod"
] | false | 0.045557 | 0.084807 | 0.537187 | [
"s481158884",
"s437807520"
] |
u606045429 | p03504 | python | s902977544 | s529507729 | 252 | 227 | 36,468 | 36,468 | Accepted | Accepted | 9.92 | N, C, *STC = list(map(int, open(0).read().split()))
T = [[0] * 10 ** 5 for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
T[c][s - 1:t] = [1] * (t - s + 1)
print((max(list(map(sum, list(zip(*T))))))) | def main():
N, C, *STC = list(map(int, open(0).read().split()))
T = [[0] * 10 ** 5 for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
T[c][s - 1:t] = [1] * (t - s + 1)
print((max(list(map(sum, list(zip(*T)))))))
main() | 7 | 10 | 201 | 244 | N, C, *STC = list(map(int, open(0).read().split()))
T = [[0] * 10**5 for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
T[c][s - 1 : t] = [1] * (t - s + 1)
print((max(list(map(sum, list(zip(*T)))))))
| def main():
N, C, *STC = list(map(int, open(0).read().split()))
T = [[0] * 10**5 for _ in range(C + 1)]
for s, t, c in zip(*[iter(STC)] * 3):
T[c][s - 1 : t] = [1] * (t - s + 1)
print((max(list(map(sum, list(zip(*T)))))))
main()
| false | 30 | [
"-N, C, *STC = list(map(int, open(0).read().split()))",
"-T = [[0] * 10**5 for _ in range(C + 1)]",
"-for s, t, c in zip(*[iter(STC)] * 3):",
"- T[c][s - 1 : t] = [1] * (t - s + 1)",
"-print((max(list(map(sum, list(zip(*T)))))))",
"+def main():",
"+ N, C, *STC = list(map(int, open(0).read().split()))",
"+ T = [[0] * 10**5 for _ in range(C + 1)]",
"+ for s, t, c in zip(*[iter(STC)] * 3):",
"+ T[c][s - 1 : t] = [1] * (t - s + 1)",
"+ print((max(list(map(sum, list(zip(*T)))))))",
"+",
"+",
"+main()"
] | false | 0.174639 | 0.07819 | 2.233508 | [
"s902977544",
"s529507729"
] |
u729133443 | p03951 | python | s935954716 | s585639241 | 19 | 17 | 3,956 | 2,940 | Accepted | Accepted | 10.53 | I=input;n=i=int(I());s,t=I(),I();j=0;exec('j=max(i*(s[-i:]==t[:i]),j);i-=1;'*n);print((2*n-j)) | I=input;n=int(I());s,t=I(),I();print((2*n-max(i*(s[-i:]==t[:i])for i in range(n+1)))) | 1 | 1 | 92 | 83 | I = input
n = i = int(I())
s, t = I(), I()
j = 0
exec("j=max(i*(s[-i:]==t[:i]),j);i-=1;" * n)
print((2 * n - j))
| I = input
n = int(I())
s, t = I(), I()
print((2 * n - max(i * (s[-i:] == t[:i]) for i in range(n + 1))))
| false | 0 | [
"-n = i = int(I())",
"+n = int(I())",
"-j = 0",
"-exec(\"j=max(i*(s[-i:]==t[:i]),j);i-=1;\" * n)",
"-print((2 * n - j))",
"+print((2 * n - max(i * (s[-i:] == t[:i]) for i in range(n + 1))))"
] | false | 0.036133 | 0.049207 | 0.7343 | [
"s935954716",
"s585639241"
] |
u850491413 | p03045 | python | s323984612 | s386098104 | 624 | 495 | 118,620 | 53,040 | Accepted | Accepted | 20.67 |
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math
N, M = list(map(int, input().split()))
XYZ = []
for i in range(M):
XYZ.append(list(map(int, input().split())))
renketu = [dict() for i in range(N)]
for i in range(N):
renketu[i]["iro"] = -1
renketu[i]["eda"] = []
for i in range(M):
renketu[XYZ[i][0] - 1]["eda"].append([XYZ[i][0], XYZ[i][1]])
renketu[XYZ[i][1] - 1]["eda"].append([XYZ[i][1], XYZ[i][0]])
num = 0
for i in range(N):
if renketu[i]['iro'] == -1:
num += 1
stack = [i]
# print(rest, num)
renketu[i]['iro'] = num
while len(stack) > 0:
node = stack.pop()
for edge in renketu[node]["eda"]:
if renketu[edge[1] - 1]["iro"] == -1:
renketu[edge[1] - 1]["iro"] = num
stack.append(edge[1] - 1)
print(num) |
import sys
def input():
return sys.stdin.readline().strip()
N, M = list(map(int, input().split()))
class Union_Find():
def __init__(self, n):
self.union = [i for i in range(n)]
self.level = [0 for i in range(n)]
self.num = n
def root(self, i, mode=0):
keiro = [i]
ans = i
while ans != self.union[ans]:
ans = self.union[ans]
keiro.append(ans)
if mode == 0:
return ans
else:
return ans, keiro
def unite(self, i, j):
root_i, list_i = self.root(i, 1)
root_j, list_j = self.root(j, 1)
if root_i != root_j:
self.num -= 1
if self.level[root_i] < self.level[root_j]:
self.level[root_j] = max(self.level[root_i] + 1, self.level[root_j])
for node in list_i:
self.union[node] = root_j
else:
self.level[root_i] = max(self.level[root_j] + 1, self.level[root_i])
for node in list_j:
self.union[node] = root_i
union = Union_Find(N)
for i in range(M):
X, Y, Z = list(map(int, input().split()))
union.unite(X - 1, Y - 1)
print((union.num)) | 39 | 47 | 885 | 1,051 | import sys
from collections import deque, defaultdict
import copy
import bisect
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
import math
N, M = list(map(int, input().split()))
XYZ = []
for i in range(M):
XYZ.append(list(map(int, input().split())))
renketu = [dict() for i in range(N)]
for i in range(N):
renketu[i]["iro"] = -1
renketu[i]["eda"] = []
for i in range(M):
renketu[XYZ[i][0] - 1]["eda"].append([XYZ[i][0], XYZ[i][1]])
renketu[XYZ[i][1] - 1]["eda"].append([XYZ[i][1], XYZ[i][0]])
num = 0
for i in range(N):
if renketu[i]["iro"] == -1:
num += 1
stack = [i]
# print(rest, num)
renketu[i]["iro"] = num
while len(stack) > 0:
node = stack.pop()
for edge in renketu[node]["eda"]:
if renketu[edge[1] - 1]["iro"] == -1:
renketu[edge[1] - 1]["iro"] = num
stack.append(edge[1] - 1)
print(num)
| import sys
def input():
return sys.stdin.readline().strip()
N, M = list(map(int, input().split()))
class Union_Find:
def __init__(self, n):
self.union = [i for i in range(n)]
self.level = [0 for i in range(n)]
self.num = n
def root(self, i, mode=0):
keiro = [i]
ans = i
while ans != self.union[ans]:
ans = self.union[ans]
keiro.append(ans)
if mode == 0:
return ans
else:
return ans, keiro
def unite(self, i, j):
root_i, list_i = self.root(i, 1)
root_j, list_j = self.root(j, 1)
if root_i != root_j:
self.num -= 1
if self.level[root_i] < self.level[root_j]:
self.level[root_j] = max(self.level[root_i] + 1, self.level[root_j])
for node in list_i:
self.union[node] = root_j
else:
self.level[root_i] = max(self.level[root_j] + 1, self.level[root_i])
for node in list_j:
self.union[node] = root_i
union = Union_Find(N)
for i in range(M):
X, Y, Z = list(map(int, input().split()))
union.unite(X - 1, Y - 1)
print((union.num))
| false | 17.021277 | [
"-from collections import deque, defaultdict",
"-import copy",
"-import bisect",
"-input = sys.stdin.readline",
"-sys.setrecursionlimit(10**9)",
"-import math",
"+",
"+def input():",
"+ return sys.stdin.readline().strip()",
"+",
"-XYZ = []",
"+",
"+",
"+class Union_Find:",
"+ def __init__(self, n):",
"+ self.union = [i for i in range(n)]",
"+ self.level = [0 for i in range(n)]",
"+ self.num = n",
"+",
"+ def root(self, i, mode=0):",
"+ keiro = [i]",
"+ ans = i",
"+ while ans != self.union[ans]:",
"+ ans = self.union[ans]",
"+ keiro.append(ans)",
"+ if mode == 0:",
"+ return ans",
"+ else:",
"+ return ans, keiro",
"+",
"+ def unite(self, i, j):",
"+ root_i, list_i = self.root(i, 1)",
"+ root_j, list_j = self.root(j, 1)",
"+ if root_i != root_j:",
"+ self.num -= 1",
"+ if self.level[root_i] < self.level[root_j]:",
"+ self.level[root_j] = max(self.level[root_i] + 1, self.level[root_j])",
"+ for node in list_i:",
"+ self.union[node] = root_j",
"+ else:",
"+ self.level[root_i] = max(self.level[root_j] + 1, self.level[root_i])",
"+ for node in list_j:",
"+ self.union[node] = root_i",
"+",
"+",
"+union = Union_Find(N)",
"- XYZ.append(list(map(int, input().split())))",
"-renketu = [dict() for i in range(N)]",
"-for i in range(N):",
"- renketu[i][\"iro\"] = -1",
"- renketu[i][\"eda\"] = []",
"-for i in range(M):",
"- renketu[XYZ[i][0] - 1][\"eda\"].append([XYZ[i][0], XYZ[i][1]])",
"- renketu[XYZ[i][1] - 1][\"eda\"].append([XYZ[i][1], XYZ[i][0]])",
"-num = 0",
"-for i in range(N):",
"- if renketu[i][\"iro\"] == -1:",
"- num += 1",
"- stack = [i]",
"- # print(rest, num)",
"- renketu[i][\"iro\"] = num",
"- while len(stack) > 0:",
"- node = stack.pop()",
"- for edge in renketu[node][\"eda\"]:",
"- if renketu[edge[1] - 1][\"iro\"] == -1:",
"- renketu[edge[1] - 1][\"iro\"] = num",
"- stack.append(edge[1] - 1)",
"-print(num)",
"+ X, Y, Z = list(map(int, input().split()))",
"+ union.unite(X - 1, Y - 1)",
"+print((union.num))"
] | false | 0.160073 | 0.087516 | 1.829077 | [
"s323984612",
"s386098104"
] |
u670180528 | p03660 | python | s630902576 | s517147760 | 493 | 450 | 37,208 | 37,232 | Accepted | Accepted | 8.72 | from collections import deque
n,*L=list(map(int,open(0).read().split()))
G=[[]for _ in range(n)]
db=[-1]*n
dw=[-1]*n
for a,b in zip(*[iter(L)]*2):
G[a-1]+=[b-1]
G[b-1]+=[a-1]
q=deque([(0,0)])
while q:
cur,d=q.popleft()
db[cur]=d
for nxt in G[cur]:
if db[nxt]<0:
q.append((nxt,d+1))
q=deque([(n-1,0)])
while q:
cur,d=q.popleft()
dw[cur]=d
for nxt in G[cur]:
if dw[nxt]<0:
q.append((nxt,d+1))
b=w=0
for i,j in zip(db,dw):
if i<=j:b+=1
else:w+=1
if b<=w:
print("Snuke")
else:
print("Fennec") | from collections import deque
n,*L=list(map(int,open(0).read().split()))
G=[[]for _ in range(n)]
db=[-1]*n;db[0]=0
dw=[-1]*n;dw[-1]=0
for a,b in zip(*[iter(L)]*2):
G[a-1]+=[b-1]
G[b-1]+=[a-1]
q=deque([0])
while q:
cur=q.popleft()
for nxt in G[cur]:
if db[nxt]<0:
q.append(nxt)
db[nxt]=db[cur]+1
q=deque([n-1])
while q:
cur=q.popleft()
for nxt in G[cur]:
if dw[nxt]<0:
q.append(nxt)
dw[nxt]=dw[cur]+1
b=w=0
for i,j in zip(db,dw):
if i<=j:b+=1
else:w+=1
if b<=w:print("Snuke")
else:print("Fennec") | 30 | 28 | 533 | 540 | from collections import deque
n, *L = list(map(int, open(0).read().split()))
G = [[] for _ in range(n)]
db = [-1] * n
dw = [-1] * n
for a, b in zip(*[iter(L)] * 2):
G[a - 1] += [b - 1]
G[b - 1] += [a - 1]
q = deque([(0, 0)])
while q:
cur, d = q.popleft()
db[cur] = d
for nxt in G[cur]:
if db[nxt] < 0:
q.append((nxt, d + 1))
q = deque([(n - 1, 0)])
while q:
cur, d = q.popleft()
dw[cur] = d
for nxt in G[cur]:
if dw[nxt] < 0:
q.append((nxt, d + 1))
b = w = 0
for i, j in zip(db, dw):
if i <= j:
b += 1
else:
w += 1
if b <= w:
print("Snuke")
else:
print("Fennec")
| from collections import deque
n, *L = list(map(int, open(0).read().split()))
G = [[] for _ in range(n)]
db = [-1] * n
db[0] = 0
dw = [-1] * n
dw[-1] = 0
for a, b in zip(*[iter(L)] * 2):
G[a - 1] += [b - 1]
G[b - 1] += [a - 1]
q = deque([0])
while q:
cur = q.popleft()
for nxt in G[cur]:
if db[nxt] < 0:
q.append(nxt)
db[nxt] = db[cur] + 1
q = deque([n - 1])
while q:
cur = q.popleft()
for nxt in G[cur]:
if dw[nxt] < 0:
q.append(nxt)
dw[nxt] = dw[cur] + 1
b = w = 0
for i, j in zip(db, dw):
if i <= j:
b += 1
else:
w += 1
if b <= w:
print("Snuke")
else:
print("Fennec")
| false | 6.666667 | [
"+db[0] = 0",
"+dw[-1] = 0",
"-q = deque([(0, 0)])",
"+q = deque([0])",
"- cur, d = q.popleft()",
"- db[cur] = d",
"+ cur = q.popleft()",
"- q.append((nxt, d + 1))",
"-q = deque([(n - 1, 0)])",
"+ q.append(nxt)",
"+ db[nxt] = db[cur] + 1",
"+q = deque([n - 1])",
"- cur, d = q.popleft()",
"- dw[cur] = d",
"+ cur = q.popleft()",
"- q.append((nxt, d + 1))",
"+ q.append(nxt)",
"+ dw[nxt] = dw[cur] + 1"
] | false | 0.043873 | 0.03795 | 1.156065 | [
"s630902576",
"s517147760"
] |
u260216890 | p02659 | python | s702991086 | s332880046 | 68 | 56 | 61,740 | 61,628 | Accepted | Accepted | 17.65 | a,b=input().split()
a=int(a)
b1=int(b[0])
b2=int(b[2:])
x=a*b1+(a*b2)//100
print(x)
| a,b=input().split()
a=int(a)
b=round(float(b)*100)
x=a*b//100
print(x)
| 6 | 5 | 89 | 75 | a, b = input().split()
a = int(a)
b1 = int(b[0])
b2 = int(b[2:])
x = a * b1 + (a * b2) // 100
print(x)
| a, b = input().split()
a = int(a)
b = round(float(b) * 100)
x = a * b // 100
print(x)
| false | 16.666667 | [
"-b1 = int(b[0])",
"-b2 = int(b[2:])",
"-x = a * b1 + (a * b2) // 100",
"+b = round(float(b) * 100)",
"+x = a * b // 100"
] | false | 0.036501 | 0.03602 | 1.013347 | [
"s702991086",
"s332880046"
] |
u968166680 | p03078 | python | s454787888 | s070789729 | 1,514 | 42 | 248,372 | 10,452 | Accepted | Accepted | 97.23 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
C = list(map(int, readline().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB = [a + b for a in A[:K] for b in B[:K]]
AB.sort(reverse=True)
ABC = [ab + c for ab in AB[:K] for c in C[:K]]
ABC.sort(reverse=True)
print(*ABC[:K], sep='\n')
return
if __name__ == '__main__':
main()
| import sys
from heapq import heappush, heappop
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
C = list(map(int, readline().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
ans = [0] * K
seen = {(0, 0, 0)}
for idx in range(K):
s, i, j, k = heappop(hq)
ans[idx] = -s
if i < X - 1 and (i + 1, j, k) not in seen:
heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
seen.add((i + 1, j, k))
if j < Y - 1 and (i, j + 1, k) not in seen:
heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
seen.add((i, j + 1, k))
if k < Z - 1 and (i, j, k + 1) not in seen:
heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
seen.add((i, j, k + 1))
print(*ans, sep='\n')
return
if __name__ == '__main__':
main()
| 33 | 45 | 691 | 1,214 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
C = list(map(int, readline().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
AB = [a + b for a in A[:K] for b in B[:K]]
AB.sort(reverse=True)
ABC = [ab + c for ab in AB[:K] for c in C[:K]]
ABC.sort(reverse=True)
print(*ABC[:K], sep="\n")
return
if __name__ == "__main__":
main()
| import sys
from heapq import heappush, heappop
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007
def main():
X, Y, Z, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
C = list(map(int, readline().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]
ans = [0] * K
seen = {(0, 0, 0)}
for idx in range(K):
s, i, j, k = heappop(hq)
ans[idx] = -s
if i < X - 1 and (i + 1, j, k) not in seen:
heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
seen.add((i + 1, j, k))
if j < Y - 1 and (i, j + 1, k) not in seen:
heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
seen.add((i, j + 1, k))
if k < Z - 1 and (i, j, k + 1) not in seen:
heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
seen.add((i, j, k + 1))
print(*ans, sep="\n")
return
if __name__ == "__main__":
main()
| false | 26.666667 | [
"+from heapq import heappush, heappop",
"- AB = [a + b for a in A[:K] for b in B[:K]]",
"- AB.sort(reverse=True)",
"- ABC = [ab + c for ab in AB[:K] for c in C[:K]]",
"- ABC.sort(reverse=True)",
"- print(*ABC[:K], sep=\"\\n\")",
"+ hq = [(-(A[0] + B[0] + C[0]), 0, 0, 0)]",
"+ ans = [0] * K",
"+ seen = {(0, 0, 0)}",
"+ for idx in range(K):",
"+ s, i, j, k = heappop(hq)",
"+ ans[idx] = -s",
"+ if i < X - 1 and (i + 1, j, k) not in seen:",
"+ heappush(hq, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))",
"+ seen.add((i + 1, j, k))",
"+ if j < Y - 1 and (i, j + 1, k) not in seen:",
"+ heappush(hq, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))",
"+ seen.add((i, j + 1, k))",
"+ if k < Z - 1 and (i, j, k + 1) not in seen:",
"+ heappush(hq, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))",
"+ seen.add((i, j, k + 1))",
"+ print(*ans, sep=\"\\n\")"
] | false | 0.08866 | 0.042584 | 2.082002 | [
"s454787888",
"s070789729"
] |
u775681539 | p02984 | python | s869486648 | s970727290 | 294 | 174 | 118,384 | 13,656 | Accepted | Accepted | 40.82 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
from itertools import accumulate
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
Ae = A[1::2]
Ao = A[::2]
x1 = (sum(Ao)-sum(Ae))//2
table = [0]*(N+1)
table[0] = x1
def rec(i):
if i == N:
return
table[i+1] = A[i] - table[i]
rec(i+1)
rec(0)
for i in table[:N]:
print(i*2, end=' ')
if __name__ == '__main__':
main()
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
Ae = A[1::2]
Ao = A[::2]
x1 = (sum(Ao)-sum(Ae))//2
table = [0]*(N+1)
table[0] = x1
for i in range(N):
table[i+1] = A[i] - table[i]
for i in table[:N]:
print(i*2, end=' ')
if __name__ == '__main__':
main()
| 24 | 20 | 597 | 502 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
from itertools import accumulate
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
Ae = A[1::2]
Ao = A[::2]
x1 = (sum(Ao) - sum(Ae)) // 2
table = [0] * (N + 1)
table[0] = x1
def rec(i):
if i == N:
return
table[i + 1] = A[i] - table[i]
rec(i + 1)
rec(0)
for i in table[:N]:
print(i * 2, end=" ")
if __name__ == "__main__":
main()
| import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000000)
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
Ae = A[1::2]
Ao = A[::2]
x1 = (sum(Ao) - sum(Ae)) // 2
table = [0] * (N + 1)
table[0] = x1
for i in range(N):
table[i + 1] = A[i] - table[i]
for i in table[:N]:
print(i * 2, end=" ")
if __name__ == "__main__":
main()
| false | 16.666667 | [
"-from itertools import accumulate",
"-",
"- def rec(i):",
"- if i == N:",
"- return",
"+ for i in range(N):",
"- rec(i + 1)",
"-",
"- rec(0)"
] | false | 0.05427 | 0.083049 | 0.65347 | [
"s869486648",
"s970727290"
] |
u887207211 | p03293 | python | s790741285 | s186178466 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | S = eval(input())
T = eval(input())
ans = "No"
for i in range(len(S)):
if(T == S[i:]+S[:i]):
ans = "Yes"
print(ans) | S = eval(input())
T = eval(input())
ans = "No"
for i in range(len(S)):
S[i:]+S[:i]
if(S[i:]+S[:i] == T):
ans = "Yes"
print(ans) | 7 | 9 | 115 | 132 | S = eval(input())
T = eval(input())
ans = "No"
for i in range(len(S)):
if T == S[i:] + S[:i]:
ans = "Yes"
print(ans)
| S = eval(input())
T = eval(input())
ans = "No"
for i in range(len(S)):
S[i:] + S[:i]
if S[i:] + S[:i] == T:
ans = "Yes"
print(ans)
| false | 22.222222 | [
"- if T == S[i:] + S[:i]:",
"+ S[i:] + S[:i]",
"+ if S[i:] + S[:i] == T:"
] | false | 0.041266 | 0.042202 | 0.977816 | [
"s790741285",
"s186178466"
] |
u850491413 | p03216 | python | s803360006 | s515085530 | 2,118 | 1,745 | 143,060 | 143,060 | Accepted | Accepted | 17.61 | import sys
def input():
return sys.stdin.readline().strip()
N = int(eval(input()))
S = eval(input())
Q = int(eval(input()))
k = list(map(int, input().split()))
DM_total = [(0,0,0)]
C_list = []
for i in range(N):
if S[i] == "D":
DM_total.append((DM_total[-1][0] + 1, DM_total[-1][1], DM_total[-1][2]))
elif S[i] == "M":
DM_total.append((DM_total[-1][0], DM_total[-1][1] + 1, DM_total[-1][2] + DM_total[-1][0]))
else:
DM_total.append(DM_total[-1])
if S[i] == "C":
C_list.append(i)
for q in range(Q):
ans = 0
for c in C_list:
if k[q] > c:
ans += DM_total[c + 1][2]
else:
ans += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]
ans -= DM_total[c + 1 - k[q]][0] * (DM_total[c + 1][1] - DM_total[c + 1 - k[q]][1])
print(ans) | import sys
def input():
return sys.stdin.readline().strip()
N = int(eval(input()))
S = eval(input())
Q = int(eval(input()))
k = list(map(int, input().split()))
DM_total = [(0,0,0)]
C_list = []
for i in range(N):
if S[i] == "D":
DM_total.append((DM_total[-1][0] + 1, DM_total[-1][1], DM_total[-1][2]))
elif S[i] == "M":
DM_total.append((DM_total[-1][0], DM_total[-1][1] + 1, DM_total[-1][2] + DM_total[-1][0]))
else:
DM_total.append(DM_total[-1])
if S[i] == "C":
C_list.append(i)
ans_list = [0]*Q
for q in range(Q):
for c in C_list:
if k[q] > c:
ans_list[q] += DM_total[c + 1][2]
else:
ans_list[q] += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]
ans_list[q] -= DM_total[c + 1 - k[q]][0] * (DM_total[c + 1][1] - DM_total[c + 1 - k[q]][1])
for q in range(Q):
print((ans_list[q]))
| 33 | 33 | 765 | 824 | import sys
def input():
return sys.stdin.readline().strip()
N = int(eval(input()))
S = eval(input())
Q = int(eval(input()))
k = list(map(int, input().split()))
DM_total = [(0, 0, 0)]
C_list = []
for i in range(N):
if S[i] == "D":
DM_total.append((DM_total[-1][0] + 1, DM_total[-1][1], DM_total[-1][2]))
elif S[i] == "M":
DM_total.append(
(DM_total[-1][0], DM_total[-1][1] + 1, DM_total[-1][2] + DM_total[-1][0])
)
else:
DM_total.append(DM_total[-1])
if S[i] == "C":
C_list.append(i)
for q in range(Q):
ans = 0
for c in C_list:
if k[q] > c:
ans += DM_total[c + 1][2]
else:
ans += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]
ans -= DM_total[c + 1 - k[q]][0] * (
DM_total[c + 1][1] - DM_total[c + 1 - k[q]][1]
)
print(ans)
| import sys
def input():
return sys.stdin.readline().strip()
N = int(eval(input()))
S = eval(input())
Q = int(eval(input()))
k = list(map(int, input().split()))
DM_total = [(0, 0, 0)]
C_list = []
for i in range(N):
if S[i] == "D":
DM_total.append((DM_total[-1][0] + 1, DM_total[-1][1], DM_total[-1][2]))
elif S[i] == "M":
DM_total.append(
(DM_total[-1][0], DM_total[-1][1] + 1, DM_total[-1][2] + DM_total[-1][0])
)
else:
DM_total.append(DM_total[-1])
if S[i] == "C":
C_list.append(i)
ans_list = [0] * Q
for q in range(Q):
for c in C_list:
if k[q] > c:
ans_list[q] += DM_total[c + 1][2]
else:
ans_list[q] += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]
ans_list[q] -= DM_total[c + 1 - k[q]][0] * (
DM_total[c + 1][1] - DM_total[c + 1 - k[q]][1]
)
for q in range(Q):
print((ans_list[q]))
| false | 0 | [
"+ans_list = [0] * Q",
"- ans = 0",
"- ans += DM_total[c + 1][2]",
"+ ans_list[q] += DM_total[c + 1][2]",
"- ans += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]",
"- ans -= DM_total[c + 1 - k[q]][0] * (",
"+ ans_list[q] += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]",
"+ ans_list[q] -= DM_total[c + 1 - k[q]][0] * (",
"- print(ans)",
"+for q in range(Q):",
"+ print((ans_list[q]))"
] | false | 0.049104 | 0.048864 | 1.004918 | [
"s803360006",
"s515085530"
] |
u906501980 | p03361 | python | s080405154 | s826798305 | 1,539 | 182 | 21,536 | 13,352 | Accepted | Accepted | 88.17 | import numpy as np
h, w = list(map(int, input().split()))
s = [list(eval(input())) for _ in range(h)]
s = np.array(s)
out = "Yes"
for i in range(h):
for j in range(w):
if s[i][j] == ".":
continue
if i == 0 and j == 0:
up = s[i][j]
down = s[i + 1][j]
left = s[i][j]
right = s[i][j + 1]
elif i == 0 and j == w-1:
up = s[i][j]
down = s[i + 1][j]
left = s[i][j - 1]
right = s[i][j]
elif i == h-1 and j == 0:
up = s[i - 1][j]
down = s[i][j]
left = s[i][j]
right = s[i][j + 1]
elif i == h-1 and j == w-1:
up = s[i - 1][j]
down = s[i][j]
left = s[i][j - 1]
right = s[i][j]
elif i == 0 and j != 0 and j != w-1:
up = s[i][j]
down = s[i + 1][j]
left = s[i][j - 1]
right = s[i][j + 1]
elif i == h-1 and j != 0 and j != w-1:
up = s[i - 1][j]
down = s[i][j]
left = s[i][j - 1]
right = s[i][j + 1]
elif j == 0 and i != 0 and i != h-1:
up = s[i - 1][j]
down = s[i + 1][j]
left = s[i][j]
right = s[i][j + 1]
elif j == w-1 and i != 0 and i!= h-1:
up = s[i - 1][j]
down = s[i + 1][j]
left = s[i][j - 1]
right = s[i][j]
else:
up = s[i-1][j]
down = s[i+1][j]
left = s[i][j-1]
right = s[i][j+1]
if s[i][j] != up and s[i][j] != down and s[i][j] != left and s[i][j] != right:
out = "No"
print(out)
| import numpy as np
h, w = list(map(int, input().split()))
s = np.array([list(eval(input())) for _ in range(h)])
w1, w2 = np.array(["."]*h), np.array(["."]*(w+2))
s = np.hstack((w1.reshape(len(w1),1), s))
s = np.hstack((s, w1.reshape(len(w1),1)))
s = np.vstack((w2, s))
s = np.vstack((s, w2))
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
for i in range(1, h+1, 1):
for j in range(1, w+1, 1):
now = s[i][j]
c = 0
if now == ".":
continue
for d in range(4):
x = j + dx[d]
y = i + dy[d]
if now == s[y][x]:
c += 1
if c == 0:
print("No")
exit()
print("Yes") | 57 | 24 | 1,768 | 686 | import numpy as np
h, w = list(map(int, input().split()))
s = [list(eval(input())) for _ in range(h)]
s = np.array(s)
out = "Yes"
for i in range(h):
for j in range(w):
if s[i][j] == ".":
continue
if i == 0 and j == 0:
up = s[i][j]
down = s[i + 1][j]
left = s[i][j]
right = s[i][j + 1]
elif i == 0 and j == w - 1:
up = s[i][j]
down = s[i + 1][j]
left = s[i][j - 1]
right = s[i][j]
elif i == h - 1 and j == 0:
up = s[i - 1][j]
down = s[i][j]
left = s[i][j]
right = s[i][j + 1]
elif i == h - 1 and j == w - 1:
up = s[i - 1][j]
down = s[i][j]
left = s[i][j - 1]
right = s[i][j]
elif i == 0 and j != 0 and j != w - 1:
up = s[i][j]
down = s[i + 1][j]
left = s[i][j - 1]
right = s[i][j + 1]
elif i == h - 1 and j != 0 and j != w - 1:
up = s[i - 1][j]
down = s[i][j]
left = s[i][j - 1]
right = s[i][j + 1]
elif j == 0 and i != 0 and i != h - 1:
up = s[i - 1][j]
down = s[i + 1][j]
left = s[i][j]
right = s[i][j + 1]
elif j == w - 1 and i != 0 and i != h - 1:
up = s[i - 1][j]
down = s[i + 1][j]
left = s[i][j - 1]
right = s[i][j]
else:
up = s[i - 1][j]
down = s[i + 1][j]
left = s[i][j - 1]
right = s[i][j + 1]
if s[i][j] != up and s[i][j] != down and s[i][j] != left and s[i][j] != right:
out = "No"
print(out)
| import numpy as np
h, w = list(map(int, input().split()))
s = np.array([list(eval(input())) for _ in range(h)])
w1, w2 = np.array(["."] * h), np.array(["."] * (w + 2))
s = np.hstack((w1.reshape(len(w1), 1), s))
s = np.hstack((s, w1.reshape(len(w1), 1)))
s = np.vstack((w2, s))
s = np.vstack((s, w2))
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
for i in range(1, h + 1, 1):
for j in range(1, w + 1, 1):
now = s[i][j]
c = 0
if now == ".":
continue
for d in range(4):
x = j + dx[d]
y = i + dy[d]
if now == s[y][x]:
c += 1
if c == 0:
print("No")
exit()
print("Yes")
| false | 57.894737 | [
"-s = [list(eval(input())) for _ in range(h)]",
"-s = np.array(s)",
"-out = \"Yes\"",
"-for i in range(h):",
"- for j in range(w):",
"- if s[i][j] == \".\":",
"+s = np.array([list(eval(input())) for _ in range(h)])",
"+w1, w2 = np.array([\".\"] * h), np.array([\".\"] * (w + 2))",
"+s = np.hstack((w1.reshape(len(w1), 1), s))",
"+s = np.hstack((s, w1.reshape(len(w1), 1)))",
"+s = np.vstack((w2, s))",
"+s = np.vstack((s, w2))",
"+dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]",
"+for i in range(1, h + 1, 1):",
"+ for j in range(1, w + 1, 1):",
"+ now = s[i][j]",
"+ c = 0",
"+ if now == \".\":",
"- if i == 0 and j == 0:",
"- up = s[i][j]",
"- down = s[i + 1][j]",
"- left = s[i][j]",
"- right = s[i][j + 1]",
"- elif i == 0 and j == w - 1:",
"- up = s[i][j]",
"- down = s[i + 1][j]",
"- left = s[i][j - 1]",
"- right = s[i][j]",
"- elif i == h - 1 and j == 0:",
"- up = s[i - 1][j]",
"- down = s[i][j]",
"- left = s[i][j]",
"- right = s[i][j + 1]",
"- elif i == h - 1 and j == w - 1:",
"- up = s[i - 1][j]",
"- down = s[i][j]",
"- left = s[i][j - 1]",
"- right = s[i][j]",
"- elif i == 0 and j != 0 and j != w - 1:",
"- up = s[i][j]",
"- down = s[i + 1][j]",
"- left = s[i][j - 1]",
"- right = s[i][j + 1]",
"- elif i == h - 1 and j != 0 and j != w - 1:",
"- up = s[i - 1][j]",
"- down = s[i][j]",
"- left = s[i][j - 1]",
"- right = s[i][j + 1]",
"- elif j == 0 and i != 0 and i != h - 1:",
"- up = s[i - 1][j]",
"- down = s[i + 1][j]",
"- left = s[i][j]",
"- right = s[i][j + 1]",
"- elif j == w - 1 and i != 0 and i != h - 1:",
"- up = s[i - 1][j]",
"- down = s[i + 1][j]",
"- left = s[i][j - 1]",
"- right = s[i][j]",
"- else:",
"- up = s[i - 1][j]",
"- down = s[i + 1][j]",
"- left = s[i][j - 1]",
"- right = s[i][j + 1]",
"- if s[i][j] != up and s[i][j] != down and s[i][j] != left and s[i][j] != right:",
"- out = \"No\"",
"-print(out)",
"+ for d in range(4):",
"+ x = j + dx[d]",
"+ y = i + dy[d]",
"+ if now == s[y][x]:",
"+ c += 1",
"+ if c == 0:",
"+ print(\"No\")",
"+ exit()",
"+print(\"Yes\")"
] | false | 0.525432 | 0.232604 | 2.258917 | [
"s080405154",
"s826798305"
] |
u225084815 | p03288 | python | s922067106 | s436751896 | 171 | 92 | 38,384 | 68,428 | Accepted | Accepted | 46.2 | R = int(eval(input()))
if R >= 2800:
print('AGC')
elif R >= 1200:
print('ARC')
else:
print('ABC') | import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return list(map(int,sys.stdin.readline().rstrip().split()))
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
R = I()
if R < 1200:
print('ABC')
elif R < 2800:
print('ARC')
else:
print('AGC') | 7 | 14 | 103 | 466 | R = int(eval(input()))
if R >= 2800:
print("AGC")
elif R >= 1200:
print("ARC")
else:
print("ABC")
| import bisect, collections, copy, heapq, itertools, math, string
import sys
def S():
return sys.stdin.readline().rstrip()
def M():
return list(map(int, sys.stdin.readline().rstrip().split()))
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def LS():
return list(sys.stdin.readline().rstrip().split())
R = I()
if R < 1200:
print("ABC")
elif R < 2800:
print("ARC")
else:
print("AGC")
| false | 50 | [
"-R = int(eval(input()))",
"-if R >= 2800:",
"- print(\"AGC\")",
"-elif R >= 1200:",
"+import bisect, collections, copy, heapq, itertools, math, string",
"+import sys",
"+",
"+",
"+def S():",
"+ return sys.stdin.readline().rstrip()",
"+",
"+",
"+def M():",
"+ return list(map(int, sys.stdin.readline().rstrip().split()))",
"+",
"+",
"+def I():",
"+ return int(sys.stdin.readline().rstrip())",
"+",
"+",
"+def LI():",
"+ return list(map(int, sys.stdin.readline().rstrip().split()))",
"+",
"+",
"+def LS():",
"+ return list(sys.stdin.readline().rstrip().split())",
"+",
"+",
"+R = I()",
"+if R < 1200:",
"+ print(\"ABC\")",
"+elif R < 2800:",
"- print(\"ABC\")",
"+ print(\"AGC\")"
] | false | 0.037108 | 0.037232 | 0.996675 | [
"s922067106",
"s436751896"
] |
u699089116 | p02917 | python | s657836104 | s404938403 | 161 | 71 | 38,384 | 62,032 | Accepted | Accepted | 55.9 | n = int(eval(input()))
b = list(map(int, input().split()))
a = [0] * n
a[0] = b[0]
a[-1] = b[-1]
for i in range(1, n-1):
a[i] = min(b[i], b[i - 1])
print((sum(a))) | n = int(eval(input()))
B = list(map(int, input().split()))
a = [-1] * n
for i, b in enumerate(B):
if a[i] > B[i]:
a[i] = b
a[i+1] = b
elif a[i] != -1:
a[i+1] = b
elif a[i] == -1:
a[i] = b
a[i+1] = b
print((sum(a))) | 11 | 16 | 172 | 276 | n = int(eval(input()))
b = list(map(int, input().split()))
a = [0] * n
a[0] = b[0]
a[-1] = b[-1]
for i in range(1, n - 1):
a[i] = min(b[i], b[i - 1])
print((sum(a)))
| n = int(eval(input()))
B = list(map(int, input().split()))
a = [-1] * n
for i, b in enumerate(B):
if a[i] > B[i]:
a[i] = b
a[i + 1] = b
elif a[i] != -1:
a[i + 1] = b
elif a[i] == -1:
a[i] = b
a[i + 1] = b
print((sum(a)))
| false | 31.25 | [
"-b = list(map(int, input().split()))",
"-a = [0] * n",
"-a[0] = b[0]",
"-a[-1] = b[-1]",
"-for i in range(1, n - 1):",
"- a[i] = min(b[i], b[i - 1])",
"+B = list(map(int, input().split()))",
"+a = [-1] * n",
"+for i, b in enumerate(B):",
"+ if a[i] > B[i]:",
"+ a[i] = b",
"+ a[i + 1] = b",
"+ elif a[i] != -1:",
"+ a[i + 1] = b",
"+ elif a[i] == -1:",
"+ a[i] = b",
"+ a[i + 1] = b"
] | false | 0.043806 | 0.039963 | 1.096167 | [
"s657836104",
"s404938403"
] |
u596536048 | p03145 | python | s409949537 | s518430573 | 28 | 25 | 9,048 | 9,048 | Accepted | Accepted | 10.71 | AB, BC, CA = list(map(int, input().split()))
print((int(AB * BC / 2)))
| length1, length2, length3 = list(map(int, input().split()))
area = length1 * length2 / 2
print((int(area))) | 2 | 3 | 64 | 101 | AB, BC, CA = list(map(int, input().split()))
print((int(AB * BC / 2)))
| length1, length2, length3 = list(map(int, input().split()))
area = length1 * length2 / 2
print((int(area)))
| false | 33.333333 | [
"-AB, BC, CA = list(map(int, input().split()))",
"-print((int(AB * BC / 2)))",
"+length1, length2, length3 = list(map(int, input().split()))",
"+area = length1 * length2 / 2",
"+print((int(area)))"
] | false | 0.03602 | 0.037396 | 0.963194 | [
"s409949537",
"s518430573"
] |
u261103969 | p02791 | python | s626459547 | s398923350 | 151 | 101 | 25,768 | 100,020 | Accepted | Accepted | 33.11 | n = int(eval(input()))
p = [int(i) for i in input().split()]
p_min = [p[0],] * n
for i in range(1,n):
if p_min[i-1] > p[i]:
p_min[i] = p[i]
else:
p_min[i] = p_min[i-1]
print((sum([1 for i in range(n) if p_min[i] >= p[i]]))) | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
N = int(readline())
P = list(map(int, readline().split()))
cur = N + 1
ans = 0
for x in P:
if cur > x:
ans += 1
cur = x
print(ans)
if __name__ == '__main__':
main()
| 12 | 22 | 253 | 372 | n = int(eval(input()))
p = [int(i) for i in input().split()]
p_min = [
p[0],
] * n
for i in range(1, n):
if p_min[i - 1] > p[i]:
p_min[i] = p[i]
else:
p_min[i] = p_min[i - 1]
print((sum([1 for i in range(n) if p_min[i] >= p[i]])))
| import sys
readline = sys.stdin.readline
MOD = 10**9 + 7
INF = float("INF")
sys.setrecursionlimit(10**5)
def main():
N = int(readline())
P = list(map(int, readline().split()))
cur = N + 1
ans = 0
for x in P:
if cur > x:
ans += 1
cur = x
print(ans)
if __name__ == "__main__":
main()
| false | 45.454545 | [
"-n = int(eval(input()))",
"-p = [int(i) for i in input().split()]",
"-p_min = [",
"- p[0],",
"-] * n",
"-for i in range(1, n):",
"- if p_min[i - 1] > p[i]:",
"- p_min[i] = p[i]",
"- else:",
"- p_min[i] = p_min[i - 1]",
"-print((sum([1 for i in range(n) if p_min[i] >= p[i]])))",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+MOD = 10**9 + 7",
"+INF = float(\"INF\")",
"+sys.setrecursionlimit(10**5)",
"+",
"+",
"+def main():",
"+ N = int(readline())",
"+ P = list(map(int, readline().split()))",
"+ cur = N + 1",
"+ ans = 0",
"+ for x in P:",
"+ if cur > x:",
"+ ans += 1",
"+ cur = x",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.044026 | 0.04276 | 1.029606 | [
"s626459547",
"s398923350"
] |
u416758623 | p03556 | python | s728961632 | s636388007 | 36 | 27 | 2,940 | 2,940 | Accepted | Accepted | 25 | N=int(eval(input()))
ans=1
for i in range(1,N):
if i**2<=N:
ans=i**2
else:
break
print(ans)
| n = int(eval(input()))
ans = 1
for i in range(1,n+1):
if i **2 > n:
ans = (i-1) ** 2
break
print(ans)
| 8 | 7 | 117 | 122 | N = int(eval(input()))
ans = 1
for i in range(1, N):
if i**2 <= N:
ans = i**2
else:
break
print(ans)
| n = int(eval(input()))
ans = 1
for i in range(1, n + 1):
if i**2 > n:
ans = (i - 1) ** 2
break
print(ans)
| false | 12.5 | [
"-N = int(eval(input()))",
"+n = int(eval(input()))",
"-for i in range(1, N):",
"- if i**2 <= N:",
"- ans = i**2",
"- else:",
"+for i in range(1, n + 1):",
"+ if i**2 > n:",
"+ ans = (i - 1) ** 2"
] | false | 0.047681 | 0.038504 | 1.238363 | [
"s728961632",
"s636388007"
] |
u496344397 | p03565 | python | s185289494 | s260276941 | 22 | 17 | 3,444 | 3,064 | Accepted | Accepted | 22.73 | from copy import deepcopy
S = eval(input())
T = eval(input())
answer = ''
for i in range(len(S)-len(T)+1):
found = True
if any([S[i+j] != '?' and S[i+j] != T[j] for j in range(len(T))]):
continue
tmp = deepcopy(S).replace('?', 'a')
tmp = tmp[:i] + T + tmp[i+len(T):]
if answer == '' or tmp < answer:
answer = tmp
if answer == '':
print('UNRESTORABLE')
else:
print(answer) | S = eval(input())
T = eval(input())
answer = ''
for i in range(len(S)-len(T)+1):
if any([S[i+j] != '?' and S[i+j] != T[j] for j in range(len(T))]):
continue
tmp = (S[:i] + T + S[i+len(T):]).replace('?', 'a')
if answer == '' or tmp < answer:
answer = tmp
if answer == '':
print('UNRESTORABLE')
else:
print(answer) | 19 | 15 | 424 | 353 | from copy import deepcopy
S = eval(input())
T = eval(input())
answer = ""
for i in range(len(S) - len(T) + 1):
found = True
if any([S[i + j] != "?" and S[i + j] != T[j] for j in range(len(T))]):
continue
tmp = deepcopy(S).replace("?", "a")
tmp = tmp[:i] + T + tmp[i + len(T) :]
if answer == "" or tmp < answer:
answer = tmp
if answer == "":
print("UNRESTORABLE")
else:
print(answer)
| S = eval(input())
T = eval(input())
answer = ""
for i in range(len(S) - len(T) + 1):
if any([S[i + j] != "?" and S[i + j] != T[j] for j in range(len(T))]):
continue
tmp = (S[:i] + T + S[i + len(T) :]).replace("?", "a")
if answer == "" or tmp < answer:
answer = tmp
if answer == "":
print("UNRESTORABLE")
else:
print(answer)
| false | 21.052632 | [
"-from copy import deepcopy",
"-",
"- found = True",
"- tmp = deepcopy(S).replace(\"?\", \"a\")",
"- tmp = tmp[:i] + T + tmp[i + len(T) :]",
"+ tmp = (S[:i] + T + S[i + len(T) :]).replace(\"?\", \"a\")"
] | false | 0.046495 | 0.048373 | 0.961167 | [
"s185289494",
"s260276941"
] |
u729133443 | p03208 | python | s626368253 | s187938463 | 261 | 97 | 71,612 | 14,092 | Accepted | Accepted | 62.84 | n,k,*h=list(map(int,open(0).read().split()));h.sort();print((min(h[i]-h[i-k+1]for i in range(k-1,n)))) | n,k,*h=list(map(int,open(0).read().split()));h.sort();print((min(h[i+k-1]-h[i]for i in range(n-k+1)))) | 1 | 1 | 94 | 94 | n, k, *h = list(map(int, open(0).read().split()))
h.sort()
print((min(h[i] - h[i - k + 1] for i in range(k - 1, n))))
| n, k, *h = list(map(int, open(0).read().split()))
h.sort()
print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))
| false | 0 | [
"-print((min(h[i] - h[i - k + 1] for i in range(k - 1, n))))",
"+print((min(h[i + k - 1] - h[i] for i in range(n - k + 1))))"
] | false | 0.03863 | 0.038683 | 0.998641 | [
"s626368253",
"s187938463"
] |
u207799478 | p02682 | python | s888505985 | s034937666 | 84 | 42 | 68,736 | 10,496 | Accepted | Accepted | 50 | import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not(item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n+1):
if n % i == 0:
divisor.append(i)
return divisor
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = list(map(int, input().split()))
ans = 0
if a <= k:
ans += a*1
if a > k:
ans += k*1
print(ans)
exit()
if b <= (k-a):
ans += b*0
if b > (k-a):
ans += 0*(k-a)
print(ans)
exit()
if c <= (k-a-b):
ans += c*(-1)
print(ans)
if c > (k-a-b):
ans += (-1)*(k-a-b)
print(ans)
| from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not(item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n+1):
if n % i == 0:
divisor.append(i)
return divisor
def gcd(a, b):
while(b != 0):
a, b = b, a % b
return a
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = list(map(int, input().split()))
#print(a, b, c, k)
if a >= k:
print(k)
elif a+b >= k:
print(a)
else:
print((a-(k-a-b)))
| 60 | 55 | 1,109 | 1,035 | import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2 * 10**5)
INF = 2**60
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not (item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n + 1):
if n % i == 0:
divisor.append(i)
return divisor
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = list(map(int, input().split()))
ans = 0
if a <= k:
ans += a * 1
if a > k:
ans += k * 1
print(ans)
exit()
if b <= (k - a):
ans += b * 0
if b > (k - a):
ans += 0 * (k - a)
print(ans)
exit()
if c <= (k - a - b):
ans += c * (-1)
print(ans)
if c > (k - a - b):
ans += (-1) * (k - a - b)
print(ans)
| from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy
def readints():
return list(map(int, input().split()))
def nCr(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def has_duplicates2(seq):
seen = []
for item in seq:
if not (item in seen):
seen.append(item)
return len(seq) != len(seen)
def divisor(n):
divisor = []
for i in range(1, n + 1):
if n % i == 0:
divisor.append(i)
return divisor
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, k = list(map(int, input().split()))
# print(a, b, c, k)
if a >= k:
print(k)
elif a + b >= k:
print(a)
else:
print((a - (k - a - b)))
| false | 8.333333 | [
"-import itertools",
"+from copy import deepcopy",
"+from decimal import Decimal",
"+import sys",
"+import fractions",
"-import sys",
"-",
"-sys.setrecursionlimit(2 * 10**5)",
"-INF = 2**60",
"+import itertools",
"+import copy",
"+def gcd(a, b):",
"+ while b != 0:",
"+ a, b = b, a % b",
"+ return a",
"+",
"+",
"-ans = 0",
"-if a <= k:",
"- ans += a * 1",
"-if a > k:",
"- ans += k * 1",
"- print(ans)",
"- exit()",
"-if b <= (k - a):",
"- ans += b * 0",
"-if b > (k - a):",
"- ans += 0 * (k - a)",
"- print(ans)",
"- exit()",
"-if c <= (k - a - b):",
"- ans += c * (-1)",
"- print(ans)",
"-if c > (k - a - b):",
"- ans += (-1) * (k - a - b)",
"- print(ans)",
"+# print(a, b, c, k)",
"+if a >= k:",
"+ print(k)",
"+elif a + b >= k:",
"+ print(a)",
"+else:",
"+ print((a - (k - a - b)))"
] | false | 0.047718 | 0.046813 | 1.019343 | [
"s888505985",
"s034937666"
] |
u621935300 | p03495 | python | s151469840 | s029256771 | 286 | 107 | 43,596 | 81,148 | Accepted | Accepted | 62.59 | import collections
import sys
N,K=list(map(int,input().split()))
a=[]
a=collections.Counter( list(map(int,input().split())) )
b=sorted(list(a.items()), key=lambda x:x[1])
if len(b)=="K":
print(0)
sys.exit()
else:
sum=0
for i in range(len(b)-K):
sum+=b[i][1]
else:
print(sum)
| import sys
from collections import Counter
N,K=list(map(int, sys.stdin.readline().split()))
A=list(map(int, sys.stdin.readline().split()))
C=Counter(A)
C=list(C.values())
C.sort()
print(sum(C[:-1*K])) | 16 | 8 | 288 | 194 | import collections
import sys
N, K = list(map(int, input().split()))
a = []
a = collections.Counter(list(map(int, input().split())))
b = sorted(list(a.items()), key=lambda x: x[1])
if len(b) == "K":
print(0)
sys.exit()
else:
sum = 0
for i in range(len(b) - K):
sum += b[i][1]
else:
print(sum)
| import sys
from collections import Counter
N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))
C = Counter(A)
C = list(C.values())
C.sort()
print(sum(C[: -1 * K]))
| false | 50 | [
"-import collections",
"+from collections import Counter",
"-N, K = list(map(int, input().split()))",
"-a = []",
"-a = collections.Counter(list(map(int, input().split())))",
"-b = sorted(list(a.items()), key=lambda x: x[1])",
"-if len(b) == \"K\":",
"- print(0)",
"- sys.exit()",
"-else:",
"- sum = 0",
"- for i in range(len(b) - K):",
"- sum += b[i][1]",
"- else:",
"- print(sum)",
"+N, K = list(map(int, sys.stdin.readline().split()))",
"+A = list(map(int, sys.stdin.readline().split()))",
"+C = Counter(A)",
"+C = list(C.values())",
"+C.sort()",
"+print(sum(C[: -1 * K]))"
] | false | 0.042412 | 0.034983 | 1.212346 | [
"s151469840",
"s029256771"
] |
u729133443 | p03136 | python | s152678523 | s797835890 | 165 | 11 | 38,384 | 2,568 | Accepted | Accepted | 93.33 | _,*s=list(map(int,open(0).read().split()));print(('YNeos'[sum(s)-max(s)*2<1::2])) | eval(input());s=list(map(int,input().split()));print('YNeos'[sum(s)-max(s)*2<1::2]) | 1 | 1 | 73 | 73 | _, *s = list(map(int, open(0).read().split()))
print(("YNeos"[sum(s) - max(s) * 2 < 1 :: 2]))
| eval(input())
s = list(map(int, input().split()))
print("YNeos"[sum(s) - max(s) * 2 < 1 :: 2])
| false | 0 | [
"-_, *s = list(map(int, open(0).read().split()))",
"-print((\"YNeos\"[sum(s) - max(s) * 2 < 1 :: 2]))",
"+eval(input())",
"+s = list(map(int, input().split()))",
"+print(\"YNeos\"[sum(s) - max(s) * 2 < 1 :: 2])"
] | false | 0.081997 | 0.034469 | 2.378848 | [
"s152678523",
"s797835890"
] |
u596276291 | p03805 | python | s145147215 | s988591925 | 32 | 28 | 3,316 | 3,572 | Accepted | Accepted | 12.5 | from collections import defaultdict
from itertools import permutations
def main():
N, M = list(map(int, input().split()))
graph = defaultdict(list)
for _ in range(M):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
ans = 0
for route in permutations(list(range(2, N + 1)), N - 1):
ok = True
now = 1
for node in route:
if node in graph[now]:
now = node
else:
ok = False
ans += ok
print(ans)
if __name__ == '__main__':
main()
| from collections import defaultdict
from itertools import permutations
def main():
N, M = list(map(int, input().split()))
s = set()
for _ in range(M):
a, b = list(map(int, input().split()))
s.add((a, b))
s.add((b, a))
ans = 0
for x in permutations(list(range(2, N + 1))):
now = 1
for i in range(len(x)):
if (now, x[i]) not in s:
break
now = x[i]
else:
ans += 1
print(ans)
if __name__ == '__main__':
main()
| 28 | 24 | 607 | 542 | from collections import defaultdict
from itertools import permutations
def main():
N, M = list(map(int, input().split()))
graph = defaultdict(list)
for _ in range(M):
a, b = list(map(int, input().split()))
graph[a].append(b)
graph[b].append(a)
ans = 0
for route in permutations(list(range(2, N + 1)), N - 1):
ok = True
now = 1
for node in route:
if node in graph[now]:
now = node
else:
ok = False
ans += ok
print(ans)
if __name__ == "__main__":
main()
| from collections import defaultdict
from itertools import permutations
def main():
N, M = list(map(int, input().split()))
s = set()
for _ in range(M):
a, b = list(map(int, input().split()))
s.add((a, b))
s.add((b, a))
ans = 0
for x in permutations(list(range(2, N + 1))):
now = 1
for i in range(len(x)):
if (now, x[i]) not in s:
break
now = x[i]
else:
ans += 1
print(ans)
if __name__ == "__main__":
main()
| false | 14.285714 | [
"- graph = defaultdict(list)",
"+ s = set()",
"- graph[a].append(b)",
"- graph[b].append(a)",
"+ s.add((a, b))",
"+ s.add((b, a))",
"- for route in permutations(list(range(2, N + 1)), N - 1):",
"- ok = True",
"+ for x in permutations(list(range(2, N + 1))):",
"- for node in route:",
"- if node in graph[now]:",
"- now = node",
"- else:",
"- ok = False",
"- ans += ok",
"+ for i in range(len(x)):",
"+ if (now, x[i]) not in s:",
"+ break",
"+ now = x[i]",
"+ else:",
"+ ans += 1"
] | false | 0.072475 | 0.044209 | 1.639372 | [
"s145147215",
"s988591925"
] |
u631277801 | p03353 | python | s572572761 | s843702694 | 44 | 33 | 4,548 | 4,464 | Accepted | Accepted | 25 | s = eval(input())
N = int(eval(input()))
len_s = len(s)
sub_set = set()
for start in range(len_s):
k = 1
while k <= min(len_s-start, N):
sub_set.add(s[start:start+k])
k += 1
sub_list = list(sub_set)
sub_list.sort()
print((sub_list[N-1])) | s = eval(input())
K = int(eval(input()))
len_s = len(s)
sub_set = set()
for k in range(1,6):
for i in range(len_s-k+1):
sub_set.add(s[i:i+k])
sub_list = list(sub_set)
sub_list.sort()
print((sub_list[K-1]))
| 17 | 15 | 276 | 246 | s = eval(input())
N = int(eval(input()))
len_s = len(s)
sub_set = set()
for start in range(len_s):
k = 1
while k <= min(len_s - start, N):
sub_set.add(s[start : start + k])
k += 1
sub_list = list(sub_set)
sub_list.sort()
print((sub_list[N - 1]))
| s = eval(input())
K = int(eval(input()))
len_s = len(s)
sub_set = set()
for k in range(1, 6):
for i in range(len_s - k + 1):
sub_set.add(s[i : i + k])
sub_list = list(sub_set)
sub_list.sort()
print((sub_list[K - 1]))
| false | 11.764706 | [
"-N = int(eval(input()))",
"+K = int(eval(input()))",
"-for start in range(len_s):",
"- k = 1",
"- while k <= min(len_s - start, N):",
"- sub_set.add(s[start : start + k])",
"- k += 1",
"+for k in range(1, 6):",
"+ for i in range(len_s - k + 1):",
"+ sub_set.add(s[i : i + k])",
"-print((sub_list[N - 1]))",
"+print((sub_list[K - 1]))"
] | false | 0.033897 | 0.036397 | 0.931316 | [
"s572572761",
"s843702694"
] |
u027557357 | p03325 | python | s150999155 | s055529854 | 126 | 85 | 4,148 | 10,016 | Accepted | Accepted | 32.54 | N = eval(input())
a = list(map(int,input().split()))
ans=0
for x in a:
if x%2!=0:
continue
for j in range(1,50):
if x%2**j!=0:
ans+=j-1
break
print(ans) | N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in a :
if i%2 == 0:
for j in range(i):
if i%2 == 1:
break
i = i/2
ans += 1
print((int(ans))) | 11 | 11 | 204 | 230 | N = eval(input())
a = list(map(int, input().split()))
ans = 0
for x in a:
if x % 2 != 0:
continue
for j in range(1, 50):
if x % 2**j != 0:
ans += j - 1
break
print(ans)
| N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in a:
if i % 2 == 0:
for j in range(i):
if i % 2 == 1:
break
i = i / 2
ans += 1
print((int(ans)))
| false | 0 | [
"-N = eval(input())",
"+N = int(eval(input()))",
"-for x in a:",
"- if x % 2 != 0:",
"- continue",
"- for j in range(1, 50):",
"- if x % 2**j != 0:",
"- ans += j - 1",
"- break",
"-print(ans)",
"+for i in a:",
"+ if i % 2 == 0:",
"+ for j in range(i):",
"+ if i % 2 == 1:",
"+ break",
"+ i = i / 2",
"+ ans += 1",
"+print((int(ans)))"
] | false | 0.075762 | 0.067762 | 1.118049 | [
"s150999155",
"s055529854"
] |
u353919145 | p02789 | python | s543822704 | s051660675 | 21 | 19 | 2,940 | 2,940 | Accepted | Accepted | 9.52 | s = eval(input())
a = s.split()
if len(a) != 2:
print("No")
if a[0] == a[1]:
print("Yes")
else:
print("No") | r = input ().split ()
print(("Yes" if r[0] == r[1] else "No")) | 8 | 2 | 114 | 62 | s = eval(input())
a = s.split()
if len(a) != 2:
print("No")
if a[0] == a[1]:
print("Yes")
else:
print("No")
| r = input().split()
print(("Yes" if r[0] == r[1] else "No"))
| false | 75 | [
"-s = eval(input())",
"-a = s.split()",
"-if len(a) != 2:",
"- print(\"No\")",
"-if a[0] == a[1]:",
"- print(\"Yes\")",
"-else:",
"- print(\"No\")",
"+r = input().split()",
"+print((\"Yes\" if r[0] == r[1] else \"No\"))"
] | false | 0.110026 | 0.041843 | 2.629497 | [
"s543822704",
"s051660675"
] |
u606045429 | p03738 | python | s159263446 | s780770254 | 20 | 18 | 2,940 | 3,060 | Accepted | Accepted | 10 | A, B = eval(input()), eval(input())
if len(A) > len(B):
print("GREATER")
elif len(A) < len(B):
print("LESS")
elif A > B:
print("GREATER")
elif A < B:
print("LESS")
else:
print("EQUAL")
| A, B = eval(input()), eval(input())
C = len(A) - len(B)
if C == 0 and A > B or C > 0:
print("GREATER")
elif C == 0 and A < B or C < 0:
print("LESS")
else:
print("EQUAL") | 11 | 8 | 203 | 176 | A, B = eval(input()), eval(input())
if len(A) > len(B):
print("GREATER")
elif len(A) < len(B):
print("LESS")
elif A > B:
print("GREATER")
elif A < B:
print("LESS")
else:
print("EQUAL")
| A, B = eval(input()), eval(input())
C = len(A) - len(B)
if C == 0 and A > B or C > 0:
print("GREATER")
elif C == 0 and A < B or C < 0:
print("LESS")
else:
print("EQUAL")
| false | 27.272727 | [
"-if len(A) > len(B):",
"+C = len(A) - len(B)",
"+if C == 0 and A > B or C > 0:",
"-elif len(A) < len(B):",
"- print(\"LESS\")",
"-elif A > B:",
"- print(\"GREATER\")",
"-elif A < B:",
"+elif C == 0 and A < B or C < 0:"
] | false | 0.0454 | 0.045919 | 0.98869 | [
"s159263446",
"s780770254"
] |
u609061751 | p03281 | python | s275164646 | s017401909 | 174 | 72 | 38,896 | 63,880 | Accepted | Accepted | 58.62 | N = int(eval(input()))
ans = 0
for i in range(1, N + 1, 2):
cnt = 0
for j in range(1, N + 1):
if i % j == 0:
cnt += 1
if cnt == 8:
ans += 1
print(ans) | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
n = int(eval(input()))
def num_divisors_table(n):
table = [0] * (n + 1)
for i in range(1, n + 1):
for j in range(i, n + 1, i):
table[j] += 1
return table
table = num_divisors_table(n)
ans = 0
for i in range(1, n + 1, 2):
if table[i] == 8:
ans += 1
print(ans) | 11 | 20 | 195 | 391 | N = int(eval(input()))
ans = 0
for i in range(1, N + 1, 2):
cnt = 0
for j in range(1, N + 1):
if i % j == 0:
cnt += 1
if cnt == 8:
ans += 1
print(ans)
| import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
n = int(eval(input()))
def num_divisors_table(n):
table = [0] * (n + 1)
for i in range(1, n + 1):
for j in range(i, n + 1, i):
table[j] += 1
return table
table = num_divisors_table(n)
ans = 0
for i in range(1, n + 1, 2):
if table[i] == 8:
ans += 1
print(ans)
| false | 45 | [
"-N = int(eval(input()))",
"+import sys",
"+",
"+input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")",
"+n = int(eval(input()))",
"+",
"+",
"+def num_divisors_table(n):",
"+ table = [0] * (n + 1)",
"+ for i in range(1, n + 1):",
"+ for j in range(i, n + 1, i):",
"+ table[j] += 1",
"+ return table",
"+",
"+",
"+table = num_divisors_table(n)",
"-for i in range(1, N + 1, 2):",
"- cnt = 0",
"- for j in range(1, N + 1):",
"- if i % j == 0:",
"- cnt += 1",
"- if cnt == 8:",
"+for i in range(1, n + 1, 2):",
"+ if table[i] == 8:"
] | false | 0.039222 | 0.044959 | 0.872382 | [
"s275164646",
"s017401909"
] |
u561231954 | p03364 | python | s354001920 | s308335367 | 828 | 389 | 73,856 | 27,840 | Accepted | Accepted | 53.02 | import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
def main():
N = int(eval(input()))
grid = [eval(input()) for _ in range(N)]
ans = 0
for i in range(N):
flag = True
for j in range(N):
for k in range(N):
if j == k:
continue
if grid[j][(k + i)%N] != grid[k][(j + i)%N]:
flag = False
break
if flag:
ans += N
print(ans)
if __name__ == '__main__':
main() | import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
import numpy as np
def main():
N = int(eval(input()))
grid = np.array([list(eval(input())) for _ in range(N)],'S1')
ans = 0
for i in range(N):
X = np.vstack((grid[i:,:],grid[:i,:]))
if np.all(X == X.T):
ans += N
print(ans)
if __name__ == '__main__':
main() | 24 | 18 | 552 | 395 | import sys
sys.setrecursionlimit(10000000)
MOD = 10**9 + 7
INF = 10**15
def main():
N = int(eval(input()))
grid = [eval(input()) for _ in range(N)]
ans = 0
for i in range(N):
flag = True
for j in range(N):
for k in range(N):
if j == k:
continue
if grid[j][(k + i) % N] != grid[k][(j + i) % N]:
flag = False
break
if flag:
ans += N
print(ans)
if __name__ == "__main__":
main()
| import sys
sys.setrecursionlimit(10000000)
MOD = 10**9 + 7
INF = 10**15
import numpy as np
def main():
N = int(eval(input()))
grid = np.array([list(eval(input())) for _ in range(N)], "S1")
ans = 0
for i in range(N):
X = np.vstack((grid[i:, :], grid[:i, :]))
if np.all(X == X.T):
ans += N
print(ans)
if __name__ == "__main__":
main()
| false | 25 | [
"+import numpy as np",
"- grid = [eval(input()) for _ in range(N)]",
"+ grid = np.array([list(eval(input())) for _ in range(N)], \"S1\")",
"- flag = True",
"- for j in range(N):",
"- for k in range(N):",
"- if j == k:",
"- continue",
"- if grid[j][(k + i) % N] != grid[k][(j + i) % N]:",
"- flag = False",
"- break",
"- if flag:",
"+ X = np.vstack((grid[i:, :], grid[:i, :]))",
"+ if np.all(X == X.T):"
] | false | 0.04762 | 0.266079 | 0.178969 | [
"s354001920",
"s308335367"
] |
u753803401 | p02854 | python | s451567987 | s054780126 | 283 | 254 | 80,928 | 76,016 | Accepted | Accepted | 10.25 | import sys
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
st = sum(a)
t = 0
abs_t = 10 ** 10
for i in range(n-1):
t += a[i]
st -= a[i]
abs_t = min(abs_t, abs(st - t))
print(abs_t)
if __name__ == '__main__':
solve()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
sa = sum(a)
t = 0
mt = 10 ** 20
for v in a:
t += v
mt = min(mt, abs(sa - t - t))
print(mt)
if __name__ == '__main__':
solve()
| 20 | 19 | 392 | 342 | import sys
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input().rstrip("\n"))
a = list(map(int, input().rstrip("\n").split()))
st = sum(a)
t = 0
abs_t = 10**10
for i in range(n - 1):
t += a[i]
st -= a[i]
abs_t = min(abs_t, abs(st - t))
print(abs_t)
if __name__ == "__main__":
solve()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n = int(readline())
a = list(map(int, readline().split()))
sa = sum(a)
t = 0
mt = 10**20
for v in a:
t += v
mt = min(mt, abs(sa - t - t))
print(mt)
if __name__ == "__main__":
solve()
| false | 5 | [
"- input = sys.stdin.readline",
"+ readline = sys.stdin.buffer.readline",
"- n = int(input().rstrip(\"\\n\"))",
"- a = list(map(int, input().rstrip(\"\\n\").split()))",
"- st = sum(a)",
"+ n = int(readline())",
"+ a = list(map(int, readline().split()))",
"+ sa = sum(a)",
"- abs_t = 10**10",
"- for i in range(n - 1):",
"- t += a[i]",
"- st -= a[i]",
"- abs_t = min(abs_t, abs(st - t))",
"- print(abs_t)",
"+ mt = 10**20",
"+ for v in a:",
"+ t += v",
"+ mt = min(mt, abs(sa - t - t))",
"+ print(mt)"
] | false | 0.049687 | 0.080834 | 0.61468 | [
"s451567987",
"s054780126"
] |
u977389981 | p02989 | python | s554149883 | s071995954 | 224 | 71 | 52,780 | 20,764 | Accepted | Accepted | 68.3 | N = int(eval(input()))
D = sorted([int(i) for i in input().split()])
maxK = D[N // 2]
minK = D[N // 2 - 1]
print((maxK - minK)) | n = int(eval(input()))
D = sorted([int(i) for i in input().split()])
if n % 2 == 1:
print((0))
else:
m = n // 2
print((D[m] - D[m - 1])) | 7 | 8 | 127 | 146 | N = int(eval(input()))
D = sorted([int(i) for i in input().split()])
maxK = D[N // 2]
minK = D[N // 2 - 1]
print((maxK - minK))
| n = int(eval(input()))
D = sorted([int(i) for i in input().split()])
if n % 2 == 1:
print((0))
else:
m = n // 2
print((D[m] - D[m - 1]))
| false | 12.5 | [
"-N = int(eval(input()))",
"+n = int(eval(input()))",
"-maxK = D[N // 2]",
"-minK = D[N // 2 - 1]",
"-print((maxK - minK))",
"+if n % 2 == 1:",
"+ print((0))",
"+else:",
"+ m = n // 2",
"+ print((D[m] - D[m - 1]))"
] | false | 0.06192 | 0.045448 | 1.362427 | [
"s554149883",
"s071995954"
] |
u579699847 | p03338 | python | s025308092 | s206720949 | 23 | 18 | 3,316 | 3,060 | Accepted | Accepted | 21.74 | import collections,sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
N = I()
S = S()
ans = 0
for i in range(N):
set_top = set()
set_bottom = set()
for s in collections.Counter(S[:i]):
set_top.add(s)
for s in collections.Counter(S[i:]):
set_bottom.add(s)
ans = max(ans,len(set_top&set_bottom))
print(ans)
| import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
N = I()
S = S()
ans = 0
for i in range(N):
ans = max(ans,len(set(S[:i])&set(S[i:])))
print(ans)
| 15 | 9 | 405 | 216 | import collections, sys
def S():
return sys.stdin.readline().rstrip()
def I():
return int(sys.stdin.readline().rstrip())
N = I()
S = S()
ans = 0
for i in range(N):
set_top = set()
set_bottom = set()
for s in collections.Counter(S[:i]):
set_top.add(s)
for s in collections.Counter(S[i:]):
set_bottom.add(s)
ans = max(ans, len(set_top & set_bottom))
print(ans)
| import sys
def S():
return sys.stdin.readline().rstrip()
def I():
return int(sys.stdin.readline().rstrip())
N = I()
S = S()
ans = 0
for i in range(N):
ans = max(ans, len(set(S[:i]) & set(S[i:])))
print(ans)
| false | 40 | [
"-import collections, sys",
"+import sys",
"- set_top = set()",
"- set_bottom = set()",
"- for s in collections.Counter(S[:i]):",
"- set_top.add(s)",
"- for s in collections.Counter(S[i:]):",
"- set_bottom.add(s)",
"- ans = max(ans, len(set_top & set_bottom))",
"+ ans = max(ans, len(set(S[:i]) & set(S[i:])))"
] | false | 0.047441 | 0.097434 | 0.4869 | [
"s025308092",
"s206720949"
] |
u285891772 | p03546 | python | s634233486 | s850284017 | 314 | 223 | 21,560 | 14,692 | Accepted | Accepted | 28.98 | import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]
#ワーシャルフロイド法 注意 PyPy非対応!!!!
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
graph = csr_matrix(c) #隣接行列からcsr行列をつくる
c = floyd_warshall(graph, directed=True) #無向の場合directed=True
#dist_matrixの中身はfloatになっているので注意!
#for i in range(10):
# print(c[i])
import numpy as np
#距離
def distance(p1, p2):
p1 = np.array(p1)
p2 = np.array(p2)
return np.linalg.norm(p1-p2)
ans = 0
for i in range(H):
for x in A[i]:
if x == 1 or x == -1:
continue
else:
ans += c[x][1]
print((int(ans)))
| import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]
#ワーシャルフロイド法 注意 PyPy非対応!!!!
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
graph = csr_matrix(c) #隣接行列からcsr行列をつくる
c = floyd_warshall(graph, directed=True) #無向の場合directed=True
#dist_matrixの中身はfloatになっているので注意!
#for i in range(10):
# print(c[i])
import numpy as np
#距離
def distance(p1, p2):
p1 = np.array(p1)
p2 = np.array(p2)
return np.linalg.norm(p1-p2)
ans = 0
for i in range(H):
for j in range(len(A[i])):
if A[i][j] != -1:
ans += c[A[i][j]][1]
print((int(ans)))
| 54 | 52 | 1,497 | 1,489 | import sys, re
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2
from collections import deque, defaultdict, Counter
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]
# ワーシャルフロイド法 注意 PyPy非対応!!!!
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
graph = csr_matrix(c) # 隣接行列からcsr行列をつくる
c = floyd_warshall(graph, directed=True) # 無向の場合directed=True
# dist_matrixの中身はfloatになっているので注意!
# for i in range(10):
# print(c[i])
import numpy as np
# 距離
def distance(p1, p2):
p1 = np.array(p1)
p2 = np.array(p2)
return np.linalg.norm(p1 - p2)
ans = 0
for i in range(H):
for x in A[i]:
if x == 1 or x == -1:
continue
else:
ans += c[x][1]
print((int(ans)))
| import sys, re
from math import (
ceil,
sqrt,
hypot,
factorial,
pi,
sin,
cos,
tan,
asin,
acos,
atan,
radians,
degrees,
) # , log2
from collections import deque, defaultdict, Counter
from itertools import (
accumulate,
permutations,
combinations,
combinations_with_replacement,
product,
groupby,
)
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input():
return sys.stdin.readline().strip()
def INT():
return int(eval(input()))
def MAP():
return list(map(int, input().split()))
def LIST():
return list(map(int, input().split()))
def ZIP(n):
return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]
# ワーシャルフロイド法 注意 PyPy非対応!!!!
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
graph = csr_matrix(c) # 隣接行列からcsr行列をつくる
c = floyd_warshall(graph, directed=True) # 無向の場合directed=True
# dist_matrixの中身はfloatになっているので注意!
# for i in range(10):
# print(c[i])
import numpy as np
# 距離
def distance(p1, p2):
p1 = np.array(p1)
p2 = np.array(p2)
return np.linalg.norm(p1 - p2)
ans = 0
for i in range(H):
for j in range(len(A[i])):
if A[i][j] != -1:
ans += c[A[i][j]][1]
print((int(ans)))
| false | 3.703704 | [
"- for x in A[i]:",
"- if x == 1 or x == -1:",
"- continue",
"- else:",
"- ans += c[x][1]",
"+ for j in range(len(A[i])):",
"+ if A[i][j] != -1:",
"+ ans += c[A[i][j]][1]"
] | false | 0.768361 | 0.593726 | 1.294134 | [
"s634233486",
"s850284017"
] |
u454557108 | p03805 | python | s859887379 | s332539369 | 172 | 31 | 12,436 | 3,316 | Accepted | Accepted | 81.98 | # -*- coding: utf-8 -*-
import numpy as np
n,m = list(map(int, input().split()))
graph = [[0 for i in range(n)] for j in range(n)]
graph = np.array(graph)
for i in range(m):
a,b = list(map(int, input().split()))
graph[a-1,b-1] = 1
graph[b-1,a-1] = 1
used = [False]*n
used[0] = True
def DFS(v,used):
if all(used):
return 1
ans = 0
for i in range(n):
if used[i]:
continue
if graph[i,v] == 0:
continue
used[i] = True
ans += DFS(i,used)
used[i] = False
return ans
print((DFS(0,used))) | from collections import deque
def dfs(G, visited, s, n, ans):
# すべての頂点を訪れた場合の処理
if all(visited) :
ans += 1
return ans
# 次の頂点の探索
for i in range(n) :
if visited[i] == False and (G[s][i] == 1 or G[i][s] == 1) :
visited[i] = True
ans = dfs(G, visited, i, n, ans)
visited[i] = False
return ans
# グラフGの入力
n,m = list(map(int,input().split()))
G = [[0 for i in range(n)] for j in range(n)]
for i in range(m) :
a,b = list(map(int,input().split()))
G[a-1][b-1] = 1
G[b-1][a-1] = 1
visited = [False for i in range(n)]
visited[0] = True
ans = 0
print((dfs(G, visited, 0, n, ans))) | 30 | 28 | 602 | 633 | # -*- coding: utf-8 -*-
import numpy as np
n, m = list(map(int, input().split()))
graph = [[0 for i in range(n)] for j in range(n)]
graph = np.array(graph)
for i in range(m):
a, b = list(map(int, input().split()))
graph[a - 1, b - 1] = 1
graph[b - 1, a - 1] = 1
used = [False] * n
used[0] = True
def DFS(v, used):
if all(used):
return 1
ans = 0
for i in range(n):
if used[i]:
continue
if graph[i, v] == 0:
continue
used[i] = True
ans += DFS(i, used)
used[i] = False
return ans
print((DFS(0, used)))
| from collections import deque
def dfs(G, visited, s, n, ans):
# すべての頂点を訪れた場合の処理
if all(visited):
ans += 1
return ans
# 次の頂点の探索
for i in range(n):
if visited[i] == False and (G[s][i] == 1 or G[i][s] == 1):
visited[i] = True
ans = dfs(G, visited, i, n, ans)
visited[i] = False
return ans
# グラフGの入力
n, m = list(map(int, input().split()))
G = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
a, b = list(map(int, input().split()))
G[a - 1][b - 1] = 1
G[b - 1][a - 1] = 1
visited = [False for i in range(n)]
visited[0] = True
ans = 0
print((dfs(G, visited, 0, n, ans)))
| false | 6.666667 | [
"-# -*- coding: utf-8 -*-",
"-import numpy as np",
"-",
"-n, m = list(map(int, input().split()))",
"-graph = [[0 for i in range(n)] for j in range(n)]",
"-graph = np.array(graph)",
"-for i in range(m):",
"- a, b = list(map(int, input().split()))",
"- graph[a - 1, b - 1] = 1",
"- graph[b - 1, a - 1] = 1",
"-used = [False] * n",
"-used[0] = True",
"+from collections import deque",
"-def DFS(v, used):",
"- if all(used):",
"- return 1",
"- ans = 0",
"+def dfs(G, visited, s, n, ans):",
"+ # すべての頂点を訪れた場合の処理",
"+ if all(visited):",
"+ ans += 1",
"+ return ans",
"+ # 次の頂点の探索",
"- if used[i]:",
"- continue",
"- if graph[i, v] == 0:",
"- continue",
"- used[i] = True",
"- ans += DFS(i, used)",
"- used[i] = False",
"+ if visited[i] == False and (G[s][i] == 1 or G[i][s] == 1):",
"+ visited[i] = True",
"+ ans = dfs(G, visited, i, n, ans)",
"+ visited[i] = False",
"-print((DFS(0, used)))",
"+# グラフGの入力",
"+n, m = list(map(int, input().split()))",
"+G = [[0 for i in range(n)] for j in range(n)]",
"+for i in range(m):",
"+ a, b = list(map(int, input().split()))",
"+ G[a - 1][b - 1] = 1",
"+ G[b - 1][a - 1] = 1",
"+visited = [False for i in range(n)]",
"+visited[0] = True",
"+ans = 0",
"+print((dfs(G, visited, 0, n, ans)))"
] | false | 1.006245 | 0.094498 | 10.648344 | [
"s859887379",
"s332539369"
] |
u597455618 | p03457 | python | s432002292 | s997901738 | 531 | 351 | 37,132 | 35,940 | Accepted | Accepted | 33.9 | def dif(two_lists):
return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]
n = int(eval(input()))
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
dtxy = list(map(dif, list(zip(txy, txy[1:]))))
for i in range(n):
dt, dx, dy = dtxy[i]
if dx + dy > dt or (dt - dx - dy) % 2:
print("No")
exit()
print("Yes")
| import sys
def dif(two_lists):
return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]
n = int(eval(input()))
txy = [[0, 0, 0]] + [[int(s) for s in line.split()] for line in sys.stdin]
dtxy = list(map(dif, list(zip(txy, txy[1:]))))
for i in range(n):
dt, dx, dy = dtxy[i]
if dx + dy > dt or (dt - dx - dy) % 2:
print("No")
exit()
print("Yes")
| 15 | 16 | 374 | 389 | def dif(two_lists):
return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]
n = int(eval(input()))
txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
dtxy = list(map(dif, list(zip(txy, txy[1:]))))
for i in range(n):
dt, dx, dy = dtxy[i]
if dx + dy > dt or (dt - dx - dy) % 2:
print("No")
exit()
print("Yes")
| import sys
def dif(two_lists):
return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]
n = int(eval(input()))
txy = [[0, 0, 0]] + [[int(s) for s in line.split()] for line in sys.stdin]
dtxy = list(map(dif, list(zip(txy, txy[1:]))))
for i in range(n):
dt, dx, dy = dtxy[i]
if dx + dy > dt or (dt - dx - dy) % 2:
print("No")
exit()
print("Yes")
| false | 6.25 | [
"+import sys",
"+",
"+",
"-txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]",
"+txy = [[0, 0, 0]] + [[int(s) for s in line.split()] for line in sys.stdin]"
] | false | 0.075152 | 0.054849 | 1.370162 | [
"s432002292",
"s997901738"
] |
u077291787 | p02913 | python | s605360236 | s038553937 | 83 | 74 | 11,208 | 10,120 | Accepted | Accepted | 10.84 | from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(source)
def _build(self, source: str) -> Tuple[List[int], List[int]]:
"""Compute "hash" and "mod of power of base" of interval [0, right)."""
hash_, power = [0] * (len(source) + 1), [0] * (len(source) + 1)
power[0] = 1
for i, c in enumerate(source, 1):
hash_[i] = (hash_[i - 1] * self._base + ord(c)) % self._mod
power[i] = power[i - 1] * self._base % self._mod
return hash_, power
def get_hash(self, left: int, right: int):
"""Return hash of interval [left, right)."""
return (
self._hash[right] - self._hash[left] * self._power[right - left]
) % self._mod
def abc141_e():
# https://atcoder.jp/contests/abc141/tasks/abc141_e
N = int(eval(input()))
S = input().rstrip()
rh = RollingHash(S)
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
flg = False
memo = set()
for i in range(N - 2 * mid + 1):
memo.add(rh.get_hash(i, i + mid))
if rh.get_hash(i + mid, i + 2 * mid) in memo:
flg = True
break
if flg:
ok = mid # next mid will be longer
else:
ng = mid # next mid will be shorter
print(ok) # max length of substrings appeared twice or more
if __name__ == "__main__":
abc141_e()
| class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7) -> None:
self._base = base
self._mod = mod
self._hash = [0] * (len(source) + 1)
self._power = [0] * (len(source) + 1)
self._power[0] = 1
for i, c in enumerate(source, 1):
self._hash[i] = (self._hash[i - 1] * self._base + ord(c)) % self._mod
self._power[i] = self._power[i - 1] * self._base % self._mod
def get_hash(self, left: int, right: int) -> int:
"""Return hash of interval [left, right)."""
return (
self._hash[right] - self._hash[left] * self._power[right - left]
) % self._mod
def abc141_e():
# https://atcoder.jp/contests/abc141/tasks/abc141_e
N = int(eval(input()))
S = input().rstrip()
rh = RollingHash(S)
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
flg = False
memo = set()
for i in range(N - 2 * mid + 1):
memo.add(rh.get_hash(i, i + mid))
if rh.get_hash(i + mid, i + 2 * mid) in memo:
flg = True
break
if flg:
ok = mid # next mid will be longer
else:
ng = mid # next mid will be shorter
print(ok) # max length of substrings appeared twice or more
if __name__ == "__main__":
abc141_e()
| 55 | 49 | 1,723 | 1,518 | from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10**9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(source)
def _build(self, source: str) -> Tuple[List[int], List[int]]:
"""Compute "hash" and "mod of power of base" of interval [0, right)."""
hash_, power = [0] * (len(source) + 1), [0] * (len(source) + 1)
power[0] = 1
for i, c in enumerate(source, 1):
hash_[i] = (hash_[i - 1] * self._base + ord(c)) % self._mod
power[i] = power[i - 1] * self._base % self._mod
return hash_, power
def get_hash(self, left: int, right: int):
"""Return hash of interval [left, right)."""
return (
self._hash[right] - self._hash[left] * self._power[right - left]
) % self._mod
def abc141_e():
# https://atcoder.jp/contests/abc141/tasks/abc141_e
N = int(eval(input()))
S = input().rstrip()
rh = RollingHash(S)
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
flg = False
memo = set()
for i in range(N - 2 * mid + 1):
memo.add(rh.get_hash(i, i + mid))
if rh.get_hash(i + mid, i + 2 * mid) in memo:
flg = True
break
if flg:
ok = mid # next mid will be longer
else:
ng = mid # next mid will be shorter
print(ok) # max length of substrings appeared twice or more
if __name__ == "__main__":
abc141_e()
| class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10**9 + 7) -> None:
self._base = base
self._mod = mod
self._hash = [0] * (len(source) + 1)
self._power = [0] * (len(source) + 1)
self._power[0] = 1
for i, c in enumerate(source, 1):
self._hash[i] = (self._hash[i - 1] * self._base + ord(c)) % self._mod
self._power[i] = self._power[i - 1] * self._base % self._mod
def get_hash(self, left: int, right: int) -> int:
"""Return hash of interval [left, right)."""
return (
self._hash[right] - self._hash[left] * self._power[right - left]
) % self._mod
def abc141_e():
# https://atcoder.jp/contests/abc141/tasks/abc141_e
N = int(eval(input()))
S = input().rstrip()
rh = RollingHash(S)
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
flg = False
memo = set()
for i in range(N - 2 * mid + 1):
memo.add(rh.get_hash(i, i + mid))
if rh.get_hash(i + mid, i + 2 * mid) in memo:
flg = True
break
if flg:
ok = mid # next mid will be longer
else:
ng = mid # next mid will be shorter
print(ok) # max length of substrings appeared twice or more
if __name__ == "__main__":
abc141_e()
| false | 10.909091 | [
"-from typing import List, Tuple",
"-",
"-",
"- def __init__(self, source: str, base: int = 1007, mod: int = 10**9 + 7):",
"+ def __init__(self, source: str, base: int = 1007, mod: int = 10**9 + 7) -> None:",
"- self._hash, self._power = self._build(source)",
"+ self._hash = [0] * (len(source) + 1)",
"+ self._power = [0] * (len(source) + 1)",
"+ self._power[0] = 1",
"+ for i, c in enumerate(source, 1):",
"+ self._hash[i] = (self._hash[i - 1] * self._base + ord(c)) % self._mod",
"+ self._power[i] = self._power[i - 1] * self._base % self._mod",
"- def _build(self, source: str) -> Tuple[List[int], List[int]]:",
"- \"\"\"Compute \"hash\" and \"mod of power of base\" of interval [0, right).\"\"\"",
"- hash_, power = [0] * (len(source) + 1), [0] * (len(source) + 1)",
"- power[0] = 1",
"- for i, c in enumerate(source, 1):",
"- hash_[i] = (hash_[i - 1] * self._base + ord(c)) % self._mod",
"- power[i] = power[i - 1] * self._base % self._mod",
"- return hash_, power",
"-",
"- def get_hash(self, left: int, right: int):",
"+ def get_hash(self, left: int, right: int) -> int:"
] | false | 0.081822 | 0.080907 | 1.011302 | [
"s605360236",
"s038553937"
] |
u562935282 | p03331 | python | s458994587 | s678178289 | 135 | 107 | 3,060 | 3,060 | Accepted | Accepted | 20.74 | def func(x):
if x // 10 == 0:
return x
else:
return x % 10 + func(x // 10)
n = int(eval(input()))
ans = float('inf')
for a in range(1, (n // 2) + 1):
ans = min(ans, func(a) + func(n - a))
print(ans) | def d_sum(x):
res = 0
while x > 0:
res += x % 10
x //= 10
return res
n = int(eval(input()))
ans = float('inf')
for a in range(1, n // 2 + 1):
b = n - a
ans = min(ans, d_sum(a) + d_sum(b))
print(ans) | 11 | 15 | 231 | 245 | def func(x):
if x // 10 == 0:
return x
else:
return x % 10 + func(x // 10)
n = int(eval(input()))
ans = float("inf")
for a in range(1, (n // 2) + 1):
ans = min(ans, func(a) + func(n - a))
print(ans)
| def d_sum(x):
res = 0
while x > 0:
res += x % 10
x //= 10
return res
n = int(eval(input()))
ans = float("inf")
for a in range(1, n // 2 + 1):
b = n - a
ans = min(ans, d_sum(a) + d_sum(b))
print(ans)
| false | 26.666667 | [
"-def func(x):",
"- if x // 10 == 0:",
"- return x",
"- else:",
"- return x % 10 + func(x // 10)",
"+def d_sum(x):",
"+ res = 0",
"+ while x > 0:",
"+ res += x % 10",
"+ x //= 10",
"+ return res",
"-for a in range(1, (n // 2) + 1):",
"- ans = min(ans, func(a) + func(n - a))",
"+for a in range(1, n // 2 + 1):",
"+ b = n - a",
"+ ans = min(ans, d_sum(a) + d_sum(b))"
] | false | 0.05191 | 0.143142 | 0.362647 | [
"s458994587",
"s678178289"
] |
u756195685 | p03160 | python | s064336078 | s702587535 | 138 | 125 | 13,928 | 20,420 | Accepted | Accepted | 9.42 | N = int(eval(input()))
A = list(map(int,input().split()))
dp = [0] * (N+10)
dp[2] = abs(A[1] - A[0])
for i in range(2,N):
Ai = abs(A[i] - A[i-1])
Ai2 = abs(A[i] - A[i-2])
dp[i+1] = min(dp[i]+Ai,dp[i-1]+Ai2)
print((dp[N])) | N = int(eval(input()))
h = list(map(int,input().split()))
dp = [0] * N
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print((dp[-1]))
| 10 | 7 | 235 | 196 | N = int(eval(input()))
A = list(map(int, input().split()))
dp = [0] * (N + 10)
dp[2] = abs(A[1] - A[0])
for i in range(2, N):
Ai = abs(A[i] - A[i - 1])
Ai2 = abs(A[i] - A[i - 2])
dp[i + 1] = min(dp[i] + Ai, dp[i - 1] + Ai2)
print((dp[N]))
| N = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * N
dp[1] = abs(h[0] - h[1])
for i in range(2, N):
dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))
print((dp[-1]))
| false | 30 | [
"-A = list(map(int, input().split()))",
"-dp = [0] * (N + 10)",
"-dp[2] = abs(A[1] - A[0])",
"+h = list(map(int, input().split()))",
"+dp = [0] * N",
"+dp[1] = abs(h[0] - h[1])",
"- Ai = abs(A[i] - A[i - 1])",
"- Ai2 = abs(A[i] - A[i - 2])",
"- dp[i + 1] = min(dp[i] + Ai, dp[i - 1] + Ai2)",
"-print((dp[N]))",
"+ dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]))",
"+print((dp[-1]))"
] | false | 0.11101 | 0.081026 | 1.370061 | [
"s064336078",
"s702587535"
] |
u581187895 | p02881 | python | s286161038 | s424797203 | 246 | 169 | 3,064 | 29,000 | Accepted | Accepted | 31.3 | # a+b-2
# N = a*b よってNの約数を求める
N = int(eval(input()))
ans = N-1
for i in range(1, int(N**0.5+1)):
if N//i*i == N:
ans = min(ans, i+N//i-2)
print(ans)
| # a+b-2
# N = a*b よってNの約数を求める
import numpy as np
N = int(eval(input()))
U = 10**6+100
x = np.arange(1, U, dtype=np.int64)
div = x[N%x==0]
ans = (div + N//div).min() - 2
print(ans) | 9 | 10 | 163 | 184 | # a+b-2
# N = a*b よってNの約数を求める
N = int(eval(input()))
ans = N - 1
for i in range(1, int(N**0.5 + 1)):
if N // i * i == N:
ans = min(ans, i + N // i - 2)
print(ans)
| # a+b-2
# N = a*b よってNの約数を求める
import numpy as np
N = int(eval(input()))
U = 10**6 + 100
x = np.arange(1, U, dtype=np.int64)
div = x[N % x == 0]
ans = (div + N // div).min() - 2
print(ans)
| false | 10 | [
"+import numpy as np",
"+",
"-ans = N - 1",
"-for i in range(1, int(N**0.5 + 1)):",
"- if N // i * i == N:",
"- ans = min(ans, i + N // i - 2)",
"+U = 10**6 + 100",
"+x = np.arange(1, U, dtype=np.int64)",
"+div = x[N % x == 0]",
"+ans = (div + N // div).min() - 2"
] | false | 0.040288 | 0.551405 | 0.073065 | [
"s286161038",
"s424797203"
] |
u707124227 | p03388 | python | s668998717 | s073784356 | 68 | 29 | 63,652 | 9,444 | Accepted | Accepted | 57.35 | q=int(eval(input()))
ab=[list(map(int,input().split())) for _ in range(q)]
from math import floor
for a,b in ab:
if a==b:
print((2*a-2))
continue
t=floor((a*b)**0.5)
# t,t+1 組み合わせの積がa*bで抑えられているかどうか
if t*t>=a*b: # t*tもだめ
print((2*t-3))
elif t*(t+1)>=a*b: # t*(t+1)はだめ
print((2*t-2))
else: # t*tもt*(t+1)もOK
print((2*t-1))
| q=int(eval(input()))
ab=[list(map(int,input().split())) for _ in range(q)]
from math import floor
for a,b in ab:
# a*bをぎりぎりまで攻めたい
# (1,1)とかはもったいない。(1,a*b-1)は良い。片方は√a*b未満で、片方は√a*bより大きい組み合わせ。
# a==bならa未満の整数yについて適切な数字xを選べばy*x<a*bとできる。xは他のxと被らないように選択できる。
if a==b:
print((2*a-2))
else:
# t,t+1 組み合わせの積がa*bで抑えられているかどうか。(t+1)*(t+1)は必ずa*bを超える。
# t未満の自然数については適切な整数を選べばa*b以下にできる。
t=floor((a*b)**0.5)
# (1,2*t-1),(2,2*t-2),(3,(a*b-1)//3),...,(t-1,(a*b-1)//(t-1))
if t*t>=a*b:
# (t,t),(t,t+1)はだめ。この条件を満たすのはt*t=a*b、a!=bのときのみ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
print((2*t-3))
elif t*(t+1)>=a*b:
# (t,t)はOK。(t,t+1)はだめ。(t,t)をまず選ぶ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
print((2*t-2))
else:
# t*tもt*(t+1)もOK。(t,t+1),(t+1,t)をまず選ぶ。あとはt未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
print((2*t-1))
| 15 | 23 | 352 | 954 | q = int(eval(input()))
ab = [list(map(int, input().split())) for _ in range(q)]
from math import floor
for a, b in ab:
if a == b:
print((2 * a - 2))
continue
t = floor((a * b) ** 0.5)
# t,t+1 組み合わせの積がa*bで抑えられているかどうか
if t * t >= a * b: # t*tもだめ
print((2 * t - 3))
elif t * (t + 1) >= a * b: # t*(t+1)はだめ
print((2 * t - 2))
else: # t*tもt*(t+1)もOK
print((2 * t - 1))
| q = int(eval(input()))
ab = [list(map(int, input().split())) for _ in range(q)]
from math import floor
for a, b in ab:
# a*bをぎりぎりまで攻めたい
# (1,1)とかはもったいない。(1,a*b-1)は良い。片方は√a*b未満で、片方は√a*bより大きい組み合わせ。
# a==bならa未満の整数yについて適切な数字xを選べばy*x<a*bとできる。xは他のxと被らないように選択できる。
if a == b:
print((2 * a - 2))
else:
# t,t+1 組み合わせの積がa*bで抑えられているかどうか。(t+1)*(t+1)は必ずa*bを超える。
# t未満の自然数については適切な整数を選べばa*b以下にできる。
t = floor((a * b) ** 0.5)
# (1,2*t-1),(2,2*t-2),(3,(a*b-1)//3),...,(t-1,(a*b-1)//(t-1))
if t * t >= a * b:
# (t,t),(t,t+1)はだめ。この条件を満たすのはt*t=a*b、a!=bのときのみ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
print((2 * t - 3))
elif t * (t + 1) >= a * b:
# (t,t)はOK。(t,t+1)はだめ。(t,t)をまず選ぶ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
print((2 * t - 2))
else:
# t*tもt*(t+1)もOK。(t,t+1),(t+1,t)をまず選ぶ。あとはt未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
print((2 * t - 1))
| false | 34.782609 | [
"+ # a*bをぎりぎりまで攻めたい",
"+ # (1,1)とかはもったいない。(1,a*b-1)は良い。片方は√a*b未満で、片方は√a*bより大きい組み合わせ。",
"+ # a==bならa未満の整数yについて適切な数字xを選べばy*x<a*bとできる。xは他のxと被らないように選択できる。",
"- continue",
"- t = floor((a * b) ** 0.5)",
"- # t,t+1 組み合わせの積がa*bで抑えられているかどうか",
"- if t * t >= a * b: # t*tもだめ",
"- print((2 * t - 3))",
"- elif t * (t + 1) >= a * b: # t*(t+1)はだめ",
"- print((2 * t - 2))",
"- else: # t*tもt*(t+1)もOK",
"- print((2 * t - 1))",
"+ else:",
"+ # t,t+1 組み合わせの積がa*bで抑えられているかどうか。(t+1)*(t+1)は必ずa*bを超える。",
"+ # t未満の自然数については適切な整数を選べばa*b以下にできる。",
"+ t = floor((a * b) ** 0.5)",
"+ # (1,2*t-1),(2,2*t-2),(3,(a*b-1)//3),...,(t-1,(a*b-1)//(t-1))",
"+ if t * t >= a * b:",
"+ # (t,t),(t,t+1)はだめ。この条件を満たすのはt*t=a*b、a!=bのときのみ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。",
"+ print((2 * t - 3))",
"+ elif t * (t + 1) >= a * b:",
"+ # (t,t)はOK。(t,t+1)はだめ。(t,t)をまず選ぶ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。",
"+ print((2 * t - 2))",
"+ else:",
"+ # t*tもt*(t+1)もOK。(t,t+1),(t+1,t)をまず選ぶ。あとはt未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。",
"+ print((2 * t - 1))"
] | false | 0.036239 | 0.078424 | 0.462087 | [
"s668998717",
"s073784356"
] |
u227438830 | p02399 | python | s682236240 | s148994999 | 30 | 20 | 7,620 | 5,604 | Accepted | Accepted | 33.33 | a, b = list(map(int, input().split()))
d = a//b
r = a % b
f = a / b
print(("{:d} {:d} {:.5f}".format(d,r,f))) | a, b = list(map(int,input().split()))
d,r,f = a//b,a%b,a/b
print(('{} {} {:.5f}'.format(d,r,f)))
| 5 | 3 | 105 | 91 | a, b = list(map(int, input().split()))
d = a // b
r = a % b
f = a / b
print(("{:d} {:d} {:.5f}".format(d, r, f)))
| a, b = list(map(int, input().split()))
d, r, f = a // b, a % b, a / b
print(("{} {} {:.5f}".format(d, r, f)))
| false | 40 | [
"-d = a // b",
"-r = a % b",
"-f = a / b",
"-print((\"{:d} {:d} {:.5f}\".format(d, r, f)))",
"+d, r, f = a // b, a % b, a / b",
"+print((\"{} {} {:.5f}\".format(d, r, f)))"
] | false | 0.043039 | 0.137054 | 0.314025 | [
"s682236240",
"s148994999"
] |
u644907318 | p03715 | python | s624703906 | s080259744 | 192 | 89 | 40,304 | 73,784 | Accepted | Accepted | 53.65 | H,W = list(map(int,input().split()))
if (H*W)%3==0:
dif = 0
else:
dif = min(H,W)
for i in range(1,W//2+1):
s1 = H*i
s2 = (W-i)*(H//2)
s3 = (W-i)*(H-H//2)
d = max(s1,s2,s3)-min(s1,s2,s3)
dif = min(dif,d)
for j in range(1,H//2+1):
s1 = W*j
s2 = (H-j)*(W//2)
s3 = (H-j)*(W-W//2)
d = max(s1,s2,s3)-min(s1,s2,s3)
dif = min(dif,d)
print(dif) | H,W = list(map(int,input().split()))
cmin = H*W
if H%3==0 or W%3==0:
ans = 0
else:
for i in range(H-1):
s1 = W*(i+1)
t = H-i-1
s2 = W*(t//2)
s3 = W*(t-t//2)
d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))
cmin = min(cmin,d)
t1 = W//2
s2 = t*t1
s3 = t*(W-t1)
d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))
cmin = min(cmin,d)
for j in range(W-1):
s1 = H*(j+1)
t = W-j-1
s2 = H*(t//2)
s3 = H*(t-t//2)
d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))
cmin = min(cmin,d)
t1 = H//2
s2 = t*t1
s3 = t*(H-t1)
d = max(abs(s1-s2),abs(s2-s3),abs(s3-s1))
cmin = min(cmin,d)
ans = cmin
print(ans) | 18 | 31 | 442 | 780 | H, W = list(map(int, input().split()))
if (H * W) % 3 == 0:
dif = 0
else:
dif = min(H, W)
for i in range(1, W // 2 + 1):
s1 = H * i
s2 = (W - i) * (H // 2)
s3 = (W - i) * (H - H // 2)
d = max(s1, s2, s3) - min(s1, s2, s3)
dif = min(dif, d)
for j in range(1, H // 2 + 1):
s1 = W * j
s2 = (H - j) * (W // 2)
s3 = (H - j) * (W - W // 2)
d = max(s1, s2, s3) - min(s1, s2, s3)
dif = min(dif, d)
print(dif)
| H, W = list(map(int, input().split()))
cmin = H * W
if H % 3 == 0 or W % 3 == 0:
ans = 0
else:
for i in range(H - 1):
s1 = W * (i + 1)
t = H - i - 1
s2 = W * (t // 2)
s3 = W * (t - t // 2)
d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
cmin = min(cmin, d)
t1 = W // 2
s2 = t * t1
s3 = t * (W - t1)
d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
cmin = min(cmin, d)
for j in range(W - 1):
s1 = H * (j + 1)
t = W - j - 1
s2 = H * (t // 2)
s3 = H * (t - t // 2)
d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
cmin = min(cmin, d)
t1 = H // 2
s2 = t * t1
s3 = t * (H - t1)
d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))
cmin = min(cmin, d)
ans = cmin
print(ans)
| false | 41.935484 | [
"-if (H * W) % 3 == 0:",
"- dif = 0",
"+cmin = H * W",
"+if H % 3 == 0 or W % 3 == 0:",
"+ ans = 0",
"- dif = min(H, W)",
"- for i in range(1, W // 2 + 1):",
"- s1 = H * i",
"- s2 = (W - i) * (H // 2)",
"- s3 = (W - i) * (H - H // 2)",
"- d = max(s1, s2, s3) - min(s1, s2, s3)",
"- dif = min(dif, d)",
"- for j in range(1, H // 2 + 1):",
"- s1 = W * j",
"- s2 = (H - j) * (W // 2)",
"- s3 = (H - j) * (W - W // 2)",
"- d = max(s1, s2, s3) - min(s1, s2, s3)",
"- dif = min(dif, d)",
"-print(dif)",
"+ for i in range(H - 1):",
"+ s1 = W * (i + 1)",
"+ t = H - i - 1",
"+ s2 = W * (t // 2)",
"+ s3 = W * (t - t // 2)",
"+ d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))",
"+ cmin = min(cmin, d)",
"+ t1 = W // 2",
"+ s2 = t * t1",
"+ s3 = t * (W - t1)",
"+ d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))",
"+ cmin = min(cmin, d)",
"+ for j in range(W - 1):",
"+ s1 = H * (j + 1)",
"+ t = W - j - 1",
"+ s2 = H * (t // 2)",
"+ s3 = H * (t - t // 2)",
"+ d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))",
"+ cmin = min(cmin, d)",
"+ t1 = H // 2",
"+ s2 = t * t1",
"+ s3 = t * (H - t1)",
"+ d = max(abs(s1 - s2), abs(s2 - s3), abs(s3 - s1))",
"+ cmin = min(cmin, d)",
"+ ans = cmin",
"+print(ans)"
] | false | 0.035028 | 0.035564 | 0.984922 | [
"s624703906",
"s080259744"
] |
u013513417 | p03162 | python | s482076571 | s970419666 | 672 | 273 | 71,772 | 100,904 | Accepted | Accepted | 59.38 | #S = [[0 for j in range(3)] for i in range(2)] 2行3列の場合
S = [[0 for j in range(3)] for i in range(100010)]
DP= [[0 for j in range(3)] for i in range(100010)]
N=int(eval(input()))
for i in range(N):
L=list(map(int,input().split()))
for j in range(len(L)):
S[i][j]=L[j]
for i in range(N):
for j in range(3):
for k in range(3):
if j==k:
pass
else:
if DP[i+1][k]<DP[i][j]+S[i][k]:
DP[i+1][k]=DP[i][j]+S[i][k]
ans=0
for j in range(3):
if ans<DP[N][j]:
ans=DP[N][j]
print(ans) | N=int(eval(input()))
#S = [[0 for j in range(3)] for i in range(2)] 2行3列の場合
S = [[0 for j in range(3)] for i in range(100010)]
def chmax(a,b):
if a>b:
return a
else:
return b
for i in range(N):
A,B,C=list(map(int,input().split()))
S[i+1][0]=A
S[i+1][1]=B
S[i+1][2]=C
DP=[[0 for j in range(3)] for i in range(100010)]
DP[0][0]=0
DP[0][1]=0
DP[0][2]=0
DP[1][0]=S[1][0]
DP[1][1]=S[1][1]
DP[1][2]=S[1][2]
if N==1:
print((max(DP[1])))
exit()
for k in range(2,N+1):
for i in range(3):
for j in range(3):
if i!=j:
DP[k][i]=chmax(DP[k-1][j]+S[k][i],DP[k][i])
DP[k][j]=chmax(DP[k-1][i]+S[k][j],DP[k][j])
print((max(DP[N])))
| 27 | 39 | 611 | 762 | # S = [[0 for j in range(3)] for i in range(2)] 2行3列の場合
S = [[0 for j in range(3)] for i in range(100010)]
DP = [[0 for j in range(3)] for i in range(100010)]
N = int(eval(input()))
for i in range(N):
L = list(map(int, input().split()))
for j in range(len(L)):
S[i][j] = L[j]
for i in range(N):
for j in range(3):
for k in range(3):
if j == k:
pass
else:
if DP[i + 1][k] < DP[i][j] + S[i][k]:
DP[i + 1][k] = DP[i][j] + S[i][k]
ans = 0
for j in range(3):
if ans < DP[N][j]:
ans = DP[N][j]
print(ans)
| N = int(eval(input()))
# S = [[0 for j in range(3)] for i in range(2)] 2行3列の場合
S = [[0 for j in range(3)] for i in range(100010)]
def chmax(a, b):
if a > b:
return a
else:
return b
for i in range(N):
A, B, C = list(map(int, input().split()))
S[i + 1][0] = A
S[i + 1][1] = B
S[i + 1][2] = C
DP = [[0 for j in range(3)] for i in range(100010)]
DP[0][0] = 0
DP[0][1] = 0
DP[0][2] = 0
DP[1][0] = S[1][0]
DP[1][1] = S[1][1]
DP[1][2] = S[1][2]
if N == 1:
print((max(DP[1])))
exit()
for k in range(2, N + 1):
for i in range(3):
for j in range(3):
if i != j:
DP[k][i] = chmax(DP[k - 1][j] + S[k][i], DP[k][i])
DP[k][j] = chmax(DP[k - 1][i] + S[k][j], DP[k][j])
print((max(DP[N])))
| false | 30.769231 | [
"+N = int(eval(input()))",
"+",
"+",
"+def chmax(a, b):",
"+ if a > b:",
"+ return a",
"+ else:",
"+ return b",
"+",
"+",
"+for i in range(N):",
"+ A, B, C = list(map(int, input().split()))",
"+ S[i + 1][0] = A",
"+ S[i + 1][1] = B",
"+ S[i + 1][2] = C",
"-N = int(eval(input()))",
"-for i in range(N):",
"- L = list(map(int, input().split()))",
"- for j in range(len(L)):",
"- S[i][j] = L[j]",
"-for i in range(N):",
"- for j in range(3):",
"- for k in range(3):",
"- if j == k:",
"- pass",
"- else:",
"- if DP[i + 1][k] < DP[i][j] + S[i][k]:",
"- DP[i + 1][k] = DP[i][j] + S[i][k]",
"-ans = 0",
"-for j in range(3):",
"- if ans < DP[N][j]:",
"- ans = DP[N][j]",
"-print(ans)",
"+DP[0][0] = 0",
"+DP[0][1] = 0",
"+DP[0][2] = 0",
"+DP[1][0] = S[1][0]",
"+DP[1][1] = S[1][1]",
"+DP[1][2] = S[1][2]",
"+if N == 1:",
"+ print((max(DP[1])))",
"+ exit()",
"+for k in range(2, N + 1):",
"+ for i in range(3):",
"+ for j in range(3):",
"+ if i != j:",
"+ DP[k][i] = chmax(DP[k - 1][j] + S[k][i], DP[k][i])",
"+ DP[k][j] = chmax(DP[k - 1][i] + S[k][j], DP[k][j])",
"+print((max(DP[N])))"
] | false | 0.682638 | 0.718199 | 0.950486 | [
"s482076571",
"s970419666"
] |
u075595666 | p02837 | python | s657388658 | s590144324 | 339 | 210 | 53,340 | 9,136 | Accepted | Accepted | 38.05 | import sys
input = sys.stdin.readline
n = int(eval(input()))
chk = [[set(),set()] for _ in range(n)]
for o in range(n):
a = int(eval(input()))
for i in range(a):
x,y = [int(i) for i in input().split()]
if y == 0:
chk[o][0].add(x-1)
if y == 1:
chk[o][1].add(x-1)
chk = tuple(chk)
answer = 0
for i in range(2**n):
b = format(i,'b')
b = b.zfill(n)[::-1]
chk_0 = set()
chk_1 = set()
p = []
for j in range(n):
if b[j] == '1':
p.append(j)
chk_1.add(j)
if b[j] == '0':
chk_0.add(j)
for i in p:
if not chk[i][0] <= chk_0:
break
if not chk[i][1] <= chk_1:
break
if i == p[len(p)-1]:
answer = max(answer,len(p))
print(answer) | n = int(eval(input()))
a = []
xy = []
for i in range(n):
a += [int(eval(input()))]
xy += [[list(map(int,input().split())) for i in range(a[i])]]
honest = []
for i in range(2 ** n):
flag = 0
for j in range(n):
if (i >> j)&1 == 1: #j番目は正直であるとき
for person_state in xy[j]:
if (i >> (person_state[0]-1) & 1) != person_state[1]:
flag = 1 #矛盾が生じるとflagを立てる
break
if flag == 0:
honest += [bin(i)[2:].count("1")]
print((max(honest))) | 36 | 18 | 748 | 524 | import sys
input = sys.stdin.readline
n = int(eval(input()))
chk = [[set(), set()] for _ in range(n)]
for o in range(n):
a = int(eval(input()))
for i in range(a):
x, y = [int(i) for i in input().split()]
if y == 0:
chk[o][0].add(x - 1)
if y == 1:
chk[o][1].add(x - 1)
chk = tuple(chk)
answer = 0
for i in range(2**n):
b = format(i, "b")
b = b.zfill(n)[::-1]
chk_0 = set()
chk_1 = set()
p = []
for j in range(n):
if b[j] == "1":
p.append(j)
chk_1.add(j)
if b[j] == "0":
chk_0.add(j)
for i in p:
if not chk[i][0] <= chk_0:
break
if not chk[i][1] <= chk_1:
break
if i == p[len(p) - 1]:
answer = max(answer, len(p))
print(answer)
| n = int(eval(input()))
a = []
xy = []
for i in range(n):
a += [int(eval(input()))]
xy += [[list(map(int, input().split())) for i in range(a[i])]]
honest = []
for i in range(2**n):
flag = 0
for j in range(n):
if (i >> j) & 1 == 1: # j番目は正直であるとき
for person_state in xy[j]:
if (i >> (person_state[0] - 1) & 1) != person_state[1]:
flag = 1 # 矛盾が生じるとflagを立てる
break
if flag == 0:
honest += [bin(i)[2:].count("1")]
print((max(honest)))
| false | 50 | [
"-import sys",
"-",
"-input = sys.stdin.readline",
"-chk = [[set(), set()] for _ in range(n)]",
"-for o in range(n):",
"- a = int(eval(input()))",
"- for i in range(a):",
"- x, y = [int(i) for i in input().split()]",
"- if y == 0:",
"- chk[o][0].add(x - 1)",
"- if y == 1:",
"- chk[o][1].add(x - 1)",
"-chk = tuple(chk)",
"-answer = 0",
"+a = []",
"+xy = []",
"+for i in range(n):",
"+ a += [int(eval(input()))]",
"+ xy += [[list(map(int, input().split())) for i in range(a[i])]]",
"+honest = []",
"- b = format(i, \"b\")",
"- b = b.zfill(n)[::-1]",
"- chk_0 = set()",
"- chk_1 = set()",
"- p = []",
"+ flag = 0",
"- if b[j] == \"1\":",
"- p.append(j)",
"- chk_1.add(j)",
"- if b[j] == \"0\":",
"- chk_0.add(j)",
"- for i in p:",
"- if not chk[i][0] <= chk_0:",
"- break",
"- if not chk[i][1] <= chk_1:",
"- break",
"- if i == p[len(p) - 1]:",
"- answer = max(answer, len(p))",
"-print(answer)",
"+ if (i >> j) & 1 == 1: # j番目は正直であるとき",
"+ for person_state in xy[j]:",
"+ if (i >> (person_state[0] - 1) & 1) != person_state[1]:",
"+ flag = 1 # 矛盾が生じるとflagを立てる",
"+ break",
"+ if flag == 0:",
"+ honest += [bin(i)[2:].count(\"1\")]",
"+print((max(honest)))"
] | false | 0.075989 | 0.054127 | 1.403908 | [
"s657388658",
"s590144324"
] |
u964494353 | p03244 | python | s832959775 | s645411848 | 102 | 94 | 17,528 | 17,056 | Accepted | Accepted | 7.84 | n = int(eval(input()))
lst = list(map(int, input().split()))
ma = {}
mb = {}
for i in range(0, n, 2):
lst[i] in ma
if lst[i] in ma:
ma[lst[i]] += 1
else:
ma[lst[i]] = 1
lst[i+1] in mb
if lst[i+1] in mb:
mb[lst[i+1]] += 1
else:
mb[lst[i+1]] = 1
if max(ma, key=ma.get) != max(mb, key=mb.get):
d = n - max(ma.values()) - max(mb.values())
else:
ma2 = max(ma.values())
mb2 = max(mb.values())
ma[max(ma, key=ma.get)] = 0
mb[max(mb, key=mb.get)] = 0
d1 = n - ma2 - max(mb.values())
d2 = n - max(ma.values()) - mb2
d = min(d1, d2)
print(d) | n = int(eval(input()))
lst = list(map(int, input().split()))
m1 = {}
m2 = {}
for i in range(0, n, 2):
if lst[i] in m1:
m1[lst[i]] += 1
else:
m1[lst[i]] = 1
if lst[i+1] in m2:
m2[lst[i+1]] += 1
else:
m2[lst[i+1]] = 1
if max(m1, key=m1.get) != max(m2, key=m2.get):
mm = n - max(m1.values()) - max(m2.values())
else:
mm1 = max(m1.values())
mm2 = max(m2.values())
m1[max(m1, key=m1.get)] = 0
m2[max(m2, key=m2.get)] = 0
mm = min(n - max(m1.values()) - mm2, n - max(m2.values()) - mm1)
print(mm) | 26 | 22 | 638 | 578 | n = int(eval(input()))
lst = list(map(int, input().split()))
ma = {}
mb = {}
for i in range(0, n, 2):
lst[i] in ma
if lst[i] in ma:
ma[lst[i]] += 1
else:
ma[lst[i]] = 1
lst[i + 1] in mb
if lst[i + 1] in mb:
mb[lst[i + 1]] += 1
else:
mb[lst[i + 1]] = 1
if max(ma, key=ma.get) != max(mb, key=mb.get):
d = n - max(ma.values()) - max(mb.values())
else:
ma2 = max(ma.values())
mb2 = max(mb.values())
ma[max(ma, key=ma.get)] = 0
mb[max(mb, key=mb.get)] = 0
d1 = n - ma2 - max(mb.values())
d2 = n - max(ma.values()) - mb2
d = min(d1, d2)
print(d)
| n = int(eval(input()))
lst = list(map(int, input().split()))
m1 = {}
m2 = {}
for i in range(0, n, 2):
if lst[i] in m1:
m1[lst[i]] += 1
else:
m1[lst[i]] = 1
if lst[i + 1] in m2:
m2[lst[i + 1]] += 1
else:
m2[lst[i + 1]] = 1
if max(m1, key=m1.get) != max(m2, key=m2.get):
mm = n - max(m1.values()) - max(m2.values())
else:
mm1 = max(m1.values())
mm2 = max(m2.values())
m1[max(m1, key=m1.get)] = 0
m2[max(m2, key=m2.get)] = 0
mm = min(n - max(m1.values()) - mm2, n - max(m2.values()) - mm1)
print(mm)
| false | 15.384615 | [
"-ma = {}",
"-mb = {}",
"+m1 = {}",
"+m2 = {}",
"- lst[i] in ma",
"- if lst[i] in ma:",
"- ma[lst[i]] += 1",
"+ if lst[i] in m1:",
"+ m1[lst[i]] += 1",
"- ma[lst[i]] = 1",
"- lst[i + 1] in mb",
"- if lst[i + 1] in mb:",
"- mb[lst[i + 1]] += 1",
"+ m1[lst[i]] = 1",
"+ if lst[i + 1] in m2:",
"+ m2[lst[i + 1]] += 1",
"- mb[lst[i + 1]] = 1",
"-if max(ma, key=ma.get) != max(mb, key=mb.get):",
"- d = n - max(ma.values()) - max(mb.values())",
"+ m2[lst[i + 1]] = 1",
"+if max(m1, key=m1.get) != max(m2, key=m2.get):",
"+ mm = n - max(m1.values()) - max(m2.values())",
"- ma2 = max(ma.values())",
"- mb2 = max(mb.values())",
"- ma[max(ma, key=ma.get)] = 0",
"- mb[max(mb, key=mb.get)] = 0",
"- d1 = n - ma2 - max(mb.values())",
"- d2 = n - max(ma.values()) - mb2",
"- d = min(d1, d2)",
"-print(d)",
"+ mm1 = max(m1.values())",
"+ mm2 = max(m2.values())",
"+ m1[max(m1, key=m1.get)] = 0",
"+ m2[max(m2, key=m2.get)] = 0",
"+ mm = min(n - max(m1.values()) - mm2, n - max(m2.values()) - mm1)",
"+print(mm)"
] | false | 0.039182 | 0.038345 | 1.021834 | [
"s832959775",
"s645411848"
] |
u098012509 | p02631 | python | s011685993 | s540728302 | 159 | 141 | 31,404 | 31,408 | Accepted | Accepted | 11.32 | import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
def main():
N = int(input())
A = [int(x) for x in input().split()]
ans = A[0]
for a in A[1:]:
ans ^= a
for a in A:
print(a ^ ans, end=" ")
if __name__ == '__main__':
main()
| import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [int(x) for x in input().split()]
s = 0
for a in A:
s ^= a
for a in A:
print((s ^ a))
if __name__ == '__main__':
main()
| 21 | 22 | 310 | 298 | import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
def main():
N = int(input())
A = [int(x) for x in input().split()]
ans = A[0]
for a in A[1:]:
ans ^= a
for a in A:
print(a ^ ans, end=" ")
if __name__ == "__main__":
main()
| import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
def main():
N = int(eval(input()))
A = [int(x) for x in input().split()]
s = 0
for a in A:
s ^= a
for a in A:
print((s ^ a))
if __name__ == "__main__":
main()
| false | 4.545455 | [
"- N = int(input())",
"+ N = int(eval(input()))",
"- ans = A[0]",
"- for a in A[1:]:",
"- ans ^= a",
"+ s = 0",
"- print(a ^ ans, end=\" \")",
"+ s ^= a",
"+ for a in A:",
"+ print((s ^ a))"
] | false | 0.040967 | 0.097369 | 0.420742 | [
"s011685993",
"s540728302"
] |
u753803401 | p03160 | python | s616881490 | s143912126 | 234 | 209 | 52,208 | 51,696 | Accepted | Accepted | 10.68 | def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip('\n'))
a = list(map(int, input().rstrip('\n').split()))
ls = [0] * n
for i in range(1, n):
if i == 1:
ls[i] = abs(a[i] - a[i-1])
else:
ls[i] = min(ls[i-1] + abs(a[i] - a[i-1]), ls[i-2] + abs(a[i] - a[i-2]))
print((ls[-1]))
if __name__ == '__main__':
slove()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
h = list(map(int, readline().split()))
dp = [10 ** 10] * n
dp[0] = 0
for i in range(1, n):
if i == 1:
dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i])
else:
dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]), dp[i])
print((dp[-1]))
if __name__ == '__main__':
solve()
| 16 | 20 | 419 | 483 | def slove():
import sys
input = sys.stdin.readline
n = int(input().rstrip("\n"))
a = list(map(int, input().rstrip("\n").split()))
ls = [0] * n
for i in range(1, n):
if i == 1:
ls[i] = abs(a[i] - a[i - 1])
else:
ls[i] = min(
ls[i - 1] + abs(a[i] - a[i - 1]), ls[i - 2] + abs(a[i] - a[i - 2])
)
print((ls[-1]))
if __name__ == "__main__":
slove()
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n = int(readline())
h = list(map(int, readline().split()))
dp = [10**10] * n
dp[0] = 0
for i in range(1, n):
if i == 1:
dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i])
else:
dp[i] = min(
dp[i - 1] + abs(h[i - 1] - h[i]),
dp[i - 2] + abs(h[i - 2] - h[i]),
dp[i],
)
print((dp[-1]))
if __name__ == "__main__":
solve()
| false | 20 | [
"-def slove():",
"- import sys",
"+import sys",
"- input = sys.stdin.readline",
"- n = int(input().rstrip(\"\\n\"))",
"- a = list(map(int, input().rstrip(\"\\n\").split()))",
"- ls = [0] * n",
"+",
"+def solve():",
"+ readline = sys.stdin.buffer.readline",
"+ mod = 10**9 + 7",
"+ n = int(readline())",
"+ h = list(map(int, readline().split()))",
"+ dp = [10**10] * n",
"+ dp[0] = 0",
"- ls[i] = abs(a[i] - a[i - 1])",
"+ dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i])",
"- ls[i] = min(",
"- ls[i - 1] + abs(a[i] - a[i - 1]), ls[i - 2] + abs(a[i] - a[i - 2])",
"+ dp[i] = min(",
"+ dp[i - 1] + abs(h[i - 1] - h[i]),",
"+ dp[i - 2] + abs(h[i - 2] - h[i]),",
"+ dp[i],",
"- print((ls[-1]))",
"+ print((dp[-1]))",
"- slove()",
"+ solve()"
] | false | 0.044826 | 0.044359 | 1.010524 | [
"s616881490",
"s143912126"
] |
u872538555 | p02791 | python | s284708354 | s379985222 | 148 | 89 | 25,116 | 25,116 | Accepted | Accepted | 39.86 | n, *p_n = list(map(int, open(0).read().split()))
count = 0
p_n_min = p_n[0]
for i in range(n):
p_n_min = min(p_n_min,p_n[i])
if p_n_min == p_n[i]:
count += 1
print(count) | n, *p_n = list(map(int, open(0).read().split()))
count = 0
min_num = p_n[0]
for p in p_n:
if p <= min_num:
min_num = p
count += 1
print(count) | 9 | 9 | 189 | 165 | n, *p_n = list(map(int, open(0).read().split()))
count = 0
p_n_min = p_n[0]
for i in range(n):
p_n_min = min(p_n_min, p_n[i])
if p_n_min == p_n[i]:
count += 1
print(count)
| n, *p_n = list(map(int, open(0).read().split()))
count = 0
min_num = p_n[0]
for p in p_n:
if p <= min_num:
min_num = p
count += 1
print(count)
| false | 0 | [
"-p_n_min = p_n[0]",
"-for i in range(n):",
"- p_n_min = min(p_n_min, p_n[i])",
"- if p_n_min == p_n[i]:",
"+min_num = p_n[0]",
"+for p in p_n:",
"+ if p <= min_num:",
"+ min_num = p"
] | false | 0.059615 | 0.064214 | 0.928388 | [
"s284708354",
"s379985222"
] |
u667084803 | p02775 | python | s376822651 | s006075604 | 1,113 | 932 | 154,500 | 154,884 | Accepted | Accepted | 16.26 | Z = [0,1,2,3,4,5,6,7,8,9,10]
C = [0,1,2,3,4,5,6,7,8,9]
X = [0,1,2,3,4,5,6,7,8,9]
def solve_dp(s):
n = len(s)
s = [int(c) for c in s]
inf = 10**9
dp = [[inf] * 2 for _ in range(n)]
d0 = s[0]
dp[0][0] = Z[d0]
dp[0][1] = Z[d0+1]
for i in range(1, n):
for j in range(2):
d = s[i] + j
for k in range(10):
if d + C[k] >= 10:
dp[i][j] = min(dp[i][j], dp[i-1][1] + X[k] + Z[d + C[k] - 10])
else:
dp[i][j] = min(dp[i][j], dp[i-1][0] + X[k] + Z[d + C[k]])
return dp[n-1][0]
if __name__ == '__main__':
s = eval(input())
s = "0"+ s
print((solve_dp(s))) | def solve_dp(s):
n = len(s)
s = [int(c) for c in s]
inf = 10**9
dp = [[inf] * 2 for _ in range(n)]
d0 = s[0]
dp[0][0] = d0
dp[0][1] = d0+1
for i in range(1, n):
for j in range(2):
d = s[i] + j
for k in range(10):
if d + k >= 10:
dp[i][j] = min(dp[i][j], dp[i-1][1] + 2*k + d - 10)
else:
dp[i][j] = min(dp[i][j], dp[i-1][0] + 2*k + d)
return dp[n-1][0]
if __name__ == '__main__':
s = eval(input())
s = "0"+ s
print((solve_dp(s))) | 30 | 26 | 719 | 602 | Z = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
C = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
X = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def solve_dp(s):
n = len(s)
s = [int(c) for c in s]
inf = 10**9
dp = [[inf] * 2 for _ in range(n)]
d0 = s[0]
dp[0][0] = Z[d0]
dp[0][1] = Z[d0 + 1]
for i in range(1, n):
for j in range(2):
d = s[i] + j
for k in range(10):
if d + C[k] >= 10:
dp[i][j] = min(dp[i][j], dp[i - 1][1] + X[k] + Z[d + C[k] - 10])
else:
dp[i][j] = min(dp[i][j], dp[i - 1][0] + X[k] + Z[d + C[k]])
return dp[n - 1][0]
if __name__ == "__main__":
s = eval(input())
s = "0" + s
print((solve_dp(s)))
| def solve_dp(s):
n = len(s)
s = [int(c) for c in s]
inf = 10**9
dp = [[inf] * 2 for _ in range(n)]
d0 = s[0]
dp[0][0] = d0
dp[0][1] = d0 + 1
for i in range(1, n):
for j in range(2):
d = s[i] + j
for k in range(10):
if d + k >= 10:
dp[i][j] = min(dp[i][j], dp[i - 1][1] + 2 * k + d - 10)
else:
dp[i][j] = min(dp[i][j], dp[i - 1][0] + 2 * k + d)
return dp[n - 1][0]
if __name__ == "__main__":
s = eval(input())
s = "0" + s
print((solve_dp(s)))
| false | 13.333333 | [
"-Z = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"-C = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"-X = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"-",
"-",
"- dp[0][0] = Z[d0]",
"- dp[0][1] = Z[d0 + 1]",
"+ dp[0][0] = d0",
"+ dp[0][1] = d0 + 1",
"- if d + C[k] >= 10:",
"- dp[i][j] = min(dp[i][j], dp[i - 1][1] + X[k] + Z[d + C[k] - 10])",
"+ if d + k >= 10:",
"+ dp[i][j] = min(dp[i][j], dp[i - 1][1] + 2 * k + d - 10)",
"- dp[i][j] = min(dp[i][j], dp[i - 1][0] + X[k] + Z[d + C[k]])",
"+ dp[i][j] = min(dp[i][j], dp[i - 1][0] + 2 * k + d)"
] | false | 0.050852 | 0.05052 | 1.006556 | [
"s376822651",
"s006075604"
] |
u533883485 | p02265 | python | s912308658 | s650067664 | 4,860 | 3,590 | 557,300 | 214,360 | Accepted | Accepted | 26.13 | # coding=utf-8
from collections import deque
n = int(eval(input()))
deque = deque()
input_lines = [input().split() for x in range(n)]
for i in range(n):
inp = input_lines[i]
if inp[0] == 'insert':
deque.appendleft(inp[1])
elif inp[0] == 'deleteFirst':
deque.popleft()
elif inp[0] == 'deleteLast':
deque.pop()
else:
if inp[1] in deque:
deque.remove(inp[1])
print((*deque)) | # coding=utf-8
from collections import deque
n = int(eval(input()))
deque = deque()
input_lines = [eval(input()) for x in range(n)]
for i in range(n):
inp = input_lines[i].split()
if inp[0] == 'insert':
deque.appendleft(inp[1])
elif inp[0] == 'deleteFirst':
deque.popleft()
elif inp[0] == 'deleteLast':
deque.pop()
else:
if inp[1] in deque:
deque.remove(inp[1])
print((*deque)) | 19 | 19 | 447 | 447 | # coding=utf-8
from collections import deque
n = int(eval(input()))
deque = deque()
input_lines = [input().split() for x in range(n)]
for i in range(n):
inp = input_lines[i]
if inp[0] == "insert":
deque.appendleft(inp[1])
elif inp[0] == "deleteFirst":
deque.popleft()
elif inp[0] == "deleteLast":
deque.pop()
else:
if inp[1] in deque:
deque.remove(inp[1])
print((*deque))
| # coding=utf-8
from collections import deque
n = int(eval(input()))
deque = deque()
input_lines = [eval(input()) for x in range(n)]
for i in range(n):
inp = input_lines[i].split()
if inp[0] == "insert":
deque.appendleft(inp[1])
elif inp[0] == "deleteFirst":
deque.popleft()
elif inp[0] == "deleteLast":
deque.pop()
else:
if inp[1] in deque:
deque.remove(inp[1])
print((*deque))
| false | 0 | [
"-input_lines = [input().split() for x in range(n)]",
"+input_lines = [eval(input()) for x in range(n)]",
"- inp = input_lines[i]",
"+ inp = input_lines[i].split()"
] | false | 0.035998 | 0.037401 | 0.962493 | [
"s912308658",
"s650067664"
] |
u909514237 | p02554 | python | s877706227 | s909043408 | 288 | 29 | 82,256 | 8,728 | Accepted | Accepted | 89.93 | import math
mod = 10**9 + 7
N = int(eval(input()))
ans = (10**N % mod) - 2 * (9**N % mod) + (8**N % mod)
print((ans%mod)) | N = int(eval(input()))
mod = 10**9 + 7
ans = pow(10,N,mod) - pow(9,N,mod)*2 + pow(8,N,mod)
print((ans%mod)) | 7 | 5 | 121 | 104 | import math
mod = 10**9 + 7
N = int(eval(input()))
ans = (10**N % mod) - 2 * (9**N % mod) + (8**N % mod)
print((ans % mod))
| N = int(eval(input()))
mod = 10**9 + 7
ans = pow(10, N, mod) - pow(9, N, mod) * 2 + pow(8, N, mod)
print((ans % mod))
| false | 28.571429 | [
"-import math",
"-",
"+N = int(eval(input()))",
"-N = int(eval(input()))",
"-ans = (10**N % mod) - 2 * (9**N % mod) + (8**N % mod)",
"+ans = pow(10, N, mod) - pow(9, N, mod) * 2 + pow(8, N, mod)"
] | false | 0.130835 | 0.039498 | 3.312423 | [
"s877706227",
"s909043408"
] |
u670180528 | p03045 | python | s355720884 | s829937515 | 1,192 | 488 | 291,544 | 120,460 | Accepted | Accepted | 59.06 | from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)
n,m,*l=list(map(int,open(0).read().split()))
graph=[[]*n for _ in range(n)]
unvis=[True]*n
@lru_cache(maxsize=None)
def dfs(x):
for y in graph[x]:
if unvis[y]:
unvis[y]=False
dfs(y)
for i,j in zip(l[::3],l[1::3]):
graph[i-1].append(j-1)
graph[j-1].append(i-1)
ans=0
for x in range(n):
if unvis[x]:
unvis[x]=False
dfs(x)
ans+=1
print(ans)
| import sys
sys.setrecursionlimit(200000)
n,m,*l=list(map(int,open(0).read().split()))
graph=[[]*n for _ in range(n)]
unvis=[True]*n
def dfs(x):
for y in graph[x]:
if unvis[y]:
unvis[y]=False
dfs(y)
for i,j in zip(l[::3],l[1::3]):
graph[i-1].append(j-1)
graph[j-1].append(i-1)
ans=0
for x in range(n):
if unvis[x]:
unvis[x]=False
dfs(x)
ans+=1
print(ans)
| 26 | 24 | 454 | 396 | from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)
n, m, *l = list(map(int, open(0).read().split()))
graph = [[] * n for _ in range(n)]
unvis = [True] * n
@lru_cache(maxsize=None)
def dfs(x):
for y in graph[x]:
if unvis[y]:
unvis[y] = False
dfs(y)
for i, j in zip(l[::3], l[1::3]):
graph[i - 1].append(j - 1)
graph[j - 1].append(i - 1)
ans = 0
for x in range(n):
if unvis[x]:
unvis[x] = False
dfs(x)
ans += 1
print(ans)
| import sys
sys.setrecursionlimit(200000)
n, m, *l = list(map(int, open(0).read().split()))
graph = [[] * n for _ in range(n)]
unvis = [True] * n
def dfs(x):
for y in graph[x]:
if unvis[y]:
unvis[y] = False
dfs(y)
for i, j in zip(l[::3], l[1::3]):
graph[i - 1].append(j - 1)
graph[j - 1].append(i - 1)
ans = 0
for x in range(n):
if unvis[x]:
unvis[x] = False
dfs(x)
ans += 1
print(ans)
| false | 7.692308 | [
"-from functools import lru_cache",
"-sys.setrecursionlimit(10**7)",
"+sys.setrecursionlimit(200000)",
"-@lru_cache(maxsize=None)"
] | false | 0.048124 | 0.045722 | 1.052516 | [
"s355720884",
"s829937515"
] |
u169138653 | p02936 | python | s717414415 | s860966137 | 1,841 | 1,672 | 106,124 | 54,524 | Accepted | Accepted | 9.18 | from collections import deque
n,q=list(map(int,input().split()))
edge=[[] for i in range(n)]
cnt=[0 for i in range(n)]
visited=[-1 for i in range(n)]
for i in range(n-1):
a,b=list(map(int,input().split()))
a-=1
b-=1
edge[a].append(b)
edge[b].append(a)
for i in range(q):
p,x=list(map(int,input().split()))
cnt[p-1]+=x
def dfs(edge,cnt,visited):
stack=deque([0])
visited[0]=0
while stack:
x=stack.pop()
for i in edge[x]:
newx=i
if visited[newx]==-1:
visited[newx]=0
cnt[newx]+=cnt[x]
stack.append(newx)
return cnt
print((*dfs(edge,cnt,visited)))
| from collections import deque
n,q=list(map(int,input().split()))
edge=[[] for _ in range(n)]
for _ in range(n-1):
a,b=list(map(int,input().split()))
a-=1
b-=1
edge[a].append(b)
edge[b].append(a)
def dfs(edge):
visited=[-1]*n
stack=deque([0])
visited[0]=0
while stack:
p=stack.pop()
for c in edge[p]:
if visited[c]==-1:
visited[c]=0
cnt[c]+=cnt[p]
stack.append(c)
return cnt
cnt=[0]*n
for _ in range(q):
k,x=list(map(int,input().split()))
k-=1
cnt[k]+=x
ans=dfs(edge)
print((*ans)) | 27 | 28 | 617 | 551 | from collections import deque
n, q = list(map(int, input().split()))
edge = [[] for i in range(n)]
cnt = [0 for i in range(n)]
visited = [-1 for i in range(n)]
for i in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edge[a].append(b)
edge[b].append(a)
for i in range(q):
p, x = list(map(int, input().split()))
cnt[p - 1] += x
def dfs(edge, cnt, visited):
stack = deque([0])
visited[0] = 0
while stack:
x = stack.pop()
for i in edge[x]:
newx = i
if visited[newx] == -1:
visited[newx] = 0
cnt[newx] += cnt[x]
stack.append(newx)
return cnt
print((*dfs(edge, cnt, visited)))
| from collections import deque
n, q = list(map(int, input().split()))
edge = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
edge[a].append(b)
edge[b].append(a)
def dfs(edge):
visited = [-1] * n
stack = deque([0])
visited[0] = 0
while stack:
p = stack.pop()
for c in edge[p]:
if visited[c] == -1:
visited[c] = 0
cnt[c] += cnt[p]
stack.append(c)
return cnt
cnt = [0] * n
for _ in range(q):
k, x = list(map(int, input().split()))
k -= 1
cnt[k] += x
ans = dfs(edge)
print((*ans))
| false | 3.571429 | [
"-edge = [[] for i in range(n)]",
"-cnt = [0 for i in range(n)]",
"-visited = [-1 for i in range(n)]",
"-for i in range(n - 1):",
"+edge = [[] for _ in range(n)]",
"+for _ in range(n - 1):",
"-for i in range(q):",
"- p, x = list(map(int, input().split()))",
"- cnt[p - 1] += x",
"-def dfs(edge, cnt, visited):",
"+def dfs(edge):",
"+ visited = [-1] * n",
"- x = stack.pop()",
"- for i in edge[x]:",
"- newx = i",
"- if visited[newx] == -1:",
"- visited[newx] = 0",
"- cnt[newx] += cnt[x]",
"- stack.append(newx)",
"+ p = stack.pop()",
"+ for c in edge[p]:",
"+ if visited[c] == -1:",
"+ visited[c] = 0",
"+ cnt[c] += cnt[p]",
"+ stack.append(c)",
"-print((*dfs(edge, cnt, visited)))",
"+cnt = [0] * n",
"+for _ in range(q):",
"+ k, x = list(map(int, input().split()))",
"+ k -= 1",
"+ cnt[k] += x",
"+ans = dfs(edge)",
"+print((*ans))"
] | false | 0.037673 | 0.036269 | 1.038685 | [
"s717414415",
"s860966137"
] |
u375616706 | p02585 | python | s600081319 | s673998224 | 1,999 | 718 | 413,528 | 78,144 | Accepted | Accepted | 64.08 | N,K = list(map(int,input().split()))
P=list([int(x)-1 for x in input().split()])
C=list(map(int,input().split()))
DP=[[C[P[n]]] for n in range(N)]
for start in range(N):
visited=set()
cur=P[start]
while cur not in visited:
visited.add(cur)
cur = P[cur]
DP[start].append(C[cur]+DP[start][-1])
for n in range(N):
DP[n]=DP[n][:-1]
ans=-float("inf")
for start in range(N):
for goal in range(min(K,len(DP[start]))):
no_loop_sum=DP[start][goal]
remain_hops=K-goal-1
if DP[start][-1]>0:
loops=remain_hops//len(DP[start])
else:
loops=0
ans=max(ans,no_loop_sum+DP[start][-1]*loops)
print(ans)
| N,K = list(map(int,input().split()))
P=list([int(x)-1 for x in input().split()])
C=list(map(int,input().split()))
ans=-float("inf")
for start in range(N):
cur=P[start]
scores=[C[cur]]
for _ in range(K):
if cur==start:
break
cur = P[cur]
scores.append(C[cur]+scores[-1])
for goal in range(len(scores)):
no_loop_sum=scores[goal]
remain_hops=K-goal-1
if scores[-1]>0:
loops=remain_hops//len(scores)
else:
loops=0
ans=max(ans,no_loop_sum+scores[-1]*loops)
print(ans)
| 30 | 25 | 724 | 604 | N, K = list(map(int, input().split()))
P = list([int(x) - 1 for x in input().split()])
C = list(map(int, input().split()))
DP = [[C[P[n]]] for n in range(N)]
for start in range(N):
visited = set()
cur = P[start]
while cur not in visited:
visited.add(cur)
cur = P[cur]
DP[start].append(C[cur] + DP[start][-1])
for n in range(N):
DP[n] = DP[n][:-1]
ans = -float("inf")
for start in range(N):
for goal in range(min(K, len(DP[start]))):
no_loop_sum = DP[start][goal]
remain_hops = K - goal - 1
if DP[start][-1] > 0:
loops = remain_hops // len(DP[start])
else:
loops = 0
ans = max(ans, no_loop_sum + DP[start][-1] * loops)
print(ans)
| N, K = list(map(int, input().split()))
P = list([int(x) - 1 for x in input().split()])
C = list(map(int, input().split()))
ans = -float("inf")
for start in range(N):
cur = P[start]
scores = [C[cur]]
for _ in range(K):
if cur == start:
break
cur = P[cur]
scores.append(C[cur] + scores[-1])
for goal in range(len(scores)):
no_loop_sum = scores[goal]
remain_hops = K - goal - 1
if scores[-1] > 0:
loops = remain_hops // len(scores)
else:
loops = 0
ans = max(ans, no_loop_sum + scores[-1] * loops)
print(ans)
| false | 16.666667 | [
"-DP = [[C[P[n]]] for n in range(N)]",
"-for start in range(N):",
"- visited = set()",
"- cur = P[start]",
"- while cur not in visited:",
"- visited.add(cur)",
"- cur = P[cur]",
"- DP[start].append(C[cur] + DP[start][-1])",
"-for n in range(N):",
"- DP[n] = DP[n][:-1]",
"- for goal in range(min(K, len(DP[start]))):",
"- no_loop_sum = DP[start][goal]",
"+ cur = P[start]",
"+ scores = [C[cur]]",
"+ for _ in range(K):",
"+ if cur == start:",
"+ break",
"+ cur = P[cur]",
"+ scores.append(C[cur] + scores[-1])",
"+ for goal in range(len(scores)):",
"+ no_loop_sum = scores[goal]",
"- if DP[start][-1] > 0:",
"- loops = remain_hops // len(DP[start])",
"+ if scores[-1] > 0:",
"+ loops = remain_hops // len(scores)",
"- ans = max(ans, no_loop_sum + DP[start][-1] * loops)",
"+ ans = max(ans, no_loop_sum + scores[-1] * loops)"
] | false | 0.041207 | 0.06818 | 0.604395 | [
"s600081319",
"s673998224"
] |
u745087332 | p03339 | python | s920561795 | s636930734 | 233 | 186 | 3,780 | 3,708 | Accepted | Accepted | 20.17 | # coding:utf-8
INF = float('inf')
N = int(eval(input()))
S = eval(input())
num_E = 0
num_W = 0
for s in S:
if s == 'E':
num_E += 1
else:
num_W += 1
e = num_E
w = num_W
ans = INF
for s in S:
cost = 0
if s == 'E':
e -= 1
cost = e + (num_W - w)
else:
w -= 1
cost = e + (num_W - w - 1)
ans = min(ans, cost)
print(ans)
| # coding:utf-8
INF = float('inf')
N = int(eval(input()))
S = eval(input())
num_E = S[:].count('E')
num_W = S[:].count('W')
e = num_E
w = num_W
ans = INF
for s in S:
cost = 0
if s == 'E':
e -= 1
cost = e + (num_W - w)
else:
w -= 1
cost = e + (num_W - w - 1)
ans = min(ans, cost)
print(ans) | 30 | 26 | 409 | 356 | # coding:utf-8
INF = float("inf")
N = int(eval(input()))
S = eval(input())
num_E = 0
num_W = 0
for s in S:
if s == "E":
num_E += 1
else:
num_W += 1
e = num_E
w = num_W
ans = INF
for s in S:
cost = 0
if s == "E":
e -= 1
cost = e + (num_W - w)
else:
w -= 1
cost = e + (num_W - w - 1)
ans = min(ans, cost)
print(ans)
| # coding:utf-8
INF = float("inf")
N = int(eval(input()))
S = eval(input())
num_E = S[:].count("E")
num_W = S[:].count("W")
e = num_E
w = num_W
ans = INF
for s in S:
cost = 0
if s == "E":
e -= 1
cost = e + (num_W - w)
else:
w -= 1
cost = e + (num_W - w - 1)
ans = min(ans, cost)
print(ans)
| false | 13.333333 | [
"-num_E = 0",
"-num_W = 0",
"-for s in S:",
"- if s == \"E\":",
"- num_E += 1",
"- else:",
"- num_W += 1",
"+num_E = S[:].count(\"E\")",
"+num_W = S[:].count(\"W\")"
] | false | 0.047285 | 0.046996 | 1.006154 | [
"s920561795",
"s636930734"
] |
u541610817 | p02923 | python | s447561356 | s852997088 | 132 | 105 | 14,252 | 14,252 | Accepted | Accepted | 20.45 | n = int(eval(input()))
H = [int(x) for x in input().split()]
res = 0
right = 0
for left in range(n):
while right+1 < n and H[right] >= H[right+1]:
right += 1
res = max(res, right - left)
if right == left:
right += 1
print(res) | n = int(eval(input()))
h = [int(x) for x in input().split()]
dp = [0] * (n + 1)
cc = 0
for i in range(1, n):
if h[i] <= h[i-1]:
cc += 1
dp[i+1] = max(cc, dp[i])
else:
dp[i+1] = dp[i]
cc = 0
print((dp[n]))
| 11 | 12 | 245 | 228 | n = int(eval(input()))
H = [int(x) for x in input().split()]
res = 0
right = 0
for left in range(n):
while right + 1 < n and H[right] >= H[right + 1]:
right += 1
res = max(res, right - left)
if right == left:
right += 1
print(res)
| n = int(eval(input()))
h = [int(x) for x in input().split()]
dp = [0] * (n + 1)
cc = 0
for i in range(1, n):
if h[i] <= h[i - 1]:
cc += 1
dp[i + 1] = max(cc, dp[i])
else:
dp[i + 1] = dp[i]
cc = 0
print((dp[n]))
| false | 8.333333 | [
"-H = [int(x) for x in input().split()]",
"-res = 0",
"-right = 0",
"-for left in range(n):",
"- while right + 1 < n and H[right] >= H[right + 1]:",
"- right += 1",
"- res = max(res, right - left)",
"- if right == left:",
"- right += 1",
"-print(res)",
"+h = [int(x) for x in input().split()]",
"+dp = [0] * (n + 1)",
"+cc = 0",
"+for i in range(1, n):",
"+ if h[i] <= h[i - 1]:",
"+ cc += 1",
"+ dp[i + 1] = max(cc, dp[i])",
"+ else:",
"+ dp[i + 1] = dp[i]",
"+ cc = 0",
"+print((dp[n]))"
] | false | 0.096537 | 0.036737 | 2.627755 | [
"s447561356",
"s852997088"
] |
u413021823 | p03086 | python | s791638997 | s745288312 | 67 | 29 | 64,988 | 9,084 | Accepted | Accepted | 56.72 | import sys
from collections import deque
from itertools import *
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = 0
temp = 0
for s_s in s:
if s_s in 'ACGT':
temp += 1
else:
temp = 0
ans = max(ans, temp)
print(ans)
| import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
temp = 0
ans = 0
for char in s:
if char in 'ACGT':
temp += 1
else:
temp = 0
ans = max(ans,temp)
print(ans) | 28 | 19 | 474 | 403 | import sys
from collections import deque
from itertools import *
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def S():
return sys.stdin.readline().rstrip()
def LS():
return list(sys.stdin.readline().rstrip().split())
s = S()
ans = 0
temp = 0
for s_s in s:
if s_s in "ACGT":
temp += 1
else:
temp = 0
ans = max(ans, temp)
print(ans)
| import sys
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
def S():
return sys.stdin.readline().rstrip()
def LS():
return list(sys.stdin.readline().rstrip().split())
s = S()
temp = 0
ans = 0
for char in s:
if char in "ACGT":
temp += 1
else:
temp = 0
ans = max(ans, temp)
print(ans)
| false | 32.142857 | [
"-from collections import deque",
"-from itertools import *",
"+temp = 0",
"-temp = 0",
"-for s_s in s:",
"- if s_s in \"ACGT\":",
"+for char in s:",
"+ if char in \"ACGT\":"
] | false | 0.037417 | 0.074027 | 0.505449 | [
"s791638997",
"s745288312"
] |
u189487046 | p03624 | python | s228337368 | s735208897 | 19 | 17 | 3,188 | 3,188 | Accepted | Accepted | 10.53 | ALPHABET = ["a", "b", "c", "d", "e", "f", "g", "h",
"i", "j", "k", "l", "m", "n", "o", "p",
"q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
s = eval(input())
for i in range(26):
if s.count(ALPHABET[i]) == 0:
print((ALPHABET[i]))
break
else:
print("None")
| ALPHABET = ["a", "b", "c", "d", "e", "f", "g", "h",
"i", "j", "k", "l", "m", "n", "o", "p",
"q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
s = eval(input())
for i in range(26):
if ALPHABET[i] not in s:
print((ALPHABET[i]))
break
else:
print("None")
| 11 | 11 | 308 | 303 | ALPHABET = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
s = eval(input())
for i in range(26):
if s.count(ALPHABET[i]) == 0:
print((ALPHABET[i]))
break
else:
print("None")
| ALPHABET = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
s = eval(input())
for i in range(26):
if ALPHABET[i] not in s:
print((ALPHABET[i]))
break
else:
print("None")
| false | 0 | [
"- if s.count(ALPHABET[i]) == 0:",
"+ if ALPHABET[i] not in s:"
] | false | 0.040514 | 0.040436 | 1.001926 | [
"s228337368",
"s735208897"
] |
u545368057 | p02991 | python | s050453291 | s574110087 | 703 | 523 | 60,100 | 61,372 | Accepted | Accepted | 25.6 | from collections import deque
# 木構造を作る
N,M = list(map(int, input().split()))
G = [[] for i in range(3*N)]
for i in range(M):
# グラフに頂点を追加(距離があるときは,u,vの後に入れる)
u,v = list(map(int,input().split()))
G[3*(u-1)].append((3*(v-1)+1))
G[3*(u-1)+1].append((3*(v-1)+2))
G[3*(u-1)+2].append((3*(v-1)))
S,T = list(map(int, input().split()))
# 木をBFSをする
dist = [-1] * (3*N)
dist[3*(S-1)] = 0
q = deque([3*(S-1)])
while q:
v = q.popleft()
d = dist[v]
Vs = G[v]
for u in Vs:
if dist[u] == -1:
q.append(u)
dist[u] = d + 1
ans = dist[3*(T-1)]
print((-1 if ans == -1 else ans//3))
| from collections import deque
n, m = list(map(int, input().split()))
edges = [[] for i in range(3*n)]
for i in range(m):
u,v = list(map(int, input().split()))
u -= 1
v -= 1
edges[u].append(v+n)
edges[u+n].append(v+2*n)
edges[u+2*n].append(v)
s,t = list(map(int, input().split()))
s -= 1
t -= 1
INF = 1<<50
dists = [INF] * (3*n)
q = deque([])
q.append(s)
dists[s] = 0
while len(q)>0:
v = q.popleft()
for u in edges[v]:
if dists[u] != INF: continue
q.append(u)
dists[u] = dists[v] + 1
if dists[t] == INF:
print((-1))
else:
print((dists[t]//3))
| 29 | 32 | 640 | 619 | from collections import deque
# 木構造を作る
N, M = list(map(int, input().split()))
G = [[] for i in range(3 * N)]
for i in range(M):
# グラフに頂点を追加(距離があるときは,u,vの後に入れる)
u, v = list(map(int, input().split()))
G[3 * (u - 1)].append((3 * (v - 1) + 1))
G[3 * (u - 1) + 1].append((3 * (v - 1) + 2))
G[3 * (u - 1) + 2].append((3 * (v - 1)))
S, T = list(map(int, input().split()))
# 木をBFSをする
dist = [-1] * (3 * N)
dist[3 * (S - 1)] = 0
q = deque([3 * (S - 1)])
while q:
v = q.popleft()
d = dist[v]
Vs = G[v]
for u in Vs:
if dist[u] == -1:
q.append(u)
dist[u] = d + 1
ans = dist[3 * (T - 1)]
print((-1 if ans == -1 else ans // 3))
| from collections import deque
n, m = list(map(int, input().split()))
edges = [[] for i in range(3 * n)]
for i in range(m):
u, v = list(map(int, input().split()))
u -= 1
v -= 1
edges[u].append(v + n)
edges[u + n].append(v + 2 * n)
edges[u + 2 * n].append(v)
s, t = list(map(int, input().split()))
s -= 1
t -= 1
INF = 1 << 50
dists = [INF] * (3 * n)
q = deque([])
q.append(s)
dists[s] = 0
while len(q) > 0:
v = q.popleft()
for u in edges[v]:
if dists[u] != INF:
continue
q.append(u)
dists[u] = dists[v] + 1
if dists[t] == INF:
print((-1))
else:
print((dists[t] // 3))
| false | 9.375 | [
"-# 木構造を作る",
"-N, M = list(map(int, input().split()))",
"-G = [[] for i in range(3 * N)]",
"-for i in range(M):",
"- # グラフに頂点を追加(距離があるときは,u,vの後に入れる)",
"+n, m = list(map(int, input().split()))",
"+edges = [[] for i in range(3 * n)]",
"+for i in range(m):",
"- G[3 * (u - 1)].append((3 * (v - 1) + 1))",
"- G[3 * (u - 1) + 1].append((3 * (v - 1) + 2))",
"- G[3 * (u - 1) + 2].append((3 * (v - 1)))",
"-S, T = list(map(int, input().split()))",
"-# 木をBFSをする",
"-dist = [-1] * (3 * N)",
"-dist[3 * (S - 1)] = 0",
"-q = deque([3 * (S - 1)])",
"-while q:",
"+ u -= 1",
"+ v -= 1",
"+ edges[u].append(v + n)",
"+ edges[u + n].append(v + 2 * n)",
"+ edges[u + 2 * n].append(v)",
"+s, t = list(map(int, input().split()))",
"+s -= 1",
"+t -= 1",
"+INF = 1 << 50",
"+dists = [INF] * (3 * n)",
"+q = deque([])",
"+q.append(s)",
"+dists[s] = 0",
"+while len(q) > 0:",
"- d = dist[v]",
"- Vs = G[v]",
"- for u in Vs:",
"- if dist[u] == -1:",
"- q.append(u)",
"- dist[u] = d + 1",
"-ans = dist[3 * (T - 1)]",
"-print((-1 if ans == -1 else ans // 3))",
"+ for u in edges[v]:",
"+ if dists[u] != INF:",
"+ continue",
"+ q.append(u)",
"+ dists[u] = dists[v] + 1",
"+if dists[t] == INF:",
"+ print((-1))",
"+else:",
"+ print((dists[t] // 3))"
] | false | 0.041202 | 0.035125 | 1.173 | [
"s050453291",
"s574110087"
] |
u515052479 | p03053 | python | s887338264 | s458326464 | 956 | 499 | 51,584 | 146,144 | Accepted | Accepted | 47.8 | def main():
h,w = list(map(int,input().split()))
a = []
for i in range(h):
a.append(eval(input()))
used = [True]*(h*w)
p = []
for i in range(h):
for j in range(w):
if a[i][j] == '#':
p.append(i*w+j)
used[i*w+j] = False
res = 0
while p:
tank = []
for e in p:
if (e-w)>=0 and used[e-w]:
tank.append(e-w)
used[e-w] = False
if e%w-1 >= 0 and used[e-1]:
tank.append(e-1)
used[e-1] = False
if e+w<w*h and used[e+w]:
tank.append(e+w)
used[e+w] = False
if e%w+1<w and used[e+1]:
tank.append(e+1)
used[e+1] = False
p = tank
res += 1
print((res-1))
if __name__ == '__main__':
main() | def main():
num_r,num_c = list(map(int,input().split()))
field = [eval(input()) for i in range(num_r)]
q = []
seen = [0]*(num_c*num_r)
count = 0
for i in range(num_r):
for j in range(num_c):
if field[i][j] == "#":
seen[i*num_c+j] = 1
q.append([i,j])
while q:
tank = []
for i in q:
r = i[0]
c = i[1]
if (0<=r-1) and (seen[(r-1)*num_c+c] == 0):
tank.append([r-1,c])
seen[(r-1)*num_c+c] = 1
if (r+1<num_r) and (seen[(r+1)*num_c+c] == 0):
tank.append([r+1,c])
seen[(r+1)*num_c+c] = 1
if (0<=c-1) and (seen[r*num_c+(c-1)] == 0):
tank.append([r,c-1])
seen[r*num_c+(c-1)] = 1
if (c+1<num_c) and (seen[r*num_c+(c+1)] == 0):
tank.append([r,c+1])
seen[r*num_c+(c+1)] = 1
count = count + 1
q = tank
print((count-1))
if __name__ == '__main__':
main() | 39 | 38 | 919 | 939 | def main():
h, w = list(map(int, input().split()))
a = []
for i in range(h):
a.append(eval(input()))
used = [True] * (h * w)
p = []
for i in range(h):
for j in range(w):
if a[i][j] == "#":
p.append(i * w + j)
used[i * w + j] = False
res = 0
while p:
tank = []
for e in p:
if (e - w) >= 0 and used[e - w]:
tank.append(e - w)
used[e - w] = False
if e % w - 1 >= 0 and used[e - 1]:
tank.append(e - 1)
used[e - 1] = False
if e + w < w * h and used[e + w]:
tank.append(e + w)
used[e + w] = False
if e % w + 1 < w and used[e + 1]:
tank.append(e + 1)
used[e + 1] = False
p = tank
res += 1
print((res - 1))
if __name__ == "__main__":
main()
| def main():
num_r, num_c = list(map(int, input().split()))
field = [eval(input()) for i in range(num_r)]
q = []
seen = [0] * (num_c * num_r)
count = 0
for i in range(num_r):
for j in range(num_c):
if field[i][j] == "#":
seen[i * num_c + j] = 1
q.append([i, j])
while q:
tank = []
for i in q:
r = i[0]
c = i[1]
if (0 <= r - 1) and (seen[(r - 1) * num_c + c] == 0):
tank.append([r - 1, c])
seen[(r - 1) * num_c + c] = 1
if (r + 1 < num_r) and (seen[(r + 1) * num_c + c] == 0):
tank.append([r + 1, c])
seen[(r + 1) * num_c + c] = 1
if (0 <= c - 1) and (seen[r * num_c + (c - 1)] == 0):
tank.append([r, c - 1])
seen[r * num_c + (c - 1)] = 1
if (c + 1 < num_c) and (seen[r * num_c + (c + 1)] == 0):
tank.append([r, c + 1])
seen[r * num_c + (c + 1)] = 1
count = count + 1
q = tank
print((count - 1))
if __name__ == "__main__":
main()
| false | 2.564103 | [
"- h, w = list(map(int, input().split()))",
"- a = []",
"- for i in range(h):",
"- a.append(eval(input()))",
"- used = [True] * (h * w)",
"- p = []",
"- for i in range(h):",
"- for j in range(w):",
"- if a[i][j] == \"#\":",
"- p.append(i * w + j)",
"- used[i * w + j] = False",
"- res = 0",
"- while p:",
"+ num_r, num_c = list(map(int, input().split()))",
"+ field = [eval(input()) for i in range(num_r)]",
"+ q = []",
"+ seen = [0] * (num_c * num_r)",
"+ count = 0",
"+ for i in range(num_r):",
"+ for j in range(num_c):",
"+ if field[i][j] == \"#\":",
"+ seen[i * num_c + j] = 1",
"+ q.append([i, j])",
"+ while q:",
"- for e in p:",
"- if (e - w) >= 0 and used[e - w]:",
"- tank.append(e - w)",
"- used[e - w] = False",
"- if e % w - 1 >= 0 and used[e - 1]:",
"- tank.append(e - 1)",
"- used[e - 1] = False",
"- if e + w < w * h and used[e + w]:",
"- tank.append(e + w)",
"- used[e + w] = False",
"- if e % w + 1 < w and used[e + 1]:",
"- tank.append(e + 1)",
"- used[e + 1] = False",
"- p = tank",
"- res += 1",
"- print((res - 1))",
"+ for i in q:",
"+ r = i[0]",
"+ c = i[1]",
"+ if (0 <= r - 1) and (seen[(r - 1) * num_c + c] == 0):",
"+ tank.append([r - 1, c])",
"+ seen[(r - 1) * num_c + c] = 1",
"+ if (r + 1 < num_r) and (seen[(r + 1) * num_c + c] == 0):",
"+ tank.append([r + 1, c])",
"+ seen[(r + 1) * num_c + c] = 1",
"+ if (0 <= c - 1) and (seen[r * num_c + (c - 1)] == 0):",
"+ tank.append([r, c - 1])",
"+ seen[r * num_c + (c - 1)] = 1",
"+ if (c + 1 < num_c) and (seen[r * num_c + (c + 1)] == 0):",
"+ tank.append([r, c + 1])",
"+ seen[r * num_c + (c + 1)] = 1",
"+ count = count + 1",
"+ q = tank",
"+ print((count - 1))"
] | false | 0.086375 | 0.046135 | 1.872218 | [
"s887338264",
"s458326464"
] |
u136090046 | p03575 | python | s314873704 | s481987697 | 29 | 20 | 3,444 | 3,064 | Accepted | Accepted | 31.03 | import copy
n, m = list(map(int, input().split()))
array = [[int(x) for x in input().split()] for y in range(m)]
t = copy.copy(array)
def solver(start, array, visited, cnt):
if visited[start]:
return cnt
else:
visited[start] = True
for i in array[start]:
if len(set(visited)) == 1:
return 1
else:
cnt = solver(i, array, visited, cnt)
return cnt
res2 = 0
for i in range(m):
tmp = array[:i] + array[i + 1:]
modify = [[] for x in range(n + 1)]
for value1, value2 in tmp:
modify[value1].append(value2)
modify[value2].append(value1)
visited = [False if x != 0 and x != 1 else True for x in range(n + 1)]
if not modify[1]:
continue
res = 0
for i in modify[1]:
res += solver(i, modify, visited, 0)
else:
res2 += 1 if res > 0 else 0
print((m - res2))
| n, m = list(map(int, input().split()))
ab_array = [[int(x) for x in input().split()] for y in range(m)]
graph = [[] for x in range(n + 1)]
def dfs(graph, now, a, b):
visited[now] = True
for next in graph[now]:
if (now == a and next == b) or (now == b and next == a):
continue
if not visited[next]:
dfs(graph, next, a, b)
return visited.count(False) == 1
for a, b in ab_array:
graph[a].append(b)
graph[b].append(a)
ans = 0
for a, b in ab_array:
start = a
end = b
visited = [False for x in range(n + 1)]
if dfs(graph, 1, a, b):
ans += 1
print((m - ans))
| 41 | 26 | 929 | 657 | import copy
n, m = list(map(int, input().split()))
array = [[int(x) for x in input().split()] for y in range(m)]
t = copy.copy(array)
def solver(start, array, visited, cnt):
if visited[start]:
return cnt
else:
visited[start] = True
for i in array[start]:
if len(set(visited)) == 1:
return 1
else:
cnt = solver(i, array, visited, cnt)
return cnt
res2 = 0
for i in range(m):
tmp = array[:i] + array[i + 1 :]
modify = [[] for x in range(n + 1)]
for value1, value2 in tmp:
modify[value1].append(value2)
modify[value2].append(value1)
visited = [False if x != 0 and x != 1 else True for x in range(n + 1)]
if not modify[1]:
continue
res = 0
for i in modify[1]:
res += solver(i, modify, visited, 0)
else:
res2 += 1 if res > 0 else 0
print((m - res2))
| n, m = list(map(int, input().split()))
ab_array = [[int(x) for x in input().split()] for y in range(m)]
graph = [[] for x in range(n + 1)]
def dfs(graph, now, a, b):
visited[now] = True
for next in graph[now]:
if (now == a and next == b) or (now == b and next == a):
continue
if not visited[next]:
dfs(graph, next, a, b)
return visited.count(False) == 1
for a, b in ab_array:
graph[a].append(b)
graph[b].append(a)
ans = 0
for a, b in ab_array:
start = a
end = b
visited = [False for x in range(n + 1)]
if dfs(graph, 1, a, b):
ans += 1
print((m - ans))
| false | 36.585366 | [
"-import copy",
"-",
"-array = [[int(x) for x in input().split()] for y in range(m)]",
"-t = copy.copy(array)",
"+ab_array = [[int(x) for x in input().split()] for y in range(m)]",
"+graph = [[] for x in range(n + 1)]",
"-def solver(start, array, visited, cnt):",
"- if visited[start]:",
"- return cnt",
"- else:",
"- visited[start] = True",
"- for i in array[start]:",
"- if len(set(visited)) == 1:",
"- return 1",
"- else:",
"- cnt = solver(i, array, visited, cnt)",
"- return cnt",
"+def dfs(graph, now, a, b):",
"+ visited[now] = True",
"+ for next in graph[now]:",
"+ if (now == a and next == b) or (now == b and next == a):",
"+ continue",
"+ if not visited[next]:",
"+ dfs(graph, next, a, b)",
"+ return visited.count(False) == 1",
"-res2 = 0",
"-for i in range(m):",
"- tmp = array[:i] + array[i + 1 :]",
"- modify = [[] for x in range(n + 1)]",
"- for value1, value2 in tmp:",
"- modify[value1].append(value2)",
"- modify[value2].append(value1)",
"- visited = [False if x != 0 and x != 1 else True for x in range(n + 1)]",
"- if not modify[1]:",
"- continue",
"- res = 0",
"- for i in modify[1]:",
"- res += solver(i, modify, visited, 0)",
"- else:",
"- res2 += 1 if res > 0 else 0",
"-print((m - res2))",
"+for a, b in ab_array:",
"+ graph[a].append(b)",
"+ graph[b].append(a)",
"+ans = 0",
"+for a, b in ab_array:",
"+ start = a",
"+ end = b",
"+ visited = [False for x in range(n + 1)]",
"+ if dfs(graph, 1, a, b):",
"+ ans += 1",
"+print((m - ans))"
] | false | 0.163851 | 0.078844 | 2.07816 | [
"s314873704",
"s481987697"
] |
u227082700 | p02911 | python | s990838780 | s092265907 | 269 | 245 | 4,808 | 8,632 | Accepted | Accepted | 8.92 | n,k,q=list(map(int,input().split()))
p=[0]*n
for i in range(q):p[int(eval(input()))-1]+=1
for i in range(n):
if k<=q-p[i]:print("No")
else:print("Yes") | n,k,q=list(map(int,input().split()))
k=q-k
a=[int(eval(input()))for _ in range(q)]
x=[0]*n
for i in a:x[i-1]+=1
for i in x:
if i>k:print('Yes')
else:print('No') | 6 | 8 | 148 | 159 | n, k, q = list(map(int, input().split()))
p = [0] * n
for i in range(q):
p[int(eval(input())) - 1] += 1
for i in range(n):
if k <= q - p[i]:
print("No")
else:
print("Yes")
| n, k, q = list(map(int, input().split()))
k = q - k
a = [int(eval(input())) for _ in range(q)]
x = [0] * n
for i in a:
x[i - 1] += 1
for i in x:
if i > k:
print("Yes")
else:
print("No")
| false | 25 | [
"-p = [0] * n",
"-for i in range(q):",
"- p[int(eval(input())) - 1] += 1",
"-for i in range(n):",
"- if k <= q - p[i]:",
"+k = q - k",
"+a = [int(eval(input())) for _ in range(q)]",
"+x = [0] * n",
"+for i in a:",
"+ x[i - 1] += 1",
"+for i in x:",
"+ if i > k:",
"+ print(\"Yes\")",
"+ else:",
"- else:",
"- print(\"Yes\")"
] | false | 0.044146 | 0.042237 | 1.045186 | [
"s990838780",
"s092265907"
] |
u845333844 | p03361 | python | s967258511 | s996358479 | 30 | 18 | 3,064 | 3,064 | Accepted | Accepted | 40 | h,w=list(map(int,input().split()))
l=[eval(input()) for i in range(h)]
ans='Yes'
for i in range(1,h-1):
for j in range(1,w-1):
if l[i][j]=='#':
if l[i-1][j]==l[i+1][j]==l[i][j-1]==l[i][j+1]=='.':
ans='No'
print(ans) | h,w=list(map(int,input().split()))
l=['.'*(w+2)]+['.'+eval(input())+'.' for i in range(h)]+['.'*(w+2)]
ans='Yes'
for i in range(1,h+1):
for j in range(1,w+1):
if l[i][j]=='#':
if l[i-1][j]==l[i+1][j]==l[i][j-1]==l[i][j+1]=='.':
ans='No'
print(ans) | 10 | 10 | 253 | 285 | h, w = list(map(int, input().split()))
l = [eval(input()) for i in range(h)]
ans = "Yes"
for i in range(1, h - 1):
for j in range(1, w - 1):
if l[i][j] == "#":
if l[i - 1][j] == l[i + 1][j] == l[i][j - 1] == l[i][j + 1] == ".":
ans = "No"
print(ans)
| h, w = list(map(int, input().split()))
l = ["." * (w + 2)] + ["." + eval(input()) + "." for i in range(h)] + ["." * (w + 2)]
ans = "Yes"
for i in range(1, h + 1):
for j in range(1, w + 1):
if l[i][j] == "#":
if l[i - 1][j] == l[i + 1][j] == l[i][j - 1] == l[i][j + 1] == ".":
ans = "No"
print(ans)
| false | 0 | [
"-l = [eval(input()) for i in range(h)]",
"+l = [\".\" * (w + 2)] + [\".\" + eval(input()) + \".\" for i in range(h)] + [\".\" * (w + 2)]",
"-for i in range(1, h - 1):",
"- for j in range(1, w - 1):",
"+for i in range(1, h + 1):",
"+ for j in range(1, w + 1):"
] | false | 0.035173 | 0.042005 | 0.83735 | [
"s967258511",
"s996358479"
] |
u596276291 | p03803 | python | s251407468 | s927165657 | 107 | 27 | 3,700 | 3,316 | Accepted | Accepted | 74.77 | from collections import defaultdict
def main():
A, B = list(map(int, input().split()))
if A == 1:
A += 100
if B == 1:
B += 100
if A == B:
print("Draw")
elif A > B:
print("Alice")
else:
print("Bob")
if __name__ == '__main__':
main()
| from collections import defaultdict
def main():
A, B = list(map(int, input().split()))
d = {1: 14}
if d.get(A, A) == d.get(B, B):
print("Draw")
elif d.get(A, A) > d.get(B, B):
print("Alice")
else:
print("Bob")
if __name__ == '__main__':
main()
| 21 | 17 | 320 | 307 | from collections import defaultdict
def main():
A, B = list(map(int, input().split()))
if A == 1:
A += 100
if B == 1:
B += 100
if A == B:
print("Draw")
elif A > B:
print("Alice")
else:
print("Bob")
if __name__ == "__main__":
main()
| from collections import defaultdict
def main():
A, B = list(map(int, input().split()))
d = {1: 14}
if d.get(A, A) == d.get(B, B):
print("Draw")
elif d.get(A, A) > d.get(B, B):
print("Alice")
else:
print("Bob")
if __name__ == "__main__":
main()
| false | 19.047619 | [
"- if A == 1:",
"- A += 100",
"- if B == 1:",
"- B += 100",
"- if A == B:",
"+ d = {1: 14}",
"+ if d.get(A, A) == d.get(B, B):",
"- elif A > B:",
"+ elif d.get(A, A) > d.get(B, B):"
] | false | 0.03772 | 0.037185 | 1.014393 | [
"s251407468",
"s927165657"
] |
u280667879 | p03078 | python | s415024025 | s291619247 | 193 | 151 | 38,044 | 35,560 | Accepted | Accepted | 21.76 | #!/usr/bin/python
import sys
import heapq
R=lambda:list(map(int,sys.stdin.readline().split()))
xa,xb,xc,k=R()
a=sorted(R())
b=sorted(R())
c=sorted(R())
h=set()
q=[[-(a[-1]+b[-1]+c[-1]),xa-1,xb-1,xc-1]]
for _ in range(k):
x,ya,yb,yc=heapq.heappop(q)
print((-x))
if ya>0 and (ya-1,yb,yc) not in h:
h.add((ya-1,yb,yc))
heapq.heappush(q,[x+a[ya]-a[ya-1],ya-1,yb,yc])
if yb>0 and (ya,yb-1,yc) not in h:
h.add((ya,yb-1,yc))
heapq.heappush(q,[x+b[yb]-b[yb-1],ya,yb-1,yc])
if yc>0 and (ya,yb,yc-1) not in h:
h.add((ya,yb,yc-1))
heapq.heappush(q,[x+c[yc]-c[yc-1],ya,yb,yc-1]) | import sys,heapq
R=lambda:list(map(int,sys.stdin.readline().split()))
x=list(R())
k=x.pop()
a=[sorted(R())for _ in range(3)]
h=set()
q=[[-sum(e[-1] for e in a)]+[e-1 for e in x]]
for _ in range(k):
y=heapq.heappop(q)
x=y.pop(0)
print((-x))
for i in range(3):
ny=list(y)
ny[i]-=1
if y[i] and tuple(ny) not in h:
h.add(tuple(ny))
heapq.heappush(q,[x+a[i][y[i]]-a[i][y[i]-1]]+ny) | 22 | 17 | 596 | 400 | #!/usr/bin/python
import sys
import heapq
R = lambda: list(map(int, sys.stdin.readline().split()))
xa, xb, xc, k = R()
a = sorted(R())
b = sorted(R())
c = sorted(R())
h = set()
q = [[-(a[-1] + b[-1] + c[-1]), xa - 1, xb - 1, xc - 1]]
for _ in range(k):
x, ya, yb, yc = heapq.heappop(q)
print((-x))
if ya > 0 and (ya - 1, yb, yc) not in h:
h.add((ya - 1, yb, yc))
heapq.heappush(q, [x + a[ya] - a[ya - 1], ya - 1, yb, yc])
if yb > 0 and (ya, yb - 1, yc) not in h:
h.add((ya, yb - 1, yc))
heapq.heappush(q, [x + b[yb] - b[yb - 1], ya, yb - 1, yc])
if yc > 0 and (ya, yb, yc - 1) not in h:
h.add((ya, yb, yc - 1))
heapq.heappush(q, [x + c[yc] - c[yc - 1], ya, yb, yc - 1])
| import sys, heapq
R = lambda: list(map(int, sys.stdin.readline().split()))
x = list(R())
k = x.pop()
a = [sorted(R()) for _ in range(3)]
h = set()
q = [[-sum(e[-1] for e in a)] + [e - 1 for e in x]]
for _ in range(k):
y = heapq.heappop(q)
x = y.pop(0)
print((-x))
for i in range(3):
ny = list(y)
ny[i] -= 1
if y[i] and tuple(ny) not in h:
h.add(tuple(ny))
heapq.heappush(q, [x + a[i][y[i]] - a[i][y[i] - 1]] + ny)
| false | 22.727273 | [
"-#!/usr/bin/python",
"-import sys",
"-import heapq",
"+import sys, heapq",
"-xa, xb, xc, k = R()",
"-a = sorted(R())",
"-b = sorted(R())",
"-c = sorted(R())",
"+x = list(R())",
"+k = x.pop()",
"+a = [sorted(R()) for _ in range(3)]",
"-q = [[-(a[-1] + b[-1] + c[-1]), xa - 1, xb - 1, xc - 1]]",
"+q = [[-sum(e[-1] for e in a)] + [e - 1 for e in x]]",
"- x, ya, yb, yc = heapq.heappop(q)",
"+ y = heapq.heappop(q)",
"+ x = y.pop(0)",
"- if ya > 0 and (ya - 1, yb, yc) not in h:",
"- h.add((ya - 1, yb, yc))",
"- heapq.heappush(q, [x + a[ya] - a[ya - 1], ya - 1, yb, yc])",
"- if yb > 0 and (ya, yb - 1, yc) not in h:",
"- h.add((ya, yb - 1, yc))",
"- heapq.heappush(q, [x + b[yb] - b[yb - 1], ya, yb - 1, yc])",
"- if yc > 0 and (ya, yb, yc - 1) not in h:",
"- h.add((ya, yb, yc - 1))",
"- heapq.heappush(q, [x + c[yc] - c[yc - 1], ya, yb, yc - 1])",
"+ for i in range(3):",
"+ ny = list(y)",
"+ ny[i] -= 1",
"+ if y[i] and tuple(ny) not in h:",
"+ h.add(tuple(ny))",
"+ heapq.heappush(q, [x + a[i][y[i]] - a[i][y[i] - 1]] + ny)"
] | false | 0.123144 | 0.044543 | 2.764599 | [
"s415024025",
"s291619247"
] |
u403234553 | p02694 | python | s836474897 | s261297326 | 22 | 20 | 9,160 | 9,156 | Accepted | Accepted | 9.09 | n = 0
m = 100
X = int(eval(input()))
while m < X:
m += (m // 100)
n += 1
print(n)
| X = int(eval(input()))
n = 0
x = 100
while x < X:
x += x // 100
n += 1
print(n) | 7 | 7 | 90 | 83 | n = 0
m = 100
X = int(eval(input()))
while m < X:
m += m // 100
n += 1
print(n)
| X = int(eval(input()))
n = 0
x = 100
while x < X:
x += x // 100
n += 1
print(n)
| false | 0 | [
"+X = int(eval(input()))",
"-m = 100",
"-X = int(eval(input()))",
"-while m < X:",
"- m += m // 100",
"+x = 100",
"+while x < X:",
"+ x += x // 100"
] | false | 0.04632 | 0.046459 | 0.996998 | [
"s836474897",
"s261297326"
] |
u334712262 | p02693 | python | s173979705 | s016030435 | 569 | 66 | 76,908 | 61,956 | Accepted | Accepted | 88.4 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(K, A, B):
ans = 0
for i in range(100000):
if A <= i*K <= B:
return 'OK'
if i * K > B:
break
return 'NG'
def main():
K = read_int()
A, B = read_int_n()
print(slv(K, A, B))
if __name__ == '__main__':
main()
| # -*- coding: utf-8 -*-
INF = 2**62-1
def read_int():
return int(eval(input()))
def read_int_n():
return list(map(int, input().split()))
def slv(K, A, B):
for i in range(INF):
if A <= i*K <= B:
return 'OK'
if i * K > B:
break
return 'NG'
def main():
K = read_int()
A, B = read_int_n()
print((slv(K, A, B)))
if __name__ == '__main__':
main()
| 77 | 29 | 1,408 | 443 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62 - 1
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
@mt
def slv(K, A, B):
ans = 0
for i in range(100000):
if A <= i * K <= B:
return "OK"
if i * K > B:
break
return "NG"
def main():
K = read_int()
A, B = read_int_n()
print(slv(K, A, B))
if __name__ == "__main__":
main()
| # -*- coding: utf-8 -*-
INF = 2**62 - 1
def read_int():
return int(eval(input()))
def read_int_n():
return list(map(int, input().split()))
def slv(K, A, B):
for i in range(INF):
if A <= i * K <= B:
return "OK"
if i * K > B:
break
return "NG"
def main():
K = read_int()
A, B = read_int_n()
print((slv(K, A, B)))
if __name__ == "__main__":
main()
| false | 62.337662 | [
"-import bisect",
"-import heapq",
"-import math",
"-import random",
"-import sys",
"-from collections import Counter, defaultdict, deque",
"-from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal",
"-from functools import lru_cache, reduce",
"-from itertools import combinations, combinations_with_replacement, product, permutations",
"-from operator import add, mul, sub",
"-",
"-# sys.setrecursionlimit(100000)",
"-input = sys.stdin.buffer.readline",
"- return int(input())",
"+ return int(eval(input()))",
"-def read_float():",
"- return float(input())",
"-",
"-",
"-def read_float_n():",
"- return list(map(float, input().split()))",
"-",
"-",
"-def read_str():",
"- return input().strip()",
"-",
"-",
"-def read_str_n():",
"- return list(map(str, input().split()))",
"-",
"-",
"-def error_print(*args):",
"- print(*args, file=sys.stderr)",
"-",
"-",
"-def mt(f):",
"- import time",
"-",
"- def wrap(*args, **kwargs):",
"- s = time.time()",
"- ret = f(*args, **kwargs)",
"- e = time.time()",
"- error_print(e - s, \"sec\")",
"- return ret",
"-",
"- return wrap",
"-",
"-",
"-@mt",
"- ans = 0",
"- for i in range(100000):",
"+ for i in range(INF):",
"- print(slv(K, A, B))",
"+ print((slv(K, A, B)))"
] | false | 0.074276 | 0.062292 | 1.192387 | [
"s173979705",
"s016030435"
] |
u644907318 | p03800 | python | s982316068 | s177438459 | 194 | 98 | 4,340 | 75,516 | Accepted | Accepted | 49.48 | def f(x,y,z):
if x=="S" and y=="o":
return z
if x=="S" and y=="x":
return g(z)
if x=="W" and y=="o":
return g(z)
if x=="W" and y=="x":
return z
def g(x):
if x=="S":
return "W"
if x=="W":
return "S"
def check(x,y):
t[0]=x
t[1]=y
for j in range(1,N-1):
t[j+1] = f(t[j],s[j],t[j-1])
x1 = f(t[N-1],s[N-1],t[N-2])
y1 = f(x1,s[0],t[N-1])
if x==x1 and y==y1:
return True
else:
return False
N = int(eval(input()))
s = input().strip()
t = [0 for _ in range(N)]
if check("S","S"):
print(("".join(t)))
elif check("S","W"):
print(("".join(t)))
elif check("W","S"):
print(("".join(t)))
elif check("W","W"):
print(("".join(t)))
else:
print((-1)) | N = int(eval(input()))
s = input().strip()
flag = 1
A = [0 for _ in range(N)]
for a in range(2):
for b in range(2):
A[0]=a
A[1]=b
for i in range(1,N-1):
if A[i]==0 and s[i]=="o":
A[i+1]=A[i-1]
elif A[i]==0 and s[i]=="x":
A[i+1]=1-A[i-1]
elif A[i]==1 and s[i]=="o":
A[i+1]=1-A[i-1]
elif A[i]==1 and s[i]=="x":
A[i+1]=A[i-1]
if A[N-1]==0 and s[N-1]=="o":
if A[0]==A[N-2]:
flag = 0
else:
flag = 1
continue
elif A[N-1]==0 and s[N-1]=="x":
if A[0]==1-A[N-2]:
flag = 0
else:
flag = 1
continue
elif A[N-1]==1 and s[N-1]=="o":
if A[0]==1-A[N-2]:
flag = 0
else:
flag = 1
continue
elif A[N-1]==1 and s[N-1]=="x":
if A[0]==A[N-2]:
flag = 0
else:
flag =1
continue
if A[0]==0 and s[0]=="o":
if A[1]==A[N-1]:
flag = 0
else:
flag =1
continue
elif A[0]==0 and s[0]=="x":
if A[1]==1-A[N-1]:
flag = 0
else:
flag = 1
continue
elif A[0]==1 and s[0]=="o":
if A[1]==1-A[N-1]:
flag = 0
else:
flag = 1
continue
elif A[0]==1 and s[0]=="x":
if A[1]==A[N-1]:
flag = 0
else:
flag = 1
continue
if flag==0:
B = []
for i in range(N):
if A[i]==0:
B.append("S")
else:
B.append("W")
break
if flag==0:break
if flag==1:
print((-1))
else:
print(("".join(B))) | 38 | 78 | 796 | 2,096 | def f(x, y, z):
if x == "S" and y == "o":
return z
if x == "S" and y == "x":
return g(z)
if x == "W" and y == "o":
return g(z)
if x == "W" and y == "x":
return z
def g(x):
if x == "S":
return "W"
if x == "W":
return "S"
def check(x, y):
t[0] = x
t[1] = y
for j in range(1, N - 1):
t[j + 1] = f(t[j], s[j], t[j - 1])
x1 = f(t[N - 1], s[N - 1], t[N - 2])
y1 = f(x1, s[0], t[N - 1])
if x == x1 and y == y1:
return True
else:
return False
N = int(eval(input()))
s = input().strip()
t = [0 for _ in range(N)]
if check("S", "S"):
print(("".join(t)))
elif check("S", "W"):
print(("".join(t)))
elif check("W", "S"):
print(("".join(t)))
elif check("W", "W"):
print(("".join(t)))
else:
print((-1))
| N = int(eval(input()))
s = input().strip()
flag = 1
A = [0 for _ in range(N)]
for a in range(2):
for b in range(2):
A[0] = a
A[1] = b
for i in range(1, N - 1):
if A[i] == 0 and s[i] == "o":
A[i + 1] = A[i - 1]
elif A[i] == 0 and s[i] == "x":
A[i + 1] = 1 - A[i - 1]
elif A[i] == 1 and s[i] == "o":
A[i + 1] = 1 - A[i - 1]
elif A[i] == 1 and s[i] == "x":
A[i + 1] = A[i - 1]
if A[N - 1] == 0 and s[N - 1] == "o":
if A[0] == A[N - 2]:
flag = 0
else:
flag = 1
continue
elif A[N - 1] == 0 and s[N - 1] == "x":
if A[0] == 1 - A[N - 2]:
flag = 0
else:
flag = 1
continue
elif A[N - 1] == 1 and s[N - 1] == "o":
if A[0] == 1 - A[N - 2]:
flag = 0
else:
flag = 1
continue
elif A[N - 1] == 1 and s[N - 1] == "x":
if A[0] == A[N - 2]:
flag = 0
else:
flag = 1
continue
if A[0] == 0 and s[0] == "o":
if A[1] == A[N - 1]:
flag = 0
else:
flag = 1
continue
elif A[0] == 0 and s[0] == "x":
if A[1] == 1 - A[N - 1]:
flag = 0
else:
flag = 1
continue
elif A[0] == 1 and s[0] == "o":
if A[1] == 1 - A[N - 1]:
flag = 0
else:
flag = 1
continue
elif A[0] == 1 and s[0] == "x":
if A[1] == A[N - 1]:
flag = 0
else:
flag = 1
continue
if flag == 0:
B = []
for i in range(N):
if A[i] == 0:
B.append("S")
else:
B.append("W")
break
if flag == 0:
break
if flag == 1:
print((-1))
else:
print(("".join(B)))
| false | 51.282051 | [
"-def f(x, y, z):",
"- if x == \"S\" and y == \"o\":",
"- return z",
"- if x == \"S\" and y == \"x\":",
"- return g(z)",
"- if x == \"W\" and y == \"o\":",
"- return g(z)",
"- if x == \"W\" and y == \"x\":",
"- return z",
"-",
"-",
"-def g(x):",
"- if x == \"S\":",
"- return \"W\"",
"- if x == \"W\":",
"- return \"S\"",
"-",
"-",
"-def check(x, y):",
"- t[0] = x",
"- t[1] = y",
"- for j in range(1, N - 1):",
"- t[j + 1] = f(t[j], s[j], t[j - 1])",
"- x1 = f(t[N - 1], s[N - 1], t[N - 2])",
"- y1 = f(x1, s[0], t[N - 1])",
"- if x == x1 and y == y1:",
"- return True",
"- else:",
"- return False",
"-",
"-",
"-t = [0 for _ in range(N)]",
"-if check(\"S\", \"S\"):",
"- print((\"\".join(t)))",
"-elif check(\"S\", \"W\"):",
"- print((\"\".join(t)))",
"-elif check(\"W\", \"S\"):",
"- print((\"\".join(t)))",
"-elif check(\"W\", \"W\"):",
"- print((\"\".join(t)))",
"+flag = 1",
"+A = [0 for _ in range(N)]",
"+for a in range(2):",
"+ for b in range(2):",
"+ A[0] = a",
"+ A[1] = b",
"+ for i in range(1, N - 1):",
"+ if A[i] == 0 and s[i] == \"o\":",
"+ A[i + 1] = A[i - 1]",
"+ elif A[i] == 0 and s[i] == \"x\":",
"+ A[i + 1] = 1 - A[i - 1]",
"+ elif A[i] == 1 and s[i] == \"o\":",
"+ A[i + 1] = 1 - A[i - 1]",
"+ elif A[i] == 1 and s[i] == \"x\":",
"+ A[i + 1] = A[i - 1]",
"+ if A[N - 1] == 0 and s[N - 1] == \"o\":",
"+ if A[0] == A[N - 2]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ elif A[N - 1] == 0 and s[N - 1] == \"x\":",
"+ if A[0] == 1 - A[N - 2]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ elif A[N - 1] == 1 and s[N - 1] == \"o\":",
"+ if A[0] == 1 - A[N - 2]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ elif A[N - 1] == 1 and s[N - 1] == \"x\":",
"+ if A[0] == A[N - 2]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ if A[0] == 0 and s[0] == \"o\":",
"+ if A[1] == A[N - 1]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ elif A[0] == 0 and s[0] == \"x\":",
"+ if A[1] == 1 - A[N - 1]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ elif A[0] == 1 and s[0] == \"o\":",
"+ if A[1] == 1 - A[N - 1]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ elif A[0] == 1 and s[0] == \"x\":",
"+ if A[1] == A[N - 1]:",
"+ flag = 0",
"+ else:",
"+ flag = 1",
"+ continue",
"+ if flag == 0:",
"+ B = []",
"+ for i in range(N):",
"+ if A[i] == 0:",
"+ B.append(\"S\")",
"+ else:",
"+ B.append(\"W\")",
"+ break",
"+ if flag == 0:",
"+ break",
"+if flag == 1:",
"+ print((-1))",
"- print((-1))",
"+ print((\"\".join(B)))"
] | false | 0.047983 | 0.085164 | 0.563419 | [
"s982316068",
"s177438459"
] |
u481250941 | p02899 | python | s718469964 | s821353227 | 377 | 251 | 78,824 | 55,852 | Accepted | Accepted | 33.42 | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
I = list(range(1, N+1))
dic = dict(list(zip(I, A)))
dic2 = sorted(list(dic.items()), key=lambda x: x[1])
ans = []
for i in dic2:
ans.append(i[0])
print((*ans))
if __name__ == '__main__':
main()
| import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
ans = [None] * N
for i in range(N):
ans[A[i]-1] = i+1
print((*ans))
if __name__ == '__main__':
main()
| 21 | 18 | 374 | 285 | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
I = list(range(1, N + 1))
dic = dict(list(zip(I, A)))
dic2 = sorted(list(dic.items()), key=lambda x: x[1])
ans = []
for i in dic2:
ans.append(i[0])
print((*ans))
if __name__ == "__main__":
main()
| import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
ans = [None] * N
for i in range(N):
ans[A[i] - 1] = i + 1
print((*ans))
if __name__ == "__main__":
main()
| false | 14.285714 | [
"- I = list(range(1, N + 1))",
"- dic = dict(list(zip(I, A)))",
"- dic2 = sorted(list(dic.items()), key=lambda x: x[1])",
"- ans = []",
"- for i in dic2:",
"- ans.append(i[0])",
"+ ans = [None] * N",
"+ for i in range(N):",
"+ ans[A[i] - 1] = i + 1"
] | false | 0.141936 | 0.100651 | 1.410183 | [
"s718469964",
"s821353227"
] |
u671060652 | p02771 | python | s656899047 | s475745632 | 274 | 181 | 64,876 | 38,384 | Accepted | Accepted | 33.94 | import itertools
import math
import fractions
import functools
a, b, c = list(map(int, input().split()))
if (a == b and a != c) or (b == c and b != a) or (a == c and a != b):
print("Yes")
else: print("No") | a, b, c = list(map(int, input().split()))
if (a == b or a == c or b ==c) and not (a == b and a == c):
print("Yes")
else:print("No") | 8 | 4 | 210 | 132 | import itertools
import math
import fractions
import functools
a, b, c = list(map(int, input().split()))
if (a == b and a != c) or (b == c and b != a) or (a == c and a != b):
print("Yes")
else:
print("No")
| a, b, c = list(map(int, input().split()))
if (a == b or a == c or b == c) and not (a == b and a == c):
print("Yes")
else:
print("No")
| false | 50 | [
"-import itertools",
"-import math",
"-import fractions",
"-import functools",
"-",
"-if (a == b and a != c) or (b == c and b != a) or (a == c and a != b):",
"+if (a == b or a == c or b == c) and not (a == b and a == c):"
] | false | 0.04122 | 0.041876 | 0.984353 | [
"s656899047",
"s475745632"
] |
u607865971 | p03475 | python | s833039056 | s675589790 | 115 | 75 | 3,188 | 3,188 | Accepted | Accepted | 34.78 | import sys
import math
N = int(eval(input()))
C = []
S = []
F = []
for i in range(N - 1):
c, s, f = [int(x) for x in input().split()]
C.append(c)
S.append(s)
F.append(f)
def f(idx, t):
depT = -1
if t <= S[idx]:
depT = S[idx]
else:
depT = S[idx] + F[idx] * math.ceil((t - S[idx]) / F[idx])
return depT + C[idx]
for i in range(N - 1):
t = 0
for j in range(i, N - 1):
t = f(j, t)
print(t)
print((0))
| #!/usr/bin/python3
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7
#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]
N = int(eval(input()))
CSF = []
for _ in range(N-1):
C, S, F = [int(x) for x in input().split()]
CSF.append((C, S, F))
def f(i):
ans_r = [0]
cur = 0
for c, s, f in CSF[i:]:
cur = max(cur, s)
if cur % f != 0:
cur = cur + (f - (cur % f))
# print("出発:{}".format(cur))
cur += c
# print("到着:{}".format(cur))
ans_r.append(cur)
return ans_r[-1]
for i in range(N):
print((f(i))) | 31 | 33 | 494 | 689 | import sys
import math
N = int(eval(input()))
C = []
S = []
F = []
for i in range(N - 1):
c, s, f = [int(x) for x in input().split()]
C.append(c)
S.append(s)
F.append(f)
def f(idx, t):
depT = -1
if t <= S[idx]:
depT = S[idx]
else:
depT = S[idx] + F[idx] * math.ceil((t - S[idx]) / F[idx])
return depT + C[idx]
for i in range(N - 1):
t = 0
for j in range(i, N - 1):
t = f(j, t)
print(t)
print((0))
| #!/usr/bin/python3
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10**9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
N = int(eval(input()))
CSF = []
for _ in range(N - 1):
C, S, F = [int(x) for x in input().split()]
CSF.append((C, S, F))
def f(i):
ans_r = [0]
cur = 0
for c, s, f in CSF[i:]:
cur = max(cur, s)
if cur % f != 0:
cur = cur + (f - (cur % f))
# print("出発:{}".format(cur))
cur += c
# print("到着:{}".format(cur))
ans_r.append(cur)
return ans_r[-1]
for i in range(N):
print((f(i)))
| false | 6.060606 | [
"+#!/usr/bin/python3",
"-import math",
"+# input = sys.stdin.readline",
"+sys.setrecursionlimit(100000)",
"+MOD = 10**9 + 7",
"+# N = int(input())",
"+# A = [int(x) for x in input().split()]",
"+# V = [[0] * 100 for _ in range(100)]",
"-C = []",
"-S = []",
"-F = []",
"-for i in range(N - 1):",
"- c, s, f = [int(x) for x in input().split()]",
"- C.append(c)",
"- S.append(s)",
"- F.append(f)",
"+CSF = []",
"+for _ in range(N - 1):",
"+ C, S, F = [int(x) for x in input().split()]",
"+ CSF.append((C, S, F))",
"-def f(idx, t):",
"- depT = -1",
"- if t <= S[idx]:",
"- depT = S[idx]",
"- else:",
"- depT = S[idx] + F[idx] * math.ceil((t - S[idx]) / F[idx])",
"- return depT + C[idx]",
"+def f(i):",
"+ ans_r = [0]",
"+ cur = 0",
"+ for c, s, f in CSF[i:]:",
"+ cur = max(cur, s)",
"+ if cur % f != 0:",
"+ cur = cur + (f - (cur % f))",
"+ # print(\"出発:{}\".format(cur))",
"+ cur += c",
"+ # print(\"到着:{}\".format(cur))",
"+ ans_r.append(cur)",
"+ return ans_r[-1]",
"-for i in range(N - 1):",
"- t = 0",
"- for j in range(i, N - 1):",
"- t = f(j, t)",
"- print(t)",
"-print((0))",
"+for i in range(N):",
"+ print((f(i)))"
] | false | 0.036989 | 0.044092 | 0.838914 | [
"s833039056",
"s675589790"
] |
u642874916 | p03127 | python | s751074580 | s868423952 | 351 | 243 | 88,428 | 63,084 | Accepted | Accepted | 30.77 | import fractions
# N個の最大公約数
# ユークリッド互除法
def good(A, N):
# A = sorted(A)
ans = A[0]
for i in range(1, N):
ans = fractions.gcd(A[i], ans)
print(ans)
def my(A, N):
A = sorted(A)
while True:
v = A[0]
tmp = [v]
for i in range(len(A)):
if A[i] % v == 1:
print((1))
return
if A[i] % v == 0:
pass
else:
tmp.append(A[i] % v)
if len(A) == 1:
print((A[0]))
return
A = sorted(tmp)
# print(A)
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
good(A, N)
if __name__ == '__main__':
main()
| # N個の最大公約数
# ユークリッド互除法
# Check
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def lcm(a, b):
return a*b // gcd(a, b)
def good(A, N):
# A = sorted(A)
ans = A[0]
# for i in range(1, N):
# ans = fractions.gcd(A[i], ans)
for i in range(1, N):
ans = lcm(ans, A[i])
return ans
def my(A, N):
A = sorted(A)
while True:
v = A[0]
tmp = [v]
for i in range(len(A)):
if A[i] % v == 1:
print(1)
return
if A[i] % v == 0:
pass
else:
tmp.append(A[i] % v)
if len(A) == 1:
print(A[0])
return
A = sorted(tmp)
# print(A)
def main():
N = int(input())
A = list(map(int, input().split()))
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def show(*inp, end='\n'):
if show_flg:
print(*inp, end=end)
YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def main():
N = I()
A = LI()
n = A[0]
for i in range(1, N):
n = gcd(n, A[i])
print(n)
if __name__ == '__main__':
main()
| 46 | 126 | 764 | 2,208 | import fractions
# N個の最大公約数
# ユークリッド互除法
def good(A, N):
# A = sorted(A)
ans = A[0]
for i in range(1, N):
ans = fractions.gcd(A[i], ans)
print(ans)
def my(A, N):
A = sorted(A)
while True:
v = A[0]
tmp = [v]
for i in range(len(A)):
if A[i] % v == 1:
print((1))
return
if A[i] % v == 0:
pass
else:
tmp.append(A[i] % v)
if len(A) == 1:
print((A[0]))
return
A = sorted(tmp)
# print(A)
def main():
N = int(eval(input()))
A = list(map(int, input().split()))
good(A, N)
if __name__ == "__main__":
main()
| # N個の最大公約数
# ユークリッド互除法
# Check
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def lcm(a, b):
return a * b // gcd(a, b)
def good(A, N):
# A = sorted(A)
ans = A[0]
# for i in range(1, N):
# ans = fractions.gcd(A[i], ans)
for i in range(1, N):
ans = lcm(ans, A[i])
return ans
def my(A, N):
A = sorted(A)
while True:
v = A[0]
tmp = [v]
for i in range(len(A)):
if A[i] % v == 1:
print(1)
return
if A[i] % v == 0:
pass
else:
tmp.append(A[i] % v)
if len(A) == 1:
print(A[0])
return
A = sorted(tmp)
# print(A)
def main():
N = int(input())
A = list(map(int, input().split()))
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I():
return int(input())
def S():
return input()
def MI():
return map(int, input().split())
def MS():
return map(str, input().split())
def LI():
return [int(i) for i in input().split()]
def LI_():
return [int(i) - 1 for i in input().split()]
def StoI():
return [ord(i) - 97 for i in input()]
def ItoS(nn):
return chr(nn + 97)
def input():
return sys.stdin.readline().rstrip()
def show(*inp, end="\n"):
if show_flg:
print(*inp, end=end)
YNL = {False: "No", True: "Yes"}
YNU = {False: "NO", True: "YES"}
MOD = 10**9 + 7
inf = float("inf")
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
show_flg = False
# show_flg = True
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def main():
N = I()
A = LI()
n = A[0]
for i in range(1, N):
n = gcd(n, A[i])
print(n)
if __name__ == "__main__":
main()
| false | 63.492063 | [
"-import fractions",
"-",
"+# Check",
"+def gcd(a, b):",
"+ if b == 0:",
"+ return a",
"+ return gcd(b, a % b)",
"+",
"+",
"+def lcm(a, b):",
"+ return a * b // gcd(a, b)",
"+",
"+",
"+ # for i in range(1, N):",
"+ # ans = fractions.gcd(A[i], ans)",
"- ans = fractions.gcd(A[i], ans)",
"- print(ans)",
"+ ans = lcm(ans, A[i])",
"+ return ans",
"- print((1))",
"+ print(1)",
"- print((A[0]))",
"+ print(A[0])",
"- N = int(eval(input()))",
"+ N = int(input())",
"- good(A, N)",
"+",
"+",
"+from heapq import heappush, heappop, heapify",
"+from collections import deque, defaultdict, Counter",
"+import itertools",
"+from itertools import permutations, combinations, accumulate",
"+import sys",
"+import bisect",
"+import string",
"+import math",
"+import time",
"+",
"+",
"+def I():",
"+ return int(input())",
"+",
"+",
"+def S():",
"+ return input()",
"+",
"+",
"+def MI():",
"+ return map(int, input().split())",
"+",
"+",
"+def MS():",
"+ return map(str, input().split())",
"+",
"+",
"+def LI():",
"+ return [int(i) for i in input().split()]",
"+",
"+",
"+def LI_():",
"+ return [int(i) - 1 for i in input().split()]",
"+",
"+",
"+def StoI():",
"+ return [ord(i) - 97 for i in input()]",
"+",
"+",
"+def ItoS(nn):",
"+ return chr(nn + 97)",
"+",
"+",
"+def input():",
"+ return sys.stdin.readline().rstrip()",
"+",
"+",
"+def show(*inp, end=\"\\n\"):",
"+ if show_flg:",
"+ print(*inp, end=end)",
"+",
"+",
"+YNL = {False: \"No\", True: \"Yes\"}",
"+YNU = {False: \"NO\", True: \"YES\"}",
"+MOD = 10**9 + 7",
"+inf = float(\"inf\")",
"+IINF = 10**10",
"+l_alp = string.ascii_lowercase",
"+u_alp = string.ascii_uppercase",
"+ts = time.time()",
"+sys.setrecursionlimit(10**6)",
"+nums = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\"]",
"+show_flg = False",
"+# show_flg = True",
"+def gcd(a, b):",
"+ if b == 0:",
"+ return a",
"+ return gcd(b, a % b)",
"+",
"+",
"+def main():",
"+ N = I()",
"+ A = LI()",
"+ n = A[0]",
"+ for i in range(1, N):",
"+ n = gcd(n, A[i])",
"+ print(n)"
] | false | 0.040781 | 0.037377 | 1.091073 | [
"s751074580",
"s868423952"
] |
u753803401 | p02886 | python | s954943566 | s382788179 | 175 | 161 | 38,512 | 38,512 | Accepted | Accepted | 8 | import sys
import itertools
def solve():
input = sys.stdin.readline
mod = 10 ** 9 + 7
n = int(input().rstrip('\n'))
d = list(map(int, input().rstrip('\n').split()))
t = 0
for v in itertools.combinations(d, 2):
t += (v[0] * v[1])
print(t)
if __name__ == '__main__':
solve()
| import sys
import itertools
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
t = 0
for v in itertools.combinations(a, 2):
t += v[0] * v[1]
print(t)
if __name__ == '__main__':
solve()
| 17 | 17 | 333 | 321 | import sys
import itertools
def solve():
input = sys.stdin.readline
mod = 10**9 + 7
n = int(input().rstrip("\n"))
d = list(map(int, input().rstrip("\n").split()))
t = 0
for v in itertools.combinations(d, 2):
t += v[0] * v[1]
print(t)
if __name__ == "__main__":
solve()
| import sys
import itertools
def solve():
readline = sys.stdin.buffer.readline
mod = 10**9 + 7
n = int(readline())
a = list(map(int, readline().split()))
t = 0
for v in itertools.combinations(a, 2):
t += v[0] * v[1]
print(t)
if __name__ == "__main__":
solve()
| false | 0 | [
"- input = sys.stdin.readline",
"+ readline = sys.stdin.buffer.readline",
"- n = int(input().rstrip(\"\\n\"))",
"- d = list(map(int, input().rstrip(\"\\n\").split()))",
"+ n = int(readline())",
"+ a = list(map(int, readline().split()))",
"- for v in itertools.combinations(d, 2):",
"+ for v in itertools.combinations(a, 2):"
] | false | 0.065091 | 0.040571 | 1.604375 | [
"s954943566",
"s382788179"
] |
u836939578 | p02787 | python | s626037892 | s946808487 | 451 | 415 | 41,836 | 41,708 | Accepted | Accepted | 7.98 | H, N = list(map(int, input().split()))
A, B = [0] * N, [0] * N
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
dp = [[10**9]*(H+1)]*(N+1)
dp[0][0] = 0
for i in range(N):
for j in range(H+1):
nj = min(j+A[i], H)
dp[i+1][nj] = min(dp[i][nj], dp[i+1][j] + B[i])
print((dp[N][H])) | H, N = list(map(int, input().split()))
A, B = [0] * N, [0] * N
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
dp = [10**9] * (H+1)
dp[0] = 0
for i in range(N):
for j in range(H+1):
nj = min(j+A[i], H)
dp[nj] = min(dp[nj], dp[j]+B[i])
print((dp[H])) | 17 | 15 | 324 | 293 | H, N = list(map(int, input().split()))
A, B = [0] * N, [0] * N
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
dp = [[10**9] * (H + 1)] * (N + 1)
dp[0][0] = 0
for i in range(N):
for j in range(H + 1):
nj = min(j + A[i], H)
dp[i + 1][nj] = min(dp[i][nj], dp[i + 1][j] + B[i])
print((dp[N][H]))
| H, N = list(map(int, input().split()))
A, B = [0] * N, [0] * N
for i in range(N):
A[i], B[i] = list(map(int, input().split()))
dp = [10**9] * (H + 1)
dp[0] = 0
for i in range(N):
for j in range(H + 1):
nj = min(j + A[i], H)
dp[nj] = min(dp[nj], dp[j] + B[i])
print((dp[H]))
| false | 11.764706 | [
"-dp = [[10**9] * (H + 1)] * (N + 1)",
"-dp[0][0] = 0",
"+dp = [10**9] * (H + 1)",
"+dp[0] = 0",
"- dp[i + 1][nj] = min(dp[i][nj], dp[i + 1][j] + B[i])",
"-print((dp[N][H]))",
"+ dp[nj] = min(dp[nj], dp[j] + B[i])",
"+print((dp[H]))"
] | false | 0.103171 | 0.272204 | 0.37902 | [
"s626037892",
"s946808487"
] |
u352394527 | p00429 | python | s208043471 | s836560120 | 140 | 100 | 7,568 | 7,580 | Accepted | Accepted | 28.57 | while True:
n = int(eval(input()))
if not n:
break
ss = [s for s in input()[::-1]]
for i in range(n):
new = []
app = new.append
last = ss.pop()
count = 1
while ss:
a = ss.pop()
if a == last:
count += 1
else:
app(str(count))
app(last)
last = a
count = 1
app(str(count))
app(last)
new = "".join(new)
ss = [s for s in new[::-1]]
# print("".join(new))
print(("".join(new)))
| def main():
while True:
n = int(eval(input()))
if not n:
break
ss = [s for s in input()[::-1]]
for i in range(n):
new = []
app = new.append
last = ss.pop()
count = 1
while ss:
a = ss.pop()
if a == last:
count += 1
else:
app(str(count))
app(last)
last = a
count = 1
app(str(count))
app(last)
new = "".join(new)
ss = [s for s in new[::-1]]
# print("".join(new))
print(("".join(new)))
main()
| 25 | 28 | 497 | 570 | while True:
n = int(eval(input()))
if not n:
break
ss = [s for s in input()[::-1]]
for i in range(n):
new = []
app = new.append
last = ss.pop()
count = 1
while ss:
a = ss.pop()
if a == last:
count += 1
else:
app(str(count))
app(last)
last = a
count = 1
app(str(count))
app(last)
new = "".join(new)
ss = [s for s in new[::-1]]
# print("".join(new))
print(("".join(new)))
| def main():
while True:
n = int(eval(input()))
if not n:
break
ss = [s for s in input()[::-1]]
for i in range(n):
new = []
app = new.append
last = ss.pop()
count = 1
while ss:
a = ss.pop()
if a == last:
count += 1
else:
app(str(count))
app(last)
last = a
count = 1
app(str(count))
app(last)
new = "".join(new)
ss = [s for s in new[::-1]]
# print("".join(new))
print(("".join(new)))
main()
| false | 10.714286 | [
"-while True:",
"- n = int(eval(input()))",
"- if not n:",
"- break",
"- ss = [s for s in input()[::-1]]",
"- for i in range(n):",
"- new = []",
"- app = new.append",
"- last = ss.pop()",
"- count = 1",
"- while ss:",
"- a = ss.pop()",
"- if a == last:",
"- count += 1",
"- else:",
"- app(str(count))",
"- app(last)",
"- last = a",
"- count = 1",
"- app(str(count))",
"- app(last)",
"- new = \"\".join(new)",
"- ss = [s for s in new[::-1]]",
"- # print(\"\".join(new))",
"- print((\"\".join(new)))",
"+def main():",
"+ while True:",
"+ n = int(eval(input()))",
"+ if not n:",
"+ break",
"+ ss = [s for s in input()[::-1]]",
"+ for i in range(n):",
"+ new = []",
"+ app = new.append",
"+ last = ss.pop()",
"+ count = 1",
"+ while ss:",
"+ a = ss.pop()",
"+ if a == last:",
"+ count += 1",
"+ else:",
"+ app(str(count))",
"+ app(last)",
"+ last = a",
"+ count = 1",
"+ app(str(count))",
"+ app(last)",
"+ new = \"\".join(new)",
"+ ss = [s for s in new[::-1]]",
"+ # print(\"\".join(new))",
"+ print((\"\".join(new)))",
"+",
"+",
"+main()"
] | false | 0.042765 | 0.035748 | 1.196268 | [
"s208043471",
"s836560120"
] |
u204800924 | p02659 | python | s408471597 | s480310999 | 33 | 24 | 10,056 | 9,044 | Accepted | Accepted | 27.27 | from decimal import Decimal
a, b = input().split()
a = Decimal(a)
b = Decimal(b)
print((int(a*b))) | a, b = input().split()
a = int(a)
b = int(b.replace('.', ''))
ans = a * b // 100
print(ans) | 8 | 7 | 106 | 101 | from decimal import Decimal
a, b = input().split()
a = Decimal(a)
b = Decimal(b)
print((int(a * b)))
| a, b = input().split()
a = int(a)
b = int(b.replace(".", ""))
ans = a * b // 100
print(ans)
| false | 12.5 | [
"-from decimal import Decimal",
"-",
"-a = Decimal(a)",
"-b = Decimal(b)",
"-print((int(a * b)))",
"+a = int(a)",
"+b = int(b.replace(\".\", \"\"))",
"+ans = a * b // 100",
"+print(ans)"
] | false | 0.035836 | 0.043733 | 0.819418 | [
"s408471597",
"s480310999"
] |
u906501980 | p02901 | python | s271882452 | s521605171 | 883 | 767 | 3,188 | 3,188 | Accepted | Accepted | 13.14 | def main():
n, m = list(map(int, input().split()))
p = 2**n
inf = float('inf')
dp = [inf]*p
dp[0] = 0
for _ in range(m):
a, _ = list(map(int, input().split()))
c = sum([2**(int(i)-1) for i in input().split()])
for s in range(p):
t = s|c
if dp[t] > dp[s] + a:
dp[t] = dp[s] + a
ans = dp[-1]
if ans == inf:
ans = -1
print(ans)
if __name__ == '__main__':
main() | def main():
n, m = list(map(int, input().split()))
p = 2**n
inf = 10**7
dp = [inf]*p
dp[0] = 0
for _ in range(m):
a, _ = list(map(int, input().split()))
c = sum([1<<(int(i)-1) for i in input().split()])
for s in range(p):
t = s|c
new = dp[s] + a
if dp[t] > new:
dp[t] = new
ans = dp[-1]
if ans == inf:
ans = -1
print(ans)
if __name__ == '__main__':
main() | 20 | 21 | 490 | 504 | def main():
n, m = list(map(int, input().split()))
p = 2**n
inf = float("inf")
dp = [inf] * p
dp[0] = 0
for _ in range(m):
a, _ = list(map(int, input().split()))
c = sum([2 ** (int(i) - 1) for i in input().split()])
for s in range(p):
t = s | c
if dp[t] > dp[s] + a:
dp[t] = dp[s] + a
ans = dp[-1]
if ans == inf:
ans = -1
print(ans)
if __name__ == "__main__":
main()
| def main():
n, m = list(map(int, input().split()))
p = 2**n
inf = 10**7
dp = [inf] * p
dp[0] = 0
for _ in range(m):
a, _ = list(map(int, input().split()))
c = sum([1 << (int(i) - 1) for i in input().split()])
for s in range(p):
t = s | c
new = dp[s] + a
if dp[t] > new:
dp[t] = new
ans = dp[-1]
if ans == inf:
ans = -1
print(ans)
if __name__ == "__main__":
main()
| false | 4.761905 | [
"- inf = float(\"inf\")",
"+ inf = 10**7",
"- c = sum([2 ** (int(i) - 1) for i in input().split()])",
"+ c = sum([1 << (int(i) - 1) for i in input().split()])",
"- if dp[t] > dp[s] + a:",
"- dp[t] = dp[s] + a",
"+ new = dp[s] + a",
"+ if dp[t] > new:",
"+ dp[t] = new"
] | false | 0.059583 | 0.039552 | 1.506442 | [
"s271882452",
"s521605171"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.