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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u394271841 | p03160 | python | s947107460 | s176079778 | 287 | 138 | 12,380 | 13,980 | Accepted | Accepted | 51.92 | #!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile
def read(
f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
def read_word():
w = lambda c: c in whitespaces
nw = lambda c: c not in whitespaces
return f("".join(takewhile(nw, dropwhile(w, it))))
if not shape:
return read_word()
elif len(shape) == 1:
return [read_word() for _ in range(shape[0])]
elif len(shape) == 2:
return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]
def arr(*shape, fill_value=0):
if len(shape) == 1:
return [fill_value] * shape[fill_value]
elif len(shape) == 2:
return [[fill_value] * shape[1] for _ in range(shape[0])]
def dbg(**kwargs):
print(
", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
file=sys.stderr,
)
def main():
n = read(int)
hs = read(int, n)
dp = arr(n)
dp[1] = abs(hs[1] - hs[0])
for i in range(2, n):
dp[i] = min(
dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2])
)
print(dp[-1])
if __name__ == "__main__":
main()
| n = int(eval(input()))
hs = [int(s) for s in input().split()]
dp = [0] * n
dp[0], dp[1] = 0, abs(hs[1] - hs[0])
for i in range(2, n):
dp[i] = min(
dp[i-1] + abs(hs[i] - hs[i-1]),
dp[i-2] + abs(hs[i] - hs[i-2]),
)
print((dp[-1])) | 50 | 13 | 1,277 | 259 | #!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile
def read(
f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
def read_word():
w = lambda c: c in whitespaces
nw = lambda c: c not in whitespaces
return f("".join(takewhile(nw, dropwhile(w, it))))
if not shape:
return read_word()
elif len(shape) == 1:
return [read_word() for _ in range(shape[0])]
elif len(shape) == 2:
return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]
def arr(*shape, fill_value=0):
if len(shape) == 1:
return [fill_value] * shape[fill_value]
elif len(shape) == 2:
return [[fill_value] * shape[1] for _ in range(shape[0])]
def dbg(**kwargs):
print(
", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
file=sys.stderr,
)
def main():
n = read(int)
hs = read(int, n)
dp = arr(n)
dp[1] = abs(hs[1] - hs[0])
for i in range(2, n):
dp[i] = min(
dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2])
)
print(dp[-1])
if __name__ == "__main__":
main()
| n = int(eval(input()))
hs = [int(s) for s in input().split()]
dp = [0] * n
dp[0], dp[1] = 0, abs(hs[1] - hs[0])
for i in range(2, n):
dp[i] = min(
dp[i - 1] + abs(hs[i] - hs[i - 1]),
dp[i - 2] + abs(hs[i] - hs[i - 2]),
)
print((dp[-1]))
| false | 74 | [
"-#!/usr/bin/env python",
"-import string",
"-import sys",
"-from itertools import chain, dropwhile, takewhile",
"-",
"-",
"-def read(",
"- f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)",
"-):",
"- def read_word():",
"- w = lambda c: c in whitespaces",
"- nw = lambda c: c not in whitespaces",
"- return f(\"\".join(takewhile(nw, dropwhile(w, it))))",
"-",
"- if not shape:",
"- return read_word()",
"- elif len(shape) == 1:",
"- return [read_word() for _ in range(shape[0])]",
"- elif len(shape) == 2:",
"- return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]",
"-",
"-",
"-def arr(*shape, fill_value=0):",
"- if len(shape) == 1:",
"- return [fill_value] * shape[fill_value]",
"- elif len(shape) == 2:",
"- return [[fill_value] * shape[1] for _ in range(shape[0])]",
"-",
"-",
"-def dbg(**kwargs):",
"- print(",
"- \", \".join(\"{} = {}\".format(k, repr(v)) for k, v in kwargs.items()),",
"- file=sys.stderr,",
"+n = int(eval(input()))",
"+hs = [int(s) for s in input().split()]",
"+dp = [0] * n",
"+dp[0], dp[1] = 0, abs(hs[1] - hs[0])",
"+for i in range(2, n):",
"+ dp[i] = min(",
"+ dp[i - 1] + abs(hs[i] - hs[i - 1]),",
"+ dp[i - 2] + abs(hs[i] - hs[i - 2]),",
"-",
"-",
"-def main():",
"- n = read(int)",
"- hs = read(int, n)",
"- dp = arr(n)",
"- dp[1] = abs(hs[1] - hs[0])",
"- for i in range(2, n):",
"- dp[i] = min(",
"- dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2])",
"- )",
"- print(dp[-1])",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+print((dp[-1]))"
] | false | 0.044945 | 0.040717 | 1.103843 | [
"s947107460",
"s176079778"
] |
u671060652 | p03147 | python | s976638634 | s506864099 | 259 | 69 | 63,980 | 65,740 | Accepted | Accepted | 73.36 | import itertools
import math
import fractions
import functools
import copy
n = int(eval(input()))
h = list(map(int, input().split()))
ans = 0
active = 0
for i in range(n):
if h[i] <= active:
active = h[i]
else:
ans += h[i] - active;
active = h[i]
print(ans) | def main():
n = int(eval(input()))
# n, m = map(int, input().split())
h = list(map(int, input().split()))
# s = input()
# h = [int(input()) for _ in range(n)]
count = 0
h.append(0)
for j in range(max(h)):
for i in range(n):
if h[i] != 0 and h[i+1] == 0:
count += 1
if h[i] != 0:
h[i] -= 1
print(count)
if __name__ == '__main__':
main()
| 17 | 22 | 305 | 464 | import itertools
import math
import fractions
import functools
import copy
n = int(eval(input()))
h = list(map(int, input().split()))
ans = 0
active = 0
for i in range(n):
if h[i] <= active:
active = h[i]
else:
ans += h[i] - active
active = h[i]
print(ans)
| def main():
n = int(eval(input()))
# n, m = map(int, input().split())
h = list(map(int, input().split()))
# s = input()
# h = [int(input()) for _ in range(n)]
count = 0
h.append(0)
for j in range(max(h)):
for i in range(n):
if h[i] != 0 and h[i + 1] == 0:
count += 1
if h[i] != 0:
h[i] -= 1
print(count)
if __name__ == "__main__":
main()
| false | 22.727273 | [
"-import itertools",
"-import math",
"-import fractions",
"-import functools",
"-import copy",
"+def main():",
"+ n = int(eval(input()))",
"+ # n, m = map(int, input().split())",
"+ h = list(map(int, input().split()))",
"+ # s = input()",
"+ # h = [int(input()) for _ in range(n)]",
"+ count = 0",
"+ h.append(0)",
"+ for j in range(max(h)):",
"+ for i in range(n):",
"+ if h[i] != 0 and h[i + 1] == 0:",
"+ count += 1",
"+ if h[i] != 0:",
"+ h[i] -= 1",
"+ print(count)",
"-n = int(eval(input()))",
"-h = list(map(int, input().split()))",
"-ans = 0",
"-active = 0",
"-for i in range(n):",
"- if h[i] <= active:",
"- active = h[i]",
"- else:",
"- ans += h[i] - active",
"- active = h[i]",
"-print(ans)",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.059915 | 0.035176 | 1.70327 | [
"s976638634",
"s506864099"
] |
u645250356 | p03378 | python | s485933644 | s894322206 | 167 | 124 | 38,256 | 77,300 | Accepted | Accepted | 25.75 | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
n,m,x = inpl()
a = inpl()
for i in range(m):
if a[i] >= x:
break
print((min(i,m-i))) | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
n,m,X = inpl()
a = inpl()
f = [False] * n
for x in a:
f[x] = True
print((min(sum(f[:X]), sum(f[X:]))))
| 15 | 16 | 457 | 464 | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def inpln(n):
return list(int(sys.stdin.readline()) for i in range(n))
n, m, x = inpl()
a = inpl()
for i in range(m):
if a[i] >= x:
break
print((min(i, m - i)))
| from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions, pprint
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
n, m, X = inpl()
a = inpl()
f = [False] * n
for x in a:
f[x] = True
print((min(sum(f[:X]), sum(f[X:]))))
| false | 6.25 | [
"-from heapq import heappop, heappush, heapify",
"-import sys, bisect, math, itertools",
"+from heapq import heappop, heappush",
"+from bisect import bisect_left, bisect_right",
"+import sys, math, itertools, fractions, pprint",
"+INF = float(\"inf\")",
"-def inpln(n):",
"- return list(int(sys.stdin.readline()) for i in range(n))",
"-",
"-",
"-n, m, x = inpl()",
"+n, m, X = inpl()",
"-for i in range(m):",
"- if a[i] >= x:",
"- break",
"-print((min(i, m - i)))",
"+f = [False] * n",
"+for x in a:",
"+ f[x] = True",
"+print((min(sum(f[:X]), sum(f[X:]))))"
] | false | 0.040204 | 0.033851 | 1.187664 | [
"s485933644",
"s894322206"
] |
u312025627 | p03592 | python | s632892151 | s185915689 | 201 | 171 | 51,176 | 38,768 | Accepted | Accepted | 14.93 | def main():
N, M, K = (int(i) for i in input().split())
ans = set()
for i in range(M+1):
for j in range(N+1):
if N-j >= 0 and M-i >= 0:
ans.add((N-j)*i + (M-i)*j)
if K in ans:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
| def main():
N, M, K = (int(i) for i in input().split())
for i in range(N+1):
for j in range(M+1):
cur = i*j + (N-i)*(M-j)
if cur == K:
return print("Yes")
print("No")
if __name__ == '__main__':
main()
| 15 | 12 | 333 | 278 | def main():
N, M, K = (int(i) for i in input().split())
ans = set()
for i in range(M + 1):
for j in range(N + 1):
if N - j >= 0 and M - i >= 0:
ans.add((N - j) * i + (M - i) * j)
if K in ans:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| def main():
N, M, K = (int(i) for i in input().split())
for i in range(N + 1):
for j in range(M + 1):
cur = i * j + (N - i) * (M - j)
if cur == K:
return print("Yes")
print("No")
if __name__ == "__main__":
main()
| false | 20 | [
"- ans = set()",
"- for i in range(M + 1):",
"- for j in range(N + 1):",
"- if N - j >= 0 and M - i >= 0:",
"- ans.add((N - j) * i + (M - i) * j)",
"- if K in ans:",
"- print(\"Yes\")",
"- else:",
"- print(\"No\")",
"+ for i in range(N + 1):",
"+ for j in range(M + 1):",
"+ cur = i * j + (N - i) * (M - j)",
"+ if cur == K:",
"+ return print(\"Yes\")",
"+ print(\"No\")"
] | false | 0.073282 | 0.072966 | 1.004326 | [
"s632892151",
"s185915689"
] |
u945181840 | p03878 | python | s623719980 | s172296451 | 375 | 284 | 26,844 | 27,740 | Accepted | Accepted | 24.27 | import sys
read = sys.stdin.read
N, *ab = list(map(int, read().split()))
mod = 10 ** 9 + 7
ab = list(zip(ab[:N], [0] * N)) + list(zip(ab[N:], [1] * N))
ab.sort()
remain_pc = 0
remain_power = 0
answer = 1
for x, p in ab:
if p == 0:
if remain_power == 0:
remain_pc += 1
continue
answer *= remain_power
remain_power -= 1
else:
if remain_pc == 0:
remain_power += 1
continue
answer *= remain_pc
remain_pc -= 1
answer %= mod
print(answer)
| import sys
from operator import itemgetter
read = sys.stdin.read
N, *ab = list(map(int, read().split()))
mod = 10 ** 9 + 7
ab = list(zip(ab[:N], [0] * N)) + list(zip(ab[N:], [1] * N))
ab.sort(key=itemgetter(0))
remain_pc = 0
remain_power = 0
answer = 1
for x, p in ab:
if p == 0:
if remain_power == 0:
remain_pc += 1
continue
answer *= remain_power
remain_power -= 1
else:
if remain_pc == 0:
remain_power += 1
continue
answer *= remain_pc
remain_pc -= 1
answer %= mod
print(answer)
| 29 | 30 | 568 | 618 | import sys
read = sys.stdin.read
N, *ab = list(map(int, read().split()))
mod = 10**9 + 7
ab = list(zip(ab[:N], [0] * N)) + list(zip(ab[N:], [1] * N))
ab.sort()
remain_pc = 0
remain_power = 0
answer = 1
for x, p in ab:
if p == 0:
if remain_power == 0:
remain_pc += 1
continue
answer *= remain_power
remain_power -= 1
else:
if remain_pc == 0:
remain_power += 1
continue
answer *= remain_pc
remain_pc -= 1
answer %= mod
print(answer)
| import sys
from operator import itemgetter
read = sys.stdin.read
N, *ab = list(map(int, read().split()))
mod = 10**9 + 7
ab = list(zip(ab[:N], [0] * N)) + list(zip(ab[N:], [1] * N))
ab.sort(key=itemgetter(0))
remain_pc = 0
remain_power = 0
answer = 1
for x, p in ab:
if p == 0:
if remain_power == 0:
remain_pc += 1
continue
answer *= remain_power
remain_power -= 1
else:
if remain_pc == 0:
remain_power += 1
continue
answer *= remain_pc
remain_pc -= 1
answer %= mod
print(answer)
| false | 3.333333 | [
"+from operator import itemgetter",
"-ab.sort()",
"+ab.sort(key=itemgetter(0))"
] | false | 0.04523 | 0.038118 | 1.186574 | [
"s623719980",
"s172296451"
] |
u088816384 | p02392 | python | s006966421 | s214148369 | 40 | 20 | 6,724 | 4,188 | Accepted | Accepted | 50 | (a, b, c) = input().rstrip().split(' ')
a = int(a)
b = int(b)
c = int(c)
if a < b < c:
print('Yes')
else:
print('No') | a, b, c = list(map(int, input().split()))
if a<b<c:
print("Yes")
else:
print("No") | 9 | 5 | 135 | 84 | (a, b, c) = input().rstrip().split(" ")
a = int(a)
b = int(b)
c = int(c)
if a < b < c:
print("Yes")
else:
print("No")
| a, b, c = list(map(int, input().split()))
if a < b < c:
print("Yes")
else:
print("No")
| false | 44.444444 | [
"-(a, b, c) = input().rstrip().split(\" \")",
"-a = int(a)",
"-b = int(b)",
"-c = int(c)",
"+a, b, c = list(map(int, input().split()))"
] | false | 0.035724 | 0.035753 | 0.999173 | [
"s006966421",
"s214148369"
] |
u585482323 | p02973 | python | s159349375 | s384269731 | 328 | 301 | 53,340 | 47,708 | Accepted | Accepted | 8.23 | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
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():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
a = IR(n)
a = [-i for i in a]
dp = [float("inf")]*n
for i in a:
j = bisect.bisect_right(dp,i)
dp[j] = i
print((n-dp.count(float("inf"))))
return
#Solve
if __name__ == "__main__":
solve()
| #!usr/bin/env python3
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.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
a = IR(n)
dp = [float("inf")]*n
for i in a:
j = bisect.bisect_right(dp,-i)
dp[j] = -i
print((n-dp.count(float("inf"))))
return
#Solve
if __name__ == "__main__":
solve()
| 41 | 40 | 984 | 988 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
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():
return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
a = IR(n)
a = [-i for i in a]
dp = [float("inf")] * n
for i in a:
j = bisect.bisect_right(dp, i)
dp[j] = i
print((n - dp.count(float("inf"))))
return
# Solve
if __name__ == "__main__":
solve()
| #!usr/bin/env python3
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.buffer.readline().split()]
def I():
return int(sys.stdin.buffer.readline())
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
n = I()
a = IR(n)
dp = [float("inf")] * n
for i in a:
j = bisect.bisect_right(dp, -i)
dp[j] = -i
print((n - dp.count(float("inf"))))
return
# Solve
if __name__ == "__main__":
solve()
| false | 2.439024 | [
"-from itertools import permutations",
"+from itertools import permutations, accumulate",
"- return [int(x) for x in sys.stdin.readline().split()]",
"+ return [int(x) for x in sys.stdin.buffer.readline().split()]",
"- return int(sys.stdin.readline())",
"+ return int(sys.stdin.buffer.readline())",
"- a = [-i for i in a]",
"- j = bisect.bisect_right(dp, i)",
"- dp[j] = i",
"+ j = bisect.bisect_right(dp, -i)",
"+ dp[j] = -i"
] | false | 0.111133 | 0.10843 | 1.024931 | [
"s159349375",
"s384269731"
] |
u252729807 | p03698 | python | s600750084 | s493458185 | 176 | 162 | 38,256 | 38,384 | Accepted | Accepted | 7.95 | import sys
l = list(eval(input()))
for x in l:
if l.count(x) > 1:
print('no')
sys.exit(0)
print('yes') | S = eval(input())
if len(set(S)) == len(S):
print('yes')
else:
print('no') | 9 | 6 | 126 | 82 | import sys
l = list(eval(input()))
for x in l:
if l.count(x) > 1:
print("no")
sys.exit(0)
print("yes")
| S = eval(input())
if len(set(S)) == len(S):
print("yes")
else:
print("no")
| false | 33.333333 | [
"-import sys",
"-",
"-l = list(eval(input()))",
"-for x in l:",
"- if l.count(x) > 1:",
"- print(\"no\")",
"- sys.exit(0)",
"-print(\"yes\")",
"+S = eval(input())",
"+if len(set(S)) == len(S):",
"+ print(\"yes\")",
"+else:",
"+ print(\"no\")"
] | false | 0.144148 | 0.045462 | 3.170712 | [
"s600750084",
"s493458185"
] |
u729133443 | p02788 | python | s316840742 | s113015541 | 923 | 531 | 48,852 | 55,768 | Accepted | Accepted | 42.47 | from bisect import*
n,d,a,*t=list(map(int,open(0).read().split()))
c=[0]*-~n
z=sorted(zip(*[iter(t)]*2))
s=0
for i,(x,h)in enumerate(z):
c[i]+=c[i-1]
h-=c[i]
t=min(-h//a,0)
c[i]-=t*a
c[bisect(z,(x+d+d,9e9))]+=t*a
s-=t
print(s) | def main():
import sys
from bisect import bisect
from operator import itemgetter
b=sys.stdin.buffer
n,d,a=list(map(int,b.readline().split()))
m=list(map(int,b.read().split()))
c=[0]*(n+1)
z=sorted(zip(m,m),key=itemgetter(0))
y=[x for x,_ in z]
s=0
for i,(x,h)in enumerate(z):
c[i]+=c[i-1]
h-=c[i]
t=-h//a
if t>0:t=0
c[i]-=t*a
c[bisect(y,x+d+d)]+=t*a
s-=t
print(s)
main() | 13 | 21 | 256 | 482 | from bisect import *
n, d, a, *t = list(map(int, open(0).read().split()))
c = [0] * -~n
z = sorted(zip(*[iter(t)] * 2))
s = 0
for i, (x, h) in enumerate(z):
c[i] += c[i - 1]
h -= c[i]
t = min(-h // a, 0)
c[i] -= t * a
c[bisect(z, (x + d + d, 9e9))] += t * a
s -= t
print(s)
| def main():
import sys
from bisect import bisect
from operator import itemgetter
b = sys.stdin.buffer
n, d, a = list(map(int, b.readline().split()))
m = list(map(int, b.read().split()))
c = [0] * (n + 1)
z = sorted(zip(m, m), key=itemgetter(0))
y = [x for x, _ in z]
s = 0
for i, (x, h) in enumerate(z):
c[i] += c[i - 1]
h -= c[i]
t = -h // a
if t > 0:
t = 0
c[i] -= t * a
c[bisect(y, x + d + d)] += t * a
s -= t
print(s)
main()
| false | 38.095238 | [
"-from bisect import *",
"+def main():",
"+ import sys",
"+ from bisect import bisect",
"+ from operator import itemgetter",
"-n, d, a, *t = list(map(int, open(0).read().split()))",
"-c = [0] * -~n",
"-z = sorted(zip(*[iter(t)] * 2))",
"-s = 0",
"-for i, (x, h) in enumerate(z):",
"- c[i] += c[i - 1]",
"- h -= c[i]",
"- t = min(-h // a, 0)",
"- c[i] -= t * a",
"- c[bisect(z, (x + d + d, 9e9))] += t * a",
"- s -= t",
"-print(s)",
"+ b = sys.stdin.buffer",
"+ n, d, a = list(map(int, b.readline().split()))",
"+ m = list(map(int, b.read().split()))",
"+ c = [0] * (n + 1)",
"+ z = sorted(zip(m, m), key=itemgetter(0))",
"+ y = [x for x, _ in z]",
"+ s = 0",
"+ for i, (x, h) in enumerate(z):",
"+ c[i] += c[i - 1]",
"+ h -= c[i]",
"+ t = -h // a",
"+ if t > 0:",
"+ t = 0",
"+ c[i] -= t * a",
"+ c[bisect(y, x + d + d)] += t * a",
"+ s -= t",
"+ print(s)",
"+",
"+",
"+main()"
] | false | 0.040078 | 0.07351 | 0.545197 | [
"s316840742",
"s113015541"
] |
u624689667 | p03545 | python | s156184865 | s483280277 | 183 | 165 | 38,384 | 38,256 | Accepted | Accepted | 9.84 | import itertools
s = [int(i) for i in eval(input())]
for bs in itertools.product((0, 1), repeat=3):
res = s[0]
expr = [str(s[0])]
for b, n in zip(bs, s[1:]):
if b:
res += n
expr.append("+")
expr.append(str(n))
else:
res -= n
expr.append("-")
expr.append(str(n))
if res == 7:
print(("".join(expr) + "=7"))
break
| ABCD = [int(s) for s in list(input())]
operators = ["-", "+"]
for bit in range(1 << 3):
ops = [(bit >> i) & 1 for i in range(3)]
tmp = ABCD[0]
for op, val in zip(ops, ABCD[1:]):
if op:
tmp += val
else:
tmp -= val
if tmp == 7:
print(ABCD[0], end="")
for op, val in zip(ops, ABCD[1:]):
print(operators[op], val, sep="", end="")
print("=7")
exit()
| 20 | 16 | 445 | 460 | import itertools
s = [int(i) for i in eval(input())]
for bs in itertools.product((0, 1), repeat=3):
res = s[0]
expr = [str(s[0])]
for b, n in zip(bs, s[1:]):
if b:
res += n
expr.append("+")
expr.append(str(n))
else:
res -= n
expr.append("-")
expr.append(str(n))
if res == 7:
print(("".join(expr) + "=7"))
break
| ABCD = [int(s) for s in list(input())]
operators = ["-", "+"]
for bit in range(1 << 3):
ops = [(bit >> i) & 1 for i in range(3)]
tmp = ABCD[0]
for op, val in zip(ops, ABCD[1:]):
if op:
tmp += val
else:
tmp -= val
if tmp == 7:
print(ABCD[0], end="")
for op, val in zip(ops, ABCD[1:]):
print(operators[op], val, sep="", end="")
print("=7")
exit()
| false | 20 | [
"-import itertools",
"-",
"-s = [int(i) for i in eval(input())]",
"-for bs in itertools.product((0, 1), repeat=3):",
"- res = s[0]",
"- expr = [str(s[0])]",
"- for b, n in zip(bs, s[1:]):",
"- if b:",
"- res += n",
"- expr.append(\"+\")",
"- expr.append(str(n))",
"+ABCD = [int(s) for s in list(input())]",
"+operators = [\"-\", \"+\"]",
"+for bit in range(1 << 3):",
"+ ops = [(bit >> i) & 1 for i in range(3)]",
"+ tmp = ABCD[0]",
"+ for op, val in zip(ops, ABCD[1:]):",
"+ if op:",
"+ tmp += val",
"- res -= n",
"- expr.append(\"-\")",
"- expr.append(str(n))",
"- if res == 7:",
"- print((\"\".join(expr) + \"=7\"))",
"- break",
"+ tmp -= val",
"+ if tmp == 7:",
"+ print(ABCD[0], end=\"\")",
"+ for op, val in zip(ops, ABCD[1:]):",
"+ print(operators[op], val, sep=\"\", end=\"\")",
"+ print(\"=7\")",
"+ exit()"
] | false | 0.057975 | 0.036299 | 1.597179 | [
"s156184865",
"s483280277"
] |
u053856575 | p02712 | python | s740951506 | s521564512 | 285 | 204 | 33,672 | 9,192 | Accepted | Accepted | 28.42 | n = int(eval(input()))
a = [0 for i in range(n)]
count = 0
for i in range(n):
if (i+1)%3 == 0 or (i+1)%5 == 0:
continue
else:
a[i] = (i+1)
count += (i+1)
print(count) | n = int(eval(input()))
count = 0
for i in range(n):
if (i+1)%3 != 0 and (i+1)%5 != 0:
count += (i+1)
print(count)
| 14 | 9 | 193 | 125 | n = int(eval(input()))
a = [0 for i in range(n)]
count = 0
for i in range(n):
if (i + 1) % 3 == 0 or (i + 1) % 5 == 0:
continue
else:
a[i] = i + 1
count += i + 1
print(count)
| n = int(eval(input()))
count = 0
for i in range(n):
if (i + 1) % 3 != 0 and (i + 1) % 5 != 0:
count += i + 1
print(count)
| false | 35.714286 | [
"-a = [0 for i in range(n)]",
"- if (i + 1) % 3 == 0 or (i + 1) % 5 == 0:",
"- continue",
"- else:",
"- a[i] = i + 1",
"+ if (i + 1) % 3 != 0 and (i + 1) % 5 != 0:"
] | false | 0.23437 | 0.156465 | 1.497907 | [
"s740951506",
"s521564512"
] |
u581187895 | p03268 | python | s010352680 | s052134001 | 75 | 60 | 10,376 | 9,168 | Accepted | Accepted | 20 |
def resolve():
N, K = list(map(int, input().split()))
A = [0] * K
# a % K を決め打つと b % K, c % K のとるべき値が一意に決まることを利用します
for i in range(1, N + 1):
A[i % K] += 1
res = 0
for a in range(K):
b = (K - a) % K
c = (K - a) % K
if (b + c) % K != 0:
continue
res += A[a] * A[b] * A[c]
print(res)
if __name__ == "__main__":
resolve() |
def resolve():
N, K = list(map(int, input().split()))
# Kの倍数である数値の個数を数える
a = 0
for i in range(1, N + 1):
if i % K == 0:
a += 1
# 余りがKの半分となる数値の個数を数える
b = 0
for i in range(1, N + 1):
if i % K == K // 2:
b += 1
# 全ての要素がKの倍数の場合を足す
ans = a * a * a
if K % 2 == 0:
# 全ての要素がK/2の場合を足す
ans += b * b * b
print(ans)
if __name__ == "__main__":
resolve()
| 22 | 27 | 423 | 472 | def resolve():
N, K = list(map(int, input().split()))
A = [0] * K
# a % K を決め打つと b % K, c % K のとるべき値が一意に決まることを利用します
for i in range(1, N + 1):
A[i % K] += 1
res = 0
for a in range(K):
b = (K - a) % K
c = (K - a) % K
if (b + c) % K != 0:
continue
res += A[a] * A[b] * A[c]
print(res)
if __name__ == "__main__":
resolve()
| def resolve():
N, K = list(map(int, input().split()))
# Kの倍数である数値の個数を数える
a = 0
for i in range(1, N + 1):
if i % K == 0:
a += 1
# 余りがKの半分となる数値の個数を数える
b = 0
for i in range(1, N + 1):
if i % K == K // 2:
b += 1
# 全ての要素がKの倍数の場合を足す
ans = a * a * a
if K % 2 == 0:
# 全ての要素がK/2の場合を足す
ans += b * b * b
print(ans)
if __name__ == "__main__":
resolve()
| false | 18.518519 | [
"- A = [0] * K",
"- # a % K を決め打つと b % K, c % K のとるべき値が一意に決まることを利用します",
"+ # Kの倍数である数値の個数を数える",
"+ a = 0",
"- A[i % K] += 1",
"- res = 0",
"- for a in range(K):",
"- b = (K - a) % K",
"- c = (K - a) % K",
"- if (b + c) % K != 0:",
"- continue",
"- res += A[a] * A[b] * A[c]",
"- print(res)",
"+ if i % K == 0:",
"+ a += 1",
"+ # 余りがKの半分となる数値の個数を数える",
"+ b = 0",
"+ for i in range(1, N + 1):",
"+ if i % K == K // 2:",
"+ b += 1",
"+ # 全ての要素がKの倍数の場合を足す",
"+ ans = a * a * a",
"+ if K % 2 == 0:",
"+ # 全ての要素がK/2の場合を足す",
"+ ans += b * b * b",
"+ print(ans)"
] | false | 0.089831 | 0.044644 | 2.012182 | [
"s010352680",
"s052134001"
] |
u254871849 | p03998 | python | s725817395 | s507572123 | 25 | 20 | 3,768 | 3,316 | Accepted | Accepted | 20 | import string
alphabets = string.ascii_uppercase
players_cards = {}
for i in range(3):
players_cards[alphabets[i]] = [letter for letter in eval(input())]
first_player = 'A'
next_player = first_player
while True:
current_player = next_player
current_player_cards = players_cards[current_player]
if current_player_cards:
next_player = current_player_cards[0].upper()
current_player_cards.pop(0)
else:
winner = current_player
print(winner)
exit() | import sys
from collections import deque
a, b, c = sys.stdin.read().split()
def main():
deck = dict([('a', deque(a)), ('b', deque(b)), ('c', deque(c))])
p = 'a'
while True:
if deck[p]:
p = deck[p].popleft()
else:
return p.upper()
if __name__ == '__main__':
ans = main()
print(ans) | 21 | 18 | 521 | 361 | import string
alphabets = string.ascii_uppercase
players_cards = {}
for i in range(3):
players_cards[alphabets[i]] = [letter for letter in eval(input())]
first_player = "A"
next_player = first_player
while True:
current_player = next_player
current_player_cards = players_cards[current_player]
if current_player_cards:
next_player = current_player_cards[0].upper()
current_player_cards.pop(0)
else:
winner = current_player
print(winner)
exit()
| import sys
from collections import deque
a, b, c = sys.stdin.read().split()
def main():
deck = dict([("a", deque(a)), ("b", deque(b)), ("c", deque(c))])
p = "a"
while True:
if deck[p]:
p = deck[p].popleft()
else:
return p.upper()
if __name__ == "__main__":
ans = main()
print(ans)
| false | 14.285714 | [
"-import string",
"+import sys",
"+from collections import deque",
"-alphabets = string.ascii_uppercase",
"-players_cards = {}",
"-for i in range(3):",
"- players_cards[alphabets[i]] = [letter for letter in eval(input())]",
"-first_player = \"A\"",
"-next_player = first_player",
"-while True:",
"- current_player = next_player",
"- current_player_cards = players_cards[current_player]",
"- if current_player_cards:",
"- next_player = current_player_cards[0].upper()",
"- current_player_cards.pop(0)",
"- else:",
"- winner = current_player",
"- print(winner)",
"- exit()",
"+a, b, c = sys.stdin.read().split()",
"+",
"+",
"+def main():",
"+ deck = dict([(\"a\", deque(a)), (\"b\", deque(b)), (\"c\", deque(c))])",
"+ p = \"a\"",
"+ while True:",
"+ if deck[p]:",
"+ p = deck[p].popleft()",
"+ else:",
"+ return p.upper()",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ ans = main()",
"+ print(ans)"
] | false | 0.051312 | 0.040722 | 1.260069 | [
"s725817395",
"s507572123"
] |
u673173160 | p03730 | python | s832430982 | s855778723 | 47 | 42 | 9,264 | 9,084 | Accepted | Accepted | 10.64 | import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
a, b, c = list(map(int, input().split()))
for i in range(1, 100000):
if (b*i + c)%a == 0:
print("YES")
exit()
print("NO") | a, b, c = list(map(int, input().split()))
for i in range(1, 100000):
if a*i % b == c:
print("YES")
exit()
print("NO") | 11 | 6 | 340 | 136 | import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
mans = inf
ans = 0
count = 0
pro = 1
a, b, c = list(map(int, input().split()))
for i in range(1, 100000):
if (b * i + c) % a == 0:
print("YES")
exit()
print("NO")
| a, b, c = list(map(int, input().split()))
for i in range(1, 100000):
if a * i % b == c:
print("YES")
exit()
print("NO")
| false | 45.454545 | [
"-import sys, math, itertools, collections, bisect",
"-",
"-input = lambda: sys.stdin.buffer.readline().rstrip().decode(\"utf-8\")",
"-inf = float(\"inf\")",
"-mod = 10**9 + 7",
"-mans = inf",
"-ans = 0",
"-count = 0",
"-pro = 1",
"- if (b * i + c) % a == 0:",
"+ if a * i % b == c:"
] | false | 0.125735 | 0.077728 | 1.617616 | [
"s832430982",
"s855778723"
] |
u948524308 | p02768 | python | s582166666 | s858715708 | 1,053 | 221 | 3,064 | 11,064 | Accepted | Accepted | 79.01 | n,a,b=list(map(int,input().split()))
mod=10**9+7
def repmod(n,m):
if n==1:return 2
nn = n // 2
te = repmod(nn, m)
if n%2==0:
ans=(te*te)%mod
return ans
elif n%2==1:
ans=(2*te*te)%mod
return ans
def extgcd(a,b):
a0,b0=a,b
x0,y0=1,0
x1,y1=0,1
while b0!=0:
q = a0 // b0
r = a0 % b0
a0,b0=b0,r
temp=x1
x0,x1=x1,x0-q*x1
y0,y1=y1,y0-q*y1
return a0,x0,y0
def mo(x,m):
return (m+x%m)%m
def inv(a,m):
g,x,y=extgcd(a,m)
ans=mo(x,m)
return ans
total=repmod(n,mod)-1
c=max(a,b)
temp=1
s=0
for i in range(c):
temp=(temp*(n-i))%mod
invi=inv(i+1,mod)
temp=temp*invi
if i+1==a:
s+=temp
if i+1==b:
s+=temp
ans=(total-s)%mod
print(ans) | def inv(N):
#n^-1
inv=[1,1]
for i in range(2,N+1):
inv.append(mod-mod//i*inv[(mod%i)]%mod)
return inv
n,a,b=list(map(int,input().split()))
mod=10**9+7
def repmod(n,m):
if n==1:return 2
nn = n // 2
te = repmod(nn, m)
if n%2==0:
ans=(te*te)%mod
return ans
elif n%2==1:
ans=(2*te*te)%mod
return ans
total=repmod(n,mod)-1
c=max(a,b)
temp=1
s=0
invlist=inv(c)
for i in range(c):
temp=(temp*(n-i))%mod
invi=invlist[i+1]
temp=temp*invi
if i+1==a:
s+=temp
if i+1==b:
s+=temp
ans=(total-s)%mod
print(ans)
| 55 | 41 | 848 | 650 | n, a, b = list(map(int, input().split()))
mod = 10**9 + 7
def repmod(n, m):
if n == 1:
return 2
nn = n // 2
te = repmod(nn, m)
if n % 2 == 0:
ans = (te * te) % mod
return ans
elif n % 2 == 1:
ans = (2 * te * te) % mod
return ans
def extgcd(a, b):
a0, b0 = a, b
x0, y0 = 1, 0
x1, y1 = 0, 1
while b0 != 0:
q = a0 // b0
r = a0 % b0
a0, b0 = b0, r
temp = x1
x0, x1 = x1, x0 - q * x1
y0, y1 = y1, y0 - q * y1
return a0, x0, y0
def mo(x, m):
return (m + x % m) % m
def inv(a, m):
g, x, y = extgcd(a, m)
ans = mo(x, m)
return ans
total = repmod(n, mod) - 1
c = max(a, b)
temp = 1
s = 0
for i in range(c):
temp = (temp * (n - i)) % mod
invi = inv(i + 1, mod)
temp = temp * invi
if i + 1 == a:
s += temp
if i + 1 == b:
s += temp
ans = (total - s) % mod
print(ans)
| def inv(N):
# n^-1
inv = [1, 1]
for i in range(2, N + 1):
inv.append(mod - mod // i * inv[(mod % i)] % mod)
return inv
n, a, b = list(map(int, input().split()))
mod = 10**9 + 7
def repmod(n, m):
if n == 1:
return 2
nn = n // 2
te = repmod(nn, m)
if n % 2 == 0:
ans = (te * te) % mod
return ans
elif n % 2 == 1:
ans = (2 * te * te) % mod
return ans
total = repmod(n, mod) - 1
c = max(a, b)
temp = 1
s = 0
invlist = inv(c)
for i in range(c):
temp = (temp * (n - i)) % mod
invi = invlist[i + 1]
temp = temp * invi
if i + 1 == a:
s += temp
if i + 1 == b:
s += temp
ans = (total - s) % mod
print(ans)
| false | 25.454545 | [
"+def inv(N):",
"+ # n^-1",
"+ inv = [1, 1]",
"+ for i in range(2, N + 1):",
"+ inv.append(mod - mod // i * inv[(mod % i)] % mod)",
"+ return inv",
"+",
"+",
"-def extgcd(a, b):",
"- a0, b0 = a, b",
"- x0, y0 = 1, 0",
"- x1, y1 = 0, 1",
"- while b0 != 0:",
"- q = a0 // b0",
"- r = a0 % b0",
"- a0, b0 = b0, r",
"- temp = x1",
"- x0, x1 = x1, x0 - q * x1",
"- y0, y1 = y1, y0 - q * y1",
"- return a0, x0, y0",
"-",
"-",
"-def mo(x, m):",
"- return (m + x % m) % m",
"-",
"-",
"-def inv(a, m):",
"- g, x, y = extgcd(a, m)",
"- ans = mo(x, m)",
"- return ans",
"-",
"-",
"+invlist = inv(c)",
"- invi = inv(i + 1, mod)",
"+ invi = invlist[i + 1]"
] | false | 0.629941 | 0.148752 | 4.234852 | [
"s582166666",
"s858715708"
] |
u761320129 | p03618 | python | s687511303 | s021010867 | 79 | 30 | 3,500 | 3,880 | Accepted | Accepted | 62.03 | S = eval(input())
N = len(S)
ans = 1 + N*(N-1)//2
ct = [0] * 26
for c in S:
i = ord(c) - ord('a')
ct[i] += 1
for a in ct:
ans -= a*(a-1)//2
print(ans) | from collections import Counter
A = eval(input())
ctr = Counter(A)
ans = 0
for k,v in list(ctr.items()):
for k2,v2 in list(ctr.items()):
if k==k2: continue
ans += v*v2
print((ans//2 + 1)) | 11 | 10 | 167 | 197 | S = eval(input())
N = len(S)
ans = 1 + N * (N - 1) // 2
ct = [0] * 26
for c in S:
i = ord(c) - ord("a")
ct[i] += 1
for a in ct:
ans -= a * (a - 1) // 2
print(ans)
| from collections import Counter
A = eval(input())
ctr = Counter(A)
ans = 0
for k, v in list(ctr.items()):
for k2, v2 in list(ctr.items()):
if k == k2:
continue
ans += v * v2
print((ans // 2 + 1))
| false | 9.090909 | [
"-S = eval(input())",
"-N = len(S)",
"-ans = 1 + N * (N - 1) // 2",
"-ct = [0] * 26",
"-for c in S:",
"- i = ord(c) - ord(\"a\")",
"- ct[i] += 1",
"-for a in ct:",
"- ans -= a * (a - 1) // 2",
"-print(ans)",
"+from collections import Counter",
"+",
"+A = eval(input())",
"+ctr = Counter(A)",
"+ans = 0",
"+for k, v in list(ctr.items()):",
"+ for k2, v2 in list(ctr.items()):",
"+ if k == k2:",
"+ continue",
"+ ans += v * v2",
"+print((ans // 2 + 1))"
] | false | 0.044651 | 0.06226 | 0.717169 | [
"s687511303",
"s021010867"
] |
u024383312 | p03086 | python | s075618631 | s024569294 | 20 | 17 | 3,188 | 3,060 | Accepted | Accepted | 15 | import re
S = eval(input())
pattern = '[AGCT]+'
print((max(list(map(len, re.findall(pattern, S))), default=0))) | S = eval(input())
src = ["A","T","C","G"]
ok = True
ans = 0
tmp = 0
for s in S:
if not ok:
tmp = 0
ok = s in src
if ok:
tmp += 1
ans = max(ans, tmp)
print(ans) | 4 | 14 | 100 | 199 | import re
S = eval(input())
pattern = "[AGCT]+"
print((max(list(map(len, re.findall(pattern, S))), default=0)))
| S = eval(input())
src = ["A", "T", "C", "G"]
ok = True
ans = 0
tmp = 0
for s in S:
if not ok:
tmp = 0
ok = s in src
if ok:
tmp += 1
ans = max(ans, tmp)
print(ans)
| false | 71.428571 | [
"-import re",
"-",
"-pattern = \"[AGCT]+\"",
"-print((max(list(map(len, re.findall(pattern, S))), default=0)))",
"+src = [\"A\", \"T\", \"C\", \"G\"]",
"+ok = True",
"+ans = 0",
"+tmp = 0",
"+for s in S:",
"+ if not ok:",
"+ tmp = 0",
"+ ok = s in src",
"+ if ok:",
"+ tmp += 1",
"+ ans = max(ans, tmp)",
"+print(ans)"
] | false | 0.049696 | 0.045703 | 1.087384 | [
"s075618631",
"s024569294"
] |
u332385682 | p04040 | python | s047451478 | s909694836 | 968 | 324 | 19,404 | 26,740 | Accepted | Accepted | 66.53 | from sys import stdin, stdout, stderr, setrecursionlimit
from functools import lru_cache
setrecursionlimit(10**7)
mod = 10**9 + 7
def solve():
def binom(n, k):
res = (modfact[n] * factinv[k]) % mod
res = (res * factinv[n - k]) % mod
return res
h, w, a, b = list(map(int, input().split()))
ans = 0
modfact = [1] * (h + w)
factinv = [1] * (h + w)
for i in range(1, h + w):
modfact[i] = (i * modfact[i - 1]) % mod
factinv[i] = (pow(i, mod - 2, mod) * factinv[i - 1]) % mod
for i in range(h - a):
ans += (binom(b + i - 1, i) * binom(w + h - b - i - 2, h - i - 1)) % mod
ans %= mod
print(ans)
'''
@lru_cache(maxsize=None)
def binom(n, k):
res = (modfact(n) * factinv(k)) % mod
res = (res * factinv(n - k)) % mod
return res
@lru_cache(maxsize=None)
def modfact(n):
if n == 0:
return 1
return (n * modfact(n - 1)) % mod
@lru_cache(maxsize=None)
def factinv(n):
if n == 0:
return 1
return (pow(n, mod - 2, mod) * factinv(n - 1)) % mod
'''
if __name__ == '__main__':
solve() | from sys import stdin, stdout, stderr
mod = 10**9 + 7
def solve():
def binom(n, k):
res = (modfact[n] * factinv[k]) % mod
res = (res * factinv[n - k]) % mod
return res
h, w, a, b = list(map(int, input().split()))
ans = 0
modfact = [1] * (h + w)
factinv = [1] * (h + w)
inv = [1] * (h + w)
for i in range(2, h + w):
modfact[i] = (i * modfact[i - 1]) % mod
inv[i] = (-(mod // i) * inv[mod % i]) % mod
factinv[i] = (inv[i] * factinv[i - 1]) % mod
for i in range(h - a):
ans += (binom(b + i - 1, i) * binom(w + h - b - i - 2, h - i - 1)) % mod
ans %= mod
print(ans)
if __name__ == '__main__':
solve() | 52 | 29 | 1,159 | 729 | from sys import stdin, stdout, stderr, setrecursionlimit
from functools import lru_cache
setrecursionlimit(10**7)
mod = 10**9 + 7
def solve():
def binom(n, k):
res = (modfact[n] * factinv[k]) % mod
res = (res * factinv[n - k]) % mod
return res
h, w, a, b = list(map(int, input().split()))
ans = 0
modfact = [1] * (h + w)
factinv = [1] * (h + w)
for i in range(1, h + w):
modfact[i] = (i * modfact[i - 1]) % mod
factinv[i] = (pow(i, mod - 2, mod) * factinv[i - 1]) % mod
for i in range(h - a):
ans += (binom(b + i - 1, i) * binom(w + h - b - i - 2, h - i - 1)) % mod
ans %= mod
print(ans)
"""
@lru_cache(maxsize=None)
def binom(n, k):
res = (modfact(n) * factinv(k)) % mod
res = (res * factinv(n - k)) % mod
return res
@lru_cache(maxsize=None)
def modfact(n):
if n == 0:
return 1
return (n * modfact(n - 1)) % mod
@lru_cache(maxsize=None)
def factinv(n):
if n == 0:
return 1
return (pow(n, mod - 2, mod) * factinv(n - 1)) % mod
"""
if __name__ == "__main__":
solve()
| from sys import stdin, stdout, stderr
mod = 10**9 + 7
def solve():
def binom(n, k):
res = (modfact[n] * factinv[k]) % mod
res = (res * factinv[n - k]) % mod
return res
h, w, a, b = list(map(int, input().split()))
ans = 0
modfact = [1] * (h + w)
factinv = [1] * (h + w)
inv = [1] * (h + w)
for i in range(2, h + w):
modfact[i] = (i * modfact[i - 1]) % mod
inv[i] = (-(mod // i) * inv[mod % i]) % mod
factinv[i] = (inv[i] * factinv[i - 1]) % mod
for i in range(h - a):
ans += (binom(b + i - 1, i) * binom(w + h - b - i - 2, h - i - 1)) % mod
ans %= mod
print(ans)
if __name__ == "__main__":
solve()
| false | 44.230769 | [
"-from sys import stdin, stdout, stderr, setrecursionlimit",
"-from functools import lru_cache",
"+from sys import stdin, stdout, stderr",
"-setrecursionlimit(10**7)",
"- for i in range(1, h + w):",
"+ inv = [1] * (h + w)",
"+ for i in range(2, h + w):",
"- factinv[i] = (pow(i, mod - 2, mod) * factinv[i - 1]) % mod",
"+ inv[i] = (-(mod // i) * inv[mod % i]) % mod",
"+ factinv[i] = (inv[i] * factinv[i - 1]) % mod",
"-\"\"\"",
"-@lru_cache(maxsize=None)",
"-def binom(n, k):",
"- res = (modfact(n) * factinv(k)) % mod",
"- res = (res * factinv(n - k)) % mod",
"- return res",
"-@lru_cache(maxsize=None)",
"-def modfact(n):",
"- if n == 0:",
"- return 1",
"- return (n * modfact(n - 1)) % mod",
"-@lru_cache(maxsize=None)",
"-def factinv(n):",
"- if n == 0:",
"- return 1",
"- return (pow(n, mod - 2, mod) * factinv(n - 1)) % mod",
"-\"\"\""
] | false | 0.277127 | 0.236988 | 1.16937 | [
"s047451478",
"s909694836"
] |
u345389118 | p02678 | python | s281871834 | s197057298 | 732 | 670 | 34,928 | 35,852 | Accepted | Accepted | 8.47 | from collections import deque
N, M = list(map(int, input().split()))
arr = [[] for n in range(N)]
que = deque([1])
for m in range(M):
a, b = list(map(int, input().split()))
arr[a - 1].append(b)
arr[b - 1].append(a)
dist = [-1] * N
dist[0] = 0
arr2 = [0] * (N - 1)
print("Yes")
while que:
c = que.popleft()
for i in arr[c - 1]:
if dist[i - 1] != -1:
continue
dist[i - 1] = 0
arr2[i - 2] = c
que.append(i)
for i in arr2:
print(i)
| from collections import deque
N, M = list(map(int, input().split()))
arr = [[] for n in range(N)]
for m in range(M):
a, b = list(map(int, input().split()))
arr[a - 1].append(b - 1)
arr[b - 1].append(a - 1)
que = deque([0])
dist = [-1] * N
dist[0] = 0
pre = [0] * N
while que:
c = que.popleft()
for i in arr[c]:
if dist[i] != -1:
continue
dist[i] = 0
pre[i] = c
que.append(i)
print("Yes") # 必ずYesになる
for i in pre[1:]:
print((i+1))
| 30 | 26 | 521 | 514 | from collections import deque
N, M = list(map(int, input().split()))
arr = [[] for n in range(N)]
que = deque([1])
for m in range(M):
a, b = list(map(int, input().split()))
arr[a - 1].append(b)
arr[b - 1].append(a)
dist = [-1] * N
dist[0] = 0
arr2 = [0] * (N - 1)
print("Yes")
while que:
c = que.popleft()
for i in arr[c - 1]:
if dist[i - 1] != -1:
continue
dist[i - 1] = 0
arr2[i - 2] = c
que.append(i)
for i in arr2:
print(i)
| from collections import deque
N, M = list(map(int, input().split()))
arr = [[] for n in range(N)]
for m in range(M):
a, b = list(map(int, input().split()))
arr[a - 1].append(b - 1)
arr[b - 1].append(a - 1)
que = deque([0])
dist = [-1] * N
dist[0] = 0
pre = [0] * N
while que:
c = que.popleft()
for i in arr[c]:
if dist[i] != -1:
continue
dist[i] = 0
pre[i] = c
que.append(i)
print("Yes") # 必ずYesになる
for i in pre[1:]:
print((i + 1))
| false | 13.333333 | [
"-que = deque([1])",
"- arr[a - 1].append(b)",
"- arr[b - 1].append(a)",
"+ arr[a - 1].append(b - 1)",
"+ arr[b - 1].append(a - 1)",
"+que = deque([0])",
"-arr2 = [0] * (N - 1)",
"-print(\"Yes\")",
"+pre = [0] * N",
"- for i in arr[c - 1]:",
"- if dist[i - 1] != -1:",
"+ for i in arr[c]:",
"+ if dist[i] != -1:",
"- dist[i - 1] = 0",
"- arr2[i - 2] = c",
"+ dist[i] = 0",
"+ pre[i] = c",
"-for i in arr2:",
"- print(i)",
"+print(\"Yes\") # 必ずYesになる",
"+for i in pre[1:]:",
"+ print((i + 1))"
] | false | 0.034602 | 0.036066 | 0.959406 | [
"s281871834",
"s197057298"
] |
u430726059 | p03805 | python | s789400987 | s007549996 | 308 | 278 | 13,812 | 13,840 | Accepted | Accepted | 9.74 | n,m=list(map(int, input().split()))
alist=[]
for i in range(m):
a,b=list(map(int, input().split()))
alist.append([a,b])
alist.append([b,a])
ans=0
import itertools
t=[i for i in range(1,n+1)]
blist=list(itertools.permutations(t,n))
ans=0
for i in blist:
flag=True
for j in range(n-1):
if [i[j],i[j+1]] not in alist:
flag=False
if i[0]!=1:
flag=False
if flag:
ans+=1
print(ans) | n,m=list(map(int, input().split()))
alist=[]
for i in range(m):
a,b=list(map(int, input().split()))
alist.append([a,b])
alist.append([b,a])
ans=0
import itertools
t=[i for i in range(1,n+1)]
blist=list(itertools.permutations(t,n))
ans=0
for i in blist:
flag=True
for j in range(n-1):
if [i[j],i[j+1]] not in alist:
flag=False
if i[0]!=1:
flag=False
if flag:
ans+=1
print(ans) | 21 | 21 | 419 | 417 | n, m = list(map(int, input().split()))
alist = []
for i in range(m):
a, b = list(map(int, input().split()))
alist.append([a, b])
alist.append([b, a])
ans = 0
import itertools
t = [i for i in range(1, n + 1)]
blist = list(itertools.permutations(t, n))
ans = 0
for i in blist:
flag = True
for j in range(n - 1):
if [i[j], i[j + 1]] not in alist:
flag = False
if i[0] != 1:
flag = False
if flag:
ans += 1
print(ans)
| n, m = list(map(int, input().split()))
alist = []
for i in range(m):
a, b = list(map(int, input().split()))
alist.append([a, b])
alist.append([b, a])
ans = 0
import itertools
t = [i for i in range(1, n + 1)]
blist = list(itertools.permutations(t, n))
ans = 0
for i in blist:
flag = True
for j in range(n - 1):
if [i[j], i[j + 1]] not in alist:
flag = False
if i[0] != 1:
flag = False
if flag:
ans += 1
print(ans)
| false | 0 | [
"- if i[0] != 1:",
"- flag = False",
"+ if i[0] != 1:",
"+ flag = False"
] | false | 0.060988 | 0.06069 | 1.004908 | [
"s789400987",
"s007549996"
] |
u887207211 | p03250 | python | s867621320 | s736431152 | 20 | 18 | 2,940 | 2,940 | Accepted | Accepted | 10 | def ans():
a, b, c = sorted(input().split())
print((int(a)+int(c+b)))
ans() | A, B, C = sorted(input().split())
print((int(C+B)+int(A))) | 4 | 2 | 80 | 57 | def ans():
a, b, c = sorted(input().split())
print((int(a) + int(c + b)))
ans()
| A, B, C = sorted(input().split())
print((int(C + B) + int(A)))
| false | 50 | [
"-def ans():",
"- a, b, c = sorted(input().split())",
"- print((int(a) + int(c + b)))",
"-",
"-",
"-ans()",
"+A, B, C = sorted(input().split())",
"+print((int(C + B) + int(A)))"
] | false | 0.044722 | 0.044452 | 1.006062 | [
"s867621320",
"s736431152"
] |
u763881112 | p03737 | python | s032885738 | s810998387 | 250 | 153 | 17,968 | 12,396 | Accepted | Accepted | 38.8 |
import numpy as np
import math
s=" "+input()
for i in range(len(s)):
if(s[i]==" "):
print(chr(ord(s[i+1])-32),end="")
print()
|
import numpy as np
import math
a=input().split()
for s in a:
print(s[0].upper(),end="")
print()
| 11 | 9 | 151 | 110 | import numpy as np
import math
s = " " + input()
for i in range(len(s)):
if s[i] == " ":
print(chr(ord(s[i + 1]) - 32), end="")
print()
| import numpy as np
import math
a = input().split()
for s in a:
print(s[0].upper(), end="")
print()
| false | 18.181818 | [
"-s = \" \" + input()",
"-for i in range(len(s)):",
"- if s[i] == \" \":",
"- print(chr(ord(s[i + 1]) - 32), end=\"\")",
"+a = input().split()",
"+for s in a:",
"+ print(s[0].upper(), end=\"\")"
] | false | 0.068153 | 0.08467 | 0.804922 | [
"s032885738",
"s810998387"
] |
u102461423 | p03087 | python | s994253890 | s595869111 | 1,693 | 808 | 17,956 | 17,580 | Accepted | Accepted | 52.27 | import numpy as np
N,Q = list(map(int,input().split()))
S = np.array([b' '] + list(eval(input())), dtype='S1')
A = (S == b'A')
C = (S == b'C')
AC = (A[:-1] & C[1:])
AC_cum = list(AC.cumsum())
for _ in range(Q):
L,R = list(map(int,input().split()))
print((AC_cum[R-1] - AC_cum[L-1]))
| import numpy as np
import sys
buf = sys.stdin.buffer
N,Q = list(map(int,buf.readline().split()))
S = np.zeros(N+2, dtype='S1')
S[1:] = np.frombuffer(buf.read(N+1), dtype='S1')
A = (S == b'A')
C = (S == b'C')
AC = (A[:-1] & C[1:])
AC_cum = list(AC.cumsum())
for _ in range(Q):
L,R = list(map(int,buf.readline().split()))
print((AC_cum[R-1] - AC_cum[L-1]))
| 11 | 14 | 278 | 359 | import numpy as np
N, Q = list(map(int, input().split()))
S = np.array([b" "] + list(eval(input())), dtype="S1")
A = S == b"A"
C = S == b"C"
AC = A[:-1] & C[1:]
AC_cum = list(AC.cumsum())
for _ in range(Q):
L, R = list(map(int, input().split()))
print((AC_cum[R - 1] - AC_cum[L - 1]))
| import numpy as np
import sys
buf = sys.stdin.buffer
N, Q = list(map(int, buf.readline().split()))
S = np.zeros(N + 2, dtype="S1")
S[1:] = np.frombuffer(buf.read(N + 1), dtype="S1")
A = S == b"A"
C = S == b"C"
AC = A[:-1] & C[1:]
AC_cum = list(AC.cumsum())
for _ in range(Q):
L, R = list(map(int, buf.readline().split()))
print((AC_cum[R - 1] - AC_cum[L - 1]))
| false | 21.428571 | [
"+import sys",
"-N, Q = list(map(int, input().split()))",
"-S = np.array([b\" \"] + list(eval(input())), dtype=\"S1\")",
"+buf = sys.stdin.buffer",
"+N, Q = list(map(int, buf.readline().split()))",
"+S = np.zeros(N + 2, dtype=\"S1\")",
"+S[1:] = np.frombuffer(buf.read(N + 1), dtype=\"S1\")",
"- L, R = list(map(int, input().split()))",
"+ L, R = list(map(int, buf.readline().split()))"
] | false | 0.301547 | 0.286273 | 1.053354 | [
"s994253890",
"s595869111"
] |
u324314500 | p03136 | python | s353230266 | s604414933 | 165 | 33 | 38,256 | 9,484 | Accepted | Accepted | 80 | # ContestName
# URL
import sys
#import numpy as np
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
def main():
N = i2n()
L = i2nn()
L.sort()
l1 = sum(L[:-1])
l2 = L[-1]
if l1 > l2:
print('Yes')
else:
print('No')
main()
| import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque # 双方向キュー
from collections import defaultdict # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー
from bisect import bisect_left, bisect_right # 二分探索
sys.setrecursionlimit(int(1e+6))
MOD = int(1e+9) + 7
#import numpy as np # 1.8.2
#import scipy # 0.13.3
def main():
N = i2n()
L = i2nn()
lsum = 0
lmax = 0
for l in L:
lsum += l
if lmax < l:
lmax = l
if lsum - lmax > lmax:
print('Yes')
else:
print('No')
main()
| 27 | 35 | 608 | 1,032 | # ContestName
# URL
import sys
# import numpy as np
s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
def main():
N = i2n()
L = i2nn()
L.sort()
l1 = sum(L[:-1])
l2 = L[-1]
if l1 > l2:
print("Yes")
else:
print("No")
main()
| import sys
s2nn = lambda s: [int(c) for c in s.split(" ")]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
from collections import deque # 双方向キュー
from collections import defaultdict # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー
from bisect import bisect_left, bisect_right # 二分探索
sys.setrecursionlimit(int(1e6))
MOD = int(1e9) + 7
# import numpy as np # 1.8.2
# import scipy # 0.13.3
def main():
N = i2n()
L = i2nn()
lsum = 0
lmax = 0
for l in L:
lsum += l
if lmax < l:
lmax = l
if lsum - lmax > lmax:
print("Yes")
else:
print("No")
main()
| false | 22.857143 | [
"-# ContestName",
"-# URL",
"-# import numpy as np",
"+ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]",
"+from collections import deque # 双方向キュー",
"+from collections import defaultdict # 初期化済み辞書",
"+from heapq import heapify, heappush, heappop, heappushpop # プライオリティキュー",
"+from bisect import bisect_left, bisect_right # 二分探索",
"-",
"+sys.setrecursionlimit(int(1e6))",
"+MOD = int(1e9) + 7",
"+# import numpy as np # 1.8.2",
"+# import scipy # 0.13.3",
"- L.sort()",
"- l1 = sum(L[:-1])",
"- l2 = L[-1]",
"- if l1 > l2:",
"+ lsum = 0",
"+ lmax = 0",
"+ for l in L:",
"+ lsum += l",
"+ if lmax < l:",
"+ lmax = l",
"+ if lsum - lmax > lmax:"
] | false | 0.039014 | 0.068189 | 0.572138 | [
"s353230266",
"s604414933"
] |
u493130708 | p03222 | python | s885815418 | s937910044 | 122 | 84 | 73,904 | 68,596 | Accepted | Accepted | 31.15 | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9+7
INF = float('inf')
#############
# Functions #
#############
######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(eval(input())) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]
#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if(len(kaijo_memo) > n):
return kaijo_memo[n]
if(len(kaijo_memo) == 0):
kaijo_memo.append(1)
while(len(kaijo_memo) <= n):
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if(len(gyaku_kaijo_memo) > n):
return gyaku_kaijo_memo[n]
if(len(gyaku_kaijo_memo) == 0):
gyaku_kaijo_memo.append(1)
while(len(gyaku_kaijo_memo) <= n):
gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
return gyaku_kaijo_memo[n]
def nCr(n,r):
if(n == r):
return 1
if(n < r or r < 0):
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n-r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr.append([n, 1])
return arr
#####LCM#####
def lcm(a, b):
return a * b // gcd (a, b)
#####BitCount#####
def bit_count(n):
count = 0
while n:
n &= n -1
count += 1
return count
#############
# Main Code #
#############
H,W,K = inputIL()
if W == 1:
print((1))
exit()
possible = []
for i in range(1<<(W-1)):
b = bin(i)[2:]
flag = 1
for j in range(len(b)-1):
if b[j] == b[j+1] == "1":
flag = 0
if flag:
possible.append(int(b,2))
def amida(b):
ret = [i for i in range(W)]
for i in range(W-1):
if b>>i & 1:
ret[i],ret[i+1] = ret[i+1],ret[i]
return ret
ans = [0 for i in range(W)]
ans[0] = 1
for _ in range(H):
new_ans = [0 for i in range(W)]
for b in possible:
for i in range(W):
new_ans[i] = (new_ans[i] + ans[amida(b)[i]])%MOD
ans = new_ans
print((ans[K-1])) | H,W,K = list(map(int,input().split()))
MOD = 10**9+7
if W == 1:
print((1))
exit()
possible = []
for i in range(1<<(W-1)):
b = bin(i)[2:]
flag = 1
for j in range(len(b)-1):
if b[j] == b[j+1] == "1":
flag = 0
if flag:
possible.append(int(b,2))
def amida(b):
ret = [i for i in range(W)]
for i in range(W-1):
if b>>i & 1:
ret[i],ret[i+1] = ret[i+1],ret[i]
return ret
ans = [0 for i in range(W)]
ans[0] = 1
for _ in range(H):
new_ans = [0 for i in range(W)]
for b in possible:
for i in range(W):
new_ans[i] = (new_ans[i] + ans[amida(b)[i]])%MOD
ans = new_ans
print((ans[K-1])) | 141 | 35 | 3,016 | 661 | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
#############
# Functions #
#############
######INPUT######
def inputI():
return int(input().strip())
def inputS():
return input().strip()
def inputIL():
return list(map(int, input().split()))
def inputSL():
return list(map(str, input().split()))
def inputILs(n):
return list(int(eval(input())) for _ in range(n))
def inputSLs(n):
return list(input().strip() for _ in range(n))
def inputILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n):
return [list(map(str, input().split())) for _ in range(n)]
#####Inverse#####
def inv(n):
return pow(n, MOD - 2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if len(kaijo_memo) > n:
return kaijo_memo[n]
if len(kaijo_memo) == 0:
kaijo_memo.append(1)
while len(kaijo_memo) <= n:
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if len(gyaku_kaijo_memo) > n:
return gyaku_kaijo_memo[n]
if len(gyaku_kaijo_memo) == 0:
gyaku_kaijo_memo.append(1)
while len(gyaku_kaijo_memo) <= n:
gyaku_kaijo_memo.append(
gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD
)
return gyaku_kaijo_memo[n]
def nCr(n, r):
if n == r:
return 1
if n < r or r < 0:
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n - r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#####BitCount#####
def bit_count(n):
count = 0
while n:
n &= n - 1
count += 1
return count
#############
# Main Code #
#############
H, W, K = inputIL()
if W == 1:
print((1))
exit()
possible = []
for i in range(1 << (W - 1)):
b = bin(i)[2:]
flag = 1
for j in range(len(b) - 1):
if b[j] == b[j + 1] == "1":
flag = 0
if flag:
possible.append(int(b, 2))
def amida(b):
ret = [i for i in range(W)]
for i in range(W - 1):
if b >> i & 1:
ret[i], ret[i + 1] = ret[i + 1], ret[i]
return ret
ans = [0 for i in range(W)]
ans[0] = 1
for _ in range(H):
new_ans = [0 for i in range(W)]
for b in possible:
for i in range(W):
new_ans[i] = (new_ans[i] + ans[amida(b)[i]]) % MOD
ans = new_ans
print((ans[K - 1]))
| H, W, K = list(map(int, input().split()))
MOD = 10**9 + 7
if W == 1:
print((1))
exit()
possible = []
for i in range(1 << (W - 1)):
b = bin(i)[2:]
flag = 1
for j in range(len(b) - 1):
if b[j] == b[j + 1] == "1":
flag = 0
if flag:
possible.append(int(b, 2))
def amida(b):
ret = [i for i in range(W)]
for i in range(W - 1):
if b >> i & 1:
ret[i], ret[i + 1] = ret[i + 1], ret[i]
return ret
ans = [0 for i in range(W)]
ans[0] = 1
for _ in range(H):
new_ans = [0 for i in range(W)]
for b in possible:
for i in range(W):
new_ans[i] = (new_ans[i] + ans[amida(b)[i]]) % MOD
ans = new_ans
print((ans[K - 1]))
| false | 75.177305 | [
"-# -*- coding: utf-8 -*-",
"-#############",
"-# Libraries #",
"-#############",
"-import sys",
"-",
"-input = sys.stdin.readline",
"-import math",
"-import bisect",
"-from collections import deque",
"-from fractions import gcd",
"-from functools import lru_cache",
"-",
"-#############",
"-# Constants #",
"-#############",
"+H, W, K = list(map(int, input().split()))",
"-INF = float(\"inf\")",
"-#############",
"-# Functions #",
"-#############",
"-######INPUT######",
"-def inputI():",
"- return int(input().strip())",
"-",
"-",
"-def inputS():",
"- return input().strip()",
"-",
"-",
"-def inputIL():",
"- return list(map(int, input().split()))",
"-",
"-",
"-def inputSL():",
"- return list(map(str, input().split()))",
"-",
"-",
"-def inputILs(n):",
"- return list(int(eval(input())) for _ in range(n))",
"-",
"-",
"-def inputSLs(n):",
"- return list(input().strip() for _ in range(n))",
"-",
"-",
"-def inputILL(n):",
"- return [list(map(int, input().split())) for _ in range(n)]",
"-",
"-",
"-def inputSLL(n):",
"- return [list(map(str, input().split())) for _ in range(n)]",
"-",
"-",
"-#####Inverse#####",
"-def inv(n):",
"- return pow(n, MOD - 2, MOD)",
"-",
"-",
"-######Combination######",
"-kaijo_memo = []",
"-",
"-",
"-def kaijo(n):",
"- if len(kaijo_memo) > n:",
"- return kaijo_memo[n]",
"- if len(kaijo_memo) == 0:",
"- kaijo_memo.append(1)",
"- while len(kaijo_memo) <= n:",
"- kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)",
"- return kaijo_memo[n]",
"-",
"-",
"-gyaku_kaijo_memo = []",
"-",
"-",
"-def gyaku_kaijo(n):",
"- if len(gyaku_kaijo_memo) > n:",
"- return gyaku_kaijo_memo[n]",
"- if len(gyaku_kaijo_memo) == 0:",
"- gyaku_kaijo_memo.append(1)",
"- while len(gyaku_kaijo_memo) <= n:",
"- gyaku_kaijo_memo.append(",
"- gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD",
"- )",
"- return gyaku_kaijo_memo[n]",
"-",
"-",
"-def nCr(n, r):",
"- if n == r:",
"- return 1",
"- if n < r or r < 0:",
"- return 0",
"- ret = 1",
"- ret = ret * kaijo(n) % MOD",
"- ret = ret * gyaku_kaijo(r) % MOD",
"- ret = ret * gyaku_kaijo(n - r) % MOD",
"- return ret",
"-",
"-",
"-######Factorization######",
"-def factorization(n):",
"- arr = []",
"- temp = n",
"- for i in range(2, int(-(-(n**0.5) // 1)) + 1):",
"- if temp % i == 0:",
"- cnt = 0",
"- while temp % i == 0:",
"- cnt += 1",
"- temp //= i",
"- arr.append([i, cnt])",
"- if temp != 1:",
"- arr.append([temp, 1])",
"- if arr == []:",
"- arr.append([n, 1])",
"- return arr",
"-",
"-",
"-#####LCM#####",
"-def lcm(a, b):",
"- return a * b // gcd(a, b)",
"-",
"-",
"-#####BitCount#####",
"-def bit_count(n):",
"- count = 0",
"- while n:",
"- n &= n - 1",
"- count += 1",
"- return count",
"-",
"-",
"-#############",
"-# Main Code #",
"-#############",
"-H, W, K = inputIL()"
] | false | 0.044991 | 0.046427 | 0.969082 | [
"s885815418",
"s937910044"
] |
u531220228 | p02981 | python | s136838368 | s252047927 | 40 | 17 | 2,940 | 2,940 | Accepted | Accepted | 57.5 | N,A,B = list(map(int, input().split()))
print((min(N*A, B))) | N, A, B = list(map(int, input().split()))
train = N*A
taxi = B
print((min(train, taxi))) | 2 | 6 | 53 | 87 | N, A, B = list(map(int, input().split()))
print((min(N * A, B)))
| N, A, B = list(map(int, input().split()))
train = N * A
taxi = B
print((min(train, taxi)))
| false | 66.666667 | [
"-print((min(N * A, B)))",
"+train = N * A",
"+taxi = B",
"+print((min(train, taxi)))"
] | false | 0.036186 | 0.036492 | 0.991641 | [
"s136838368",
"s252047927"
] |
u855831834 | p02608 | python | s524214779 | s908129742 | 1,748 | 238 | 71,276 | 146,304 | Accepted | Accepted | 86.38 | n = int(eval(input()))
for num in range(1,n+1):
tmp = 0
th = set([])
for x in range(1,int(num**0.5)+1):
for y in range(1,x+1):
if (4*num-2*x*y-3*(x**2+y**2)) < 0:
break
z = ((4*num-2*x*y-3*(x**2+y**2))**0.5-(x+y))/2
#print('#######N=',num)
#print(z)
if z >= 1:
if z.is_integer():
if x**2+y**2+z**2+x*y+y*z+z*x == num:
a = [x,y,z]
a.sort()
a = tuple(a)
if a not in th:
th.add(a)
if x==y and y==z:
#print("pl1")
tmp += 1
elif x!=y and y!=z and z!=x:
#print('pl3')
tmp += 6
else:
#print('pl2')
tmp += 3
print(tmp) | n = int(input())
A = [0]*10**7
for x in range(1,100):
for y in range(1,100):
for z in range(1,100):
A[x**2+y**2+z**2+x*y+y*z+z*x] += 1
print(*A[1:n+1],sep='\n')
| 29 | 9 | 1,068 | 210 | n = int(eval(input()))
for num in range(1, n + 1):
tmp = 0
th = set([])
for x in range(1, int(num**0.5) + 1):
for y in range(1, x + 1):
if (4 * num - 2 * x * y - 3 * (x**2 + y**2)) < 0:
break
z = ((4 * num - 2 * x * y - 3 * (x**2 + y**2)) ** 0.5 - (x + y)) / 2
# print('#######N=',num)
# print(z)
if z >= 1:
if z.is_integer():
if x**2 + y**2 + z**2 + x * y + y * z + z * x == num:
a = [x, y, z]
a.sort()
a = tuple(a)
if a not in th:
th.add(a)
if x == y and y == z:
# print("pl1")
tmp += 1
elif x != y and y != z and z != x:
# print('pl3')
tmp += 6
else:
# print('pl2')
tmp += 3
print(tmp)
| n = int(input())
A = [0] * 10**7
for x in range(1, 100):
for y in range(1, 100):
for z in range(1, 100):
A[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1
print(*A[1 : n + 1], sep="\n")
| false | 68.965517 | [
"-n = int(eval(input()))",
"-for num in range(1, n + 1):",
"- tmp = 0",
"- th = set([])",
"- for x in range(1, int(num**0.5) + 1):",
"- for y in range(1, x + 1):",
"- if (4 * num - 2 * x * y - 3 * (x**2 + y**2)) < 0:",
"- break",
"- z = ((4 * num - 2 * x * y - 3 * (x**2 + y**2)) ** 0.5 - (x + y)) / 2",
"- # print('#######N=',num)",
"- # print(z)",
"- if z >= 1:",
"- if z.is_integer():",
"- if x**2 + y**2 + z**2 + x * y + y * z + z * x == num:",
"- a = [x, y, z]",
"- a.sort()",
"- a = tuple(a)",
"- if a not in th:",
"- th.add(a)",
"- if x == y and y == z:",
"- # print(\"pl1\")",
"- tmp += 1",
"- elif x != y and y != z and z != x:",
"- # print('pl3')",
"- tmp += 6",
"- else:",
"- # print('pl2')",
"- tmp += 3",
"- print(tmp)",
"+n = int(input())",
"+A = [0] * 10**7",
"+for x in range(1, 100):",
"+ for y in range(1, 100):",
"+ for z in range(1, 100):",
"+ A[x**2 + y**2 + z**2 + x * y + y * z + z * x] += 1",
"+print(*A[1 : n + 1], sep=\"\\n\")"
] | false | 0.132506 | 1.471952 | 0.09002 | [
"s524214779",
"s908129742"
] |
u439063038 | p02596 | python | s345997829 | s018726066 | 126 | 66 | 63,332 | 63,096 | Accepted | Accepted | 47.62 | K = int(eval(input()))
mod = 0
last_mod = 0
for i in range(K):
if i==0:
last_mod = 7 % K
else:
last_mod = (last_mod*10)%K
mod += last_mod
mod %= K
if mod%K == 0:
print((i+1))
exit()
print((-1)) | K = int(eval(input()))
mod = 7 % K
for i in range(K):
if mod == 0:
print((i+1))
exit()
mod = (10*mod + 7) % K
if mod == 0:
print(K)
else:
print((-1)) | 15 | 14 | 250 | 187 | K = int(eval(input()))
mod = 0
last_mod = 0
for i in range(K):
if i == 0:
last_mod = 7 % K
else:
last_mod = (last_mod * 10) % K
mod += last_mod
mod %= K
if mod % K == 0:
print((i + 1))
exit()
print((-1))
| K = int(eval(input()))
mod = 7 % K
for i in range(K):
if mod == 0:
print((i + 1))
exit()
mod = (10 * mod + 7) % K
if mod == 0:
print(K)
else:
print((-1))
| false | 6.666667 | [
"-mod = 0",
"-last_mod = 0",
"+mod = 7 % K",
"- if i == 0:",
"- last_mod = 7 % K",
"- else:",
"- last_mod = (last_mod * 10) % K",
"- mod += last_mod",
"- mod %= K",
"- if mod % K == 0:",
"+ if mod == 0:",
"-print((-1))",
"+ mod = (10 * mod + 7) % K",
"+if mod == 0:",
"+ print(K)",
"+else:",
"+ print((-1))"
] | false | 0.106056 | 0.154545 | 0.686243 | [
"s345997829",
"s018726066"
] |
u606033239 | p03416 | python | s022322866 | s685736055 | 47 | 21 | 2,940 | 3,064 | Accepted | Accepted | 55.32 | a,b = list(map(int,input().split()))
d = 0
for i in range(a,b+1):
s = str(i)
if s[0] == s[-1] and s[1] == s[-2]:
d += 1
print(d) | s = input().split()
sa,sb = s[0],s[1]
a,b = int(sa),int(sb)
ap = int(sa[0]+sa[1]+sa[2]+sa[1]+sa[0])
bp = int(sb[0]+sb[1]+sb[2]+sb[1]+sb[0])
da = int(a/100)
db = int(b/100)
if ap < a:
da += 1
if b < bp:
db -= 1
print((db-da + 1)) | 7 | 13 | 144 | 247 | a, b = list(map(int, input().split()))
d = 0
for i in range(a, b + 1):
s = str(i)
if s[0] == s[-1] and s[1] == s[-2]:
d += 1
print(d)
| s = input().split()
sa, sb = s[0], s[1]
a, b = int(sa), int(sb)
ap = int(sa[0] + sa[1] + sa[2] + sa[1] + sa[0])
bp = int(sb[0] + sb[1] + sb[2] + sb[1] + sb[0])
da = int(a / 100)
db = int(b / 100)
if ap < a:
da += 1
if b < bp:
db -= 1
print((db - da + 1))
| false | 46.153846 | [
"-a, b = list(map(int, input().split()))",
"-d = 0",
"-for i in range(a, b + 1):",
"- s = str(i)",
"- if s[0] == s[-1] and s[1] == s[-2]:",
"- d += 1",
"-print(d)",
"+s = input().split()",
"+sa, sb = s[0], s[1]",
"+a, b = int(sa), int(sb)",
"+ap = int(sa[0] + sa[1] + sa[2] + sa[1] + sa[0])",
"+bp = int(sb[0] + sb[1] + sb[2] + sb[1] + sb[0])",
"+da = int(a / 100)",
"+db = int(b / 100)",
"+if ap < a:",
"+ da += 1",
"+if b < bp:",
"+ db -= 1",
"+print((db - da + 1))"
] | false | 0.045723 | 0.068956 | 0.663084 | [
"s022322866",
"s685736055"
] |
u756195685 | p02844 | python | s743835853 | s945440922 | 669 | 20 | 3,188 | 3,060 | Accepted | Accepted | 97.01 | def search(num, moji):
num2str = str(num)
for i, n in enumerate(moji):
if n == num2str:
return moji[i+1:], True
return "", False
a = int(eval(input()))
b = eval(input())
buf = b[:]
result = 0
for i in range(10):
buf, flag = search(i, b[:])
if flag:
for j in range(10):
buf2, flag2 = search(j, buf)
if flag2:
for k in range(10):
_, flag3 = search(k, buf2)
if flag3:
result += 1
print(result)
| N = eval(input())
S = eval(input())
all = "0123456789"
result = 0
for i in all:
Si = S.find(i)
if Si != -1:
for j in all:
Sj = S[Si+1:].find(j)
if Sj != -1:
for k in all:
Sk = S[Si+Sj+2:].find(k)
if Sk != -1:
result += 1
print(result)
| 23 | 16 | 555 | 359 | def search(num, moji):
num2str = str(num)
for i, n in enumerate(moji):
if n == num2str:
return moji[i + 1 :], True
return "", False
a = int(eval(input()))
b = eval(input())
buf = b[:]
result = 0
for i in range(10):
buf, flag = search(i, b[:])
if flag:
for j in range(10):
buf2, flag2 = search(j, buf)
if flag2:
for k in range(10):
_, flag3 = search(k, buf2)
if flag3:
result += 1
print(result)
| N = eval(input())
S = eval(input())
all = "0123456789"
result = 0
for i in all:
Si = S.find(i)
if Si != -1:
for j in all:
Sj = S[Si + 1 :].find(j)
if Sj != -1:
for k in all:
Sk = S[Si + Sj + 2 :].find(k)
if Sk != -1:
result += 1
print(result)
| false | 30.434783 | [
"-def search(num, moji):",
"- num2str = str(num)",
"- for i, n in enumerate(moji):",
"- if n == num2str:",
"- return moji[i + 1 :], True",
"- return \"\", False",
"-",
"-",
"-a = int(eval(input()))",
"-b = eval(input())",
"-buf = b[:]",
"+N = eval(input())",
"+S = eval(input())",
"+all = \"0123456789\"",
"-for i in range(10):",
"- buf, flag = search(i, b[:])",
"- if flag:",
"- for j in range(10):",
"- buf2, flag2 = search(j, buf)",
"- if flag2:",
"- for k in range(10):",
"- _, flag3 = search(k, buf2)",
"- if flag3:",
"+for i in all:",
"+ Si = S.find(i)",
"+ if Si != -1:",
"+ for j in all:",
"+ Sj = S[Si + 1 :].find(j)",
"+ if Sj != -1:",
"+ for k in all:",
"+ Sk = S[Si + Sj + 2 :].find(k)",
"+ if Sk != -1:"
] | false | 0.069769 | 0.007813 | 8.92974 | [
"s743835853",
"s945440922"
] |
u222668979 | p02608 | python | s495401556 | s503768365 | 889 | 477 | 9,616 | 9,712 | Accepted | Accepted | 46.34 | n = int(input())
cnt = [0] * n
for x in range(1, int(n ** 0.5) + 1):
for y in range(1, int(n ** 0.5) + 1):
for z in range(1, int(n ** 0.5) + 1):
num = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
if num <= n:
cnt[num - 1] += 1
print(*cnt, sep="\n")
| n = int(input())
cnt = [0] * n
for x in range(1, int(n ** 0.5) + 1):
for y in range(1, int(n ** 0.5) + 1):
for z in range(1, int(n ** 0.5) + 1):
num = (x + y) ** 2 - x * y + z * (x + y + z)
if num <= n:
cnt[num - 1] += 1
print(*cnt, sep="\n")
| 10 | 10 | 315 | 305 | n = int(input())
cnt = [0] * n
for x in range(1, int(n**0.5) + 1):
for y in range(1, int(n**0.5) + 1):
for z in range(1, int(n**0.5) + 1):
num = x**2 + y**2 + z**2 + x * y + y * z + z * x
if num <= n:
cnt[num - 1] += 1
print(*cnt, sep="\n")
| n = int(input())
cnt = [0] * n
for x in range(1, int(n**0.5) + 1):
for y in range(1, int(n**0.5) + 1):
for z in range(1, int(n**0.5) + 1):
num = (x + y) ** 2 - x * y + z * (x + y + z)
if num <= n:
cnt[num - 1] += 1
print(*cnt, sep="\n")
| false | 0 | [
"- num = x**2 + y**2 + z**2 + x * y + y * z + z * x",
"+ num = (x + y) ** 2 - x * y + z * (x + y + z)"
] | false | 0.072021 | 0.036627 | 1.966314 | [
"s495401556",
"s503768365"
] |
u644907318 | p03486 | python | s189224048 | s499002797 | 170 | 101 | 38,384 | 61,696 | Accepted | Accepted | 40.59 | s = list(input().strip())
s1 = sorted(s)
t = list(input().strip())
t1 = sorted(t,reverse=True)
if s1<t1:
print("Yes")
else:
print("No") | s = list(eval(input()))
t = list(eval(input()))
s = sorted(s)
t = sorted(t,reverse=True)
if s<t:
print("Yes")
else:
print("No") | 8 | 8 | 150 | 130 | s = list(input().strip())
s1 = sorted(s)
t = list(input().strip())
t1 = sorted(t, reverse=True)
if s1 < t1:
print("Yes")
else:
print("No")
| s = list(eval(input()))
t = list(eval(input()))
s = sorted(s)
t = sorted(t, reverse=True)
if s < t:
print("Yes")
else:
print("No")
| false | 0 | [
"-s = list(input().strip())",
"-s1 = sorted(s)",
"-t = list(input().strip())",
"-t1 = sorted(t, reverse=True)",
"-if s1 < t1:",
"+s = list(eval(input()))",
"+t = list(eval(input()))",
"+s = sorted(s)",
"+t = sorted(t, reverse=True)",
"+if s < t:"
] | false | 0.037682 | 0.037779 | 0.997449 | [
"s189224048",
"s499002797"
] |
u844789719 | p02863 | python | s211094482 | s056141475 | 300 | 214 | 42,860 | 12,900 | Accepted | Accepted | 28.67 | I = [int(_) for _ in open(0).read().split()]
N, T = I[:2]
A, B = I[2::2], I[3::2]
dp = [-1] * 6001
dp[0] = 0
for a, b in sorted(zip(A, B)):
for k in range(T - 1, -1, -1):
if dp[k] == -1:
continue
dp[k + a] = max(dp[k + a], dp[k] + b)
print((max(dp)))
| import numpy as np
I = [int(_) for _ in open(0).read().split()]
N, T = I[:2]
A, B = I[2::2], I[3::2]
dp = np.array([-1] * 6001, dtype=np.int64)
dp[0] = 0
for a, b in sorted(zip(A, B)):
dp_new = dp[:]
dp_new[a:a + T] = np.maximum(dp[a:a + T], dp[:T] + b)
dp = dp_new
print((max(dp)))
| 11 | 11 | 291 | 303 | I = [int(_) for _ in open(0).read().split()]
N, T = I[:2]
A, B = I[2::2], I[3::2]
dp = [-1] * 6001
dp[0] = 0
for a, b in sorted(zip(A, B)):
for k in range(T - 1, -1, -1):
if dp[k] == -1:
continue
dp[k + a] = max(dp[k + a], dp[k] + b)
print((max(dp)))
| import numpy as np
I = [int(_) for _ in open(0).read().split()]
N, T = I[:2]
A, B = I[2::2], I[3::2]
dp = np.array([-1] * 6001, dtype=np.int64)
dp[0] = 0
for a, b in sorted(zip(A, B)):
dp_new = dp[:]
dp_new[a : a + T] = np.maximum(dp[a : a + T], dp[:T] + b)
dp = dp_new
print((max(dp)))
| false | 0 | [
"+import numpy as np",
"+",
"-dp = [-1] * 6001",
"+dp = np.array([-1] * 6001, dtype=np.int64)",
"- for k in range(T - 1, -1, -1):",
"- if dp[k] == -1:",
"- continue",
"- dp[k + a] = max(dp[k + a], dp[k] + b)",
"+ dp_new = dp[:]",
"+ dp_new[a : a + T] = np.maximum(dp[a : a + T], dp[:T] + b)",
"+ dp = dp_new"
] | false | 0.048597 | 0.244048 | 0.199127 | [
"s211094482",
"s056141475"
] |
u847467233 | p00029 | python | s923591744 | s022967452 | 30 | 20 | 5,968 | 5,540 | Accepted | Accepted | 33.33 | # AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u
import collections
from operator import itemgetter
a = list(input().split())
maxlen = 0
for i in a:
if len(i) > maxlen:
maxlen = len(i)
ans_max_len = i
dict = collections.Counter(a)
print((max(dict.most_common(), key=itemgetter(1))[0], ans_max_len))
| # AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u
a = list(input().split())
print((max(a, key=a.count), max(a, key=len)))
| 15 | 5 | 324 | 129 | # AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u
import collections
from operator import itemgetter
a = list(input().split())
maxlen = 0
for i in a:
if len(i) > maxlen:
maxlen = len(i)
ans_max_len = i
dict = collections.Counter(a)
print((max(dict.most_common(), key=itemgetter(1))[0], ans_max_len))
| # AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u
a = list(input().split())
print((max(a, key=a.count), max(a, key=len)))
| false | 66.666667 | [
"-import collections",
"-from operator import itemgetter",
"-",
"-maxlen = 0",
"-for i in a:",
"- if len(i) > maxlen:",
"- maxlen = len(i)",
"- ans_max_len = i",
"-dict = collections.Counter(a)",
"-print((max(dict.most_common(), key=itemgetter(1))[0], ans_max_len))",
"+print((max(a, key=a.count), max(a, key=len)))"
] | false | 0.031407 | 0.032709 | 0.960183 | [
"s923591744",
"s022967452"
] |
u645250356 | p03576 | python | s585929290 | s295721722 | 1,812 | 974 | 73,432 | 73,176 | Accepted | Accepted | 46.25 | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def main():
n,k = inpl()
xary = []; yary = []
a = []
x_append = xary.append
y_append = yary.append
a_append = a.append
for i in range(n):
x,y = inpl()
xary += [x]
yary += [y]
a += [[x,y]]
xary.sort(); yary.sort()
res = INF
for xi in range(n-1):
for xj in range(xi+1,n):
for yi in range(n-1):
for yj in range(yi+1,n):
cnt = 0
l = xary[xi]; r = xary[xj]
d = yary[yi]; u = yary[yj]
# print(l,r,d,u)
for i in range(n):
x,y = a[i]
if l<=x<=r and d<=y<=u:
cnt += 1
if cnt >= k:
res = min(res, (r-l)*(u-d))
print(res)
if __name__ == "__main__":
main() | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def main():
n,k = inpl()
xary = []; yary = []
a = []
x_append = xary.append
y_append = yary.append
a_append = a.append
for i in range(n):
x,y = inpl()
xary.append(x)
yary.append(y)
a.append((x,y))
xary.sort(); yary.sort()
res = INF
for xi in range(n-1):
for xj in range(xi+1,n):
for yi in range(n-1):
for yj in range(yi+1,n):
cnt = 0
l = xary[xi]; r = xary[xj]
d = yary[yi]; u = yary[yj]
# print(l,r,d,u)
for i in range(n):
x,y = a[i]
if l<=x<=r and d<=y<=u:
cnt += 1
if cnt >= k:
res = min(res, (r-l)*(u-d))
print(res)
if __name__ == "__main__":
main()
| 40 | 40 | 1,226 | 1,236 | from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def main():
n, k = inpl()
xary = []
yary = []
a = []
x_append = xary.append
y_append = yary.append
a_append = a.append
for i in range(n):
x, y = inpl()
xary += [x]
yary += [y]
a += [[x, y]]
xary.sort()
yary.sort()
res = INF
for xi in range(n - 1):
for xj in range(xi + 1, n):
for yi in range(n - 1):
for yj in range(yi + 1, n):
cnt = 0
l = xary[xi]
r = xary[xj]
d = yary[yi]
u = yary[yj]
# print(l,r,d,u)
for i in range(n):
x, y = a[i]
if l <= x <= r and d <= y <= u:
cnt += 1
if cnt >= k:
res = min(res, (r - l) * (u - d))
print(res)
if __name__ == "__main__":
main()
| from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions
sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
def main():
n, k = inpl()
xary = []
yary = []
a = []
x_append = xary.append
y_append = yary.append
a_append = a.append
for i in range(n):
x, y = inpl()
xary.append(x)
yary.append(y)
a.append((x, y))
xary.sort()
yary.sort()
res = INF
for xi in range(n - 1):
for xj in range(xi + 1, n):
for yi in range(n - 1):
for yj in range(yi + 1, n):
cnt = 0
l = xary[xi]
r = xary[xj]
d = yary[yi]
u = yary[yj]
# print(l,r,d,u)
for i in range(n):
x, y = a[i]
if l <= x <= r and d <= y <= u:
cnt += 1
if cnt >= k:
res = min(res, (r - l) * (u - d))
print(res)
if __name__ == "__main__":
main()
| false | 0 | [
"- xary += [x]",
"- yary += [y]",
"- a += [[x, y]]",
"+ xary.append(x)",
"+ yary.append(y)",
"+ a.append((x, y))"
] | false | 0.037732 | 0.037502 | 1.006129 | [
"s585929290",
"s295721722"
] |
u141610915 | p02782 | python | s026229556 | s723330004 | 868 | 309 | 211,220 | 213,036 | Accepted | Accepted | 64.4 | import sys
input = sys.stdin.readline
r1, c1, r2, c2 = list(map(int, input().split()))
mod = 10 ** 9 + 7
class Factorial:
def __init__(self, n, mod):
self.mod = mod
self.f = [1]
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[: : -1]:
self.i.append(self.i[-1] * i % mod)
self.i.reverse()
def factorial(self, i):
return self.f[i]
def ifactorial(self, i):
return self.i[i]
def combi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
def permi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod
f = Factorial(max(r1, c1, r2, c2) * 3, mod)
res = 0
for i in range(r1, r2 + 1):
res += (f.combi(i + c2 + 1, c2 + 1) * (c2 + 1) - f.combi(i + c1, c1) * c1) % mod * pow(i + 1, mod - 2, mod) % mod
res %= mod
print(res) | import sys
input = sys.stdin.readline
r1, c1, r2, c2 = list(map(int, input().split()))
mod = 10 ** 9 + 7
class Factorial:
def __init__(self, n, mod):
self.mod = mod
self.f = [1]
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[: : -1]:
self.i.append(self.i[-1] * i % mod)
self.i.reverse()
def factorial(self, i):
return self.f[i]
def ifactorial(self, i):
return self.i[i]
def combi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
def permi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod
n = max(r1, c1, r2, c2)
f = Factorial(n * 2 + 1, mod)
res = 0
for i in range(r1, r2 + 1):
res += f.combi(c2 + i + 1, i + 1) - f.combi(c1 + i, i + 1)
res %= mod
print(res) | 31 | 31 | 916 | 870 | import sys
input = sys.stdin.readline
r1, c1, r2, c2 = list(map(int, input().split()))
mod = 10**9 + 7
class Factorial:
def __init__(self, n, mod):
self.mod = mod
self.f = [1]
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[::-1]:
self.i.append(self.i[-1] * i % mod)
self.i.reverse()
def factorial(self, i):
return self.f[i]
def ifactorial(self, i):
return self.i[i]
def combi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
def permi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod
f = Factorial(max(r1, c1, r2, c2) * 3, mod)
res = 0
for i in range(r1, r2 + 1):
res += (
(f.combi(i + c2 + 1, c2 + 1) * (c2 + 1) - f.combi(i + c1, c1) * c1)
% mod
* pow(i + 1, mod - 2, mod)
% mod
)
res %= mod
print(res)
| import sys
input = sys.stdin.readline
r1, c1, r2, c2 = list(map(int, input().split()))
mod = 10**9 + 7
class Factorial:
def __init__(self, n, mod):
self.mod = mod
self.f = [1]
for i in range(1, n + 1):
self.f.append(self.f[-1] * i % mod)
self.i = [pow(self.f[-1], mod - 2, mod)]
for i in range(1, n + 1)[::-1]:
self.i.append(self.i[-1] * i % mod)
self.i.reverse()
def factorial(self, i):
return self.f[i]
def ifactorial(self, i):
return self.i[i]
def combi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod
def permi(self, n, k):
return self.f[n] * self.i[n - k] % self.mod
n = max(r1, c1, r2, c2)
f = Factorial(n * 2 + 1, mod)
res = 0
for i in range(r1, r2 + 1):
res += f.combi(c2 + i + 1, i + 1) - f.combi(c1 + i, i + 1)
res %= mod
print(res)
| false | 0 | [
"-f = Factorial(max(r1, c1, r2, c2) * 3, mod)",
"+n = max(r1, c1, r2, c2)",
"+f = Factorial(n * 2 + 1, mod)",
"- res += (",
"- (f.combi(i + c2 + 1, c2 + 1) * (c2 + 1) - f.combi(i + c1, c1) * c1)",
"- % mod",
"- * pow(i + 1, mod - 2, mod)",
"- % mod",
"- )",
"+ res += f.combi(c2 + i + 1, i + 1) - f.combi(c1 + i, i + 1)"
] | false | 0.084553 | 0.0489 | 1.729106 | [
"s026229556",
"s723330004"
] |
u540877546 | p02658 | python | s690316964 | s426572335 | 50 | 45 | 21,568 | 19,408 | Accepted | Accepted | 10 | n = int(eval(input()))
li = list(map(int, input().split()))
x = 1
if 0 in li:
print((0))
else:
for i in li:
x = x * i
if x > 10**18:
print((-1))
exit()
print(x)
| n = int(eval(input()))
list = input().split(" ")
if '0' in list:
print((0))
exit()
x = 1
for i in list:
x = x * int(i)
if x > 10**18:
print((-1))
exit()
print(x)
| 12 | 14 | 214 | 199 | n = int(eval(input()))
li = list(map(int, input().split()))
x = 1
if 0 in li:
print((0))
else:
for i in li:
x = x * i
if x > 10**18:
print((-1))
exit()
print(x)
| n = int(eval(input()))
list = input().split(" ")
if "0" in list:
print((0))
exit()
x = 1
for i in list:
x = x * int(i)
if x > 10**18:
print((-1))
exit()
print(x)
| false | 14.285714 | [
"-li = list(map(int, input().split()))",
"+list = input().split(\" \")",
"+if \"0\" in list:",
"+ print((0))",
"+ exit()",
"-if 0 in li:",
"- print((0))",
"-else:",
"- for i in li:",
"- x = x * i",
"- if x > 10**18:",
"- print((-1))",
"- exit()",
"- print(x)",
"+for i in list:",
"+ x = x * int(i)",
"+ if x > 10**18:",
"+ print((-1))",
"+ exit()",
"+print(x)"
] | false | 0.046583 | 0.047268 | 0.985506 | [
"s690316964",
"s426572335"
] |
u729133443 | p02610 | python | s166103701 | s189720753 | 1,042 | 916 | 39,888 | 39,884 | Accepted | Accepted | 12.09 | from heapq import*
i=input
def f(x):
x.sort();s,n,*h=0,len(x)
while n:
n-=1
while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))
if h:s+=heappop(h)[1]
return s+sum(r for*_,r in x+h)
for _ in'_'*int(i()):
n,x,*y=int(i()),[]
for _ in'_'*n:
k,l,r=list(map(int,i().split()))
if l>r:x+=(k,l,r),
else:y+=(n-k,r,l),
print((f(x)+f(y))) | from heapq import*
i=input
for _ in'_'*int(i()):
n,s,x,*y=int(i()),0,[]
for _ in'_'*n:
k,l,r=list(map(int,i().split()))
if l>r:x+=(k,l,r),
else:y+=(n-k,r,l),
for x in(x,y):
x.sort();n,*h=len(x),
while n:
n-=1
while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))
if h:s+=heappop(h)[1]
for*_,r in x+h:s+=r
print(s) | 16 | 16 | 358 | 352 | from heapq import *
i = input
def f(x):
x.sort()
s, n, *h = 0, len(x)
while n:
n -= 1
while x and x[-1][0] > n:
k, l, r = x.pop()
heappush(h, (r - l, l, r))
if h:
s += heappop(h)[1]
return s + sum(r for *_, r in x + h)
for _ in "_" * int(i()):
n, x, *y = int(i()), []
for _ in "_" * n:
k, l, r = list(map(int, i().split()))
if l > r:
x += ((k, l, r),)
else:
y += ((n - k, r, l),)
print((f(x) + f(y)))
| from heapq import *
i = input
for _ in "_" * int(i()):
n, s, x, *y = int(i()), 0, []
for _ in "_" * n:
k, l, r = list(map(int, i().split()))
if l > r:
x += ((k, l, r),)
else:
y += ((n - k, r, l),)
for x in (x, y):
x.sort()
n, *h = (len(x),)
while n:
n -= 1
while x and x[-1][0] > n:
k, l, r = x.pop()
heappush(h, (r - l, l, r))
if h:
s += heappop(h)[1]
for *_, r in x + h:
s += r
print(s)
| false | 0 | [
"-",
"-",
"-def f(x):",
"- x.sort()",
"- s, n, *h = 0, len(x)",
"- while n:",
"- n -= 1",
"- while x and x[-1][0] > n:",
"- k, l, r = x.pop()",
"- heappush(h, (r - l, l, r))",
"- if h:",
"- s += heappop(h)[1]",
"- return s + sum(r for *_, r in x + h)",
"-",
"-",
"- n, x, *y = int(i()), []",
"+ n, s, x, *y = int(i()), 0, []",
"- print((f(x) + f(y)))",
"+ for x in (x, y):",
"+ x.sort()",
"+ n, *h = (len(x),)",
"+ while n:",
"+ n -= 1",
"+ while x and x[-1][0] > n:",
"+ k, l, r = x.pop()",
"+ heappush(h, (r - l, l, r))",
"+ if h:",
"+ s += heappop(h)[1]",
"+ for *_, r in x + h:",
"+ s += r",
"+ print(s)"
] | false | 0.036341 | 0.043451 | 0.836376 | [
"s166103701",
"s189720753"
] |
u467175809 | p02314 | python | s413156699 | s852915701 | 780 | 610 | 7,644 | 11,220 | Accepted | Accepted | 21.79 | n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = [i for i in range(n + 1)]
for cost in c:
for i in range(cost, n + 1):
DP[i] = min(DP[i], DP[i - cost] + 1)
print((DP[n]))
| #!/usr/bin/env python
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}
for i in range(n + 1):
DP[i] = n
DP[0] = 0
for cost in c:
for i in range(cost, n + 1):
DP[i] = min(DP[i], DP[i - cost] + 1)
print((DP[n]))
| 8 | 12 | 211 | 258 | n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = [i for i in range(n + 1)]
for cost in c:
for i in range(cost, n + 1):
DP[i] = min(DP[i], DP[i - cost] + 1)
print((DP[n]))
| #!/usr/bin/env python
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
DP = {}
for i in range(n + 1):
DP[i] = n
DP[0] = 0
for cost in c:
for i in range(cost, n + 1):
DP[i] = min(DP[i], DP[i - cost] + 1)
print((DP[n]))
| false | 33.333333 | [
"+#!/usr/bin/env python",
"-DP = [i for i in range(n + 1)]",
"+DP = {}",
"+for i in range(n + 1):",
"+ DP[i] = n",
"+DP[0] = 0"
] | false | 0.095077 | 0.116791 | 0.81408 | [
"s413156699",
"s852915701"
] |
u201387466 | p02662 | python | s587173901 | s929583843 | 244 | 212 | 144,504 | 27,384 | Accepted | Accepted | 13.11 | import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,S = list(map(int,input().split()))
MOD = 998244353
A = list(map(int,input().split()))
dp = [[0]*(S+1) for _ in range(N)]
if A[0] <= S:
dp[0][A[0]] = 1
dp[0][0] = 2
for i in range(1,N):
a = A[i]
for j in range(S+1):
dp[i][j] += 2*dp[i-1][j] % MOD
if j - a < 0:
continue
else:
dp[i][j] += dp[i-1][j-a]
dp[i][j] %= MOD
print((dp[N-1][S]))
| import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
import numpy as np
N,S = list(map(int,input().split()))
MOD = 998244353
A = list(map(int,input().split()))
dp = np.zeros(3003,dtype = np.int64)
dp[0] = 2
if A[0] <= S:
dp[A[0]] = 1
for i in range(1,N):
a = A[i]
p = dp*2
p[a:] += dp[:-a]
p %= MOD
dp = p
print((dp[S]))
| 56 | 54 | 1,418 | 1,302 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# import numpy as np
INF = float("inf")
# d = defaultdict(int)
# d = defaultdict(list)
# N = int(input())
# A = list(map(int,input().split()))
# S = list(input())[:-1]
# S.remove("\n")
# N,M = map(int,input().split())
# S,T = map(str,input().split())
# A = [int(input()) for _ in range(N)]
# S = [list(input())[:-1] for _ in range(N)]
# A = [list(map(int,input().split())) for _ in range(N)]
N, S = list(map(int, input().split()))
MOD = 998244353
A = list(map(int, input().split()))
dp = [[0] * (S + 1) for _ in range(N)]
if A[0] <= S:
dp[0][A[0]] = 1
dp[0][0] = 2
for i in range(1, N):
a = A[i]
for j in range(S + 1):
dp[i][j] += 2 * dp[i - 1][j] % MOD
if j - a < 0:
continue
else:
dp[i][j] += dp[i - 1][j - a]
dp[i][j] %= MOD
print((dp[N - 1][S]))
| import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# import numpy as np
INF = float("inf")
# d = defaultdict(int)
# d = defaultdict(list)
# N = int(input())
# A = list(map(int,input().split()))
# S = list(input())[:-1]
# S.remove("\n")
# N,M = map(int,input().split())
# S,T = map(str,input().split())
# A = [int(input()) for _ in range(N)]
# S = [list(input())[:-1] for _ in range(N)]
# A = [list(map(int,input().split())) for _ in range(N)]
import numpy as np
N, S = list(map(int, input().split()))
MOD = 998244353
A = list(map(int, input().split()))
dp = np.zeros(3003, dtype=np.int64)
dp[0] = 2
if A[0] <= S:
dp[A[0]] = 1
for i in range(1, N):
a = A[i]
p = dp * 2
p[a:] += dp[:-a]
p %= MOD
dp = p
print((dp[S]))
| false | 3.571429 | [
"+import numpy as np",
"+",
"-dp = [[0] * (S + 1) for _ in range(N)]",
"+dp = np.zeros(3003, dtype=np.int64)",
"+dp[0] = 2",
"- dp[0][A[0]] = 1",
"-dp[0][0] = 2",
"+ dp[A[0]] = 1",
"- for j in range(S + 1):",
"- dp[i][j] += 2 * dp[i - 1][j] % MOD",
"- if j - a < 0:",
"- continue",
"- else:",
"- dp[i][j] += dp[i - 1][j - a]",
"- dp[i][j] %= MOD",
"-print((dp[N - 1][S]))",
"+ p = dp * 2",
"+ p[a:] += dp[:-a]",
"+ p %= MOD",
"+ dp = p",
"+print((dp[S]))"
] | false | 0.144154 | 0.629381 | 0.22904 | [
"s587173901",
"s929583843"
] |
u020390084 | p04031 | python | s768969655 | s451077438 | 155 | 24 | 12,484 | 3,064 | Accepted | Accepted | 84.52 | #!/usr/bin/env python3
import sys
import numpy as np
def solve(N: int, a: "List[int]"):
a_num = np.array(a)
min_value = np.min(a_num)
max_value = np.max(a_num)
answer = 10**7
for i in range(min_value,max_value+1):
goal = np.full(N,i)
dif = a_num-goal
nijo = dif**2
answer = min(answer,np.sum(nijo))
print((int(answer)))
return
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
a = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
solve(N, a)
if __name__ == '__main__':
main()
| #!/usr/bin/env python3
import sys
def solve(N: int, a: "List[int]"):
min_cost = 10**9
for target in range(-100,101):
tmp = 0
for i in range(N):
tmp += (a[i]-target)**2
min_cost = min(min_cost,tmp)
print(min_cost)
return
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
a = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
solve(N, a)
if __name__ == '__main__':
main()
| 31 | 27 | 744 | 627 | #!/usr/bin/env python3
import sys
import numpy as np
def solve(N: int, a: "List[int]"):
a_num = np.array(a)
min_value = np.min(a_num)
max_value = np.max(a_num)
answer = 10**7
for i in range(min_value, max_value + 1):
goal = np.full(N, i)
dif = a_num - goal
nijo = dif**2
answer = min(answer, np.sum(nijo))
print((int(answer)))
return
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
a = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
solve(N, a)
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
import sys
def solve(N: int, a: "List[int]"):
min_cost = 10**9
for target in range(-100, 101):
tmp = 0
for i in range(N):
tmp += (a[i] - target) ** 2
min_cost = min(min_cost, tmp)
print(min_cost)
return
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
a = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
solve(N, a)
if __name__ == "__main__":
main()
| false | 12.903226 | [
"-import numpy as np",
"- a_num = np.array(a)",
"- min_value = np.min(a_num)",
"- max_value = np.max(a_num)",
"- answer = 10**7",
"- for i in range(min_value, max_value + 1):",
"- goal = np.full(N, i)",
"- dif = a_num - goal",
"- nijo = dif**2",
"- answer = min(answer, np.sum(nijo))",
"- print((int(answer)))",
"+ min_cost = 10**9",
"+ for target in range(-100, 101):",
"+ tmp = 0",
"+ for i in range(N):",
"+ tmp += (a[i] - target) ** 2",
"+ min_cost = min(min_cost, tmp)",
"+ print(min_cost)"
] | false | 0.290943 | 0.071815 | 4.051272 | [
"s768969655",
"s451077438"
] |
u633255271 | p02583 | python | s259457908 | s112039878 | 104 | 86 | 68,608 | 74,064 | Accepted | Accepted | 17.31 | from itertools import combinations
N = int(eval(input()))
L = list(map(int, input().split()))
def f(a, b, c):
return len(set([a, b, c])) == 3 and a+b>c and b+c>a and c+a>b
ans = 0
for a, b, c in combinations(L, 3):
if f(a, b, c):
ans += 1
print(ans) | from collections import Counter
from itertools import combinations
N = int(eval(input()))
L = Counter(list(map(int, input().split())))
ans = 0
for a, b, c in combinations(list(L.keys()), 3):
if a+b>c and b+c>a and c+a>b:
ans += L[a]*L[b]*L[c]
print(ans) | 13 | 10 | 274 | 263 | from itertools import combinations
N = int(eval(input()))
L = list(map(int, input().split()))
def f(a, b, c):
return len(set([a, b, c])) == 3 and a + b > c and b + c > a and c + a > b
ans = 0
for a, b, c in combinations(L, 3):
if f(a, b, c):
ans += 1
print(ans)
| from collections import Counter
from itertools import combinations
N = int(eval(input()))
L = Counter(list(map(int, input().split())))
ans = 0
for a, b, c in combinations(list(L.keys()), 3):
if a + b > c and b + c > a and c + a > b:
ans += L[a] * L[b] * L[c]
print(ans)
| false | 23.076923 | [
"+from collections import Counter",
"-L = list(map(int, input().split()))",
"-",
"-",
"-def f(a, b, c):",
"- return len(set([a, b, c])) == 3 and a + b > c and b + c > a and c + a > b",
"-",
"-",
"+L = Counter(list(map(int, input().split())))",
"-for a, b, c in combinations(L, 3):",
"- if f(a, b, c):",
"- ans += 1",
"+for a, b, c in combinations(list(L.keys()), 3):",
"+ if a + b > c and b + c > a and c + a > b:",
"+ ans += L[a] * L[b] * L[c]"
] | false | 0.091406 | 0.080712 | 1.132491 | [
"s259457908",
"s112039878"
] |
u316603606 | p03697 | python | s609430540 | s151392743 | 28 | 25 | 9,096 | 9,140 | Accepted | Accepted | 10.71 | a,b = (int(x) for x in input().split())
if a+b < 10:
print((a+b))
else:
print ('error')
| A,B = list(map (int, input (). split ()))
if A+B>=10:
print ('error')
else:
print((A+B)) | 5 | 5 | 95 | 89 | a, b = (int(x) for x in input().split())
if a + b < 10:
print((a + b))
else:
print("error")
| A, B = list(map(int, input().split()))
if A + B >= 10:
print("error")
else:
print((A + B))
| false | 0 | [
"-a, b = (int(x) for x in input().split())",
"-if a + b < 10:",
"- print((a + b))",
"+A, B = list(map(int, input().split()))",
"+if A + B >= 10:",
"+ print(\"error\")",
"- print(\"error\")",
"+ print((A + B))"
] | false | 0.078507 | 0.070957 | 1.106402 | [
"s609430540",
"s151392743"
] |
u576917603 | p03779 | python | s727737709 | s265629103 | 31 | 25 | 2,940 | 2,940 | Accepted | Accepted | 19.35 | x=int(eval(input()))
a=0
i=1
while a<x:
a+=i
if a>=x:
print(i)
exit()
i+=1 | x=int(eval(input()))
a=0
for i in range(1,10**9):
a+=i
if a>=x:
print(i)
exit() | 9 | 7 | 104 | 103 | x = int(eval(input()))
a = 0
i = 1
while a < x:
a += i
if a >= x:
print(i)
exit()
i += 1
| x = int(eval(input()))
a = 0
for i in range(1, 10**9):
a += i
if a >= x:
print(i)
exit()
| false | 22.222222 | [
"-i = 1",
"-while a < x:",
"+for i in range(1, 10**9):",
"- i += 1"
] | false | 0.043708 | 0.042386 | 1.031206 | [
"s727737709",
"s265629103"
] |
u633068244 | p00613 | python | s247313480 | s127760948 | 40 | 30 | 4,300 | 4,304 | Accepted | Accepted | 25 | while 1:
k = eval(input()) - 1
if not k+1: break
print(sum(map(int,input().split()))/k) | while 1:
k=eval(input())
if not k:break
print(sum(map(int, input().split()))/(k-1)) | 4 | 4 | 93 | 89 | while 1:
k = eval(input()) - 1
if not k + 1:
break
print(sum(map(int, input().split())) / k)
| while 1:
k = eval(input())
if not k:
break
print(sum(map(int, input().split())) / (k - 1))
| false | 0 | [
"- k = eval(input()) - 1",
"- if not k + 1:",
"+ k = eval(input())",
"+ if not k:",
"- print(sum(map(int, input().split())) / k)",
"+ print(sum(map(int, input().split())) / (k - 1))"
] | false | 0.038968 | 0.042712 | 0.912329 | [
"s247313480",
"s127760948"
] |
u223646582 | p03575 | python | s836400742 | s946598727 | 132 | 19 | 3,572 | 3,064 | Accepted | Accepted | 85.61 | import copy
N,M=list(map(int,input().split()))
l_2d = [[0] * N for i in range(N)]
edges=[]
def dfs(i):
l_visit[i-1]=1
for j in range(1,N+1):
if l_2d_temp[i-1][j-1]==1 and l_visit[j-1]==0:
dfs(j)
return
for _ in range(M):
i,j=list(map(int,input().split()))
edges.append([i,j])
l_2d[i-1][j-1]=1
l_2d[j-1][i-1]=1
ans=0
for edge in edges:
i,j=edge
l_2d_temp=copy.deepcopy(l_2d)
l_2d_temp[i-1][j-1]=0
l_2d_temp[j-1][i-1]=0
l_visit=[0]*N
dfs(1)
if 0 in l_visit:
ans+=1
print(ans) | N, M = list(map(int, input().split()))
R = []
G = {k: [] for k in range(N)} # 0-indexed
for _ in range(M):
a, b = list(map(int, input().split()))
G[a-1].append(b-1)
G[b-1].append(a-1)
R.append((a-1, b-1))
def dfs(p, i, arrived):
for n in G[p]:
if arrived[n] is False and tuple(sorted((p, n))) != R[i]:
arrived[n] = True
dfs(n, i, arrived)
ans = 0
for i in range(M):
arrived = [False]*N
arrived[0] = True
dfs(0, i, arrived)
if not all(arrived):
ans += 1
print(ans)
| 33 | 26 | 588 | 559 | import copy
N, M = list(map(int, input().split()))
l_2d = [[0] * N for i in range(N)]
edges = []
def dfs(i):
l_visit[i - 1] = 1
for j in range(1, N + 1):
if l_2d_temp[i - 1][j - 1] == 1 and l_visit[j - 1] == 0:
dfs(j)
return
for _ in range(M):
i, j = list(map(int, input().split()))
edges.append([i, j])
l_2d[i - 1][j - 1] = 1
l_2d[j - 1][i - 1] = 1
ans = 0
for edge in edges:
i, j = edge
l_2d_temp = copy.deepcopy(l_2d)
l_2d_temp[i - 1][j - 1] = 0
l_2d_temp[j - 1][i - 1] = 0
l_visit = [0] * N
dfs(1)
if 0 in l_visit:
ans += 1
print(ans)
| N, M = list(map(int, input().split()))
R = []
G = {k: [] for k in range(N)} # 0-indexed
for _ in range(M):
a, b = list(map(int, input().split()))
G[a - 1].append(b - 1)
G[b - 1].append(a - 1)
R.append((a - 1, b - 1))
def dfs(p, i, arrived):
for n in G[p]:
if arrived[n] is False and tuple(sorted((p, n))) != R[i]:
arrived[n] = True
dfs(n, i, arrived)
ans = 0
for i in range(M):
arrived = [False] * N
arrived[0] = True
dfs(0, i, arrived)
if not all(arrived):
ans += 1
print(ans)
| false | 21.212121 | [
"-import copy",
"-",
"-l_2d = [[0] * N for i in range(N)]",
"-edges = []",
"+R = []",
"+G = {k: [] for k in range(N)} # 0-indexed",
"+for _ in range(M):",
"+ a, b = list(map(int, input().split()))",
"+ G[a - 1].append(b - 1)",
"+ G[b - 1].append(a - 1)",
"+ R.append((a - 1, b - 1))",
"-def dfs(i):",
"- l_visit[i - 1] = 1",
"- for j in range(1, N + 1):",
"- if l_2d_temp[i - 1][j - 1] == 1 and l_visit[j - 1] == 0:",
"- dfs(j)",
"- return",
"+def dfs(p, i, arrived):",
"+ for n in G[p]:",
"+ if arrived[n] is False and tuple(sorted((p, n))) != R[i]:",
"+ arrived[n] = True",
"+ dfs(n, i, arrived)",
"-for _ in range(M):",
"- i, j = list(map(int, input().split()))",
"- edges.append([i, j])",
"- l_2d[i - 1][j - 1] = 1",
"- l_2d[j - 1][i - 1] = 1",
"-for edge in edges:",
"- i, j = edge",
"- l_2d_temp = copy.deepcopy(l_2d)",
"- l_2d_temp[i - 1][j - 1] = 0",
"- l_2d_temp[j - 1][i - 1] = 0",
"- l_visit = [0] * N",
"- dfs(1)",
"- if 0 in l_visit:",
"+for i in range(M):",
"+ arrived = [False] * N",
"+ arrived[0] = True",
"+ dfs(0, i, arrived)",
"+ if not all(arrived):"
] | false | 0.039783 | 0.047093 | 0.844766 | [
"s836400742",
"s946598727"
] |
u709079466 | p02819 | python | s138199047 | s360394541 | 29 | 24 | 2,940 | 2,940 | Accepted | Accepted | 17.24 | x = int(eval(input()))
ok = False
while ok == False:
ok = True
for i in range(2, x):
if x%i == 0:
ok = False
x += 1
#print("####")
break
if ok == True:
print(x)
break
| x = int(eval(input()))
ok = False
while ok == False:
ok = True
for i in range(2, int(x/2)):
if x%i == 0:
ok = False
x += 1
#print("####")
break
if ok == True:
print(x)
break
| 14 | 14 | 259 | 266 | x = int(eval(input()))
ok = False
while ok == False:
ok = True
for i in range(2, x):
if x % i == 0:
ok = False
x += 1
# print("####")
break
if ok == True:
print(x)
break
| x = int(eval(input()))
ok = False
while ok == False:
ok = True
for i in range(2, int(x / 2)):
if x % i == 0:
ok = False
x += 1
# print("####")
break
if ok == True:
print(x)
break
| false | 0 | [
"- for i in range(2, x):",
"+ for i in range(2, int(x / 2)):"
] | false | 0.044466 | 0.103507 | 0.429592 | [
"s138199047",
"s360394541"
] |
u098012509 | p03266 | python | s435842750 | s619194378 | 20 | 18 | 3,316 | 2,940 | Accepted | Accepted | 10 | import sys
input = sys.stdin.readline
def main():
N, K = [int(x) for x in input().split()]
ans = 0
if K & 1:
print(((N // K) ** 3))
else:
ans += (N // K) ** 3
ans += ((N + K // 2) // K) ** 3
print(ans)
if __name__ == '__main__':
main()
| N, K = [int(x) for x in input().split()]
ans = 0
ans += (N // K) ** 3
if K % 2 == 0:
ans += ((N - K // 2) // K + 1) ** 3
print(ans)
| 19 | 13 | 310 | 155 | import sys
input = sys.stdin.readline
def main():
N, K = [int(x) for x in input().split()]
ans = 0
if K & 1:
print(((N // K) ** 3))
else:
ans += (N // K) ** 3
ans += ((N + K // 2) // K) ** 3
print(ans)
if __name__ == "__main__":
main()
| N, K = [int(x) for x in input().split()]
ans = 0
ans += (N // K) ** 3
if K % 2 == 0:
ans += ((N - K // 2) // K + 1) ** 3
print(ans)
| false | 31.578947 | [
"-import sys",
"-",
"-input = sys.stdin.readline",
"-",
"-",
"-def main():",
"- N, K = [int(x) for x in input().split()]",
"- ans = 0",
"- if K & 1:",
"- print(((N // K) ** 3))",
"- else:",
"- ans += (N // K) ** 3",
"- ans += ((N + K // 2) // K) ** 3",
"- print(ans)",
"-",
"-",
"-if __name__ == \"__main__\":",
"- main()",
"+N, K = [int(x) for x in input().split()]",
"+ans = 0",
"+ans += (N // K) ** 3",
"+if K % 2 == 0:",
"+ ans += ((N - K // 2) // K + 1) ** 3",
"+print(ans)"
] | false | 0.041167 | 0.040256 | 1.022633 | [
"s435842750",
"s619194378"
] |
u809819902 | p02675 | python | s456009511 | s661880233 | 30 | 26 | 9,044 | 9,048 | Accepted | Accepted | 13.33 | x = eval(input())
if x[-1] == "0" or x[-1] == "1" or x[-1]== "6" or x[-1]=="8":
print("pon")
elif x[-1] == "3":
print("bon")
else:
print("hon") | n=eval(input())
x=int(n[-1])
if x in [2,4,5,7,9]:print("hon")
elif x in [0,1,6,8]:print("pon")
else :print("bon")
| 7 | 5 | 155 | 112 | x = eval(input())
if x[-1] == "0" or x[-1] == "1" or x[-1] == "6" or x[-1] == "8":
print("pon")
elif x[-1] == "3":
print("bon")
else:
print("hon")
| n = eval(input())
x = int(n[-1])
if x in [2, 4, 5, 7, 9]:
print("hon")
elif x in [0, 1, 6, 8]:
print("pon")
else:
print("bon")
| false | 28.571429 | [
"-x = eval(input())",
"-if x[-1] == \"0\" or x[-1] == \"1\" or x[-1] == \"6\" or x[-1] == \"8\":",
"+n = eval(input())",
"+x = int(n[-1])",
"+if x in [2, 4, 5, 7, 9]:",
"+ print(\"hon\")",
"+elif x in [0, 1, 6, 8]:",
"-elif x[-1] == \"3\":",
"+else:",
"-else:",
"- print(\"hon\")"
] | false | 0.035891 | 0.057969 | 0.61914 | [
"s456009511",
"s661880233"
] |
u497952650 | p03127 | python | s021566968 | s502889659 | 70 | 62 | 15,020 | 20,516 | Accepted | Accepted | 11.43 | N = int(eval(input()))
A = list(map(int,input().split()))
def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
gcd_a = A[0]
for i in A:
gcd_a = gcd(gcd_a,i)
print(gcd_a) | from math import gcd
N = int(eval(input()))
A = list(map(int,input().split()))
g = A[0]
for i in A:
g = gcd(g,i)
print(g)
| 14 | 11 | 192 | 134 | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
gcd_a = A[0]
for i in A:
gcd_a = gcd(gcd_a, i)
print(gcd_a)
| from math import gcd
N = int(eval(input()))
A = list(map(int, input().split()))
g = A[0]
for i in A:
g = gcd(g, i)
print(g)
| false | 21.428571 | [
"+from math import gcd",
"+",
"-",
"-",
"-def gcd(a, b):",
"- while b != 0:",
"- a, b = b, a % b",
"- return a",
"-",
"-",
"-gcd_a = A[0]",
"+g = A[0]",
"- gcd_a = gcd(gcd_a, i)",
"-print(gcd_a)",
"+ g = gcd(g, i)",
"+print(g)"
] | false | 0.039143 | 0.044711 | 0.875469 | [
"s021566968",
"s502889659"
] |
u342869120 | p02768 | python | s835195891 | s112845977 | 384 | 184 | 108,236 | 38,512 | Accepted | Accepted | 52.08 | def cmb(n, r):
if n - r < r:
r = n - r
if r == 0:
return 1
if r == 1:
return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2, r+1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for k in range(p-1, r, p):
numerator[k - offset] /= pivot
denominator[k] /= pivot
result = 1
for k in range(r):
if numerator[k] > 1:
result *= int(numerator[k])
result %= M
return result
def pow(x, n):
ans = 1
while(n > 0):
if(bin(n & 1) == bin(1)):
ans = (ans*x) % M
x = (x*x) % M
n = n >> 1 # ビットシフト
return ans
N, a, b = list(map(int, input().split()))
M = 10**9+7
print(((pow(2, N) - cmb(N, a)-cmb(N, b)-1) % M))
| def cmb(n, r, mod):
p, q = 1, 1
for i in range(r):
p *= n - i
p %= mod
q *= i + 1
q %= mod
# 1/q!の逆元をかける(= q! ^ (mod-2) % mod)
return p * pow(q, mod - 2, mod)
N, a, b = list(map(int, input().split()))
MOD = 10**9+7
print(((pow(2, N, MOD) - cmb(N, a, MOD)-cmb(N, b, MOD)-1) % MOD))
| 42 | 15 | 922 | 338 | def cmb(n, r):
if n - r < r:
r = n - r
if r == 0:
return 1
if r == 1:
return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2, r + 1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for k in range(p - 1, r, p):
numerator[k - offset] /= pivot
denominator[k] /= pivot
result = 1
for k in range(r):
if numerator[k] > 1:
result *= int(numerator[k])
result %= M
return result
def pow(x, n):
ans = 1
while n > 0:
if bin(n & 1) == bin(1):
ans = (ans * x) % M
x = (x * x) % M
n = n >> 1 # ビットシフト
return ans
N, a, b = list(map(int, input().split()))
M = 10**9 + 7
print(((pow(2, N) - cmb(N, a) - cmb(N, b) - 1) % M))
| def cmb(n, r, mod):
p, q = 1, 1
for i in range(r):
p *= n - i
p %= mod
q *= i + 1
q %= mod
# 1/q!の逆元をかける(= q! ^ (mod-2) % mod)
return p * pow(q, mod - 2, mod)
N, a, b = list(map(int, input().split()))
MOD = 10**9 + 7
print(((pow(2, N, MOD) - cmb(N, a, MOD) - cmb(N, b, MOD) - 1) % MOD))
| false | 64.285714 | [
"-def cmb(n, r):",
"- if n - r < r:",
"- r = n - r",
"- if r == 0:",
"- return 1",
"- if r == 1:",
"- return n",
"- numerator = [n - r + k + 1 for k in range(r)]",
"- denominator = [k + 1 for k in range(r)]",
"- for p in range(2, r + 1):",
"- pivot = denominator[p - 1]",
"- if pivot > 1:",
"- offset = (n - r) % p",
"- for k in range(p - 1, r, p):",
"- numerator[k - offset] /= pivot",
"- denominator[k] /= pivot",
"- result = 1",
"- for k in range(r):",
"- if numerator[k] > 1:",
"- result *= int(numerator[k])",
"- result %= M",
"- return result",
"-",
"-",
"-def pow(x, n):",
"- ans = 1",
"- while n > 0:",
"- if bin(n & 1) == bin(1):",
"- ans = (ans * x) % M",
"- x = (x * x) % M",
"- n = n >> 1 # ビットシフト",
"- return ans",
"+def cmb(n, r, mod):",
"+ p, q = 1, 1",
"+ for i in range(r):",
"+ p *= n - i",
"+ p %= mod",
"+ q *= i + 1",
"+ q %= mod",
"+ # 1/q!の逆元をかける(= q! ^ (mod-2) % mod)",
"+ return p * pow(q, mod - 2, mod)",
"-M = 10**9 + 7",
"-print(((pow(2, N) - cmb(N, a) - cmb(N, b) - 1) % M))",
"+MOD = 10**9 + 7",
"+print(((pow(2, N, MOD) - cmb(N, a, MOD) - cmb(N, b, MOD) - 1) % MOD))"
] | false | 0.385149 | 0.126547 | 3.043532 | [
"s835195891",
"s112845977"
] |
u392029857 | p03610 | python | s957822363 | s500182352 | 42 | 18 | 3,188 | 3,188 | Accepted | Accepted | 57.14 | s = eval(input())
t = ''
for i in range(len(s)):
if ( (i + 1) % 2 ) != 0:
t += s[i]
print(t) | s = eval(input())
print((s[0::2])) | 6 | 2 | 103 | 27 | s = eval(input())
t = ""
for i in range(len(s)):
if ((i + 1) % 2) != 0:
t += s[i]
print(t)
| s = eval(input())
print((s[0::2]))
| false | 66.666667 | [
"-t = \"\"",
"-for i in range(len(s)):",
"- if ((i + 1) % 2) != 0:",
"- t += s[i]",
"-print(t)",
"+print((s[0::2]))"
] | false | 0.094356 | 0.036743 | 2.568027 | [
"s957822363",
"s500182352"
] |
u229156891 | p03029 | python | s650552719 | s991279670 | 169 | 17 | 38,256 | 2,940 | Accepted | Accepted | 89.94 | A, P = list(map(int, input().split()))
P = A * 3 + P
print((P // 2)) | A, P = list(map(int, input().split()))
print(((A * 3 + P) // 2)) | 3 | 3 | 62 | 59 | A, P = list(map(int, input().split()))
P = A * 3 + P
print((P // 2))
| A, P = list(map(int, input().split()))
print(((A * 3 + P) // 2))
| false | 0 | [
"-P = A * 3 + P",
"-print((P // 2))",
"+print(((A * 3 + P) // 2))"
] | false | 0.118672 | 0.043086 | 2.754339 | [
"s650552719",
"s991279670"
] |
u098968285 | p03013 | python | s382595756 | s646533212 | 488 | 188 | 46,680 | 7,668 | Accepted | Accepted | 61.48 | def makelist(n, m):
return [[0 for _ in range(m)] for _ in range(n)]
MOD = int(1e9) + 7
N, M = list(map(int, input().split()))
a = [True]*(N+1)
for i in range(1, M+1):
n = int(eval(input()))
a[n] = False
##
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
if a[i]:
if i == 1:
dp[i] = dp[i-1]
else:
dp[i] = (dp[i-1] + dp[i-2]) % MOD
print((dp[-1]))
| MOD = int(1e9) + 7
N, M = list(map(int, input().split()))
a = [True]*(N+1)
for _ in range(1, M+1):
n = int(eval(input()))
a[n] = False
##
dp = [0]*(N+1)
dp[0] = 1
for i in range(1, N+1):
if a[i]:
if i == 1:
dp[i] = dp[i-1]
else:
dp[i] = (dp[i-1] + dp[i-2]) % MOD
print((dp[-1]))
| 22 | 19 | 415 | 338 | def makelist(n, m):
return [[0 for _ in range(m)] for _ in range(n)]
MOD = int(1e9) + 7
N, M = list(map(int, input().split()))
a = [True] * (N + 1)
for i in range(1, M + 1):
n = int(eval(input()))
a[n] = False
##
dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
if a[i]:
if i == 1:
dp[i] = dp[i - 1]
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
print((dp[-1]))
| MOD = int(1e9) + 7
N, M = list(map(int, input().split()))
a = [True] * (N + 1)
for _ in range(1, M + 1):
n = int(eval(input()))
a[n] = False
##
dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
if a[i]:
if i == 1:
dp[i] = dp[i - 1]
else:
dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
print((dp[-1]))
| false | 13.636364 | [
"-def makelist(n, m):",
"- return [[0 for _ in range(m)] for _ in range(n)]",
"-",
"-",
"-for i in range(1, M + 1):",
"+for _ in range(1, M + 1):"
] | false | 0.075656 | 0.04305 | 1.757415 | [
"s382595756",
"s646533212"
] |
u156815136 | p03427 | python | s467902884 | s806022277 | 44 | 38 | 5,404 | 10,416 | Accepted | Accepted | 13.64 | from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int,input().split()))
def main():
n = eval(input())
if len(n) == 1:
print(n)
exit()
allnine = True
for i in range(1,len(n)):
if n[i] == '9':
pass
else:
allnine = False
if n[0] == '9' and allnine:
print((9 * len(n)))
exit()
if n[0] == '1' and allnine:
print((1 + (len(n)-1) * 9))
exit()
if n[0] != '1' and allnine:
print((int(n[0]) + (len(n)-1) * 9))
exit()
print((int(n[0]) + (len(n)-1) * 9 - 1))
if __name__ == '__main__':
main()
| #from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
return list(map(int,input().split()))
def I():
return int(eval(input()))
n = eval(input())
if len(n) == 1:
print(n)
exit()
allnine = True
for i in range(1, len(n)):
if n[i] == '9':
pass
else:
allnine = False
if n[0] == '9' and allnine:
print((9 * len(n)))
exit()
if n[0] == '1' and allnine:
print((1 + (len(n)-1) * 9))
exit()
if n[0] != '1' and allnine:
print((int(n[0]) + (len(n)-1) * 9))
exit()
print((int(n[0]) + (len(n)-1) * 9 - 1))
| 48 | 49 | 1,106 | 1,148 | from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
def readInts():
return list(map(int, input().split()))
def main():
n = eval(input())
if len(n) == 1:
print(n)
exit()
allnine = True
for i in range(1, len(n)):
if n[i] == "9":
pass
else:
allnine = False
if n[0] == "9" and allnine:
print((9 * len(n)))
exit()
if n[0] == "1" and allnine:
print((1 + (len(n) - 1) * 9))
exit()
if n[0] != "1" and allnine:
print((int(n[0]) + (len(n) - 1) * 9))
exit()
print((int(n[0]) + (len(n) - 1) * 9 - 1))
if __name__ == "__main__":
main()
| # from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations, permutations, accumulate # (string,3) 3回
# from collections import deque
from collections import deque, defaultdict, Counter
import decimal
import re
# import bisect
#
# d = m - k[i] - k[j]
# if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも!!
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
return list(map(int, input().split()))
def I():
return int(eval(input()))
n = eval(input())
if len(n) == 1:
print(n)
exit()
allnine = True
for i in range(1, len(n)):
if n[i] == "9":
pass
else:
allnine = False
if n[0] == "9" and allnine:
print((9 * len(n)))
exit()
if n[0] == "1" and allnine:
print((1 + (len(n) - 1) * 9))
exit()
if n[0] != "1" and allnine:
print((int(n[0]) + (len(n) - 1) * 9))
exit()
print((int(n[0]) + (len(n) - 1) * 9 - 1))
| false | 2.040816 | [
"-from statistics import median",
"-",
"+# from statistics import median",
"-from itertools import combinations # (string,3) 3回",
"-from collections import deque",
"-from collections import defaultdict",
"-import bisect",
"+from itertools import combinations, permutations, accumulate # (string,3) 3回",
"+# from collections import deque",
"+from collections import deque, defaultdict, Counter",
"+import decimal",
"+import re",
"+",
"+# import bisect",
"+# my_round_int = lambda x:np.round((x*2 + 1)//2)",
"+# 四捨五入",
"-",
"-",
"+# mod = 9982443453",
"-def main():",
"- n = eval(input())",
"- if len(n) == 1:",
"- print(n)",
"- exit()",
"- allnine = True",
"- for i in range(1, len(n)):",
"- if n[i] == \"9\":",
"- pass",
"- else:",
"- allnine = False",
"- if n[0] == \"9\" and allnine:",
"- print((9 * len(n)))",
"- exit()",
"- if n[0] == \"1\" and allnine:",
"- print((1 + (len(n) - 1) * 9))",
"- exit()",
"- if n[0] != \"1\" and allnine:",
"- print((int(n[0]) + (len(n) - 1) * 9))",
"- exit()",
"- print((int(n[0]) + (len(n) - 1) * 9 - 1))",
"+def I():",
"+ return int(eval(input()))",
"-if __name__ == \"__main__\":",
"- main()",
"+n = eval(input())",
"+if len(n) == 1:",
"+ print(n)",
"+ exit()",
"+allnine = True",
"+for i in range(1, len(n)):",
"+ if n[i] == \"9\":",
"+ pass",
"+ else:",
"+ allnine = False",
"+if n[0] == \"9\" and allnine:",
"+ print((9 * len(n)))",
"+ exit()",
"+if n[0] == \"1\" and allnine:",
"+ print((1 + (len(n) - 1) * 9))",
"+ exit()",
"+if n[0] != \"1\" and allnine:",
"+ print((int(n[0]) + (len(n) - 1) * 9))",
"+ exit()",
"+print((int(n[0]) + (len(n) - 1) * 9 - 1))"
] | false | 0.070093 | 0.085688 | 0.818002 | [
"s467902884",
"s806022277"
] |
u336705996 | p02388 | python | s187290588 | s820110363 | 40 | 20 | 7,684 | 5,576 | Accepted | Accepted | 50 | a = int(eval(input()))
print((a**3)) | x = int(eval(input()))
print((x**3))
| 2 | 3 | 30 | 32 | a = int(eval(input()))
print((a**3))
| x = int(eval(input()))
print((x**3))
| false | 33.333333 | [
"-a = int(eval(input()))",
"-print((a**3))",
"+x = int(eval(input()))",
"+print((x**3))"
] | false | 0.153061 | 0.036125 | 4.237029 | [
"s187290588",
"s820110363"
] |
u860002137 | p03102 | python | s546513250 | s677297259 | 302 | 123 | 21,388 | 27,364 | Accepted | Accepted | 59.27 | import numpy as np
N, M, C = list(map(int, input().split()))
B = np.array(list(map(int, input().split())))
ans = 0
for i in range(N):
tmp = np.dot(np.array(list(map(int, input().split()))), B)
if (tmp.sum() + C) > 0:
ans += 1
print(ans) | import numpy as np
n, m, c = list(map(int, input().split()))
b = np.array(list(map(int, input().split())))
arr = np.array([list(map(int, input().split())) for _ in range(n)])
result = (arr * b).sum(axis=1) + c
print((np.where(result > 0)[0].shape[0])) | 12 | 8 | 260 | 252 | import numpy as np
N, M, C = list(map(int, input().split()))
B = np.array(list(map(int, input().split())))
ans = 0
for i in range(N):
tmp = np.dot(np.array(list(map(int, input().split()))), B)
if (tmp.sum() + C) > 0:
ans += 1
print(ans)
| import numpy as np
n, m, c = list(map(int, input().split()))
b = np.array(list(map(int, input().split())))
arr = np.array([list(map(int, input().split())) for _ in range(n)])
result = (arr * b).sum(axis=1) + c
print((np.where(result > 0)[0].shape[0]))
| false | 33.333333 | [
"-N, M, C = list(map(int, input().split()))",
"-B = np.array(list(map(int, input().split())))",
"-ans = 0",
"-for i in range(N):",
"- tmp = np.dot(np.array(list(map(int, input().split()))), B)",
"- if (tmp.sum() + C) > 0:",
"- ans += 1",
"-print(ans)",
"+n, m, c = list(map(int, input().split()))",
"+b = np.array(list(map(int, input().split())))",
"+arr = np.array([list(map(int, input().split())) for _ in range(n)])",
"+result = (arr * b).sum(axis=1) + c",
"+print((np.where(result > 0)[0].shape[0]))"
] | false | 0.6988 | 0.630706 | 1.107964 | [
"s546513250",
"s677297259"
] |
u188827677 | p02773 | python | s870849039 | s630614874 | 786 | 726 | 42,332 | 43,908 | Accepted | Accepted | 7.63 | n = int(eval(input()))
s = {}
for i in range(n):
a = eval(input())
if a in s:
s[a] += 1
else:
s[a] = 1
max = max(s.values())
s = sorted(s.items())
for i in s:
if i[1] == max:
print((i[0]))
| n = int(eval(input()))
a = {}
b = []
for i in range(n):
s = eval(input())
b.append(s)
if s in a:
a[s] += 1
else:
a[s] = 1
b = sorted(list(set(b)))
p = max(a.values())
for i in b:
if a[i] == p:
print(i) | 15 | 18 | 211 | 231 | n = int(eval(input()))
s = {}
for i in range(n):
a = eval(input())
if a in s:
s[a] += 1
else:
s[a] = 1
max = max(s.values())
s = sorted(s.items())
for i in s:
if i[1] == max:
print((i[0]))
| n = int(eval(input()))
a = {}
b = []
for i in range(n):
s = eval(input())
b.append(s)
if s in a:
a[s] += 1
else:
a[s] = 1
b = sorted(list(set(b)))
p = max(a.values())
for i in b:
if a[i] == p:
print(i)
| false | 16.666667 | [
"-s = {}",
"+a = {}",
"+b = []",
"- a = eval(input())",
"- if a in s:",
"- s[a] += 1",
"+ s = eval(input())",
"+ b.append(s)",
"+ if s in a:",
"+ a[s] += 1",
"- s[a] = 1",
"-max = max(s.values())",
"-s = sorted(s.items())",
"-for i in s:",
"- if i[1] == max:",
"- print((i[0]))",
"+ a[s] = 1",
"+b = sorted(list(set(b)))",
"+p = max(a.values())",
"+for i in b:",
"+ if a[i] == p:",
"+ print(i)"
] | false | 0.047797 | 0.069827 | 0.684507 | [
"s870849039",
"s630614874"
] |
u291373585 | p03448 | python | s189756212 | s564008337 | 54 | 49 | 3,060 | 3,060 | Accepted | Accepted | 9.26 | five_hnd = int(eval(input()))
one_hnd = int(eval(input()))
fifty = int(eval(input()))
target = int(eval(input()))
num = 0
for i in range(five_hnd + 1):
for j in range(one_hnd + 1):
for k in range(fifty + 1):
sum = 500*i + 100*j + 50*k
if (sum) == target :
num +=1
print(num) | five_hund = int(eval(input()))
one_hund = int(eval(input()))
fifty = int(eval(input()))
X = int(eval(input()))
count = 0
for five in range(five_hund + 1):
for one in range(one_hund + 1):
for fif in range(fifty + 1):
if(five * 500 + one * 100 + fif * 50 == X):
count += 1
print(count) | 12 | 12 | 287 | 291 | five_hnd = int(eval(input()))
one_hnd = int(eval(input()))
fifty = int(eval(input()))
target = int(eval(input()))
num = 0
for i in range(five_hnd + 1):
for j in range(one_hnd + 1):
for k in range(fifty + 1):
sum = 500 * i + 100 * j + 50 * k
if (sum) == target:
num += 1
print(num)
| five_hund = int(eval(input()))
one_hund = int(eval(input()))
fifty = int(eval(input()))
X = int(eval(input()))
count = 0
for five in range(five_hund + 1):
for one in range(one_hund + 1):
for fif in range(fifty + 1):
if five * 500 + one * 100 + fif * 50 == X:
count += 1
print(count)
| false | 0 | [
"-five_hnd = int(eval(input()))",
"-one_hnd = int(eval(input()))",
"+five_hund = int(eval(input()))",
"+one_hund = int(eval(input()))",
"-target = int(eval(input()))",
"-num = 0",
"-for i in range(five_hnd + 1):",
"- for j in range(one_hnd + 1):",
"- for k in range(fifty + 1):",
"- sum = 500 * i + 100 * j + 50 * k",
"- if (sum) == target:",
"- num += 1",
"-print(num)",
"+X = int(eval(input()))",
"+count = 0",
"+for five in range(five_hund + 1):",
"+ for one in range(one_hund + 1):",
"+ for fif in range(fifty + 1):",
"+ if five * 500 + one * 100 + fif * 50 == X:",
"+ count += 1",
"+print(count)"
] | false | 0.118546 | 0.107047 | 1.107416 | [
"s189756212",
"s564008337"
] |
u072053884 | p02280 | python | s302003244 | s860645960 | 40 | 20 | 7,844 | 7,848 | Accepted | Accepted | 50 | class Node:
def __init__(self, num, leftChild, rightChild):
self.id = num
self.parent = -1
self.sibling = -1
self.degree = 0
self.depth = 0
self.height = 0
self.type = 'leaf'
self.leftChild = leftChild
self.rightChild = rightChild
def show_info(self):
print(('node {}:'.format(self.id), 'parent = {},'.format(self.parent),
'sibling = {},'.format(self.sibling),
'degree = {},'.format(self.degree),
'depth = {},'.format(self.depth),
'height = {},'.format(self.height),
'{}'.format(self.type)))
def set_node(i_s):
num, leftChild, rightChild = list(map(int, i_s.split()))
node = Node(num, leftChild, rightChild)
T[num] = node
T[-1] -= (max(0, leftChild) + max(0, rightChild))
def set_attributes(n_i, parent, sibling, depth):
node = T[n_i]
node.parent = parent
node.sibling = sibling
node.depth = depth
if node.leftChild != -1:
node.degree += 1
node.type = 'internal node'
set_attributes(node.leftChild, node.id, node.rightChild, depth + 1)
if node.rightChild != -1:
node.degree += 1
node.type = 'internal node'
set_attributes(node.rightChild, node.id, node.leftChild, depth + 1)
if node.leftChild != -1 and node.rightChild != -1:
node.height = max(T[node.leftChild].height,
T[node.rightChild].height) + 1
elif node.leftChild != -1:
node.height = T[node.leftChild].height + 1
elif node.rightChild != -1:
node.height = T[node.rightChild].height + 1
import sys
n = int(sys.stdin.readline())
T = [None] * n
T.append(int(n * (n - 1) / 2))
for x in sys.stdin.readlines():
set_node(x)
set_attributes(T[-1], -1, -1, 0)
T[T[-1]].type = 'root'
for n in T[:-1]:
n.show_info() | """Binary Trees."""
class Node:
def __init__(self, num, leftChild, rightChild):
self.id = num
self.parent = -1
self.sibling = -1
self.degree = 0
self.depth = 0
self.height = 0
self.type = 'leaf'
self.leftChild = leftChild
self.rightChild = rightChild
def show_info(self):
print(('node {}:'.format(self.id), 'parent = {},'.format(self.parent),
'sibling = {},'.format(self.sibling),
'degree = {},'.format(self.degree),
'depth = {},'.format(self.depth),
'height = {},'.format(self.height),
'{}'.format(self.type)))
def set_attributes(n_i, parent, sibling, depth):
if n_i == -1:
return -1
node = T[n_i]
lc = node.leftChild
rc = node.rightChild
node.parent = parent
node.sibling = sibling
node.depth = depth
node.degree = (node.leftChild != -1) + (node.rightChild != -1)
if lc != -1 or rc != -1:
node.type = 'internal node'
node.height = max(set_attributes(lc, n_i, rc, depth + 1),
set_attributes(rc, n_i, lc, depth + 1)) + 1
return node.height
import sys
n = int(sys.stdin.readline())
T = [None] * n
rt_n = int(n * (n - 1) / 2)
for x in sys.stdin.readlines():
num, leftChild, rightChild = list(map(int, x.split()))
node = Node(num, leftChild, rightChild)
T[num] = node
rt_n -= (max(0, leftChild) + max(0, rightChild))
set_attributes(rt_n, -1, -1, 0)
T[rt_n].type = 'root'
for n in T:
n.show_info() | 68 | 61 | 1,964 | 1,633 | class Node:
def __init__(self, num, leftChild, rightChild):
self.id = num
self.parent = -1
self.sibling = -1
self.degree = 0
self.depth = 0
self.height = 0
self.type = "leaf"
self.leftChild = leftChild
self.rightChild = rightChild
def show_info(self):
print(
(
"node {}:".format(self.id),
"parent = {},".format(self.parent),
"sibling = {},".format(self.sibling),
"degree = {},".format(self.degree),
"depth = {},".format(self.depth),
"height = {},".format(self.height),
"{}".format(self.type),
)
)
def set_node(i_s):
num, leftChild, rightChild = list(map(int, i_s.split()))
node = Node(num, leftChild, rightChild)
T[num] = node
T[-1] -= max(0, leftChild) + max(0, rightChild)
def set_attributes(n_i, parent, sibling, depth):
node = T[n_i]
node.parent = parent
node.sibling = sibling
node.depth = depth
if node.leftChild != -1:
node.degree += 1
node.type = "internal node"
set_attributes(node.leftChild, node.id, node.rightChild, depth + 1)
if node.rightChild != -1:
node.degree += 1
node.type = "internal node"
set_attributes(node.rightChild, node.id, node.leftChild, depth + 1)
if node.leftChild != -1 and node.rightChild != -1:
node.height = max(T[node.leftChild].height, T[node.rightChild].height) + 1
elif node.leftChild != -1:
node.height = T[node.leftChild].height + 1
elif node.rightChild != -1:
node.height = T[node.rightChild].height + 1
import sys
n = int(sys.stdin.readline())
T = [None] * n
T.append(int(n * (n - 1) / 2))
for x in sys.stdin.readlines():
set_node(x)
set_attributes(T[-1], -1, -1, 0)
T[T[-1]].type = "root"
for n in T[:-1]:
n.show_info()
| """Binary Trees."""
class Node:
def __init__(self, num, leftChild, rightChild):
self.id = num
self.parent = -1
self.sibling = -1
self.degree = 0
self.depth = 0
self.height = 0
self.type = "leaf"
self.leftChild = leftChild
self.rightChild = rightChild
def show_info(self):
print(
(
"node {}:".format(self.id),
"parent = {},".format(self.parent),
"sibling = {},".format(self.sibling),
"degree = {},".format(self.degree),
"depth = {},".format(self.depth),
"height = {},".format(self.height),
"{}".format(self.type),
)
)
def set_attributes(n_i, parent, sibling, depth):
if n_i == -1:
return -1
node = T[n_i]
lc = node.leftChild
rc = node.rightChild
node.parent = parent
node.sibling = sibling
node.depth = depth
node.degree = (node.leftChild != -1) + (node.rightChild != -1)
if lc != -1 or rc != -1:
node.type = "internal node"
node.height = (
max(
set_attributes(lc, n_i, rc, depth + 1),
set_attributes(rc, n_i, lc, depth + 1),
)
+ 1
)
return node.height
import sys
n = int(sys.stdin.readline())
T = [None] * n
rt_n = int(n * (n - 1) / 2)
for x in sys.stdin.readlines():
num, leftChild, rightChild = list(map(int, x.split()))
node = Node(num, leftChild, rightChild)
T[num] = node
rt_n -= max(0, leftChild) + max(0, rightChild)
set_attributes(rt_n, -1, -1, 0)
T[rt_n].type = "root"
for n in T:
n.show_info()
| false | 10.294118 | [
"+\"\"\"Binary Trees.\"\"\"",
"+",
"+",
"-def set_node(i_s):",
"- num, leftChild, rightChild = list(map(int, i_s.split()))",
"- node = Node(num, leftChild, rightChild)",
"- T[num] = node",
"- T[-1] -= max(0, leftChild) + max(0, rightChild)",
"-",
"-",
"+ if n_i == -1:",
"+ return -1",
"+ lc = node.leftChild",
"+ rc = node.rightChild",
"- if node.leftChild != -1:",
"- node.degree += 1",
"+ node.degree = (node.leftChild != -1) + (node.rightChild != -1)",
"+ if lc != -1 or rc != -1:",
"- set_attributes(node.leftChild, node.id, node.rightChild, depth + 1)",
"- if node.rightChild != -1:",
"- node.degree += 1",
"- node.type = \"internal node\"",
"- set_attributes(node.rightChild, node.id, node.leftChild, depth + 1)",
"- if node.leftChild != -1 and node.rightChild != -1:",
"- node.height = max(T[node.leftChild].height, T[node.rightChild].height) + 1",
"- elif node.leftChild != -1:",
"- node.height = T[node.leftChild].height + 1",
"- elif node.rightChild != -1:",
"- node.height = T[node.rightChild].height + 1",
"+ node.height = (",
"+ max(",
"+ set_attributes(lc, n_i, rc, depth + 1),",
"+ set_attributes(rc, n_i, lc, depth + 1),",
"+ )",
"+ + 1",
"+ )",
"+ return node.height",
"-T.append(int(n * (n - 1) / 2))",
"+rt_n = int(n * (n - 1) / 2)",
"- set_node(x)",
"-set_attributes(T[-1], -1, -1, 0)",
"-T[T[-1]].type = \"root\"",
"-for n in T[:-1]:",
"+ num, leftChild, rightChild = list(map(int, x.split()))",
"+ node = Node(num, leftChild, rightChild)",
"+ T[num] = node",
"+ rt_n -= max(0, leftChild) + max(0, rightChild)",
"+set_attributes(rt_n, -1, -1, 0)",
"+T[rt_n].type = \"root\"",
"+for n in T:"
] | false | 0.049417 | 0.049846 | 0.991397 | [
"s302003244",
"s860645960"
] |
u737758066 | p02708 | python | s494276408 | s589317847 | 384 | 121 | 79,776 | 9,084 | Accepted | Accepted | 68.49 |
n, k = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(k, n+2):
ans += int(n*(n+1)/2 - (n-i)*(n-i+1)/2 - (i-1)*i/2 + 1)
print((ans % mod))
'''
n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
a = 0.5*i*(i-1)
b = 0.5*n*(n+1)-0.5*(n-i)*(n-i+1)
ans += int(b-a+1)
print(ans % (10**9+7))
'''
| n, k = list(map(int, input().split()))
ans = 0
for i in range(k, n+2):
ma = (n+n-i+1)*i//2
mi = (i-1)*i//2
# print(ma, mi)
add = ma-mi+1
ans += add
print((int(ans % (10**9+7))))
| 19 | 10 | 354 | 200 | n, k = list(map(int, input().split()))
ans = 0
mod = 10**9 + 7
for i in range(k, n + 2):
ans += int(n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - (i - 1) * i / 2 + 1)
print((ans % mod))
"""
n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
a = 0.5*i*(i-1)
b = 0.5*n*(n+1)-0.5*(n-i)*(n-i+1)
ans += int(b-a+1)
print(ans % (10**9+7))
"""
| n, k = list(map(int, input().split()))
ans = 0
for i in range(k, n + 2):
ma = (n + n - i + 1) * i // 2
mi = (i - 1) * i // 2
# print(ma, mi)
add = ma - mi + 1
ans += add
print((int(ans % (10**9 + 7))))
| false | 47.368421 | [
"-mod = 10**9 + 7",
"- ans += int(n * (n + 1) / 2 - (n - i) * (n - i + 1) / 2 - (i - 1) * i / 2 + 1)",
"-print((ans % mod))",
"-\"\"\"",
"-n, k = map(int, input().split())",
"-ans = 0",
"-for i in range(k, n+2):",
"- a = 0.5*i*(i-1)",
"- b = 0.5*n*(n+1)-0.5*(n-i)*(n-i+1)",
"- ans += int(b-a+1)",
"-print(ans % (10**9+7))",
"-\"\"\"",
"+ ma = (n + n - i + 1) * i // 2",
"+ mi = (i - 1) * i // 2",
"+ # print(ma, mi)",
"+ add = ma - mi + 1",
"+ ans += add",
"+print((int(ans % (10**9 + 7))))"
] | false | 0.052636 | 0.071695 | 0.734165 | [
"s494276408",
"s589317847"
] |
u301624971 | p02813 | python | s547059064 | s222991735 | 33 | 27 | 8,052 | 3,060 | Accepted | Accepted | 18.18 | import itertools
N = int(eval(input()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis = [i for i in range(1, N+1)]
a = 0
b = 0
ans = list(itertools.permutations(lis))
TP=tuple(P)
TQ=tuple(Q)
for n, i in enumerate(ans):
if(i == TP):
a=n+1
if(b!=0):
break
if(i==TQ):
b=n+1
if(a!=0):
break
print((abs(a-b))) | import itertools
N=int(eval(input()))
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
l=[i for i in range(1,N+1)]
for n,t in enumerate(itertools.permutations(l,N)):
if(t==P):
a=n
if(t==Q):
b=n
print((abs(a-b)))
| 22 | 15 | 401 | 265 | import itertools
N = int(eval(input()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis = [i for i in range(1, N + 1)]
a = 0
b = 0
ans = list(itertools.permutations(lis))
TP = tuple(P)
TQ = tuple(Q)
for n, i in enumerate(ans):
if i == TP:
a = n + 1
if b != 0:
break
if i == TQ:
b = n + 1
if a != 0:
break
print((abs(a - b)))
| import itertools
N = int(eval(input()))
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
l = [i for i in range(1, N + 1)]
for n, t in enumerate(itertools.permutations(l, N)):
if t == P:
a = n
if t == Q:
b = n
print((abs(a - b)))
| false | 31.818182 | [
"-P = list(map(int, input().split()))",
"-Q = list(map(int, input().split()))",
"-lis = [i for i in range(1, N + 1)]",
"-a = 0",
"-b = 0",
"-ans = list(itertools.permutations(lis))",
"-TP = tuple(P)",
"-TQ = tuple(Q)",
"-for n, i in enumerate(ans):",
"- if i == TP:",
"- a = n + 1",
"- if b != 0:",
"- break",
"- if i == TQ:",
"- b = n + 1",
"- if a != 0:",
"- break",
"+P = tuple(map(int, input().split()))",
"+Q = tuple(map(int, input().split()))",
"+l = [i for i in range(1, N + 1)]",
"+for n, t in enumerate(itertools.permutations(l, N)):",
"+ if t == P:",
"+ a = n",
"+ if t == Q:",
"+ b = n"
] | false | 0.041545 | 0.048338 | 0.859454 | [
"s547059064",
"s222991735"
] |
u768896740 | p02682 | python | s158967165 | s671901963 | 22 | 20 | 9,184 | 9,164 | Accepted | Accepted | 9.09 | a,b,c,k =list(map(int, input().split()))
ans = 0
while k > 0:
if a >= k:
ans += k
break
else:
ans += a
k -= a
if b >= k:
break
else:
k -= b
ans -= k
break
print(ans) | a,b,c,k =list(map(int, input().split()))
ans = 0
x = min(k , a)
ans += x
k2 = k - x
x2 = min(k2, b)
k3 = k2 - x2
x3 = min(k3, c)
ans -= k3
print(ans) | 17 | 12 | 248 | 156 | a, b, c, k = list(map(int, input().split()))
ans = 0
while k > 0:
if a >= k:
ans += k
break
else:
ans += a
k -= a
if b >= k:
break
else:
k -= b
ans -= k
break
print(ans)
| a, b, c, k = list(map(int, input().split()))
ans = 0
x = min(k, a)
ans += x
k2 = k - x
x2 = min(k2, b)
k3 = k2 - x2
x3 = min(k3, c)
ans -= k3
print(ans)
| false | 29.411765 | [
"-while k > 0:",
"- if a >= k:",
"- ans += k",
"- break",
"- else:",
"- ans += a",
"- k -= a",
"- if b >= k:",
"- break",
"- else:",
"- k -= b",
"- ans -= k",
"- break",
"+x = min(k, a)",
"+ans += x",
"+k2 = k - x",
"+x2 = min(k2, b)",
"+k3 = k2 - x2",
"+x3 = min(k3, c)",
"+ans -= k3"
] | false | 0.035489 | 0.042733 | 0.830471 | [
"s158967165",
"s671901963"
] |
u896741788 | p02823 | python | s893307458 | s859123949 | 167 | 32 | 38,256 | 9,112 | Accepted | Accepted | 80.84 | n,a,b=list(map(int,input().split()))
if (a-b)%2:
print((min(n-b+1+(b-1-a)//2,a-1+1+(b-a-1)//2)))
else:
print((abs(a-b)//2)) | n,a,b=list(map(int,input().split()))
if b<a:b,a=a,b
ans=float("inf")
if abs(a-b)%2==0:print((abs(a-b)//2))
else:
print((min(n-b+1,a)+abs(b-a-1)//2)) | 5 | 7 | 125 | 149 | n, a, b = list(map(int, input().split()))
if (a - b) % 2:
print((min(n - b + 1 + (b - 1 - a) // 2, a - 1 + 1 + (b - a - 1) // 2)))
else:
print((abs(a - b) // 2))
| n, a, b = list(map(int, input().split()))
if b < a:
b, a = a, b
ans = float("inf")
if abs(a - b) % 2 == 0:
print((abs(a - b) // 2))
else:
print((min(n - b + 1, a) + abs(b - a - 1) // 2))
| false | 28.571429 | [
"-if (a - b) % 2:",
"- print((min(n - b + 1 + (b - 1 - a) // 2, a - 1 + 1 + (b - a - 1) // 2)))",
"+if b < a:",
"+ b, a = a, b",
"+ans = float(\"inf\")",
"+if abs(a - b) % 2 == 0:",
"+ print((abs(a - b) // 2))",
"- print((abs(a - b) // 2))",
"+ print((min(n - b + 1, a) + abs(b - a - 1) // 2))"
] | false | 0.085481 | 0.064107 | 1.333403 | [
"s893307458",
"s859123949"
] |
u655110382 | p03252 | python | s122578169 | s591152321 | 104 | 66 | 6,832 | 6,832 | Accepted | Accepted | 36.54 | S = eval(input())
T = eval(input())
Sd = {}
Sl = []
for c in S:
if c not in Sd:
Sd[c] = len(Sd)
Sl.append(Sd[c])
Td = {}
Tl = []
for c in T:
if c not in Td:
Td[c] = len(Td)
Tl.append(Td[c])
print(('Yes' if Sl == Tl else 'No'))
| def convert(st):
d = {}
lst = []
for ch in st:
if ch not in d:
d[ch] = len(d)
lst.append(d[ch])
return lst
S = eval(input())
T = eval(input())
Sl = convert(S)
Tl = convert(T)
print(('Yes' if Sl == Tl else 'No')) | 18 | 15 | 265 | 257 | S = eval(input())
T = eval(input())
Sd = {}
Sl = []
for c in S:
if c not in Sd:
Sd[c] = len(Sd)
Sl.append(Sd[c])
Td = {}
Tl = []
for c in T:
if c not in Td:
Td[c] = len(Td)
Tl.append(Td[c])
print(("Yes" if Sl == Tl else "No"))
| def convert(st):
d = {}
lst = []
for ch in st:
if ch not in d:
d[ch] = len(d)
lst.append(d[ch])
return lst
S = eval(input())
T = eval(input())
Sl = convert(S)
Tl = convert(T)
print(("Yes" if Sl == Tl else "No"))
| false | 16.666667 | [
"+def convert(st):",
"+ d = {}",
"+ lst = []",
"+ for ch in st:",
"+ if ch not in d:",
"+ d[ch] = len(d)",
"+ lst.append(d[ch])",
"+ return lst",
"+",
"+",
"-Sd = {}",
"-Sl = []",
"-for c in S:",
"- if c not in Sd:",
"- Sd[c] = len(Sd)",
"- Sl.append(Sd[c])",
"-Td = {}",
"-Tl = []",
"-for c in T:",
"- if c not in Td:",
"- Td[c] = len(Td)",
"- Tl.append(Td[c])",
"+Sl = convert(S)",
"+Tl = convert(T)"
] | false | 0.118576 | 0.035495 | 3.340585 | [
"s122578169",
"s591152321"
] |
u729133443 | p02574 | python | s419163760 | s025078001 | 1,634 | 1,169 | 101,212 | 101,708 | Accepted | Accepted | 28.46 | c=[m:=0]*6**8
n,a=open(0)
for a in a.split():c[int(a)]+=1
print((('not','psaeitr'[any([(m:=max(m,sum(c[i::i])))>1for i in range(2,6**8)])::2]+'wise')[m<int(n)],'coprime')) | c=[0]*6**8
n,a=open(0)
for a in a.split():c[int(a)]+=1
m=max(sum(c[i::i])for i in range(2,6**8))
print((('not','psaeitr'[m>1::2]+'wise')[m<int(n)],'coprime')) | 4 | 5 | 172 | 160 | c = [m := 0] * 6**8
n, a = open(0)
for a in a.split():
c[int(a)] += 1
print(
(
(
"not",
"psaeitr"[
any([(m := max(m, sum(c[i::i]))) > 1 for i in range(2, 6**8)]) :: 2
]
+ "wise",
)[m < int(n)],
"coprime",
)
)
| c = [0] * 6**8
n, a = open(0)
for a in a.split():
c[int(a)] += 1
m = max(sum(c[i::i]) for i in range(2, 6**8))
print((("not", "psaeitr"[m > 1 :: 2] + "wise")[m < int(n)], "coprime"))
| false | 20 | [
"-c = [m := 0] * 6**8",
"+c = [0] * 6**8",
"-print(",
"- (",
"- (",
"- \"not\",",
"- \"psaeitr\"[",
"- any([(m := max(m, sum(c[i::i]))) > 1 for i in range(2, 6**8)]) :: 2",
"- ]",
"- + \"wise\",",
"- )[m < int(n)],",
"- \"coprime\",",
"- )",
"-)",
"+m = max(sum(c[i::i]) for i in range(2, 6**8))",
"+print(((\"not\", \"psaeitr\"[m > 1 :: 2] + \"wise\")[m < int(n)], \"coprime\"))"
] | false | 2.827208 | 2.342364 | 1.206989 | [
"s419163760",
"s025078001"
] |
u633068244 | p02417 | python | s621018708 | s578927461 | 30 | 20 | 4,236 | 4,236 | Accepted | Accepted | 33.33 | import sys
az =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sum_az = [0 for x in range(26)]
for x in sys.stdin.read().lower():
for i in range(26):
for j in range(len(x)):
if x[j] == az[i]:
sum_az[i] += 1
for i in range(26):
print(("%s : %d" % (az[i], sum_az[i])))
| import sys
az =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sum_az = [0 for x in range(26)]
for x in sys.stdin.read().lower():
for i in range(26):
if x == az[i]:
sum_az[i] += 1
for i in range(26):
print(("%s : %d" % (az[i], sum_az[i])))
| 14 | 13 | 400 | 356 | import sys
az = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
sum_az = [0 for x in range(26)]
for x in sys.stdin.read().lower():
for i in range(26):
for j in range(len(x)):
if x[j] == az[i]:
sum_az[i] += 1
for i in range(26):
print(("%s : %d" % (az[i], sum_az[i])))
| import sys
az = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
sum_az = [0 for x in range(26)]
for x in sys.stdin.read().lower():
for i in range(26):
if x == az[i]:
sum_az[i] += 1
for i in range(26):
print(("%s : %d" % (az[i], sum_az[i])))
| false | 7.142857 | [
"- for j in range(len(x)):",
"- if x[j] == az[i]:",
"- sum_az[i] += 1",
"+ if x == az[i]:",
"+ sum_az[i] += 1"
] | false | 0.140021 | 0.044051 | 3.178613 | [
"s621018708",
"s578927461"
] |
u731436822 | p03331 | python | s053977946 | s103153040 | 319 | 17 | 3,480 | 3,060 | Accepted | Accepted | 94.67 | N = int(eval(input()))
summ = []
for i in range(1,N//2 + 1):
A = []
B = []
k = N-i
for __ in range(6):
A.append(int(i%10))
B.append(int(k%10))
i /= 10
k /= 10
summ.append(sum(A+B))
print((min(summ))) | N = int(eval(input()))
if N%10 == 0:
print((10))
else:
l = []
for i in range(6):
l.append(int(N%10))
N /= 10
print((sum(l))) | 14 | 10 | 257 | 156 | N = int(eval(input()))
summ = []
for i in range(1, N // 2 + 1):
A = []
B = []
k = N - i
for __ in range(6):
A.append(int(i % 10))
B.append(int(k % 10))
i /= 10
k /= 10
summ.append(sum(A + B))
print((min(summ)))
| N = int(eval(input()))
if N % 10 == 0:
print((10))
else:
l = []
for i in range(6):
l.append(int(N % 10))
N /= 10
print((sum(l)))
| false | 28.571429 | [
"-summ = []",
"-for i in range(1, N // 2 + 1):",
"- A = []",
"- B = []",
"- k = N - i",
"- for __ in range(6):",
"- A.append(int(i % 10))",
"- B.append(int(k % 10))",
"- i /= 10",
"- k /= 10",
"- summ.append(sum(A + B))",
"-print((min(summ)))",
"+if N % 10 == 0:",
"+ print((10))",
"+else:",
"+ l = []",
"+ for i in range(6):",
"+ l.append(int(N % 10))",
"+ N /= 10",
"+ print((sum(l)))"
] | false | 0.225267 | 0.035688 | 6.312036 | [
"s053977946",
"s103153040"
] |
u879870653 | p03805 | python | s499351231 | s228213123 | 34 | 28 | 3,064 | 3,064 | Accepted | Accepted | 17.65 | from itertools import permutations
N,M = list(map(int,input().split()))
Matrix = [[False for i in range(N)] for j in range(N)]
for i in range(M) :
a,b = list(map(int,input().split()))
a -= 1
b -= 1
Matrix[a][b] = True
Matrix[b][a] = True
for i in range(N) :
Matrix[i][i] = True
arange = list(range(2,N+1))
ans = 0
for pm in permutations(arange) :
pm = [1] + list(pm)
for row,col in zip(pm,pm[1:]) :
row -= 1
col -= 1
if not Matrix[row][col] :
break
else :
ans += 1
print(ans)
| from itertools import permutations
N,M = list(map(int,input().split()))
Matrix = [[False for x in range(N)] for y in range(N)]
for i in range(N) :
Matrix[i][i] = True
for i in range(M) :
a,b = list(map(int,input().split()))
a -= 1
b -= 1
Matrix[a][b] = True
Matrix[b][a] = True
arange = permutations(list(range(1,N)))
ans = 0
for i in arange :
pm = [0] + list(i)
for a,b in zip(pm, pm[1:]) :
if not Matrix[a][b] :
break
else :
ans += 1
print(ans)
| 29 | 24 | 578 | 519 | from itertools import permutations
N, M = list(map(int, input().split()))
Matrix = [[False for i in range(N)] for j in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
Matrix[a][b] = True
Matrix[b][a] = True
for i in range(N):
Matrix[i][i] = True
arange = list(range(2, N + 1))
ans = 0
for pm in permutations(arange):
pm = [1] + list(pm)
for row, col in zip(pm, pm[1:]):
row -= 1
col -= 1
if not Matrix[row][col]:
break
else:
ans += 1
print(ans)
| from itertools import permutations
N, M = list(map(int, input().split()))
Matrix = [[False for x in range(N)] for y in range(N)]
for i in range(N):
Matrix[i][i] = True
for i in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
Matrix[a][b] = True
Matrix[b][a] = True
arange = permutations(list(range(1, N)))
ans = 0
for i in arange:
pm = [0] + list(i)
for a, b in zip(pm, pm[1:]):
if not Matrix[a][b]:
break
else:
ans += 1
print(ans)
| false | 17.241379 | [
"-Matrix = [[False for i in range(N)] for j in range(N)]",
"+Matrix = [[False for x in range(N)] for y in range(N)]",
"+for i in range(N):",
"+ Matrix[i][i] = True",
"-for i in range(N):",
"- Matrix[i][i] = True",
"-arange = list(range(2, N + 1))",
"+arange = permutations(list(range(1, N)))",
"-for pm in permutations(arange):",
"- pm = [1] + list(pm)",
"- for row, col in zip(pm, pm[1:]):",
"- row -= 1",
"- col -= 1",
"- if not Matrix[row][col]:",
"+for i in arange:",
"+ pm = [0] + list(i)",
"+ for a, b in zip(pm, pm[1:]):",
"+ if not Matrix[a][b]:"
] | false | 0.111239 | 0.055034 | 2.021281 | [
"s499351231",
"s228213123"
] |
u585482323 | p02955 | python | s287548160 | s687337341 | 833 | 243 | 45,504 | 41,708 | Accepted | Accepted | 70.83 | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
#A
def A():
a,b,c = LI()
c -= a-b
print((max(0,c)))
return
#B
def B():
n = I()
ans = 0
for i in range(1,n+1):
s = str(i)
if len(s)%2:
ans += 1
print(ans)
return
#C
def C():
n = I()
h = LI()
h[0] -= 1
for i in range(n-1):
if h[i+1] < h[i]:
print("No")
return
if h[i+1] > h[i]:
h[i+1] -= 1
print("Yes")
return
#D
def D():
s = S()
n = len(s)
ans = [0]*n
l = 0
i = 0
while i < n:
if s[i] == "L":
j = i
while i < n and s[i] == "L":
i += 1
l += 1
if l:
if (l+j-i)%2:
ans[j-1] = l-l//2
ans[j] = l//2
else:
ans[j-1] = l//2
ans[j] = l-l//2
l = 0
else:
l += 1
i += 1
print((*ans))
return
#E
def E():
def factor(n):
if n == 1:
return [1]
if n < 4:
return [1,n]
i = 2
res = [1]
while i**2 <= n:
if n%i == 0:
res.append(i)
if n//i != i:
res.append(n//i)
i += 1
res.append(n)
res.sort()
return res
n,k = LI()
a = LI()
s = sum(a)
f = factor(s)
for i in f[::-1]:
s = 0
b = [[a[j]%i,-a[j]%i] for j in range(n)]
b.sort()
for j in range(n-1):
b[j+1][0] += b[j][0]
b[j+1][1] += b[j][1]
for j in range(n-1):
if b[j][0] == b[n-1][1]-b[j][1]:
break
s = b[j][0]
if s <= k:
print(i)
return
return
#F
def F():
return
#Solve
if __name__ == "__main__":
E()
| #!usr/bin/env python3
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.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
def fact(n):
if n < 4:
return [n,1]
i = 2
res = [1,n]
while i*i <= n:
if n%i == 0:
res.append(i)
m = n//i
if m != i:
res.append(m)
i += 1
res.sort(reverse = True)
return res
n,k = LI()
a = LI()
s = sum(a)
f = fact(s)
for i in f:
s = [j%i for j in a]
s.sort()
s = list(accumulate(s))
for j in range(n-1):
sl = s[j]
sr = i*(n-j-1)-s[-1]+s[j]
if sl == sr:
break
if sl <= k:
print(i)
return
return
#Solve
if __name__ == "__main__":
solve()
| 134 | 63 | 2,671 | 1,528 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return [int(x) for x in sys.stdin.readline().split()]
def I():
return int(sys.stdin.readline())
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
# A
def A():
a, b, c = LI()
c -= a - b
print((max(0, c)))
return
# B
def B():
n = I()
ans = 0
for i in range(1, n + 1):
s = str(i)
if len(s) % 2:
ans += 1
print(ans)
return
# C
def C():
n = I()
h = LI()
h[0] -= 1
for i in range(n - 1):
if h[i + 1] < h[i]:
print("No")
return
if h[i + 1] > h[i]:
h[i + 1] -= 1
print("Yes")
return
# D
def D():
s = S()
n = len(s)
ans = [0] * n
l = 0
i = 0
while i < n:
if s[i] == "L":
j = i
while i < n and s[i] == "L":
i += 1
l += 1
if l:
if (l + j - i) % 2:
ans[j - 1] = l - l // 2
ans[j] = l // 2
else:
ans[j - 1] = l // 2
ans[j] = l - l // 2
l = 0
else:
l += 1
i += 1
print((*ans))
return
# E
def E():
def factor(n):
if n == 1:
return [1]
if n < 4:
return [1, n]
i = 2
res = [1]
while i**2 <= n:
if n % i == 0:
res.append(i)
if n // i != i:
res.append(n // i)
i += 1
res.append(n)
res.sort()
return res
n, k = LI()
a = LI()
s = sum(a)
f = factor(s)
for i in f[::-1]:
s = 0
b = [[a[j] % i, -a[j] % i] for j in range(n)]
b.sort()
for j in range(n - 1):
b[j + 1][0] += b[j][0]
b[j + 1][1] += b[j][1]
for j in range(n - 1):
if b[j][0] == b[n - 1][1] - b[j][1]:
break
s = b[j][0]
if s <= k:
print(i)
return
return
# F
def F():
return
# Solve
if __name__ == "__main__":
E()
| #!usr/bin/env python3
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.buffer.readline().split()]
def I():
return int(sys.stdin.buffer.readline())
def LS():
return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
def fact(n):
if n < 4:
return [n, 1]
i = 2
res = [1, n]
while i * i <= n:
if n % i == 0:
res.append(i)
m = n // i
if m != i:
res.append(m)
i += 1
res.sort(reverse=True)
return res
n, k = LI()
a = LI()
s = sum(a)
f = fact(s)
for i in f:
s = [j % i for j in a]
s.sort()
s = list(accumulate(s))
for j in range(n - 1):
sl = s[j]
sr = i * (n - j - 1) - s[-1] + s[j]
if sl == sr:
break
if sl <= k:
print(i)
return
return
# Solve
if __name__ == "__main__":
solve()
| false | 52.985075 | [
"+from itertools import permutations, accumulate",
"-import random",
"- return [int(x) for x in sys.stdin.readline().split()]",
"+ return [int(x) for x in sys.stdin.buffer.readline().split()]",
"- return int(sys.stdin.readline())",
"+ return int(sys.stdin.buffer.readline())",
"-# A",
"-def A():",
"- a, b, c = LI()",
"- c -= a - b",
"- print((max(0, c)))",
"- return",
"-# B",
"-def B():",
"- n = I()",
"- ans = 0",
"- for i in range(1, n + 1):",
"- s = str(i)",
"- if len(s) % 2:",
"- ans += 1",
"- print(ans)",
"- return",
"-",
"-",
"-# C",
"-def C():",
"- n = I()",
"- h = LI()",
"- h[0] -= 1",
"- for i in range(n - 1):",
"- if h[i + 1] < h[i]:",
"- print(\"No\")",
"- return",
"- if h[i + 1] > h[i]:",
"- h[i + 1] -= 1",
"- print(\"Yes\")",
"- return",
"-",
"-",
"-# D",
"-def D():",
"- s = S()",
"- n = len(s)",
"- ans = [0] * n",
"- l = 0",
"- i = 0",
"- while i < n:",
"- if s[i] == \"L\":",
"- j = i",
"- while i < n and s[i] == \"L\":",
"- i += 1",
"- l += 1",
"- if l:",
"- if (l + j - i) % 2:",
"- ans[j - 1] = l - l // 2",
"- ans[j] = l // 2",
"- else:",
"- ans[j - 1] = l // 2",
"- ans[j] = l - l // 2",
"- l = 0",
"- else:",
"- l += 1",
"- i += 1",
"- print((*ans))",
"- return",
"-",
"-",
"-# E",
"-def E():",
"- def factor(n):",
"- if n == 1:",
"- return [1]",
"+def solve():",
"+ def fact(n):",
"- return [1, n]",
"+ return [n, 1]",
"- res = [1]",
"- while i**2 <= n:",
"+ res = [1, n]",
"+ while i * i <= n:",
"- if n // i != i:",
"- res.append(n // i)",
"+ m = n // i",
"+ if m != i:",
"+ res.append(m)",
"- res.append(n)",
"- res.sort()",
"+ res.sort(reverse=True)",
"- f = factor(s)",
"- for i in f[::-1]:",
"- s = 0",
"- b = [[a[j] % i, -a[j] % i] for j in range(n)]",
"- b.sort()",
"+ f = fact(s)",
"+ for i in f:",
"+ s = [j % i for j in a]",
"+ s.sort()",
"+ s = list(accumulate(s))",
"- b[j + 1][0] += b[j][0]",
"- b[j + 1][1] += b[j][1]",
"- for j in range(n - 1):",
"- if b[j][0] == b[n - 1][1] - b[j][1]:",
"+ sl = s[j]",
"+ sr = i * (n - j - 1) - s[-1] + s[j]",
"+ if sl == sr:",
"- s = b[j][0]",
"- if s <= k:",
"+ if sl <= k:",
"-# F",
"-def F():",
"- return",
"-",
"-",
"- E()",
"+ solve()"
] | false | 0.037807 | 0.036069 | 1.048171 | [
"s287548160",
"s687337341"
] |
u888092736 | p02707 | python | s904812890 | s019338357 | 174 | 145 | 33,992 | 32,204 | Accepted | Accepted | 16.67 | from collections import Counter
n = int(eval(input()))
A = Counter(list(map(int, input().split())))
for i in range(1, n + 1):
print((A.get(i, 0)))
| n = int(input())
A = list(map(int, input().split()))
ans = [0] * n
for i in A:
ans[i - 1] += 1
[print(i) for i in ans]
| 7 | 6 | 151 | 128 | from collections import Counter
n = int(eval(input()))
A = Counter(list(map(int, input().split())))
for i in range(1, n + 1):
print((A.get(i, 0)))
| n = int(input())
A = list(map(int, input().split()))
ans = [0] * n
for i in A:
ans[i - 1] += 1
[print(i) for i in ans]
| false | 14.285714 | [
"-from collections import Counter",
"-",
"-n = int(eval(input()))",
"-A = Counter(list(map(int, input().split())))",
"-for i in range(1, n + 1):",
"- print((A.get(i, 0)))",
"+n = int(input())",
"+A = list(map(int, input().split()))",
"+ans = [0] * n",
"+for i in A:",
"+ ans[i - 1] += 1",
"+[print(i) for i in ans]"
] | false | 0.035907 | 0.037401 | 0.960073 | [
"s904812890",
"s019338357"
] |
u941407962 | p03185 | python | s509168524 | s337645145 | 430 | 333 | 94,540 | 90,108 | Accepted | Accepted | 22.56 | def fi(i, x):
a, b = lines[i]
return a*x+b
def find(x):
def f(i):
return fi(i+1,x) > fi(i,x)
mn, mx = -1, len(lines)-1
idx = (mn+mx)//2
while mx-mn>1:
if f(idx):
mx, idx = idx, (mn + idx)//2
continue
mn, idx = idx, (mx + idx)//2
return fi(idx+1, x)
def insert(a, b):
(e, f) = lines[-1]
while len(lines)-1:
(c, d), (e, f) = (e, f), lines[-2]
if (c-e)*(b-d) < (d-f)*(a-c):
break
lines.pop()
lines.append((a, b))
N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
lines = [(-2*hs[0], hs[0]**2)]
for h in hs[1:]:
r = find(h) + h**2+C
insert(-2*h, r+h**2)
print(r)
| N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
lines = [(-2*hs[0], hs[0]**2)]
I = 0
for h in hs[1:]:
u, v = lines[I]
while I+1<len(lines):
uu, vv = lines[I+1]
if u*h+v < uu*h+vv:
break
u, v = uu, vv
I += 1
r = u*h+v + h**2+C
a, b = -2*h, r+h**2
(e, f) = lines[-1]
while len(lines)-1:
(c, d), (e, f) = (e, f), lines[-2]
if (c-e)*(b-d) < (d-f)*(a-c):
break
lines.pop()
lines.append((a, b))
print(r) | 32 | 22 | 745 | 548 | def fi(i, x):
a, b = lines[i]
return a * x + b
def find(x):
def f(i):
return fi(i + 1, x) > fi(i, x)
mn, mx = -1, len(lines) - 1
idx = (mn + mx) // 2
while mx - mn > 1:
if f(idx):
mx, idx = idx, (mn + idx) // 2
continue
mn, idx = idx, (mx + idx) // 2
return fi(idx + 1, x)
def insert(a, b):
(e, f) = lines[-1]
while len(lines) - 1:
(c, d), (e, f) = (e, f), lines[-2]
if (c - e) * (b - d) < (d - f) * (a - c):
break
lines.pop()
lines.append((a, b))
N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
lines = [(-2 * hs[0], hs[0] ** 2)]
for h in hs[1:]:
r = find(h) + h**2 + C
insert(-2 * h, r + h**2)
print(r)
| N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
lines = [(-2 * hs[0], hs[0] ** 2)]
I = 0
for h in hs[1:]:
u, v = lines[I]
while I + 1 < len(lines):
uu, vv = lines[I + 1]
if u * h + v < uu * h + vv:
break
u, v = uu, vv
I += 1
r = u * h + v + h**2 + C
a, b = -2 * h, r + h**2
(e, f) = lines[-1]
while len(lines) - 1:
(c, d), (e, f) = (e, f), lines[-2]
if (c - e) * (b - d) < (d - f) * (a - c):
break
lines.pop()
lines.append((a, b))
print(r)
| false | 31.25 | [
"-def fi(i, x):",
"- a, b = lines[i]",
"- return a * x + b",
"-",
"-",
"-def find(x):",
"- def f(i):",
"- return fi(i + 1, x) > fi(i, x)",
"-",
"- mn, mx = -1, len(lines) - 1",
"- idx = (mn + mx) // 2",
"- while mx - mn > 1:",
"- if f(idx):",
"- mx, idx = idx, (mn + idx) // 2",
"- continue",
"- mn, idx = idx, (mx + idx) // 2",
"- return fi(idx + 1, x)",
"-",
"-",
"-def insert(a, b):",
"+N, C = list(map(int, input().split()))",
"+hs = list(map(int, input().split()))",
"+lines = [(-2 * hs[0], hs[0] ** 2)]",
"+I = 0",
"+for h in hs[1:]:",
"+ u, v = lines[I]",
"+ while I + 1 < len(lines):",
"+ uu, vv = lines[I + 1]",
"+ if u * h + v < uu * h + vv:",
"+ break",
"+ u, v = uu, vv",
"+ I += 1",
"+ r = u * h + v + h**2 + C",
"+ a, b = -2 * h, r + h**2",
"-",
"-",
"-N, C = list(map(int, input().split()))",
"-hs = list(map(int, input().split()))",
"-lines = [(-2 * hs[0], hs[0] ** 2)]",
"-for h in hs[1:]:",
"- r = find(h) + h**2 + C",
"- insert(-2 * h, r + h**2)"
] | false | 0.049877 | 0.182494 | 0.273305 | [
"s509168524",
"s337645145"
] |
u602677143 | p02813 | python | s573155556 | s165530017 | 45 | 39 | 3,064 | 10,228 | Accepted | Accepted | 13.33 | import itertools
n = int(eval(input()))
ls = []
for i in range(1,n+1):
ls.append(i)
p = list(map(int,input().split()))
q = list(map(int,input().split()))
a = 0
b = 0
c = 1
for v in itertools.permutations(ls, n):
if list(v) == p:
a = c
if list(v) == q:
b = c
c += 1
print((abs(a-b))) | #ABC150C
import itertools
n = int(eval(input()))
ls = [i+1 for i in range(n)]
p = list(map(int,input().split()))
q = list(map(int,input().split()))
v = [ list(v) for v in itertools.permutations(ls, n)]
a, b = v.index(p), v.index(q)
print((abs(a-b))) | 20 | 9 | 336 | 249 | import itertools
n = int(eval(input()))
ls = []
for i in range(1, n + 1):
ls.append(i)
p = list(map(int, input().split()))
q = list(map(int, input().split()))
a = 0
b = 0
c = 1
for v in itertools.permutations(ls, n):
if list(v) == p:
a = c
if list(v) == q:
b = c
c += 1
print((abs(a - b)))
| # ABC150C
import itertools
n = int(eval(input()))
ls = [i + 1 for i in range(n)]
p = list(map(int, input().split()))
q = list(map(int, input().split()))
v = [list(v) for v in itertools.permutations(ls, n)]
a, b = v.index(p), v.index(q)
print((abs(a - b)))
| false | 55 | [
"+# ABC150C",
"-ls = []",
"-for i in range(1, n + 1):",
"- ls.append(i)",
"+ls = [i + 1 for i in range(n)]",
"-a = 0",
"-b = 0",
"-c = 1",
"-for v in itertools.permutations(ls, n):",
"- if list(v) == p:",
"- a = c",
"- if list(v) == q:",
"- b = c",
"- c += 1",
"+v = [list(v) for v in itertools.permutations(ls, n)]",
"+a, b = v.index(p), v.index(q)"
] | false | 0.037699 | 0.039472 | 0.955095 | [
"s573155556",
"s165530017"
] |
u089230684 | p02917 | python | s165535539 | s744832757 | 19 | 17 | 3,060 | 3,060 | Accepted | Accepted | 10.53 | n = int(eval(input())); b = list(map(int, input().split())); summ = 0
for i in range(0, n-2):
summ = summ + min(b[i], b[i+1])
summ = summ + b[0] + b[n-2]
print(summ) | N = int(eval(input()))
seqB = [int(x) for x in input().split()]
ai = aj = seqB[0]
seqA = [ai,aj]
for i in range(1, len(seqB)):
aj = max(aj, seqB[i])
if aj > seqB[i]:
aj = seqA[i] = seqB[i]
seqA.append(aj)
print((sum(seqA))) | 5 | 12 | 167 | 239 | n = int(eval(input()))
b = list(map(int, input().split()))
summ = 0
for i in range(0, n - 2):
summ = summ + min(b[i], b[i + 1])
summ = summ + b[0] + b[n - 2]
print(summ)
| N = int(eval(input()))
seqB = [int(x) for x in input().split()]
ai = aj = seqB[0]
seqA = [ai, aj]
for i in range(1, len(seqB)):
aj = max(aj, seqB[i])
if aj > seqB[i]:
aj = seqA[i] = seqB[i]
seqA.append(aj)
print((sum(seqA)))
| false | 58.333333 | [
"-n = int(eval(input()))",
"-b = list(map(int, input().split()))",
"-summ = 0",
"-for i in range(0, n - 2):",
"- summ = summ + min(b[i], b[i + 1])",
"-summ = summ + b[0] + b[n - 2]",
"-print(summ)",
"+N = int(eval(input()))",
"+seqB = [int(x) for x in input().split()]",
"+ai = aj = seqB[0]",
"+seqA = [ai, aj]",
"+for i in range(1, len(seqB)):",
"+ aj = max(aj, seqB[i])",
"+ if aj > seqB[i]:",
"+ aj = seqA[i] = seqB[i]",
"+ seqA.append(aj)",
"+print((sum(seqA)))"
] | false | 0.042878 | 0.041225 | 1.040106 | [
"s165535539",
"s744832757"
] |
u958506960 | p03775 | python | s585274225 | s054204485 | 44 | 40 | 9,440 | 9,372 | Accepted | Accepted | 9.09 | n = int(eval(input()))
l = []
for a in range(1, int(n**0.5) + 1):
if n % a == 0:
b = n // a
f = max(len(str(a)), len(str(b)))
l.append(f)
print((min(l))) | n = int(eval(input()))
l = []
for a in range(1, int(n**0.5) + 1):
if n % a == 0:
b = n // a
l.append(max(len(str(a)), len(str(b))))
print((min(l))) | 10 | 9 | 184 | 169 | n = int(eval(input()))
l = []
for a in range(1, int(n**0.5) + 1):
if n % a == 0:
b = n // a
f = max(len(str(a)), len(str(b)))
l.append(f)
print((min(l)))
| n = int(eval(input()))
l = []
for a in range(1, int(n**0.5) + 1):
if n % a == 0:
b = n // a
l.append(max(len(str(a)), len(str(b))))
print((min(l)))
| false | 10 | [
"- f = max(len(str(a)), len(str(b)))",
"- l.append(f)",
"+ l.append(max(len(str(a)), len(str(b))))"
] | false | 0.04083 | 0.045104 | 0.905224 | [
"s585274225",
"s054204485"
] |
u426534722 | p02277 | python | s918950764 | s560513291 | 750 | 660 | 26,604 | 26,996 | Accepted | Accepted | 12 | import sys
readline = sys.stdin.readline
import sys
readline = sys.stdin.readline
INF = int(1e10)
def partition(A, p, r):
x = A[r][1]
i = p - 1
for j in range(p, r):
if A[j][1] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
def quicksort(A, p, r):
if p < r:
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
def isStable(A):
for i in range(0, len(A) - 1):
if A[i][1] == A[i + 1][1]:
if A[i][2] > A[i + 1][2]:
return False
return True
n = int(input())
f = lambda a, i: (a[0], int(a[1]), i)
A = [f(readline().split(), i) for i in range(n)]
quicksort(A, 0, n - 1)
print("Stable" if isStable(A) else "Not stable")
print(*(f"{a} {b}" for a, b, c in A), sep="\n")
| import sys
readline = sys.stdin.readline
def partition(A, p, r):
x = A[r][1]
i = p - 1
for j in range(p, r):
if A[j][1] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
def quicksort(A, p, r):
if p < r:
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
def isStable(A):
for i in range(0, len(A) - 1):
if A[i][1] == A[i + 1][1]:
if A[i][2] > A[i + 1][2]:
return False
return True
n = int(eval(input()))
f = lambda a, i: (a[0], int(a[1]), i)
A = [f(readline().split(), i) for i in range(n)]
quicksort(A, 0, n - 1)
print(("Stable" if isStable(A) else "Not stable"))
print(("\n".join(f"{a} {b}" for a, b, c in A)))
| 32 | 29 | 868 | 806 | import sys
readline = sys.stdin.readline
import sys
readline = sys.stdin.readline
INF = int(1e10)
def partition(A, p, r):
x = A[r][1]
i = p - 1
for j in range(p, r):
if A[j][1] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
def quicksort(A, p, r):
if p < r:
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
def isStable(A):
for i in range(0, len(A) - 1):
if A[i][1] == A[i + 1][1]:
if A[i][2] > A[i + 1][2]:
return False
return True
n = int(input())
f = lambda a, i: (a[0], int(a[1]), i)
A = [f(readline().split(), i) for i in range(n)]
quicksort(A, 0, n - 1)
print("Stable" if isStable(A) else "Not stable")
print(*(f"{a} {b}" for a, b, c in A), sep="\n")
| import sys
readline = sys.stdin.readline
def partition(A, p, r):
x = A[r][1]
i = p - 1
for j in range(p, r):
if A[j][1] <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
def quicksort(A, p, r):
if p < r:
q = partition(A, p, r)
quicksort(A, p, q - 1)
quicksort(A, q + 1, r)
def isStable(A):
for i in range(0, len(A) - 1):
if A[i][1] == A[i + 1][1]:
if A[i][2] > A[i + 1][2]:
return False
return True
n = int(eval(input()))
f = lambda a, i: (a[0], int(a[1]), i)
A = [f(readline().split(), i) for i in range(n)]
quicksort(A, 0, n - 1)
print(("Stable" if isStable(A) else "Not stable"))
print(("\n".join(f"{a} {b}" for a, b, c in A)))
| false | 9.375 | [
"-import sys",
"-",
"-readline = sys.stdin.readline",
"-INF = int(1e10)",
"-n = int(input())",
"+n = int(eval(input()))",
"-print(\"Stable\" if isStable(A) else \"Not stable\")",
"-print(*(f\"{a} {b}\" for a, b, c in A), sep=\"\\n\")",
"+print((\"Stable\" if isStable(A) else \"Not stable\"))",
"+print((\"\\n\".join(f\"{a} {b}\" for a, b, c in A)))"
] | false | 0.044202 | 0.036245 | 1.219534 | [
"s918950764",
"s560513291"
] |
u962127640 | p03805 | python | s437932418 | s871944674 | 42 | 23 | 8,052 | 3,064 | Accepted | Accepted | 45.24 | import itertools
N, M = list(map(int, input().split()))
graph = [[0] * N for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
graph[a-1][b-1] = 1
graph[b-1][a-1] = 1
p = list(itertools.permutations(list(range(N))))
Sum = 0
for i in range(len(p)):
if p[i][0] != 0:
break
for j in range(N - 1):
if graph[p[i][j]][p[i][j + 1]] != 1:
break
elif j == N - 2:
Sum += 1
print(Sum) | N, M = list(map(int, input().split()))
g = [[] for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
g[a-1].append(b-1)
g[b-1].append(a-1)
visited = [False for _ in range(N)]
def dfs(v, visited):
if all(visited):
return 1
total = 0
for cv in g[v]:
if not visited[cv]:
visited[cv] = True
total += dfs(cv, visited)
visited[cv] = False
return total
visited[0] = True
ret = dfs(0, visited)
print(ret) | 23 | 25 | 478 | 492 | import itertools
N, M = list(map(int, input().split()))
graph = [[0] * N for i in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
graph[a - 1][b - 1] = 1
graph[b - 1][a - 1] = 1
p = list(itertools.permutations(list(range(N))))
Sum = 0
for i in range(len(p)):
if p[i][0] != 0:
break
for j in range(N - 1):
if graph[p[i][j]][p[i][j + 1]] != 1:
break
elif j == N - 2:
Sum += 1
print(Sum)
| N, M = list(map(int, input().split()))
g = [[] for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split()))
g[a - 1].append(b - 1)
g[b - 1].append(a - 1)
visited = [False for _ in range(N)]
def dfs(v, visited):
if all(visited):
return 1
total = 0
for cv in g[v]:
if not visited[cv]:
visited[cv] = True
total += dfs(cv, visited)
visited[cv] = False
return total
visited[0] = True
ret = dfs(0, visited)
print(ret)
| false | 8 | [
"-import itertools",
"-",
"-graph = [[0] * N for i in range(N)]",
"+g = [[] for _ in range(N)]",
"- graph[a - 1][b - 1] = 1",
"- graph[b - 1][a - 1] = 1",
"-p = list(itertools.permutations(list(range(N))))",
"-Sum = 0",
"-for i in range(len(p)):",
"- if p[i][0] != 0:",
"- break",
"- for j in range(N - 1):",
"- if graph[p[i][j]][p[i][j + 1]] != 1:",
"- break",
"- elif j == N - 2:",
"- Sum += 1",
"-print(Sum)",
"+ g[a - 1].append(b - 1)",
"+ g[b - 1].append(a - 1)",
"+visited = [False for _ in range(N)]",
"+",
"+",
"+def dfs(v, visited):",
"+ if all(visited):",
"+ return 1",
"+ total = 0",
"+ for cv in g[v]:",
"+ if not visited[cv]:",
"+ visited[cv] = True",
"+ total += dfs(cv, visited)",
"+ visited[cv] = False",
"+ return total",
"+",
"+",
"+visited[0] = True",
"+ret = dfs(0, visited)",
"+print(ret)"
] | false | 0.12543 | 0.037932 | 3.306698 | [
"s437932418",
"s871944674"
] |
u372102441 | p02791 | python | s211104321 | s484033300 | 126 | 92 | 24,744 | 24,772 | Accepted | Accepted | 26.98 | #n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
a, b = map(int, input().split())
A.append(a)
B.append(b)'''
n = int(eval(input()))
p = list(map(int, input().split()))
mi = 1000000000
cnt = 0
for i in range(n):
if p[i] <= mi:
cnt += 1
if mi > p[i]:
mi = p[i]
print(cnt)
| #n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
a, b = map(int, input().split())
A.append(a)
B.append(b)'''
def main():
n = int(eval(input()))
p = list(map(int, input().split()))
mi = 1000000000
cnt = 0
for i in range(n):
if p[i] <= mi:
cnt += 1
if mi > p[i]:
mi = p[i]
print(cnt)
main() | 24 | 25 | 366 | 424 | # n = int(input())
# l = list(map(int, input().split()))
"""
A=[]
B=[]
for i in range():
a, b = map(int, input().split())
A.append(a)
B.append(b)"""
n = int(eval(input()))
p = list(map(int, input().split()))
mi = 1000000000
cnt = 0
for i in range(n):
if p[i] <= mi:
cnt += 1
if mi > p[i]:
mi = p[i]
print(cnt)
| # n = int(input())
# l = list(map(int, input().split()))
"""
A=[]
B=[]
for i in range():
a, b = map(int, input().split())
A.append(a)
B.append(b)"""
def main():
n = int(eval(input()))
p = list(map(int, input().split()))
mi = 1000000000
cnt = 0
for i in range(n):
if p[i] <= mi:
cnt += 1
if mi > p[i]:
mi = p[i]
print(cnt)
main()
| false | 4 | [
"-n = int(eval(input()))",
"-p = list(map(int, input().split()))",
"-mi = 1000000000",
"-cnt = 0",
"-for i in range(n):",
"- if p[i] <= mi:",
"- cnt += 1",
"- if mi > p[i]:",
"- mi = p[i]",
"-print(cnt)",
"+",
"+",
"+def main():",
"+ n = int(eval(input()))",
"+ p = list(map(int, input().split()))",
"+ mi = 1000000000",
"+ cnt = 0",
"+ for i in range(n):",
"+ if p[i] <= mi:",
"+ cnt += 1",
"+ if mi > p[i]:",
"+ mi = p[i]",
"+ print(cnt)",
"+",
"+",
"+main()"
] | false | 0.036213 | 0.034741 | 1.042378 | [
"s211104321",
"s484033300"
] |
u315703650 | p03424 | python | s877275887 | s079144153 | 19 | 17 | 3,060 | 2,940 | Accepted | Accepted | 10.53 | n = int(eval(input()))
s = list(map(str,input().split()))
a = len(list(set(s)))
if a==3:
print("Three")
else:
print("Four") | n = int(eval(input()))
s = list(map(str,input().split()))
if "Y" in s:
print("Four")
else:
print("Three") | 7 | 6 | 131 | 112 | n = int(eval(input()))
s = list(map(str, input().split()))
a = len(list(set(s)))
if a == 3:
print("Three")
else:
print("Four")
| n = int(eval(input()))
s = list(map(str, input().split()))
if "Y" in s:
print("Four")
else:
print("Three")
| false | 14.285714 | [
"-a = len(list(set(s)))",
"-if a == 3:",
"+if \"Y\" in s:",
"+ print(\"Four\")",
"+else:",
"-else:",
"- print(\"Four\")"
] | false | 0.049769 | 0.057505 | 0.865475 | [
"s877275887",
"s079144153"
] |
u537782349 | p03544 | python | s234690043 | s129981175 | 27 | 17 | 3,188 | 2,940 | Accepted | Accepted | 37.04 | a = int(eval(input()))
b = [2, 1]
for i in range(2, a+1):
b.append(b[i-1]+b[i-2])
print((b[a]))
| a = int(eval(input()))
b = [2, 1]
for i in range(1, a):
b.append(b[i] + b[i-1])
print((b[len(b)-1]))
| 5 | 5 | 96 | 101 | a = int(eval(input()))
b = [2, 1]
for i in range(2, a + 1):
b.append(b[i - 1] + b[i - 2])
print((b[a]))
| a = int(eval(input()))
b = [2, 1]
for i in range(1, a):
b.append(b[i] + b[i - 1])
print((b[len(b) - 1]))
| false | 0 | [
"-for i in range(2, a + 1):",
"- b.append(b[i - 1] + b[i - 2])",
"-print((b[a]))",
"+for i in range(1, a):",
"+ b.append(b[i] + b[i - 1])",
"+print((b[len(b) - 1]))"
] | false | 0.039966 | 0.066559 | 0.600456 | [
"s234690043",
"s129981175"
] |
u416011173 | p02572 | python | s861751864 | s410544008 | 137 | 118 | 31,508 | 30,752 | Accepted | Accepted | 13.87 | # -*- coding: utf-8 -*-
# 標準入力を取得
N = int(eval(input()))
A = list(map(int, input().split()))
# 求解処理
ans = 0
sum_A_j = sum(A)
for A_i in A:
sum_A_j -= A_i
ans += A_i * sum_A_j
ans %= 10**9 + 7
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
# 標準入力を取得
N = int(eval(input()))
A = list(map(int, input().split()))
return N, A
def main(N: int, A: list) -> None:
"""
メイン処理.
Args:\n
N (int): 整数(2 <= N <= 2 * 10**5)
A (list): 整数(0 <= A_i <= 10**9)
"""
# 求解処理
mod = 10**9 + 7
ans = 0
sum_A_j = sum(A)
for i in range(N):
A_i = A[i]
sum_A_j -= A_i
ans += A_i * sum_A_j
ans %= mod
# 結果出力
print(ans)
if __name__ == "__main__":
# 標準入力を取得
N, A = get_input()
# メイン処理
main(N, A)
| 15 | 44 | 232 | 709 | # -*- coding: utf-8 -*-
# 標準入力を取得
N = int(eval(input()))
A = list(map(int, input().split()))
# 求解処理
ans = 0
sum_A_j = sum(A)
for A_i in A:
sum_A_j -= A_i
ans += A_i * sum_A_j
ans %= 10**9 + 7
# 結果出力
print(ans)
| # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
# 標準入力を取得
N = int(eval(input()))
A = list(map(int, input().split()))
return N, A
def main(N: int, A: list) -> None:
"""
メイン処理.
Args:\n
N (int): 整数(2 <= N <= 2 * 10**5)
A (list): 整数(0 <= A_i <= 10**9)
"""
# 求解処理
mod = 10**9 + 7
ans = 0
sum_A_j = sum(A)
for i in range(N):
A_i = A[i]
sum_A_j -= A_i
ans += A_i * sum_A_j
ans %= mod
# 結果出力
print(ans)
if __name__ == "__main__":
# 標準入力を取得
N, A = get_input()
# メイン処理
main(N, A)
| false | 65.909091 | [
"-# 標準入力を取得",
"-N = int(eval(input()))",
"-A = list(map(int, input().split()))",
"-# 求解処理",
"-ans = 0",
"-sum_A_j = sum(A)",
"-for A_i in A:",
"- sum_A_j -= A_i",
"- ans += A_i * sum_A_j",
"- ans %= 10**9 + 7",
"-# 結果出力",
"-print(ans)",
"+def get_input() -> tuple:",
"+ \"\"\"",
"+ 標準入力を取得する.",
"+ Returns:\\n",
"+ tuple: 標準入力",
"+ \"\"\"",
"+ # 標準入力を取得",
"+ N = int(eval(input()))",
"+ A = list(map(int, input().split()))",
"+ return N, A",
"+",
"+",
"+def main(N: int, A: list) -> None:",
"+ \"\"\"",
"+ メイン処理.",
"+ Args:\\n",
"+ N (int): 整数(2 <= N <= 2 * 10**5)",
"+ A (list): 整数(0 <= A_i <= 10**9)",
"+ \"\"\"",
"+ # 求解処理",
"+ mod = 10**9 + 7",
"+ ans = 0",
"+ sum_A_j = sum(A)",
"+ for i in range(N):",
"+ A_i = A[i]",
"+ sum_A_j -= A_i",
"+ ans += A_i * sum_A_j",
"+ ans %= mod",
"+ # 結果出力",
"+ print(ans)",
"+",
"+",
"+if __name__ == \"__main__\":",
"+ # 標準入力を取得",
"+ N, A = get_input()",
"+ # メイン処理",
"+ main(N, A)"
] | false | 0.077813 | 0.007272 | 10.700038 | [
"s861751864",
"s410544008"
] |
u022407960 | p02265 | python | s787764561 | s229816033 | 2,120 | 1,440 | 214,248 | 214,216 | Accepted | Accepted | 32.08 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(eval(input()))
task_deque = deque()
_input = sys.stdin.readlines()
for i in range(array_length):
l_arg = _input[i].split()
action = _input[i].split()[0]
if len(l_arg) > 1:
value = _input[i].split()[-1]
# print(action, 'v', value)
if action == 'insert':
task_deque.appendleft(value)
elif action == 'deleteFirst':
task_deque.popleft()
elif action == 'deleteLast':
task_deque.pop()
elif action == 'delete':
try:
task_deque.remove(value)
except Exception as e:
pass
print((" ".join(task_deque)))
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(eval(input()))
task_deque = deque()
_input = sys.stdin.readlines()
for i in range(array_length):
l_arg = _input[i].split()
action = l_arg[0]
if len(l_arg) > 1:
value = l_arg[-1]
# print(action, 'v', value)
if action == 'insert':
task_deque.appendleft(value)
elif action == 'deleteFirst':
task_deque.popleft()
elif action == 'deleteLast':
task_deque.pop()
elif action == 'delete':
try:
task_deque.remove(value)
except Exception as e:
pass
print((" ".join(task_deque)))
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() | 38 | 38 | 1,059 | 1,035 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(eval(input()))
task_deque = deque()
_input = sys.stdin.readlines()
for i in range(array_length):
l_arg = _input[i].split()
action = _input[i].split()[0]
if len(l_arg) > 1:
value = _input[i].split()[-1]
# print(action, 'v', value)
if action == "insert":
task_deque.appendleft(value)
elif action == "deleteFirst":
task_deque.popleft()
elif action == "deleteLast":
task_deque.pop()
elif action == "delete":
try:
task_deque.remove(value)
except Exception as e:
pass
print((" ".join(task_deque)))
if __name__ == "__main__":
solution = Solution()
solution.doubly_linked_list()
| # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(eval(input()))
task_deque = deque()
_input = sys.stdin.readlines()
for i in range(array_length):
l_arg = _input[i].split()
action = l_arg[0]
if len(l_arg) > 1:
value = l_arg[-1]
# print(action, 'v', value)
if action == "insert":
task_deque.appendleft(value)
elif action == "deleteFirst":
task_deque.popleft()
elif action == "deleteLast":
task_deque.pop()
elif action == "delete":
try:
task_deque.remove(value)
except Exception as e:
pass
print((" ".join(task_deque)))
if __name__ == "__main__":
solution = Solution()
solution.doubly_linked_list()
| false | 0 | [
"- action = _input[i].split()[0]",
"+ action = l_arg[0]",
"- value = _input[i].split()[-1]",
"+ value = l_arg[-1]"
] | false | 0.037273 | 0.037702 | 0.988613 | [
"s787764561",
"s229816033"
] |
u597374218 | p03252 | python | s411647715 | s044457668 | 129 | 42 | 6,704 | 3,828 | Accepted | Accepted | 67.44 | s=list(eval(input()))
t=list(eval(input()))
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print(("Yes" if S==T else "No")) | from collections import Counter
S=Counter(eval(input()))
T=Counter(eval(input()))
s=list(S.values())
t=list(T.values())
print(("Yes" if sorted(s)==sorted(t) else "No")) | 5 | 6 | 126 | 147 | s = list(eval(input()))
t = list(eval(input()))
S = sorted(map(s.count, set(s)))
T = sorted(map(t.count, set(t)))
print(("Yes" if S == T else "No"))
| from collections import Counter
S = Counter(eval(input()))
T = Counter(eval(input()))
s = list(S.values())
t = list(T.values())
print(("Yes" if sorted(s) == sorted(t) else "No"))
| false | 16.666667 | [
"-s = list(eval(input()))",
"-t = list(eval(input()))",
"-S = sorted(map(s.count, set(s)))",
"-T = sorted(map(t.count, set(t)))",
"-print((\"Yes\" if S == T else \"No\"))",
"+from collections import Counter",
"+",
"+S = Counter(eval(input()))",
"+T = Counter(eval(input()))",
"+s = list(S.values())",
"+t = list(T.values())",
"+print((\"Yes\" if sorted(s) == sorted(t) else \"No\"))"
] | false | 0.038277 | 0.037601 | 1.017967 | [
"s411647715",
"s044457668"
] |
u476124554 | p03111 | python | s851744287 | s411541484 | 73 | 67 | 4,984 | 4,992 | Accepted | Accepted | 8.22 | n,a,b,c = list(map(int,input().split()))
l = []
ans = []
for i in range(n):
l.append(int(eval(input())))
def f(x,y,z,arr,ca,cb,cc):
global a
global b
global c
global ans
if arr:
f(x + arr[0], y, z, arr[1:],ca+1,cb,cc)
f(x, y + arr[0], z, arr[1:],ca,cb+1,cc)
f(x, y, z + arr[0], arr[1:],ca,cb,cc+1)
f(x, y, z, arr[1:],ca,cb,cc)
else:
if x > 0 and y > 0 and z > 0:
ans.append(abs(a-x) + abs(b-y) + abs(c-z) + 10 * (ca + cb + cc - 3))
f(0,0,0,l,0,0,0)
print((min(ans))) | n,a,b,c = list(map(int,input().split()))
l = []
ans = []
for i in range(n):
l.append(int(eval(input())))
def f(x,y,z,arr,cnt):
global a
global b
global c
global ans
if arr:
f(x + arr[0], y, z, arr[1:],cnt+1)
f(x, y + arr[0], z, arr[1:],cnt+1)
f(x, y, z + arr[0], arr[1:],cnt+1)
f(x, y, z, arr[1:],cnt)
else:
if x > 0 and y > 0 and z > 0:
ans.append(abs(a-x) + abs(b-y) + abs(c-z) + 10 * (cnt - 3))
f(0,0,0,l,0)
print((min(ans))) | 21 | 21 | 559 | 521 | n, a, b, c = list(map(int, input().split()))
l = []
ans = []
for i in range(n):
l.append(int(eval(input())))
def f(x, y, z, arr, ca, cb, cc):
global a
global b
global c
global ans
if arr:
f(x + arr[0], y, z, arr[1:], ca + 1, cb, cc)
f(x, y + arr[0], z, arr[1:], ca, cb + 1, cc)
f(x, y, z + arr[0], arr[1:], ca, cb, cc + 1)
f(x, y, z, arr[1:], ca, cb, cc)
else:
if x > 0 and y > 0 and z > 0:
ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (ca + cb + cc - 3))
f(0, 0, 0, l, 0, 0, 0)
print((min(ans)))
| n, a, b, c = list(map(int, input().split()))
l = []
ans = []
for i in range(n):
l.append(int(eval(input())))
def f(x, y, z, arr, cnt):
global a
global b
global c
global ans
if arr:
f(x + arr[0], y, z, arr[1:], cnt + 1)
f(x, y + arr[0], z, arr[1:], cnt + 1)
f(x, y, z + arr[0], arr[1:], cnt + 1)
f(x, y, z, arr[1:], cnt)
else:
if x > 0 and y > 0 and z > 0:
ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (cnt - 3))
f(0, 0, 0, l, 0)
print((min(ans)))
| false | 0 | [
"-def f(x, y, z, arr, ca, cb, cc):",
"+def f(x, y, z, arr, cnt):",
"- f(x + arr[0], y, z, arr[1:], ca + 1, cb, cc)",
"- f(x, y + arr[0], z, arr[1:], ca, cb + 1, cc)",
"- f(x, y, z + arr[0], arr[1:], ca, cb, cc + 1)",
"- f(x, y, z, arr[1:], ca, cb, cc)",
"+ f(x + arr[0], y, z, arr[1:], cnt + 1)",
"+ f(x, y + arr[0], z, arr[1:], cnt + 1)",
"+ f(x, y, z + arr[0], arr[1:], cnt + 1)",
"+ f(x, y, z, arr[1:], cnt)",
"- ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (ca + cb + cc - 3))",
"+ ans.append(abs(a - x) + abs(b - y) + abs(c - z) + 10 * (cnt - 3))",
"-f(0, 0, 0, l, 0, 0, 0)",
"+f(0, 0, 0, l, 0)"
] | false | 0.137399 | 0.116144 | 1.183008 | [
"s851744287",
"s411541484"
] |
u027622859 | p03835 | python | s797214419 | s244551950 | 1,635 | 1,441 | 2,940 | 2,940 | Accepted | Accepted | 11.87 | k, s = list(map(int, input().split()))
count = 0
for y in range(k+1):
for x in range(k+1):
z = s - x - y
if 0 <= z <= k:
count += 1
print(count) | k, s = list(map(int, input().split()))
count = 0
for x in range(k+1):
for y in range(k+1):
z = s-x-y
if 0 <= z <= k:
count += 1
print(count) | 8 | 8 | 177 | 173 | k, s = list(map(int, input().split()))
count = 0
for y in range(k + 1):
for x in range(k + 1):
z = s - x - y
if 0 <= z <= k:
count += 1
print(count)
| k, s = list(map(int, input().split()))
count = 0
for x in range(k + 1):
for y in range(k + 1):
z = s - x - y
if 0 <= z <= k:
count += 1
print(count)
| false | 0 | [
"-for y in range(k + 1):",
"- for x in range(k + 1):",
"+for x in range(k + 1):",
"+ for y in range(k + 1):"
] | false | 0.047076 | 0.046903 | 1.003688 | [
"s797214419",
"s244551950"
] |
u873190923 | p03240 | python | s794348566 | s283675662 | 245 | 125 | 43,244 | 79,012 | Accepted | Accepted | 48.98 | import sys
import bisect
inf = 10**15
mod = 10**9+7
def getH(Cx, Cy, x, y, h):
return h + abs(x-Cx) + abs(y-Cy)
inf = 10**15
mod = 10**9+7
n = int(eval(input()))
Hinfo = [list(map(int, input().split())) for i in range(n)]
H = -1
Hmax = inf
for Cx in range(101):
for Cy in range(101):
H = -1
flag = True
for tmp in Hinfo:
x,y,h = tmp
if h == 0:
Hmax = getH(Cx, Cy, x, y, h)
else:
canH = getH(Cx, Cy, x, y, h)
if H > 0:
if H != canH:
flag = False
break
else:
H = canH
if Hmax < H:
flag = False
break
if Hmax >= H and flag:
print(('{} {} {}'.format(Cx, Cy, H)))
sys.exit() | # input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools
sr = lambda: eval(input())
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
arr = []
temp = n
if n == 1:
return arr
for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
# a^n
def power(a, n, mod):
x = 1
while n:
if n & 1:
x *= a % mod
n >>= 1
a *= a % mod
return x % mod
# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
if n == 0:
return 1
a = n
tmp = n - 1
while (tmp >= l):
a = a * tmp % mod
tmp -= 1
return a
# Union Find
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
# 約数生成
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()
return divisors
inf = 10 ** 18
mod = 10 ** 9 + 7
n = ir()
xyh = [lr() for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for i in range(0,101):
for j in range(0,101):
H = abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
flag = True
for k in range(1,n):
h = abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
if not ((h>H and xyh[k][2]==0) or h==H):
flag = False
break
if flag:
print((i,j,H))
sys.exit() | 37 | 148 | 896 | 3,281 | import sys
import bisect
inf = 10**15
mod = 10**9 + 7
def getH(Cx, Cy, x, y, h):
return h + abs(x - Cx) + abs(y - Cy)
inf = 10**15
mod = 10**9 + 7
n = int(eval(input()))
Hinfo = [list(map(int, input().split())) for i in range(n)]
H = -1
Hmax = inf
for Cx in range(101):
for Cy in range(101):
H = -1
flag = True
for tmp in Hinfo:
x, y, h = tmp
if h == 0:
Hmax = getH(Cx, Cy, x, y, h)
else:
canH = getH(Cx, Cy, x, y, h)
if H > 0:
if H != canH:
flag = False
break
else:
H = canH
if Hmax < H:
flag = False
break
if Hmax >= H and flag:
print(("{} {} {}".format(Cx, Cy, H)))
sys.exit()
| # input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools
sr = lambda: eval(input())
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
arr = []
temp = n
if n == 1:
return arr
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
# a^n
def power(a, n, mod):
x = 1
while n:
if n & 1:
x *= a % mod
n >>= 1
a *= a % mod
return x % mod
# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
if n == 0:
return 1
a = n
tmp = n - 1
while tmp >= l:
a = a * tmp % mod
tmp -= 1
return a
# Union Find
class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots())
# 約数生成
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()
return divisors
inf = 10**18
mod = 10**9 + 7
n = ir()
xyh = [lr() for i in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)
for i in range(0, 101):
for j in range(0, 101):
H = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]
flag = True
for k in range(1, n):
h = abs(xyh[k][0] - i) + abs(xyh[k][1] - j) + xyh[k][2]
if not ((h > H and xyh[k][2] == 0) or h == H):
flag = False
break
if flag:
print((i, j, H))
sys.exit()
| false | 75 | [
"+# input()",
"+# int(input())",
"+# map(int, input().split())",
"+# list(map(int, input().split()))",
"+# list(map(int, list(input()))) # スペースがない数字リストを読み込み",
"+import math",
"+import fractions",
"+import heapq # 優先度付きキュー(最小値取り出し)",
"+import collections",
"+from collections import Counter",
"+from collections import deque",
"+import pprint",
"+import itertools",
"-inf = 10**15",
"-mod = 10**9 + 7",
"+sr = lambda: eval(input())",
"+ir = lambda: int(sr())",
"+lr = lambda: list(map(int, sr().split()))",
"+\"\"\"nを素因数分解\"\"\"",
"+\"\"\"2以上の整数n => [[素因数, 指数], ...]の2次元リスト\"\"\"",
"-def getH(Cx, Cy, x, y, h):",
"- return h + abs(x - Cx) + abs(y - Cy)",
"+def factorization(n):",
"+ arr = []",
"+ temp = n",
"+ if n == 1:",
"+ return arr",
"+ for i in range(2, int(-(-(n**0.5) // 1)) + 1):",
"+ if temp % i == 0:",
"+ cnt = 0",
"+ while temp % i == 0:",
"+ cnt += 1",
"+ temp //= i",
"+ arr.append([i, cnt])",
"+ if temp != 1:",
"+ arr.append([temp, 1])",
"+ if arr == []:",
"+ arr.append([n, 1])",
"+ return arr",
"-inf = 10**15",
"+# a^n",
"+def power(a, n, mod):",
"+ x = 1",
"+ while n:",
"+ if n & 1:",
"+ x *= a % mod",
"+ n >>= 1",
"+ a *= a % mod",
"+ return x % mod",
"+",
"+",
"+# n*(n-1)*...*(l+1)*l",
"+def kaijo(n, l, mod):",
"+ if n == 0:",
"+ return 1",
"+ a = n",
"+ tmp = n - 1",
"+ while tmp >= l:",
"+ a = a * tmp % mod",
"+ tmp -= 1",
"+ return a",
"+",
"+",
"+# Union Find",
"+class UnionFind:",
"+ def __init__(self, n):",
"+ self.n = n",
"+ self.parents = [-1] * n",
"+",
"+ def find(self, x):",
"+ if self.parents[x] < 0:",
"+ return x",
"+ else:",
"+ self.parents[x] = self.find(self.parents[x])",
"+ return self.parents[x]",
"+",
"+ def union(self, x, y):",
"+ x = self.find(x)",
"+ y = self.find(y)",
"+ if x == y:",
"+ return",
"+ if self.parents[x] > self.parents[y]:",
"+ x, y = y, x",
"+ self.parents[x] += self.parents[y]",
"+ self.parents[y] = x",
"+",
"+ def size(self, x):",
"+ return -self.parents[self.find(x)]",
"+",
"+ def same(self, x, y):",
"+ return self.find(x) == self.find(y)",
"+",
"+ def members(self, x):",
"+ root = self.find(x)",
"+ return [i for i in range(self.n) if self.find(i) == root]",
"+",
"+ def roots(self):",
"+ return [i for i, x in enumerate(self.parents) if x < 0]",
"+",
"+ def group_count(self):",
"+ return len(self.roots())",
"+",
"+ def all_group_members(self):",
"+ return {r: self.members(r) for r in self.roots()}",
"+",
"+ def __str__(self):",
"+ return \"\\n\".join(\"{}: {}\".format(r, self.members(r)) for r in self.roots())",
"+",
"+",
"+# 約数生成",
"+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()",
"+ return divisors",
"+",
"+",
"+inf = 10**18",
"-n = int(eval(input()))",
"-Hinfo = [list(map(int, input().split())) for i in range(n)]",
"-H = -1",
"-Hmax = inf",
"-for Cx in range(101):",
"- for Cy in range(101):",
"- H = -1",
"+n = ir()",
"+xyh = [lr() for i in range(n)]",
"+xyh.sort(key=lambda x: x[2], reverse=True)",
"+for i in range(0, 101):",
"+ for j in range(0, 101):",
"+ H = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]",
"- for tmp in Hinfo:",
"- x, y, h = tmp",
"- if h == 0:",
"- Hmax = getH(Cx, Cy, x, y, h)",
"- else:",
"- canH = getH(Cx, Cy, x, y, h)",
"- if H > 0:",
"- if H != canH:",
"- flag = False",
"- break",
"- else:",
"- H = canH",
"- if Hmax < H:",
"+ for k in range(1, n):",
"+ h = abs(xyh[k][0] - i) + abs(xyh[k][1] - j) + xyh[k][2]",
"+ if not ((h > H and xyh[k][2] == 0) or h == H):",
"- if Hmax >= H and flag:",
"- print((\"{} {} {}\".format(Cx, Cy, H)))",
"+ if flag:",
"+ print((i, j, H))"
] | false | 0.039768 | 0.036206 | 1.098403 | [
"s794348566",
"s283675662"
] |
u716660050 | p02995 | python | s028048576 | s290435346 | 39 | 29 | 5,304 | 9,132 | Accepted | Accepted | 25.64 | import fractions
a,b,c,d=list(map(int,input().split()))
g=fractions.gcd(c,d)
l=c*d//g
print((b-b//c-b//d+b//l-(a-1-(a-1)//c-(a-1)//d+(a-1)//l))) | import math as m
A,B,C,D=list(map(int,input().split()))
A-=1
g=C*D//m.gcd(C,D)
x=B//C-A//C
y=B//D-A//D
z=B//g-A//g
print((B-A-x-y+z)) | 5 | 8 | 140 | 132 | import fractions
a, b, c, d = list(map(int, input().split()))
g = fractions.gcd(c, d)
l = c * d // g
print(
(
b
- b // c
- b // d
+ b // l
- (a - 1 - (a - 1) // c - (a - 1) // d + (a - 1) // l)
)
)
| import math as m
A, B, C, D = list(map(int, input().split()))
A -= 1
g = C * D // m.gcd(C, D)
x = B // C - A // C
y = B // D - A // D
z = B // g - A // g
print((B - A - x - y + z))
| false | 37.5 | [
"-import fractions",
"+import math as m",
"-a, b, c, d = list(map(int, input().split()))",
"-g = fractions.gcd(c, d)",
"-l = c * d // g",
"-print(",
"- (",
"- b",
"- - b // c",
"- - b // d",
"- + b // l",
"- - (a - 1 - (a - 1) // c - (a - 1) // d + (a - 1) // l)",
"- )",
"-)",
"+A, B, C, D = list(map(int, input().split()))",
"+A -= 1",
"+g = C * D // m.gcd(C, D)",
"+x = B // C - A // C",
"+y = B // D - A // D",
"+z = B // g - A // g",
"+print((B - A - x - y + z))"
] | false | 0.053533 | 0.043341 | 1.23516 | [
"s028048576",
"s290435346"
] |
u074220993 | p03503 | python | s063818950 | s519157524 | 297 | 160 | 27,188 | 27,220 | Accepted | Accepted | 46.13 | import numpy as np
import heapq as hq
N = int(eval(input()))
F = np.array([[int(x) for x in input().split()] for _ in range(N)])
P = np.array([[int(x) for x in input().split()] for _ in range(N)])
Profit = []
for i in range(1,2**10): #bit全探索
Open = np.array([int(x) for x in format(i, '010b')]) #2進数をベクトルに変換
prf = 0
for f, p in zip(F, P):
cnt = np.dot(Open, f)
prf += p[cnt]
hq.heappush(Profit, -prf)
print((-Profit[0]))
| import numpy as np
import heapq as hq
N = int(eval(input()))
F = np.array([[int(x) for x in input().split()] for _ in range(N)])
P = np.array([[int(x) for x in input().split()] for _ in range(N)])
Profit = []
for i in range(1,2**10): #営業時間帯についてbit全探索
Open = np.array([int(x) for x in format(i, '010b')]).T #2進数を縦ベクトルに変換
c = np.dot(F, Open) #店別に被る時間帯の個数をベクトルとして算出
hq.heappush(Profit, -sum(P[i, c[i]] for i in range(N))) #-1倍した利益をProfitにpush。
print((-Profit[0])) #heapから最小値を取得
| 16 | 13 | 469 | 500 | import numpy as np
import heapq as hq
N = int(eval(input()))
F = np.array([[int(x) for x in input().split()] for _ in range(N)])
P = np.array([[int(x) for x in input().split()] for _ in range(N)])
Profit = []
for i in range(1, 2**10): # bit全探索
Open = np.array([int(x) for x in format(i, "010b")]) # 2進数をベクトルに変換
prf = 0
for f, p in zip(F, P):
cnt = np.dot(Open, f)
prf += p[cnt]
hq.heappush(Profit, -prf)
print((-Profit[0]))
| import numpy as np
import heapq as hq
N = int(eval(input()))
F = np.array([[int(x) for x in input().split()] for _ in range(N)])
P = np.array([[int(x) for x in input().split()] for _ in range(N)])
Profit = []
for i in range(1, 2**10): # 営業時間帯についてbit全探索
Open = np.array([int(x) for x in format(i, "010b")]).T # 2進数を縦ベクトルに変換
c = np.dot(F, Open) # 店別に被る時間帯の個数をベクトルとして算出
hq.heappush(Profit, -sum(P[i, c[i]] for i in range(N))) # -1倍した利益をProfitにpush。
print((-Profit[0])) # heapから最小値を取得
| false | 18.75 | [
"-for i in range(1, 2**10): # bit全探索",
"- Open = np.array([int(x) for x in format(i, \"010b\")]) # 2進数をベクトルに変換",
"- prf = 0",
"- for f, p in zip(F, P):",
"- cnt = np.dot(Open, f)",
"- prf += p[cnt]",
"- hq.heappush(Profit, -prf)",
"-print((-Profit[0]))",
"+for i in range(1, 2**10): # 営業時間帯についてbit全探索",
"+ Open = np.array([int(x) for x in format(i, \"010b\")]).T # 2進数を縦ベクトルに変換",
"+ c = np.dot(F, Open) # 店別に被る時間帯の個数をベクトルとして算出",
"+ hq.heappush(Profit, -sum(P[i, c[i]] for i in range(N))) # -1倍した利益をProfitにpush。",
"+print((-Profit[0])) # heapから最小値を取得"
] | false | 0.499505 | 0.214777 | 2.325686 | [
"s063818950",
"s519157524"
] |
u227476288 | p03051 | python | s278670173 | s862327297 | 674 | 536 | 138,528 | 128,848 | Accepted | Accepted | 20.47 | N = int(eval(input()))
A = [int(i) for i in input().split()]
mod = 10**9 + 7
b = [0]*N #
b[0] = A[0]
for n in range(1,N):
b[n] = A[n] ^ b[n-1]
#print('累積論理和',b)
m = max(b)
dp = [[0]*(m+1) for j in range(2)]
dp[0] = [True]*(m+1)
dp[1] = [False]*(m+1)
cnt = [0]*(m+1)
z = 0
for i in range(N):
if b[i] == 0:
z +=1
dp[0][b[i]] += dp[1][b[i]]*(z-cnt[b[i]])
dp[0][b[i]] %= mod
dp[1][b[i]] += dp[0][b[i]]
dp[1][b[i]] %= mod
cnt[b[i]] = z
if b[N-1]:
print((dp[0][b[N-1]]))
else:
ans = pow(2, z-1, mod)
for i in range(1,m+1):
ans += dp[1][i]
ans %= mod
print(ans) | N = int(eval(input()))
A = [int(i) for i in input().split()]
mod = 10**9 + 7
b = [0]*N
b[0] = A[0]
for n in range(1,N):
b[n] = A[n] ^ b[n-1]
#print('累積論理和',b)
m = max(b)
dp = [[0]*(m+1) for j in range(2)]
dp[0] = [1]*(m+1)
cnt = [0]*(m+1)
z = 0
for i in range(N):
if b[i] == 0:
z +=1
dp[0][b[i]] += dp[1][b[i]]*(z-cnt[b[i]])
dp[0][b[i]] %= mod
dp[1][b[i]] += dp[0][b[i]]
dp[1][b[i]] %= mod
cnt[b[i]] = z
if b[N-1]:
print((dp[0][b[N-1]]))
else:
ans = pow(2, z-1, mod)
for i in range(1,m+1):
ans += dp[1][i]
ans %= mod
print(ans) | 34 | 33 | 652 | 625 | N = int(eval(input()))
A = [int(i) for i in input().split()]
mod = 10**9 + 7
b = [0] * N #
b[0] = A[0]
for n in range(1, N):
b[n] = A[n] ^ b[n - 1]
# print('累積論理和',b)
m = max(b)
dp = [[0] * (m + 1) for j in range(2)]
dp[0] = [True] * (m + 1)
dp[1] = [False] * (m + 1)
cnt = [0] * (m + 1)
z = 0
for i in range(N):
if b[i] == 0:
z += 1
dp[0][b[i]] += dp[1][b[i]] * (z - cnt[b[i]])
dp[0][b[i]] %= mod
dp[1][b[i]] += dp[0][b[i]]
dp[1][b[i]] %= mod
cnt[b[i]] = z
if b[N - 1]:
print((dp[0][b[N - 1]]))
else:
ans = pow(2, z - 1, mod)
for i in range(1, m + 1):
ans += dp[1][i]
ans %= mod
print(ans)
| N = int(eval(input()))
A = [int(i) for i in input().split()]
mod = 10**9 + 7
b = [0] * N
b[0] = A[0]
for n in range(1, N):
b[n] = A[n] ^ b[n - 1]
# print('累積論理和',b)
m = max(b)
dp = [[0] * (m + 1) for j in range(2)]
dp[0] = [1] * (m + 1)
cnt = [0] * (m + 1)
z = 0
for i in range(N):
if b[i] == 0:
z += 1
dp[0][b[i]] += dp[1][b[i]] * (z - cnt[b[i]])
dp[0][b[i]] %= mod
dp[1][b[i]] += dp[0][b[i]]
dp[1][b[i]] %= mod
cnt[b[i]] = z
if b[N - 1]:
print((dp[0][b[N - 1]]))
else:
ans = pow(2, z - 1, mod)
for i in range(1, m + 1):
ans += dp[1][i]
ans %= mod
print(ans)
| false | 2.941176 | [
"-b = [0] * N #",
"+b = [0] * N",
"-dp[0] = [True] * (m + 1)",
"-dp[1] = [False] * (m + 1)",
"+dp[0] = [1] * (m + 1)"
] | false | 0.043045 | 0.042398 | 1.015262 | [
"s278670173",
"s862327297"
] |
u707498674 | p02863 | python | s472173628 | s362452015 | 775 | 360 | 177,416 | 112,860 | Accepted | Accepted | 53.55 | import sys
def input(): return sys.stdin.readline().strip()
def main():
N, T = list(map(int, input().split()))
cv = [tuple(map(int, input().split())) for _ in range(N)]
cv = sorted(cv, key=lambda x : x[0])
dp = [[0]*(T+1) for _ in range(N+1)]
dp_ext = [[0]*(T+1) for _ in range(N+1)]
values = [v for c, v in cv]
max_values = [max(values[i:]) for i in range(N)]
# 貰うdp
for i in range(N):
cost, value = cv[i]
for now in range(cost, T+1):
old = now - cost
dp[i+1][now] = max(dp[i][now], dp[i][old] + value)
for j in range(1, T+1):
dp[i+1][j] = max(dp[i+1][j], dp[i+1][j-1])
for j in range(1, T+1):
dp_ext[i+1][j] = max(dp[i+1][j], dp[i][j-1] + max_values[i], dp_ext[i][j])
print((dp_ext[N][T]))
if __name__ == "__main__":
main() | import sys
def input(): return sys.stdin.readline().strip()
def main():
N, T = list(map(int, input().split()))
cv = [tuple(map(int, input().split())) for _ in range(N)]
cv = sorted(cv, key=lambda x : x[0])
dp = [[0]*(T+1) for _ in range(N+1)]
# 貰うdp
ans = 0
for i in range(N):
cost, value = cv[i]
for now in range(min(T+1, cost)):
dp[i+1][now] = dp[i][now]
for now in range(cost, T+1):
old = now - cost
dp[i+1][now] = max(dp[i][now], dp[i][old] + value)
ans = max(ans, dp[i][T-1] + value)
print(ans)
if __name__ == "__main__":
main() | 30 | 27 | 885 | 672 | import sys
def input():
return sys.stdin.readline().strip()
def main():
N, T = list(map(int, input().split()))
cv = [tuple(map(int, input().split())) for _ in range(N)]
cv = sorted(cv, key=lambda x: x[0])
dp = [[0] * (T + 1) for _ in range(N + 1)]
dp_ext = [[0] * (T + 1) for _ in range(N + 1)]
values = [v for c, v in cv]
max_values = [max(values[i:]) for i in range(N)]
# 貰うdp
for i in range(N):
cost, value = cv[i]
for now in range(cost, T + 1):
old = now - cost
dp[i + 1][now] = max(dp[i][now], dp[i][old] + value)
for j in range(1, T + 1):
dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - 1])
for j in range(1, T + 1):
dp_ext[i + 1][j] = max(
dp[i + 1][j], dp[i][j - 1] + max_values[i], dp_ext[i][j]
)
print((dp_ext[N][T]))
if __name__ == "__main__":
main()
| import sys
def input():
return sys.stdin.readline().strip()
def main():
N, T = list(map(int, input().split()))
cv = [tuple(map(int, input().split())) for _ in range(N)]
cv = sorted(cv, key=lambda x: x[0])
dp = [[0] * (T + 1) for _ in range(N + 1)]
# 貰うdp
ans = 0
for i in range(N):
cost, value = cv[i]
for now in range(min(T + 1, cost)):
dp[i + 1][now] = dp[i][now]
for now in range(cost, T + 1):
old = now - cost
dp[i + 1][now] = max(dp[i][now], dp[i][old] + value)
ans = max(ans, dp[i][T - 1] + value)
print(ans)
if __name__ == "__main__":
main()
| false | 10 | [
"- dp_ext = [[0] * (T + 1) for _ in range(N + 1)]",
"- values = [v for c, v in cv]",
"- max_values = [max(values[i:]) for i in range(N)]",
"+ ans = 0",
"+ for now in range(min(T + 1, cost)):",
"+ dp[i + 1][now] = dp[i][now]",
"- for j in range(1, T + 1):",
"- dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - 1])",
"- for j in range(1, T + 1):",
"- dp_ext[i + 1][j] = max(",
"- dp[i + 1][j], dp[i][j - 1] + max_values[i], dp_ext[i][j]",
"- )",
"- print((dp_ext[N][T]))",
"+ ans = max(ans, dp[i][T - 1] + value)",
"+ print(ans)"
] | false | 0.03507 | 0.035909 | 0.976628 | [
"s472173628",
"s362452015"
] |
u543954314 | p03291 | python | s060792429 | s147362985 | 105 | 93 | 3,188 | 3,188 | Accepted | Accepted | 11.43 | S = eval(input())
N = len(S)
a,b,c,d = 0,0,0,1
mod = 10**9+7
for x in reversed(S):
if x == "?":
a,b,c,d = 3*a+b, 3*b+c, 3*c+d, 3*d
elif x == "A":
a += b
elif x == "B":
b += c
elif x == "C":
c += d
a %= mod; b %= mod; c %= mod; d %= mod
print(a) | S = eval(input()); N = len(S)
a,b,c,d = 0,0,0,1
mod = 10**9+7
for x in reversed(S):
if x == "?":
a,b,c,d = (3*a+b)%mod, (3*b+c)%mod, (3*c+d)%mod, 3*d%mod
elif x == "A": a = (a+b)%mod
elif x == "B": b = (b+c)%mod
elif x == "C": c = (c+d)%mod
print(a) | 15 | 10 | 278 | 264 | S = eval(input())
N = len(S)
a, b, c, d = 0, 0, 0, 1
mod = 10**9 + 7
for x in reversed(S):
if x == "?":
a, b, c, d = 3 * a + b, 3 * b + c, 3 * c + d, 3 * d
elif x == "A":
a += b
elif x == "B":
b += c
elif x == "C":
c += d
a %= mod
b %= mod
c %= mod
d %= mod
print(a)
| S = eval(input())
N = len(S)
a, b, c, d = 0, 0, 0, 1
mod = 10**9 + 7
for x in reversed(S):
if x == "?":
a, b, c, d = (
(3 * a + b) % mod,
(3 * b + c) % mod,
(3 * c + d) % mod,
3 * d % mod,
)
elif x == "A":
a = (a + b) % mod
elif x == "B":
b = (b + c) % mod
elif x == "C":
c = (c + d) % mod
print(a)
| false | 33.333333 | [
"- a, b, c, d = 3 * a + b, 3 * b + c, 3 * c + d, 3 * d",
"+ a, b, c, d = (",
"+ (3 * a + b) % mod,",
"+ (3 * b + c) % mod,",
"+ (3 * c + d) % mod,",
"+ 3 * d % mod,",
"+ )",
"- a += b",
"+ a = (a + b) % mod",
"- b += c",
"+ b = (b + c) % mod",
"- c += d",
"- a %= mod",
"- b %= mod",
"- c %= mod",
"- d %= mod",
"+ c = (c + d) % mod"
] | false | 0.068487 | 0.074459 | 0.919798 | [
"s060792429",
"s147362985"
] |
u561083515 | p02779 | python | s777134993 | s917925472 | 198 | 141 | 25,172 | 33,740 | Accepted | Accepted | 28.79 | N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
flag = False
for i in range(1,N):
if A[i-1] == A[i]:
flag = True
if flag:
print("NO")
else:
print("YES") | N = int(eval(input()))
A = [int(i) for i in input().split()]
from collections import Counter
Acnt = Counter(A)
flag = False
for _, cnt in list(Acnt.items()):
if cnt > 1:
flag = True
if flag:
print("NO")
else:
print("YES") | 12 | 15 | 204 | 246 | N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
flag = False
for i in range(1, N):
if A[i - 1] == A[i]:
flag = True
if flag:
print("NO")
else:
print("YES")
| N = int(eval(input()))
A = [int(i) for i in input().split()]
from collections import Counter
Acnt = Counter(A)
flag = False
for _, cnt in list(Acnt.items()):
if cnt > 1:
flag = True
if flag:
print("NO")
else:
print("YES")
| false | 20 | [
"-A = sorted([int(i) for i in input().split()])",
"+A = [int(i) for i in input().split()]",
"+from collections import Counter",
"+",
"+Acnt = Counter(A)",
"-for i in range(1, N):",
"- if A[i - 1] == A[i]:",
"+for _, cnt in list(Acnt.items()):",
"+ if cnt > 1:"
] | false | 0.032605 | 0.032655 | 0.998463 | [
"s777134993",
"s917925472"
] |
u771532493 | p03659 | python | s725228630 | s491634773 | 495 | 226 | 24,832 | 24,948 | Accepted | Accepted | 54.34 | N=int(eval(input()))
lst=[int(i) for i in input().split()]
import numpy
res=numpy.cumsum(lst)
ans=10e20
for i in range(N-1):
ans=min(ans,abs(res[i]-(res[-1]-res[i])))
print(ans) | n=int(eval(input()))
l=[int(i) for i in input().split()]
lst=[0]
for i in l:
lst.append(lst[-1]+i)
sm=lst[-1]
ans=10**20
for i in range(1,n):
x=lst[i]
y=sm-x
a=abs(x-y)
ans=min(ans,a)
print(ans) | 8 | 13 | 180 | 220 | N = int(eval(input()))
lst = [int(i) for i in input().split()]
import numpy
res = numpy.cumsum(lst)
ans = 10e20
for i in range(N - 1):
ans = min(ans, abs(res[i] - (res[-1] - res[i])))
print(ans)
| n = int(eval(input()))
l = [int(i) for i in input().split()]
lst = [0]
for i in l:
lst.append(lst[-1] + i)
sm = lst[-1]
ans = 10**20
for i in range(1, n):
x = lst[i]
y = sm - x
a = abs(x - y)
ans = min(ans, a)
print(ans)
| false | 38.461538 | [
"-N = int(eval(input()))",
"-lst = [int(i) for i in input().split()]",
"-import numpy",
"-",
"-res = numpy.cumsum(lst)",
"-ans = 10e20",
"-for i in range(N - 1):",
"- ans = min(ans, abs(res[i] - (res[-1] - res[i])))",
"+n = int(eval(input()))",
"+l = [int(i) for i in input().split()]",
"+lst = [0]",
"+for i in l:",
"+ lst.append(lst[-1] + i)",
"+sm = lst[-1]",
"+ans = 10**20",
"+for i in range(1, n):",
"+ x = lst[i]",
"+ y = sm - x",
"+ a = abs(x - y)",
"+ ans = min(ans, a)"
] | false | 0.39912 | 0.047734 | 8.361246 | [
"s725228630",
"s491634773"
] |
u983918956 | p03450 | python | s938096038 | s156882961 | 1,711 | 1,362 | 9,388 | 8,812 | Accepted | Accepted | 20.4 | class Unionfind:
__slots__ = ["nodes","diff_weight"]
def __init__(self, n):
self.nodes = [-1]*n
self.diff_weight = [0]*n
def root(self, x):
if self.nodes[x] < 0:
return x
else:
root_x = self.root(self.nodes[x])
self.diff_weight[x] += self.diff_weight[self.nodes[x]]
self.nodes[x] = root_x
return root_x
def unite(self, x, y, w=0):
w += self.weight(x); w -= self.weight(y)
x = self.root(x); y = self.root(y)
if x == y:
return
rank_x = -self.nodes[x]; rank_y = -self.nodes[y]
if rank_x < rank_y:
x, y = y, x; w = -w
if rank_x == rank_y:
self.nodes[x] -= 1
self.nodes[y] = x
self.diff_weight[y] = w
def weight(self, x):
self.root(x)
return self.diff_weight[x]
def diff(self, x, y):
return self.weight(y) - self.weight(x)
def same(self, x, y):
return self.root(x) == self.root(y)
def rank(self, x):
return -self.nodes[self.root(x)]
N,M = list(map(int,input().split()))
uf = Unionfind(N)
ans = "Yes"
for _ in range(M):
L, R, D = list(map(int,input().split()))
L -= 1; R -= 1
uf.unite(L, R, D)
if uf.diff(L, R) != D:
ans = "No"
break
print(ans) | import sys
input = sys.stdin.readline
class Unionfind:
__slots__ = ["nodes","diff_weight"]
def __init__(self, n):
self.nodes = [-1]*n
self.diff_weight = [0]*n
def root(self, x):
if self.nodes[x] < 0:
return x
else:
root_x = self.root(self.nodes[x])
self.diff_weight[x] += self.diff_weight[self.nodes[x]]
self.nodes[x] = root_x
return root_x
def unite(self, x, y, w=0):
w += self.weight(x); w -= self.weight(y)
x = self.root(x); y = self.root(y)
if x == y:
return
rank_x = -self.nodes[x]; rank_y = -self.nodes[y]
if rank_x < rank_y:
x, y = y, x; w = -w
if rank_x == rank_y:
self.nodes[x] -= 1
self.nodes[y] = x
self.diff_weight[y] = w
def weight(self, x):
self.root(x)
return self.diff_weight[x]
def diff(self, x, y):
return self.weight(y) - self.weight(x)
def same(self, x, y):
return self.root(x) == self.root(y)
def rank(self, x):
return -self.nodes[self.root(x)]
N,M = list(map(int,input().split()))
uf = Unionfind(N)
ans = "Yes"
for _ in range(M):
L, R, D = list(map(int,input().split()))
L -= 1; R -= 1
uf.unite(L, R, D)
if uf.diff(L, R) != D:
ans = "No"
break
print(ans) | 53 | 56 | 1,402 | 1,447 | class Unionfind:
__slots__ = ["nodes", "diff_weight"]
def __init__(self, n):
self.nodes = [-1] * n
self.diff_weight = [0] * n
def root(self, x):
if self.nodes[x] < 0:
return x
else:
root_x = self.root(self.nodes[x])
self.diff_weight[x] += self.diff_weight[self.nodes[x]]
self.nodes[x] = root_x
return root_x
def unite(self, x, y, w=0):
w += self.weight(x)
w -= self.weight(y)
x = self.root(x)
y = self.root(y)
if x == y:
return
rank_x = -self.nodes[x]
rank_y = -self.nodes[y]
if rank_x < rank_y:
x, y = y, x
w = -w
if rank_x == rank_y:
self.nodes[x] -= 1
self.nodes[y] = x
self.diff_weight[y] = w
def weight(self, x):
self.root(x)
return self.diff_weight[x]
def diff(self, x, y):
return self.weight(y) - self.weight(x)
def same(self, x, y):
return self.root(x) == self.root(y)
def rank(self, x):
return -self.nodes[self.root(x)]
N, M = list(map(int, input().split()))
uf = Unionfind(N)
ans = "Yes"
for _ in range(M):
L, R, D = list(map(int, input().split()))
L -= 1
R -= 1
uf.unite(L, R, D)
if uf.diff(L, R) != D:
ans = "No"
break
print(ans)
| import sys
input = sys.stdin.readline
class Unionfind:
__slots__ = ["nodes", "diff_weight"]
def __init__(self, n):
self.nodes = [-1] * n
self.diff_weight = [0] * n
def root(self, x):
if self.nodes[x] < 0:
return x
else:
root_x = self.root(self.nodes[x])
self.diff_weight[x] += self.diff_weight[self.nodes[x]]
self.nodes[x] = root_x
return root_x
def unite(self, x, y, w=0):
w += self.weight(x)
w -= self.weight(y)
x = self.root(x)
y = self.root(y)
if x == y:
return
rank_x = -self.nodes[x]
rank_y = -self.nodes[y]
if rank_x < rank_y:
x, y = y, x
w = -w
if rank_x == rank_y:
self.nodes[x] -= 1
self.nodes[y] = x
self.diff_weight[y] = w
def weight(self, x):
self.root(x)
return self.diff_weight[x]
def diff(self, x, y):
return self.weight(y) - self.weight(x)
def same(self, x, y):
return self.root(x) == self.root(y)
def rank(self, x):
return -self.nodes[self.root(x)]
N, M = list(map(int, input().split()))
uf = Unionfind(N)
ans = "Yes"
for _ in range(M):
L, R, D = list(map(int, input().split()))
L -= 1
R -= 1
uf.unite(L, R, D)
if uf.diff(L, R) != D:
ans = "No"
break
print(ans)
| false | 5.357143 | [
"+import sys",
"+",
"+input = sys.stdin.readline",
"+",
"+"
] | false | 0.041009 | 0.040471 | 1.013299 | [
"s938096038",
"s156882961"
] |
u935558307 | p03295 | python | s349558181 | s961506339 | 582 | 508 | 29,152 | 20,168 | Accepted | Accepted | 12.71 | import numpy as np
def main():
N,M = list(map(int,input().split()))
ab=[]
for _ in range(M):
a,b = list(map(int,input().split()))
ab.append([b,a])
ab.sort()
tmp=0
count = 0
for i in range(M):
if ab[i][1] >= tmp:
tmp = ab[i][0]
count += 1
print(count)
main() | N,M = list(map(int,input().split()))
ts = []
for i in range(M):
a,b = list(map(int,input().split()))
ts.append([b,a])
ts.sort()
tmp = 0
count = 0
for i in range(M):
if ts[i][1]>=tmp:
tmp = ts[i][0]
count += 1
print(count) | 18 | 13 | 304 | 249 | import numpy as np
def main():
N, M = list(map(int, input().split()))
ab = []
for _ in range(M):
a, b = list(map(int, input().split()))
ab.append([b, a])
ab.sort()
tmp = 0
count = 0
for i in range(M):
if ab[i][1] >= tmp:
tmp = ab[i][0]
count += 1
print(count)
main()
| N, M = list(map(int, input().split()))
ts = []
for i in range(M):
a, b = list(map(int, input().split()))
ts.append([b, a])
ts.sort()
tmp = 0
count = 0
for i in range(M):
if ts[i][1] >= tmp:
tmp = ts[i][0]
count += 1
print(count)
| false | 27.777778 | [
"-import numpy as np",
"-",
"-",
"-def main():",
"- N, M = list(map(int, input().split()))",
"- ab = []",
"- for _ in range(M):",
"- a, b = list(map(int, input().split()))",
"- ab.append([b, a])",
"- ab.sort()",
"- tmp = 0",
"- count = 0",
"- for i in range(M):",
"- if ab[i][1] >= tmp:",
"- tmp = ab[i][0]",
"- count += 1",
"- print(count)",
"-",
"-",
"-main()",
"+N, M = list(map(int, input().split()))",
"+ts = []",
"+for i in range(M):",
"+ a, b = list(map(int, input().split()))",
"+ ts.append([b, a])",
"+ts.sort()",
"+tmp = 0",
"+count = 0",
"+for i in range(M):",
"+ if ts[i][1] >= tmp:",
"+ tmp = ts[i][0]",
"+ count += 1",
"+print(count)"
] | false | 0.059324 | 0.043918 | 1.350798 | [
"s349558181",
"s961506339"
] |
u232852711 | p03111 | python | s035669461 | s228817862 | 661 | 75 | 3,064 | 3,064 | Accepted | Accepted | 88.65 | n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
ans = 10**9
for m in range(4**n):
length = [0, 0, 0, 0]
counts = [0, 0, 0, 0]
for d in range(n-1, -1, -1):
i = m//(4**d)
length[i] += l[d]
counts[i] += 1
m %= 4**d
if 0 in length[:3]:
continue
ans_tmp = 0
for i in range(3):
ans_tmp += abs([a,b,c][i] - length[i]) + 10*(counts[i]-1)
ans = min(ans, ans_tmp)
print(ans)
| inf = 10**9
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
def dfs(i, a_cur, b_cur, c_cur):
if i == n:
return abs(a_cur-a) + abs(b_cur-b) + abs(c_cur-c) - 30 if min(a_cur, b_cur, c_cur) > 0 else inf
ans0 = dfs(i+1, a_cur+l[i], b_cur, c_cur) + 10
ans1 = dfs(i+1, a_cur, b_cur+l[i], c_cur) + 10
ans2 = dfs(i+1, a_cur, b_cur, c_cur+l[i]) + 10
ans3 = dfs(i+1, a_cur, b_cur, c_cur)
return min(ans0, ans1, ans2, ans3)
print((dfs(0, 0, 0, 0))) | 20 | 14 | 498 | 510 | n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
ans = 10**9
for m in range(4**n):
length = [0, 0, 0, 0]
counts = [0, 0, 0, 0]
for d in range(n - 1, -1, -1):
i = m // (4**d)
length[i] += l[d]
counts[i] += 1
m %= 4**d
if 0 in length[:3]:
continue
ans_tmp = 0
for i in range(3):
ans_tmp += abs([a, b, c][i] - length[i]) + 10 * (counts[i] - 1)
ans = min(ans, ans_tmp)
print(ans)
| inf = 10**9
n, a, b, c = list(map(int, input().split()))
l = [int(eval(input())) for _ in range(n)]
def dfs(i, a_cur, b_cur, c_cur):
if i == n:
return (
abs(a_cur - a) + abs(b_cur - b) + abs(c_cur - c) - 30
if min(a_cur, b_cur, c_cur) > 0
else inf
)
ans0 = dfs(i + 1, a_cur + l[i], b_cur, c_cur) + 10
ans1 = dfs(i + 1, a_cur, b_cur + l[i], c_cur) + 10
ans2 = dfs(i + 1, a_cur, b_cur, c_cur + l[i]) + 10
ans3 = dfs(i + 1, a_cur, b_cur, c_cur)
return min(ans0, ans1, ans2, ans3)
print((dfs(0, 0, 0, 0)))
| false | 30 | [
"+inf = 10**9",
"-ans = 10**9",
"-for m in range(4**n):",
"- length = [0, 0, 0, 0]",
"- counts = [0, 0, 0, 0]",
"- for d in range(n - 1, -1, -1):",
"- i = m // (4**d)",
"- length[i] += l[d]",
"- counts[i] += 1",
"- m %= 4**d",
"- if 0 in length[:3]:",
"- continue",
"- ans_tmp = 0",
"- for i in range(3):",
"- ans_tmp += abs([a, b, c][i] - length[i]) + 10 * (counts[i] - 1)",
"- ans = min(ans, ans_tmp)",
"-print(ans)",
"+",
"+",
"+def dfs(i, a_cur, b_cur, c_cur):",
"+ if i == n:",
"+ return (",
"+ abs(a_cur - a) + abs(b_cur - b) + abs(c_cur - c) - 30",
"+ if min(a_cur, b_cur, c_cur) > 0",
"+ else inf",
"+ )",
"+ ans0 = dfs(i + 1, a_cur + l[i], b_cur, c_cur) + 10",
"+ ans1 = dfs(i + 1, a_cur, b_cur + l[i], c_cur) + 10",
"+ ans2 = dfs(i + 1, a_cur, b_cur, c_cur + l[i]) + 10",
"+ ans3 = dfs(i + 1, a_cur, b_cur, c_cur)",
"+ return min(ans0, ans1, ans2, ans3)",
"+",
"+",
"+print((dfs(0, 0, 0, 0)))"
] | false | 0.499052 | 0.058359 | 8.551387 | [
"s035669461",
"s228817862"
] |
u352499693 | p03474 | python | s604703188 | s215047352 | 11 | 10 | 2,568 | 2,568 | Accepted | Accepted | 9.09 | a=list(map(int,input().split()));t=list(map(len,input().split('-')));print(['No','Yes'][a==t]) | print(['No','Yes'][list(map(int,input().split()))==list(map(len,input().split('-')))]) | 1 | 1 | 88 | 80 | a = list(map(int, input().split()))
t = list(map(len, input().split("-")))
print(["No", "Yes"][a == t])
| print(
["No", "Yes"][list(map(int, input().split())) == list(map(len, input().split("-")))]
)
| false | 0 | [
"-a = list(map(int, input().split()))",
"-t = list(map(len, input().split(\"-\")))",
"-print([\"No\", \"Yes\"][a == t])",
"+print(",
"+ [\"No\", \"Yes\"][list(map(int, input().split())) == list(map(len, input().split(\"-\")))]",
"+)"
] | false | 0.033407 | 0.103225 | 0.323631 | [
"s604703188",
"s215047352"
] |
u133936772 | p02640 | python | s039703568 | s738624840 | 23 | 21 | 9,032 | 9,168 | Accepted | Accepted | 8.7 | x,y=list(map(int,input().split()))
print(('YNeos'[y%2 or x*2-y//2<0 or y//2-x<0::2])) | x,y=list(map(int,input().split()))
print(('YNeos'[y%2 or x*2<y//2 or y//2<x::2])) | 2 | 2 | 78 | 74 | x, y = list(map(int, input().split()))
print(("YNeos"[y % 2 or x * 2 - y // 2 < 0 or y // 2 - x < 0 :: 2]))
| x, y = list(map(int, input().split()))
print(("YNeos"[y % 2 or x * 2 < y // 2 or y // 2 < x :: 2]))
| false | 0 | [
"-print((\"YNeos\"[y % 2 or x * 2 - y // 2 < 0 or y // 2 - x < 0 :: 2]))",
"+print((\"YNeos\"[y % 2 or x * 2 < y // 2 or y // 2 < x :: 2]))"
] | false | 0.056526 | 0.037539 | 1.505798 | [
"s039703568",
"s738624840"
] |
u671060652 | p03206 | python | s841657883 | s559557951 | 259 | 72 | 63,980 | 61,832 | Accepted | Accepted | 72.2 | import itertools
import math
import fractions
import functools
import copy
D = int(eval(input()))
if D == 25: print("Christmas")
if D == 24: print("Christmas Eve")
if D == 23: print("Christmas Eve Eve")
if D == 22: print("Christmas Eve Eve Eve") | def main():
n = int(eval(input()))
# t, a = map(int, input().split())
# h = list(map(int, input().split()))
# s = input()
if n == 25:
print("Christmas")
elif n== 24:
print("Christmas Eve")
elif n==23:
print("Christmas Eve Eve")
elif n==22:
print("Christmas Eve Eve Eve")
if __name__ == '__main__':
main()
| 12 | 18 | 252 | 387 | import itertools
import math
import fractions
import functools
import copy
D = int(eval(input()))
if D == 25:
print("Christmas")
if D == 24:
print("Christmas Eve")
if D == 23:
print("Christmas Eve Eve")
if D == 22:
print("Christmas Eve Eve Eve")
| def main():
n = int(eval(input()))
# t, a = map(int, input().split())
# h = list(map(int, input().split()))
# s = input()
if n == 25:
print("Christmas")
elif n == 24:
print("Christmas Eve")
elif n == 23:
print("Christmas Eve Eve")
elif n == 22:
print("Christmas Eve Eve Eve")
if __name__ == "__main__":
main()
| false | 33.333333 | [
"-import itertools",
"-import math",
"-import fractions",
"-import functools",
"-import copy",
"+def main():",
"+ n = int(eval(input()))",
"+ # t, a = map(int, input().split())",
"+ # h = list(map(int, input().split()))",
"+ # s = input()",
"+ if n == 25:",
"+ print(\"Christmas\")",
"+ elif n == 24:",
"+ print(\"Christmas Eve\")",
"+ elif n == 23:",
"+ print(\"Christmas Eve Eve\")",
"+ elif n == 22:",
"+ print(\"Christmas Eve Eve Eve\")",
"-D = int(eval(input()))",
"-if D == 25:",
"- print(\"Christmas\")",
"-if D == 24:",
"- print(\"Christmas Eve\")",
"-if D == 23:",
"- print(\"Christmas Eve Eve\")",
"-if D == 22:",
"- print(\"Christmas Eve Eve Eve\")",
"+",
"+if __name__ == \"__main__\":",
"+ main()"
] | false | 0.041139 | 0.054242 | 0.758433 | [
"s841657883",
"s559557951"
] |
u631277801 | p03805 | python | s953701561 | s979131905 | 81 | 38 | 3,572 | 3,064 | Accepted | Accepted | 53.09 | from itertools import permutations
N,M = list(map(int, input().split()))
AB = set()
for i in range(M):
A,B = list(map(int, input().split()))
AB.add((A-1,B-1))
s = ""
for i in range(1,N):
s = s + str(i)
paths = permutations(s,N-1)
paths = list(paths)
ans = 0
for path in paths:
path = [0] + [int(i) for i in path]
for i in range(N-1):
if (not (path[i],path[i+1]) in AB) and (not (path[i+1], path[i]) in AB):
break
if i == N-2:
ans += 1
print(ans) | # 入力
import sys
stdin = sys.stdin
def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())
from itertools import permutations
# 全探索をするのです
n,m = li()
edges = set()
for _ in range(m):
a,b = li()
edges.add((a,b))
edges.add((b,a))
paths = permutations([str(i) for i in range(2,n+1)],n-1)
cnt = 0
for path in paths:
path = [1] + [int(i) for i in path]
exist = True
for i in range(n-1):
if not (path[i], path[i+1]) in edges:
exist = False
if exist:
cnt += 1
print(cnt) | 27 | 37 | 542 | 874 | from itertools import permutations
N, M = list(map(int, input().split()))
AB = set()
for i in range(M):
A, B = list(map(int, input().split()))
AB.add((A - 1, B - 1))
s = ""
for i in range(1, N):
s = s + str(i)
paths = permutations(s, N - 1)
paths = list(paths)
ans = 0
for path in paths:
path = [0] + [int(i) for i in path]
for i in range(N - 1):
if (not (path[i], path[i + 1]) in AB) and (not (path[i + 1], path[i]) in AB):
break
if i == N - 2:
ans += 1
print(ans)
| # 入力
import sys
stdin = sys.stdin
def li():
return [int(x) for x in stdin.readline().split()]
def li_():
return [int(x) - 1 for x in stdin.readline().split()]
def lf():
return [float(x) for x in stdin.readline().split()]
def ls():
return stdin.readline().split()
def ns():
return stdin.readline().rstrip()
def lc():
return list(ns())
def ni():
return int(ns())
def nf():
return float(ns())
from itertools import permutations
# 全探索をするのです
n, m = li()
edges = set()
for _ in range(m):
a, b = li()
edges.add((a, b))
edges.add((b, a))
paths = permutations([str(i) for i in range(2, n + 1)], n - 1)
cnt = 0
for path in paths:
path = [1] + [int(i) for i in path]
exist = True
for i in range(n - 1):
if not (path[i], path[i + 1]) in edges:
exist = False
if exist:
cnt += 1
print(cnt)
| false | 27.027027 | [
"+# 入力",
"+import sys",
"+",
"+stdin = sys.stdin",
"+",
"+",
"+def li():",
"+ return [int(x) for x in stdin.readline().split()]",
"+",
"+",
"+def li_():",
"+ return [int(x) - 1 for x in stdin.readline().split()]",
"+",
"+",
"+def lf():",
"+ return [float(x) for x in stdin.readline().split()]",
"+",
"+",
"+def ls():",
"+ return stdin.readline().split()",
"+",
"+",
"+def ns():",
"+ return stdin.readline().rstrip()",
"+",
"+",
"+def lc():",
"+ return list(ns())",
"+",
"+",
"+def ni():",
"+ return int(ns())",
"+",
"+",
"+def nf():",
"+ return float(ns())",
"+",
"+",
"-N, M = list(map(int, input().split()))",
"-AB = set()",
"-for i in range(M):",
"- A, B = list(map(int, input().split()))",
"- AB.add((A - 1, B - 1))",
"-s = \"\"",
"-for i in range(1, N):",
"- s = s + str(i)",
"-paths = permutations(s, N - 1)",
"-paths = list(paths)",
"-ans = 0",
"+# 全探索をするのです",
"+n, m = li()",
"+edges = set()",
"+for _ in range(m):",
"+ a, b = li()",
"+ edges.add((a, b))",
"+ edges.add((b, a))",
"+paths = permutations([str(i) for i in range(2, n + 1)], n - 1)",
"+cnt = 0",
"- path = [0] + [int(i) for i in path]",
"- for i in range(N - 1):",
"- if (not (path[i], path[i + 1]) in AB) and (not (path[i + 1], path[i]) in AB):",
"- break",
"- if i == N - 2:",
"- ans += 1",
"-print(ans)",
"+ path = [1] + [int(i) for i in path]",
"+ exist = True",
"+ for i in range(n - 1):",
"+ if not (path[i], path[i + 1]) in edges:",
"+ exist = False",
"+ if exist:",
"+ cnt += 1",
"+print(cnt)"
] | false | 0.125434 | 0.132892 | 0.943881 | [
"s953701561",
"s979131905"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.