Skip to content

Instantly share code, notes, and snippets.

@aahnik
Created January 9, 2024 12:33
Show Gist options
  • Save aahnik/c33501e106200d25819b8160ff59fe11 to your computer and use it in GitHub Desktop.
Save aahnik/c33501e106200d25819b8160ff59fe11 to your computer and use it in GitHub Desktop.
Cp Vs code setup for leetcode and codeforces
{
"Cp cpp": {
"prefix": "cpp",
"body": [
"#include <bits/stdc++.h>",
"using namespace std;",
"",
"#ifdef aahnik",
"#include \"dbg.cpp\"",
"#else",
"#define dbg(x)",
"#define std_files",
"#define display_time",
"#endif",
"",
"#define int long long",
"#define all(x) (x).begin(), (x).end()",
"",
"void solve() {",
" $0",
"}",
"",
"int32_t main() {",
" // clang-format off",
" std_files;",
" cin.tie(nullptr)->sync_with_stdio(false);",
" int T = 1;",
" const auto start_time = chrono::high_resolution_clock::now();",
" cin >> T; // testcases",
" while (T--)",
"\tsolve();",
" display_time;",
" return 0;",
"}"
],
"description": "cpp template for cp"
}
"Leetcpp": {
"prefix": "leet",
"body": [
"#include <bits/stdc++.h>",
"using namespace std;",
"",
"#ifdef aahnik",
"#include \"dbg.cpp\"",
"#else",
"#define dbg(x)",
"#define std_files",
"#define display_time",
"#endif",
"",
"#define int long long",
"#define all(x) (x).begin(), (x).end()",
"",
"class Solution {",
" public:",
" $0",
" void test() {",
"\tcerr << \"# Tests\" << '\\n';",
" }",
"};",
"",
"int32_t main() {",
" // clang-format off",
" std_files;",
" cin.tie(nullptr)->sync_with_stdio(false);",
" const auto start_time = chrono::high_resolution_clock::now();",
" Solution sol = Solution();",
" sol.test();",
" display_time;",
" return 0;",
"}"
],
"description": "leetcode template"
}
}
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define dbg(x) \
cerr << #x << " "; \
_print(x); \
cerr << '\n';
template <typename T>
void _print(T t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
cerr << "{";
_print(p.fi);
cerr << ",";
_print(p.se);
cerr << "}";
}
template <class T>
void _print(vector<T> v) {
cerr << "[ ";
for (T i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(set<T> v) {
cerr << "[ ";
for (T i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
cerr << "[ ";
for (T i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
cerr << "[ ";
for (auto i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T, class V>
void _print(unordered_map<T, V> v) {
cerr << "[ ";
for (auto i : v) {
_print(i);
cerr << " ";
}
cerr << "]";
}
#define std_files \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout); \
freopen("error.txt", "w", stderr)
#define display_time \
auto end_time = chrono::high_resolution_clock::now(); \
chrono::duration<double> diff = end_time - start_time; \
cerr << "Time Taken : " << diff.count() * 1000 << " ms\n"
#include <bits/stdc++.h>
using namespace std;
#ifdef aahnik
#include "dbg.cpp"
#else
#define dbg(x)
#define std_files
#define display_time
#endif
#define int long long
#define all(x) (x).begin(), (x).end()
class Solution {
public:
void test() {
cerr << "# Tests" << '\n';
}
};
#ifdef aahnik
int32_t main() {
// clang-format off
std_files;
cin.tie(nullptr)->sync_with_stdio(false);
const auto start_time = chrono::high_resolution_clock::now();
Solution sol = Solution();
sol.test();
display_time;
return 0;
}
#endif
#include <bits/stdc++.h>
using namespace std;
#ifdef aahnik
#include "dbg.cpp"
#else
#define dbg(x)
#define std_files
#define display_time
#endif
#define int long long
#define all(x) (x).begin(), (x).end()
void solve() {
int n = 0;
cin >> n;
dbg(n);
}
int32_t main() {
// clang-format off
std_files;
cin.tie(nullptr)->sync_with_stdio(false);
int T = 1;
const auto start_time = chrono::high_resolution_clock::now();
cin >> T; // testcases
while (T--)
solve();
display_time;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment