func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n, k; pair<int, int> d[3] = {{0, 1}, {1, 0}, {1, 1}}; int b[550][550]; void rec(int k) { if (k == 1) { b[0][0] = 1; return; } rec(k /= 2); for (int c = 0; c < 3; c++) { for (int i = 0; i < k; i++) { for (int j = 0; j <... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x7FFFFFFF; template <class T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template <class T> T big_mod(T n, T p, T m) { if (p == 0) return (T)1; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; long long cp[200010]; long long find(long long x) { return cp[x] = cp[x] == x ? x : find(cp[x]); } void union_(long long x, long long y) { cp[find(x)] = find(y); } int32_t main() { ios::sync_with_stdio(false); cin.tie(0); ... |
#include <bits/stdc++.h> using namespace std; const int DIM = 1e5 + 5; int szt[DIM], ans[DIM]; vector<int> edg[DIM]; map<int, int> son, par, out; void dfs1(int x, int sz) { szt[x] = 1; for (int y : edg[x]) { dfs1(y, sz); szt[x] += szt[y]; } out[szt[x]]++; ans[x] = sz - 1; ... |
#include <bits/stdc++.h> using namespace std; int main() { long n; while (cin >> n) { string s; cin >> s; long a[10010] = {0}, x = 0, c = 0, l; l = s.size(); for (int i = 0; i < l; i++) { if (i % 2 == 0) { a[s[i]]++; } else { x = s[i] + 32; ... |
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e6 + 5; const long long inf = 1e10; const long long mod = 1e9 + 7; long long n; long long x[maxN]; long long a, b; int main() { ios_base::sync_with_stdio(0); cin >> n; for (long long i = 1; i <= n; i++) cin >> x[i]; ci... |
/// By: CooloTran #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using str = string; #define st first #define nd second #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define er equal_range #define f... |
#include <bits/stdc++.h> int cmp(const void* a, const void* b); int main() { long long t = 1; while (t--) { long long n, n1, n2; scanf( %lld%lld%lld , &n, &n1, &n2); long long arr[n]; for (long long i = 0; i < n; i++) { scanf( %lld , &arr[i]); } qsort(arr, n, size... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k; cin >> n >> k; long long a[k + 1]; for (long long i = 0; i < k; i++) { cin >> a[i]; } long long c4 = n, c2 = 2 * n; long long o1 = 0; for (long long i = 0; i < k; i++) { while (c4 > 0 && a[i] > 3) ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, num = 0; for (i = 1; i <= 5; i++) { int temp; scanf( %d , &temp); num += temp; } if (num % 5 || num == 0) { printf( -1 n ); } else { printf( %d n , num / 5); } return 0; } |
#include <bits/stdc++.h> using namespace std; string s; int main() { ios_base::sync_with_stdio(false); cin >> s; bool f = false; for (int i = 0; i < s.size() / 2; i++) if (s[0] != s[i] or s[0] != s[s.size() - i - 1]) { f = true; break; } if (!f) { cout << Imp... |
#include <bits/stdc++.h> static const int MaxSize = 1e5; int tree[4 * MaxSize][2]; static void build(std::vector<int> &v, int vertex, int tl, int tr) { if (tl == tr) tree[vertex][0] = v[tl]; else { int tm = (tl + tr) / 2; build(v, 2 * vertex + 1, tl, tm + 0); build(v, 2 * vertex + ... |
#include <bits/stdc++.h> using namespace std; int solveA(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y, pair<pair<int, int>, int> z) { pair<int, int> a = x.first; pair<int, int> b = y.first; pair<int, int> c = z.first; int n = a.first + b.first + c.first; if (n != a.secon... |
#include <bits/stdc++.h> using namespace std; const int N = 3005; const int inf = 5e8; vector<int> to[N], from[N]; int d[N][N], b[N][N]; vector<pair<int, int>> go[N], back[N]; bool done[N]; int n; void bfs(vector<int>* edge, int dist[N][N], vector<pair<int, int>>* ret) { for (int i = 0; i < N; i++... |
#include <bits/stdc++.h> using namespace std; int dr[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dc[] = {-1, 0, 1, -1, 1, -1, 0, 1}; struct node { int r, c, dist; node() {} node(int _r, int _c, int _dist) : r(_r), c(_c), dist(_dist) {} }; set<pair<int, int> > valid, visited; int main() { int r0, ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; vector<int> arr; arr.push_back(b); while (b > a) { if (b % 10 == 1) arr.push_back(b /= 10); else if (b % 2 == 1) { cout << NO << endl; return 0; } else arr.push... |
#include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const lo... |
#include <bits/stdc++.h> int main() { int num; scanf( %d , &num); int res = 0; for (int i = 0; i < num; i++) { char shape[30]; scanf( %s , shape); switch (shape[0]) { case T : res += 4; break; case C : res += 6; break; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, len, vf, va, k; cin >> n >> len >> vf >> va >> k; long long bl = (n + k - 1) / k; double eff = static_cast<double>(va - vf) / (va + vf); double koef = (va + (bl + (bl - 1) * eff - 1) * vf); double ta = len / koef; do... |
#include <bits/stdc++.h> using namespace std; int a[] = { 0, 4784, 4194, 4003, 3920, 3831, 3791, 3726, 3667, 3669, 3591, 3642, 3612, 3532, 3554, 3507, 3500, 3517, 3449, 3496, 3432, 3462, 3406, 3394, 3376, 3378, 3445, 3362, 3368, 3371, 3305, 3369, 3386, 3336, 3320, 3302, 3273, 3356, 3286, ... |
#include <bits/stdc++.h> #pragma GCC optimize trapv using namespace std; void solveEachTest(long long int T35TC453N = 1) { unsigned long long int a, b; cin >> a >> b; bool ok = true; bitset<64> xandy((a - b) / 2); bitset<64> xxory(b); unsigned long long int x = (a - b) / 2; unsigned ... |
#include <bits/stdc++.h> using namespace std; int k; string res; int c[500]; int main(void) { for (int i = 2; i < 449; i++) { c[i] = i * (i - 1) / 2; } scanf( %d , &k); if (k == 0) { cout << a << endl; } char cur = a ; while (k > 0) { int takeind = upper_bound(... |
#include <bits/stdc++.h> int main() { double n2, a, b, c, n1; scanf( %lf %lf %lf , &a, &b, &c); n1 = ((-b + pow((b * b - 4 * a * c), 0.5)) / (a * 2)); n2 = ((-b - pow((b * b - 4 * a * c), 0.5)) / (a * 2)); if (n1 >= n2) printf( %lf %lf , n1, n2); else printf( %lf %lf , n2, n1); ... |
#include <bits/stdc++.h> const int inf = 1e9 + 7; const int md = 1e9 + 7; const double eps = -1e5; using namespace std; int n, ans, x, y; bool a[1001][1001]; bool isin(int x, int y) { return x > 0 && x <= 1000 && y > 0 && y <= 1000; } int main() { cin >> n; for (int i = 0; i < n; i++) { ci... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int maxn = 1e5 + 5; long long h[maxn], l[maxn], r[maxn]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %lld , &h[i]); l[1] = r[n] = 1; for (int i = 2; i <= n; ++i) l[i] = min(h[i], l[i -... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, tot, i; cin >> n >> k; tot = n * (n - 1) / 2; if (tot <= k) { cout << no solution ; } else { for (i = 0; i < n; i++) { cout << 0 << << i << endl; } } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 300000; int parent[N], size[N]; vector<pair<int, pair<int, int>>> v; pair<int, int> q[N]; long long ans[N]; int Find(int a) { if (parent[a] == a) return a; return parent[a] = Find(parent[a]); } void Union(int a, int b) { parent[Find(b... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); string line; while (getline(cin, line)) { map<int, vector<string> > answer; line += , ; istringstream iss(line); string s; stack<int> stk; ... |
#include <bits/stdc++.h> using namespace std; int n, k; long long sum, s[1000005], ans = -(1LL << 62); struct el { long long val; int poz; bool operator<(const el &A) const { return val < A.val; } }; el a[1000005]; int main() { int i, poz; cin.sync_with_stdio(0); cin >> n; for ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, x, y, aa; scanf( %I64d %I64d , &x, &y); if (y > x) { printf( -1 n ); return 0; } a = x / y; if ((x % y) && (a % 2)) a++; if (!(a % 2)) aa = a - 1; else aa = a; double cc = (doub... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int N, M; int ar[MAXN]; char s[MAXN]; int dn[MAXN][2]; int used[MAXN][2]; int f(int k, int flag) { if (k == -1) return 0; if (used[k][flag]) return dn[k][flag]; used[k][flag] = 1; if (!flag) return dn[k][flag] = f(k -... |
#include <bits/stdc++.h> using namespace std; char a[15]; char rr[15]; char ans[15]; int main() { int maxx = -99; cin >> a; int len = strlen(a); for (int i = 1; i < 1 << len; i++) { int cnt = 0; for (int j = 0; j <= len - 1; j++) { if (i >> j & 1) rr[++cnt] = a[j]; } ... |
#include <bits/stdc++.h> using namespace std; int dist(int a, int b) { return min(abs(a - b), 360 - abs(a - b)); } long long d; int main() { scanf( %I64d , &d); d = (d % 360 + 360) % 360; int ans = 1000; for (int i = 0; i < 4; i++) ans = min(ans, dist(d, 90 * i)); for (int i = 0; i < 4; i++)... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int MOD = 1e9 + 7; int a[MAXN]; class Matrix { public: void prinf() { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { cout << a[i][j]; } cout << endl; } } long... |
#include <bits/stdc++.h> using namespace std; vector<int> v[100146]; int val[100146], a[100146], b[100146]; long long cnt[1 << 18], sum[1 << 18]; int leftError[100146], rightError[100146]; void countDps(int e) { if (v[e].size() == 0) leftError[e] = rightError[e] = val[e]; else { countDps... |
#include <bits/stdc++.h> using namespace std; int n; vector<vector<int> > G; vector<vector<int> > ID; vector<vector<int> > ans; void addp(int id, int t) { while (ans.size() <= t) ans.push_back(vector<int>()); ans[t].push_back(id); } void solve(int from, int lab, int v) { int ctr = 0; for... |
#include <bits/stdc++.h> using namespace std; char s[705]; int match[705]; int tmp[705]; long long dp[705][705][3][3]; void getmatch(int len) { int kk = 0; for (kk = 0; kk <= 10000; kk++) ; int p = 0; for (int i = 0; i < len; i++) { if (s[i] == ( ) tmp[p++] = i; el... |
#include <bits/stdc++.h> using namespace std; vector<string> split(const string& s, char c) { vector<string> v; stringstream second(s); string x; while (getline(second, x, c)) v.emplace_back(x); return move(v); } template <typename T, typename... Args> inline string arrStr(T arr, int n) { ... |
#include <bits/stdc++.h> using namespace std; vector<int> s[10]; int n1, n2; int ok(int a, int b) { int sum = a + b * 2; int len = 0; for (int i = 0; i < n1 - a; i++) len += s[1][i]; for (int i = 0; i < n2 - b; i++) len += s[2][i]; return len <= sum; } int main() { int a, b, n, m, i,... |
#include <bits/stdc++.h> using namespace std; const int inf = (1 << 30) - 1; const int maxn = 100010; char s[maxn]; int calc(char a, char b) { int mx = 30; mx = min(mx, a > b ? a - b : b - a); mx = min(mx, a > b ? b + 26 - a : a + 26 - b); return mx; } int main() { scanf( %s , s); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int q = 30; if (n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12) q++; if (n == 2) q = 28; q = q - 8 + m; if (q % 7 == 0) cout << (q / 7) + 1; else cout << (q / 7) + 2;... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a * b / gcd(a, b); } struct data { int num; int init; }; bool byNum(const data &left, const data &right) { return left.num > right.num; } bo... |
#include <bits/stdc++.h> using namespace std; vector<int> caps, full; int main() { int w, l; cin >> w >> l; caps = vector<int>(w + 1, 0); caps[w] = 2e9; full = vector<int>(w + 1, 0); full[0] = 2e9; for (int i = 1; i < w; i++) cin >> caps[i]; int from = 0; int to = 1; while ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long T; cin >> T; while (T--) { string s; cin >> s; long long ans = (long long)s.size(), curr = 0; for (long long i = 0; i < s.size(); i++) { if (s[i] == + ) { curr++; } else { ... |
#include <bits/stdc++.h> using namespace std; int main() { int event, ghotona; cin >> event; int hired = 0, untreated = 0; for (int i = 0; i < event; i++) { cin >> ghotona; hired += ghotona; if (hired < 0) { untreated++; hired = 0; } } cout << untreate... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) using namespace std; int bit[1100]; int tot = 0; void GetBinary(int n) { memset(bit, 0, sizeof bit); while (n) { bit[tot++] = n & 1; n >>= 1; } } int layer[1100][2]; void Construct() { layer[1][0] ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; string s; cin >> n >> s; for (long long int i = 0; i < n; i++) cout << s[n - 1]; cout << endl; } int main() { int test; cin >> test; for (int TEST = 1; TEST <= test; TEST++) solve(); } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } pair<int, int> p[n * n]; int in = 0; for (int i = 0; i < n; i++) { for (int j = 0; j... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 103; int p[MAXN], c[MAXN]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; bool check = true; for (int i = 1; i <= n; i++) { cin >> p[i] >> c[i]; if (c[i] > p[i] || c[i] < c[i - 1] || ... |
#include <bits/stdc++.h> using namespace std; double const pi = 3.14159265358979; int const MAXN = 2000000; long long const MOD = 1000000007; long long const INF = 1000000000000000000ll; int a[2000000], d[2000000]; bool is[2000000]; int main() { int n, res = 0; scanf( %d , &n); for (int i = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005, mod = 998244353; inline int gi() { char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); int sum = 0; while ( 0 <= c && c <= 9 ) sum = sum * 10 + c - 48, c = getchar(); return sum; } inline int add(int a, int ... |
#include <bits/stdc++.h> using namespace std; int m[100][100]; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(0); long n, suma = 0; cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { m[i][j] = 1; } } for (int i = 1; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; scanf( %i %i %i %i , &a, &b, &c, &d); int sum1 = max(3 * a / 10, a - a / 250 * c); int sum2 = max(3 * b / 10, b - b / 250 * d); if (sum1 > sum2) { printf( Misha n ); } else if (sum1 == sum2) { printf( Tie ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; const long long INF = 1e18 + 10; struct node { int next, v; } edge[maxn * 2 + 10]; int cnt, head[maxn], vis[maxn], pa[maxn]; long long sum[maxn], cost[maxn], a[maxn], ss[maxn]; queue<int> q; int find(int x) { if (x == pa[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; const char character[] = ./ ; int n, a[N], tag[N], type[N][N]; int main() { scanf( %d , &n); for (register int i = 1; i <= n; ++i) { scanf( %d , &a[i]); } int o = 0, r = 0; for (register int i = 1; i <= n; ++i) {... |
#include <bits/stdc++.h> using namespace std; int n, r; int x[105], y[105]; vector<pair<int, int> > pos, neg; bool cmp(pair<int, int> p1, pair<int, int> p2) { return p1.first + p1.second > p2.first + p2.second; } int main() { cin >> n >> r; for (int i = 0; i < n; i++) { scanf( %d%d , &x[... |
#include <bits/stdc++.h> using namespace std; long long p; map<long long, int> m[123]; int main() { int characters_value[26]; long long i; for (i = 0; i < 26; i++) cin >> characters_value[i]; string s; cin >> s; long long ans = 0; for (i = 0; i < s.size(); i++) { ans += m[s[i]]... |
#include <bits/stdc++.h> using namespace std; const long long mod = 811287553; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } int n, m, s, t, a, b, d; vector<long ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) { return {l.first + r.first, l.second + r.second}; } typedef void (*callback_function)(void); const long long ZERO = 0LL; const long long INF64 ... |
#include <bits/stdc++.h> using namespace std; bool compare(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { int n, k; cin >> n >> k; pair<int, int> power[n]; for (int i = 0; i < n; ++i) { pair<int, int> a; int p; cin >> p; a.first = p; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[200005]; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &a[i]); } int flag = 0; for (int i = 0; i < n; i++) { if (a[i] >= 2) a[i] %= 2; if (a[i] == 0) continue; if (i == n - 1) { f... |
#include <bits/stdc++.h> using namespace std; const int maxn = (1 << 18); struct segment { private: static const int maxn = (1 << 18); int arr[2 * maxn]; int private_sum(int node, int first, int last, int a, int b) { if (first >= a && last <= b) return arr[node]; if (a >= last || b <= f... |
#include <bits/stdc++.h> using namespace std; void FastIO() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } long long int mod = 2e9 + 10; class SegmentTree { public: vector<int> st; vector<int> lazy; vector<int> A; int n; int left(int p) { return (p << 1) + ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const double eps = 1e-8; const int mod = 1e9 + 7; int jia[N], jian[N], x[N], yes[N]; int out[N][3]; int abbs(int x) { if (x > 0) return x; else return -x; } int main() { int n, m, t; scanf( %d%d , &n, &m);... |
#include <bits/stdc++.h> using namespace std; void c_p_c() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } bool prime(long long c) { for (long long i = 2; i * i <= c; i++) { if (c % i == 0) return 0; } return 1; } int32_t main() { c_p_c(); long long n; ci... |
#include <bits/stdc++.h> int main() { int m, n, i, j, k, p, l; scanf( %d %d , &m, &n); p = m + n; int a[m], b[n], c[p]; for (i = 0; i < m; i++) { scanf( %d , &a[i]); } for (i = 0; i < n; i++) { scanf( %d , &b[i]); } k = 0; for (i = 0; i < m; i++) { for (j = 0;... |
#include <bits/stdc++.h> #pragma GCC optimize( O1 ) #pragma GCC optimize( O2 ) #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; void input() { return; } template <typename T1, typename... T2> void input(T1 &x, T2 &...args) { ((cin >> x), input(args...)); } vo... |
#include <bits/stdc++.h> using namespace std; void debug() { cout << endl; } template <class T, class... R> void debug(T f, R... r) { cout << [ << f << ] ; debug(r...); } template <class T> T mmin(T a, T b) { return min(a, b); } template <class T, class... R> T mmin(T a, R... b) { ... |
#include <bits/stdc++.h> const long double PI = acos(-1.0); using namespace std; int n, m; long long dp[505][505]; int a[505]; long long cal(int l, int r) { if (l >= r) return 1; long long &ret = dp[l][r]; if (ret != -1) return ret; ret = 0; int mn = n + 1, idx = 0; for (int i = l; i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, l, m[1100]; char s[1100][34]; scanf( %d , &n); map<string, int> mp, mp2; for (i = 0; i < n; i++) { scanf( %s%d , s[i], &m[i]); mp[s[i]] += m[i]; } string name; int max = 0; for (map<string, int... |
#include <bits/stdc++.h> using namespace std; struct node { int st, ed; } ch[100010]; bool cmp(node a, node b) { return a.st < b.st; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, l, a; cin >> n >> l >> a; for (int i = 0; i < n; i++) { cin >> ch[i].st >> ch[i].ed;... |
#include <bits/stdc++.h> using namespace std; long long int x2, y2, x3, y3; bool check(long long int x, long long int y) { long long int xx = x3 * x3 + y3 * y3, tx = x2 + x, ty = y2 + y; if (xx == 0) return x == x2 && y == y2; long long int ret1 = tx * x3 + ty * y3, ret2 = tx * y3 - ty * x3; if (r... |
#include <bits/stdc++.h> using namespace std; struct debugger { template <typename T> debugger& operator,(const T& v) { cerr << v << ; return *this; } } dbg; vector<int> aa(200); vector<int> bb(200); int n, k; int count(int i, int j) { for (int h = i; h < n; h++) { bb[... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; for (int l = 0; l < t; l++) { cin >> n; int k; k = 0; int c; c = 0; char arr[n][5]; for (int i = 0; i < n; i++) { for (int j = 0; j < 5; j++) { cin >> arr[i][j]; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) #pragma GCC target( sse2 ) using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << : << arg1 << n ; } template <typename Arg1, typename... Args> vo... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int *arr = new int[2 * n + 1]; cin >> arr[0]; for (int i = 1; i < 2 * n + 1; i += 2) { cin >> arr[i] >> arr[i + 1]; if (k > 0 && arr[i] > arr[i - 1] + 1 && arr[i] > arr[i + 1] + 1) { k -= 1; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 105; int no[maxn][maxn][15], sum[maxn][maxn][15]; int main() { int n, q, c, ans, i, j, k, x, y, s, ss, t, x1, x2, y1, y2, tt, num; while (scanf( %d%d%d , &n, &q, &c) != EOF) { memset(no, 0, sizeof(no)); memset(sum, 0, sizeof(sum)... |
#include <bits/stdc++.h> const int MaxN = 52, mod_v = 1000000007; long long f[MaxN][MaxN >> 1][2], C[MaxN][MaxN]; void init_comb(int n) { for (int i = 0; i <= n; ++i) { C[i][i] = C[i][0] = 1; for (int j = 1; j < i; ++j) { C[i][j] = C[i - 1][j] + C[i - 1][j - 1]; if (C[i][j] >= mod_... |
#include <bits/stdc++.h> using namespace std; vector<int> v1; int status[(100000007 / 32) + 10]; bool check1(int n, int pos) { return (bool)(n & (1 << pos)); } int set1(int n, int pos) { return n = n | (1 << pos); } void sieve() { int i, j, k; k = int(sqrt(100000007)); for (i = 3; i <= k; i += 2... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100 + 5; const int inf = 1e9 + 7; int n, m; int num[MAXN]; map<int, int> q; int main() { scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &num[i]); for (int i = 2; i <= n; ++i) { q[num[i] - num[i - 1]]++; } i... |
#include <bits/stdc++.h> using namespace std; string ulaz, jed = 1 , dva = 14 , tri = 144 ; bool je[10]; int main() { cin >> ulaz; int l = ulaz.size(); for (int i = 0; i < l; i++) je[i] = false; for (int i = 0; i < l; i++) { if (je[i] == true) continue; if (i + 2 < l) { st... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll P = 1e9 + 7; ll N, M, K, R, C; ll Dx, Dy; ll mult(ll a, ll b) { return (a * b) % P; } ll exp(ll num_classes) { if (num_classes == 0) { return 1; } ll temp = exp(num_classes / 2); return (num_classes % 2) ? m... |
#include <bits/stdc++.h> using namespace std; int main() { int num; scanf( %d , &num); printf( %d , num + 1); } |
#include <bits/stdc++.h> using namespace std; const long long mod = (1e9 + 7); const long long inf = (1e18 + 3); const long long N = 1e7 + 5; void no() { cout << -1 ; exit(0); } void yes() { cout << YES ; exit(0); } long long powmod(long long a, long long b) { long long res = 1; ... |
#include <bits/stdc++.h> using namespace std; bool checkC(int n) { for (int i = 2; i * i <= n; i++) { if (n % i == 0) return 1; } return 0; } void per(string s, int i, int &num, string &ans) { if (i == s.length()) { if (num != 0 && checkC(num)) { int x = num; int d = ... |
#include <bits/stdc++.h> using namespace std; const int Maxn = 500010; const int inf = 2147483647; const double pi = acos(-1.0); 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; int main() { long long a, b, c, l; cin >> a >> b >> c >> l; long long cnt = (l + 1) * (l + 2) * (l + 3) / 6; for (int i = 0; i <= l; i++) { long long x = min(l - i, c + i - a - b); if (x < 0) continue; cnt -= (x + 1) * (x + 2) / 2; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000007; const long long INFLL = 1000000000000000007; const long long MOD = 998244353; bool comp(long long a, long long b) { return a > b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, k; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; const int MOD = 1e9 + 7; const long long INF = 1e18; long long add(long long a, long long b) { a = a % MOD; b = b % MOD; return (a + b) % MOD; } long long sub(long long a, long long... |
#include <bits/stdc++.h> using namespace std; void c_p_c() {} int main(int argc, char const *argv[]) { c_p_c(); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; string arr; cin >> n >> arr; int cnt = 0; if (n == 1) { cout << cnt << endl; cout << arr <<... |
#include <bits/stdc++.h> using namespace std; const long long infll = powl(2, 62) - 1; const long long mod = pow(10, 9) + 7; int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) { if (!a) { x = 0; y = 1; return b; } int64_t x1, y1; int64_t d = extGcd(b % a, a, x1, y1); ... |
#include <bits/stdc++.h> using namespace std; void Input_Preparing() {} void Processing() { int a, b; cin >> a >> b; cout << min(a, b) << << (max(a, b) - min(a, b)) / 2; } int main() { std::cin.tie(0)->sync_with_stdio(0); ; Processing(); return 0; } |
#include <bits/stdc++.h> using namespace std; int l[(100000 + 10)], size = 0; int fa[(100000 + 10)], son[(100000 + 10)], n, x, spec, specp; bool b[(100000 + 10)] = {0}, f[(100000 + 10)] = {0}; int main() { scanf( %d%d , &n, &x); for (int i = 1; i <= n; i++) scanf( %d , &fa[i]); for (int i = 1; i <... |
#include <bits/stdc++.h> using namespace std; string to_string(string s) { return + s + ; } string to_string(const char* s) { return to_string((string)s); } template <typename A, typename B> string to_string(pair<A, B> p) { return ( + to_string(p.first) + , + to_string(p.second) + ) ; } t... |
#include <bits/stdc++.h> using namespace std; int a[200001]; int main() { int n, w; cin >> n >> w; for (int i = 0; i < 2 * n; i++) { cin >> a[i]; } sort(a, a + 2 * n); double x = min((double)a[0], (double)a[n] / 2); double ans = min((double)w, (double)3 * n * x); cout.precisi... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int mod = 1e9 + 7; void solve() { long long v1, v2, t, d; cin >> v1 >> v2 >> t >> d; long long ans = 0; for (int i = 0; i < t; i++) ans += min(v1 + d * i, v2 + (t - i - 1) * d); cout << ans << endl; } int main(... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1) cout << W ; else cout << B ; } cout ... |
#include <bits/stdc++.h> using namespace std; vector<pair<long long, long long> > v(3000); int main() { std::ios::sync_with_stdio(false); long long n, x1, y1, x2, y2, x, y; cin >> n; cin >> x1 >> y1 >> x2 >> y2; long long d1, d2; for (long long i = (long long)(0); i <= (long long)(n - 1); ... |
#include <bits/stdc++.h> using namespace std; int rbq[505][505]; int score[505]; int main() { int n, m, q; while (~scanf( %d%d%d , &n, &m, &q)) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf( %d , &rbq[i][j]); } } for (int i = 1; i <= n;... |
#include <bits/stdc++.h> #define f(c,a,b) for(int c=a; c<=b; c++) #define N 5000010 #define pii pair<int,int> #define mp make_pair #define fi first #define se second #define sl (u<<1) #define sr ((u<<1)+1) #define pb push_back using namespace std; typedef double db; typedef long long ll; st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.