func_code_string
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { if (b == 0) return 1; if (b == 1) return a; long long int c = power(a, b / 2); if (b % 2 == 0) return ((c % 1000000007) * (c % 1000000007)) % 1000000007; return ((((c % 1000000007) * (c % 100000...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n + 1]; if (n % 2 == 0) cout << n * n / 2 << endl; else cout << ((n * n) + 1) / 2 << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i % 2 != 0 && j % 2 != 0...
#include <bits/stdc++.h> using namespace std; template <typename T, size_t N> long long SIZE(const T (&t)[N]) { return N; } template <typename T> long long SIZE(const T &t) { return t.size(); } string to_string(const string s, long long x1 = 0, long long x2 = 1e9) { return + ((x1 < s.siz...
#include <bits/stdc++.h> using namespace std; const int INF = numeric_limits<int>::max(); const long long LLINF = numeric_limits<long long>::max(); const unsigned long long ULLINF = numeric_limits<unsigned long long>::max(); vector<vector<int>> g; int main() { ios_base::sync_with_stdio(0); cin.tie(0...
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, an; int f[(1 << 20)], h[(1 << 20)]; int main() { scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &k), f[k]++; m = (1 << 20) - 1; for (i = 0; i <= 19; i++) for (j = 0; j <= m; j++) if (!(j & (1 << i))) f[j] += f[...
#include <bits/stdc++.h> using namespace std; int lg[1000005], jump[1000005][20], depth[1000005], head[1000005], cnt = 4; int q, tot, s, t, zj; struct edge { int to, next; } e[2000005]; void add(int x, int y) { e[++tot].to = y; e[tot].next = head[x]; head[x] = tot; } void dfs(int now, in...
#include <bits/stdc++.h> using namespace std; long long int INF = 10000000000; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m; cin >> n >> m; long long int chestOdd = 0, chestEven = 0; long long int i; for (i = 0; i < n; i++) { long long int temp...
#include <bits/stdc++.h> using namespace std; const int N = 1000010; const int mod = 998244353; int n; long long jc[N], inv[N], ans = 0, an = 0; long long poww(long long x, long long y) { long long ans = 1; while (y) { if (y & 1) { ans = ans * x % mod; } x = x * x % mod; ...
#include <bits/stdc++.h> using namespace std; int main() { int p, q; cin >> p >> q; string s; int **b = new int *[p]; for (long long int i = 0; i < p; i++) b[i] = new int[q]; for (long long int i = 0; i < p; i++) { cin >> s; for (long long int j = 0; j < q; j++) { b[i][j]...
#include <bits/stdc++.h> using namespace std; struct pole { int a, b; long long odp; int nr; }; bool porownanie1(pole a, pole b) { if (a.b < b.b) return true; if (a.b > b.b) return false; if (a.nr < b.nr) return true; return false; } bool porownanie2(pole a, pole b) { if (a.n...
#include <bits/stdc++.h> namespace myland { using namespace std; namespace _abbr { const double EPS(1e-8); const double PI(acos(-1.0)); const int INF(0x3f3f3f3f); const long long INFL(0x3f3f3f3f3f3f3f3fll); const int MOD(1e9 + 7); } // namespace _abbr using namespace _abbr; namespace _solve {} ...
#include <bits/stdc++.h> using namespace std; string s; bool check(long long l, long long r) { for (long long i = l; i < (r + l) / 2; i++) { if (s[i] != s[r - i - 1]) { return false; } } return true; } long long sulganlox(long long l, long long r) { if (r - l == 1) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 19391; long long a[maxn]; namespace FAST_IO { template <typename T> void read(T &a) { a = 0; long long f = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) { f = -1; } c = getchar(); } ...
#include <bits/stdc++.h> using namespace std; const int nmax = 1e5 + 42; int n; long long k; int arr[nmax]; void compress() { set<int> seen = {}; for (int i = 1; i <= n; i++) seen.insert(arr[i]); map<int, int> c = {}; int val = 0; for (auto k : seen) { val++; c[k] = val; ...
#include <bits/stdc++.h> using namespace std; int n; std::vector<int> ch[1005]; bool dfs(const int &u) { if (!ch[u].size()) return true; int res = 0; if (ch[u].size()) { for (auto it = ch[u].begin(); it != ch[u].end(); it++) { if (!(ch[*it].size())) res++; } } if (res >= ...
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; vector<ll> prime_factors(ll num) { vector<ll> ans; while (num % 2) { ans.push_back(2); num /= 2; } for (int i = 3; i * i <= num; i += 2) { while (num % i == 0) { ans.push_back(i)...
#include <bits/stdc++.h> using namespace std; int a[100010]; int b[100010]; int cha[100010]; vector<int> lis; int inc[100010]; int decr[100010]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; cha[x]++; cha[y + 1]--; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; pair<char, bool> ar[100][100]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> ar[i][j].first; ar[i][j].second = false; } } for (int i = 0; i < n; i++) { f...
#include <bits/stdc++.h> using namespace std; const int maxN = 100007; const int maxM = 300007; const long long INF = (1LL << 60); const long long M = 1000000007; long long C[maxN]; vector<int> G[maxN]; vector<int> H[maxN]; int V[maxN]; stack<int> S; vector<int> SSS[maxN]; void DFSG(int x) { ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int a[N], b[N]; int main() { int n, ans = 0, x; cin >> n >> x; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; sort(a + 1, a + 1 + n); sort(b + 1, b + 1 + n); for (int i = 1, j = ...
#include <bits/stdc++.h> using namespace std; void check(vector<vector<long long> >& a, vector<vector<long long> >& b) { long long n = a.size(), m = a[0].size(); for (long long i = 0; i < n; i++) for (long long j = 0; j < m; j++) if (a[i][j] > b[i][j]) swap(a[i][j], b[i][j]); } bool correc...
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long n, m, a, b, c, k, temp, x, y; const int MAXN = 100000 + 11; inline long long max(long long a, long long b) { return ((a > b) ? a : b); } inlin...
#include <bits/stdc++.h> using namespace std; int main() { long long int h, l, i; cin >> h >> l; long double x; x = (long double)(l * l - h * h) / (long double)(2 * h); std::cout << std::setprecision(9) << x << n ; }
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 200010; inline void solve() { ...
#include <bits/stdc++.h> using namespace std; int n; vector<int> sz[1001]; vector<int> s[1001]; vector<int> l; bool v[1001]; int dist[1001][1001]; vector<pair<int, pair<int, int> > > t; void bfs(int a, int f) { for (int i = 0; i < sz[a].size(); i++) { int x = sz[a][i]; if (dist[x][f] =...
#include <bits/stdc++.h> using namespace std; int n, a[44], b[44], PP[44], PPP[44], PHI[44]; long long dp[1 << 22], DP[1 << 22]; pair<int, int> P[44]; void is_ok() { dp[0] = 0; DP[0] = 0; int st = 0; for (int i = 0; i < n; ++i) { int dr = st + (1 << i); while (st < dr) { ++...
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, q; string s; int dp[251][251][251]; int nxt[26][112345]; int len[3]; int chs[3][250]; template <class T, class U> inline void smax(T &a, U b) { a = a > b ? a : b; } template <class T, class U> inline void smin(T &a,...
#include <bits/stdc++.h> using namespace std; const int mxn = 1e6 + 3; struct node { int v, i, j, id; } a[mxn]; int n, m, r[mxn], c[mxn], f[mxn], v[mxn], o[mxn]; int cmp(node a, node b) { return a.v < b.v; } int fffa(int x) { return f[x] == x ? x : f[x] = fffa(f[x]); } int main() { scanf( %d%d ,...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2000000; const long long int MOD = 1000000009; const long long int P = 31; int N; long long int t[4 * MAXN] = {0}; long long int tp[4 * MAXN] = {0}; void make_push(int v, int l, int r, long long int tmp) { t[v] += (r - l + 1) * tmp; ...
#include <bits/stdc++.h> using namespace std; int main() { int h = 0, v = 0, size; string s; cin >> s; size = s.size(); for (int i = 0; i < size; i++) { if (s[i] == 0 ) { if (v == 0) { cout << 1 3 n ; v++; } else { cout << 3 3 n ; ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7, N = 1e5 + 10; void test() { string s; cin >> s; vector<ll> cnt(26); for (auto c : s) { cnt[c - a ]++; } ll m; cin >> m; vector<ll> b(m); for (ll i = 0; i < m; i++) { cin >...
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long int l; #define fastIO ios::sync_with_stdio(false), cin.tie(0) #define pf push_front #define pb push_back #define popb pop_back() #define popf p...
#include <bits/stdc++.h> using namespace std; int ans[210000], k; vector<pair<int, int>> item, b; struct R { int l, r, cc; long long value; R(int L, int R, int CC = 0, long long VALUE = 0) { l = L, r = R, cc = CC, value = VALUE; } }; vector<R> range; void update() { long long val...
#include <bits/stdc++.h> using namespace std; int main() { long long t, i, j, k, l, m, n, p, q, r, s = 0, a, b, c, d, ans = 0, x, y; cin >> n >> k; string s1; cin >> s1; for (i = 0; i < n; i++) { if (s1[i] == G ) { p = i; } else if (s1[i] == T ) { q = i; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int x, y, a, b; double dis = 0; cin >> x >> y; a = x; b = y; n--; while (n--) { cin >> x >> y; dis += (double)sqrt(pow(y - b, 2) + pow(x - a, 2)); a = x; b = y; } d...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, sum = 0; cin >> n >> m; sum = n + (n - 1) / (m - 1); cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 200010; const long long MOD = 998244353; int main() { int n; scanf( %d , &n); if (n == 1) printf( 1 2 n ); else printf( %d 2 n , (n - 1) * 2); printf( 1 2 n ); }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; const int N = 3e5 + 2; int v[N], n, q; void read() { cin >> n >> q; for (int i = 1; i <= n; i++) cin >> v[i]; v[0] = 0; v[n + 1...
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 10; const long long mod = 1e9 + 7; long long read() { long long x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 1) ...
#include <bits/stdc++.h> using namespace std; const int N = 1000005; const int inf = 1e9 + 7; long long fac[N], M, inv[N]; inline long long po(long long x, long long y, long long z) { long long res = 1; while (y) { if (y & 1) res = res * x % z; x = x * x % z; y >>= 1; } retur...
#include <bits/stdc++.h> using namespace std; int II() { int n; scanf( %d , &n); return n; } int table[100][100]; char message[100][200]; string names[100]; void recprint(int m, int s) { if (m < 0) return; recprint(m - 1, table[m][s]); cout << names[s]; printf( :%s n , message[...
#include <bits/stdc++.h> using namespace std; vector<int> ans; struct item { int key, prior; item *left, *right; item() {} item(int key, int prior) : key(key), prior(prior), left(NULL), right(NULL) {} }; typedef item* pitem; void split(pitem temp, int key, pitem& left, pitem& right) { if...
#include <bits/stdc++.h> #pragma GCC optimize( -O2 ) using namespace std; void err(istream_iterator<string> it) { cerr << endl; } template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << = << a << t ; err(++it, args...); } template <ty...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int *a = new int[m]; if (m % 2 == 0) { for (int i = 0; i < m; i++) { if (i % 2 == 0) a[i] = m / 2 - i / 2; if (i % 2 == 1) a[i] = m / 2 + 1 + (i - 1) / 2; } } else { for (int i =...
#include bits/stdc++.h using namespace std; #define pb push_back #define ll long long #define mp make_pair #define pii pair<int,int> #define vi vector<int> #define vii vector<pii> #define mi map<int,int> #define mii map<pii,int> ...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int maxn = 115 + 5; char s[maxn][maxn]; int main() { int n, m; while (~scanf( %d%d , &n, &m)) { int mini = inf, maxi = 0, minj = inf, maxj = 0; getchar(); for (int i = 1; i <= n; i++) { for (int j...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, two, one; cin >> n >> m; if (m < n - 1 || m > 2 * n + 2) cout << -1 ; else { if (m < n) { cout << 0 ; n--; } while (m > 0 || n > 0) { two = max(m - n - 1, 0); one = min(2 * ...
#include <bits/stdc++.h> using namespace std; using LL = long long; constexpr int maxn = 100000 + 1; LL h[maxn], p[maxn], up[maxn], sz[maxn]; int par[maxn]; vector<int> G[maxn], order; void DFS(int u) { sz[u] = p[u]; for (int v : G[u]) if (v != par[u]) { par[v] = u; DFS(v); ...
#include <bits/stdc++.h> using namespace std; long long n; bool check(int x, long long y) { if (n * 2 / x < x + y) return true; if (n * 2 / x > x + y) return false; return n * 2 <= x * (x + y); } long long calc(long long y) { int l = 1, r = 2e9, mid; while (l < r) { mid = (l >> 1) + ...
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 10; pair<int, int> p[maxn], q[maxn]; int t[maxn]; int tot; int n, k; int dp[maxn][2]; void solve() { memset(dp, 0x3f3f3f3f, sizeof(dp)); int e = 0; for (int i = 1; i <= tot; i++) { dp[i][e] = min(dp[i - 1][e], q[i].se...
#include <bits/stdc++.h> using namespace std; const int N = 100; const int V = 100 * 50; bool edge[V][V], nf[V]; int ans, cnt_v, n; int from[V], start_v[N], value[V]; void ri() { int a, i, j, m, x1, x2; memset(from, 0xff, sizeof(from)); memset(edge, false, sizeof(edge)); cin >> n >> m; ...
#include <bits/stdc++.h> const int MAXN = 4e5 + 10; const double eps = 1e-8; const long long inf = 1e18 + 7; using namespace std; struct edge { int t, v; edge *next; } e[MAXN << 1], *h[MAXN], *o = e; void add(int x, int y, int w) { o->t = y; o->v = w; o->next = h[x]; h[x] = o++; ...
#include <bits/stdc++.h> using namespace std; int n, k = 0, dem = 0, s; char c[1000001]; int e[100001]; deque<int> pq; int main() { cin >> n; ; for (int i = 1; i <= n; ++i) { cin >> c[i]; if (c[i] == 8 ) { pq.push_back(i); dem++; } } s = n - 11; s /...
#include <bits/stdc++.h> using namespace std; vector<int> p, rk; int getp(int v) { if (v == p[v]) return v; return p[v] = getp(p[v]); } long long res; long long get(int cnt) { return cnt * 1ll * (cnt - 1) / 2; } void merge(int u, int v) { u = getp(u); v = getp(v); if (rk[u] < rk[v]) sw...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; s[0] = toupper(s[0]); cout << s; }
#include <bits/stdc++.h> using namespace std; long long i, a[200005], n, x = 0; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; a[i] += x; x = max(x, a[i]); } for (i = 0; i < n; i++) cout << a[i] << ; cout << endl; }
#include bits/stdc++.h #define FI first.first #define SE first.second #define TH second #define fi first #define se second #define th second using namespace std; string to_string(const string& str) { return str; } template<typename T> string to_string(const set<T>& mys) { if(mys...
#include <bits/stdc++.h> using namespace std; int luck_number[105], tot; int dp[10005][7]; bool is_luck(int x) { while (x) { int y = x % 10; x = x / 10; if (y > 0 && y < 4) return false; if (y > 4 && y < 7) return false; if (y > 7) return false; } return true; } voi...
#include <bits/stdc++.h> const long long md = 998244353; const int Inf = 1e9; const long long Inf64 = 1e18; const long long MaxN = 2e5 + 10; const long long MaxM = 11; const long double eps = 1e-15; const long long dx[4] = {0, 1, 0, -1}; const long long dy[4] = {1, 0, -1, 0}; const long long ddx[4] = ...
#include <bits/stdc++.h> using namespace std; vector<vector<int> > adj(2001); int match[2001 + 1], dis[2001 + 1]; bool visited[2001 + 1], minimumVertexCover[2001], maximumIndependentSet[2001]; const int inf = 1E9; void ResetVisited() { for (int i = 0; i <= 2001; ++i) { visited[i] = 0; } } ...
#include <bits/stdc++.h> using namespace std; const long long linf = 1e18 + 9; const int inf = 1e9 + 9; const int N = 2e5 + 9; int n, q, l[N], r[N], a[N], wh[N]; long long bit[N], ans[N]; vector<int> h[N]; vector<pair<int, int> > Q[N]; void update(int t) { t++; while (t <= n + 1) { bit[t...
#include <bits/stdc++.h> using namespace std; signed main() { cin.tie(nullptr)->sync_with_stdio(false); long long t; cin >> t; while (t--) { long long n, a, b, da, db; cin >> n >> a >> b >> da >> db; vector<vector<long long>> adj(n + 1); for (long long i = 0; i < n - 1; i++) ...
#include <bits/stdc++.h> using namespace std; int main() { long long p, d; while (scanf( %I64d%I64d , &p, &d) != EOF) { long long ans = ++p; for (long long i = 10;; i *= 10) { if (p % i > d) break; ans = p - p % i; } printf( %I64d n , ans - 1); } return 0; }...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; if (s.find( 0 ) != string::npos) { s.erase(s.find( 0 ), 1); } else { s.erase(s.size() - 1, 1); } cout << s; }
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int d = 0, tot = 0, c; bool flag = false; for (int i = 0; i < n; i++) { cin >> c; tot = tot + c; if (tot >= 8 && flag == false) { k = k - 8; tot = tot - 8; d++; i...
#include <bits/stdc++.h> int main() { int n, sum = 0, minodd = 101, i; scanf( %d , &n); for (; n > 0; --n) { scanf( %d , &i); if (minodd > i && i % 2) { minodd = i; } sum += i; } if (minodd == 101) printf( 0 ); else if (sum % 2) printf( %d , sum); ...
#include <bits/stdc++.h> using namespace std; int main() { int n, t, m; cin >> t; while (t--) { cin >> n; int i; int a[n], b[n]; for (i = 0; i < n; i++) { cin >> a[i]; } int f = 0; for (i = 0; i < n; i++) { cin >> b[i]; } int p = 0, v...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2000; int cubeta[MAXN + 2]; int color; int arr[MAXN + 2]; void mapea(int n) { set<int> nums; for (int i = 1; i <= n; i++) nums.insert(arr[i]); map<int, int> val; int cnt = 1; set<int>::iterator it = nums.begin(); while (i...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int res = -1; for (int i = 1; i < s.size(); i++) { for (int j = 1; i + j < s.size(); j++) { int p1; string P1 = s.substr(0, i); if (P1.size() > 1 && P1[0] == 0 ) p1 = -1; e...
#include <bits/stdc++.h> using namespace std; using LL = long long; using PII = pair<int, int>; int main() { auto get_factors = [](int n) { vector<int> ret; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, i, name[100], cnt; string str; char ch; cin >> n >> k; cnt = 0; for (i = 1; i <= k - 1; i++) { name[i] = ++cnt; } for (i = k; i <= n; i++) { cin >> str; if (str[0] == N ) { name[i] = name[...
#include <bits/stdc++.h> using namespace std; char c[100]; int main() { int n; cin >> n; int i; cin.getline(c, 100); int open = 0; string tt = ; for (i = 0; i < n; i++) { cin.getline(c, 100); string s = ; int k = strlen(c); int j = 0, z; while (j < k &...
#include <bits/stdc++.h> using namespace std; void debugv(std::vector<long long> v); void printv(std::vector<long long> v); void inputv(std::vector<long long> &v); void solve() { long long n; cin >> n; string s; cin >> s; unordered_map<string, long long> mp; for (long long i = 0; i < n...
#include <bits/stdc++.h> using namespace std; long long n, k, s[30][105], cnt[105]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; string t; cin >> t; s[t[0] - a ][1] = 1; for (int i = 1; i < t.size(); i++) { int u = t[i] - a ; for (int j = i + 1; j ...
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; int power(int p, int k) { int a = 1; while (k) { if (k & 1) a = (a * p) % mod; p = (p * p) % mod; k >>= 1; } return a; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tc = 1; ...
#include <bits/stdc++.h> using namespace std; struct time { int s; int e; }; int main() { int n; cin >> n; int s, e; int minc = INT_MAX, maxc = -1; for (int i = 0; i < n; i++) { cin >> s >> e; if (minc > e) { minc = e; } if (maxc < s) { maxc = ...
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long double PI = 3.141592653589793; const long long int INF = 9223372036854775807ll; void solve() { string p, h; cin >> p >> h; if (h.size() < p.size()) { cout << NO n ; return; } vector<int...
#include <bits/stdc++.h> using namespace std; namespace IO { const int maxn(1 << 21 | 1); char *iS, *iT, ibuf[maxn], obuf[maxn], *oS = obuf, *oT = obuf + maxn - 1, c, st[20]; int f, tp, len; inline char getc() { return iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int flag1; flag1 = 0; int flag2 = 0; for (int i = 0; i < n; i++) { if (s[i] == I ) { flag1++; } if (s[i] == A ) { flag2++; } } if (flag1 =...
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long INF = mod * mod; const long double eps = 1e-5; const long double pi = acos(-1.0); int n, m; long long w[1 << 18]; vector<int> G[1 << 18]; bool canr[1 << 18]; long long score[1 << 18]; int c[1 << 18]; b...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; const int K = 20; int go[N][K]; int tin[N], tout[N]; vector<int> g[N]; int timer = 0; int perm[N]; int where[N]; pair<int, int> t[4 * N]; int n; void dfs(int u, int p = 0) { go[u][0] = p; tin[u] = timer++; for (int ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); string s; cin >> s; string t = s; int n = s.size(); auto check = [&]() { for (int i = 0; i <= 0; i++) { int mx0 = 0, mx1 = 0, mmx0 = 0, mmx1 = 0; for (int j = i; j < n; j++) { ...
#include <bits/stdc++.h> using namespace std; const long long MAX1 = 1e6 + 10; long long T, a, b, c, d, e, f, x, y, z, l, r, mid, num[MAX1], cnt, flag, p1[55][55], p2[55][55]; string s, t; stack<char> st; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; cin...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int l; cin >> l; string s; cin >> s; if (s.length() % l != 0) { string pattern(l, 0 ); pattern[0] = 1 ; int times = s.length() / l + 1; while (times-- > 0) {...
#include <bits/stdc++.h> using namespace std; int cnt[5005]; int nearest[5005]; int main(void) { int n, m; cin >> n >> m; memset(cnt, 0, sizeof(cnt)); for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; b = b > a ? b : b + n; if (!cnt[a] || b < nearest[a]) nearest[a] =...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, mod = 1e9 + 7; const int maxn = 2e5 + 100, mxn = 5e5 + 100; const long double PI = acos(-1.0); long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); } void exgcd(long long a, long long b, long long& d, long long& x...
#include <bits/stdc++.h> using namespace std; vector<int> final; void seive(int n) { vector<bool> prime(n + 1, true); prime[0] = false; prime[1] = false; for (long long int i = 2; i <= (long long int)sqrt(n); ++i) { if (prime[i]) { for (int j = i * i; j <= n; j += i) prime[j] = false...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, w, l; cin >> n >> l >> w; long double p[n + 1]; long long int b[n + 1]; for (long long int i = 1; i <= n; i++) { cin >> p[i]; p[i] /= 100; } fo...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; multiset<long long> A, B; for (long long i = 0; i < n; i++) { long long num; cin >> num; A.insert(-num); } for (long long...
#include <bits/stdc++.h> using namespace std; int n, m; int adj[5000005], can[5000005], fuck[5000005]; inline int read() { int x = 0, f = 1; char ch = getchar(); for (; ch < 0 || ch > 9 ; ch = getchar()) if (ch == - ) f = -1; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; int n; int dig[N]; vector<int> ans[N]; bool vis[N]; int main() { cin >> n; vector<int> x; for (int i = (0); i < (n); i++) scanf( %d , &dig[i]), x.push_back(dig[i]); sort((x).begin(), (x).end()); for (int i = (0); i < ...
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; for (int i = 0; i < s1.size(); i++) { if (s1[i] <= 90) s1[i] += 32; if (s2[i] <= 90) s2[i] += 32; if (s1[i] > s2[i]) { cout << 1 << endl; return 0; } else if (s1[i] < s2[i])...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; char a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; ...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1000 + 20, MAX_K = 5 + 2; int a[MAX_K][MAX_N]; int dp[MAX_N]; map<int, int> D, ke; int ans; int n, k; int main() { ios::sync_with_stdio(false); cin >> n >> k; for (int i(0); i < int(k); ++i) for (int j(0); j < int(n); ++j)...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const char nl = n ; using vi = vector<int>; using vll = vector<ll>; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename... Args, template <typename...> typename T> strin...
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, need4demon, puppets; cin >> n >> x >> y; need4demon = ceil((y / 100.0) * n); if (x >= need4demon) puppets = 0; else puppets = need4demon - x; cout << puppets << endl; }
#include <bits/stdc++.h> using namespace std; long long n, a[1231231]; long long mark[1231231]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; mark[1] = 1; for (int i = 2; i <= n; i++) { mark[i] = mark[i - 1]; mark[i] = max(mark[i], a[i] + 1); } for (int i =...
#include <bits/stdc++.h> using namespace std; int a[1000000], n; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); int i = 1, j = n / 2 + 1; int ans = n; while (true) { if (i > n / 2) break; if (j > n) break; if (2 * a[...
#include <bits/stdc++.h> using namespace std; inline int read() { int sum = 0; char c = getchar(); bool f = 0; while (c < 0 || c > 9 ) { if (c == - ) f = 1; c = getchar(); } while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } if (f) r...
#include <bits/stdc++.h> using namespace std; inline int lowbit(int x) { return x & (-x); } int n, K, a[16], sum[1 << 16], mp[1 << 16], b[16], fac[2001], vl[2001]; bitset<2001> f[1 << 16]; vector<int> v[16]; void construct(int cur, int sum) { if (!cur) return; if (sum * K <= 2000 && f[cur][sum * K])...