func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)(1e9 + 7); bool check(pair<int, int> a, pair<int, int> b) { return (a.first < b.first); } int main() { int t; cin >> t; while (t--) { int m, n; cin >> m >> n; int a[31][31]; pair<int, int> x[65]; ... |
#include <bits/stdc++.h> using namespace std; int n, a[100010], new_arr[100010], new_arr1[100010], arr[100010]; int x = 1000000; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { new_arr[i] = min((i + 1), (n - i)); new_arr1[i] = a... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int mod = 1000000007; const int inf = 2012345678; const long long infl = 9012345678901234567; const double pi = 3.1415926535897932384626433832795; struct rat { long long a, b; rat(long long _a = 0, long long _b = 1... |
#include <bits/stdc++.h> using namespace std; int main() { string pixels; getline(cin, pixels); getline(cin, pixels); int len = 0, flen = 0, last = pixels.at(0) - 0 ; bool first = false; for (int i = (0); i < (pixels.size()); i += (2)) { if ((pixels.at(i) == 0 && last == 0) || ... |
#include <bits/stdc++.h> using namespace std; int cnt[200010]; long long num[200010]; struct P { int x, y, fl; bool operator<(const P &hs) const { if (x != hs.x) return x < hs.x; else return y < hs.y; } } p[200010]; int row[200010]; int pre[200010]; int n, k; in... |
#include <bits/stdc++.h> using namespace std; const long long MM = 10000000000000001; int n; long long a[200005]; int rs[200005]; long long lazy[4 * 200005]; pair<long long, int> it[4 * 200005]; pair<long long, int> minp(pair<long long, int> A, pair<long long, int> B) { if (A.first < B.first) return... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } int mx = *max_element(v.begin(), v.end()); int mn = *min_element(v.begin(), v.end()); int... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, l, i, j = 0, s = 0, a, b, x, y; cin >> n >> a >> x >> b >> y; while (a != x && b != y) { a++; b--; if (b == 0 && b != y) b = n; if (a == n + 1 && a != x) a = 1; if (a == b) { cout << yes ; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n; long long k; long long a[maxn]; long long b[maxn], c[maxn], d[maxn]; int main() { scanf( %d%lld , &n, &k); for (int i = 1; i <= n; i++) scanf( %lld , a + i); sort(a + 1, a + n + 1); int m = 0; for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int dx[] = {1, -1, 0, 0}; int dy[] = {0, 0, 1, -1}; double PI = 3.1415926535897932384626433832795; const long long oo = (long long)1e9 + 1; const double eps = 1e-9; const long long mod = 1000000007; string s; long long nb, ns, nc, pb, ps, pc, R; int main... |
#include <bits/stdc++.h> int main() { long long palite, primeite; std::cin >> palite >> primeite; long long primes = 0, palindromes = 0, max; static bool prime[12000001]; for (long long i = 0; i <= 12000000; i++) { prime[i] = true; } prime[1] = false; std::string str = 0 ; f... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j; string s; cin >> n; cin >> s; n = s.size(); for (i = 0; i < n - 1; i++) { if (s[i] > s[i + 1]) break; } if (i != n - 1) { cout << YES << n ; cout << i + 1 << << i + 2 << n ;... |
#include <bits/stdc++.h> int main() { char s[512]; scanf( %s , s); int length = strlen(s); int i; int alpha_cnt = 0; for (i = 0; i < length; i++) { if (s[i] - a > alpha_cnt) { puts( NO ); return 0; } if (s[i] - a == alpha_cnt) { alpha_cnt++; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = double; using pll = pair<ll, ll>; using vll = vector<ll>; using vpll = vector<pll>; using vvll = vector<vll>; vector<vector<ll>> g; vector<bool> v; ll res; pair<bool, bool> dfs(int u, int depth) { v[u] = true; i... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve() { long long n; cin >> n; vector<long long> a(n), b; for (long long i = 0; i < n; i++) { cin >> a[i]; } b = a; sort(b.begin(), b.end()); b.resize(uni... |
#include <bits/stdc++.h> int n, up, s; int a[20], ans[5][5], s1[5], s2[5], s3, s4, idx[1 << 16], cnt[1 << 16]; bool ans_u, vis[1 << 16]; void dfs(int sta) { if (sta == up) { if (ans_u) return; printf( %d n , s); for (int i = 0, j; i < n; ++i) { for (j = 0; j < n; ++j) { i... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0), cin.tie(0); int n, j = 0; cin >> n; int a[n], b[n]; pair<int, int> s[n]; for (auto &i : s) cin >> i.first, i.second = j++; sort(s, s + n); map<int, int> mp; for (int i = 0; i < n; i++) mp[s[i].sec... |
#include <bits/stdc++.h> using namespace std; void populate(string& s, char c, int n) { for (int i = 0; i < n; ++i) s[s.find_first_of( ? )] = c; } int main() { ios::sync_with_stdio(0); int n; cin >> n; string s; cin >> s; auto na = count(s.begin(), s.end(), A ); auto nc = count(... |
#include <bits/stdc++.h> using namespace std; using Real = long double; Real g_err = 1e-9; bool r_eq(Real x, Real y, Real err = g_err) { return abs(x - y) <= err || abs(x - y) <= abs(x) * err; } bool r_le(Real x, Real y, Real err = g_err) { return x - y <= err || x - y <= abs(x) * err; } bool r_... |
#include <bits/stdc++.h> using namespace std; signed main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long k; vector<long long> ans; if (n > 3) { if (n % 2 == 1) k = n - 1; else k = n; while (k > 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n, r; cin >> n >> r; double alpha = 90.0 - 180.0 / n; double val = cos(alpha * 3.14159265 / 180.0); double ans = val * (double)r / (1 - val); cout << fixed << setprecision(6) << ans << endl; r... |
#include <bits/stdc++.h> int d[3000], g[3000], q[3000]; int i, j, k, m, n, r, t; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) { scanf( %d , &g[i]); if (g[i] <= m) d[g[i]]++; else r++; } for (k = 0;; k++) { t = 1; for (i = 2; i <= m; i++... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100009; int acc[MAXN], sav[MAXN]; int extr(string &s) { int num = 0; for (int i = 1; i < s.length(); i++) { num *= 10; num += (s[i] - 0 ); } return num; } int main() { int n, m; scanf( %d , &n); scanf( %d... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1e6 + 1e5 + 5; struct Node { int len, pa; int trans[26]; } st[maxN + 1]; int n, m, last, cnt; int L[11], R[11]; int sum[11][maxN + 1]; char s[maxN + 1]; vector<int> son[maxN + 1]; inline int insert(int c) { if (st[last].trans... |
#include <bits/stdc++.h> using namespace std; const long long linf = 4000000000000000000LL; const long long inf = 1000000007; void pv(vector<int> a) { for (auto& x : a) cout << x << ; cout << endl; } void pv(vector<long long> a) { for (auto& x : a) cout << x << ; cout << endl; } vo... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const long long G = 300005, BASE = 666667, M1 = 2e9 + 11, M2 = 1e9 + 9; long long IB1, IB2; long long a, o; long long m[G], pwb1[G], pwb2[G]; long long binpow(... |
#include <bits/stdc++.h> using namespace std; long long unorder(int n) { if (n == 0) return 1; if (n == 1) return 0; bool good; long long ans = 0; vector<int> V(n); for (int i = 0; i < n; i++) V[i] = i; do { good = true; for (int i = 0; i < n && good; i++) good = (V[i] != i);... |
#include <bits/stdc++.h> using namespace std; int dist[100010], n; vector<pair<int, int> > gr[100010]; void dfs() { memset(dist, -1, sizeof(dist)); dist[1] = 0; queue<int> q; q.push(1); while (!q.empty()) { int u = q.front(); q.pop(); for (int i = 0; i < gr[u].size(); i++) ... |
#include <bits/stdc++.h> using namespace std; int n, a, b; vector<pair<int, int> > x[255][4005]; int main() { scanf( %d n , &n); for (int i = 0; i < n; i++) { scanf( %d %d n , &a, &b); x[a / 4000][b / 250].push_back(make_pair(a, i + 1)); } for (int i = 0; i < 252; i++) { for (i... |
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; vector<vector<int> > v = {{1}}; for (int i = 0; i < k; i++) { int current = v.size(); for (int j = 0; j < current; j++) { vector<int> vnew(2 * current); for (int l = 0; l < current; l++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << --n / 2 << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; namespace IO { template <typename t> inline void read(t& x) { x = 0; bool f = 1; char ch; for (ch = getchar(); ch < 0 || 9 < ch; ch = getchar()) if (ch == - ) f ^= 1; for (; 0 <= ch && ch <= 9 ; ch = getchar()) x = (x << 3) + ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n, h; cin >> n >> h; bool flag; for (int k = 0; k < n; k++) { flag = false; for (int j = 0; j < n; j++) { if (flag) cout << ; flag = true; if (j == k) cout << h; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, p, q, ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> p; cin >> q; if (q - p >= 2) ans++; } cout << ans << endl; } |
#include <bits/stdc++.h> using namespace std; struct vals { bool vd; char val[1010]; bool cur; int idx[2]; string nome, op; } s[5020]; bool valdef(bool k, int vv, int curidx) { if (s[curidx].idx[vv] == -1) return k; return s[s[curidx].idx[vv]].cur; } bool value(string op, bool k,... |
#include <bits/stdc++.h> using namespace std; string A[8]; int dx[9] = {-1, -1, -1, 0, 1, 1, 1, 0, 0}; int dy[9] = {-1, 0, 1, 1, 1, 0, -1, -1, 0}; bool dfs(int x, int y, int tour) { if (x == 0 && y == 7) return 1; if (tour > 8) return true; for (int k = 0; k <= 8; k++) { int nx = x + dx[k], ... |
#include <bits/stdc++.h> using namespace std; void io() { freopen( input.txt , r , stdin); freopen( output.txt , w , stdout); } const int N = 2e5 + 9; const long long MOD = 1e9 + 7; const int INF = 1e9; int dx[5] = {0, -1, 1, 0, 0}; int dy[5] = {0, 0, 0, -1, 1}; char dc[5] = { 0 , U , D , ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, m, d[N], a[N]; bool flag[N]; bool check(int x) { memset(flag, 0, sizeof(flag)); int cur = x - 1; for (int i = x; i >= 1; i--) { cur = min(cur, i - 1); if (d[i] && !flag[d[i]] && a[d[i]] <= cur) { flag[d... |
#include <bits/stdc++.h> using namespace std; template <typename T, size_t N> struct ma : array<T, N> { T &operator[](size_t n) { return (*static_cast<array<T, N> *>(this))[n]; } }; template <class T> string to_str(const T &a) { ostringstream os; os << a; return os.str(); } template <> ... |
#include <bits/stdc++.h> using namespace std; int dx8[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, dx4[4] = {-1, 0, 1, 0}; int dy8[8] = {0, -1, -1, -1, 0, 1, 1, 1}, dy4[4] = {0, -1, 0, 1}; inline void open(string name) { freopen((name + .in ).c_str(), r , stdin); freopen((name + .out ).c_str(), w , stdout); ... |
#include <bits/stdc++.h> using namespace std; int main() { string str; char tmp = z ; cin >> str; for (int i = 0; i < str.length(); i++) { if (str[i] <= tmp) { tmp = str[i]; cout << Mike << endl; } else { cout << Ann << endl; } } return 0; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n, m, a, b; cin >> n >> m >> a >> b; long long int res, ans; res = n / m; if (n % m) res++; res = (res * m - n) * a; ans = (n % m) * b; cout... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; long long min(long long a, long long b) { return (a < b) ? a : b; } long long max(long long a, long long b) { return (a > b) ? a : b; } long long fp(long long a, long long b) { if (b == 0) return 1; long long x = fp(a, b / 2); ... |
#include <bits/stdc++.h> using namespace std; int n, m, x; vector<pair<int, int> > leti[26]; vector<pair<int, int> > shift; vector<int> dis[26]; int main() { cin >> n >> m >> x; int d = x * x; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { char t; cin >> t; ... |
#include <bits/stdc++.h> using namespace std; const long long int Maxn3 = 1e3 + 10; const long long int Maxn4 = 1e4 + 10; const long long int Maxn5 = 1e5 + 10; const long long int Maxn6 = 1e6 + 10; const long long int Maxn7 = 1e7 + 10; const long long int Maxn8 = 1e8 + 10; const long long int Maxn9 = 1e... |
#include <bits/stdc++.h> #pragma warning(disable : 4996) FILE *in = stdin, *out = stdout; using namespace std; #pragma comment(linker, /stack:36777216 ) int n; char a[300005]; int D[300005]; void input() { fscanf(in, %d , &n); fscanf(in, %s , &a[1]); } bool isSame(int x) { if (x & 1) ... |
#include <bits/stdc++.h> using namespace std; int n, m; int main() { cin >> n >> m; if (m / n == 2) cout << n - m % n; else if (m / n == 1) cout << m % n; else cout << 0; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 110, M = 10010; int n; long double x; int c[N], all; long double binom[N][N]; long double f[N][M]; int main() { cin >> n >> x; for (int i = 1; i <= n; i++) scanf( %d , &c[i]), all += c[i]; f[0][0] = 1; for (int i = 0; i <= n; i+... |
#include <bits/stdc++.h> using namespace std; long long k, l, g = 0, h = 0; int a, b, p[3][3], q[3][3], t, u, v, c; vector<pair<int, int> > s; bool con; int gg(int a, int b) { if (a == b + 1 || a == b - 2) return 1; return 0; } void sim(int x, int t, int u) { while (x > 0) { g += gg(t,... |
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 3; const int inf = 1e8; int n, m; char str[N][N]; int sx, sy; int tx, ty; struct data { int up; int down; int rgt; int lft; data() { up = 0; down = 0; rgt = 0; lft = 0; } void rotate() {... |
#include <bits/stdc++.h> using namespace std; bool sortbysecdesc(const pair<long long, long long> &a, const pair<long long, long long> &b) { if (a.first == b.first) return a.second > b.second; else return 0; } const long long N = 100010; bool prime[N]; void SieveOfEr... |
#include <bits/stdc++.h> using namespace std; long long fastpower(long long power, long long base) { if (power == 0) return (1 % 1000000007); long long sum; sum = fastpower(power / 2, base) % 1000000007; sum = ((sum % 1000000007) * (sum % 1000000007)) % 1000000007; if (power & 1) sum = ((sum % 1... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx ) #pragma GCC target( avx,tune=native ) using namespace std; class CodeHash { public: string precise(double number, int prec) { stringstream ss; ss << fixed ... |
#include <bits/stdc++.h> using namespace std; int getn() { int h; scanf( %d , &h); return h; } template <class T, class U> ostream& operator<<(ostream& out, const pair<T, U>& par) { cout << [ << par.first << ; << par.second << ] ; return out; } vector<vector<int> > mini; int n; ... |
#include <bits/stdc++.h> using namespace std; int main() { int l, r; cin >> l >> r; int k = r - l; if (k >= 1) cout << 2 << endl; else cout << l << endl; return 0; } |
#include <bits/stdc++.h> int main() { int sum = 0, a, n, m, i; scanf( %d %d , &n, &m); for (i = 1; i <= n; i++) { sum = sum + i; if (m > sum && i == n) { i = 0; } a = m - sum; if (a < i + 1) { printf( %d , a); break; } } return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 2000000 + 10; int a[N], b[N]; int n, m; int main() { int x, y; scanf( %d%d , &n, &m); { for (int i = 0; i < m; i++) { scanf( %d%d , &x, &y); x--; y--; a[x]++; a[y]++; } for (int i ... |
#include <bits/stdc++.h> using namespace std; long long mult(long long a, long long b, long long p = 1000000007) { return ((a % p) * (b % p)) % p; } long long add(long long a, long long b, long long p = 1000000007) { return (a % p + b % p) % p; } long long sub(long long a, long long b, long long p =... |
#include <bits/stdc++.h> using namespace std; const int N = 2 * 100 * 1000; long double l[N]; long double Maks(long double dod, int n) { int i; long double as, mi, w; mi = 0; w = -10000000000000; as = 0; for (i = 1; i <= n; ++i) { as += (l[i] - dod); w = max(w, as - mi); ... |
#include <bits/stdc++.h> using namespace std; int a[100005], lg[100005]; int rmq[100005][20]; struct trie { struct node { node *edge[2]; vector<int> ps[2]; node() { for (int i = 0; i < 2; i++) edge[i] = 0; ps[0].clear(); ps[1].clear(); } } * root; trie... |
#include <bits/stdc++.h> using namespace std; int n, g[20][20], r, c, k, ans = 0, x, y; bool chk(int a, int b, int c, int d) { int cnt = 0; for (int i = a; i <= a + c; i++) { for (int j = b; j <= b + d; j++) { cnt += g[i][j]; if (cnt >= k) return 1; } } return 0; } ... |
#include <bits/stdc++.h> using namespace std; void printVec(vector<int> v2, string s = ) { cout << s; for (int i = 0; i < (int)v2.size(); ++i) cout << v2[i] << ; cout << n ; } bool isOdd(int a) { return (a % 2 == 1); } void initMem(int n, int mem[]) { for (int i = 0; i < n; i++) mem[i] ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b; cin >> a >> b; long long ans = abs(a - b) / 5; a = abs(a - b) % 5; if (a == 4) cout << ans + 2; if (a == 3) cout << ans + 2; if (a == 2) cout << ans + 1; if (a == 1) cout << ans + 1; if (a == 0) cout << ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int gizzly; cin >> gizzly; priority_queue<int> scoreList; for (int i = 1; i < n; i++) { int x; cin >> x; scoreList.push(x); } int candy = 0; while (gizzly <= scoreList.top()) { int... |
#include <bits/stdc++.h> using namespace std; int n, k, a[((int)1001 * 1000)], maxi, mini; vector<int> v; int jaghool; bitset<((int)1001 * 1000)> dp, mark; int main() { scanf( %d%d , &n, &k); int k2 = k; for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1; i <= n; i++) if (... |
#include <bits/stdc++.h> using namespace std; int Q, cnt = 1; int par[400010][21], nxt[400010][21], len[400010]; long long w[400010], sum[400010][21]; long long mx[400010][21]; int find_first_bigger(int u, int W) { if (mx[u][0] >= W) return u; for (int i = 18; i >= 0; i--) if (mx[u][i + 1] >= ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vec; set<int> st; for (int i = 0; i < int(n); ++i) { int a; cin >> a; st.insert(i); vec.push_back(a); } queue<int> tok; int ans = 0; int killed = 0; for (int i = n ... |
#include <bits/stdc++.h> using namespace std; const long double pie = 3.14159265358979; const long long mod = 1e9 + 7; string vow = aeiou ; void solve(int test_case) { string f, m, s; cin >> f >> m >> s; map<string, string> beat; beat[ rock ] = scissors ; beat[ scissors ] = paper ; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, t, k, d; cin >> n >> t >> k >> d; int curr = 0; while (curr <= d) { n -= k; curr += t; } if (n > 0) { cout << YES ; } else { cout << NO ; } } |
#include <bits/stdc++.h> using namespace std; int n, ls[310]; int dp[110][310][310]; pair<int, int> p[110]; int L[110], R[110], x[110]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d%d , &p[i].first, &p[i].second); ls[i * 3 - 2] = p[i].first - p[i].second; l... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == - ) f = -1; for (; isdigit(c); c = getchar()) x = x * 10 + c - 0 ; return x * f; } const int MAXN = 200010; const int INF = 1e9; con... |
#include <bits/stdc++.h> using namespace std; const int N = 600000; const int MOD = (int)1e9 + 7; int n, m, k, u, v, g[N]; long long c[N], w[N]; set<long long> s; vector<pair<long long, pair<int, int> > > e; int find(int cur) { return cur == g[cur] ? g[cur] : g[cur] = find(g[cur]); } int main() { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, lamps[2002], sol = 0, cs; memset(lamps, 0, sizeof(lamps)); cin >> n >> m; string s[2002]; for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (s[i]... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 200000 + 100; const int M = 30; vector<int> G[MAXN]; int deep[MAXN], fa[MAXN][M]; void DFS(int cur, int pre) { fa[cur][0] = pre; for (int i = 1; i < 20; ++i) fa[cur][i] = fa[fa[cur][i - 1]][i - 1]; for (int i = 0; i < G[cur].size(); ... |
#include <bits/stdc++.h> using namespace std; bool check(int i, int n, set<pair<int, int> >& st) { for (auto it : st) { pair<int, int> t(it.first + i, it.second + i); if (t.first > n) t.first %= n; if (t.second > n) t.second %= n; if (t.first > t.second) swap(t.first, t.second); if... |
#include <bits/stdc++.h> using namespace std; int i, j, k, l, n, m, s, an, K, X; const int N = 5100; int a[1100000], g[1100000]; long long f[N][N]; int main() { scanf( %d%d , &n, &K); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(&a[1], &a[n + 1]); int v1 = n / K + 1; int v2 = n ... |
#include <bits/stdc++.h> using namespace std; void fun(long long a[], long long remain, long long total, long long n, long long m) { vector<long long> ans; long long i, j; for (i = 0; i < n && total > 0; i++) { if (a[i] % m == remain) { ans.push_back(a[i]); total--; ... |
#include <bits/stdc++.h> using namespace std; bool isprime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = 0; while (s.at(n) != . ) n++; if (s.at(n - 1) == 9 ) cout << GOTO Vasilisa. ; else { if (s.at(n + 1) < 53) cout << s.substr(0, n); else { cout << s.substr(0, n - 1); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (scanf( %I64d , &n) != EOF) { long long x, y, l, h, mid; l = 0, h = 1e18 + 7; while (l < h - 1) { mid = (l + h) >> 1; if (n / (3 * mid) >= mid + 1) l = mid; else h = mi... |
#include <bits/stdc++.h> using namespace std; const int M = 4e5 + 10; int n, a[M], b[M], ans, cnt; int f(int x, int i) { return n - (x >> i) - (lower_bound(b, b + n, (1 << (i + 1)) - x) - b); } int32_t main() { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , a + i); for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; const long double PI = acos(-1); const long long MOD = 1000000007; const long long FMOD = 998244353; long long cnt1, cnt2, x, y; bool isSafe(long long mid) { long long div1 = mid / x; long long div2 = mid / y; long long div3 = mid / (x * y); long... |
/*/ Author: Aniruddh Lawande /*/ #include<bits/stdc++.h> using namespace std; /*/---------------------------Defines----------------------/*/ #define ll long long #define F first #define S second #define pb push_back #define endl n #define all(v) (v).begin(),(v).end() typedef pair<ll,ll>... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2e5L + 11, M = N * 2; int a[M], b[M], c[M]; int back[M]; struct SegTree { ll flag[N * 8]; ll val[N * 4]; void push(int x) { val[x] += flag[x]; flag[2 * x] += flag[x]; flag[2 * x + 1] += flag[x]; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e17 + 7; const long long maxn = 5e5 + 700; const int mod = 998244353; const int up = 1e9; template <typename T> inline void read(T &a) { char c = getchar(); T x = 0, f = 1; while (!isdigit(c)) { if (c == - ) f = -1; ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 30, Mod = 1e9 + 7; const long long SQ = 330; map<long long, vector<long long> > mp; pair<long long, long long> E[N]; long long p[N], sz[N], M[N], cnt[N]; vector<long long> G[N]; long long r[N], ans[N]; void DFS(long long v, long l... |
#include <bits/stdc++.h> using namespace std; int main() { int n, l = 0, r = 0; cin >> n; for (int i = 0; i < n; i++) { bool a, b; cin >> a >> b; l += a; r += b; } int left = 2 * l > n ? (n - l) : l; int right = 2 * r > n ? (n - r) : r; int count = left + right; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1e9 + 7; class SegTree { private: const ll NEUT = 0; vector<ll> seg, tag; int h = 1; ll len(int i) { return h >> (31 - __builtin_clz(i)); } void apply(int i, ll v) { seg[i] = (seg[i] + v * len(i)) % M... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7, NMAX = 100010; int N, M; int color[NMAX]; vector<int> Left[NMAX], Right[NMAX]; void DFS(int node, int current_color) { if (color[node] && color[node] != current_color) { cout << 0 n ; exit(0); } if (color[node] =... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int current = 0; int i = 1, i2 = 2; int ans = 0; while (current + i <= n) { current += i; ans++; i += i2; i2++; } cout << ans; } |
#include <bits/stdc++.h> using namespace std; int n = 0, m = 0; char** values; bool** values1; void PrintArray() { cout << Values n ; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << values[i][j] << ; } cout << endl; } cout << Values1 n ; f... |
#include <bits/stdc++.h> using namespace std; const int Imx = 2147483647; const long long Lbig = 2e18; const int mod = 1e9 + 7; struct fastio { char s[100000]; int it, len; fastio() { it = len = 0; } inline char get() { if (it < len) return s[it++]; it = 0; len = fread(s, 1, ... |
#include <bits/stdc++.h> using namespace std; long long int dig(long long int n) { long long int r = 0; while (n) { ++r; n = n / 10; } return (r - 1); } long long int func(long long int n) { if (n <= 9) return (n + 1); long long int lt = dig(n); lt = pow(10, lt); long... |
#include <bits/stdc++.h> using namespace std; int main() { long long int a, b, c; cin >> a >> b >> c; cout << a * b + (a + b - 1) * (c - 1); return 0; } |
#include <bits/stdc++.h> using namespace std; const double inf = 1e14; const double pi = acos(-1); const double eps = 1e-10; const int maxn = 25010; int n, x[maxn], y[maxn], dx[maxn], dy[maxn], s[maxn]; double ans = inf, ddx[maxn], ddy[maxn], K[maxn], B[maxn]; inline double solve(int a, int b) { dou... |
#include<iostream> typedef long long ll; using namespace std; const int maxn =1e5+5; int n,q; ll sum[maxn]; string s; int main() { cin>>n>>q; cin>>s; s = # +s; for(int i=1;i<=n;i++) sum[i] = sum[i-1]+s[i]- a +1; while (q--) { int l,r; cin>>l>>r; ... |
#include <bits/stdc++.h> using namespace std; int n, a[100010]; int la, ra; void update(int i, int delta) { for (; i < n; i = i | (i + 1)) { a[i] += delta; } } int get(int fr, int to) { int res = 0; for (int i = to; i >= 0; i = (i & (i + 1)) - 1) { res += a[i]; } for (int... |
#include <bits/stdc++.h> using namespace std; const short maxn = 5000 + 5; const int mod = 1000000000 + 7; int n; short x[maxn], y[maxn]; short d[maxn][maxn]; short md; char col[maxn]; void dfs(int x) { for (int i = 0, _n = (int)(n); i < _n; i++) if (d[x][i] > md) { if (col[x] == col... |
#include <bits/stdc++.h> using namespace std; long long n, A, B; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; while (n--) { cin >> A >> B; cout << A * (long long)log10(B + 1) << endl; } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.