func_code_string
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; unsigned int dp[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, cnt = 0; cin >> n; string s; cin >> s; if (n % 2 == 1) { cout << 0 << n ; return 0; } dp[0] = 1; for (int ...
#include <bits/stdc++.h> long long arr[100005]; using namespace std; int main() { cin.tie(0); std::ios::sync_with_stdio(false); ; int n; cin >> n; for (int i = 0; i < n; cin >> arr[i++]) ; sort(arr, arr + n); cout << arr[n - 1] << ; for (int i = 1; i < n - 1; i++) { ...
#include <bits/stdc++.h> using namespace std; int main() { int j, t, n, m = 0, i; unsigned long long p = 0, q = 0; char a[1000001]; cin >> a; n = strlen(a); for (j = 0; j < n; j++) { if (a[j] == ^ ) { break; } } for (i = j - 1; i >= 0; i--) { if ((a[i] >= ...
#include <bits/stdc++.h> using namespace std; int n, m; double b[100005]; struct node { double he, cheng; } a[100005 * 4]; node merge(node a, node b) { node c; c.cheng = a.cheng * b.cheng; c.he = a.he + a.cheng * (b.he - 1); return c; } void build(int x, int l, int r) { if (l == ...
#include <bits/stdc++.h> using namespace std; const int N = 50010; const int inf = 1e9; inline int read() { int p = 0; int f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { p = p * 10 + c...
#include <bits/stdc++.h> using namespace std; const int Maxn = 14; const int INF = 0x3f3f3f3f; int N, M; vector<int> G[Maxn + 5]; void addedge(int u, int v) { G[u].push_back(v), G[v].push_back(u); } int f[(1 << Maxn) + 5]; pair<int, int> last[(1 << Maxn) + 5]; int lasts[(1 << Maxn) + 5]; bool go[Max...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int T, cnt = 0; cin >> T; while (T--) { long long int k, n, a, b; cin >> k >> n >> a >> b; k -= n * a; if (k > 0) cout << n << n ; else { k ...
#include <bits/stdc++.h> using namespace std; const int maxn = 510000; char s[maxn]; int n, maxtime; int house; bool ok(int need) { int time = 0, candy = need, total = house; int p = 0, q = 0; int i; for (i = 0; i < n; i++) { p += (s[i] == H ); q += (s[i] == S ); if (p ==...
#include <bits/stdc++.h> using namespace std; int f[505][505], g[505][505], a[505], b[505], id[505], xinyue, n, m, vis[505], ed; int cmp(int x, int y) { return b[x] < b[y]; } void dfs(int n, int m) { if (!n) return; if (g[n][m] == 1) vis[n] = 1, m--; dfs(n - 1, m); } int main() { scanf...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a[200], b[200]; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; int j; for (int i = 0; i < n; i++) { for (j = 1; j < n; j++) { if ((a[i] - b[0] + m) % m != (a[(...
#include <bits/stdc++.h> using namespace std; struct business { int num; int dif; }; bool compare(business x, business y) { return (x.dif < y.dif); } int main() { int n; int x; cin >> n; vector<business> A(n + 1); for (int i = 1; i <= n; i++) { cin >> x; A[i].num = i; ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; string s; cin >> n; cin >> s; vector<long long> cnts(60, 0); long long k = 0; for (long long i = 0; i < n; i++) { if (cnts[s[i] - 65] == 0) k++; cnts[s[i] - 65]++; } for (long long i = 0; i < 60; ...
#include <bits/stdc++.h> using namespace std; int main() { string Scale, left, right, rest_elements; int Slash; cin >> Scale; Slash = Scale.find( | ); left = Scale.substr(0, Slash); right = Scale.substr(Slash + 1, Scale.size()); cin >> rest_elements; for (auto i : rest_elements) ...
#include <bits/stdc++.h> using namespace std; const int MAX = 50050; vector<int> e[MAX]; vector<int> ee[MAX]; int c[MAX][555]; int vis[MAX]; int n, k; void solve(int indx) { c[indx][0] = 1; vis[indx] = 1; for (int i = 0; i < e[indx].size(); i++) { if (vis[e[indx][i]] == 1) continue; ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007ll; vector<int> adj[100005]; vector<pair<int, int> > grop[100005]; int now; int weig[100005]; int bu[100005]; int flag[100005]; pair<int, int> dfs(int u) { if (flag[u]) return make_pair(0, 0); flag[u] = 1; pair<i...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int C[1005][1005]; void build() { C[0][0] = 1; for (int i = 1; i <= 1000; i++) { C[i][0] = 1; for (int j = 1; j <= 1000; j++) { C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod; } } } int main() { ...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0; char ch = getchar(); bool f = 0; for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = 1; for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 0 ; return f ? -x : x; } void write(long long ...
#include <bits/stdc++.h> using namespace std; struct MCMF { using F = int; const static F INF = 0x3f3f3f3f; struct Edge { int v, bro; F cap, cost; Edge() {} Edge(int _v, int _bro, F _cap, F _cost) : v(_v), bro(_bro), cap(_cap), cost(_cost) {} }; vector<Edge> e; ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); ; int n; bool allSame = true; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (i > 0 and a[i] != a[i - 1]) allSame = false; } sort(a, a + n); if (n == 1) { ...
#include <bits/stdc++.h> using namespace std; long long t, n, k; int main() { ios_base::sync_with_stdio(0); cin >> t; while (t--) { cin >> n >> k; if (!n && !k) cout << 0 << n ; else cout << 1440 - n * 60 - k << n ; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k < 25) { cout << -1 << endl; } else { int r = 0, c = 0; for (int i = 5; i <= sqrt(k); i++) { if (k % i == 0) { r = i; c = k / i; break; } } if ...
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; int cnt = 0; if (n >= 5) { int x = n / 5; cnt += x; n -= x * 5; } if (n == 0) cout << cnt; else cout << cnt + 1; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; unordered_set<int> s; s.insert(s1); s.insert(s2); s.insert(s3); s.insert(s4); int si = s.size(); if (si == 4) cout << 0; else if (si == 3) cout << 1; el...
#include <bits/stdc++.h> using namespace std; bool sort_1(pair<int, int> &a, pair<int, int> &b) { return a.first < b.first; } bool sort_2(pair<int, int> &a, pair<int, int> &b) { return a.first > b.first; } int main() { int n, cnt = 0; scanf( %d , &n); vector<vector<pair<int, int>>> a(1001); for ...
#include <bits/stdc++.h> using namespace std; int main(void) { int h, l; std::cin >> h >> l; cout << fixed << setprecision(10); std::cout << (1.0 * l / (2.0 * h) * l - 1.0 * h / 2.0); return 0; }
#include <bits/stdc++.h> using namespace std; int q; long long r, n; vector<int> degp[1000005]; long long answ[1000005][21]; long long m = 1000000007; long long powmod(long long x, long long po) { if (po == 0) { return 1; } long long res = powmod(x, po / 2); res = (res * res) % m; ...
#include <bits/stdc++.h> using namespace std; struct no { int x, y, r; }; no A, B, b, a; int dist(no u, no v) { return (u.x - v.x) * (u.x - v.x) + (u.y - v.y) * (u.y - v.y); } bool contido(no v, no u) { if (u.r < v.r) return 0; if ((sqrt(dist(v, u)) + (double)((v.r)) - 1e-2 < (double)(u.r)...
#include <bits/stdc++.h> using namespace std; string s; int k; set<pair<string, int> > st; pair<string, int> tmp; int main() { cin >> s >> k; for (int i = 0; i < (int)s.length(); i++) { string q = ; q += s[i]; st.insert(make_pair(q, i)); } while (k > 1 && (int)st.size() >...
#include <bits/stdc++.h> int n, q, maxn; int a[200005]; std::vector<int> v[1901][105]; inline void merge(std::vector<int> &v1, std::vector<int> &v2) { if (v1.size() < v2.size()) std::swap(v1, v2); v1.insert(v1.end(), v2.begin(), v2.end()); v2.clear(); } inline void assign(int i, int x, int y, in...
#include <bits/stdc++.h> using namespace std; const int INF = INT_MAX; const signed long long int LINF = LLONG_MAX; const double EPS = 1e-9; const int MOD = 1000000007; const int MAXN = 100001; const int ALPH = 26; const int DALPH = 52; struct Node { int l, r, m; int minValue; Node *lson, ...
#include <bits/stdc++.h> using namespace std; int q, n, x; void f() { cin >> n; vector<int> v; for (int i = 0; i < n; i++) { cin >> x; v.push_back(x); } sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); int maxi = v.back(); for (int i = v.size() - ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, s; cin >> a >> b >> s; a < 0 ? a *= -1 : a *= 1; b < 0 ? b *= -1 : b *= 1; int l = min(a, b) * 2 + (max(a, b) - min(a, b)); cout << (l <= s ? l % 2 == s % 2 ? YES : NO : NO ); }
#include <bits/stdc++.h> using namespace std; long long n, k, x, ans; long long findX(long long R) { if (R < 0) return 0; return (R * (R + 1)) / 2; } int main() { scanf( %lld %lld , &n, &k); x = 0; for (int i = 1; i <= n - 1; i++) { if (findX(i - 1) <= k) x = i; } if (findX(x...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n, m, a, b, c, p[100010], cnt; bool vis[100010], ed; vector<pair<int, int> > V[100010]; int powmod(int x, int y) { int res = 1, cro = x; while (y) { if (y % 2) res = 1ll * res * cro % mod; cro = 1ll * cro * cro % ...
#include <bits/stdc++.h> using namespace std; int dp[10000]; int main() { int N, M; cin >> N >> M; int T; double D; int ans = 0; for (int i = 0; i < N; i++) { cin >> T >> D; dp[T - 1]++; for (int j = 0; j < T - 1; j++) dp[T - 1] = max(dp[T - 1], dp[j] + 1); } for ...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); if (n < 4) printf( NO n ); else if (n % 2) { printf( YES n ); printf( 1 + 5 = 6 n3 - 2 = 1 n4 * 6 = 24 n24 * 1 = 24 n ); for (int j = n; j > 6; j -= 2) { printf( %d - %d = 1 n , j, j - ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const double PI = acos(-1.0); const double E = exp(1.0); const int M = 200010; long long a[M]; long long ans[M][2]; int main() { int n, k, x; cin >> n >> k >> x; long long temp = 1; while (k--) temp *= x; ...
#include <bits/stdc++.h> using namespace std; long long k; vector<pair<long long, char>> aa; void print(long long a, char c) { a = min(a, k); if (a != 0) { aa.push_back({a, c}); } k -= a; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long lon...
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 10; int arr[MAX]; int n; vector<int> v[MAX]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { cin >> n; for (int i = 0; i < n; ++i) v[i].clear(); for (int i = 0; i <...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int i, a[n]; long long int c = 0, ans = 0; for (i = 0; i < n; i++) { cin >> a[i]; c += a[i]; } for (i = 1; i <= 5; i++) { if ((c + i) % (n + 1) != 1) ans++; } cout << ans << endl; re...
#include <bits/stdc++.h> using namespace std; template <typename _T> inline void read(_T &f) { f = 0; _T fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) { fu = -1; } c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << ...
#include <bits/stdc++.h> using namespace std; int n, c; vector<int> locck[567567]; const int S = 1 << 20; int tree[2 * S]; void loduj() { cin >> n >> c; int x, l; for (int i = 0; i < n; ++i) { cin >> l; for (int j = 0; j < l; ++j) { cin >> x; locck[i].push_back(x); ...
#include <bits/stdc++.h> using namespace std; const unsigned long long MOD = 4207849484; int main() { int n, m, i, g, h, j; char c; scanf( %d%d , &n, &m); vector<int> a(n + 1, 0), bl(n + 1, 0); for (int(i) = 0; (i) < (m); ++(i)) { getchar(); scanf( %c %d , &c, &g); if (c == ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; assert(n >= 1 && n <= 10000 && m >= 1 && m <= 10); if (n == m && (n == 1 || n == 2)) cout << n << endl; else { if (n == m) cout << n << endl; else { int t2 = 0, t1 = 0; i...
#include <bits/stdc++.h> using namespace std; const long long INF = 2e18 + 9; const long long MAXN = 1e6 + 7; const long long MAXN1 = 5e2 + 7; const long long MOD = 1e9 + 7; const long long ST = 157; const long long ST1 = 199; const long double EPS = 1e-9; const long long BLOCK = 138; void solve(); ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int t = 1; cin >> t; while (t--) { long long int p, q, x; cin >> p >> q; long long int b = 0; set<long long int> pf; long ...
#include <bits/stdc++.h> using namespace std; int main() { double v, d, l, g, r; cin >> l >> d >> v >> g >> r; double t; t = d / v; double k = 0; while (k <= t) { k += g; if (t < k) { t += (l - d) / v; cout << setprecision(8) << t; exit(0); } k...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const double eps = 0.000000001; double dist(double x, double y) { return x * x + y * y; } double xx, yy, v, t, x, y, r; int n; vector<pair<double, int> > vt; int main() { scanf( %lf %lf %lf %lf %d , &xx, &yy, &v, &t, &n); ...
#include <bits/stdc++.h> using namespace std; int nexto[120]; int ara[120]; int main() { std::ios_base::sync_with_stdio(false); ; int n; cin >> n; for (int i = 0; i <= n - 1; i++) { cin >> ara[i]; } int tt = n; for (int i = n - 1; i >= 0; i--) { nexto[i] = tt; i...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } string S; long long dp[3333333]; signed main() { for (long long i = 0; i...
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); int n; long long l, first, second; cin >> n >> l >> first >> second; vector<long long> a(n); map<long long, bool> flag; for (int i = 0; i < int(n); i++) { cin >> a[i]; flag[a[i]]...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template <class T> inline bool Min(T &a, T b) { return a > b ? (a = b, true) : false; } template <class T> inline bool Max(T &a, T b) { re...
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; int a[n], b[n]; map<pair<int, int>, int> mpa, mpb; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } for (int i = 0, j = n - 1; i < j; i++, j--) { ...
#include <bits/stdc++.h> int main() { int m = 0, i = 0, c[100], x, y, s1 = 0, s2 = 0, ans = 0; scanf( %d , &m); for (i = 0; i < m; i++) { scanf( %d , &c[i]); s1 += c[i]; } scanf( %d%d , &x, &y); for (i = 0; i < m; i++) { s1 -= c[i]; s2 += c[i]; if ((s1 >= x) && (s...
#include <bits/stdc++.h> int isprime(long long p) { int i; double max = sqrt(p); for (i = 2; i <= max; i++) if (p % i == 0) break; if (i > max && p != 1) return 1; return 0; } long long gcd(long long a, long long b) { long long i; for (i = a < b ? a : b; i > 0; i--) if ((a ...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } inline long long Max(long long x, long long y) { return x > y ? x : y; } inline long...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e9 + 9; const long long N = 500500; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long long T; cin >> T; while (T--) { long long n, k; cin >> n >> k; string...
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 0, flag = 0; int arr[100]; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] != arr[i + 1]) { flag = 1; } } if (flag == 0) { cout << ans << endl; return 0; } ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 5, Mod = 998244353; char buf[1 << 12], *pp1 = buf, *pp2 = buf, nc; int ny; inline char gc() { return pp1 == pp2 && (pp2 = (pp1 = buf) + fread(buf, 1, 1 << 12, stdin), pp1 == pp2) ? EOF : *...
#include <bits/stdc++.h> using namespace std; const int maxn = 111111; const double inf = 0.000001; const int INF = ~0U >> 1; const int mod = 1000000007; int n, a[maxn], m; int equal(double x, double y) { if (x - y >= -inf && x - y <= inf) return 0; else if (x - y > inf) return 1; ...
#include <bits/stdc++.h> using namespace std; const int M = 105; char ch[2][M]; int dp[M][4], mask[M], n, ans; void in() { scanf( %s%s , ch[0] + 1, ch[1] + 1); } void ac() { n = strlen(ch[0] + 1); for (int i = 1; i <= n; ++i) ch[0][i] == 0 ? (ch[1][i] == 0 ? mask[i] = 0 : mask[i] = 1) ...
#include <bits/stdc++.h> using namespace std; long long n, k; vector<vector<long long>> ft(12, vector<long long>(100005, 0)); void add(long long kk, long long ind, long long val) { while (ind <= n) { ft[kk][ind] += val; ind += ind & -ind; } } long long sum(long long kk, long long ind) { ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int n, S = 0; char x[2], s[MAXN]; int viv[MAXN]; bool use[MAXN]; int cqf() { int l = -1, r = -1; int ans = MAXN, sum = 0; while (true) { while (r <= n && sum < S) { r++; if (!viv[s[r]] && use[s[r]]) su...
#include <bits/stdc++.h> int main() { std::string input( ), answer( ), output( ); getline(std::cin, input); getline(std::cin, answer); int count[10] = {0}; char minNonZero( A ); for (int k = 0; k < input.size(); k++) { ++count[input[k] - 0 ]; if (input[k] > 0 && input[k] < mi...
#include <bits/stdc++.h> using namespace std; const int N = 105; int S[N], E[N], T[N], C[N]; int t[N], W[N]; int main() { int n, m; scanf( %d %d , &n, &m); int i; for (i = 1; i <= n; i++) { t[i] = 1006; W[i] = -1; } for (i = 1; i <= m; i++) { scanf( %d %d %d %d , &S[i...
#include <bits/stdc++.h> using namespace std; int n, m; long long l[200001], r[200001]; struct data { long long l, r, ans, num; bool operator<(const data &p) const { return r > p.r; } } a[300001]; priority_queue<data> q; bool cmp(data p, data q) { if (p.l == q.l) return p.num < q.num; retu...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f; long k = min(d, min(c, b)); long m = min(a, d); long cost = 0; if (e > f) { d = d - m; cost = m * e + min(d, min(c, b)) * f; } else { d = d - k; cos...
#include <bits/stdc++.h> using namespace std; int N, L, K; string s; int cnt[26]; string res[1000]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> L >> K; cin >> s; for (int i = 0; i < N * L; i++) cnt[s[i] - a ]++; int l = 0; int t = 0; while (l...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n > 2) cout << n - 2 << endl; else cout << 7 << endl; }
#include <bits/stdc++.h> using namespace std; long long int justgreater(long long int n) { long long int i; for (i = 1;; i++) if (i * (i + 1) / 2 > n) break; return i - 1; } int main() { long long int m, n, a[100009] = {0}, sum = 0, cnt = 0; cin >> m >> n; long long int up = justgr...
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1.0); long long n, maxl = 2e5; long long montonic(vector<long long> &b) { bool inc = true, dec = true; long long n = (long long)b.size(); for (long long i = 1; i < n; ++i) { if (b[i] <= b[i - 1]) { inc = false; ...
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const long long maxn = 1e6 + 10; int a[4], b[10] = {0, 1, 2, 0, 2, 1, 0}, c[4]; int check(int w) { int sum = 0; for (int i = 0; i < 3; i++) c[i] = a[i]; for (int i = w; i < 7; i++) { if (c[b[i]] == 0) break; --c[b[i...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; long long read() { long long s = 0; char c = getchar(), lc = + ; while (c < 0 || 9 < c) lc = c, c = getchar(); while ( 0 <= c && c <= 9 ) s = s * 10 + c - 0 , c = getchar(); return lc == - ? -s : s; } void...
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; int n; bool M[1005][1005]; int q; bool ans = 0; void setMatrix() { for (int i = 0; i < n; i++) if (M[i][i]) ans = !ans; } void CallEdit() { int i; scanf( %d , &i); ans = !ans; } void CallPuts() { printf(...
#include <bits/stdc++.h> using namespace std; const int maxn = 10000010; int p[maxn]; int main() { int i, j, st, a, n, maxi; long long ans = 0; scanf( %d%d , &a, &n); maxi = (int)(sqrt(a + n - 1) + 1e-7); for (i = 1; i <= maxi; i++) { st = (int)(a / (i * i) + 1e-7) * i * i; for (...
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n, m, c; cin >> n >> m >> c; for (int i = 1; i <= m; i++) { int x, ans; cin >> x; if (x <= c / 2) { for (int j = 1; j <= n; j++) { if (x < a[j] || a[j] == 0) { a[j] = x; ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; using namespace std; const long long INF = 1LL << 60; const double PI = acos(-1); using ll = long long; using P = array<ll, 2>; template <typename T> istream& operator>>(istream& i, vector<T>& v) { for (ll j = (0); j < (l...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); struct T { int id, v, c, l, r, sum, prev; void read(int ii) { id = ii; scanf( %d%d%d%d , &v, &c, &l, &r); } int total() { return c + l + r; } }; int n; map<int, vector<T> > gr; vector<int> ans; int re...
#include <bits/stdc++.h> using namespace std; template <typename T> inline string toString(T a) { ostringstream os( ); os << a; return os.str(); } template <typename T> inline long long toLong(T a) { long long res; istringstream os(a); os >> res; return res; } template <type...
#include <bits/stdc++.h> using namespace std; long long bigmod(long long x, int p) { long long res = 1; while (p) { if (p & 1) res = (res * x) % 998244353; x = (x * x) % 998244353; p >>= 1; } return res; } int main() { int n, m; cin >> n >> m; vector<long long> d(n)...
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265358979323846264338327950288419716939937510, EPS = 1e-9; const int MAX = 1 << 17; struct prav { long double a, b, c; }; pair<int, int> sred; long double Sq(long double x) { return x * x; } long double D...
#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; const int maxn = 5000 + 5; int n, k, v; int a[maxn]; bool f[maxn][maxn]; pair<int, int> fr[maxn][maxn]; bool u[maxn][maxn]; bool vis[maxn]; struct ex { int cnt, x, y; }; vector<ex> ans; vector<int> vec; int read() { int x; scanf( %d , &...
#include <bits/stdc++.h> using namespace std; char buffer[10]; bool query(int x, int y) { cout << x << << y << endl; cout.flush(); cin >> buffer; return (buffer[0] == w ); } const int Y = 100; bool get(int x) { return query(x, Y); } void answer(int l, int r) { cout << l << << ...
#include <bits/stdc++.h> using namespace std; const int N = 200010; int T, n, m, ans; char s[N], p[N]; int ne[N], len[N]; int main() { scanf( %s , s + 1); m = strlen(s + 1); cin >> T; while (T--) { scanf( %s , p + 1); n = strlen(p + 1); if (n == 1) continue; for (int ...
#include <bits/stdc++.h> using namespace std; int min_dist[3005][3005]; vector<int> furthest_out[3005]; vector<pair<int, int> > X; vector<pair<int, int> > furthest_in[3005]; vector<int> E[3005]; int n; void bfs(int source) { for (int j = 1; j <= n; j++) min_dist[source][j] = 1 << 30; min_dist[so...
#include <bits/stdc++.h> using namespace std; namespace myrand { mt19937 mt(chrono::system_clock::now().time_since_epoch() / chrono::microseconds(1)); long long Int(long long l, long long r) { return uniform_int_distribution<long long>(l, r)(mt); } } // namespace myrand using namespace m...
#include <bits/stdc++.h> using namespace std; int n, k[110], v[110][110], t[110][110], res, s, i, j; int ktra(long long &s1, long long &s2, long long f1, long long f2, int &p) { int res = ((s1 - s2) * (f1 - f2) < 0) || ((s1 == s2) && (p * (f1 - f2) < 0)); if (f1 > f2) p = 1; if (f1 < f2) p = -1; s...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int dp[300000]; int main() { int r, g; cin >> r >> g; int h; int low = 0, high = 1000; while (low <= high) { int mid = (low + high) / 2; if (mid * (mid + 1) / 2 <= r + g) h = mid, low = mid + 1; ...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 50, B = 1111; const long double inf = 5e18; const long double eps = 1e-12; int n, q, a[N], b[N], f[N], blo[N], sq, num, ll[N], rr[N], dfn[N], dfm[N], clk, idfn[N]; vector<int> v[N]; int read() { int x = 0, c, f = 1; while (!is...
#include <bits/stdc++.h> using namespace std; int main() { int n, A[100]; cin >> n; int aux = 0, ans = 15; while (n--) { int t; cin >> t; if (t <= ans) ans = t + 15; else break; } if (ans > 90) ans = 90; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 5; const long long INF = 1e9 + 7; long long n, ans = INF; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> s; long long n = s.size(); for (long long mask = 1; mask < ...
#include <bits/stdc++.h> using namespace std; const long long INF = 2000000000000000001, mod = 1000000007; long long toi(string s) { long long a; istringstream in(s); in >> a; return a; } int main() { string s; cin >> s; for (int i = 1; i < s.length(); i++) if (s[i] == s[i - ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t = 1; while (t--) { long long int n, i, arr[200005]; string s; cin >> n; cin >> s; long long int ans = 0; for (i = 0; i < n; i++) {...
#include <bits/stdc++.h> using namespace std; int n; long long k; vector<vector<long long>> operator*(vector<vector<long long>> a, vector<vector<long long>> b) { vector<vector<long long>> ans(n, vector<long long>(n)); for (int i = 0; i < n; i++) { for (int j =...
#include <bits/stdc++.h> using namespace std; int a, b, n, i, x, y, v; double min1, ans, k; int main() { cin >> a >> b; cin >> n; min1 = 999999; for (i = 1; i <= n; i++) { cin >> x >> y >> v; k = (x - a) * (x - a) + (y - b) * (y - b); ans = sqrt(k) / v; min1 = min(min1, a...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } long long gcd(long long a, long long b...
#include <bits/stdc++.h> using namespace std; int main() { int i, n, k, j; cin >> n >> k; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) if (i == j) cout << k << ; else cout << 0 << ; cout << n ; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int t; cin >> t; while (t--) { int c, d; cin >> c >> d; int temp = abs(c - d); if (temp % 2) { cout << -1 << endl; continue; ...
#include <bits/stdc++.h> using namespace std; const long long N = 305; long long n, k; long long a[N][N], rows[N], cols[N]; long long sqr(long long x) { return x * x; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; cin >> t; while (t--) { ...