func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int gi() { int x = 0, o = 1; char ch = getchar(); while (!isdigit(ch) && ch != - ) ch = getchar(); if (ch == - ) o = -1, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 0 , ch = getchar(); return x * o; } in... |
#include <bits/stdc++.h> using namespace std; int main(void) { int i, n, k; cin >> n >> k; if ((k == 1 && n > 1) || k > n) { cout << -1 ; } else { if (n == 1 && k == 1) { cout << a ; return 0; } string str; for (i = 0; i < n - (k - 2); i++) if ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5, maxh = 3; int mod[maxh] = {(int)1e9 + 7, (int)1e9 + 9, (int)998244353}; struct data { int v[maxh]; data(int a = 0, int b = 0, int c = 0) { v[0] = a; v[1] = b; v[2] = c; } int& operator[](int w) { return v[w]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int l, r; cin >> l >> r; if (l * 2 <= r) { cout << l << << l * 2 << endl; } else { cout << -1 << << -1 << endl; } } return 0; } |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int SIZE = 1e6 + 10; using namespace std; int main() { long long m, h1, a1, x1, y1, h2, a2, x2, y2; cin >> m >> h1 >> a1 >> x1 >> y1 >> h2 >> a2 >> x2 >> y2; long long res1 = 0, per1 = 0, now = h1, now3 = h1, now4 = h2, p... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, dp[105], a, b; memset(dp, 0, sizeof dp); cin >> n; for (int i = 1; i < n; ++i) { cin >> dp[i]; dp[i] += dp[i - 1]; } cin >> a >> b; cout << dp[b - 1] - dp[a... |
#include <bits/stdc++.h> using namespace std; double pi = acos(-1); void OJ() {} int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long t; cin >> t; while (t--) { long long n, x, od = 0, ev = 0; cin >> n >> x; for (long long i = 0;... |
#include <bits/stdc++.h> using namespace std; bool sortp(const pair<int, int> a, const pair<int, int> b) { if (a.first > b.first) return 0; else if (a.first < b.first) return 1; else return a.second > b.second; } int main() { int n, m; cin >> n >> m; pair<int, int> b; ... |
#include<bits/stdc++.h> #define int long long #define p pair<int, int> #define endl n const int INF = 1000000001; using namespace std; int A(int k, int n, int C){ int ans = 1; for (int q = n; q > n-k; q--){ ans = ans*q % C; } return ans; } signed main(){ ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double EPS = 1e-9; int n, k, deg[1000015], ans, vis[1000015]; vector<int> e[1000015]; int dfs(int u) { if (e[u].size() == 1) return 1; vis[u] = 1; vector<int... |
#include <bits/stdc++.h> using namespace std; const long long inf = 2e18 + 7; const long long mod = 1e9 + 7; const double eps = 1e-9; const double PI = 2 * acos(0.0); const double E = 2.71828; int n; pair<int, int> a[200005]; int main(void) { scanf( %d , &n); for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; int a, b, q; cin >> q; for (int i = 0; i < q; i++) { cin >> n >> a >> b; if (a * 2 <= b) cout << n * a << endl; else { { if (n % 2 == 0) cout << b * n / 2 << endl; ... |
#include <bits/stdc++.h> using namespace std; int64_t max(int32_t a, int64_t b) { return max((int64_t)a, b); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); pair<int64_t, int64_t> lc, rc; cin >> rc.second >> rc.first; lc.first = lc.second = 1; int64_t k; c... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { long long n, side = 0, ans = 0; cin >> n; int i = (n + 1) % 4; if (i == 0) ans = n + 1; else if (i == 1 || i == 3) ans = 4 * n + 1; else ans = 2 * n + 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, s; cin >> s1 >> s2 >> s; string s3 = s1 + s2; sort(s3.begin(), s3.end()); sort(s.begin(), s.end()); if (s == s3) cout << YES n ; else cout << NO n ; return 0; } |
#include <bits/stdc++.h> struct node { int x, y, next; } e[100861]; int head[100861], book[100861] = {0}, b[100861]; int main() { memset(head, -1, sizeof(head)); int n, m, a; scanf( %d%d , &n, &m); for (int i = 1; i <= m; i++) { scanf( %d%d , &e[i].x, &e[i].y); e[i].next = head[e... |
#include <bits/stdc++.h> using namespace std; void reader() {} const long long MOD = 1e9 + 7; const long long N = 3e7 + 5; const long long inf = 1e18; long long Set(long long qq, long long pos) { return (qq | (1 << pos)); } long long chk(long long qq, long long pos) { return (qq & (1 << pos)); } void so... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100100; int ar[MAXN]; int N; int main() { int sum = 0; for (int i = 0; i < 6; ++i) { scanf( %d , ar + i); sum ^= ar[i]; } sort(ar, ar + 6); if (ar[0] != ar[3] && ar[1] != ar[4] && ar[2] != ar[5]) { printf( Ali... |
#include <bits/stdc++.h> using namespace std; template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; } int n, a, b; void solve() { cin >> n >> a >> b; string s; cin >> s; a-... |
#include <bits/stdc++.h> int main() { int n1, n2, n3, n4, n5, n6 = 0; std::cin >> n1 >> n2 >> n3 >> n4; for (int i = 0; i < n4; i++) { std::cin >> n5; if (n5 > n2 && n5 < n3 && n1 > n2 && n1 < n3) n6++; } std::cout << n6; } |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int N = 110031; long long n, m; vector<vector<long long> > one(int sz) { vector<vector<long long> > ret; ret.resize(sz); for (int i = 0; i < ret.size(); i++) { ret[i].resize(sz); for (int j = 0; j < ret.size... |
#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 << 3) + (x << 1) + (ch ^ 48), ch = getchar(); return x * f;... |
#include <bits/stdc++.h> using namespace std; int f[10005]; int vis[100005]; void init() { f[1] = 1; f[2] = 1; vis[1] = 1; for (int i = 3; i <= 20; i++) { f[i] = f[i - 1] + f[i - 2]; vis[f[i]] = 1; } } int main() { int n; scanf( %d , &n); init(); for (int i = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; string s, t; int pre[maxn][26], pos[26]; int f[maxn]; int g[maxn]; void solve(string &s, string &t, int f[]) { for (int i = 0; i < 26; i++) pos[i] = -1; int n = t.size(), m = s.size(); for (int i = 0; i <= n; i++) { f... |
#include <bits/stdc++.h> using namespace std; inline long long sqr(long long x) { return (x * x); } inline long long dist(pair<long long, long long> a, pair<long long, long long> b) { return sqr(a.first - b.first) + sqr(a.second - b.second); } int main() { vector<pair<long long... |
#include <bits/stdc++.h> using namespace std; static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; template <typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static void amax(T &x, U y) { if (x < y) x = ... |
#include <iostream> #include <cmath> using namespace std; const int N=2e3+3; int a[N]; int b[N]; int main(){ int n; cin>>n; n<<=1; for(int i=1;i<=n;i++) cin>>a[i]; int ans=n; for(int C=0;C<=1;C++){ for(int j=1;j<=n;j++) b[j]=a[j]; int cnt=0; for(int i=0;... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); } template <class T> inline T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); } template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); ... |
#include <bits/stdc++.h> using namespace std; int main() { long double nb; cin >> nb; if (nb <= 127) cout << byte ; else if (nb <= 32767) cout << short ; else if (nb <= 2147483647) cout << int ; else if (nb <= 9223372036854775807LL) cout << long ; else c... |
#include <bits/stdc++.h> using namespace std; long long a1, a2, b1, b2, c1, c2; int main() { ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2; if (!a1 && !b1 && c1 || !a2 && !b2 && c2) { cout << 0 ; return 0; } if (a1 * b2 != a2 ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 5; int A[M]; char B[M]; int main() { int n; scanf( %d , &n); for (int j = 0; j < n; j++) scanf( %d , &A[j]); scanf( %s , B); int cnt = 0; for (int j = 0; j < n; j++) if (B[j] == 1 ) cnt += A[j]; int ans = cnt,... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; string s; long long ans; long long mem[N][5]; int n; long long dp(int i, int last) { if (i == n) { if (last == 2 || last == 4) return 0; return 1; } if (mem[i][last] != -1) return mem[i][last]; long long p = 0... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; long long f[n - 1]; long long s[n - 1]; for (long long i = 0; i < n - 1; i++) { f[i] = ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int t; cin >> t; while (t--) { int n; cin >> n; while (n--) { if (n == 0) { cout << 1 << n ; } else { cout << 1 ; ... |
#include <bits/stdc++.h> using namespace std; int a, b; int main() { scanf( %d:%d , &a, &b); if (a > 11) a = a - 12; cout << (b / 2.0 + a * 30) << << 6 * b; } |
#include <bits/stdc++.h> using namespace std; int a[4]; int cur[100005]; void work(int x, int y, int z, int w, int tp) { if (x + z < y + w) return; if (x + z >= y + w + 2) return; int nlen = x + y + z + w; for (int pl = 1; pl <= nlen; pl += 2) { if (x) cur[pl] = 0, x--; else ... |
#include <bits/stdc++.h> namespace ringo { template <class T> inline void read(T &x) { x = 0; char c = getchar(); bool f = 0; while (!isdigit(c)) f ^= c == - , c = getchar(); while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); if (f) x = -x; } template <class T> inline void prin... |
#include <bits/stdc++.h> using namespace std; struct rec { int x, p; } a[101]; vector<rec> ans; int n; bool was[101]; bool cmp(rec a, rec b) { return a.x > b.x; } void dfs(int v) { was[v] = true; for (int i = v + 1; i < n; ++i) { if (a[v].x == 0) break; if (!was[i]) { a[v... |
#include <bits/stdc++.h> using namespace std; int a[1000100]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int x; scanf( %i , &x); a[x]++; } int res = 0; for (int i = 0; i < 1000100 - 1; i++) { a[i + 1] += a[i] / 2; a[i] %= 2; res += a[i];... |
#include <bits/stdc++.h> using namespace std; template <class T> void DBGpair(T a, string s = ) { cerr << s << (s == ? : : ) << a.first << , << a.second << n ; } template <class T> void DBGvec(vector<T> a) { for (T i : a) cerr << i << ; cerr << n ; } int dx[] = {0, 0, 1, ... |
#include <bits/stdc++.h> const int MAXN = 50 + 10; bool row[MAXN]; bool column[MAXN]; int main() { int n, x, y; std::cin >> n; for (int i = 0; i <= n * n; i++) { std::cin >> x >> y; if (row[x - 1] == false && column[y - 1] == false) { row[x - 1] = true; column[y - 1] = tr... |
#include <bits/stdc++.h> using namespace std; template <class T> istream& operator>>(istream& is, vector<T>& v) { for (T& x : v) is >> x; return is; } ostream& operator<<(ostream& os, const pair<int, int>& unit) { return os << y = << unit.first << x + << unit.second; } template <class T>... |
#include <bits/stdc++.h> using namespace std; vector<int> vec[200005]; queue<int> Q; int n, m; int cvp[200005]; int top[200005], in[200005]; int a[200005], b[200005], c[200005]; void oku() { int f, s, cost, i; scanf( %d %d , &n, &m); for (i = 1; i <= m; i++) { scanf( %d %d %d , &f, &s,... |
#include <bits/stdc++.h> namespace IO { char buf[1000000], *p1, *p2; inline char getc() { if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin); return p1 == p2 ? EOF : *(p1++); } template <typename tp> inline void r(tp &n) { n = 0; char c = getc(); while (!isdigit(c)) c = getc()... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 , unroll-loops ) using namespace std; template <class T> inline void sort(T &a) { sort((a).begin(), (a).end()); } template <class T> inline void rsort(T &a) { sort((a).rbegin(), (a).rend()); } template <class T> inline void reverse(T &a) { ... |
#include <bits/stdc++.h> using namespace std; int main() { size_t n; string s, t; cin >> n >> s >> t; int base = ( z - a ) + 1; vector<int> l(n + 1), r(n + 1); for (int i = 0; i < int(n); ++i) { l[i + 1] = s[i] - a ; } for (int i = 0; i < int(n); ++i) { r[i + 1] = t[i]... |
#include <bits/stdc++.h> using namespace std; long n, m, a, b, c; vector<pair<long, long> > g[220000]; long cap[220000]; map<pair<long, long>, long> mapp; set<pair<long, long> > done; long ans[220000]; void solve(long v) { for (int i = 0; i < g[v].size(); i++) { long q = g[v][i].first; l... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, mod = 998244353; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double pi = acosl(-1.), eps = 1e-9; inline void sum(int &a, int b) { a += b; if (a >= mod) a -= mod; } inline int power(int a, int b, int m = mod, int ans = ... |
#include <bits/stdc++.h> using namespace std; pair<pair<int, int>, int> e[100010]; int parent[100010]; int Rank[100010]; int sz[100010]; vector<int> v[100010]; bool mark[100010]; bool mark1[100010]; int color[100010]; vector<int> out[2]; bool success[2]; int cnt[2]; int n, m; int find(int cu... |
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; const long long int MAX = 1e9 + 7; void array_show(int *array, int array_n, char middle = ) { for (int i = 0; i < array_n; i++) printf( %d%c , array[i], (i != array_n - 1 ? middle : n )); } void array_show(long long int *a... |
#include <bits/stdc++.h> using namespace std; long long int dp[2002][2002]; vector<long long int> col, row; long long int sol(long int p, long int q, int n, int m, int jk) { if (p == 0 || q == 0) { return 0; } vector<long long int>::iterator it; if (p <= 2 * n && q <= 2 * m) { if (jk... |
#include <bits/stdc++.h> using namespace std; string s; int n; int a[26]; int b[26]; bool flag[26]; bool cmp(int x, int y) { return a[x] < a[y]; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s >> n; memset(a, 0, sizeof(a)); memset(flag, 1, sizeof(flag));... |
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long n) { if (a == 0) return 0; if (a == 1 || n == 0) return 1; if (n == 1) return a % 1000000007; long long t = power(a, n / 2); t = t * t % 1000000007; if (n & 1) return t * a % 1000000007; return t; } ... |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265358979323846; long long MOD = 1e9 + 7; const char nl = n ; const long long inf = 1e15; long long nxt() { long long x; cin >> x; return x; } long long mul(long long x, long long y) { return (1ll * (x % MOD) *... |
#include <bits/stdc++.h> using namespace std; template <typename T> T In() { T x; cin >> x; return x; } int main() { ios::sync_with_stdio(false), cin.tie(0); cout << ((In<int>() & 1) ? Ehab : Mahmoud ); return cout << endl, 0; } |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; bool isprime(int a) { for (int i = 2; i <= sqrt((double)a); i++) { if (a % i == 0) return false; } return true; } int main() { int n; cin >> n; if (n <= 7) cout << 1 << endl << n; else { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; string n1 = to_string(m); for (int i = 0; i < n1.length() / 2; i++) { char s = n1[i]; n1[i] = n1[n1.length() - 1 - i]; n1[n1.length() - 1 - i] = s; } cout << n + stoi(n1); return 0; } ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long l, r; cin >> l >> r; long long ans = 0; for (long long i = 1; i <= r; i *= 2) { long long cur = i; while (cur <= r) { if (cur >= l) ans++; ... |
#include <bits/stdc++.h> using namespace std; string s, h1, m1; int h[10000], m[10000]; bool a[10000]; int main() { int n; cin >> n; cin.ignore(); for (__typeof(n) i = (1); i <= (n); i++) { getline(cin, s); h1 = s.substr(1, 2); m1 = s.substr(4, 2); if (s[7] == a ) ... |
#include <bits/stdc++.h> typedef struct { char name[20]; char phone[200][20]; int len[200]; int avai[200]; int cnt, now; } friends; friends frd[20]; int total; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { char tmp[20]; scanf( %s , tmp); i... |
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::string; using std::vector; int zfn[100010]; int count = 0, nodes_count; string P, T; vector<string> str; vector<vector<int> > connections; void kmpPreprocess() { int i = 0, j = -1; zfn[0] = -1; while ... |
#include <bits/stdc++.h> int main() { int y, k, n; scanf( %d%d%d , &y, &k, &n); int x = k - y % k; int top = n - y; if (x <= top) { printf( %d , x); x += k; while (x <= top) { printf( %d , x); x += k; } printf( n ); } else { printf( -1 n );... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ans1 = INT_MAX, ans = -198896785; cin >> n; int c = 0, d = 0; for (int i = 0; i < n; i++) { int a; cin >> a; if (a < 0) { c++; ans = max(a, ans); } if (a > 0) { d++; ans1 =... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; const int MOD = 1e9 + 7; int dp[MAXN][MAXN][2]; int Steps[MAXN]; int add(int a, int b) { return ((a + b) >= MOD ? a + b - MOD : a + b); } void PreproccessSteps() { Steps[1] = 1; for (int i = (2); i < (1010); i++) Steps[i] =... |
#include <bits/stdc++.h> using namespace std; void solve() { int x, y, n; cin >> x >> y >> n; int max = (n / x) * x; if (max + y > n) { max = max - x + y; } else { max += y; } cout << max << n ; } int main() { int t; cin >> t; while (t--) solve(); return... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const long long mod = 1e9 + 7; void rd(int &x) { int f = 1; x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = x * 10 +... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector ) using namespace std; string s; const int maxn = (int)1e5 + 1; const int maxlog = 19; struct vt { int w[26]; vector<int> lnk[26]; vector<int> rlnk[26]; string s; vt() {} vt(string s) : s(s) {} int get_cnt(in... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a = (n * (n + 1) / 2); cout << (6 * a) + 1; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<bool> primes(n + 1, 1); primes[0] = primes[1] = 0; for (int i = 2; i <= n; ++i) { if (!primes[i]) continue; for (int j = i * i; j <= n; j += i) primes[j] = 0; } vector<int> quest; for (int ... |
#include <bits/stdc++.h> using namespace std; char mat[110][110]; int main() { int r, c; int cnt = 0; int status = 0; int i, j; scanf( %d%d , &r, &c); for (i = 0; i < r; i++) { for (j = 0; j < c; j++) { scanf( %c , &mat[i][j]); } getchar(); } for (i = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int m, r, t, i; long double s = 1.4142135623730950488; long long int b, f; long double d, ans, last, sum = 0; long double x, y, z; cin >> m >> r; x = 2 * r; y = 2 * r + (s * r); z = 2 * r + (2 * s * r); t = ... |
#include <bits/stdc++.h> using namespace std; long long t, a, b, cnt, p; long long ak[101], tot; int main() { cin >> t >> a >> b; if (t == a && a == b) { if (t == 1) cout << inf ; else cout << 2 ; } else if (a == b) cout << 1 ; else { if (a == 1) { ... |
#include <bits/stdc++.h> using namespace std; int n; long long a[200100]; long long t[800800]; long long d[800800]; void build(int v, int tl, int tr) { if (tl == tr) { t[v] = a[tl]; } else { int tm = (tl + tr) / 2; build(2 * v, tl, tm); build(2 * v + 1, tm + 1, tr); t[v... |
#include <bits/stdc++.h> const long long N = 100100; const long long Q = 10100; const long long mod = 1e9 + 7; const long long block = sqrt(N); using namespace std; int n; int a[N]; int t[4 * N]; int rl[4 * N]; int lz[4 * N]; void push(int x) { if (lz[x]) { t[x * 2] += lz[x]; lz[x ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int i, j, k, n, m, s, t, ans1, ans2, ans; int dp[1005][1 << 12]; struct Tree { int head[1005]; struct edge { int vet, next; } E[2005]; int son[1005]; int num[1005]; int a[1005][1005]; int n, tot; Tree(... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); long long no_of_input; long long input; cin >> no_of_input; vector<long long> vect1; for (long long i = 0; i < no_of_input; i++) { cin >> input; vect1.push_back(input); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 100100; int n, a[N], b[N], aa[N], bb[N]; long long ans; void go(int i, int x) { if (ans == 0) return; if (x == 1) { if (a[i + 1] == 9) go(i + 1, -1); if (ans == 0) return; cout << i + 1 << << 1 << n ; --ans; ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; bool replace(std::string& str, const std::string& from, const std::string& to) { size_t start_pos = str.find... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const double EXP = 2.7182818284590452; const double Pi = 3.14159265; const double EPS = 1e-13; const int INF = 1000 * 1000 * 1000; const long long INFL = (long long)INF * (long long)INF; long long n; long long res; void accept... |
#include <bits/stdc++.h> using namespace std; int M = 1e9 + 7; int incr(string &s) { int i, n = s.length(); for (i = n - 1; i >= 0; --i) { if (s[i] != 9 ) { s[i]++; return 0; } s[i] = 0 ; } for (i = n - 1; i >= 0; --i) { s[i] = 0 ; } s = 1 + s; ... |
#include <bits/stdc++.h> using namespace std; ifstream fin( B.in ); ofstream fout( B.out ); long long n, a[100001], v[100001], heap[100001], pending[100001], s1, s2, ok, ideal, current, maxv, nr; string s; int main() { cin >> n; for (int i = 1; i <= 2 * n; ++i) { cin >> a[i]; v[a[i... |
#include <bits/stdc++.h> using namespace std; int i, ans, f; long long n, l, r, mid, x; long long check(long long mid) { if ((mid - 1) / 2 > n / mid) return n + 1; return mid * ((1ll << i) - 1) + mid * (mid - 1) / 2; } int main() { scanf( %I64d , &n); x = (int)(sqrt(n * 2) + 1e-11); if (... |
#include <bits/stdc++.h> using namespace std; long long int pwr(long long int a, long long int n, long long int m) { long long int p = 1; while (n > 0) { if (n % 2 == 1) p = (p * a) % m; a = (a * a) % m; n = n / 2; } return p; } char str[1000000]; int main() { ios::sync_w... |
#include <bits/stdc++.h> using namespace std; const int N = 1000; int main(int argc, char *argv[]) { string s; vector<pair<char, int> > count; int n; cin >> s; n = s.size(); for (int i = 0; i < n;) { int cnt = 0; int prev = s[i]; while (s[i] == prev) { cnt++; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long n, a, b, p, q; cin >> n >> a >> b >> p >> q; long long someGcd = gcd(a, b); long long lcm = ... |
#include <bits/stdc++.h> using namespace std; int main() { string second; cin >> second; bool check = 0; string tmp(1, second[0]); for (int i = 1; i < second.size(); i++) { if (second[i] == d && second[i + 1] == o && second[i + 2] == t && i < second.size() - 3) tmp ... |
#include <bits/stdc++.h> using namespace std; int k; long long ans[10009]; bool chk(long long n) { int m = 0; while (n) { m += (n % 10); n /= 10; if (m > 10) return 0; } return (m == 10); } int main() { cin >> k; ans[0] = 19; for (int i = 1; i <= 10000; i++) { ... |
#include <bits/stdc++.h> using namespace std; string s; void solve() { long long n = s.length(), i, j, k; long long piv = 0; for (i = 0; i < n; i++) if (s[i] == ^ ) { piv = i; break; } long long l = piv; long long r = n - piv - 1; long long c1 = 0, c2 = 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200; int h[maxn]; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int main() { long long n, m, sx, sy, ex, ey; int q; scanf( %lld%lld%d , &n, &m, &q); long long gc = gcd(n, m); long long stp1 = n / gc,... |
#include <bits/stdc++.h> using namespace std; int k[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2}; int main(void) { int n; scanf( %d , &n); int x = n / 10, y = n % 10; printf( %d n , k[x] * k[y]); } |
#include <bits/stdc++.h> using namespace std; template <typename T> void printContainer(T& a, int n = -1) { if (n == -1) n = a.size(); cout << { ; int i = 0; for (auto it : a) { cout << (it) << , ; if (++i == n) break; } cout << } n ; } int main() { string s[2]; ... |
#include <bits/stdc++.h> using namespace std; const double PI = 2 * acos(0.0); const double eps = 1e-9; double toRad(int angle) { return PI * angle / 180.0; } int a, w, h; double angle; complex<double> intersect(complex<double> p1, complex<double> p2, complex<double> p3, comple... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int t; cin >> t; while (t--) { long long int n; cin >> n; float a = 1; float b = (float)360 / ((2 * n)); b /= 2; b = (3.1415926535897932... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B, typename C> struct triple { A X; B Y; C Z; triple(A a = 0, B b = 0, C c = 0) : X(a), Y(b), Z(c) {} }; template <typename A, typename B, typename C> triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0) { ret... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b != 0) return gcd(b, a % b); else return a; } long long int power(long long int a, long long int b) { if (b == 0) return 1; if (b == 1) return a; if (b % 2 == 0) { long ... |
#include <bits/stdc++.h> using namespace std; void read(long long &x) { x = 0; char c = getchar(); int f = 1; while (!(c >= 0 && c <= 9 )) { if (c == - ) f = -1; c = getchar(); } while ((c >= 0 && c <= 9 )) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); ... |
#include <bits/stdc++.h> using namespace std; struct ln { long long m, k; ln(long long mm, long long kk) { m = mm; k = kk; } }; deque<ln> cvt; long long dp[100010][2]; long long sw[100010]; long long wt[100010]; long long hilldist[100010]; long long cs(long long x, int ci) { re... |
#include <bits/stdc++.h> using namespace std; int x[100]; int a[10010000]; int main() { int a, b, n; scanf( %d%d%d , &a, &b, &n); if (b >= n - 1) puts( 2 ); else { int f = 0; for (int i = 1; i < n && i <= a; i++) { int x = (long long)i * 1000000000 % n; if (x > ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const int mod = 1e9 + 7; const int maxn = 2e6 + 100; const int maxm = 2e6 + 100; const int inf = 0x3f3f3f3f; const double pi = acos(-1.0); int t; pair<long long, long long> a[maxn]; long long s; int n; int vis[maxn]; bool c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.