func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 300000; long long abss(long long a) { if (a < 0) { a = -a; } return a; } long long n; long long xx; long long aa[N + 5] = {0}, su[N + 5]; long long mm[105] = {0}; int main() { mm[0] = 1; scanf( %lld , &n); long l... |
#include <bits/stdc++.h> int u[400000]; int v[400000]; int s[400000]; int n; int parent[200000]; int f[200000]; int t[200001]; bool b[200000]; int tt[200000]; bool func(int x, int y) { return u[x] < u[y]; } int main() { scanf( %d , &n); for (int i = 0; i < n - 1; i++) { scanf( %d%d ,... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,unroll-loops ) #pragma GCC target( avx,avx2,fma ) using namespace std; const long long sz = 3e3 + 10, mod = 998244353; char s[sz], t[sz]; long long dp[sz][sz]; long long solve(long long l, long long r) { if (l > r) return 1; long long &ret = dp[... |
#include <bits/stdc++.h> int main() { int n; scanf( %d , &n); printf( %d 0 0 , n); } |
#include <bits/stdc++.h> using namespace std; int n, k, d, t; int a[1000005], b[1000005], c[1000005]; char ch[1000005], ans[1000005]; void mul(int* a, int* b) { for (int i = 0; i < n; ++i) { c[i] = b[a[i]]; } for (int i = 0; i < n; ++i) { a[i] = c[i]; } } int main() { scanf... |
#include <bits/stdc++.h> using namespace std; long long M[110000 * 4]; long long lazy[110000 * 4]; void down(int x) { if (lazy[x] != -1) { M[x * 2] = max(M[x * 2], lazy[x]); M[x * 2 + 1] = max(M[x * 2 + 1], lazy[x]); lazy[x * 2] = max(lazy[x], lazy[x * 2]); lazy[x * 2 + 1] = max(lazy... |
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T1, class T2> inline void gmax(T1 &a, T2 b) { if (b > a) a = b; } template <class T1, class T2> inline void gmin(T1 &a, T2 b) ... |
#include <bits/stdc++.h> using namespace std; vector<int> vv[3001]; int graf[3001][3001]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int f, t; cin >> f >> t; vv[f].push_back(t); graf[f][t] = 1; } long long ans(0); for (int a = 1; a <= n; a... |
#include <bits/stdc++.h> using namespace std; const long long INF = LLONG_MAX; const long long base = 1e9; const double PI = acos(-1); const long long MOD = 1e9 + 7; const long long N = 1e5 + 10; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin >> n... |
#include <bits/stdc++.h> using namespace std; const int N = 755, M = 10000005; char s[M]; bool e[N][N]; int n; struct ACAutomaton { int trie[M][2], id[M], idx, pos[M], fa[M]; void ins(char *s, int t) { int cur = 0, l = strlen(s + 1); for (int i = 1; i <= l; i++) { if (!trie[cur][... |
#include <bits/stdc++.h> int n, ans, lst[5010][2]; int comp(const void *a, const void *b) { int x = ((int *)a)[0] - ((int *)b)[0]; if (x) return x; return ((int *)a)[1] - ((int *)b)[1]; } int main() { int i; scanf( %d , &n); for (i = 1; i <= n; i++) scanf( %d%d , &lst[i][0], &lst[i][1]);... |
#include <bits/stdc++.h> int ATTENTION() { http: return 0; } using namespace std; const int iinf = 0x7fffffff; const long long linf = ~(1LL << 63); template <typename T> inline T gcd(T a, T b) { if (a < 0) return gcd(-a, b); if (b < 0) return gcd(a, -b); if (a < b) return gcd(b, a); ... |
#include <bits/stdc++.h> using namespace std; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; const int mod = (int)1e9 + 7; long long INF64 = 3e18; void smxl(long long &a, long long b) { if (a < b) a = b; } void smnl(long long &a, long long b) { if (a > b) a = b; } void adsl(long long ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; long long int i; while (t--) { string a, b, c; cin >> a >> b >> c; long long int n = a.length(), f = 0; for (i = 0; i < n; i++) { if (a[i] != c[i] && b[i] != c[i]) { cout <... |
#include <bits/stdc++.h> using namespace std; long long a[200005]; int main() { long long k, sum, subs, di; int i, n, rel; cin >> n >> k; int n1 = n; for (i = 1; i <= n; i++) cin >> a[i]; i = 1; sum = 0; rel = 1; while (1) { if (i > n1) break; subs = (n - rel) * a[i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 500 + 10; const int INF = 0x3f3f3f3f; const int mod = 1000000007; int n, m; int a[maxn][maxn], b[maxn][maxn]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; ... |
#include <bits/stdc++.h> long long INF = (long long)1e18; struct node { int n; double rat; }; bool operator<(const node& n1, const node& n2) { return n1.rat > n2.rat; } std::vector<int> edge[100010]; int ch[100010], ne[100010]; int main() { int x, a, b, k, n, m, q, t, num, in = 0, to, i; d... |
#include <bits/stdc++.h> using namespace std; int a[404040]; inline void solve() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , a + i); int N = 0; for (int i = 1, j = 1; i <= n; i = j) { for (; j <= n && a[i] == a[j]; j++) ; a[++N] = j - i; } int... |
#include <bits/stdc++.h> using namespace std; long long pw(int x, int y, int z) { if (y == 0) return 1 % z; long long a = pw(x, y / 2, z); if (y % 2 == 0) return (a * a) % z; else return (((a * a) % z) * x % z) % z; } int main() { ios_base::sync_with_stdio(false); cin.tie(NUL... |
#include <bits/stdc++.h> using namespace std; struct info { long long tp, ii, jj, qn, nxt, prv; } d; long long cn[1002][1002], n, m; long long rev[1003], cnt[1003], tot, an[100003]; long long vis[100002]; long long par[100002]; vector<info> v[100005]; long long go(long long nd, long long pr, long ... |
#include <bits/stdc++.h> using namespace std; vector<long long int> v, primev; int prime[2750150]; map<long long int, long long int> mp; void FindPrime() { long long int n = 2750140; for (long long int i = 4; i <= n; i += 2) { prime[i] = true; } prime[1] = true; for (long long int i ... |
#include <bits/stdc++.h> const int N = 1e6; const int M = 2e5 + 10; const int mod = 1e9 + 7; long long n, a[M], cnt[N], cnt2[N], sol[N]; long long brzo_stepenovanje(long long x, long long k) { if (k == 0) return 1; if (k == 1) return x; if (k % 2) return (x * brzo_stepenovanje((x * x) % mod,... |
#include <bits/stdc++.h> using namespace std; struct node { string name; vector<struct node *> sub; }; typedef struct node *NODE; class cf56c { public: int ans = 0; void solve(std::istream &in, std::ostream &out) { string s; int n; in >> s; n = s.length(); stac... |
#include <bits/stdc++.h> int main() { int a, b, c, d; scanf( %d%d%d%d , &a, &b, &c, &d); int ans = 0; if (a == b) { ans++; } else if (b == c) { ans++; } else if (b == d) { ans++; } if (a == c) { ans++; } else if (c == d) { ans++; } if (a == d) ... |
#include <bits/stdc++.h> using namespace std; struct Node { int l, r, x, id; } a[1000005]; bool operator<(const Node& t1, const Node& t2) { if (t1.l != t2.l) return t1.l < t2.l; if (t1.x != t2.x) return t1.x > t2.x; if (t1.r != t2.r) return t1.l < t2.r; return t1.x > t2.x; } struct Node1... |
#include <bits/stdc++.h> using namespace std; int main() { int ntests; cin >> ntests; while (ntests--) { int n, k, a, b; cin >> k >> n >> a >> b; if (k <= 1ll * n * b) cout << -1 << endl; else { long long x = (k - 1ll * n * b - 1) / (a - b); if (x > n) x =... |
#include <bits/stdc++.h> using namespace std; long long tree[100002] = {0}; long long findcf(long long ind) { long long sum = 0; while (ind > 0) { sum += tree[ind]; ind -= (ind & (-ind)); } return sum; } void update(long long ind, long long val) { while (ind <= 100000) { ... |
#include <bits/stdc++.h> using namespace std; struct LINE { int start; int end; }; int ans = 0; vector<int> res; string shift(string s, int p1, int p2) { char t; for (int f = p2; f > p1; f--) { ans++; res.push_back(f); t = s[f]; s[f] = s[f - 1]; s[f - 1] = t; ... |
#include <bits/stdc++.h> using namespace std; int i; char s[100005]; int main() { scanf( %s , s); int l = strlen(s); for (i = 0; i < l; i++) { if (s[i] == s[l - 1 - i]) continue; return 0 * printf( NO n ); } for (i = 0; i < l; i++) { if (s[i] == A || s[i] == H || s[i] =... |
#include <bits/stdc++.h> using namespace std; int n; char in[100005]; int main() { scanf( %d %s , &n, in); for (int i = 1; i < n; i++) { if (in[i] == in[i - 1]) { for (int j = i;; j++) { in[j] = 1 - (in[j] - 0 ) + 0 ; if (in[j + 1] != in[j]) break; } b... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7, maxn = 1e6 + 6; int n, m, k, x, res = 1, fact[maxn]; map<vector<int>, int> f; vector<int> a[maxn]; int main() { fact[0] = 1; for (int i = 1; i < maxn; ++i) fact[i] = 1LL * fact[i - 1] * i % mod; scanf( %d%d , &n, &m); for... |
#include <bits/stdc++.h> using namespace std; int main() { int t, a[100], b[100], i; cin >> t; string s1, s2; while (t--) { set<char> track; string s3 = , s4; int flag = 0; cin >> s1 >> s2; if (s1.size() > s2.size()) { cout << NO << endl; continue; ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5, M = 5e5 + 5; bool vis[N]; int q[N], tot, fa[N]; int n, m, k, head[N], ne[M << 1], to[M << 1], cnt, d[N]; inline int read() { int x, f = 1; char ch; while (!(isdigit(ch = getchar()))) ch == - ? f = -1 : f; x = ch ^ 48; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int INF = 2e9; const int MOD = 1e9 + 7; int main() { vector<int> RES; string S = ; cin >> S; int N = S.size(), last = -1, depth = 0; for (int i = 0; i < N; i++) { if (S[i] == ( ) depth++; e... |
#include <bits/stdc++.h> void swap(long double& a, long double& b) { long double tmp = a; a = b, b = tmp; } long double solve(long double d, long double r, long double R) { const long double EPS = 1e-9L; if (d + EPS >= r + R) return 0; if (r > R) swap(r, R); if (R + EPS >= d + r) return ac... |
#include <bits/stdc++.h> using namespace std; const long long int inf = 1000000000; const long long int mod = 1000000000 + 7; inline void IO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline int dcmp(long double x) { return x < -1e-12 ? -1 : (x > 1e-12); } template <class T> ... |
#include <bits/stdc++.h> using namespace std; int main() { long long d, k, tc, tf, tr, res = 100 * 100 * 100 * 100LL; scanf( %lld , &d); ; scanf( %lld , &k); ; scanf( %lld , &tc); ; scanf( %lld , &tf); ; scanf( %lld , &tr); ; if (k >= d) return 0 * printf( %lld , d * ... |
#include <bits/stdc++.h> using namespace std; int f[100001], d[40], sor[100001]; int n, kq; bool solve(int a, int b, int &x, int &y) { if (a % 2 != b % 2) return false; y = (a + b) / 2; x = (a - b) / 2; return true; } int main() { scanf( %d , &n); kq = -1; for (int i = 3; i < n +... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const long long mod = 998244353; int mp[maxn], a[maxn]; char s[maxn]; int main() { int T; scanf( %d , &T); while (T--) { int n, x; scanf( %d , &n); scanf( %d , &x); scanf( %s , s + 1); int mn = ... |
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pi; const int maxn=1e5+7; double dp[maxn][10]; int pre[maxn][10]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n,d; cin>>n>>d; vector<int> a(n+1); for(int i=0;i<maxn;i++) for(int j=0;j... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } inline long long read() { long long x = 0; char ch = getcha... |
#include<bits/stdc++.h> using namespace std; int check(vector<long long> a) { for (int i = 0; i + 1 < a.size(); i++) { if (a[i] > a[i + 1]) { return 0; } a[i + 1] -= a[i]; a[i] = 0; } if (a.back() == 0) return 1; return 0; } void solve() { int n; cin >> n; vec... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 7; set<int> a[N], b[N]; int maxa[N << 2], minb[N << 2]; int badv = 0; bool bad(int v, int l, int r) { if (l == r) { return a[l].size() && b[l].size() && *a[l].rbegin() >= *b[l].begin(); } else { return maxa[v * 2 + 2] >= m... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; long long ans = 0; for (int i = 1; i < min(b, c); i++) { ans += a; a++; } ans *= 2; for (int i = min(b, c); i <= max(b, c); i++) { ans += a; } cout << ans << endl; re... |
#include <bits/stdc++.h> using namespace std; const long long int N = 1e5; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int tc = 1; for (long long int T = 1; T <= tc; T++) { long long int n; cin >> n; string s; cin >> s; lo... |
#include <bits/stdc++.h> using namespace std; int bs(vector<int>& a, int que) { auto it = lower_bound(a.begin(), a.end(), que); if (*it == que) { return it - a.begin(); } return -1; } bool isprime(int x) { if (x == 2) return true; if (x < 2) return false; for (int i = 2; i * i ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, k; cin >> n >> k; set<long long int> s; map<long long int, long long int> mp; long long int x; for (long long int i = 0; i < n; i++) { cin >> x; s.... |
#include <bits/stdc++.h> using namespace std; char a[2000][1000]; int main() { int n, s; cin >> n; int nowx = 0, nowy = 1000; int miny = 1000, maxy = 1000; for (int i = 0; i < n; i++) { cin >> s; for (int j = nowx; j < nowx + s; j++) if (i % 2 == 0) a[nowy][j] = ... |
#include <bits/stdc++.h> using namespace std; int main() { priority_queue<pair<unsigned long long int, int> > matches; unsigned long long int n; int m; unsigned long long int a; int b; unsigned long long int max = 0; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; ... |
#include <bits/stdc++.h> using namespace std; int n; int v[2][1000000 + 10]; void solve(int n, int p) { if (n == 0) { v[p][0] = 0; return; } if (!(n & (n + 1))) { for (int i = 0; i <= n; ++i) { v[p][i] = n - i; } } else { int two = 1; while (two * 2 < ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); int n; scanf( %d , &n); vector<int> game(n + 1); game[0] = game[1] = game[2] = 0; vector<int> res(n + 1, -1); for (int i = 3; i <= n; i++) { int ok[300001]; memset(ok, 0, sizeof(0)); ... |
#include <bits/stdc++.h> using namespace std; int A[100005], P[100005]; int other_end[100005]; long long ans[100005], seg[100005]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) scanf( %d , &A[i]); for (int i = 1; i <= n; ++i) scanf( %d , &P[i]); long long res = 0; for (int... |
#include <bits/stdc++.h> #pragma comment(linker, ”/ STACK : 38777216“ using namespace std; const int N = 100005; const int inf = 1000 * 1000 * 1000; const int mod = 1000 * 1000 * 1000 + 7; string s; int a, b, c, d, t; int main() { cin >> t >> s; if (t % 4 != 0) { cout << === << endl; ... |
#include <bits/stdc++.h> using namespace std; struct node { int degree; int xorsum; }; struct Edge { int src, des; }; struct node virtex[100000]; vector<struct Edge> edge; vector<struct Edge>::iterator it; queue<int> que; int main() { struct Edge temp; int n, d, s, i, src, des; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1000010; int cnt[N]; int a, b, n; void genPrime() { for (int i = 2; i < N; ++i) cnt[i] = 1; for (int i = 2; i <= 1000; ++i) if (cnt[i]) for (int j = i * i; j < N; cnt[j] = 0, j += i) ; for (int i = 1; i < N; ++i) c... |
#include <bits/stdc++.h> using namespace std; const int N = 20; int n; int a[N]; int b[N]; vector<string> ans; int get(int s, int e) { int res = 0; for (int i = s; i < e; ++i) { res = res * 10 + b[i]; } return res; } string getstr(int x, int y, int z, int l) { string s = ; ... |
#include <bits/stdc++.h> using namespace std; const int N = 5e3 + 9; const int M = 5e4 + 9; long long read() { long long x = 0, op = 1; char c = getchar(); while (!isdigit(c)) { if (c == - ) op = -1; c = getchar(); } while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); ret... |
#include <bits/stdc++.h> using namespace std; const int fx[8] = {0, -1, -1, -1, 0, 1, 1, 1}; const int fy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const int maxn = 310; int vis[maxn][maxn][8][30]; int v[maxn][maxn]; int step[40]; queue<pair<int, int> > q; pair<int, int> mkstate(int x, int y, int d, int t) { ... |
#include <bits/stdc++.h> using namespace std; void exitall() { cout << -1; exit(0); } int main() { ios::sync_with_stdio(false); int n; long long d; cin >> n >> d; vector<long long> v(n); for (int i = 0; i < n; ++i) { cin >> v[i]; } long long mx = 0; int ans = 0;... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int> > v; for (int i = (int)0; i < (int)(n); i++) { int second = 0; int a; for (int j = (int)0; j < (int)(4); j++) { cin >> a; second += a; } v.push_back(make_pa... |
#include <bits/stdc++.h> using namespace std; char s[10000]; int main() { int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> s; bool t = 0; for (int i = 1; s[i]; ++i) { if (!isdigit(s[i]) && isdigit(s[i - 1])) { t = 1; break; } } if... |
#include <bits/stdc++.h> using namespace std; const int MAX = 5000; vector<int> edge[MAX + 5]; int p[MAX + 5], c[MAX + 5], lft[MAX + 5], used[MAX + 5], vis[MAX + 5], cp[MAX + 5], ans[MAX + 5]; int n, m, d, mex, dfn; bool dfs(int x) { for (int i = 0; i < edge[x].size(); i++) { int j = edge[x]... |
#include <bits/stdc++.h> using namespace std; int main() { string s[] = { zero , one , two , three , four , five , six , seven , eight , nine , ten , eleven , twelve , thirteen , fourteen , fifteen , sixt... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e4, SQN = 3e2; map<int, int> dst_idx, idx_dst; int n, d, dp[MAXN + 3][SQN + 3], a[MAXN + 3], max_idx; int fazdp(int idx, int li) { if (dp[idx][li] != -1) return dp[idx][li]; int di = idx_dst[li]; int ret = 0; for (int i = -1; i <=... |
#include <bits/stdc++.h> using namespace std; long long int d[400001], num[400001]; int decr[400001], inc[400001]; priority_queue<pair<long long int, int>, vector<pair<long long int, int> >, greater<pair<long long int, int> > > H1; priority_queue<pair<long long int, int> > H2; int mai... |
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int a; std::cin >> a; int d[6]; for (int i = 0; i < 6; ++i) d[i] = a >> i & 1; std::cout << (d[0] << 4 | d[1] << 1 | d[2] << 3 | d[3] << 2 | d[4] | d[5] << 5) << ... |
#include <bits/stdc++.h> using namespace std; int main() { int t, a, b, c, d, ans1, ans2, ans3; cin >> t; while (t--) { ans1 = 0; ans2 = 0; ans3 = 0; cin >> a >> b >> c >> d; ans1 = a / b; ans2 = (c - 1) / b; ans3 = d / b; ans1 -= ans3; ans1 += ans2;... |
#include <bits/stdc++.h> using namespace std; char a[50][50]; int main() { int n, m; cin >> n >> m; for (int j = 0; j < m; j++) a[0][j] = # ; for (int j = 0; j < m - 1; j++) a[1][j] = . ; a[1][m - 1] = # ; for (int i = 2; i < n; i++) { for (int j = 0; j < m; j++) { if (i %... |
#include <bits/stdc++.h> using namespace std; int main() { int n, number; cin >> n; int arr[n + 1]; bool marcado[n + 1]; memset(marcado, 0, sizeof marcado); for (int i = 1; i <= n; i++) { cin >> number; if (!marcado[number] && number <= n) { marcado[number] = true; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, tmp, k, gbd; cin >> n; k = 1; while (k < 10) { tmp = pow(2, k - 1) * (pow(2, k) - 1); if (n % tmp == 0) gbd = tmp; k++; } cout << gbd; } |
#include <bits/stdc++.h> using namespace std; int s, a, n; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; while (n--) cin >> a, s += abs(a); cout << s; return 0; } |
#include <bits/stdc++.h> using namespace std; int n, ans = -1000001; int main() { cin >> n; float a; for (int i = 1; i <= n; i++) { cin >> a; if (floor(sqrt(a)) != sqrt(a)) { ans = max(ans, (int)a); } } cout << ans << n ; 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, i, j, s = 0, min1 = INT_MAX, min2 = INT_MIN, od = 0; cin >> n; long long int a[n + 5]; for (i = 0; i < n; i++) { cin >> a[i]; if (a[i] >= 0) ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { long long int n, x, ans, ans1, y; cin >> y; n = (long long int)sqrt((double)y); for (long long int i = n; i > 0;... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (T i : v) os << i << ; return os; } template <class T> ostream& operator<<(ostream& os, const set<T>& v) { for (T i : v) os << i << ; return os; } template <c... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, k, ans = 0; cin >> n >> k; if (n < 3) { cout << 0; return 0; } for (int i = 0; i < n; ++i) { cin >> x; if (5 - x >= k) ans++; } cout << ans / 3; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int arr[4]; for (int i = 0; i < 4; i++) cin >> arr[i]; string strips; cin >> strips; int n = strips.length(); int cal = 0; for (int i = 0; i < n; i++) { if (strips[i] == 1 ) cal += arr[0]; else if (strips[i] ... |
#include <bits/stdc++.h> using namespace std; void Kinishinaide() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); } const long long N = 1e2 + 7; const long long Mod = 1e9 + 7; const long long Inf = 1e18 + 7; int M, L; long long Aq[N]; long long dp[N], Ans; int main() { Kinishina... |
#include <bits/stdc++.h> using namespace std; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; const double EPS = 1e-9; const int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int daysleap[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int n, k; ... |
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long x = 1, y = a; while (b > 0) { if (b % 2) { x = (x * y) % 1000000007; } y = (y * y) % 1000000007; b /= 2; } return x % 1000000007; } int main() { ios_base::sync_... |
#include <bits/stdc++.h> #pragma GCC optimize( -O3 ) using namespace std; const long long N = 1e6 + 5; const long long MAX = 1e7 + 9; long long binarySearch(long long arr[], long long l, long long r, long long x) { if (r >= l) { long long mid = l + (r - l) / 2; if (arr[mid] == x) return mid; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 5; int n; char str[N]; vector<int> g[N]; inline void init() { scanf( %d , &n); for (int i = 1, u, v; i < n; i++) { scanf( %d%d , &u, &v); g[u].push_back(v); g[v].push_back(u); } scanf( %s , str + 1); for ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int test = 1; cin >> test; while (test--) { string s; cin >> s; int a = -1, b = -1, c = -1; int ans = s.size(); for... |
#include <bits/stdc++.h> const int BARIER = 0; class Rng { private: static std::mt19937 engine; public: static std::mt19937& get_engine() { return engine; } template <typename T> static void set_seed(T const& seed) { engine = std::mt19937(seed); } static void timebased_seed() ... |
#include <bits/stdc++.h> using namespace std; const long double gr = (1 + sqrt(5)) / 2; long long n, k, c, res[107], mres; string s; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k >> s; c = 1; for (int i = 0; i < n; i++) { if (i > 0) { if (s[... |
#include <bits/stdc++.h> using namespace std; vector<int> primes; void sieve() { vector<int> a(1000000, 0); for (int u = 2; u <= 1000000; u++) { if (a[u]) continue; for (int i = 2 * u; i <= 1000000; i += u) a[i] = u; } for (int i = 2; i <= 1000000; i++) { if (!a[i]) primes.push_b... |
#include <bits/stdc++.h> using namespace std; char s[105]; int main(void) { int n, f; while (cin >> n) { scanf( %s , s); f = 0; for (int l = (1); l <= (n); ++l) { for (int j = (0); j <= (n - 4 * l - 1); ++j) { if (j + 4 * l >= n) break; if (s[j] == * && s[j ... |
#include <bits/stdc++.h> using namespace std; vector<int> thing[20005 * 4], query[20005 * 4]; struct Thing { int cost, happy; } d[20005]; int cost[20005], f[4005], tree[20005 * 4], tmp[16][4005], ans[20005]; int x, i, n, m, p, y; void build1(int k, int l, int r) { if (x <= l && r <= y) { thi... |
#include <bits/stdc++.h> using namespace std; template <class T> T sqr(T a) { return a * a; } #pragma comment(linker, /STACK:16777216 ) int n; char s[105]; string str; int main() { gets(s); str = s; n = strlen(s); for (int i = n - 1; i > 0; --i) for (int j = 0; j <= n - i; +... |
#include <bits/stdc++.h> using namespace std; const int N = 205; int read() { int x = 0, f = 1; char ch; while (!isdigit(ch = getchar())) (ch == - ) && (f = -f); for (x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48)) ; return x * f; } vector<int> ve... |
#include <bits/stdc++.h> using namespace std; int const maxn = (int)1e4 + 111; int const inf = (1 << 30) - 1; int k; int a[4]; int t[4]; int d[maxn][4]; int first[maxn][4]; int main() { cin >> k; for (int i = 1; i <= 3; i++) cin >> a[i]; for (int i = 1; i <= 3; i++) cin >> t[i]; for (i... |
#include <bits/stdc++.h> using namespace std; long long a, b, qa, qb, answer; int i, j, p, k, lcm, d; int dist[1000000]; char inq[1000000]; int gcd(int x, int y) { if ((x % y) == 0) return y; return gcd(y, x % y); } void ComputeDist() { for (i = 0; i <= lcm; i++) { dist[i] = lcm + 1; ... |
#include <bits/stdc++.h> using namespace std; const int MaxN = 100005, LOG = 22; int n, fth[MaxN], poz[MaxN], fr[MaxN], w[MaxN], sz[MaxN], nrzone = 1; pair<int, int> v[MaxN]; int Find(int x) { if (!fth[x]) return x; return fth[x] = Find(fth[x]); } void Join(int x, int y) { int X = Find(x), Y =... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000006; const long long MOD = 1000000007; struct Query { int a, t, x, id; } query[MAXN]; map<int, int> cnt; int n, ans[MAXN], qcnt; void solve(int l, int r) { ; if (l != r - 1) { int mid = (l + r) >> 1; solve(l, mid)... |
#include <bits/stdc++.h> using namespace std; int n; int m; int a[1 << 7]; int min_k, max_k; bool ok(int ask) { int need = 0; for (int i = 0; i < n; i++) { if (a[i] > ask) { return false; } if (ask > a[i]) { need += ask - a[i]; } } if (need >= m) { ... |
#include <bits/stdc++.h> constexpr int Maxn = 1e5 + 7; constexpr int Mod = 1e9 + 7; int fac[Maxn], ifac[Maxn]; inline int fpm(int a, int b) { int res = 1; while (b) { if (b & 1) res = 1LL * res * a % Mod; a = 1LL * a * a % Mod; b >>= 1; } return res; } inline int C(int n, i... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { y: cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); ; ll n = 0, k = 0; cin >> n >> k; ll a = 0, b = 0; ll sum = 0; ll pos = 0; for (int i = 0; i < k; ++i) { cin >> a >> b; sum += ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; int a, n; cin >> n >> s; for (int i = 0; i < n; ++i) { for (int j = 1; j < n + 1; ++j) { if (i + 4 * j >= n) break; if (s[i] == * && s[i + j] == * && s[i + 2 * j] == * && s[i + 3 * j] == * ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(m + 1, vector<int>(2, 0))); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { dp[i][j][1] = dp[i]... |
#include <bits/stdc++.h> using namespace std; int n, k, a, ans; set<pair<int, int> > s; int x, m; bool used[1000000]; int solve(int x) { return (x + 1) / (a + 1); } void go(int x) { set<pair<int, int> >::iterator it = s.upper_bound(make_pair(x, 1000000000)); --it; pair<int, int> cur = *it; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.