func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int n, k; cin >> n >> k; int a[n + 1]; for (int i = (1); i <= (n); i++) cin >> a[i]; long long int d = 1 + 8 * k; long long int x = (long long int)floor(((sqrt(... |
#include <bits/stdc++.h> using namespace std; bool check_prime(long long n) { long long flag = 0; for (long long i = 2; i * i <= n; i++) { if (n % i == 0) { flag = 1; break; } } if (n == 1) return false; else if (flag == 0 || n == 2 || n == 3) { return tru... |
#include <bits/stdc++.h> using namespace std; struct data { int val; int col; vector<int> vec; } arr[100005]; void connect(int a, int b) { arr[a].vec.push_back(b); arr[b].vec.push_back(a); } int goal[100005]; vector<int> ans; void dfs(int n, int fl, int flip, int flip1) { arr[n].... |
#include <bits/stdc++.h> using namespace std; int main() { double p, d, t, f, c; scanf( %lf %lf %lf %lf %lf , &p, &d, &t, &f, &c); if (p >= d) return puts( 0 ), 0; double now = t * p, bizo = 0; while (now <= c) { double step = now / (d - p); if (now + p * step >= c) break; bizo... |
#include <bits/stdc++.h> using namespace std; bool arr[1000][1000]; void change(int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { arr[i][j] = !arr[i][j]; } } } int main() { int n, x, y; int orig_x; cin >> n >> x >> y; orig_x = x; if (x == 1 &&... |
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005]; long long int n, m, k; long long int judge(long long int x) { long long int sum = 0; for (int t = 0; t < x; t++) { if (a[n - x + t] < b[t]) { sum = sum + b[t] - a[n - x + t]; } } return sum; } int mai... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; vector<int> G[N]; vector<pair<int, pair<int, int> > > query; int color[N], Ecolor[2 * N], f[N], s[2 * N], start[N], finish[N], ans[N]; int n, m, u, v, cnt; int block_size; void dfs(int u) { start[u] = ++cnt; Ecolor[cnt] = colo... |
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; for (int i = 0; i < test; i++) { int n, k; cin >> n >> k; if ((n % 2 != 0 && k % 2 == 0) || k > n) cout << NO << endl; else { if (n % 2 == 0) { if (k % 2 != 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; if (t <= 203) { int dp[n * t + 1][301]; memset(dp, 0, sizeof(dp)); int ar[n * t]; int N = n * t; for (int ctr1 = 0; ctr1 < N; ctr1++) { if (ctr1 < n) cin >> ar[ctr1]; ... |
#include <bits/stdc++.h> using namespace std; int n, m, ans = 0; string s; void go(vector<char> k, pair<int, int> start, vector<string> a) { for (int i = 0; i < s.size(); i++) { if (s[i] == k[0]) { start.first--; } if (s[i] == k[1]) { start.first++; } if (s[i] =... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1 << 17; pair<int, int> v[MAXN]; set<pair<int, int> > ans; queue<int> Q; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> v[i].first >> v[i].second; if (v[i].first == 1) Q.push(i); } while (!Q.em... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class T> void print(vector<T>& v, bool spaced = true) { int n = v.size(); string space = (spaced ? : ); for (int i = 0; i < n; ++i) { cout << v[i] << space; } cout << n ; } int main() { ios_ba... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:66777216 ) using namespace std; map<char, int> mp; vector<pair<string, int>> lex; vector<string> lvl[1000001]; int lex_p = -1; int max_l = 0; void rec(int l, int cnt) { if (l > max_l) max_l = l; lvl[l].push_back(lex[lex_p].first); for ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int mx = 999999; int n, k, q; long long f[6], dp[N]; int main() { scanf( %d , &k); for (int i = 0; i < 6; ++i) scanf( %d , &f[i]); for (int i = 1; i <= mx; ++i) { int tmp = i, ct = 0; while (tmp) { in... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, lns, t = 0, pos = -1, posl = 0; string s, ot; cin >> s; lns = s.length(); ot.clear(); for (i = 0; i < lns; ++i) { if (s[i] == a ) t++; else posl++; } if (t == lns) { cout << ... |
#include <bits/stdc++.h> using namespace std; int N, M; long long f[155][155][155][2][2], g[155][155][2][2]; void doit() { scanf( %d %d , &N, &M); int ans = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) for (int k = j; k <= M; k++) { f[i][j][k][0][0] = i == 1... |
#include <bits/stdc++.h> using namespace std; struct camel { int pos; int tof; }; int main() { cout << setprecision(8) << fixed; double l, d, v, g, r; cin >> l >> d >> v >> g >> r; double temp; double T; temp = d / v; double q; bool yer = 1; while (temp >= 0) { ... |
#include <bits/stdc++.h> using namespace std; const long long o = 1e4 + 1; long long n, m, q, a[o], b[o]; long long qwq(long long x) { long long s = 0; for (long long i = 1; i <= n; i++) { if (1.0 * x * a[i] > b[i] * (m + 100)) return m + 1000; s += 1 + x * a[i] / b[i]; } return s; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; pair<int, int> a[n], b[m]; for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } for (int i = 0; i < m; i++) { cin >> b[i].first >> b[i].second; } set<int> s; for (int i = ... |
#include <bits/stdc++.h> using namespace std; void solve(); int main() { solve(); return 0; } void solve() { long long int n, x, y; cin >> n >> x >> y; if (n > y) { cout << -1; return; } if ((y - n + 1) * (y - n + 1) + n - 1 >= x) { for (int i = 1; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 210; int n, m, ans[maxn]; string s[maxn]; int solve(string s) { for (int i = 10; i >= 0; i--) { bool flag = 0; for (int j = 0; j < (1 << i); j++) { string t; for (int k = 0; k < i; k++) if (j & (1 << k)) ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int A[N]; long long sum = 0, ans = 0; bool state; map<int, int> cnt; int main() { cnt[0] = 1; int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> A[i]; } for (int i = 0; i < n; i++) { if (A[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (auto& i : a) { cin >> i; } vector<int> ops; ... |
#include <bits/stdc++.h> using namespace std; namespace IO { char buf_[1 << 21], *p1_ = buf_, *p2_ = buf_; inline long long in() { long long s = 0, f = 1; char x = (p1_ == p2_ && (p2_ = (p1_ = buf_) + fread(buf_, 1, 1 << 21, stdin), p1_ == p2_) ? EOF ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> tt[1005], kk[1005]; int n1, n2, top; vector<int> vv[1005]; int main() { int k, i, j, n, a, tmp; long long ans = 0, sum = 0; scanf( %d %d , &n, &k); for (i = 0; i < n; i++) { scanf( %d %d , &a, &tmp); if (tmp == 1) ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005; struct Node { int left, right; long long sum; } L[N << 2]; void bulid(int step, int l, int r) { L[step].left = l; L[step].right = r; L[step].sum = 0; if (l == r) return; int m = (l + r) >> 1; bulid(step << 1, ... |
#include <bits/stdc++.h> using namespace std; int a[1000][1000]; int main() { int n, ans = 0; cin >> n; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) cin >> a[i][j]; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { int sum1 = 0, sum2 = 0; for (int... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > a[5001]; int n, t; int main() { int m, u, v, w; cin >> n >> m >> t; vector<vector<int> > f(n + 1, vector<int>(2, 0)); vector<vector<int> > p(n + 1, vector<int>(2, 2e9 + 1)); vector<vector<int> > track(n + 1, vector<int>(n ... |
#include <bits/stdc++.h> using namespace std; namespace jumpmelon { const int MAXN = 52; int A[MAXN + 1], B[MAXN + 1]; bool F[MAXN + 1]; void work() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &A[i]); vector<vector<int>> Ans; while (1) { memset(F + 1, 0, size... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n, m, cnt = 0; cin >> n >> m; char mat[n][m]; for (int i = 0; i < (int)(n); i++) { for (int j = 0; j < (int)(m); j++) { cin >> mat[i][j]; } } for ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int N = 1000005; const double PI = 4 * atan(1); long long m, x, y, n, p, z, k; long long h1, m1, h2, m2; char c, cc; int main() { ios::sync_with_stdio(0); cin >> h1 >> c >> m1 >> h2 >> cc >> m2; x = (h2 - h1) * 6... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= 500; i++) putchar( 9 ); for (int i = 1; i <= 500; i++) putchar( 0 ); putchar( 1 ); putchar( n ); for (int i = 1; i <= 501; i++) putchar( 9 ); return 0; } |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; const int oo = 1e9 + 7; const long long mod = 1e9 + 7; const double eps = 1e-11; long long n; int main() { cin.sync_with_stdio(false); cin.tie(0); cin >> n; cout << (n - 2LL) * (n - 2LL) << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int y, b, r; int l, m, n; int ans; cin >> y >> b >> r; l = y; m = b; n = r; int mins = min(min(y, b), r); if (mins == r) { ans = r + (r - 1) + (r - ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int win(long long s, long long e) { if (e % 2 == 1) { if (s % 2 == 1) return 0; else return 1; } else { if (2 * s > e) { if (s % 2 == 1) return 1; else return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int c, v0, v1, a, l; cin >> c >> v0 >> v1 >> a >> l; int ans = 1; c -= min(v0, v1); int p = 0; while (c > 0) { v0 = v0 + a; p = min(v0, v1... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3005; vector<int> flist[maxn], rlist[maxn], clist[maxn]; int n, m, q; int component[maxn], cptr = 0; int visited[maxn]; stack<int> etime; void fdfs(int cur, vector<int> adj[]) { visited[cur] = 1; for (auto u : adj[cur]) { if (v... |
#include <bits/stdc++.h> using namespace std; long long a[105]; int32_t main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); long long n, m; cin >> n >> m; long long maxi = 0, mini = 107; for (long long i = 0; i < n; i++) { cin >> a[i]; maxi = max(maxi, a[i]); } ... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int get_next_state(bool s1, bool s2, bool b1, bool b2) { if (s1 && b1) { return -1; } if (s2 && b2) { return -1; } bool a1 = s1 | b1; bool a2 = s2 | b2; if ((a1 && a2) || (!a1 && !a2)) { retu... |
#include <bits/stdc++.h> using namespace std; const int MODULO = 998244353; const int N_MAX = 200010; vector<int> neighbors[N_MAX]; int factorials[N_MAX]; int n; int calculateBranch(int x, int par) { int perm = factorials[neighbors[x].size()]; for (int y : neighbors[x]) { if (y != par) { ... |
#include<bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define izq nod * 2 #define der nod * 2 + 1 #define md (( a + b ) >> 1) #define oo (1LL<<30LL) #define len(X) (int)(X).size() using namespace std; const ll MOD = 998244353; const int MX = 2 * 1... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; enum { MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009 }; template <typename T> class FenwickTree { vector<T> tree; public: FenwickTree<T>() : tree() {} FenwickTree<T>(vector<T> a) : tree(a.size() + 1, 0) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const long long mod = 1e9 + 7; long long qpow(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; } int n; int vis[N], prim... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, k, b, e; cin >> n >> k; if (n == 1) { cout << 0 << endl; return 0; } long long p = ((k - 1) * k) / 2 - 1; if (n >= 2 && n <= (p + 2)) { b = 2; ... |
#include <bits/stdc++.h> using namespace std; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 100; const int mod = 1e9 + 7; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int q, n = 1000000; long long seg[maxn * 4], lazy[maxn * 4]; void build(int id = 1, int l = 1, int r = n) { if (l == r) { ... |
#include <bits/stdc++.h> using namespace std; using INT = long long; string a[111]; int main() { int n; string s; cin >> s; cin >> n; int flag = 0; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] == s) flag |= 3; if (a[i][1] == s[0]) flag |= 1; if (a[i][0] ==... |
#include <bits/stdc++.h> using namespace std; long long n, m, a, b, res = 0, ans = 0; int main() { cin >> n >> m; a = n % m; b = n / m; ans = (m - a) * b * (b - 1) / 2 + a * b * (b + 1) / 2; res = (n - m + 1) * (n - m) / 2; cout << ans << << res; return 0; } |
#include <bits/stdc++.h> using namespace std; long double gimmearea(long double x1, long double y1, long double r1, long double x2, long double y2, long double r2, long double c) { long double t1, t2, p1, p2; t1 = acos((r1 * r1 + c - r2 * r2) / (2 * r1 * sqrt(... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, l, m, n, ok = 0; char s1[110], s2[110], ans[110]; scanf( %s , s1); scanf( %s , s2); l = strlen(s1); for (i = 0; i < l; i++) { if (s1[i] > s2[i]) { ans[i] = s2[i]; } else if (s1[i] < s2[i]) { o... |
#include <bits/stdc++.h> using namespace std; const long long mm = 1000000007; const long long inf = 1e18; long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch -... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e5 + 7; const int inf = INT_MAX / 2; const long long INF = LLONG_MAX / 3; const int MOD = 998244353; const long double eps = 1e-6; const pair<int, int> dir[] = {{0, 1}, {0, -... |
#include <bits/stdc++.h> using namespace std; struct node { int v, fr; node(){}; node(int a, int b) { v = a, fr = b; } } C[115 + 115]; long long f[115 + 115][115], K; int ar[115 + 115], n, m, P[115][115]; inline bool cmp(node a, node b) { return a.v < b.v; } inline void pluss(long long &p, lon... |
#include <bits/stdc++.h> long double eps = 1e-8; int main() { int n, k; std::cin >> n >> k; std::vector<long double> probabilities(n); for (long double& probability : probabilities) { std::cin >> probability; } long long max_size = (1 << n); std::vector<std::vector<long double>> dp... |
#include <bits/stdc++.h> using namespace std; int read() { int kkk = 0, x = 1; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) c = getchar(), x = -1; while (c >= 0 && c <= 9 ) kkk = (kkk << 3) + (kkk << 1) + (c - 0 ), c = getchar(); return ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<ld, ld>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vector<ld>; using vs = v... |
#include <bits/stdc++.h> using namespace std; long long x[100005], y[100005], q[100005], N = ((long long)1 << 40) - 1; struct node { long long r, l, v, sum; } tree[400005]; void buildtree(int i, int l, int r) { tree[i].l = l; tree[i].r = r; tree[i].v = 0; if (tree[i].r == tree[i].l) { ... |
#include <bits/stdc++.h> using namespace std; char op[600001]; long long id[600001], ans[600001], s[600001]; long long n, m, t; bool cmp(long long x, long long y) { long long pa, pb; if (op[x] == L ) { pa = ((s[x] - t) % m + m) % m; } else pa = (s[x] + t) % m; if (op[y] == L ) { ... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 5; long long add[N << 2], sum[N << 2], color[N << 1]; int n, m; void down(int rt, int len) { if (add[rt]) { add[(rt << 1)] += add[rt]; add[(rt << 1 | 1)] += add[rt]; sum[(rt << 1)] += add[rt] * (len - (len >> 1)); ... |
#include <bits/stdc++.h> using namespace std; long long ans; int a, b; int main() { cin >> a >> b; int c = min(a, b); ans = 1; for (int i = 1; i <= c; i++) ans *= i; cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 260, mo = 777777777; int f[30][N][N], c[N * 2][N * 2], n, k, ans; int power(int x, int y) { int s = 1; for (; y; y /= 2, x = 1ll * x * x % mo) if (y & 1) s = 1ll * s * x % mo; return s; } int main() { scanf( %d%d , &n, &k); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, count; long long l, u; scanf( %d , &n); long long int a[n]; long long int h[n]; for (i = 0; i < n; ++i) { cin >> a[i] >> h[i]; } l = a[0]; h[n - 1] = 0; h[0] = 0; u = a[n - 1]; if (n > 1) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, x = 0, m, num; cin >> n >> k; map<int, int> mp; int arr[1000000]; for (i = 0; (i < n) && (x < k); i++) { cin >> num; if (mp[num] == 0) { arr[x] = num; mp[num] = 1; x++; } } i... |
#include <bits/stdc++.h> using namespace std; int n, k, q; vector<int> style; vector<vector<int> > place; vector<int> base; vector<vector<int> > t; void read() { cin >> n >> k; style.resize(n + 1); place.resize(100001); base.resize(n + 1); t.resize(n * 4 + 4); for (int i = 1; i < n... |
#include <bits/stdc++.h> using namespace std; int main(void) { char a; int k = 0; vector<int> s; while (1) { cin >> a >> a; k++; if (a == + ) s.push_back(1); else if (a == - ) s.push_back(-1); else break; } int n; cin >> n; int ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 545; int a[MAX_N]; int main() { int n, minus = 0; cin >> n; int sum = 0; for (int i = (0); i < (int)(2 * n - 1); ++i) { cin >> a[i]; if (a[i] < 0) { a[i] = abs(a[i]); minus++; } sum += a[i]; ... |
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; const int MM = 998244353; template <typename T, typename U> static inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static inline void amax(T &x, U y) { if (x < y) x = y; } map<int, map... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n, i, ans, arr[100005]; ans = 0; cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; for (i = 1; i < n; i++) { if (arr[i] < arr[i - 1]) ans += arr[i - 1] - arr[i]; } cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long N_MAX = 1123; const long long MOD = 998244353; long long w; long long h; long long result = 1; int main() { ios_base::sync_with_stdio(0); cin >> w; cin >> h; for (long long i = 1; i <= w; i++) { for (long long j = 1; j <= ... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100005]; bool vis[100005]; long long min_val; void dfs(int v, long long* arr) { min_val = min(arr[v], min_val); vis[v] = true; for (int i = 0; i < g[v].size(); i++) { int neig = g[v][i]; if (!vis[neig]) { dfs(neig, arr... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int ans, n, m, k, a[12]; struct Edge { int to, t; Edge() { to = t = 0; } Edge(int _to, int _t) { to = _to; t = _t; } bool operator<(const Edge &z) const { return t < z.t; } }; vector<Edge> vec[N]; int d[N]... |
#include <bits/stdc++.h> using namespace std; int g[20] = {0, 1, 0, 18, 0, 1800, 0, 670320, 0, 734832000, 0, 890786230, 0, 695720788, 0, 150347555, 0}; int main() { int n; cin >> n; cout << g[n] << endl; } |
#include <bits/stdc++.h> using namespace std; priority_queue<pair<int, int> > a; priority_queue<pair<int, int> > b; vector<pair<int, int> > A; vector<pair<int, int> > B; int main() { int n, x; scanf( %d%d , &n, &x); int x0 = x; for (int i = 0; i < n; i++) { int t; int h, m; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, q, num; cin >> n >> q; vector<int> a(n), b(n), c(n); for (int i = 0; i < n; ++i) cin >> a[i]; b[0] = a[0]; for (int i = 1; i < n; ++i) { b[i] = max(a[i], b[i - 1]); if (b[i] == a[i]) c[i - 1] = b[i - ... |
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template <class T = ll> constexpr T TEN(int n) { return (n == 0) ? 1 : 10 * TEN<T>(n - 1); } ll calc(string s) { int n = int(s.size()); if (n == 1) { if (s[0] ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n; cin >> n; long long int mn = 0; for (int i = 1; i <= n; i++) { long long int temp; cin >> temp; mn = max(mn, (temp - i)); } cout << mn <<... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int k, a[N], b[N]; char s[N], t[N]; int main() { cin >> k; scanf( %s , s + 1); scanf( %s , t + 1); for (int i = k; i; i--) { a[i] = t[i] - s[i]; if (a[i] < 0) { a[i] += 26; t[i - 1]--; } ... |
#include <bits/stdc++.h> using namespace std; bool myfunction(int i, int j) { return (i < j); } int main() { int n, a, b, h; cin >> n >> a >> b; vector<int> myvector(n); for (int i = 0; i < n; ++i) { cin >> h; myvector.at(i) = h; } sort(myvector.begin(), myvector.end(), myfunct... |
#include <bits/stdc++.h> using namespace std; const int mxN = 5005; deque<deque<int> > Painter(mxN); vector<bool> Painted(mxN); vector<vector<int> > cnt(mxN, vector<int>(mxN, 0)); int main() { int n, q; cin >> n >> q; for (int i = 0; i < q; i++) { int l, r; cin >> l >> r; for (... |
#include <bits/stdc++.h> const long long int INF = (1e9 + 12312), MOD = 1e9 + 7; const long double EPS = 0.0000000001; using namespace std; vector<pair<long long int, long long int> > a; pair<long long int, pair<long long int, long long int> > l(long long int x, ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const double PI = 3.14159265359; int oneCt = 0, n; class File { public: string name; int type; bool isNum; int numVal; File(string _name, int _type) : name(_name), type(_type), isNum(true) { int sz = name... |
#include <bits/stdc++.h> using namespace std; long long ans = 1e18; vector<char> ops; void solve(vector<long long> a, int pos) { if (pos == 3) { ans = min(ans, a[0]); return; } for (int i = 0; i < (int)(a).size(); ++i) { for (int j = i + 1; j < (int)(a).size(); ++j) { long ... |
#include <bits/stdc++.h> using namespace std; long long INF = 9999999999; double EPSILON = 0.00000001; int sint(string s) { int num = 0; istringstream myStream(s); (myStream >> num); return num; } string str(int num) { ostringstream oss; oss << num; return oss.str(); } vector... |
#include <bits/stdc++.h> using namespace std; char str[100005]; char notValid[15] = { B , C , D , E , F , G , J , K , L , N , P , Q , R , S , Z }; bool valid(char c) { static int i; for (i = 0; i < 15; ++i) if (c == notValid[i]) return false; return true; ... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline int read() { int x = 0; char ch = getchar(); boo... |
#include <bits/stdc++.h> using namespace std; const int mv4[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; const int mv8[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; const int inf = (int)1e9; const char *boo[2] = { NO , YES }; const char *inv = Imp... |
#include <bits/stdc++.h> bool commonDigits(long a, long b) { bool digits[10] = {0}; bool output(0); while (a > 0) { digits[a % 10] = 1; a /= 10; } while (b > 0) { if (digits[b % 10]) { output = 1; break; }; b /= 10; } return output; } int m... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000002; long long memo[MAXN]; long long cost[MAXN]; int tin[MAXN]; int low[MAXN]; bool in_stack[MAXN]; int Stack[MAXN]; int comp[MAXN]; vector<pair<int, int> > g[MAXN]; vector<pair<int, int> > t[MAXN]; int n, m, s; int u, v, w; ... |
#include <bits/stdc++.h> char buf[1 << 21], *p1 = buf, *p2 = buf; inline long long read() { long long ret = 0, ff = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) ff = -ff; ch = getchar(); } while (isdigit(ch)) { ret = (ret << 3) + (ret << 1) + ch - 0 ; ch... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<vector<int>> adj(n); for (int i = 1; i < n; ++i) { int u, v; cin >> u >> v, --u, --v; adj[u].push_back(v), adj[v].push_back(u); } array<int, 2> cnt{}; ... |
#include <bits/stdc++.h> using namespace std; long long int fact[100010]; long long int ifact[100010]; long long int ncr(int n, int r) { if (r < 0 || n < 0) return 0; return (fact[n] * ifact[n - r] % 1000000007) * ifact[r] % 1000000007; } int A[10]; long long int dp[11][101]; int main() { fa... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (n == 1 && m == 1) cout << 1; else if (m + n < 5) cout << -1; else { int x = n * m / 2 + 1, y = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if ((i +... |
#include <bits/stdc++.h> using namespace std; template <typename G> struct triple { G first, second, T; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long d, n, m; cin >> d >> n >> m; vector<pair<long long, long long> > x(m + 2); x[m + 1].first = d... |
#include <bits/stdc++.h> using namespace std; void run() { vector<string> v; for (int i = 0; i < 8; i++) { string s; cin >> s; v.push_back(s); } int a = INT_MAX, b = INT_MAX; for (int i = 0; i < 8; i++) { int c = 0; for (int j = 7; j >= 0; j--) { if (v[j][i]... |
#include <bits/stdc++.h> using namespace std; int n, m, k; struct Lesson { long long a, b; int c, id; bool operator<(const Lesson &t) const { return c < t.c; } } ls[55]; int fstc[110]; long long dp[55][55][110]; pair<int, int> trans[55][55][110]; inline void upd(int x1, int y1, int z1, int y... |
#include <bits/stdc++.h> using namespace std; int Rand(int x) { return rand() * rand() % x + 1; } const int INF = 0x3f3f3f3f, N = 5000005, M = 2000005, MOD = 1e9 + 7; long long qpow(long long a, long long b) { long long ret = 1; for (; b; b >>= 1, a = a * a % MOD) if (b & 1) ret = ret * a % MOD; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, minx, h, m, ans; int a[105]; cin >> n >> minx; for (int i = 1; i <= n; i++) { cin >> h >> m; a[i] = h * 60 + m; } if (a[1] >= minx + 1) { cout << 0 << << 0 << endl; return 0; } for (int i = ... |
#include <bits/stdc++.h> const double eps = 1e-10, pi = acos(-1.0); const int maxS = 1e2 + 10; const int maxS2 = 5e4 + 10; const unsigned long long MOD = 1e9 + 7; using namespace std; struct point { int x, y, z; }; int n, m, i, j, k, x, y, z, T, ii, t, l, r, pos; int tot = 0, cnt = 0, ans = 0, sum... |
#include <bits/stdc++.h> using namespace std; int main() { long long l, r; cin >> l >> r; int t = 0; while (l != r) { r >>= 1; l >>= 1; ++t; } cout << ((1ll << t) - 1); return 0; } |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.