Skip to content

Instantly share code, notes, and snippets.

@hppRC
Last active April 4, 2020 07:45
Show Gist options
  • Save hppRC/49db7400cf17097a0f46e3ffbca7928a to your computer and use it in GitHub Desktop.
Save hppRC/49db7400cf17097a0f46e3ffbca7928a to your computer and use it in GitHub Desktop.
{"lastUpload":"2020-04-04T07:45:57.757Z","extensionVersion":"v3.4.3"}
[
{
"metadata": {
"id": "2e9fe0cb-4e63-42fc-a809-fb056aad49c3",
"publisherId": "stevencl.addDocComments",
"publisherDisplayName": "stevencl"
},
"name": "addDocComments",
"publisher": "stevencl",
"version": "0.0.8"
},
{
"metadata": {
"id": "6e440e71-8ed9-4f25-bb78-4b13096b8a03",
"publisherId": "formulahendry.auto-rename-tag",
"publisherDisplayName": "formulahendry"
},
"name": "auto-rename-tag",
"publisher": "formulahendry",
"version": "0.1.1"
},
{
"metadata": {
"id": "70378119-1d85-4935-9733-0298c7a369a2",
"publisherId": "steoates.autoimport",
"publisherDisplayName": "steoates"
},
"name": "autoimport",
"publisher": "steoates",
"version": "1.5.3"
},
{
"metadata": {
"id": "7a0110bb-231a-4598-aa1b-0769ea46d28b",
"publisherId": "aaron-bond.better-comments",
"publisherDisplayName": "aaron-bond"
},
"name": "better-comments",
"publisher": "aaron-bond",
"version": "2.0.5"
},
{
"metadata": {
"id": "464f4ac7-af65-4aa9-9907-4ba7fa419085",
"publisherId": "bungcip.better-toml",
"publisherDisplayName": "bungcip"
},
"name": "better-toml",
"publisher": "bungcip",
"version": "0.3.2"
},
{
"metadata": {
"id": "5a6e2b21-1d61-4acd-b31b-907f9c23f18a",
"publisherId": "CoenraadS.bracket-pair-colorizer-2",
"publisherDisplayName": "CoenraadS"
},
"name": "bracket-pair-colorizer-2",
"publisher": "CoenraadS",
"version": "0.0.29"
},
{
"metadata": {
"id": "8a0c151b-eb13-4bed-9d49-4a252a118a0c",
"publisherId": "michelemelluso.code-beautifier",
"publisherDisplayName": "michelemelluso"
},
"name": "code-beautifier",
"publisher": "michelemelluso",
"version": "2.3.3"
},
{
"metadata": {
"id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd",
"publisherId": "Shan.code-settings-sync",
"publisherDisplayName": "Shan"
},
"name": "code-settings-sync",
"publisher": "Shan",
"version": "3.4.3"
},
{
"metadata": {
"id": "121396ad-85a1-45ec-9fd1-d95028a847f5",
"publisherId": "naumovs.color-highlight",
"publisherDisplayName": "naumovs"
},
"name": "color-highlight",
"publisher": "naumovs",
"version": "2.3.0"
},
{
"metadata": {
"id": "690b692e-e8a9-493f-b802-8089d50ac1b2",
"publisherId": "ms-vscode.cpptools",
"publisherDisplayName": "ms-vscode"
},
"name": "cpptools",
"publisher": "ms-vscode",
"version": "0.27.0"
},
{
"metadata": {
"id": "532533c9-a894-4a58-9eee-bbfbe7c06f71",
"publisherId": "mikestead.dotenv",
"publisherDisplayName": "mikestead"
},
"name": "dotenv",
"publisher": "mikestead",
"version": "1.0.1"
},
{
"metadata": {
"id": "f60a60a6-95ba-42d4-b41c-3d24c1b89588",
"publisherId": "EditorConfig.EditorConfig",
"publisherDisplayName": "EditorConfig"
},
"name": "EditorConfig",
"publisher": "EditorConfig",
"version": "0.14.4"
},
{
"metadata": {
"id": "85f62745-7ea6-4f23-8aa0-521c0732f664",
"publisherId": "elmTooling.elm-ls-vscode",
"publisherDisplayName": "elmTooling"
},
"name": "elm-ls-vscode",
"publisher": "elmTooling",
"version": "0.10.1"
},
{
"metadata": {
"id": "e8f8ede3-8c67-40a1-b54b-fe103df8c600",
"publisherId": "ChFlick.firecode",
"publisherDisplayName": "ChFlick"
},
"name": "firecode",
"publisher": "ChFlick",
"version": "1.2.2"
},
{
"metadata": {
"id": "b78d2f2b-8801-40a5-ae88-27d420197d49",
"publisherId": "skyapps.fish-vscode",
"publisherDisplayName": "skyapps"
},
"name": "fish-vscode",
"publisher": "skyapps",
"version": "0.2.1"
},
{
"metadata": {
"id": "5960f38e-0bbe-4644-8f9c-9c8824e82511",
"publisherId": "donjayamanne.githistory",
"publisherDisplayName": "donjayamanne"
},
"name": "githistory",
"publisher": "donjayamanne",
"version": "0.6.3"
},
{
"metadata": {
"id": "3e891cf9-53cb-49a3-8d01-8f0b1f0afb29",
"publisherId": "codezombiech.gitignore",
"publisherDisplayName": "codezombiech"
},
"name": "gitignore",
"publisher": "codezombiech",
"version": "0.6.0"
},
{
"metadata": {
"id": "4de763bd-505d-4978-9575-2b7696ecf94e",
"publisherId": "eamodio.gitlens",
"publisherDisplayName": "eamodio"
},
"name": "gitlens",
"publisher": "eamodio",
"version": "10.2.1"
},
{
"metadata": {
"id": "d6f6cfea-4b6f-41f4-b571-6ad2ab7918da",
"publisherId": "ms-vscode.Go",
"publisherDisplayName": "ms-vscode"
},
"name": "Go",
"publisher": "ms-vscode",
"version": "0.13.1"
},
{
"metadata": {
"id": "7b71fc1b-190d-4f7d-95d1-93e422649b0a",
"publisherId": "Zignd.html-css-class-completion",
"publisherDisplayName": "Zignd"
},
"name": "html-css-class-completion",
"publisher": "Zignd",
"version": "1.19.0"
},
{
"metadata": {
"id": "1cbadbba-0bd6-46fa-a309-76704bf66217",
"publisherId": "mike-co.import-sorter",
"publisherDisplayName": "mike-co"
},
"name": "import-sorter",
"publisher": "mike-co",
"version": "3.3.1"
},
{
"metadata": {
"id": "eaa2127d-cb69-4ab9-8505-a60c9ee5f28b",
"publisherId": "oderwat.indent-rainbow",
"publisherDisplayName": "oderwat"
},
"name": "indent-rainbow",
"publisher": "oderwat",
"version": "7.4.0"
},
{
"metadata": {
"id": "9981eadc-a934-4353-83d7-84fee5ac69e7",
"publisherId": "HookyQR.JSDocTagComplete",
"publisherDisplayName": "HookyQR"
},
"name": "JSDocTagComplete",
"publisher": "HookyQR",
"version": "0.0.2"
},
{
"metadata": {
"id": "ad4edb9f-0d7e-4bec-9fee-3895f14b2cd2",
"publisherId": "faustinoaq.lex-flex-yacc-bison",
"publisherDisplayName": "faustinoaq"
},
"name": "lex-flex-yacc-bison",
"publisher": "faustinoaq",
"version": "0.0.3"
},
{
"metadata": {
"id": "b22fb9f5-0fe2-4584-b174-b4ae31d56b10",
"publisherId": "RReverser.llvm",
"publisherDisplayName": "RReverser"
},
"name": "llvm",
"publisher": "RReverser",
"version": "0.0.3"
},
{
"metadata": {
"id": "98790d67-10fa-497c-9113-f6c7489207b2",
"publisherId": "yzhang.markdown-all-in-one",
"publisherDisplayName": "yzhang"
},
"name": "markdown-all-in-one",
"publisher": "yzhang",
"version": "2.7.0"
},
{
"metadata": {
"id": "5db78037-f674-459f-a236-db622c427c5b",
"publisherId": "PKief.material-icon-theme",
"publisherDisplayName": "PKief"
},
"name": "material-icon-theme",
"publisher": "PKief",
"version": "4.0.1"
},
{
"metadata": {
"id": "ef2a5b38-02c4-4193-8561-1f072c209474",
"publisherId": "silvenon.mdx",
"publisherDisplayName": "silvenon"
},
"name": "mdx",
"publisher": "silvenon",
"version": "0.1.0"
},
{
"metadata": {
"id": "4bf45e86-a448-4531-8c01-ef33f4536306",
"publisherId": "ms-mssql.mssql",
"publisherDisplayName": "ms-mssql"
},
"name": "mssql",
"publisher": "ms-mssql",
"version": "1.9.0"
},
{
"metadata": {
"id": "2a3e1925-d174-4cd7-baa7-3e13824d68c7",
"publisherId": "ronnidc.nunjucks",
"publisherDisplayName": "ronnidc"
},
"name": "nunjucks",
"publisher": "ronnidc",
"version": "0.2.3"
},
{
"metadata": {
"id": "113b22c8-8125-42ec-8c6b-80c3f5d5fa5f",
"publisherId": "IBM.output-colorizer",
"publisherDisplayName": "IBM"
},
"name": "output-colorizer",
"publisher": "IBM",
"version": "0.1.2"
},
{
"metadata": {
"id": "96fa4707-6983-4489-b7c5-d5ffdfdcce90",
"publisherId": "esbenp.prettier-vscode",
"publisherDisplayName": "esbenp"
},
"name": "prettier-vscode",
"publisher": "esbenp",
"version": "4.0.0"
},
{
"metadata": {
"id": "f1f59ae4-9318-4f3c-a9b5-81b2eaa5f8a5",
"publisherId": "ms-python.python",
"publisherDisplayName": "ms-python"
},
"name": "python",
"publisher": "ms-python",
"version": "2020.3.71659"
},
{
"metadata": {
"id": "e05d98bf-3735-4c1e-9fae-86ef0a52e19f",
"publisherId": "quicktype.quicktype",
"publisherDisplayName": "quicktype"
},
"name": "quicktype",
"publisher": "quicktype",
"version": "12.0.46"
},
{
"metadata": {
"id": "93ce222b-5f6f-49b7-9ab1-a0463c6238df",
"publisherId": "ms-vscode-remote.remote-containers",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-containers",
"publisher": "ms-vscode-remote",
"version": "0.106.0"
},
{
"metadata": {
"id": "607fd052-be03-4363-b657-2bd62b83d28a",
"publisherId": "ms-vscode-remote.remote-ssh",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-ssh",
"publisher": "ms-vscode-remote",
"version": "0.51.0"
},
{
"metadata": {
"id": "bfeaf631-bcff-4908-93ed-fda4ef9a0c5c",
"publisherId": "ms-vscode-remote.remote-ssh-edit",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-ssh-edit",
"publisher": "ms-vscode-remote",
"version": "0.51.0"
},
{
"metadata": {
"id": "f0c5397b-d357-4197-99f0-cb4202f22818",
"publisherId": "ms-vscode-remote.remote-wsl",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "remote-wsl",
"publisher": "ms-vscode-remote",
"version": "0.42.4"
},
{
"metadata": {
"id": "838d060e-1c47-4e05-b553-439c5b94fedc",
"publisherId": "plibither8.remove-comments",
"publisherDisplayName": "plibither8"
},
"name": "remove-comments",
"publisher": "plibither8",
"version": "1.2.2"
},
{
"metadata": {
"id": "dda49fd5-1f3b-4d25-bf61-4fc41905ede5",
"publisherId": "humao.rest-client",
"publisherDisplayName": "humao"
},
"name": "rest-client",
"publisher": "humao",
"version": "0.23.2"
},
{
"metadata": {
"id": "570e6089-b871-41df-9cf4-a723cb34ef01",
"publisherId": "rust-lang.rust",
"publisherDisplayName": "rust-lang"
},
"name": "rust",
"publisher": "rust-lang",
"version": "0.7.0"
},
{
"metadata": {
"id": "c6f87c08-f5ca-4f59-8cee-bc29464dcbfb",
"publisherId": "scala-lang.scala",
"publisherDisplayName": "scala-lang"
},
"name": "scala",
"publisher": "scala-lang",
"version": "0.3.9"
},
{
"metadata": {
"id": "aef85b85-41b9-433a-919e-19a72452133a",
"publisherId": "dragos.scala-lsp",
"publisherDisplayName": "dragos"
},
"name": "scala-lsp",
"publisher": "dragos",
"version": "0.2.3"
},
{
"metadata": {
"id": "3a63675f-7987-4cff-a411-d4a9568f560c",
"publisherId": "slevesque.shader",
"publisherDisplayName": "slevesque"
},
"name": "shader",
"publisher": "slevesque",
"version": "1.1.4"
},
{
"metadata": {
"id": "bfde0096-d13f-4161-9bed-32a535438701",
"publisherId": "hex-ci.stylelint-plus",
"publisherDisplayName": "hex-ci"
},
"name": "stylelint-plus",
"publisher": "hex-ci",
"version": "0.52.10"
},
{
"metadata": {
"id": "f7ca3c4f-a370-4a7f-8691-7ad0f29f8275",
"publisherId": "JamesBirtles.svelte-vscode",
"publisherDisplayName": "JamesBirtles"
},
"name": "svelte-vscode",
"publisher": "JamesBirtles",
"version": "0.9.3"
},
{
"metadata": {
"id": "6ad45f5a-09ec-44e5-b363-867ddc1ec674",
"publisherId": "shardulm94.trailing-spaces",
"publisherDisplayName": "shardulm94"
},
"name": "trailing-spaces",
"publisher": "shardulm94",
"version": "0.3.1"
},
{
"metadata": {
"id": "a697ef49-8649-4960-903b-de276438d8b6",
"publisherId": "kevinmcgowan.TypeScriptImport",
"publisherDisplayName": "kevinmcgowan"
},
"name": "TypeScriptImport",
"publisher": "kevinmcgowan",
"version": "1.17.0"
},
{
"metadata": {
"id": "0479fc1c-3d67-49f9-b087-fb9069afe48f",
"publisherId": "ms-azuretools.vscode-docker",
"publisherDisplayName": "ms-azuretools"
},
"name": "vscode-docker",
"publisher": "ms-azuretools",
"version": "1.0.0"
},
{
"metadata": {
"id": "583b2b34-2c1e-4634-8c0b-0b82e283ea3a",
"publisherId": "dbaeumer.vscode-eslint",
"publisherDisplayName": "dbaeumer"
},
"name": "vscode-eslint",
"publisher": "dbaeumer",
"version": "2.1.2"
},
{
"metadata": {
"id": "aaee577c-f062-495a-9816-0cbd442f1d25",
"publisherId": "ecmel.vscode-html-css",
"publisherDisplayName": "ecmel"
},
"name": "vscode-html-css",
"publisher": "ecmel",
"version": "0.2.3"
},
{
"metadata": {
"id": "414b2873-c80e-4dc6-9031-bd185cfb3944",
"publisherId": "william-voyek.vscode-nginx",
"publisherDisplayName": "william-voyek"
},
"name": "vscode-nginx",
"publisher": "william-voyek",
"version": "0.7.2"
},
{
"metadata": {
"id": "23d72dfc-8dd1-4e30-926e-8783b4378f13",
"publisherId": "ms-vscode-remote.vscode-remote-extensionpack",
"publisherDisplayName": "ms-vscode-remote"
},
"name": "vscode-remote-extensionpack",
"publisher": "ms-vscode-remote",
"version": "0.20.0"
},
{
"metadata": {
"id": "e09613e9-f75d-4ddf-be87-bdf45c6121ea",
"publisherId": "lightbend.vscode-sbt-scala",
"publisherDisplayName": "lightbend"
},
"name": "vscode-sbt-scala",
"publisher": "lightbend",
"version": "0.2.4"
},
{
"metadata": {
"id": "beb68b20-7c55-471c-9b63-3486f9423566",
"publisherId": "mrmlnc.vscode-scss",
"publisherDisplayName": "mrmlnc"
},
"name": "vscode-scss",
"publisher": "mrmlnc",
"version": "0.9.0"
},
{
"metadata": {
"id": "3fb77af3-b8b3-4cb9-9137-f555bd80e2b1",
"publisherId": "richie5um2.vscode-sort-json",
"publisherDisplayName": "richie5um2"
},
"name": "vscode-sort-json",
"publisher": "richie5um2",
"version": "1.18.0"
},
{
"metadata": {
"id": "06cc3e44-aedb-41b8-a4ea-29ebf3c491fd",
"publisherId": "jpoissonnier.vscode-styled-components",
"publisherDisplayName": "jpoissonnier"
},
"name": "vscode-styled-components",
"publisher": "jpoissonnier",
"version": "0.0.29"
},
{
"metadata": {
"id": "785e4166-645b-4602-a232-157729c81571",
"publisherId": "johnuphoff.vscode-styled-sort",
"publisherDisplayName": "johnuphoff"
},
"name": "vscode-styled-sort",
"publisher": "johnuphoff",
"version": "0.0.7"
},
{
"metadata": {
"id": "a42d3dd1-f528-407c-a110-d5e35c7ca4c2",
"publisherId": "fivethree.vscode-svelte-snippets",
"publisherDisplayName": "fivethree"
},
"name": "vscode-svelte-snippets",
"publisher": "fivethree",
"version": "0.3.0"
},
{
"metadata": {
"id": "8911c2a6-cf78-4874-bf2e-de8377074174",
"publisherId": "seansassenrath.vscode-theme-superonedark",
"publisherDisplayName": "seansassenrath"
},
"name": "vscode-theme-superonedark",
"publisher": "seansassenrath",
"version": "0.0.15"
},
{
"metadata": {
"id": "f2fd462f-f1bd-4c62-b54f-59a4e5ffc6a3",
"publisherId": "WakaTime.vscode-wakatime",
"publisherDisplayName": "WakaTime"
},
"name": "vscode-wakatime",
"publisher": "WakaTime",
"version": "4.0.0"
},
{
"metadata": {
"id": "876e8f93-74d0-4f4f-91b7-34a09f19f444",
"publisherId": "VisualStudioExptTeam.vscodeintellicode",
"publisherDisplayName": "VisualStudioExptTeam"
},
"name": "vscodeintellicode",
"publisher": "VisualStudioExptTeam",
"version": "1.2.6"
},
{
"metadata": {
"id": "2b2535e4-d0cd-4b0a-9a18-5db6d6fb0c31",
"publisherId": "toba.vsfire",
"publisherDisplayName": "toba"
},
"name": "vsfire",
"publisher": "toba",
"version": "1.4.1"
},
{
"metadata": {
"id": "79f7a759-79aa-486d-b65f-d39ad40f7a6b",
"publisherId": "carlubian.yacc",
"publisherDisplayName": "carlubian"
},
"name": "yacc",
"publisher": "carlubian",
"version": "1.3.1"
}
]
{
"emmet.triggerExpansionOnTab": true,
"window.zoomLevel": 1,
"workbench.colorTheme": "Super One Dark",
"workbench.iconTheme": "material-icon-theme",
"terminal.integrated.rendererType": "dom",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"sync.gist": "49db7400cf17097a0f46e3ffbca7928a",
"stylelint.autoFixOnSave": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.jediEnabled": false,
"python.formatting.provider": "autopep8",
"prettier.prettierPath": "/usr/local/lib/node_modules/prettier",
"terminal.integrated.shell.osx": "/bin/bash",
"typescript.tsdk": "./node_modules/typescript/lib",
"javascript.format.enable": false,
"importSorter.generalConfiguration.sortOnBeforeSave": true,
"editor.fontLigatures": true,
"go.useLanguageServer": true,
"gitlens.gitCommands.closeOnFocusOut": true,
"git.ignoreLegacyWarning": true,
"explorer.confirmDragAndDrop": false,
"explorer.confirmDelete": false,
"emmet.syntaxProfiles": {
"jsx": {
"self_closing_tag": true
},
"javascript": "jsx",
},
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"vue-html": "html",
"svelte": "html"
},
"editor.suggestSelection": "first",
"editor.semanticHighlighting.enabled": true,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.fontFamily": "JetBrains Mono, Menlo, Monaco, 'Courier New', monospace, Cica",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[cpp]": {
"editor.tabSize": 2
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
],
"C_Cpp.updateChannel": "Insiders",
"C_Cpp.clang_format_style": "Google",
"rust-client.enableMultiProjectSetup": true,
"svelte.language-server.runtime": "/Users/tsukakoshihayato/.anyenv/envs/nodenv/shims/node",
"prettier.singleQuote": true
}
{
"read line": {
"prefix": "readln",
"body": [
"fn get_line() -> String {",
" let mut s = String::new();",
" std::io::stdin().read_line(&mut s).ok();",
" s.trim().to_string()",
"}",
"fn readln<T>() -> T",
" where",
" T: std::str::FromStr,",
" <T as std::str::FromStr>::Err: std::fmt::Debug {",
" get_line().parse().unwrap()",
"}"
]
},
"UnionFind": {
"prefix": "union",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct UnionFind {",
" par: Vec<usize>,",
" rank: Vec<usize>,",
" group: Vec<usize>,",
"}",
"#[allow(dead_code)]",
"impl UnionFind {",
" fn new(n: usize) -> Self {",
" UnionFind {",
" par: (0..n).collect(),",
" rank: vec![0; n],",
" group: vec![1; n],",
" }",
" }",
" fn find(&mut self, x: usize) -> usize {",
" if self.par[x] == x {",
" x",
" } else {",
" let px = self.par[x];",
" let root = self.find(px);",
" self.par[x] = root;",
" root",
" }",
" }",
" fn unite(&mut self, x: usize, y: usize) {",
" let x = self.find(x);",
" let y = self.find(y);",
" if x == y {",
" return",
" }",
" if self.rank[x] < self.rank[y] {",
" self.group[y] += self.group[x];",
" self.par[x] = y;",
" } else {",
" self.group[x] += self.group[y];",
" self.par[y] = x;",
" }",
" if self.rank[x] == self.rank[y] {",
" self.rank[y] += 1;",
" }",
" }",
" fn group_size(&mut self, x: usize) -> usize {",
" let p = self.find(x);",
" self.group[p]",
" }",
"}"
]
},
"directions": {
"prefix": "dire",
"body": [
"let dire: Vec<(isize, isize)> = vec![(1, 0), (0, 1), (-1, 0), (0, -1)];",
"let dire8: Vec<(isize, isize)> = vec![(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)];"
]
},
"gcd": {
"prefix": "gcd",
"body": [
"fn gcd(a: usize, b: usize) -> usize {",
" if b == 0 {",
" a",
" } else {",
" gcd(b, a % b)",
" }",
"}"
]
},
"lcm": {
"prefix": "lcm",
"body": [
"fn lcm(a: usize, b:usize) -> usize {",
" a * b / gcd(a, b)",
"}"
]
},
"mod_pow": {
"prefix": "modp",
"body": [
"fn mod_pow(x: usize, n: usize, m: usize) -> usize {",
" let mut res = 1;",
" let mut x = x;",
" let mut n = n;",
" while n > 0 {",
" if n & 1 == 1 {",
" res = (res * x) % m;",
" }",
" x = (x * x) % m;",
" n = n >> 1;",
" }",
" res",
"}"
]
},
"mod_inverse": {
"prefix": "modi",
"body": [
"fn mod_inv(a: usize, m: usize) -> usize {",
" let (_, x, _) = extgcd(a as i64, m as i64);",
" (m as i64 + x) as usize % m",
"}"
]
},
"extended gcd": {
"prefix": "extg",
"body": [
"fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {",
" if b == 0 {",
" (a, 1, 0)",
" } else {",
" let (gcd, x, y) = extgcd(b, a % b);",
" (gcd, y, x - (a / b) * y)",
" }",
"}"
]
},
"FactInverse": {
"prefix": "facti",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct FactInv {",
" fact: Vec<usize>,",
" inv: Vec<usize>,",
" factinv: Vec<usize>,",
" m: usize,",
"}",
"#[allow(dead_code)]",
"impl FactInv {",
" fn new(n: usize, m: usize) -> Self {",
" let mut fact: Vec<usize> = vec![0; n + 1];",
" fact[0] = 1;",
" for i in 1..n+1 {",
" fact[i] = i * &fact[i - 1] % m;",
" }",
" let mut inv = vec![0; n + 1];",
" inv[0] = 0;",
" inv[1] = 1;",
" for i in 2..n+1 {",
" inv[i] = inv[m % i] * (m - m / i) % m;",
" }",
" let mut factinv = vec![0; n + 1];",
" factinv[0] = 1;",
" for i in 1..n+1 {",
" factinv[i] = factinv[i - 1] * inv[i] % m;",
" }",
" FactInv {",
" fact: fact,",
" inv: inv,",
" factinv: factinv,",
" m: m,",
" }",
" }",
" fn comb(&self, n: usize, r: usize) -> usize {",
" if n < r {",
" 0",
" } else {",
" (self.fact[n] * self.factinv[r] % self.m) * self.factinv[n-r] % self.m",
" }",
" }",
"}"
]
},
"alphabets": {
"prefix": "alpha",
"body": [
"let alphabets = vec!['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'];"
]
},
"digit_sum": {
"prefix": "digits",
"body": [
"fn digit_sum(n: i64, b: i64) -> i64 {",
" if n < b {",
" n",
" } else {",
" digit_sum((n as f64/b as f64).floor() as i64, b) + (n % b)",
" }",
"}"
]
},
"Binary Search": {
"prefix": "bin",
"body": [
"pub trait BinarySearch<T> {",
" fn lower_bound(&self, x: &T) -> usize;",
" fn upper_bound(&self, x: &T) -> usize;",
"}",
"impl<T: Ord> BinarySearch<T> for [T] {",
" fn lower_bound(&self, x: &T) -> usize {",
" let mut low = 0;",
" let mut high = self.len();",
" while low != high {",
" let mid = (low + high) / 2;",
" match self[mid].cmp(x) {",
" Ordering::Less => {",
" low = mid + 1;",
" }",
" Ordering::Equal | Ordering::Greater => {",
" high = mid;",
" }",
" }",
" }",
" low",
" }",
" fn upper_bound(&self, x: &T) -> usize {",
" let mut low = 0;",
" let mut high = self.len();",
" while low != high {",
" let mid = (low + high) / 2;",
" match self[mid].cmp(x) {",
" Ordering::Less | Ordering::Equal => {",
" low = mid + 1;",
" }",
" Ordering::Greater => {",
" high = mid;",
" }",
" }",
" }",
" low",
" }",
"}"
]
},
"Total Order": {
"prefix": "total",
"body": [
"#[derive(PartialEq, PartialOrd, Clone, Debug)]",
"pub struct Total<T>(pub T);",
"impl<T: PartialEq> Eq for Total<T> {}",
"impl<T: PartialOrd> Ord for Total<T> {",
" fn cmp(&self, other: &Total<T>) -> Ordering {",
" self.0.partial_cmp(&other.0).unwrap()",
" }",
"}"
]
},
"Reverse": {
"prefix": "reverse",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"pub struct Rev<T>(pub T);",
"impl<T: PartialOrd> PartialOrd for Rev<T> {",
" fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {",
" other.0.partial_cmp(&self.0)",
" }",
"}",
"impl<T: Ord> Ord for Rev<T> {",
" fn cmp(&self, other: &Rev<T>) -> Ordering {",
" other.0.cmp(&self.0)",
" }",
"}"
]
},
"lexical permutation": {
"prefix": "permu",
"body": [
"//thanks for https://github.com/bluss/permutohedron/blob/master/src/lexical.rs",
"pub trait LexicalPermutation {",
" fn next_permutation(&mut self) -> bool;",
" fn prev_permutation(&mut self) -> bool;",
"}",
"impl<T> LexicalPermutation for [T] where T: Ord {",
" fn next_permutation(&mut self) -> bool {",
" if self.len() < 2 { return false; }",
" let mut i = self.len() - 1;",
" while i > 0 && self[i-1] >= self[i] {",
" i -= 1;",
" }",
" if i == 0 {",
" return false;",
" }",
" let mut j = self.len() - 1;",
" while j >= i && self[j] <= self[i-1] {",
" j -= 1;",
" }",
" self.swap(j, i-1);",
" self[i..].reverse();",
" true",
" }",
" fn prev_permutation(&mut self) -> bool {",
" if self.len() < 2 { return false; }",
" let mut i = self.len() - 1;",
" while i > 0 && self[i-1] <= self[i] {",
" i -= 1;",
" }",
" if i == 0 {",
" return false;",
" }",
" self[i..].reverse();",
" let mut j = self.len() - 1;",
" while j >= i && self[j-1] < self[i-1] {",
" j -= 1;",
" }",
" self.swap(i-1, j);",
" true",
" }",
"}"
]
},
"Warshall Floyd": {
"prefix": "warshallfloyd",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct WarshallFloyd {",
" dist: Vec<Vec<isize>>,",
" next: Vec<Vec<usize>>,",
" n: usize,",
"}",
"#[allow(dead_code)]",
"impl WarshallFloyd {",
" fn new(n: usize, edges: &Vec<(usize, usize, isize)>) -> Self {",
" let inf: isize = 1000000007;",
" let mut dist: Vec<Vec<isize>> = vec![vec![inf as isize; n]; n];",
" let mut next: Vec<Vec<usize>> = vec![vec![0; n]; n];",
" for &(a, b, c) in edges.into_iter() {",
" dist[a][b] = c;",
" }",
" for i in 0..n {",
" dist[i][i] = 0;",
" }",
" for i in 0..n {",
" for j in 0..n {",
" next[i][j] = j;",
" }",
" }",
" for k in 0..n {",
" for i in 0..n {",
" for j in 0..n {",
" if dist[i][j] > dist[i][k] + dist[k][j] {",
" dist[i][j] = dist[i][k] + dist[k][j];",
" next[i][j] = next[i][k];",
" }",
" }",
" }",
" }",
" WarshallFloyd {",
" dist: dist,",
" next: next,",
" n: n",
" }",
" }",
" fn get_path(&mut self, i: usize, j: usize) -> Vec<usize> {",
" let mut path = vec![];",
" let mut to = self.next[i][j];",
" path.push(i);",
" while to != j {",
" path.push(to);",
" to = self.next[to][j];",
" }",
" path.push(to);",
" path",
" }",
" fn has_negative_loop(&mut self) -> bool {",
" for i in 0..self.n {",
" if self.dist[i][i] < 0 {",
" return true",
" }",
" }",
" false",
" }",
"}"
]
},
"Eratosthenes": {
"prefix": "eratosthenes",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct Eratosthenes {",
" end: usize,",
" primes: Vec<usize>,",
" flags: Vec<usize>,",
"}",
"#[allow(dead_code)]",
"impl Eratosthenes {",
" fn new(n: usize) -> Self {",
" let bits = 32;",
" let flags_num = n / bits + 1;",
" let defaults: Vec<usize> = vec![0x5D75D75D, 0xD75D75D7, 0x75D75D75];",
" let (mut i, mut f, mut j);",
" let max = ((n as f32).sqrt() as usize) + 1;",
" let mut flags: Vec<usize> = (0..flags_num).map(|i| defaults[i % 3]).collect();",
" flags[flags_num - 1] &= (1 << (n % bits + 1)) - 1 ;",
" i = 5;",
" f = 4;",
" while i <= max {",
" let t = (flags[i / bits] >> (i % bits)) & 1 == 1;",
" if !t {",
" j = i * (i | 1);",
" while j <= n {",
" flags[j / bits] |= 1 << (j % bits);",
" j += i * 2;",
" }",
" }",
" f = 6 - f;",
" i += f;",
" }",
" flags[0] &= !0b1100;",
" flags[0] |= 0b11;",
" let mut primes = vec![];",
" for p in 2..n+1 {",
" if (flags[p / bits] >> (p % bits)) & 1 == 0 {",
" primes.push(p);",
" }",
" }",
" Eratosthenes {",
" end: n,",
" primes: primes,",
" flags: flags,",
" }",
" }",
" fn is_prime(&self, m: usize) -> bool {",
" self.flags[m / 32] >> (m % 32) & 1 == 0",
" }",
" fn factorization(&self, n: usize) -> HashMap<usize, usize> {",
" let mut n = n;",
" let mut factors: HashMap<usize, usize> = HashMap::new();",
" for &p in &self.primes {",
" while n % p == 0 {",
" n /= p;",
" *factors.entry(p).or_insert(0) += 1;",
" }",
" if p > n {",
" break;",
" }",
" }",
" factors",
" }",
"}"
]
},
"Dijkstra": {
"prefix": "dijkstra",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct Dijkstra {",
" dist: Vec<isize>,",
" neighbors: Vec<Vec<(usize, isize)>>,",
" n: usize,",
"}",
"#[allow(dead_code)]",
"impl Dijkstra {",
" fn new(n: usize, edges: &Vec<(usize, usize, isize)>, s: usize) -> Self {",
" let inf: isize = 1000000007;",
" let mut dist: Vec<isize> = vec![inf; n];",
" let mut neighbors: Vec<Vec<(usize, isize)>> = vec![vec![]; n];",
" let mut heap: BinaryHeap<Rev<(usize, isize)>> = BinaryHeap::new();",
" for &(a, b, c) in edges.into_iter() {",
" neighbors[a].push((b, c));",
" }",
" dist[s] = 0;",
" heap.push(Rev((s, 0)));",
" while !heap.is_empty() {",
" let Rev((v, d)) = heap.pop().unwrap();",
" if dist[v] < d {",
" continue;",
" }",
" for &(u, cost) in &neighbors[v] {",
" if dist[u] > dist[v] + cost {",
" dist[u] = dist[v] + cost;",
" heap.push(Rev((u, cost)));",
" }",
" }",
" }",
" Dijkstra {",
" dist: dist,",
" neighbors: neighbors,",
" n: n,",
" }",
" }",
"}"
]
},
"debug": {
"prefix": "debugmacro",
"body": [
"macro_rules! debug {",
" (\\$(\\$a:expr),*) => {",
" println!(concat!(\\$(stringify!(\\$a), \" = {:?}, \"),*), \\$(\\$a),*);",
" }",
"}"
]
},
"Neighbor list": {
"prefix": "neighbor",
"body": [
"let mut g: Vec<Vec<usize>> = vec![vec![]; N];",
"for &(a, b) in &ab {",
" g[a].push(b);",
" g[b].push(a);",
"}"
]
},
"print vector": {
"prefix": "printvec",
"body": [
"macro_rules! printvec {",
" ( \\$item:expr ) => {",
" for &i in &\\$item {",
" print!(\"{} \", i);",
" }",
" println!(\"\");",
" }",
"}"
]
},
"LowestCommonAncestor": {
"prefix": "LowestCommonAncestor",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct LowestCommonAncestor {",
" g: Vec<Vec<usize>>,",
" parent: Vec<Vec<Option<usize>>>,",
" depth: Vec<usize>,",
"}",
"#[allow(dead_code)]",
"impl LowestCommonAncestor {",
" fn new(n: usize, edges: &[(usize, usize)]) -> Self",
" {",
" let mut g = vec![vec![]; n];",
" for &(a, b) in edges.into_iter() {",
" g[a].push(b);",
" g[b].push(a);",
" }",
" let log_n = (1..).find(|i| (1usize << i) > n).unwrap();;",
" let mut parent = vec![vec![None; n]; log_n];",
" let mut depth = vec![0; n];",
" LowestCommonAncestor::build(n, log_n, &g, &mut parent, &mut depth);",
" LowestCommonAncestor {",
" g: g,",
" parent: parent,",
" depth: depth,",
" }",
" }",
" fn build(",
" n: usize,",
" log_n: usize,",
" g: &[Vec<usize>],",
" parent: &mut [Vec<Option<usize>>],",
" depth: &mut [usize],",
" ) -> () {",
" LowestCommonAncestor::dfs(0, None, 0, g, parent, depth);",
" for k in 0..log_n-1 {",
" for v in 0..n {",
" if parent[k][v] == None {",
" parent[k+1][v] = None;",
" } else {",
" let super_parent = parent[k][v].unwrap();",
" parent[k+1][v] = parent[k][super_parent];",
" }",
" }",
" }",
" }",
" fn dfs(",
" v: usize,",
" p: Option<usize>,",
" d: usize,",
" g: &[Vec<usize>],",
" parent: &mut [Vec<Option<usize>>],",
" depth: &mut [usize],",
" ) -> () {",
" parent[0][v] = p;",
" depth[v] = d;",
" for &u in &g[v] {",
" if Some(u) != p {",
" LowestCommonAncestor::dfs(u, Some(v), d+1, g, parent, depth);",
" }",
" }",
" }",
" fn lca(&self, mut a: usize, mut b: usize) -> usize {",
" if self.depth[a] > self.depth[b] {",
" std::mem::swap(&mut a, &mut b);",
" }",
" while self.depth[a] != self.depth[b] {",
" b = self.parent[(self.depth[b] - self.depth[a]).trailing_zeros() as usize][b].unwrap();",
" }",
" if a == b {",
" return a;",
" }",
" for k in (0..self.parent.len()).rev() {",
" if self.parent[k][a] != self.parent[k][b] {",
" a = self.parent[k][a].unwrap();",
" b = self.parent[k][b].unwrap();",
" }",
" }",
" self.parent[0][a].unwrap()",
" }",
" fn dist(&self, a: usize, b: usize) -> usize {",
" self.depth[a] + self.depth[b] - 2 * self.depth[self.lca(a, b)]",
" }",
"}"
]
},
"ForestLowestCommonAncestor": {
"prefix": "ForestLowestCommonAncestor",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct ForestLowestCommonAncestor {",
" g: Vec<Vec<usize>>,",
" parent: Vec<Vec<Option<usize>>>,",
" depth: Vec<usize>,",
"}",
"#[allow(dead_code)]",
"impl ForestLowestCommonAncestor {",
" fn new(n: usize, edges: &[(usize, usize)]) -> Self",
" {",
" let mut g = vec![vec![]; n];",
" for &(a, b) in edges.into_iter() {",
" g[a].push(b);",
" g[b].push(a);",
" }",
" let log_n = (1..).find(|i| (1usize << i) > n).unwrap();;",
" let mut parent = vec![vec![None; n]; log_n];",
" let mut depth = vec![0; n];",
" let mut visit = vec![false; n];",
" ForestLowestCommonAncestor::build(",
" n,",
" log_n,",
" &g,",
" &mut parent,",
" &mut depth,",
" &mut visit,",
" );",
" ForestLowestCommonAncestor {",
" g: g,",
" parent: parent,",
" depth: depth,",
" }",
" }",
" fn build(",
" n: usize,",
" log_n: usize,",
" g: &[Vec<usize>],",
" parent: &mut [Vec<Option<usize>>],",
" depth: &mut [usize],",
" visit: &mut [bool],",
" ) -> () {",
" for v in 0..n {",
" if !visit[v] {",
" ForestLowestCommonAncestor::dfs(v, None, 0, g, parent, depth, visit);",
" }",
" }",
" for k in 0..log_n-1 {",
" for v in 0..n {",
" if parent[k][v] == None {",
" parent[k+1][v] = None;",
" } else {",
" let super_parent = parent[k][v].unwrap();",
" parent[k+1][v] = parent[k][super_parent];",
" }",
" }",
" }",
" }",
" fn dfs(",
" v: usize,",
" p: Option<usize>,",
" d: usize,",
" g: &[Vec<usize>],",
" parent: &mut [Vec<Option<usize>>],",
" depth: &mut [usize],",
" visit: &mut [bool],",
" ) -> () {",
" parent[0][v] = p;",
" depth[v] = d;",
" visit[v] = true;",
" for &u in &g[v] {",
" if !visit[u] {",
" ForestLowestCommonAncestor::dfs(u, Some(v), d+1, g, parent, depth, visit);",
" }",
" }",
" }",
" fn lca(&self, mut a: usize, mut b: usize) -> Option<usize> {",
" if self.depth[a] > self.depth[b] {",
" std::mem::swap(&mut a, &mut b);",
" }",
" while self.depth[a] != self.depth[b] {",
" b = self.parent[(self.depth[b] - self.depth[a]).trailing_zeros() as usize][b].unwrap();",
" }",
" if a == b {",
" return Some(a);",
" }",
" for k in (0..self.parent.len()).rev() {",
" if self.parent[k][a] != self.parent[k][b] {",
" a = self.parent[k][a].unwrap();",
" b = self.parent[k][b].unwrap();",
" }",
" }",
" if self.parent[0][a] == None && self.parent[0][b] == None {",
" None",
" } else {",
" self.parent[0][a]",
" }",
" }",
" fn dist(&self, a: usize, b: usize) -> Option<usize> {",
" if let Some(lca) = self.lca(a, b) {",
" Some(self.depth[a] + self.depth[b] - 2 * self.depth[lca])",
" } else {",
" None",
" }",
" }",
"}"
]
},
"WeightedForestLowestCommonAncestor": {
"prefix": "WeightedForestLowestCommonAncestor",
"body": [
"#[derive(Eq, PartialEq, Clone, Debug)]",
"struct WeightedForestLowestCommonAncestor {",
" g: Vec<Vec<(usize, usize)>>,",
" parent: Vec<Vec<Option<usize>>>,",
" weight: Vec<Vec<Option<usize>>>,",
" depth: Vec<usize>,",
"}",
"#[allow(dead_code)]",
"impl WeightedForestLowestCommonAncestor {",
" fn new<T>(n: usize, edges: &[(usize, usize, usize)], comp: T) -> Self",
" where T: Fn(usize, usize) -> usize",
" {",
" let mut g = vec![vec![]; n];",
" for &(a, b, cost) in edges.into_iter() {",
" g[a].push((b, cost));",
" g[b].push((a, cost));",
" }",
" let log_n = (1..).find(|i| (1usize << i) > n).unwrap();;",
" let mut parent = vec![vec![None; n]; log_n];",
" let mut weight = vec![vec![None; n]; log_n];",
" let mut depth = vec![0; n];",
" let mut visit = vec![false; n];",
" WeightedForestLowestCommonAncestor::build(",
" n,",
" log_n,",
" &g,",
" &mut parent,",
" &mut weight,",
" &mut depth,",
" &mut visit,",
" &comp",
" );",
" WeightedForestLowestCommonAncestor {",
" g: g,",
" parent: parent,",
" weight: weight,",
" depth: depth,",
" }",
" }",
" fn build<T>(",
" n: usize,",
" log_n: usize,",
" g: &[Vec<(usize, usize)>],",
" parent: &mut [Vec<Option<usize>>],",
" weight: &mut [Vec<Option<usize>>],",
" depth: &mut [usize],",
" visit: &mut [bool],",
" comp: T",
" ) -> ()",
" where T: Fn(usize, usize) -> usize",
" {",
" for v in 0..n {",
" if !visit[v] {",
" WeightedForestLowestCommonAncestor::dfs(v, None, 0, g, parent, weight, depth, visit);",
" }",
" }",
" for k in 0..log_n-1 {",
" for v in 0..n {",
" if parent[k][v] == None {",
" parent[k+1][v] = None;",
" } else {",
" let super_parent = parent[k][v].unwrap();",
" parent[k+1][v] = parent[k][super_parent];",
" if parent[k+1][v] != None {",
" let weight_p = weight[k][v].unwrap();",
" let weight_sp = weight[k][super_parent].unwrap();",
" weight[k+1][v] = Some(comp(weight_p, weight_sp));",
" } else {",
" weight[k+1][v] = None;",
" }",
" }",
" }",
" }",
" }",
" fn dfs(",
" v: usize,",
" p: Option<usize>,",
" d: usize,",
" g: &[Vec<(usize, usize)>],",
" parent: &mut [Vec<Option<usize>>],",
" weight: &mut [Vec<Option<usize>>],",
" depth: &mut [usize],",
" visit: &mut [bool],",
" ) -> () {",
" parent[0][v] = p;",
" depth[v] = d;",
" visit[v] = true;",
" for &(u, cost) in &g[v] {",
" if !visit[u] {",
" weight[0][u] = Some(cost);",
" WeightedForestLowestCommonAncestor::dfs(u, Some(v), d+1, g, parent, weight, depth, visit);",
" }",
" }",
" }",
" fn lca(&self, mut a: usize, mut b: usize) -> Option<usize> {",
" if self.depth[a] > self.depth[b] {",
" std::mem::swap(&mut a, &mut b);",
" }",
" while self.depth[a] != self.depth[b] {",
" b = self.parent[(self.depth[b] - self.depth[a]).trailing_zeros() as usize][b].unwrap();",
" }",
" if a == b {",
" return Some(a);",
" }",
" for k in (0..self.parent.len()).rev() {",
" if self.parent[k][a] != self.parent[k][b] {",
" a = self.parent[k][a].unwrap();",
" b = self.parent[k][b].unwrap();",
" }",
" }",
" if self.parent[0][a] == None && self.parent[0][b] == None {",
" None",
" } else {",
" self.parent[0][a]",
" }",
" }",
" fn dist(&self, a: usize, b: usize) -> Option<usize> {",
" self.query_interface(a, b, |x, y| { x + y }, 0)",
" }",
" fn max_path_weight(&self, a: usize, b: usize) -> Option<usize> {",
" self.query_interface(a, b, |x, y| { std::cmp::max(x, y) }, 0)",
" }",
" fn min_path_weight(&self, a: usize, b: usize) -> Option<usize> {",
" let inf = 1000000007;",
" self.query_interface(a, b, |x, y| { std::cmp::min(x, y) }, inf)",
" }",
" fn query_interface<T>(&self, mut a: usize, mut b: usize, f: T, init_ret: usize) -> Option<usize>",
" where T: Fn(usize, usize) -> usize",
" {",
" if a == b {",
" return None",
" }",
" let mut ret = init_ret;",
" if self.depth[a] > self.depth[b] {",
" std::mem::swap(&mut a, &mut b);",
" }",
" while self.depth[a] != self.depth[b] {",
" let step = (self.depth[b] - self.depth[a]).trailing_zeros() as usize;",
" ret = f(ret, self.weight[step][b].unwrap());",
" b = self.parent[step][b].unwrap();",
" }",
" if a == b {",
" return Some(ret);",
" }",
" for k in (0..self.parent.len()).rev() {",
" if self.parent[k][a] != self.parent[k][b] {",
" ret = f(ret, self.weight[k][a].unwrap());",
" ret = f(ret, self.weight[k][b].unwrap());",
" a = self.parent[k][a].unwrap();",
" b = self.parent[k][b].unwrap();",
" }",
" }",
" if self.parent[0][a] == None && self.parent[0][b] == None {",
" None",
" } else {",
" ret = f(ret, self.weight[0][a].unwrap());",
" ret = f(ret, self.weight[0][b].unwrap());",
" Some(ret)",
" }",
" }",
"}"
]
},
"programmingContenst": {
"prefix": "pro",
"body": [
"#![allow(non_snake_case)]",
"#[allow(unused_imports)]",
"use std::io::{self, Write};",
"#[allow(unused_imports)]",
"use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};",
"#[allow(unused_imports)]",
"use std::cmp::{max, min, Ordering};",
"macro_rules! input {",
" (source = \\$s:expr, \\$(\\$r:tt)*) => {",
" let mut iter = \\$s.split_whitespace();",
" let mut next = || { iter.next().unwrap() };",
" input_inner!{next, \\$(\\$r)*}",
" };",
" (\\$(\\$r:tt)*) => {",
" let stdin = std::io::stdin();",
" let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));",
" let mut next = move || -> String{",
" bytes",
" .by_ref()",
" .map(|r|r.unwrap() as char)",
" .skip_while(|c|c.is_whitespace())",
" .take_while(|c|!c.is_whitespace())",
" .collect()",
" };",
" input_inner!{next, \\$(\\$r)*}",
" };",
"}",
"macro_rules! input_inner {",
" (\\$next:expr) => {};",
" (\\$next:expr, ) => {};",
" (\\$next:expr, \\$var:ident : \\$t:tt \\$(\\$r:tt)*) => {",
" let \\$var = read_value!(\\$next, \\$t);",
" input_inner!{\\$next \\$(\\$r)*}",
" };",
"}",
"macro_rules! read_value {",
" (\\$next:expr, ( \\$(\\$t:tt),* )) => {",
" ( \\$(read_value!(\\$next, \\$t)),* )",
" };",
" (\\$next:expr, [ \\$t:tt ; \\$len:expr ]) => {",
" (0..\\$len).map(|_| read_value!(\\$next, \\$t)).collect::<Vec<_>>()",
" };",
" (\\$next:expr, chars) => {",
" read_value!(\\$next, String).chars().collect::<Vec<char>>()",
" };",
" (\\$next:expr, char) => {",
" read_value!(\\$next, String).chars().collect::<Vec<char>>()[0]",
" };",
" (\\$next:expr, usize1) => {",
" read_value!(\\$next, usize) - 1",
" };",
" (\\$next:expr, isize1) => {",
" read_value!(\\$next, isize) - 1",
" };",
" (\\$next:expr, \\$t:ty) => {",
" \\$next().parse::<\\$t>().expect(\"Parse error\")",
" };",
"}",
"macro_rules! printvec {",
" ( \\$item:expr ) => {",
" for &i in &\\$item {",
" print!(\"{} \", i);",
" }",
" println!(\"\");",
" }",
"}",
"macro_rules! debug {",
" (\\$(\\$a:expr),*) => {",
" println!(concat!(\\$(stringify!(\\$a), \" = {:?}, \"),*), \\$(\\$a),*);",
" }",
"}",
"#[derive(Eq, PartialEq, Clone, Debug)]",
"pub struct Rev<T>(pub T);",
"impl<T: PartialOrd> PartialOrd for Rev<T> {",
" fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {",
" other.0.partial_cmp(&self.0)",
" }",
"}",
"impl<T: Ord> Ord for Rev<T> {",
" fn cmp(&self, other: &Rev<T>) -> Ordering {",
" other.0.cmp(&self.0)",
" }",
"}",
"#[derive(PartialEq, PartialOrd, Clone, Debug)]",
"pub struct Total<T>(pub T);",
"impl<T: PartialEq> Eq for Total<T> {}",
"impl<T: PartialOrd> Ord for Total<T> {",
" fn cmp(&self, other: &Total<T>) -> Ordering {",
" self.0.partial_cmp(&other.0).unwrap()",
" }",
"}",
"#[allow(dead_code)]",
"const MOD: usize = 1000000007;",
"\n",
"fn main() {",
" input!{",
" N: usize,",
" }",
"}"
]
},
"utils": {
"prefix": "utils",
"body": [
"trait CharUtils {",
" fn to_num(self) -> usize;",
"}",
"impl CharUtils for char {",
" fn to_num(self) -> usize {",
" self as usize",
" }",
"}",
"trait UsizeUtils {",
" fn sqrt_floor(self) -> usize;",
" fn sqrt_ceil(self) -> usize;",
" fn factors(self) -> HashMap<usize, usize>;",
" fn digits(self) -> usize;",
" fn bit_length(self) -> usize;",
"}",
"impl UsizeUtils for usize {",
" fn sqrt_floor(self) -> usize {",
" (self as f64).sqrt() as usize",
" }",
" fn sqrt_ceil(self) -> usize {",
" let tmp = (self as f64).sqrt() as usize;",
" if tmp * tmp == self {",
" tmp",
" } else {",
" tmp + 1",
" }",
" }",
" fn factors(self) -> HashMap<usize, usize> {",
" let mut facs: HashMap<usize, usize> = HashMap::new();",
" let mut n = self;",
" let mut a = 2;",
" while n >= a*a {",
" if n % a == 0{",
" n /= a;",
" *facs.entry(a).or_insert(0) += 1;",
" } else {",
" a += 1;",
" }",
" }",
" *facs.entry(n).or_insert(0) += 1;",
" facs",
" }",
" fn digits(self) -> usize {",
" (self as f64).log10() as usize + 1",
" }",
"fn bit_length(self) -> usize {",
" let mut ret = 0;",
" let mut n = self;",
" while n > 0 {",
" ret += 1;",
" n >>= 1;",
" }",
" ret",
"}",
"}",
"trait VecUtils<T> {",
" fn transpose(&self) -> Vec<Vec<&T>>;",
"}",
"impl<T> VecUtils<T> for Vec<Vec<T>> {",
" fn transpose(&self) -> Vec<Vec<&T>> {",
" (0..self[0].len()).map(|j| (0..self.len()).map(|i| &self[i][j]).collect::<Vec<&T>>()).collect::<Vec<Vec<&T>>>()",
" }",
"}"
]
}
}
{
// Place your snippets for typescriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"component template": {
"prefix": "template",
"body": [
"import React from 'react';",
"import styled from '@emotion/styled';",
"",
"type ContainerProps = {};",
"type Props = {} & ContainerProps;",
"",
"const Component: React.FCX<Props> = ({ className }) => (",
" <div className={className}>",
" </div>",
");",
"",
"const StyledComponent = styled(Component)`",
"@media screen and (max-width: 1100px) {",
"}",
"@media screen and (max-width: 768px) {",
"}",
"@media screen and (max-width: 480px) {",
"}",
"@media screen and (max-height: 430px) {",
"}",
"`;",
"",
"const Container: React.FCX<ContainerProps> = props => {",
" return <StyledComponent {...props} />;",
"};",
"",
"export default Container;",
]
},
"media query": {
"prefix": "media",
"body": [
"@media screen and (max-width: 1100px) {",
"}",
"@media screen and (max-width: 768px) {",
"}",
"@media screen and (max-width: 480px) {",
"}",
"@media screen and (max-height: 430px) {",
"}",
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment