func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 10; const long long M = 998244353; const long double PI = acos(-1); long long n, k; long long a[N], d[N], mn[N] = {INT_MAX}; signed main() { long long i, s = 0, ans = 0; cin >> n >> k; for (i = 1; i <= n; i++) cin >> a[i];... |
#include <bits/stdc++.h> using namespace std; multiset<int64_t> h, hl, v, vl; int main() { cin.tie(0), ios_base::sync_with_stdio(0); int W, H, q, r, c, nr, nc, pr, pc; auto tmp = h.begin(); char t; cin >> W >> H >> q; int64_t mv = H, mh = W; h.insert(0); h.insert(W); hl.insert(... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); char str[1000][1000]; int i; for (i = 0; i < n; i++) { scanf( %[^ n] , str[i]); } int cnt = 0; int j; for (i = 0; i < n; i++) { if (strcmp(str[i], -1 ) == 0) continue; cnt++; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18 + 9; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, k; cin >> n >> k; vector<long long> a(n); for (long long i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); vector<l... |
#include <bits/stdc++.h> using namespace std; int main() { long long int test; cin >> test; while (test--) { long long int n; cin >> n; long long int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } long long int total_sum = 0; for (int i = 0; i < n; i... |
#include <bits/stdc++.h> const int maxn = 1e5 + 3; int n; int k; int A; int a[maxn]; int ans[maxn]; int main() { int sum = 0; scanf( %d%d , &n, &k); for (int i = 1; i <= n; ++i) scanf( %d , &a[i]), sum += a[i]; if (sum % k) { puts( No ); return 0; } sum /= k; for (i... |
#include <bits/stdc++.h> using namespace std; ifstream fi( test.txt ); ifstream fir( inp.txt ); ofstream fo( out.txt ); const long long MOD = 1e9 + 7; const long long base = 269; const int ooi = 1 << 30; const int N = 1e5 + 5; long long n, m, q, k, pos, rs, t, T, cnt, rs1; long long maxx = -1e9, min... |
#include <bits/stdc++.h> using namespace std; vector<long long> gr[200011]; vector<long long> v; vector<long long> v1; bool vis[200011]; queue<pair<long long, bool> > q; long long n, m; void bfs(long long s, bool k) { q.push({s, k}); while (!q.empty()) { long long node = q.front().first; ... |
#include <bits/stdc++.h> using namespace std; template <class T> using vc = vector<T>; template <class T> using vvc = vc<vc<T>>; template <class T> void mkuni(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); } template <class T> void print(T x, int suc ... |
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second const int N = 2e5+5; int n , dp[N] , ans; vector<int> adj[N]; void dfs(int node , int par) { vector<int> v; for(auto ch : adj[node]) { if (ch==par) continue; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int a[n][2]; int l = 0, r = 0; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1]; l += a[i][0]; r += a[i][1]; } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e7 + 5; int l, r, x, y; char c; int main() { cin >> l >> c >> r; cin >> x >> c >> y; l = l * 60 + r; x = x * 60 + y; l = l - x; if (l < 0) { l += 24 * 60; } printf( %02d:%02d n , l / 60, l % 60); return 0... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int tc; cin >> tc; while (tc-- > 0) { long long int n; cin >> n; if (n % 2 == 0) { long long int a = 2; long long int b = n / 2; cout <<... |
#include <bits/stdc++.h> using namespace std; const int N = 200 + 10; int main() { int n, arr[N]; char f; char ch[N]; scanf( %d , &n); cin >> ch; n = 2 * n; for (int i = 0; i < n; i++) arr[i] = ch[i] - 0 ; sort(arr, arr + n / 2); sort(arr + n / 2, arr + n); bool a = false,... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; long long int i, j, a, b, ans; for (i = 1; i <= t; i++) { cin >> a >> b; ans = 0; while ((a + b + ans * (ans + 1) / 2) % 2 != 0 || (a + b + ans * (ans + 1) / 2) < 2 * max(a, b)) { ans++... |
#include <bits/stdc++.h> using namespace std; struct point { long long x, a; } p[100]; int n; long long key[100][100]; long long k[100]; long long s[3], ans; long long v; void getb(long long ab, long long b, int cur) { if (ab < b * b) return; if (cur > n + 1) return; if (cur == n + 1) ... |
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define all(v) v.begin(), v.end() #define eb emplace_back #define ll long long const int N = 2e5 + 5; const int inf = 1e9 + 7; ll t[4 * N]; ll z[4 * N]; ll a[N]; bool modify[4 * N]; void push(int tl, int tr, int v) {... |
#include <bits/stdc++.h> using namespace std; int cnt[300007]; int main() { int n, k; scanf( %d%d , &n, &k); string s; cin >> s; int check = 100; for (int i = (0); i <= ((int)s.size() - 1); ++i) ++cnt[s[i] - a ]; for (int i = ( a ); i <= ( z ); ++i) { if (k >= cnt[i - a ]) ... |
#include <bits/stdc++.h> using namespace std; string num; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> num; for (int i = 0; i < num.length(); i++) { cout << num[i]; } for (int i = num.length() - 1; i >= 0; i--) { cout << num[i]; } retur... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-7; const long long MOD = 1000000007LL; const int INF = 0x3f3f3f3f; const int _NAN = -0x3f3f3f3f; const double EULC = 0.5772156649015328; const int NIL = -1; template <typename T> void read(T &x) { x... |
#include <bits/stdc++.h> using namespace std; vector<int> g[100005]; int par[18][100005]; int depth[100005]; void dfs(int u, int p = 0, int d = 0) { par[0][u] = p; depth[u] = d; for (int i = 0; i < g[u].size(); i++) { int v = g[u][i]; if (v == p) continue; dfs(v, u, d + 1); }... |
#include <bits/stdc++.h> using namespace std; bool is_integer(long double k) { return std::floor(k) == k; } int main() { long long i, j = 0; string s; cin >> s; if (s.length() == 1 && s[0] == 0 ) { cout << 0; return 0; } int c = 0; for (i = (s.length() - 1); i >= 0; i--) {... |
#include <bits/stdc++.h> using namespace std; using tint = tuple<int, int, int>; const int maxn = 200004; int N, M; tint a[maxn]; struct dsu { dsu() { iota(p, p + maxn, 0); } int p[maxn], add[maxn]; int root(int k) { return p[k] != k ? p[k] = root(p[k]) : k; } bool connect(int x, int y) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int totb = 0, totr = 0, totx = 0, deep; int n; struct data { int next, num; } edgeb[400001], edger[400001]; struct data2 { int x; bool judge; } ans[200001]; struct seg { int l, r, va; } tr[1600001], tb[1600001]; int... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e6 + 7; const int mod = 1e9 + 7; long long int dp[maxn] = {0}; int main() { int t; cin >> t; dp[1] = 0; dp[2] = 0; dp[3] = 1; for (int i = 4; i < maxn; i++) { dp[i] = 2 * dp[i - 2] + dp[i - 1]; if (i % 3 == 0) ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200010; const int MOD = 1e9 + 7; int read() { int x = 0, ch; while (isspace(ch = getchar())) ; do x = x * 10 + ch - 0 ; while (isdigit(ch = getchar())); return x; } int n; map<int, int> idx, idy; int nid; namespa... |
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <ctype.h> #include <deque> #include <cstring> #include <set> #include <bitset> #include <map> #include <chrono> #include <random> #include <unordered_map> #include <stdio.h> using namespace std; typ... |
#include <bits/stdc++.h> using namespace std; const int inf = ~0u >> 2; const int N = 500010; int Max[N << 2]; struct node { int x, y, z; } in[N]; int tot, n; int num[N]; int max(int a, int b) { return a > b ? a : b; } void pushup(int rt) { Max[rt] = max(Max[rt << 1], Max[rt << 1 | 1]); } void... |
#include <bits/stdc++.h> using namespace std; int main() { int a[] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, ... |
#include <bits/stdc++.h> namespace chtholly { char buf[1 << 23], *p1 = buf, *p2 = buf; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) f ^= c == - ; for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 0 ); return f ? x : -x; } tem... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e17; const long long maxn = 2e5 + 700; const int mod = 1e9 + 7; template <typename T> inline void read(T &a) { char c = getchar(); T x = 0, f = 1; while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; int q[3001], t, n; int main() { scanf( %d , &n); for (int i = 2; i <= n; i++) { if (q[i - 1] == 2) t++; if (q[i] > 0) continue; for (int j = i; j <= n; j += i) q[j]++; } if (q[n] == 2) t++; printf( %d n , t); } |
#include <bits/stdc++.h> using namespace std; long long n, x; vector<string> ans; long long dec(string s) { long long ret = 0; for (long long i = 0; i < s.size(); i++) { ret = ret * 10 + s[i] - 48; } return ret; } void add(long long v) { long long rs = 0; if (ans.size() == 0) {... |
#include <bits/stdc++.h> using namespace std; int main() { int N; scanf( %d , &N); if (N == 1) { puts( 1 ); return 0; } int s = 0; for (int i = 0; i < N; ++i) { int t; scanf( %d , &t); s += t; } printf( %d n , s % N == 0 ? N : N - 1); } |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); #pragma GCC diagnostic ignored -Wsign-compare int main() { int n, ind = 0; scanf( %d , &n); vector<long long> vals(n); vector<long long> pref(n); for (int i = 0; i < n; i++) { scanf( %d , &vals[i]); } ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a < b) { swap(a, b); } if (a % b == 0) { return b; } return gcd(b, a % b); } vector<vector<int>> gr; vector<int> used; void dfs(int v) { used[v] = 1; for (auto i : gr[v]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int res; cin >> res; if (res % 2 == 0) { cout << Mahmoud ; } else { cout << Ehab ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int grundy[] = {0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12}; int main() { int n; scanf( %d , &n); int ones = n; bool vis[100100] = {false}; vector<int> v; for (long long i = 2... |
#include <bits/stdc++.h> using namespace std; long long xyp(long long x, long long y) { if (y == 0) return 1LL; if (y == 1) return x; if (y % 2) { long long p = xyp(x, y - 1); return (x * p) % 1000000007; } long long p = xyp(x, y / 2); return (p * p) % 1000000007; } long long... |
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1.0); const long double EPS = 1e-14; const long long INF = 1e18; const long long MOD = 1e9 + 7; const long long p = 97; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.precision(9); long long n; c... |
#include<bits/stdc++.h> using namespace std; int main() { int n,i,j,cnt,ara2[20000],m; string ss; cin>>m; for(i=0;i<m;i++) { cin>>n; cin>>ss; if((ss[0]== 2 )&&(ss[n-1]== 0 )&&(ss[n-2]== 2 )&&(ss[n-3]== 0 )) { cout<< Yes <<endl; } el... |
#include <bits/stdc++.h> using namespace std; int main() { int nCases; cin >> nCases; for (int i = 0; i < nCases; i++) { long long nCandy = 0; cin >> nCandy; if (nCandy == 1 || nCandy == 2) { cout << 0 << endl; } else if (nCandy % 2 == 0) { cout << (nCandy / 2) - ... |
#include <bits/stdc++.h> using namespace std; const int N = 300005, B = 35; int n; char t[N]; struct AC { struct Trie { int ch[26], fail, c, c2; } A[N]; int siz[B], root[N], top, cnt; string str[N]; void build(int RT) { queue<int> q; q.push(RT); while (!q.empty()) {... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; 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<<1)+(x<<3)+(ch^48); c... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, N = 20, M = 1 << 5; int n, m; int f[2][N][N][N][N][2][2], (*nxt)[N][N][N][2][2] = f[1], (*cur)[N][N][N][2][2] = *f; int snx[M], sny[M], spx[M], spy[M], A; void add(int &x, int y) { x += y - mod; x ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; char s[N]; int main() { int t; scanf( %d , &t); while (t--) { map<long long, long long> mp; long long n; scanf( %lld , &n); scanf( %s , s); long long sum = 0, ans = 0; long long x; for (int ... |
#include <bits/stdc++.h> using namespace std; int par[200005], vis[200005], tree[200005]; set<pair<int, int> > par_change; void dfs(int u, vector<int> next[], int dfs_par) { vis[u] = 1; if (par[u] == u) { par_change.insert({1, u}); } for (int i = 0; i < next[u].size(); ++i) { int v =... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 10; int cnt[maxn]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int t; scanf( %d , &t); ++cnt[t]; } int ans = 0; for (int i = 0; i < maxn - 1; i++) { cnt[i + 1] += (cnt[i] /... |
#include <bits/stdc++.h> using namespace std; void swap(int ar[], int i, int j) { int aux = ar[j]; ar[j] = ar[i]; ar[i] = ar[j]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; int Ma[n][m]; int Mb[n][m]; for (i... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { char c; int f = 1; while (!isdigit(c = getchar())) if (c == - ) f = -1; x = (c & 15); while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15); x *= f; } const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; vector<pair<int, int> > opt[18 * MAX]; map<pair<int, int>, vector<pair<int, int> > > mp; int par[MAX]; int col[MAX]; int sz[MAX]; int an[MAX]; vector<int> roll_back_num; vector<pair<pair<int, pair<int, int> >, pair<int, pair<int,... |
#include <bits/stdc++.h> using namespace std; const int mxn = 100006; const int mxm = 100006 * 2; int n, m; int fe[mxn] = {}; int ne[mxm]; int ev[mxm]; bool v[mxm]; int el = 1; void add1(int L, int R) { ++el; ne[el] = fe[L]; fe[L] = el; ev[el] = R; } bool vis[mxn]; int dfs(int ... |
#include <bits/stdc++.h> using namespace std; struct people { long long a, b, id; } p[300010]; long long n, s[300010], t; bool v[300010], ans[300010]; bool cmp(people a, people b) { return a.a == b.a ? a.b > b.b : a.a > b.a; } long double check(people a, people b) { return (long double)a.a * b.a *... |
#include <bits/stdc++.h> /** #include <ext/pb_ds/assoc_container.hpp> * #include <ext/pb_ds/tree_policy.hpp> * using namespace __gnu_pbds; */ using namespace std; #define ll long long #define ull unsigned long long #define f(a, b) for (ll i = a; i < b; i++) #define mod 1000000007 #define pb push_... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n / 2 * 2 + (n + 1) / 2 << endl; for (int i = 2; i <= n; i += 2) cout << i << ; for (int i = 1; i <= n; i += 2) cout << i << ; for (int i = 2; i <= n; i += 2) cout << i << ; } |
#include <bits/stdc++.h> using namespace std; char s1[128]; int l1; char s2[128]; int l2; char virus[128]; int lv; int nxt[128][128]; vector<int> froms[128][128]; void calc_nxt() { char tmp[128]; strcpy(tmp, virus); for (int l = 0; l < lv; l++) { for (char ch = A ; ch <= Z ; ch++... |
#include <bits/stdc++.h> using namespace std; const int N = 3001; const int mod = 1000000007; char s[N][N]; int f[N][N]; int calc(int sr, int sc, int tr, int tc) { if (tr < sr || tc < sc) return 0; int n = tr - sr + 1, m = tc - sc + 1; f[0][0] = (s[sr][sc] != # ); for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> template <typename T> T inline SQR(const T &a) { return a * a; } template <typename T> T inline ABS(const T &a) { return a < 0 ? -a : a; } template <typename T> T inline MIN(const T &a, const T &b) { if (a < b) return a; return b; } template <typename T> T ... |
#include <bits/stdc++.h> using namespace std; vector<int> adj[100005]; struct Tree { vector<vector<int> > anc; vector<vector<int> > cost; vector<int> T, X; vector<int> depth; vector<bool> vis; int n; int root; Tree(int N = 1e5, int r = 1) { n = N + 5; root = r; an... |
#include <bits/stdc++.h> using namespace std; int read() { int q = 0; char ch = ; while (ch < 0 || ch > 9 ) ch = getchar(); while (ch >= 0 && ch <= 9 ) q = q * 10 + ch - 0 , ch = getchar(); return q; } const int N = 200005, inf = 0x3f3f3f3f; int n, m, Q, SZ, st_top, tim; int w[... |
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a > b) return a; return b; } long long min(long long a, long long b) { if (a > b) return b; return a; } int main() { { ios_base::sync_with_stdio(false); cin.tie(NULL); }; int q... |
#include <bits/stdc++.h> using namespace std; char x; int n; int main() { cin >> n; cin >> x; cout << x; cin >> x; cout << x; n -= 2; if (n % 2 == 1) { cin >> x; cout << x; n--; } for (int i = 1; i <= n; i++) { if (i % 2 == 1) cout << - ; cin >>... |
#include <bits/stdc++.h> using namespace std; std::vector<string> v(2000); vector<vector<int> > mark(2000); set<pair<int, int> > ans; int bfs(int x, int y) { int m = x, n = y; vector<pair<int, int> > q; int i = 0; while (v[x][y] != # && mark[x][y] == -2) { q.push_back(make_pair(x, y));... |
#include <bits/stdc++.h> using namespace std; long long add(long long n) { long long mi = INT_MAX, ma = INT_MIN; while (n > 0) { mi = min(n % 10, mi); ma = max(n % 10, ma); n = n / 10; } return mi * ma; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m, k, cntr = 1, s = 1; cin >> n >> m >> k; string str; cin >> str >> str; if (str == head ) cntr = -1; cin >> str; int l = str.length(); if ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long sum, xr; cin >> sum >> xr; long long dp[2] = {1, 0}; for (int bit = 0; bit < 50; bit++) { long long ndp[2] = {0, 0}; int needSum = (sum >> bit) & 1; int needXor = (xr >> bit) ... |
#include <bits/stdc++.h> using namespace std; inline void splay(long long &v) { v = 0; char c = 0; int p = 1; while (c < 0 || c > 9 ) { if (c == - ) p = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { v = (v << 3) + (v << 1) + c - 0 ; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2000010; int main() { int len, cnt; char s, d, st[maxn], word[26]; cin >> len >> cnt; cin >> st; for (int i = 0; i < 26; ++i) { word[i] = a + i; } for (int i = 1; i <= cnt; ++i) { cin >> s >> d; if (s ==... |
#include <bits/stdc++.h> const int N = 100010; using ll = long long; int a[N]; int main() { int n, d, m; scanf( %d%d%d , &n, &d, &m); for (int i = 0; i < n; ++i) { scanf( %d , &a[i]); } std::sort(a, a + n); int last = n; for (int i = 0; i < n; ++i) { if (a[i] > m) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, arr[100]; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int i = 0; i < n - 1; i++) { for (int j = i; j < n; j++) { if (arr[i] > arr[j]) { int swap = arr[j]; arr[j] = arr[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; if (s.length() > 10) cout << s[0] << (s.length() - 2) << s[s.length() - 1] << endl; else cout << s << endl; } } |
#include <bits/stdc++.h> const int MAX_N = 1000000; const int MOD = 1000000007; std::vector<int> groups; int table[1 + MAX_N], dp[1 + MAX_N]; std::deque<int> tablePositions; int main() { std::string s; std::cin >> s; groups.push_back(0); int cnt = 0; for (int i = 0; i < s.size(); ++i) ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 200200; vector<int> adj[MAX]; int ch[MAX], sz, from[MAX], dpthMx[MAX], dpthMn[MAX], n; void dfs(int cur, int par) { for (auto i : adj[cur]) if (i != par) { dfs(i, cur); dpthMn[cur] = min(dpthMn[cur], dpthMn[i] + 1); ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 100005; template <typename T> void readv(vector<T>& v, int n) { for (int i = 0; i < n; ++i) { T tmp; cin >> tmp; v.push_back(tmp); } } struct cmp { bool operator()(const pair<int, int>& i1, const pair<int, int>& i2) ... |
#include <bits/stdc++.h> using namespace std; void file_io() { freopen( input.txt , r , stdin); freopen( output.txt , w , stdout); } void PLAY() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); } int main() { PLAY(); int n; cin >> n; int x[1000000] = {0}; fo... |
#include <bits/stdc++.h> using namespace std; long long n; int licznik; long long sym(long long k) { long long eat = k, m = n - k; while (m > 0) { licznik++; m -= m / 10; eat += min(k, m); m -= k; } return eat; } long long binsuche(long long lewy, long long prawy) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10, INF = 1e9; inline int read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) f = -f; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; double a, b, c; int main() { while (~scanf( %lf%lf%lf , &a, &b, &c)) { double x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a), x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a); if (a < 0) swap(x1, x2); printf( %.6lf n%.6lf n , x1, x2); ... |
#include <bits/stdc++.h> using namespace std; void _fill_int(int* p, int val, int rep) { int i; for (i = 0; i < rep; i++) p[i] = val; } signed long long GETi() { signed long long i; scanf( %lld , &i); return i; } int N, X, Y; int mat[501][501]; int vis[501][501]; int LM[501], RM[50... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; const long long mod = 998244353; const long long maxn = 5e4 + 10, maxval = 1e9 + 10, mlg = (1 << 18) + 10; struct edge { long long u, v, c, t; } ed[maxn * 6]; long long n, m, cnt; long long ans[maxn * 6], comp[maxn * 6], mark1... |
#include <bits/stdc++.h> #pragma optimization_level 3 #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 ) using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int main() { cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_wit... |
#include <bits/stdc++.h> using namespace std; ; vector<pair<int, int>> vec; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k, a, b, c; c = 1; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a >> b; vec.push_back(make_pair(a * -1, b)); } sort(... |
#include <bits/stdc++.h> using namespace std; struct node { int x, y, id; bool operator<(const node &A) const { return x < A.x; } }; vector<node> line[2][100005 << 2]; bool mark[2][100005 << 2]; int n, m, k; long long t[100005]; void add(int x, int y, int i) { node a; a.x = x, a.y = y, a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, ctr = 0, j; int arr[1000]; cin >> n; for (i = 0; i < n; i++) cin >> arr[i]; for (i = 0; i < n; i++) if (arr[i] == 1) break; if (i == n) { cout << 0; return 0; } for (j = n - 1; j >= 0; j--) i... |
#include <bits/stdc++.h> using namespace std; #pragma warning(disable : 4996) const double eps = 1e-7; struct node { long long first; node() {} node(long long first) : first(first) {} bool operator<(const node& a) const { return first < a.first; } }; int dx[4] = {-1, 1, 0, 0}; int dy[4] = ... |
#include <bits/stdc++.h> using namespace std; int d[] = {25, 18, 15, 12, 10, 8, 6, 4, 2, 1}; int t, n, k; struct edge { string name; int s, win[50]; } a[100]; bool cmp1(edge x, edge y) { if (x.s != y.s) { return x.s > y.s; } for (int i = 0; i < 50; i++) { if (x.win[i] != y.wi... |
#include <bits/stdc++.h> using namespace std; char ch[200][200]; int rp[200], cp[200]; int main() { int n; while (cin >> n) { memset(rp, 0, sizeof(rp)); memset(cp, 0, sizeof(cp)); for (int i = 1; i <= n; i++) { scanf( %s , ch[i] + 1); for (int j = 1; j <= n; j++) ... |
#include <bits/stdc++.h> long n, m, x, y, i, a[1000], z; double aa, bb, sum; int main() { scanf( %ld%ld , &n, &m); for (i = 1; i <= n; i++) scanf( %ld , &a[i]); sum = 0; for (i = 1; i <= m; i++) { scanf( %ld%ld%ld , &x, &y, &z); aa = a[x] + a[y]; bb = z; if (aa / bb > sum) ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using pii = pair<int, int>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tests; cin >> tests; for (int test = 0; test < tests; ++test) { int n; cin >> n; vector<... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 100; vector<int> adj[MAXN], *vec[MAXN]; int col[MAXN], pw[MAXN], goni[MAXN], sz[MAXN]; long long sum[MAXN]; void getsz(int v = 1, int pre = -1) { sz[v] = 1; for (auto u : adj[v]) { if (u != pre) { getsz(u, v); ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, n, k, tmp; vector<long long> ans; vector<int> vec; cin >> t; while (t--) { cin >> n >> k; for (int i = 0; i < n * k; i++) { cin >> tmp; vec.push_back(tmp); } int med; if (n % 2 == 0) ... |
#include <bits/stdc++.h> using namespace std; int t, n, k; void solve() { scanf( %d%d , &n, &k); if (n < k) { printf( NO n ); return; } if ((n - (k - 1)) % 2 == 1) { printf( YES n ); for (int i = 1; i <= k - 1; ++i) printf( 1 ); printf( %d n , n - (k - 1)); } els... |
#include <bits/stdc++.h> using namespace std; int n, Q; const int md = 998244353; const int maxn = 200010; int t[4 * maxn], tmul[4 * maxn], tadd[4 * maxn]; inline int mod(long long x) { return (x % md + md) % md; } void build(int v, int vl, int vr) { tmul[v] = 1, tadd[v] = 0; if (vl == vr) return;... |
#include <bits/stdc++.h> using namespace std; long long int M = 1e9 + 7; int sum_digit(int x) { int sum = 0; while (x > 0) { sum += x % 10; x /= 10; } return sum; } int reverse_num(int n) { int tmp = n, ans = 0, r; while (tmp > 0) { r = tmp % 10; ans = ans * 10 ... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> adjlist[1000050], ans; bool done[1000050], use[1000050]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; adjlist[a].push_back(b... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7, inf = 1e17, N = 1e6 + 10; bool vowel(char che) { if (che == A || che == E || che == I || che == O || che == U || che == Y ) { return true; } else { return false; } } long long pw(long long a... |
#include <bits/stdc++.h> using namespace std; int main() { long long N, M; cin >> N >> M; set<long long> x_t; set<long long> y_t; vector<long long> ans; for (long long i = 0; i < M; i++) { long long x, y; cin >> x >> y; if (x_t.find(x) == x_t.end()) x_t.insert(x); if ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, l, a, q[100001], w[100001], sum = 0, i; cin >> n >> l >> a; for (i = 0; i < n; i++) { cin >> q[i] >> w[i]; } if (n == 0) { cout << l / a; return 0; } sum = sum + q[0] / a; for (i = 1; i < n;... |
#include <bits/stdc++.h> using namespace std; vector<int> divi[2002]; long long dp[2002][2002]; int main() { int n, k; cin >> k >> n; int i, j; for (i = 1; i <= k; i++) { for (j = i; j <= k; j += i) divi[i].push_back(j); } for (i = 1; i <= n; i++) { for (j = 1; j <= k; j++) {... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); long long int mx = n * n; for (int i = 1, j = mx; i < j; i++, j--) { cout << i << << j << endl; } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.