func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c = 0; cin >> a >> b; int x[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6}; for (int i = a; i <= b; i++) { int y = i; while (y != 0) { c += x[y % 10]; y = y / 10; } } cout << c; return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using ld = long double; const int MN = 2e5 + 3, MOD = 1e9 + 7; void solve() { int n, a, b; scanf( %d %d %d , &n, &a, &b); if (a > b) swap(a, b); printf( %d %d n , min(n... |
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; const int N = (int)2e5 + 7; const int MOD = (int)1e9 + 7; const int INF = (int)2e7; const long long BIG = 1e18; int a[N], b[N], c[N], d[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.... |
#include <bits/stdc++.h> using namespace std; const int N = 151; int m, n; char gd[N][N]; inline int fab(int x) { return x > 0 ? x : -x; } int main() { while (scanf( %d%d , &m, &n) != -1) { for (int i = 0; i < m; i++) scanf( %s , gd[i]); int ans = 0, x = 0, y = 0; for (int i = 0; i < m... |
#include <bits/stdc++.h> using namespace std; long long g, r; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n, m; cin >> n >> m; vector<int> d; for (int i = 0; i < m; i++) { long long dt; cin >> dt; d.push_back(dt); } sort(d.begin(), d.en... |
#include <bits/stdc++.h> using namespace std; void no(int ex = -1) { cout << ex << n ; } void win(bool bl) { if (bl) cout << YES ; else cout << NO ; cout << n ; } const int N = 2 * 100000; const int mod = 998244353; double T, n, m, k, p, res, pr; bool bw; string str; in... |
#include <bits/stdc++.h> using namespace std; const int M = 1000000007; const int MM = 998244353; const long double PI = acos(-1); long long power(long long b, long long e, long long m) { if (e == 0) return 1; if (e & 1) return b * power(b * b % m, e / 2, m) % m; return power(b * b % m, e / 2, m);... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int M = 1e9 + 7; const int INF = 2e9 + 5; const int rx[8] = {-1, 0, 1, 0, 1, 1, -1, -1}; const int ry[8] = {0, -1, 0, 1, 1, -1, 1, -1}; mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count()); int main() { ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> g; vector<int> a; int n; vector<map<int, int>> dp; int ans = 0; int gcd(int a, int b) { while (b) { a %= b; swap(a, b); } return a; } void dfs(int v, int p = -1) { for (auto to : g[v]) { if (to != p) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; const int md = 1e9 + 7; int mul(int a, int b) { return (long long)a * b % md; } char s[N]; int n, m, nn, x[N], z[N]; bool start[N]; int main() { scanf( %d %d %s , &n, &m, s); nn = strlen(s); for (int i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int s; cin >> s; long long int tot = 0; while (s >= 10) { tot += s / 10 * 10; s = s / 10 + s % 10; } cout << tot + s << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.t... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; const long long EPS = 1e-9; long long mpow(long long a, long long b, long long p = MOD) { a = a % p; long long res = 1; while (b > 0) { if (b & 1) res = (res * a) % p; a = (a * a) % p; b = b >> 1; } ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } const long long MOD = (long long)(1e9) + 7; long long getVal(pair<pair<int, int>, long... |
#include <bits/stdc++.h> using namespace std; long long M = 1e15 + 37; const long long N = 1000 + 10; const long long IM = 1e18; const long long PI = 3.14159265; void PV(vector<long long> v) { for (long long i = 0; i < v.size(); i++) cout << v[i] << ; cout << n ; } void PA(long long v[], lo... |
#include <bits/stdc++.h> int dp[1000 + 1][3]; int v[1000 + 1]; inline int getmin(int a, int b) { if (a < b) return a; return b; } int main() { int n, i; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d , &v[i]); dp[1][0] = 1; if (v[1] % 2 == 1) dp[1][1] = 0; else ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> static inline void amn(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> static inline void amx(T &x, U y) { if (x < y) x = y; } const long long MOD = 1e9 + 7; const long long INF = 1e18; const l... |
#include <bits/stdc++.h> using namespace std; int binarySearch(int a[], int l, int r, int x); int main() { int n, m, i, temp; vector<int> v1; vector<int> v2; scanf( %d %d , &n, &m); for (i = 0; i < n; i++) { scanf( %d , &temp); v1.push_back(temp); } for (i = 0; i < m; i++) ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e4 + 3; const long long MOD = 998244353; int a[MAX]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; int s = 2 * n, mid = n, one = 0, left = 0; for (int i = 1; i <= k; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[200005]; scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); int s, t, m = 0; for (s = 0; s < n;) { t = s + 1; while (a[t] <= a[t - 1] * 2 && t < n) t++; int res = t - s; m = max(m, res); ... |
#include <bits/stdc++.h> using namespace std; int cmp(string s1, string s2) { if (s1 == rock && s2 == scissors ) return 1; if (s1 == scissors && s2 == paper ) return 1; if (s1 == paper && s2 == rock ) return 1; return 0; } int main() { string s1, s2, s3; cin >> s1 >> s2 >> s3; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; const long long mod = 1e9 + 7; long long mpow(long long a, long long b) { long long res = 1; while (b) { if (b % 2 == 1) { res = res * a; } b = b / 2; a = a * a; } return res; } long long pow... |
#include <bits/stdc++.h> using namespace std; template <class T> long long ToInt(const T &x) { stringstream s; s << x; long long r; s >> r; return r; } template <class T> string ToString(const T &x) { stringstream s; s << x; return s.str(); } int main() { string str, ... |
#include <bits/stdc++.h> using namespace std; int a, b, c, d, e, f, g, h, i, j, k; int father[100005][20]; vector<int> tree[100005]; int deep[100005]; int que[100005], num[100005]; int K; int an; void soso(int x) { int ii, jj, kk; que[++que[0]] = x; deep[x] = deep[father[x][0]] + 1; fo... |
#include <bits/stdc++.h> using namespace std; long long int a[505], b[505]; void solve() { long long int n; cin >> n; for (long long int i = 1; i <= n; i++) cin >> a[i]; for (long long int i = 1; i <= n; i++) cin >> b[i]; long long int x = (n + 1) / 2; if (n % 2 == 1 && a[x] != b[x]) { ... |
#include <bits/stdc++.h> #define ll long long #define f(n) for(ll i=0;i<n;i++) #define mod 998244353 #define vl vector<ll> #define pb push_back #define mk make_pair #define forn(i, n) for (int i = 0; i < int(n); i++) #define nl n #define IOS ios_base::sync_with_stdio(false); #include <iostrea... |
#include <bits/stdc++.h> using namespace std; using ll = long long int; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll,ll> ii; typedef vector<ii> vii; typedef vector<vii> vvii; #define F first #define S second ll min(ll x, ll y){ return ((x < y) ? x : y); } ll max(... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b, c; cin >> n >> a >> b >> c; long long x = n % 4; long long y = 4 - x; if (n % 4 == 0) cout << 0 << n ; else { if (y == 1) { cout << min(min(a, b + c), 3 * c) << n ; } else if (y == 2) ... |
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; inline long long gcd(long long a, long long b) { a = ((a) < 0 ? -(a) : (a)); b = ((b) < 0 ? -(b) : (b)); while (b) ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long fin(long long a, long long b) { long long ans = 1; a %= mod; while (b) { if (b % 2 == 1) { ans = (ans * a) % mod; } a = (a * a) % mod; b = b / 2; } return ans; } int main() {... |
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); //freopen( input.txt , r ,stdin); //freopen( output.txt , w ,stdout); int T; cin>>T; for(int t=0;t<T;t++){ int n,k; cin>>n>>k; if(n==1&&k==1){cout<<0<<endl;continue;} ... |
#include <bits/stdc++.h> using namespace std; long long n, m, A; long long b[200005]; long long beki[200005]; long long pow(long long a, long long n) { if (n == 0) return 1; if (n % 2) { return ((a % 998244353) * (pow(a, n - 1) % 998244353)) % 998244353; } else { return pow((a * a) % 9... |
#include <bits/stdc++.h> using namespace std; void init_code() {} long long int c[207]; bool adj[207][207]; long long int n; void dfs(long long int u, long long int cu) { if (~c[u]) { if (c[u] ^ cu) { cout << NO << n ; exit(0); } return; } c[u] ... |
#include <bits/stdc++.h> using namespace std; template <typename A> using VE = vector<A>; template <typename A> using USET = unordered_set<A>; template <typename A> using HEAP = priority_queue<A>; template <typename A, typename B> using PA = pair<A, B>; template <typename A, typename B> using UMAP... |
#include <bits/stdc++.h> using namespace std; int a[27], c[27], d[27]; int main() { int count, i, n, max, co, t, index, k; char str[1010], ch, b[1010]; ch = getchar(); while (ch != n ) { a[ch - a + 1]++; ch = getchar(); } count = 0; for (i = 1; i <= 26; i++) if (a... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 5, mod = 1e9 + 7, inf = 1e18; long long n, m, ans[maxn], h[maxn], par[20][maxn], mx[20][maxn], pw2[20], p[maxn], sz[maxn], ip[maxn]; vector<pair<long long, long long>> v1[maxn], v2[maxn]; vector<pair<long long, pair<long long, lo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, v; cin >> n; for (int i = 0; i < n; i++) { cin >> v; if (v == 1) { cout << -1; return 0; } } cout << 1; } |
#include <bits/stdc++.h> using namespace std; int main() { cout << INTERCAL << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { set<int> s; int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; s.insert(x); } set<int>::iterator it, it1, it2; it = s.begin(); it1 = it; it1++; it2 = s.end(); it2--; if (s.size()... |
#include <bits/stdc++.h> using namespace std; const int N = 2000010; int n, ans, q[N], x[N], y[N]; struct node { int a, b, m, id; }; vector<node> a[N]; bool cmp(node x, node y) { return x.a < y.a; } void Work() { scanf( %d , &n); for (int i = 1, x, y, z; i <= n; i++) { scanf( %d%d%d , ... |
#include <bits/stdc++.h> using namespace std; int d8x[8] = {1, -1, 0, 0, 1, 1, -1, -1}; int d8y[8] = {0, 0, 1, -1, 1, -1, 1, -1}; const int M = 1e9 + 7; const int N = 1e3, Nx = 500; int a[N + 1], c[N + 1]; bool isPrime[N + 1]; void sieve(int x) { for (int i = 0; i <= x; i++) isPrime[i] = true; i... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int inf = 1e9 + 7; const ll longinf = 1LL << 60; const ll mod = 1e9 + 7; template <typename T, typename S> struct LazySegmentTree { private: int n; vector<T> node; vector<S> lazy; T E0; S E1; inline void u... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<pair<int, int> > v(n); for (int i = 0; i < n; i++) cin >> v[i].first; bool is0 = false, is1 = false; for (int i = 0; i < n; i++) { cin >> v[i].second; if (v[i].second) is1 = true; e... |
#include <bits/stdc++.h> using namespace std; int n, m; int mat[1000010]; int row(int r) { int s = r * m, e = s + m; bool eq = false, dif = false; for (int i = s, idx = 0; i < e; i++, idx++) { if (mat[i] == -1) continue; int a = mat[i] / 2; int b = idx & 1; if (a == b) eq = t... |
#include <bits/stdc++.h> using namespace std; const int N = 100; int n, x, t; long long ans, s[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) { scanf( %d , &x); t = 0; while (x) { t += x % 2; x /= 2; } ++s[t]; } for (int i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; int n, i, j; vector<string> koutsompolio; int main() { cin >> n; string lol; bool r, f; for (i = 0; i <= n; i++) { getline(cin, lol); koutsompolio.push_back(lol); } for (i = 1; i <= n; i++) { r = false; f = false; ... |
#include <bits/stdc++.h> using namespace std; void solve() { int x{}; cin >> x; if (x % 3 == 0 || x % 7 == 0) { cout << YES << endl; return; } int ms{x / 3}; int ml{x / 7}; for (int i{0}; i <= ms; ++i) { for (int j{0}; j <= ml; ++j) { int chunks{3 * i + 7 * j}... |
#include <bits/stdc++.h> using namespace std; int main() { long long k; cin >> k; long long cnt = 0; for (double a = 2 + 2. / 3; a < (2 * k) / sqrt(3); a += 2) { double b = 1e-8 + (-a + sqrt((16 * k * k) / 3. - (3 * a * a))) / 2. - 2. / 3; if (b > 0) cnt += ((int)b + 2) / 2; ... |
#include <bits/stdc++.h> using namespace std; int cmpint(const void *a, const void *b) { if (((int *)a)[0] == ((int *)b)[0]) return ((int *)a)[1] - ((int *)b)[1]; return ((int *)a)[0] - ((int *)b)[0]; } int prim[500005] = {0}; bool isprim[5000005] = {0}; int prim_len; void count_prim() { int i... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); vector<long> A; long N, L, R, M, T, Sum, Min = 2147483647; cin >> N; A.resize(N); for (long i = 0; i < N; ++i) cin >> A[i]; for (long M = 1; M <= 100; ++M) { ... |
#include <bits/stdc++.h> const int mod = 1e6 + 3; int add(int a, int b) { return (a += b) >= mod ? a -= mod : a; } int sub(int a, int b) { return add(a, mod - b); } int mul(int a, int b) { return int(1LL * a * b % mod); } int pow(int a, int64_t n) { int res = 1; while (n > 0) { if (n & 1) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, sticks; cin >> n; while (n--) { cin >> sticks; if (sticks % 2 == 0) cout << (sticks / 2) << endl; else cout << (1 + (sticks - 1) / 2) << endl; } } |
#include <bits/stdc++.h> using namespace std; const double PI = 2 * acos(0.0); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count()); const string DIGITS = 0123456789 ; const string ALPH = abcdefghijklmnopqrstuvwxyz ;... |
#include <bits/stdc++.h> using namespace std; int n, ans, dp[105], a[105]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); if (n % 2 == 0 || n == 1) { printf( -1 ); return 0; } for (int i = n; i >= 2; i--) { ans += max(a[i], a[i - 1]); a[(... |
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <unordered_set> #include <unordered_map> #include <cmath> #include <random> #include <chrono> #include <set> #include <queue> #include <stack> #include <deque> #include <cstring> const long... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cout.tie(0), cin.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; vector<string> ar(n); long long cnt = 0; vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0)); ... |
#include <bits/stdc++.h> using namespace std; struct pt { long long x, y; } a[3005]; long long n, m, q, lim, las, pre[3005], suf[3005], rc[3005][3005], c, x, y, z, v, ans; long long cmp(pt x, pt y) { return x.y < y.y || (x.y == y.y && x.x < y.x); } long long cb(long long x) { return (x + 1) * x >>... |
#include <bits/stdc++.h> using namespace std; long long int a[1000005], b[1000005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n, i; cin >> n; a[1] = 1; b[1] = 0; for (i = 2; i <= n; i++) { if (i % 2 == 0) { a[i] = a[i - 1]; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 300 * 1000 + 10; long long dist[MAX_N], dist1[MAX_N]; vector<pair<int, int>> adj[MAX_N]; set<pair<long long, int>> s; bool inPath[MAX_N]; pair<int, int> mx; int nxt[MAX_N]; bool dfs_path(int u, int par = -1) { for (auto x : adj[u]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long i = -1, k, l; cin >> k >> l; while (l % k == 0) { l /= k; i++; } if (i >= 0 && l == 1) cout << YES << endl << i << endl; else cout << NO << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { int a, b; cin >> a >> b; int sum = 0; int h; for (int i = 1; i < a; i++) { sum += i; if (sum >= b) { sum -= i; h = i - 1; break; }... |
#include <bits/stdc++.h> using namespace std; long long int c1, c2, x, y, l, r, mid; int main() { ios::sync_with_stdio(false); cin >> c1 >> c2 >> x >> y; l = c1 + c2; r = 2000000009; while (l < r) { mid = (l + r) / 2; if ((mid - (mid / x) >= c1) && (mid - (mid / y) >= c2) && ... |
#include <bits/stdc++.h> using namespace std; int main() { int a[16] = {15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7}; int n; cin >> n; cout << a[n]; return 0; } |
#include <bits/stdc++.h> using namespace std; multiset<long long> h[1000005]; int main() { int q; scanf( %d , &q); while (q--) { char op, s[20]; long long a; scanf( %c , &op); if (op == + ) { scanf( %lld , &a); int idx = 0, k = 0; for (long long x = a;... |
#include <bits/stdc++.h> using namespace std; int n, pre = -1; priority_queue<pair<int, int> > q; const int M = 3000000 * 4, N = 1e9; int tree[M], lson[M], rson[M], val[M], size, k, root; void updata(int &root, int l, int r, int x, int v) { if (!root) root = ++size; if (l == r) { val[root] = t... |
#include <bits/stdc++.h> using namespace std; int main() { long long int p; cin >> p; for (long long int z = 0; z < p; z++) { long long int n; cin >> n; while (1) { break; } string a; cin >> a; long long int re = 0, ro = 0, be = 0, bo = 0; for (lon... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; string s; cin >> s; int l = -1, r = -1; for (int i = 0; i < n; i++) { int cnt1 = 0, cnt2 = 0; if (s[i] == a ) ++cnt1; else ++cnt2; for (int j = i + 1; j < n; j++) { ... |
#include <bits/stdc++.h> using namespace std; int N, M; int tam[200005], ans[200005]; map<pair<int, int>, bool> ex; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> N >> M; for (int m = 0; m < M; m++) { int u, v; cin >> u >> v; tam[u]++; tam[v]++; ex[... |
#include <bits/stdc++.h> using namespace std; int a, d[101], b, f, g, h, j, k, l, n, i; string s, x; int main() { cin >> s >> x; a = s.size(); b = x.size(); if (s == x) { cout << YES ; return 0; } if (a != b) { cout << NO ; return 0; } for (i = 0; i < a;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1505; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; int n, m; pair<int, int> start; char a[MAXN][MAXN]; bool vis[MAXN][MAXN]; pair<int, int> sm[MAXN][MAXN]; bool dfs(int x, int y, pair<int, int> shift) { if (vis[x][... |
#include <bits/stdc++.h> using namespace std; int n; int deg[1001]; int main() { cin >> n; for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; deg[a]++; deg[b]++; } int ans = 0; for (int i = 1; i <= n; i++) if (deg[i] == 1) ans++; cout << ans << endl;... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> a[100100]; vector<long long> v, v2; int main() { int n, i; cin >> n; long long Answer = 0; for (i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; v.push_back(a[i].first); v2.push_back(a[i].second); ... |
#include <bits/stdc++.h> using namespace std; int A[10005], B[10005]; long long int dp[10005]; int main() { int n, C; scanf( %d %d , &n, &C); for (int i = 0; i < n; i++) scanf( %d , &A[i]); for (int i = 0; i < n; i++) scanf( %d , &B[i]); for (int i = n - 1; i >= 0; i--) { for (int j = ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; char hh[25]; string s; map<string, int> ma; int fr[100005]; int ax[100005]; int bx[100005]; int main() { scanf( %d%d%d , &n, &k, &m); int i, j, a, b; for (i = 1; i <= n; i++) { scanf( %s , hh); s = hh; ma[s] = i; ... |
#include <bits/stdc++.h> long long MOD = 1e9 + 7; using namespace std; int main() { long long n, t; cin >> n >> t; long long a[200010], x[200010], b[200010]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { cin >> x[i]; x[i]--; if ((i > 0 && x[i] < x[i -... |
#include <bits/stdc++.h> using namespace std; int counts[26]; int main() { string s; cin >> s; int N = s.size(); for (int i = 0; i < N; i++) counts[s[i] - a ]++; for (int i = 0; i < 26; i++) { if (counts[i] % 2 == 1) { int k = -1; for (int j = 25; j >= 0 && k < 0; j--) ... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; void bset(int &b, int i) { b |= (1 << i); } void bunset(int &b, int i) { b = (b & ~(1 << i)); } int bget(int b, int i) { return b & (1 << i); } int bcnt(int b) { return __builtin_popcount(b); } map<char, in... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); if (n == 1) { printf( -1 ); return 0; } printf( %d %d %d , n, n + 1, n * (n + 1)); } |
#include <bits/stdc++.h> using namespace std; template <class T> inline void umax(T &a, T b) { if (a < b) a = b; } const int maxn = 100 + 10; const int INF = 1e9 + 7; char a[maxn][maxn]; int c[maxn], d[maxn]; inline void solve(void) { int n; cin >> n; for (int i = (0); i < (n); i++) ci... |
#include <bits/stdc++.h> using namespace std; int main() { int n, xC = 0, XC = 0, i, f = 0; char c; char remain; cin >> n; string o = ; for (i = 0; i < n; i++) { cin >> c; if (c == x ) { xC++; o = o + x ; if (xC == n / 2) { remain = X ; ... |
#include <bits/stdc++.h> template <class T> bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; } template <class T> bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; } using namespace std; const long long MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0)... |
#include <bits/stdc++.h> using namespace std; const long long N = 5 * 1e5 + 100; long long n, m, nxt[N], MAX[N]; char s[N], t[N]; inline void add(long long &a, long long b, long long mod) { a = ((a + b >= mod) ? a + b - mod : a + b); } inline void del(long long &a, long long b, long long mod) { a ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; char buf[1 << 15], *fs, *ft; inline char getc() { return (ft == fs && (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), ft == fs)) ? 0 : *fs++; } template <typename T> inline void read(T ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (a == 0) return b; return gcd(b % a, a); } int main() { long long int n, a[100001], sum = 0, m; cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; sort(a, a + n); for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; class Solution { public: int count(vector<int>& pieces, int p) { int n = pieces.size(); preprocess(n); vector<vector<vector<int>>> cur( n + 1, vector<vector<int>>(n + 1, vector<int>(n + 1, 0))); vector<vector<vector<int>>> nxt( ... |
#include <bits/stdc++.h> using namespace std; using namespace chrono; struct stopwatch { time_point<high_resolution_clock> last_tick; bool notock = false; void tick() { last_tick = high_resolution_clock::now(); } void tock() const { duration<double> dur = high_resolution_clock::now() - last_... |
#include <bits/stdc++.h> using namespace std; int main() { int T, money; cin >> T >> money; int n; int g; vector<int> lista; for (int i = 1; i <= T; i++) { cin >> n; int brk = 0; for (int j = 0; j < n; j++) { cin >> g; if (brk == 0 && money > g) { ... |
#include <bits/stdc++.h> #pragma GCC optimize(3, inline , Ofast ) using namespace std; int p[1010]; bool vis[1010]; void dfs(int pos) { if (vis[pos]) return (void)(printf( %d , pos)); else vis[pos] = 1, dfs(p[pos]); } int main() { int n; scanf( %d , &n); for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100100; bool vis[maxn]; long long val[3][maxn]; long long mii[3]; vector<int> g[maxn]; vector<int> a; int ans[maxn]; int d[maxn]; void dfs(int now) { a.push_back(now); vis[now] = 1; for (int i = 0; i < g[now].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int dp[510][510]; long long MOD; vector<string> v; long long nc2(long long num) { return (num * (num - 1)) / 2; } int recur(int ones, int zeros) { if (ones == 0 and zeros == 0) return 1; if (dp[ones][zeros] != -1) { return dp[ones][zeros] % MOD; ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; inline int read() { char ch = getchar(); int x = 0, f = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = (x << 1) + (x << 3) - 0 + ch; ... |
#include <bits/stdc++.h> using namespace std; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string a[n], b[n]; map<string, int> m; for (int i = 0; i < n; ++i) { cin >> a[i]; ++m[a[i]]; } for (int i = 0; i < n; ++i) { cin... |
#include <bits/stdc++.h> using namespace std; long long n, q, ans[50005], sum[50005], a[50005], p[50005], x[50005], cont, pos, us[50005]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 2; i <= n; i++) cin >> p[i... |
#include <bits/stdc++.h> using namespace std; string S, T; int n, m; int nxt[200005][30]; unsigned long long hashS[200005][30], hashT[200005][30], bpw[200005]; unsigned long long ht; int base = 10007; int f[30]; vector<int> ans; bool chk(int p) { memset(f, 0, sizeof(f)); int ps, pt; unsi... |
#include <bits/stdc++.h> int main() { int t, n; scanf( %d , &t); while (t--) { scanf( %d , &n); if (n == 1) { printf( -1 n ); } else { printf( 2 ); for (int i = 1; i < n; i++) { printf( 7 ); } printf( n ); } } } |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0, f = 1; char c = getchar(); while ((c < 0 || c > 9 ) && (c != - )) c = getchar(); if (c == - ) f = -1, c = getchar(); while (c >= 0 && c <= 9 ) x = x * 10 + c - 0 , c = getchar(); return x * f; ... |
#include <bits/stdc++.h> using namespace std; long long inv_euclid(long long a, long long m = 998244353) { long long m0 = m; long long y = 0, x = 1; if (m == 1) return 0; while (a > 1) { long long q = a / m; long long t = m; m = a % m, a = t; t = y; y = x - q * y; ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m, k, i, j, count = 0, sum = 0, maxi = 0, mini = 1e18, flag = 0; cin >> n; vector<long long> res; vector<char> temp; string a, b; cin >> a >> b; if (a == b) { cout << 0 << n ; return; } if (n ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5005; int u[maxn], v[maxn], w[maxn], dp[maxn][maxn], parent[maxn][maxn], x[maxn]; int main() { int n, m, t, pos; cin >> n >> m >> t; for (int i = 0; i < m; i++) { cin >> u[i] >> v[i] >> w[i]; } memset(dp, 0x3f, sizeof(dp));... |
#include <bits/stdc++.h> using namespace std; int k, n, m; const int dx[4] = {-1, 1, 0, 0}; const int dy[4] = {0, 0, -1, 1}; int bx, by, s, ansx[1000000], ansy[1000000]; bool g[510][510]; char ansc[1000000]; int dfs(int x, int y) { if (x > 0 && y > 0 && x <= n && y <= m && g[x][y] == 0) { g[x]... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int n, c1, c2; long long f[501]; long long c[501][501]; long long dp[501][501]; long long gao(int a, int b) { if (a == 0 && b == 0) { return 1; } if (dp[a][b] == -1) { long long& cur = dp[a][b] = 0; if ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.