func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int i = 0, j = 0, cs = 0, in; int n; cin >> n; vector<int> v; int sum = 0, s = 0; for (int i = 1; i < n; i++) { cout << ? << i << << n << n ; int x; cin >> x; if (i > 1) { v.push_back(sum - x ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5; int N, M, A[MAXN + 10], ans[MAXN + 10]; int main() { int i, j; scanf( %d%d , &N, &M); long long sum = 0; for (i = 1; i <= M; i++) scanf( %d , &A[i]), sum += A[i]; if (sum < N) return !printf( -1 ); int last = 987654321; ... |
#include <bits/stdc++.h> using namespace std; int n; double p[100008]; struct Tprogram { void open() { freopen( 1.in , r , stdin); freopen( 1.out , w , stdout); } void close() {} void init() { scanf( %d , &n); for (int i = 0; i <= n; i++) scanf( %lf , &p[i]); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int m; cin >> n >> m; vector<int> zahlen(n); for (int i = 0; i < n; i++) cin >> zahlen[i]; for (int i = 0; i < m; i++) { int l, r, x; cin >> l >> r >> x; l--; x--; r--; int tr = zahlen[x]; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using vi = vector<int>; using vll = vector<ll>; using vii = vector<ii>; const ll MOD = 998244353; const ll INF = 1e15 + 9; const int MAXN = 1000006; int n, m, a[MAXN], p[MAXN], b[MAXN]; int rev[MAXN]; ... |
#include <bits/stdc++.h> using namespace std; long long n, a, b, ans; vector<long long> v[100005]; vector<long long> res; long long cost(long long num) { res.clear(); long long sum = 0; long long need = num - v[0].size(); for (long long i = 1; i <= 100000; i++) { for (long long j = 0; j ... |
#include <bits/stdc++.h> using namespace std; template <typename Container> void print(Container& container) { auto Start = container.begin(), End = container.end(); while (Start != End) cout << *(Start++) << ; cout << n ; } const int N = 5e2 + 1; int dp[2][N][N], a[N]; inline void solve(... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; getline(cin, s1); getline(cin, s2); sort(s1.begin(), s1.end()); sort(s2.begin(), s2.end()); int j(0); for (int i = 0; i < s1.size(); i++) { while (s2[j] == ) j++; while (s1[i] == ) i++; if (... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n; cin >> n; vector<int> list; int maxx, ma; for (int i = 0; i < n; i++) { int u; cin >> u; list.push_back(u); } int u1, u2, u3; int... |
#include <bits/stdc++.h> using namespace std; long long a1[1000007], b1[1000007]; int main() { long long n, i, j, k = 0; cin >> n; for (i = 0; i < n; i++) { string st; cin >> st; long long si = st.size(), c1 = 0, c2 = 0; for (j = 0; j < si; j++) { if (st[j] == ( ) { ... |
#include <bits/stdc++.h> using namespace std; int DEBUG = 0; bool isss(vector<int> s1, vector<int> s2) { int si1, si2; si1 = s1.size(); si2 = s2.size(); for (int i = 0; i < si1; i++) { bool ttt = false; for (int j = 0; j < si2; j++) { if (s1[i] == s2[j]) { ttt = true;... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int arr[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) cin >> arr[i][j]; } bool chk[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) chk[i][j] = 1... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = (long long)1e5 + 10; vector<long long> G[MAXN]; pair<long long, long long> p; vector<long long> v; long long n, x, y, k, ans, sum, flag; string s; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x >> y; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, i, j, k; cin >> n; vector<string> v; vector<pair<int, string> > v1; for (i = 0; i < n; i++) { string s; cin >> s; v.push_back(s); v1.push_b... |
#include <bits/stdc++.h> using namespace std; const int maxn = 50 + 10; int a[maxn][maxn]; int dx[10] = {0, 2, 1, 0, -1, -2}; int dy[10] = {2, 0, 1, -2, -1, 0}; int sx, sy; struct Node { int x, y; }; int main() { int n; scanf( %d , &n); memset(a, -1, sizeof(a)); a[1][1] = 1; a[... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, sum = 0, x, count = 0; cin >> n; long long int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; sum = sum + a[i]; } sort(a, a + n); if (sum % 2 == 0) { cout << sum; return 0; } else { ... |
#include <bits/stdc++.h> using namespace std; bool m(int i, int j) { return (i % 10) > (j % 10); } int main() { int x, y; cin >> y >> x; vector<int> vi; int i = 0, j = 0; int k = 0; for (i = 0; i < y; i++) { cin >> j; k += (j % 10); vi.push_back(j); } sort(vi.begi... |
#include <bits/stdc++.h> using namespace std; const int T = 1 << 19; struct nod { int best = 0, best2 = 0; int pref0 = 0, pref1 = 0, suf0 = 0, suf1 = 0; int pref01 = 0, pref10 = 0, suf01 = 0, suf10 = 0; int cnt0 = 0, cnt1 = 0; }; void umax(int &a, int b) { a = max(a, b); } nod merge(nod a, n... |
#include <bits/stdc++.h> using namespace std; int main() { unsigned long long y = 0; unsigned int x = 0; int i; string s; cin >> s; if (s.length() > 19) printf( BigInteger n ); else if (s.length() > 10) { y = 0; for (i = 0; i < s.length(); i++) { if (y > 0) y *=... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, sum = 0, p = 0, res = 0; map<long long, long long> m; cin >> n; m[0] = 1; for (long long i = 1; i <= n; i++) { cin >> a; sum += a; p = max(p, m[sum]); res += i - p; m[sum] = i + 1; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int lo[N]; int n, r[N], lb[N], rb[N], i, j, k; struct ST { pair<int, int> f[20][N]; function<pair<int, int>(pair<int, int>, pair<int, int>)> uni; void ini(int* a) { for (int i = 1; i <= n * 3; ++i) f[0][i] = {a[i], i}; ... |
#include <bits/stdc++.h> using namespace std; void Fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int gcd(int a, int b) { if (b == 0) return a; gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } int main() { Fast(); string s; cin >> ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } const int inf = 0x7fffffff; const int maxn = 505; const long long mod = 1e9 + 7; long long dp[maxn][maxn]; int n; int main() { ios::sync_with_stdio(false); cin >> n; d... |
#include <bits/stdc++.h> using namespace std; vector<int> primes; int prime_marker[1000000]; void PrecomputePrimes() { const int MAX_PRIME = 1000000; for (int i = 2; i * i < MAX_PRIME; ++i) { for (int j = i; i * j < MAX_PRIME; ++j) { prime_marker[i * j] = 1; } } for (int i = ... |
#include <bits/stdc++.h> using namespace std; int main() { long int n, i, d; cin >> n; long int a[n], b[n], c[1000000]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { cin >> b[i]; c[b[i]] = i; } d = 0; for (i = 1; i < n; i++) { if (c[a[... |
#include <bits/stdc++.h> using namespace std; vector<long long> per, obs; long long n, k, p; bool check(long long t) { long long i = 0; for (long long j = 0; j <= obs.size() - 1; j++) { if (abs(per[i] - obs[j]) + abs(p - obs[j]) <= t) { i++; if (i == n) return 1; } } ... |
#include <cstdio> #include <cstring> #include <iostream> #include <vector> #include <cmath> #include <cstdlib> #include <ctime> #include <algorithm> #include <string> #include <map> #define ll long long #define ls id << 1 #define rs id << 1 | 1 #define mem(array, value, size, type) memset(arra... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; template <class T> inline void checkmin(T &a, T b) { if (a > b) a = b; } template <class T> inline void checkmax(T &a, T b) { if (a < b) a = b; } const int oo = 1 << 30; const double eps = 1e-7; const ... |
#include <bits/stdc++.h> int n, c; void p(int a) { if (a <= n) { c++; p(a * 10); p(a * 10 + 1); } } int main() { std::cin >> n; p(1); std::cout << c; } |
#include <bits/stdc++.h> using namespace std; const int N = 200100; const int M = 2 * N; const long long MOD1 = 98764321261LL; const long long MOD = 998244353LL; inline int lowbit(int x) { return x & (-x); } struct fenwick { long long a[N]; int n; void init(int n) { for (int i = 0; i <= ... |
#include <bits/stdc++.h> using namespace std; void prt(long x) { cerr << x; } void prt(long long x) { cerr << x; } void prt(unsigned x) { cerr << x; } void prt(unsigned long x) { cerr << x; } void prt(unsigned long long x) { cerr << x; } void prt(float x) { cerr << x; } void prt(double x) { cerr << x; }... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > ed[200005]; int n, m, k; unsigned long long Hash[200005]; unsigned long long H = 1e9 + 7; unsigned long long a[10][10]; unsigned long long sum; long long ans = 0; void dfs(int kk1, unsigned long long s) { if (kk1 == k) { i... |
#include <bits/stdc++.h> using namespace std; int compare(const void *a, const void *b) { int A = *((int *)a); int B = *((int *)b); return B - A; } int main() { long long a[200000], b, c = 0, d, f = 0, i, j, k, n, m, p = 0, q = 0, r, t = 0, l, mid = 0, sum = 0, x, y, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int arr[n + 2]; vector<int> s; s.push_back(n); for (int i = 2; i < n + 1; i++) cin >> arr[i]; arr[1] = 0; int k = n; while (k > 0) { s.push_back(arr[k]); k = arr[k]; } for (int i = s.s... |
#include <bits/stdc++.h> using namespace std; long long c[105], x[105][105], dp[105][105][105]; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n, m, k, i, j, l, p, ans = 10000000000000000; cin >> n >> m >> k; for (i = 1; i <= n; i++) cin >> c[i]; for... |
#include <bits/stdc++.h> using namespace std; const int MAXN = (int)1e6; vector<int> g[MAXN + 1]; pair<int, int> arr[MAXN + 1]; int k; void dfs(int nod, int par, int lvl) { arr[nod] = {2 * MAXN, 0}; for (auto it : g[nod]) { if (it != par) { dfs(it, nod, lvl + 1); if (lvl >= arr... |
#include <bits/stdc++.h> char s[101]; char t[10] = ><+-.,[] ; int c[10] = {8, 9, 10, 11, 12, 13, 14, 15}; void func() { int n = strlen(s), i, j, ans = 0; const int mod = 1000003; for (i = 0; i < n; i++) { for (j = 0; j < 8; j++) { if (t[j] == s[i]) { ans = (ans * 16 + c[j]) ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int i = 1; i <= t; i++) { int x1, x2, y1, y2; string arr[8]; for (int i = 0; i < 8; i++) cin >> arr[i]; bool check = 0; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { ... |
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; long long MAX = 9223372036854775807; int visited[1001][1001]; int main() { ios_base::sync_with_stdio(0); ; int n, m; cin >> n >> m; int a[n][m], l[n][m], r[n][m], u[n][m], d[n][m]; for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { int n, m, k; cin >> n >> m >> k; vector<int> p(n); for (int i = 0; i < n; ++i) cin >> p[i]; vector<int> s(n); for (int i = 0; i < n; ++i) cin >> s[i]; vector<int> c(k); for (int i = 0; i < k; ++i) cin >> c[i]; vector<... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1010; const double oo = 1E7, eps = 1E-7; struct point { double x, y; } P[maxn]; int n; double ansl, ansr; point operator+(point a, point b) { return (point){a.x + b.x, a.y + b.y}; } point operator-(point a, point b) { return (point){a.... |
#include <bits/stdc++.h> using namespace std; long long int a[100001] = {0}; long long int d[100001] = {0}; long long int vis[100001] = {0}; long long int cons[100001] = {0}; vector<long long int> vec[100001]; void dfs(long long int x, long long int p) { vis[x] = 1; if (a[x] == 1) { if (a[p]... |
#include <bits/stdc++.h> using namespace std; inline int read() { int res = 0; int neg; while (true) { char ch = getchar(); if (ch >= 0 && ch <= 9 || ch == - ) { if (ch == - ) neg = -1; else neg = 1, res = ch - 0 ; break; } } w... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long read() { long long x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int a[100005]; cin >> n; int fa = 1; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] != i) { fa = 0; } } if (fa == 1) { cout << 0 ; } else { int ji = n - 1; while (a[ji... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9, MOD = 1e9 + 7, N = 1e5 + 1, M = 20; void setIO(string name = ) { ios::sync_with_stdio(false); cin.tie(0); if (name.size()) { freopen((name + .in ).c_str(), r , stdin); freopen((name + .out ).c_str(), w , stdout); ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:65777216 ) using namespace std; char s[1111][1111]; int n, m; int best; int now; int v[1111][1111]; vector<pair<int, int> > c; bool u[1111][1111]; void dfs(int x, int y) { if (u[x][y]) return; u[x][y] = true; for (int dx(-1); dx < ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string l, r; cin >> l >> r; vector<stack<int>> l_array; vector<stack<int>> r_array; for (int i = 0; i < 27; i++) { stack<int> buf; l_array.push_back(buf); r_array.push_back(buf); } for (... |
#include <bits/stdc++.h> using namespace std; long long n, m, z, x, c, sum, a[101][101], us[101][101]; char cc, stl; set<long long> s; void dfs(long long i, long long j) { if (a[i][j] == 0 || us[i][j] == 1 || i > n || j > m || i < 1 || j < 1) return; us[i][j] = 1; if (s.count(a[i][j]) == 0) sum++,... |
#include <bits/stdc++.h> using namespace std; const int okX[] = {0, 0, 0, 1, 1, 2, 2, 2}; const int okY[] = {0, 1, 2, 0, 2, 0, 1, 2}; const int n = 8; void normalize(int a[n]) { vector<int> v(a, a + n); sort(v.begin(), v.end()); map<int, int> m; for (int i = 0; i < v.size(); ++i) if (!m.... |
#include <bits/stdc++.h> using namespace std; bool is_prime[100000]; void gen_is_primes(int n); void gen_prime_groups(int n, vector<bool>& to_match, list<int>& candidate_primes, list<pair<int, int> >& groups); void gen_prime_groups(int n, int p, vector<bool>& to... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) using namespace std; long long MOD9 = 998244353; long long MOD = 1000000007; double eps = 1e-12; void solve() { int n; cin >> n; ... |
#include <bits/stdc++.h> using namespace std; int n, d1, d2; bool d[400001]; int a[200001]; int nextprime(int x) { for (int i = x + 1; i <= 2 * n; ++i) if (d[i]) return i; return 2 * n + 1000000; } int main() { ios_base::sync_with_stdio(0); cin >> n; int x; for (int i = 1; i ... |
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = (1000000007LL)) { long long ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } long long gcd(long long a, long lon... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 10; const int MAXM = 100 + 10; const int MOD = 1000000007; const int INF = 1000000001; int a[20][120]; int l[20], r[20]; int f[20], g[20]; bool w[20]; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m... |
#include <bits/stdc++.h> using namespace std; int main() { short n; int n1, n2; bool state = false; char handle[11]; cin >> n; for (short i = 0; i < n; i++) { cin >> handle; cin >> n1; cin >> n2; if (n1 >= 2400 && n2 > n1) state = true; } if (state) cout... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000 + 7; const double EPS = 1e-9; int bit_count(int first) { return first == 0 ? 0 : 1 + bit_count(first & (first - 1)); } inline int low_bit(int first) { return first & -first; } inline int sign(double first) { return fi... |
#include <bits/stdc++.h> using namespace std; int graph[27]; int grapht[27]; vector<bool> used(27, false); vector<bool> opened(27, false); string result; void dfs(int node) { used[node] = true; opened[node] = true; if (graph[node] == -1) { result += (node + a ); opened[node] = fal... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; const ll MOD = 1e9 + 7, N = 1e5 + 10; void test() { ll n; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } vector<ll> ans; sort(a.begin(), a.end()); ll l = ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int N = 1e4 + 10; int main() { string str; cin >> str; cout << str[0]; int flag = 0; for (int i = 1; i < str.length(); i++) { if (!(i + 2 >= str.length() || flag == 1)) { if (str.substr(i, 2) == at ) ... |
#include<bits/stdc++.h> #define mod 998244353 using namespace std; int n, A[2], f[200010], pw2; int powmod(int x, int y){ int ans = 1; for(;y;y >>= 1, x = 1ll * x * x % mod) if(y & 1)ans = 1ll * x * ans % mod; return ans; } int main(){ scanf( %d , &n); A[0] = 1; A[1] = 0; pw2 = powm... |
#include <bits/stdc++.h> using namespace std; const int N = 100; int gi() { int w = 0; bool q = 1; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) q = 0, c = getchar(); while (c >= 0 && c <= 9 ) w = w * 10 + c - 0 , c = getchar(); return q ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (~scanf( %d , &n)) { printf( %d n , n); for (int i = 1; i <= n; i++) printf( 1 ); printf( n ); } return 0; } |
#include <bits/stdc++.h> using namespace std; bool compare(const pair<long long, long long> &a, const pair<long long, long long> &b) { return a.second > b.second; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); long long i, j; string s; cin >> s; ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n; cin >> n; long long ar[n]; for (long long i = 0; i < n; i++) cin >> ar[i]; sort(ar, ar + n); long long dist = 0; for (long long i = 0; i < n; i++) dist += (long long)abs(ar[i] - (i + 1)); cout << dist << n ; ... |
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 100000; long long n; struct ab { long long a; long long b; bool operator < (const struct ab &c) const { return b < c.b; } } aa[N + 5]; long long sus[N + 5];... |
#include <bits/stdc++.h> using namespace std; const int iinf = 1e9 + 7; const long long linf = 1ll << 60; const double dinf = 1e10; template <typename T> inline void scf(T &x) { bool f = 0; x = 0; char c = getchar(); while ((c < 0 || c > 9 ) && c != - ) c = getchar(); if (c == - ) {... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); long long int t; cin >> t; while (t--) { int n, m; cin >> n >> m; vector<int> v1(n), v2(m); vector<int> v; for (auto &x : v1) cin >> x; for (auto &x : v2) cin >... |
#include <bits/stdc++.h> using namespace std; static int LOCAL = 0; const long long int mod = 1000000007ll; const long long int MOD = 1000000009ll; const long long int INF = LLONG_MAX / 10; const int inf = INT_MAX / 10; long long int powermod(long long int _a, long long int _b, lo... |
/* Author: EndlessK * Time: 2021-05-06 20:40:25 **/ #include<bits/stdc++.h> #define maxn 100010 #define pb push_back #define ll long long #define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; int main() { fast; int t; cin>>t; map<int,int> mp; ... |
#include <bits/stdc++.h> using namespace std; bool way[5003][5003]; int dis[5003], counter; vector<pair<int, int> > edge[5003], child[5003]; priority_queue<pair<int, int> > pq[5003]; void cari(int pos) { int j, sz; sz = edge[pos].size(); for (j = 0; j < sz; ++j) { if (way[pos][edge[pos][j]... |
#include <bits/stdc++.h> using namespace std; long long GCD(long long a, long long b) { if (b == 0) return a; return (a % b == 0 ? b : GCD(b, a % b)); } long long POW(long long base, long long exp) { long long val; val = 1; while (exp > 0) { if (exp % 2 == 1) { val = (val * bas... |
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; const int maxn = 2e5 + 10, mod = 1e9 + 7, inf = 0x3f3f3f3f; int n, a[maxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); int _t; cin >> _t; while (_t--) { cin >> n; for (int i = 1; i <= n; i++) cin >> a[... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000ll * 1000 * 1000 + 7; int main() { vector<string> name; string str; int n, m; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> str; name.push_back(str); } long long ans = 1ll; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; int a[26]; int A[26]; string s, t; int x1, x2; char c; int main() { cin >> s >> t; for (int i = 0; i < t.size(); i++) { c = t[i]; if (c > 96) a[c - 97]++; else A[c - 65]++; } for (int i = 0; i < s.size(); i++) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; int T, n, m, sum, du[maxn], K; vector<pair<int, int> > p[maxn]; struct node { int x, y; long long val; bool operator<(const node i) const { return val < i.val; } } a[maxn]; queue<int> q2; int b[maxn], cnt; long lon... |
#include <bits/stdc++.h> using namespace std; struct online_hull { map<int, int> points; long long area; inline online_hull() { points.clear(); area = 0; } inline map<int, int>::iterator prev(map<int, int>::iterator it) { return it == points.begin() ? it : --it; } inlin... |
#include <bits/stdc++.h> using namespace std; map<string, int> id; inline int getID(string s) { if (id.find(s) == id.end()) { int sz = id.size(); id[s] = sz; } return id[s]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, a, b, k, f; cin >> n >> a >>... |
#include <bits/stdc++.h> using namespace std; inline int two(int n) { return 1 << n; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b) { n &= ~two(b); } inline int last_bit(int n) { return n & (-n); } template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>... |
#include <bits/stdc++.h> using namespace std; const int N = 2005; const long long inf = 0x3f3f3f3f3f3f3f3f; const int mod = 998244353; vector<int> ga[N], gb[N]; int n, a, b; int ca[N], cb[N]; int dp[N][N][2]; int ha[N], hb[N]; int lfta[N], rgta[N], lftb[N], rgtb[N]; int cnta, cntb; int faa[N][11... |
#include <bits/stdc++.h> using namespace std; struct th { int id, num; th() { id = 0, num = 0; } th(int a, int b) { id = a, num = b; } bool operator<(const th &a) const { if (num != a.num) return num < a.num; return id < a.id; } }; set<th> x; vector<int> ns[1000005]; int n, m... |
#include <bits/stdc++.h> using namespace std; int n, k, m; int arr[50]; int sub[50]; int result = 0; int task_tot_time = 0; void take(int score, int t) { if (0 >= t) return; int tt = t; int ss = score; for (decltype(0) i = 0; i < k; i++) { int su = sub[i]; while (su > 0) { ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 110; const int MOD = 1e9 + 7; long long n, k, dp[MAXN][MAXN][MAXN], local[MAXN][MAXN]; vector<int> adj[MAXN]; void add(long long& v, long long u) { v = (v + u) % MOD; } void dfs(int v, int par = -1) { dp[v][1][0] = dp[v][0][1] = 1; for... |
#include <bits/stdc++.h> using namespace std; long long arr[200200]; int main() { string a, b; cin >> a >> b; long long x = 0, y = 0; for (int i = 0; i <= b.size() - a.size(); i++) x += (b[i] - 0 ); for (int i = 0; i < a.size(); i++) { y += (a[i] == 0 ) ? x : (b.size() - a.size() + 1) ... |
#include <bits/stdc++.h> using namespace std; void Heap(int A[], int n, int l, int r) { int x, i, j; x = A[l]; i = l; while (1) { j = 2 * i; if (j > r) break; if (j < r && A[j + 1] >= A[j]) j++; if (x >= A[j]) break; A[i] = A[j]; i = j; } A[i] = x; } v... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long dot(complex<long long> c1, complex<long long> c2) { return imag(c1 * conj(c2)); } double dot(complex<double> c1, complex<double> c2) { return imag(c... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 47 == 0 || n % 744 == 0 || n % 4 == 0 || n % 7 == 0 || n % 44 == 0 || n % 444 == 0 || n % 777 == 0 || n % 74 == 0 || n % 447 == 0 || n % 474 == 0 || n % 477 == 0) { cout << YES ; } else { ... |
#include <bits/stdc++.h> using namespace std; const int N = 45; int nd, nm, G[N][N]; int cntClique, pts[N], res[N], cnt[N]; map<string, int> H; int n; vector<int> v; bool dfs(int pos, int num) { for (int i = pos + 1; i <= n; ++i) { if (cnt[i] + num <= cntClique) return false; if (G[pos][... |
#include <bits/stdc++.h> using namespace std; void _print(long long int t) { cerr << t; } void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long lon... |
#include <bits/stdc++.h> using namespace std; const int M = 100001; int n, m, x, y, b, r, p, l, ri; long long ans; vector<int> B, R, P; int bef(int x, int c) { if (!c) return (lower_bound(B.begin(), B.end(), x) - B.begin() - 1); return (lower_bound(R.begin(), R.end(), x) - R.begin() - 1); } int ... |
#include <bits/stdc++.h> using namespace std; const int INF = 2 * int(1e9); const long long INFll = 1ll * int(1e9) * int(1e9); const int MOD = 1000000007; template <typename T> ostream& operator<<(ostream& out, pair<T, T>& a) { out << a.first << << a.second; return out; } template <typename ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; void dir(char& smb, int& x, int& y) { if (smb == L ) x--; else if (smb == R ) x++; else if (smb == U ) y++; else y--; } void solve() { int n; cin >> n; string s; cin >> s; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x1, y1, x2, y2; cin >> n >> m >> x1 >> y1 >> x2 >> y2; int x = abs(x1 - x2), y = abs(y1 - y2); if (x <= 4 && y <= 4 && x + y <= 6) cout << First << endl; else cout << Second << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; template <typename T> void print(vector<T> v) { for (T &i : v) cout << i << ; cout << n ; } void solve() { unsigned long long int n, x; cin >> n >> x; vector<unsigned long long int> v(n); for (unsigned long l... |
#include <bits/stdc++.h> int main() { long long n, m; int dig[10]; char cn[12], cm[12]; while (scanf( %s n%s , &cn, &cm) != EOF) { if (strlen(cn) != strlen(cm)) { printf( WRONG_ANSWER n ); continue; } n = atol(cn); m = atol(cm); for (int i = 0; i < 10; i++... |
#include <bits/stdc++.h> using namespace std; void input(long &n) { scanf( %ld , &n); } void output(long n) { printf( %ld , n); } void input(long &n, long a[]) { input(n); for (long i = 1; i <= n; i++) input(a[i]); } bool test(long n, long a[], long id1, long id2, long tid, vector<long> &st1, ... |
#include <bits/stdc++.h> using namespace std; int a1, a2; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> a1 >> a2; int res = 0; if (a1 == 1 && a2 == 1) { cout << 0 << n ; return 0; } while (a1 > 0 && a2 > 0) { if (a1 < a2) ++a1, a2 -= 2... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b = 1, c = 2, o = 1, j, k; cin >> a; int p = a / 2; for (k = 0; k < a; k++) { for (j = 0; j < p; j++) { cout << c << ; c += 2; } for (j = 0; j < a - p * 2; j++) { cout << b << ; ... |
#include <bits/stdc++.h> using namespace std; using namespace std; int ar[30005]; int dp1[30005][205][2], dp2[30005][205][2][5]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 1; i <= n; i++) scanf( %d , &ar[i]), ar[i] += ar[i - 1]; fill(dp1[0][0], dp1[n][k] + 2, -1000000000); ... |
#include <bits/stdc++.h> using namespace std; void aayush() { ios_base::sync_with_stdio(false); cin.tie(NULL); } int main() { aayush(); long long int t; cin >> t; while (t--) { long long int n; cin >> n; if (n % 4 == 0) { cout << YES << endl; } else { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.