func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a > b) { return a; } else { return b; } } long long min(long long a, long long b) { if (a < b) { return a; } else { return b; } } vector<string> split(const string& s, ... |
#include <bits/stdc++.h> using namespace std; struct ilter { int job; long long ti; bool operator<(const ilter &a) const { return a.ti > ti; } } T[100001]; int s, c; long long TIME; int main() { map<int, int> M2; int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >>... |
#include <bits/stdc++.h> const double EPS = 1e-9; const int MAX_REPS = 2000; double bx, by, h, r; void solve(double x, double& y1, double& y2, double& y3) { double A1, A2, B1, B2, C1, C2, dy1, dy2, dx, dy; dx = -(x - bx); dy = ((h - r) - by); A1 = -dy; B1 = dx; C1 = A1 * x + B1 * (h - r)... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000 * 100 * 2 + 10; long long int a[MAXN]; long long int b[MAXN]; long long int p[MAXN]; long long int d[MAXN]; long long int mod = 1000 * 1000 * 1000 + 7; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int ... |
#include <bits/stdc++.h> using namespace std; int l[1000005], n, m; long long f[5005][5005], g[2][5005], fa[5005], fac[5005], p, sum; inline int read() { int ret = 0; char fa = getchar(); while (!isdigit(fa)) fa = getchar(); while (isdigit(fa)) { ret = (ret << 1) + (ret << 3) + fa - 0 ; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; long long max(long long a, long long b) { if (a > b) { return a; } else { return b; } } long long min(long long a, long long b) { if (a < b) { return a; } else { return b; } } long l... |
#include <bits/stdc++.h> using namespace std; int main(void) { int n, k; cin >> n >> k; string s; cin >> s; unordered_map<char, int> m; char last = s[0]; int streak = 1; int cur_max = 0; if (k == 1) { cur_max = 1; m[last] = 1; streak = 0; } for (int i = ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename TT> ostream &operator<<(ostream &s, pair<T, TT> t) { return s << ( << t.first << , << t.second << ) ; } template <typename T> ostream &operator<<(ostream &s, vector<T> t) { s << { ; for (int i = 0; i < t.size(); i... |
#include <bits/stdc++.h> using namespace std; static const int maxn = 100010; static const int INF = 0x3f3f3f3f; static const int mod = (int)1e9 + 7; static const double eps = 1e-6; static const double pi = acos(-1); void redirect() {} char s[maxn]; int cnt[26]; int main() { redirect(); int ... |
/* Problem : Algorithm : Status : */ #include<bits/stdc++.h> #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cstdlib> #define DEBUG cerr << Passing Line << __LINE__<< in Function [ << __FUNCTION__ << ]. n ; using namespace std; typedef long long ll;... |
#include <bits/stdc++.h> using namespace std; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; struct MCMF { enum { MAXN = 6500 }; struct Edge { int x, y; int cap, cost; }; vector<Edge> E; vector<int> adj[MAXN]; int N, prev[MAXN]; int dist[MAXN], phi[MAXN]; MCMF(in... |
#include <bits/stdc++.h> using namespace std; const int N = 3005; const int mod = 1e9 + 7; int dp1[N][N], dp2[N][N], a[N]; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); } memset(dp... |
#include <bits/stdc++.h> using namespace std; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); long long n; cin >> n; if (n <= 5) { cout << -1 << endl; } else { cout << 1 << << 2 << endl; for (int i = 3; i <= n; i++) { if (i % 2) cout <<... |
#include <bits/stdc++.h> using namespace std; bool SR(int &x) { return scanf( %d , &x) == 1; } bool SR(long long &x) { return scanf( %lld , &x) == 1; } bool SR(double &x) { return scanf( %lf , &x) == 1; } bool SR(char *s) { return scanf( %s , s) == 1; } bool RI() { return true; } template <typename I, typ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; int... |
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-5; bool board[8][8]; const int dx[8] = {1, 2, 2, 1, -1, -2, -2, -1}; const int dy[8] = {2, 1, -1, -2, -2, -1, 1, 2}; void check(int x, int y, int n) { board[x][y] = true; if (n == 1) { for (int i = (0); i < (int)(8); ++... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 10; int SL[MAXN], SR[MAXN]; int A[MAXN][2], n; int main() { while (~scanf( %d , &n)) { SL[0] = SR[0] = 0; for (int i = 1; i <= n; i++) { scanf( %d%d , &A[i][0], &A[i][1]); SL[i] = A[i][0] + SL[i - 1]; ... |
#include <bits/stdc++.h> using namespace std; long long n, a[300005], tp, lt, ans; int main() { cin >> n; for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); for (int i = 1; i <= n; i++) { tp = min(a[i] / 2, lt); lt -= tp; a[i] -= tp * 2; ans += tp + a[i] / 3; lt += a[i] %... |
#include <bits/stdc++.h> using namespace std; int n, m; char my_array[50][50]; bool visited[50][50]; bool dfs(int i, int j, int c_i, int c_j) { if (visited[i][j]) { return true; } visited[i][j] = true; char col = my_array[i][j]; bool res = false; if (i > 0 && col == my_array[i - ... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e6, N2 = 5e3, delta = 46639, mod = 1e9 + 7, oo = 1e16; const long double PI = 3.141592653589793; int main() { long long int n, cnt1 = 1, cnt2 = 1, mx = 0; string s; cin >> n >> s; for (long long int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 2002; int main() { int h, m; char c1, c2, c3, c4; double r1, r2; cin >> c1 >> c2 >> c3 >> c3 >> c4; h = (c1 - 0 ) * 10 + (c2 - 0 ); m = (c3 - 0 ) * 10 + (c4 - 0 ); h %= 12; double hh = h + double(m) / 60; r1 = hh /... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:256000000 ) using namespace std; const long double PI = 3.14159265358979323846; const long double eps = 1e-5; const int INF = numeric_limits<int>::max(); const long long LINF = numeric_limits<long long>::max(); const long long mod = 1000 * 1000 * 10... |
#include <bits/stdc++.h> using namespace std; bool grid[3][10004]; int n; long long dp[10004][8]; long long calc(int i, int mask) { int mask2 = 0; if (grid[0][i]) mask2 |= 1; if (grid[1][i]) mask2 |= 2; if (grid[2][i]) mask2 |= 4; if ((mask & mask2) != 0) { return 0; } mask |... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, const U &b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, const U &b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100005, INF = 0X3F3F3F3F; int n, tot; char s[N]; vector<int> ans; set<int> s1, s2; int main() { scanf( %s , s + 1), n = strlen(s + 1); for (int i = (1); i <= (n); ++i) { if (s[i] == L ) s1.insert(i); else s2.i... |
#include <iostream> #include <vector> #include <array> #define vi vector<int> #define pii pair<int, int> #define fst first #define snd second using namespace std; const int SZ = (1 << 19) + 5, INF = (1e9) + 7; int N, ans[200001]; vi idx[200001]; array<int, 4> seg[2][SZ]; int lz[2][SZ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; template <typename T> inline T Abs(T x) { return (x >= 0) ? x : -x; } template <typename T> inline T sqr(T x) { return x * x; } template <typename T> string toStr(T x) { stringstream st; st << x... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 710; const int MOD = 1000000007; int n; int mate[MAXN]; long long int dp[MAXN][MAXN][3][3]; char v[MAXN]; stack<int, vector<int> > s; long long int solve(int l, int r, int bl, int br) { long long int& ans = dp[l][r][bl][br]; if (an... |
#include <bits/stdc++.h> using namespace std; int n, m, x, y, z, cnt, c[100100], d[100100]; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq; vector<pair<int, pair<int, int> > > graph[100100]; vector<pair<int, pair<int, int> > > edge, v; bool mark[... |
#include <bits/stdc++.h> using namespace std; int n, d, ans = 128, x[128], sum[128]; int main() { cin >> n >> d; for (int i = 0; i < n; ++i) cin >> x[i]; sort(x, x + n); for (int l = 0; l < n; ++l) for (int r = l; r < n; ++r) if (x[r] - x[l] <= d) ans = min(ans, l + n - 1 - r); c... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1e9 + 7, oo = 1e9; const ll loo = 1e18; ll modpow(ll a, ll b) { ll ans = 1; for (; b; b /= 2, a = a * a % mod) if (b & 1) ans = (ans * a) % mod; return ans; } ll gcd(ll a, ll b) { while (a) b %= a, sw... |
#include <bits/stdc++.h> using namespace std; const int N = 100000; int n, a, b, da, db; vector<int> nei[N + 1]; int dep[N + 1], dp[N + 1]; int ans; void dfs(int x = a, int fa = 0) { vector<int> v; v.push_back(dep[x]); dp[x] = dep[x]; for (int i = 0; i < nei[x].size(); i++) { int y =... |
#include <bits/stdc++.h> using namespace std; template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; struct pt { long long x, y; pt(long long x = 0, long long y = 0) : x(x), y(y) {} pt operator-(const pt &o) const { return pt(x - o.x, y - o.y); } long long cross(const pt &... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long power(long long a, long long n) { long long ret = 1; while (n) { if (n & 1) { ret = ret * a % mod; } a = a * a % mod; n >>= 1; } return ret; } vector<long long> st; long l... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long MAX = 8e18; const long long MIN = -8e18; int n; long long x[N]; long long y[N]; long long z[N]; vector<long long> ansX; vector<long long> ansY; vector<long long> ansZ; inline long long llabs(const long long &a, ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = 1e16; const long long ninf = LLONG_MIN; const double eps = 1e-12; const long long N = 1000005; const double PI = 3.14159265358979323846; const long long LOGN = 19; long long n, m; long long s[N], t[... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5, M = 350; long long dp[5][N], B, a[N], b[N], t[N], n, m, d, minans = 1e9 + 10, dpL[N], dpR[N]; int last, ldel; deque<int> stac; int main() { ios::sync_with_stdio(false); cin.tie(0); ... |
#include <bits/stdc++.h> using namespace std; struct node { long long st, en; node() {} node(long long _st, long long _en) : st(_st), en(_en) {} }; int main() { int n, b, t, d; long long etime[200000]; long long ftime; int qlen = 0; cin >> n >> b; cin >> t >> d; etime[0] ... |
#include <bits/stdc++.h> using namespace std; map<pair<long long, long long>, pair<long long, long long> > Mp; pair<long long, long long> DFS(pair<long long, long long> u) { if (u.second < 10) return pair<long long, long long>(u.first || u.second, u.second - max(u... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; const int LOG = 18; int n, m, par[MAX][LOG], h[MAX]; vector<int> graph[MAX]; int par_tree[MAX], mini[MAX]; void lca_dfs(int node, int p) { if (p + 1) h[node] = h[p] + 1; par[node][0] = p; for (int k = 1; k < LOG; k++) ... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << : << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ... |
#include <bits/stdc++.h> using namespace std; int t; int x, n, m; int main() { cin >> t; while (t--) { cin >> x >> n >> m; while (x > 20 && n) { x = x / 2 + 10; n--; } while (m) x -= 10, m--; if (x > 0) printf( NO n ); else printf( YES ... |
#include <bits/stdc++.h> using namespace std; int main() { string a, s; cin >> a >> s; sort(s.begin(), s.end()); int ind = s.length() - 1, n = a.length(); for (int i = 0; i < n; i++) { if (ind >= 0 && s[ind] > a[i]) { a[i] = s[ind]; ind--; } } cout << a; r... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vl = vector<ll>; using pii = pair<int, int>; using vpii = vector<pair<int, int>>; template <typename T> using pque = priority_queue<T, vector<T>, greater<T>>; constexpr int N = 2... |
#include <bits/stdc++.h> using namespace std; int main() { long long int arr[200005] = {0}; long long int ans[200005] = {0}; int x, y, n, k, q; cin >> n >> k >> q; while (n--) { cin >> x >> y; arr[x]++; arr[y + 1]--; } for (int i = 1; i <= 200000; i++) { arr[i] +=... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) #pragma comment(linker, /STACK:20000007 ) #pragma GCC optimize( unroll-loops ) const int N = (int)1e6 + 100; const int maxn = (int)1e3 + 100; const int base = (int)1e9; const int mod = (int)1e9 + 7; const int inf = INT_MAX;... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cout << x; } void __print(long x) { cout << x; } void __print(long long x) { cout << x; } void __print(unsigned x) { cout << x; } void __print(unsigned long x) { cout << x; } void __print(unsigned long long x) { cout << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; constexpr int maxn = 1e5 + 10; vector<int> topo; vector<vector<pii>> pilha; int ans[maxn]; int main() { int n; scanf( %d , &n); vector<int> a(n); for (auto& it : a) scanf( %d , &it); for (int i = 0; i < n; i++) {... |
#include<bits/stdc++.h> using namespace std; void solve(){ int n; cin >> n; int a[n]; for(int i=0;i<n;i++){ cin >> a[i]; } vector<int> ans; ans.push_back(0); int current = a[0]; for(int i=1;i<n;i++){ int cans = (current|a[i])^a[i]; ans.push_back(cans); current =... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int len = s.length(); for (int i = 0; i < len;) { if (s[i] != 1 ) { cout << NO << endl; return 0; } if (i + 3 <= len) { if (s[i + 1] == 4 and s[i + 2] == 4 ) { i +... |
#include <bits/stdc++.h> using namespace std; template <typename T> class graph { public: struct edge { int from; int to; T cost; }; vector<edge> edges; vector<vector<int>> g; int n; graph(int _n) : n(_n) { g.resize(n); } virtual int add(int from, int to, T cost) =... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cout << 0 << << 0 << << n; return 0; } |
#include <bits/stdc++.h> using namespace std; inline int read() { register int res = 0, c; while (c = getchar(), c < 0 || c > 9 ) ; do { res = (res << 3) + (res << 1) + (c ^ 48); } while (c = getchar(), c >= 0 && c <= 9 ); return res; } const int inf = 0x3f3f3f3f; const i... |
#include <bits/stdc++.h> int main(void) { int n; std::cin >> n; int arr[2 * n]; for (int i = 0; i < 2 * n; i++) std::cin >> arr[i]; int swc = 0; for (int i = 0; i < 2 * n; i += 2) { int pos = -1; for (int j = i + 1; j < 2 * n; j++) { if (arr[j] == arr[i]) { pos = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const long long inf = 1e18; int a[maxn]; vector<int> g[maxn]; bool c[maxn], ok[maxn]; int dpdown[maxn], dpup[maxn]; int salem[maxn]; int mxdown[maxn], mxup[maxn]; int cnt[maxn]; int sum[maxn]; int n; int dip[maxn]; void... |
#include <bits/stdc++.h> using namespace std; const int PI = acos(-1); const int MAXN = 1e6; unsigned long long comb(unsigned long long n, unsigned long long k) { if (k > n) return 0; unsigned long long u = 1; for (unsigned long long i = 1; i <= k; i++) { u *= n--; u /= i; } retu... |
#include <bits/stdc++.h> using namespace std; int n, m, u, v, cnt, ans; int t[1100000], nxt[1100000], to[1100000]; int a[1100000], b[1100000], c[1100000], f[1100000]; int vis[1100000]; void add(int u, int v) { nxt[cnt] = t[u], t[u] = cnt, to[cnt++] = v; } void dfs(int x) { vis[x] = true; for (int ... |
#include <bits/stdc++.h> const long double pi = acos(-1); const long long mod = 1e9 + 7, N = 1e5 + 5; using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long q; cin >> q; while (q--) { long long a, b; cin >> a >> b; if (a > b) { ... |
#include <bits/stdc++.h> using namespace std; int val[300000]; vector<pair<int, int> > ed[300000]; int fa[300000][20], maxt[300000][20], dfn[300000], dep[300000]; void dfs_bas(int u, int f) { dep[u] = dep[f] + 1, dfn[u] = ++dfn[0]; fa[u][0] = f; for (int i = 1; i < 20; i++) fa[u][i] = fa[fa[... |
#include <bits/stdc++.h> using namespace std; const int maxint = 999999999; string s; int cnt[30]; int k; int main() { int i; while (cin >> s) { cin >> k; int l = s.length(); if (l <= k) { printf( 0 n ); printf( n ); continue; } for (i = 0; i < ... |
#include <bits/stdc++.h> #pragma Optimize( O3 ) using namespace std; int n, x, a, b, y, m, ans; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; vector<int> v(n); vector<int> a; for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n; i += 2) a.push_back(v[... |
#include <bits/stdc++.h> using namespace std; int main() { int a[4]; for (int i = 0; i < 4; i++) cin >> a[i]; sort(a, a + 4); for (int i = 0; i < 2; i++) if (a[i] + a[i + 1] > a[i + 2]) return 0 * printf( TRIANGLE ); for (int i = 0; i < 2; i++) if (a[i] + a[i + 1] == a[i + 2]) return... |
#include <bits/stdc++.h> using namespace std; 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 / gcd(a, b)); } long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { ... |
#include <bits/stdc++.h> const int N = 2e5 + 5; const int MOD = 1e9 + 7; using namespace std; int n; char str1[N], str2[N]; vector<int> lt[30], rt[30]; vector<pair<int, int> > ans; int main() { scanf( %d , &n); scanf( %s , str1); scanf( %s , str2); for (int a = 0; a < n; a++) { i... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i]; iota(b.begin(), b.end(), 0); sort(b.begin(), b.end(), [&](int i, int j) { return a[i] < a[j]; })... |
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; int ind = -1; int indn = -1; int l = n.length(); for (int i = l - 1; i >= 0; i--) { if (n[i] == 0 || n[i] == 2 || n[i] == 4 || n[i] == 6 || n[i] == 8 ) { if (n[i] < n[l - 1]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n + 1]; vector<int> g[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; } set<pair<int, int> > last; int k = 0; for (int i = 1; i <= n; i++) { set<pair<int, int> >::iterator it = last.... |
#include <bits/stdc++.h> using namespace std; int main() { int n1, n2, k1, k2; cin >> n1 >> n2 >> k1 >> k2; if (n1 > n2) { cout << First ; } else { cout << Second ; } return 0; } |
#include <bits/stdc++.h> using namespace std; const int MAXN = 33333; const int mod = 998244353, G = 3; int n, k, T, a[MAXN], W, rev[MAXN], gen[MAXN]; vector<int> vec[MAXN]; inline int qpow(int a, int b) { int re = 1; for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) re = 1ll * re * a % mod... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; map<int, int> m; int u = 0; long long powers[32]; powers[0] = 1; for (int i = 1; i < 32; i++) powers[i] = 2 * powers[i - 1]; for (int i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; ... |
#include <bits/stdc++.h> using namespace std; int arr[500010]; int d1[500010]; int d2[500010]; int main() { int n; cin >> n; for (int i = (0); i < (int)(n); i++) cin >> arr[i]; int last2left = 0; for (int i = (1); i < (int)(n - 1); i++) { if (arr[i] == arr[i - 1]) { last2left... |
#include <bits/stdc++.h> using namespace std; string ANSWER[2] = { NO n , YES n }; int v[2009], s1[2009], s2[2009]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &v[i]); s1[i] = s1[i - 1] + (v[i] == 1); s2[i] = s2[i - 1] + (v[i] == 2); } i... |
#include <bits/stdc++.h> using namespace std; int x, y, n, d, x_i, y_i; vector<pair<int, int> > v; double dist(double x1, double y1) { return sqrt(pow(x1, 2) + pow(y1, 2)); } int a[605][605]; int f(int _x, int _y) { if (a[200 + _x][200 + _y] == -1) { int tmp = 1; if (dist(_x, _y) <= d) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, i, n; int edges[int(2e5 + 1)][2], weights[int(2e5 + 1)], freq[int(2e5 + 1)]; cin >> n; for (i = 1; i <= n; i++) freq[i] = 0; for (i = 0; i < n; i++) { weights[i] = -1; cin >> edges[i][0] >> edges[i][1]; freq[e... |
#include <bits/stdc++.h> using namespace std; void debug() { cout << endl; } template <typename T, typename... E> void debug(T t, E... e) { cout << t << (sizeof...(e) ? : ); debug(e...); } int main() { ios::sync_with_stdio(0); cin.tie(0); int a, b, c, d; cin >> a >> b >> c >> d... |
#include <bits/stdc++.h> using namespace std; inline int in() { int32_t x; scanf( %d , &x); return x; } inline long long lin() { long long x; scanf( %lld , &x); return x; } const int maxn = 2e5 + 10; const int mod = 1e9 + 7; const long long infll = 1e18; const int inf = 1e9; ... |
#include <bits/stdc++.h> const int N = 4005; const int M = 80; const int MOD = 998244353; int m, jc[M], ny[M]; struct Tree { int n, cnt, last[N], f[M][N], g[M][N], size[N], ans[M], w[N], tot, a[N], sum, root; bool vis[N]; struct edge { int to, next; } e[N * 2]; void addedge(i... |
#include <bits/stdc++.h> using namespace std; using namespace std; const long long mod2 = 998244353; long long fpow(long long x, long long y, long long p = 1000000007) { x = x % p; long long sum = 1; while (y) { if (y & 1) sum = sum * x; sum %= p; y = y >> 1; x = x * x; ... |
#include <bits/stdc++.h> using namespace std; struct Node { int num, cnt; friend bool operator<(const Node &n1, const Node &n2) { if (n1.cnt != n2.cnt) return n1.cnt < n2.cnt; else return n1.num < n2.num; } }; set<Node> cur, tmp; vector<int> xx, num; map<int, int> mp;... |
#include <bits/stdc++.h> using namespace std; long long n, a[33], ans; map<long long, long long> us; int main() { cin >> n; for (long long i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + 1 + n); for (long long i = 1; i <= n; ++i) { while (us[a[i]] && a[i] > 0) a[i]--; ans += a[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int digit[10] = {2, 7, 2, 3, 3, 4, 2, 5, 1, 2}; string n; cin >> n; int a = digit[(n[1] - 48)]; int b = digit[(n[0] - 48)]; cout << a * b; return 0; }... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> t; int get(int a) { if (t[a] == a) { return a; } else { return t[a] = get(t[a]); } } struct kek { int a; int b; int c; }; bool operator<(kek a, kek b) { return a.c < b.c; } void uni(int a, int b) { ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; long long pwr(long long a, long long b, long long mod) { if (b == 0) return 1; long long temp = pwr(a, b / 2, mod); temp = (temp * temp) % mod; if (b & 1) temp = (temp * a) % mod; return temp; } long long pwr(long lo... |
#include <bits/stdc++.h> using namespace std; long long f(int d) { long long res = 0; long long dp[100]; memset(dp, 0ll, sizeof(dp)); for (int k = 1; k < d; k++) if (d % k == 0) { res += ((1ll << (k - 1)) - dp[k]); int nk = k * 2; for (; nk <= d; nk += k) dp[nk] += ((1l... |
#include <bits/stdc++.h> using namespace std; const int MAXM = 500005; const int MAXN = 15; const int N = 12; int w[MAXN]; char query[MAXN]; char s[MAXN]; int n, m, q; int transform(char* s) { int ans = 0; for (int i = 0; i < n; i++) { ans = 2 * ans + (s[i] - 0 ); } return ans; ... |
#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; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; int m = a[n - 1], ans = 0; for (int i = n -... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector ) #pragma GCC target( sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( fast-math ) using namespace std; const int INF = 1e9 + 9; const long long MAXN = 5e... |
#include <bits/stdc++.h> using namespace std; const int N = 5005; const int inf = 1000000005; int n, m, r[N][N]; char str[N][N]; int main() { scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) { scanf( %s , str[i] + 1); } for (int i = 1; i <= n; i++) { for (int j = m; j >= 1; j... |
#include <bits/stdc++.h> int main() { long long t = 1; while (t--) { long long a, b, sum = 0; scanf( %lld%lld , &a, &b); while (b > 0) { int r = b % 10; sum = sum * 10 + r; b = b / 10; } sum += a; printf( %lld , sum); } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int P; cin >> P; cout << 2 << << P - 1 << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; for (int i = (0); ((1) > 0 ? i < (t) : i > (t)); i += (1)) { ll n, s; cin >> n >> s; vector<ll> v(n), pref(n + 2); for (... |
#include <bits/stdc++.h> using namespace std; const int N = 5e6 + 5; int a, b, c; long long gcd(long long a, long long b, long long& x, long long& y) { if (!b) { x = 0; y = 1; return a; } long long x1, y1; long long d = gcd(b, a % b, x1, y1); x = y1 - (a / b) * x1; y = ... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> int main() { std::map<char, long> commands; commands.insert(std::pair<char, long>( > , 8)); commands.insert(std::pair<char, long>( < , 9)); commands.insert(std::pair<char, long>( + , 10)); commands.insert(std::pair<char, long>( - , 11)); commands.insert(std::pair<char,... |
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); unsigned n, m; vector<long long> a; vector<long long> prefix; map<long long, long long, greater<long long> > time; cin >> n >> m; prefix.resize(n + 1, 0); a.resize(n); for (unsigned i = 0; i < n; cin >> a[i++]... |
#include <bits/stdc++.h> using namespace std; unsigned long long jav[70][70]; unsigned long long memoise[70]; unsigned long long kat(long long n) { if (memoise[n] > 0) return memoise[n]; unsigned long long ans = 1; unsigned long long bayad = 1; for (unsigned long long i = n + 2; i <= 2 * n; i++)... |
#include <bits/stdc++.h> using namespace std; int n, a; set<int> st; int main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n; while (n--) cin >> a, st.insert(a); st.erase(0); cout << st.size(); return 0; } |
#include <bits/stdc++.h> using namespace std; int inpt1[300000], inpt2[300000]; int main() { priority_queue<int> q; int n, k, x, sm; scanf( %d %d , &n, &k); sm = 0; for (int i = 0; i < n; i++) scanf( %d , &inpt1[i]); for (int i = 0; i < n; i++) { scanf( %d , &x); sm += x; ... |
#include <bits/stdc++.h> using namespace std; const int N = 105; const int K = 32; const int TIME = K * 24 * 60; int tot_subj, tot_stud, tot_days; map<string, int> subj_time; pair<int, int> occupied[4]; struct student { int time, when, pays; } st[N]; int dp_money[N][TIME]; int dp_nxt[N][TIME];... |
#include <bits/stdc++.h> using namespace std; using namespace std; long long int fast_expo(long long int base, long long int to) { long long int res = 1; while (to) { if (to & 1) { res *= base; } base *= base; to /= 2; } return res; } long long int to_bin[50]; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.