user_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 1
value | submission_id_v0 stringlengths 10 10 | submission_id_v1 stringlengths 10 10 | cpu_time_v0 int64 10 38.3k | cpu_time_v1 int64 0 24.7k | memory_v0 int64 2.57k 1.02M | memory_v1 int64 2.57k 869k | status_v0 stringclasses 1
value | status_v1 stringclasses 1
value | improvement_frac float64 7.51 100 | input stringlengths 20 4.55k | target stringlengths 17 3.34k | code_v0_loc int64 1 148 | code_v1_loc int64 1 184 | code_v0_num_chars int64 13 4.55k | code_v1_num_chars int64 14 3.34k | code_v0_no_empty_lines stringlengths 21 6.88k | code_v1_no_empty_lines stringlengths 20 4.93k | code_same bool 1
class | relative_loc_diff_percent float64 0 79.8 | diff list | diff_only_import_comment bool 1
class | measured_runtime_v0 float64 0.01 4.45 | measured_runtime_v1 float64 0.01 4.31 | runtime_lift float64 0 359 | key list |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u119982001 | p03325 | python | s974145388 | s781322014 | 178 | 122 | 4,148 | 4,148 | Accepted | Accepted | 31.46 | from math import log2
N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
tmp = a[i]
while a[i]%2 != 1:
if a[i]%2 == 0:
ans += 1
a[i] /= 2
print(ans)
| from math import log2
N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
while a[i]%2 != 1:
ans += 1
a[i] /= 2
print(ans)
| 14 | 12 | 239 | 190 | from math import log2
N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
tmp = a[i]
while a[i] % 2 != 1:
if a[i] % 2 == 0:
ans += 1
a[i] /= 2
print(ans)
| from math import log2
N = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
for i in range(len(a)):
while a[i] % 2 != 1:
ans += 1
a[i] /= 2
print(ans)
| false | 14.285714 | [
"- tmp = a[i]",
"- if a[i] % 2 == 0:",
"- ans += 1",
"- a[i] /= 2",
"+ ans += 1",
"+ a[i] /= 2"
] | false | 0.041368 | 0.041563 | 0.995323 | [
"s974145388",
"s781322014"
] |
u600402037 | p02947 | python | s954376785 | s461128606 | 792 | 258 | 26,844 | 19,724 | Accepted | Accepted | 67.42 | import sys
from collections import Counter, defaultdict
from math import factorial
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def combinations_count(n, r): # 組み合わせ
return factorial(n) // (factorial(n - r) * factorial(r))
N = ir()
S = de... | import sys
from collections import Counter
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
S = [''.join(sorted(list(sr()))) for _ in range(N)]
counter = Counter(S)
answer = sum(x*(x-1)//2 for x in list(counter.values()))
print(answer)
| 29 | 13 | 610 | 313 | import sys
from collections import Counter, defaultdict
from math import factorial
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def combinations_count(n, r): # 組み合わせ
return factorial(n) // (factorial(n - r) * factorial(r))
N = ir()
S = defaultdict... | import sys
from collections import Counter
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
S = ["".join(sorted(list(sr()))) for _ in range(N)]
counter = Counter(S)
answer = sum(x * (x - 1) // 2 for x in list(counter.values()))
print(answer)
| false | 55.172414 | [
"-from collections import Counter, defaultdict",
"-from math import factorial",
"+from collections import Counter",
"-",
"-",
"-def combinations_count(n, r): # 組み合わせ",
"- return factorial(n) // (factorial(n - r) * factorial(r))",
"-",
"-",
"-S = defaultdict(int)",
"-for _ in range(N):",
"-... | false | 0.102215 | 0.04556 | 2.243538 | [
"s954376785",
"s461128606"
] |
u626891113 | p02572 | python | s732988176 | s905468325 | 415 | 140 | 117,584 | 103,804 | Accepted | Accepted | 66.27 | n = int(eval(input()))
a = list(map(int, input().split()))
a = [i % (10**9 + 7) for i in a]
val = sum(a[1:])
l = [val]
for i in range(1, n):
val -= a[i]
l.append(val)
ans = 0
for i in range(n - 1):
ans += a[i]*l[i]
ans %= 10**9 + 7
print(ans) | n = int(eval(input()))
a = list(map(int, input().split()))
a = [i % (10**9 + 7) for i in a]
val = sum(a[1:])
ans = 0
for i in range(n - 1):
ans += a[i]*val
ans %= 10**9 + 7
val -= a[i + 1]
print(ans) | 13 | 11 | 264 | 216 | n = int(eval(input()))
a = list(map(int, input().split()))
a = [i % (10**9 + 7) for i in a]
val = sum(a[1:])
l = [val]
for i in range(1, n):
val -= a[i]
l.append(val)
ans = 0
for i in range(n - 1):
ans += a[i] * l[i]
ans %= 10**9 + 7
print(ans)
| n = int(eval(input()))
a = list(map(int, input().split()))
a = [i % (10**9 + 7) for i in a]
val = sum(a[1:])
ans = 0
for i in range(n - 1):
ans += a[i] * val
ans %= 10**9 + 7
val -= a[i + 1]
print(ans)
| false | 15.384615 | [
"-l = [val]",
"-for i in range(1, n):",
"- val -= a[i]",
"- l.append(val)",
"- ans += a[i] * l[i]",
"+ ans += a[i] * val",
"+ val -= a[i + 1]"
] | false | 0.062053 | 0.060493 | 1.025785 | [
"s732988176",
"s905468325"
] |
u191874006 | p02996 | python | s042297333 | s449933240 | 1,042 | 450 | 55,232 | 114,112 | Accepted | Accepted | 56.81 | #!/usr/bin/env python3
#ABC131 D
import sys
import math
N = int(eval(input()))
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key = lambda x:x[1])
#print(AB)
time = 0
for i in range(N):
time += AB[i][0]
if time > AB[i][1]:
print('No')
exit()
print('Ye... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from... | 18 | 29 | 317 | 737 | #!/usr/bin/env python3
# ABC131 D
import sys
import math
N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[1])
# print(AB)
time = 0
for i in range(N):
time += AB[i][0]
if time > AB[i][1]:
print("No")
exit()
print("Yes")
| #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collectio... | false | 37.931034 | [
"-# ABC131 D",
"+from bisect import bisect_right as br",
"+from bisect import bisect_left as bl",
"-N = int(eval(input()))",
"-AB = [list(map(int, input().split())) for _ in range(N)]",
"-AB = sorted(AB, key=lambda x: x[1])",
"-# print(AB)",
"+sys.setrecursionlimit(2147483647)",
"+from heapq import ... | false | 0.130526 | 0.037433 | 3.48697 | [
"s042297333",
"s449933240"
] |
u134302690 | p03285 | python | s114746033 | s399738650 | 170 | 17 | 38,384 | 2,940 | Accepted | Accepted | 90 | n = int(eval(input()))
flag = False
for i in range(int(n/4)+1):
for j in range(int(n/7)+1):
if i==0 and j==0:
continue
if n%((4*i)+(7*j)) == 0:
flag = True
break
if flag:
print("Yes")
else:
print("No") | N = int(eval(input()))
f = False
for i in range(N//4+1):
for j in range(N//7+1):
if i*4 + j*7 == N:
f = True
break
if f:
print("Yes")
else:
print("No") | 13 | 11 | 271 | 199 | n = int(eval(input()))
flag = False
for i in range(int(n / 4) + 1):
for j in range(int(n / 7) + 1):
if i == 0 and j == 0:
continue
if n % ((4 * i) + (7 * j)) == 0:
flag = True
break
if flag:
print("Yes")
else:
print("No")
| N = int(eval(input()))
f = False
for i in range(N // 4 + 1):
for j in range(N // 7 + 1):
if i * 4 + j * 7 == N:
f = True
break
if f:
print("Yes")
else:
print("No")
| false | 15.384615 | [
"-n = int(eval(input()))",
"-flag = False",
"-for i in range(int(n / 4) + 1):",
"- for j in range(int(n / 7) + 1):",
"- if i == 0 and j == 0:",
"- continue",
"- if n % ((4 * i) + (7 * j)) == 0:",
"- flag = True",
"+N = int(eval(input()))",
"+f = False",
"+f... | false | 0.033413 | 0.041527 | 0.804614 | [
"s114746033",
"s399738650"
] |
u129836004 | p03830 | python | s728095333 | s156532593 | 135 | 40 | 3,828 | 3,316 | Accepted | Accepted | 70.37 | import math
import collections
def primes(n):
a = list(range(2, n+1))
primes = [2]
for i in a:
flag = True
m = math.sqrt(i)
for j in primes:
if j > m:
break
else:
if i % j == 0:
flag = False
... | import math
import collections
# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
if x < 2: return []
primes = [i for i in range(x)]
primes[1] = 0 # 1は素数ではない
# エラトステネスのふるい
for prime in primes:
if prime > math.sqrt(x): break
if prime == 0: continue
for non_prime in ran... | 34 | 32 | 731 | 713 | import math
import collections
def primes(n):
a = list(range(2, n + 1))
primes = [2]
for i in a:
flag = True
m = math.sqrt(i)
for j in primes:
if j > m:
break
else:
if i % j == 0:
flag = False
... | import math
import collections
# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
if x < 2:
return []
primes = [i for i in range(x)]
primes[1] = 0 # 1は素数ではない
# エラトステネスのふるい
for prime in primes:
if prime > math.sqrt(x):
break
if prime == 0:
continue
for... | false | 5.882353 | [
"-",
"-def primes(n):",
"- a = list(range(2, n + 1))",
"- primes = [2]",
"- for i in a:",
"- flag = True",
"- m = math.sqrt(i)",
"- for j in primes:",
"- if j > m:",
"- break",
"- else:",
"- if i % j == 0:",
"-... | false | 0.06685 | 0.041222 | 1.621699 | [
"s728095333",
"s156532593"
] |
u272557899 | p03061 | python | s382977057 | s180404103 | 577 | 243 | 63,984 | 14,140 | Accepted | Accepted | 57.89 |
n = int(eval(input()))
a = [int(m) for m in input().split()]
a.sort()
m0 = a[0]
m1 = a[1]
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
# divisors.s... | import sys
# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
# from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bise... | 35 | 50 | 632 | 1,794 | n = int(eval(input()))
a = [int(m) for m in input().split()]
a.sort()
m0 = a[0]
m1 = a[1]
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
# divisors.sort()
... | import sys
# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
# from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
# from itertools import permutations, combinations, product, accumulate, groupby
# from bisect import bisect_... | false | 30 | [
"-n = int(eval(input()))",
"-a = [int(m) for m in input().split()]",
"-a.sort()",
"-m0 = a[0]",
"-m1 = a[1]",
"+import sys",
"+",
"+# import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random",
"+# from collections import deque, defaultdict, Counter; f... | false | 0.061341 | 0.035801 | 1.713407 | [
"s382977057",
"s180404103"
] |
u037430802 | p04013 | python | s392522661 | s211222297 | 1,313 | 206 | 65,504 | 5,492 | Accepted | Accepted | 84.31 | N, A = list(map(int, input().split()))
x = list(map(int, input().split()))
max_num = max(x)
max_num = max(A, max_num)
# x_jまでからk枚選んで合計がsになる選び方の総数。sはk*Aにすれば平均がAになる
dp = [[[0 for _ in range(max_num * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
#何も選ばないで平均が0
dp[0][0][0] = 1
for j in range(N+1):
for... | from collections import Counter
N,A = list(map(int, input().split()))
X = list(map(int, input().split()))
"""
普通にやると最大で2**50通りなのでTLE
i枚選んだ時に合計がi*Aになる物を考えるとよい
"""
# 0枚からN枚まで選んで、合計値がkeyでその組み合わせの数がvalue
dp = [Counter() for _ in range(N+1)]
dp[0][0] = 1
for i, a in enumerate(X): # i番目のカードまで選べる
for j ... | 26 | 24 | 770 | 670 | N, A = list(map(int, input().split()))
x = list(map(int, input().split()))
max_num = max(x)
max_num = max(A, max_num)
# x_jまでからk枚選んで合計がsになる選び方の総数。sはk*Aにすれば平均がAになる
dp = [[[0 for _ in range(max_num * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
# 何も選ばないで平均が0
dp[0][0][0] = 1
for j in range(N + 1):
for k in ra... | from collections import Counter
N, A = list(map(int, input().split()))
X = list(map(int, input().split()))
"""
普通にやると最大で2**50通りなのでTLE
i枚選んだ時に合計がi*Aになる物を考えるとよい
"""
# 0枚からN枚まで選んで、合計値がkeyでその組み合わせの数がvalue
dp = [Counter() for _ in range(N + 1)]
dp[0][0] = 1
for i, a in enumerate(X): # i番目のカードまで選べる
for j in reversed(
... | false | 7.692308 | [
"+from collections import Counter",
"+",
"-x = list(map(int, input().split()))",
"-max_num = max(x)",
"-max_num = max(A, max_num)",
"-# x_jまでからk枚選んで合計がsになる選び方の総数。sはk*Aにすれば平均がAになる",
"-dp = [[[0 for _ in range(max_num * N + 1)] for _ in range(N + 1)] for _ in range(N + 1)]",
"-# 何も選ばないで平均が0",
"-dp[0][... | false | 0.12194 | 0.038243 | 3.188537 | [
"s392522661",
"s211222297"
] |
u423966555 | p02780 | python | s996903312 | s752673317 | 260 | 169 | 25,060 | 25,060 | Accepted | Accepted | 35 | n, k = list(map(int, input().split()))
P = list(map(int,input().split()))
check = [0]*1001
tmp_p = []
for p in P:
if check[p]!=0:
tmp_p.append(check[p])
else:
tmp = ((1+p)*p/2)/p #期待値の計算
tmp_p.append(tmp)
ans = sum(tmp_p[0:k])
tmp_ans = ans
for i in range(n-k):
tmp_ans +... | n,k = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [(1+p)/2 for p in P]
#期待値の累積和
S = [0]*(n+1)
for i in range(1, n+1):
S[i] = S[i-1]+P[i-1]
ans = max([S[x]-S[x-k] for x in range(k,n+1)])
print(ans) | 16 | 11 | 379 | 234 | n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
check = [0] * 1001
tmp_p = []
for p in P:
if check[p] != 0:
tmp_p.append(check[p])
else:
tmp = ((1 + p) * p / 2) / p # 期待値の計算
tmp_p.append(tmp)
ans = sum(tmp_p[0:k])
tmp_ans = ans
for i in range(n - k):
tmp_a... | n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [(1 + p) / 2 for p in P]
# 期待値の累積和
S = [0] * (n + 1)
for i in range(1, n + 1):
S[i] = S[i - 1] + P[i - 1]
ans = max([S[x] - S[x - k] for x in range(k, n + 1)])
print(ans)
| false | 31.25 | [
"-check = [0] * 1001",
"-tmp_p = []",
"-for p in P:",
"- if check[p] != 0:",
"- tmp_p.append(check[p])",
"- else:",
"- tmp = ((1 + p) * p / 2) / p # 期待値の計算",
"- tmp_p.append(tmp)",
"-ans = sum(tmp_p[0:k])",
"-tmp_ans = ans",
"-for i in range(n - k):",
"- tmp_ans ... | false | 0.037197 | 0.044707 | 0.832027 | [
"s996903312",
"s752673317"
] |
u512212329 | p02660 | python | s385616585 | s955495376 | 464 | 248 | 9,168 | 9,084 | Accepted | Accepted | 46.55 | def main():
n = int(eval(input()))
ans = 0
fac = 2
e = 1
while True:
div = pow(fac, e)
if n % div == 0:
n //= div
ans += 1
e += 1
else:
while n % fac == 0:
n //= fac
fac += 1
... | def main():
n = int(eval(input()))
ans = 0
fac = 2
e = 1
while True:
div = pow(fac, e)
if n % div == 0:
n //= div
ans += 1
e += 1
else:
while n % fac == 0:
n //= fac
if fac == 2:
... | 27 | 30 | 474 | 549 | def main():
n = int(eval(input()))
ans = 0
fac = 2
e = 1
while True:
div = pow(fac, e)
if n % div == 0:
n //= div
ans += 1
e += 1
else:
while n % fac == 0:
n //= fac
fac += 1
if fac * fac ... | def main():
n = int(eval(input()))
ans = 0
fac = 2
e = 1
while True:
div = pow(fac, e)
if n % div == 0:
n //= div
ans += 1
e += 1
else:
while n % fac == 0:
n //= fac
if fac == 2:
fac +... | false | 10 | [
"- fac += 1",
"+ if fac == 2:",
"+ fac += 1",
"+ else:",
"+ fac += 2"
] | false | 0.180258 | 0.041506 | 4.342958 | [
"s385616585",
"s955495376"
] |
u627803856 | p02642 | python | s577187771 | s298900103 | 227 | 197 | 143,740 | 133,548 | Accepted | Accepted | 13.22 | n = int(eval(input()))
A = list(map(int, input().split()))
N = 10 ** 6 + 1
# 一度しか現れないものを抽出する
cnt = [0] * (N + 1)
for a in A:
cnt[a] += 1
once = []
for a in A:
if cnt[a] == 1:
once.append(a)
# 倍数を排除
bl = [True] * (N + 1)
A = list(set(A))
for elem in A:
for m in range(elem * 2, ... | n = int(eval(input()))
A = sorted(list(map(int, input().split())))
from collections import Counter
c = Counter(A)
MAX = 10 ** 6 + 1000
dp = [True] * MAX
for k, v in list(c.items()):
if dp[k] == False: continue
if v > 1: dp[k] = False
for x in range(k + k, MAX, k):
dp[x] = False
res ... | 27 | 18 | 429 | 370 | n = int(eval(input()))
A = list(map(int, input().split()))
N = 10**6 + 1
# 一度しか現れないものを抽出する
cnt = [0] * (N + 1)
for a in A:
cnt[a] += 1
once = []
for a in A:
if cnt[a] == 1:
once.append(a)
# 倍数を排除
bl = [True] * (N + 1)
A = list(set(A))
for elem in A:
for m in range(elem * 2, N + 1, elem):
bl[... | n = int(eval(input()))
A = sorted(list(map(int, input().split())))
from collections import Counter
c = Counter(A)
MAX = 10**6 + 1000
dp = [True] * MAX
for k, v in list(c.items()):
if dp[k] == False:
continue
if v > 1:
dp[k] = False
for x in range(k + k, MAX, k):
dp[x] = False
res = ... | false | 33.333333 | [
"-A = list(map(int, input().split()))",
"-N = 10**6 + 1",
"-# 一度しか現れないものを抽出する",
"-cnt = [0] * (N + 1)",
"-for a in A:",
"- cnt[a] += 1",
"-once = []",
"-for a in A:",
"- if cnt[a] == 1:",
"- once.append(a)",
"-# 倍数を排除",
"-bl = [True] * (N + 1)",
"-A = list(set(A))",
"-for elem... | false | 0.351271 | 0.121715 | 2.886018 | [
"s577187771",
"s298900103"
] |
u999799597 | p02584 | python | s881605411 | s526061882 | 32 | 25 | 9,200 | 9,180 | Accepted | Accepted | 21.88 | x, k, d = list(map(int, input().split()))
x = abs(x)
ans = 0
if x >= k * d:
ans = x - d * k
else:
i = x // d
j = k - i
if (j % 2 == 0):
ans = x - d * i
else:
ans = x - d * (i + 1)
print((abs(ans))) | x, k, d = list(map(int, input().split()))
x = abs(x)
ans = 0
if x // d > k:
ans = x - d * k
else:
e = x // d
k -= e
x -= e * d
if (k % 2 == 1):
x = abs(x - d)
ans = x
print(ans)
| 13 | 13 | 237 | 216 | x, k, d = list(map(int, input().split()))
x = abs(x)
ans = 0
if x >= k * d:
ans = x - d * k
else:
i = x // d
j = k - i
if j % 2 == 0:
ans = x - d * i
else:
ans = x - d * (i + 1)
print((abs(ans)))
| x, k, d = list(map(int, input().split()))
x = abs(x)
ans = 0
if x // d > k:
ans = x - d * k
else:
e = x // d
k -= e
x -= e * d
if k % 2 == 1:
x = abs(x - d)
ans = x
print(ans)
| false | 0 | [
"-if x >= k * d:",
"+if x // d > k:",
"- i = x // d",
"- j = k - i",
"- if j % 2 == 0:",
"- ans = x - d * i",
"- else:",
"- ans = x - d * (i + 1)",
"-print((abs(ans)))",
"+ e = x // d",
"+ k -= e",
"+ x -= e * d",
"+ if k % 2 == 1:",
"+ x = abs(... | false | 0.036258 | 0.095112 | 0.381215 | [
"s881605411",
"s526061882"
] |
u761320129 | p03320 | python | s909480443 | s696439420 | 57 | 26 | 3,696 | 3,316 | Accepted | Accepted | 54.39 | K = int(input())
S = lambda n: sum(map(int,str(n)))
R = lambda n: n/S(n)
arr = []
for i in range(1,1000):
for j in range(1,15):
arr.append(int(str(i) + '9'*j))
arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
r = R(a)
if r < min_r:
min_r = r
snukes.ap... | K = int(input())
S = lambda n: sum(map(int,str(n)))
R = lambda n: n/S(n)
arr = []
for i in range(1,200):
for j in range(1,15):
arr.append(int(str(i) + '9'*j))
arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
r = R(a)
if r < min_r:
min_r = r
snukes.app... | 25 | 25 | 441 | 440 | K = int(input())
S = lambda n: sum(map(int, str(n)))
R = lambda n: n / S(n)
arr = []
for i in range(1, 1000):
for j in range(1, 15):
arr.append(int(str(i) + "9" * j))
arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
r = R(a)
if r < min_r:
min_r = r
snukes.append(a)
for... | K = int(input())
S = lambda n: sum(map(int, str(n)))
R = lambda n: n / S(n)
arr = []
for i in range(1, 200):
for j in range(1, 15):
arr.append(int(str(i) + "9" * j))
arr.sort(reverse=True)
min_r = arr[0]
snukes = []
for a in arr:
r = R(a)
if r < min_r:
min_r = r
snukes.append(a)
for ... | false | 0 | [
"-for i in range(1, 1000):",
"+for i in range(1, 200):"
] | false | 0.084512 | 0.052214 | 1.618555 | [
"s909480443",
"s696439420"
] |
u644907318 | p02854 | python | s907024701 | s242612960 | 322 | 118 | 100,688 | 107,028 | Accepted | Accepted | 63.35 | N = int(eval(input()))
A = list(map(int,input().split()))
tot = sum(A)
B = [0 for _ in range(N-1)]
cnt = A[0]
for i in range(1,N):
B[i-1] = abs(tot-2*cnt)
cnt += A[i]
print((min(B))) | N = int(eval(input()))
A = list(map(int,input().split()))
tot = sum(A)
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
B[i] = B[i-1]+A[i-1]
cmin = abs(tot-2*B[1])
for i in range(2,N):
cmin = min(cmin,abs(tot-2*B[i]))
print(cmin) | 9 | 10 | 190 | 242 | N = int(eval(input()))
A = list(map(int, input().split()))
tot = sum(A)
B = [0 for _ in range(N - 1)]
cnt = A[0]
for i in range(1, N):
B[i - 1] = abs(tot - 2 * cnt)
cnt += A[i]
print((min(B)))
| N = int(eval(input()))
A = list(map(int, input().split()))
tot = sum(A)
B = [0 for _ in range(N + 1)]
for i in range(1, N + 1):
B[i] = B[i - 1] + A[i - 1]
cmin = abs(tot - 2 * B[1])
for i in range(2, N):
cmin = min(cmin, abs(tot - 2 * B[i]))
print(cmin)
| false | 10 | [
"-B = [0 for _ in range(N - 1)]",
"-cnt = A[0]",
"-for i in range(1, N):",
"- B[i - 1] = abs(tot - 2 * cnt)",
"- cnt += A[i]",
"-print((min(B)))",
"+B = [0 for _ in range(N + 1)]",
"+for i in range(1, N + 1):",
"+ B[i] = B[i - 1] + A[i - 1]",
"+cmin = abs(tot - 2 * B[1])",
"+for i in ra... | false | 0.132949 | 0.059513 | 2.233923 | [
"s907024701",
"s242612960"
] |
u506705885 | p02401 | python | s004146875 | s344427836 | 30 | 20 | 7,744 | 5,596 | Accepted | Accepted | 33.33 | answers=[]
while True:
iquation=[]
iquation=input().split()
iquation[0]=int(iquation[0])
iquation[2]=int(iquation[2])
if iquation[1]=='+':
answers.append(iquation[0]+iquation[2])
elif iquation[1]=='-':
answers.append(iquation[0]-iquation[2])
elif iquation[1]=='*':
... | while True:
a,op,b=input().split()
a=int(a)
b=int(b)
if op=="+":
print((a+b))
elif op=="-":
print((a-b))
elif op=="*":
print((a*b))
elif op=="/":
print((a//b))
elif op=="?":
break | 20 | 14 | 583 | 256 | answers = []
while True:
iquation = []
iquation = input().split()
iquation[0] = int(iquation[0])
iquation[2] = int(iquation[2])
if iquation[1] == "+":
answers.append(iquation[0] + iquation[2])
elif iquation[1] == "-":
answers.append(iquation[0] - iquation[2])
elif iquation[1]... | while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == "+":
print((a + b))
elif op == "-":
print((a - b))
elif op == "*":
print((a * b))
elif op == "/":
print((a // b))
elif op == "?":
break
| false | 30 | [
"-answers = []",
"- iquation = []",
"- iquation = input().split()",
"- iquation[0] = int(iquation[0])",
"- iquation[2] = int(iquation[2])",
"- if iquation[1] == \"+\":",
"- answers.append(iquation[0] + iquation[2])",
"- elif iquation[1] == \"-\":",
"- answers.append(i... | false | 0.036505 | 0.038763 | 0.941743 | [
"s004146875",
"s344427836"
] |
u873915460 | p02561 | python | s576453102 | s745969471 | 501 | 322 | 84,560 | 85,336 | Accepted | Accepted | 35.73 | N,M=list(map(int,input().split()))
S=[list(eval(input())) for i in range(N)]
V=N*M
G=[[] for i in range(V)]
ma=[0]*V
us=[0]*V
def ae(u,v):
G[u].append(v)
G[v].append(u)
def df(v):
us[v]=1
for i in range(len(G[v])):
u=G[v][i]
w=ma[u]
if w<0 or(not(us[w]) and df(w)):
ma[v]=u
... | from collections import deque
N,M=list(map(int,input().split()))
S=[list(eval(input())) for i in range(N)]
V=N*M+2
G=[[] for i in range(V)]
L=[0]*V
I=[0]*V
INF=10**15
def ae(fr,to,ca):
global G
G[fr].append([to,ca,len(G[to]),0])
G[to].append([fr,0,len(G[fr])-1,0])
def bfs(s):
global INF,L,V,G
... | 58 | 96 | 1,140 | 1,980 | N, M = list(map(int, input().split()))
S = [list(eval(input())) for i in range(N)]
V = N * M
G = [[] for i in range(V)]
ma = [0] * V
us = [0] * V
def ae(u, v):
G[u].append(v)
G[v].append(u)
def df(v):
us[v] = 1
for i in range(len(G[v])):
u = G[v][i]
w = ma[u]
if w < 0 or (not... | from collections import deque
N, M = list(map(int, input().split()))
S = [list(eval(input())) for i in range(N)]
V = N * M + 2
G = [[] for i in range(V)]
L = [0] * V
I = [0] * V
INF = 10**15
def ae(fr, to, ca):
global G
G[fr].append([to, ca, len(G[to]), 0])
G[to].append([fr, 0, len(G[fr]) - 1, 0])
def ... | false | 39.583333 | [
"+from collections import deque",
"+",
"-V = N * M",
"+V = N * M + 2",
"-ma = [0] * V",
"-us = [0] * V",
"+L = [0] * V",
"+I = [0] * V",
"+INF = 10**15",
"-def ae(u, v):",
"- G[u].append(v)",
"- G[v].append(u)",
"+def ae(fr, to, ca):",
"+ global G",
"+ G[fr].append([to, ca, l... | false | 0.107385 | 0.04539 | 2.365856 | [
"s576453102",
"s745969471"
] |
u707124227 | p02902 | python | s443413883 | s908471852 | 38 | 32 | 10,188 | 10,176 | Accepted | Accepted | 15.79 | import sys
sys.setrecursionlimit(10**7)
n,m=list(map(int,input().split()))
g=[[] for _ in range(n)]
for _ in range(m):
u,v=list(map(int,input().split()))
u,v=u-1,v-1
g[u].append(v)
mi=set(range(n))
flg=False
def func(path):
chk=set(path)
if len(path)!=2:
for i,v in enumerate(path):
nvs... | n,m=list(map(int,input().split()))
g=[[] for _ in range(n)]
for _ in range(m):
u,v=list(map(int,input().split()))
u,v=u-1,v-1
g[u].append(v)
import sys
sys.setrecursionlimit(10**7)
def func(loop):
sl=set(loop)
k=len(loop)
for i in range(k):
v=loop[i]
for nv in g[... | 55 | 48 | 1,143 | 1,068 | import sys
sys.setrecursionlimit(10**7)
n, m = list(map(int, input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
u, v = list(map(int, input().split()))
u, v = u - 1, v - 1
g[u].append(v)
mi = set(range(n))
flg = False
def func(path):
chk = set(path)
if len(path) != 2:
for i, v... | n, m = list(map(int, input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
u, v = list(map(int, input().split()))
u, v = u - 1, v - 1
g[u].append(v)
import sys
sys.setrecursionlimit(10**7)
def func(loop):
sl = set(loop)
k = len(loop)
for i in range(k):
v = loop[i]
fo... | false | 12.727273 | [
"-import sys",
"-",
"-sys.setrecursionlimit(10**7)",
"-mi = set(range(n))",
"-flg = False",
"+import sys",
"+",
"+sys.setrecursionlimit(10**7)",
"-def func(path):",
"- chk = set(path)",
"- if len(path) != 2:",
"- for i, v in enumerate(path):",
"- nvs = [nv for nv in g... | false | 0.007911 | 0.038062 | 0.207857 | [
"s443413883",
"s908471852"
] |
u047796752 | p03440 | python | s869265147 | s081941819 | 512 | 457 | 81,592 | 78,616 | Accepted | Accepted | 10.74 | import sys
input = sys.stdin.readline
from collections import defaultdict
class Unionfind:
def __init__(self, n):
self.par = [-1]*n
self.rank = [1]*n
def root(self, x):
p = x
while not self.par[p]<0:
p = self.par[p]
while... | import sys
input = sys.stdin.readline
from collections import defaultdict
class Unionfind:
def __init__(self, n):
self.par = [-1]*n
self.rank = [1]*n
def root(self, x):
p = x
while not self.par[p]<0:
p = self.par[p]
whil... | 81 | 79 | 1,512 | 1,497 | import sys
input = sys.stdin.readline
from collections import defaultdict
class Unionfind:
def __init__(self, n):
self.par = [-1] * n
self.rank = [1] * n
def root(self, x):
p = x
while not self.par[p] < 0:
p = self.par[p]
while x != p:
tmp = x
... | import sys
input = sys.stdin.readline
from collections import defaultdict
class Unionfind:
def __init__(self, n):
self.par = [-1] * n
self.rank = [1] * n
def root(self, x):
p = x
while not self.par[p] < 0:
p = self.par[p]
while x != p:
tmp = x
... | false | 2.469136 | [
"-rs = set()",
"- r = uf.root(i)",
"- rs.add(r)",
"- d[r].append(a[i])",
"-if len(rs) == 1:",
"+ d[uf.root(i)].append(a[i])",
"+keys = list(d.keys())",
"+if len(keys) == 1:",
"-if 2 * (len(rs) - 1) > N:",
"+if N < 2 * (len(keys) - 1):",
"+for k in keys:",
"+ d[k].sort()",
"-fo... | false | 0.0458 | 0.041894 | 1.093225 | [
"s869265147",
"s081941819"
] |
u046187684 | p03478 | python | s485765156 | s352115863 | 36 | 31 | 3,064 | 3,296 | Accepted | Accepted | 13.89 | #!/usr/bin/env python3
# coding=utf-8
import sys
def digit_sum(n):
s = str(n)
array = list(map(int, list(s)))
return sum(array)
n, a, b = sys.stdin.readline().split(" ")
n = int(n)
a = int(a)
b = int(b)
ans = 0
for i in range(1, n + 1):
if a <= digit_sum(i) <= b:
ans += i
pr... | def solve(string):
n, a, b = list(map(int, string.split()))
def check(i):
return a <= sum([int(_i) for _i in str(i)]) <= b
return str(sum([i for i in range(n + 1) if check(i)]))
if __name__ == '__main__':
print((solve(eval(input()))))
| 19 | 11 | 328 | 259 | #!/usr/bin/env python3
# coding=utf-8
import sys
def digit_sum(n):
s = str(n)
array = list(map(int, list(s)))
return sum(array)
n, a, b = sys.stdin.readline().split(" ")
n = int(n)
a = int(a)
b = int(b)
ans = 0
for i in range(1, n + 1):
if a <= digit_sum(i) <= b:
ans += i
print(ans)
| def solve(string):
n, a, b = list(map(int, string.split()))
def check(i):
return a <= sum([int(_i) for _i in str(i)]) <= b
return str(sum([i for i in range(n + 1) if check(i)]))
if __name__ == "__main__":
print((solve(eval(input()))))
| false | 42.105263 | [
"-#!/usr/bin/env python3",
"-# coding=utf-8",
"-import sys",
"+def solve(string):",
"+ n, a, b = list(map(int, string.split()))",
"+",
"+ def check(i):",
"+ return a <= sum([int(_i) for _i in str(i)]) <= b",
"+",
"+ return str(sum([i for i in range(n + 1) if check(i)]))",
"-def d... | false | 0.035728 | 0.056884 | 0.628082 | [
"s485765156",
"s352115863"
] |
u644907318 | p02718 | python | s846616606 | s707701215 | 63 | 26 | 62,080 | 9,200 | Accepted | Accepted | 58.73 | import math
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = sum(A)
b = math.ceil(a/(4*M))
cnt = 0
for i in range(N):
if A[i]>=b:
cnt += 1
if cnt>=M:
print("Yes")
else:
print("No") | N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
tot = sum(A)
if tot%(4*M)==0:
a = tot//(4*M)
else:
a = tot//(4*M)+1
cnt = 0
for i in range(N):
if A[i]>=a:
cnt += 1
if cnt>=M:
print("Yes")
else:
print("No") | 13 | 15 | 233 | 265 | import math
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
a = sum(A)
b = math.ceil(a / (4 * M))
cnt = 0
for i in range(N):
if A[i] >= b:
cnt += 1
if cnt >= M:
print("Yes")
else:
print("No")
| N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
tot = sum(A)
if tot % (4 * M) == 0:
a = tot // (4 * M)
else:
a = tot // (4 * M) + 1
cnt = 0
for i in range(N):
if A[i] >= a:
cnt += 1
if cnt >= M:
print("Yes")
else:
print("No")
| false | 13.333333 | [
"-import math",
"-",
"-a = sum(A)",
"-b = math.ceil(a / (4 * M))",
"+tot = sum(A)",
"+if tot % (4 * M) == 0:",
"+ a = tot // (4 * M)",
"+else:",
"+ a = tot // (4 * M) + 1",
"- if A[i] >= b:",
"+ if A[i] >= a:"
] | false | 0.037796 | 0.034158 | 1.106487 | [
"s846616606",
"s707701215"
] |
u831244171 | p02384 | python | s522689276 | s757616353 | 30 | 20 | 7,700 | 7,716 | Accepted | Accepted | 33.33 | def whatIsRight(u,f):
r = 0
if u == 1:
if f == 2:
r = 3
elif f == 3:
r = 5
elif f == 4:
r = 2
elif f == 5:
r = 4
elif u == 2:
if f == 6:
r = 3
elif f == 3:
r = 1
... | def move(up,bottom,right,left,front,back,direction):
if direction == "N":
return (front,back,right,left,bottom,up)
elif direction == "S":
return (back,front,right,left,up,bottom)
elif direction == "E":
return (left,right,up,bottom,front,back)
elif direction == "W":
... | 77 | 42 | 1,478 | 1,407 | def whatIsRight(u, f):
r = 0
if u == 1:
if f == 2:
r = 3
elif f == 3:
r = 5
elif f == 4:
r = 2
elif f == 5:
r = 4
elif u == 2:
if f == 6:
r = 3
elif f == 3:
r = 1
elif f == 1:
... | def move(up, bottom, right, left, front, back, direction):
if direction == "N":
return (front, back, right, left, bottom, up)
elif direction == "S":
return (back, front, right, left, up, bottom)
elif direction == "E":
return (left, right, up, bottom, front, back)
elif direction =... | false | 45.454545 | [
"-def whatIsRight(u, f):",
"- r = 0",
"- if u == 1:",
"- if f == 2:",
"- r = 3",
"- elif f == 3:",
"- r = 5",
"- elif f == 4:",
"- r = 2",
"- elif f == 5:",
"- r = 4",
"- elif u == 2:",
"- if f == 6:",
... | false | 0.042534 | 0.080087 | 0.531094 | [
"s522689276",
"s757616353"
] |
u906428167 | p02822 | python | s018701236 | s507826499 | 932 | 673 | 89,032 | 91,992 | Accepted | Accepted | 27.79 | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
mod = 10**9+7
n = int(eval(input()))
g = [[] for _ in range(n)]
for _ in range(n-1):
a, b = list(map(int, input().split()))
g[a-1].append(b-1)
g[b-1].append(a-1)
par = [-1]*n
depth = [-1]*n
sizesub = [1 for _ in range(n... | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
mod = 10**9+7
n = int(eval(input()))
g = [[] for _ in range(n)]
pow2 = [0 for _ in range(n+1)]
pow2[0] = 1
for i in range(n):
pow2[i+1] = pow2[i]*2 % mod
for _ in range(n-1):
a, b = list(map(int, input().split()))
g[a-1... | 61 | 66 | 1,257 | 1,329 | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
mod = 10**9 + 7
n = int(eval(input()))
g = [[] for _ in range(n)]
for _ in range(n - 1):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
par = [-1] * n
depth = [-1] * n
sizesub = [1 for _ in range(n)]
bl... | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
mod = 10**9 + 7
n = int(eval(input()))
g = [[] for _ in range(n)]
pow2 = [0 for _ in range(n + 1)]
pow2[0] = 1
for i in range(n):
pow2[i + 1] = pow2[i] * 2 % mod
for _ in range(n - 1):
a, b = list(map(int, input().split()))
g[a - 1].append(... | false | 7.575758 | [
"+pow2 = [0 for _ in range(n + 1)]",
"+pow2[0] = 1",
"+for i in range(n):",
"+ pow2[i + 1] = pow2[i] * 2 % mod",
"- black[par[v]] += pow(2, sizesub[v], mod) - 1",
"+ black[par[v]] += pow2[sizesub[v]] - 1",
"- tmp = pow(2, n - 1, mod) - pow(2, n - sizesub[i], mod) - black[i]",
"+ ... | false | 0.039195 | 0.110865 | 0.353536 | [
"s018701236",
"s507826499"
] |
u883040023 | p02813 | python | s888222942 | s693344460 | 46 | 40 | 12,276 | 10,228 | Accepted | Accepted | 13.04 | n = int(eval(input()))
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
import itertools
A = []
for i in range(1,n+1):
A.append(i)
p = itertools.permutations(A,n)
p = list(p)
for i in range(len(p)):
p[i] = list(p[i])
print((abs(p.index(P)-p.index(Q)))) | n = int(eval(input()))
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
import itertools
p = [list(i) for i in itertools.permutations(list(range(1,n+1)),n)]
print((abs(p.index(P)-p.index(Q)))) | 18 | 8 | 300 | 208 | n = int(eval(input()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
import itertools
A = []
for i in range(1, n + 1):
A.append(i)
p = itertools.permutations(A, n)
p = list(p)
for i in range(len(p)):
p[i] = list(p[i])
print((abs(p.index(P) - p.index(Q))))
| n = int(eval(input()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
import itertools
p = [list(i) for i in itertools.permutations(list(range(1, n + 1)), n)]
print((abs(p.index(P) - p.index(Q))))
| false | 55.555556 | [
"-A = []",
"-for i in range(1, n + 1):",
"- A.append(i)",
"-p = itertools.permutations(A, n)",
"-p = list(p)",
"-for i in range(len(p)):",
"- p[i] = list(p[i])",
"+p = [list(i) for i in itertools.permutations(list(range(1, n + 1)), n)]"
] | false | 0.046198 | 0.04669 | 0.989469 | [
"s888222942",
"s693344460"
] |
u189023301 | p02574 | python | s357602546 | s371388496 | 686 | 469 | 268,016 | 194,644 | Accepted | Accepted | 31.63 | from math import gcd
n = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)
res = s[0]
for ss in s:
dp[ss] += 1
res = gcd(res, ss)
A = max(s)
pairwise = True
setwise = (res == 1)
primes = set(range(2, A+1))
for i in range(2, int(A**0.5+1)):
if i ... | n = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)
for ss in s:
dp[ss] += 1
A = max(s)
pairwise = True
setwise = True
for i in range(2, A + 1):
cnt = 0
for j in range(i, A + 1, i):
cnt += dp[j]
if cnt > 1:
pairwise = False... | 38 | 28 | 723 | 498 | from math import gcd
n = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10**6) + 100)
res = s[0]
for ss in s:
dp[ss] += 1
res = gcd(res, ss)
A = max(s)
pairwise = True
setwise = res == 1
primes = set(range(2, A + 1))
for i in range(2, int(A**0.5 + 1)):
if i not in primes:
... | n = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10**6) + 100)
for ss in s:
dp[ss] += 1
A = max(s)
pairwise = True
setwise = True
for i in range(2, A + 1):
cnt = 0
for j in range(i, A + 1, i):
cnt += dp[j]
if cnt > 1:
pairwise = False
if cnt >= n:
... | false | 26.315789 | [
"-from math import gcd",
"-",
"-res = s[0]",
"- res = gcd(res, ss)",
"-setwise = res == 1",
"-primes = set(range(2, A + 1))",
"-for i in range(2, int(A**0.5 + 1)):",
"- if i not in primes:",
"- i += 1",
"- else:",
"- ran = list(range(i * 2, A + 1, i))",
"- primes.... | false | 0.10528 | 0.054887 | 1.91812 | [
"s357602546",
"s371388496"
] |
u754022296 | p02567 | python | s123045430 | s969625730 | 644 | 478 | 97,032 | 94,972 | Accepted | Accepted | 25.78 | class RMaxQ:
__slots__ = ["n", "data"]
def __init__(self, li):
self.n = len(li)
self.data = li*2
for i in range(self.n - 1, 0, -1):
self.data[i] = max(self.data[2*i], self.data[2*i+1])
def update(self, i, a):
i += self.n
self.dat... | class RMaxQ:
__slots__ = ["n", "data"]
def __init__(self, li):
self.n = len(li)
self.data = li*2
for i in range(self.n - 1, 0, -1):
self.data[i] = max(self.data[2*i], self.data[2*i+1])
def get(self, i):
return self.data[i+self.n]
... | 61 | 90 | 1,513 | 2,348 | class RMaxQ:
__slots__ = ["n", "data"]
def __init__(self, li):
self.n = len(li)
self.data = li * 2
for i in range(self.n - 1, 0, -1):
self.data[i] = max(self.data[2 * i], self.data[2 * i + 1])
def update(self, i, a):
i += self.n
self.data[i] = a
... | class RMaxQ:
__slots__ = ["n", "data"]
def __init__(self, li):
self.n = len(li)
self.data = li * 2
for i in range(self.n - 1, 0, -1):
self.data[i] = max(self.data[2 * i], self.data[2 * i + 1])
def get(self, i):
return self.data[i + self.n]
def update(self, ... | false | 32.222222 | [
"+",
"+ def get(self, i):",
"+ return self.data[i + self.n]",
"+ def max_right(self, l, r, check):",
"+ l += self.n",
"+ r += self.n",
"+ left_li = []",
"+ right_li = []",
"+ while l < r:",
"+ if l % 2:",
"+ left_li.append... | false | 0.035549 | 0.035884 | 0.990665 | [
"s123045430",
"s969625730"
] |
u562935282 | p03495 | python | s705740015 | s854084212 | 137 | 120 | 44,572 | 35,616 | Accepted | Accepted | 12.41 | n, k = list(map(int, input().split()))
a = input().split()
d = dict()
for i in a:
d[i] = d.get(i, 0) + 1
d_sorted = sorted(d.values())
knd = len(set(a))##種類数
print((sum(d_sorted[:knd - k]))) | n, k = list(map(int, input().split()))
a = input().split()
b = dict()
for i in a:
b[i] = b.get(i, 0) + 1
print((sum(sorted(b.values())[:-k]))) | 9 | 6 | 199 | 143 | n, k = list(map(int, input().split()))
a = input().split()
d = dict()
for i in a:
d[i] = d.get(i, 0) + 1
d_sorted = sorted(d.values())
knd = len(set(a)) ##種類数
print((sum(d_sorted[: knd - k])))
| n, k = list(map(int, input().split()))
a = input().split()
b = dict()
for i in a:
b[i] = b.get(i, 0) + 1
print((sum(sorted(b.values())[:-k])))
| false | 33.333333 | [
"-d = dict()",
"+b = dict()",
"- d[i] = d.get(i, 0) + 1",
"-d_sorted = sorted(d.values())",
"-knd = len(set(a)) ##種類数",
"-print((sum(d_sorted[: knd - k])))",
"+ b[i] = b.get(i, 0) + 1",
"+print((sum(sorted(b.values())[:-k])))"
] | false | 0.043585 | 0.045281 | 0.962544 | [
"s705740015",
"s854084212"
] |
u349449706 | p03095 | python | s127106494 | s895751519 | 83 | 70 | 68,380 | 66,256 | Accepted | Accepted | 15.66 | import operator
import functools
N = int(eval(input()))
S = eval(input())
c = [1] * 26
for s in S:
c[ord(s)-ord('a')] += 1
print(((functools.reduce(operator.mul,c)-1) % (10**9+7)))
| eval(input())
S=eval(input())
s=set(S)
a=1
for c in s:a=a*(S.count(c)+1)%(10**9+7)
print((a-1))
| 9 | 6 | 180 | 87 | import operator
import functools
N = int(eval(input()))
S = eval(input())
c = [1] * 26
for s in S:
c[ord(s) - ord("a")] += 1
print(((functools.reduce(operator.mul, c) - 1) % (10**9 + 7)))
| eval(input())
S = eval(input())
s = set(S)
a = 1
for c in s:
a = a * (S.count(c) + 1) % (10**9 + 7)
print((a - 1))
| false | 33.333333 | [
"-import operator",
"-import functools",
"-",
"-N = int(eval(input()))",
"+eval(input())",
"-c = [1] * 26",
"-for s in S:",
"- c[ord(s) - ord(\"a\")] += 1",
"-print(((functools.reduce(operator.mul, c) - 1) % (10**9 + 7)))",
"+s = set(S)",
"+a = 1",
"+for c in s:",
"+ a = a * (S.count(c... | false | 0.033533 | 0.039366 | 0.851818 | [
"s127106494",
"s895751519"
] |
u247922466 | p03013 | python | s553079635 | s990281040 | 191 | 172 | 11,024 | 7,080 | Accepted | Accepted | 9.95 | def C_TypicalStairs():
N, M = list(map(int, input().split()))
am = [int(eval(input())) for i in range(M)]
n_list = [i for i in range(N+1)]
can_move = True
num_move = 0
if(M == 0):
num_move = fib(len(n_list))
else:
# 到達不可を除く
for i in range(M-1):
... | def C_TypicalStairs():
N, M = list(map(int, input().split()))
am = [int(eval(input())) for i in range(M)]
can_move = True
num_move = 0
if(M == 0):
num_move = fib(N+1)
else:
# 到達不可を除く
for i in range(M-1):
if ((am[i] + 1) == am[i+1]):
... | 33 | 32 | 914 | 833 | def C_TypicalStairs():
N, M = list(map(int, input().split()))
am = [int(eval(input())) for i in range(M)]
n_list = [i for i in range(N + 1)]
can_move = True
num_move = 0
if M == 0:
num_move = fib(len(n_list))
else:
# 到達不可を除く
for i in range(M - 1):
if (am[i... | def C_TypicalStairs():
N, M = list(map(int, input().split()))
am = [int(eval(input())) for i in range(M)]
can_move = True
num_move = 0
if M == 0:
num_move = fib(N + 1)
else:
# 到達不可を除く
for i in range(M - 1):
if (am[i] + 1) == am[i + 1]:
can_move... | false | 3.030303 | [
"- n_list = [i for i in range(N + 1)]",
"- num_move = fib(len(n_list))",
"+ num_move = fib(N + 1)",
"- num_move = fib(len(n_list[: am[0]]))",
"+ num_move = fib(am[0])",
"- num_move *= fib(len(n_list[am[i] + 1 : am[i + 1]]))",
"- num_mo... | false | 0.046733 | 0.046556 | 1.003796 | [
"s553079635",
"s990281040"
] |
u488127128 | p03262 | python | s817743175 | s710649223 | 124 | 88 | 14,864 | 14,224 | Accepted | Accepted | 29.03 | N,X = list(map(int, input().split()))
l = sorted(map(int, input().split()+[X]))
r = [l[n+1] - l[n] for n in range(N)]
ans = r.pop()
for i in r:
while ans%i != 0:
ans,i = i,ans%i
ans = i
print(ans) | N,X = list(map(int, input().split()))
r = [abs(X-i) for i in map(int, input().split())]
ans = r.pop()
for i in r:
while ans%i != 0:
ans,i = i,ans%i
ans = i
print(ans) | 9 | 8 | 214 | 183 | N, X = list(map(int, input().split()))
l = sorted(map(int, input().split() + [X]))
r = [l[n + 1] - l[n] for n in range(N)]
ans = r.pop()
for i in r:
while ans % i != 0:
ans, i = i, ans % i
ans = i
print(ans)
| N, X = list(map(int, input().split()))
r = [abs(X - i) for i in map(int, input().split())]
ans = r.pop()
for i in r:
while ans % i != 0:
ans, i = i, ans % i
ans = i
print(ans)
| false | 11.111111 | [
"-l = sorted(map(int, input().split() + [X]))",
"-r = [l[n + 1] - l[n] for n in range(N)]",
"+r = [abs(X - i) for i in map(int, input().split())]"
] | false | 0.036712 | 0.037388 | 0.981918 | [
"s817743175",
"s710649223"
] |
u022407960 | p02238 | python | s921825195 | s327064769 | 50 | 30 | 7,816 | 7,852 | Accepted | Accepted | 40 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2
def generate_adj(v_info):
for v_detail in v_info:
v_adj_list = v_detail[2:]
assert len(v_adj_list) == int(v_detail[1])
for each in v_adj_list:
init_adj_matr... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2
def generate_adj_matrix(v_info):
for v_detail in v_info:
v_adj_list = v_detail[2:]
assert len(v_adj_list) == int(v_detail[1])
for each in v_adj_list:
init_a... | 83 | 80 | 2,749 | 2,435 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2
def generate_adj(v_info):
for v_detail in v_info:
v_adj_list = v_detail[2:]
assert len(v_adj_list) == int(v_detail[1])
for each in v_adj_list:
init_adj_matrix[int(v_detai... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2
def generate_adj_matrix(v_info):
for v_detail in v_info:
v_adj_list = v_detail[2:]
assert len(v_adj_list) == int(v_detail[1])
for each in v_adj_list:
init_adj_matrix[int(... | false | 3.614458 | [
"-def generate_adj(v_info):",
"+def generate_adj_matrix(v_info):",
"- # print('start', current_vertex, next_vertex, vertex_status_list, vertex_visit_stack)",
"- # print('on', current_vertex, next_vertex, vertex_status_list, vertex_visit_stack)",
"- # print('no out degree', c... | false | 0.043684 | 0.046941 | 0.930617 | [
"s921825195",
"s327064769"
] |
u188827677 | p02725 | python | s573481999 | s011429178 | 161 | 137 | 26,060 | 26,060 | Accepted | Accepted | 14.91 | k,n = list(map(int, input().split()))
a = list(map(int, input().split()))
x = [0]*n
for i in range(n):
t = a[i] - a[i-1]
if i == 0:
t += k
x[i] = t
x[i] = t
print((sum(i for i in sorted(x)[:-1]))) | k,n = list(map(int, input().split()))
a = list(map(int, input().split()))
l = [0]*n
l[-1] = k+a[0]-a[-1]
for i in range(n-1):
l[i] = a[i+1] - a[i]
print((sum(sorted(l)[:-1]))) | 12 | 8 | 215 | 177 | k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
x = [0] * n
for i in range(n):
t = a[i] - a[i - 1]
if i == 0:
t += k
x[i] = t
x[i] = t
print((sum(i for i in sorted(x)[:-1])))
| k, n = list(map(int, input().split()))
a = list(map(int, input().split()))
l = [0] * n
l[-1] = k + a[0] - a[-1]
for i in range(n - 1):
l[i] = a[i + 1] - a[i]
print((sum(sorted(l)[:-1])))
| false | 33.333333 | [
"-x = [0] * n",
"-for i in range(n):",
"- t = a[i] - a[i - 1]",
"- if i == 0:",
"- t += k",
"- x[i] = t",
"- x[i] = t",
"-print((sum(i for i in sorted(x)[:-1])))",
"+l = [0] * n",
"+l[-1] = k + a[0] - a[-1]",
"+for i in range(n - 1):",
"+ l[i] = a[i + 1] - a[i]",
"+... | false | 0.068099 | 0.070413 | 0.967135 | [
"s573481999",
"s011429178"
] |
u493520238 | p03050 | python | s904997706 | s046625302 | 194 | 67 | 40,172 | 63,704 | Accepted | Accepted | 65.46 | import math
n = int(eval(input()))
ans = 0
for i in range(1, int(-(-n**0.5//1))+1):
if n%i == 0:
m = n//i - 1
if i < m: ans += m
print(ans) | n=int(eval(input()))
ans = 0
for i in range(1,int(n**0.5)+1):
if n%i == 0:
# print('----',i)
a = i
x1 = n//i
x = x1-1
# print(a,x)
if a < x:
ans += x
a = n//i
x1 = i
x = x1 - 1
if a < x:
... | 9 | 19 | 163 | 338 | import math
n = int(eval(input()))
ans = 0
for i in range(1, int(-(-(n**0.5) // 1)) + 1):
if n % i == 0:
m = n // i - 1
if i < m:
ans += m
print(ans)
| n = int(eval(input()))
ans = 0
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
# print('----',i)
a = i
x1 = n // i
x = x1 - 1
# print(a,x)
if a < x:
ans += x
a = n // i
x1 = i
x = x1 - 1
if a < x:
ans += x
pri... | false | 52.631579 | [
"-import math",
"-",
"-for i in range(1, int(-(-(n**0.5) // 1)) + 1):",
"+for i in range(1, int(n**0.5) + 1):",
"- m = n // i - 1",
"- if i < m:",
"- ans += m",
"+ a = i",
"+ x1 = n // i",
"+ x = x1 - 1",
"+ # print(a,x)",
"+ if a < x... | false | 0.4487 | 0.308445 | 1.454719 | [
"s904997706",
"s046625302"
] |
u588341295 | p03305 | python | s063712247 | s875296999 | 1,352 | 1,206 | 89,024 | 82,376 | Accepted | Accepted | 10.8 | # -*- coding: utf-8 -*-
"""
参考:https://img.atcoder.jp/soundhound2018-summer-qual/editorial.pdf
https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2018/0707_soundhound2018_summer_qual
"""
import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, fa... | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in rang... | 86 | 73 | 2,814 | 2,032 | # -*- coding: utf-8 -*-
"""
参考:https://img.atcoder.jp/soundhound2018-summer-qual/editorial.pdf
https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2018/0707_soundhound2018_summer_qual
"""
import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi... | # -*- coding: utf-8 -*-
import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d... | false | 15.116279 | [
"-\"\"\"",
"-参考:https://img.atcoder.jp/soundhound2018-summer-qual/editorial.pdf",
"- https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2018/0707_soundhound2018_summer_qual",
"-\"\"\"",
"-import sys, re",
"-from collections import deque, defaultdict, Counter",
"-from math import sq... | false | 0.007548 | 0.044717 | 0.168803 | [
"s063712247",
"s875296999"
] |
u118211443 | p03997 | python | s671733073 | s573422667 | 19 | 17 | 2,940 | 2,940 | Accepted | Accepted | 10.53 | a=int(eval(input()))
b=int(eval(input()))
h=int(eval(input()))
print((int((a+b)*h/2))) | a = int(eval(input()))
b = int(eval(input()))
h = int(eval(input()))
print(((a + b) * h // 2))
| 4 | 4 | 69 | 78 | a = int(eval(input()))
b = int(eval(input()))
h = int(eval(input()))
print((int((a + b) * h / 2)))
| a = int(eval(input()))
b = int(eval(input()))
h = int(eval(input()))
print(((a + b) * h // 2))
| false | 0 | [
"-print((int((a + b) * h / 2)))",
"+print(((a + b) * h // 2))"
] | false | 0.066041 | 0.067412 | 0.97966 | [
"s671733073",
"s573422667"
] |
u133936772 | p02984 | python | s840547207 | s261244446 | 157 | 116 | 16,320 | 14,036 | Accepted | Accepted | 26.11 | n=int(eval(input()))
l=list(map(int,input().split()))
e,o=l[0::2],l[1::2]
a=[0]*n
a[0]=sum(l)-sum(o)*2
p=o[0]
m=n//2
s=o+e
for i in range(m):
a[i*2+2]=a[i*2]-s[m+i]*2+p*2
p=s[i+1]
s=e+o
for i in range(m):
a[i*2+1]=a[i*2-1]-s[m+i]*2+p*2
p=s[i+1]
print((*a)) | eval(input())
l=list(map(int,input().split()))
a=[]
t=sum(l)-sum(l[1::2])*2
for i in l:
a+=[t]
t=i*2-t
print((*a)) | 16 | 8 | 271 | 117 | n = int(eval(input()))
l = list(map(int, input().split()))
e, o = l[0::2], l[1::2]
a = [0] * n
a[0] = sum(l) - sum(o) * 2
p = o[0]
m = n // 2
s = o + e
for i in range(m):
a[i * 2 + 2] = a[i * 2] - s[m + i] * 2 + p * 2
p = s[i + 1]
s = e + o
for i in range(m):
a[i * 2 + 1] = a[i * 2 - 1] - s[m + i] * 2 + p *... | eval(input())
l = list(map(int, input().split()))
a = []
t = sum(l) - sum(l[1::2]) * 2
for i in l:
a += [t]
t = i * 2 - t
print((*a))
| false | 50 | [
"-n = int(eval(input()))",
"+eval(input())",
"-e, o = l[0::2], l[1::2]",
"-a = [0] * n",
"-a[0] = sum(l) - sum(o) * 2",
"-p = o[0]",
"-m = n // 2",
"-s = o + e",
"-for i in range(m):",
"- a[i * 2 + 2] = a[i * 2] - s[m + i] * 2 + p * 2",
"- p = s[i + 1]",
"-s = e + o",
"-for i in range(... | false | 0.187937 | 0.038385 | 4.896138 | [
"s840547207",
"s261244446"
] |
u998435601 | p02415 | python | s132413362 | s078913623 | 20 | 10 | 6,432 | 6,428 | Accepted | Accepted | 50 | # -*- coding: utf-8 -*-
str = input()
s = []
for c in str:
s.append(c.lower() if c.isupper() else c.upper())
print(''.join(s)) | # -*- coding: utf-8 -*-
str = input()
s = ""
for c in str:
s += (c.lower() if c.isupper() else c.upper())
print(s) | 6 | 6 | 135 | 123 | # -*- coding: utf-8 -*-
str = input()
s = []
for c in str:
s.append(c.lower() if c.isupper() else c.upper())
print("".join(s))
| # -*- coding: utf-8 -*-
str = input()
s = ""
for c in str:
s += c.lower() if c.isupper() else c.upper()
print(s)
| false | 0 | [
"-s = []",
"+s = \"\"",
"- s.append(c.lower() if c.isupper() else c.upper())",
"-print(\"\".join(s))",
"+ s += c.lower() if c.isupper() else c.upper()",
"+print(s)"
] | false | 0.049311 | 0.091008 | 0.541835 | [
"s132413362",
"s078913623"
] |
u761320129 | p02901 | python | s621884917 | s402644623 | 1,554 | 1,367 | 3,188 | 3,564 | Accepted | Accepted | 12.03 | N,M = list(map(int,input().split()))
INF = float('inf')
V = [INF] * (1<<N)
V[0] = 0
for i in range(M):
v,_ = list(map(int,input().split()))
b = 0
s = list(map(int,input().split()))
for a in s:
b |= (1<<(a-1))
V[b] = min(V[b], v)
vbs = []
for b,v in enumerate(V):
if v==INF:... | N,M = list(map(int,input().split()))
from collections import defaultdict
INF = float('inf')
dic = defaultdict(lambda: INF)
for i in range(M):
a,b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = 0
for k in c:
d |= (1<<(k-1))
dic[d] = min(dic[d], a)
dp = [I... | 23 | 20 | 500 | 550 | N, M = list(map(int, input().split()))
INF = float("inf")
V = [INF] * (1 << N)
V[0] = 0
for i in range(M):
v, _ = list(map(int, input().split()))
b = 0
s = list(map(int, input().split()))
for a in s:
b |= 1 << (a - 1)
V[b] = min(V[b], v)
vbs = []
for b, v in enumerate(V):
if v == INF:
... | N, M = list(map(int, input().split()))
from collections import defaultdict
INF = float("inf")
dic = defaultdict(lambda: INF)
for i in range(M):
a, b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
for k in c:
d |= 1 << (k - 1)
dic[d] = min(dic[d], a)
dp = [INF] *... | false | 13.043478 | [
"+from collections import defaultdict",
"+",
"-V = [INF] * (1 << N)",
"-V[0] = 0",
"+dic = defaultdict(lambda: INF)",
"- v, _ = list(map(int, input().split()))",
"- b = 0",
"- s = list(map(int, input().split()))",
"- for a in s:",
"- b |= 1 << (a - 1)",
"- V[b] = min(V[b], ... | false | 0.04145 | 0.04539 | 0.913195 | [
"s621884917",
"s402644623"
] |
u532966492 | p02728 | python | s682869646 | s115355654 | 2,828 | 1,088 | 169,824 | 122,932 | Accepted | Accepted | 61.53 | def main():
from sys import stdin
input = stdin.readline
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
g = [set() for _ in [0]*n]
for a, b in ab:
g[a-1].add(b-1)
g[b-1].add(a-1)
mod = 10**9+7
fact = [1, 1]
inv = [pow(i... | def main():
from sys import stdin
input = stdin.readline
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
g = [[] for _ in [0]*n]
for a, b in ab:
g[a-1].append(b-1)
g[b-1].append(a-1)
mod = 10**9+7
fact = [1, 1]
inv = [po... | 88 | 81 | 2,647 | 2,014 | def main():
from sys import stdin
input = stdin.readline
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0] * (n - 1)]
g = [set() for _ in [0] * n]
for a, b in ab:
g[a - 1].add(b - 1)
g[b - 1].add(a - 1)
mod = 10**9 + 7
fact = [1, 1]
inv = [pow... | def main():
from sys import stdin
input = stdin.readline
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in [0] * (n - 1)]
g = [[] for _ in [0] * n]
for a, b in ab:
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
mod = 10**9 + 7
fact = [1, 1]
inv = [... | false | 7.954545 | [
"- g = [set() for _ in [0] * n]",
"+ g = [[] for _ in [0] * n]",
"- g[a - 1].add(b - 1)",
"- g[b - 1].add(a - 1)",
"+ g[a - 1].append(b - 1)",
"+ g[b - 1].append(a - 1)",
"+ # merge:頂点aにbをマージするときのモノイド",
"+ # adj_bu:ボトムアップ時の調整(a:値,i:頂点)",
"+ # adj_td:トップダウン時... | false | 0.007534 | 0.033937 | 0.221989 | [
"s682869646",
"s115355654"
] |
u714225686 | p03281 | python | s960678422 | s643522638 | 40 | 36 | 5,456 | 5,076 | Accepted | Accepted | 10 | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
... | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
... | 49 | 44 | 1,089 | 1,017 | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def perm... | import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def perm... | false | 10.204082 | [
"- for i in range(1, N + 1):",
"- if i % 2 != 0:",
"- if count(i) == 8:",
"- ans += 1",
"- print(ans)",
"+ print((sum(count(x) == 8 for x in range(1, N + 1, 2))))"
] | false | 0.046279 | 0.112926 | 0.40982 | [
"s960678422",
"s643522638"
] |
u112364985 | p02934 | python | s967307895 | s107919890 | 32 | 27 | 9,888 | 9,064 | Accepted | Accepted | 15.62 | from decimal import Decimal
n=int(eval(input()))
List=list(map(int,input().split()))
add=0
for i in List:
add+=Decimal(1/i)
print((Decimal(1/add))) | n=int(eval(input()))
List=list(map(int,input().split()))
add=0
for i in List:
add+=1/i
print((1/add)) | 7 | 6 | 149 | 102 | from decimal import Decimal
n = int(eval(input()))
List = list(map(int, input().split()))
add = 0
for i in List:
add += Decimal(1 / i)
print((Decimal(1 / add)))
| n = int(eval(input()))
List = list(map(int, input().split()))
add = 0
for i in List:
add += 1 / i
print((1 / add))
| false | 14.285714 | [
"-from decimal import Decimal",
"-",
"- add += Decimal(1 / i)",
"-print((Decimal(1 / add)))",
"+ add += 1 / i",
"+print((1 / add))"
] | false | 0.042886 | 0.039969 | 1.07296 | [
"s967307895",
"s107919890"
] |
u852690916 | p02763 | python | s058281367 | s820660950 | 728 | 508 | 165,220 | 74,440 | Accepted | Accepted | 30.22 | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
S = ['$'] + list(input().rstrip())
c = lambda x: ord(x) - ord('a')
bit = [BinaryIndexedTree(N) for _ in range(26)]
for i, l in enumerate(S):
if i == 0: continue
bit[c(l)].add(i, 1)
Q = int(eval... | class SegmentTree:
def __init__(self, initial_values, f=max, zero=0, converter=lambda x:x):
self.__f, self.__z, self.__c, self.__size = f, zero, converter, len(initial_values)
self.__n = 1 << ((self.__size - 1).bit_length())
self.__dat = [zero] * (2 * self.__n)
zi = self.__get_l... | 52 | 47 | 1,507 | 1,994 | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
S = ["$"] + list(input().rstrip())
c = lambda x: ord(x) - ord("a")
bit = [BinaryIndexedTree(N) for _ in range(26)]
for i, l in enumerate(S):
if i == 0:
continue
bit[c(l)].add(i, 1)
Q = int(eva... | class SegmentTree:
def __init__(self, initial_values, f=max, zero=0, converter=lambda x: x):
self.__f, self.__z, self.__c, self.__size = (
f,
zero,
converter,
len(initial_values),
)
self.__n = 1 << ((self.__size - 1).bit_length())
self.... | false | 9.615385 | [
"+class SegmentTree:",
"+ def __init__(self, initial_values, f=max, zero=0, converter=lambda x: x):",
"+ self.__f, self.__z, self.__c, self.__size = (",
"+ f,",
"+ zero,",
"+ converter,",
"+ len(initial_values),",
"+ )",
"+ self.__n... | false | 0.036381 | 0.072435 | 0.502262 | [
"s058281367",
"s820660950"
] |
u165578704 | p02367 | python | s564959438 | s924174803 | 200 | 180 | 19,152 | 21,732 | Accepted | Accepted | 10 | # -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10 ** 9)
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()))
INF=float('inf')
N,M=MAP()
nodes=[[] for i in range(... | import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1)... | 48 | 82 | 1,113 | 2,283 | # -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
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()))
INF = float("inf")
N, M = MAP()
nodes = [[... | import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [[c] * b for i in range(a)]
def list3d(a, b, c, d):
return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]... | false | 41.463415 | [
"-# -*- coding: utf-8 -*-",
"-",
"-sys.setrecursionlimit(10**9)",
"+",
"+",
"+def list2d(a, b, c):",
"+ return [[c] * b for i in range(a)]",
"+",
"+",
"+def list3d(a, b, c, d):",
"+ return [[[d] * c for j in range(b)] for i in range(a)]",
"+",
"+",
"+def list4d(a, b, c, d, e):",
"+... | false | 0.037286 | 0.061546 | 0.605819 | [
"s564959438",
"s924174803"
] |
u619458041 | p03018 | python | s605069436 | s218043900 | 103 | 36 | 3,500 | 3,500 | Accepted | Accepted | 65.05 | import sys
def main():
input = sys.stdin.readline
S = input().strip()
n = len(S)
T = ''
i = 0
while i < n:
if S[i] == 'A':
T += 'A'
i += 1
elif S[i:i+2] == 'BC':
T += 'D'
i += 2
else:
T += S[i]... | import sys
def main():
input = sys.stdin.readline
S = input().strip()
S = S.replace('BC', 'D')
ans = 0
cnt = 0
for c in S:
if c == 'A':
cnt += 1
elif c == 'D':
ans += cnt
else:
cnt = 0
return ans
if __name__... | 35 | 22 | 583 | 355 | import sys
def main():
input = sys.stdin.readline
S = input().strip()
n = len(S)
T = ""
i = 0
while i < n:
if S[i] == "A":
T += "A"
i += 1
elif S[i : i + 2] == "BC":
T += "D"
i += 2
else:
T += S[i]
... | import sys
def main():
input = sys.stdin.readline
S = input().strip()
S = S.replace("BC", "D")
ans = 0
cnt = 0
for c in S:
if c == "A":
cnt += 1
elif c == "D":
ans += cnt
else:
cnt = 0
return ans
if __name__ == "__main__":
p... | false | 37.142857 | [
"- n = len(S)",
"- T = \"\"",
"- i = 0",
"- while i < n:",
"- if S[i] == \"A\":",
"- T += \"A\"",
"- i += 1",
"- elif S[i : i + 2] == \"BC\":",
"- T += \"D\"",
"- i += 2",
"- else:",
"- T += S[i]",
"- ... | false | 0.037409 | 0.036685 | 1.019731 | [
"s605069436",
"s218043900"
] |
u177398299 | p03818 | python | s755058191 | s302841412 | 61 | 43 | 19,316 | 19,316 | Accepted | Accepted | 29.51 | N = int(eval(input()))
f = set()
eat = 0
for a in map(int, input().split()):
if a in f:
eat += 1
else:
f.add(a)
print((N - eat - eat % 2)) | N = int(eval(input()))
eat = N - len(set(map(int, input().split())))
print((N - eat - eat % 2)) | 9 | 3 | 162 | 89 | N = int(eval(input()))
f = set()
eat = 0
for a in map(int, input().split()):
if a in f:
eat += 1
else:
f.add(a)
print((N - eat - eat % 2))
| N = int(eval(input()))
eat = N - len(set(map(int, input().split())))
print((N - eat - eat % 2))
| false | 66.666667 | [
"-f = set()",
"-eat = 0",
"-for a in map(int, input().split()):",
"- if a in f:",
"- eat += 1",
"- else:",
"- f.add(a)",
"+eat = N - len(set(map(int, input().split())))"
] | false | 0.008068 | 0.070709 | 0.114107 | [
"s755058191",
"s302841412"
] |
u966695411 | p04005 | python | s279845974 | s795741027 | 38 | 24 | 3,064 | 3,064 | Accepted | Accepted | 36.84 | A, B, C = list(map(int, input().split()))
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
print((0))
else:
s = sorted([A, B, C])
print((s[0] * s[1])) | *l, = list(map(int, input().split()))
a, b, c = sorted(l)
if a%2 == 0 or b%2 == 0 or c%2 == 0:
print((0))
else:
print((a*b)) | 6 | 6 | 151 | 127 | A, B, C = list(map(int, input().split()))
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
print((0))
else:
s = sorted([A, B, C])
print((s[0] * s[1]))
| (*l,) = list(map(int, input().split()))
a, b, c = sorted(l)
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
print((0))
else:
print((a * b))
| false | 0 | [
"-A, B, C = list(map(int, input().split()))",
"-if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:",
"+(*l,) = list(map(int, input().split()))",
"+a, b, c = sorted(l)",
"+if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:",
"- s = sorted([A, B, C])",
"- print((s[0] * s[1]))",
"+ print((a * b))"
] | false | 0.041529 | 0.035914 | 1.156338 | [
"s279845974",
"s795741027"
] |
u057109575 | p02984 | python | s553154653 | s175484588 | 275 | 123 | 71,228 | 93,132 | Accepted | Accepted | 55.27 | N, *A = list(map(int, open(0).read().split()))
ans = [0] * N
for i in range(N):
ans[0] += A[i] * (-1) ** int(i % 2 != 0)
for i in reversed(list(range(1, N))):
ans[i] = 2 * A[i] - ans[(i + 1) % N]
print((*ans)) | N, *A = list(map(int, open(0).read().split()))
ans = [0] * N
for i in range(N):
ans[0] += (-1) ** i * A[i]
for i in range(1, N):
ans[i] = (A[i - 1] - ans[i - 1] // 2) * 2
print((*ans))
| 10 | 10 | 219 | 205 | N, *A = list(map(int, open(0).read().split()))
ans = [0] * N
for i in range(N):
ans[0] += A[i] * (-1) ** int(i % 2 != 0)
for i in reversed(list(range(1, N))):
ans[i] = 2 * A[i] - ans[(i + 1) % N]
print((*ans))
| N, *A = list(map(int, open(0).read().split()))
ans = [0] * N
for i in range(N):
ans[0] += (-1) ** i * A[i]
for i in range(1, N):
ans[i] = (A[i - 1] - ans[i - 1] // 2) * 2
print((*ans))
| false | 0 | [
"- ans[0] += A[i] * (-1) ** int(i % 2 != 0)",
"-for i in reversed(list(range(1, N))):",
"- ans[i] = 2 * A[i] - ans[(i + 1) % N]",
"+ ans[0] += (-1) ** i * A[i]",
"+for i in range(1, N):",
"+ ans[i] = (A[i - 1] - ans[i - 1] // 2) * 2"
] | false | 0.040544 | 0.039923 | 1.015557 | [
"s553154653",
"s175484588"
] |
u481187938 | p02726 | python | s987451338 | s752600495 | 1,971 | 139 | 137,424 | 75,180 | Accepted | Accepted | 92.95 | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): ... | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): ... | 85 | 61 | 1,723 | 1,083 | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
ret... | #!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
ret... | false | 28.235294 | [
"- dist = [[N] * N for _ in range(N)]",
"- q = deque()",
"- for i in range(N):",
"- q.append(i)",
"- dist[i][i] = 0",
"- while q:",
"- u = q.popleft()",
"- t = dist[i][u] + 1",
"- if u < N - 1:",
"- if dist[i][u + 1] > t... | false | 0.112562 | 0.036573 | 3.077734 | [
"s987451338",
"s752600495"
] |
u285891772 | p03087 | python | s524622365 | s043232359 | 380 | 334 | 32,716 | 10,976 | Accepted | Accepted | 12.11 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ... | 35 | 34 | 1,029 | 1,009 | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_... | import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_... | false | 2.857143 | [
"-lr = [LIST() for _ in range(Q)]",
"-T = [0] * N",
"-cnt = 0",
"-for i in range(1, N):",
"- if S[i] == \"C\" and S[i - 1] == \"A\":",
"- cnt += 1",
"- T[i] = cnt",
"- else:",
"- T[i] = cnt",
"-for i in range(Q):",
"- print((T[lr[i][1] - 1] - T[lr[i][0] - 1]))",
"... | false | 0.046164 | 0.045545 | 1.013596 | [
"s524622365",
"s043232359"
] |
u879870653 | p03038 | python | s412167696 | s569963583 | 775 | 706 | 44,736 | 44,996 | Accepted | Accepted | 8.9 | N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
L = [list(map(int,input().split())) for i in range(M)]
P = sorted(([[1,A[i]] for i in range(N)] + L),key=lambda x: x[1],reverse=True)
ans = 0
rest = N
for cost,value in P :
K = min(cost, rest)
K = max(0,K)
ans += K * valu... | N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
L = [list(map(int,input().split())) for i in range(M)]
for i in range(N) :
L.append([1,A[i]])
L = sorted(L, key=lambda x: x[1], reverse=True)
ans = 0
for i in range(len(L)) :
number, point = L[i]
if number > N... | 16 | 23 | 348 | 405 | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(M)]
P = sorted(([[1, A[i]] for i in range(N)] + L), key=lambda x: x[1], reverse=True)
ans = 0
rest = N
for cost, value in P:
K = min(cost, rest)
K = max(0, K)
ans += K * value
r... | N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(M)]
for i in range(N):
L.append([1, A[i]])
L = sorted(L, key=lambda x: x[1], reverse=True)
ans = 0
for i in range(len(L)):
number, point = L[i]
if number > N:
number = N
... | false | 30.434783 | [
"-P = sorted(([[1, A[i]] for i in range(N)] + L), key=lambda x: x[1], reverse=True)",
"+for i in range(N):",
"+ L.append([1, A[i]])",
"+L = sorted(L, key=lambda x: x[1], reverse=True)",
"-rest = N",
"-for cost, value in P:",
"- K = min(cost, rest)",
"- K = max(0, K)",
"- ans += K * value... | false | 0.043785 | 0.038838 | 1.127359 | [
"s412167696",
"s569963583"
] |
u349449706 | p02844 | python | s175913492 | s284502129 | 863 | 227 | 74,092 | 68,116 | Accepted | Accepted | 73.7 | N=int(eval(input()))
S=eval(input())
ans=0
for i in range(1000):
l=[]
for j in range(3):
l.append(i//10**(2-j)%10)
k=0
for j in range(N):
if int(S[j])==l[k]:
k+=1
if k==3:
ans += 1
break
print(ans) | N=int(eval(input()))
S=eval(input())
ans=0
for i in range(1000):
l=str(i).zfill(3)
k=0
for j in range(N):
if S[j]==l[k]:
k+=1
if k==3:
ans += 1
break
print(ans) | 15 | 13 | 243 | 198 | N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1000):
l = []
for j in range(3):
l.append(i // 10 ** (2 - j) % 10)
k = 0
for j in range(N):
if int(S[j]) == l[k]:
k += 1
if k == 3:
ans += 1
break
print(ans)
| N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1000):
l = str(i).zfill(3)
k = 0
for j in range(N):
if S[j] == l[k]:
k += 1
if k == 3:
ans += 1
break
print(ans)
| false | 13.333333 | [
"- l = []",
"- for j in range(3):",
"- l.append(i // 10 ** (2 - j) % 10)",
"+ l = str(i).zfill(3)",
"- if int(S[j]) == l[k]:",
"+ if S[j] == l[k]:"
] | false | 0.057819 | 0.035338 | 1.636151 | [
"s175913492",
"s284502129"
] |
u969850098 | p02787 | python | s250740270 | s016544425 | 350 | 138 | 41,840 | 73,868 | Accepted | Accepted | 60.57 | INF = 10 ** 9
def main():
H, N = list(map(int, input().split()))
dp = [INF] * (H+1)
dp[0] = 0
for _ in range(N):
a, b = list(map(int, input().split()))
for j in range(H):
nj = min(j+a, H)
dp[nj] = min(dp[nj], dp[j]+b)
print((dp[H]))
if _... | import sys
readline = sys.stdin.readline
INF = 10 ** 8
def main():
H, N = list(map(int, readline().rstrip().split()))
dp = [INF] * (H + 1) # HPを減らすのに必要な最小のMP
dp[0] = 0
for _ in range(N):
hp, mp = list(map(int, readline().rstrip().split()))
for i in range(H):
... | 17 | 22 | 340 | 435 | INF = 10**9
def main():
H, N = list(map(int, input().split()))
dp = [INF] * (H + 1)
dp[0] = 0
for _ in range(N):
a, b = list(map(int, input().split()))
for j in range(H):
nj = min(j + a, H)
dp[nj] = min(dp[nj], dp[j] + b)
print((dp[H]))
if __name__ == "__m... | import sys
readline = sys.stdin.readline
INF = 10**8
def main():
H, N = list(map(int, readline().rstrip().split()))
dp = [INF] * (H + 1) # HPを減らすのに必要な最小のMP
dp[0] = 0
for _ in range(N):
hp, mp = list(map(int, readline().rstrip().split()))
for i in range(H):
j = min(i + hp,... | false | 22.727273 | [
"-INF = 10**9",
"+import sys",
"+",
"+readline = sys.stdin.readline",
"+INF = 10**8",
"- H, N = list(map(int, input().split()))",
"- dp = [INF] * (H + 1)",
"+ H, N = list(map(int, readline().rstrip().split()))",
"+ dp = [INF] * (H + 1) # HPを減らすのに必要な最小のMP",
"- a, b = list(map(in... | false | 0.223056 | 0.094357 | 2.363957 | [
"s250740270",
"s016544425"
] |
u349449706 | p02891 | python | s729885733 | s019053750 | 73 | 62 | 62,000 | 62,184 | Accepted | Accepted | 15.07 | import math
S = eval(input())
K = int(eval(input()))
s = list(S)
c1 = 0
for i in range(len(s)-1):
if s[i+1] == s[i]:
c1 += 1
s[i+1] = 0
s = list(S*2)
c2 = 0
for i in range(len(s)-1):
if s[i+1] == s[i]:
c2 += 1
s[i+1] = 0
c = S[0]
for s in S:
if s != c:
... | import math
S = list(eval(input()))
K = int(eval(input()))
s = S * 2
c1 = 0
c2 = 0
for i in range(len(s)-1):
if s[i+1] == s[i]:
if i < len(S)-1:
c1 += 1
c2 += 1
s[i+1] = 0
c = S[0]
for s in S:
if s != c:
print((c1+(c2-c1)*(K-1)))
exit()
print(... | 21 | 18 | 382 | 330 | import math
S = eval(input())
K = int(eval(input()))
s = list(S)
c1 = 0
for i in range(len(s) - 1):
if s[i + 1] == s[i]:
c1 += 1
s[i + 1] = 0
s = list(S * 2)
c2 = 0
for i in range(len(s) - 1):
if s[i + 1] == s[i]:
c2 += 1
s[i + 1] = 0
c = S[0]
for s in S:
if s != c:
... | import math
S = list(eval(input()))
K = int(eval(input()))
s = S * 2
c1 = 0
c2 = 0
for i in range(len(s) - 1):
if s[i + 1] == s[i]:
if i < len(S) - 1:
c1 += 1
c2 += 1
s[i + 1] = 0
c = S[0]
for s in S:
if s != c:
print((c1 + (c2 - c1) * (K - 1)))
exit()
print(... | false | 14.285714 | [
"-S = eval(input())",
"+S = list(eval(input()))",
"-s = list(S)",
"+s = S * 2",
"-for i in range(len(s) - 1):",
"- if s[i + 1] == s[i]:",
"- c1 += 1",
"- s[i + 1] = 0",
"-s = list(S * 2)",
"+ if i < len(S) - 1:",
"+ c1 += 1"
] | false | 0.037116 | 0.042768 | 0.867835 | [
"s729885733",
"s019053750"
] |
u017525488 | p00013 | python | s736982777 | s853909036 | 20 | 10 | 4,196 | 4,204 | Accepted | Accepted | 50 | import sys
lst = []
for line in sys.stdin:
num = line.strip()
if num == "0":
print(lst.pop())
else:
lst.append(num) | import sys
lst = []
for line in sys.stdin:
if line.strip() :
num = int(line.strip())
if num == 0:
print(lst.pop())
else:
lst.append(num) | 9 | 10 | 151 | 197 | import sys
lst = []
for line in sys.stdin:
num = line.strip()
if num == "0":
print(lst.pop())
else:
lst.append(num)
| import sys
lst = []
for line in sys.stdin:
if line.strip():
num = int(line.strip())
if num == 0:
print(lst.pop())
else:
lst.append(num)
| false | 10 | [
"- num = line.strip()",
"- if num == \"0\":",
"- print(lst.pop())",
"- else:",
"- lst.append(num)",
"+ if line.strip():",
"+ num = int(line.strip())",
"+ if num == 0:",
"+ print(lst.pop())",
"+ else:",
"+ lst.append(num)"
] | false | 0.036691 | 0.035282 | 1.039939 | [
"s736982777",
"s853909036"
] |
u562935282 | p03831 | python | s687112873 | s627561056 | 71 | 64 | 14,352 | 11,100 | Accepted | Accepted | 9.86 | n, a, b = list(map(int, input().split()))
x = tuple(map(int, input().split()))
# o <-tel-> o --walk-- 0 -- walk-- o <=tel-> ...
# 左から順にa,b最小コストを選択
print((sum(min((after - prev) * a, b) for prev, after in zip(x, x[1:]))))
# http://xxxasdfghjk999.hatenablog.jp/entry/2018/07/29/214705
# 最小全域木だとTLEする
# 徒歩区間を連結でき... | def main():
N, A, B = list(map(int, input().split()))
X = list(map(int, input().split()))
ret = 0
curr = next(X)
for x in X:
ret += min((x - curr) * A, B)
curr = x
print(ret)
if __name__ == '__main__':
main()
| 10 | 14 | 323 | 257 | n, a, b = list(map(int, input().split()))
x = tuple(map(int, input().split()))
# o <-tel-> o --walk-- 0 -- walk-- o <=tel-> ...
# 左から順にa,b最小コストを選択
print((sum(min((after - prev) * a, b) for prev, after in zip(x, x[1:]))))
# http://xxxasdfghjk999.hatenablog.jp/entry/2018/07/29/214705
# 最小全域木だとTLEする
# 徒歩区間を連結できるので、貪欲に決まる
| def main():
N, A, B = list(map(int, input().split()))
X = list(map(int, input().split()))
ret = 0
curr = next(X)
for x in X:
ret += min((x - curr) * A, B)
curr = x
print(ret)
if __name__ == "__main__":
main()
| false | 28.571429 | [
"-n, a, b = list(map(int, input().split()))",
"-x = tuple(map(int, input().split()))",
"-# o <-tel-> o --walk-- 0 -- walk-- o <=tel-> ...",
"-# 左から順にa,b最小コストを選択",
"-print((sum(min((after - prev) * a, b) for prev, after in zip(x, x[1:]))))",
"-# http://xxxasdfghjk999.hatenablog.jp/entry/2018/07/29/214705",... | false | 0.046113 | 0.04935 | 0.934407 | [
"s687112873",
"s627561056"
] |
u752694775 | p02947 | python | s156739179 | s006121768 | 345 | 191 | 19,400 | 21,128 | Accepted | Accepted | 44.64 | #n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
n = int(eval(input()))
sl = []
for i in range(n):
S = ''.join(sorted(eval(input())))
sl.append(S)
count = 0
dict ={}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count) | n,*sl, = [''.join(sorted(x)) for x in open(0).read().split()]
count = 0
dict ={}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count) | 16 | 11 | 294 | 198 | # n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())
n = int(eval(input()))
sl = []
for i in range(n):
S = "".join(sorted(eval(input())))
sl.append(S)
count = 0
dict = {}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count)
| (
n,
*sl,
) = ["".join(sorted(x)) for x in open(0).read().split()]
count = 0
dict = {}
for s in sl:
if s in dict:
count += dict[s]
dict[s] += 1
else:
dict[s] = 1
print(count)
| false | 31.25 | [
"-# n,*sl, = map(lambda x:''.join(sorted(x)),open(0).read().split())",
"-n = int(eval(input()))",
"-sl = []",
"-for i in range(n):",
"- S = \"\".join(sorted(eval(input())))",
"- sl.append(S)",
"+(",
"+ n,",
"+ *sl,",
"+) = [\"\".join(sorted(x)) for x in open(0).read().split()]"
] | false | 0.091106 | 0.052387 | 1.739092 | [
"s156739179",
"s006121768"
] |
u466330895 | p03556 | python | s413107795 | s827346461 | 57 | 17 | 3,060 | 2,940 | Accepted | Accepted | 70.18 | import math
n = int(eval(input()))
ans = n
while True: # breakなどされるまで無限ループ
ans_sqrt = math.sqrt(ans)
if math.ceil(ans_sqrt) == math.floor(ans_sqrt):
print(ans)
exit()
else:
ans -= 1
| import math
n = int(eval(input()))
print((int(math.floor(math.sqrt(n))**2))) | 11 | 4 | 224 | 72 | import math
n = int(eval(input()))
ans = n
while True: # breakなどされるまで無限ループ
ans_sqrt = math.sqrt(ans)
if math.ceil(ans_sqrt) == math.floor(ans_sqrt):
print(ans)
exit()
else:
ans -= 1
| import math
n = int(eval(input()))
print((int(math.floor(math.sqrt(n)) ** 2)))
| false | 63.636364 | [
"-ans = n",
"-while True: # breakなどされるまで無限ループ",
"- ans_sqrt = math.sqrt(ans)",
"- if math.ceil(ans_sqrt) == math.floor(ans_sqrt):",
"- print(ans)",
"- exit()",
"- else:",
"- ans -= 1",
"+print((int(math.floor(math.sqrt(n)) ** 2)))"
] | false | 0.042311 | 0.048065 | 0.880292 | [
"s413107795",
"s827346461"
] |
u703950586 | p03608 | python | s612314215 | s301606903 | 658 | 381 | 75,736 | 55,384 | Accepted | Accepted | 42.1 | import sys,queue,math,copy,itertools,bisect,collections
from heapq import *
def main():
sys.setrecursionlimit(10**7)
INF = 10**8
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : in... | import sys,queue,math,copy,itertools,bisect,collections
from heapq import *
def main():
sys.setrecursionlimit(10**7)
INF = 10**8
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : in... | 49 | 50 | 1,388 | 1,428 | import sys, queue, math, copy, itertools, bisect, collections
from heapq import *
def main():
sys.setrecursionlimit(10**7)
INF = 10**8
MOD = 10**9 + 7
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
_LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()]
NI = lambda: int(s... | import sys, queue, math, copy, itertools, bisect, collections
from heapq import *
def main():
sys.setrecursionlimit(10**7)
INF = 10**8
MOD = 10**9 + 7
LI = lambda: [int(x) for x in sys.stdin.readline().split()]
_LI = lambda: [int(x) - 1 for x in sys.stdin.readline().split()]
NI = lambda: int(s... | false | 2 | [
"+ node[s] = 0",
"- if l >= node[u]:",
"+ if l > node[u]:",
"- node[u] = l",
"+ node[v] = l + m"
] | false | 0.158563 | 0.039309 | 4.033769 | [
"s612314215",
"s301606903"
] |
u970308980 | p03578 | python | s564255475 | s574168461 | 385 | 268 | 35,420 | 67,680 | Accepted | Accepted | 30.39 | N = int(eval(input()))
D = sorted(map(int, input().split()))
M = int(eval(input()))
T = sorted(map(int, input().split()))
n = 0
for t in T:
for i in range(n, N):
if D[i] == t:
n = i + 1
break
if D[i] > t:
print('NO')
exit()
if i ... | from collections import Counter
N = int(eval(input()))
D = Counter(list(map(int, input().split())))
M = int(eval(input()))
T = Counter(list(map(int, input().split())))
for k, v in list(T.items()):
if D[k] < v:
print('NO')
exit()
print('YES')
| 18 | 11 | 377 | 243 | N = int(eval(input()))
D = sorted(map(int, input().split()))
M = int(eval(input()))
T = sorted(map(int, input().split()))
n = 0
for t in T:
for i in range(n, N):
if D[i] == t:
n = i + 1
break
if D[i] > t:
print("NO")
exit()
if i == N - 1:
... | from collections import Counter
N = int(eval(input()))
D = Counter(list(map(int, input().split())))
M = int(eval(input()))
T = Counter(list(map(int, input().split())))
for k, v in list(T.items()):
if D[k] < v:
print("NO")
exit()
print("YES")
| false | 38.888889 | [
"+from collections import Counter",
"+",
"-D = sorted(map(int, input().split()))",
"+D = Counter(list(map(int, input().split())))",
"-T = sorted(map(int, input().split()))",
"-n = 0",
"-for t in T:",
"- for i in range(n, N):",
"- if D[i] == t:",
"- n = i + 1",
"- ... | false | 0.047354 | 0.038828 | 1.219579 | [
"s564255475",
"s574168461"
] |
u077291787 | p03721 | python | s840761725 | s106571588 | 328 | 135 | 28,640 | 5,744 | Accepted | Accepted | 58.84 | # ABC061C - Big Array
import sys
input = sys.stdin.readline
def main():
n, k = list(map(int, input().rstrip().split()))
arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
cur, cnt = 0, 0
for i, j in arr:
cnt += j
if cnt >= k:
print(i)
... | # ABC061C - Big Array
import sys
input = sys.stdin.readline
def main():
n, k = list(map(int, input().split()))
memo = [0] * (10 ** 5 + 1)
for _ in range(n):
i, j = list(map(int, input().split()))
memo[i] += j
cnt = 0
for i, j in enumerate(memo):
cnt += j
... | 17 | 20 | 377 | 407 | # ABC061C - Big Array
import sys
input = sys.stdin.readline
def main():
n, k = list(map(int, input().rstrip().split()))
arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
cur, cnt = 0, 0
for i, j in arr:
cnt += j
if cnt >= k:
print(i)
br... | # ABC061C - Big Array
import sys
input = sys.stdin.readline
def main():
n, k = list(map(int, input().split()))
memo = [0] * (10**5 + 1)
for _ in range(n):
i, j = list(map(int, input().split()))
memo[i] += j
cnt = 0
for i, j in enumerate(memo):
cnt += j
if cnt >= k:... | false | 15 | [
"- n, k = list(map(int, input().rstrip().split()))",
"- arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])",
"- cur, cnt = 0, 0",
"- for i, j in arr:",
"+ n, k = list(map(int, input().split()))",
"+ memo = [0] * (10**5 + 1)",
"+ for _ in range(n):",
"+ ... | false | 0.035536 | 0.042677 | 0.83267 | [
"s840761725",
"s106571588"
] |
u179169725 | p02936 | python | s473442382 | s742285202 | 1,277 | 558 | 232,200 | 169,308 | Accepted | Accepted | 56.3 | # 木上の累積和
import sys
from collections import defaultdict
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina(*argv, sub=1): return list([x - sub for x in argv])
def ints():
return list(map(int, read().split()))
N, Q = ints()
tree = defaultdict(lambda:... | # 木上の累積和
import sys
from collections import defaultdict
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina(*argv, sub=1): return list([x - sub for x in argv])
def ints():
return list(map(int, read().split()))
N, Q = ints()
tree = defaultdict(lambda:... | 43 | 80 | 739 | 1,595 | # 木上の累積和
import sys
from collections import defaultdict
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina(*argv, sub=1):
return list([x - sub for x in argv])
def ints():
return list(map(int, read().split()))
N, Q = ints()
tree = defaultdict(lambda: [])
for _ in ... | # 木上の累積和
import sys
from collections import defaultdict
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
def mina(*argv, sub=1):
return list([x - sub for x in argv])
def ints():
return list(map(int, read().split()))
N, Q = ints()
tree = defaultdict(lambda: [])
for _ in ... | false | 46.25 | [
"-def dfs(u, p): # uは現在のノード、pは親のノード",
"- cnt[u] += cnt[p]",
"- for nv in tree[u]:",
"- if nv == p:",
"- continue",
"- dfs(nv, u)",
"+# def dfs(u, p): # uは現在のノード、pは親のノード",
"+# cnt[u] += cnt[p]",
"+# for nv in tree[u]:",
"+# if nv == p:",
"+# ... | false | 0.044824 | 0.036432 | 1.230357 | [
"s473442382",
"s742285202"
] |
u638795007 | p02815 | python | s188058801 | s982955688 | 317 | 240 | 81,520 | 24,268 | Accepted | Accepted | 24.29 | def examA():
K, X = LI()
if K*500>=X:
ans = "Yes"
else:
ans = "No"
print(ans)
return
def examB():
N = I()
S = SI()
ans = 0
for i in range(N-2):
if S[i:i+3]=="ABC":
ans +=1
print(ans)
return
def examC():
N = I()
... | def examA():
N = I()
X = [LI()for _ in range(N)]
l = 0; r = inf
while(r-l>_ep):
now = (l+r)/2
x_l = -inf; x_r = inf
y_l = -inf; y_r = inf
for x,y,c in X:
move = now / c
x_l = max(x_l,x-move)
x_r = min(x_r,x+move)
... | 119 | 72 | 2,641 | 1,637 | def examA():
K, X = LI()
if K * 500 >= X:
ans = "Yes"
else:
ans = "No"
print(ans)
return
def examB():
N = I()
S = SI()
ans = 0
for i in range(N - 2):
if S[i : i + 3] == "ABC":
ans += 1
print(ans)
return
def examC():
N = I()
P = ... | def examA():
N = I()
X = [LI() for _ in range(N)]
l = 0
r = inf
while r - l > _ep:
now = (l + r) / 2
x_l = -inf
x_r = inf
y_l = -inf
y_r = inf
for x, y, c in X:
move = now / c
x_l = max(x_l, x - move)
x_r = min(x_r, ... | false | 39.495798 | [
"- K, X = LI()",
"- if K * 500 >= X:",
"- ans = \"Yes\"",
"- else:",
"- ans = \"No\"",
"+ N = I()",
"+ X = [LI() for _ in range(N)]",
"+ l = 0",
"+ r = inf",
"+ while r - l > _ep:",
"+ now = (l + r) / 2",
"+ x_l = -inf",
"+ x_r = inf... | false | 0.038427 | 0.037062 | 1.036841 | [
"s188058801",
"s982955688"
] |
u588794534 | p03436 | python | s318871974 | s155646603 | 215 | 80 | 40,176 | 73,508 | Accepted | Accepted | 62.79 | h,w=list(map(int,input().split()))
sx,sy=0,0
gx,gy=w-1,h-1
maze=[]
white=0
for _ in range(h):
temp=eval(input())
t=[]
for s in temp:
t.append(s)
if s==".":
white+=1
maze.append(t)
maze[sy][sx]=1
from collections import deque
fifo = deque()
fifo.append([s... | h,w=list(map(int,input().split()))
s=[list(eval(input())) for _ in range(h)]
black_cnt=0
for ss in s:
black_cnt+=ss.count("#")
from collections import deque
stack=deque([(0,0)])
s[0][0]=1
flag=0
while len(stack)>0:
#print(stack)
tmp=stack.popleft()
if tmp[0]==h-1 and tmp[1]==w-1:
... | 59 | 38 | 1,017 | 810 | h, w = list(map(int, input().split()))
sx, sy = 0, 0
gx, gy = w - 1, h - 1
maze = []
white = 0
for _ in range(h):
temp = eval(input())
t = []
for s in temp:
t.append(s)
if s == ".":
white += 1
maze.append(t)
maze[sy][sx] = 1
from collections import deque
fifo = deque()
fifo.... | h, w = list(map(int, input().split()))
s = [list(eval(input())) for _ in range(h)]
black_cnt = 0
for ss in s:
black_cnt += ss.count("#")
from collections import deque
stack = deque([(0, 0)])
s[0][0] = 1
flag = 0
while len(stack) > 0:
# print(stack)
tmp = stack.popleft()
if tmp[0] == h - 1 and tmp[1] ==... | false | 35.59322 | [
"-sx, sy = 0, 0",
"-gx, gy = w - 1, h - 1",
"-maze = []",
"-white = 0",
"-for _ in range(h):",
"- temp = eval(input())",
"- t = []",
"- for s in temp:",
"- t.append(s)",
"- if s == \".\":",
"- white += 1",
"- maze.append(t)",
"-maze[sy][sx] = 1",
"+s = ... | false | 0.04303 | 0.085933 | 0.500743 | [
"s318871974",
"s155646603"
] |
u513081876 | p03379 | python | s266023001 | s124640149 | 376 | 312 | 25,224 | 26,772 | Accepted | Accepted | 17.02 | N = int(eval(input()))
a = [int(i) for i in input().split()]
big = sorted(a)[N // 2]
sma = sorted(a)[N // 2 - 1]
if big == sma:
for i in range(N):
print(big)
else:
for i in a:
if i < big:
print(big)
else:
print(sma) | N = int(eval(input()))
X = [int(i) for i in input().split()]
x = sorted(X)
num1 = x[N//2]
num2 = x[N//2 - 1]
ans = []
for i in X:
if i <= num2:
ans.append(num1)
else:
ans.append(num2)
for i in ans:
print(i) | 13 | 13 | 277 | 240 | N = int(eval(input()))
a = [int(i) for i in input().split()]
big = sorted(a)[N // 2]
sma = sorted(a)[N // 2 - 1]
if big == sma:
for i in range(N):
print(big)
else:
for i in a:
if i < big:
print(big)
else:
print(sma)
| N = int(eval(input()))
X = [int(i) for i in input().split()]
x = sorted(X)
num1 = x[N // 2]
num2 = x[N // 2 - 1]
ans = []
for i in X:
if i <= num2:
ans.append(num1)
else:
ans.append(num2)
for i in ans:
print(i)
| false | 0 | [
"-a = [int(i) for i in input().split()]",
"-big = sorted(a)[N // 2]",
"-sma = sorted(a)[N // 2 - 1]",
"-if big == sma:",
"- for i in range(N):",
"- print(big)",
"-else:",
"- for i in a:",
"- if i < big:",
"- print(big)",
"- else:",
"- print(sma)... | false | 0.101973 | 0.108301 | 0.941574 | [
"s266023001",
"s124640149"
] |
u344412812 | p03209 | python | s355066813 | s191247676 | 19 | 17 | 3,188 | 3,064 | Accepted | Accepted | 10.53 | N, X = list(map(int, input().split()))
pcnt = [0] * (N+1)
fcnt = [0] * (N+1)
pcnt[0] = fcnt[0] = 1
for i in range(N):
pcnt[i+1] = pcnt[i]*2+1
fcnt[i+1] = fcnt[i]*2+3
def func(l=N, x=X):
if (l == 0):
if (x >= 1):
return 1
else:
return 0
if (x <= 1):
return 0
if (x < fcnt[l-1]+2):
ret... | N, X = list(map(int, input().split()))
pcnt = [0] * (N+1)
fcnt = [0] * (N+1)
pcnt[0] = fcnt[0] = 1
for i in range(N):
pcnt[i+1] = pcnt[i]*2+1
fcnt[i+1] = fcnt[i]*2+3
def func(l=N, x=X):
if (l == 0):
if (x >= 1):
return 1
else:
return 0
if (x < fcnt[l-1]+2):
return func(l-1, x-1)
else:
... | 24 | 20 | 458 | 378 | N, X = list(map(int, input().split()))
pcnt = [0] * (N + 1)
fcnt = [0] * (N + 1)
pcnt[0] = fcnt[0] = 1
for i in range(N):
pcnt[i + 1] = pcnt[i] * 2 + 1
fcnt[i + 1] = fcnt[i] * 2 + 3
def func(l=N, x=X):
if l == 0:
if x >= 1:
return 1
else:
return 0
if x <= 1:
... | N, X = list(map(int, input().split()))
pcnt = [0] * (N + 1)
fcnt = [0] * (N + 1)
pcnt[0] = fcnt[0] = 1
for i in range(N):
pcnt[i + 1] = pcnt[i] * 2 + 1
fcnt[i + 1] = fcnt[i] * 2 + 3
def func(l=N, x=X):
if l == 0:
if x >= 1:
return 1
else:
return 0
if x < fcnt[l ... | false | 16.666667 | [
"- if x <= 1:",
"- return 0",
"- elif x == fcnt[l - 1] + 2:",
"- return pcnt[l - 1] + 1"
] | false | 0.043401 | 0.040371 | 1.075059 | [
"s355066813",
"s191247676"
] |
u561083515 | p02802 | python | s315898126 | s866246969 | 340 | 309 | 4,596 | 27,504 | Accepted | Accepted | 9.12 | N,M = list(map(int,input().split()))
AC = [False] * (N+1)
WA_cnt = [0] * (N+1)
penal = 0
for _ in range(M):
p,s = list(map(str,input().split()))
p = int(p)
if AC[p]:
continue
if s == "WA":
WA_cnt[p] += 1
else:
AC[p] = True
penal += WA_cnt[p]
ac = s... | N,M = list(map(int,input().split()))
pS = [[i for i in input().split()] for _ in range(M)]
# True -> AC済み
AC = [False] * N
WA_cnt = [0] * N
pena = 0
for p,S in pS:
p = int(p) - 1
if AC[p]:
continue
if S == "WA":
WA_cnt[p] += 1
else:
AC[p] = True
pena... | 19 | 22 | 332 | 363 | N, M = list(map(int, input().split()))
AC = [False] * (N + 1)
WA_cnt = [0] * (N + 1)
penal = 0
for _ in range(M):
p, s = list(map(str, input().split()))
p = int(p)
if AC[p]:
continue
if s == "WA":
WA_cnt[p] += 1
else:
AC[p] = True
penal += WA_cnt[p]
ac = sum(AC)
print... | N, M = list(map(int, input().split()))
pS = [[i for i in input().split()] for _ in range(M)]
# True -> AC済み
AC = [False] * N
WA_cnt = [0] * N
pena = 0
for p, S in pS:
p = int(p) - 1
if AC[p]:
continue
if S == "WA":
WA_cnt[p] += 1
else:
AC[p] = True
pena += WA_cnt[p]
ac = ... | false | 13.636364 | [
"-AC = [False] * (N + 1)",
"-WA_cnt = [0] * (N + 1)",
"-penal = 0",
"-for _ in range(M):",
"- p, s = list(map(str, input().split()))",
"- p = int(p)",
"+pS = [[i for i in input().split()] for _ in range(M)]",
"+# True -> AC済み",
"+AC = [False] * N",
"+WA_cnt = [0] * N",
"+pena = 0",
"+for... | false | 0.040295 | 0.03972 | 1.014471 | [
"s315898126",
"s866246969"
] |
u179169725 | p03031 | python | s294185635 | s368783482 | 34 | 26 | 3,064 | 3,064 | Accepted | Accepted | 23.53 | # https://atcoder.jp/contests/abc128/tasks/abc128_c
# なんかかすかに解いた記憶あるな?
# load data
N, M = list(map(int, input().split()))
S = []
for _ in range(M):
S.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))
def is_on(i, S, p):
# bit表現 i のときSのスイッチの個数とpでonか返す
cnt = 0
... | # https://atcoder.jp/contests/abc128/tasks/abc128_c
# なんかかすかに解いた記憶あるな?
# load data
N, M = list(map(int, input().split()))
S = []
for _ in range(M):
S.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))
def is_on(i, S, p):
# bit表現 i のときSのスイッチの個数とpでonか返す
cnt = 0
... | 29 | 31 | 613 | 658 | # https://atcoder.jp/contests/abc128/tasks/abc128_c
# なんかかすかに解いた記憶あるな?
# load data
N, M = list(map(int, input().split()))
S = []
for _ in range(M):
S.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))
def is_on(i, S, p):
# bit表現 i のときSのスイッチの個数とpでonか返す
cnt = 0
for j in S:
... | # https://atcoder.jp/contests/abc128/tasks/abc128_c
# なんかかすかに解いた記憶あるな?
# load data
N, M = list(map(int, input().split()))
S = []
for _ in range(M):
S.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))
def is_on(i, S, p):
# bit表現 i のときSのスイッチの個数とpでonか返す
cnt = 0
for j in S:
... | false | 6.451613 | [
"- flg *= is_on(i, s, p)",
"+ if not is_on(i, s, p):",
"+ flg = False",
"+ break"
] | false | 0.036478 | 0.038323 | 0.951864 | [
"s294185635",
"s368783482"
] |
u770300100 | p03107 | python | s287033946 | s326889276 | 1,545 | 29 | 3,956 | 3,188 | Accepted | Accepted | 98.12 | N = eval(input())
A = []
for i in N:
A.append(i)
cnt = 0
j = 0
while len(A) >= 2 and len(A)-1 > j:
if A[j] != A[j+1]:
cnt = cnt + 2
del A[j]
del A[j]
if j != 0:
j -= 1
else:
j += 1
print(cnt) | N = eval(input())
num0 = 0
num1 = 0
for i in N:
if i == '0':
num0 = num0 + 1
else:
num1 = num1 + 1
print((2*min(num0,num1))) | 19 | 11 | 274 | 152 | N = eval(input())
A = []
for i in N:
A.append(i)
cnt = 0
j = 0
while len(A) >= 2 and len(A) - 1 > j:
if A[j] != A[j + 1]:
cnt = cnt + 2
del A[j]
del A[j]
if j != 0:
j -= 1
else:
j += 1
print(cnt)
| N = eval(input())
num0 = 0
num1 = 0
for i in N:
if i == "0":
num0 = num0 + 1
else:
num1 = num1 + 1
print((2 * min(num0, num1)))
| false | 42.105263 | [
"-A = []",
"+num0 = 0",
"+num1 = 0",
"- A.append(i)",
"-cnt = 0",
"-j = 0",
"-while len(A) >= 2 and len(A) - 1 > j:",
"- if A[j] != A[j + 1]:",
"- cnt = cnt + 2",
"- del A[j]",
"- del A[j]",
"- if j != 0:",
"- j -= 1",
"+ if i == \"0\":",
"... | false | 0.08591 | 0.046003 | 1.867506 | [
"s287033946",
"s326889276"
] |
u844005364 | p03044 | python | s117827179 | s226220188 | 885 | 818 | 123,424 | 98,148 | Accepted | Accepted | 7.57 | from collections import defaultdict
import sys
def tree_path_dict():
sys.setrecursionlimit(100000)
n = int(eval(input()))
edge = defaultdict(lambda: defaultdict(lambda: float("inf")))
for _ in range(n - 1):
u, v, w = list(map(int, input().split()))
edge[u][v] = w
edg... | import sys
def tree_path():
# 辺と長さが与えられる
# 頂点1からの各点の距離を計算する
# 距離が偶数か奇数かで色分け
def walk(i, c):
if d[i] == -1:
d[i] = c
for node, dist in path[i]:
walk(node, c + dist)
sys.setrecursionlimit(100000)
n = int(eval(input()))
path = [[] fo... | 27 | 27 | 591 | 611 | from collections import defaultdict
import sys
def tree_path_dict():
sys.setrecursionlimit(100000)
n = int(eval(input()))
edge = defaultdict(lambda: defaultdict(lambda: float("inf")))
for _ in range(n - 1):
u, v, w = list(map(int, input().split()))
edge[u][v] = w
edge[v][u] = w... | import sys
def tree_path():
# 辺と長さが与えられる
# 頂点1からの各点の距離を計算する
# 距離が偶数か奇数かで色分け
def walk(i, c):
if d[i] == -1:
d[i] = c
for node, dist in path[i]:
walk(node, c + dist)
sys.setrecursionlimit(100000)
n = int(eval(input()))
path = [[] for _ in rang... | false | 0 | [
"-from collections import defaultdict",
"-def tree_path_dict():",
"- sys.setrecursionlimit(100000)",
"- n = int(eval(input()))",
"- edge = defaultdict(lambda: defaultdict(lambda: float(\"inf\")))",
"- for _ in range(n - 1):",
"- u, v, w = list(map(int, input().split()))",
"- ... | false | 0.047622 | 0.048141 | 0.989229 | [
"s117827179",
"s226220188"
] |
u377989038 | p03212 | python | s812832484 | s602584278 | 65 | 46 | 3,060 | 3,060 | Accepted | Accepted | 29.23 | def dfs(s):
global cnt
if s != "":
if int(s) > n:
return
if len(set(s)) == 3:
cnt += 1
dfs(s + "3")
dfs(s + "5")
dfs(s + "7")
n = int(eval(input()))
cnt = 0
dfs("")
print(cnt) | from itertools import product
n = int(eval(input()))
cnt = 0
for i in range(3, 10):
for j in product(["3", "5", "7"], repeat=i):
if len(set(j)) == 3:
if int("".join(j)) <= n:
cnt += 1
print(cnt)
| 16 | 10 | 238 | 239 | def dfs(s):
global cnt
if s != "":
if int(s) > n:
return
if len(set(s)) == 3:
cnt += 1
dfs(s + "3")
dfs(s + "5")
dfs(s + "7")
n = int(eval(input()))
cnt = 0
dfs("")
print(cnt)
| from itertools import product
n = int(eval(input()))
cnt = 0
for i in range(3, 10):
for j in product(["3", "5", "7"], repeat=i):
if len(set(j)) == 3:
if int("".join(j)) <= n:
cnt += 1
print(cnt)
| false | 37.5 | [
"-def dfs(s):",
"- global cnt",
"- if s != \"\":",
"- if int(s) > n:",
"- return",
"- if len(set(s)) == 3:",
"- cnt += 1",
"- dfs(s + \"3\")",
"- dfs(s + \"5\")",
"- dfs(s + \"7\")",
"-",
"+from itertools import product",
"-dfs(\"\")",
"+for i in ... | false | 0.076338 | 0.082553 | 0.924713 | [
"s812832484",
"s602584278"
] |
u952708174 | p03062 | python | s985713441 | s379416783 | 64 | 58 | 14,284 | 14,412 | Accepted | Accepted | 9.38 | def d_flipping_signs(N, A):
minus_count = 0
_a = []
for a in A:
if a >= 0:
_a.append(a)
else:
minus_count += 1
_a.append(abs(a))
ans = sum(_a)
if minus_count % 2 == 1:
ans -= 2 * min(_a)
return ans
N = int(eval(input()))
... | def d_flipping_signs(N, A):
minus_count_parity = len([1 for a in A if a < 0]) % 2
a = list(map(abs, A))
return sum(a) + (-2 * min(a) if minus_count_parity == 1 else 0)
N = int(eval(input()))
A = [int(i) for i in input().split()]
print((d_flipping_signs(N, A))) | 17 | 8 | 383 | 272 | def d_flipping_signs(N, A):
minus_count = 0
_a = []
for a in A:
if a >= 0:
_a.append(a)
else:
minus_count += 1
_a.append(abs(a))
ans = sum(_a)
if minus_count % 2 == 1:
ans -= 2 * min(_a)
return ans
N = int(eval(input()))
A = [int(i) f... | def d_flipping_signs(N, A):
minus_count_parity = len([1 for a in A if a < 0]) % 2
a = list(map(abs, A))
return sum(a) + (-2 * min(a) if minus_count_parity == 1 else 0)
N = int(eval(input()))
A = [int(i) for i in input().split()]
print((d_flipping_signs(N, A)))
| false | 52.941176 | [
"- minus_count = 0",
"- _a = []",
"- for a in A:",
"- if a >= 0:",
"- _a.append(a)",
"- else:",
"- minus_count += 1",
"- _a.append(abs(a))",
"- ans = sum(_a)",
"- if minus_count % 2 == 1:",
"- ans -= 2 * min(_a)",
"- retur... | false | 0.10504 | 0.047172 | 2.226761 | [
"s985713441",
"s379416783"
] |
u569322757 | p02837 | python | s190435518 | s260516931 | 217 | 135 | 3,064 | 3,064 | Accepted | Accepted | 37.79 | n = int(eval(input()))
x = []
for i in range(n):
ai = int(eval(input()))
xi = []
for j in range(ai):
xi.append(list(map(int, input().split())))
x.append(xi)
m = 0
for h in range(2**n - 1, -1, -1):
is_break = False
h = bin(h)[2:].zfill(n)
for i, xi in enumerate(x):
... | n = int(eval(input()))
v = []
for i in range(n):
ai = int(eval(input()))
vi = []
for j in range(ai):
vi.append(list(map(int, input().split())))
v.append(vi)
m = 0
for bit in range(2**n - 1, -1, -1):
is_break = False
for i in range(n):
if not (bit & (1 << i)):
... | 26 | 25 | 584 | 572 | n = int(eval(input()))
x = []
for i in range(n):
ai = int(eval(input()))
xi = []
for j in range(ai):
xi.append(list(map(int, input().split())))
x.append(xi)
m = 0
for h in range(2**n - 1, -1, -1):
is_break = False
h = bin(h)[2:].zfill(n)
for i, xi in enumerate(x):
if h[i] == ... | n = int(eval(input()))
v = []
for i in range(n):
ai = int(eval(input()))
vi = []
for j in range(ai):
vi.append(list(map(int, input().split())))
v.append(vi)
m = 0
for bit in range(2**n - 1, -1, -1):
is_break = False
for i in range(n):
if not (bit & (1 << i)):
continue... | false | 3.846154 | [
"-x = []",
"+v = []",
"- xi = []",
"+ vi = []",
"- xi.append(list(map(int, input().split())))",
"- x.append(xi)",
"+ vi.append(list(map(int, input().split())))",
"+ v.append(vi)",
"-for h in range(2**n - 1, -1, -1):",
"+for bit in range(2**n - 1, -1, -1):",
"- h = bi... | false | 0.040273 | 0.140398 | 0.286845 | [
"s190435518",
"s260516931"
] |
u629454253 | p03160 | python | s153334044 | s026820893 | 271 | 139 | 103,512 | 13,980 | Accepted | Accepted | 48.71 | import sys
sys.setrecursionlimit(200000)
n = int(eval(input()))
h = [int(i) for i in input().split()]
d = {}
def dp(p):
if p in d:
return d[p]
if p == n-1:
return 0
if p < n-2:
m = min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]))
d[p] = m
return m
if p == n-2... | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
print((dp[-1]))
| 22 | 10 | 369 | 203 | import sys
sys.setrecursionlimit(200000)
n = int(eval(input()))
h = [int(i) for i in input().split()]
d = {}
def dp(p):
if p in d:
return d[p]
if p == n - 1:
return 0
if p < n - 2:
m = min(dp(p + 1) + abs(h[p] - h[p + 1]), dp(p + 2) + abs(h[p] - h[p + 2]))
d[p] = m
... | n = int(eval(input()))
h = list(map(int, input().split()))
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))
print((dp[-1]))
| false | 54.545455 | [
"-import sys",
"-",
"-sys.setrecursionlimit(200000)",
"-h = [int(i) for i in input().split()]",
"-d = {}",
"-",
"-",
"-def dp(p):",
"- if p in d:",
"- return d[p]",
"- if p == n - 1:",
"- return 0",
"- if p < n - 2:",
"- m = min(dp(p + 1) + abs(h[p] - h[p + 1]... | false | 0.034716 | 0.034746 | 0.999133 | [
"s153334044",
"s026820893"
] |
u622045059 | p03329 | python | s303213897 | s327210880 | 1,113 | 709 | 3,864 | 3,864 | Accepted | Accepted | 36.3 | max_n = 100000
N = int(eval(input()))
dp = [N for _ in range(N+1)]
dp[0] = 0
for n in range(1, N+1):
for pow6 in range(n+1):
if 6 ** pow6 <= n:
dp[n] = min(dp[n], dp[n - 6 ** pow6] + 1)
else:
break
for pow9 in range(n+1):
if 9 ** pow9 <= n:
... | N = int(eval(input()))
one = [1]
six_multi = [6, 6**2, 6**3, 6**4, 6**5, 6**6]
nine_multi = [9, 9**2, 9**3, 9**4, 9**5]
deposit = one + six_multi + nine_multi
dp = [10**10 for _ in range(N+1)]
dp[0] = 0
for i in range(0, N):
for d in range(len(deposit)):
if i+deposit[d] <= N:
dp... | 19 | 17 | 411 | 382 | max_n = 100000
N = int(eval(input()))
dp = [N for _ in range(N + 1)]
dp[0] = 0
for n in range(1, N + 1):
for pow6 in range(n + 1):
if 6**pow6 <= n:
dp[n] = min(dp[n], dp[n - 6**pow6] + 1)
else:
break
for pow9 in range(n + 1):
if 9**pow9 <= n:
dp[n] = m... | N = int(eval(input()))
one = [1]
six_multi = [6, 6**2, 6**3, 6**4, 6**5, 6**6]
nine_multi = [9, 9**2, 9**3, 9**4, 9**5]
deposit = one + six_multi + nine_multi
dp = [10**10 for _ in range(N + 1)]
dp[0] = 0
for i in range(0, N):
for d in range(len(deposit)):
if i + deposit[d] <= N:
dp[i + deposit[... | false | 10.526316 | [
"-max_n = 100000",
"-dp = [N for _ in range(N + 1)]",
"+one = [1]",
"+six_multi = [6, 6**2, 6**3, 6**4, 6**5, 6**6]",
"+nine_multi = [9, 9**2, 9**3, 9**4, 9**5]",
"+deposit = one + six_multi + nine_multi",
"+dp = [10**10 for _ in range(N + 1)]",
"-for n in range(1, N + 1):",
"- for pow6 in range(... | false | 0.383779 | 0.155526 | 2.467628 | [
"s303213897",
"s327210880"
] |
u224353074 | p02642 | python | s347154995 | s669112450 | 321 | 266 | 167,564 | 157,664 | Accepted | Accepted | 17.13 | import bisect as bc
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
dp = [True for _ in range(A[-1]+1)]
for i in range(N):
ai = A[i]
for j in range(2,A[-1]+1):
if ai*j > A[-1]:
break
dp[ai*j] = False
ans = 0
finish = [True for _ in range(A[-1]+1... | import bisect as bc
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
dp = [True for _ in range(A[-1]+1)]
for i in range(N):
ai = A[i]
for j in range(2,A[-1]+1):
if ai*j > A[-1]:
break
dp[ai*j] = False
ans = 0
for i in range(N):
if dp[A[i... | 26 | 22 | 513 | 421 | import bisect as bc
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
dp = [True for _ in range(A[-1] + 1)]
for i in range(N):
ai = A[i]
for j in range(2, A[-1] + 1):
if ai * j > A[-1]:
break
dp[ai * j] = False
ans = 0
finish = [True for _ in range(A[-1] + 1)]
for ... | import bisect as bc
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
dp = [True for _ in range(A[-1] + 1)]
for i in range(N):
ai = A[i]
for j in range(2, A[-1] + 1):
if ai * j > A[-1]:
break
dp[ai * j] = False
ans = 0
for i in range(N):
if dp[A[i]]:
if... | false | 15.384615 | [
"-finish = [True for _ in range(A[-1] + 1)]",
"- if dp[A[i]] and finish[A[i]]:",
"+ if dp[A[i]]:",
"- finish[A[i]] = False"
] | false | 0.007586 | 0.039234 | 0.19335 | [
"s347154995",
"s669112450"
] |
u357267874 | p02283 | python | s987203543 | s025556895 | 8,850 | 7,050 | 105,168 | 147,764 | Accepted | Accepted | 20.34 | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
def insert(self, node):
y = None
x = self.root
while x is not None:
... | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.inorder = []
self.preorder = []
def insert(self, node):
p = None
... | 56 | 88 | 1,330 | 2,387 | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
def insert(self, node):
y = None
x = self.root
while x is not None:
y = x
... | class Node:
def __init__(self, key):
self.key = key
self.parent = None
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
self.inorder = []
self.preorder = []
def insert(self, node):
p = None
x = self... | false | 36.363636 | [
"+ self.inorder = []",
"+ self.preorder = []",
"- y = None",
"+ p = None",
"- y = x",
"+ p = x",
"+ # print(node.key, x.key)",
"- if y is None:",
"+ # insertするnodeの親を設定",
"+ node.parent = p",
"+ if p is None... | false | 0.112948 | 0.045145 | 2.501874 | [
"s987203543",
"s025556895"
] |
u682672120 | p03722 | python | s242269933 | s766176801 | 299 | 137 | 79,680 | 74,752 | Accepted | Accepted | 54.18 | n, m = list(map(int, input().split()))
edges = []
for i in range(m):
a, b, w = list(map(int, input().split()))
edges.append((a-1, b-1, w))
init_val = -10 ** 9 * 1000
d = [init_val] * n
d[0] = 0
for _ in range(n):
updated = False
for a, b, w in edges:
if d[a] != init_val and d[b] <... | class BellmanFord:#Union-Find
def __init__(self, n, init_val = float('inf')):
self.d = [init_val] * n #根にサイズを負の値で格納する。
self.init_val = init_val
def shortest_path(self, s, edges):
self.d[s] = 0
for _ in range(n):
updated = False
for a, b, w in edg... | 26 | 34 | 636 | 1,066 | n, m = list(map(int, input().split()))
edges = []
for i in range(m):
a, b, w = list(map(int, input().split()))
edges.append((a - 1, b - 1, w))
init_val = -(10**9) * 1000
d = [init_val] * n
d[0] = 0
for _ in range(n):
updated = False
for a, b, w in edges:
if d[a] != init_val and d[b] < d[a] + w:
... | class BellmanFord: # Union-Find
def __init__(self, n, init_val=float("inf")):
self.d = [init_val] * n # 根にサイズを負の値で格納する。
self.init_val = init_val
def shortest_path(self, s, edges):
self.d[s] = 0
for _ in range(n):
updated = False
for a, b, w in edges:
... | false | 23.529412 | [
"+class BellmanFord: # Union-Find",
"+ def __init__(self, n, init_val=float(\"inf\")):",
"+ self.d = [init_val] * n # 根にサイズを負の値で格納する。",
"+ self.init_val = init_val",
"+",
"+ def shortest_path(self, s, edges):",
"+ self.d[s] = 0",
"+ for _ in range(n):",
"+ ... | false | 0.194418 | 0.089731 | 2.166682 | [
"s242269933",
"s766176801"
] |
u083960235 | p02723 | python | s653300604 | s402767926 | 147 | 27 | 5,716 | 3,896 | Accepted | Accepted | 81.63 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii... | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii... | 27 | 25 | 819 | 833 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... | false | 7.407407 | [
"-from fractions import gcd",
"+from heapq import heapify, heappop, heappush",
"-s = eval(input())",
"-if s[2] == s[3] and s[4] == s[5]:",
"+S = eval(input())",
"+if S[2] == S[3] and S[4] == S[5]:"
] | false | 0.047047 | 0.04707 | 0.999508 | [
"s653300604",
"s402767926"
] |
u861141787 | p03212 | python | s540683055 | s726966119 | 94 | 39 | 3,060 | 3,060 | Accepted | Accepted | 58.51 | N = int(eval(input()))
def dfs(s):
if int(s) > N:
return 0
ret = 1 if all(s.count(c) > 0 for c in "753") else 0
for c in "753":
ret += dfs(s + c)
return ret
print((dfs("0"))) | ans = 0
def dfs(x, a, b, c):
global ans
if x > N : return
if a & b & c: ans += 1
dfs(10*x+3, 1, b, c)
dfs(10*x+5, a, 1, c)
dfs(10*x+7, a, b, 1)
N = int(eval(input()))
dfs(0, 0, 0, 0)
print(ans) | 12 | 13 | 213 | 225 | N = int(eval(input()))
def dfs(s):
if int(s) > N:
return 0
ret = 1 if all(s.count(c) > 0 for c in "753") else 0
for c in "753":
ret += dfs(s + c)
return ret
print((dfs("0")))
| ans = 0
def dfs(x, a, b, c):
global ans
if x > N:
return
if a & b & c:
ans += 1
dfs(10 * x + 3, 1, b, c)
dfs(10 * x + 5, a, 1, c)
dfs(10 * x + 7, a, b, 1)
N = int(eval(input()))
dfs(0, 0, 0, 0)
print(ans)
| false | 7.692308 | [
"-N = int(eval(input()))",
"+ans = 0",
"-def dfs(s):",
"- if int(s) > N:",
"- return 0",
"- ret = 1 if all(s.count(c) > 0 for c in \"753\") else 0",
"- for c in \"753\":",
"- ret += dfs(s + c)",
"- return ret",
"+def dfs(x, a, b, c):",
"+ global ans",
"+ if x > ... | false | 0.10548 | 0.039713 | 2.656095 | [
"s540683055",
"s726966119"
] |
u761320129 | p04034 | python | s563133037 | s732298148 | 403 | 358 | 4,596 | 18,140 | Accepted | Accepted | 11.17 | N,M = list(map(int,input().split()))
red_possible = [1] + [0]*(N-1)
balls = [1] * N
for i in range(M):
x,y = [int(x)-1 for x in input().split()]
if red_possible[x]:
red_possible[y] = 1
if balls[x] == 1:
red_possible[x] = 0
balls[x] -= 1
balls[y] += 1
print((sum(red... | N,M = list(map(int,input().split()))
src = [tuple(map(int,input().split())) for i in range(M)]
red = [0] * N
red[0] = 1
ballnum = [1] * N
for a,b in src:
a,b = a-1,b-1
ballnum[b] += 1
ballnum[a] -= 1
if red[a]:
red[b] = 1
if not ballnum[a]:
red[a] = 0
print((su... | 12 | 15 | 327 | 320 | N, M = list(map(int, input().split()))
red_possible = [1] + [0] * (N - 1)
balls = [1] * N
for i in range(M):
x, y = [int(x) - 1 for x in input().split()]
if red_possible[x]:
red_possible[y] = 1
if balls[x] == 1:
red_possible[x] = 0
balls[x] -= 1
balls[y] += 1
print((sum(red_p... | N, M = list(map(int, input().split()))
src = [tuple(map(int, input().split())) for i in range(M)]
red = [0] * N
red[0] = 1
ballnum = [1] * N
for a, b in src:
a, b = a - 1, b - 1
ballnum[b] += 1
ballnum[a] -= 1
if red[a]:
red[b] = 1
if not ballnum[a]:
red[a] = 0
print((sum(red... | false | 20 | [
"-red_possible = [1] + [0] * (N - 1)",
"-balls = [1] * N",
"-for i in range(M):",
"- x, y = [int(x) - 1 for x in input().split()]",
"- if red_possible[x]:",
"- red_possible[y] = 1",
"- if balls[x] == 1:",
"- red_possible[x] = 0",
"- balls[x] -= 1",
"- balls[y] ... | false | 0.066428 | 0.068412 | 0.970991 | [
"s563133037",
"s732298148"
] |
u046187684 | p02996 | python | s197378885 | s040556866 | 680 | 569 | 51,460 | 52,096 | Accepted | Accepted | 16.32 | from itertools import accumulate
def solve(string):
n, *ab = list(map(int, string.split()))
ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1])
a = [a for a, b in ab]
b = [b for a, b in ab]
*a, = accumulate(a)
return "No" if any([_a > _b for _a, _b in zip(a, b)]) else "Yes"
if ... | from operator import itemgetter
def solve(string):
n, *ab = list(map(int, string.split()))
ab = sorted(zip(*[iter(ab)] * 2), key=itemgetter(1))
past = 0
for a, b in ab:
past += a
if past > b:
return "No"
return "Yes"
if __name__ == '__main__':
n = i... | 15 | 17 | 437 | 403 | from itertools import accumulate
def solve(string):
n, *ab = list(map(int, string.split()))
ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1])
a = [a for a, b in ab]
b = [b for a, b in ab]
(*a,) = accumulate(a)
return "No" if any([_a > _b for _a, _b in zip(a, b)]) else "Yes"
if __name__ =... | from operator import itemgetter
def solve(string):
n, *ab = list(map(int, string.split()))
ab = sorted(zip(*[iter(ab)] * 2), key=itemgetter(1))
past = 0
for a, b in ab:
past += a
if past > b:
return "No"
return "Yes"
if __name__ == "__main__":
n = int(eval(input()... | false | 11.764706 | [
"-from itertools import accumulate",
"+from operator import itemgetter",
"- ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1])",
"- a = [a for a, b in ab]",
"- b = [b for a, b in ab]",
"- (*a,) = accumulate(a)",
"- return \"No\" if any([_a > _b for _a, _b in zip(a, b)]) else \"Yes\"",
... | false | 0.036833 | 0.035827 | 1.028059 | [
"s197378885",
"s040556866"
] |
u077291787 | p02837 | python | s850921436 | s825977020 | 45 | 41 | 3,064 | 3,064 | Accepted | Accepted | 8.89 | # ABC147C - HonestOrUnkind2
from itertools import combinations
def main():
N = int(eval(input()))
testimonies = [[] for i in range(N + 1)]
for i in range(1, N + 1):
A = int(eval(input()))
for _ in range(A):
x, y = list(map(int, input().split()))
testimoni... | # ABC147C - HonestOrUnkind2
from itertools import combinations
def main():
N = int(eval(input()))
testimonies = [[] for i in range(N + 1)]
for i in range(1, N + 1):
A = int(eval(input()))
for _ in range(A):
x, y = list(map(int, input().split()))
testimoni... | 32 | 31 | 983 | 935 | # ABC147C - HonestOrUnkind2
from itertools import combinations
def main():
N = int(eval(input()))
testimonies = [[] for i in range(N + 1)]
for i in range(1, N + 1):
A = int(eval(input()))
for _ in range(A):
x, y = list(map(int, input().split()))
testimonies[i].appen... | # ABC147C - HonestOrUnkind2
from itertools import combinations
def main():
N = int(eval(input()))
testimonies = [[] for i in range(N + 1)]
for i in range(1, N + 1):
A = int(eval(input()))
for _ in range(A):
x, y = list(map(int, input().split()))
testimonies[i].appen... | false | 3.125 | [
"- honest_people = set(honest_people)"
] | false | 0.046616 | 0.045602 | 1.02224 | [
"s850921436",
"s825977020"
] |
u600402037 | p02804 | python | s935257254 | s768562438 | 1,234 | 524 | 126,964 | 26,476 | Accepted | Accepted | 57.54 | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = lr()
A.sort()
MOD = 10 ** 9 + 7
if K == 1:
print((0))
exit()
def cmb(n, k):
# nCkを計算する
k = min(k, n-k)
return fac[n] * ifac[k] % MOD * ifac[n-k... | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10 ** 9 + 7
# 組合せ nCr (MOD) 逆元を使う方法
def perm(n,k):
if k > n or k < 0: return 0
return fact[n] * fact_inv[n-k] % MOD
def cmb(n, k):
if k < 0 or k ... | 46 | 49 | 1,007 | 1,367 | import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N, K = lr()
A = lr()
A.sort()
MOD = 10**9 + 7
if K == 1:
print((0))
exit()
def cmb(n, k):
# nCkを計算する
k = min(k, n - k)
return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD
def mak... | import sys
import numpy as np
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
MOD = 10**9 + 7
# 組合せ nCr (MOD) 逆元を使う方法
def perm(n, k):
if k > n or k < 0:
return 0
return fact[n] * fact_inv[n - k] % MOD
def cmb(n, k):
if k < 0 or k > n:
... | false | 6.122449 | [
"+import numpy as np",
"+MOD = 10**9 + 7",
"+# 組合せ nCr (MOD) 逆元を使う方法",
"+def perm(n, k):",
"+ if k > n or k < 0:",
"+ return 0",
"+ return fact[n] * fact_inv[n - k] % MOD",
"+",
"+",
"+def cmb(n, k):",
"+ if k < 0 or k > n:",
"+ return 0",
"+ return fact[n] * fact_i... | false | 1.654583 | 0.253651 | 6.523068 | [
"s935257254",
"s768562438"
] |
u562935282 | p03160 | python | s526249947 | s953177633 | 181 | 138 | 13,924 | 13,980 | Accepted | Accepted | 23.76 | INF = 10 ** 10
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF for _ in range(N)]
dp[0] = 0
# 0-indexed
for i in range(1, N):
dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
if i - 2 >= 0:
dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[N - 1]))... | INF = float('inf')
N = int(eval(input()))
h = list(map(int, input().split()))
h = [0] + h
dp = [INF for i in range(N + 1)]
# 1-indexed, 1 -> N
dp[1] = 0
for i in range(2, N + 1):
if i > 2:
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
else:
dp[i... | 15 | 16 | 313 | 365 | INF = 10**10
N = int(eval(input()))
h = list(map(int, input().split()))
dp = [INF for _ in range(N)]
dp[0] = 0
# 0-indexed
for i in range(1, N):
dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
if i - 2 >= 0:
dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))
print((dp[N - 1]))
| INF = float("inf")
N = int(eval(input()))
h = list(map(int, input().split()))
h = [0] + h
dp = [INF for i in range(N + 1)]
# 1-indexed, 1 -> N
dp[1] = 0
for i in range(2, N + 1):
if i > 2:
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
else:
dp[i] = dp[i - 1] + a... | false | 6.25 | [
"-INF = 10**10",
"+INF = float(\"inf\")",
"-dp = [INF for _ in range(N)]",
"-dp[0] = 0",
"-# 0-indexed",
"-for i in range(1, N):",
"- dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))",
"- if i - 2 >= 0:",
"- dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))",
"-print((dp[N - 1]... | false | 0.05506 | 0.03584 | 1.53628 | [
"s526249947",
"s953177633"
] |
u173148629 | p02703 | python | s986806478 | s166070006 | 779 | 671 | 23,880 | 24,144 | Accepted | Accepted | 13.86 | N,M,S=list(map(int,input().split()))
from heapq import heappop,heappush
inf = 10**18
cost=[[] for _ in range(N)]
exc=[]
for _ in range(M):
u,v,a,b=list(map(int,input().split()))
u,v=u-1,v-1
cost[u].append((v,a,b))
cost[v].append((u,a,b))
for _ in range(N):
c,d=list(map(int,input().... | N,M,S=list(map(int,input().split()))
from heapq import heappop,heappush
inf = float('inf')
cost=[[] for _ in range(N)]
exc=[]
for _ in range(M):
u,v,a,b=list(map(int,input().split()))
u,v=u-1,v-1
cost[u].append((v,a,b))
cost[v].append((u,a,b))
for _ in range(N):
c,d=list(map(int,in... | 50 | 48 | 987 | 960 | N, M, S = list(map(int, input().split()))
from heapq import heappop, heappush
inf = 10**18
cost = [[] for _ in range(N)]
exc = []
for _ in range(M):
u, v, a, b = list(map(int, input().split()))
u, v = u - 1, v - 1
cost[u].append((v, a, b))
cost[v].append((u, a, b))
for _ in range(N):
c, d = list(ma... | N, M, S = list(map(int, input().split()))
from heapq import heappop, heappush
inf = float("inf")
cost = [[] for _ in range(N)]
exc = []
for _ in range(M):
u, v, a, b = list(map(int, input().split()))
u, v = u - 1, v - 1
cost[u].append((v, a, b))
cost[v].append((u, a, b))
for _ in range(N):
c, d = l... | false | 4 | [
"-inf = 10**18",
"+inf = float(\"inf\")",
"+S = min(S, 2450)",
"-if S > 2450:",
"- S = 2450",
"+ if t > di[v]:",
"+ continue",
"- if s + c > 2450:",
"- c = 2450 - s",
"+ c = min(c, 2450 - s)",
"- m = di[i * 2451]",
"- for j in range(1, 2451):",
"- m = m... | false | 0.151389 | 0.216215 | 0.700179 | [
"s986806478",
"s166070006"
] |
u597455618 | p03830 | python | s583268997 | s145041198 | 29 | 21 | 3,316 | 3,064 | Accepted | Accepted | 27.59 | import collections
def e(N):
res = []
x = N
y = 2
while y*y <= x:
while x % y == 0:
res.append(y)
x //= y
y += 1
if x > 1:
res.append(x)
return res
MOD = 10**9 + 7
n = int(eval(input()))
chk = [0 for i in range(n+1)]
for i in range(... | MOD = 10**9 + 7
n = int(eval(input()))
chk = [0 for i in range(n+1)]
for i in range(2, n+1):
y = 2
while y*y <= i:
while i % y == 0:
chk[y] += 1
i //= y
y += 1
if i > 1:
chk[i] += 1
ans = 1
for i in chk:
if i:
ans = ans*(i + 1)%MOD... | 25 | 18 | 482 | 326 | import collections
def e(N):
res = []
x = N
y = 2
while y * y <= x:
while x % y == 0:
res.append(y)
x //= y
y += 1
if x > 1:
res.append(x)
return res
MOD = 10**9 + 7
n = int(eval(input()))
chk = [0 for i in range(n + 1)]
for i in range(2, n + 1... | MOD = 10**9 + 7
n = int(eval(input()))
chk = [0 for i in range(n + 1)]
for i in range(2, n + 1):
y = 2
while y * y <= i:
while i % y == 0:
chk[y] += 1
i //= y
y += 1
if i > 1:
chk[i] += 1
ans = 1
for i in chk:
if i:
ans = ans * (i + 1) % MOD
print(... | false | 28 | [
"-import collections",
"-",
"-",
"-def e(N):",
"- res = []",
"- x = N",
"- y = 2",
"- while y * y <= x:",
"- while x % y == 0:",
"- res.append(y)",
"- x //= y",
"- y += 1",
"- if x > 1:",
"- res.append(x)",
"- return res",
"-... | false | 0.108243 | 0.044643 | 2.424666 | [
"s583268997",
"s145041198"
] |
u143100985 | p03285 | python | s886033044 | s930750859 | 20 | 18 | 2,940 | 2,940 | Accepted | Accepted | 10 | import sys
n = int(eval(input()))
i = 0
j = 0
while(i < 100):
j = 0
while(j < 100):
if 7* i + 4 * j == n:
print("Yes")
sys.exit()
j+= 1
i+= 1
print("No")
| import sys
n = int(eval(input()))
for i in range(100):
for j in range(100):
if 7* i + 4 * j == n:
print("Yes")
sys.exit()
print("No")
| 15 | 9 | 226 | 174 | import sys
n = int(eval(input()))
i = 0
j = 0
while i < 100:
j = 0
while j < 100:
if 7 * i + 4 * j == n:
print("Yes")
sys.exit()
j += 1
i += 1
print("No")
| import sys
n = int(eval(input()))
for i in range(100):
for j in range(100):
if 7 * i + 4 * j == n:
print("Yes")
sys.exit()
print("No")
| false | 40 | [
"-i = 0",
"-j = 0",
"-while i < 100:",
"- j = 0",
"- while j < 100:",
"+for i in range(100):",
"+ for j in range(100):",
"- j += 1",
"- i += 1"
] | false | 0.04227 | 0.038432 | 1.099856 | [
"s886033044",
"s930750859"
] |
u456353530 | p02936 | python | s953087227 | s286759294 | 1,295 | 1,099 | 136,404 | 136,532 | Accepted | Accepted | 15.14 | import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]
class Tree:
C = {}
N, D = None, None
def __init__(s, num):
s.N = num
def setC(s, a, b):
if a i... | import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]
class Tree:
C = {}
N, D = None, None
def __init__(s, num):
s.N = num
def setC(s, a, b):
if a i... | 43 | 42 | 847 | 827 | import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]
class Tree:
C = {}
N, D = None, None
def __init__(s, num):
s.N = num
def setC(s, a, b):
... | import sys
input = sys.stdin.readline
N, Q = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]
class Tree:
C = {}
N, D = None, None
def __init__(s, num):
s.N = num
def setC(s, a, b):
... | false | 2.325581 | [
"- L[i] = 1"
] | false | 0.036384 | 0.036192 | 1.005302 | [
"s953087227",
"s286759294"
] |
u033524082 | p03319 | python | s659141524 | s770115404 | 40 | 18 | 13,880 | 3,060 | Accepted | Accepted | 55 | n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
print(((n-2)//(k-1)+1)) | n,k=list(map(int,input().split()))
print(((n-2)//(k-1)+1)) | 3 | 2 | 85 | 51 | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
print(((n - 2) // (k - 1) + 1))
| n, k = list(map(int, input().split()))
print(((n - 2) // (k - 1) + 1))
| false | 33.333333 | [
"-a = list(map(int, input().split()))"
] | false | 0.04553 | 0.083975 | 0.542182 | [
"s659141524",
"s770115404"
] |
u026075806 | p03194 | python | s930732830 | s060450821 | 991 | 215 | 3,444 | 3,316 | Accepted | Accepted | 78.3 | import math
from collections import defaultdict
def is_prime(n: int)-> bool:
if n == 2:
return True
if n < 2 or n % 2 == 0:
return False
# when n is a prime number
# x^(n-1) ≡ 1 (mod n)
return pow(2, (n-1), n) == 1
def prime_factorize(n: int):
prime_factors = def... | import math
from collections import defaultdict
def prime_factorize(n: int):
prime_factors = defaultdict(int)
for i in range(2, int(math.sqrt(n)) + 1):
while True:
div, mod = divmod(n, i)
if mod == 0:
prime_factors[i] += 1
n = div
... | 47 | 35 | 980 | 714 | import math
from collections import defaultdict
def is_prime(n: int) -> bool:
if n == 2:
return True
if n < 2 or n % 2 == 0:
return False
# when n is a prime number
# x^(n-1) ≡ 1 (mod n)
return pow(2, (n - 1), n) == 1
def prime_factorize(n: int):
prime_factors = defaultdict(i... | import math
from collections import defaultdict
def prime_factorize(n: int):
prime_factors = defaultdict(int)
for i in range(2, int(math.sqrt(n)) + 1):
while True:
div, mod = divmod(n, i)
if mod == 0:
prime_factors[i] += 1
n = div
els... | false | 25.531915 | [
"-",
"-",
"-def is_prime(n: int) -> bool:",
"- if n == 2:",
"- return True",
"- if n < 2 or n % 2 == 0:",
"- return False",
"- # when n is a prime number",
"- # x^(n-1) ≡ 1 (mod n)",
"- return pow(2, (n - 1), n) == 1",
"- if not is_prime(i):",
"- ... | false | 0.188594 | 0.085706 | 2.200473 | [
"s930732830",
"s060450821"
] |
u867826040 | p03645 | python | s244318241 | s736723438 | 976 | 660 | 101,280 | 55,652 | Accepted | Accepted | 32.38 | n,m = list(map(int,input().split()))
d = {str(x):[] for x in range(1,n+1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
t = input().split()
d[t[0]].append(t)
for l1 in d["1"]:
if l1[1]==n:
ans="POSSIBLE"
else:
for l2 in d[l1[1]]:
if l2[1]==n:
... | n,m = list(map(int,input().split()))
d = {str(x):[] for x in range(1,n+1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
t = input().split()
d[t[0]].append(t[1])
for l1 in d["1"]:
if l1==n:
ans="POSSIBLE"
break
else:
for l2 in d[l1]:
if l2==n:
... | 16 | 18 | 342 | 375 | n, m = list(map(int, input().split()))
d = {str(x): [] for x in range(1, n + 1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
t = input().split()
d[t[0]].append(t)
for l1 in d["1"]:
if l1[1] == n:
ans = "POSSIBLE"
else:
for l2 in d[l1[1]]:
if l2[1] == n:
a... | n, m = list(map(int, input().split()))
d = {str(x): [] for x in range(1, n + 1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
t = input().split()
d[t[0]].append(t[1])
for l1 in d["1"]:
if l1 == n:
ans = "POSSIBLE"
break
else:
for l2 in d[l1]:
if l2 == n:
... | false | 11.111111 | [
"- d[t[0]].append(t)",
"+ d[t[0]].append(t[1])",
"- if l1[1] == n:",
"+ if l1 == n:",
"+ break",
"- for l2 in d[l1[1]]:",
"- if l2[1] == n:",
"+ for l2 in d[l1]:",
"+ if l2 == n:",
"+ break"
] | false | 0.041843 | 0.038972 | 1.073666 | [
"s244318241",
"s736723438"
] |
u864197622 | p02644 | python | s902765072 | s485077909 | 2,896 | 2,600 | 162,500 | 383,952 | Accepted | Accepted | 10.22 | import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
H, W, K = list(map(int, input().split()))
x1, y1, x2, y2 = list(map(int, input().split()))
X = [1] * (W + 2)
for _ in range(H):
X += [1] + [1 if a == "@" else 0 for a in eval(input())] + [1]
X += [1] * (W + 2)
H, W = H+2... | import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
H, W, K = list(map(int, input().split()))
x1, y1, x2, y2 = list(map(int, input().split()))
X = [1] * (W + 2)
for _ in range(H):
X += [1] + [1 if a == "@" else 0 for a in eval(input())] + [1]
X += [1] * (W + 2)
H, W = H+2... | 49 | 48 | 1,540 | 1,501 | import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
H, W, K = list(map(int, input().split()))
x1, y1, x2, y2 = list(map(int, input().split()))
X = [1] * (W + 2)
for _ in range(H):
X += [1] + [1 if a == "@" else 0 for a in eval(input())] + [1]
X += [1] * (W + 2)
H, W = H + 2, W +... | import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
H, W, K = list(map(int, input().split()))
x1, y1, x2, y2 = list(map(int, input().split()))
X = [1] * (W + 2)
for _ in range(H):
X += [1] + [1 if a == "@" else 0 for a in eval(input())] + [1]
X += [1] * (W + 2)
H, W = H + 2, W +... | false | 2.040816 | [
"- dd = [(), (1, -1), (W, -W), (1, -1, W, -W)]",
"- if D[y] == -1:",
"- D[y] = D[x] + 1",
"- Q.append((y, 2))",
"+ if 0 <= D[y] <= D[x]:",
"+ break",
"+ D[y] = D[x] + 1",
"+... | false | 0.045224 | 0.045881 | 0.985681 | [
"s902765072",
"s485077909"
] |
u634384370 | p03455 | python | s040610691 | s466519589 | 20 | 17 | 2,940 | 2,940 | Accepted | Accepted | 15 | # -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = list(map(int, input().split()))
c = a * b
if c % 2 == 0:
print("Even")
else:
print("Odd") | i = list(map(int, input().split()))
j = i[0] * i[1]
if j % 2 == 0:
print("Even")
else:
print("Odd") | 8 | 6 | 141 | 108 | # -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = list(map(int, input().split()))
c = a * b
if c % 2 == 0:
print("Even")
else:
print("Odd")
| i = list(map(int, input().split()))
j = i[0] * i[1]
if j % 2 == 0:
print("Even")
else:
print("Odd")
| false | 25 | [
"-# -*- coding: utf-8 -*-",
"-# スペース区切りの整数の入力",
"-a, b = list(map(int, input().split()))",
"-c = a * b",
"-if c % 2 == 0:",
"+i = list(map(int, input().split()))",
"+j = i[0] * i[1]",
"+if j % 2 == 0:"
] | false | 0.071849 | 0.068928 | 1.042372 | [
"s040610691",
"s466519589"
] |
u225388820 | p03112 | python | s967720548 | s754328849 | 1,080 | 660 | 107,220 | 96,300 | Accepted | Accepted | 38.89 | from bisect import bisect_left
a, b, q = list(map(int, input().split()))
INF = 10**12
s = [-INF] + [int(eval(input())) for i in range(a)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(b)] + [INF]
for _ in range(q):
x = int(eval(input()))
k = bisect_left(s, x)
l = bisect_left(t, x)
... | from bisect import bisect_left
import sys
input = sys.stdin.readline
a, b, q = list(map(int, input().split()))
INF = 10**12
s = [-INF] + [int(eval(input())) for i in range(a)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(b)] + [INF]
for _ in range(q):
x = int(eval(input()))
k = bisect_... | 18 | 20 | 487 | 527 | from bisect import bisect_left
a, b, q = list(map(int, input().split()))
INF = 10**12
s = [-INF] + [int(eval(input())) for i in range(a)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(b)] + [INF]
for _ in range(q):
x = int(eval(input()))
k = bisect_left(s, x)
l = bisect_left(t, x)
sm = x - s[... | from bisect import bisect_left
import sys
input = sys.stdin.readline
a, b, q = list(map(int, input().split()))
INF = 10**12
s = [-INF] + [int(eval(input())) for i in range(a)] + [INF]
t = [-INF] + [int(eval(input())) for i in range(b)] + [INF]
for _ in range(q):
x = int(eval(input()))
k = bisect_left(s, x)
... | false | 10 | [
"+import sys",
"+input = sys.stdin.readline"
] | false | 0.047323 | 0.130501 | 0.362629 | [
"s967720548",
"s754328849"
] |
u664373116 | p02775 | python | s487130073 | s059383308 | 1,142 | 323 | 208,192 | 122,980 | Accepted | Accepted | 71.72 | def dp_solver(tmp):
l=len(tmp)
rev=tmp[::-1]+"0"
dp=[[float("inf") for _ in range(2)] for _ in range(l+2)]
dp[0][0]=0
for i in range(l+1):
for j in range(2):
num=int(rev[i])
num+=j
if num<10:
dp[i+1][0]=min(dp[i+1][0],dp[i][j]+num... | ###さらに綺麗に!!!
def y_solver(tmp):
l=len(tmp)
rev=[int(i) for i in tmp[::-1]+"0"]
ans=0
for i in range(l):
num=rev[i]
next_num=rev[i+1]
if (num>5) or (num==5 and next_num>=5):
rev[i+1]+=1
ans+=min(num,10-num)
last=rev[l]
ans+=min(last,10-las... | 21 | 18 | 522 | 382 | def dp_solver(tmp):
l = len(tmp)
rev = tmp[::-1] + "0"
dp = [[float("inf") for _ in range(2)] for _ in range(l + 2)]
dp[0][0] = 0
for i in range(l + 1):
for j in range(2):
num = int(rev[i])
num += j
if num < 10:
dp[i + 1][0] = min(dp[i + 1]... | ###さらに綺麗に!!!
def y_solver(tmp):
l = len(tmp)
rev = [int(i) for i in tmp[::-1] + "0"]
ans = 0
for i in range(l):
num = rev[i]
next_num = rev[i + 1]
if (num > 5) or (num == 5 and next_num >= 5):
rev[i + 1] += 1
ans += min(num, 10 - num)
last = rev[l]
ans... | false | 14.285714 | [
"-def dp_solver(tmp):",
"+###さらに綺麗に!!!",
"+def y_solver(tmp):",
"- rev = tmp[::-1] + \"0\"",
"- dp = [[float(\"inf\") for _ in range(2)] for _ in range(l + 2)]",
"- dp[0][0] = 0",
"- for i in range(l + 1):",
"- for j in range(2):",
"- num = int(rev[i])",
"- ... | false | 0.123494 | 0.044092 | 2.800811 | [
"s487130073",
"s059383308"
] |
u609061751 | p03208 | python | s946838324 | s123018662 | 298 | 257 | 20,296 | 44,124 | Accepted | Accepted | 13.76 | import sys
from collections import deque
input = sys.stdin.readline
import numpy as np
N, K = [int(x) for x in input().split()]
h = []
for _ in range(N):
h.append(int(eval(input())))
h.sort()
i = 0
ans = []
while N - i >= K:
temp = []
temp.append(h[i])
temp.append(h[i+K-1])
ans.append... | import sys
input = sys.stdin.readline
n, k = [int(x) for x in input().split()]
h = [int(eval(input())) for _ in range(n)]
h.sort()
ans = 10 ** 10
for i in range(n):
if i + k - 1 >= n:
break
ans = min(ans, h[i + k - 1] - h[i])
print(ans)
| 18 | 12 | 363 | 262 | import sys
from collections import deque
input = sys.stdin.readline
import numpy as np
N, K = [int(x) for x in input().split()]
h = []
for _ in range(N):
h.append(int(eval(input())))
h.sort()
i = 0
ans = []
while N - i >= K:
temp = []
temp.append(h[i])
temp.append(h[i + K - 1])
ans.append(temp[-1]... | import sys
input = sys.stdin.readline
n, k = [int(x) for x in input().split()]
h = [int(eval(input())) for _ in range(n)]
h.sort()
ans = 10**10
for i in range(n):
if i + k - 1 >= n:
break
ans = min(ans, h[i + k - 1] - h[i])
print(ans)
| false | 33.333333 | [
"-from collections import deque",
"-import numpy as np",
"-",
"-N, K = [int(x) for x in input().split()]",
"-h = []",
"-for _ in range(N):",
"- h.append(int(eval(input())))",
"+n, k = [int(x) for x in input().split()]",
"+h = [int(eval(input())) for _ in range(n)]",
"-i = 0",
"-ans = []",
"... | false | 0.047019 | 0.046148 | 1.018868 | [
"s946838324",
"s123018662"
] |
u285169240 | p03352 | python | s449736167 | s309556813 | 19 | 17 | 2,940 | 3,060 | Accepted | Accepted | 10.53 | import math
X = int(eval(input()))
max = 0
x = math.floor(math.sqrt(X))
for b in range(x + 1):
for p in range(x + 1):
# print(b**p)
if(max < b**p <= X):
max = b**p
print(max)
| import math
X = int(eval(input()))
max = 0
bRange = math.floor(math.sqrt(X))
pRange = math.floor(math.log(X,2))
for b in range(bRange + 1):
for p in range(pRange + 1):
# print(b**p)
if(max < b**p <= X):
max = b**p
print(max)
| 10 | 11 | 210 | 261 | import math
X = int(eval(input()))
max = 0
x = math.floor(math.sqrt(X))
for b in range(x + 1):
for p in range(x + 1):
# print(b**p)
if max < b**p <= X:
max = b**p
print(max)
| import math
X = int(eval(input()))
max = 0
bRange = math.floor(math.sqrt(X))
pRange = math.floor(math.log(X, 2))
for b in range(bRange + 1):
for p in range(pRange + 1):
# print(b**p)
if max < b**p <= X:
max = b**p
print(max)
| false | 9.090909 | [
"-x = math.floor(math.sqrt(X))",
"-for b in range(x + 1):",
"- for p in range(x + 1):",
"+bRange = math.floor(math.sqrt(X))",
"+pRange = math.floor(math.log(X, 2))",
"+for b in range(bRange + 1):",
"+ for p in range(pRange + 1):"
] | false | 0.062325 | 0.061773 | 1.00893 | [
"s449736167",
"s309556813"
] |
u050708958 | p03487 | python | s043234522 | s986716757 | 109 | 73 | 23,668 | 23,668 | Accepted | Accepted | 33.03 | from collections import Counter
n = eval(input())
c = Counter(list(map(int, input().split())))
print((sum(0 if c[key] == key else c[key] if c[key] < key else c[key] - key for key in c)))
| from collections import Counter
n = eval(input())
c = Counter(list(map(int, input().split())))
print((sum(v if v < k else v - k for k,v in list(c.items()))))
| 4 | 4 | 176 | 141 | from collections import Counter
n = eval(input())
c = Counter(list(map(int, input().split())))
print(
(sum(0 if c[key] == key else c[key] if c[key] < key else c[key] - key for key in c))
)
| from collections import Counter
n = eval(input())
c = Counter(list(map(int, input().split())))
print((sum(v if v < k else v - k for k, v in list(c.items()))))
| false | 0 | [
"-print(",
"- (sum(0 if c[key] == key else c[key] if c[key] < key else c[key] - key for key in c))",
"-)",
"+print((sum(v if v < k else v - k for k, v in list(c.items()))))"
] | false | 0.041873 | 0.044914 | 0.932293 | [
"s043234522",
"s986716757"
] |
u141642872 | p03285 | python | s741405222 | s019786904 | 20 | 17 | 3,060 | 2,940 | Accepted | Accepted | 15 | # 入力
N = int(eval(input()))
# 処理
exist = False # 条件を満たす買い方が存在する
for i in range(100): # ケーキを買う個数
for j in range(100): # ドーナツを買う個数
s = i*4 + j*7 # 合計金額
if s == N:
exist = True # 条件を満たす買い方を見つけた
# 出力
if exist:
print("Yes")
else:
print("No") | N = int(eval(input()))
ans = "No"
for i in range(N):
rem = N-4*i
if rem >= 0 and rem % 7 == 0:
ans = "Yes"
print(ans)
| 16 | 7 | 302 | 126 | # 入力
N = int(eval(input()))
# 処理
exist = False # 条件を満たす買い方が存在する
for i in range(100): # ケーキを買う個数
for j in range(100): # ドーナツを買う個数
s = i * 4 + j * 7 # 合計金額
if s == N:
exist = True # 条件を満たす買い方を見つけた
# 出力
if exist:
print("Yes")
else:
print("No")
| N = int(eval(input()))
ans = "No"
for i in range(N):
rem = N - 4 * i
if rem >= 0 and rem % 7 == 0:
ans = "Yes"
print(ans)
| false | 56.25 | [
"-# 入力",
"-# 処理",
"-exist = False # 条件を満たす買い方が存在する",
"-for i in range(100): # ケーキを買う個数",
"- for j in range(100): # ドーナツを買う個数",
"- s = i * 4 + j * 7 # 合計金額",
"- if s == N:",
"- exist = True # 条件を満たす買い方を見つけた",
"-# 出力",
"-if exist:",
"- print(\"Yes\")",
"-else:... | false | 0.056202 | 0.052016 | 1.080476 | [
"s741405222",
"s019786904"
] |
u286941902 | p03797 | python | s066111053 | s826150003 | 17 | 10 | 2,940 | 2,568 | Accepted | Accepted | 41.18 | n,m=list(map(int,input().split()));print((min(m//2+n,m)//2)) | n,m=list(map(int,input().split()));print(min(m/2+n,m)/2) | 1 | 1 | 52 | 53 | n, m = list(map(int, input().split()))
print((min(m // 2 + n, m) // 2))
| n, m = list(map(int, input().split()))
print(min(m / 2 + n, m) / 2)
| false | 0 | [
"-print((min(m // 2 + n, m) // 2))",
"+print(min(m / 2 + n, m) / 2)"
] | false | 0.07784 | 0.038321 | 2.031281 | [
"s066111053",
"s826150003"
] |
u753803401 | p04045 | python | s964951199 | s299687744 | 1,042 | 190 | 3,188 | 40,428 | Accepted | Accepted | 81.77 | import itertools
n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
ls = []
for i in range(10):
if i not in d:
ls.append(i)
mp = 10 ** 9
for j in range(len(str(n)), 7):
for i in itertools.product(ls, repeat=j):
m = int("".join(map(str, i)))
if m >= n:
... | def slove():
import sys
import collections
input = sys.stdin.readline
n, k = list(map(int, input().rstrip('\n').split()))
d = collections.defaultdict(int)
for i in list(map(int, input().rstrip('\n').split())):
d[i]
for i in range(n, 10 ** 10):
s = str(i)
b =... | 14 | 22 | 353 | 543 | import itertools
n, k = list(map(int, input().split()))
d = list(map(int, input().split()))
ls = []
for i in range(10):
if i not in d:
ls.append(i)
mp = 10**9
for j in range(len(str(n)), 7):
for i in itertools.product(ls, repeat=j):
m = int("".join(map(str, i)))
if m >= n:
m... | def slove():
import sys
import collections
input = sys.stdin.readline
n, k = list(map(int, input().rstrip("\n").split()))
d = collections.defaultdict(int)
for i in list(map(int, input().rstrip("\n").split())):
d[i]
for i in range(n, 10**10):
s = str(i)
b = True
... | false | 36.363636 | [
"-import itertools",
"+def slove():",
"+ import sys",
"+ import collections",
"-n, k = list(map(int, input().split()))",
"-d = list(map(int, input().split()))",
"-ls = []",
"-for i in range(10):",
"- if i not in d:",
"- ls.append(i)",
"-mp = 10**9",
"-for j in range(len(str(n))... | false | 0.068506 | 0.074904 | 0.914587 | [
"s964951199",
"s299687744"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.