func_code_string
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; int main() { int h1, a1, c1, h2, a2; int move_counter = 0; vector<char> move; cin >> h1 >> a1 >> c1 >> h2 >> a2; while (h2 > 0) { if (h2 - a1 <= 0) { move.push_back( S ); ++move_counter; break; } else { if ...
#include <bits/stdc++.h> using namespace std; long long n, k, x[1010], dp[1010][1010], sm[1010]; long long solve(long long gap) { dp[0][0] = 1, x[0] = -200000; for (long long i = 1; i <= k; ++i) { for (long long j = 0; j <= n; ++j) sm[j] = j == 0 ? dp[i - 1][j] : (dp[i - 1][j] + sm[j - 1]) %...
#include <bits/stdc++.h> using namespace std; int main() { int arr[1000]; int num; cin >> num; for (int i = 0; i < num; i++) { cin >> arr[i]; arr[num + i] = arr[i]; } int ans = 360; for (int i = 0; i < num; i++) { int temp = 0; for (int j = i; j < num * 2; j++) { ...
#include <bits/stdc++.h> using namespace std; int n, a, b; char s[1000005]; int arr[205]; int main() { scanf( %d%d%d%s , &n, &a, &b, s); int i, j, len = strlen(s), tag; if (len > n * b || len < n * a) { puts( No solution ); return 0; } int eve = len / n; for (i = 0; i < n; ...
#include <bits/stdc++.h> using namespace std; int main() { char instr[51], outstr[51] = {}, ch; int n, i; cin >> instr; cin >> n; for (i = 0; i < strlen(instr); i++) { if (instr[i] < 97) instr[i] += 32; } for (i = 0; i < strlen(instr); i++) { ch = instr[i]; if (int(ch) ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<int> arr(N + 2); arr[0] = 1; for (int i = 0; i < N; ++i) cin >> arr[i + 1]; arr[N + 1] = 1; int q = M, w = M; int r = 0; while (q > 0 || w < N + 1) { ...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d = 0, e = 0, f = 0, g = 0, i, j, k = 1, l = 1, r = 1, n[300001], m[300001], q, u, v, w, y, z[400001], h[400001], p[500001]; string s, t, x; cin >> a >> b >> c; for (i = 1; i <...
#include <bits/stdc++.h> using namespace std; long long int d[300002]; int safe[300002]; bool solve() { long long int n, k, l, i; cin >> n >> k >> l; for (i = 1; i <= n; i++) cin >> d[i]; int tide, dir, mtide; tide = k; dir = -1; for (i = 1; i <= n; i++) { if (d[i] + k <= l) ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; long long int a[n]; unordered_map<long long int, long long int> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]]++; } if (mp.size() ...
#include <bits/stdc++.h> using namespace std; const long long MAX = 2e5 + 10; int n; string s, xx = RGB ; int getID(char c) { if (c == R ) return 1; else if (c == G ) return 2; return 3; } int last[4]; int dp[MAX][4][4][4]; int mn = 1e9; vector<char> v, ans; int tokyoGho...
#include <bits/stdc++.h> using namespace std; template <class T> T min(T a, T b, T c) { return min(a, min(b, c)); } template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } int r, c, k, n, a[15][15]; int main() { scanf( %d%d%d%d , &r, &c, &n, &k); for (int i = (1); i <= (n...
#include <bits/stdc++.h> using namespace std; const int maxn = 5010, inf = 0x7fffffff; bool has[maxn][maxn], flag = 0; int sum[maxn][maxn], n, m, l[10], r[10], req; long long ans; void init() { for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) sum[i][j] = sum[i - 1][j] ...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, ta, tb; cin >> a >> ta >> b >> tb; int t, m; char c; cin >> t >> c >> m; m += 60 * t; int cur = 5 * 60; int res = 0; while (cur < 24 * 60) { if (min(cur + tb, m + ta) > max(cur, m)) ++res; cur += b; ...
#include <bits/stdc++.h> using namespace std; const long long mod = 100000007; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a %...
#include <bits/stdc++.h> using namespace std; int main() { int n; string res = ; cin >> n; int arr[2004] = {0}; for (int i = 0; i < n; ++i) { cin >> arr[i]; } int now_rejt = 0; int mesto = 1; for (int i = 0; i < n; ++i) { now_rejt = arr[i]; mesto = 1; fo...
#include <bits/stdc++.h> using namespace std; map<int, map<int, vector<int>>> answers; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int bus, tram, money; cin >> bus >> tram >> money; string s; cin >> s; int cur = s.size() - 2; while (true) { c...
#include <bits/stdc++.h> using namespace std; int GCD(int x, int y) { return !y ? x : GCD(y, x % y); } int LCM(int x, int y) { return x * y / GCD(x, y); } long long ceilDivision(long long dividend, long long divisor) { return (dividend + divisor - 1) / divisor; } bool check(pair<long long, int> right, p...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> dir_graph; vector<int> vis, order; void dfs(int i) { vis[i] = true; for (int j = 0; j < dir_graph[i].size(); j++) { if (!vis[dir_graph[i][j]]) { dfs(dir_graph[i][j]); } } order.push_back(i); } int main() { ...
#include <bits/stdc++.h> using namespace std; int main() { char ch[] = { B , u , l , b , a , s , a , u , r }; map<char, int> mp; string ss; int n, k, i, cnt = 100000; cin >> ss; for (i = 0; i < ss.size(); i++) { mp[ss[i]]++; } for (i = 0; i < 9; i++) { k = mp[ch[i...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n; if (n % 2 == 0) printf( -1 n ); else { for (k = 0; k < n; k++) printf( %d , ((n / 2 + 1 - k) + n) % n); cout << endl; for (k = 0; k < n; k++) printf( %d , ((n / 2 + 2 * k) + n) % n); cout <...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int n; int arr1[10]; int arr2[100005]; pair<int, int> diffs[600005]; int cnts[100005]; int main() { while (scanf( %d , arr1) == 1) { for (int i = 1; i < 6; ++i) { scanf( %d , arr1 + i); } scanf( %d , ...
#include <bits/stdc++.h> using namespace std; int main() { char a; cin >> a; string str1, str2; cin >> str1 >> str2; int b1, b2; switch (str1[0]) { case T : b1 = 10; break; case J : b1 = 11; break; case Q : b1 = 12; break; ...
#include <bits/stdc++.h> using namespace std; const int N = 5001; int n, m, x, y, c[N], p[N], A; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) p[i] = N; while (m-- && cin >> x >> y) c[x]++, p[x] = min(p[x], (y + n - x) % n); for (int i = 1; i <= n; i++) { A = 0; for (int j...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 50; int n, q; int lca[N][25], mark[N], sum[N], h[N], a[N][4]; vector<int> adj[N]; map<int, map<int, int> > m; void DFS(int v, int p, int hi) { h[v] = hi; lca[v][0] = p; for (auto u : adj[v]) { if (u == p) continue; D...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long maxn = 1e5 + 5; void solve() { long long k; cin >> k; long long first = pow(2, 17); cout << 2 << << 3 << n ; cout << first + k << << first << << 0 << n << k << << first ...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 6; int n, m, k; int s[N], c[N]; bool vis[N]; int fir[N]; long long ans = 1e15; void can(int u) { long long rep = 0; for (int i = 1; i <= n;) { if (fir[i + u] == i) { return; } rep += c[u]; if (i + u...
#include <bits/stdc++.h> using namespace std; int where[26][26]; int n, dp[(1 << 23) + 5], d[35]; bool fdp[(1 << 23) + 5]; int rec(int mask) { if (fdp[mask]) return dp[mask]; int next = 0; for (int i = n - 1; i >= 0; --i) { if (mask & (1 << i)) { next = i; break; } ...
#include <bits/stdc++.h> using namespace std; long long a, b, p, q, ay, by, tx, g, l, ty, x, y, n = 15, d, m, tot, last, lst2; map<int, int> wow; long long shob[104]; vector<int> all; char c; int setbit(int n, int pos) { return n | (1 << (pos)); } int isbit(int n, int pos) { return n & (1 << (pos)); } ...
#include <bits/stdc++.h> using namespace std; const long long mod = (long long)1e9 + 7; const long long inf = (long long)1e16; const long double eps = 1e-12; const long long N = (int)1e5 + 5; const long long LOGN = 19; const long double PI = 3.14159265358979323846; inline long long mul(long long a, long...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; if (n / k % 2) printf( YES n ); else printf( NO n ); return 0; }
#include <bits/stdc++.h> using namespace std; int maxx(int fd, int sd) { return (fd > sd) ? fd : sd; } int minn(int fd, int sd) { return (fd < sd) ? fd : sd; } long long nod(long long a, long long b) { if (a < b) { return nod(b, a); } if (b == 0) { return a; } return nod(b, a % b...
#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; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } long long gcd(long...
#include <bits/stdc++.h> using namespace std; struct edge { int b; bool x; edge *next; } E[100010], *rt[100010]; int o = 0; int mi = 100000000; int N; void addedge(int a, int b) { edge *p = &E[o++]; p->b = b; p->x = false; p->next = rt[a]; rt[a] = p; p = &E[o++]; p-...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long h[100000], ans[100000]; cin >> n; for (int i = 0; i < n; i++) cin >> h[i]; ans[n - 1] = 0; for (int i = n - 2; i >= 0; i--) { if (h[i] <= h[i + 1]) ans[i] = h[i + 1] - h[i] + 1; else ans[i...
#include <bits/stdc++.h> int inp() { char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); int sum = 0; while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum; } int root[1000010]; struct President_Tree { int lc[10000000], rc[10000000...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { while (b) { int temp = b; b = a % b; a = temp; } return a; } int main() { int a, b, n, counting = 0, GCD; scanf( %d %d %d , &a, &b, &n); while (1) { counting++; GCD = gcd(a, n); if (...
#include <bits/stdc++.h> using namespace std; long long date(int y, int m, int d) { if (m < 3) y--, m += 12; return (long long)365 * y + y / 4 - y / 100 + y / 400 + (153 * m - 457) / 5 + d - 306; } int main() { int y1, y2, m1, m2, d1, d2; scanf( %d:%d:%d , &y1, &m1, &d1); scanf( %...
#include <bits/stdc++.h> using namespace std; mt19937 Rand(time(0)); long long rnd(long long a) { return Rand() % a; } long long rnd(long long a, long long b) { return Rand() % (b - a + 1) + a; } double rnd_01d() { return (double)Rand() / (1ll << 32); } double rnd_d(double r) { return rnd_01d() * r; } con...
#include <bits/stdc++.h> using namespace std; int minimum(int x, int y) { return (x < y ? x : y); } template <typename type> struct even { bool operator()(const type &x, const type &y) const { return x % 2 == 0; } }; template <typename type> struct odd { bool operator()(const type &x, const type &...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << (n * 3) / 2 << endl; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 50; long long kol, sum, id, ans; string s; vector<long long> a; int main() { cin >> s; ans = 0; sum = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == v ) { id += 1; if (i == s.size() - 1) { ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(NULL); int n, x; cin >> n; while (n--) { cin >> x; if (x < 3 || x == 4 || x == 5 || x == 8 || x == 11) cout << NO << endl; else cout << YES << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; int ans = 0; cin >> n >> m >> k; int t; for (int i = 0; i < n; ++i) { cin >> t; if (t == 1) { if (m == 0) ++ans; else --m; } else { if (m + k == 0) ++an...
#include <bits/stdc++.h> using namespace std; const int MAXN = 300005; const int MAXINT = 1073741823; vector<int> neighbors[MAXN]; int a[MAXN]; int greater_right[MAXN]; int greater_left[MAXN]; int less_right[MAXN]; int less_left[MAXN]; int dp[MAXN]; stack<int> s; int main() { ios::sync_with_...
#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 ll = long long; using ld = long double; using ull = unsigned long long; using namespace std; const int N = 2e5 + 2, mod = 998244353; int n, m, d[N][20]; pair<int, int> dist[N][2]; vector<int> g[2][N]; struct State { int d, ver, B; bool operator<(const State& oth)...
#include <iostream> #include <algorithm> #include <cassert> #include <fstream> using ll = long long; const int maxn = 5007; ll t, n, S[maxn], ans[maxn]; ll res; int main(int argc, char *argv[]) { std::ios::sync_with_stdio(false); std::cin.tie(0); std::cin >> t; while (t--) { res...
#include <bits/stdc++.h> using namespace std; int n, k, pos; long long a[200005], sum[200005], ans; vector<long long> vec; int main() { cin.tie(0), ios::sync_with_stdio(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; sum[i] = a[i]; sum[i] += sum[i - 1]; if (a...
#include <bits/stdc++.h> using namespace std; int a[300000]; int ans[300000]; map<int, int> m; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int n; scanf( %d , &n); for (int i = 0; i < n * n; i++) { scanf( %d , &a[i]); m...
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, long long int>> v1; int main() { long long int n, i, A[300005], minn, t1, a1, i1; cin >> n; for (i = 1; i <= n; i++) { cin >> A[i]; v1.push_back(make_pair(A[i], i)); } minn = 10000000000; for (i = 2; i <= ...
#include <bits/stdc++.h> using namespace std; const int maxN = 2e5 + 10; const long long oo = 1e18; char s[maxN]; long long cost[maxN][2]; int main() { int test; scanf( %d , &test); while (test--) { int n, a, b; scanf( %d%d%d%*c , &n, &a, &b); gets(s); cost[0][0] = b; ...
#include <bits/stdc++.h> using namespace std; int n, a[100001], g[100001], h[100001], m; set<int> events[100001]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) events[i].clear(); for (int i = 1; i <= n; i++) scanf( %d , &a[i]), events[a[i]].insert(i); m = 0; bool ok = true; ...
#include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t,f[200009],A[200009],B[200009],rg[200009][20],rgx[200009][20],lf[200009][20],lfx[200009][20],P[200009],pas; stack <long long> st; set <long long> s; set <long long>::iterator it,lft,rgt; long long uprg(long long q, long lo...
#include <bits/stdc++.h> using namespace std; int solve(int n, int m, int k) { if (n > m) return 0; if (n == 0) return min(m + 1, (1 << (k + 1))); if ((1 << k) & n) { int c = solve(n - (1 << k), m - (1 << k), k - 1); if (c == (1 << k)) return (1 << (k + 1)); else return...
#include <bits/stdc++.h> using namespace std; bool f = 0; const double eps = 1e-8; int n; struct point { double x, y; } p[100010]; inline int rd() { int x = 0; bool f = 0; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = 1; c = getchar(); } while (isdigit...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const long long inf = 2e9 + 10; template <typename T1, typename T2> static void relax(T1 &x, T2 y) { if (x > y) x = y; } template <typename T1, typename T2> static void gain(T1 &x, T2 y) { if (x < y) x = y; } long long po...
#include <bits/stdc++.h> using namespace std; long long a[200010]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int f = 0; for (int i = 1; i < n; i++) if (a[i] != a[i - 1]) { f = 1; break; ...
#include <bits/stdc++.h> using namespace std; int gcd(int(a), int(b)) { return ((a) % (b) ? gcd((b), (a) % (b)) : (b)); } long long lgcd(long long(a), long long(b)) { return ((a) % (b) ? gcd((b), (a) % (b)) : (b)); } int lcm(int a, int b) { return (a) / gcd((a), (b)) * b; } long long llcm(long long a, l...
#include <bits/stdc++.h> using namespace std; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1}; const int dx8[] = {-1, 0, 1, 0, 1, 1, -1, -1}; const int dy8[] = {0, -1, 0, 1, 1, -1, 1, -1}; void solve() { long long n; cin >> n; vector<long long> a(n); vector<vector<long long>> ...
#include <bits/stdc++.h> using namespace std; template <class node> struct link_cut_tree { bool connected(node* u, node* v) { return lca(u, v) != NULL; } int depth(node* u) { access(u); return get_sz(u->ch[0]); } node* get_root(node* u) { access(u); while (u->ch[0]) u = u->...
#include <bits/stdc++.h> using namespace std; map<int, map<int, int> > m; long long int lol(long long int a, long long int r) { if (a >= 0 && r <= 0) return a; if (a <= 0 && r >= 0) return a; return a % r; } int main() { long long int a, b; cin >> a >> b; string s; cin >> s; lo...
#include <bits/stdc++.h> using namespace std; const int V = 100100; int l[V], r[V], a[V], ret, n; int main() { while (~scanf( %d , &n)) { ret = 0; for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) l[i] = r[i] = i; for (int i = 1; i <= n; i++) { whi...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 17; int n; vector<int> adj[(1 << MAX_N) + 9]; bool used[(1 << MAX_N) + 9]; int cnt[(1 << MAX_N) + 9]; vector<int> vRoot; vector<int> ans; void buildCnt(int x) { used[x] = true; cnt[x] = 1; for (int y : adj[x]) { if (!use...
#include <bits/stdc++.h> using namespace std; int n, k, maxx, idx, max1, s; int main(int argc, char *argv[]) { pair<int, int> a[10000]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = 0; } maxx = 0; max1 = 0; for (int i = 0; i < n; i++) { if (...
#include <bits/stdc++.h> using namespace std; long long z, mn, mx, sum, ans, k, pos, pos1, r, xx, yy, zz, n, m, x, y; vector<int> v; bool OK[1000002], KO[1000002], zoom; int b[100003], c[100002]; map<char, int> mp, mr; set<int> st; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >...
#include <bits/stdc++.h> using namespace std; int main(void) { long long int n = 0ll, k = 0ll, p = 0ll, pn = 0ll, even = 0ll, odd = 0ll; while (cin >> n) { cin >> k >> p; if (k == 0) { for (long long int i = 0; i < p; i++) { cin >> pn; cout << . ; } c...
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int fin(int rem) { for (auto p : mp) { if (p.first >= rem) return p.first; } return -1; } int main() { long long ans = 0, rem = 0, p, x, y, n, RES = 1e9; cin >> n >> x >> y; long long a[] = {x, x, x, x, y, y}; so...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2000005; template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -f; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; x *= f; } templ...
#include <bits/stdc++.h> using namespace std; int sum[100005]; int main() { int h1, h2, a, b, k, x; cin >> h1 >> h2 >> a >> b; int num = h1 + a * 8; if (num >= h2) x = 0; else if (a <= b) x = -1; else { x = 1; num -= b * 12; for (int i = 1;; i++) { num...
#include <bits/stdc++.h> const int N = 200010; const long long INF = 1ll << 60; const int inf = 0x3f3f3f3f; class SegmentTree { public: SegmentTree() {} void Init(int n, int v[]) { n_ = n; Build(1, n, 1, v); } void ChangeSingle(int l, int r, int rt, int id, int x) { if (l ==...
#include <bits/stdc++.h> int main() { int n, k; scanf( %d %d , &n, &k); printf( %d n , 6 * n * k - k); for (int i = 0; i < n; ++i) { printf( %d %d %d %d n , 6 * i * k + k, 6 * i * k + 2 * k, 6 * i * k + 3 * k, 6 * i * k + 5 * k); } return 0; }
#include <bits/stdc++.h> using namespace std; long long t, fact[405], inv[405], dp[405][405], ans[405], n, dp2[405]; long long p; long long exp(long long x, long long k) { if (k == 0) return 1; if (k % 2 == 1) return x * exp(x, k - 1) % p; long long y = exp(x, k / 2); return y * y % p; } int...
#include <bits/stdc++.h> using namespace std; struct Amulet { char p[2][2]; void Read() { cin >> p[0][0] >> p[0][1] >> p[1][0] >> p[1][1]; } Amulet Rotate() const { Amulet ret(*this); ret.p[0][0] = this->p[0][1]; ret.p[0][1] = this->p[1][1]; ret.p[1][0] = this->p[0][0]; ret...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; cout << (n / k + 1) * k; }
#include <bits/stdc++.h> using namespace std; struct node { int a; int id; bool operator<(const node &b) const { if (a != b.a) return a < b.a; else return id > b.id; } }; struct node que[305]; bool vis[305]; int main() { int t, n, m; scanf( %d , &t); w...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int ara[2 * n + 1], count = 0; for (int i = 0; i <= 2 * n; i++) { cin >> ara[i]; } for (int i = 0; count < k; i++) { if (ara[i] + 1 < ara[i + 1] && ara[i + 1] - 1 > ara[i + 2]) { ara[i + 1...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; set<char> ss; for (char c : s) ss.insert(c); if (ss.size() < n) cout << NO << endl; else { cout << YES << endl; int vis[30]; memset(vis, 0, sizeof vis); s...
#include <bits/stdc++.h> long long stk[300001][3], top = 1, n, m, best = 1, nownum, K, B; long long eval(long long x) { return (K + stk[x][0]) * stk[x][2] + B + stk[x][1]; } double intersect(long long x, long long y) { return (double)(stk[x][0] - stk[y][0]) / (stk[y][1] - stk[x][1]); } bool comp(lon...
#include <bits/stdc++.h> using namespace std; int to[55][35][35][4][3]; int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int Sign(int x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } int main() { int n, b; cin >> n >> b; ++b; for (int i = 0; i < b; ++i) { for (int j = 0; j < b; ++j) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, p, x; cin >> n >> k >> p; int impair(k - p); vector<int> pai, imp; for (int i = 0; i < n; ++i) { cin >> x; if (x & 1) imp.push_back(x); else pai.push_back(x); } int avpair(pai.size()), ...
#include <bits/stdc++.h> using namespace std; int main() { int x; cin >> x; cout << 25; }
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { x = 0; bool f = false; char ch = getchar(); while (!isdigit(ch)) { f |= ch == - , ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); ...
#include <bits/stdc++.h> using namespace std; template <class t> t mag(t a) { return a > 0 ? a : -a; } template <class T, class U> T cdiv(T num, U den) { return (num / den) + ((num % den) > 0); } std::ifstream term( /dev/tty ); std::string tempstring; using ll = int_fast64_t; using ii = pa...
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 28; const long long LINF = 1ll << 61; inline long long getnum() { register long long r = 0; register bool ng = 0; register char c; c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); if (c == - )...
#include <bits/stdc++.h> using namespace std; class Solve { public: int num; int inputNum[2005]; int inversion[2005][2]; int sequence[2005]; public: Solve() { num = 0; memset(inputNum, 0, sizeof(inputNum)); memset(inversion, 0, sizeof(inversion)); memset(sequence...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y; cin >> n >> m; y = 3 * m; x = 2 * n; for (int i = 6; i <= x && i <= y; i += 6) { if (x <= y) x += 2; else y += 3; } cout << max(x, y); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 505; bool arr[N][N]; int dp[N][N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, k; cin >> n >> m >> k; for (int i = 1; i <= n; i++) { string s; cin >> s; for (int j ...
#include <bits/stdc++.h> using namespace std; static long long mi[400005][20]; static bool mark[400005][20]; static long long psum[400005]; long long f(int x, int k) { if (k == 0) return psum[x]; if (mark[x][k]) return mi[x][k]; mark[x][k] = 1; return mi[x][k] = min(f(x, k - 1), f(x + (1 << (k...
#include <bits/stdc++.h> using namespace std; int get() { char ch; while (ch = getchar(), (ch < 0 || ch > 9 ) && ch != - ) ; if (ch == - ) { int s = 0; while (ch = getchar(), ch >= 0 && ch <= 9 ) s = s * 10 + ch - 0 ; return -s; } int s = ch - 0 ; while (ch ...
#include <bits/stdc++.h> using namespace std; bool vis[50]; bool OK(vector<set<int> > v) { for (int i = 0; i < (int)v.size(); i++) if ((int)v[i].size() > 3) return 1; return 0; } int Find(vector<set<int> > v, int x) { for (int i = 0; i < (int)v.size(); i++) if (find(v[i].begin(), v[i]....
#include <bits/stdc++.h> using namespace std; int main() { long long w1, h1, w2, h2; cin >> w1 >> h1 >> w2 >> h2; long long ans = h1 + h2 + 2; ans += h1 + h2 + 2 + (w1 - w2); ans += w1 + w2; cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100005; vector<int> cnt[N]; int res[N]; int main() { int n; while (cin >> n) { for (int i = 1; i < N; i++) cnt[i].clear(); for (int i = 1; i <= n; i++) { int v; cin >> v; cnt[v].push_back(i); } ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { int a, s, d; cin >> a >> s >> d; if (a > s) swap(a, s); if (a > d) swap(a, d); if (s > d) swap(s, d); if (s == d) { cout << YES << endl; cout << a << << a <...
#include <bits/stdc++.h> using namespace std; const int N = 1005; const int INF = 1e9; pair<int, int> NULLPOINT = make_pair(INF, INF); int n; int gcd(int x, int y) { while (y) { int t = x; x = y; y = t % y; } return x; } struct Line { int x, y, xx, yy; pair<int, int...
#include <bits/stdc++.h> int main() { long long n, k; scanf( %lld%lld , &n, &k); if (k < 2) { printf( %lld , n); return 0; } long long s = 1; while (s - 1 < n) s *= 2; printf( %lld , s - 1); }
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); int n; cin >> n; vector<long long> a(n); long long s = 0; for (int i = 0; i < n; i++) { cin >> a[i]; s += a[i]; } sort(a.begin(), a.end()); ...
#include <bits/stdc++.h> using namespace std; const int N = 160; const int mod = 1e9 + 7; int n, m, f[N][N][2][2], ans; void inc(int& a, int b) { if (a += b, a >= mod) a -= mod; } int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= m; ++i) for (int j = i; j <= m; ++j) { f[i...
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 5; char a[MAX_N]; int main() { int N; cin >> N; scanf( %s , a + 1); int cnt = 0; for (int i = 1; i <= N; i++) { if (a[i] == S && a[i] >= 2 && a[i - 1] == G ) { cnt++; } } if (a[N] == G ) cnt...
#include <bits/stdc++.h> using namespace std; int t, a[4][200010], len; string s; bool check(int x) { for (int i = x; i <= len; i++) if (a[1][i] - a[1][i - x] && a[2][i] - a[2][i - x] && a[3][i] - a[3][i - x]) return 1; return 0; } int main() { scanf( %d , &t); while (t--) { ...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-10; const long double INF = (int)1e9 + 34; const int N = (int)1e6 + 34; void ret(int x) { cout << x; exit(0); } int n, k; int a[N]; int b[N], len; bool u[N]; int main() { scanf( %d%d , &n, &k); for (int i = 0;...