func_code_string
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; using Int = long long; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } struct FastIO { FastIO() { cin.tie(0)...
#include <bits/stdc++.h> using namespace std; const int LOG = 22; int32_t main() { ios::sync_with_stdio(false); int n; cin >> n; vector<int> tab(n); vector<int> dp(1 << LOG); vector<pair<int, int> > samples(1 << LOG, {-1, -1}); auto update = [&](int a, int i) { if (i == -1) retur...
#include <bits/stdc++.h> using namespace std; int s, x1, x2, t1, t2, p, d; int main() { cin >> s >> x1 >> x2 >> t1 >> t2 >> p >> d; int t = 0, flag1 = 0, flag2 = 0; while (flag1 == 0 || flag2 == 0) { if (flag1) { if (p == x2) break; } else if (p == x1) flag1 = 1; if (...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; void run(istream &cin, ostream &cout) { int n, m; cin >> n >> m; string a, b; cin >> a >> b; int diff = n - m; if (diff > 0) { b = string(diff, 0 ) + b; } else { a = string(-diff, 0 ) + a; ...
#include <bits/stdc++.h> int n, m, k; int kex[101][101] = {0}; int main() { scanf( %d%d%d , &n, &m, &k); int i; int x, y; int have = 0; for (i = 0; i < k; i++) { scanf( %d%d , &x, &y); if (x <= 5 || x >= n - 4 || y <= 5 || y >= m - 4) have = 1; } if (have) printf( YES...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int testcases; cin >> testcases; while (testcases) { int n, s, t; cin >> n >> s >> t; if (s > t) cout << (s - (s + t - n) + 1) << n ; else ...
#include <bits/stdc++.h> #pragma GCC optimize(2) #pragma G++ optimize(2) using namespace std; const int MAX_N = 1e5 + 5; long long n, k; long long a[MAX_N], b[MAX_N]; bool use[MAX_N]; long long cal(int i, long long x) { return a[i] - 3 * x * x + 3 * x - 1; } long long check(long long delta) { long...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n; long long k; int a[N]; int main() { cin >> n >> k; k -= n * 1LL * (n + 1) / 2; if (k < 0) { printf( -1 n ); return 0; } iota(a + 1, a + n + 1, 1); reverse(a + 1, a + n + 1); long long added =...
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<double, string> > p(6); p[0].first = 6 % 6; p[0].second = 1/1 ; p[1].first = 5 % 6; p[1].second = 5/6 ; p[2].first = 4 % 6; p[2].second = 2/3 ; p[3].first = 3 % 6; p[3].second = 1/2 ; p[4].first = 2 % ...
#include <bits/stdc++.h> using namespace std; int n, b; string a, c; int main() { cin >> n; int l = -2e9, r = 2e9; for (; n--;) { cin >> a >> b >> c; if (a == > && c == Y || a == <= && c == N ) l = max(l, b + 1); else if (a == >= && c == Y || a == < && c == N ...
#include <bits/stdc++.h> using namespace std; long long int n; set<long long int> nos; long long powmod(long long x, long long y, long long m) { long long res = 1LL; while (y) { if (y & 1) res = (res * x) % m; x = (x * x) % m; y /= 2; } return res; } int main() { ios_ba...
#include <bits/stdc++.h> using namespace std; vector<int> cri[100100], notcri[100100]; int totalnot = 0; int crinum[100100] = {}, notcrinum[100100] = {}; bool cand[100100]; int candnum = 0; int claim[100100]; int main() { int N, M; scanf( %d%d , &N, &M); for (int i = 1; i <= N; i++) { ...
#include <bits/stdc++.h> using namespace std; const long long M = 1000000007; const double pi = 3.141592653589793238463; bool vow(char ch) { return ch == a || ch == e || ch == i || ch == o || ch == u ; } bool isPrime(long long n) { for (long long i = 2; i * i <= n; i++) if (n % i == 0...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } int l3, l4, l5; double calc3(double r) { double x = r / 2; double y = r / 6 * sqrt(3); double z = sqrt(r * r - x * x - y * y); double ret = z * r * r / 12 * sqrt(3); r...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 4; string s, des[3]; int n, q, next_occur[26][MAX], dp[255][255][255]; void makeNO() { for (int j = 0; j < 26; j++) next_occur[j][n + 1] = next_occur[j][n] = n; for (int i = n - 1; i >= 0; i--) { for (int j = 0; j < 26; j++) { ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<int> s[k]; for (int i = 0; i < k; ++i) { int c; cin >> c; for (int j = 0; j < c; ++j) { int p; cin >> p; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 10; struct fridge { int w, id; } f[maxn]; struct edge { int u, v; } e[maxn]; bool cmp(fridge a, fridge b) { return a.w < b.w; } int n, m, a[maxn], ans, fd[maxn]; int main() { int t; cin >> t; while (t--) { ...
#include <bits/stdc++.h> using namespace std; const long long MX = 1e5 + 9; long long par[MX], num[MX]; void MS(long long v) { par[v] = v, num[v] = 1; } long long FS(long long v) { if (par[v] == v) return v; return par[v] = FS(par[v]); } void US(long long a, long long b) { a = FS(a), b = FS(b)...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; long long int k = 1, ans = 1; cin >> n >> m; for (int i = 0; i < m; i++) { k *= 2; k = k % 1000000009; } for (int i = 1; i <= n; i++) { ans *= (k - i); ans = ans % 1000000009; } cout << ans; ...
#include <bits/stdc++.h> using namespace std; int main() { map<string, vector<string> > mp; vector<string> v; string pat; cin >> pat; int n; cin >> n; for (int i = 0; i < n; i++) { string tx; cin >> tx; v.push_back(tx); } sort(v.begin(), v.end()); for (int i...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; const int inf = INT_MAX; const long long inff = 1e18; const int mod = 1e9 + 7; string s, t; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; cout << 0 << << 0 << endl; ...
#include <bits/stdc++.h> using namespace std; int main() { int a1, b1, a2, b2; scanf( %d%d%d%d , &a1, &b1, &a2, &b2); int i; int two1 = 0, three1 = 0, two2 = 0, three2 = 0; long long s1 = (long long)a1 * b1, s2 = (long long)a2 * b2; while (!(s1 % 2)) { two1++; s1 /= 2; } ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int i = -1, j = -1, k = -1, a[n]; for (int l = 0; l < n; l++) { cin >> a[l]; } for (int l = 1; l < n - 1; l++) { j = l; for (int m = j - ...
#include <bits/stdc++.h> int p[100005]; int main(void) { int n, m, i, x; scanf( %d%d , &m, &n); for (i = 1; i <= n; i++) { scanf( %d , &x); x %= m; if (p[x] == 0) p[x] = 1; else { printf( %d n , i); return 0; } } return 0 * printf( -1 n ); ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; map<string, string> mp; for (int i = 0; i < m; i++) { string s1, s2; cin >> s1 >> s2; if (s2.size() < s1.size()) mp[s1] = s2; e...
#include <bits/stdc++.h> using namespace std; const int Inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fll; struct Shuffle { vector<int> S; Shuffle() {} Shuffle(int len) { S.resize(len); iota((S).begin(), (S).end(), 0); } friend inline Shuffle operator*(const Shuffle &a...
#include <bits/stdc++.h> using namespace std; bool major, minor; map<string, int> P; string x, y, z; int k1, k2; void go(string x, string y, string z) { if (P[x] <= P[y]) k1 = P[y] - P[x]; else k1 = 12 - P[x] + P[y]; if (P[y] <= P[z]) k2 = P[z] - P[y]; else k2 = 12 - ...
#include <bits/stdc++.h> using namespace std; int n, k; vector<int> p, q; vector<char> d; int main() { cin >> n >> k; p.resize(n); q.resize(n); d.resize(n); for (int i = 0; i < n; i++) { cin >> d[i] >> p[i] >> q[i]; } map<int, int> b, s; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; template <class T> struct node { T sum, val; int prior, cnt; node *l, *r; node() { cnt = 1; prior = (rand() << 16) + rand(); l = r = NULL; } }; template <class T> class treap { node<T> *root; inline T getsum(node<T> ...
#include <bits/stdc++.h> using namespace std; int main() { int n = 0; char ch; vector<bool> v(26, 0); while (cin >> ch) { cin >> ch; if (ch == { || ch == } || ch == , || ch == ) continue; ch -= 97; if (!v[ch]) { v[ch] = true; n++; } } co...
#include <bits/stdc++.h> using namespace std; int freq[30]; bool dp[30][200005]; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; for (int i = (1); i <= (t); i += (1)) { int n, m, s; cin >> n >> m >> s; string S; cin >> S; memset(freq, 0, s...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int INF = 2e9; const long long INFLL = 1e18; const int MAX_N = 20; int N, M, Q; string str1[MAX_N + 1], str2[MAX_N + 1]; int main() { scanf( %d%d , &N, &M); for (int i = 0; i < N; i++) { cin >> str1[i]; } ...
#include <bits/stdc++.h> int main() { int a, b, c, d, e, f, L; scanf( %d%d%d%d%d%d , &a, &b, &c, &d, &e, &f); L = a + b + c; printf( %d n , L * L - a * a - c * c - e * e); }
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int MOD = 1e9 + 7; const int MAXN = 1e6 + 3; long long gcd(long long a, long long b) { if (b == 0) return a; else return gcd(b, a % b); } long long power(long long x, long long y) { long long res = 1; ...
#include <bits/stdc++.h> using namespace std; int inX[1000001] = {0}; int used[1000001] = {0}; vector<int> ans; int main() { int n; scanf( %d , &n); vector<int> given(n, 0); for (int i = 0; i < n; i++) { scanf( %d , &given[i]); inX[given[i]] = 1; used[given[i]] = 1; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n; int a, b, c; cin >> n; int tong = 0, tong1 = 0, tong2 = 0; for (int i = 0; i < n; i++) { cin >> a >> b >> c; tong += a; tong1 += b; tong2 += c; } if (tong == 0 && tong1 == 0 && tong2 == 0) cou...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int n, k; cin >> n >> k; if ((n - 1) / 2 < k) cout << -1 << n ; else { cout << (n * k) << n ; ; for (int i = 1; i <= n; i++) ...
#include <bits/stdc++.h> using namespace std; int n, a[1003], dp[1003][1003], ans = 1e9 + 10, fr[1003][1003], now; vector<pair<int, int> > res; void dfs(int x, int wants) { if (x == 1) return; if (x == wants) { res.push_back(make_pair(x - 1, fr[x][wants])); dfs(x - 2, fr[x][wants]); } ...
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { int N; cin >> N; vector<int> vec(N); for (int j = 0; j < N; j++) { cin >> vec.at(j); } if (vec.at(0) + vec.at(1) <= vec.at(N - 1)) { cout << 1 << ...
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, a, b, i, same, unique, ans; cin >> t; while (t--) { cin >> n; same = 0; unique = 0; unordered_map<long long, long long> m; for (i = 0; i < n; i++) { cin >> a; m[a]++; if (m[a]...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a > b) { swap(a, b); } if (a == 0) return b; return gcd(b % a, a); } int invertBits(int num) { int x = log2(num) + 1; for (int i = 0; i < x; i++) num = (num ^ (1 << i)); return num; } string add(strin...
#include <bits/stdc++.h> using namespace std; long long const mod = 1e9 + 7; long long const long_max = LONG_LONG_MAX; int interact(int i, int j) { cout << ? << i + 1 << << j + 1 << n ; ; cout.flush(); int x; cin >> x; return x; } void solve() { int n; cin >> n; ...
#include <bits/stdc++.h> using namespace std; inline long long read() { char c = getchar(); long long u = 0, f = 1; while (c != - && (c < 0 || 9 < c)) c = getchar(); if (c == - ) { f = -1; c = getchar(); } while ( 0 <= c && c <= 9 ) { u = u * 10 + c - 0 ; c ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 500 * 1000 + 10; vector<int> adj[MAX_N], vec[MAX_N]; int n, m, cnt; queue<int> q; set<int> s; void readInput() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--, v--; adj...
#include <bits/stdc++.h> char s[300010], p; int main() { int n, m, sum = 0, k, i; scanf( %d%d , &n, &m); scanf( %s , s); for (i = 1; i < n; i++) if (s[i] == . && s[i - 1] == . ) sum++; while (m--) { scanf( %d %c , &k, &p); if (p != . && s[k - 1] == . ) { if (s[k -...
#include <bits/stdc++.h> int N, K, A, B, Q, a[200001], TA[524288], TB[524288]; void P(int x) { int p = 1, l = 1, r = N; while (l < r) { int m = l + r >> 1; if (x <= m) r = m, p <<= 1; else l = m + 1, p = p << 1 | 1; } TA[p] = std::min(a[x], A); TB[p] = std::min(...
#include <bits/stdc++.h> using namespace std; string n; int ar[123], sum = 0; int main() { getline(cin, n); for (int i = 1; i < n.size(); i += 3) { ar[(int)n[i]] = 1; } for (int i = 0; i < 123; i++) { sum += ar[i]; } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a, b, c; if (n % 3 == 0) { a = n - 2; b = 1; c = 1; } else { if ((n + 1) % 3 == 0) { a = n - 3; b = 2; c = 1; } else if ((n - 1) % 3 == 0) { a...
#include <bits/stdc++.h> using namespace std; using namespace std; long long int **sparse; void buildSparseTable(long long int arr[], long long int n, long long int **sparse) { for (long long int i = 0; i < n; i++) { sparse[i][0] = i; } for (long long int j = 1; pow(2, ...
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e5 + 21; long long n, m, a[maxN], cnt[maxN], ans; bool p[maxN], f = true; vector<long long> g[maxN]; int32_t main() { cin >> n >> m; for (long long i = 0; i < m; i++) { long long x, y; cin >> x >> y; g[x].push_ba...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, h, a, b, k, t1, f1, t2, f2; scanf( %lld%lld%lld%lld%lld , &n, &h, &a, &b, &k); while (k--) { scanf( %lld%lld%lld%lld , &t1, &f1, &t2, &f2); if (t1 == t2) printf( %lld n , abs(f2 - f1)); else { l...
#include <bits/stdc++.h> using namespace std; int N; long long a[100013]; long long mpow(long long x, int k) { long long res = 1; while (k) { if (k & 1) { res *= x; res %= 1000000007; } x *= x; x %= 1000000007; k >>= 1; } return res; } int main()...
#include <bits/stdc++.h> using namespace std; int l[200010], r[200010], a[200010], b[200010], n, m; long long sum = 1; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) scanf( %d , &a[i]); for (int i = 0; i < m; i++) scanf( %d , &b[i]); int p = n - 1; for (int i = m - 1; i >= 0...
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n; unsigned long long ans; string str; cin >> n >> str; map<int, vector<int> > myMap; myMap[0].push_back(0); int cur = 0; ans = 0; for (int i = 0; i < str.size(); i++) { if (str[i] == 0 ) {...
#include <bits/stdc++.h> using namespace std; const int maxn = 500500; bool x[maxn]; int p[maxn], num[maxn], tmp[110]; int main() { int n, q; long long ans = 0; scanf( %d%d , &n, &q); for (int i = 0; i < n; i++) scanf( %d , num + i + 1); for (int u = 0; u < q; u++) { int t, k, cnt = ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; const int INF = 1e9; int n, m, cl, ce, v, q; int a[maxn + 5], b[maxn + 5]; int main() { scanf( %d%d%d%d%d , &n, &m, &cl, &ce, &v); for (int i = 1; i <= cl; i++) scanf( %d , &b[i]); for (int i = 1; i <= ce; i++) scanf( %d , &a[i]...
#include <bits/stdc++.h> using namespace std; int a[300005]; int l[5005], r[5005]; long long dp[5005][5005]; const long long inf = 2e16; void Min(long long &a, long long b) { if (a > b) a = b; } int main() { int n, k; scanf( %d %d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &a[i]...
#include <bits/stdc++.h> using namespace std; char s[200010]; int a[200010]; int ans[50]; int n, k, x; void init() { cin >> n >> k; for (int i = 1; i <= n; i++) cin >> s[i]; for (int i = 1; i <= n; i++) a[i] = (int)s[i] - a + 1; a[++n] = 30; for (int i = 1; i <= 26; i++) { int l;...
#include <bits/stdc++.h> using namespace std; int main() { int f, a, b; scanf( %d , &f); scanf( %d:%d , &a, &b); if (b > 59) b %= 10; if (a > f or a == 24) a %= 10; if (a == 0 and f == 12) a = 10; printf( %02d:%02d , a, b); }
#include <bits/stdc++.h> using namespace std; int T, n, s, t; int main() { cin >> T; while (T--) { cin >> n >> s >> t; cout << max(1, max(n - s + 1, n - t + 1)) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = s...
#include <bits/stdc++.h> const int LIM = 1e5; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, q, x, p; cin >> n >> q; for (int i = 0; i < q; i++) { cin >> x; p = (n - x) + x / 2; while (x % 2 == 0) { x += p; p >>...
#include <bits/stdc++.h> using namespace std; template <class T> void operator>>(istream& is, vector<T>& v) { for (auto& e : v) { is >> e; } } template <class T> void operator<<(ostream& os, const vector<T>& v) { for (const auto& e : v) { os << e << ; } os << n ; } l...
#include <bits/stdc++.h> using namespace std; long long t, n; int main() { cin >> t; while (t--) { cin >> n; long long ls, mi = 0; bool pd = false; cin >> ls; for (int i = 2; i <= n; i++) { long long x, lg; cin >> x; if (x < ls) { lg = int(fl...
#include <bits/stdc++.h> using namespace std; int n; int p[100000]; int c[100000]; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 0; i < n; ++i) { cin >> p[i]; --p[i]; } vector<long long int> loops; for (int i = 0; i < n; ++i) { if (c[i]) continue; ...
#include <bits/stdc++.h> using namespace std; char ss[100010]; string s; string s1; pair<int, int> b[2000000]; int m[100100]; unsigned long long h[100100]; unsigned long long p[100100]; int main() { scanf( %s , &ss); s = (string)ss; h[0] = 0; p[0] = 1; for (int i = (1); i < (100100...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long dp[2005][2005], m, d, ans, bit[2005], len; char l[2005], r[2005]; long long dfs(int pos, long long sum, bool flag) { if (pos == -1) return sum == 0; if (!flag && dp[pos][sum] != -1) return dp[pos][sum]; long lon...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { long long int m, a[1000], b, sum = 0; cin >> m >> b; for (int j = 0; j < m; j++) { cin >> a[j]; } for (int j = 0; j < m; j++) { sum = sum + a[j]; ...
#include <bits/stdc++.h> using namespace std; long long n, m, i, x, ans; int main() { cin >> n >> m; x = 1; for (i = 1; i <= m; i++) x = x * 2 % 1000000009; ans = 1; for (i = 1; i <= n; i++) ans = ans * (x - i) % 1000000009; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = 3.141592653589793238463; void printVec(vector<int> v1) { for (int i = 0; i < v1.size(); i++) cout << v1[i] << ; cout << endl; } int main() { ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); priority_queue<lon...
#include <bits/stdc++.h> using namespace std; const int maxn = 200001; int n; int d[maxn], anc[maxn][18], p[maxn]; array<int, 2> tree[maxn * 4]; int jua(int x, int y) { int dd = d[y] - d[x]; for (int i = 17; i >= 0; i--) { if (dd >= 1 << i) { y = anc[y][i]; dd -= (1 << i); ...
#include <bits/stdc++.h> using namespace std; int t; int n, m; string A, B; int f[405][405]; int main() { int i, j, k; cin >> t; while (t--) { cin >> A >> B; n = A.length(), m = B.length(); A = 0 + A; B = 0 + B; i = 1, j = 1; for (i = 1; i <= n; i++) { ...
#include <bits/stdc++.h> using namespace std; const int nmax = 1005; const int inf = 1 << 28; int n, m, A[nmax][nmax], B[nmax][nmax], C[nmax][nmax]; char a[nmax][nmax]; int dx[] = {-1, 0, 0, 1}; int dy[] = {0, -1, 1, 0}; deque<pair<int, int> > q; bitset<nmax> inq[nmax]; void go(int x, int y, int d[n...
#include <bits/stdc++.h> using namespace std; string solve1(string n) { string res(n.length(), 9 ); for (char c = 8 ; c >= 0 ; c--) { string t(n.length(), c); if (t >= n) res = t; } return res; } string solve2(string n) { string res = solve1(n); for (char a = 0 ; a <= 9 ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll t; cin >> t; while (t--) { ll cnt3, cnt2; cnt2 = cnt3 = 0; ll n; cin >> n; while (n % 2 == 0) { n = n / 2; cnt2++; } while (n % 3 == 0) { n = n / 3; ...
#include <bits/stdc++.h> using namespace std; int i, n, mx, mn, p1, p2, poz, poz1, poz2, k, mx1, mx2, m, mij, u, x, y, z, q; struct para { int x, y, z, ind; } a[100007]; int cmp(para k1, para k2) { if (k1.x > k2.x) return 0; else if (k1.x == k2.x) { if (k1.y > k2.y) return 0; ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b; scanf( %d%d , &a, &b); if (a < b) { for (int i = b + 1; i <= (a + b + 1); i++) printf( %d , i); for (int j = b; j >= 1; j--) printf( %d , j); } else { for (int i = 1; i <= a; i++) printf( %d , i); for (in...
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; void qread(int &x) { int neg = 1; x = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) neg = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = 10 * x + c - 0 , c = getchar(); x *= ne...
#include <bits/stdc++.h> using namespace std; const int N = 200; 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(); ...
#include <bits/stdc++.h> #pragma GCC optimize( -O3 ) using namespace std; const long long N = 1e6 + 5; void pairsort(long long a[], long long b[], long long n) { pair<long long, long long> pairt[n]; for (long long i = 0; i < n; i++) { pairt[i].first = a[i]; pairt[i].second = b[i]; } ...
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << n ; } 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; long long n, u, r; long long a[40], b[40], k[40], p[40]; long long maxx = (long long)1 << 63; long long eval() { long long val = 0; for (int i = 0; i < n; i++) { val += a[i] * k[i]; } return val; } void gen(int now, int last) { if (no...
#include <bits/stdc++.h> const int N = 1e7 + 5; int n, pos[N], ans1, ans2; long long ans = 1e14; int main() { scanf( %d , &n); for (int i = 1, x; i <= n; ++i) { scanf( %d , &x); if (pos[x]) { if (x < ans) ans1 = pos[x], ans2 = i, ans = x; } else pos[x] = i; } fo...
#include <bits/stdc++.h> using namespace std; int n; long long arr[200010], tot = 0; int main(void) { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; if (i > 0) tot += abs(arr[i] - arr[i - 1]); else tot += abs(arr[i]); } cout << tot; return 0; }
#include <bits/stdc++.h> using namespace std; void swap(long long int &x, long long int &y) { x = x ^ y; y = x ^ y; x = x ^ y; } template <typename T> void print(T a) { for (auto i = a.begin(); i != a.end(); i++) cout << *i << ; cout << endl; } bool isVowel(char c) { if (c == a...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int k = 0; int cnt = 0; int ans = 0; for (int i = 0; i < n; i++) { int p; cin >> p; if (p > k) cnt++; else cnt = 1; k = p; ans = max(cnt, ans); } cout << an...
#include <bits/stdc++.h> namespace solution {} namespace solution { class ISolution { public: virtual void init(){}; virtual bool input() { return false; }; virtual void output(){}; virtual int run() = 0; }; } // namespace solution namespace solution { using namespace std; const long...
#include <bits/stdc++.h> using namespace std; double x1, yy1, x2, y2, v, t, vx, vy, wx, wy, l, r, mid, x, y, dis; int main() { scanf( %lf%lf , &x1, &yy1); scanf( %lf%lf , &x2, &y2); scanf( %lf%lf , &v, &t); scanf( %lf%lf , &vx, &vy); scanf( %lf%lf , &wx, &wy); l = 0.0; r = 1e9; for...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 2; struct { int x; int last; string it; } a; struct kek { string w, e, r, t; }; map<char, int> bak; vector<string> st[N + 5][7], q; vector<pair<string, string> > be, en; vector<kek> ans; int n, m; string ins; cha...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 300009; void swap(char *p, char *q) { char temp = *p; *p = *q; *q = temp; return; } long long int powxy(long long int x, long long int y) { if (y == 0) return 1; if (y % 2 == 1) return (x * powxy(x, ...
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &a) { register int b = 1, c = getchar(); a = 0; for (; !isdigit(c); c = getchar()) if (c == 45) b *= -1; for (; isdigit(c); c = getchar()) a = (a << 3) + (a << 1) + c - 48; a *= b; } const int maxn = 105;...
#include<bits/stdc++.h> #define ll long long int using namespace std; int main() { int t; cin>>t; while(t--) { ll a, b, c; cin>>a>>b>>c; if((a+b+c)%9 == 0 && min(a, min(b,c)) >= (a+b+c)/9) cout<< YES <<endl; else cout<< NO <<endl; } }
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; if (k % 2 == 1) { cout << 1 << endl; return 0; } long long x = log2(k); long long y = pow(2, x) - k; while (y != 0) { x = log2(y); y = pow(2, x) - y; } cout << x + 1 ...
#include <bits/stdc++.h> using namespace std; const long long M = 1000000007; const long long N = 1e5; long long expo(long long x, long long y) { long long res = 1; x = x % M; while (y > 0) { if (y & 1) res = (res * x) % M; y = y >> 1; x = (x * x) % M; } return (res) % M; ...
#include <bits/stdc++.h> using namespace std; const int mod = (int)1e9 + 207; const int N = (int)1e6 + 2; long long n, m, s, t; long long cnt1[N], cnt2[N]; long long D1[N], D2[N]; vector<pair<long long, long long> > G1[N], G2[N]; vector<pair<long long, pair<long long, long long> > > edge; void solve1(...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, w = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) w = -1; c = getchar(); } while (c <= 9 && c >= 0 ) { x = (x << 1) + (x << 3) + c - 0 ; c = getchar(); } return w ...
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int maxn = 1e5 + 5; const int Inf = 1e9 + 7; int main() { int a, b; while (cin >> a >> b) { if (a == 0 && b == 0) { printf( NO n ); } else if (abs(a - b) <= 1) { printf( YES n ); } else ...
#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> using namespace std; const long long INF = 1e9; const long long MD = 1e9 + 7; const double pi = acos(-1); struct segmentTree { long long tl = 1, tr = (1ll << 21); segmentTree* left = nullptr; segmentTree* right = nullptr; long long val = 0; segmentTree(long long tl...
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void ran() { srand(chrono::steady_clock::now().time_since_epoch().count()); } long long get_rand() { long long a = rand(); long long b = rand(); return a * (RAND_MAX...