func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; using lint = long long; using ld = long double; using pint = pair<int, int>; using plint = pair<lint, lint>; lint _pow(lint a, lint n) { if (n == 0) return 1; else { lint res = 1; lint buf = a; while (n > 0) { if (n % 2 ==... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:104857600 ) using namespace std; const int c = 1000100; int n, m; int a[c]; int ans; int d; void go(int i, int b) { if (a[i]) return; a[i] = 1; int k = (m - 1) << 1; int nb = b; int p = i; while (k) { if (b > 0) ... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000007; long long small(long long a, long long b) { if (a < b) return a; return b; } long long large(long long a, long long b) { if (a > b) return a; return b; } long long root(long long x, vector<long long>& a) { if (a[... |
#include <bits/stdc++.h> using namespace std; int const maxn = 60, maxl = 10010; int f[maxn * maxl]; int n, d, c, sum; int main() { cin >> n >> d; f[0] = 1; for (int i = 0; i < n; i++) { cin >> c; for (int j = sum; j >= 0; j--) if (f[j]) f[j + c] = 1; sum += c; } ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.length(); int row, col; if (n <= 20) { int row = 1; int col = n; cout << row << << col << endl; cout << s; } else if (n >= 21 && n <= 40) { int row = 2; int stars ... |
#include <bits/stdc++.h> using namespace std; int a, b; int noOfDivisors(int n) { int till = sqrt(n); int c = 0; for (int i = 1; i < till + 1; i++) { if ((n % i) == 0) { if (i > b) c++; if ((n / i) > b && (n != i * i)) c++; } } return c; } int main() { scanf... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200; const int maxm = maxn * maxn; const int INF = 0x3f3f3f3f; int n, k, s, ans, res; int a[maxn]; int dp[maxn][maxm]; inline int read() { int x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) ch = getchar(); while (ch... |
#include <bits/stdc++.h> using namespace std; const int INF = (int)2e9; const long long INFL = (long long)9e18; const int MAXINT = ((~0) ^ (1 << 31)); const long long MAXLL = ((~0) ^ ((long long)1 << 63)); template <class T> inline T pow2(T a) { return a * a; } template <class T> inline bool min... |
#include <bits/stdc++.h> using namespace std; const long long mod7 = 998244353; vector<vector<long long> > mul(vector<vector<long long> > &A, vector<vector<long long> > &B, long long mod = mod7) { vector<vector<long long> > res(A.size(), vector... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int a, b, c, d; cin >> a >> b >> c >> d; if (a != c) cout << a << << c << endl; else if (a != d) cout << a << << d << endl; } } |
#include <bits/stdc++.h> using namespace std; void sdvig(char *c, int n) { int i; char s = c[0]; for (i = 0; i < n - 1; i++) { c[i] = c[i + 1]; } c[n - 1] = s; } int main() { int n; scanf( %d n , &n); char c[1010], cc[1010]; cin >> cc; int i, g, f, l = n - 1; in... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; namespace Xrocks {} using namespace Xrocks; namespace Xrocks { class in { } user_input; class out { } output; in& operator>>(in& X, int& Y) { scanf( %d , &Y); return X; } in& operator>>(in& X, char* Y) { sc... |
#include <iostream> using namespace std; int main() { int n, q; cin >> n >> q; char s[n+1]; int x[n+1]; for (int i = 1; i < n+1; i++) { cin >> s[i]; x[i] = x[i-1] + s[i] - ` ; } int l, r; for (int i = 0; i < q; i++) { cin >> l >> r; cou... |
#include <bits/stdc++.h> using namespace std; long long f[61 + 1], g[61 + 1], x, k; int Q, op, pos; int main() { scanf( %d , &Q); f[0] = 1; for (int i = 1; i < 61; i++) f[i] = f[i - 1] * 2; while (Q--) { scanf( %d , &op); if (op == 1) { scanf( %I64d%I64d , &x, &k); fo... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, SQ = 5555; unordered_map<int, int> ed[N]; set<pair<int, int>> edge, bad; int n, m, k, last, par[N]; struct Query { int t, u, v; } qu[SQ]; bool mark[N]; queue<int> q; int gg(int u) { return ~par[u] ? par[u] = gg(par[u]) : u; } ... |
#include <bits/stdc++.h> using namespace std; double a, b, m; double vx, vy, vz; double x0, z0; int main() { scanf( %lf %lf %lf , &a, &b, &m); { scanf( %lf %lf %lf , &vx, &vy, &vz); double t = -(m / vy); double sx = vx * t; double sz = vz * t; int d = (int)(sz / b); ... |
#include <bits/stdc++.h> double arr[1005][4]; int main() { int n, k; scanf( %d%d , &n, &k); int i; long long population = k; double maxRadius = -1, minRadius = 1e6; for (i = 0; i < n; i++) { scanf( %lf%lf%lf , &arr[i][0], &arr[i][1], &arr[i][2]); population += arr[i][2]; ar... |
#include <bits/stdc++.h> const int MOD = int(1e9) + 7; inline int add(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); } inline void inc(int &a, int b) { a = add(a, b); } inline int sub(int a, int b) { return (a - b < 0) ? (a - b + MOD) : (a - b); } inline void dec(int &a, int b) { a = s... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, l, a[1000009], b[1000009], f[1000009], ans, cn, t, x, y, z, mx, mn, s; char c[1000009], d[1000009], ch; map<int, int> mp, mm; int main() { while (scanf( %d %d , &n, &m) != EOF) { ans = 1; mp.clear(); mm.clear(); ... |
#include <bits/stdc++.h> using namespace std; int dr1[] = {1, 1, 0, -1, -1, -1, 0, 1}; int dc1[] = {0, 1, 1, 1, 0, -1, -1, -1}; int dr[] = {1, -1, 0, 0}; int dc[] = {0, 0, 1, -1}; const int fx[] = {+1, -1, +0, +0}; const int fy[] = {+0, +0, +1, -1}; const int fx8[] = {+0, +0, +1, -1, -1, +1, -1, +1}; ... |
#include <bits/stdc++.h> using namespace std; const int OO = (int)2e9 + 5; const int MOD = (int)1e9 + 7; const long double Pi = 3.141592653589793238; const int N = (int)2e5 + 5; long long qqaGJJ[N], ss[2][N], vRI[2][N], n, uVyh = 0; int main() { cin >> n; for (int i = (int)(1); i <= (int)(n); i++)... |
# include <bits/stdc++.h> # define int long long using namespace std; const int N=505; const int mo=998244353; int a[2*N][N],b[N][N]; bool f[2*N]; int Pow(int x,int n) { int ans=1; while (n) { if (n&1) ans=ans*x%mo; x=x*x%mo; n>>=1; } return ans; } ... |
#include <bits/stdc++.h> using namespace std; signed main() { std::vector<std::vector<long long>> f(151, std::vector<long long>(151, 0)); f[0][0] = 1; f[1][0] = 1; f[1][1] = 1; for (long long i = 2; i <= 150; ++i) { for (long long j = 0; j <= i; ++j) { f[i][j] = ((f[i - 2][j]) + ((... |
#include <bits/stdc++.h> using namespace std; int main() { long n, sum = 1e6; cin >> n; long a[n]; for (long i = 0; i < n; cin >> a[i++]) ; long opt; for (long i = 1; i <= 1000; ++i) { long s = 0; for (long j = 0; j < n; ++j) { if (i != a[j]) s += abs(i - a[j]) - 1;... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /stack:247474112 ) #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( unroll-loops ) long long mod = 1e9 + 7; void time() {} ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; char a[maxn], b[maxn]; int pre[maxn], suf[maxn]; int main() { scanf( %s%s , a + 1, b + 1); int n = strlen(a + 1); int m = strlen(b + 1); int pos = 0; for (int i = 1; b[i]; i++, pos++) { while (pos <= n && a[pos] ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { string s; cin >> s; int cnt[26]; fill(cnt, cnt + 26, 0); set<int> st; int u = s.size(); for (int j = 0; j < u; j++) { int y = s[j] - a ; cn... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; constexpr int SQRT = 1000; struct query { int x, y, pos; short sqrt; bool operator<(const query &b) const { if (sqrt == b.sqrt) { return ((sqrt & 1) ^ y < b.y); } return sqrt < b.sqrt; } }; quer... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } const int mod = 1e9 + 7; long long binpow(long long a, long long b) { long long res = 1; while (b > 0) if (b & 1) { ... |
#include <bits/stdc++.h> using namespace std; struct S { int l, r, x; }; vector<S> tree[8000]; int mk[1000100], step, ans; int n; pair<int, int> expand(int v) { int inc = 0; if (v > 1) { while ((1 << inc) < v) ++inc; } int bef = (v - 1) + inc; pair<int, int> at = make_pair(be... |
#include <bits/stdc++.h> using namespace std; const int N = 75010; struct edge { int y, next; } s[N]; struct loop { vector<int> V; int S; } P[N]; struct node { int x, y, d; bool operator<(const node q) const { return x < q.x; } }; vector<node> A; vector<int> F[32768]; int first... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int mas[n]; for (int i = 0; i < n; i++) { cin >> mas[i]; } int d = 0; int t = 0; for (int i = 0; i < n; i++) { if (mas[i] - d == 1) { t++; d = mas[i]; } } if (!d) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s = to_string(n); int m = s.size(); vector<int> v; for (int i = 9 * m; i >= 0; i--) { int j = n - i; int sum = 0; for (sum = 0; j > 0; j /= 10) sum += j % 10; if (sum == i) v.push_back(... |
#include <bits/stdc++.h> using namespace std; int main() { const long long MOD = 1000003; int n; cin >> n; long long g = 1; for (int i = 1; i < n; i++) { g = (g * 3) % MOD; } cout << g; } |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 1303; long long solve() { long long n; string s; cin >> s; map<char, string> mp; mp[ > ] = 1000 ; mp[ < ] = 1001 ; mp[ + ] = 1010 ; mp[ - ] = 1011 ; mp[ . ] = 1100 ; mp[ , ] = 1101 ; mp[ [ ] =... |
#include <bits/stdc++.h> using namespace std; int main() { int n; char s[100005] = {0}; int i, j; int panjang; int banyak[27] = {0}; gets(s); scanf( %d , &n); panjang = strlen(s); if (panjang <= n) { printf( 0 n ); return 0; } for (i = 0; i < panjang; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 1) cout << -1 ; else { for (int i = 1; i <= n / 2; i++) { cout << 2 * i << ; cout << 2 * i - 1 << ; } } return 0; } |
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr int N = 1e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; string x; cin >> x; int H = 0; for (char &c : x) if (c == H ) H++; int result = n; for (int i... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, abc = 864197532, N = 1000001, logN = 17; vector<int> a; vector<int> d, lp; struct Seg { int l, r, m; long long int val = 0; Seg* ch[2]; Seg(int _l, int _r) : l(_l), r(_r), m(l + r >> 1) { if (r - l > 1) { ch[0... |
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T &x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T &x, L y) { return y < x ? (x = y, 1) : 0; } const int maxn = 1e5 + 17, S = 1e9 + 1, maxfen = S * 2; map<int, vector<pair<int... |
#include <bits/stdc++.h> using namespace std; const float pi = acos(-1.0); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; t = 1; while (t--) { long long int n; cin >> n; cout << 0 << << 0 << << n; } } |
#include <bits/stdc++.h> using namespace std; template <class T> T inline sqr(T x) { return x * x; } const int mlen = 303; int p[6]; char s[6][mlen]; char res[mlen][mlen]; vector<vector<string> > x; void draw(int sx, int sy, const char *s, int dx, int dy) { while (*s) res[sy][sx] = *s++, sx ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 75005; const long long maxm = (1 << 15) + 5; long long k, n[16], s[16], a[16][5005], co[maxn], col[maxn], idx, b[maxn], yhp[16], num; long long st[maxn], cnt[16], vis[maxm], lst[maxm], from[maxm], sel[maxn]; long long head[maxn], ecn... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000009; long long poww(long long base, long long power) { long long ret = 1; for (long long i = 0; i < power; i++) { ret *= base; ret %= mod; } return ret; } int main() { long long ans; long long n, m; ... |
#include <bits/stdc++.h> int search(int a[], int j, int n) { int i; for (i = 0; i < n; i++) { if (a[i] == j) { a[i] = 0; return (i + 1); } } return 0; } int main() { int t, n, i, j, k, m, x, y, z; scanf( %d , &n); int a[n]; int f[3] = {0}; for (i = 0... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int dist[200002]; vector<pair<int, int>> v[200002]; vector<int> nes[200002]; char s[200002]; vector<string> ans; void dfs(int d) { if (ans.size() >= k) return; if (d > n) { ans.push_back(s); return; } for (auto i : ne... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { long long int n, m, c = 0; cin >> n >> m; vector<set<long long int>> v(n + 1); long long int x, y; for (int i = 0; i < m; i++) { cin >> x >> y; v[x].insert(y); v[y].inser... |
#include <bits/stdc++.h> using namespace std; long long geti() { long long ret = 0; char ch = getchar(), k = 1; while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) k = 0, ch = getchar(); while (ch >= 0 && ch <= 9 ) ret = ret * 10 + ch - 0 , ch = getchar(); return k... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 5; int b[maxn]; int g[maxn]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , &b[i]); for (int i = 1; i <= m; i++) scanf( %d , &g[i]); long long sum = 0; sort(b + 1, b + n + 1)... |
//Be Name Khoda #include<bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define pp pop_back #define all(x) x.begin(), x.end() const ll mxn = 3e5 + 5; ll t, n = 0, k, q; ll cnt[mxn]; vector<ll> v, v2; void input() { for(int i = 0; i <= n; i... |
#include <bits/stdc++.h> using namespace std; int I, len[500005], las[500005]; string second, ans[500005]; char fi[500005], se[500005]; string get(int raod, char c, int ind) { len[I] = raod + len[ind]; raod = min(raod, 10); string ret = ; for (int i = 0; i < raod; i++) ret += c; ret = re... |
#include <bits/stdc++.h> using namespace std; inline int in() { int x, y; y = scanf( %d , &x); return x; } const int N = 100 * 1000 + 5; const long long INF = 10LL * 1000 * 1000 * 1000 * 1000; long long a[N]; pair<long long, long long> next(long long x, long long c) { pair<long long, long ... |
#include <bits/stdc++.h> using namespace std; int n, a, b, p[100000], la[100000], lb[100000]; int party[100000]; bool pass, assigned[100000]; map<int, int> m; inline int deg(int i) { return (la[i] != -1) + (lb[i] != -1); } int dfs(int i) { if (deg(i) == 0) { return 1; } if (~la[i]) { ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; long long n; long long deg[N], ans[N]; vector<pair<long long, long long> > g[N]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t = 1; while (t--) { long long x1, x2, y1, ... |
#include <bits/stdc++.h> using namespace std; struct second { int l, r, x, id; bool operator<(const second a) const { if (r < a.r) return 1; if (r > a.r) return 0; return id < a.id; } } s[10005]; int cmp(const second a, const second b) { if (a.l != b.l) return a.l < b.l; re... |
#include <bits/stdc++.h> #pragma optimize( Ofast ) using namespace std; unsigned int start = clock(); using ll = unsigned long long; struct obj { int fi, se; obj() { fi = se = 0; } }; void gettime(string s) { cout << endl << s << (clock() - start) / 1000000.0 << endl; } void insert() {} ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; long long powmod(long long a, long long b) { long long res = 1; a %= M; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % M; a = a * a % M; } return res % M; } const long long N = 1e5; int ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; struct Point { int x, y; Point(int x_ = 0, int y_ = 0) : x(x_), y(y_) {} Point(std::istream &in) { in >> x >> y; x *= 2; y *= 2; } }; bool operator<(const Point &a, const Point &b) { return (a.x < b... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; constexpr ll INF = (1LL << 30) - 1LL; constexpr ll LINF = (1LL << 60) - 1LL; constexpr ll MOD = 1e9 + 7; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) using namespace std; long long MOD = 998244353; double eps = 1e-12; void solve() { long long n, k; cin >> n >> k; if (n == 1 &&... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, a; cin >> n; vector<int> c(3 * 1e5, 0); for (int i = 1; i <= n / 2; i++) { cin >> a; if (a >= i) c[1e5 + a - i]++; } if (n % 2) { cin >> a; if (a >= n /... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; int sumo[maxn], sume[maxn]; int main() { int n; ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { int t; cin >> t; if (i % 2) sumo[i] = sumo[i - 1] + t; else sumo[i] = ... |
#include <bits/stdc++.h> using namespace std; const int BIG = 1e9 + 239; const int M = 2010; int n, m, kol[M], id[M][M]; vector<int> v[M]; bitset<M> a[M]; string s; bool used[M], need[M]; vector<pair<int, int> > ans; inline void upd(int s, int f) { used[s] = false; for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; int main() { cout << INTERCAL n ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; if (N == 1) { if (M == 2) { cout << 0 << endl; cout << 1 1 << endl << 1 2 << endl << 1 1 << endl; return 0; } cout << 1 << endl; cout << 1 << << M << << 1 << ... |
#include <bits/stdc++.h> using namespace std; int n; int x[1000000]; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; sort(x, x + n); int sol = x[n - 1] - x[0]; int p = n / 2 - 1; for (int i = 0; i <= p; i++) sol = min(sol, x[n - 1 - (p - i... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100, inF = 1e6 + 10; int n, k, u, v, c, maxi, a[N], sz[N]; bool ok; vector<int> nei[N]; int get_sz(int v, int par = -1) { for (int u : nei[v]) if (u != par) sz[v] += get_sz(u, v); return ++sz[v]; } int dfs(int v, int par = -... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 8; int a[N], fa[N][20]; vector<int> E[N]; long long res; void dfs(int x, int f) { fa[x][0] = f; long long temp = a[f]; for (int i = 1; i < 20; i++) { fa[x][i] = fa[fa[x][i - 1]][i - 1]; temp = min(temp, (i + 1ll) * a[f... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9 + 5; const long long LINF = LLONG_MAX; int main() { int t; cin >> t; while (t--) { int n; cin >> n; if (360 % (180 - n) == 0) cout << YES n ; else cout << NO n ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; long int k, col = 0; cin >> n >> m >> k; vector<int> desk; for (int i = 1; i < n + 1; ++i) { desk.push_back(m * i); } for (int i = 1; i < desk.size() + 1; ++i) { if (k <= desk[i - 1] * 2) { cout << i... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); using namespace std; int main() { int q; long long int a, b, c; long long int ans = 0; cin >> q; while (q--) { cin >> a >> b >> c; ans = (a + b + c) / 2; cout ... |
#include <bits/stdc++.h> using namespace std; int t, n, bt[1000001] = {}, ar[1000001] = {}; vector<int> v; int main() { ios ::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; ar[i] = i - ar[... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; while (t--) { solve(); } return 0; } void solve() { int r1, r2, c1, c2, d1, d2; cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2; int a; boo... |
#include <bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s) { int ans = 1e6; for (int i = a ; i <= z ; i++) { int t = 0, k = 0; for (int j = 0; j < s.length(); j++) { if (s[j] == i) t = 0; else t++; ... |
#include <bits/stdc++.h> using namespace std; vector<int> ans; void solve() { long long int i, a, b, c, d, n; cin >> a >> b >> c >> d; n = a + b + c + d; string s = ; while (a > 0) { s += 0 ; a--; } while (c > 0) { s += 2 ; c--; } i = 0; while (b... |
#include <bits/stdc++.h> using namespace std; vector<int> E[65600]; vector<pair<int, int> > V; int main() { int n; scanf( %d , &n); queue<int> Q; int degree[65600 + 10], Xsum[65600 + 10]; for (int i = 0; i < n; i++) { int a, b; scanf( %d %d , &a, &b); degree[i] = a; X... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; using dl = double; const int N = 2e5 + 10; ll aarray[200000 + 10]; ll magic[101][101]; vector<ll> primes; bool prime[1000001]; int main() { ios_base::sync_with_stdio(false); string str, ptr, ans = ; ll a, b, c, d, e... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long int t = 1; while (t--) { long long int k, b, n; cin >> k >> b >> n; long long int s = 0; long long int a[n]; map<long long int, vector<long long int> > mp; mp[0].push_back(-1); for (long long i... |
#include <bits/stdc++.h> using namespace std; unordered_set<long long int> s; void fun(long long int l, long long int r, long long int n) { if (n > r) return; else if (n <= r and n >= l) { s.insert(n); } fun(l, r, n * 2); fun(l, r, n * 3); } void solve() { long long int l, ... |
#include <bits/stdc++.h> using namespace std; struct mat { int num[4][4]; }; int p[100009]; mat mult(mat &a, mat &b) { mat ret; for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { long long t = 0; for (int k = 0; k < 4; k++) t += 1ll * a.num[i][k] * b.num[k][j]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n; cin >> n; long long int one = (n / 2) + (n / 3) + (n / 5) + (n / 7), two = (n / 6) + (n / 10) + (n / 14) + (n / 15) + (n / 21) + ... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; long long dc(long long x, long long y) { long long r; while (y) { r = x % y; x = y; y = r; } return x; } int main() { cin >> n >> m >> k; if (2 * n * m % k != 0) cout << NO ; else { int ... |
#include <bits/stdc++.h> using namespace std; int main() { int q, k; cin >> q; long long l, r, d, x; for (k = 0; k < q; ++k) { cin >> l >> r >> d; if (d < l || d > r) x = d; else { if (r % d == 0) x = r + d; else x = r + (d - (r % d)); ... |
#include <bits/stdc++.h> using namespace std; template <class T> T solve(T n, T k) { vector<T> arr(n); for (T i = 0; i < n; i++) { cin >> arr[i]; } T sum = 0; sort(arr.begin(), arr.end(), greater<int>()); for (int i = 2 * k; i < n; i++) { sum += arr[i]; } for (T i = 0; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9 + 10, M = 1e6 + 100, MOD = 1e9 + 7, ML = 25; int a[M], ne[M]; map<int, bool> mp[M]; vector<int> ve[M], adj[M]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { int x, y; scanf( %d%d , ... |
#include <bits/stdc++.h> using namespace std; bool check(long long n, long long pos) { return (n & (1 << pos)); } bool Set(long long n, long long pos) { return (n | (1 << pos)); } long double LOG(long double b, long double e) { return log(b) / log(e); } vector<int> v1[200005], v2[200005], comps[200005], vv; ... |
#include <bits/stdc++.h> using namespace std; int n; int q; vector<pair<int, int> > v; vector<pair<int, int> > V; vector<int> amount; int root = 0; int en = 100002 - 1; struct MaximumFlow { static const long long int InfCapacity = LLONG_MAX; struct Edge { int to; long long int capa... |
#include <bits/stdc++.h> using namespace std; vector<bool> visited; vector<vector<int> > adj; void dfs(int node, long long &s0, long long &s1, int mod) { if (mod == 0) s0++; else s1++; visited[node] = true; for (int i = 0; i < adj[node].size(); i++) { if (!visited[adj[node][i]]... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,popcnt,tune=native ) using namespace std; const int MN = 3333, inf = 1000000005, mod = 1000000007; const long long INF = 1000000000000000005LL; bitset<MN... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, a = INT_MIN, b = INT_MIN; cin >> n; vector<long long int> v(n); for (long long int i = 0; i < n; i++) { cin >> v[i]; } if (n == 1) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> string to_string(pair<T1, T2> p); template <typename T1, typename T2, typename T3> string to_string(tuple<T1, T2, T3> tup); template <typename T1, typename T2, typename T3, typename T4> string to_string(tuple<T1, T2, T3, T4>... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long long r; while (b) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a; vector<vector<int> > gr(n + 1, a); int any; int th; for (int i = 1; i <= n; i++) { cin >> th; if (th != 0) { gr[i].push_back(th); gr[th].push_back(i); } } ... |
#include <bits/stdc++.h> using namespace std; vector<string> ans; map<string, int> lo; string s[100], V[55]; long long int n, m, k, done[100], fyes = -1; void give() { string T = abcdef ; do { ans.push_back(T); } while (next_permutation(T.begin(), T.end())); for (int i = 0; i < ans.si... |
#include <bits/stdc++.h> using namespace std; int dp[1 << 23]; vector<pair<int, int> > p[23]; int a[100]; int main() { int n, res = 1000; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 0; j < i; j++) for (int k = j; k < i; k++) if (a[j] + a[k] == a[... |
#include <bits/stdc++.h> using namespace std; const int oo = (int)1e9; const double PI = 2 * acos(0.0); const double eps = 1e-9; int n, m; vector<int> len; vector<pair<int, int> > pos; deque<int> ans; vector<bool> vis; int find(int x) { for (int i = 0; i < (int)len.size(); ++i) { if (len[i... |
#include <bits/stdc++.h> int main() { int n; std::cin >> n; if (n > 1) { std::cout << 2 * (n - 1); } else { std::cout << 1; }; std::cout << << 2 << std::endl << 1 << << 2; return NULL; } |
#include <bits/stdc++.h> using namespace std; int n, a, i, j, sum, k; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> a; sum += a; j += 1 - 2 * a; if (j < 0) j = 0; if (k < j) k = j; } if (!k) { cout << sum - 1; } else { cout << sum + k; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { int a, b, c; cin >> a >> b >> c; int ans = (int)1e9; int A = -1, B = -1, C = -1; for (int cA = 1; cA <= 2 * a; cA++) { for (... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e5 + 5; long long ans[N]; struct person { int t, s, f, num; void read() { scanf( %d%d%d , &t, &s, &f); } bool operator<(const person &b) const { return t < b.t; } } a[N]; int n, m, X, D, sl, sr; long long T; multiset<pair<long... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.