func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e6 + 7; const long long mod = 1e9 + 7; const long long INF = 3e18 + 315; vector<pair<long long, long long> > va, vb; long long n, s, ans, na, nb, ta, tb; int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ci... |
#include <bits/stdc++.h> using namespace std; const int MAX = 10001; void solve() {} int main() { int a, b, c; while (cin >> a >> b >> c) { int t = a * c; for (int i = 0; i <= 1005 * 1005; i++) { if (b * i + c * b >= a * c) { cout << i << endl; break; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[200007]; map<int, bool> vis; queue<int> q; for (int i = 1; i <= n; i++) { cin >> arr[i]; if (vis[arr[i]]) continue; vis[arr[i]] = true; if (q.size() == k) { vis[q.front... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; int n, m, Q, a[300006][2], fa[300006], dep[300006], siz[300006], b[300006], D; bool vis[300006]; map<int, int> mp[300006]; vector<int> v[300006], s[300006]; const double pi = acos(-1.0); void df5(int te, int la) { vis[te] = 1; ... |
#include <bits/stdc++.h> int main() { using namespace std; int c, m, i; cin >> c >> m; int a = 0; for (i = 1; i <= 9; i++) { if (i * c % 10 == 0) { cout << i; break; } if (c == m) { cout << i; break; } if (i * c % 10 == m) { cou... |
#include <bits/stdc++.h> using namespace std; const long long mx = 105; const long long mod = 998244353; vector<vector<int>> adj; void solve() { long long n, i, j, k; cin >> n; long long a[n]; for (i = 0; i < n; i++) cin >> a[i]; long long res = 0, su = 0; for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; scanf( %I64d %I64d , &a, &b); long long t = 0; while (b) { t *= 10; t += b % 10; b /= 10; } printf( %I64d n , a + t); return 0; } |
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1); const long long int mod = 1000000007; const double epsilon = 1e-9; template <class T> ostream &operator<<(ostream &out, vector<T> &A) { for (auto x : A) out << x << ; return out; } template <class T> ostream &ope... |
#include <bits/stdc++.h> using namespace std; int d, n, m, b[200005]; int mn[200005 << 2]; long long ans; struct node { int x; long long p; bool operator<(const node &a) const { return x < a.x; } } a[200005]; int check(int x, int y) { return a[x].p < a[y].p ? x : y; } void build(int l, int r... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, s = 0, s2 = 0; cin >> n; char a[n]; cin >> a; for (i = 0; i < n; i++) { if (a[i] == 0 ) s++; else s2++; } if (s2 > 0) cout << 1 ; while (s--) cout << 0 ; return 0; } |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 1e5 + 1; const long long INF = -1e17; long long n; long long ans, cnt, mx = 0; string s; int main() { ios_base::sync_with_stdio(false); cin >> n; getline(cin, s); getline(cin, s); for (lo... |
#include <bits/stdc++.h> using namespace std; const int N = 2000010; vector<int> freqs; int t, n, k, a[N], f[N], vis[N]; int main() { cin >> t; while (t--) { scanf( %d , &n); for (int i = 1; i <= n; ++i) { f[i] = 0, vis[i] = 0; } for (int i = 1; i <= n; ++i) { s... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double e = 1e-6; int main() { int T; double n; scanf( %d , &T); while (T--) { scanf( %lf , &n); double a = 0, b = n; bool flag = false; for (int i = 0; i < 10000; i++) { double m = (a ... |
#include <bits/stdc++.h> int n, a[444], s, p, q, ans; int main() { scanf( %d , &n); ans = -1; for (int i = 0; i < n; ++i) scanf( %d , a + i); for (int i = 1; i < n; ++i) for (int j = 0; j < n; ++j) { p = a[i - 1] - 1; for (int k = q = s = 0; k <= j;) q += p / a[k], s ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; int n, m, k; set<int> a[maxn], b[maxn]; set<int, greater<int> > c[maxn], d[maxn]; int main() { scanf( %d%d%d , &n, &m, &k); int x, y, nx, ny, lx = 0, ly = 0, rx = n + 1, ry = m + 1, dir = 1; long long ans = 1; for (int i ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int cnt, n, res; int tin[maxn], tout[maxn], a[maxn + maxn], dp[maxn], f[maxn][17], st[maxn], h[maxn], b[maxn]; bool need[maxn]; vector<int> adj[maxn]; void Input() { int x, y; cin >> n; for (int i = (2); i <= (n); ++... |
#include <bits/stdc++.h> using namespace std; template <typename T> using maxpq = priority_queue<T, vector<T>, greater<T>>; template <typename T> using minpq = priority_queue<T>; int n, TOT; string a[305]; int HASH[305], len[305], p[100005]; inline int add(int a, int b) { long long c = a + b; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void __read(T& a) { cin >> a; } template <typename T, typename... Args> void __read(T& a, Args&... args) { cin >> a; __read(args...); } constexpr long long M7 = 1000000007ll; constexpr long long M9 = 1000000009ll; conste... |
#include <bits/stdc++.h> using namespace std; int main() { string s, test = hello ; int c = 0; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == test[c]) { c++; } if (c == 5) { break; } } if (c == 5) { cout << YES << endl; } els... |
#include <bits/stdc++.h> using namespace std; template <class TAT> void read(TAT &a) { static char cc; static bool fff; while (((cc = getchar()) < 0 || cc > 9 ) && cc != - ) ; if (cc == - ) fff = 1, a = 0; else fff = 0, a = cc - 48; while ((cc = getchar()) >= 0 && ... |
#include <bits/stdc++.h> using namespace std; const int N = 100009; int main() { string s; cin >> s; int l = s.size(); for (int i = 0; i < l; i++) s += s[i]; int ans = 1; for (int i = 0; i < l;) { int j = i; for (; j < l + i - 1; j++) { if (s[j] == s[j + 1]) b... |
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; long long cnt = 0; for (long long i = 0; i < s.length(); i++) { if (s[i] >= 97) cnt++; } if (cnt >= s.length() - cnt) { transform(s.begin(), s.end(), s.begin(), ::tolower); } else transform... |
#include <bits/stdc++.h> using namespace std; long long n, s, l, r, res, cur, maxx = -9999999999; int main() { cin >> n >> s; for (long long i = 1; i <= n; i++) { cin >> l >> r; maxx = max(maxx, l + r); } cout << max(maxx, s); return 0; } |
#include <bits/stdc++.h> struct MI { private: char bb[1 << 14]; FILE *f; char *bs, *be; char e; bool o, l; public: MI() : f(stdin), bs(0), be(0) {} inline char get() { if (o) { o = 0; return e; } if (bs == be) be = (bs = bb) + fread(bb, 1, sizeof(... |
#include <bits/stdc++.h> using namespace std; char s[3009], t[3009]; long long dp[3009][3009]; int n, m; long long bigmod(long long a, long long p) { long long r = 1ll; while (p) { if ((p & 1ll)) { r = (a * r) % 998244353ll; } a = (a * a) % 998244353ll; p >>= 1; } ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int a, b, c, d, i, j, n, m, k, ans; int cs[100001], mas[100001], dp[100001]; inline int sum(int a, int b) { if (!a) return cs[b]; else return cs[b] - cs[a - 1]; } int main() { scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; long long a[200005]; long long b[200005]; void solve() { long long n; cin >> n; long long c = 0, t, c1 = 0; cin >> t; for (long long i = 0; i < t; i++) { cin >> a[i]; } for (long long i = 1; i < t; i++) { if (n - a[i - 1] > 0)... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k; cin >> n >> k; m = (3 * n <= k) ? 0 : 3 * n - k; cout << m << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(); long long a, b, c, n, x; cin >> a >> b >> c >> n; x = a + b - c; x = n - x; if (x < 1 || c > a || c > b || c > (a + b)) cout << -1 << endl; else cout << x << endl; retur... |
#include <bits/stdc++.h> #define jh(x, y) (x ^= y ^= x ^= y) #define loc(x, y) ((x - 1) * m + y) #define lowbit(x) (x & -x) typedef long long ll; const int N = 5e5 + 5, INF = 0x3f3f3f3f, mod = 1e9 + 7; const double PI = acos(-1), EPS = 1e-7; using namespace std; namespace fast_IO { ll read() { ll... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; const int K = 65; const int inf = 1000 * 1000 * 1000; const int mod = 1000 * 1000 * 1000 + 7; int n, a[N], q; int t[4 * N][K]; void build(int v, int s, int e) { if (s == e) { for (int i = 0; i < 60; i++) { if (i % a[s]... |
#include <bits/stdc++.h> using namespace std; long a[100002]; long b[100002]; long s[100002]; long l[100002]; vector<int> br0, br1; map<int, vector<int> > fre, an; const int MAXN = 100001; int comp = 0; vector<int> g[MAXN], h[MAXN]; bool used[MAXN]; int timer, tin[MAXN], fup[MAXN], col[MAXN]; ... |
#include <bits/stdc++.h> int main(int argc, const char* argv[]) { int n, x; std::cin >> n >> x; std::vector<int> v(n); for (int i = 0; i < n; i++) std::cin >> v[i]; std::sort(v.begin(), v.end()); for (int i = 0; i < n; i++) { if (v[i] > x) { std::cout << x - i << std::endl; ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; const long long inf = (long long)1e9; double PI = 3.14159265; double eps = 1e-9; long long t = 0; long long pow(long long a, long long b) { if (b == 0) return 1; if (b % 2 == 1) { return (pow(a, b - 1) * a); } if ... |
#include <bits/stdc++.h> using namespace std; int main() { int a1, b1, a2, b2, a3, b3; cin >> a1 >> b1 >> a2 >> b2 >> a3 >> b3; int l1 = min(a1, b1); int l2 = min(a2, b2); int l3 = min(a3, b3); int L1 = max(a1, b1); int L2 = max(a2, b2); int L3 = max(a3, b3); if (l2 + l3 <= l1 &&... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 100; const long long M = 21; const long long mod = 1e9 + 7; const long long MOD = 998244353; const long long P = 1336; const long double eps = 0.000000001; const long long inf = 1e16 + 7; mt19937 gen(chrono::high_resolution_clock:... |
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n; std::cin >> n; int a[2][n + 2]; unsigned long long b[2][n + 2]; b[0][0] = 0; b[1][0] = 0; b[0][1] = 0; b[1][1] = 0; for (int i = 2; i <= n + 1; i++) std::cin >> a[0][i]; ... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const int INF = (((1 << 30) - 1) << 1) + 1; const int nINF = 1 << 31; string s; int main() { ios::sync_with_stdio(false); cin >> s; int n = s.size(); int open, close, q, ans = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n, k; string x; cin >> n >> k >> x; string ans = ; int o = -1; for (int i = 1; i < x.size(); i++) { if (x.substr(i, x.size() - i) == x.substr(0, x.size(... |
#include <bits/stdc++.h> using namespace std; using lli = long long; using lld = long double; using ulli = unsigned long long int; using pll = pair<lli, lli>; using ttt = pair<lli, pll>; using vttt = vector<ttt>; using vll = vector<pll>; using vl = vector<lli>; using vi = vector<int>; using vvi = ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 325; int n, s[N], sum[26][N], vc; bitset<N> b[N]; char ans[N]; void addv(int s, int e) { int flag = 0; for (int i = s - 1, j = e - 1; i <= j; i++, j--) { ... |
#include <bits/stdc++.h> using namespace std; template <class T> using vec = vector<T>; template <typename Iter> ostream &_IterOutput_(ostream &o, Iter b, Iter e, const string ss = , const string se = ) { o << ss; for (auto it = b; it != e; it++) o << (it == b ? : , ) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f; int main() { int T; cin >> T; while (T--) { int b, p, f, h, c; cin >> b >> p >> f >> h >> c; int ans = 0; for (int i = 0; i <= p; ++i) { int num1 = min(i, b / 2); ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; stringstream output; inline void eOP(); inline void solve() { int n, x, y; cin >> n >> x >> y; string s; cin >> s; char p = 1 ; long long cnt = 0; for (char c : s) { if (p == 1 && c == 0 ) { ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<pair<int, int> > v; int n, i, c = 1, ans = 0; vector<pair<int, int> >::iterator it; cin >> n; for (i = 0; i < n; i++) { int x, y; cin >> x >> y; v.push_back(make_pair(y, x)); } sort(v.begin(), v.end()); ... |
#include <bits/stdc++.h> using namespace std; double x[101010], y[101010]; double maxn[101010], minn[101010]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %lf , &maxn[i]); for (int i = 1; i <= n; i++) scanf( %lf , &minn[i]); for (int i = n - 1; i >= 1; i--) minn[i... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 10; long long arr[MAX]; int cur[MAX], want[MAX]; int n; vector<vector<int> > adj(MAX); long long ans = 0; array<int, 2> dfs(int node, int par, long long Min) { array<int, 2> a, b; a[0] = 0, a[1] = 0; if (cur[node] != want[no... |
#include <bits/stdc++.h> using namespace std; struct node { long long x, id; } a[200005]; long long st[200005], top; bool cmp(node a, node b) { return a.x < b.x; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long T; cin >> T; while (T--) { top... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long i, j, k, l, r, n, m; scanf( %llu , &l); scanf( %llu , &r); scanf( %llu , &k); j = k; n = ceil(log(l) / (double)log(k)); unsigned long long chq = 0; chq = max(chq, (unsigned long long)(floor(log(r) / (double... |
#include <bits/stdc++.h> using namespace std; char f; string tas[1000], mas; long a, b, kol, m, n, pos, mi, ma, nn, kola, kolb; double k; long long ans; int main() { cin >> mas; for (int a = 0; a < (10); a++) cin >> tas[a]; for (int a = 0; a < (8); a++) { for (int b = 0; b < (10); b++) {... |
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 16) + 5, maxm = 125; int n, f[maxn][maxm], sa[maxn], sb[maxn], va, vb; struct node { int id, r, b; } a[20]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { char ch = getchar(); while (ch != R && ch !=... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k, l; cin >> n >> k >> l; vector<int> d(n + 1), safe = {0}; for (int i = 1; i <= n; ++i) { cin >> d[i]; if (d[i] + k <= l) safe.push_back(i); } safe.push_b... |
#include <bits/stdc++.h> using namespace std; int main() { int a = 0, b = 0, x = 0, y = 0; cin >> a >> b; x = min(a, b); y = max(a, b); cout << x << << (y - x) / 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; long long count = 0; while (a != b) { if (a == 0 || b == 0) break; if (a < b) { count += b / a; b = b % a; } else { count += a / b; a = a % b; } } ... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long long r; while (b) { ... |
#include <bits/stdc++.h> #pragma GCC optimize( O999 ) using namespace std; int main() { ios::sync_with_stdio(0); cout << INTERCAL ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; int mn = min(n, m); if (mn % 2 == 0) { cout << Malvika ; } else { cout << Akshat ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, o[1010][1010], a[1010][1010], b[1010][1010], siza[1010], sizb[1010]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf( %d , &o[i][j]); a[i][j] = b[j][i] = o[i][j]; } ... |
#include <bits/stdc++.h> const long long MOD = 1e9 + 7; using namespace std; long long n, u, v, ans, dp[100005], cntt[100005]; vector<vector<long long> > g(100005); bool used[100005]; long long bpow(long long x, long long p) { if (p == 0) return 1; long long cur = bpow(x, p >> 1); cur = (cur * c... |
#include <bits/stdc++.h> template <class T> T gcd(T a, T b) { while (a && b) if (a > b) a %= b; else b %= a; return a + b; } using namespace std; long long k, n[3], t[3], ans[11111][3], i, j; int main() { cin >> k >> n[0] >> n[1] >> n[2] >> t[0] >> t[1] >> t[2]; f... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int casei(long long int tc) { long long int n, i, trn = 1, fct = 1; cin >> n; for (i = 1; i <= n; i++) { if (i < n) trn *= 2; fct *= i; trn %= mod; fct %= mod; } long long int ans = fct... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int N = 5e3 + 5; int n, vis[26][26][N]; string s; long double ans; int main() { ios::sync_with_stdio(0); cout << fixed << setprecision(12); cin >> s; n = s.size(); for (int i = 0; i < n; i++) { for (in... |
#include <bits/stdc++.h> int main() { long long t = 1; scanf( %lld , &t); while (t--) { long long n, a = 0; scanf( %lld , &n); while (n > 0) { int r = n % 2; if (r == 1) a++; n = n / 2; } long long ans = pow(2, a); printf( %lld n , ans); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; pair<int, int> edges[N]; int type[N]; bool inv[N]; vector<int> e[N]; int vis[N]; int used[N]; inline int other(int id, int u) { return edges[id].first == u ? edges[id].second : edges[id].first; } int ans1 = 0, ans2 = 0; voi... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double EPS = 1e-9; int n, a[100015]; int main() { scanf( %d , &n); if (n % 4) { printf( ! -1 n ); fflush(stdout); } else { printf( ? %d n , 1... |
#include <bits/stdc++.h> using namespace std; int main() { string s, p; cin >> s >> p; int slen = s.length(), plen = p.length(); int max = 0; if (plen > slen) { int k = slen - 1; while (k >= 0) { int n = 0; for (int i = k; i < slen; i++) { if (p[i - k] == s[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 5; const int mod = 51123987; char s[maxn]; struct Pam { vector<pair<int, int> > next[maxn]; int fail[maxn]; int len[maxn]; int num[maxn]; int S[maxn]; long long a[maxn], b[maxn]; int last, n, p; int newNode(in... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > c; vector<int> sort_cyclic_shifts(string const& s) { int n = s.size(); const int alphabet = 256; vector<int> p(n), cnt(alphabet, 0); c.clear(); c.emplace_back(); c[0].resize(n); for (int i = 0; i < n; i++) cnt[s[i]]++; ... |
#include <bits/stdc++.h> using namespace std; const int MX = 5e5 + 100, INF = 1e9; int N, M, X[MX], cnt; map<int, int> mp; struct Seg { int z; int l, r; Seg *L, *R; void update(int x) { z = min(z, x); } void pushdown() { L->update(z), R->update(z); } void init(int a, int b); void M... |
#include <bits/stdc++.h> long long n, s[2][100010], k; long long dp[100010][2]; long long ans = 1; long long p(long long a, long long b) { if (b == 0) return 1LL; if (b == 1) return a % 998244353; long long x = p(a, b >> 1); x *= x; x %= 998244353; x *= p(a, b & 1); x %= 998244353; ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 7; const int maxn = 1e5 + 5; int n, m; int a[maxn]; int num[maxn]; int main() { cin >> n; long long sum1 = 0; for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); sum1 += a[i]; } num[n] = a[n]; long... |
#include <bits/stdc++.h> using namespace std; char s[30][30]; int a, b; int main() { while (~scanf( %d%d , &a, &b)) { for (int i = 0; i < a; i++) scanf( %s , s[i]); int ss = 0; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { int d = 99999999; if (s[i... |
#include <bits/stdc++.h> using namespace std; const int N = 7010; map<long long, int> cnt; int n; long long ar[N], br[N]; bitset<N> bit[N]; bitset<N> res; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> ar[... |
#include <bits/stdc++.h> using namespace std; string s; int n, ans = 0; vector<pair<int, int>> b; vector<int> a(26); int main() { cin >> s >> n; for (int i = 0; i < s.length(); ++i) { a[s[i] - a ]++; } for (int i = 0; i < 26; ++i) { b.push_back(make_pair(a[i], i)); } sor... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 5; struct node { int op; int l; int r; int d; } cmd[maxn]; ; int a[maxn]; int b[maxn]; int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) cin >> cmd[i].op >... |
/* Creater : ANSHUMAN MISHRA All Losses In this World Are Due To Lack Of Ability. If You Want To Curse Someone , Curse Your Own Weakness */ #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define yes cout<< YES n #define no cout<< NO n ... |
#include <bits/stdc++.h> using namespace std; int Get() { char c; while (c = getchar(), c < 0 || c > 9 ) ; int X = c - 48; while (c = getchar(), c >= 0 && c <= 9 ) X = X * 10 + c - 48; return X; } void Output(long long X) { int Data[20], Len = 0; while (X) { Data[Le... |
#include <bits/stdc++.h> using namespace std; int a[1010], b[1010]; bool vis[1010]; int main() { int n, i, ans, nn, lb; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); memset(vis, false, sizeof(vis)); ans = 0; nn = 0; while (1) { lb = 0... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int INF = 0x3f3f3f3f; const int maxn = 100010; inline int read() { int x = 0, f = 1; char ch = 0; while (!isdigit(ch)) { ch = getchar(); if (ch == - ) f = -1; } while (isdigit(ch)) x = x * 10 + ch - 48... |
#include <bits/stdc++.h> using namespace std; long long t, n, m; int a[200003]; pair<int, int> p[200003]; int main() { cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } long long re = 0; for (int i = 1; i <= n;) { int val = a[... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, cf, cm, m; cin >> n >> a >> cf >> cm >> m; vector<vector<long long> > stat(n, vector<long long>(2)); for (int i = 0; i < n; i++) { cin >> stat[i][0]; stat[i][1] = i; } stable_sort(stat.begin(), stat.end())... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; set<string> s0; for (int i = 0; i < n; i++) { cin >> s; unordered_set<char> s1; s.erase(remove_if(s.begin(), s.end(), [&](char const c) { return !(s1.insert(c).second);... |
#include <bits/stdc++.h> using namespace std; #define intt long long int #define F first #define S second #define pb push_back int main() { int n;cin>>n; int arr[n+1]; vector<int> pos; pos.pb(-1); for(int i=1;i<=n;i++) {cin>>arr[i];if(arr[i]==1) pos.pb(i); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; string t[6] = { lios , liala , etr , etra , initis , inites }; bool mark[3]; int md = -1; int typ(string s) { for (int i = 0; i < 6; i++) if (t[i].size() <= s.size()) { bool flag = true; for (int j = 0; j < t... |
#include <bits/stdc++.h> using namespace std; long long INF = 1LL << 60; long long MOD = 1e9 + 7; namespace output { void pr(short x) { cout << x; } void pr(signed x) { cout << x; } void pr(long x) { cout << x; } void pr(long long x) { cout << x; } void pr(unsigned short x) { cout << x; } void pr(un... |
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(ll a = 0; a < (b); ++a) #define pb push_back #define st first #define nd second #define all(a) a.begin(), a.end() #define lg(a) (31-__builtin_clz(a)) void solve() { int n; ... |
#include <bits/stdc++.h> using namespace std; int main() { int c = 1, mx = 0; string s; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] != A && s[i] != O && s[i] != I && s[i] != U && s[i] != Y && s[i] != E ) { c++; } else { if (c > mx) mx = c;... |
#include <bits/stdc++.h> using namespace std; int n, s, i, a[1003], res, x; int main() { cin >> n >> x; for (i = 1; i <= n; i++) { cin >> a[i]; s += a[i]; } if (s <= 0) s *= (-1); res = s / x; if (s % x > 0) res++; cout << res; return 0; } |
#include <bits/stdc++.h> using namespace std; int n; struct node { int s, r, no; } xx[500001], dance[500001], fire[500001]; bool cmp(node x, node y) { return x.s > y.s || (x.s == y.s && x.r > y.r); } int S[500001]; int ans[500001]; int mal = 0; int k; int q; bool yes[500001]; double eps = 1e... |
#include <bits/stdc++.h> using namespace std; int n, m, k; const int maxn = 2e5 + 10; template <class T> inline T read() { int f = 1; T ret = 0; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -1; ch = getchar(); } while (isdigit(ch)) { ret = (ret << 1)... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; if (n == k) cout << 0 << endl; else if (k > n) cout << k - n << endl; else { if ((n - k) % 2 == 0) cout << 0 << endl; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int n, m; pair<int, int> tl = {-100, -100}, br = {-100, -100}; cin >> n >> m; char paper[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m;... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200010; const int maxv = 1000000010; int a[maxn]; int l[maxn], r[maxn]; int rj[maxn]; stack<int> s; int main() { int n; cin >> n; a[0] = 0; for (int i = 1; i <= n; i++) scanf( %d , &a[i]); a[n + 1] = 0; s.push(0); ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n; cin >> n; long long a[n], b[n]; long long m = INT_MAX; for (int i = 0; i < n; i++) ... |
#include <bits/stdc++.h> using namespace std; struct Point { int x; int y; }; bool onSegment(Point p, Point q, Point r) { if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) && q.y <= max(p.y, r.y) && q.y >= min(p.y, r.y)) return true; return false; } int orientation(Point p, Poin... |
#include <bits/stdc++.h> using namespace std; int main() { int d[105], n, sum1 = 0, sum2 = 0, begin, end; cin >> n; for (int i = 1; i <= n; i++) cin >> d[i]; cin >> begin >> end; if (begin > end) { int t; t = begin; begin = end; end = t; } for (int i = begin; i < ... |
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 5; struct Edge { int v, nxt; } E[MX * 2]; int Head[MX], erear; void edge_init() { erear = 0; memset(Head, -1, sizeof(Head)); } void edge_add(int u, int v) { E[erear].v = v; E[erear].nxt = Head[u]; Head[u] = erear+... |
#include <bits/stdc++.h> using namespace std; int test; int n, k; string s; int tipus[200009]; int darab[3]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> test; for (int tt = 1; tt <= test; tt++) { cin >> n; int minx = -100000; int maxx = 100000; int ... |
#include <bits/stdc++.h> using namespace std; inline long long n2(int n) { return (n * 1ll * (n + 1)) / 2; } const int N = 2e5; vector<int> f(N + 1); long long get(int pos) { long long res = 0; for (; pos >= 0; pos = (pos & (pos + 1)) - 1) res += f[pos]; return res; } long long get(int l, int ... |
#include <bits/stdc++.h> using namespace std; class Graph { public: vector<vector<int>> a; vector<int> vis; int N, M; int n; int R(int i) { return i; } int C(int i) { return i + N; } void addEdge(int l, int r) { a[R(l)].push_back(C(r)); a[C(r)].push_back(R(l)); } G... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.