func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; template <typename T> void debug(vector<T> x) { for (auto e : x) { cout << e << ; } cout << n ; } void solve() { long long n, m, x, y; cin >> n >> m >> x >> y; vector<pair<long long, long long>> ans;... |
#include <bits/stdc++.h> using namespace std; int main() { long long int N, cn = 0, Z = 0, max = 0; cin >> N; int arr[N]; for (int i = 0; i < N; i++) { cin >> arr[i]; } for (int i = 0; i < N; i++) { cn = 0; for (int j = i + 1; j < N; j++) { if (arr[i] == arr[j] && a... |
#include <bits/stdc++.h> using namespace std; using ui32 = unsigned; using ui64 = unsigned long long; using i64 = long long; using i32 = int; static constexpr bool debug = false; struct node { node *c[2] = {0, 0}; int cnt = 0; }; node *root = new node; void insert_rec(node *nd, ui32 number, ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 55; const int inf = 1e9 + 77; const int MOD = 1e9 + 7; const double eps = 1e-7; map<int, int> mp; pair<int, int> pi; vector<long long> v; map<char, int> mp1; deque<int> d; int x[MAX], y[MAX]; char c[MAX]; int cnt[MAX]; int m... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; if (k == 0 || k == n) { cout << 0 0 ; return 0; } cout << min(1LL, n - k) << << min(n - k, k * 2LL); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, tx, ty, ans = 0; vector<int> x, y; cin >> n; for (int i = 0; i <= n; i++) { cin >> tx >> ty; x.push_back(tx), y.push_back(ty); } for (int i = 1; i < n; i++) { int fx = x[i + 1], fy = y[i + 1]; int cx = ... |
#include <bits/stdc++.h> using namespace std; long long int INF = 9223372036854775807; const long long int mod = 1000000007; long long int MOD(long long int a, long long int b) { if (a > b) return a - b; else return b - a; } long long int max3(long long int a, long long int b, long long ... |
#include <bits/stdc++.h> using namespace std; long long INF = 1e18; int INFi = 2e9; double eps = 1e-6; long long mod = 1e9 + 7; vector<char> used; vector<vector<int>> edge; vector<int> p; vector<int> cnt; int sz = 0; void add(int beg, int end) { while (beg != end) { cnt[beg]++; beg... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { if (y == 0) return 1; else if (y % 2 == 0) return power(x, y / 2) * power(x, y / 2); else return x * power(x, y / 2) * power(x, y / 2); } double slope(long long int x1, long long i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int n, m, ROOT, head; bool vis[MAXN]; int depth[MAXN], deg[MAXN]; vector<int> adj[MAXN]; vector<int> c; stack<int> stk; pair<bool, vector<int> > independentSet() { set<pair<int, int> > s; vector<int> v; for (auto i = 0... |
#include <bits/stdc++.h> using namespace std; namespace whatever { int readu() { char ch = getchar(); while (!isdigit(ch)) ch = getchar(); int value = ch - 0 ; ch = getchar(); while (isdigit(ch)) { value = value * 10 + ch - 0 ; ch = getchar(); } return value; } long l... |
#include <bits/stdc++.h> using namespace std; const int buffer_size = 1 << 20; int rd_char() { static char buf[buffer_size]; static int l = buffer_size, r = buffer_size; if (l == r && r == buffer_size) { r = fread(buf, sizeof(char), 1 << 20, stdin); l = 0; } if (l == r) return EOF;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, i; vector<int> arr, sol, orig; cin >> n; arr.resize(n); for (i = 0; i < n; ++i) { cin >> arr[i]; } orig = arr; sort(orig.begin(), orig.end()); for (... |
#include<bits/stdc++.h> using namespace std; int main() { int t,p,k,q,b; cin>>t; string s; while(t--) { cin>>s; k=0; q=0; b=0; p=0; for(int i=0;i<s.size();i++) { if(s[0]== ) || s[s.size()-1]== ( ) { ... |
#include<bits/stdc++.h> using namespace std; #define il inline #define rg register #define int long long #define M 998244353 const int P=3,Pn=332748118; il int read() { int re=0,k=1;char ch=getchar(); while(ch> 9 ||ch< 0 ){if(ch== - )k=-1;ch=getchar();} while(ch<= 9 &&ch>= 0 ){re=re*10+... |
#include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; const double eps = 1e-8; const double pi = acos(-1); int main() { int T; cin >> T; while (T--) { string s; cin >> s; int cnt = 0; bool flag0 = false, flag1 = false, flag2 = false; for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 5; int readint() { int x = 0, f = 1; char s = getchar(); while (s < 0 || s > 9 ) { if (s == - ) f = -1; (s = getchar()); } while (s >= 0 && s <= 9 ) { x = (x << 3) + (x << 1) + (s ^ 48); (s = ge... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.1415926535897932384626433; const long long mod = 1000000007; const int INF = 0x3f3f3f3f; const double eps = 1e-8; template <class T> T gcd(T a, T b) { if (!b) return a; return gcd(b, a % b); } const int maxn = 1e5 + 10; vector... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a[5000] = {0}; cin >> n >> k; for (int i = 1; i <= k; i++) { int la = 0; cin >> la; if (la == 1) { int p, q; cin >> p >> q; a[p] = 1; a[q] = 1; } else if (la == 2) { int p... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2001; const int inf = 1000000000; int d[maxn], a[maxn], n, k; bool check(int x) { int ans = inf; for (int i = 1; i <= n; i++) { d[i] = i - 1; for (int j = 1; j < i; j++) if (abs(a[i] - a[j]) <= (i - j) * 1ll * x) ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int INF = 1e9; const int maxn = 1e6 + 10; const double eps = 1e-8; int add(int x, int y) { x += y; return x >= mod ? x - mod : x; } int sub(int x, int y) { x -= y; return x < 0 ? x + mod : x; } int mul(int... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; int n; int t[maxn], c[maxn]; long long d[maxn][maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> t[i] >> c[i]; for (int i = 0; i < n + 1; i++) d[0][i] = 1ll << 62; d[0][0] = 0; for (int i = 1; i < n + 1; ... |
#include <bits/stdc++.h> using namespace std; int l[500000], r[500000]; long long a[500000]; int L, R; int n, q; int main() { scanf( %d%d , &n, &q); a[0] = 0; for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = n; i >= 1; i--) a[i] = abs(a[i] - a[i - 1]); stack<int> S; fo... |
#include <bits/stdc++.h> using namespace std; multiset<int> val[33]; long long sum[33]; int n = 0; int calc() { long long allsum = 0; int res = 0; for (int i = 0; i < 30; i++) { if (val[i].empty()) continue; if (allsum * 2 < *(val[i].begin())) res++; allsum += sum[i]; } r... |
#include <bits/stdc++.h> using namespace std; namespace IO { const int sz = 1 << 20; char a[sz + 5], b[sz + 5], *p1 = a, *p2 = a, *t = b, p[105]; inline char gc() { return getchar(); if (p1 == p2) p2 = (p1 = a) + fread(a, 1, sz, stdin); return *p1++; } template <class T> inline T read() { ... |
#include <bits/stdc++.h> using namespace std; long long n, a[2000005], num[2000005], ans; long long ksm(long long x, long long y) { long long ans = 1, t = x; while (y) { if (y & 1) ans = ans * t % 1000000007; t = t * t % 1000000007; y >>= 1; } return ans; } int main() { s... |
#include <bits/stdc++.h> using namespace std; const int N = 100010, M = N * 2, mod = 1e9 + 7; const double PI = acos(-1.0), eps = 1e-6; int T, n, m, k, c1, c2; int a[N * 10], b[N], tot, cnt[N], s[N * 10], ans; map<int, int> mp; vector<int> v; string g[N * 10]; signed main() { ios::sync_with_stdio(... |
#include <bits/stdc++.h> inline void cmin(int &a, int b) { if (b < a) a = b; } int a[1000005], f[1 << 21]; int main() { int n, i, now, ans, l, j, k; char s[22]; for (scanf( %d , &n), i = 0; i < n; i++) { scanf( %s , s); for (a[i] = j = 0; s[j]; j++) a[i] = (a[i] << 1) + s[j] - 0 ; ... |
#include <bits/stdc++.h> using namespace std; map<long long, bool> mapa; long long _abs(long long a) { if (a >= 0) return a; else return -a; } int main() { long long b1, q, l, m; cin >> b1 >> q >> l >> m; for (int i = 0; i < m; i++) { long long a; cin >> a; ma... |
#include <bits/stdc++.h> using namespace std; int n, k, p; int tot, head[100010], next1[100010 << 1], to[100010 << 1]; int deep[100010], cnt[100010]; void add(int x, int y) { to[++tot] = y; next1[tot] = head[x]; head[x] = tot; } void dfs(int x, int f) { deep[x] = deep[f] + 1; cnt[deep[... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int k, b, n; cin >> k >> b >> n; map<int, int> freq; freq[0]++; int cont_zeros = 0; int cur_mod = 0; long long total_zeros = 0; long long total_mod = 0; for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int N = 1E5 + 5; long long n, l, r, ql, qr; long long arr[N], pre[N]; int main() { fast(); cin >> n >> l >> r >> ql >> qr; for (int i = 1; i <= n; i+... |
#include <bits/stdc++.h> using namespace std; struct node { bool w, l; int a[26]; node() { w = false; l = false; memset(a, -1, sizeof a); } }; node a[100030]; long long cnt; char second[100010]; void insert(long long n) { int curr = 0; int i = 0; while (curr <... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; struct point { int x, y; } s[N], t[N]; vector<int> q[2]; int cntx, cnty, vis[N], n, now, dis[N], S, ax[N], ay[N]; set<pair<int, int> > a[N]; set<pair<int, int> >::iterator it; int lowbit(int x) { return x & (-x); } void upd(int ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const long long M = 1000000007; const long double PI = acos((long double)-1.0); template <typename T> struct SegmentTree { T data[N << 2]; T calc(const T &x, const T &y) const { return max(x, y); } void push_up(int rt) { data[rt... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 1ll; long long lim = 0, Ans = 0; struct Plan { long long pos; long long c, p; } a[N]; struct Tree { long long c, p; Tree() { c = p = 0; }; } t[N << 2ll]; struct Acht { long long a, b; Acht() { a = b = 0; }; ... |
#include <bits/stdc++.h> using namespace std; struct s { int x; int y; int str; s(int a, int b, int st) { x = a; y = b; str = st; } }; bool func(s x, s y) { return x.str > y.str; } int main() { int n; cin >> n; vector<s> v; for (int i = 2; i <= 2 * n; i++)... |
#include <bits/stdc++.h> using namespace std; template <class T> T read1() { T t = 0; bool vis = 0; char k; do (k = getchar()) == - && (vis = 1); while ( 0 > k || k > 9 ); while ( 0 <= k && k <= 9 ) t = (t << 3) + (t << 1) + (k ^ 0 ), k = getchar(); return vis ? -t : t; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, ans; while (cin >> a >> b) { if (a == 0 && b == 0) cout << NO << endl; else { ans = abs(a - b); if (ans <= 1) cout << YES << endl; else cout << NO << endl; } }... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; } template <typename T1, typename T2> inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } inline int readChar(); template <class T = int> inline T readInt()... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int number_of_ones = 0; string binary_string; cin >> n >> binary_string; for (int i = 0; i < n; i++) { if (binary_string[i] == 1 ) number_of_ones++; if (binary_string[i] == 0 ) { cout << number_of_ones; ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18 + 1e17; const long long mod = 1e9 + 7; long long modInverse(long long a, long long m) { long long m0 = m; long long y = 0, x = 1; if (m == 1) return 0; while (a > 1) { long long q = a / m; long long t = m; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000; double ans, T, sumb, sumc; int n, nb, nc; struct node { double x, y; bool operator<(const node &a) const { return y < a.y; } } a[N], b[N], c[N]; int main() { scanf( %d%lf , &n, &T); for (int i = 1; i <= n; i++) scanf( %lf... |
#include <bits/stdc++.h> using namespace std; int a, b, c, d, e, k[30]; string s; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> a >> s; for (b = 1; b < a; b++) { if (s[b] < s[b - 1]) { cout << YES << endl; cout << b << << b + 1; re... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 3, M = 3e4 + 4, inf = 2e9 + 1; int m, n, s, t, cur, tim, mn; int low[N], dfn[N], vis[N], cst[M]; vector<pair<int, int> > vt[N]; vector<int> pat, rut, ans; bool dfs(int u) { vis[u] = 1; if (u == t) return 1; for (int i = 0; i < v... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, l, c, d, p, nl, nd, np, min = 0, totl, totp, res; cin >> n >> k >> l >> c >> d >> p >> nl >> np; nd = d * c; totl = (k * l) / nl; totp = p / np; if (totl <= nd && totl <= totp) min = totl; else if (nd <= totl && n... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << x; } void __print(const char *x) { cerr << x; } void __pri... |
#include <bits/stdc++.h> using namespace std; vector<int> a; int64_t func(int64_t c) { int64_t cost = 0, pc = 1; for (int ai : a) { long long diff = ai - pc; cost += abs(diff); if (pc > LLONG_MAX / c) return LLONG_MAX; pc *= c; } return cost; } int main(void) { int ... |
#include <iostream> using namespace std; const int N = 210; int a[N]; int main() { int t,i,j,k,n,s1=0,s0=0; cin >> t; while(t--) { cin>>n; s1=0;s0=0; for(i=0;i<2*n;i++) cin>>a[i]; for(i=0;i<2*n;i++) { if(a[i]%2==1)s1++; ... |
#include <bits/stdc++.h> using namespace std; const long long mxn = 1e5 + 7; int main() { int n, a[mxn], q, l[mxn], r[mxn], x; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { if (i == 1) { l[i] = 1; r[i] = a[i]; } else { ... |
#include <bits/stdc++.h> using namespace std; int xs[2123], ys[2123], bs[2123]; long long fat[2123], prefix[2123][2123]; long long fatinv[2123]; long long sum(int row1, int row2, int col1, int col2) { if (row1 > row2 || col1 > col2) return 0ll; row2 = min(row2, 2000); col2 = min(col2, 2000); -... |
#include <bits/stdc++.h> using namespace std; int a[10], flag[200]; int main() { int sum = 0; for (int i = 1; i <= 5; i++) { cin >> a[i]; sum += a[i]; flag[a[i]]++; } int ans = sum; for (int i = 1; i <= 5; i++) { if (flag[a[i]] > 1 && flag[a[i]] < 4) ans = min(a... |
#include <bits/stdc++.h> using namespace std; namespace p316GGoodSubstrings { template <size_t MAXLEN, size_t ALPHABET> struct SuffixAutomaton { struct Node { Node *child[ALPHABET], *suff, *next; int len, cnt; }; Node pool[2 * MAXLEN], *root, *nextnode, *last, *first[MAXLEN + 1]; Nod... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int mod = 1e9 + 7; const double PI = acos(-1.0); const double eps = 1e-10; const int N = 3e5 + 5; int n, m, d[N]; vector<pair<int, int> > g[N]; vector<int> vec; bool vis[N]; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; char ch = getchar(); int fh = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) fh = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getcha... |
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T x) { return x * x; } long double pi = 3.1415926535897932384626433832795; const int N = 5e5 + 10, lg = 20; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { long long a, b, c; cin >> a >> b >> c; i... |
#include <bits/stdc++.h> using namespace std; int n, m; int check(vector<long long> &a, long long q) { multiset<long long> s; for (int j = 0; j < n; ++j) { if (q + a[j] >= 0) { q += a[j]; s.insert(a[j]); } else if (a[j] > (*s.begin())) { q += (a[j] - (*s.begin())); ... |
#include <bits/stdc++.h> using namespace std; bool life[1000005]; int main() { long long a, b; int l, r, mid; int ans, cnt = 0; scanf( %lld%lld , &a, &b); l = 0; r = 1000000007; while (l != r) { mid = (r + l + 1) / 2; if (((mid + 1LL) * mid) / 2 > a + b) r = mid - 1... |
#include <bits/stdc++.h> using namespace std; long long int addingval[100]; long long int lastOcc[100]; long long int wt[100]; long long int cum[100005]; map<long long int, long long int> mp[100]; int main() { for (int i = 0; i < 26; ++i) cin >> wt[i]; string s; cin >> s; int sz = s.size()... |
#include <bits/stdc++.h> using namespace std; int a[26][26]; int main() { int n; cin >> n; memset(a, 0, sizeof(a)); char ch[20]; int len; for (int i = 1; i <= n; i++) { scanf( %s , ch); for (len = 0; ch[len]; len++) ; for (int j = 0; j < 26; j++) if (a[j]... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1 << 20; int bio[MAX]; vector<int> V[MAX]; int a[MAX], b[MAX]; int deg[MAX]; void dfs(int x) { if (bio[x]++) return; for (auto it : V[x]) dfs(it); } int main() { int n, m; scanf( %d%d , &n, &m); int usebe = 0; for (i... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5; int n, m; int fir[N + 10][2], nex[N + 10][2], tot[2], en[N + 10][2]; int tag[N + 10][2], vis[N + 10]; void addEdge(int x, int y, int p) { tot[p]++; nex[tot[p]][p] = fir[x][p]; fir[x][p] = tot[p]; en[tot[p]][p] = y; } void d... |
#include <bits/stdc++.h> using namespace std; long long n, arr[100001]; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } cin >> s; bool gotwater = false; long long curt = 0, energy = 0, totwalk ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000000 + 7; int main() { long long a, b; cin >> a >> b; long long ans = 0; for (long long r = 1; r < b; ++r) { long long tmp = (a * (a + 1) / 2) % mod; tmp = (tmp * r) % mod; tmp = (tmp * b) % mod; tmp = (tmp... |
#include <bits/stdc++.h> using namespace std; long long a[101010]; long long l, r, pref[101010]; long long ans, cnt, sum, max1, min1, ali; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; string s; cin >> n; while (n--) { cin >> l >> r; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; const int mod = 998244353; const int maxn = 2e5 + 10; struct edge { int st, ed; int w; bool operator<(const edge &b) const { return w < b.w; } edge() {} edge(... |
#include <bits/stdc++.h> using namespace std; long long int check(long long int a) { if (a >= 1000000000 + 7) a %= 1000000000 + 7; return a; } long long int check2(long long int a) { if (a > 0) return a; long long int b = a / 1000000000 + 7; a -= b * 1000000000 + 7; if (a < 0) a += 10000... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:33554432 ) using namespace std; const double PI = 2 * acos(0.0); const double EPS = 1e-8; const int INF = (1 << 30) - 1; int n; string s; vector<int> p; set<int> ans; void add01(char c1, char c2, int a, int b) { for (int i = 0; i < a; ++i)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2 * 100000 + 10; int _min(int a, int b) { if (a < b) return a; else return b; } int _max(int a, int b) { if (a > b) return a; else return b; } char s[1005]; int col[4] = {0}; int row[4] = {0}; int ... |
#include <bits/stdc++.h> using namespace std; int n, v, t, p, cnt1, cnt2, x; vector<pair<int, int>> k, c; vector<int> ans; void add(bool sm) { v--; if (sm) { x += k[cnt1].first; ans.push_back(k[cnt1++].second); } else { x += c[cnt2].first; ans.push_back(c[cnt2++].second); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); map<long long int, long long int> mpp; long long int n; cin >> n; for (long long int i = 0; i < n; i++) { long long int x; cin >> x; mpp[__builtin_popcount(x)]++; ... |
#include <bits/stdc++.h> using namespace std; int N, T, K; int a[200333]; int lo[200333], hi[200333]; int mid[200333]; int main() { scanf( %d%d%d , &N, &T, &K); for (int i = 1; i <= T; i++) scanf( %d , &a[i]); K = N - K - 1; for (int t = 1; t < T; t++) hi[t] = min(a[t], a[t + 1]); for (i... |
#include <bits/stdc++.h> using namespace std; const int M = 1005; int parent[2 * M]; vector<pair<pair<int, int>, pair<int, int> > > edges; void init() { for (int i = 0; i < 2 * M; i++) parent[i] = i; } int find(int u) { if (u == parent[u]) return u; return parent[u] = find(parent[u]); } vo... |
#include <bits/stdc++.h> using namespace std; int n; long long qp(long long x, long long y) { long long r = 1; for (; y; y >>= 1, x = x * x % 1000000007ll) if (y & 1) r = r * x % 1000000007ll; return r; } long long c[1000010]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i... |
#include <bits/stdc++.h> using namespace std; const double inf = 1e13; const double eps = 1e-9; int Sgn(double k) { return fabs(k) < eps ? 0 : (k < 0 ? -1 : 1); } int Cmp(double k1, double k2) { return Sgn(k1 - k2); } struct Point { double x, y; }; Point operator-(Point k1, Point k2) { return (P... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; long long Pot(long long a, long long b) { if (b == 0) return 1; if (b % 2 == 0) { long long x = Pot(a, b / 2); return x * x % MOD; } else return Pot(a, b - 1) * a % MOD; } long long Inv(long long x) {... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j; int main() { ios::sync_with_stdio(false); cin >> n; cout << 3 * n / 2 << n ; for (i = 2; i <= n; i += 2) cout << i << ; for (i = 1; i <= n; i += 2) cout << i << ; for (i = 2; i <= n; i += 2) cout << i << ; return ... |
#include <bits/stdc++.h> using namespace std; int gi() { char cc = getchar(); int cn = 0, flus = 1; while (cc < 0 || cc > 9 ) { if (cc == - ) flus = -flus; cc = getchar(); } while (cc >= 0 && cc <= 9 ) cn = cn * 10 + cc - 0 , cc = getchar(); return cn * flus; } const ... |
#include <bits/stdc++.h> using namespace std; static char a[55][55]; bool vis[55][55]; bool dfs(int i, int j, int px, int py, int n, int m) { bool flag = false; if (i > n || j > m) return false; if (i == 0 || j == 0) return false; vis[i][j] = 1; int xi[] = {1, 0, -1, 0}; int yi[] = {0, -... |
#include <bits/stdc++.h> using namespace std; template <typename T> string tos(T a) { stringstream ss; string ret; ss << a; ss >> ret; return ret; } int n, a; vector<int> arr; int main() { while (cin >> n) { arr.clear(); for (int(i) = (0); (i) < (n); (i)++) { ci... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 105000; int n, m; int tin[MAXN], tout[MAXN]; vector<int> g[MAXN]; vector<int> gr[MAXN]; vector<int> gg[MAXN]; vector<int> vv; bool used[MAXN]; int sz[MAXN]; int cursize; int p[MAXN]; bool has[MAXN]; int ans; void dfs(int v) { ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long n = s.size() / 2 + s.size() % 2; long long x = n; cout << s[x - 1]; for (long long t = 1; t <= 100; t++) { if (x + t - 1 < s.size()) cout << s[x + t - 1]; if (x - t - 1 >= 0) cout << s[x - t ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimization( unroll-loops ) using namespace std; template <typename T> ostream& operator<<(ostream& out, vector<T>& a) { for (auto& p : a) out << p << ; return out; } template <typename T> istream& operator>>(istream& inp, ve... |
#include <bits/stdc++.h> using namespace std; namespace math { template <typename T> T gcd(T a, T b) { if (a < 0) a = -a; if (b < 0) b = -b; while (b > 0) { T r = a % b; a = b; b = r; } return a; } } // namespace math template <typename C> int SZ(const C& c) { ... |
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } template <class T> inline T sqr(T x) { return... |
#include <bits/stdc++.h> int main() { long long l3, l4, l5; std::cin >> l3 >> l4 >> l5; long double pi = 3.141592653589793238462643383279; long double v3 = 1.0 / 3.0 * l3 * l3 * sqrtl(3.0) / 4.0 * l3 * sqrtl(2.0 / 3); long double v4 = 1.0 / 3.0 * l4 * l4 * l4 * sqrtl(2) / 2; long double v5 = 1... |
#include <bits/stdc++.h> using namespace std; long long p2(long long x) { return x * x; } int main() { long long n; cin >> n; if (n <= 2) cout << -1 << endl; else if (!(n % 2)) cout << (n * n) / 4 - 1 << << (n * n) / 4ll + 1ll << endl; else cout << (n * n - 1) / 2ll << ... |
///Bismillahir Rahmanir Rahim #include<bits/stdc++.h> #define u64 uint64_t #define ll long long #define endl n #define PI acos(-1) #define fi first #define si second #define mkp... |
#include <bits/stdc++.h> using namespace std; long long pwr(long long a, long long b, long long mod) { a %= mod; if (a < 0) a += mod; long long ans = 1; while (b) { if (b & 1) ans = (ans * a) % mod; a = (a * a) % mod; b /= 2; } return ans; } long long pwr(long long a, l... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll P = 998244353; constexpr ll modPow(ll a, ll b, ll c) { if ((b & 1) == 1) return a * modPow(a, b - 1, c) % c; if (b == 0) return 1 % c; return modPow(a * a % c, b / 2, c); } void bitReverse(vector<int>& vec) { int n ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long qpow(long long x, long long k) { return k == 0 ? 1 : 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod; } const int md = 1e9 + 7; const int Maxn = 5005; int n, k; long long dp[Maxn][Maxn]; ... |
#include <bits/stdc++.h> using namespace std; int mat[101][101]; int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int main() { int n, m; int i, j; string s; cin >> n >> m; for (i = 0; i < n; ++i) { cin >> s; for (j = 0; j < m; ++j)... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; const int MOD = 998244353; int fact[N], factinv[N]; int lgcput(int b, int p) { int a = 1; while (p) { if (p & 1) { a = (1LL * a * b) % MOD; } b = (1LL * b * b) % MOD; p /= 2; } return a; } i... |
#include <bits/stdc++.h> using namespace std; const int nMax = 200003; int smen[nMax]; int main() { cin.sync_with_stdio(false); cin.tie(NULL); int n, k, q, st, dr; cin >> n >> k >> q; int m = nMax - 3; for (int i = 1; i <= n; i++) { cin >> st >> dr; smen[st]++; smen[dr ... |
#include <bits/stdc++.h> using namespace std; map<long long, long long> dp; long long fastPow(long long a, long long b) { long long ret = 1; while (b) { if (b & 1) ret = (ret * a) % 1000000007; a = (a * a) % 1000000007; b >>= 1; } return ret; } long long cc(long long y) { ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int cases; scanf( %d , &cases); while (cases--) { int n, p; scanf( %d%d , &n, &p); for (int i = 2; i <= n; i++) { printf( %d %d n , 1, i); } for (int i = 2; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int p[31111], dp[31111][800]; int main() { int i, j, n, d, u; scanf( %d%d , &n, &d); for (i = 0; i < n; i++) { scanf( %d , &u); p[u]++; } for (i = 0; i <= 30000; i++) { for (j = 0; j <= 650; j++) { dp[i][j] = -10000000; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int dx[]{-1, 0, 0, 1}; int dy[]{-1, -1, 1, 1}; void solve() { string str; cin >> str; cout << str; reverse(str.begin(), str.end()); cout << str << ... |
#include <bits/stdc++.h> using namespace std; namespace FastIO { const int L = (1 << 20); char buf[L], *S, *T; inline char getchar() { if (S == T) { T = (S = buf) + fread(buf, 1, L, stdin); if (S == T) return EOF; } return *S++; } inline int read() { int s = 0, f = 1; char ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.