func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int read(int &x) { return scanf( %d , &x); } int read(long long &x) { return scanf( %lld , &x); } int read(double &x) { return scanf( %lf , &x); } int read(int &x, int &y) { return scanf( %d%d , &x, &y); } int read(long long &x, long long &y) { return scanf( %ll... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { int num; cin >> num; v.push_back(num); } vector<pair<int, int> > vp; int x, y; for (int i =... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long INF = 1e18; bool isPrime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2)... |
#include <bits/stdc++.h> using namespace std; const long long BIG = 1000000007; const double PI = 3.141592653589793238; template <typename T, typename Q> T max(T a, Q b) { if (a < b) return b; return a; } template <typename T, typename Q> T min(T a, Q b) { if (a > b) return b; return a; ... |
#include <bits/stdc++.h> using namespace std; const double eps = (1e-8); int dcmp(double a, double b) { if (fabs(a - b) <= eps) return 0; return a < b ? -1 : 1; } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n, m; double w; cin >> n >> w >> m; double how =... |
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { v.push_back(0); for (int i = 0; i < int(30); i++) v.push_back(1 << i); while (1) { int hi, lo; int test; string s; cin >> s; if (s == mistake || s == end ) return 0; bool found = 0; f... |
#include <bits/stdc++.h> using namespace std; struct Tree { static const int MAXN = 500010; struct Edge { int son, dis; Edge *pre; void add(int _s, int _d, Edge *_p) { son = _s, dis = _d, pre = _p; } } edge[MAXN << 1], *pos[MAXN]; int sum; void clear() { sum = 0; me... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1073741824; const int N = 200005; const double PI = 4 * atan(1); set<char> vowel = { A , O , Y , E , U , I , a , o , e , u , y , i }; int dx[] = {1, -1, 0, 0, 1, -1, 1, -1}; int dy[] = {0, 0, 1, -1, 1, 1, -1, -1}; long long gcd(lon... |
#include <bits/stdc++.h> using namespace std; int main() { long long r = 0, mod = 1e9 + 7, a, b, i, z, x, y; cin >> a >> b; for (i = 1; i < b; ++i) { r += i * a + b * i % mod * (a * (a + 1) / 2 % mod); r %= mod; } cout << r << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int x = 0, y = 0, i, j, count = 0, n; cin >> n; string s1; cin >> s1; for (i = 0; i < n - 1; i++) { x = 0; y = 0; for (j = i; j < s1.size(); j++) { switch (s1[j]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int m; cin >> m; vector<int> b(m); for (int i = 0; i < m; ++i) { cin >> b[i]; } int M = -1, cur = 0; for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d%d , &n, &m); if (m == 3 && n > 4) return puts( -1 ), 0; for (int i = 1; i <= m; i++) printf( %d %d n , i, i * i + 300000); for (int i = 1; i <= n - m; i++) printf( %d %d n , i, -i * i - 300000); } |
#include <bits/stdc++.h> using namespace std; int R; vector<int> hv, use; vector<char> ans; int req[1000005]; int fr[1000005]; int main() { int n; scanf( %d , &n); if (n >= 1389) R = 4; else if (n >= 232) R = 3; else if (n >= 199) R = 2; else if (n >= 2) R =... |
#include <bits/stdc++.h> using namespace std; const int N = 1000000; long long cost[N][10], step[N][10], n; int getMax(int x) { int ret = 0; while (x) { ret = max(ret, int(x % 10)); x /= 10; } return ret; } void init() { for (int i = 0; i < N; i++) { int c = getMax(i); ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > v; vector<vector<int> > vv; vector<vector<long long int> > dp; void merg(int x) { if (v[x].size() == 1) return; if (v[x].size() == 2) { vector<int> v1; v1.push_back(0); for (int i = 0; i < v[x * 2].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, m, rb, cb, rd, cd; int count = 0; cin >> n >> m >> rb >> cb >> rd >> cd; if (rb <= rd && cb <= cd) cout << min(rd - rb, cd - cb) << endl; else if (rb <= rd && cb > cd) ... |
#include <bits/stdc++.h> using namespace std; long long n, q, a[3000000 + 5], m[3000000 + 5], dp[3000000 + 5]; inline long long read() { long long q = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = 0; ch = getchar(); } while (isdigit(ch)) q = (q << 3) + (q... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) w = -1; for (; isdigit(ch); ch = getchar()) s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; } inline void print(lo... |
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& _s, vector<T> _t) { for (int i = 0; i < (int)(_t.size()); i++) _s << (i ? : ) << _t[i]; return _s; } template <typename T> istream& operator>>(istream& _s, vector<T>& _t) { for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:16777216 ) const int inf = 0x3f3f3f3f; const long double pi = acos(-1.0); const string debug_line = yolo ; const double PI = 4 * atan(1); long long dp[81][81]; bool visited[81][81]; vector<pair<int, int> > Adj[81]; int n;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, q, w, x, y, flag = 0, sum = 0; char c; while (true) { c = getchar(); if (c == n ) break; sum = sum * 10 + int(c - 0 ); q = sum / 2; sum = sum % 2; } if (sum == 1 || q % 2 == 1) cout ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int deg[N]; vector<int> adj[N]; int e[N][3]; int seen[N]; int dfs(int u) { seen[u] = true; if (deg[u] == 1) return u; for (int i = 0; i < adj[u].size(); i++) if (!seen[adj[u][i]]) return dfs(adj[u][i]); } int main()... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a == 0) return b; if (b == 0) return a; return gcd(b % a, a); } long long int my_pow(long long int a, long long int b) { if (b == 0) return 1; if (b == 1) return a; long long int half ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; const ll MOD = 1e9 + 7, N = 2e5 + 10; vector<ll> g[N]; ll vis[N]; ll n, m, k; void bfs(ll s, vector<ll> &dist) { for (ll i = 1; i < n + 1; i++) { vis[i] = 0; } dist[s] = 0; queue<pii> q; ... |
#include <bits/stdc++.h> using namespace std; int str2int(string s) { istringstream ss(s); int t; ss >> t; return t; } int main() { string s; cin >> s; int ans = -1; for (int i = 1; i < s.length(); i++) { string s1 = s.substr(0, i); if (s1.length() > 1 && s1[0] == 0 ... |
#include <bits/stdc++.h> using namespace std; inline int calc(int x, int y, char c) { if (c == & ) return x & y; if (c == | ) return x | y; return x ^ y; } int work() { char c; scanf( %c , &c); if (c == ( ) { int l = work(); char op; scanf( %c , &op); int r = w... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const long double pi = acos(-1.0); const long double eps = 1e-5; const int INF = 0x3f3f3f3f; const long long INFLL = 0x3f3f3f3f3f3f3f3f; int a[300010]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007LL; long long large = 2000000000000000000LL; int main() { int n, m; cin >> n >> m; vector<vector<int> > adj(n, vector<int>()); set<pair<int, int> > s; for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; ... |
#include <bits/stdc++.h> using namespace std; typedef long long arr64[200020]; int n, tn, tS, qS = 1; pair<int, long long> pr[200020]; arr64 pX, pY, K, B; int main() { long long s; scanf( %d%I64d , &n, &s); for (int i = 1; i <= n; i++) scanf( %d%d , &pr[i].first, &pr[i].second); sort(pr + 1,... |
#include <bits/stdc++.h> using namespace std; const long long int N = 200010; const long long mod = 1000000007; const long long inf = 1000000000000000000; const long double pi = 3.14159265358979323846264338; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; ci... |
#include <bits/stdc++.h> using namespace std; template <typename T> T sqr(T x) { return x * x; } template <typename T> T abs(T x) { return x < 0 ? -x : x; } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } const int MOD = (int)1e+9 + 7; int n; vector<pair<int... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int N = 110; struct T { int bits; int x; int k; }; bool cmp(const T& a, const T& b) { return a.k < b.k; } T a[N]; long long dp[(1 << 20) + 4]; int n, m; long long b; long long Ans() { const long l... |
#include <bits/stdc++.h> using namespace std; long long n, a, b; int main() { cin >> n >> a >> b; for (long long tx = 0; tx <= n; tx += a) { if ((n - tx) % b == 0) { cout << YES << endl << tx / a << << (n - tx) / b << endl; return 0; } } cout << NO ; return 0... |
#include <bits/stdc++.h> using namespace std; char str[100010]; int dp[26][100010]; int maxP[260][260][260]; int len[3]; int idx[3]; char desc[3][260]; int get(int rel) { int m = maxP[idx[0] - (rel == 0)][idx[1] - (rel == 1)][idx[2] - (rel == 2)]; if (m == 100010) return 100010; return dp[de... |
#include <bits/stdc++.h> using namespace std; void task(); int main() { task(); return 0; } const int N = (int)1e5 + 10; const int MODULO = (int)1e9 + 3; const long long int INF = (long long int)1e18; const int BUF_SIZE = (int)1e5 + 10; bool used[110]; int n, k; int a[110], b[110]; long ... |
#include <bits/stdc++.h> using namespace std; const long long inf = INT_MAX, df = 3e5 + 7; long long i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, dp[df], pos[df], a[df]; inline long long read() { long long x = 0, y = 1; char ch = getchar(); while (ch > 9 || ch < 0 ) y = (ch == - )... |
#include <bits/stdc++.h> using namespace std; template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; } template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; } const long long mod = 1e9 + 7, N = 2e5 + 5; inline long long msb(long lo... |
#include <bits/stdc++.h> using namespace std; const int N = 123456; int n, d[N], h[N]; bool vis[N]; vector<int> G[N]; struct Node { int u, h; bool operator<(const Node& rhs) const { return h < rhs.h; } Node(int u, int h) : u(u), h(h) {} }; priority_queue<Node> pq; int bfs() { memset(d,... |
#include <bits/stdc++.h> using namespace std; map<int, int> f; long long fib[100] = {0}; int solve(long long n) { int what[100] = {0}; int ind = -1; for (int i = 90; i >= 0; i--) { if (n >= fib[i]) { n -= fib[i], what[i] = true; if (ind == -1) ind = i; } } vector<... |
#include <bits/stdc++.h> using namespace std; const int inf = 2e9 + 1e8; const long long INF = 2e18 + 1e17; const int mod = 998244353; const int MOD = 1e9 + 7; long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); } bool is_prime(int x) { if (x <= 1 || (x % 2 == 0 && x > 2)) r... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s1, s2; cin >> s1 >> s2; int n = s1.size(); int m = s2.size(); pair<pair<int, int>, pair<int, char> > parent[n + 1][m + 1][205]; int dp[n + 5][m + 5][205]; for (int ... |
#include <bits/stdc++.h> using namespace std; int DEBUG = 0; double Min(double a, double b) { return (a < b ? a : b); } double Max(double a, double b) { return (a > b ? a : b); } double Abs(double a) { return (a >= 0 ? a : -a); } void print1d(int *vec, int M, const char *str = NULL) { if (str != NULL) p... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:8000000 ) int main() { int n; scanf( %d , &n); if (n % 2 == 1) { printf( -1 ); return 0; } for (int k = 0; k != n; ++k) for (int i = 0; i != n; ++i) { for (int j = 0; j != n; ++j) ... |
#include <bits/stdc++.h> using namespace std; string a = 01234567891011121314151617181920212223242526272829303132333435363738394041 42434445464748495051525354555657585960616263646566676869707172737475767778 79808182838485868788899091929394959697989910010110210310410510610710810911 011... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; double l, v1, v2; scanf( %d%lf%lf%lf%d , &n, &l, &v1, &v2, &k); int num = n / k; if (num * k < n) { num++; } double w = (v1 + v2) * v2 / (2 * v1 * v2 * num + v2 * v2 - v1 * v2) * l; double t = w / v2 + (l - w)... |
#include <bits/stdc++.h> using namespace std; void SOLVE(int, int); int main() { int A, B; cin >> A >> B; SOLVE(A, B); return 0; } void SOLVE(int A, int B) { int T1 = min(A, B); int T2 = (A + B) / 2; cout << T1 << << abs(T2 - T1) << endl; } |
#include <bits/stdc++.h> using namespace std; const int Hash = 743; const int Mod = 51123987; int powh[2000005], N, h1[2000005], h2[2000005], start[2000005], finish[2000005], a[2000005], b[2000005]; char s[2000005]; int getsub1(int lo, int hi) { return lo == 0 ? h1[hi] : h1[hi] - h1[lo - 1] * powh... |
#include <bits/stdc++.h> using namespace std; vector<long long> v[100000 + 1]; long long n, m; long long taken[100000 + 1]; map<int, int> v2; int check = 0, sum; void bfs() { queue<long long> q; long long j, x, y; for (int i = 1; i <= n; i++) { if (taken[i] == 0) { q.push(i); ... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int a, b, c, d; cin >> a >> b >> c; d = (a + b + c) / 3; int ans = min(a, b); ans = min(d, ans); cout << ans << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chkmin(T &x, T y) { return y < x ? x = y, 1 : 0; } template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, 1 : 0; } inline long long Max(long long x, long long y) { return x > y ? x : y; } inline long... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100 * 1000 + 19; const int MASK = 20; const int inf = 2e9 + 19; long long n, m, dp[1 << MASK][MASK + 1]; string s[MAX_N]; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n >> m; for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100100; int n, m; long long h[MAX], t[MAX]; bool can(int cur, int last, int nxt, long long val) { if (t[last] >= h[cur]) return val >= t[nxt] - h[cur]; if (t[nxt] <= h[cur]) return val >= h[cur] - t[last]; return val >= min((h[cur] - t[... |
#include <bits/stdc++.h> using namespace std; double a[1 << 19]; double ans; int n, r, w; int main() { scanf( %d%d , &n, &r); w = 1 << n; for (register int i = 0; i < w; i++) { scanf( %lf , &a[i]); ans += a[i]; } printf( %.6lf n , ans / w); while (r--) { int pos; ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; void DBG() { cerr << ] << endl; } template <class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if (sizeof...(t)) cerr << , ; DBG(t...); } int main(void) { ios_base::sync_with_stdio(false); ... |
#include <bits/stdc++.h> using namespace std; struct node { int t, l, r, m; } op[5010]; int a[5010], b[5010], n, m; bool solve() { int p, i, k; for (i = 1; i <= n; i++) { a[i] = 1000000000; } memset(b, 0, sizeof(b)); for (p = 1; p <= m; p++) { if (op[p].t == 1) for ... |
#include <bits/stdc++.h> using namespace std; struct point { int n; int value; vector<int> next; } p[100010]; queue<struct point> q; int main() { int n, m, x, y, flag = 1, t; scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { scanf( %d %d , &x, &y); p[x].next.push_back(y)... |
#include <bits/stdc++.h> using namespace std; const int N = 16, K = 225; struct HASH { size_t operator()(const pair<long long, long long> &x) const { return hash<long long>()((x.first) ^ ((x.second) << 32)); } }; int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0}; int n, m; int len = 0; long... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 5e10 + 5; int main() { bool flag = 0; int n, ans = 0, k; cin >> n; int arr[n + 5]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); k = n / 2; for (int i = 0; i < n / ... |
#include <bits/stdc++.h> using namespace std; int val{0}; struct Triplet { char letter; int onePosn; int otherPosn; }; int findContinuous(string s) { int j{0}; for (auto i = 0; i < s.length() - 2; i++) { if (s[i] == Q && s[i + 1] == A && s[i + 2] == Q ) { j++; } ... |
#include <bits/stdc++.h> using namespace std; template <class T, class L> bool smax(T& x, L y) { return x < y ? (x = y, 1) : 0; } template <class T, class L> bool smin(T& x, L y) { return x > y ? (x = y, 1) : 0; } const int maxn = 2e5 + 17, mod = 1e9 + 7; struct Seg { int lazy[maxn << 2], ... |
#include <bits/stdc++.h> using namespace std; const int iL = 666666; char *iS, *iT, ibuf[iL]; inline char gc() { if (iS == iT) { iT = (iS = ibuf) + fread(ibuf, 1, iL, stdin); return iS == iT ? EOF : *iS++; } return *iS++; } template <class I> void gi(I &x) { static char c; ... |
#pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #define _CRT_SECURE_NO_WARNINGS # include <iostream> # include <cmath> # include <algorithm> # include <stdio.h> ... |
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { string a; cin >> a; int sz = int(a.size()); for (__typeof(sz) i = 0; i < sz; i++) for (__typeof(sz) j = 0; j < sz; j++) if (a.substr(0, i) + a.substr(j + 1) == CODEFORCES ) { cout << YES n ; ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-10; const int OO = 2147483647; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, -1, 1}; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin >> n; map<pair<long long, long... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 1; const int MOD = 1e9 + 7; long long a[MAXN], b[MAXN]; bool used[MAXN]; vector<int> g[MAXN]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; long long n, m, cnt = 0, ans = 0; bool y = 0; cin >> ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 * 1005; bool bad[maxn]; vector<int> blocked; vector<int> g[maxn]; bool seen[maxn]; int deg[maxn]; vector<int> good; int n, m, k; bool can(double mid) { memset(bad, 0, sizeof(bad)); memset(deg, 0, sizeof(deg)); memset(seen... |
#include <bits/stdc++.h> using namespace std; namespace MincostMaxFlow { const int maxn(2e5 + 5); struct Edge { int to, next, w, f; }; int first[maxn], cnt, vis[maxn], dis[maxn], S, T, pe[maxn], pv[maxn], maxflow, mincost; Edge edge[maxn * 20]; queue<int> Q; inline void Init(int _S, int _T) ... |
#include <bits/stdc++.h> using namespace std; int N; int A[3][30]; int p3[30]; map<pair<int, int>, pair<int, signed long long> > M[2]; void solve() { int i, j, k, l, r, x, y; string s; cin >> N; p3[0] = 1; for (i = 0; i < N; i++) p3[i + 1] = p3[i] * 3; for (i = 0; i < N; i++) cin >> ... |
#include <bits/stdc++.h> using namespace std; int node[100005][2]; int main() { int n, m; scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) scanf( %d%d , &node[i][0], &node[i][1]); int ans = node[0][1] + node[0][0] - 1; bool flag = 0; for (int i = 1; i < m; i++) { int d_val = node[i... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 600; char graph[MAXN][MAXN]; int dx[4] = {-1, 0, 0, 1}; int dy[4] = {0, -1, 1, 0}; vector<char> op; vector<pair<int, int> > pos; bool visited[MAXN][MAXN]; void solve(int x, int y, int n, int m, int initX, int initY) { visited[x][y] = t... |
// Author: Vinay Khilwani // Language: C++ // @vok8: Codeforces, AtCoder, LeetCode, HackerEarth, TopCoder, Google, FB, CSES, Spoj, GitHub // @vok_8: CodeChef, GFG // @vok8_khilwani: HackerRank // Never Stop Trying. // Trying to be Better than Myself. // while(true) // { // if(AC) // ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, h, m, l, r, x; cin >> n >> h >> m; vector<int> v(n, h); for (int i = 0; i < m; i++) { cin >> l >> r >> x; for (int j = l - 1; j < r; j++) { v[j] = min(v[j], x); } } long long sum = 0; for (int i =... |
#include <bits/stdc++.h> using namespace std; int main() { string s1; cin >> s1; int condition = 1; for (int i = 1; i <= s1.length(); i++) { if (s1[i] == s1[i - 1]) { condition++; if (condition == 7) { cout << YES << endl; return 0; } } else ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; pair<int, int> point[n]; for (int i = 0; i < n; i++) { cin >> point[i].first >> point[i].second; } sort(point, point + n, [](pair<int, ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int hoa = 0; int thuong = 0; for (int i = 0; i < s.size(); i++) { if (s[i] >= 65 && s[i] <= 90) { hoa++; } else { thuong++; } } if (thuong >= hoa) { for (int i = 0; i < ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long long int cmod = 998244353; const long long int N = 2e5 + 5; const long long int inf = 1e16 + 2; void solve(long long int ze) { long long int n, x, t, pr = 0; cin >> n >> x; vector<long long int> ans; ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-8; const int mod = 1e9 + 7; const int inf = 1061109567; const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; double dp[205][205][405], p[205]; int a[205]; int main() { int n, l, tmp; cin >> n ... |
#include <bits/stdc++.h> using namespace std; inline long long in() { long long x = 0; int n = 1; char c = getchar(); while (!isdigit(c)) { n = (c == - ) ? -1 : 1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - 0 ; c = getchar(); } return x * n; } ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long mod1 = 998244353; const double pie = 3.1415926535; unsigned long long power(unsigned long long x, unsigned long long y) { if (y == 0) return 1; else { if (y % 2 == 0) return power(x * x, y ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long binPow(long long a, long long b) { long long x = 1, y = a; while (b) { if (b & 1) x = (x * y) % mod; y = (y * y) % mod; b >>= 1; } return x % mod; } long long inverserEuler(int n) { return binPow... |
#include <bits/stdc++.h> using namespace std; long long int n, p, l, r, K; long long int gt[100005], rev[100005], gt1[100005]; long long int mu(long long int a, long long int n, long long int K) { if (n == 0) return 1; long long int q = mu(a, n / 2, K); if (n % 2 == 0) return q * q % K; return q... |
#include <bits/stdc++.h> using namespace std; int s, n, m, t, x, y; vector<int> ord; vector<vector<int>> g; bool vis[200010]; void dfs(int c) { vis[c] = true; for (auto &v : g[c]) { if (!vis[v]) dfs(v); } ord.push_back(c); } int main() { std::istream::sync_with_stdio(false); ... |
#include <bits/stdc++.h> using namespace std; int n, l, top, tmp, m, c[12]; bool opt[12][11][1 << 13]; void Search(int t, int v, int sum, int u, int i) { if (v < 0) return; if (sum >= v) opt[t][sum - v][u | (1 << t)] = 1; if (i >= t) return; if (((u >> i) & 1) == 1 && c[i] + 1 < c[t]) Sear... |
#include <bits/stdc++.h> using namespace std; int n, m; int a[100010]; long long ans = 0; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int Q = 0; Q < 20; Q++) { for (int j = 1; j <= n; j++) if (a[j] & (1 << Q)) { int k = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; char c; cin >> n >> m; vector<int> rows(n), cols(m); vector<vector<bool> > A(n); for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) { cin >> c; if (c == * ) { A[i].push_back(true); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); vector<vector<int>> t(n); for (int i = 0; i < m; ++i) { int x, y; scanf( %d %d , &x, &y); --x, --y; t[x].push_back(y); t[y].push_back(x); } vector<int> dist(n * n, -1); ... |
#include <bits/stdc++.h> using namespace std; const int mo = 1e9 + 7; const int N = 200005; map<int, int> mx, my; int n, x, y, dx, dy, cnt, answer; int parent[N], Size[N]; bool flag[N]; int get_parent(int x) { if (parent[x] == x) { return x; } else { return get_parent(parent[x]); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, x; cin >> n >> x; int mins = 0; int prevr = 1; for (int i = 0; i < int(n); i++) { int l, r; cin >> l >> r; mins += ((l - prevr) % x + ((r - l) + 1)); ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int res = 1; a %= 1000000007; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % 1000000007; a = a * a % 1000000007; } return res; } long long int modI... |
#include <bits/stdc++.h> using namespace std; int n, a[100001], t, l, r; int _gcd[262144][19], _min[262144][19], _num[262144][19]; int gcd(int x, int y) { if (x < y) swap(x, y); if (y == 0) return x; int r = x % y; return gcd(y, r); } int main() { scanf( %d , &n); for (int i = 1; i <... |
#include <bits/stdc++.h> using namespace std; int dp[2005][2005][2][2]; int m, d, mod = 1e9 + 7; string a, b; int solve(int i, int mm, bool aa, bool bb) { if (i == a.size()) return !mm; int &x = dp[i][mm][aa][bb]; if (x != -1) return x; x = 0; for (int j = 0; j <= 9; j++) { if (i % 2... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long linf = 1e18; const double pi = acos(-1.0); const int MAXN = 150000 + 10; const int MAXM = 1e5 + 10; const double eps = 1e-8; bool du[MAXN]; vector<int> g[MAXN]; bool vis[MAXN]; int sum; bool flag; void df... |
#include <bits/stdc++.h> using namespace std; int t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { string s; cin >> s; s = 0 + s; s = s + 0 ; for (int i = 1; i <= s.size(); i++) { if (s[i] == ? ) { if (s[i - 1] ==... |
#include <bits/stdc++.h> using namespace std; int mas[21][21]; int n, m; inline bool checkarr() { for (int i = 0; i < n; i++) { int wrongs = 0; for (int j = 0; j < m; j++) { if (mas[i][j] != j + 1) wrongs++; if (wrongs > 2) return false; } } return true; } inlin... |
#include <bits/stdc++.h> using namespace std; const long long mxN = 1e5 + 5; const long long INF = 1e18; const long long mod = 1e9 + 7; signed main() { long long n; cin >> n; vector<string> v(n); for (long long i = 0; i < n; i++) { cin >> v[i]; } map<long long, long long> o, c; ... |
#include <bits/stdc++.h> using namespace std; int a, c, d[205], f, n, b, x, i; string s, s1, s11, s12; char i1, i2, j; int main() { cin >> n; for (i = 1; i <= n; i++) { cin >> s1; b = s1.size(); c = c + b; s = s + % ; s = s + s1; } c = c + n - 1; for (i1 = a... |
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<int> cur; unordered_set<long long> bad; unordered_set<int> was; void err() { cout << impossible << endl; exit(0); } void go(int x) { cur.push_back(x); vector<int> g; for (auto it = was.begin(); it != was.end(); it++)... |
#include <bits/stdc++.h> using namespace std; int main() { long int n, k, a[222], i; cin >> n >> k; for (i = 1; i <= 2 * n + 1; i++) { cin >> a[i]; } for (i = 2; i <= 2 * n; i += 2) { if ((a[i] - a[i - 1] > 1) && (a[i] - a[i + 1] > 1) && k > 0) { a[i]--; k--; } ... |
#include <bits/stdc++.h> using namespace std; template <typename Tp> inline void read(Tp &x) { static bool neg; static char c; x = 0, neg = 0, c = getchar(); for (; !isdigit(c); c = getchar()) { if (c == - ) { neg = 1; } } for (; isdigit(c); c = getchar()) { x = ... |
#include <bits/stdc++.h> using namespace std; void add(int& a, int b) { a += b; a = min(a, 100000000); } const int MX = 300005; int root[MX]; bool is_left[MX]; vector<int> nodes[MX]; int left_size[MX], right_size[MX]; int ans = 0; char s[MX]; vector<int> comps[MX]; int main() { int n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.