func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int arr[101] = { 0, }; int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int t; scanf( %d , &t); for (int j = 0; j < t; j++) { int tmp; scanf( %d , &tmp); arr[tmp]++; } } ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 200015; const int nil = 100005; int n; set<pair<int, int> > S; set<pair<int, int> > T; int w[Maxn]; vector<pair<int, int> > cand[Maxn]; pair<int, int> res[Maxn]; int main() { scanf( %d , &n); for (int i = 0; i < n; i++) { i... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(false); ; cin.tie(NULL); ; long long int t = 1; while (t--) { long long int n; cin >> n; pair<long long int, long long int> tree[n]; long long int i, j, k; map<pair<long long i... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-5; const int p = 131; const int inf = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int N = 1e6 + 10; long long Hash[N], fac[N]; char s[N], ss[N]; long long get(int l, int r) { return (Hash[r] - Hash[l - 1] * fac[r - l + 1] % m... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; char ch = getchar(); int fh = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) fh = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); x *= ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int vis[maxn], son[maxn], f[maxn], sum, root, ans[maxn]; vector<int> g[maxn]; void getroot(int x, int fa) { son[x] = 1; f[x] = 0; for (int i = 0; i < g[x].size(); i++) { int v = g[x][i]; if (v == fa || vis[v]) con... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; struct ele { int value, jj, index; }; bool ordena(ele a, ele b) { return a.value < b.value; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int k, n; cin... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, c = 0, n, s = 0; cin >> n >> k; for (i = 1; i <= n; i++) { s += (5 * i); if (s + k <= 240) c++; } cout << c; return 0; } |
#include <bits/stdc++.h> using namespace std; signed main() { int n, a, b; cin >> n >> a >> b; string s; cin >> s; vector<int> dp(n + 1, INT_MAX); vector<vector<int> > lcp(n, vector<int>(n)); for (int i = n - 1; i >= 0; --i) { for (int j = n - 1; j >= 0; --j) { if (s[i] == ... |
#include <bits/stdc++.h> using namespace std; bool vis[100001]; int pi[100001]; int level[100001]; list<int> adj[100001]; void dfs(int s) { vis[s] = 1; bool flag = 1; for (list<int>::iterator it = adj[s].begin(); it != adj[s].end(); ++it) if (!vis[*it]) { level[*it] = level[s] + 1;... |
#include <bits/stdc++.h> using namespace std; template <typename tn> void read(tn &a) { tn x = 0, f = 1; char c = ; for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; a = x * f; } const int N = 101000; long long lim[8... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; long long arr[maxn]; int vis[maxn]; int main() { int T; scanf( %d , &T); while (T--) { int n; if (n == 1) { printf( YES n ); continue; } scanf( %d , &n); n *= 4; for (int i =... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, cnt = 0, sum = 1; vector<int> v; cin >> n >> k; if (k == 1) { cout << n << endl; return 0; } for (int i = 2; i <= n / 2; i++) { while (n % i == 0 && cnt < k - 1) { cnt++; n /= i; v.... |
#include <bits/stdc++.h> const int N = 12; using namespace std; int n, x, y, a[N][N]; pair<pair<int, int>, pair<int, int> > b[N] = { {{0, 0}, {0, 0}}, {{1, 1}, {3, 3}}, {{1, 4}, {3, 6}}, {{1, 7}, {3, 9}}, {{4, 1}, {6, 3}}, {{4, 4}, {6, 6}}, {{4, 7}, {6, 9}}, {{7, 1}, {9, 3}}, {{7, 4}, {9, 6}},... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; long long dp[N][2]; struct segment { int l, r; }; auto cmp = [](segment& s1, segment& s2) { if (s1.r != s2.r) return s1.r < s2.r; else return s1.l > s2.l; }; void solve() { int n, m; cin >> n >> m; ... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline long long int rand(long long int x, long long int y) { ++y; return (rng() % (y - x)) + x; } string to_string(char c) { string second(1, c); return second; } string to_s... |
#include <bits/stdc++.h> const int maxn = 2e5 + 10; int N; int A[maxn]; long long Q[maxn]; long long sum1[maxn]; long long sum2[maxn]; double X(int i) { return i; } double Y(int i) { return i * sum1[i] - sum2[i]; }; double slope(int i, int j) { return (Y(i) - Y(j)) / (X(i) - X(j)); } long long Calc(... |
#include <bits/stdc++.h> using namespace std; int a, b, res; int check(int a, int b) { return a < b; } int main() { scanf( %d%d , &a, &b); if (a == b) { printf( infinity ); return 0; } res = 0; a -= b; if (a < 0) { printf( 0 ); return 0; } for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; int n, m, c, l, r, cp, cm; string s; int main() { cin >> n >> s; for (int i = 0; i < n; i++) { l = i - 1; r = i; cp = 1; cm = 1; while (l >= 0 && s[l] != L ) { cp += (s[l] == R ); l--; } while (r < ... |
#include <bits/stdc++.h> using namespace std; struct node; struct node { node* arr[26]; int val; node(); void insert(char ch[], int l, int pos); void win(); void lose(); }; node::node() { val = 0; for (int i = 0; i < 26; i++) arr[i] = 0; } void node::insert(char ch[], int l... |
#include <bits/stdc++.h> using namespace std; int main() { char a, b; cin >> a >> b; int n; cin >> n; n = n % 4; if (n == 0) { cout << undefined ; return 0; } int arr[] = {118, 60, 94, 62}; int arr2[] = {118, 62, 94, 60}; int i = 0; for (i = 0; i < 4; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; int sum = n; for (int i = n / 2; i >= 1; i--) { if (n % i == 0) { sum += i; n = i; } } cout << sum; return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const long long INFL = 1e18 + 123; const double PI = atan2(0, -1); mt19937 tw(960172); long long rnd(long long x, long long y) { static uniform_int_distribution<long long> d; return d(tw) % (y - x + 1) + x; } int cross(int x1... |
#include <bits/stdc++.h> using namespace std; string s; int n, i, k = 0; int main() { cin >> s; for (i = 0; i < s.size(); i++) { while (s[i] == s[i + 1] && s.size()) { s.erase(i, 2); i--; k++; } } if (k % 2 != 0) cout << YES << endl; else if (k % 2... |
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 100; vector<int> ans; set<pair<int, int>> add[MAX], rem[MAX], cur; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { int x, y; c... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int t; cin >> t; while (t--) { int n; cin >> n; int a[n], b[n], min, count = 0; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long n; cin >> n; long long ans = 0; for (long long i = 1; i < n; i++) { if (n % i == 0) { ans++; } } cout << ans << n ; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; vector<pair<int, int> > v; struct Node { Node *left, *right; int val; int lazy; Node() { left = right = NULL; val = 0; lazy = 0; } }; inline void refresh(Node*& root, int x, int y) { if (root->lazy... |
/* Washief Hossain Mugdho 20 December 2020 Codeforces 691F */ #include <bits/stdc++.h> #define ull unsigned long long #define ll long long #define pb push_back #define mp make_pair #define fr first #define sc second #define fastio ios_base::sync_with_stdio(0) #define untie cin.t... |
#include <bits/stdc++.h> using namespace std; long long cnt[19], val[19]; void init() { cnt[1] = 9, cnt[2] = 9, cnt[3] = 90; val[1] = 1, val[2] = 10, val[3] = 100; long long t = 100; for (int i = 4; i <= 19; i++) cnt[i] = t * 9, t *= 10, val[i] = val[i - 1] * 10; } long long cal(long lon... |
#include <bits/stdc++.h> using namespace std; void Display(vector<double> row) { for (int i = 0; i < row.size(); i++) cout << row[i] << ; cout << endl; } void Display(vector<vector<double> > matrix) { for (int i = 0; i < matrix.size(); i++) Display(matrix[i]); cout << endl; } vector<vecto... |
#include <bits/stdc++.h> using namespace std; 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 <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; string s; void rev() { for (int i = 0; i < s.size(); i++) if (s[i] == L ) s[i] = R ; else s[i] = L ; } vector<int> v; int k[2000011]; const int delta = 1000005; bool verify(int nr) { memset(k, 0, sizeof(k)); int now... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 2; long long n, a[maxn], k, ans[maxn]; long long Check(long long m) { long long res = 0, l, r, mid; for (int i = 1; i <= n; i++) { l = 1; r = a[i]; while (l <= r) { mid = (l + r) / 2; if (a[i] - 3 * mi... |
#include <bits/stdc++.h> using namespace std; int n, m; int k; bool debug = false; int f[100005]; int ff(int x) { while (x != f[x]) x = f[x]; return x; } int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) f[i] = i; int a, b; long long ans = 1; for (int i = 0; i ... |
#include <bits/stdc++.h> using namespace std; int nn, n, b, q; vector<pair<int, int> > d; int main() { d.push_back(make_pair(0, 0)); scanf( %d%d%d , &n, &b, &q), nn = n; d.push_back(make_pair(b, n)); for (int i = 1; i <= q; i++) scanf( %d%d , &b, &n), d.push_back(make_pair(b, n)); sort... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 0; const int LOGN = 0; const int MOD = 1e9 + 7; const int INF = 1e9 + 10; long long N, Q; long long x; long long f(long long x) { if (x & 1) return (x + 1) >> 1; long long id = N - (x >> 1); while (!(id & 1)) id >>= 1; id >>=... |
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { if (b) return GCD(b, a % b); return a; } bool u1[10]; bool u2[10]; int main() { long long n, m, v; vector<long long> a, b; ios_base::sync_with_stdio(0); cin >> n >> m; for (long long i = 0; i ... |
#include <bits/stdc++.h> using namespace std; /*<DEBUG>*/ #define tem template <typename #define can_shift(_X_, ...) enable_if_t<sizeof test<_X_>(0) __VA_ARGS__ 8, debug&> operator<<(T i) #define _op debug& operator<< tem C > auto test(C *x) -> decltype(cerr << *x, 0LL); tem C > char test(...); tem ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long n, k; cin >> n >> k; vector<long long> occ(255); string s; cin >> s; long long streak = 0; char curr = s[0]; for (long long i = 0; i < n; i++) { if (s[i] == curr) { streak++; if (streak == ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; const int MOD = 1e9 + 7; template <typename Tp> void read(Tp &x) { x = 0; int op = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) op = -1; ch = getchar(); } while (isdigit(ch)) { x = ... |
#include <bits/stdc++.h> using namespace std; const int SIZE = 1 << 17; char buffer[SIZE]; int pointer = SIZE; char Advance() { if (pointer == SIZE) { fread(buffer, 1, SIZE, stdin); pointer = 0; } return buffer[pointer++]; } int Read() { int answer = 0; char ch = Advance();... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d%d , &n, &m); ; int cnt = 0; for (int i = 0; i < (n + 1); i++) for (int j = 0; j < (n + 1); j++) { if (i * i + j == n && i + j * j == m) cnt++; } printf( %d n , cnt); } |
#include <bits/stdc++.h> using namespace std; int N, ans = 0, overtake = 0, pspeed, plimit = 1000; stack<int> signs; int main() { cin >> N; for (int i = 0, a, b; i < N; i++) { cin >> a; if (a == 1) { cin >> b; pspeed = b; while (!signs.empty()) { if (signs.t... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 1e6 + 5; const long long inf = 1e18; long long powermod(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; ... |
#include <bits/stdc++.h> using namespace std; const int NMax = 2000010; char A[NMax]; int N, can[NMax], H[NMax], min1[NMax], min2[NMax], H1[NMax]; int main() { scanf( %s , A); N = strlen(A); int last = 0; for (int i = 0; i < N; i++) A[N + i] = A[i]; for (int i = 0; i < N; i++) { if (... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; int sum = 0; int c; int ans = 0; int k = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> c; sum += c; k += c; if (k < 0) k = ... |
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); if (flag) x = -x; } using names... |
#include <bits/stdc++.h> using namespace std; const int N = 666; const double eps = 1e-10; int n, m, K, cnt, sz; int id[N], nod[N], cur[N]; double deg[N], g[N][N]; bool trap[N]; double v[N][N]; struct node { double vec[N]; } vv[N]; struct mat { double v[166][166]; mat() { memset(v, 0, ... |
#include <bits/stdc++.h> using namespace std; namespace Input { const int BUF = 65536; char buf[BUF + 1]; char *head = buf, *tail = buf; inline char inputchar() { if (head == tail) *(tail = (head = buf) + fread(buf, 1, BUF, stdin)) = 0; return *head++; } inline void inputnum(int &ret) { char... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; long long n, m, dau, cuoi, giua, pos1, pos2, t; bool kt; struct point { long long x, y; } p[N], ab, ac, z; long long ccw(point a, point b, point c) { ab = {b.x - a.x, b.y - a.y}; ac = {c.x - a.x, c.y - a.y}; return ab.x... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long power(long long base, long long exp); void solve() { long long n, m, k; cin >> n >> m >> k; vector<vec... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; getline(cin, s); for (auto i = s.end() - 1; i >= s.begin(); i--) { if ((int(*i) >= 65 && (int(*i) <= 90)) || (int(*i) >= 97 && (int(*i) <= ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 110; int N; struct notlaptop { int speed, ram, hdd, cost; notlaptop(int a, int b, int c, int d) { speed = a; ram = b; hdd = c; cost = d; } notlaptop()<% %> }; notlaptop ar[MAXN]; int main() { scanf( ... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char now[1 << 16], *S, *T; if (T == S) { T = (S = now) + fread(now, 1, 1 << 16, stdin); if (T == S) return EOF; } return *S++; } inline long long read() { register long long x = 0, f = 1; char ch = gc(); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, s = 0; scanf( %I64d , &n); while (n > 0) { if (n % 8 == 1) s++; n /= 8; } printf( %I64d , s); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int a = sqrt(n); long long int b = n / a; if (n % a != 0) b+... |
#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 n, m, t; long long a[500000]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t; for (long long ti = 0; ti < t; ti++) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> v[600]; char s[600]; int cnt = 0; int rec[3]; void dfs(int src, char c) { s[src] = c; for (int i = 0; i < v[src].size(); i++) if (s[v[src][i]] != b ) { cnt++; s[v[src][i]] = c; } } int main() { int n, m; ... |
#include <bits/stdc++.h> using namespace std; string s; int i; int main() { cin >> s; i = s.find( 0 ); if (i > -1) s.erase(i, 1); else s.erase(0, 1); cout << s << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A &a, B b) { if (a < b) a = b; } long long N, M; string S; signed main() { cin >> N >> M >> S; long l... |
#include <bits/stdc++.h> using namespace std; long long int n, k, a[105], b[105], c[105], ai[105]; map<long long int, long long int> pos; void apply_f(long long int c[105]) { for (int i = 1; i <= n; i++) c[i] = a[c[i]]; } void apply_if(long long int c[105]) { for (int i = 1; i <= n; i++) c[i] = ai[c... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 10, MAXM = 2e5 + 10; pair<int, int> v[MAXM]; int l[MAXM], r[MAXM], s[MAXM], t[MAXM]; vector<int> qv[MAXM]; bool ans[MAXM]; int last[MAXN][MAXN]; int main() { int n, m, q; scanf( %d %d %d , &n, &m, &q); for (int i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, x1, y1, x2, y2; long double s = 0; scanf( %d %d , &n, &k); scanf( %d %d , &x1, &y1); for (int i = 1; i < n; i++) { scanf( %d %d , &x2, &y2); s += (long double)sqrt((long double)(x2 - x1) * (x2 - x1) + ... |
#include <bits/stdc++.h> using namespace std; int n, k, ans, t; int a[100005]; int main() { scanf( %d%d , &n, &k); ans = 1; t = 1; for (int i = 1; i <= n; ++i) { scanf( %d , &a[i]); if (a[i] == a[i - 1]) { ans = max(ans, i - t); t = i; } } ans = max(ans,... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:50000000 ) using namespace std; int n, z = 0, x, y; int a[105]; bool f; int main() { scanf( %d , &n); if (n % 2 == 0 || n < 2) { printf( -1 n ); return 0; } for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = ... |
#include <bits/stdc++.h> using namespace std; int fx[] = {-1, 1, 0, 0}; int fy[] = {0, 0, 1, -1}; int dx[] = {-1, 1, 0, 0, 1, 1, -1, -1}; int dy[] = {0, 0, 1, -1, 1, -1, -1, 1}; int cx[] = {1, 1, 2, 2, -1, -1, -2, -2}; int cy[] = {2, -2, 1, -1, 2, -2, 1, -1}; const int N = 1 << 11; int n; int ans[N ... |
#include <bits/stdc++.h> using namespace std; struct Compteur { int nbs[4]; Compteur() { for (int iCoeff = 0; iCoeff < 4; iCoeff++) { nbs[iCoeff] = 0; } } }; Compteur operator+(const Compteur &a, const Compteur &b) { Compteur nouv; for (int iCoeff = 0; iCoeff < 4; iCoeff+... |
#include <bits/stdc++.h> using namespace std; int main() { string s, d, b; char a, ch[3]; cin >> s; long long i, j, ans, n, flag = 0; a = s[0]; for (i = 1; i < s.size(); i++) { if (s[i] == . ) continue; if (s[i] == e ) { flag = 1; } if (s[i] != e ) { ... |
#include <bits/stdc++.h> using namespace std; const int sz = 15000001; int n; int sieve[sz]; int v[300001]; int cnt[sz]; inline void solve() { scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &v[i]); } for (int i = 2; i < sz; i++) if (sieve[i] == 0) { for (int... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; template <typename T> inline void rit(T &x) { char c; for (x = 0, c = getchar(); c < - ; c = getchar()) ; for (; c >= 0 ; x = x * 10 + c - 0 , c = getchar()) ; } int Q, op, x, c, p = 1; long long int s[5000... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; long long n; int Q; void ReadInput() { cin >> n >> Q; n *= 2LL; } long long Get(long long first) { if (first % 2 == 1) return (first + 1) / 2; return Get(first + (n - first) / 2); } void Solve() { while (Q-- > ... |
#include <bits/stdc++.h> using namespace std; int n, k; string a[2005]; int common[2005][2005]; int main() { std::ios::sync_with_stdio(false); cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) f... |
#include <bits/stdc++.h> using namespace std; void bfs(int v, vector<vector<int> > &graf, vector<vector<int> > &dist) { queue<int> q; q.push(v); while (!q.empty()) { int p = q.front(); q.pop(); for (int i = 0; i < graf[p].size(); i++) { int to = graf[p][i]; if (dist[v][... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; template <class T> void chkmin(T &a, T b) { if (a > b) a = b; } int n, s, m; int a[2005]; int z[2005], id[2005]; int dp[2][2005], f[2][2005]; int nxt[2005], prv[2005]; int ans; vector<int> v[2005]; int cnt; int pos[2005];... |
#include <bits/stdc++.h> using namespace std; bool chk(int a, int b, int c, int sum) { return a + b + c == sum; } int main() { int sum = 0; vector<int> u(6); for (int i = 0; i < 6; i++) { cin >> u[i]; sum += u[i]; } if (sum % 2) { cout << NO ; return 0; } sum /... |
#include <bits/stdc++.h> using namespace std; long long a[100000], lim, n, flag; void DFS(long long x, long long y) { if (x > n) { if (y == a[lim]) flag = 1; return; } if (flag) return; DFS(x + 1, y); if (x != lim) { DFS(x + 1, y + a[x]); DFS(x + 1, y - a[x]); } }... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const double eps = 1e-9; vector<long long> prnum; void sieve() { bool prime[1000001]; memset(prime, true, sizeof(prime)); for (int i = 2; i * i <= 1000000; i++) { if (prime[i] == true) { for (int j = 2 * i; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; signed main() { long long n, sum = 0, temp; multiset<long long> a; cin >> n; for (long long i = 0; i < n; ++i) { cin >> temp; a.insert(temp); } while (a.size() > 1) { long long temp_sum = 0, sz = a.... |
#include <bits/stdc++.h> using namespace std; int ht[300][300], tt[300][300][8], n, m, t, tp, tu, td; void print(const char *s, int k) { cout << s << endl; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) cout << setw(2) << tt[i][j][k] << ; cout << endl; } } int main() { ... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 0; char ch = getchar(); while (!isdigit(ch)) f |= ch == - , ch = getchar(); while (isdigit(ch)) x = 10 * x + ch - 0 , ch = getchar(); return f ? -x : x; } template <typename T> void print(T x) { if (x < 0) putc... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x, y; cin >> x >> y; int u = 0, v = 0, turns = 0, flag = 1, c = 1; while (1) { if (u == x and v == y) break; if (flag == 1) { int d = 0; while (d != c) ... |
#include <bits/stdc++.h> using namespace std; int main() { string line; int persons = 0; int data = 0; while (getline(cin, line)) { if (line[0] == + ) ++persons; else if (line[0] == - ) --persons; else data += (line.size() - line.find( : ) - 1) * persons; ... |
#include <bits/stdc++.h> using namespace std; int n; string s; int l = 0, u = 0, d = 0; int main() { cin >> n; for (int i = 0; i < n; i++) { int l = -1, u = -1, d = -1; cin >> s; for (int j = 0; j < s.length(); j++) { if (isdigit(s[j])) d = j; if (islower(s[j])) l = j... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int count = 0; cin >> n; for (int i = 0; i < n; i++) { string a; cin >> a; if (a == ABSINTH || a == BEER || a == BRANDY || a == CHAMPAGNE || a == GIN || a == RUM || a == SAKE || a == TEQUILA ... |
#include <bits/stdc++.h> using namespace std; void solve() { int a, b; cin >> a >> b; int c = min(a, b); a = max(a, b) - c; cout << c << << a / 2; ; } int main() { int count = 1; while (count--) { solve(); } return 0; } |
#include <bits/stdc++.h> using namespace std; long long modpower(long long n, long long k) { long long res = 1; while (k) { if (k & 1) res = (res * n) % 1000000009; k >>= 1; n = (n * n) % 1000000009; } return res; } signed main() { ios_base::sync_with_stdio(false); cin.... |
#include <bits/stdc++.h> using namespace std; using namespace std; vector<vector<int> > g; vector<int> depth; void dfs(int v, int d = 0) { depth[v] = d; for (int to : g[v]) { if (depth[to] == -1) { dfs(to, d + 1); } } } int main() { int n, m; cin >> n >> m; g.re... |
#include <bits/stdc++.h> using namespace std; class strocks { public: string strocksguy() {} }; int main() { strocks strocks; iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> m; string s, d; unordered_map<string, string> master; for (l... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; const int N = 100005; int n, m, k; vector<int> adj[N]; int cnt[N]; int mark[N]; int pass; int aux[N]; bool ta[N]; bool clique(int x) { pass++; mark[x] = pass; int id = 0; for (int i : a... |
#include <bits/stdc++.h> using namespace std; int ara[1000]; int rf[1000]; int main() { int n, i, f, w, cnt = 0, m, r; char str[1000001]; scanf( %d %d , &n, &m); scanf( %s , str); for (i = 0; i < n; i++) { r = str[i]; ara[r] = ara[r] + 1; } for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const long long mint = 0x7fffffff; const long long linf = 1000000000000000000LL; const long long mod = 1000000007LL; const double eps = 1e-3; const int N = 1000020; inline long long read() { long long x = 0, f = 1; char ch... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; long long n; long long a[N], b[N], c[N]; bool check() { bool check = 0; for (long long i = 1; i <= n; i++) if (a[i] != b[i]) check = 1; bool check2 = 0; for (long long i = 1; i <= n; i++) if (a[i] != c[i]) c... |
#include <bits/stdc++.h> using namespace std; int n, dem; string s; void setup() {} void solve() { cin >> n; cin >> s; if (n == 1) cout << s; else { for (int i = 0; i <= n - 1; ++i) dem += s[i] == 0 ; cout << 1; for (int i = 1; i <= dem; ++i) cout << 0; } } int... |
#include <bits/stdc++.h> using namespace std; long long f[100], f0[100]; int main() { int n, k, m; scanf( %d %d %d , &n, &k, &m); for (int i = 1; i < k; i++) f0[i] = 0, f[i] = 0; int tmp = 1; long long ans = 0; for (int i = 0; i < n; i++) { f0[0] = 1; for (int j = 0; j < k; j++... |
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n; cin >> n; long long int a[n]; for (long long int i = 0; i < n; i++) cin >> a[i]; long long int m; cin >> m; long long int num1[m], ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e16; const long long maxn = 128; const long long maxlog = 60; long long a, b; string s, t; long long dp[maxlog][maxn]; long long ans; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> a >> b; cin >> s >> t;... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using vec = vector<T>; template <typename T> using Prior = priority_queue<T>; template <typename T> using prior = priority_queue<T... |
#include <bits/stdc++.h> using namespace std; const long long int M = 100 + 5, SM = 600; const long long int inf = 1e18; const long long int lg = 18; const long long int z = 26; long long int dp[M][M][M]; string dps[M][M][M]; long long int x; long long int nxt[M][z]; long long int tt = 1; long lon... |
#include <bits/stdc++.h> using namespace std; void candy(int x, int y) { int d = 1; bool flag = true; while (x >= 0 && y >= 0) { if (flag) { x = x - d; d++; flag = false; } else { y = y - d; d++; flag = true; } if (flag == true && x... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.