func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, m; long long v[100100]; vector<int> pos, neg; vector<int> X, Y; vector<long long> V; int main() { scanf( %d %d , &n, &m); int x, y; long long z; memset(v, 0, sizeof(v)); for (int i = 0; i < m; i++) { scanf( %d %d %I64d , &x, &y... |
#include <bits/stdc++.h> using namespace std; int n, p; long long int a[100001]; int is_good(long long int q) { int b[n]; for (int i = n - 1; i >= 0; i--) { long long int l = max(a[i] - q, 0ll); b[i] = n - l - (n - 1 - i); if (b[i] % p == 0) return 0; } return 1; } int main... |
#include <bits/stdc++.h> using namespace std; char ss[1002][1002]; int ak = -1, p = 0; int main() { while (gets(ss[p])) { if ((int)strlen(ss[p]) > ak) ak = (int)strlen(ss[p]); p++; } for (int i = 0; i <= ak + 1; i++) printf( * ); printf( n ); bool k = false; for (int i = 0; ... |
#include <bits/stdc++.h> const int N = 30; int a[N]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); } int max = 0, sit; for (int i = 1; i <= 100000; ++i) { bool div = true; for (int j = 0; j < n; ++j) { if (a[j] % i) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 9; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, s; cin >> n >> s; if (s < 2 * n) return cout << NO n , 0; cout << YES n ; for (int i = 1; i < n; i++) cout << 2 << ; cout << s - 2 * (n - 1) <... |
#include <bits/stdc++.h> using namespace std; double eps = 1e-9; pair<int, int> get_closer(int a, vector<int> &v) { auto it = lower_bound(v.begin(), v.end(), a); int b = 2000000000, c = 2000000000; if (it != v.end()) b = *it; if (it != v.begin()) c = *(it - 1); return {c, b}; } unsigned lo... |
#include <bits/stdc++.h> int main() { int k; std::cin >> k; std::cout << 3 2 n262143 131071 n131072 262143 n131072 << k; } |
#include <bits/stdc++.h> int main() { int n; int a[10000]; while (scanf( %d , &n) != EOF) { for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) { if (a[i] % 2 == 0) a[i] -= 1; } for (int i = 1; i <= n - 1; i++) printf( %d , a[i]); printf( %d... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); map<char, int> mp; mp.insert(pair<char, int>( A , 0)); mp.insert(pair<char, int>( B , 0)); mp.insert(pair<char, int>( C , 0)); int i = 3; while (i--) { string s; ... |
#include <bits/stdc++.h> using namespace std; long long GCD(long long u, long long v) { long long r; while (v) { r = u % v; u = v; v = r; } return u; } long long modpow(long long a, long long p, long long mod) { long long ret = 1; while (p) { if (p & 1) ret = (ret... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 4) { cout << NO n ; return 0; } cout << YES n ; if (n >= 4 && !(n & 1)) { int ones = 0; for (int i = 5; i < n; i += 2) { printf( %d - %d = 1 n , i + 1, i); ones++; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, ai, m, xi, yi; cin >> n; vector<int> wire(100); for (int i = 1; i <= n; i++) { cin >> wire[i]; } cin >> m; for (int i = 1; i <= m; i++) { cin >> xi >> yi; wire[xi - 1] += (yi - 1); wire[xi + 1] += (... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e6 + 3; const int INFI = 1e9 * 2; const long long LINFI = 1e17; const double pi = acos(-1.0); const double s2 = sqrt(2.0); const int N = 222; const int M = 11; const int move[8][2] = {1, 0, -1, 0, 0, 1, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; ... |
#include <bits/stdc++.h> int main() { int t, n, *arr, i, a, odd, even; scanf( %d , &t); while (t--) { scanf( %d , &n); arr = (int*)malloc(n * sizeof(int)); for (i = 0; i < n; i++) scanf( %d , &arr[i]); even = 0; odd = 0; for (i = 0; i < n; i++) { if (arr[i] % 2 ... |
#include <bits/stdc++.h> using namespace std; long long dp[100][10]; string s; int ss[100]; int main() { cin >> s; int n = ((int)(s).size()); for (int i = 0; i < n; i++) ss[i + 1] = s[i] - 0 ; for (int i = 0; i < 10; i++) dp[1][i] = 1; for (int i = 2; i <= n; i++) for (int j = 0; j ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, c = 0, temp; int h[101], g[101]; cin >> n; for (int i = 0; i < n; i++) { cin >> h[i] >> g[i]; } for (int j = 0; j < n; j++) { temp = n - 1; while (temp > j) { ... |
#include <bits/stdc++.h> using namespace std; int t,n; int a[100010]; int main(){ cin>>t; while(t--){ cin>>n; for(int i=0;i<n;++i)cin>>a[i]; sort(a,a+n); long long ans=a[n-1],sum=0; for(int i=0;i<n;++i){ sum+=a[i]; ans+=sum-1ll*a[i]*(i+1); } cout<<ans<< n ; } } ... |
#include <bits/stdc++.h> long int temp, i, j, k, T; long int ABS(int test) { if (test < 0) return test * -1; else return test; } int x8[] = {1, 1, 0, -1, -1, -1, 0, 1}; int y8[] = {0, 1, 1, 1, 0, -1, -1, -1}; int x4[] = {1, 0, -1, 0}; int y4[] = {0, 1, 0, -1}; long int arr[1000000]; ... |
#include <bits/stdc++.h> using namespace std; int n, a[2][300004]; long long sf[2][300004]; long long ca[2][300004]; int w33ha() { memset(sf, 0, sizeof(sf)); memset(ca, 0, sizeof(ca)); for (int t = 0; t <= 1; t++) for (int i = 1; i <= n; i++) scanf( %d , &a[t][i]); for (int t = 0; t <= 1... |
#include <bits/stdc++.h> using namespace std; int main() { int a, t, i; cin >> t; for (i = 0; i < t; i++) { cin >> a; cout << a / 2 << endl; } } |
#include <bits/stdc++.h> using namespace std; int main() { queue<unsigned long long> q; vector<unsigned long long> v; unsigned long long temp; q.push(0); while (!q.empty()) { temp = q.front(); v.push_back(temp * 10 + 4); v.push_back(temp * 10 + 7); if (temp * 10 + 7 >= 44... |
#include <bits/stdc++.h> using namespace std; int n, m, b; struct chel { int cost; int mas; int coun; }; chel f[103]; chel tem[103]; void mergesort(chel *a, chel *b, int n) { int i, i0, i1, iRight, iEnd, width, j; for (width = 1; width < n; width *= 2) for (i = 0; i < n; i += wid... |
#include <bits/stdc++.h> using namespace std; long long int md = 1e9 + 7; long long int __gcd(long long int a, long long int b) { if (b == 0) return a; return __gcd(b, a % b); } long long int poww(long long int a, long long int b) { long long int res = 1; while (b) { if (b & 1) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, g = 0; cin >> t; for (int i = 0; i < t; i++) { vector<int> p; int n, x; g = 0; cin >> n; if (n == 1) { cin >> x; cout << YES << endl; continue; } for (int l = 0; l < n; l... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int n; bool check, lucky; string s; cin >> n; for (int i = 4; i < n + 1; i++) { check = false; s = to_string(i); for (int j = 0; j < s.size(); j++) if ((s[j] == 4 ) || (s[j] == 7 ))... |
#include <bits/stdc++.h> using namespace std; void solve(int d) { cout << fixed << setprecision(9); if (d == 0) { cout << Y << 0.0 << << 0.0; } else if (d >= 1 && d < 4) cout << N ; else { double D = sqrt(d * (d - 4)); double a = (d + D) / 2.0; double b = (d - D... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); vector<int> a(n, 0); for (int i = 0; i < n; i++) scanf( %d , &a[i]); int m; scanf( %d , &m); vector<pair<int, int> > h(m, {0, 0}); for ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n + 1]; int i, s = 0; for (i = 0; i < n; i++) { cin >> arr[i]; } int j; for (i = 1; i < n - 1; i++) { if (arr[i - 1] < arr[i]... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 17; int N, root[maxn], sz[maxn]; long long minv, maxv, val[maxn]; vector<int> tree[maxn]; vector<pair<long long, int> > nodes; int find(int x) { if (root[x] == x) return x; return root[x] = find(root[x]); } long long merge(in... |
/** * Author: dhruv_gheewala * Problem: A. Spy Detected! * Date: 12.04.2021 * Time: 00:19:53 **/ #include bits/stdc++.h using namespace std; #ifndef DEBUG #define fundri 108 #define debug(...) 1729 #define endl n #endif #define int int64_t typedef pair<... |
#include <bits/stdc++.h> using namespace std; int n, arr[110], ans[110]; int primes[17] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59}; int fact[65]; int memo[110][1 << 17]; int find_min_cost(int ind, int mask) { if (ind >= n) return 0; if (memo[ind][mask]... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int a; cin >> a; int k = a; while (a--) { cout << 1 << ; } cout << endl; } } |
#include <bits/stdc++.h> using namespace std; int dx[4] = {0, 0, 1, -1}; int dy[4] = {-1, 1, 0, 0}; int lredge[600][599]; //n, m-1 int tdedge[599][600]; //n-1, m int n, m, k; int distance(int i1, int j1, int i2, int j2){ //next cell is above if(i1 > i2){ return tdedge[i2][j1]; } /... |
#include <bits/stdc++.h> long long sum = 0, dd = 0; int N, R, V[(1 << 18) + 233]; int main() { scanf( %d%d , &N, &R); dd = 1 << N; for (int i = 0; i < dd; ++i) { scanf( %d , V + i); sum += V[i]; } printf( %.10lf n , sum / (double)dd); for (int i = 0; i < R; ++i) { int z, ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q; cin >> n >> q; std::vector<vector<int>> v... |
#include <bits/stdc++.h> using namespace std; template <class T> long long size(const T& x) { return x.size(); } template <class T> T smod(T a, T b) { return (a % b + b) % b; } long long n, k; vector<long long> X; vector<pair<long long, pair<long long, long long> > > A; vector<vector<long ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int i = 1; while ((n * i) % 10 != k && (n * i) % 10 != 0) { i++; } cout << i << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, m, q, cnt, ans, w[13][100010], bi[20], g[13][100010], tot; bitset<4096> f[2 * 100010]; int main() { int i, s, a, b, j, k; for (i = bi[0] = 1; i < 20; i++) bi[i] = bi[i - 1] << 1; scanf( %d%d%d , &n, &m, &q); tot = m; for (i = 1; i <= m; i+... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000007; int n, m; int fa[200010]; struct Line { int u, v, c; } l[200010]; int p[200010]; bool cmp(int x, int y) { return l[x].c < l[y].c; } bool intree[200010]; struct Edge { int v, id, nxt; } e[400010]; int tot; int fir... |
#include <bits/stdc++.h> using namespace std; vector<int> e[400010], b[400010]; int ll[400010], rr[400010], son[400010], No, an[400010], now; void dfs0(int x, int last) { son[x] = 1; ll[x] = No++; for (int i = 0; i < e[x].size(); i++) { if (e[x][i] == last) continue; dfs0(e[x][i], x); ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, v; cin >> n >> v; if (n >= v) { long long t = (n - v) * (n - v + 1); t /= 2; t += v - 1; cout << t; } else { cout << n - 1; } } int32_t main() { ios_base::sync_with_stdio(false); c... |
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; for (int i = 0; i < n.length(); i++) cout << n[i]; for (int i = n.length() - 1; i >= 0; i--) cout << n[i]; } |
#include <bits/stdc++.h> using namespace std; const int N = 100010, C = 1000000000; int n, num; int kd[N], t[N], x[N], fr[N], nxt[N], ans[N]; map<int, int> S; int lc[N * 40], rc[N * 40], s[N * 40]; void change(int &i, int l, int r, int k, int d) { if (i == 0) i = ++num; s[i] += d; if (l == r) ... |
#include <bits/stdc++.h> using namespace std; long long in() { long long a; scanf( %lld , &a); return a; } bool isprime(long long n) { if (n == 1) return 0; if (n == 2) return 1; if (n % 2) return 0; for (int i = 2; i <= sqrt(n) + 2; i++) if (n % i == 0) return 0; return 1;... |
#include <bits/stdc++.h> using namespace std; long long mod, n, m, a[200005], b[200005], kq, vt1, vt2, l, r, mid, mn[200005]; map<int, bool> mp; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; mod = 998244353; for (int i = 1; i <= n; ++i) { cin >>... |
#include <bits/stdc++.h> using namespace std; int main() { int n, r, x, s = 0; cin >> n >> r >> x; int a[r + 1]; for (int i = 1; i <= r; i++) { a[i] = 10000000; } while (n--) { int l, m; cin >> l >> m; a[l] = min(a[l], m); } for (int i = 1; i <= r; i++) { ... |
#include <bits/stdc++.h> using namespace std; __int128 read() { __int128 s = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s << 1) + ch - 0 , ch = getchar(); return f * ... |
#include <bits/stdc++.h> using namespace std; using ull = unsigned long long; const int kMod = 1e9 + 7; mt19937_64 rng(time(0)); struct SegTree { struct Node { ull dp = 0; int l = 0, r = 0; ull hash = 0; }; int n; vector<Node> T; vector<ull> rnd; SegTree(int n) : n(n)... |
#include <bits/stdc++.h> using namespace std; int t, n, a[11]; int main() { scanf( %d , &t); while (t--) { scanf( %d , &n); int day = 0; for (int i = 0; i < 7; i++) scanf( %d , a + i), day += a[i]; int week = (n - 1) / day, best = 7, left = n - week * day; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; vector<char> ch1; int main() { string s, str = ; getline(cin, s); for (int i = 0; i < s.length(); i++) { if (s[i] == . ) { ch1.push_back( - ); i = i + 2; continue; } if (s[i] == && s[i + 1] >= 0 && s[i + 1... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t; cin >> n >> t; int f = 0; int x; int sum = 1; for (int i = 1; i < n; i++) { cin >> x; if (i == sum) sum += x; if (sum == t) f = 1; } if (f == 1) cout << YES << endl; else cout << ... |
#include <bits/stdc++.h> using namespace std; int xuli(long long l, long long r, long long d) { if (l > d || r < d) return d; else return (r / d + 1) * d; } int main() { long long n; cin >> n; long long i, l, r, d; for (i = 1; i <= n; i++) { cin >> l >> r >> d; co... |
#include <bits/stdc++.h> using namespace std; long long Set(long long N, long long pos) { return N = N | (1 << pos); } long long reset(long long N, long long pos) { return N = N & ~(1 << pos); } bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); } void CI(long long &_x) { scanf( %d , &_x)... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n; cin >> n; int cnt = 0; while (n > 1) { if (n % 5 == 0) { n = (4 * n) / 5; cnt++; continue; } else if (n % 3 == 0) { n... |
#include <bits/stdc++.h> using namespace std; const int N = 103; using pi = pair<int, int>; inline int rd() { int x = 0, f = 1, c; while (!isdigit(c = getchar())) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return f * x; } int n, m, k; char p[N][N]; ... |
#include <bits/stdc++.h> using namespace std; struct dd { int k1; char k2; } a[25000]; bool cmp(struct dd q, struct dd b) { return q.k1 > b.k1; } int main() { int i, j, m, n, sum; char b[1000]; gets(b); sum = 0; char k = a ; scanf( %d , &m); for (i = 0; i < 26; i++) { ... |
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T a) { return (a >= 0 ? a : -a); } int main() { int k, no[12]; cin >> k; for (int i = 0; i < 12; i++) cin >> no[i]; sort(no, no + 12); int res = 0, i = 11; while (k > 0 && i >= 0) { res++; k -= no[i]... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e6 + 5; const long long int INF = 1e18; const long long int MOD = 1e9 + 7; int a[N], has[N], hol[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int n, m, k, u, v; cin >> n >> m >> k; ... |
#include <bits/stdc++.h> int main() { int a, b, i, d, c = 0, m = 0, j; scanf( %d %d , &a, &b); d = b; while (d != 0) { c++; d = d / 10; } for (j = 1, i = 1; j < c; j++) { i = i * 10; } while (b != 0) { m = m + (b % 10) * i; b = b / 10; i = i / 10; ... |
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, /STACK:256000000 ) template <class T> T sqr(T a) { return a * a; } int n, m, b; long long a[1 << 20]; int was[1 << 20]; struct dr { int mon, pl, zad; int mask; const bool operator<(dr a) const { if (mon < a.mo... |
#include <bits/stdc++.h> using namespace ::std; int a[110], n, c, i, j, o, m; int main() { cin >> n >> c; cin >> a[0]; for (i = 1; i < n; i++) { cin >> a[i]; m = max(a[i - 1] - a[i] - c, m); } cout << m; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y; cin >> n >> m >> x >> y; int vis[105][105]; int i, j; for (i = 0; i < 105; i++) for (j = 0; j < 105; j++) vis[i][j] = 0; vis[x][y] = 1; cout << x << << y << endl; cout << x << << m << endl; f... |
#include <bits/stdc++.h> using namespace std; map<string, int> mp; int n, m, cc; char s[1010]; int a[1010], cnt[1010]; void getcc(string s) { if (mp.find(s) == mp.end()) mp[s] = cc++; cnt[mp[s]]++; } int main() { int i, j, k; while (scanf( %d%d , &n, &m) > 0) { for (i = 0; i < n; i... |
#include <bits/stdc++.h> const int MAXINT = 2147483640; const long long MAXLL = 9223372036854775800LL; const long long MAXN = 1000000; using namespace std; int l[MAXN], r[MAXN]; int n; int ans[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while (T--) ... |
#include <bits/stdc++.h> using namespace std; int main(void) { int t; cin >> t; while (t--) { long long n, g, b; cin >> n >> g >> b; long long t = (n + 1) / 2; long long r = t / g * (g + b); if (t % g == 0) { r -= b; } else { r += t % g; } ... |
#include <bits/stdc++.h> using namespace std; long long a[10]; long long ans = 0; void DFS(long long n, long long u, long long r[10]) { if (n == 10) { long long sum = 1; for (long long i = 2; i <= u; i++) sum *= i; for (long long i = 1; i < 10; i++) for (long long j = 2; j <= r[i];... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long long MOD = 1e9 + 7; const int inf = 1e9; const int N = 3e5 + 5; bool flag; template <typename T> istream& operator>>(istream& is, vector<T>& v) { for (auto& i : v) is >> i; return is; } template <typename T>... |
#include <bits/stdc++.h> using namespace std; template <class T> void debug(T a, T b) { ; } template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const T& b) { if (a < b) a = b; } namespace std { template <class S, class T> ostrea... |
#include <bits/stdc++.h> using namespace std; bool PIIfs(const pair<int, int>& a, const pair<int, int>& b) { return a.first < b.first || (a.first == b.first && a.second < b.second); } bool PIIsf(const pair<int, int>& a, const pair<int, int>& b) { return a.second < b.second || (a.second == b.second && a.... |
#include <bits/stdc++.h> using namespace std; long double DP[202][202][202]; long double P[202]; int A[202]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, l, k; cin >> n >> l >> k; k = min(k, n); for (int i = 1; i <= n; i++) cin >> P[i], P[i] /= 100.0; f... |
#include <bits/stdc++.h> using namespace std; int mod = 1e9 + 7; vector<long long> num; long long gcd(long long x, long long y) { if (y > x) return gcd(y, x); return x % y ? gcd(y, x % y) : y; } int a[3]; vector<vector<int> > grid; vector<vector<int> > dist; void bfs(int x, vector<bool>& vis) ... |
#include <bits/stdc++.h> using namespace std; bool query = 0; struct line { long long m, b; mutable function<const line*()> succ; bool operator<(const line rhs) const { if (!query) return (m < rhs.m); const line* s = succ(); return s ? (b - s->b) < (rhs.m * (s->m - m)) : 0; } }... |
#include <bits/stdc++.h> using namespace std; int triangle(long long n) { if (n == 1) return 1; else return n + triangle(n - 1); } int heart(long long a) { if (a == 1) return 1; else return (6 * (a - 1)) + heart(a - 1); } int balls(long long a) { if (a == 1) ... |
#include <bits/stdc++.h> using namespace std; int n, m; set<int> nx[1000100]; vector<pair<int, int> > nw; int a[1000100]; vector<pair<int, int> > ans; set<pair<int, int> > order; set<pair<int, int> > lst; int main() { ios_base ::sync_with_stdio(0); cin.tie(); cout.tie(); srand(23095); ... |
#include <bits/stdc++.h> using namespace std; long long a[201010]; int main() { long long n, m, k; while (~scanf( %lld%lld%lld , &n, &m, &k)) { memset(a, 0, sizeof(a)); long long i, j, ans = 0, sum = k; for (i = 1; i <= n; i++) scanf( %lld , &a[i]); for (i = n; i >= 1; i--) { ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long power(long long a, long long b) { if (b == 1) return a; if (b == 0) return 1; long long ans = power(a, b / 2); ans = (ans * ans); if (b & 1)... |
#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 % b); } long long int power(long long int x, long long int n) { long long ans = 1; while (n > 0) { ... |
#include <bits/stdc++.h> using namespace std; template <typename... Args> void trace(Args... args) {} template <typename... Args> void recInit(Args... args) {} template <typename... Args> void recEnd(Args... args) {} struct node { long long sum, lp, rp, L, R, sz; } tree[4 * 200020], np; node mer... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &x) { int f = 0, c = getchar(); x = 0; while (!isdigit(c)) f |= c == 45, c = getchar(); while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); if (f) x = -x; } template <typename T, typena... |
#include <bits/stdc++.h> using namespace std; char mat[55][55]; int n; int A[] = {-1, 0, 1, 0}; int B[] = {0, 1, 0, -1}; vector<pair<int, int> > ilha1, ilha2; void flood_fill(int i, int j, bool prima) { if (i < 0 or j < 0 or i >= n or j >= n or mat[i][j] != 0 ) return; mat[i][j] = 1 ; if (pr... |
#include <bits/stdc++.h> using namespace std; inline void PAUSE() { char tmp; cin >> tmp; } char s[102]; int main() { int n, k; int f = 0; scanf( %d %d , &n, &k); if (n == k) f = 1; cin >> s; if (n >= 2 * k) for (int i = k - 1; i >= 1; i--) { cout << LEFT << end... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e6 + 5; int ends_here[MAX]; int qs, qe; struct data { int child[26]; int score; bool leaf; int suf; int ends; }; data arr[MAX]; int que[MAX]; int cur; struct aho_corasick { int root; int size; void init() ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1, c = getchar(); while (c < 48) c == - && (f = -1), c = getchar(); while (c > 47) x = x * 10 + c - 0 , c = getchar(); return x * f; } const int MAXN = 100005; std::vector<long long> adj; long long n, ans; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2E5 + 10; long long jc[15]; int main() { jc[0] = 1; for (int i = 1; i <= 14; ++i) jc[i] = jc[i - 1] * i; int n, m; cin >> n >> m; int z = max(n - 13, 1); long long ad = 0, p = jc[n - z + 1]; while (m--) { int k; ... |
#include <bits/stdc++.h> using namespace std; long long Q; long long sum[105]; multiset<long long> s; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> Q; while (Q--) { char op; long long f; cin >> op >> f; if (op == + ) { long long i = 0; w... |
#include <bits/stdc++.h> using namespace std; int b[205]; int a[205]; int main() { int n, m, k; int x; scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= k; i++) { scanf( %d , &x); a[i] = x; } int sum = 0; int mm = m; while (n--) { mm = m; while (mm--) { ... |
#include <bits/stdc++.h> using namespace std; int main() { char dir; cin >> dir; string m; cin >> m; string kboard = qwertyuiopasdfghjkl;zxcvbnm,./ ; if (dir == R ) { for (int i = 0; i < m.length(); i++) { int index = kboard.find(m[i]); cout << kboard[index - 1]; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int N = 1e5 + 5; vector<int> g[N]; vector<pair<int, int> > ans; int maxx; void dfs(int x, int fa, int t) { int siz = g[x].size(); int tmp = t; ans.push_back(make_pair(x, t)); for (int i = 0; i <= siz - 1; i++) {... |
#include <bits/stdc++.h> using namespace std; template <class T> inline void chkmax(T &x, T y) { if (x < y) x = y; } template <class T> inline void chkmin(T &x, T y) { if (x > y) x = y; } int q, n, f, inv[100100], fac[100100], p[6]; void Euclid(int a, int b, int &x, int &y) { if (!a) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; set<int> v; int a; for (int i = 0; i < n; ++i) { cin >> a; v.insert(a); } v.erase(0); cout << v.size(); return 0; } |
#include <bits/stdc++.h> using namespace std; long long rr[] = {0, 1, 1, 1, 0, -1, -1, -1}; long long cc[] = {1, 1, 0, -1, -1, -1, 0, 1}; const long long mod = 1e9 + 7; const long long N = 300050; long long m, fact[N]; void pre() { fact[0] = 1; for (long long i = 1; i < N; i++) { fact[i] = (... |
#include <bits/stdc++.h> using namespace std; int tab[300000]; vector<int> numbers; int main() { int n; cin >> n; numbers.resize(n + 10); vector<int> unused; for (int i = 1; i <= n; i++) { cin >> numbers[i]; if (numbers[i] > n || numbers[i] < 1) { unused.push_back(i); ... |
#include <bits/stdc++.h> using namespace std; long long int mod = 998244353; long double eps = 1e-12; long long int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; long long int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; long long int n, res = 0, k = 0, h, ans = 0, m; long long int gcd(long long int a, long long int b) { ... |
#include <bits/stdc++.h> using namespace std; const int nmax = 1e5 + 42, mod = 1e9 + 7; int n, inp[nmax]; vector<int> seen[nmax], dvd[nmax]; int phi[nmax]; int cnt[nmax]; long long sum_gcd(vector<int> cur) { long long alone = 0; for (auto w : cur) alone = (alone + w) % mod; long long together ... |
#include <bits/stdc++.h> using namespace std; void cal(long long number, long long x, long long s) { long long d = number ^ x; long long temp = 2 * number - (s + d); if (temp % 2 == 0) { cout << 3 << endl; cout << d << << temp / 2 << << temp / 2 << endl; } if (temp % 2 == 1) ... |
#include <bits/stdc++.h> using namespace std; int kor = 1e7; int main() { long long n, rad, v; cin >> n >> rad >> v; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; long long d = r - l; int ma = 0; while (d < kor) { d *= 10; rad *= 10; ma++;... |
#include <bits/stdc++.h> using namespace std; int n, i, v[5005]; int ans(int st, int dr, int lvl) { if (st > dr) return 0; int mini = 1000000001; int minipoz; for (int i = st; i <= dr; i++) { if (v[i] <= lvl) { return ans(st, i - 1, lvl) + ans(i + 1, dr, lvl); } if (v[i] ... |
#include <bits/stdc++.h> using namespace std; vector<int> a, b, e; char s[5]; long long ans; int c; int main() { int n, f; scanf( %d , &n); while (n--) { scanf( %s %d , &s, &f); if (s[0] == 0 && s[1] == 1 ) a.push_back(f); else if (s[0] == 1 && s[1] == 0 ) ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; int m; scanf( %I64d %d , &n, &m); std::vector<long long int> v(n, 0); for (int i = 0; i < m; i++) { int x, y; scanf( %d%d , &x, &y); v[x - 1]++; v[y - 1]++; } long long int res = 0; fo... |
#include <bits/stdc++.h> using namespace std; vector<long long> z, q; long long w, p = 10, l = 60; long long mul(long long x, long long y) { long long z = 0; for (; y; y >>= 1, x = x * 2 % p) if (y & 1) z = (z + x) % p; return z; } pair<long long, long long> F(long long x) { if (x == 0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.