func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 100100, M = 32401000, S = 90, oo = 1000000000; int i, j, k, n, m, ch, ff; int s[N]; int F[M]; void R(int &x) { ff = x = 0; while (ch < 0 || 9 < ch) { if (ch == - ) ff = 1; ch = getchar(); } while ( 0 <= ch && ch <=... |
#include <bits/stdc++.h> inline int getx() { char c; int x; for (c = getchar(); c < 0 || c > 9 ; c = getchar()) ; for (x = 0; c >= 0 && c <= 9 ; c = getchar()) x = (x << 3) + (x << 1) + c - 0 ; return x; } bool upmax(int &a, const int &b) { return a < b ? a = b, 1 : 0; } c... |
#include <bits/stdc++.h> using namespace std; struct guy { int x; int y; int t; }; int r, n; vector<guy> arr; vector<int> dp; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> r >> n; arr = vector<guy>(n); dp = vector<int>(n, 0); for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; const int INFint = 2e9; const long long INF = 1e18; const long long MOD = 1000000007ll; int g[100][100]; vector<int> used; set<int> roots; int n, m; void dfs(int v, int p) { used[v] = 1; for (int i = 0; i < n; i++) { if (i == p || !g[v][i]) c... |
#include <bits/stdc++.h> long long memo[100005][205]; std::pair<long long, int> pre[100005]; int n; struct q4 { int s, t, d, pin; long long w; bool operator<(const q4& wx) const { return ((w > wx.w) || ((w == wx.w) && (d > wx.d))); } }; std::vector<q4> Q[100005]; std::multiset<q4> X;... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAX = 2e5 + 5; long long dis[MAX]; int a[MAX], ans[MAX]; int pos[MAX]; vector<pair<int, int> > adj[MAX]; void dfs(int x, int idx, long long d) { pos[idx] = x; dis[idx] = d; int len = lower_bound(dis, dis + idx +... |
#include <bits/stdc++.h> int main(int argc, char const *argv[]) { int n, a, b; while (scanf( %d%d%d , &n, &a, &b) != EOF) printf( %d n , (n - a) < (b + 1) ? (n - a) : (b + 1)); return 0; } |
#include <bits/stdc++.h> static const int MAXN = 2e5 + 10; int n, m; std::pair<int, int> p[MAXN]; int x_idx[MAXN], x[MAXN]; int a_i, l_i; inline int solve_query(int u, int len) { while (true) { int last_len = len; int p = std::upper_bound(x, x + n, x[u] + len) - x - 1; len -= (x[p] - x... |
#include <bits/stdc++.h> using namespace std; long long a[100010]; int main() { long long n; cin >> n; long long tmp = n; for (int i = 2; (long long)i * i <= tmp; i++) { if (tmp % i == 0) { a[++a[0]] = i; while (tmp % i == 0) { tmp /= i; } } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; long long l; cin >> n >> l; long long *lanterns = new long long[n]; for (long long i = 0; i < n; i++) cin >> lanterns[i]; double maxDistance = 0; sort(lanterns, lanterns + n); for (long long i = 0; i < n - 1; i++) ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; set<int> ms; for (int i = 0; i < n; ++i) { int x; cin >> x; if (x) ms.insert(x); } cout << ms.size() << n ; return 0; } |
#include <bits/stdc++.h> using namespace std; double pi = acos(-1); void Open() {} long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } void PrintNumber(int n, int len) { if (!len) return; cout << (n & 1); } void PrintAllSubset(int n) { for (int i = 0; i < (1 << n); i... |
#include <bits/stdc++.h> int main() { int a, b; scanf( %d%d , &a, &b); if (a == b) printf( %d n , a); else printf( 2 n ); return 0; } |
#include <bits/stdc++.h> using namespace std; bool visited[100005]; vector<long long> mp[100005]; long long res = 0; long long ans = 0; const long long U = 1e8 + 7; void dfs(long long second) { visited[second] = true; ans++; for (int i = 0; i < mp[second].size(); i++) { res++; if (... |
#include <bits/stdc++.h> using namespace std; int m[100005], v[100005], selected[100005]; vector<pair<pair<int, int>, int> > V; int k, n, h; bool check(long double time) { long double pos = 1.0; int id = 0; for (int i = 0; i < n; i++) { if (V[i].first.second * 1.0 * time >= pos * h) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; struct dsu { int forests = 0, parent[N], groupsize[N]; void add(int x) { parent[x] = x; groupsize[x] = 1; forests++; } int findset(int node) { if (parent[node] == node) return node; return parent[nod... |
#include <bits/stdc++.h> using namespace std; int main() { string a, b; long long team1 = 0, team2 = 0; cin >> a; cin >> b; for (int i = 0; i <= a.size(); i++) { if ((a[i] == [ && b[i] == ( ) || (a[i] == 8 && b[i] == [ ) || (a[i] == ( && b[i] == 8 )) { team1++; ... |
#include <bits/stdc++.h> using namespace std; int q; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> q; while (q--) { bool ch = false; string s; cin >> s; if (s.size() == 1) { if (s[0] == ? ) cout << a ; else ... |
#include <bits/stdc++.h> using namespace std; int a[300]; int main() { int n, k, cnt = 0; cin >> n >> k; for (int i = 0; i < 2 * n + 1; i++) cin >> a[i]; for (int i = 1; (i <= 2 * n - 1) && (cnt != k); i += 2) { if (a[i] - 1 > a[i - 1] && a[i] - 1 > a[i + 1]) { a[i]--; cnt++;... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 1E5; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); string s; cin >> s; int len = s.size(); int ans = 0; for (int i = 0; i < len; i++) { int l = 0, r = 0; for (int j = i; j <... |
/* Author: Sanskar Agarwal Nick: sanskaragarwal Birla Institute Of Technology, Mesra */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define endl n #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++) #def... |
#include <bits/stdc++.h> using namespace std; const int N = 55; int type; const long long int mod = 1e9 + 7; long long C[N][N]; void matrix_mul(long long A[N][N], long long B[N][N]) { for (int i = 0; i < type; i++) { for (int j = 0; j < type; j++) { C[i][j] = 0; for (int k = 0; k <... |
#include <bits/stdc++.h> using namespace std; template <class t> inline void rd(t &s) { s = 0; register char c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar(); return; } int ans[5050]; signed main(void) { register i... |
#include <bits/stdc++.h> using namespace std; const int ZIMAX = 3005; int n, v; int cnt[ZIMAX]; int main() { cin >> n >> v; for (int i = 1; i <= n; ++i) { int ai, bi; cin >> ai >> bi; cnt[ai] += bi; } int ans = 0; int before = 0; for (int i = 0; i < ZIMAX; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a[50]; scanf( %d , &n); scanf( %d , &k); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a, a + n); if (k > n) { cout << -1 << endl; return 0; } if (n == k) { cout << 0 << << 0 << endl; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10, mod = 1e9 + 7; inline int ad(int x, int y) { int ans = x + y; if (ans > mod) ans -= mod; return ans; } inline int mu(int x, int y) { return 1LL * x * y % mod; } inline int wop(int x, int y) { int ret = 1; while (y) ... |
#include <bits/stdc++.h> using namespace std; vector<int> e[200005], E[200005], v; int vis[200005]; inline void dfs(int u) { if (vis[u]) return; vis[u] = 1; v.push_back(u); int x = E[u][0], y = E[u][1]; if (e[x][0] == e[u][0] || e[x][0] == e[u][1] || e[x][1] == e[u][1] || e[x][1] == ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; string s1; cin >> s1; vector<pair<char, int> > v; long long int sz = s1.size(); long long int j = 0; while (j < sz) { char ch = s1[j]; ... |
#include <bits/stdc++.h> using namespace std; struct state { int x, y; } bl[100005], rec[100005], cur[100005]; long long n, m; bool cmp(const state& a, const state& b) { if (a.y == b.y) return a.x < b.x; return a.y < b.y; } bool funct() { int counter = 1; rec[0].x = 1, rec[0].y = 1; ... |
#include <bits/stdc++.h> using namespace std; long long x; int n, d; int res[100010], a[100010], b[100010]; long long getNextX() { x = (x * 37 + 10007) % 1000000007; return x; } void initab() { for (int i = 0; i < n; i++) { a[i] = i + 1; } for (int i = 0; i < n; i++) { swap... |
#include <bits/stdc++.h> using namespace std; const int max_n = 2e5 + 10; int n, temp; vector<int> ans; int main() { ios_base::sync_with_stdio(false), cin.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> temp; int pos = lower_bound(ans.begin(), ans.end(), temp) - ans.begin(); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; int r = m * n - 2 * (k - 1); cout << r << ; int i = 0, j = 0; for (; i < n; i++) { if (i % 2 == 0) { for (j = 0; j < m; j++) {... |
#include <bits/stdc++.h> using namespace std; int digit(char c) { char digits[] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }; for (int i = 0; i < 10; i++) { if (c == digits[i]) return 0; } return 1; } int main() { int t = 0; scanf( %d , &t); while (t--) { string s... |
#include <bits/stdc++.h> using namespace std; int root[1000100]; unordered_map<int, int> mp[1000100]; pair<pair<int, int>, int> edge[1000100]; int cnt[1000100]; int find_root(int u) { if (root[u] == u) return u; return root[u] = find_root(root[u]); } bool cmp(pair<pair<int, int>, int> u, pair<pa... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; double gmin = 100000000000000017; int a, b; int Y1[100005], Y2[100005], L[100005]; double dist(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } double f(int i, int j) { ... |
#include <bits/stdc++.h> using namespace std; struct Node { char s[110]; int x[30]; } a[2010]; int len, k, n; int main() { scanf( %d , &k); scanf( %s , a[1].s); len = strlen(a[1].s); memset(a[1].x, 0, sizeof(a[1].x)); for (int i = 0; i < len; i++) a[1].x[a[1].s[i] - a ]++; for... |
#include <bits/stdc++.h> #pragma GCC optimize(3) using namespace std; const double PI = acos(-1.0); const double eps = 1e-6; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch... |
#include <bits/stdc++.h> using namespace std; const int inft = 1000000009; const int MAXN = 2000006; bool P[MAXN]; int SP[MAXN]; int PAL[MAXN]; char S[123]; bool pal(int a) { sprintf(S, %d , a); reverse(S, S + strlen(S)); int q; sscanf(S, %d , &q); return a == q; } int main() {... |
#include <bits/stdc++.h> int main() { char s[1000000], c; int x = 0, y = 0, sum = 0, d; scanf( %d , &d); for (int i = 0; i < d; i++) { scanf( %c , &c); s[i] = c; } for (int i = 0; i < strlen(s); i++) { if (s[i] == L ) x--; if (s[i] == R ) y++; } for (int i = ... |
#include <bits/stdc++.h> using namespace std; void print(int x, int b) { if (x) { print(x / b, b); printf( %d , x % b); } } int main() { int k; cin >> k; for (int i = (1); i <= (k - 1); ++i) for (int j = (1); j <= (k - 1); ++j) print(i * j, k), printf( %c , j == k -... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); } bool possible(long long p, long long q, long long x, long long y) { if (q < y) { return false; } if (p < x) { return false; } return q - y >= p - x; } in... |
#include <bits/stdc++.h> using namespace std; int q_pow(int x, int n) { int ret = 1; for (; n; n >>= 1, x = (long long)x * x % 998244353) if (n & 1) ret = (long long)ret * x % 998244353; return ret; } int A[100005 << 2], B[100005 << 2], tmp[100005], tx[100005], ty[100005], Q, n, m; voi... |
#include <bits/stdc++.h> int main(int argc, char *argv[]) { int i, j; unsigned long long n, result, a[10]; a[0] = 0; a[1] = 9; for (i = 2; i <= 9; i++) a[i] = a[i - 1] * 10 + 9; scanf( %llu , &n); result = 0; i = 9; ; while (n < a[i]) i--; result = result + (n - a[i]) * (i ... |
#include <bits/stdc++.h> using namespace std; ifstream f( date.in ); queue<long long> q; long long n, k, fr[1000001]; long long GCD(long long x, long long y) { long long r; do { r = x % y; x = y; y = r; } while (y != 0); return x; } int main() { long long ans; cin... |
#include <bits/stdc++.h> using namespace std; int n, a[1000000], k, cnt, ans; int main() { cin >> n; a[0] = 1; a[1] = 1; a[2] = 0; for (int i = 1; i < n; i++) { if (a[i] == 0) { for (int j = i * i; j <= n; j += i) { a[j] = 1; } } } for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { string p; getline(cin, p); bool f = 0; for (int i = 0; i < p.size(); i++) { if (p[i] >= a && p[i] <= z ) { if (p[i] == a || p[i] == i || p[i] == u || p[i] == e || p[i] == o || p[i] == y ) f =... |
#include <bits/stdc++.h> using namespace std; long long summ(long long n) { return (n * (n + 1)) / 2; } long long sear(long long n, long long k) { if (n == 1 && k == 1) return 0; long long lo = 0, hi = n, mid; long long sum, eaten; while (lo <= hi) { mid = lo + (hi - lo) / 2; sum = sum... |
#include <bits/stdc++.h> using namespace std; long long query(long long t, long long i, long long j, long long k) { cout << t << << i << << j << << k << << n ; cout.flush(); long long res; cin >> res; return res; } void solve() { long long n; cin >> n; long long... |
#include <bits/stdc++.h> using namespace std; int n, centru; int l[10]; int r[10]; int vars(int i, int tip) { if (!tip) { if (l[i] <= centru && centru <= r[i]) return centru - l[i]; else if (r[i] < centru) return r[i] - l[i] + 1; return 0; } else if (tip == 1) r... |
#include <bits/stdc++.h> using namespace std; template <class T> inline T abs(T &a) { return a > 0 ? a : -a; } template <class T> inline T min(T &a, T &b) { return a < b ? a : b; } template <class T> inline T max(T &a, T &b) { return a > b ? a : b; } inline void read(int &x) { char... |
#include <bits/stdc++.h> using namespace std; long long a[200005]; map<long long, int> mp; int main() { int t; scanf( %d , &t); while (t--) { long long n; scanf( %lld , &n); long long sum = 0; mp.clear(); for (int i = 1; i <= n; i++) { scanf( %lld , &a[i]); ... |
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,fma ) #pragma GCC optimize( fast-math ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( Ofast ) using namespace std; const long long mod = 1e9 + 7, mod2 = 998244353; const long double eps = 1e-6; con... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cout << 1 + 6 * (n) * (n + 1) / 2 << endl; } |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int MAX = 200005; int cnt[MAX], pre[MAX], suf[MAX]; int bpow(int a, int b) { int ans = 1; while (b) { if (b & 1) ans = 1LL * ans * a % MOD; b >>= 1; a = 1LL * a * a % MOD; } return ans; } int ... |
#include <bits/stdc++.h> using namespace std; int a[610000], i, j, k, l, n, m, p[610000], t, last, o, r, mid; char c[610000]; bool check(int mid) { int tmp = 1e9, res = 0; p[0] = mid; m = last; for (i = 1; i <= n; ++i) { p[i] = p[i - 1] + a[i]; if (p[i] == 0 && p[i - 1] == -1) m = ma... |
#include <bits/stdc++.h> using namespace std; long long a[200010]; long long l[200010]; long long r[200010]; int main() { ios_base::sync_with_stdio(0); long long n, h; cin >> n >> h; vector<long long> rast2(n + 1, 0); for (int i = 1; i <= n; i++) { cin >> l[i] >> r[i]; rast2[i]... |
#include <bits/stdc++.h> using namespace std; int n; set<pair<int, int> > s; vector<int> od; int p[512]; vector<int> v[512]; inline void dfs(int b, int pr = -1) { od.push_back(b); p[b] = pr; auto it = s.lower_bound(make_pair(b, -1)); while (it != s.end() && (*it).first == b) { if (it... |
#include <bits/stdc++.h> using namespace std; int N, M; map<string, string> m1; int main() { cin >> N >> M; string s1; string s2; for (int i = 1; i <= N; i++) { cin >> s1; cin >> s2; m1[s2] = s1; } for (int i = 1; i <= M; i++) { cin >> s1; cin >> s2; s... |
#include <bits/stdc++.h> using namespace std; int p[110]; int main() { int n, cnt; cin >> n; for (int i = 0; i < n; i++) cin >> p[i]; string s; getline(cin, s); for (int i = 0; i < n; i++) { cnt = 0; getline(cin, s); for (int j = 0; j < s.size(); j++) if (s[j] == ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename S> ostream &operator<<(ostream &os, const pair<T, S> &v) { os << ( ; os << v.first << , << v.second << ) ; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << [ ; ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long int t; cin >> t; while (t--) { long long int x = 0; long long int n, m; cin >> n >> m; for (long long int i = 0; i < n; i++) { long long int a, b, c, d; cin >> a >> b >> c >> d; if (b... |
#include <bits/stdc++.h> using namespace std; const int N = 200020; long long int n; int main() { cin >> n; for (long long int i = 1; i <= n - 1; i++) { for (long long int j = 1; j <= n - 1; j++) { if (i == j) cout << 0 ; else cout << 1 + (i + j - 2) % (n - 1)... |
#include <bits/stdc++.h> using namespace std; int p[1001][1001], row[1001], col[1001]; int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); for (int r = 1; r <= n; ++r) row[r] = r; for (int c = 1; c <= m; ++c) col[c] = c; for (int r = 1; r <= n; ++r) for (int c = 1; c <= m; ++c) scanf(... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; struct P { int x, y; bool operator<(const P &a) const { return x > a.x; } } a[N]; int main() { static int n, b[N * 2]; cin >> n; for (int i = 1; i <= n; i++) scanf( %d , (int *)(a + i)), a[i].y = i * 2 - 1; sort(a + 1... |
#include <bits/stdc++.h> using namespace std; vector<int> graph[100005]; int a[100005], b[100005]; vector<int> ans; void dfs(int source, int parent, int oddlevel, int evenlevel, int depth) { if (depth % 2 == 1) a[source] ^= oddlevel; else a[source] ^= evenlevel; if (a[source] != b[sour... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { string s; cin >> s; int l[3005], r[3005]; memset(l, -1, sizeof(l)); memset(r, -1, sizeof(r)); int cnt = 0, t1 = 0, t2 = 0; for (int i = 0; i < n; ++i) { if (s[i] == L ) { ... |
#include <bits/stdc++.h> using namespace std; const int maxN = 100100; const long double INF = 1e100; const long double eps = 1e-6; const long double PI = 3.14159265358979323846264338328; long long x[maxN], y[maxN]; long double Dis(long long a, long long b, long long p, long long q) { long double aa =... |
#include <bits/stdc++.h> using namespace std; int a[500005]; int q[500005]; int n, k, d; int main() { scanf( %d%d%d , &n, &k, &d); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); int l = 1, r = 1; q[l] = 0; for (int i = k; i <= n; i++) { while (l <= r && ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n == 1 || n == 2) cout << -1 ; else { for (i = n; i >= 1; i--) cout << i << ; cout << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n + 1); for (int i = 1; i <= n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); vector<vector<vector<int>>> dp( 2, vector<vector<int>>(k + 1, vector<int>(k + 1))); dp[0][0]... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int m, long long int n) { if (n == 0) return m; return gcd(n, m % n); } int MOD = 1000000000; long long int powmod(long long int a, long long int b) { if (b == 0) return 1; long long int x = powmod(a, b / 2); long lo... |
#include <bits/stdc++.h> using namespace std; bool pid_comp_second(pair<int, double> a, pair<int, double> b) { if (a.second == b.second) return a.first < b.first; return a.second > b.second; } int main() { double x, y, z; cin >> x >> y >> z; map<int, string> expr; expr[1] = x^y^z ; ... |
#include <bits/stdc++.h> using namespace std; ofstream fo( test.out ); ifstream fi( test.inp ); const long long MOD = 1e9 + 7; const long long base = 269; const int N = 1e5 + 5; long long n, m, q, K, pos, t, rs, r; long long cnt10, cnt11; string s, a, b; int main() { ios_base::sync_with_stdio(fa... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, ind; cin >> t; while (t--) { cin >> n; ind = -1; int a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; if (a[i] % 2 == 0) ind = i; } if (ind != -1) cout << 1 n << ind + 1 << ... |
#include <bits/stdc++.h> using namespace std; using namespace std; struct my { int a; double b; }; bool Cmp(my a, my b) { return a.b <= b.b; } int main() { int n, m; cin >> n >> m; my mine[n]; for (int i = 0; i < n; ++i) { int a; cin >> a; double b; cin >> b; ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 1e7 + 10, M = 998244353; int n, m, k, inv[Maxn], s[Maxn], idk[Maxn]; int mo2(int x) { return (x < 0) ? x + M : x; } int fpow(int a, int p = M - 2) { int ret = 1; for (; p; p >>= 1, a = 1ll * a * a % M) if (p & 1) ret = 1ll * ret * a ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000009; const double PI = acos(-1.0); const double eps = 1e-8; const int MAXN = 0; const int MAXM = 0; bool a[5002]; int i, j, k, n, h, m, id, p, hesh; map<int, int> M; char c; int ans = 0; int main() { cin >> h >> m >> n; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, a, b, x, y, ans = 0; scanf( %d , &n); printf( YES n ); for (int i = 1; i <= n; i++) { scanf( %d %d %d %d , &a, &b, &x, &y); x = min(a, x); y = min(y, b); ans = abs(x) % 2; ans = ans * 2 + (abs(y) % 2);... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; vector<vector<string> > dp; int n, m; string resp = ; vector<string> a; vector<set<char> > occr; string solve(int at, int estado) { if (at == m) { return ; } if ... |
#include <bits/stdc++.h> using namespace std; const long long MX = 1e5 + 10; long long A[MX]; long long cnt[MX]; vector<long long> pos[MX]; long long ans[MX]; void init(long long n) { for (long long i = 0; i <= n + 2; i++) cnt[i] = 0; for (long long i = 0; i <= n + 2; i++) pos[i].clear(); for ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const double pi = acos(-1.0); const double dinf = 1e250; const long long INF = (long long)(2e18); const int inf = (int)(1e9 + 7); struct myt { int d, s, t; }; void out(int a, int b) { cout << a << << b << n ; } vector<i... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100010; long long quick_Mod(long long n) { long long ans = 1; long long x = 2; while (n) { if (n & 1) ans = ans * x % 1000000007; n = n >> 1; x = x * x % 1000000007; } return ans; } void ex_gcd(long long a, lon... |
#include <bits/stdc++.h> using namespace std; int n, m, Q; set<int> cut[2]; map<int, int> mx[2]; long long getmx() { map<int, int>::iterator it; it = mx[0].end(); it--; int u = (*it).first; it = mx[1].end(); it--; int v = (*it).first; return 1ll * u * v; } void Insert(int t... |
#include <bits/stdc++.h> using namespace std; const int IINF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const double DINF = numeric_limits<double>::infinity(); const int MOD = 1000000007; const double EPS = 1e-9; const double PI = acos(-1.0); const int DX[] = {1, 0, -1, 0, 1, -1, 1, -1};... |
#include <bits/stdc++.h> template <class T> std::string toStr(T t); using namespace std; int main() { int statA[4]; int statB[4]; for (__typeof(4) i = 0; i < 4; i++) { cin >> statA[i]; cin >> statB[i]; } int pos[4][4] = {{0, 1, 2, 3}, {1, 0, 2, 3}, {0, 1, 3, 2}, {1, 0, 3, 2}}; ... |
#include <bits/stdc++.h> using namespace std; inline int scan() { int x; scanf( %d , &x); return x; } struct data { int first; int edge_used; int prev; data() { first = 0; edge_used = 0; prev = 0; } }; vector<pair<int, int> > v[100005]; bool edge[100005] =... |
#include <bits/stdc++.h> using namespace std; const int MX = 256; vector<vector<vector<vector<vector<int> > > > > dp; char grid[MX][MX]; int R, C, mxmask, MOD = 1e9 + 7; int ison(int x, int bit) { if ((x & (1 << bit))) return 1; return 0; } int turnoff(int x, int bit) { if ((x & (1 << bit)))... |
#include <bits/stdc++.h> using namespace std; long long n, a[1234], i; int main() { cin >> n; for (i = 0; i < n; i++) cin >> a[i]; for (i = 0; i < n; i++) if (a[i] % 2 == 0) a[i]--; for (i = 0; i < n; i++) cout << a[i] << ; cout << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e1) { cout << e1 << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << << e... |
#include <bits/stdc++.h> using namespace std; template <typename T, bool MIN> struct ConvexHullTrickAddMonotone { using Line = pair<T, T>; deque<Line> deq; inline bool check(const Line &a, const Line &b, const Line &c) { return (b.first - a.first) * (c.second - b.second) >= (b.secon... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000000; long long A, B, n, l, t, m, r; bool check(long long len) { long long sum = A + (B * (l - 1)); long long mx = A + (B * (len - 1)); if (mx <= t && mx + sum <= 2 * m * t / (len - l + 1)) return true; else ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = URDL ; cons... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int n, k; scanf( %d %d , &n, &k); if (k > n * 3) { printf( %d , 0); } else { printf( %d , 3 * n - k); } return 0; } |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1; else v = (c & 15); while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15); x = v * f;... |
#include <bits/stdc++.h> using namespace std; vector<int> v[188]; int dist[188][188]; int n, m; int dp[188][188]; int best[188]; void dfs(int x, int p) { for (int i = 0; i < v[x].size(); i++) { int t = v[x][i]; if (t != p) dfs(t, x); } best[x] = 1; for (int c = 1; c <= n; c++) ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { int n; cin >> n; if (n == 2) return cout << -1, 0; cout << 385 n21 n165 n ; for (int i = 0; i < n - 3; i++) { cout << 21 * (i + 100) << endl; } } |
#include <bits/stdc++.h> using namespace std; long long int binpowmod(long long int a, long long int b, long long int m) { a %= m; long long int res = 1; while (b > 0) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } unsigned long long modInverse(unsi... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long n; cin >> n; string s; while (1) { if (n % 7 == 0) { n = n / 7; for (long long i = 0; i < n; i++) s.push_back( 7 ); break; } else { i... |
#include <bits/stdc++.h> using namespace std; char s[1000050]; int max(int x, int y) { return (x > y) ? x : y; } int main() { scanf( %s , &s); int len = strlen(s); int cnt = 1, j; int result = 1; for (int i = len; i < 2 * len; i++) { s[i] = s[i - len]; } len = 2 * len; for ... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long n, k; cin >> n >> k; unsigned long long r = 1, l = 0, num = n, mid; for (int i = 0; i < n; i++) { r <<= 1; } mid = (l + r) >> 1; while (mid != k) { --num; if (mid > k) r = mid; e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.