if dist_y < dist[y]: dist[y] = dist_y heappush(q, B * dist_y + y) x = dist[5 * T] if x == INF: return -1 return dist[5 * T] // K if sys.argv[-1] == 'ONLINE_JUDGE': from numba.pycc import CC cc = CC('my_module') cc.export('main', '(b1[:],i8,i8,i8,i8,i8)')(main) cc.compile() exit() from my_module import main H, W, K = map(int, readline().split()) x1, y1, x2, y2 = map(int, readline().split()) C = np.zeros((H + 2, W + 2), np.bool_) C[1:-1, 1:-1] = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] == b'.' C = C.ravel() H += 2 W += 2 S = W * x1 + y1 T = W * x2 + y2 print(main(C, H, W, S, T, K))
minvalue = old_min() answers[t] = minvalue return answers USE_NUMBA = False if USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE' or sys.argv[-1] == '-c': print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'void(i8,i8)')(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: if USE_NUMBA and sys.argv[-1] != '-p': # -p: pure python mode # if not -p, import compiled module from my_module import main # pylint: disable=all elif sys.argv[-1] == "-t": _test() exit() elif len(sys.argv) == 2: # input given as file input_as_file = open(sys.argv[1]) input = input_as_file.buffer.readline # read parameter print(*main(), sep="\n")
import sys import numba import numpy as np def main(xs): ret = 0 a = {} for x in xs: a[x] = ret ret += x return ret if sys.argv[-1] == "-c": # numba compile print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'i8(i8[:])')(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: from my_module import main print(main(np.array(range(10))))
count += c[x] ln += 1 if x == i: if t > ln: if count > 0: sub += (t // ln - 1) * count t %= ln t += ln else: t = 0 l = False sub += c[x] t -= 1 ans = max(sub, ans) if t < 1: break return ans # >>> numba compile >>> if sys.argv[-1] == 'ONLINE_JUDGE' or sys.argv[-1] == 'main.py': from numba.pycc import CC cc = CC('my_module') cc.export('main', 'i8(i8,i8,i8[:],i8[:])')(main) cc.compile() exit() from my_module import main # <<< numba compile <<< (n, k), p, c = [np.int_(i.split()) for i in open(0)] print(main(n, k, p, c))
# plan to visit neighbors for i in range(4): if not ng_edges[pos][i]: next = pos + direction[i] if visited[next]: continue to_visit.append(next) else: print(total_area) if sys.argv[-1] == 'ONLINE_JUDGE' or sys.argv[-1] == '-c': print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', "void(i4, i4, i4[:])")(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: if sys.argv[-1] != '-p': # -p: pure python mode # if not -p, import compiled module from my_module import main # pylint: disable=all # read parameter import numba N, M = map(int, input().split()) data = np.int32(sys.stdin.read().split()) main(N, M, data)
return result[0] # print(sys.argv) if sys.argv[-1] == 'ONLINE_JUDGE': print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'i8(i8,i8,i8,i8,i8,i8,i8,b1[:])')(main) cc.compile() exit() else: H, W, K = map(int, input().split()) x1, y1, x2, y2 = map(int, input().split()) from my_module import main import numpy as np C = np.zeros((H + 2, W + 2), np.bool_) data = np.frombuffer(sys.stdin.buffer.read(), 'S1') # print(data) data = data.reshape(H, -1) # print(data) data = data[:, :W] == b'.' # print(data) C[1:-1, 1:-1] = data C = C.ravel() H += 2 W += 2 print(main(H, W, K, x1, y1, x2, y2, C))
def _test(): import doctest doctest.testmod() USE_NUMBA = False if USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE' or sys.argv[-1] == '-c': print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'void()')(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: if USE_NUMBA and sys.argv[-1] != '-p': # -p: pure python mode # if not -p, import compiled module from my_module import main # pylint: disable=all elif sys.argv[-1] == "-t": _test() exit() elif len(sys.argv) == 2: # input given as file input_as_file = open(sys.argv[1]) input = input_as_file.buffer.readline # read parameter main()
import my_module print("Hello") my_module.main()
import sys import numba def main(x): # NG # def recur(t): # if t == 0: # return 1 # return t * recur(t - 1) # OK def recur(t): return 1 return recur(x) if sys.argv[-1] == "-c": # numba compile print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'i8(i8)')(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: from my_module import main print(main(5))
USE_NUMBA = True if USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE' or sys.argv[-1] == '-c': print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'i8[:](i8,i8,i8[::1])')(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: input = sys.stdin.buffer.readline read = sys.stdin.buffer.read if USE_NUMBA and sys.argv[-1] != '-p': # -p: pure python mode # if not -p, import compiled module from my_module import main # pylint: disable=all elif sys.argv[-1] == "-t": _test() exit() elif sys.argv[-1] != '-p' and len(sys.argv) == 2: # input given as file input_as_file = open(sys.argv[1]) input = input_as_file.buffer.readline read = input_as_file.buffer.read # read parameter N, Q = [int(x) for x in input().split()] data = np.int64(read().split()) print(*main(N, Q, data), sep="\n")
q, r = divmod(P, i) INV[i] = -INV[r] * q % P invf *= INV[i] invf %= P INVF[i] = invf def comb_rep(n, r): return (F[n + r - 1] * INVF[r] % P) * INVF[n - 1] % P ret = 0 for i in range(K + 1): ret += (P25[i] * P26[K - i] % P * comb_rep(N, i) % P) return (ret % P) if sys.argv[-1] == 'ONLINE_JUDGE': print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'i8(i8,i8)')(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: # read parameter from my_module import main # K = int(input()) # S = input() # print(main(K, len(S))) print(main(10**6, 10**6))
import sys import numpy as np def main(A): return 0 def cc_export(): from numba.pycc import CC cc = CC('my_module') cc.export('main', 'i8(i8[:])')(main) cc.compile() if sys.argv[-1] == 'ONLINE_JUDGE': cc_export() exit(0) if sys.argv[-1] != 'LOCAL': from my_module import main A = np.ones(10, dtype=np.int64) ans = main(A) print(ans)
def main(N, S, AS): DP = np.zeros((S + 1, N + 1), dtype=np.int64) DP[0, 0] = 1 # print(DP) for i in range(N): for j in range(S + 1): v = DP[j, i] * 2 if AS[i] <= j: v += DP[j - AS[i], i] DP[j, i + 1] = v % P # print(DP) print(DP[S, N]) if sys.argv[-1] == 'ONLINE_JUDGE': print("compiling") from numba.pycc import CC cc = CC('my_module') cc.export('main', 'void(i8,i8,i8[:])')(main) # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :] cc.compile() exit() else: # read parameter N, S = map(int, input().split()) AS = np.array(list(map(int, input().split()))) from my_module import main main(N, S, AS)
""" # if lo < 0: # raise ValueError('lo must be non-negative') # if hi is None: # hi = len(a) # FIXME: optional paramaters lo = 0 hi = len(a) while lo < hi: mid = (lo + hi) // 2 # Use __lt__ to match the logic in list.sort() and in heapq if x < a[mid]: hi = mid else: lo = mid + 1 return lo @cc.export("main", "i8(i8[:], i8)") def main(xs, x): print(bisect(xs, x)) if 1: cc.compile() else: from my_module import main main(np.arange(10), 3) # => 4