func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { long long n, first = 0, second = 0, no = 0, spare; cin >> n; vector<long long> v1; vector<long long> v2; for (long long i = 0; i < n; i++) { long long p; cin >> p; if (p > 0) { first += p; v1.push_back(p... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> ostream& operator<<(ostream& cout, const pair<T1, T2>& a) { return cout << ( << a.first << ; << a.second << ) ; } template <typename T> ostream& operator<<(ostream& cout, const vector<T>& a) { if (a.size() == 0) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int i, n, j; cin >> n; int arr[n], a[n]; set<int> s1, s2; int flag = 0, p = 0; for (i = 0; i < n; i++) { cin >> arr[i]; a[i] = arr[i]; s2.insert(arr[i]); ... |
#include <bits/stdc++.h> using namespace std; int ini() { int x; scanf( %d , &x); return x; } long long inl() { long long x; scanf( %lld , &x); return x; } void file_mamager() {} int arr[105], mask[105], dp[105][1 << 17]; pair<int, int> path[105][1 << 17]; vector<int> primes; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; using pi = pair<int, int>; using pl = pair<ll, ll>; template <typename U> void print(U arr) { for (auto element : ar... |
#include <bits/stdc++.h> using namespace std; string s; int l, r; inline void get() { l = 1; r = 2; printf( ? %d %d n , l, r); fflush(stdout); cin >> s; while (s[0] == y ) { l <<= 1; r <<= 1; printf( ? %d %d n , l, r); fflush(stdout); cin >> s; } } ... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; char mat[105][105]; int n, m; int main() { scanf( %d %d , &n, &m); for (int i = 0; i < n; i++) { scanf( %s , mat[i]); } int flag = 0; for (int i = 0; i < n... |
#include <bits/stdc++.h> using namespace std; string s; void rd() { cin >> s; if (s != start ) exit(0); } int q(int x, int y) { cout << ? << x << << y << endl; cin >> s; if (s[0] == x ) return 1; if (s[0] == y ) return 0; exit(0); } int main() { int i, l, r; w... |
#include <bits/stdc++.h> using namespace std; struct E { int to, col, time, ind; E(int to, int col, int time, int ind) : to(to), col(col), time(time), ind(ind) {} }; int n, m, cnt; vector<E> g[50000]; int a[50000], b[50000], c[50000], d[50000], t[50000]; map<int, pair<int, int> > colInd; ... |
#include <bits/stdc++.h> using namespace std; int n, m; int cna, cnb; bool isha[108]; bool ishb[108]; bool vis[108]; int main() { cin >> n >> m; cin >> cna; int tmp; for (int i = 0; i < cna; i++) { scanf( %d , &tmp); isha[tmp] = 1; } cin >> cnb; for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 310; int g[maxn][maxn]; int best[maxn]; int a[maxn]; int ans[maxn]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int v; scanf( %d , &v); g[i][v] = ... |
#include <bits/stdc++.h> using namespace std; int n, a[300010], cnt, fa[300010], siz[300010], ans; bool tag[300010]; inline int find(int x) { while (x ^ fa[x]) x = fa[x] = fa[fa[x]]; return x; } inline void merge(int x, int y) { x = find(x), y = find(y); if (x ^ y) fa[x] = y, siz[y] += siz[x... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, i; cin >> n >> k; if (n % (2 * k + 1) == 0) { cout << n / (2 * k + 1) << n ; for (i = k + 1; i <= n; i += (2 * k + 1)) cout << i << ; } else if (n % (2 * k + 1) < (k + 1)) { cout << n / (2 * k + 1) ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7; const double eps = 1e-9; mt19937 rnd(time(0)); long long n; long long cnt[maxn]; struct state { long long a, b, d; state(long long a, long long b, long long d) : a(a), b(b), d... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 1; while (t--) { long long n; cin >> n; long long a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 1) { cout << 1 1 << endl; cout << 0 << endl; cout << 1 1 << endl; c... |
#include <bits/stdc++.h> using namespace std; struct pt { int x, y; }; int h, t, r, n, m; int w[205][205], unc[205][205], siofdjsodi[205][205]; basic_string<pt> e[205][205], f[205][205], qu; pt hd[205], td[205]; void ae(int i, int j, int u, int v) { if (u + v > r) return; e[i][j] += {u, v}; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; const int inf = 1e9 + 7; const long long linf = 1e18; const double pi = acos(-1.0); int main() { ios::sync_with_stdio(false); int t; cin >> t; for (int total = 0; total < t; total++) { i... |
#include <bits/stdc++.h> using namespace std; static struct FastInput { static constexpr int BUF_SIZE = 1 << 20; char buf[BUF_SIZE]; size_t chars_read = 0; size_t buf_pos = 0; FILE* in = stdin; char cur = 0; inline char get_char() { if (buf_pos >= chars_read) { chars_read =... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long ksm(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } long long gcd(long lo... |
#include <bits/stdc++.h> using namespace std; template <class T1> void debug(T1 e) { cout << e << endl; } template <class T1, class T2> void debug(T1 e1, T2 e2) { cout << e1 << t << e2 << endl; } template <class T1, class T2, class T3> void debug(T1 e1, T2 e2, T3 e3) { cout << e1 << t... |
#include <bits/stdc++.h> using namespace std; int read() { char c = getchar(); int d = 0, f = 1; for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) f = -1; for (; c >= 0 && c <= 9 ; d = d * 10 + c - 48, c = getchar()) ; return d * f; } int r, d, n; const int N = 100001;... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double PI = acos(-1.0); const double E = exp(1); const double EPS = 1e-5; const int maxn = 2000 + 5; int n, m; char mp[maxn][maxn] = {0}; int dx[] = {1, 0, 0, -1}; int dy[] = {0, 1, -1, 0}; int cnt = 0; bool check(in... |
#include <bits/stdc++.h> using namespace std; using LL = long long; using pss = pair<string, string>; using pis = pair<int, string>; const int maxn = 300300; int n; LL val[maxn], mask[maxn], sum; signed main() { while (cin >> n) { sum = 0; for (int i = 1; i <= n; i++) { cin >> va... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; int n, x[500005]; char c[500005]; int a[20]; int q, w, e; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < 10; i++) a[i] = 2; for (int i = 0; i < n; i++) { cin >> c[i] >> x[i]; ... |
#include <bits/stdc++.h> using namespace std; bool prime[100001]; bool ispoweroftwo(long long int x) { return x && !(x & (x - 1)); } long long int xorcal(long long int n) { if (n % 4 == 0) return n; if (n % 4 == 1) return 1; if (n % 4 == 2) return n + 1; if (n % 4 == 3) return 0; } void siev... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, m, pnt[N], vis[N]; long long vsum[N], esum[N], vcnt[N]; pair<pair<int, int>, pair<int, int> > edge[N]; vector<int> edge2[N]; int find(int x) { if (x != pnt[x]) pnt[x] = find(pnt[x]); return pnt[x]; } void dfs(int u, int... |
#include <bits/stdc++.h> using namespace std; int main() { bool v[60], h[60]; int a, b, n; while (cin >> n) { memset(v, false, sizeof(v)); memset(h, false, sizeof(h)); for (int i = 1; i <= n * n; i++) { cin >> a >> b; if (i == 1) { cout << 1; h[a] = ... |
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream &operator<<(ostream &os, pair<S, T> &m) { os << [ << m.first << << m.second << ] ; return os; } int n; vector<int> v; bool func(int k) { int x = k - 1, y = n - 1; for (int i = x; i >= 0; --i) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<int> v[1000010]; vector<int> vv; bool visit[1000010] = {0}; int t, tt; int res = 0; void dfs(int x) { visit[x] = 1; t++; for (int i = 0; i < v[x].size(); i++) { int xi = v[x][i]; if (!visit[xi]) dfs(xi); } } ... |
#include <bits/stdc++.h> using namespace std; const int N = 4000 + 1; const int sq = 100; const long long int mod = 1e9 + 7; const long long int inf = 4000 + 1; unordered_map<long long int, int> dp; int ps[N], n; inline int get(int l, int r) { return ps[r] - ps[l]; } int solve(int l, int r, int k, boo... |
#include <bits/stdc++.h> using namespace std; void enable_comma() {} string tostring(char c); string tostring(long long x); template <class A, class B> string tostring(pair<A, B> p); template <class A> string tostring(vector<A> v); string tostring(char c) { string s = ; s += c; return s;... |
#include <bits/stdc++.h> using namespace std; void init() { ios_base::sync_with_stdio(false); cin.tie(NULL); } void skipInputLine() { cin.ignore(numeric_limits<streamsize>::max(), n ); } template <typename TYPE> TYPE readNum() { TYPE item; cin >> item; return item; } template <type... |
#include <bits/stdc++.h> using namespace std; inline long long read() { register long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; int n; while (cin >> n) { cin >> s; int gold = 0, cnt = 0, prev = 0, ans = 0; for (auto ch : s) { if (ch == G ) gold++, cnt++; ... |
#include <bits/stdc++.h> using namespace std; int t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { int a, b, c; cin >> a >> b >> c; if (c == 0) { if (a <= b) cout << 0 << endl; else cout << 1 <<... |
#include <bits/stdc++.h> using namespace std; int main() { int n; std::cin >> n; bool letters[26]; bool d = false; int extra = 0; for (int i = 0; i < 26; i++) { letters[i] = true; } char action; string input = ; for (int i = 0; i < n; i++) { cin >> action; ... |
#include <bits/stdc++.h> using namespace std; const int M = 100010; int n, m; struct road { int to, th; bool f; } in; struct dot { int come_road; int come_point; bool func; } r[M]; vector<road> work[M]; vector<road> not_work[M]; vector<road> rw[M]; vector<road> rnw[M]; bool v... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; void solve(int tc) { int n, k; cin >> n >> k; string s; cin >> s; for (int i = k; i < s.size(); i++) { if (s[i] == ? ) { if (s[i - k] != ? ) { s[i] = s[i - k]; } } else { if (... |
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265359; inline long long add(long long a, long long b, long long m) { if ((a + b) >= m) return (a + b) % m; return a + b; } inline long long mul(long long a, long long b, long long m) { if ((a * b) < m) return a * b; r... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e2 + 5; int ans[N][N][N]; bool was[N][N][N]; vector<pair<int, int> > adj[N]; bool calc(int x, int y, int pr) { if (was[x][y][pr]) return ans[x][y][pr]; was[x][y][pr] = 1; for (auto to : adj[x]) { if (to.se... |
#include <bits/stdc++.h> using namespace std; int v[2000]; int a, b, n, res; int main() { scanf( %d %d %d , &n, &a, &b); for (int i = 0; i < n; i++) scanf( %d , &v[i]); sort(v, v + n); int res = v[b] - v[b - 1]; cout << res << endl; } |
#include <bits/stdc++.h> using namespace std; const long long maxsize = 100000 + 9; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T; T = 1; while (T--) { long long i, j, k, m, n, flag = 0; vector<int> v; string s; cin >> n >> s; f... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s = 0; cin >> n; if (n >= 1 && n <= 100) { if (n == 1) cout << 1; else { while (1) { if (n == 2) { s = s + 5; break; } s = s + (n * 2) + (n - 2) * 2; ... |
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; long long gcd(long long a, long long b) { if (b == 0) { return a; } else { return gcd(b, a % b); } } void change(map<long long, long long> &m, long long n) { long long i; for (long long i = 1; i < n + 1;... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a[101][101] = {0}, d = 0; cin >> n; for (long long int i = 1; i <= n; i++) { long long int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; for (long long int j = x1; j <= x2; j++) { for (long long int k = ... |
#include <bits/stdc++.h> using namespace std; long long getLL() { long long ret = 0; char c; while (1) { c = getchar(); if (c >= 0 && c <= 9 ) break; } while (1) { ret = ret * 10 + c - 0 ; c = getchar(); if (c < 0 || c > 9 ) break; } return ret; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 12; int p[1 << N], q[1 << N], a[1 << N], pos[1 << N], ans[1 << N]; void do_swap(int x, int y) { int val = (p[x] ^ q[x] ^ a[x]); if (!val) { return; } int idx = pos[a[x] ^ q[x]]; swap(pos[p[x]], pos[p[idx]]); swap(p[x], p[i... |
#include <bits/stdc++.h> using namespace std; long long r, d, n; vector<vector<long long>> data; const long double pi = 3.1415926535897932; long long per(vector<long long> x, vector<long long> y) { long long su = 0; for (long long(i) = 0; (i) < (5); (i)++) { su += x[i] * y[i]; } return s... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n; cin >> n; long long ans = 0, turn = 1; while (n > 0) { if (n % 2) { n--; if (turn % 2) { ans++; } } else { if... |
#include <bits/stdc++.h> using namespace std; using namespace chrono; const int infinity = (int)1e9 + 42; const int64_t llInfinity = (int64_t)1e18 + 256; const int module = (int)1e9 + 7; const long double eps = 1e-8; mt19937_64 randGen(system_clock().now().time_since_epoch().count()); inline void raiseE... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, f = 0, se = 0, so = 0, sume = 0, sumo = 0, c = 0, x, y; cin >> n; long long int a[n]; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n; i++) { if (i % 2) so += a[i]; else se += a[i]; ... |
#include <bits/stdc++.h> using namespace std; int dividers[60]; int main() { long long int n, k; cin >> n >> k; if (k == 1) { cout << Yes ; return 0; } if (k == 2 && n == 1) { cout << Yes ; return 0; } if (n <= k) { cout << No ; return 0; } ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e3 + 5; char a[MAX][MAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n, m, k; cin >> n >> m >> k; for (int i = (1); i <= (n); ++i) for (int j = (1); j <= (m); ++j) cin >> a[i][j]; int an... |
#include <bits/stdc++.h> using namespace std; const int oo = 10000000; int n, m, x, y, a, b; int vabs(int t) { return (t > 0) ? t : (-t); } int calc(int cx, int cy) { int dx = vabs(cx - x); int dy = vabs(cy - y); if (dx == 0 && dy == 0) return 0; if (dx % a != 0 || dy % b != 0) return oo; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e10; void solve() { long long n, c; cin >> n >> c; long long a[n], b[n]; for (long long i = 0; i < n; i++) { cin >> a[i] >> b[i]; } long long low = -1, high = -1; for (long long i = 1; i <= 100000; i++) { lo... |
#include <bits/stdc++.h> int main() { int n, x; std::cin >> n >> x; std::vector<int> data; int counter = 0; for (int i = 0; i != n; i++) { int temp; std::cin >> temp; data.push_back(temp); } std::sort(data.begin(), data.end()); if (std::find(data.begin(), data.end(), ... |
#include <bits/stdc++.h> #define ll long long #define sz(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end() #define vi vector<int> #define pii pair<int, int> #define rep(i, a, b) for(int i = (a); i < (b); i++) using namespace std; template<typename T> using minpq = priority_queue<T, vec... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a[102400], i, j, o = 0, l = 0, ma, k = 0; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; for (i = 1; i < n; i++) { if (a[i] + k < a[i - 1]) { o += a[i - 1] - (a[i] + k); k += a[i - 1] - (a[i] + k); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100110; const int maxm = 100010; char s[maxn][5]; long long sum[maxm * 4][5][11]; int n; void init() { for (int i = 1; i < maxn; i++) for (int z = 2; z <= 6; z++) { int tp = i % (2 * (z - 1)); if (tp == 0) s... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; getline(cin, s); for (int i = 0; i < n; ++i) { getline(cin, s); int len = s.length(); if (len < 5) cout << OMG>.< I don t know! << endl; else { string prefix(s.substr(0... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int inf = 2e9 + 5; const int N = 1e5; int cost[26]; map<long long, long long> m[26]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); for (int i = 0; i < 26; i++) cin >> cost[i]; string s; cin >> s;... |
#include <bits/stdc++.h> using namespace std; void prv(vector<int> v) { int n = v.size(); for (int i = 0; i < n; i++) cout << v[i] << ; } void swap(long long int &a, long long int &b) { int tm = a; a = b; b = tm; } bool comp(const pair<int, int> &p1, const pair<int, int> &p2) { if... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); template <class T> T SQR(const T &a) { return a * a; } void run() { char str[1000100]; scanf( %s , str); int n = strlen(str); int m; cin >> m; int A[10001]; int B[10001]; map<int, int> res; ch... |
#include <bits/stdc++.h> #define st first #define nd second #define pb push_back #define BOOST ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); #define PI 3.14159265359 using namespace std; typedef long long ll; constexpr ll MOD = 1000000007, sup = 29; constexpr ll MOD_1 = 1234567891... |
#include <bits/stdc++.h> using namespace std; 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 <= 9 ) s = s * 10 + ch - 0 , ch = getchar(); return s * w; } const int inf... |
#include <bits/stdc++.h> using namespace std; struct edge { long long to, cost; edge() {} edge(long long a, long long b) { to = a, cost = b; } }; const long long dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; const long long mod = 1000000007; struct mint { long long x = 0; mint(long long y ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double PI = acos(-1.0); const double EPS = 1e-8; const int MOD = 998244353; template <typename T> void cmin(T &x, T y) { if (y < x) x = y; } template <typename T> void c... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e18; const string nl = n ; int32_t main() { ios::sync_with_stdio(0); cin.tie(nullptr); long long n, k; cin >> n >> k; vector<long long> a(n); for (auto& i : a) { cin >> i; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, cc = 0; cin >> a >> b >> c; if (a < 0 || b < 2 || c < 4) cout << 0 << endl; else { while (a >= 1 && b >= 2 && c >= 4) { cc++; a--; b -= 2; c -= 4; } cout << cc * 7 << endl;... |
#include <bits/stdc++.h> using namespace std; vector<long long> v[100001]; int main() { int n; cin >> n; for (long long i = 1; i < n; i++) { long long a, b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a); } for (long long i = 1; i <= n; i++) { if (v[i].size()... |
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize( -Ofast ) #pragma GCC optimize( trapv ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native ) #pragma GCC optimize( -ffast-math ) #pragma GCC optimize( -funroll-loops ) #pragma GCC optimize( -funroll... |
#include <bits/stdc++.h> using namespace std; long n, k, iters, p[10000], q[1000], rp[1000], ar[200000], ar1[20000]; long ans; bool not_same() { for (int i = 1; i <= n; i++) if (ar[i] != q[i]) return true; return false; } int main() { ios_base::sync_with_stdio(0); cin >> n >> k; fo... |
#include <bits/stdc++.h> using namespace std; int n, a, b, ans = 6; int len[15], last[15]; void dfs(int x, int va) { if (x == 7) { ans = min(ans, va); return; } for (int i = 1; i <= va; i++) { if (last[i] >= len[x]) { last[i] -= len[x]; dfs(x + 1, va); last[... |
#include <bits/stdc++.h> using namespace std; int main() { vector<string> s; set<string> ss; string a, b, res; int n, cnt_a = 0, cnt_b = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a; ss.insert(a); s.push_back(a); } if (ss.size() == 1) cout << s[0] << en... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; int x, y; while (t--) { cin >> x >> y; if (y <= sqrt(x)) { if (x % 2 == 0 && y % 2 == 0) cout << YES << endl; else if (x % 2 == 1 && y % 2 == 1) cout << YES << endl; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000003; long double pi = 3.1415926536; const int mx = 1000003; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long bp(long long a, long long b) { long long ans = 1; while (b > 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b; cin >> a >> b; if (a == 0 && b == 0) { cout << 1; } if (a == 0 && b != 0) { for (int i = b + 1; i > 0; i--) { cout << i << ; } } if (b == 0 && a != 0) { for (int i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; long long qitaceruts(long long num) { long long n = 0, d, p = 1; while (num > 0) { d = num % 10; num = num / 10; if (d != 0) { n = (d * p) + n; p *= 10; } } return n; } int main() { long long a, b, c1, c2; ... |
#include <bits/stdc++.h> using namespace std; string s1, s2; int main() { int n, i, j; scanf( %d , &n); cin >> s1 >> s2; int ans = 0; for (i = 0; i < (n / 2); i++) { j = n - i - 1; map<char, int> mp; mp[s1[i]]++; mp[s1[j]]++; mp[s2[i]]++; mp[s2[j]]++; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cout.tie(0); int n; cin >> n; vector<bool> in(n + 1); for (int i = 0; i < n; i++) { int a; cin >> a; in[a] = true; } vector<int> b(n); for (int i = 0; i < n; i++) { cin... |
#include <bits/stdc++.h> using namespace std; int n; long long L[500005]; char ch[500005]; class segtree { public: long long seg[(1 << 19) * 2]; long long lazy[(1 << 19) * 2]; void lazy_evaluate(int k) { if (k * 2 + 2 >= (1 << 19) * 2) return; lazy[k * 2 + 2] += lazy[k]; lazy[... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const int MAXN = 3e6 + 3; bool appear[MAXN]; int ans[MAXN]; signed main() { int cnt = 1; int n, x; scanf( %d%d , &n, &x); int now = 0; appear[0] = true; appear[x] = true; for (int... |
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; void JIZZ(string output = ) { cout << output; exit(0); } const long double PI = 3.14159265358979323846264338327950288; const long double eps = 1e-13; const long long mod = ... |
#include <bits/stdc++.h> using namespace std; long long N, Q; long long A[1100100], a, b; vector<pair<long long, long long> > qu[1100100]; long long sol[1100100], dp[1100100]; long long solve(long long I, long long b) { if (I > N) return 0; long long ret = A[I]; return ret += solve(I + b, b); ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100000 + 10; int n, m; pair<int, int> s[MAX]; pair<long long, long long> ans; void update(long long a, long long b) { if (b <= 0) return; if (a > ans.first) { ans.first = a; ans.second = b; } else if (a == ans.first) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; if (n == 1) cout << 1 << endl; else cout << (n / 2) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 200005; const int inf = 1e9 + 7; int main() { int n; scanf( %d , &n); while (n--) { int x; scanf( %d , &x); if (x <= 3 || x == 5 || x == 7 || x == 11) puts( -1 ); else { int ans = 0, tg = x & 3; ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = ((int)1e5) + 100; int arr[Maxn], n; map<int, int> num, numL, numR; long long Solve(int a[]) { int l = 0, r = n - 1; while (a[l] == a[r] && l < r) ++l, --r; if (l >= r) return n * 1ll * (n + 1) / 2; for (int(i) = (l); (i) <= (r); ++... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long INF = 1e18; const int M = 1e9 + 7; const int maxn = 1e6; int b[maxn], c[maxn]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(10); int m, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100007; const int maxv = 100000; long long fac[maxn], fac2[maxn]; map<pair<int, int>, int> save; int cnt; long long mypow(int base, int n) { if (n == 0) return 1; long long t = mypow(base, n / 2); t = (t * t) % 1000000007; if (... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, s1 = 1, s2 = 1, d = 0; cin >> n >> m; if (n == 1 && m == 1) { cout << 0 << endl; cout << 1 << << 1 << endl; cout << 1 << << 1 << endl; exit(0); } if (n == 1 && m == 2) { cout << 0 << ... |
#include <bits/stdc++.h> char T[1 << 21]; int n, m, ar[21][21]; int U[21], V[21], P[21], way[21], minv[21]; int hungarian(int n, int m, int ar[21][21]) { memset(way, 0, sizeof(way)), memset(U, 0, sizeof(U)), memset(V, 0, sizeof(V)), memset(P, 0, sizeof(P)); int i, j, i0, i1, j0, j1, x, y, cur, d... |
#include <bits/stdc++.h> int n, m; int map[1010][1010]; int strpnt[1001000][2]; int q[1001000][2]; int qs, qe; int stn; int ans; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int main() { int i, j, k, l, t; scanf( %d%d , &n, &m); for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; inline long long in() { int32_t x; scanf( %d , &x); return x; } inline string getStr() { char ch[1000000]; scanf( %s , ch); return ch; } const long long MOD = 1e9 + 7; const long long base = 29; const long long MAX_N = 3e5 + 1; inli... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int res = 0; for (int i = 0; i < n; i++) { res++; if (i == n - 1) break; if (s[i] != s[i + 1]) { i++; } } cout << res << n ; } |
#include <bits/stdc++.h> using namespace std; int n, x, y, z, x_, y_, z_; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x_ >> y_ >> z_; x += x_; z += z_; y += y_; } if (x != 0 || y != 0 || z != 0) cout << NO << endl; else cout << YES << end... |
#include <bits/stdc++.h> using namespace std; struct IInt { int z; }; bool cmp(int a, int b) { return a < b; } bool operator<(IInt a, IInt b) { return a.z > b.z; } int main() { int n, m, x, i, ans, ans1; IInt t; scanf( %d%d , &n, &m); vector<int> q; priority_queue<IInt> w; for (i... |
#include <bits/stdc++.h> using namespace std; const int N = 2005, M = 2000010; const long long MOD = 1E9 + 7; long long Pow(long long a, long long b) { long long c = 1; for (; b; a = a * a % MOD, b >>= 1) if (b & 1) c = c * a % MOD; return c; } struct Node { int x, y; bool operator... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int MOD = 1000000007; signed main() { cin.tie(0), cout.tie(0); ios::sync_with_stdio(0); int n, k; cin >> n >> k; int a, b, c, d; cin >> a >> b >> c >> d; if (k < n + 1 || n <= 4) cout << -1 << n ,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.