func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int diri[4] = {-1, 0, 1, 0}; const int dirj[4] = {0, 1, 0, -1}; int A, B; int va[110000], vb[110000]; bool esquerra(int a, int b) { if (b < 0) return false; if (a == 0) return true; return va[a - 1] < vb[b]; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int biceps = 0, back = 0, chest = 0; for (int i = 0; i < n; i++) { int a; cin >> a; if (i % 3 == 0) chest += a; if (i % 3 == 1) biceps += a; if (i % 3 == 2) back += a; } if (chest > back... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { cin >> n; int a[n], flag = 0, x; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { if (a[i] % 2 == 0) { x = i + 1; flag = 1; bre... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 10; int cnt[MAX]; vector<int> up, down; int main() { ios::sync_with_stdio(false); memset(cnt, 0, sizeof(cnt)); int n, x, max_num = -1; cin >> n; for (int i = 0; i < n; i++) { cin >> x; cnt[x]++; max_num =... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 101000; int N; bool getv(int n) { int a, b; printf( ? %d n , 1 + n); fflush(stdout); scanf( %d , &a); printf( ? %d n , 1 + n + (N / 2)); fflush(stdout); scanf( %d , &b); if (a == b) { printf( ! %d n , 1 + n); ... |
#include <bits/stdc++.h> using namespace std; long long n, len, i, j, a[300009]; int main() { while (scanf( %I64d , &n) == 1) { for (i = 0; i < n; i++) { scanf( %I64d , &a[i]); } sort(a, a + n); if (n % 2 != 0) { printf( %I64d n , a[n / 2]); } else { print... |
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979323846; const double eps = (1e-10); int isGreater(long double x, long double y) { if (abs(x - y) < eps) return 0; if (x > y) return 1; return -1; } const int MOD = 998244353; int mult(int x, int y) { return (1LL * ... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long>> calced; long long x_m(long long m, long long mod) { for (pair<long long, long long> a : calced) { if (a.first == m) return a.second; } if (m == 1) return 1 % mod; if (m == 2) return 3 % mod; for (long long i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; int i, k, cnt = 0; for (i = 0; i < s.length(); i++) if (s[i] != 0 ) break; k = i; for (i; i < s.length(); i++) if (s[i] == 0 ) cnt++; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); ; long long t; cin >> t; while (t--) { long long n, x, m; cin >> n >> x >> m; long long c, d; long long l = x, r = x; while (m--) { cin >> c >> d; ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 27; long long n, a[inf], b[inf], c[inf], ans = -1e9; vector<long long> res; map<pair<long long, long long>, pair<long long, vector<long long> > > mp; vector<long long> mask; void btadd(long long pos, long long sum1, long long sum2, long l... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int sl = s.length(); pair<int, int> a[26] = {}; for (int i = 0; i < 26; i++) a[i].second = i + a ; for (int i = 0; i < sl; i++) a[s[i] - a ].first++; sort(a, a + 26, greater<pair<int, int> >()); string a... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; constexpr ll MAXN = 100000 + 5; int n, m; ll bot, inc, dam; ll maxh[MAXN]; ll starth[MAXN]; ll regen[MAXN]; vector<pair<ll, ll>> up[MAXN]; unordered_map<ll, ll> mt; unordered_set<ll> tpoints; vo... |
#include <bits/stdc++.h> using namespace std; const int N = 2000005; const int P = 998244353; long long n; long long f[N], g[N]; long long a[N]; long long inv_9, inv_6, inv_1; long long ans; long long exp_3[N]; long long fac[N], c_n[N]; inline long long ksm(long long base, long long x) { long ... |
#include <bits/stdc++.h> using namespace std; int n, u, d, l, r, i, h[10005]; string a; int main() { cin >> n >> a; for (i = 0; i < n; i++) { if (a[i] == 0 ) d = r = l = 1; if (a[i] == 1 || a[i] == 2 || a[i] == 3 ) u = 1; if (a[i] == 1 || a[i] == 4 || a[i] == 7 ) l = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int k; int arr[N]; vector<int> v[N]; vector<int> gap[N]; int solve(int l, int r, int c) { int m = (l + r) >> 1; if (l == r) return v[c][l]; if (l >= r) return 0; if (r == l + 1) { if (gap[c][l] <= k) return v... |
#include <bits/stdc++.h> using namespace std; int main() { long int n, k, t; cin >> n >> k >> t; if (t < k) cout << t << endl; else if (t > n) cout << k - (t - n) << endl; else cout << k << endl; } |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e17; struct edge { int u, v; edge() {} edge(int _u, int _v) : u(_u), v(_v) {} }; struct node { vector<edge> edges; }; struct tree { vector<node> nodes; int root, n; tree(int _n, int _r = 0) : n(_n), root(_r) {... |
#include <bits/stdc++.h> using namespace std; const int N = 3e4 + 100, M = 210; int gi() { int w = 0; bool q = 1; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) q = 0, c = getchar(); while (c >= 0 && c <= 9 ) w = w * 10 + c - 0 , c = getchar()... |
#include <bits/stdc++.h> using namespace std; int a[1001]; int main() { int n; scanf( %d , &n); int m = n; int pos = 0; int k = 1; while (true) { if (a[pos] == 0) m--; if (m == 0) { printf( YES n ); return 0; } a[pos] = 1; if (pos == (pos + k) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) cout << 1 << << 1 << n << 1; else cout << 2 * (n - 1) << << 2 << n << 1 << << 2; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long maxn = 200010; const long long MOD = 1e9 + 7; const long long INF = 1e9; const long long LINF = 1e18; long long n, m, a[maxn], b[maxn]; map<long long, long long> M, N; string s, ss; set<long long> S; long long l, r, h; int32_t main() { ... |
#include <bits/stdc++.h> using namespace std; char buffer[1000005]; char str[1000005]; vector<vector<int>> loop; int n; int op(int k, int d) { int t = -1; strcpy(buffer, str); loop.clear(); vector<int> nxt(k); vector<int> pre(k + 1); vector<int> vis(k + 1); vector<int> lpi(k + 1)... |
#include <bits/stdc++.h> using namespace std; long long n, T, a, b, c; int x[4], y[4]; long long cost[4]; string ans; long long f(long long x, long long y) { return (x + y) * (abs(y - x) + 1) / 2; } long long Cal(int X, int Y, int x, int y) { if (X <= x && Y <= y) return f(0, x + y - X - Y) + f(0, n +... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int s, f, t; for (int i = 0; i < n; i++) { cin >> s >> f >> t; int flag = t / (m - 1); int yushu = t % (m - 1); int floor; if (flag & 1) { floor = m - yushu; } else ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 25; long long a[MAX]; int main() { ios_base::sync_with_stdio(false); long long n, k, h; cin >> n >> h >> k; for (int i = 0; i < n; i++) cin >> a[i]; long long ans = 0; long long in = a[0]; for (int i = 1; i < n; i++)... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); long long n; cin >> n; vector<int> v(n); for (int i = (0); i < (n); ++i) cin >> v[i]; sort(v.begin(), v.end()); vector<int> res = {v[0]}; for (int i = (0); i < (n); ++i) ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 0; const int MOD = 1000000007; template <class T> inline void CLR(T &g) { T t; swap(t, g); } template <class T> inline void CLR(T &g, int a) { memset(g, a, sizeof g); } template <class T> inline void CPY(T &a, T &b) { m... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 5; const int MAXQ = 5e5 + 5; const int MAXP = 8e6 + 5; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x... |
#include <bits/stdc++.h> using namespace std; int a[100000], d[100000]; int main() { int n, ans = 0; cin >> n; for (int i = 0; i < n; i++) scanf( %d , &a[i]); vector<int> p; for (int i = 0; i < n; i++) { if (a[i] == 1) ans = max(ans, 1); p.clear(); int x = a[i]; int k =... |
#include <bits/stdc++.h> using namespace std; const int M = 1010, mod = 1000000007; vector<vector<int> > lst[M]; vector<vector<int> > flag[M]; vector<int> sz[M]; vector<int> tmp, bmp; vector<pair<int, int> > edge; int id[M][M]; int pos[M][M]; int visited[M]; string s, t; void make_list(int u, st... |
#include <bits/stdc++.h> using namespace std; inline void checkMAX(int& a, int b) { if (a < b) a = b; } inline void checkMIN(int& a, int b) { if (a > b) a = b; } int main() { char s[333] = {}; cin >> s; int mn = 0, mx = 0, curr = 0; for (int i = 0; s[i]; i++) { if (s[i] == + )... |
#include <bits/stdc++.h> using namespace std; int main() { char str[25]; gets(str); int let[26]; for (int i = 0; i < 26; i++) { let[i] = 0; } int len = 0; for (int i = 0; str[i]; i++) { let[str[i] - a ]++; len++; } long long c = 0; for (int i = 0; i < 26; i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0; cin >> n; for (int i = 1; i <= n; i++) { int ans = (i * (i + 1)) / 2; if (ans == n) { cnt = 1; break; } } if (cnt == 1) cout << YES << endl; else cout << NO << endl; ... |
#include <bits/stdc++.h> #define For(i, a, b) for(int i = a; i <= b; i++) #define Ford(i, a, b) for(int i = a; i >= b; i--) #define make_pair(a,b) mp(a, b) using namespace std; const int N= 2e5 + 1067, K = 17, md=1e9 + 7; int n, k; int f[N][30], g[1 << K], dem[30]; string s; bool check(int x) {... |
#include <bits/stdc++.h> using namespace std; int n, a[150005]; vector<int> v; set<pair<int, int> > ans; int compute() { int problem = 0; for (int i = 1; i <= n; i = i + 2) { if (a[i] >= a[i + 1]) { problem++; } } for (int i = 2; i <= n; i = i + 2) { if (a[i] <= a[i +... |
#include <bits/stdc++.h> using namespace std; bool comp(pair<int, int> a, pair<int, int> b) { if (a.second < b.second) return true; return false; } bool com(pair<int, int> a, pair<int, int> b) { return a.first > b.first; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); co... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; long long n, ans, f[N], now, sum; char s[N]; signed main() { scanf( %lld , &n); scanf( %s , s + 1); for (long long i = 1; i <= n; i++) f[i] = n + 1; for (long long i = n; i >= 1; i--) { if (s[i] - 0 ) sum += f... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int t; struct node { char id; int num; } ans[N]; string a; int cot; int main() { cin >> a; if (a.length() == 1) { cout << 0 << endl; return 0; } cot = 1; ans[cot].id = a[0]; ans[cot].num = 1;... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long dx[] = {-1, 0, 1, 0}; long long dy[] = {0, -1, 0, 1}; vector<long long> v(10); string s; set<string> st; void call(string s, long long pos) { if (pos == 10) { sort(s.begin(), s.end()); st.insert(s); ... |
#include <bits/stdc++.h> int n; int a[1001000]; int b[1001000]; int c[1001000]; int ans; int main() { int i, j; scanf( %d , &n); n++; for (i = 2; i <= n; i++) { scanf( %d , &a[i]); b[i] = 1; c[i] = 0; j = i; if (ans < b[j]) ans = b[j]; while (a[j] != 1) { ... |
#include <bits/stdc++.h> using namespace std; bool sortbysec(pair<int, string> a, pair<int, string> b) { if (a.first != b.first) return a.first > b.first; else return a.second < b.second; } int binarySearch(vector<int> a, int n, int key) { int low = 0; int high = n, mid; while (l... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a; cin >> n >> a; if (a % 2 != 0) { cout << (((a - 1) / 2) + 1) << n ; } else { cout << ((n / 2) - ((a - 2) / 2)) << n ; } } |
#include <bits/stdc++.h> using namespace std; long long n, m, x, _, a, d, t[100001], ans; long long rua(long long l, long long r) { if (r < l) return _; if (_ >= n * a) { ans++; return r + d; } if (l % a && l / a == r / a) { ans++; return r + d; } long long f = min(... |
#include <bits/stdc++.h> using namespace std; int n, m, a[100001], q, sum; int b[1000001]; int main() { int n, m, q, sum = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; b[a[i] + sum] = i; b[1 + sum] = i; sum += a[i]; } cin >> m; for (int j = 1; j <= m; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long long int sum = 0; cin >> n; int a, b; int max = INT_MIN; for (int i = 0; i < n; i++) { cin >> a >> b; sum = sum - a + b; if (max < sum) max = sum; } cout << max; return 0; } |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) const int mod = 1e9 + 7; using namespace std; template <class T> void cinn(T& x) { cin >> x; } template <class H, class... T> void cinn(H& h, T&... t) { cinn(h);... |
#include <bits/stdc++.h> using namespace std; int const N = 1e5 + 13; int const INF = 1e9 + 13; int n, m; set<int> p[N]; int l[N], r[N]; int pos[N], x[N]; int tsz; int a[N]; int type[N]; vector<int> t[N * 4], tright[N * 4]; vector<long long> F[N * 4]; vector<int> qid; vector<pair<int, int>> ... |
#include <bits/stdc++.h> using namespace std; long long bigmod(long long p, long long e, long long M) { long long ret = 1; for (; e > 0; e >>= 1) { if (e & 1) ret = (ret * p) % M; p = (p * p) % M; } return ret; } long long extended(long long a, long long b, long long &x, long long &y... |
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int result; result = 26 + 25 * a.length(); cout << result; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, pos[200001]; struct node { node *l, *r; long long int lazy, lazy2; }; node *root[200001]; int build(int s, int e, node *n) { if (s == e) { n->l = n->r = NULL; n->lazy = -1, n->lazy2 = 1; return 0; } int mid = (s + e) ... |
#include <bits/stdc++.h> using namespace std; class node { public: int lo, hi, value; node *left, *right; node(const int _lo, const int _hi) { left = right = NULL; lo = _lo, hi = _hi, value = 0; } void build() { if (lo == hi) return; const int mid = (lo + hi) >> 1; ... |
#include <bits/stdc++.h> using namespace std; int tree[(1 << 20)]; void add(int x, int val) { for (int i = x; i < (1 << 20); i = ((i) | (i + 1))) tree[i] += val; } int sum(int x) { int ans = 0; for (int i = x; i > 0; i = ((i) & (i - 1))) ans += tree[i - 1]; return ans; } int N, Q; map<in... |
#include <bits/stdc++.h> int main() { int x; int n, m; scanf( %d %d , &n, &m); if (m == 3 && n > 4) { printf( -1 n ); return 0; } for (x = 0; x < m; ++x) printf( %d %d n , x, x * x + 10001); for (x = 0; x < n - m; ++x) printf( %d %d n , x, -x * x); return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, tp; int a[2000002]; int main() { scanf( %d , &tp); int p = 1, i, j; for (i = 0; i <= 100; i++) { n++; if (p == tp) break; p *= 4; } for (i = 0; i < tp; i++) scanf( %d , &a[i]); sort(a, a + tp); long long ans = ... |
#include <bits/stdc++.h> using namespace std; int mod = 1000000007; const int inf = 1034567891; const long long LL_INF = 1234567890123456789ll; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << : << arg1 << n ; } template <typename Arg1, typename... Args> voi... |
#include <bits/stdc++.h> using namespace std; long long res = 1; int main() { int n; cin >> n; for (int i = 1; i < n; ++i) { res += i * 12; } cout << res; return 0; } |
#include <bits/stdc++.h> using namespace std; const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 7; const double pi = acos(-1), EPS = 1e-8; int n; string str; map<deque<char>, deque<char>> mp; bool is(deque<char> ck, string s) { if (ck.size() != s.size()) return 0; for (int i = 0; i < s.size(); +... |
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << t ; return *this; } } dbg; template <class A, class B> ostream& operator<<(ostream& o, const pair<A, B>& p) { return o << ( << p.first << , <<... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops ) #pragma loop - opt(on) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native ) using namespace std; const long long mxN = 1e5 + 5; long long n, m, Q; bitset<mxN> vis, in, incy; long long dsu[mxN], lca[mxN], eu[mxN], ev[m... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, c = 0; cin >> n; for (long long i = 1; i < n; ++i) { if (n % i == 0) c++; } cout << c << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; char in[100000 + 1]; int main() { vector<array<int, 4> > cur, nex; cur.push_back(array<int, 4>{{}}); int n; scanf( %d , &n); scanf( %s , in); for (int i = 0; i < n; i++) { int p = -1; switch (in[i]) { case G : p =... |
#include <bits/stdc++.h> using namespace std; long long cross(pair<long long, long long> a, pair<long long, long long> b, pair<long long, long long> c) { pair<long long, long long> v1 = make_pair(b.first - a.first, b.second - a.second); pair<long long, long long> v2 = make_... |
#include <bits/stdc++.h> using namespace std; bool func(deque<int>& v) { int x = v.back(); if (x > 1) { v.pop_back(); int y = x / 2; int y2 = x - y; if (y == 1) v.push_front(y); else v.push_back(y); if (y2 == 1) v.push_front(y2); else ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; int cnt = 0; vector<int> v; char last = * ; for (int i = 0, to = n; i < to; i++) { if (last != s[i]) { if (cnt > 0) v.push_back(cnt); cnt = 1; last = s[i];... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k = 0; cin >> n; int arr[n + 2]; arr[0] = arr[n + 1] = 0; for (int i = 1; i <= n; i++) cin >> arr[i]; for (int i = 1; i <= n; i++) if (arr[i - 1] == 1 && arr[i + 1] == 1 && arr[i] == 0) arr[i + 1] = 0, k++; cout << k... |
#include <bits/stdc++.h> using namespace std; inline long long int read() { char C = getchar(); long long int N = 0, F = 1; while (( 0 > C || C > 9 ) && (C != - )) C = getchar(); if (C == - ) F = -1, C = getchar(); while ( 0 <= C && C <= 9 ) N = (N << 1) + (N << 3) + (C - 48), C = ge... |
#include <bits/stdc++.h> const int N = 1e5 + 3; struct edge { int v, nxt; } g[N + N]; int n, head[N], k; double ans; inline void Insert(int u, int v) { g[++k] = (edge){v, head[u]}; head[u] = k; } void Dfs(int u, int dep, int fa) { int v; ans += 1.0 / dep; for (int i = head[u]; i;... |
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; int n; string rakh1, rakh2, rakh, ch, ch_min; while (test--) { cin >> n; cin >> ch; ch_min = ch; int pos = 1; for (int i = 1; i < (n - 1); i++) { rakh1 = ch.substr(0, i); ... |
#include <bits/stdc++.h> using namespace std; int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; } int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; } void solve() { long long int x, y, z; cin >> x >> y >> z; long long int x1, y1, z1; cin >> x1 >> y... |
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const long long INFL = LLONG_MAX; int N, M, ans[200100], n, m; int main() { cin >> N >> M; n = m = 0; ans[0] = 0; n++; for (int(i) = 1; (i) <= (N + M - 1); (i)++) { if (i & 1) { if (ans[i - 1]) { ... |
#include <bits/stdc++.h> using namespace std; long long n, mod; pair<long long, long long> a[200100]; long long d[200100]; long long first(int t, int k) { long long res = 1; for (int i = 1; i <= k; i++) d[i] = i; for (int j = 2; t;) if (d[j] % 2) j += 2; else while (d[j... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; long long n, k, z, a[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { cin >> n >> k >> z; long long sum = 0; for (long long i = 1; i... |
#include <bits/stdc++.h> using namespace std; int n, m; char a[60][60]; bool isRowChecked[60]; bool isColChecked[60]; bool doCheck(int r, int c) { bool isRowRegard[60]; bool isColRegard[60]; memset(isRowRegard, false, sizeof(isRowRegard)); memset(isColRegard, false, sizeof(isColRegard)); ... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long md = 1000000007) { long long res = 1; x %= md; while (y > 0) { if (y & 1) res = (res * x) % md; x = (x * x) % md; y = y >> 1; } return res % md; } signed main() { long long... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e17; struct Node { int to; long long dis; int type; Node(int a = 0, long long b = 0, int c = 0) { to = a; dis = b; type = c; } friend bool operator<(Node a, Node b) { if (a.dis != b.dis) return a.d... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; int arr[m]; for (int i = 0; i < m; i++) cin >> arr[i]; long long res = arr[0]; for (int i = 1; i < m; i++) { if (arr... |
#include <bits/stdc++.h> using namespace std; long long a1, a2, a3, sum = 0, a12, a23, a31; int main() { cin >> a1 >> a2 >> a3; sum = a1 + a2 + a3; if (sum % 2) { cout << Impossible ; return 0; } sum /= 2; a12 = sum - a3; a23 = sum - a1; a31 = sum - a2; if (a12 < 0... |
#include <bits/stdc++.h> using namespace std; const int N = 400005; char a[N]; int n, k, delta, top, st[N]; bool vis[N]; int main() { scanf( %d%d , &n, &k), scanf( %s , a + 1); delta = (n - k) / 2, top = 0; for (int i = 1; i <= n; ++i) { if (a[i] == ( ) st[++top] = i; else {... |
//AYUSH VERMA //********************************************* ********************************* //***************/A ************************** ****** *********///************* //**************//Y ************************ ******** *******///************** //*************///U *******... |
#include <bits/stdc++.h> using namespace std; int dist[600 + 15][600 + 15]; int start[200 + 15]; int MAX_ = INT_MAX / 2 - 5; vector<pair<int, int> > sas[1000]; int cap[250000 + 15]; int v, e, n, k; int pop_w[1000]; int pop_kr[1000]; int group[1000]; int last_checked[1000]; int dead[1000]; int ... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; const int maxn = 100000 + 10; int go[maxn][26], fail[maxn]; int I[maxn], F[maxn], S[maxn], FIN[maxn]; int total; void push(string &s, int index, int freq) { int u = 0; for (auto c : s) { int x... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e18; const long long mod = 1e9; long long dp[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t = 1; cin >> t; while (t--) { long long n, k; cin >> n >> k; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 3e5 + 10, M = 2097152 + 10; long long n, x, ans, ar[N], mark[M][2]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (long long i = 0; i < n; i++) cin >> ar[i]; mark[0][1]++; for (long long i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int a, b, c, d, e, y = 0, x = 0, l = 0, z = 0, k = 0, m = 0; cin >> a >> b >> c >> d >> e; if (d > e) { while (a > 1 && b > 0) { y++; a = a - 2; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7, N = 1e5 + 10; const ll MX = 1e8; int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; ll ans = 0; for (ll i = 0; i < MX; i += 25) { string k = to_string(i); ... |
#include <bits/stdc++.h> using namespace std; char c1[1005], c2[1005]; long long f[100005][2], ans, k, l; bool pd; int main() { scanf( %s , c1); scanf( %s , c2); scanf( %lld , &k); l = strlen(c1); f[0][0] = 1; for (register long long i = 1; i <= k; i = -~i) { f[i][0] = ((l - 1) *... |
#include <bits/stdc++.h> using namespace std; struct LCA { int logn; vector<int> depth; vector<vector<int> > lca; vector<vector<int> > *edges; LCA(int n, vector<vector<int> > *edges) { logn = log(n) / log(2) + 1; depth.resize(n + 1, 0); lca.resize(n + 1, vector<int>(logn, 0)); ... |
#include <bits/stdc++.h> using namespace std; const int mxn = 257; string rec[mxn][3]; bool been[mxn][3]; inline int G(string s) { int t = 0; for (int i = 0; i < s.size(); ++i) t = t * 2 + s[i] - 0 ; return t; } priority_queue<pair<int, int> > pq; bool changed; string Min(string a, string... |
#include <bits/stdc++.h> using namespace std; const int maxn = 4e6 + 5; const int inf = 0x3f3f3f3f; int main() { int n; scanf( %d , &n); char a; getchar(); int ans = 0; for (int i = 1; i <= n; i++) { scanf( %c , &a); if (a == - ) ans--; else ans++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0; cin >> n; int a[n]; for (int x = 0; x < n; ++x) { cin >> a[x]; s += a[x] * (x + 1); } cout << s << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; char s[200005]; int n, k; int main() { scanf( %d%d , &n, &k); scanf( %s , s); if (n == 1) { if (k == 0) printf( %c n , s[0]); else printf( 0 n ); } else { if (k == 0) printf( %s n , s); else { i... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; const long long LINF = (1LL << 62); const int INF = 1 << 30; const int NS = 100010; const int MS = 19; const int MOD = 1000000007; const double PI = acos(-1.0); int n, m, q, h[NS]; pair<int, int> s[... |
#include <bits/stdc++.h> using namespace std; const int M = 2 * 1e5 + 10; int a[M]; int main() { long long s, n, p1, c, pos1, pos2, p2, i, ans = 1, d, x, j; scanf( %I64d , &n); for (i = 0; i < n; i++) scanf( %I64d , &a[i]); if (a[0] != -1) { p1 = a[0]; pos1 = 0; c = 1; } el... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0) { return b; } else { return gcd(b % a, a); } } int main() { int l_a, r_a, t_a; int l_b, r_b, t_b; int l_x, r_x, t_x; cin >> l_a >> r_a >> t_a; cin >> l_b >> r_b >> t_b; if (r_b - l_b... |
#include <bits/stdc++.h> using namespace std; const long long N = 10000; const long long M = 60; vector<long long> v; long long n, first, t, a[N], second, cn, p; void val(long long first) { long long second, z; second = first; first = upper_bound((v).begin(), (v).end(), first) - v.begin() - 1; ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast,no-stack-protector ) using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << n ; err... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, maxn = 5e5 + 79; void upd(int& a, const int& b) { a = (a + b) % mod; } int mul(const int& a, const int& b) { return (a * 1ll * b) % (long long)mod; } vector<vector<int> > dp(maxn, vector<int>(2, 0)); vector<vector<int> > g(maxn); vec... |
#include <bits/stdc++.h> using namespace std; int sum[1000000 + 10][27]; char c1[1000000 + 10], c2[1000000 + 10]; long long n, m; long long len1, len2; long long gcd(long long a, long long b) { long long t = a; while (b) { a = b; b = t % b; t = a; } return a; } int main... |
#include <bits/stdc++.h> using namespace std; int main() { string x; cin >> x; int c1 = 0, c0 = 0; bool f = 0; for (int i = 0; i < x.size(); i++) { if (x[i] == 0 ) { c0++; } else if (x[i] == 1 ) { c1++; } if (c0 < 7 && x[i] == 1 ) { c0 = 0; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.