{"id":18979640,"url":"https://github.com/reputeless/yatcoder","last_synced_at":"2026-06-21T02:32:06.005Z","repository":{"id":67723781,"uuid":"215274738","full_name":"Reputeless/YatCoder","owner":"Reputeless","description":"競技プログラミング（プログラミングコンテスト） C++14 ライブラリ","archived":false,"fork":false,"pushed_at":"2019-10-21T15:09:07.000Z","size":111,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-11T02:03:01.682Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Reputeless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-15T10:49:35.000Z","updated_at":"2021-12-09T12:42:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e8e7c8c-f0e2-41c1-bd54-3b5c5fd885a5","html_url":"https://github.com/Reputeless/YatCoder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Reputeless/YatCoder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FYatCoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FYatCoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FYatCoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FYatCoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Reputeless","download_url":"https://codeload.github.com/Reputeless/YatCoder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Reputeless%2FYatCoder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34592050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-08T15:44:17.273Z","updated_at":"2026-06-21T02:32:05.988Z","avatar_url":"https://github.com/Reputeless.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# YatCoder\n競技プログラミング（プログラミングコンテスト）のコードを、Siv3D スタイルで書けるライブラリ\n\n**対応コンパイラ:** C++14 (GCC 5.4.1)　**ライセンス:** CC0 1.0 Universal\n\n# 1. インクルードされるヘッダ\n\n`# include \u003cbits/stdc++.h\u003e`\n\n# 2. 数値型\n\n| 名前       | 説明              |\n|----------|-----------------|\n| int8     | 8-bit 符号付き整数型   |\n| int16    | 16-bit 符号付き整数型  |\n| int32    | 32-bit 符号付き整数型  |\n| int64    | 64-bit 符号付き整数型  |\n| int128   | 128-bit 符号付き整数型 |\n| uint8    | 8-bit 符号なし整数型   |\n| uint16   | 16-bit 符号なし整数型  |\n| uint32   | 32-bit 符号なし整数型  |\n| uint64   | 64-bit 符号なし整数型  |\n| uint128  | 128-bit 符号なし整数型 |\n| float32  | 単精度浮動小数点数型      |\n| float64  | 倍精度浮動小数点数型      |\n| float128 | 四倍精度浮動小数点数型     |\n\n```C++\nint main()\n{\n\tuint8 a = 0b0101;\n\tint32 b = -200;\n\tuint64 c = 1234567890123;\n\tint128 d = int128(1) \u003c\u003c 100; // 1267650600228229401496703205376\n\tuint128 e = uint128(-1); // 340282366920938463463374607431768211455\n\tfloat32 f = 3.14f;\n\tfloat64 g = 3.14;\n\tfloat128 h = 3.14L;\n}\n```\n\n\n# 3. 文字列型\n\n## 3.1 String 型\n\n| 名前     | 説明   |\n|--------|------|\n| String | 文字列型 |\n\n```C++\nint main()\n{\n\tString s = \"YatCoder\";\n}\n```\n\n## 3.2 String 型のメンバ関数\n\n### `size_t String::count(char c);`\n文字列中に含まれる文字 'c' の個数を返します。\n```C++\nint main()\n{\n\tString s1 = \"abaab\";\n\tPrint \u003c\u003c s1.count('a');\n\n\tString s2 = \"ABC\";\n\tPrint \u003c\u003c s2.count('a');\n}\n```\n出力\n```\n3\n0\n```\n\n\n🚧🚧🚧\n\n\n# 4. 動的配列型\n\n## 4.1 Array 型\n\n| 名前    | 説明    |\n|-------|-------|\n| Array | 動的配列型 |\n\n## 4.2 Array 型のメンバ関数\n\n🚧🚧🚧\n\n\n# 5. 文字列フォーマット\n\n## 5.1 値から文字列への変換\n\n**フォーマット可能** な型の値は、`Format()` で文字列に変換できます。\n\n| 型                        | Format 結果の例     |\n|--------------------------|-----------------|\n| int8                     | -100            |\n| int16                    | -100            |\n| int32                    | -100            |\n| int64                    | -100            |\n| int128                   | -100            |\n| uint8                    | 100             |\n| uint16                   | 100             |\n| uint32                   | 100             |\n| uint64                   | 100             |\n| uint128                  | 100             |\n| float32                  | 12.5000000000   |\n| float64                  | 12.5000000000   |\n| float128                 | 12.5000000000   |\n| bool                     | true            |\n| char                     | a               |\n| const char*              | abc             |\n| int[3]                   | {11, 22, 33}    |\n| String                   | abc             |\n| `std::array\u003cint, 3\u003e`     | {11, 22, 33}    |\n| `std::pair\u003cint, String\u003e` | {10, aaa}       |\n| `Array\u003cint\u003e`             | {11, 22, 33}    |\n| `Array\u003cString\u003e`          | {aaa, bbb, ccc} |\n\n```C++\nint main()\n{\n\tString s1 = Format(12345); // 12345\n\tString s2 = Format(10, \"abc\", 5); // 10abc5\n\tString s3 = Format(123.45678); // 123.4567800000\n\tString s4 = Format(int128(1) \u003c\u003c 100)); // 1267650600228229401496703205376\n\tString s5 = Format(10 \u003c 20); // true\n\tString s6 = Format(Array\u003cint\u003e{ 11, 22, 33 }); // {11, 22, 33}\n}\n```\n\n## 5.2 小数点以下の桁数指定\n\n`Format()` に `N_dp` (N は整数) を渡すと、それ以降の浮動小数点数型の引数に対して、小数点以下 N 桁まで変換します。デフォルトでは 10 です。小数点以下 (N+1) 桁目の数は四捨五入されます (例: `Format(2_dp, 1.76543)` では 5 が四捨五入されて `1.77`)\n\n```C++\nint main()\n{\n\tString s1 = Format(123.456789);\t\t\t// 123.4567890000\n\tString s2 = Format(0_dp, 123.456789);\t// 123\n\tString s3 = Format(1_dp, 123.456789);\t// 123.5\n\tString s4 = Format(3_dp, 123.456789);\t// 123.457\n\tString s5 = Format(5_dp, 123.456789);\t// 123.45679\n\tString s6 = Format(10_dp, 123.456789);\t// 123.4567890000\n\n\t// 途中で変更することも可能\n\tString s7 = Format(0_dp, 1.11, ' ', 1_dp, 2.22); // 1 2.2\n\n\t// _dp の効力はその Format 内なので、デフォルトの桁数に戻る\n\tString s8 = Format(123.456789);\t\t\t// 123.4567890000\n}\n```\n\n\n# 6. 標準出力\n\n## 6.1 Print\n\n**フォーマット可能** な型の値を `Print` に `\u003c\u003c` 演算子で送ると、`Format()` で文字列化されたのち標準出力されます。`\u003c\u003c` でつながった一連の `Print` の最後で自動的に改行が挿入されます。\n\n```C++\nint main()\n{\n\tPrint \u003c\u003c 12345;\n\tPrint \u003c\u003c 10 \u003c\u003c \"abc\" \u003c\u003c 5;\n\tPrint \u003c\u003c 123.45678;\n\tPrint \u003c\u003c (int128(1) \u003c\u003c 100);\n\tPrint \u003c\u003c (10 \u003c 20);\n\tPrint \u003c\u003c Array\u003cint\u003e{ 11, 22, 33 };\n\tPrint \u003c\u003c 0_dp \u003c\u003c 1.11 \u003c\u003c ' ' \u003c\u003c 1_dp \u003c\u003c 2.22;\n\tPrint \u003c\u003c 123.45678;\n}\n```\n出力\n```\n12345\n10abc5\n123.4567800000\n1267650600228229401496703205376\ntrue\n{11, 22, 33}\n1 2.2\n123.4567890000\n```\n\n\n# 7. 標準入力\n\n## 7.1 数値の読み込み\nスペースや改行で区切られた標準入力文字列から、数値を読み込みます。\n\n| 読み込む値    | 関数           |\n|----------|--------------|\n| int8     | ReadInt8     |\n| int16    | ReadInt16    |\n| int32    | ReadInt32    |\n| int64    | ReadInt64    |\n| uint8    | ReadUint8    |\n| uint16   | ReadUint16   |\n| uint32   | ReadUint32   |\n| uint64   | ReadUint64   |\n| float32  | ReadFloat32  |\n| float64  | ReadFloat64  |\n| float128 | ReadFloat128 |\n\n| 読み込む値   | 関数         |\n|---------|------------|\n| int32   | ReadInt    |\n| uint32  | ReadUint   |\n| float32 | ReadFloat  |\n| float64 | ReadDouble |\n\n```C++\nint main()\n{\n\tconst int32 a = ReadInt();\n\tconst int32 b = ReadInt(), c = ReadInt();\n\tPrint \u003c\u003c a;\n\tPrint \u003c\u003c b + c;\n\tPrint \u003c\u003c b - c;\n}\n```\n入力\n```\n10\n5 3\n```\n出力\n```\n10\n8\n2\n```\n\n## 7.2 数値の読み込み + 入力の終わりの判定\n入力の終わりを判定したい場合は、戻り値が `bool` で参照引数から結果を受け取るオーバーロード関数を使います。\n\n```C++\nint main()\n{\n\tint32 n;\n\n\twhile (ReadInt(n)) // 入力の終わりに達していた場合 false を返す\n\t{\n\t\tPrint \u003c\u003c n * 2;\n\t}\n}\n```\n入力\n```\n1\n3\n5\n```\n出力\n```\n2\n6\n10\n```\n\n## 7.3 文字の読み込み（空白を含まない）\n\n### `char ReadChar();`\n### `bool ReadChar(char\u0026 c);`\n標準入力から文字を 1 つ読み込み、その文字を返します。空白や改行の場合、無視して次の空白や改行でない文字を読み込みます。\n\n```C++\nint main()\n{\n\tconst char a = ReadChar();\n\tconst char b = ReadChar();\n\tconst char c = ReadChar();\n\tPrint \u003c\u003c a;\n\tPrint \u003c\u003c b;\n\tPrint \u003c\u003c c;\n}\n```\n入力\n```\nN Y Y\n```\n出力\n```\nN\nY\nY\n```\n\n## 7.4 文字の読み込み（空白を含む）\n\n### `char ReadCodePoint();`\n### `bool ReadCodePoint(char\u0026 c);`\n標準入力から文字を 1 つ読み込み、その文字を返します。空白や改行も 1 文字として扱います。\n\n```C++\nint main()\n{\n\tconst char a = ReadCodePoint();\n\tconst char b = ReadCodePoint();\n\tconst char c = ReadCodePoint();\n\tPrint \u003c\u003c a;\n\tPrint \u003c\u003c b;\n\tPrint \u003c\u003c c;\n}\n```\n入力\n```\n# #\n```\n出力\n```\n#\n\n#\n```\n\n## 7.5 文字列の読み込み（空白を含まない）\n\n### `String ReadWord();`\n### `bool ReadWord(String\u0026 s);`\n標準入力から空白や改行で区切られた一連の文字列を読み込み、その文字列を返します。\n\n```C++\nint main()\n{\n\tconst String s1 = ReadWord();\n\tconst String s2 = ReadWord();\n\tPrint \u003c\u003c s1;\n\tPrint \u003c\u003c s2;\n}\n```\n入力\n```\nhello world\n```\n出力\n```\nhello\nworld\n```\n\n## 7.6 文字列の読み込み（空白を含む 1 行全部）\n\n### `String ReadLine();`\n### `bool ReadLine(String\u0026 s);`\n標準入力から 1 行読み込み、その文字列を返します。空白行はスキップし、次の空白でない行を読み込みます。\n\n```C++\nint main()\n{\n\tconst String s1 = ReadLine();\n\tconst String s2 = ReadLine();\n\tPrint \u003c\u003c s1;\n\tPrint \u003c\u003c s2;\n}\n```\n入力\n```\nhello world\nhello yatcoder\n```\n出力\n```\nhello world\nhello yatcoder\n```\n\n## 7.7 配列の読み込み\n\n🚧🚧🚧\n\n# 8. ループ\n\n```C++\nint main()\n{\n\tfor (auto i : step(5))\n\t{\n\t\tPrint \u003c\u003c i;\n\t}\n}\n```\n出力\n```\n0\n1\n2\n3\n4\n```\n\n```C++\nint main()\n{\n\tfor (auto i : Range(1, 4))\n\t{\n\t\tPrint \u003c\u003c i;\n\t}\n}\n```\n出力\n```\n1\n2\n3\n4\n```\n\n```C++\nint main()\n{\n\tfor (auto i : Range(5, 0, -1))\n\t{\n\t\tPrint \u003c\u003c i;\n\t}\n}\n```\n出力\n```\n5\n4\n3\n2\n1\n0\n```\n\n🚧🚧🚧\n\n\n# 9. 便利関数・関数オブジェクト\n\n## 9.1 範囲内にあるかの判定\n\n🚧🚧🚧\n\n## 9.2 偶数・奇数判定\n\n### `IsOdd`\n`()` 演算子で渡した整数が奇数なら `true` を返します。\n\n```C++\nint main()\n{\n\tPrint \u003c\u003c IsOdd(3);\n\tPrint \u003c\u003c IsOdd(-3);\n\tPrint \u003c\u003c IsOdd(24);\n}\n```\n出力\n```\ntrue\ntrue\nfalse\n```\n\n### `IsEven`\n`()` 演算子で渡した整数が偶数なら `true` を返します。\n\n```C++\nint main()\n{\n\tPrint \u003c\u003c IsEven(2);\n\tPrint \u003c\u003c IsEven(-2);\n\tPrint \u003c\u003c IsEven(25);\n}\n```\n出力\n```\ntrue\ntrue\nfalse\n```\n\n🚧🚧🚧\n\n\n# AtCoder の解答例\n\n### [PracticeA - Welcome to AtCoder](https://atcoder.jp/contests/abs/tasks/practice_1)\n```C++\nint main()\n{\n\tconst int32 a = ReadInt();\n\tconst int32 b = ReadInt(), c = ReadInt();\n\tconst String s = ReadLine();\n\tPrint \u003c\u003c (a + b + c) \u003c\u003c ' ' \u003c\u003c s;\n}\n```\n\n### [ABC086A - Product](https://atcoder.jp/contests/abs/tasks/abc086_a)\n```C++\nint main()\n{\n\tconst int32 a = ReadInt(), b = ReadInt();\n\tPrint \u003c\u003c (IsEven(a * b) ? \"Even\" : \"Odd\");\n}\n```\n\n### [ABC081A - Placing Marbles](https://atcoder.jp/contests/abs/tasks/abc081_a)\n```C++\nint main()\n{\n\tPrint \u003c\u003c ReadLine().count('1');\n}\n```\n\n### [ABC081B - Shift only](https://atcoder.jp/contests/abs/tasks/abc081_b)\n```C++\nint main()\n{\n\tconst int32 N = ReadInt();\n\tArray\u003cint32\u003e as = ReadIntArray(N);\n\tint32 result = 0;\n\n\twhile (as.all(IsEven))\n\t{\n\t\tas.each([](int32\u0026 a) { a /= 2; });\n\t\t++result;\n\t}\n\n\tPrint \u003c\u003c result;\n}\n```\n\n### [ABC087B - Coins](https://atcoder.jp/contests/abs/tasks/abc087_b)\n```C++\nint main()\n{\n\tconst int32 N500 = ReadInt(), N100 = ReadInt(), N50 = ReadInt();\n\tconst int32 X = ReadInt();\n\tint32 result = 0;\n\n\tfor (auto n500 : Range(0, N500))\n\t{\n\t\tfor (auto n100 : Range(0, N100))\n\t\t{\n\t\t\tfor (auto n50 : Range(0, N50))\n\t\t\t{\n\t\t\t\tconst int32 sum = (n500 * 500) + (n100 * 100) + (n50 * 50);\n\t\t\t\tresult += (sum == X);\n\t\t\t}\n\t\t}\n\t}\n\n\tPrint \u003c\u003c result;\n}\n```\n\n### [ABC083B - Some Sums](https://atcoder.jp/contests/abs/tasks/abc083_b)\n```C++\nint main()\n{\n\tconst int32 N = ReadInt();\n\tconst int32 A = ReadInt(), B = ReadInt();\n\tint32 result = 0;\n\n\tfor (auto n : Range(1, N))\n\t{\n\t\tint32 t = 0;\n\n\t\tfor (auto i : Range(0, 4))\n\t\t{\n\t\t\tt += GetDigit(n, i);\n\t\t}\n\n\t\tif (InRange(t, A, B))\n\t\t{\n\t\t\tresult += n;\n\t\t}\n\t}\n\n\tPrint \u003c\u003c result;\n}\n```\n\n### [ABC088B - Card Game for Two](https://atcoder.jp/contests/abs/tasks/abc088_b)\n```C++\nint main()\n{\n\tconst int32 N = ReadInt();\n\tconst Array\u003cint32\u003e as_rsorted = ReadIntArray(N).rsort();\n\tint32 alice = 0, bob = 0;\n\n\tfor (auto i : step(as_rsorted.size()))\n\t{\n\t\t(IsEven(i) ? alice : bob) += as_rsorted[i];\n\t}\n\n\tPrint \u003c\u003c (alice - bob);\n}\n```\n\n### [ABC085B - Kagami Mochi](https://atcoder.jp/contests/abs/tasks/abc085_b)\n```C++\nint main()\n{\n\tconst int32 N = ReadInt();\n\tPrint \u003c\u003c ReadIntArray(N).unique().size();\n}\n```\n\n### [ABC085C - Otoshidama](https://atcoder.jp/contests/abs/tasks/abc085_c)\n```C++\nint main()\n{\n\tconst int32 N = ReadInt();\n\tconst int32 Y = ReadInt();\n\n\tfor (auto n10000 : Range(0, N))\n\t{\n\t\tfor (auto n5000 : Range(0, N - n10000))\n\t\t{\n\t\t\tconst int32 n1000 = N - n10000 - n5000;\n\t\t\tconst int32 sum = (n10000 * 10000) + (n5000 * 5000) + (n1000 * 1000);\n\n\t\t\tif (sum == Y)\n\t\t\t{\n\t\t\t\tPrint \u003c\u003c n10000 \u003c\u003c ' ' \u003c\u003c n5000 \u003c\u003c ' ' \u003c\u003c n1000;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tPrint \u003c\u003c \"-1 -1 -1\";\n}\n```\n\n### [ABC049C - 白昼夢 / Daydream](https://atcoder.jp/contests/abs/tasks/arc065_a)\n```C++\nint main()\n{\n\tString S = ReadWord();\n\n\twhile (S)\n\t{\n\t\tbool removed = false;\n\n\t\tfor (StringView keyword : { \"eraser\", \"erase\", \"dreamer\", \"dream\" })\n\t\t{\n\t\t\tif (S.ends_with(keyword))\n\t\t\t{\n\t\t\t\tS.dropBack(keyword.size());\n\t\t\t\tremoved = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!removed)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tPrint \u003c\u003c YESNO(S.isEmpty());\n}\n```\n\n### [ABC086C - Traveling](https://atcoder.jp/contests/abs/tasks/arc089_a)\n```C++\nstruct Plan\n{\n\tint32 t;\n\tPoint pos;\n};\n\nint main()\n{\n\tconst int32 N = ReadInt();\n\tPlan current{ 0, Point(0, 0) };\n\tbool result = true;\n\n\tfor (auto i : step(N))\n\t{\n\t\tPlan next;\n\t\tnext.t = ReadInt();\n\t\tnext.pos.x = ReadInt();\n\t\tnext.pos.y = ReadInt();\n\n\t\tconst int32 md = next.pos.manhattanDistanceFrom(current.pos);\n\t\tconst int32 td = next.t - current.t;\n\t\tif ((md \u003c= td) \u0026\u0026 IsEven(td - md))\n\t\t{\n\t\t\tcurrent = next;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tPrint \u003c\u003c YesNo(result);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freputeless%2Fyatcoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freputeless%2Fyatcoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freputeless%2Fyatcoder/lists"}