func_code_string
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &n) { n = 0; T f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1, c = getchar(); while (isdigit(c)) n = n * 10 + c - 0 , c = getchar(); n *= f; } template <...
#include <bits/stdc++.h> using namespace std; const int maxn = 100050; const int inf = 0x3f3f3f3f; struct Edge { int v, w; }; vector<Edge> G[maxn]; bool vis[maxn]; vector<int> st; int dep[maxn], f[maxn][20]; long long dis[maxn]; void dfs(int x, int par, long long sum) { f[x][0] = par; ...
#include <bits/stdc++.h> using namespace std; void add(map<pair<long long, long long>, long long> &mp, pair<long long, long long> elem) { if (mp.count(elem) == 0) { mp.insert({elem, 1}); } else { mp[elem]++; } } void del(map<pair<long long, long long>, long long> &mp, ...
#include <bits/stdc++.h> using namespace std; const int N = 100010; const long long INF = 1LL << 55; struct Tree { Tree *nex[26]; vector<int> G[2]; int deep; Tree() { for (int i = 0; i < 26; i++) nex[i] = NULL; deep = 0; } }; Tree *tree; void Insert(char *s, int u, int id) ...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > v(200002); bool ab[200002]; int dist[200002]; queue<int> q; int cur, i, n, h[200002], r[200002], p[200002]; void dfs() { while (!q.empty()) { cur = q.front(); q.pop(); ab[cur] = true; for (i = 0; i < v[cur].size...
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& x) { return os << ( << x.first << , << x.second << ) ; } int main() { int T; scanf( %d , &T); while (T--) { int n, k; scanf( %d%d , &n, &k); ...
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b, c, d; cin >> a >> b >> c >> d; if (a > b * c) { cout << -1 n ; return; } if (c < d) { cout << a << n ; return; } long long mx = c / d; long long k = (2 * a - b * d) / (2 * d * b); ...
#include <bits/stdc++.h> using namespace std; int times, used[200010], t[200010], first[200010], last[200010], d[200010], n, a[200010]; vector<vector<int> > g(200010); void dfs(int v, int pr) { used[v] = 1; first[v] = ++times; d[v] = d[pr] + 1; for (int i = 0; i < g[v].size(); i++) { ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1005; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); f...
#include <bits/stdc++.h> using namespace std; struct edge { long long to, cost; edge() {} edge(long long a, long long b) { to = a, cost = b; } }; const long long dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; const long long mod = 1000000007; struct mint { long long x = 0; mint(long long y ...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pci = pair<char, int>; using vi = vector<int>; using vll = vector<ll>; using vpii = vector<pii>; const ll infll = ...
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979323846264338327950288419716939937510582; int t; int n; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; cout << fixed << setprecision(20) << ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; t = 1; while (t--) { long long n, a[8] = {0}, k; cin >> n; for (int i = 0; i <= n - 1; i++) { cin >> k; a[k]++; } if (a[5] > 0 || a[7] > 0 || a[1] ...
#include <bits/stdc++.h> using namespace std; long long n, k, p, a[10001], b[10001]; bool judge(long long x) { long long j = 1; long long i; for (i = 1; i <= n; i++) { if (abs(a[i] - b[j]) + abs(p - b[j]) <= x) { j++; continue; } else j++, i--; if (j > k) retu...
#include <bits/stdc++.h> using namespace std; vector<long long> ans; long long gcd(long long x, long long y) { while (true) { if (x == y) return x; if (x < y) { long long k = (y - 1) / x; ans.push_back(-k); y -= k * x; } else { long long k = (x - 1) / y; ...
#include <bits/stdc++.h> using namespace std; int main() { FILE *inF, *outF; inF = fopen( in , r ); outF = fopen( out , w ); inF = stdin; outF = stdout; int t; fscanf(inF, %d , &t); while (t--) { int n; long long k; fscanf(inF, %d %lld , &n, &k); int m = -...
#include <bits/stdc++.h> using namespace std; int rec[2][8]; int pattern[2][5500]; int n1, n2, z; int modpow(int n, int ex) { int res = 1; while (ex > 0) { if (ex % 2 == 1) res = (res * n) % 1000000007; n = (n * n) % 1000000007; ex = ex / 2; } return res; } void solve(int...
#include <bits/stdc++.h> using namespace std; struct asdf { int y, z, next; } e[200001]; int n, m, tot, first[100001]; int siz[100001], f[100001] = {1000000000, 0}, ro, v[100001], o, dep[100001], cnt; long long p[100001] = {1, 0}, a[100001], ans; pair<int, int> g[100001], b[100001];...
#include <bits/stdc++.h> using namespace std; int n, m, tab[105][105], pot[30]; int licz(int numer) { int wyn = 0; for (int i = (0); i <= ((m)-1); ++i) { int a = 0, b = 0; for (int j = (0); j <= ((n)-1); ++j) { a += (tab[j][i] != tab[j][numer]); b += (tab[j][i] == tab[j][numer]...
#include <bits/stdc++.h> using namespace std; void solve(string s, int n) { if (s.size() <= 3) { cout << s; return; } cout << s.substr(0, 2) << - ; s = s.substr(2, n - 2); solve(s, n); } int main() { int n; cin >> n; string s; cin >> s; solve(s, n); }
#include <bits/stdc++.h> using namespace std; int n, m; struct edge { int from; int to; int next; long long flow; } E[10005 << 1]; int sz = 1; int head[10005]; void add_edge(int u, int v, long long w) { sz++; E[sz].from = u; E[sz].to = v; E[sz].next = head[u]; E[sz].flo...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; string s; int cnt, last = 0; int ans = 0; for (int i = 0; i < d; i++) { cin >> s; cnt = 0; for (int j = 0; j < n; j++) cnt += (s[j] - 0 ); ...
#include <bits/stdc++.h> template <typename element_type> std::vector<element_type> read_vector(int size); using namespace std; int main() { int particles; string direction; while (cin >> particles >> direction) { vector<int> start = read_vector<int>(particles); int best = -1; for ...
#include <bits/stdc++.h> using namespace std; namespace number_theory { int isprime(long long int a) { for (int i = 2; i * i <= a; i++) { if (a % i == 0) return 0; } return 1; } long long int binpow(long long a, long long b) { long long res = 1; while (b > 0) { if (b & 1) res =...
#include <bits/stdc++.h> using namespace std; int mp[1000007]; int dp[1010][10010]; int pre[1010][10010]; long long ans[1010][10010]; int out[1010][10010]; long long a[1010]; long long v[10010]; int cnt; int add(long long k) { if (!mp[k % 1000007]) { v[++cnt] = k; mp[k % 1000007] = c...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b, i, j, t, p = 0, q = 0; int x[200001]; cin >> n >> m; for (i = 1; i <= n; ++i) { cin >> t; if (t == -1) p++; else q++; } for (i = 0; i < m; ++i) { cin >> a >> b; if ((b - a...
#include <bits/stdc++.h> using namespace std; int main() { long double n, t; cin >> n >> t; cout << fixed << setprecision(10) << n * pow(1.000000011, t); }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int arr[N]; long long seg[N << 2], mn[N << 2], lazy[N << 2]; bool flag[N << 2]; int n, q; vector<long long> v; void push_down(int id) { if (flag[id]) { lazy[id] = lazy[((id << 1) + 1)] = lazy[((id << 1) + 2)] = 0; seg[(...
#include <bits/stdc++.h> using namespace std; const double PI = 2 * acos(0); int n; char buf[10]; set<int> lhs; set<int> rhs; long long ret; vector<int> unknown; void update(int idx) { if (!rhs.empty() && idx >= *rhs.begin()) { rhs.insert(idx); return; } if (!lhs.empty() && idx...
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; register char ch; register bool fl = 0; while (ch = getchar(), ch < 48 || 57 < ch) fl ^= ch == - ; x = (ch & 15); while (ch = getchar(), 47 < ch && ch < 58) x = (x << 1) + (x << 3) + (ch & 15); if (fl) ...
#include <bits/stdc++.h> using namespace std; bool light[123456]; vector<int> v[123456]; bool visited[123456]; int connected[123456]; int main() { int n; cin >> n; string s, t; vector<string> rat, man, woman, child, capt; for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n)); ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } if (arr[0] < arr[n - 1]) { cout << YES << endl; } else cout << NO <<...
#include <bits/stdc++.h> using namespace std; const int B = 172, N = 44005; using ll = long long; using Bit = bitset<B>; unordered_map<Bit, int> mp; Bit aa, a[N]; bool vis[20][N]; int cnt = 1, nxt[N][10]; ll dp[20][10][N]; int b[20]; ll solve(ll n, int kk) { if (!n) return 1; int m = 0, po...
#include <bits/stdc++.h> using namespace std; pair<int, int> nextInt(const string &s, int ind) { int ret = 0; while (ind < s.length() && s[ind] >= 0 && s[ind] <= 9 ) { ret = ret * 10 + ((int)s[ind] - 48); ind++; } return make_pair(ret, ind); } int main() { int counti = 0; ...
#include <bits/stdc++.h> using namespace std; int vis[15]; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int a[3]; memset(vis, 0, sizeof(vis)); for (int i = 0; i < 3; i++) cin >> a[i]; int ans = 0; for (int i = 0; i < 3; i++) { ...
#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; long long a[5000]; int main() { int t; cin >> t; while (t--) { long long a, b, c, d; cin >> a >> b >> c >> d; long long p1 = b * c, p2 = (a - c - 1) * b, p3 = a * d, p4 = a * (b - d - 1); cout << max(max(p1, p2), max...
#include <bits/stdc++.h> const int maxn = 3e5 + 7; int ch[maxn << 5][2], max[maxn << 5], n, q, k, l[maxn], r[maxn], id[maxn], rk[maxn], a, b, x, y, tl, rt[maxn]; int cmp(int x, int y) { return r[x] < r[y]; } int insert(int rt, int L, int R, int p, int v) { int nrt = ++tl; ch[nrt][0] = ch[rt][0]; ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a = 0, b = 0; cin >> n; char s; while (n--) { cin >> s; if (s == L ) a++; else b++; } cout << a + b + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int ans, cnt; struct Node { Node *Left = NULL, *Right = NULL; int value, fix, sz = 1; long long sum[5] = {}; }; typedef Node *PNode; PNode root = NULL; inline int gts(PNode &cur) { if (cur == NULL) return 0; return cur->sz; } Node nodes...
#include <bits/stdc++.h> using namespace std; long long int a[200005], b[200005], c[200005]; class Myfirst { private: string *name; long long int *age; public: long long int gcd(long long int a, long long int b) { if (b == 0) return a; a %= b; return gcd(b, a); } lon...
#include <bits/stdc++.h> int main() { int n, i, m; char a[205]; scanf( %s , a); n = strlen(a); for (i = 0; i < n; i++) { if (a[i] == W ) { if (a[i + 1] == U ) { if (a[i + 2] == B ) { a[i] = ; a[i + 1] = ; a[i + 2] = ; ...
#include <bits/stdc++.h> using namespace std; vector<string> s; map<string, bool> was; int main() { int n; cin >> n; s.resize(n); for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = n - 1; i >= 0; i--) { if (!was[s[i]]) { cout << s[i] << n ; was[s[i]] ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; vector<vector<ll>> a(n + 1, vector<ll>(m + 1)); for (int i = 1; i <= n; ++i) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) if (a[i] % 2 == 0) a[i]--; for (int i = 0; i < n; i++) cout << a[i] << ; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t, a1, a2, b1, b2, max1, max2; cin >> t; while (t > 0) { cin >> a1 >> b1; cin >> a2 >> b2; max1 = max(a1, b1); max2 = max(a2, b2); if (max1 == max2) { int min1, min2; min1 = min(a1, b1); ...
#include <bits/stdc++.h> using namespace std; const int N = 1145; int n, m, q, k; bitset<N> a[51], f, nw, tp, s[N]; unordered_map<bitset<N>, int> mn; int main() { scanf( %d%d%d , &n, &m, &q); for (int i = 1, x, y; i <= m; i++) { scanf( %d , &x); while (x--) scanf( %d , &y), a[i][y] = 1; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); char s[n][m]; int a[n][m]; int x = clock(); char ch; scanf( %c , &ch); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { s[i][j] = getchar(); } char ch; ...
#include <bits/stdc++.h> using namespace std; template <typename T> void chkmin(T &a, T b) { a = min(a, b); } template <typename T> void chkmax(T &a, T b) { a = max(a, b); } inline int fread(void) { int ret = 0, op = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) ...
#include <bits/stdc++.h> using namespace std; int v[200005]; bool inQ[200005]; vector<pair<int, int> > foo; int main() { int n, k, q, p, m, i, j; bool ok; pair<int, int> x; cin >> n >> k >> m; for (i = 1; i <= n; ++i) cin >> v[i]; priority_queue<pair<int, int> > pq; for (j = 0; j <...
#include <bits/stdc++.h> using namespace std; int n, m, ans; int r, c; char mp[201][201]; int ma[201][201]; int mac[201][201]; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) { char s[101]; scanf( %s , &s); for (int j = 0; j < n; j++) { mp[i][j] = s[j]; ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int mx[N << 2], lz[N << 2], sum[N << 2], a[N], b[N]; void pushup(int rt) { mx[rt] = max(mx[(rt << 1)], mx[(rt << 1 | 1)]); } void pushdown(int rt) { if (lz[rt]) { lz[(rt << 1)] += lz[rt]; lz[(rt << 1 | 1)] += lz[rt]; m...
#include <bits/stdc++.h> using namespace std; const int maxn = 2000003; char s[maxn], t[maxn], tt[maxn]; int kmp[maxn]; int main() { int T; scanf( %d , &T); while (T--) { scanf( %s , s + 1); int n = strlen(s + 1), p, len = 0; for (p = 1; p <= n / 2 && s[p] == s[n - p + 1]; p++) ...
#include <bits/stdc++.h> using namespace std; int main() { int t, n, i; string a, b; cin >> t; while (t--) { vector<int> k; cin >> n >> a >> b; for (i = 0; i < n; i++) { if (a[i] != b[i]) { k.push_back(i + 1); k.push_back(1); k.push_back(i + 1)...
#include <cassert> #include <climits> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cctype> #include <vector> #include <string> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <utility> #include <algorithm> #i...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int maxn = 1e6 + 2; const int base = 31; const int mod = 1e9 + 7; ll t; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> t; while (t--) { ...
#include <bits/stdc++.h> using namespace std; int pi[200015]; void PreKMP(char *P, int n) { int q, k = 0; pi[1] = 0; for (q = 2; q <= n; pi[q++] = k) { while (k && (P[k] != P[q - 1])) k = pi[k]; if (P[k] == P[q - 1]) k++; } } int KMP(char *T, int n, char *P, int m) { int i, q =...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int inf = 10000000; int arr[100005]; map<int, int> mm; int main() { int n, k; cin >> n >> k; for (int i = 0; i < (n); i++) { cin >> arr[i]; mm[arr[i]] = 1; } sort(arr, arr + n); int ans = 0;...
#include <bits/stdc++.h> using namespace std; int main() { int a[5] = {}, x, y = 0; cin >> a[0] >> a[1] >> a[2]; for (int d = 0; d < 3; d++) { for (int c = 0; c < 3; c++) { if (a[d] > a[c]) swap(a[d], a[c]); } } x = a[1]; if (a[0] > x) y += a[0] - x; if (a[0] < x) y +...
#include <bits/stdc++.h> const long long inf = 0x3f3f3f3f3f3f3f3LL; const long long mod = (long long)1e9 + 7; using namespace std; template <class T> void smin(T& a, T val) { if (a > val) a = val; } template <class T> void smax(T& a, T val) { if (a < val) a = val; } const long long N = 100 +...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = s.length(); vector<int> v; for (int i = 0; i < n; i++) if (i == n - 1 || s[i] != s[i + 1]) v.push_back(i); if (s.back() == b ) v.pop_back(); vect...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0); int n; cin >> n; if (n <= 3) { cout << 0 << n ; return 0; } int Max = -1, k; for (int i = 2; i < n; ++i) { int tp = n / i * (i - 1); if (n % i >...
#include <bits/stdc++.h> using namespace std; int a[105][105][105]; int ans[105][105]; int main() { int n, m, h, x; cin >> n >> m >> h; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) for (int k = 1; k <= h; k++) a[i][j][k] = 1; for (int i = 1; i <= m; i++) { cin >>...
#include <bits/stdc++.h> using namespace std; const long long somod = 1e9 + 7; const long long maxn = 5e4 + 7; long long cntnode = 1, m, n, a[maxn]; vector<long long> vt[maxn * 31]; long long cac[32][2]; map<long long, vector<long long>> mp; long long Pow(long long a, long long b) { long long ans = ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N], f[N]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int T; cin >> T; while (T--) { int n, k; scanf( %d , &n); memset(a, 0, sizeof a); for (int i = 1; i <= n; i++) f[i] = 1...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 200005; long long fasmul(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b = b / 2; } return res; } void solve() ...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int a[n], mx = 0; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > mx) mx = a[i]; } long long int freq[mx + 1]; for (int i = 0; i < mx + 1; i++) { freq[i] = 0; } ...
#include <bits/stdc++.h> using namespace std; const int INF = (1 << 30); const double eps = 1e-9; const int mod = 1000000007; const int MAXN = int(1e5) + 100; const int dx[] = {-1, +1, 0, 0}; const int dy[] = {0, 0, -1, +1}; int main() { ios::sync_with_stdio(false); int n; cin >> n; vect...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int n; vector<int> dig; long long cnt[15]; long long C[25][25]; struct cond { int sum; int a[20]; string s; cond() { for (int i = 0; i < 20; i++) { a[i] = 0; } s = ; sum = 0; ...
#include <bits/stdc++.h> template <typename T> inline void rd(T& x) { int si = 1; char c = getchar(); x = 0; while (!isdigit(c)) si = c == - ? -1 : si, c = getchar(); while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); x *= si; } template <typename T, typename... Args> inline void...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int a[N], c[N], f[N], g[N], n, q, m, len, ans[N]; map<int, int> mp; inline void read(int &x) { char c = getchar(); x = 0; while (c > 9 || c < 0 ) c = getchar(); while (c >= 0 && c <= 9 ) { x = x * 10 + c - 0 ; ...
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; string s; cin >> s; for (i = 0; i < s.length(); i++) { if (s[i] == 0 ) break; } if (i == s.length()) cout << s.length(); else cout << i + 1; return 0; }
#include <bits/stdc++.h> using namespace std; bool comp(long long x, long long y) { return x > y; } int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; int n, k; char s[100000 + 5]; int prefix[100000 + 5]; bool check(int x, int i) { int tmp = prefix[min(n - 1, i + x)]; ...
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; const int maxn = 3000 + 10; int n, m, A[maxn], B[maxn]; long long f[maxn][maxn]; void init() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &A[i]); A[i] -= i; B[i] = A[i]; } } void solv...
#include <bits/stdc++.h> using namespace std; int f[605][605]; int C[605][605]; map<int, int> mp; int main() { int n, m, ans = 1; scanf( %d , &n); for (int i = 1; i <= n; i++) { int x; scanf( %d , &x); for (int j = 2; j * j <= x; j++) for (; x % (j * j) == 0; x /= j * j) ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i != n; ++i) { cin >> v[i]; v[i] -= (n - i); } sort(v.begin(), v.end()); for (int i = 0; i != n - 1; ++i) { if (v[i] + 1 > v[i + 1]) { cout << :( n ; ...
#include <bits/stdc++.h> using namespace std; int n, m, x, a[100]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (i == 1) m = a[1]; m = min(m, a[i]); } for (int i = 1; i <= n; i++) { x += (a[i] == m); } if (x <= n / 2) printf( Alice ); ...
#include <bits/stdc++.h> using namespace std; const int N = 1 << 20; const int mod = 1e9 + 7; void fwht(long long f[], int n) { for (int b = 0; b < n; ++b) for (int i = 0; i < (1 << n); i += (1 << (b + 1))) for (int j = 0; j < (1 << b); ++j) { int u = f[i + j]; int v = f[i ...
#include <bits/stdc++.h> using namespace std; const signed long long llf = (signed long long)(~0ull >> 1); const signed int inf = (signed)(~0u >> 1); template <typename T> T __abs(T x) { return (x < 0) ? (-x) : (x); } template <typename T> void pfill(T* pst, const T* ped, T val) { for (; pst != ...
#include <bits/stdc++.h> using namespace std; double low = 0, high = 0, mid = 0; int binary_sear(const vector<int>& v, int x) { while (1) { mid = floor((low + high) / 2); if (low > high) break; if (v[mid] == x) { return mid; break; } else if (v[mid] < x) { low =...
#include <bits/stdc++.h> using namespace std; int W, N, M; vector<int> freq; vector<uint16_t> quick_count; int needed(char bit_gate, int bit) { switch (bit_gate) { case A : return bit == 0 ? 2 : 0; case O : return bit == 0 ? 0 : -1; case X : return bit; c...
#include <bits/stdc++.h> using namespace std; const long long int inf = 1000000000000000; string s; vector<long long> prim; set<long long> prim2; void primeFactors(int n) { while (n % 2 == 0) { prim.push_back(2); prim2.insert(2); n = n / 2; } for (int i = 3; i <= sqrt(n); i = i...
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { solve(); cout << n ; } cerr << time taken : << (float)clock() / CLOCKS_PER_SEC << secs << endl; return 0; }...
#include <bits/stdc++.h> using namespace std; long long int n; int check(long long k) { long long patsum = 0, nn = n, pat; while (nn > 0) { nn = nn - k; pat = nn / 10; nn = nn - pat; patsum += pat; if (patsum > n / 2) { return 1; } } return 0; } long...
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); int32_t n; std::cin >> n; std::set<std::pair<int32_t, int32_t> > segments; for (int32_t i = 0; i < n; i++) { int32_t left, right; std::cin >> left >> right; auto it ...
#include <bits/stdc++.h> using namespace std; vector<int> magic(string t, string s, int sk) { int tl = t.length(); string x = t + @ + s; int n = x.length(); vector<int> pi(n), r(sk + 1, -1); r[0] = sk - 1; for (int i = 1, k = 0; i < n; ++i) { while (k && x[i] != x[k]) k = pi[k - 1]; ...
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:102400000,102400000 ) inline void read(int &x) { x = 0; char ch = getchar(); while (ch < 0 ) ch = getchar(); while (ch >= 0 ) { x = x * 10 + ch - 48; ch = getchar(); } } int a[100010], ans; bool f...
#include <bits/stdc++.h> using namespace std; int N; vector<pair<int, int>> ans, packs; void sp2(int st, int n) { if (n < 2) return; sp2(st, n / 2); sp2(st + n / 2, n / 2); for (int i = 0; i < n / 2; ++i) { ans.push_back({st + i, st + n / 2 + i}); } } void getp0(int st, int now, in...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const int BIG = 1e9 + 555; const int maxN = 100 * 1000 + 9; long long n, m; pair<long long, long long> a[maxN]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i ...
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 5; int mod = 1e9 + 7; long long qpow(long long a, long long b) { long long ans = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) ans = ans * a % mod; a = a * a % mod; } return ans; } long lo...
#include <bits/stdc++.h> struct Edge { long long to, dis, next; } edge[100100]; long long n, num_edge; long long first1[100100]; long long a[100100], b[100100]; double tem; void dfs(long long x, long long fa, long long p) { long long k = first1[x]; while (k != 0) { dfs(edge[k].to, x, edg...
#include <bits/stdc++.h> using namespace std; int A, B, q; long long l, t, m; bool check(long long len) { long long ind_left = l; long long ind_righ = ind_left + len - 1; long long num_left = A + (ind_left - 1) * B; long long num_righ = A + (ind_righ - 1) * B; long long need_time; if (le...
#include <bits/stdc++.h> using namespace std; inline int gi() { int data = 0, fu = 1; char ch = 0; while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == - ) fu = -1, ch = getchar(); while ( 0 <= ch && ch <= 9 ) data = (data << 1) + (data << 3) + (ch ^ 48), ch = getchar()...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1123456; template <typename T> T sqr(T x) { return x * x; } template <typename T> void vout(T s) { cout << s << n ; exit(0); } long long bp(long long a, long long n) { long long res = 1; while (n) { if (n ...
#include <bits/stdc++.h> long long sum(long long val) { if (val % 2) return (val + 1) / 2 * val; return val / 2 * (val + 1); } int main() { long long n, x, d[200005], i, xx, l, ans = 0, now, tmp; scanf( %lld%lld , &n, &x); for (i = 0; i < n; i++) scanf( %lld , &d[i]); l = n - 1; xx = x...
#include <bits/stdc++.h> using namespace std; template <class T> inline void umax(T &a, T b) { if (a < b) a = b; } template <class T> inline void umin(T &a, T b) { if (a > b) a = b; } template <class T> inline T abs(T a) { return a > 0 ? a : -a; } template <class T> inline T gcd(T a,...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); bool t = true; int n; cin >> n; int a[200001] = {0}; vector<int> voz; vector<int> yb; for (int i = 0; i < n; i++) { int c; cin >> c; ...
#include <bits/stdc++.h> using namespace std; vector<int> a; vector<vector<int>> graph; vector<vector<int>> residual; set<int> primes; map<pair<int, int>, int> factors; void sieve(int SQRTN) { vector<int> isPrime(SQRTN, 1); for (int i = 2; i < SQRTN; i++) { if (!isPrime[i]) continue; p...
#include <bits/stdc++.h> using namespace std; namespace io { char ibuf[(1 << 18)], *iS, *iT, obuf[(1 << 18)], *oS = obuf, *oT = oS + (1 << 18) - 1, c, qu[55]; int f, qr; inline void flush(void) { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; return; } inline char getch(void) { retur...
#include <bits/stdc++.h> using namespace std; long long N, Q, S[(int)1e5 + 5], i, L, R, p1, p2; long long Putere(long long p1, long long ex) { long long i, sol = 1; for (i = 0; (1 << i) <= ex; i++) { if (((1 << i) & ex) > 0) sol = (sol * p1) % 1000000007; p1 = (p1 * p1) % 1000000007; } ...