func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; long long p; cin >> p; long long keys[2001], people[1001]; for (int i = 0; i < n; i++) cin >> people[i]; for (int i = 0; i < k; i++) cin >> keys[i]; sort(keys, keys + k); sort(people, people + n);... |
#include <bits/stdc++.h> using namespace std; int n, a[100100], d[100100]; int main() { cin >> n; int mn = 1000111222, mx = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); mn = min(mn, a[i]); mx = max(mx, a[i]); } for (int i = 0; i < n; i++) { a[i] -= mn; if ... |
#include <bits/stdc++.h> using namespace std; void read() { freopen( input.txt , r , stdin); } bool check(string s) { long long ans = s[0] - 0 ; ans = ans * 10ll + (s[1] - 0 ); if (ans % 4 == 0) return true; return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; inline long long quick(long long mul, long long b) { long long c = 1; while (b) { if (b & 1) { c = c * mul % mod; } mul = mul * mul % mod; b /= 2; } return c; } int main() { long lo... |
#include <bits/stdc++.h> using namespace std; namespace FGF { int n, m; int read() { int s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) w = -w; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - 0 ; ch = getchar(); } return s ... |
#include <bits/stdc++.h> using namespace std; const int MAX = (int)1e5 + 55; const int INF = (int)1e9 + 77; const int MOD = (int)1e9 + 7; const double PI = 2 * acos(0.0); const double EPS = 1e-7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; string s; cin >> n >> m >... |
#include <bits/stdc++.h> using namespace std; struct edge { int t; edge *next; }; struct obj { int v, a, b; obj() {} obj(int a0, int b0, int v0) { v = v0, a = a0, b = b0; } }; inline bool cmpObj(obj a, obj b) { return a.v < b.v; } const int maxn = 1010; const int maxm = 4010; obj o... |
#include <bits/stdc++.h> using namespace std; int main() { string in; cin >> in; int sz = in.size(); long long max = -1; for (int i = 1; i <= sz - 2; i++) { for (int j = 1; j <= sz - 1 - i; j++) { long long x, y, z; { stringstream ss(in.substr(0, i)); ss... |
#include <bits/stdc++.h> using namespace std; const int maxn = (1e5) + 15; const int mod = (1e9) + 7; const int inf = (1e9) + 3; long long int n, k, ans; string s; long long int a[maxn]; int main() { ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); ; cin >> n >> k; for (int i ... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second const int MXN = 200040; int cnt[MXN]; bool b[MXN]; ll n,d; int main(){ int t; cin >> t; while(t--){ string s; cin >> s; int n = s.size();... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int N = 1e6 + 5; long long n, pw[N]; int t = 3; void Solve() { pw[n + 1] = 1; for (long long i = n; i >= 3; i--) pw[i] = (pw[i + 1] * i) % mod; long long res = 0; res = (pw[3] * (n - 1)) % mod; for (long... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; #define endl n #define lowbit(x) (x & -x) #define ls(x) (x << 1) #define rs(x) (x << 1 | 1) #define ck(x) (x >= mod ? x - mod : x) #define inf 0x3f3f3f3f #define eps 1e... |
#include <bits/stdc++.h> using namespace std; using namespace rel_ops; using ll = int64_t; using Pii = pair<int, int>; using ull = uint64_t; using Vi = vector<int>; void run(); int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); run(); return 0; } ... |
#include <bits/stdc++.h> using namespace std; int n, l; double d; double arr[1001]; int main() { cin >> n >> l; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); d = 0; for (int i = 0; i < n - 1; i++) d = max(d, arr[i + 1] - arr[i]); cout << fixed << setprecision(9) << max... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n > 36) puts( -1 ); else { int x = n / 2; if (n & 1) printf( 4 ); while (x--) printf( 8 ); } return 0; } |
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; const int N = 1005; vector<pair<int, int>> graph[N]; vector<int> ans; int vis[N]; int v[N]; void dfs(int pos) { vis[pos] = 1; v[pos] = 1; for (auto& e : graph[pos]) { if (vis[e.first] == 0) { if (e.second == 0) { ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f3f3f3f3f; const long long N = 5000; long long n, m, s, t; vector<pair<long long, long long> > nei[N + 1]; vector<long long> rv[N + 1]; void ae(long long x, long long y, long long z) { nei[x].push_back(make_pair(y, z)), nei[y... |
#include <bits/stdc++.h> using namespace std; string s; int dp[50][2000], r[50], n; const int inf = 1e6; int abs(int a) { return a > 0 ? a : -a; } int getTime(int id, int k) { if (k <= 0) return 0; if (dp[id][k]) return dp[id][k]; dp[id][k] = inf; for (int i = 0; i < n; i++) { if (s[i]... |
#include <bits/stdc++.h> using namespace std; char s[1000500]; int ones[1000500], zeros[1000500], dp[1000500]; inline int solve(const vector<int> &vt) { int n = vt.size(); int cnt = 0; for (int i = 0; i < n; i++) { if (!vt[i]) cnt++; zeros[i] = cnt; } cnt = 0; for (int i = n ... |
#include <bits/stdc++.h> using namespace std; inline void intialize() { cin.tie(0); ios_base::sync_with_stdio(0); cout.tie(0); } void clearArr(int arr[], int n); bool arr[105][105]; bool farr[105]; queue<int> q; queue<int> done; int main() { intialize(); string ans[2] = { No , Yes... |
#include <bits/stdc++.h> int f[10005], c, d, n, m, k; inline int min(int x, int y) { return x < y ? x : y; } int main() { scanf( %d %d %d %d %d , &c, &d, &n, &m, &k); if (n * m <= k) { puts( 0 ); return 0; } memset(f, 0x3f, sizeof(f)); f[0] = 0; for (int i = 1; i <= n * m; ++i)... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 1; struct node { int ans = 0; int o = 0; int c = 0; node() : ans(0), o(0), c(0) {} node(int x) : ans(0), o((x == 1 ? 1 : 0)), c((x == 1 ? 0 : 1)) {} }; node t[2 * MAX]; int n; node combine(node x, node y) { node cu... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const double eps = 1e-9; const int N = 1 << 19; const int P = (int)1e9 + 7; const int Z = 239; inline int add(int a, int b) { a += b; if (a >= P) a -= P; return a; } int powP[2 * N]; inline int shift(int a, int n) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long int a[n], sum = 0; vector<int> v; vector<int> u; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; if (a[i] > 0) u.push_back(a[i]); else v.push_back(0 - a[i]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int a1, a2, b1, b2, c1, c2; while (scanf( %d%d%d%d%d%d , &a1, &b1, &c1, &a2, &b2, &c2) != EOF) { if (a1 == 0 && b1 == 0 && c1 != 0) { printf( 0 n ); continue; } if (a2 == 0 && b2 == 0 && c2 != 0) { printf( 0... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string sub; for (int i = 0; i < k; i++) { sub.push_back( k ); } long long int count = 0; set<string> arra; for (int i = 0; i < n; i++) { string a; cin >> a; arra.insert(a); ... |
#include <bits/stdc++.h> int a[100], i, j, maxim, h, l, n, b; int main() { scanf( %d , &n); scanf( %d , &l); for (i = 0; i < n; i++) { scanf( %d , &a[i]); } i = 0; j = 0; b = 0; h = l; maxim = l; while (i < n) { if (l % a[i] == 0) { h = l / a[i]; } ... |
#include <bits/stdc++.h> using namespace std; int b[255]; int main() { string a; cin >> a; for (int i = 0; i < a.size(); i++) { b[a[i]]++; } int u = b[ a ] - 1 + b[ a ]; int u2 = a.size(); cout << min(u, u2); return 0; } |
#include <bits/stdc++.h> #define ll long long #define real long double #define fr(i,l,n) for(ll i=l;i<n;i++) #define br cout<< n #define al(fu) (fu).begin(), (fu).end() #define prl(c) cout<<(c)<< n #define prv(v) {fr(qz,0,v.size()) cout<<(v)[qz]<< ; br;} #define alr(fu) (fu).rbegin(), (fu).rend() ... |
#include <bits/stdc++.h> using namespace std; pair<long long int, long long int> operator+( pair<long long int, long long int> p0, pair<long long int, long long int> p1) { return pair<long long int, long long int>(p0.first + p1.first, p0.second + p1.seco... |
#include <bits/stdc++.h> using namespace std; void fastIO() { std::ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } template <typename T, typename U> inline void mnze(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> inline void mxze(T &x, U y) { if (x < y) x... |
#include <bits/stdc++.h> using namespace std; int inf = (1e9) + 7; int mod = 998244353; int c(int num, int div) { return (num + div - 1) / div; } int main() { int n, k; scanf( %d %d , &n, &k); int nr = 2 * n; int ng = 5 * n; int nb = 8 * n; printf( %d n , c(nr, k) + c(ng, k) + c(nb, k)... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; const double eps = 1e-10; const int max_index = 62; const int inf = 0x3f3f3f3f; const int MOD = 1e9 + 7; inline int read() { char c = getchar(); while (!isdigit(c)) c = getchar(); int x = 0; while (isdigit(c)) { ... |
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void read(_T &f) { f = 0; _T fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) { fu = -1; } c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1100000000000000000; void solve() { long long n, k; cin >> n >> k; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); long long dp[k + 5][k + 5]; memset(dp, 0, sizeof(dp)); long long x =... |
#include <bits/stdc++.h> const int N = 3005; int n, D, h[N], nxt[N], adj[N], fa[N], t, f[N][N], inv[N], ifac[N], C[N][N], g[N], s[N][N]; inline void dfs(const int x) { for (register int i = 1; i <= n; ++i) f[x][i] = 1; for (register int i = h[x], j, v; i; i = nxt[i]) for (dfs(v = adj[i]), j = ... |
#include <bits/stdc++.h> using namespace std; int a[100005], ans[100005]; int main() { int n, a1, a2, num = 0, gg = 0, t = 0; cin >> n; bool ty = true, zz = true; for (int i = 1; i <= n - 1; ++i) { cin >> a1 >> a2; a[a1]++; a[a2]++; } for (int i = 1; i <= n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 10, mod = 2147493647; string a[5]; char str[5][100010]; map<string, int> ans; int main() { for (int i = 0; i < 3; i++) scanf( %s , &str[i]); for (int i = 0; i < 3; i++) { int len = strlen(str[i]); for (int j = 0; ... |
#include <bits/stdc++.h> using namespace std; int n; vector<pair<long long, int> > v; vector<int> lef, rig; long long pitaj(int t, int a, int b, int c) { long long res; cout << 3 - t << << a << << b << << c << endl; cin >> res; return res; } int main() { ios_base::sync_with... |
#include <bits/stdc++.h> const double eps = 1e-06; int main() { double t, s, q; scanf( %lf%lf%lf , &t, &s, &q); double v = (q - 1.0) / q; int cnt = 1; while (true) { s = s / (1 - v); if (s > t - eps) break; cnt++; } printf( %d n , cnt); return 0; } |
#include <bits/stdc++.h> using namespace std; int x, a, b, mx = 2500, Mx = -2500, my = 2500, My = -2500, ans; int main() { cin >> x; for (int i = 1; i <= x; i++) { cin >> a >> b; mx = min(mx, a); Mx = max(Mx, a); my = min(my, b); My = max(My, b); } if (x == 1 || mx ==... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f; int main() { int n, a, x, b, y; cin >> n >> a >> x >> b >> y; while (a != x && b != y) { a++; if (a > n) a = 1; b--; if (b < 1) b = n; if (a == b) { printf( Y... |
#include <bits/stdc++.h> using namespace std; long long ans; int a, b, c, d, e, f, g; int main() { scanf( %d%d%d%d%d%d , &a, &b, &c, &d, &e, &f); if (e > f) ans += min(a, d); a -= ans, d -= ans; ans *= e; g = min(min(b, c), d); ans += f * g; b -= g, c -= g, d -= g; ans += e * min... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n & 1) { cout << Ehab ; } else { cout << Mahmoud ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int M = 1e7 + 1; ; const long long INF = 2e9 + 10; const long long MOD = 1000 * 1000 * 1000 + 7; const long double EPS = 1e-9; int a[N]; bool prime(int x) { for (int i = 2; i < (int)sqrt(x) + 1; ++i) if (x % i == 0) ... |
#include <bits/stdc++.h> using namespace std; long long n; long long m; long long t; void solve() {} struct point { long long x, y; }; bool isSquare(point a, point b, point c, point d) { long long dist1 = (long long)(b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y); long long dis... |
#include <bits/stdc++.h> using namespace std; struct Edge { int to, w, type; Edge() {} Edge(int _to, int _w, int _type) : to(_to), w(_w), type(_type) {} bool operator<(const Edge other) { return type < other.type; } }; const long long N = 1e5 + 5, oo = 1e18; long long n, m, k, dist[N], res; ... |
#include <bits/stdc++.h> using namespace std; long long n, d; bool b; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { cin >> n >> d; b = false; if (d <= n) { cout << YES n ; continue; } for (long long x = 1;... |
#include <bits/stdc++.h> using namespace std; int64_t n; int64_t numbers[200000]; int64_t exists[200000 + 1]; struct Node { int64_t l, r, sum; Node *left, *right; int64_t first, last; }; deque<Node> nodes; Node *root; Node *newNode() { nodes.emplace_back(); return &nodes.back(); ... |
#include <bits/stdc++.h> using namespace std; std::vector<long long> digit(long long num) { string str, s; std::vector<long long> v; str = to_string(num); for (int i = 0; i < str.size(); ++i) { s = str[i]; v.push_back(stoi(s)); } return v; } void solve() { long long num, ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int T; cin >> T; while (T--) { string s[9]; for (long long int i = 0; i < 9; i++) { cin >> s[i]; } for (long long int i = 0; i < 9; i++) { for (long long int j = 0; j < 9; j++) { if (s[... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n; long long l = 1, k = n, cnt = 0, h = n, ans = 0; while (l <= h) { long long mid = l + (h - l) / 2; k = n; cnt = 0; while (k... |
#include <bits/stdc++.h> using namespace std; long long l1, l2, r1, r2, k; int main() { cin >> l1 >> r1 >> l2 >> r2 >> k; if (l2 > r1 || r2 < l1) { cout << 0 << n ; return 0; } long long l, r; if (r1 < r2) { r = r1; } else { r = r2; } if (l1 > l2) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, c[30], a[N], s[N], st[N], t, w, k, m; char b[N]; void sol() { scanf( %s , b + 1); n = strlen(b + 1); for (int i = 0; i < 26; i++) c[i] = 0; t = m = w = k = 0; for (int i = 1; i <= n; i++) { s[i] = b[i] - a ; ... |
#include <bits/stdc++.h> using namespace std; int n, m, w1[555][555], w2[555][555], w3[555][555], gl, Pre[300011], anslen; char ch; struct AnsNode { int x, y, z; void init(int _x, int _y, int _z) { x = _x, y = _y, z = _z; } } Ans[1000111]; struct Node { int x, y; void init(int _x, int _y) { ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) f = -1; for (; c >= 0 && c <= 9 ; c = getchar()) x = x * 10 + c - 0 ; return x * f; } int n; char a[1000010], b[1000010]... |
#include <bits/stdc++.h> using namespace std; int A[10000][2]; int main() { int N, M, K; cin >> N >> M >> K; int cur = 0; for (int i = 0; i < M; i++) for (int j = (i + 1); j < M; j++) { A[cur][K] = i + 1; A[cur][1 - K] = j + 1; cur++; } cout << cur << endl; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 1e6 + 5; long long a[MAXN], b[MAXN]; int main() { int x; cin >> x; for (int i = 1; i <= x; i++) for (int j = 1; j <= x; j++) { if (i * j > x && (i / j) < x && (i % j == 0)) { cout << ... |
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e5 + 10; const long long MOD = 1e9 + 17; long long s, t, n, m; long long d[2][maxN]; vector<pair<long long, long long> > g[maxN], h[maxN]; vector<pair<pair<long long, long long>, long long> > edge; long long dp[2][maxN]; void dij0(l... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c, d, i, j, k, l, arr[26], max = 1; long long int dp[1005], len[1005]; for (i = 0; i < 1005; i++) dp[i] = 0; cin >> a; string s; cin >> s; for (i = 0; i < 26; i++) cin >> arr[i]; dp[0] = 1; dp[1] = 1; ... |
#include <bits/stdc++.h> using namespace std; typedef struct { long long v; long long c; } double_pair; struct line { long long k, b; line() {} line(long long _k, long long _b) : k(_k), b(_b) {} long long Solve(long long val) { long long _a = val - b, _b = k; if (_a % _b == 0... |
#include <bits/stdc++.h> using namespace std; const int N = 123457; int n, m, S, A, D, R, h[N]; vector<int> adj[N]; bool is[N]; bool dfs(int v, int par = 0) { h[v] = h[par] + 1; bool c = is[v]; if (c && h[v] >= D) D = h[v], R = v; if (c && h[v] == D && v < S) S = v; for (int i = 0; i < a... |
#include <bits/stdc++.h> using namespace std; const int MD = 1000000007; long long A[100000 + 1], dp[100000 + 1]; long long exp(long long a, long long b) { long long r = 1; while (b > 0) { if (b & 1) r = r * a; b /= 2; a = a * a; } return r; } int main() { ios_base::syn... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int server, temp; int a, b; a = 0; b = 0; int sum1, sum2; sum1 = 0; sum2 = 0; for (int i = 0; i < n; i++) { cin >> server; if (server == 1) { cin >> temp; a++; sum1... |
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const long long linf = 1LL << 60; const int maxn = 100 + 5; int A[maxn]; bool used[maxn]; vector<int> Q; vector<vector<int> > B; vector<int> C; int n, k, m, q; long double anal() { long double res = 0; for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const double eps = 1e-4; const long long INF = 0x3f3f3f3f3f3f3f3f; const int inf = 0x3f3f3f3f; const int maxn = 1e5 + 7; const int maxm = 1e6 + 7; const double pi = acos(-1.0); long long a[maxn]; long long b[maxn], c[maxn]; int... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; vector<int> spareIndices; vector<bool> LetterPresent(n); for (int i = 0, j = s.length() - 1; i < (s.length() + 1) / 2; ++i, --j) { if (s[i] != s[j]) { if (s[i] == ? ) { s[i] = ... |
#include <bits/stdc++.h> using namespace std; char s[1000001], t[1000001]; long long z[1000001], c[1000001]; int main() { int n, k; scanf( %d%d%s%s , &n, &k, s + 1, t + 1); if (k == 1) { printf( %d n , k * n); return 0; } int o = 1; while (o <= n && s[o] == t[o]) o++; if ... |
#include <bits/stdc++.h> using namespace std; int n; string s; long long rights[1000010], lefts[1000010], mins[1000010]; long long suml[1000010], sumr[1000010]; int min(int a, int b) { return a < b ? a : b; } int main() { scanf( %d , &n); cin >> s; lefts[0] = 0; rights[n - 1] = 0; for ... |
#include <bits/stdc++.h> using namespace std; const int MX = 2e5 + 5; vector<int> v(MX); struct Q { int t, l, r; }; vector<Q> qs(MX); int n, q, m, p; int main() { cin >> n >> q >> m; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 1; i <= q; i++) cin >> qs[i].t >> qs[i].l >> qs[i]... |
#include <bits/stdc++.h> using namespace std; vector<string> v; int main(void) { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { char s[50]; scanf( %s , &s); v.push_back((string)s); } int res = 0; while (true) { int ok = 1; for (int i = 0; i < n; i++) ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long t; cin >> t; while (t--) { long long a, b; cin >> a >> b; if (a == b) { if (a == 0) cout << 0 << n ; else cout << 1 << n ; } else if ((a + b) % 2) cout << -1 <<... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, carry = 0, flag = 1; cin >> n; int ar[n]; for (i = 0; i < n; i++) { cin >> ar[i]; if (ar[i] == 0 && carry == 1) { flag = 0; } if (ar[i] % 2 == 0 && carry == 0) { continue; } if (i... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-12; struct P { double x, y; P(double x = 0, double y = 0) : x(x), y(y){}; } a, b, c, o, p; P operator+(P a, P b) { return P(a.x + b.x, a.y + b.y); } P operator*(P a, double b) { return P(a.x * b, a.y * b); } inline double dis(P a,... |
#include <bits/stdc++.h> using namespace std; void solve(istream& in, ostream& out) { int n; in >> n; int res = n % 2 ? 0 : 1LL << (n / 2); out << res << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); std::istream& in(std::cin); std::ostream& out(std::cout); ... |
#include <bits/stdc++.h> using namespace std; long long mi, mx, n, ta, tb, tc; void C(long long x, long long y, long long z) { ta = (x + 1) * (y + 2) * (z + 2); if (ta > mx) mx = ta; if (ta < mi) mi = ta; } int main() { long long a, b, c, d, uu; uu = 1000000; scanf( %I64d , &n); in... |
#include <bits/stdc++.h> using namespace std; long long expo(long long a, long long b, long long m) { long long result = 1; while (b) { if (b & 1) { result = (result * a) % m; } b = (b >> 1) % m; a = (a * a) % m; } return result; } double expof(double a, int b) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 200005; const int MOD = 1e9 + 9; vector<int> g[MAXN]; int n, m, q, ans; int rows[MAXN]; bool vist[MAXN]; pair<int, int> samp[MAXN]; void dfs(int st) { if (vist[st]) return; vist[st] = 1; for (int i... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); const long maxSteps = 1000000000; long n, m; cin >> n >> m; long x, y; cin >> x >> y; int k; cin >> k; long long total = 0; while (k--) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int l, r; scanf( %d%d , &l, &r); if (l == r) printf( %d n , l); else puts( 2 ); return 0; } |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; template <typename first, typename second> ostream &operator<<(ostream &os, const pair<first, second> &p) { return os << ( << p.first << , << p.second << ... |
#include <bits/stdc++.h> using namespace std; struct edge { int link, next; } e[100010]; int n, k, f[50010][510], h[100010], jud[50010], tt = 0; long long ans[50010], tot; void addEdge(int x, int y) { tt++; e[tt].link = y; e[tt].next = h[x]; h[x] = tt; } void dfs(int x) { jud[x] ... |
#include <bits/stdc++.h> using namespace std; int st[100100][20]; vector<int> graph[100100], ind[100100]; int lev[100100]; int t[100100], l[100100], lg[100100]; int s[100100]; void blg(int n) { lg[0] = -1; for (int i = 0; i < n; ++i) lg[i + 1] = lg[i] + !(i & (i + 1)); } void dfs(int u, int p,... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 2; const long long mod = 998244353; long long fpow(long long a, long long b) { if (b == 0) return 1; long long cur = fpow(a, b >> 1); cur *= cur; cur %= mod; if (b & 1) cur *= a; return cur % mod; } int main() { io... |
#include <bits/stdc++.h> using namespace std; template <class T> bool tomax(T &x, T y) { if (x < y) return x = y, 1; return 0; } template <class T> bool tomin(T &x, T y) { if (x > y) return x = y, 1; return 0; } int A[400005], n, K; int cnt[400005], B[400005], res; void Add(int x, in... |
#include <bits/stdc++.h> const double PI = atan(1) * 4; const double E = exp(1); const int oo = 1e9; const int eps = 1e-9; using namespace std; bool vo(char c) { return (c == a or c == e or c == i or c == o or c == u ); } int main() { ios::sync_with_stdio(0); string s; cin >> s;... |
#include <bits/stdc++.h> using namespace std; int main() { long int n; long long int a[100000]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { cout << a[i] + a[i + 1] << ; } cout << a[n - 1]; return 0; } |
#include <bits/stdc++.h> const int mod = 1000000007; const int gmod = 3; const int inf = 1039074182; const double eps = 1e-9; const long long llinf = 2LL * inf * inf; template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) { if (b < x) x = b; } template <typename T1, typename T2> inli... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200010; const int INF = 1; const double eps = 1e-10; int N, M, T = INF, Cases = 0; int arr[MAXN]; char a[MAXN], b[MAXN]; long long zeros[MAXN], ones[MAXN]; int main() { while (T-- && gets(a + 1) && gets(b + 1)) { a[0] = b[0] = ?... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; namespace io { const int L = (1 << 20) + 1; char buf[L], *S, *T, c; char getchar() { if (__builtin_expect(S == T, 0)) { T = (S = buf) + fread(buf, 1, L, stdin); return (S == T ? EOF : *S++); } return *S++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50; const long long oo = 1e9; const long long mod = 998244353; long long dp[2][510][510], cnt[501], p[501]; int main() { int n, k; scanf( %d%d , &n, &k); dp[0][0][0] = 1; for (int i = 0; i < n; i++) { int q = i % 2; ... |
#include <bits/stdc++.h> using namespace std; const int SIZE = 1000; long long a, b, p, x; long long qpow(long long x, long long y, long long MOD) { long long res = 1; while (y) { if (y & 1) res = (res * x) % MOD; x = (x * x) % MOD; y = y >> 1; } return res; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int mod = 1e9 + 7; long long int powmod(long long int a, long long int b) { long long int res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } re... |
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) using namespace std; using ll = int64_t; const size_t kBuben = 10; const int kNone = -1; struct Pair { int value, count; }; struct ByValue { inline bool operator()(const Pair& a, const Pair& b) const { r... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int maxn = 1e5 + 15; const int inf = 1e9; const int maxe = 200000; vector<int> vec[maxn]; int small[maxn]; int same[maxn]; int a[maxn]; int N; void init(int n) { for (int i = 1; i <= n; i++) for (int j = i; j... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100; vector<int> v[maxn]; int childsNo[maxn]; double expected_finish_time[maxn]; void dfs_calc_number_of_childs(int vert, int par) { for (int i = 0; i < v[vert].size(); i++) { int child = v[vert][i]; if (child != par) { ... |
#include <bits/stdc++.h> using namespace std; char op; char s[200100]; int n; int ans; char c; int tam; set<char> good, bad; set<char>::iterator it; bool ok = false; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %c %s , &op, s); tam = strlen(s); if (... |
#include <bits/stdc++.h> using namespace std; int n; int x[5001]; int ans[5001][5001]; int init() { int i, j; for (i = 1; i <= n; i++) ans[i][1] = x[i]; for (j = 2; j <= n; j++) { for (i = 1; i + j - 1 <= n; i++) ans[i][j] = ans[i][j - 1] ^ ans[i + 1][j - 1]; } for (j = 2; j ... |
#include<bits/stdc++.h> #define ll long long #define ull unsigned long long #define pii pair<int,int> using namespace std; long long mod=1000000007; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } void solve() { ll n;cin>>n; ll a[n]; l... |
#include <bits/stdc++.h> int inp() { char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); int sum = 0; while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum; } struct Node { int l; int r; int id; } s[200010]; int a[200010]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.