func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> const int N = 254; const long long INF = 0x3f3f3f3f3f3f3f3fll; int n, t, K; int a[N], d[N]; long long A[N], D[N], lim[N]; long long f[N][N][2], g[N][N][2]; inline void down(long long &x, const long long y) { x > y ? x = y : 0; } inline long long max(const long long x, const long... |
#include <bits/stdc++.h> using namespace std; long long C[4003 + 2][4003 + 2]; void pascal() { for (int i = 0; i < 4003; ++i) C[i][i] = C[i][0] = 1; for (int i = 2; i < 4003; ++i) { for (int j = 1; j < i; ++j) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007LL; } } long long pd... |
#include <bits/stdc++.h> const int maxn = 2e7 + 10; const int mod = 998244853; int n, m, qwq[maxn + 5], ifac[maxn + 5], f[maxn + 5]; void zzh_NB(int &x, int y) { (x += y) >= mod && (x -= mod); } int add(int x) { return x >= mod ? x - mod : x; } int readINT() { int xx = 0, ch = getchar(), f = 1; whil... |
#include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; long long int ans = 0; vector<string> v; string temp = ; for (int i = 0; i < s.size(); i++) { if (s[i] == . && v.size() != 0) { for (int i = 0; i < v.size(); i++) { if (temp == v[i]) ++an... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:256000000 ) template <class T> T sqr(T a) { return a * a; } double a, d, s; int n; void init() { cin >> a >> d >> n; } void solve() { double x = 0, y = 0; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1};... |
#include <bits/stdc++.h> using namespace std; vector<char> line; bool isPossible(int gLoc, int k); int main() { int n, k; cin >> n; cin >> k; char curr; int grasshopperLocation; for (int i = 0; i < n; i++) { cin >> curr; line.push_back(curr); if (curr == G ) grasshoppe... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; inline long long getint() { long long _x = 0, _tmp = 1; char _tc = getchar(); while ((_tc < 0 || _tc > 9 ) && _tc != - ) _tc = getchar(); if (_tc == - ) _tc = getchar(), _tmp = -1; while (_tc >= 0 && _tc <= 9 ) _x... |
#include <bits/stdc++.h> #pragma GCC optimize ( O2,unroll-loops ) //#pragma GCC optimize( no-stack-protector,fast-math ) //#pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typed... |
#include <bits/stdc++.h> using namespace std; long long read() { long long x = 0, F = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) F = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { x = (x << 3) + (x << 1) + c - 0 ; c = getchar(); } retu... |
#include <bits/stdc++.h> using namespace std; set<int> s[400000]; int bl[400000], S[400000], sz, n, m; void dfs(int x, int y) { bl[x] = y; ++sz; for (int z : s[x]) if (z != 1 && !bl[z]) dfs(z, y); } void dft(int x) { S[x] = sz; for (int y : s[x]) if (y != 1 && !S[y]) dft(y); ... |
#include <bits/stdc++.h> using namespace std; const long long mx = 19; const long long mx1 = 262150; long long s[mx]; long long n, m, k; long long extra[mx][mx]; long long dp[mx][mx1]; long long solve(long long prev, long long bitmask, long long m) { if (m == 0) return 0; if (dp[prev][bitmask] !... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long LINF = 1e17; const double DINF = numeric_limits<double>::max(); const int ITER = 300; const int MOD = 1e9 + 7; const double EPS = 1e-10; const int MAXN = 1e5 + 10; int n; vector<int> g[MAXN]; int B[MAXN]; int dp[M... |
#include <bits/stdc++.h> using namespace std; int a[3000010], v[2 * 1000010 + 5]; int main() { int n, k, i, mn, ans, j; scanf( %d%d , &n, &k); for (i = 0; i < n; i++) scanf( %d , &a[i]); mn = a[0]; for (i = 1; i < n; i++) mn = min(mn, a[i]); if (mn <= k + 1) { cout << mn; retur... |
#include <bits/stdc++.h> using namespace std; int N; int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N; int x = 0; int res = 0; if (N == 1) { printf( 1 n ); printf( 1 n ); return 0; } for (int i = 1; i <= N; i++) { x += i; if (x >... |
#include <bits/stdc++.h> using namespace std; const int maxint = -1u >> 1; template <class T> bool get_max(T& a, const T& b) { return b > a ? a = b, 1 : 0; } template <class T> bool get_min(T& a, const T& b) { return b < a ? a = b, 1 : 0; } int k; int num[26]; string s; int main() { ... |
#include <bits/stdc++.h> using namespace std; long long n, sav, mn = 1e9; struct point { long long x, y, uz; } p[2005]; string s; int det(point A, point B, point C) { if (A.x * B.y + A.y * C.x + B.x * C.y - A.x * C.y - A.y * B.x - B.y * C.x < 0) return -1; return 1; } int main() { ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n, m; cin >> n >> m; vector<string> v, vec; for (long long i = 1; i <= n; i++) { string s; cin >> s; v.push_back(s); } for (long ... |
#include <bits/stdc++.h> using namespace std; void z_func(const string &s, vector<int> &z) { int L = 0, R = 0; int n = s.length(); z.resize(n); for (int i = 1; i < n; i++) { if (i > R) { L = R = i; while (R < n && s[R - L] == s[R]) R++; z[i] = R - L; R--; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n, a, b; cin >> n >> a >> b; ll tot = 6 * n; ll ans = 1e18; if (a * b >= tot) { cout << a * b << n << a << << b << n ; } else... |
#include <bits/stdc++.h> using namespace std; namespace IO { char buf[1 << 23], *p1 = buf, *p2 = buf; template <typename T> inline void read(T &x) { x = 0; register char ch = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++); ... |
#include <bits/stdc++.h> using namespace std; int n, i; double am, vm2, d, tant, ti, vm, t, s, daux, tfin; int main() { scanf( %d %lf %lf , &n, &am, &d); tant = 0; for (i = 0; i < n; i++) { scanf( %lf %lf , &ti, &vm); t = (vm / am); s = 0.5 * (vm * vm / am); daux = d - s; ... |
#include <bits/stdc++.h> 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++; } int inp() { int x = 0, f... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long N = 2e5 + 5; long long gcd(long long n, long long m) { if (n == 0) return m; else return gcd(m % n, n); } long long a[105], b[105]; vector<pair<long long, long long> > v1, v2; long long dp[10... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n; long long f[N][2], down[N], g[N], h[N], a[N]; vector<int> e[N]; template <typename T> inline void chkmax(T &x, T y) { x = max(x, y); } template <typename T> inline void chkmin(T &x, T y) { x = min(x, y); } templ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y, i, j, a1 = 0, a2 = 0, b1 = 0, b2 = 0; cin >> n >> m; int a[n], b[m]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < m; i++) cin >> b[i]; for (i = 0; i < n; i++) { if (a[i] % 2 == 1) a1++; els... |
#include <bits/stdc++.h> using namespace std; int n, s, i, j, k, l, x, y; int a[200010]; struct node { int i; }; bool operator<(node x, node y) { return a[x.i] < a[y.i]; } multiset<node> S; multiset<node>::iterator p, p2; int li[200010]; vector<pair<int, int> > v; int main() { scanf( %d%d ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int read() { char ch = ; int x = 0; bool flag = false; while (!isdigit(ch)) { if (ch == - ) flag = true; ch = getchar(); } while (isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 0 ; ch = getchar(... |
#include <bits/stdc++.h> using namespace std; int atoi(string s) { int sol = 0, st = 1; for (int i = 0; i < int(s.size()); i++) { sol += (s[i] - 48) * st; st *= 10; } return sol; } int main() { string a, b; cin >> a >> b; reverse(a.begin(), a.end()); cout << atoi(a) +... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const long long ooo = 9223372036854775807ll; const int _cnt = 1000 * 1000 + 7; const int _p = 1000 * 1000 * 1000 + 7; const int N = 1001005; const double PI = acos(-1.0); const double eps = 1e-9; int o(int x) { return x % _p; } ... |
#include <bits/stdc++.h> using namespace std; bool cmp(long long x, long long y) { return x > y; } int main() { long long n; cin >> n; string S; cin >> S; vector<long long> C; for (long long i = 0; i < n; i++) { long long x = S[i] - 0 ; if (x == 0 || x == 1) continue; ... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0; char c = getchar(); while (c < 0 || 9 < c) c = getchar(); while ( 0 <= c && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); return x; } int p[200000 + 5]; int tp, stk[200000 + 5]; int U[200000 +... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( Ofast ) #pragma GCC optimize( no-stack-protector ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native ) #pragma GCC optimize( fast-math ) #pragma GCC optimize -O3 long long INF = (l... |
#include <bits/stdc++.h> int in[301]; int c[301]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int n, i, j; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , in + i); for (i = 1; i <= n; i++) scanf( %d , c + i); for (i = 1; i <= n; i++) { for (j = 2; j * j <... |
#include <bits/stdc++.h> using namespace std; inline int read() { char c = getchar(); int n = 0; bool f = 0; while (c < 0 || c > 9 ) { if (c == - ) f = 1; c = getchar(); } while (c >= 0 && c <= 9 ) { n = (n << 1) + (n << 3) + (c ^ 48); c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; } long long POW(long long a, long long p, long long M) { if (!p) return 1LL; lon... |
#include <bits/stdc++.h> using namespace std; long long n; inline bool check2(long long x, long long y3) { return (x * x + y3 * y3 * 3 <= n * n); } inline bool check(long long x, long long y3) { return check2(x - 2, y3) & check2(x - 1, y3 - 1) & check2(x + 1, y3 - 1) & check2(x + 2, y3) & c... |
#include <bits/stdc++.h> inline int getint() { register char ch; while (!isdigit(ch = getchar())) ; register int x = ch ^ 0 ; while (isdigit(ch = getchar())) x = (((x << 2) + x) << 1) + (ch ^ 0 ); return x; } const long long mod = 1e9 + 7; const int N = 150001, M = 150002, K = 100001... |
#include <bits/stdc++.h> using namespace std; inline int read() { register int x = 0, t = 1; register char ch = getchar(); while ((ch < 0 || ch > 9 ) && ch != - ) ch = getchar(); if (ch == - ) t = -1, ch = getchar(); while (ch <= 9 && ch >= 0 ) x = x * 10 + ch - 48, ch = getchar(); r... |
#include <bits/stdc++.h> using namespace std; long long dp[5005][5005], bad[30][5005], pre[5005]; const long long MOD = 1e9 + 7; long long fact[5005]; long long qikpow(long long a, long long b) { if (!b) { return 1; } long long ret = qikpow(a, b / 2); ret *= ret; ret %= MOD; if (... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n, s[3000 + 5], c[3000 + 5], f[3000 + 5][5]; inline int read() { int s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= ... |
#include <bits/stdc++.h> int main() { long long a, sum, l, i, b; char ch[10]; while (scanf( %I64d , &a) != EOF) { getchar(); scanf( %s , ch); l = strlen(ch); b = 0; for (i = l - 1; i > 0; i--) b = (ch[i] - 0 + b) * 10; b = ch[0] - 0 + b; sum = a + b; pri... |
#include <bits/stdc++.h> int x[5], j = 1, b, d, ans, t, i, u = 0; void GCD(int a, int b) { if (a == b) { x[j] = a; j++; } else if (a < b) GCD(b - a, a); else GCD(a - b, b); } int main() { scanf( %d , &b); scanf( %d , &d); GCD(b - 1, d); GCD(b, d); GCD(b + ... |
#include <bits/stdc++.h> using namespace std; const long long N = 50; long long dp[N]; void solve() { long long n; cin >> n; long long count = 0; while (n > 0) { long long quotient = n / 3; long long rem = n % 3; n = n / 3; dp[count] = rem; count++; } for (l... |
#include <bits/stdc++.h> using namespace std; const int mod = int(1e9 + 7), MAXN = int(1e3 + 50); int n, s[MAXN], br, raz, z[MAXN]; vector<int> v[MAXN]; vector<pair<pair<int, int>, int>> rez; void dfs(int i, int ot) { s[i] = 1; for (auto j : v[i]) if (j != ot) { dfs(j, i); s[i]... |
#include <bits/stdc++.h> using namespace std; const uint64_t seed = std::chrono::system_clock::now().time_since_epoch().count(); mt19937_64 rnd(seed); const int MOD = 998244353; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; set<pair<long l... |
#include <bits/stdc++.h> using namespace std; const long long N = 200005; long long n, m, u, v, k; long long flag; long long a[N]; long long x, y, z; long long aa, bb, cc, dd; long long ans[100005]; long long sum; void init() {} long long gcd(long long x, long long y) { if (!y) return x; r... |
#include <bits/stdc++.h> using namespace std; bool compare(const int a, const int b) { if (a <= b) { return false; } return true; } int main() { int t; cin >> t; for (int i = 0; i < t; i++) { string s; cin >> s; int last_count = 0; vector<int> arr; for... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000; const double PI = acos(-1.0); const int MAX = 150005; int n, len, h; pair<int, int> a[MAX]; int b[MAX]; pair<int, int> T[MAX * 8]; int lazy[MAX * 8]; bool pzdc[MAX]; void push(int v) { T[v].first += lazy[v]; ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a; int main(int argc, char *argv[]) { int n; cin >> n; if (n == 1) { cout << 1; return 0; } if (n == 2) { cout << 1 << << 2; return 0; } if (n == 3) { cout << 1 << << 1 << << 3; ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > T; vector<vector<int> > T2; set<int> att; bool keep[123456 + 5]; bool hasa(int from, int v) { keep[v] = false; if (att.find(v) != att.end()) keep[v] = 1; for (int i = 0; i < T[v].size(); ++i) { if (T[v][i] != from) keep[v] ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; const long long inf = 0x3f3f3f3f3f; long long a[1010][1010]; long long n, k; int main() { cin >> n >> k; long long cnt = 0; for (int i = 1; i <= n; i++) { for (int j = n; j >= k; j--) { a[i][j] = n * n - cnt; ... |
#include <bits/stdc++.h> using namespace std; signed main() { string s; cin >> s; long long n = s.size(); long long an = 0; for (long long i = 0; i < n; i++) { long long r = INT_MAX; for (long long j = i; j <= min((long long)(i + 9), n - 1); j++) { for (long long k = 1; k <= ... |
#include <bits/stdc++.h> using namespace std; bool cmp(string s1, string s2) { return (s1 + s2) < (s2 + s1); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; cin >> n; vector<stri... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d, e, i, j, has = 0; cin >> a >> b; has += (a / 5) * (b / 5); c = a / 5; d = b / 5; if (a % 5 >= 1) c++; if (b % 5 >= 4) d++; has += (c * d); c = a / 5; d = b / 5; if (a % 5 >= 2) c++; if (b... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math ) using namespace std; const int N = 3e5 + 100; set<pair<int, int> > s[N]; int a[N]; int nxt[N]; int dp[N]; int mol[N]; int n; void add(long long int v, long long int u) { long long int m = mol[u]; ... |
#include <bits/stdc++.h> using namespace std; template <class n, class second> ostream &operator<<(ostream &p, pair<n, second> x) { return p << < << x.first << , << x.second << > ; } template <class n> auto operator<<(ostream &p, n y) -> typename enable_if<!is_same<n, string>::value, ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 5; const long long INF = 1e18 + 5; const long long maxn = 5e5 + 5; long long n = 1000000007, d[151111], mx = -1000000001; long long a[1511111], ok[100005], sum, cnt, rg[555555], v[555555]; long long bi(long long x, long long y) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; cin >> t; while (t--) { long long int n; cin >> n; cout << n << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:102400000,102400000 ) const int N = 2000005; long long n, A, B, x, y; int p[N]; int main() { scanf( %lld%lld%lld , &n, &A, &B); y = -1; for (; x * A <= n; ++x) { long long tmp = n - x * A; if (tmp / B * B =... |
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class c... |
#include <bits/stdc++.h> using namespace std; struct kmp { vector<int> lps; string pattern; void compute_lps() { int lptr = 0, rptr = 1; lps[0] = 0; while (rptr < lps.size()) { while (lptr != 0 && pattern[lptr] != pattern[rptr]) lptr = lps[lptr - 1]; if (pattern[lptr] =... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const long double INF = 1e100; const long double eps = 1e-12; 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... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { double l, r; cin >> l >> r; if (l > r / 2) { cout << YES << endl; } else { cout << NO << endl; } } return 0; } |
// In the name of Allah. // We re nothing and you re everything. // Ya Ali! #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 1e5 + 14, MAX_K = 40; int n, k; struct XorKeeper { int a[MAX_K]{}; XorKeeper operator^(const XorKeeper &o) { ... |
#include <bits/stdc++.h> using namespace std; namespace hjt { template <typename A, typename B> std::ostream &operator<<(std::ostream &o, const std::pair<A, B> &x) { return o << ( << x.first << , << x.second << ) ; } } // namespace hjt using namespace hjt; const double eps = 1e-7; const doub... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, s, f, h, co = 0, sum, savesum, res, re, savere; cin >> n; long long a[n + 1]; for (i = 1; i <= n; i++) { cin >> a[i]; } cin >> s >> f; h = f - s; queue<long long> qu; i = 1; sum = 0; savesum ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> tr; int n; int mx_bits = 40; int ind = 0; long long xor_sum = 0; long long ans; vector<long long> v; void insert_tr(long long num) { int node = 0; for (int i = (int)mx_bits; i >= (int)0; --i) { bool bit = ((num >> i) & 1) ... |
#include <bits/stdc++.h> using uiII = unsigned int long long; using II = int long long; using namespace std; const II N = 0x3f3f3f3f3f3f3f; int main() { vector<pair<II, II>> v; vector<pair<II, II>>::iterator it; v.reserve(1000000); II t, n, l, r, i(0); for (cin >> t; i < t; i++) { ci... |
#include <bits/stdc++.h> using namespace std; const int N = 305; int n; int f[N][N], dp[2][N][N]; int main() { std::ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> f[i][j]; } } memset(dp, -1, sizeof(dp)); dp[... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t-- > 0) { long long int n, k, can = 0; cin >> n >> k; can += n / k; can = can * k; if (can < n) { if (n - can < k / 2) can += n - can; else can ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int MAXN = 30005; int lst[MAXN], N; bool ok(vector<int> &v) { if ((int)v.size() <= 2) return true; for (int i = (int)v.size() - 2; i >= max(1, (int)v.size() - 5); i--) if (v[i + 1] - v[i] != v[1] - v[0]) return false... |
#include <bits/stdc++.h> using namespace std; int main() { int A[2], B[2], C[2]; scanf( %d %d %d %d %d %d , &A[0], &A[1], &B[0], &B[1], &C[0], &C[1]); int r1 = A[0]; int r2 = B[0]; int r3 = C[0]; int c1 = A[1]; int c2 = B[1]; int c3 = C[1]; bool check = false; int row1, row2,... |
#include <bits/stdc++.h> const int INF = 0x7fffffff; const long long int LNF = 0x7fffffffffffffff; using namespace std; int ac[26], az[26]; char aa[105], bb[105]; int main() { int i, k, nn, kk = 0, len1, len2, s; scanf( %d , &nn); getchar(); while (kk < nn) { gets(aa); gets(bb); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t, c; cin >> n >> t >> c; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } int count = 0; int ans = 0; for (int i = 0; i < n; i++) { if (arr[i] <= t) { count++; if (i == n - 1) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native ) using namespace std; const long long inf = 1e9 + 5; struct Node { Node *l = 0, *r = 0; long long lo, hi, m... |
#include <bits/stdc++.h> using namespace std; double EPS = 1e-9; int conversion(string p) { int o; o = atoi(p.c_str()); return o; } string toString(int h) { stringstream ss; ss << h; return ss.str(); } long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }... |
#include <bits/stdc++.h> using namespace std; const int INF = 2e9; const long long LINF = 2e16; const int magic = 348; const int MOD = 1e9 + 7; const double eps = 1e-10; const double pi = acos(-1); struct fastio { static const int S = 1e7; char rbuf[S + 48], wbuf[S + 48]; int rpos, wpos, len... |
#include <bits/stdc++.h> using namespace std; const int TOUR = 1 << 18, MOD = 1e9 + 7; int Add(int a, int b) { a += b; if (a >= MOD) a -= MOD; return a; } int Sub(int a, int b) { a -= b; if (a < 0) a += MOD; return a; } int Mul(int a, int b) { return (int)(((long long)a * b) % MOD)... |
#include <bits/stdc++.h> using namespace std; const int N = 1 << 16; int n, m; int d[2][N]; int get_n(int x, int n) { int tmp = 3 << (n * 2); tmp = x & tmp; tmp >>= n * 2; return tmp; } int set_n(int x, int n, int y) { int tmp = 3 << (n * 2); x = x & (~tmp); y <<= (n * 2); ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > g; vector<long double> ans; vector<int> sum; void dfs0(int x) { sum[x] = 1; for (int to : g[x]) { dfs0(to); sum[x] += sum[to]; } } void dfs(int x, long double f) { ans[x] = f; int s = sum[x] - 1; for (in... |
#include <bits/stdc++.h> using namespace std; int n; long long k; long long f(int a[], int l, int r) { long long m = 0; for (int i = 0; i < n; i++) if (a[i] < l) m += l - a[i]; else if (a[i] > r) m += a[i] - r; return m; } int main() { ios_base::sync_with_stdio(fa... |
#include <bits/stdc++.h> using namespace std; struct tree { int C; int root; int number_of_branches; int *branches; }; int main() { int c, p, n, i, j, r = 0; int start, D[100000] = {0}, k = 0; struct tree A[100000]; cin >> n; for (i = 0; i < n; i++) { A[i].branches = ne... |
#include <bits/stdc++.h> using namespace std; const long long int N = 2e5 + 5; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const cha... |
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define VI vector<int> #define VL vector<ll> #define MX vector<VI > #define all(x) x.begin(), x.end() #define IOS cin.tie(0)->sync_with_stdio(0) using namespace std; ll gcd(ll a, ll b){ if(!b) return a... |
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } inline int readInt() { int x; scanf( %d , &... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int INF = 0x7fffffff; const double PI = acos(-1.0); const int MAX = 100005; const int MOD = 1000000007; inline bool isEq(double a, double b) { return abs(a - b) < EPS; } inline bool isEq(double a, double b, double eps) { return... |
#include <bits/stdc++.h> using namespace std; long long i, n, m, a[200000], q, l, p, k, c[200000], b[200000], j, ans; string s[200000], ss, s1; int main() { ios_base::sync_with_stdio(0); ans = 1000000007; cin >> n; for (i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); for (i = 1;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> a(n); for (int &i : a) { cin >> i; } vector<vector<bool> > match(n + 1, vector<bool>(n + 1, false)); for (int i = 0, x, y; i < m; i++) { cin >> x >> y; x--; y--; ... |
#include <bits/stdc++.h> using namespace std; long long n, x, ans; priority_queue<long long> q; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> x; q.push(x); if (q.top() > x) { ans += q.top() - x; q.pop(); q.push(x); } } cout << ans; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int *p = new int[100010]; fill(p, p + 100010, -1000000000); for (int i = 0; i < n; ++i) { int x, y; int res = 0; scanf( %d%d , &x, &y); int q = (int)sqrt((double)x); for (int j = 1; j <= q; ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y) { if (y == 0) return 1; long long int d = power(x, y / 2) % 1000000007; if (y % 2 == 0) return (d * d) % 1000000007; else return (((x * d) % 1000000007) * d) % 1000000007; } long long ... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1, ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) + (ch - 0 ); ch = getchar(); } return f * x; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; while (cin >> n) { stack<int> st; bool ov = true; int ovs = 0; int res = 0; int spd = 0; for (int i = 0; i < n; i++) { scanf( %d , &(a)); if (a == 1) { scanf( %d , &(b)); ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using str = string; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vd = vecto... |
#include <bits/stdc++.h> using namespace std; const int cmax = 1e5 + 8; int n; int cnt[cmax]; vector<pair<int, int> > l(cmax); long long psum[cmax]; int d[202]; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) cin >> l[i].first, cnt[l[i].first]++; for (in... |
#include <bits/stdc++.h> using namespace std; using i64 = long long; int n, p[666][666], quad[666]; bool alive[666]; i64 x[666], y[666], px[666], py[666]; int gopos[666][666], goneg[666][666], f[666], id[666]; i64 dp[666][666][4], ans; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) {... |
#include <bits/stdc++.h> using namespace std; template <class T> typename T::value_type arr_sum(const T& v, int n) { typename T::value_type sum = 0; for (int i = 0; i < n; ++i) sum += v[i]; return sum; } struct Sync_stdio { Sync_stdio() { cin.tie(NULL); ios_base::sync_with_stdio(fa... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long min(long long a, long long b) { return (a < b) ? a : b; } long long max(long long a, long long b) { return (a > b) ? a : b; } long long fp(long long a, long long b) { if (b == 0) return 1; long long x = fp(a, b / 2); ... |
#include <bits/stdc++.h> using namespace std; int main() { int ans = 1, n, k, i; cin >> n >> k; cout << (n / k + 1) * k; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { std::cout << std::setprecision(6) << std::fixed; double tux; cin >> tux; double foo = 0, bar = 0, baz = 0, quz = 1; for (; tux != 0.0; tux--) { double pur; cin >> pur; foo = foo + pur; bar = bar + 1; if ((fo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.