func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; if (k == 1) { cout << Yes << endl; return; } vector<int> divs; for (int i = 2; i < k; ++i) if (!(k % i)) { cerr << i << endl; divs.push_back(1); while (!(k % i)) ... |
#include <bits/stdc++.h> using namespace std; int n, m, color[510]; bool g[510][510]; vector<int> nbr[510]; bool dfs(int x, int c) { color[x] = c; for (int i = 0; i < nbr[x].size(); i++) { int y = nbr[x][i]; if (color[y] == c) return 0; if (color[y] == 0 && dfs(y, 3 - c) == 0) return... |
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; int Deb = 0; int Fin = 9; int Tab[10]; for (int j = 0; j < 10; j++) Tab[j] = 0; char Cuck; for (int j = 0; j < T; j++) { cin >> Cuck; if (Cuck == L ) { Tab[Deb] = 1; int curDeb = ... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { char ch = getchar(); x = 0; while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); } int n, m, a[238][238], x[238], y[238]; signed main() { read(n), read(m); for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; const int PI = 3.1415926535; const int inf = 1000111222; const int mod = 1000000007; const int N = 100007; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> ar(n); for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n, k; long long temp[55]; long long dp[105][55], ans; vector<int> g[105]; void dfs(int u, int fa) { dp[u][0] = 1; dp[u][1 + k] = 1; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; if (v != fa) { ... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int main() { int n, k, sum = 0; scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) { scanf( %d , a + i); sum += a[i]; } sort(a, a + n); int res = a[n - 1]; for (int t = n - k, i = n - k - 1; i >= 0; i--, t++) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> struct seg_tree_lazy { int S, H; T zero; std::vector<T> value; U noop; std::vector<bool> dirty; std::vector<U> prop; seg_tree_lazy<T, U>(int _S, T _zero = T(), U _noop = U()); void set_leaves(std::vecto... |
#include <bits/stdc++.h> using namespace std; int main() { long long i, n, r, S, Z, s1, s2, s3, s4, s5, s6, s7, s8, x, y, z, m, j, l, k, t; long long a[500005]; long long b[300045]; long long c[300001]; long long d[100001]; long long e[101][101]; pair<long long, long long> aa[200... |
#include <bits/stdc++.h> using namespace std; const int maxn = 50100; vector<int> v; int n, k, st, x; int nextchild[maxn], value[maxn]; void get_rand() { int arr[n + 1]; for (int i = 0; i < n; i++) { arr[i] = i + 1; } srand(time(0)); random_shuffle(arr, arr + n); for (int i = 0... |
#include <bits/stdc++.h> using namespace std; struct node { int l, r, lc, rc; int dep_a, dep_a_2b, dep_2b_c, dep_2b, dep_a_2b_c, cover; }; const int N = 200000; const int root = 0; struct Segment_Tree { int num; node tr[2 * N]; void setRange(int l, int r, int now = root) { num = 0;... |
#include <bits/stdc++.h> using namespace std; int a[200005], b[200005]; int main() { int n, m, i; cin >> n >> m; for (i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (i = 0; i < m; i++) cin >> b[i]; for (i = 0; i < m; i++) { if (i != m - 1) cout << upper_bound(a, a + n, b... |
#include <bits/stdc++.h> using namespace std; const long long K = 401, MAX = 1e18; int n, m, k, f; vector<pair<int, int>> adj[2 * K]; vector<pair<int, pair<int, int>>> E; vector<long long> sp; long long dist[2 * K]; bool vis[2 * K]; unordered_map<int, int> tb; priority_queue<pair<int, int>, vector<p... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n, t, blow, head, d, h, mx, mxd; cin >> t; while (t--) { cin >> blow >> head; mx = -1; mxd = 0; while (blow > 0) { cin >> d >> h; mx = max(mx, d - h); mxd = max(mxd, d); blow--... |
#include <bits/stdc++.h> using namespace std; char tmp[120]; int n_t, n_v, n_p; map<string, string> lei; vector<string> voids[1005]; vector<string> call; inline bool cmp(vector<string>& v1, vector<string>& v2) { int i = 0, j = 0; while (v1[i] == && i < v1.size()) i++; while (v2[j] == && ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e8 + 5; long long MAX = 1e9; long long MOD = 1e9 + 7; long long Mod = 1e9 + 7; double EPS = 0.0001; long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); } long long lcm(long long a, long long b) { return ((a * b) / gc... |
#include <bits/stdc++.h> using namespace std; int main() { long long(n), (m); scanf( %lld%lld , &(n), &(m)); ; vector<map<long long, long long>> vals(n); long long maxi = 1; for (long long i = 0; i < (m); i++) { long long(a), (b), (c); scanf( %lld%lld%lld , &(a), &(b), &(c)); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, l; cin >> n >> l; vector<int> a(n, 0), b(n, 0); for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i]; if (n == 1) cout << YES n ; el... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; long long n, m, ans, a, b, temp; int t; long long num[maxn]; long long mark[maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> num[i]; num[i] = abs(num[i]); } sort(num, num + n); int l =... |
#include <bits/stdc++.h> using namespace std; void dk_98() {} long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } void solve() { int n; cin >> n; int arr[n][n]; for (long long i = 0; i < (int)(n); i++) { for (long long j = 0; j < (int)(n); j++)... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000000 + 7; const long long int N = 1000000 + 6; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int tc; tc = 1; while (tc--) { long long int n, m; cin >> n >> m; st... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:134217728 ) using namespace std; char buf[2]; vector<int> sign; int n; int main() { sign.push_back(1); scanf( %s , buf); while (1) { scanf( %s , buf); if (buf[0] == = ) break; sign.push_back(buf[0] == + ? 1 : -1); ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; string name[MAXN], surname[MAXN]; bool u[MAXN]; int n; int x1[30], x2[30]; int Getn() { int res = 0; for (int i = 0; i < 26; i++) res += min(x1[i], x2[i]); return res; } int main() { cin >> n; for (int i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; unordered_map<int, int> f[N]; int n, m, k, ans, p[N], sx[N], sy[N]; inline int sol(int x, int y) { if (f[x].count(y)) return f[x][y]; int t; printf( ? %d %d n , x, y), fflush(stdout), scanf( %d , &t); return f[x][y] = t; } ... |
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> s; s = ? + s + ? ; int c = 0; bool flag = true; for (int i = 1; i <= n; i++) { if (s[i] == ? ) { c++; if (s[i -... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[n], y[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } if (n == 1) { cout << -1 << endl; } else if (n == 2) { if (x[0] != x[1] && y[0] != y[1]) { int a = fabs(x[0] - x[1]),... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long t, n, i, j, k, l, r, minn, maxx, ans, x, y; cin >> t; while (t--) { cin >> n; cin >> maxx >> minn; for (i = 1; i < n; i++) { cin >> x >> y; maxx = max(m... |
#include <bits/stdc++.h> using namespace std; int q; int main(void) { cin >> q; while (q--) { long long l, r, ans = 0, num = 0; cin >> l >> r; num = r - l + 1; if (r & 1) { ans -= num / 2; if (num & 1) ans -= l; } else { ans += num / 2; if (num... |
#include <bits/stdc++.h> #define rep(i,a,b) for(int i = (a); i < (b); ++i) #define rrep(i,a,b) for(int i = (b); i --> (a);) #define sz(v) int(v.size()) using namespace std; string inf, zero; string add(string x, string y, int init){ string res(sz(x), ? ); int todo = init; rrep(i,0,sz(x)){ ... |
#include <bits/stdc++.h> using namespace std; char _; const long long maxN = 200 * 1000 + 5; const long long maxM = 5000 + 5; const long long mod = 1000 * 1000 * 1000 + 7; const long long base = 701; const long long SQ = 500; const long long maxL = 20; int32_t main() { ios::sync_with_stdio(0); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; int c; cin >> c; int A[N]; A[0] = 0; int B[N]; B[0] = 0; for (int i = 1; i < N; i++) cin >> A[i]; for (int i = 1; i < N; i++) cin >> B[i]; ... |
#include <bits/stdc++.h> using ul = std::uint32_t; using li = std::int32_t; using ull = std::uint64_t; using ll = std::int64_t; using llf = long double; ul n, m, k; const ul maxn = 2e5; const ul base = 998244353; ul plus(ul a, ul b) { return a + b < base ? a + b : a + b - base; } ul plus(ul a, ul b,... |
#include <bits/stdc++.h> using namespace std; set<int> s; map<int, int> mm; int a[500005]; int main() { int n, m, d; cin >> n >> m >> d; for (int i = 0; i < n; i++) { int k; cin >> k; s.insert(k); a[i] = k; } set<int>::iterator it1, it2, it3; int sum = 0; fo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1100; const int MAXM = 1100; const int MAXK = 100100; int n, m, k, len[MAXK], max_len[MAXN][MAXM][4]; int mm[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; char mmap[MAXN][MAXM], dir[MAXK], direction[256]; vector<pair<int, int> > possible; vec... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, num = 1, mul; cin >> n; string s = codeforces ; int ln = s.length(), a[12] = {0}; for (long long int i = 2; i <= 100; i++) { long long int curr = pow(i, 10ll); if (curr >= n) { for (int j = 0; j < 10... |
#include <bits/stdc++.h> using namespace std; const int MOD9 = 1e9 + 7; const int MOD91 = 1e9 + 9; const long long MOD12 = 1e12 + 39LL; const long long MOD15 = 1e15 + 37LL; const int INF = 1e9; const int base = 1e9; const int MAX = 2e5; const long double EPS = 1e-10; int n; int a[200000]; int ma... |
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <utility> #include <set> #include <queue> #include <deque> #include <stack> #include <map> #include <math.h> #include <iomanip> #include <fstream> #include <bitset> #include <sstream> using namespac... |
#include <bits/stdc++.h> using namespace std; int solve(); int main() { solve(); } int solve() { string s; vector<int> cnt(26); cin >> s; int ncnt = 0; for (int i = 0; i < s.size(); ++i) ++cnt[s[i] - a ]; for (int i = 0; i < 26; ++i) ncnt += (cnt[i] & 1); while (ncnt > 1) { fo... |
#include <bits/stdc++.h> using namespace std; const int M = 333333; const int INF = 2000000000; int n, m, k, a[M]; inline int read() { char c = getchar(); int ans = 0; while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) ans = (ans << 1) + (ans << 3) + (c ^ 48), c = get... |
#include <bits/stdc++.h> using namespace std; long long n, ans; string a; int main() { cin >> a; ans = a.size(); long long t = 0; for (int i = 0; i < a.size(); i++) { if (a[i] == ) ) t--; else t++; if (t < 0) { t = 0; ans--; } } co... |
#include <bits/stdc++.h> using namespace std; int main() { long long int m, n; cin >> n >> m; if (n > 26) cout << m; else { int a = 2; for (int i = 2; i <= n; i++) a = a * 2; cout << m % a; } } |
#include <bits/stdc++.h> using namespace std; int ans[10000]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n, k; string s; cin >> n >> k; cin >> s; int cnt = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == s[i - 1]) { cnt++; } else { ... |
#include <bits/stdc++.h> using namespace std; struct node { long k, na; }; const long maxn = 100001; node a[maxn]; long n, b[maxn]; int qsort(long low, long high) { long i = low, j = high, x = a[(i + j) / 2].k; while (i < j) { while (a[i].k < x) i++; while (a[j].k > x) j--; i... |
#include <bits/stdc++.h> using namespace std; int n, w[1000999]; int arr[1009999]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &w[i]); arr[w[i]]++; } for (int i = 0; i < 1000099; i++) { arr[i + 1] += arr[i] / 2; arr[i] = arr[i] % 2; } i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 500 + 5; const int mod = 26; long long qp(long long a, long long n) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } template <class T> inline bool... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 1, -1, 0}; int dy[] = {1, 0, 0, -1}; long double PI = 3.14159265358979323846264338327950; pair<int, int> p[12000002]; int a[12000002], b[12000002]; int m, n, k; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m... |
#include <bits/stdc++.h> using namespace std; int a[111]; int id[111][111]; int vis[111]; int main() { int n, m, k, q; while (cin >> n >> k) { m = n / k; for (int i = 0; i < n; i++) { cin >> a[i]; vis[i] = 0; } scanf( %d , &q); double minv = 1 << 30, maxv ... |
#include <bits/stdc++.h> using namespace std; vector<vector<int> > vec1(312345), vec2(312346); int g[123456], p[123456], t[123456]; int cons; int h, w; int computeup(int i) { int val1, val; vector<int>::iterator it; val1 = t[i] - p[i] + cons; it = upper_bound(vec1[val1].begin(), vec1[val1].e... |
#include <bits/stdc++.h> using namespace std; bool check(long long int mid, long long int r, vector<long long int>& a) { long long int d = 0; long long int cnt = 0; for (long long int i = a.size() - 1; i >= 0; i--) { if (a[i] - d <= 0) continue; else { if (cnt < mid) { ... |
#include <bits/stdc++.h> using namespace std; pair<int, int> a[10], b[10]; vector<int> p; bool square(int i, int j) { double len = sqrt((a[j].first - a[i].first) * (a[j].first - a[i].first) + (a[j].second - a[i].second) * (a[j].second - a[i].second)); for (int t = i + 1; t <= j; t+... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; long long n, k; long long p[200005]; long long md = 998244353; long long binpow(long long a, long long b) { if (b == 1) { return a % md; } long long z = binpow(a, b / 2); if (b & 1) { return z * z % md * ... |
#include <bits/stdc++.h> using namespace std; int T; int a, b; int x[6], y[6]; bool check30(int a, int b) { a -= 75; x[1] = x[2] = x[3] = 25; y[1] = y[2] = y[3] = 0; if (a < 0) return 0; if (a > 0) { x[1] += a; y[1] = 23 + a; b -= 23 + a; } if (b < 0) return 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { char a, b; int A, B; cin >> a >> A; cin >> b >> B; int chess[9][9] = {0}; for (int i = 1; i < 9; i++) { chess[i][A] = 1; } for (int i = 1; i < 9; i++) { chess[a - 96][i] = 1; } if (b - 98 > 0) { if (... |
#include <bits/stdc++.h> using namespace std; int dp[2][4004]; struct node { int st; int cost; } save[4004]; int n, k; void checkmin(int &a, int b) { if (a == -1 || a > b) a = b; } int main() { int i, j; int ans; while (~scanf( %d%d , &n, &k)) { memset(dp, -1, sizeof(dp)); ... |
#include <bits/stdc++.h> using namespace std; int n, m; char** mat; short ***sparse, ***rem; void build() { sparse = new short**[n + 1]; rem = new short**[n + 1]; for (int i = 0; i <= n; ++i) { sparse[i] = new short*[m + 1]; rem[i] = new short*[m + 1]; } for (int i = 0; i <= n;... |
#include <bits/stdc++.h> using namespace std; int oriArr[2000001] = {0}; int arr[2000001]; int main() { int oriCnt; cin >> oriCnt; int maxOri = 0; for (int i = 0; i < oriCnt; i++) { int tmp; cin >> tmp; oriArr[tmp] = 1; if (maxOri < tmp) maxOri = tmp; } arr[0] = 0... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1 << 23; char s[55][55]; int p[55], r[55], d[55], h[55], ans = 0; int f[maxn], g[maxn], bit[maxn]; int ff(int x) { if (p[x] != x) p[x] = ff(p[x]); return p[x]; } void funion(int x, int y) { x = ff(x); ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; long long ans, res; int L[N], R[N]; int n, a[N]; long long dp[40][2]; void solve(int d, int l, int r) { if (l >= r) return; if (d == -1) return; int nl = 0, nr = 0; long long tmp1 = 0, tmp2 = 0; ; for (int i = l;... |
#include <bits/stdc++.h> using namespace std; signed main() { std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); ; long long CASE = 1; while (CASE--) { long long n; cin >> n; vector<std::pair<long long, long long> > c; for (long long i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; string a; cin >> a; string b; cin >> b; string c = a; int flag = 0; int count = 0; vector<int> ans; int s = 1; int e = n; ... |
#include <bits/stdc++.h> using namespace std; long long n, a[310]; long long fac[310], rev[310]; bool mmp[310][310]; long long mod = (long long)1e9 + 7; long long qmod(long long a, long long p) { long long ret = 1; while (p) { if (p & 1) ret = (ret * a) % mod; a = (a * a) % mod; p ... |
#include <bits/stdc++.h> using namespace std; const int N = 200010; struct par { int x, t; bool operator!=(par k) { return x != k.x || t != k.t; } } p[N], p2[N]; int flag, n, sa[N], ea[N], sb[N], eb[N], _[N], _lans, _rans, key1[N], key2[N]; bool cmp(par x, par y) { int kx = x.t == 1 ? sa[x.x] : ... |
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> istream &operator>>(istream &in, pair<T1, T2> &a) { in >> a.first >> a.second; return in; } template <typename T1, typename T2> ostream &operator<<(ostream &out, pair<T1, T2> a) { out << a.first << << a.second;... |
#include <bits/stdc++.h> using namespace std; int l, r, a; int main() { cin >> l >> r >> a; if (l > r) swap(l, r); if (l == r) return cout << (l + a / 2) * 2, 0; if (l < r) { if (l + a >= r) { a -= abs(l - r), l = r; cout << l * 2 + (a / 2) * 2; } else cout << (... |
#include <bits/stdc++.h> using namespace std; vector<int> v[2003]; int depth[2003], root[2003]; int ans = 0, n; void dfs(int x, int y) { depth[x] = y; for (int i = 0; i < v[x].size(); i++) { dfs(v[x][i], y + 1); } } int main() { int i, j, a; cin >> n; for (i = 1; i <= n; i++)... |
#include <map> #include <queue> #include <cmath> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #define itt map<int,int>::iterator #define ll long long #define ull unsigned long long #define dd double using namespace std; const int maxn=5000,N1=maxn+5; const int in... |
#include <bits/stdc++.h> using namespace std; int i, j, a; int main() { for (i = 1; i <= 5; i++) { for (j = 1; j <= 5; j++) { cin >> a; if (a == 1) cout << (abs(3 - i) + abs(3 - j)) << endl; } } } |
#include <bits/stdc++.h> using namespace std; signed long long p[1000005] = {0}; void sieve() { p[0] = 1; p[1] = 1; for (signed long long i = 2; i * i <= 1000000; i++) { if (p[i] == 0) { for (signed long long j = 2 * i; j <= 1000000; j = j + i) p[j] = 1; } } } int main() { ... |
#include <bits/stdc++.h> using namespace std; long long power(long long base, long long e) { long long answer = 1; while (e) { if (e % 2 == 1) { answer *= base; } base *= base; e /= 2; } return answer; } int main() { long long i, n, m, k, j; cin >> n >> m;... |
#include <bits/stdc++.h> using namespace std; bool isPrime(int n) { if (n <= 1) { return false; } for (int i = 2; i < n; i++) { if (n % i == 0) { return false; } } return true; } vector<long long int> inisum; long long int binary(long long int target) { long l... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int a, b; int c[4]; int minC = INT_MAX; for (int i = 0; i < 4; i++) { cin >> c[i]; if (minC > c[i]) minC = c[i]; } cin >> a >> b; int minXX = min(... |
#include <bits/stdc++.h> using namespace std; int n, m; string s[1111]; int c[1111]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) cin >> s[i]; int ans = 0; for (int j = 0; j < m; j++) { bool ret = false; for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; using namespace std; vector<pair<int, int> > dp(101); int cntr[101] = {0}; int getIndexes(int &a, int &b, int &c, int &i, int &m, int x, int &xc, int &k) { int res1 = 0; int res2 = 0; int f1 = 0, f2 = 0, j; if (cntr[x] == 0) { for (j = xc - m... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; string s; cin >> n >> s; int ans = 100; for (int i = 0; i < n; i++) { if (s[i] == > ) { ans... |
#include <bits/stdc++.h> using namespace std; const int N = 3e4 + 7, M = 2e2 + 7; bool fl[N]; int n, k, tot, fs[N], sum[N], pos[M], f[M][N]; map<int, bool> s[N]; struct edge { int u, v; } ed[N * M]; struct node { int ch[M], num; } qt[N]; inline int read() { int num = 0; char g = getc... |
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << << H; debug_out(T...); } const int INF = 1e9; const long long MOD = 1e9 + 7; const int N = 1e5 + 5, MO = 320, SQ = 600; in... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; const int prime = 9241; const long double pi = acos(-1.); int in[100005]; int masks[1000005]; bool used[1 << 22]; int main() { int n, m, d; scanf( %d%d%d , &n, &m, &d); for (int i = 0; i < m; i++) { int s; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int len = s.size(); int cnt = 0; for (int i = 0; i < len; i++) { if (s[i] == a || s[i] == e || s[i] == i || s[i] == o || s[i] == u ) cnt++; if (s[i] == 1 || s[i] == 3 || s[i] == 5 ||... |
#include <bits/stdc++.h> using namespace std; long long Labs(long long first) { return first < 0 ? -first : first; } int main() { long long n, d; cin >> n >> d; long long a[n]; for (int i = (0); i < (int)(n); i++) cin >> a[i]; long long ans = 0; for (int i = (0); i < (int)(n); i++) f... |
#include <bits/stdc++.h> using namespace std; const long double inf = 1e18 + 7; const long double eps = 1e-18; long long gcd(long long a, long long b) { while (a || b) a %= b, swap(a, b); return a + b; } int main() { ios_base::sync_with_stdio(0); long long t; cin >> t; for (long long... |
#include <bits/stdc++.h> using namespace std; int x[30000001]; int main() { int n, a; cin >> a >> n; long long sum = 0, limit = n + a + 1; memset((x), 0, sizeof(x)); for (long long i = 1; i * i < limit; i++) for (long long j = i * i; j < limit; j += i * i) x[j] = i * i; for (int i = ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, a, b; cin >> n >> a >> b; string s, ans; for (long long i = 0; i < b; i++) { long long m = a ; char c = m + i; s += c; } for (long lon... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long t, v; cin >> t >> v; long long a[t]; for (int i = 0; i < t; i++) cin >> a[i]; long long minx = 0; sort(a, a + t); for (int z = 0; z < t - 1; z++) { minx = max(a[z ... |
//-->FIVAR_RoX #include <bits/stdc++.h> #include <vector> #include <set> #include <string> #include <queue> #define lli long long int #define ld long double //loops #define dfloop(count1,count2,count3) for(lli i=count1;i>count2;i+=count3) #define floop(count1,count2,count3) for(lli i=count1;i<count2... |
#include <bits/stdc++.h> using namespace std; bool sieve[100000 + 5]; vector<long long> primes; int inf[100000 + 5]; vector<vector<int> > g; vector<vector<int> > h; vector<int> rab; vector<int> rtb; vector<int> res; void rec(int id, int del) { if (id == rab.size()) { res.push_back(del); ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int INF = 1e9; const long long INF64 = 9e18; const long double EPS = 1e-9; const long double PI = 3.14159265358979310000; const long long MD = 1248742437; const long long T = 378531; const int N = 1200001; const int M... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x; bool watched[1000001]; cin >> n; while (cin >> x) watched[x] = true; for (int i = 1; i <= n; i++) if (!watched[i]) cout << i; return 0; } |
#include <bits/stdc++.h> using namespace std; int tab[205]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> V; for (int i = 0; i < n; i++) { int x; cin >> x; tab[... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; t = 1; while (t--) { long long int n, m; cin >> n >> m; long long int arr[n]; string arr2[m]; for (long long int i = 0; i < n; i++) { cin >> arr[i]; } map<string, int> mp; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 10; const int maxn = 5e5 + 10; int N, M; struct edge { int v, u, l, r; edge() {} edge(int v_, int u_, int l_, int r_) : v(v_), u(u_), l(l_), r(r_) {} bool operator>(const edge& rhs) const { return l > rhs.l; } }; priority_... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, A, B, x, y; while (cin >> x >> y >> A >> B) { int Count = 0; for (i = A; i <= x; i++) { for (j = B; j <= y; j++) { if (i > j) { Count++; } } } cout << Count << endl; ... |
#include <bits/stdc++.h> using namespace std; int a[1000000]; pair<int, int> b[1000000]; int ord[1000000]; int main() { int n, k; cin >> n >> k; long long m; cin >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; b[i] = make_pair(a[i], i); } sort(b + 1, b + n, greater<pa... |
#include <bits/stdc++.h> using namespace std; void rom(long long W) { long long pot = 1LL; char val[20] = IVXLCDM ; long long w = 0LL, z, i; while (pot <= W) { pot *= 10LL; w++; } pot /= 10LL; w--; while (pot) { z = W / pot; if (z == 4) printf( %c%c ,... |
#include <bits/stdc++.h> using namespace std; int main() { int a = 0; cin >> a; int z = 0, e = 0; char b; for (int i = 0; i < a; i++) { cin >> b; if (b == D ) z++; if (b == A ) e++; } if (e == z) cout << Friendship ; else if (e < z) cout << Danik ; ... |
#include <bits/stdc++.h> using namespace std; bool good(long long int a, long long int b) { while (a and b) { if (a % 2 == 0 and b % 2 == 1) return false; a /= 2; b /= 2; } return true; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; deque<int> q; int main() { int n; while (~scanf( %d , &n)) { q.clear(); for (int i = 1; i <= n; i++) q.push_back(i); for (int i = 2; i <= n; i++) { int k = ((n - 1) / i) * i; int tmp = q[k]; ... |
#include <bits/stdc++.h> using namespace std; void setIO(string str, bool dbg) { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); if (!dbg) { freopen((str + .in ).c_str(), r , stdin); freopen((str + .out ).c_str(), w , stdout); } } const int MAX = 5e3 + 5; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t, i, j, k, n; cin >> t; while (t--) { cin >> n; long long int ans = 0; int i = 0; while (n) { ans += n; n = n / 2; } cout << ans << endl; } } |
#include <bits/stdc++.h> using namespace std; long long MOD = 998244353; long long gcd(long long a, long long b) { long long c; while (a != 0) { c = a; a = b % a; b = c; } return b; } signed main() { cin.tie(0); ios::sync_with_stdio(false); long long N; cin >>... |
#include <bits/stdc++.h> using namespace std; int a, b; int main() { while (cin >> a >> b) { if (b % 2 == 0) cout << a * b / 2 << endl; else cout << a * (b / 2) + a / 2 << endl; } return 0; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.