-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplates
29 lines (21 loc) · 6.01 KB
/
templates
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
;; ~/.config/emacs/templates
fundamental-mode ;; Available everywhere
(today (format-time-string "%Y-%m-%d"))
org-mode ;; Available Org-mode
(class "#+title: "
(p (string-join
(mapcar #'capitalize
(split-string
(let (case-fold-search)
(replace-regexp-in-string
"\\([[:lower:]]\\)\\([[:upper:]]\\)" "\\1 \\2"
(replace-regexp-in-string "\\([[:upper:]]\\)\\([[:upper:]][0-9[:lower:]]\\)"
"\\1 \\2" (file-name-base(file-name-base buffer-file-name)))))
"[^[:word:]0-9]+"
)) " " )
) n "#+description: " (p "description") n "#+latex_header_extra: \\hypersetup{colorlinks=true,linkcolor=blue}" n "#+author: Aditya Yadav" n n "* " (p "heading") n q)
c++-mode c++-ts-mode ;; Available c++-mode
(chef "#include <bits/stdc++.h>" n n "using namespace std;" n n "int main(int argc, char *argv[]) {" n> "ios_base::sync_with_stdio(false);" n> "cin.tie(NULL);" n> "int testcase;" n> "cin >> testcase;" n> "while(testcase--){" n> q n " }" n> "return 0;" n "}")
(cp "#include <bits/stdc++.h>" n "using namespace std;" n n "#define clz __builtin_clz" n "#define ctz __builtin_ctz" n "#define cnz __builtin_popcount" n "#define clmsb __builtin_clrsb" n "#define bitswap __builtin_bswap32" n "" n "#define clzl __builtin_clzl" n "#define ctzl __builtin_ctzl" n "#define cnzl __builtin_popcountl" n "#define clmsbl __builtin_clrsb" n "#define bitswapl __builtin_bswap64" n "" n "#define mod 1000000007" n "#define mods 998244353" n "#define all(x) (x).begin(), (x).end()" n "#define pwp(x,y) fixed<<setprecision(y)<<x" n "#define FIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)" n "#define repeat int t;cin>>t;while(t--)" n "" n "vector<int>sieve(int n){int*arr=new int[n+1];vector<int>vect;for(int i=2;i<=n;i++)if(arr[i]==0){vect.push_back(i);for(int j=2*i;j<=n;j+=i)arr[j]=1;}free(arr);return vect;}" n "int power(int x,unsigned int y,int m){int res=1;x=x%m;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%m;y=y>>1;x=(x*x)%m;}return res;}" n "int mod_inverse(int a,int p){return power(a,p-2,p);}" n "int mod_add(int a,int b,int m){a=a%m;b=b%m;return(((a+b)%m)+m)%m;}" n "int mod_mul(int a,int b,int m){a=a%m;b=b%m;return(((a*b)%m)+m)%m;}" n "int mod_sub(int a,int b,int m){a=a%m;b=b%m;return(((a-b)%m)+m)%m;}" n "int mod_div(int a,int b,int m){a=a%m;b=b%m;return(mod_mul(a,mod_inverse(b,m),m)+m)%m;}" n "" n "" n "#if !defined(ONLINE_JUDGE) && 1" n "#define dbg(x) cerr << #x <<\" \"; _print(x); cerr << endl;" n "#else" n "#define dbg(x)" n "#endif" n "" n "template <class T> void _print(T t) {cerr << t;}" n "void _print(string t) {cerr << '\"' << t << '\"';}" n "template <class T, class V> void _print(pair <T, V> p) {cerr << \"{\"; _print(p.first); cerr << \",\"; _print(p.second); cerr << \"}\";}" n "template <class T> void _print(vector <T> v) {cerr << \"[ \"; for (T i : v) {_print(i); cerr << \" \";} cerr << \"]\"<<endl;}" n "template <class T> void _print(set <T> v) {cerr << \"[ \"; for (T i : v) {_print(i); cerr << \" \";} cerr << \"]\";}" n "template <class T> void _print(multiset <T> v) {cerr << \"[ \"; for (T i : v) {_print(i); cerr << \" \";} cerr << \"]\";}" n "template <class T, class V> void _print(map <T, V> v) {cerr << \"[ \"; for (auto i : v) {_print(i); cerr << \" \";} cerr << \"]\";}" n n "int main(int argc, char *argv[]) {" n> "ios_base::sync_with_stdio(false);" n> "cin.tie(NULL);" n> "int testcase;" n> "cin >> testcase;" n> "while(testcase--){" n> q n " }" n> "return 0;" n "}")
rustic-mode ;; Available rustic-mode
(chef "use std::io;" n "#[allow(unused_imports)]" n "use std::io::Write;" n n "/**************************************************" n n "START OF TEMPLATE CODE" n n " *************************************************/" n "#[allow(dead_code)]" n "enum InputSource {" n> "Stdin," n> "FromFile(Vec<String>)," n "}" n n "struct Scanner {" n> "buffer: Vec<String>," n> "input_source: InputSource," n "}" n n "#[allow(dead_code)]" n "fn next_permutation(nums: &mut Vec<usize>) -> bool {" n> "if nums.len() < 2 {" n> "return false;" n> "}" n> "let mut i = nums.len() - 1;" n> "while i > 0 && nums[i - 1] >= nums[i] {" n> "i -= 1;" n> "}" n> "if i == 0 {" n> "return false;" n> "}" n> "let mut j = nums.len() - 1;" n> "while j >= i && nums[j] <= nums[i - 1] {" n> "j -= 1;" n> "}" n> "nums.swap(j, i - 1);" n> "nums[i..].reverse();" n> "true" n "}" n n "impl Scanner {" n> "#[allow(dead_code)]" n> "fn new() -> Self {" n> "Self {" n> "buffer: vec![]," n> "input_source: InputSource::Stdin," n> "}" n> "}" n> "#[allow(dead_code)]" n> "fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {" n> "(0..n).map(|_| self.next::<T>()).collect()" n> "}" n n> "fn parse_next_line(&mut self) -> bool {" n> "let mut input = String::new();" n> "match &mut self.input_source {" n> "InputSource::Stdin => {" n> "if std::io::stdin().read_line(&mut input).expect(\"Failed read\") == 0 {" n> "return false;" n> "}" n> "}" n> "InputSource::FromFile(lines) => match lines.pop() {" n> "Some(line) => input = line," n> "None => return false," n> "}," n> "}" n n> "self.buffer = input.split_whitespace().rev().map(String::from).collect();" n> "return true;" n> "}" n n> "fn next<T: std::str::FromStr>(&mut self) -> T {" n> "loop {" n> "if let Some(token) = self.buffer.pop() {" n> "return token.parse().ok().expect(\"Failed parse\");" n> "}" n n> "self.parse_next_line();" n> "}" n> "}" n n> "#[allow(dead_code)]" n> "fn has_more_elements(&mut self) -> bool {" n> "loop {" n> "if !self.buffer.is_empty() {" n> "return true;" n> "}" n> "if !self.parse_next_line() {" n> "return false;" n> "}" n> "}" n> "}" n n> "#[allow(dead_code)]" n> "fn string(&mut self) -> String {" n> "self.next::<String>()" n> "}" n "}" n n "/**************************************************" n n "END OF TEMPLATE CODE" n n " *************************************************/" n n "fn main() {" n> "let stdout = io::stdout();" n> "#[allow(unused_variables, unused_mut)]" n> "let mut out = std::io::BufWriter::new(stdout.lock());" n> "let mut sc = Scanner::new();" n> "let size = sc.next::<usize>();" n> q n "}")