func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int N, Q, T; bool matr[300][300]; int amounts[300]; vector<int> chains[300]; bool was[300]; int sorted[300]; int s = 0; long long mas[2][100010]; void srt(int v) { was[v] = true; for (int i = 0; i < N; i++) if (!was[i] && matr[v][i]) srt(i)... |
#include <bits/stdc++.h> using namespace std; map<long long int, vector<long long int>> v; map<long long int, long long int> vis; void dfs(long long int n) { long long int i; cout << n << ; vis[n] = 1; for (i = 0; i < v[n].size(); i++) { if (!vis[v[n][i]]) { vis[v[n][i]] = 1; ... |
#include <bits/stdc++.h> using namespace std; int n, m, x, y; int p[100010], q[100010]; vector<int> t[100010], v[100010]; int mn[100010]; bool flag[100010]; inline int dist(int x, int y) { if (p[x] - q[y] >= 0) return p[x] - q[y]; else return q[y] - p[x]; } int main() { scanf( ... |
#include <bits/stdc++.h> using namespace std; const double Pi = acos(-1.0); const int Inf = 0x3f3f3f3f; const int MAXN = 2e5 + 10; inline int read() { register int x = 0, f = 1, ch = getchar(); while (!isdigit(ch)) f = ch == - ? -1 : 1, ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 48, c... |
#include <bits/stdc++.h> using namespace std; int mx[4] = {0, 0, 1, -1}; int my[4] = {-1, 1, 0, 0}; int n, m, cnt, cou; char a[55][55]; bool used[55][55]; bool good(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < m); } void dfs(int i, int j) { used[i][j] = true; cou++; for (int k = ... |
#include <bits/stdc++.h> using namespace std; const int INF = 2e9 + 1; const long long INFLL = 1e18 + 1; struct Graph { struct edge { int c, f, link, to, ind; int c2 = 0; edge() {} edge(int c, int f, int link, int to, int ind) : c(c), f(f), link(link), to(to), ind(ind) {} ... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T abs(T a) { return a > 0 ? a : -a; } int n; int m; int main() { int last; cin >> n >> last; if (n == 1) { if (last == 1) { cout << 0 << endl << T << endl; } else { cout << IMPOSSIBLE <<... |
#include <bits/stdc++.h> using namespace std; const int RLEN = 1 << 18 | 1; inline char nc() { static char ibuf[RLEN], *ib, *ob; (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin)); return (ib == ob) ? -1 : *ib++; } inline int rd() { char ch = nc(); int i = 0, f = 1; while (... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 24; int f[1 << MAXN], a[MAXN], N; vector<pair<int, int> > p[MAXN]; int dp(int state, int pos) { if (f[state] != -1) return f[state]; if (state == 1) return 1; if (p[pos].size() == 0) { f[state] = 0x3F3F3F3F; return f[state]... |
#include <bits/stdc++.h> using namespace std; string A, B; int has[10]; string res; void Create(int from) { for (int i = 0; i < 10; i++) { for (int j = 0; j < has[i]; j++) { res[from++] = i + 0 ; } } } int main() { cin >> A >> B; int st = 0; for (int i = 0; i < A.l... |
#include <bits/stdc++.h> using namespace std; mt19937 rnd(chrono::system_clock::now().time_since_epoch().count()); const int MAXN = 200100, MAXK = 25; const long long MOD = 998244353; int st[MAXN][MAXK]; int n, q; int a[MAXN]; pair<int, int> lastP[MAXN]; int lg[MAXN]; void buildST() { for (int j... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 1; long long n, a[maxn], b[maxn], f1, f2; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (long long i = 0; i < n; ++i) cin >> a[i]; for (long long i = 0; i < n; ++i) cin >> b[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; int n, m, k, p, q, d[maxn][maxn]; bool vis[maxn][maxn]; bool solve(int x, int y, int r) { for (int i = max(1, x - r); i <= min(n, x + r); i++) { int tmp = r - abs(i - x); if (y - tmp >= 1 && !vis[i][y - tmp]) { p = i,... |
#include <bits/stdc++.h> using namespace std; int pro(int *a, int *b, int t, int s) { int k = 0; for (int i = 1; i < t; i++) { if (b[i] != s) { return 2; } if (b[i] == 0) { k++; } } if (k == (t - 1)) { return 3; } return 1; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int maxn = 1e6 + 5; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const double eps = 1e-8; const double PI = acos(-1.0); long long dp[1005][105]; long long d, res, tot = 9, tmp = 1; int main() { ... |
#include <bits/stdc++.h> #define PI 3.141592653589793238462643383279 #define EXP 2.71828182846 #define ll long long using namespace std; double log2(double n) { return log(n)/log(2); } double ln(double n) { return log(n)/log(EXP); } void Heap(signed long long int A[],sig... |
#include <bits/stdc++.h> using namespace std; unsigned long long int ncr(unsigned long long int a, unsigned long long int b) { unsigned long long int ans = 1; for (unsigned long long int i = 1; i <= b; i++) { ans *= (a - i + 1); } for (unsigned long long int i = 1; i <= b; i++) { ans /= ... |
#include <bits/stdc++.h> using namespace std; const int block_size = 320; const long long mod = 1e9 + 7; const long long inf = 1e9 + 7; const long double eps = 1e-9; const double PI = atan(1) * 4; template <typename T> inline int sign(const T &a) { if (a < 0) return -1; if (a > 0) return 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t = 1; ios_base::sync_with_stdio(false); cin.tie(NULL); while (t--) { long long int i, j, k, m, n, ans = 0; cin >> n >> k; if (n >= k) n = k - 1; if (k - n >= n) { cout << 0; return 0; ... |
#include <bits/stdc++.h> using namespace std; long long sum(long long n) { return (n * (n - 1)) / 2; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int arr[n + 1]; for (int i = 0; i < n; i++) cin >> arr[i]; pair<int, int> b[n + 1]; for (int i = 0; ... |
#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; } struct TPoint { long long x, y; TPoint(long long x, long long y) : x(x), y(y) {}... |
#include <bits/stdc++.h> using namespace std; int nextInt() { char c; int i; for (c = getchar(); c < 0 || c > 9 ; c = getchar()) ; for (i = c - 0 , c = getchar(); c >= 0 && c <= 9 ; i = i * 10 + c - 0 , c = getchar()) ; return i; } const int inf = 1 << 30; stru... |
#include <bits/stdc++.h> using namespace std; const int N = 1000, M = 2000; int head[N + 10], ver[M + 10], nxt[M + 10], tot = 0; void add(int x, int y) { ver[++tot] = y; nxt[tot] = head[x]; head[x] = tot; } int col[N + 10], cnt = 0; void dfs(int x) { col[x] = cnt; for (int i = head[x];... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int n, a, b, t; pair<int, int> m[MAXN]; bool ans[MAXN]; int main() { cin >> n >> a >> b; for (int i = 0; i < n; i++) { scanf( %d , &m[i].first); m[i].second = i; if (a < b) m[i].second *= -1; } if (a != ... |
#include <bits/stdc++.h> using namespace std; template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } struct matrix { vector<vector<long long> > a; int m, n; matrix(int _m, int _n) { m = _m; ... |
#include <bits/stdc++.h> using namespace std; struct node { int to, u, w; } edge[200000]; struct data { int x, y, w, d; } v[200010]; int k = 1, f[200000], low[200010], dfu[200010], n, m, ans[200010], head[200010], cnt, l; bool vis[200010]; void add(int x, int y, int z) { edge[k].u = y;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, t = 0, a[30005]; cin >> n >> k; for (int i = 1; i < n; i++) cin >> a[i]; for (t = 1; t < k; t += a[t]) ; cout << (t == k ? YES : NO ); } |
#include <bits/stdc++.h> using namespace std; void Speed() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } struct xi { long long a, b; }; const int XS = 1e3 + 12; const int second = 1e4 + 12; const int M = 1e5 + 12; const int L = 1e6 + 12; const int XL = 1e7 + 12; const ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000003ll; long long npow[64]; long long fast_pow(long long n, long long e) { if (e == 0) return 1ll; long long tmp = fast_pow(n, e / 2ll); tmp = (tmp * tmp) % MOD; if (e & 1ll) return (tmp * n) % MOD; return tmp; } int ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long su = 0, f = 1; char c = getchar(); for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) f = -1; for (; c >= 0 && c <= 9 ; c = getchar()) su = su * 10 + c - 0 ; return su * f; } inline void wr(long ... |
#include <bits/stdc++.h> using namespace std; int main() { int t , x , k; cin >> t; while(t--) { cin >> x; k = (int)(sqrt(8 * x + 1)) / 2; if((k * (k + 1) - 2 * x)!=2 && (k * (k + 1) - 2 * x) >= 0) cout << k << n ; ... |
#include <bits/stdc++.h> using namespace std; const int LG = 18; const int MX_N = 100005; int n, q; struct LowestCommonAncestor { int clk, par[MX_N][LG]; int st[MX_N], h[MX_N]; vector<int> G[MX_N]; void addEdge(int u, int v) { G[u].push_back(v); G[v].push_back(u); } void df... |
#include <bits/stdc++.h> using namespace std; int n; int a[1007]; struct Node { int pos; int val; }; Node res[1007]; int gcd(int a, int b) { int m = std::max(a, b); int n = std::min(a, b); if (m % n == 0) return n; else return gcd(n, m % n); } bool is_co_prim(int a,... |
#include <bits/stdc++.h> using namespace std; int n, t; bool ans = 0; vector<int> port; vector<bool> f; void dfs(int i) { if (i == t - 1) { ans = 1; return; } f[i] = 1; if (i != n - 1 && !f[i + port[i]]) dfs(i + port[i]); } int main() { cin >> n >> t; port.resize(n - ... |
#include <bits/stdc++.h> #pragma GCC optimize( omit-frame-pointer ) #pragma GCC optimize( unroll-loops ) const int MAXINT = 2147483640; const long long MAXLL = 9223372036854775800LL; const long long MAXN = 1000000; const double pi = 3.1415926535897932384626433832795; using namespace std; int kol[300000]... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(false); int n; cin >> n; int pass = 0, ans = 0; while (n) { ans += n; ans += (pass * (n - 1)); pass++; --n; } cout << ans; return 0; } |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string a; cin >> n >> a; stack<char> q; int m = 1; int len = 0; int he = -1; for (int i = 0; i < n; i++) { if (... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2000 + 10; const int MOD = (int)(1e9) + 7; vector<int> adj[MAXN]; int a[MAXN], f[MAXN]; bool visited[MAXN]; int d, n; void DFS(int u, int root) { visited[u] = true; f[u] = 1; for (int i = 0; i < adj[u].size(); i++) { int v ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int INF = 1000000007; const int MOD = 1000000007; const int MAXN = 100055; int dx[] = {2, 1, -1, -2, -1, 1, 2, 1, -1}; int dy[] = {0, 2, 2, 0, -2, -2, 0, 2, 2}; int main() { long long n; while (cin >> n) { n++; ... |
#include <bits/stdc++.h> using namespace std; struct Node { int s, e, d; }; int a[1010]; int in[1010]; int out[1010]; int vis[1010]; int d[1010][1010]; int n, p; int cnt = 0; int ans; Node node[1010]; void dfs(int x) { if (!out[x]) { node[cnt].e = x; node[cnt].d = ans; ... |
#include <bits/stdc++.h> template <class T> bool setmax(T &_a, T _b) { if (_b > _a) { _a = _b; return true; } return false; } template <class T> bool setmin(T &_a, T _b) { if (_b < _a) { _a = _b; return true; } return false; } const int N = 200010; int a[N... |
#include <bits/stdc++.h> const int MAXN = 2e5 + 5; using namespace std; struct info { int coord; bool taxi; } v[MAXN]; int n, m, dist[MAXN], man[MAXN], fr[MAXN]; int main() { cin >> n >> m; for (int i = 1; i <= n + m; i++) { cin >> v[i].coord; dist[i] = 2e9; } for (int i ... |
#include <bits/stdc++.h> const int MAX = 1000010; const long long MOD = 1e9 + 7; const int INF = 0x3f3f3f3f; const long long LLINF = 0x3f3f3f3f3f3f3f3f; const long double EPS = 1e-6; const long double PI = acos(-1.0); using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NU... |
#include <bits/stdc++.h> using namespace std; inline int rd() { register int ans = 0, flag = 1; register char c = getchar(); for (; c > 9 || c < 0 ; c = getchar()) if (c == - ) flag = -1; for (; c >= 0 && c <= 9 ; c = getchar()) ans = ans * 10 - 0 + c; return ans * flag; } con... |
#include <bits/stdc++.h> using namespace std; const long double PI = 3.1415926535897932384626433832795; const long double EPS = 1e-11; int n, m, first, second; bool a[110][110]; pair<long double, int> find_k(int s, int e) { queue<int> q; int ur[110]; long double kr[110]; memset(ur, 0xFF, siz... |
#include <bits/stdc++.h> using namespace std; long long d[40000]; char s[4005]; void input() { int i, j, len, a, sum; long long res; scanf( %d %s , &a, &s); len = strlen(s); for ((i) = 0; (i) < (len); (i)++) { sum = 0; for ((j) = (i); (j) <= (len - 1); (j)++) { sum += s[j... |
#include <bits/stdc++.h> using namespace std; int n, a[1000005], m, M, N, sum; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) scanf( %d , a + i), M = max(a[i], M); for (int i = 1; i <= n; ++i) sum += M - a[i]; if (m <= sum) printf( %d %d n , M, M + m); else printf... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const long long INF = 1000 * 1000 * 1000 + 7; const long long LINF = INF * (long long)INF; const int MAX = 100 + 47; int A[MAX]; vector<int> B; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> ... |
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); int tc; std::cin >> tc; while (tc--) { long long x, y; std::cin >> x >> y; if ((x == 1 || x == 3) && y > x) { std::cout << NO n ; } else ... |
#include <bits/stdc++.h> int main(void) { int n; int k; int M; scanf( %d%d%d , &n, &k, &M); int number[45][45] = {0}; for (int i = 0; i < k; i++) { int temp; scanf( %d , &temp); for (int j = 0; j < n; j++) { number[j][i] = temp; } } for (int i = 0; i < n... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; if (n % m == 0) cout << YES << endl; else cout << NO << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) { cout << Mahmoud n ; } else { cout << Ehab n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<bool> hero(n); vector<long long> v(n); vector<int> pos_num(n); for (int i = 0; i < m; i++) { int s, h; cin >> s >> h; hero[--s] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, INF = 1e9 + 7; int n, a[N]; bool used[N]; int main() { int q; cin >> q; while (q--) { cin >> n; for (int i = 1; i <= n * 2; i++) { cin >> a[i]; used[i] = 0; } vector<pair<int, int> > vec; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, q, m; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); cin >> q; while (q--) { cin >> m; cout << upper_bound(a, a + n, m) - a << endl; } } |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long t; cin >> t; while (t--) { long long a, b; cin >> a >> b; cout << min(max(2 * a, b) * max(2 * a, b), max(a, 2 * b) * max(a, 2 * b)) << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int a, b; int k; int main() { cin >> a >> b; if (b > a) { cout << -1 n ; return 0; } if (a == b) { cout << a << endl; return 0; } k = a / b; if (k & 1) k++; double ans = (a + b) * 1.0 / k; printf( %.10f n ... |
#include <bits/stdc++.h> using namespace std; int cas = 1, T; int n, a[10010], b[10010]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + 1 + n); int l = 1, r = (n + 1) / 2 + 1; for (int i = 1; i <= n; i++) { if (i % 2 == 1) printf(... |
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; } int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; } int mul(int a, int b) { return 1ll * a * b % Mod; } void Add(int &a, int b) { a = add(a, b); } void ... |
#include <bits/stdc++.h> using namespace std; void showvec(vector<long long> &arr); inline void solve() { long long n; cin >> n; vector<long long> arr(n); for (long long i = 0; i < n; i++) { cin >> arr[i]; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long int i, l, n, m, t; cin >> n >> m; long int a[m + 1]; for (i = 0; i < m; i++) cin >> a[i]; sort(a, a + m); bool flag = true; if (a[0] == 1) flag = false; if (a[m - ... |
#include <bits/stdc++.h> using namespace std; struct my { int num; int dmg; } dmg[10010]; int mx, reg, rg[10010], n; int flag[10010]; vector<pair<int, int> > v; bool operator<(my a, my b) { if (a.dmg > b.dmg) return 1; return 0; } int main() { cin >> n >> mx >> reg; for (int i ... |
#include <bits/stdc++.h> bool isvowel(char s) { if (s == a || s == A || s == e || s == E || s == i || s == I || s == o || s == O || s == u || s == U ) return true; else return false; } long long fact(long long n) { long long mul = 1; for (long long i = 1; i <... |
#include <bits/stdc++.h> using namespace std; mt19937 mt_rand( chrono::high_resolution_clock::now().time_since_epoch().count()); const int INF = 2e9; const long long ML = 4e18; long long Pow(long long x, int p) { long long res = 1; while (p) { if (p & 1) res = (res * x) % 998244353; ... |
#include <bits/stdc++.h> const long long MOD = 1e9 + 7; const long long MAXN = 1e6 + 1; using namespace std; long long readInt() { bool minus1 = false; long long result = 0; char ch; ch = getchar(); while (true) { if (ch == - ) break; if (ch >= 0 && ch <= 9 ) break; ch ... |
#include <bits/stdc++.h> const long long MAX_N = 3e5 + 10; const long long MOD = 1e9 + 9; using namespace std; vector<int> g1[MAX_N]; vector<int> g[MAX_N]; vector<int> current; int p[MAX_N]; int mark[MAX_N]; int d[MAX_N]; int h[MAX_N]; int n, m, k; void rt(int v) { mark[v]++; for (auto x... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int N = 100005; int a[N * 2], ans[N]; stack<int> s; int main() { int n; scanf( %d , &n); for (int i = 1; i <= 2 * n; i++) { char op; scanf( %c , &op); if (op == + ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int N = 1e5 + 10; int n, m; int main() { scanf( %d%d , &n, &m); long long sum1 = 0, sum2 = 0; int t = n - n / 2; for (int i = 1; i <= n; i++) { sum1 += i - 1; sum2 += ab... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; int w[55]; int n; int num_teams(int s) { map<int, int> cnt; for (int i = 0; i < n; ++i) { ++cnt[w[i]]; } int teams = 0; for (int i = 0; i < n; ++i) { int wt = w[i]; if (c... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int q = 0; q < t; q++) { long long n, m; cin >> n >> m; if (n % m == 0) cout << YES << endl; else cout << NO << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int MAX = 1005; int a[MAX][MAX], u[MAX][MAX], d[MAX][MAX], l[MAX][MAX], r[MAX][MAX]; int main() { int n, m, q; scanf( %d %d %d , &n, &m, &q); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf( %d , &a[i][j]); for (int j = 0; j... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 5; const long long mod = 1e9 + 7; const int inf = 0x7fffffff; int a[maxn]; int main() { int t; cin >> t; while (t--) { int r, g, b, w; cin >> r >> g >> b >> w; int f = 0; if (r % 2 == 1) f++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n, sum = 0, maxi, mini, start, end; ; cin >> a >> b >> n; mini = min(a, b); maxi = max(a, b); if (n <= min(a, b)) { cout << n + 1; } else { if (mini + maxi >= n) { int k = n - maxi; if (k < 0... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; int main() { v.push_back(1); long long x, i, xx = 10, c = 2, cc = 0; while (1) { i = 1; cc = c - 1; xx = 0; while (i <= c) { xx = xx + pow(2, cc); cc++; i++; } c++; if (... |
#include <bits/stdc++.h> const int d = 998244353; using namespace std; int main() { int n, m, k; cin >> n >> m >> k; vector<vector<long long int>> t(n + 1); vector<long long int> init(k + 1, 0); for (int i = 0; i <= n; i++) { t[i] = init; } t[1][0] = m; t[1][1] = 0; for (... |
#include <bits/stdc++.h> static const int MAXLEN = 1e6 + 12; int len = 0; char s[MAXLEN]; char *tokens[MAXLEN]; int token_ct = 0; int max_depth = 0; std::vector<char *> nested[MAXLEN]; int parse_comment_recursive(int start_token, int level) { if (max_depth < level) max_depth = level; nested[leve... |
#include <bits/stdc++.h> using namespace std; const int N = 0; int n, k, x; string s; vector<int> v; int main() { int a, b, c, d, e, f; int cnt = 0; scanf( %d%d%d%d%d%d , &a, &b, &c, &d, &e, &f); if (a == d) cnt++; if (b == e) cnt++; if (c == f) cnt++; if (cnt >= 1) { print... |
#include <bits/stdc++.h> char s[100100]; int n, ans = 1, tmp; int main() { scanf( %d %s , &n, s); for (int i = 1; i < n; i++) if (s[i] != s[i - 1]) ans++; else tmp++; if (tmp) ans++; if (tmp > 1) ans++; printf( %d n , ans); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if (a > b) { if (a % 2 == b % 2) cout << 1 << endl; else cout << 2 << endl; } else if (a < b) { if (a % 2 == b % 2) ... |
#include <bits/stdc++.h> using namespace std; int n; int keep[201]; int tt[201]; int first[201]; int main() { while (cin >> n) { n *= 2; int sum = 0, n1 = 0, n2 = 0, s1 = 0, s2 = 0; memset(keep, 0, sizeof(keep)); memset(first, 0, sizeof(first)); for (int i = 0; i < n; i++) ... |
#include <bits/stdc++.h> template <typename T> struct ScanfSpecifier {}; template <> struct ScanfSpecifier<char*> { static constexpr const char* value = %s ; }; template <> struct ScanfSpecifier<int> { static constexpr const char* value = %d ; }; template <> struct ScanfSpecifier<double> {... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; char second[N]; long long x, y, xx, yy; int n; bool check(long long days) { long long px = x, py = y; for (int i = 0; i < n; i++) { long long mult = days / n; if (i < (days % n)) mult++; if (second[i] == U ) py ... |
#include <bits/stdc++.h> using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, x, y; cin >> n; vector<pair<long long, long long>> a, b; for (long long i = 0; i < n; i++) { cin >> x >> y; a.push_back(make_pair(x, y)); } for (lo... |
#include <bits/stdc++.h> using namespace std; int main() { int a = 2, x; cin >> x; cout << a; for (int i = 2; i < x; i++) { a += i; if (a > x) { a -= x; } cout << << a; } cout << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int a[1024], f[10010]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, l = INT_MAX, r = INT_MIN, cnt = 0, src, dst; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; ++f[a[i]]; } for (int i = 0; i < 10001; +... |
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; const int MM = 998244353; const long double PI = acos(-1); long long power(long long b, long long e, long long m) { if (e == 0) return 1; if (e & 1) return b * power(b * b % m, e / 2, m) % m; return power(b * b % m, e / 2, m);... |
#include <bits/stdc++.h> using namespace std; int const N = 1e5 + 5; int di[] = {1, 1, -1, -1}; int dj[] = {1, -1, 1, -1}; long long n, k; long long solv() { long long st = 0, ed = k, ans; while (st <= ed) { long long x = (k * (k + 1)) / 2; long long mid = (st + ed) / 2; long long ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2) { cout << black << endl; } else { cout << white << n1 2 n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 300010; int t, n, x[N], y[N]; long long a[N], val[N]; int main() { cin >> t; while (t--) { scanf( %d , &n); long long sum = 0; for (int i = 1; i <= n; ++i) { scanf( %lld , a + i); sum += a[i]; } i... |
#include <bits/stdc++.h> using namespace std; int t, n, i, x, y, best, w, cw, rt, a[200200]; vector<int> g[200200]; bool all; void dfs(int i, int p, int cur, int dst) { if (dst > best) { best = dst; cw = cur; w = i; } for (int j : g[i]) if (j != p) { dfs(j, i, ((a[j... |
#include <bits/stdc++.h> using namespace std; string a, b; int nex[1000006], f1[1000006], f2[1000006]; long long xa[1000006], xb[1000006], mu[1000006]; const long long base = 1000000007; int main() { getline(cin, a); getline(cin, b); if (a.length() != b.length()) { cout << -1 -1 ; r... |
#include <bits/stdc++.h> int main() { int64_t l; int64_t p, q; double x, w; std::cin >> l; std::cin >> p >> q; w = (q + p); x = l * p / w; std::cout << x; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[105]; for (int i = 0; i < n; i++) { cin >> a[i]; } a[n] = a[0]; int k; int minn = 10005; for (int i = 1; i <= n; i++) { if (abs(a[i] - a[i - 1]) < minn) { minn = abs(a[i] - a[i -... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; long long int n, x, y, b, a[3]; int main() { long long int x, y; cin >> x >> y; long long int a = 0; while (true) { if (a % 2 == 0) { if (x >= 2 && y >= 2) { x -= 2; y -= 2; } else { ... |
#include <bits/stdc++.h> using namespace std; inline int ci() { register char ch; int f = 1; while (!isdigit(ch = getchar())) f = ch == - ? -1 : 1; register int x = ch ^ 0 ; while (isdigit(ch = getchar())) x = (x * 10) + (ch ^ 0 ); return f * x; } enum { N = 100024 }; int a[N]; i... |
#include <bits/stdc++.h> using namespace std; struct Dish { int ind; int cost; int cnt; }; int n; bool dishComp(Dish a, Dish b) { if (a.cost == b.cost) { return a.ind < b.ind; } return a.cost < b.cost; } int main() { int m, a, c; cin >> n >> m; vector<Dish> dishes... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 9; int seg[MAX * 4][2], n, k, a, b, q, ar[MAX]; void upd(int x, int s = 0, int e = n, int id = 0) { if (e - s == 1) { seg[id][0] = min(ar[s], a), seg[id][1] = min(ar[s], b); return; } int mid = s + e >> 1; if (x < mi... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; if (a == b) cout << a << endl; else cout << 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { while (b) { a %= b; swap(a, b); } return a; } int main() { int n; scanf( %d , &n); vector<int> a; int r2 = 0; int ans; int prev = 0; long long res = 0; int pr2 = 0; for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; struct Interval { int start, end; }; bool compare(Interval i1, Interval i2) { return (i1.start < i2.start); } vector<long long int> factors; void Divisors(long long int n) { for (long long int i = 1; i <= sqrt(n); i++) { if (n % i == 0) { i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.