func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template <class T> using vv = vector<vector<T>>; template <class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; } template <class T> inline bool MN(T &l... |
#include <bits/stdc++.h> using namespace std; const int oo = 1000000009; const double eps = 1e-9; const int mod = 1000000007; int nos[100001], n, pos = 0; int main() { cin >> n; for (int i = 0; i < n; ++i) scanf( %d , &nos[i]); sort(nos, nos + n); for (int i = 0; i < n; ++i) if (pos + ... |
#include <bits/stdc++.h> using namespace std; int n, m, qu; int a[100011]; int st[100011], en[100011]; int pos[100011]; int rt[100011], nxt[100011]; int step[100011]; bool vis[100011]; vector<int> v[100011], vv; queue<int> q; void bunhae_interval() { int r = n % m, mm = n / m; st[0] = 1; ... |
#include <bits/stdc++.h> using namespace std; long long int powers[1000100]; vector<pair<int, int> > edges; unsigned long long hashes[1000100] = {0}; unsigned long long ts[1000100] = {0}; int main(void) { powers[0] = 1; for (int i = 1; i <= 1000000; i++) powers[i] = (powers[i - 1] * (unsigned ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 1e5 + 1; int n, m; vector<int> adj[N]; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int x) { return uniform_int_distribution<int>(0, x - 1)(rng); } int d[N]; bool inq[N]; bool ... |
#include <bits/stdc++.h> const int maxN = 3e5 + 5; int main() { if (fopen( iput.txt , r )) { freopen( iput.txt , r , stdin); freopen( oput.txt , w , stdout); } int n; scanf( %d , &n); printf( %d n , n / 2 * 2 + n - n / 2); printf( 2 ); for (int i = 4; i <= n; i += 2) prin... |
#include <bits/stdc++.h> using namespace std; set<int> st[200000 + 7]; set<int>::iterator it; vector<int> graph[200000 + 7], edge[200000 + 7]; pair<int, int> edges[200000 + 7], path[200000 + 7]; int sid[200000 + 7], prio[200000 + 7], pr_id, can[200000 + 7], neg[200000 + 7], rev[200000 + 7]; long lon... |
#include <bits/stdc++.h> using namespace std; inline long long gcd(long long x, long long y) { return x ? gcd(y % x, x) : y; } const long long mod = 1e9 + 7; inline signed rd() { signed ans = 0; char last = , ch = getchar(); while (!(ch >= 0 && ch <= 9 )) last = ch, ch = getchar(); while (... |
#include <bits/stdc++.h> using namespace std; int n, m, k, a, b, ii; int ans; char ch[1500][1500]; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; int dp[1500][1500]; int p[100007]; void dfs(int x, int y) { if (x > n || x < 1 || y > m || y < 1) return; if (ch[x][y] == * ) { ans++;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b; cin >> n >> m; double mn = 101.00, x = 0.00; for (int i = 1; i <= n; i++) { cin >> a >> b; x = a / (b * 1.00); if (mn > x) mn = x; } cout << fixed << setprecision(8); cout << mn * m << endl; ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long int myRand(long long int B) { return (unsigned long long)rng() % B; } inline double time() { return static_cast<double>(chrono::duration_cast<chrono... |
#include <bits/stdc++.h> using namespace std; long long t, n, S, s, up, down, mid, mx, mn, a, b, k, l, r, ans, raod; pair<long long, long long> p[300005]; int main() { cin >> t; while (t--) { cin >> n >> S; mn = 1e10; mx = 0; for (k = 1; k <= n; k++) { cin >> a >> b; ... |
#include <bits/stdc++.h> using namespace std; int const maxn = 100 * 1000 + 5; int a[maxn]; int b[maxn]; int main() { int t; cin >> t; int n, f1, fm1; for (int i = 0; i < t; i++) { f1 = maxn; fm1 = maxn; cin >> n; for (int j = 0; j < n; j++) { cin >> a[j]; ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long k, i, j, b = 1; string s = codeforces ; vector<int> a(10, 1); cin >> k; for (; b < k;) for (i = 0; i < 10; i++) { b /= a[i]; ++a[i]; b = b * a[i]; if (b > k - 1) break; } for (... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; int dp[502][502][2], n, m; char str[502][502]; int dis; int check(int x, int y) { if (x < 0 or x >= n and y < 0 or y >= m) return 0; else return 1; } int call(int x, int y, int a, int idx) { int ham = x ... |
#include <bits/stdc++.h> using namespace std; const long long inf = (long long)1e18; const long long mod = (long long)1e9 + 7; const double eps = (double)1e-9; const double pi = acos(-1.0); const int dx[] = {0, 0, 1, 0, -1}; const int dy[] = {0, 1, 0, -1, 0}; const int N = 500500; int n, k; vector<p... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n; cin >> n; int count = 0; for (int a = 1; a <= n; a++) { for (int b = a; b <= n; b++) { int k = a * a + b * b; int c = sqrt(k); if (c * c == k && c... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; const int N = 500031; int tests, n, k; vector<pair<int, int> > g[N]; int used[N]; long long dp[N][2]; void dfs(int v) { used[v] = 1; long long guaranteed = 0; vector<long long> benefits; for (int i = 0; i < g[v].siz... |
#include <bits/stdc++.h> int map[525][525]; int note[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512}; int main() { int time = 0, size = 1, i, j, head, tail; map[1][1] = 1; while (time != 9) { time++; head = size + 1; tail = 2 * size; for (i = 1; i <= size; i++) for (j = h... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tichnas; cin >> tichnas; while (tichnas--) { long long n, c, m, maxs = 1e9, temp, ans; map<long long, long long> type; bool possible; cin >> n; for (int i... |
#include<bits/stdc++.h> using namespace std; #define ll long long #define imin INT_MIN #define imax INT_MAX #define br n #define sp #define pie 3.141592653589793238462643383279 #define lower(sl) transform(sl.begin(), sl.end(), sl.begin(), ::tolower); #define upper(sl) transform(sl.begin(), s... |
#include <bits/stdc++.h> using namespace std; int pgcd(int a, int b) { if (a == 0) return b; return pgcd(b % a, a); } int nbNombres; int vals[300 * 1000]; int minRange[20][300 * 1000]; int pgcdRange[20][300 * 1000]; vector<int> possibles(int taille) { vector<int> sol; int etage = __built... |
#include <bits/stdc++.h> using namespace std; int n, s, e; int x[5013]; int a[5013], b[5013], c[5013], d[5013]; long long dp[5013][5013]; int main() { scanf( %d%d%d , &n, &s, &e); for (int i = 1; i <= n; i++) scanf( %d , &x[i]); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f, g = 0, h = 0, i = 0, j, k, l, p = 0; cin >> a >> b >> c >> d >> e >> f; g = a - d; h = b - e; i = c - f; if (g > 0) { j = g / 2; } else { j = 0; } if (h > 0) { k = h / 2; } else... |
#include <bits/stdc++.h> int main() { int n, i, sum = 0; scanf( %d , &n); if (n == 1) sum = 1; if (n == 2) sum = 5; if (n == 3) sum = 13; if (n >= 4) { for (i = 4; i <= n; i++) { sum = sum + i * i - (i - 2) * (i - 2); } sum = sum + 13; } printf( %d , sum); }... |
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; typedef unsigned long long ull; #define RESET(a, b) memset(a, b, sizeof(a)) int INF = 1000000005; long long INFF = 1000000000000000005LL; using namespace std; struct monster { ll health, attack_power; }; ... |
#include <bits/stdc++.h> using namespace std; int upd[400000][10]; long long val[400000][10]; bool dirty[400000]; void clean(int n, int l, int r) { long long buf[10]; memset(buf, 0, sizeof buf); for (int i = 0; i < 10; i++) { buf[upd[n][i]] += val[n][i]; } dirty[n] = false; for (... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string ans; string t; for (int i = 0; i < n; i++) { cin >> t; if (i == 0) { ans = t; continue; } for (int j = 0; j < t.size... |
#include <bits/stdc++.h> using namespace std; const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1}; const int N = 212345; int n, m, q, p[N], a[N]; int f[N], g[N], last[N]; vector<int> loc[N]; int maxm[N]; int my_find(int id, int val) { int l = 0, r = loc[id].s... |
#include <bits/stdc++.h> using namespace std; const int N = 2050; int p[N], id[N], rmd[N], P[N], n; int qry(vector<int> vec) { cout << ? << vec.size() << ; for (auto t : vec) cout << t << ; cout << endl, fflush(stdout); int ok; cin >> ok; return ok; } int query(int x) { ... |
#include <bits/stdc++.h> const bool TEST = 0; const int inf = 0x7fffffff; using namespace std; template <typename T> void pA(T *begin, int n) { for (int i = 0; i < n; i++) { cout << *(begin++); } printf( n ); } const char cho[4] = { R , B , Y , G }; vector<unsigned int> fAns; boo... |
#include <bits/stdc++.h> using namespace std; const long long mx = 1e5 + 10; long long n, m, a[mx], cnt[mx], r[mx], l[mx], p[mx], ans[mx]; int main() { cin >> n >> m; for (long long i = 1; i <= n; i++) { cin >> a[i]; if (a[i] < mx) cnt[a[i]]++; } for (long long i = 0; i < m; i++) cin... |
#include <bits/stdc++.h> using namespace std; char a[1000010]; char b[1000010]; int main() { cin >> a; int ind = 0; int ans = 0; int n = strlen(a); for (int i = 0; i < n; i++) { if (a[i] == [ || a[i] == < || a[i] == ( || a[i] == { ) { b[ind] = a[i]; ind++; ... |
#include <bits/stdc++.h> using namespace std; inline void read(int &x) { x = 0; int f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == - ) f = -f; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); x *= f; } inline void print(int x) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; string st[n]; int a[m]; for (int i = 0; i < n; i++) { cin >> st[i]; } for (int i = 0; i < m; i++) { cin >> a[i]; } int maxa = 0; int ca, cb, cc, cd, ce; for (int i = 0; i < m; ... |
#include <bits/stdc++.h> using namespace std; const double PI = 2.0 * acos(0.0); inline int getInt() { int x; scanf( %d , &x); return x; } inline long long getLL() { long long x; scanf( %lld , &x); return x; }; inline int NUM(char c) { return (int)c - 48; } inline char CHR(int n)... |
#include <bits/stdc++.h> using namespace std; const int TAILLE_MAX = 1000; int main() { int n, l, r; cin >> n >> l; int p[TAILLE_MAX]; for (int i = 0; i < n; i++) cin >> p[i]; sort(p, p + n); r = max(p[0], l - p[n - 1]) * 2; for (int i = 0; i < n - 1; i++) r = max(r, p[i + 1] - p[i]); ... |
#include <bits/stdc++.h> using namespace std; long long n; long long k; long long a[200005]; long long s1; long long s2; long long inv[200005]; long long p; long long ans; long long quick_pow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = res * x % 10000000... |
#include <bits/stdc++.h> using namespace std; const int maxN = (int)2E5 + 5; const long long mdls = (long long)1E9 + 7; vector<int> Adj[maxN]; vector<long long> suff[maxN], pref[maxN]; long long f[maxN], g[maxN], h[maxN]; int n; void DFS(int u) { f[u] = 1; for (int i = 0, sz = Adj[u].size(); i <... |
#include <bits/stdc++.h> using namespace std; using LL = long long; template <class T> int size(T &&x) { return int(x.size()); } template <class A, class B> ostream &operator<<(ostream &out, const pair<A, B> &p) { return out << ( << p.first << , << p.second << ) ; } template <class T> ... |
#include <bits/stdc++.h> using namespace std; const int mx = 5e5 + 10; const double eps = 1e-9; const int inf = 1e9; char a[mx]; multiset<char> ms; int main() { scanf( %s , a); int n = strlen(a); int mn = a[0] - a ; printf( Mike n ); for (int i = 1; i < n; i++) { if (a[i] - a ... |
#include <bits/stdc++.h> using namespace std; int main() { int dem = 0; int n; int tong = 0; int s; cin >> n; for (int i = 9; i >= 1; i--) { if (n % i == 0) { s = i; break; } } int z; z = n / s; cout << z << endl; while (z) { cout << s <<... |
#include <bits/stdc++.h> using namespace std; string removeZero(string s) { int i = 0, m = 0, j = s.size() - 1; if (s[i] == 0 ) { while (s[i] == 0 ) { i++; } } s.erase(0, i); if (s[j] == 0 ) { while (s[j] == 0 ) { m++; j--; } } s.erase(... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int maxm = 1e5 + 5; const long double eps = 1e-14; const long double eps2 = 1e-9; const long double INF = 1 << 30; inline int dcmp(const long double& x) { return fabs(x) < eps ? 0 : (x < 0 ? -1 : 1); } template <typename... |
#include <bits/stdc++.h> using namespace std; const long long oo = 1e14; long long ab(long long x) { return x > 0 ? x : -x; } long long a[100005]; long long kn[66]; long long sum[100005]; map<long long, int> mp; int nxt[100005]; int main() { int n, k; scanf( %d%d , &n, &k); kn[0] = 1; ... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e16; const long long int maxn = 1 << 20; double pie = 3.1415926535; string str[101]; bool done[101]; int main() { long long int n, i, j, cnt, offset; string s, s1, ans; cin >> n >> s; ans = ; for (i = 0; i < n; ... |
#include <bits/stdc++.h> using std::max; using std::min; const int inf = 0x3f3f3f3f, Inf = 0x7fffffff; const long long INF = 0x3f3f3f3f3f3f3f3f; std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count()); template <typename _Tp> _Tp gcd(const _Tp &a, const _Tp &b) { return (!b) ? a ... |
#include <bits/stdc++.h> using namespace std; const long long inff = 0x3f3f3f3f3f3f3f3f; int main() { cin.tie(0); long long k, d, t, qw, e; scanf( %I64d , &k), scanf( %I64d , &d), scanf( %I64d , &t); qw = (k / d + 1) * d; if (k % d == 0) { cout << t << endl; return 0; } dou... |
#include <bits/stdc++.h> using namespace std; void fff() { freopen( dravde.in , r , stdin); freopen( dravde.out , w , stdout); } const int MAXN = 100001; int n; map<int, int> m[MAXN]; int f[MAXN], s[MAXN], p[MAXN], cnt = 0, z; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int n, m, v; pair<int, int> p[10]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; ++i) { scanf( n ); for (int j = 1; j <= m; ++j) { char ch = getchar(); if (ch == * ) p[++v] = make_pair(i, j); } } if (... |
#include <bits/stdc++.h> using namespace std; long long tests, t, qq, q, i, j, bb[200000], s1, ans[2100][2100]; long long a, b; long solve(long long a, long long b) { if (a < b) swap(a, b); if (a == 0 || b == 0) return 0; if (solve(a % b, b) == 0) return 1; t = a / b; if (b % 2 == 1) return ... |
#include <bits/stdc++.h> using namespace std; const int N = 100500; using ll = long long; using point = pair<ll, ll>; ll& x(point& p) { return p.first; } ll& y(point& p) { return p.second; } int n; point p[N], p2[N]; set<point> s; point centerN, center2, invP; int no() { cout << NO << endl; ... |
#include <bits/stdc++.h> using namespace std; int n, q; int kek[20]; long long a[696969]; void upd(int x, int v, int s = 0, int e = (1 << n) - 1, int d = n - 1, int p = 1) { if (s == e) { a[p] = v; return; } int m = (s + e) / 2; if (x <= m) { upd(x, v, s, m, d - 1,... |
#include <bits/stdc++.h> using namespace std; struct event { long long int peakval; long long int pos; long long int time1; }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n, m, d; cin >> n >> m >> d; struct event e1[m + 1]; e1[0].... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; class { public: int n, m; vector<pair<int, int> > V[5555]; bool vis[5555], in[5555]; int ans[5555]; void solve() { cin >> n >> m; for (int i = 0; i < m; ++i) { int u, v; cin >> u >> v; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e9 + 7; void solve() { long long n, curr, val, ans = 0; cin >> n >> curr; vector<long long> a(n), cost(n); for (long long i = 0; i < n; i++) cin >> a[i]; cin >> val; for (long long i = 0; i < n; i++) cin >> cost[i]; multiset<... |
#include <bits/stdc++.h> using namespace std; long long int n; string s; vector<long long int> ss; inline bool check(long long int lim) { long long int sum = 0, cnt = 0; for (long long int i = 0; i < ss.size(); i++) { if (sum + ss[i] <= lim) { sum += ss[i]; } else { cnt++; ... |
#include <bits/stdc++.h> using namespace std; int podch[1100]; int newp[1100]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k, x; cin >> n >> k >> x; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; podch[tmp]++; } for (int i = ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long add(long long x, long long y, long long CMOD = MOD) { return (x + y + CMOD + CMOD) % CMOD; } long long mult(long long x, long long y, long long CMOD = MOD) { return add(x, 0) * add(y, 0) % CMOD; } long long fast... |
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a[n]; int b[n]; vector<int> c; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; char q[15][15], p[15][15], max_s[15], min_s[15], tmp[15], ans[15]; int np[15]; int main() { int i, j, k, n, carry, t, flag; while (scanf( %d %d , &n, &k) != EOF) { for (i = 0; i < n; ++i) scanf( %s , q + i); for (i = 0; i < k; ++i) { np[i... |
#include <bits/stdc++.h> const int N = 100001; int i, n, m, g[N], v[N], b[N], res[N], c[N], a; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) scanf( %d , &g[i]); for (i = 1; i <= m; i++) scanf( %d , &v[i]); for (i = 1; i <= m; i++) scanf( %d , &b[i]); for (i = 1; i <= m; i++) { ... |
#include <bits/stdc++.h> using namespace std; struct var { char name[20], type[20]; } v[1010]; int vcnt; struct func { char name[20]; char para[50][20]; int paracnt; } f[1010]; int fcnt; int n; char str[110], name[110], para[110][110], cnt; int main() { scanf( %d , &fcnt); ge... |
#include <bits/stdc++.h> using namespace std; int nxt[500005], to[500005], head[500005], fa[500005], f[500005][22], dep[500005], ru[500005], tot; bool vis[500005], used[500005]; queue<int> q; vector<int> ei[500005]; void add(int u, int v) { nxt[++tot] = head[u]; head[u] = tot; to[tot] = v;... |
#include <bits/stdc++.h> using namespace std; const long long inf = 0x3f3f3f3f; const long long MAXN = 0x7fffffff; const long long INF = 0x3f3f3f3f3f3f3f3fLL; void file() {} void pr(bool num) { cout << (num == 1 ? YES : NO ) << n ; } signed main() { ios::sync_with_stdio(false), cin.tie(0), cout.t... |
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9; const long double PI = 3.141592653589793238462643383279502884197; const int MOD = 666013; const int NMax = 350000; int N, C, D; int lastIndexForSearch; long long ans = 0LL; struct Punct; long long diferente[NMax], diferenteP... |
#include <bits/stdc++.h> using namespace std; const int N = 577, INF = 1e9, mod = 1e9 + 7; int n, m; long long h; int a[N][N], b[N][N]; int ans; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf( %d , &a[i][j]); } } for (int... |
#include <iostream> #define MAX 200010 using namespace std; long long int t, n, A[MAX], DP[MAX][105], res, a; int main() { cin >> t; for (int i = 0; i <= MAX - 3; i++) { DP[i][0] = 1; if (i <= 100) DP[i][i] = 1; } for (int i = 1; i <= MAX -... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1000000007; void dispvec(set<long long int> arr) { set<long long int>::iterator itr = arr.begin(); while (itr != arr.end()) { cout << *itr << ; itr++; } cout << endl; } struct CustomCompare { bool operator()(c... |
#include <bits/stdc++.h> using namespace std; int num[300005][2]; int jichu = 100000; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, x; cin >> n >> m; if (n == 1) { cout << 0 << endl; return 0; } long long cont = 0, sum = n; for (int ... |
#include <bits/stdc++.h> using namespace std; long long fpow(long long a, int b, int mod) { long long res = 1; for (; b > 0; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res % mod; } const int mod = 1e9 + 7; const int N = 2e5 + 100; inline int read() { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, max_gcd = 1; cin >> t; while (t--) { cin >> n; cout << n / 2 << endl; } return 0; } |
#include <bits/stdc++.h> const long long iinf = 1e18; const int inf = 1e9 + 10; const int MOD = (1e6 + 3); int dir4[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; int knight[8][2] = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, 2}, {-1, 2}, {1, -2}, {-1, -2}}; using namespace std; void solve... |
#include <bits/stdc++.h> using namespace std; int n, m; bool a = true; int main() { scanf( %d%d , &n, &m); int arr[m]; if (m % 2 == 0) { arr[0] = (m) / 2; for (int i = 1; i < m; i++) { if (!a) { arr[i] = arr[i - 1] - i; a = !a; } else { arr[i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<int, int> mp; map<int, int> np; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; int p = y - x; int q = y + x; mp[p]++; np[q]++; } map<int, int>::iterator it; in... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > vc; int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long N, M, x, y, z, p, i, X, Y, j, lplp1, lplp2; cin >> N >> M >> x >> y >> z >> p; long long opop1 = x % 4; long long opop2 = y % 2; long long opop... |
#include <bits/stdc++.h> int solve(int m, int n) { if (m == 1 || n == 1) return m * n; if (m == 2 || n == 2) { if (m < n) { m = n; n = 2; } if (m % 4 == 0) return m; else if (m % 4 == 1) return m + 1; else if (m % 4 == 2) return m + 2; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << { ; string sep; for (const auto &x : v) os << sep << x, sep = , ; return os << } ; } template <typename A, typename B> ostream &operator<<(ostream &os, const p... |
#include <bits/stdc++.h> using namespace std; int n, kov = 1; int t[502][502]; void ert(int a, int b) { t[a][b] = kov, kov++; } int main() { cin >> n; if (n <= 2) { cout << -1 << n ; return 0; } if (n == 3) { cout << 1 << << 3 << << 2 << n ; cout << 5 << ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long int len = s.length(); long long int cnt = 0; for (long long int i = 0; i < len; i++) { if (s[i] == Q ) { cnt++; } } long long int suffixes = cnt; long long int prefixes = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, i, a, b, sum = 0; cin >> n >> m; long long arr[n + 1]; for (i = 1; i <= n; i++) { cin >> arr[i]; } for (i = 0; i < m; i++) { cin >> a >> b; ... |
#include <bits/stdc++.h> using namespace std; namespace perfectGroups { const int mx = 5001; int arr[mx], ans[mx], previous[mx], dp[5001][5001], zero[mx]; int transNumber(int num) { int temp = abs(num), rt = sqrt(temp), ret = 1; for (int i = 2; i <= rt; i++) { int cnt = 0; while (temp > 1 ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:60777216 ) using namespace std; int d[10]; int c[107][107]; long long dp[107][17]; long long solve(int len, int pos) { if (pos == 9) { if (len >= d[9]) { return 1; } return 0; } if (dp[len][pos] != -1) { ret... |
#include <bits/stdc++.h> using namespace std; const int N = 300005; using ll = long long; map<ll, int> dd; map<pair<int, int>, int> f; int n, pre[3][N]; ll a[3][N]; int dfs(int n, int m) { if (pre[1][n] == -1 && pre[2][m] == -1 && pre[0][min(n, m)] == -1) return 0; pair<int, int> p{n, m}; if... |
#include <bits/stdc++.h> using namespace std; int n, m, k; long long c[1010][1010]; const int mod = 1e9 + 7; void pre() { for (int i = 0; i <= 1005; i++) { c[i][0] = c[i][i] = 1; } for (int i = 1; i <= 1005; i++) { for (int j = 0; j <= i; j++) { c[i][j] = (c[i - 1][j] + c[i - 1... |
#include <bits/stdc++.h> using namespace std; constexpr long long MOD = 1e9 + 7; long long cnt[710][710]; int a[500100]; int main() { int n; scanf( %d , &n); for (int ii = 0; ii < n; ++ii) { int t, x, y; scanf( %d%d%d , &t, &x, &y); if (t == 1) { a[x] += y; for (i... |
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 3e5 + 5; constexpr int MAXW = 1e4 + 5; constexpr int MOD = 998244353; constexpr long long INF = 2e10; constexpr int LOG = 11; string s; vector<int> ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi = acos(0) * 2; template <typename T> inline void read(T &x) { char c; bool nega = 0; while ((!isdigit(c = get... |
#include <bits/stdc++.h> using namespace std; vector<bool> trust; vector<int> massive(int** mas, int num) { vector<int> mase; int nume = num; int nume1; while (nume != 0) { nume1 = nume; nume = mas[nume - 1][0]; } mase.push_back(0); while (nume1 != 0) { mase.push_back... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MX = 2e2 + 5; const long long INF = 1e18; const long double PI = 4 * atan((long double)1); const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; namespace io { void setIn(string second) { freopen(second.c_str(), r , stdi... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j; cin >> n >> m; for (i = 1; i <= n; i++) { for (j = 0; j < m; j++) { if (i % 4 == 0) { if (j == 0) cout << # ; else cout << . ; } else if (i % 4 == 2) { ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e6 + 5; long long n, m, i, t, j, k, l, x, y, z, s, e, p, q; long long dg(long long s, long long e) { if (e % 2) return 1 - s % 2; if (s > e / 2) return s % 2; if (s > e / 4) return 1; return dg(s, e / 4); } int main() { ... |
#include <bits/stdc++.h> using namespace std; char s[5005]; int n, dp[5005][5]; const int inf = 1e7 + 5; int go(int id, int need) { if (id == n) return 0; if (dp[id][need] != -1) return dp[id][need]; int ans = 0; if (need == 1) { if (s[id] == a ) ans = max(1 + go(id + 1, 1), 1 +... |
#include <bits/stdc++.h> using namespace std; const int N = 200; typedef long long matrix[N][N]; const long long MOD = 1000000007; const double EPS = 1e-8; const double PI = 2 * acos(0); const int maxn = 1e6 + 6; int main() { cin.sync_with_stdio(false); int n, ans = 0, a[100100], p[100100]; ... |
#include <bits/stdc++.h> using namespace std; long n, m; vector<string> pref; long mov[500][500]; string temp; string inp[500]; long er, td; long bst[2000]; string tst; long dp[4][500][500]; long nend, t, ncvrd, answ; void ad(long &a, long b) { a += b; if (a >= 1000000009) a -= 100000000... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a, b; for (int i = 0; i < n / 2; ++i) { a.push_back(i); } for (int i = 0; i < n - n / 2; ++i) { b.push_back(i + n / 2); } cout << a.size() * b.size() << endl; for (int i = 0; i < a... |
#include <bits/stdc++.h> using namespace std; char s1[100005], s2[100005]; int main() { int l1, l2, i; char tmp; while (~scanf( %s , s1)) { l1 = strlen(s1); for (i = l1 - 1, l2 = 0, tmp = 0; i >= 0; i--) { if (s1[i] >= tmp) { tmp = s1[i]; s2[l2++] = s1[i]; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int N = 2010; int n, m; long long f[N][N], g[N][N], h[N][N], o[N][N], p[N][N], ans; int main() { cin >> n >> m; memset(f, 0, sizeof(f)); memset(g, 0, sizeof(g)); memset(h, 0, sizeof(h)); memset(o, 0, sizeo... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 35; const long long N = 1e7 + 35; const long long mod = 3e18; const double eps = 1e-6; string a[MAX]; map<string, int> mm; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; for (int i = 0... |
#include <bits/stdc++.h> const int kMaxN = 1e7 + 5; int N; int phi[kMaxN]; long long prime[kMaxN], primeList[kMaxN], count[kMaxN]; int k = 0; void ComputePhi() { for (int i = 1; i <= N; i++) { phi[i] = i; } for (int i = 2; i <= N; i++) { if (phi[i] == i) { for (int j = i; j <... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.