{"id":13482415,"url":"https://github.com/kmyk-jikka/Jikka","last_synced_at":"2025-03-27T13:31:47.303Z","repository":{"id":46694067,"uuid":"195199314","full_name":"kmyk-jikka/Jikka","owner":"kmyk-jikka","description":"an automated solver for problems of competitive programming","archived":false,"fork":false,"pushed_at":"2021-09-29T17:44:46.000Z","size":80840,"stargazers_count":152,"open_issues_count":36,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-07-14T19:28:22.603Z","etag":null,"topics":["algorithms","competitive-programming","compiler","optimization","programming-contests","programming-language","transpiler"],"latest_commit_sha":null,"homepage":"https://kmyk-jikka.github.io/Jikka/playground","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kmyk-jikka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.ja.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-04T08:18:43.000Z","updated_at":"2024-07-14T19:28:22.603Z","dependencies_parsed_at":"2022-08-29T08:02:09.804Z","dependency_job_id":null,"html_url":"https://github.com/kmyk-jikka/Jikka","commit_stats":null,"previous_names":["kmyk/jikka"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmyk-jikka%2FJikka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmyk-jikka%2FJikka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmyk-jikka%2FJikka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kmyk-jikka%2FJikka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kmyk-jikka","download_url":"https://codeload.github.com/kmyk-jikka/Jikka/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213388631,"owners_count":15579772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","competitive-programming","compiler","optimization","programming-contests","programming-language","transpiler"],"created_at":"2024-07-31T17:01:01.770Z","updated_at":"2024-07-31T17:08:43.158Z","avatar_url":"https://github.com/kmyk-jikka.png","language":"Haskell","funding_links":[],"categories":["Haskell"],"sub_categories":[],"readme":"# Jikka\n\n[![test](https://github.com/kmyk/Jikka/actions/workflows/test.yml/badge.svg)](https://github.com/kmyk/Jikka/actions/workflows/test.yml)\n\nJikka is an automated solver for problems of competitive programming.\n\nIn competitive programming, there are some problems that can be solved just by _repeating formula transformations_ or by _pasting snippets of famous data structures_.\nJikka solves such problems automatically.\nJikka takes problems as input in the form of programs of a very restricted subset of Python, optimizes the codes to reduce their computational complexity, and converts them to implementations of C++ for output.\n/\n競技プログラミングにおいて「ただ式変形をするだけで解ける」「ただデータ構造のライブラリを貼るだけで解ける」問題は実は少なくありません。\nJikka はそのような問題を自動で解いてくれます。\nJikka は問題をとても制限された Python のサブセット言語のコードの形で入力として受け取り、計算量を落とすような最適化を行い、C++ の実装に変換して出力します。\n\n## Try on Web\n\nGo \u003chttps://kmyk.github.io/Jikka/playground\u003e.\n\n## Usage\n\n```console\n$ jikka convert PYTHON_FILE\n```\n\n## How to Install\n\n### Using prebuilt binaries (recommended)\n\nGo [Releases page](https://github.com/kmyk/Jikka/releases) and download `jikka-vA.B.C.D-Linux`, `jikka-vA.B.C.D-maxOS` or `jikka-vA.B.C.D-Windows.exe`.\n\n### Using Stack\n\n[Stack](https://www.haskellstack.org/) is required. If you are using Ubuntu, you can install Stack with `$ sudo apt install haskell-stack`.\n\n```console\n$ git clone https://github.com/kmyk/Jikka.git\n$ cd Jikka\n$ stack install\n```\n\n### Using Cabal\n\n[Cabal](https://www.haskell.org/cabal/) is required. This is bundled [Haskell Platform](https://www.haskell.org/platform/). If you are using Ubuntu, you can install Stack with `$ sudo apt install haskell-platform`.\n\n```console\n$ cabal update\n$ cabal install Jikka\n```\n\n## Discussions\n\nPlease feel free to use our [GitHub Discussions](https://github.com/kmyk/Jikka/discussions). / [GitHub Discussions](https://github.com/kmyk/Jikka/discussions) があるので気軽に使ってください。\n\n## Documents\n\nFor users:\n\n- [docs/language.md](https://github.com/kmyk/Jikka/blob/master/docs/language.md)\n  - The language specification of our restricted Python / Jikka で使われる制限された Python の言語仕様\n- [docs/optimization.md](https://github.com/kmyk/Jikka/blob/master/docs/optimization.md)\n  - A list of optimizations which Jikka does / Jikka が行なってくれる最適化の一覧\n- [examples/](https://github.com/kmyk/Jikka/blob/master/examples)\n  - [gallery](https://kmyk.github.io/Jikka/gallery)\n  - [playground](https://kmyk.github.io/Jikka/playground)\n- [CHANGELOG.md](https://github.com/kmyk/Jikka/blob/master/CHANGELOG.md)\n\nFor developpers:\n\n- [CONTRIBUTING.md](https://github.com/kmyk/Jikka/blob/master/CONTRIBUTING.md)\n- [docs/how-it-works.pdf](https://github.com/kmyk/Jikka/blob/master/docs/how-it-works.pdf) / [docs/how-it-works.ja.pdf](https://github.com/kmyk/Jikka/blob/master/docs/how-it-works.ja.pdf)\n  - How it works and related theories / 動作原理や関連する理論\n- [docs/DESIGN.md](https://github.com/kmyk/Jikka/blob/master/docs/DESIGN.md)\n  - The policy of designs / 実装方針\n- [docs/internal.md](https://github.com/kmyk/Jikka/blob/master/docs/internal.md)\n  - The overview of internal processes / 内部の処理の流れ\n- [docs/core.md](https://github.com/kmyk/Jikka/blob/master/docs/core.md)\n  - The specification of core language / core 言語の仕様\n- [Haddock](https://hackage.haskell.org/package/Jikka)\n  - [Haddock (master)](https://kmyk.github.io/Jikka/haddock)\n\nBlog articles:\n\n- [競技プログラミングの問題を自動で解きたい - うさぎ小屋](https://kimiyuki.net/blog/2020/12/09/automated-solvers-of-competitive-programming/) (Japanese)\n- [Jikka, a transpiler/solver for competitive programming - Codeforces](https://codeforces.com/blog/entry/94648)\n\n## Examples\n\n### `examples/fib.py` (`v5.0.5.0`)\n\nInput, O(N):\n\n```python\ndef f(n: int) -\u003e int:\n    a = 0\n    b = 1\n    for _ in range(n):\n        c = a + b\n        a = b\n        b = c\n    return a\n\ndef solve(n: int) -\u003e int:\n    return f(n) % 1000000007\n```\n\nOutput, O(log N):\n\n```c++\n#include \"jikka/all.hpp\"\n#include \u003calgorithm\u003e\n#include \u003ccstdint\u003e\n#include \u003cfunctional\u003e\n#include \u003ciostream\u003e\n#include \u003cnumeric\u003e\n#include \u003cstring\u003e\n#include \u003ctuple\u003e\n#include \u003cvector\u003e\nint64_t solve(int64_t n_317) {\n  return jikka::modmatap\u003c2, 2\u003e(\n      jikka::modmatpow\u003c2\u003e(jikka::make_array\u003cstd::array\u003cint64_t, 2\u003e\u003e(\n                              jikka::make_array\u003cint64_t\u003e(1, 1),\n                              jikka::make_array\u003cint64_t\u003e(1, 0)),\n                          n_317, 1000000007),\n      jikka::make_array\u003cint64_t\u003e(1, 0), 1000000007)[1];\n}\nint main() {\n  int64_t x318;\n  std::cin \u003e\u003e x318;\n  int64_t x319 = solve(x318);\n  std::cout \u003c\u003c x319;\n  std::cout \u003c\u003c '\\n';\n}\n```\n\n### `examples/static_range_sum.py` (`v5.0.10.0`)\n\nInput, O(N^2):\n\n```python\n# https://judge.yosupo.jp/problem/static_range_sum\n\nfrom typing import *\n\ndef solve(n: int, q: int, a: List[int], l: List[int], r: List[int]) -\u003e List[int]:\n    ans = [-1 for _ in range(q)]\n    for i in range(q):\n        ans[i] = sum(a[l[i]:r[i]])\n    return ans\n\ndef main() -\u003e None:\n    n, q = map(int, input().split())\n    a = list(map(int, input().split()))\n    assert len(a) == n\n    l = list(range(q))\n    r = list(range(q))\n    for i in range(q):\n        l[i], r[i] = map(int, input().split())\n    ans = solve(n, q, a, l, r)\n    for i in range(q):\n        print(ans[i])\n\nif __name__ == '__main__':\n    main()\n```\n\nOutput, O(N):\n\n```c++\n#include \u003calgorithm\u003e\n#include \u003ccstdint\u003e\n#include \u003cfunctional\u003e\n#include \u003ciostream\u003e\n#include \u003cnumeric\u003e\n#include \u003cstring\u003e\n#include \u003ctuple\u003e\n#include \u003cvector\u003e\nstd::vector\u003cint64_t\u003e solve(int64_t n_0, int64_t q_1, std::vector\u003cint64_t\u003e a_2,\n                           std::vector\u003cint64_t\u003e l_3, std::vector\u003cint64_t\u003e r_4) {\n  std::vector\u003cint64_t\u003e x6 = std::vector\u003cint64_t\u003e(a_2.size() + 1);\n  x6[0] = 0;\n  for (int32_t i7 = 0; i7 \u003c int32_t(a_2.size()); ++i7) {\n    x6[(i7 + 1)] = x6[i7] + a_2[i7];\n  }\n  std::vector\u003cint64_t\u003e x5 = x6;\n  std::vector\u003cint64_t\u003e x10 = std::vector\u003cint64_t\u003e(q_1);\n  for (int32_t i11 = 0; i11 \u003c int32_t(q_1); ++i11) {\n    x10[i11] = -x5[l_3[i11]] + x5[r_4[i11]];\n  }\n  return x10;\n}\nint main() {\n  int64_t n_13 = -1;\n  int64_t q_14 = -1;\n  std::cin \u003e\u003e n_13;\n  std::vector\u003cint64_t\u003e a_15 = std::vector\u003cint64_t\u003e(n_13, -1);\n  std::cin \u003e\u003e q_14;\n  std::vector\u003cint64_t\u003e l_16 = std::vector\u003cint64_t\u003e(q_14, -1);\n  std::vector\u003cint64_t\u003e r_17 = std::vector\u003cint64_t\u003e(q_14, -1);\n  for (int32_t i18 = 0; i18 \u003c n_13; ++i18) {\n    std::cin \u003e\u003e a_15[i18];\n  }\n  for (int32_t i_19 = 0; i_19 \u003c q_14; ++i_19) {\n    std::cin \u003e\u003e l_16[i_19];\n    std::cin \u003e\u003e r_17[i_19];\n  }\n  for (int32_t i_20 = 0; i_20 \u003c q_14; ++i_20) {\n  }\n  auto ans_21 = solve(n_13, q_14, a_15, l_16, r_17);\n  for (int32_t i_22 = 0; i_22 \u003c q_14; ++i_22) {\n  }\n  for (int32_t i_23 = 0; i_23 \u003c q_14; ++i_23) {\n    std::cout \u003c\u003c ans_21[i_23] \u003c\u003c ' ';\n    std::cout \u003c\u003c '\\n' \u003c\u003c ' ';\n  }\n}\n```\n\n## License\n\nAppache License 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmyk-jikka%2FJikka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkmyk-jikka%2FJikka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkmyk-jikka%2FJikka/lists"}