func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int maxn = 200; int s[maxn][6], n; int cnt[maxn]; int get_score(int id, int f, int a) { if (s[f][id] == -1) return 0; int sum = 0; if (s[1][id] == -1 || s[2][id] == -1 || s[1][id] < s[2][id]) sum = cnt[id]; else sum = cnt[id] + a;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); long long a, b, sum = 0; cin >> a >> b; while (true) { if (a >= b) { sum += a / b; a %= b; } if (a == 0) { break; } swap(a, b); } cout << sum; re... |
#include <bits/stdc++.h> using namespace std; long long p = 1000000007; long long fact[100000]; long long dp[100000]; long long factdp[100000]; long long ar[200000]; int main() { fact[0] = 1; fact[1] = 1; dp[0] = 1; dp[1] = 1; factdp[0] = 1; factdp[1] = 1; for (int i = 2; i < 1... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; long long cal(long long x) { return (x + 1) * x / 2; } int main() { std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n; cin >> n; long long l = 0, r = 1e8, ans = -1; while (l <= r) { long long... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int main() { int n, k; scanf( %d %d , &n, &k); int def = 0; int a[N], d[N] = {}; for (int i = 0; i <= n; i++) { int a[N]; char c[10]; if (scanf( %d , &a[i])) d[i] = 1, def++; else scanf(... |
#include <bits/stdc++.h> using namespace std; const long long int INF = (1ll << 60) - 1; long long int nCrModpDP(long long int n, long long int r, long long int p) { long long int i, j, C[r + 1]; memset(C, 0, sizeof(C)); C[0] = 1; for (i = 1; i <= n; i++) { for (j = min(i, r); j > 0; j--) { ... |
#include <bits/stdc++.h> using namespace std; int n, k; long long ans; int a[100002]; int b[100002]; bool jobs[100002]; priority_queue<int> pq[100002]; priority_queue<int> pq2; int main() { cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> b[i]; ... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char c = getchar(); bool f = 0; while (c < 48) f |= c == - , c = getchar(); while (c > 47) x = x * 10 + (c ^ 48), c = getchar(); return f ? -x : x; } int n, k; struct node { int sz, mn[10], mx[10]; bo... |
#include <bits/stdc++.h> using namespace std; const int N = 2e3 + 10, H = 2e5 + 10, MOD = 1e9 + 7; struct node { int x, y; } a[N]; long long fac[H], inv[H], f[N]; int h, w, n; long long popow(long long x, int y) { long long t = x, re = 1; while (y) { if (y & 1) re = re * t % MOD; t... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) using namespace std; const int MXN = 2e5 + 10; const int MXS = MXN * 4; const int INF = 1e9; const int Mod = 998244353; int n, q, num; int Seg[MXS], MUL[MXS], ADD[MXS]; set<pair<pair<int, int>, int> > st[MXN]; void Shift(int id, int s, int e) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); int ok = 0; for (int i = 0; i < n - 1; i++) { if (((long l... |
#include <bits/stdc++.h> using namespace std; long long int arr[1000005], t = 0; int main() { int n, cnt; cin >> n; map<long long int, int> m; for (int i = 0; i < n; i++) { cin >> arr[i]; } cnt = 1; long long int t = arr[0]; m[t]++; for (int i = 1; i < n; i++) { t =... |
#include <bits/stdc++.h> using namespace std; namespace Dango { const int MAXN = 200005, INF = 0x3f3f3f3f; struct Edge { int from, to, dis, id; bool operator<(const Edge b) const { return dis < b.dis; } } e[MAXN]; struct tree { int l, r, data; bool tag; } t[MAXN << 2]; int n, m; int he... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, int> > v[200010]; int mark[200010]; vector<pair<int, int> > sorted; int Query[200010]; int main() { int n, q, i, j; memset(mark, 0, sizeof(mark)); scanf( %d , &n); for (i = 0; i < n; i++) { int x, y; scanf( %d , &x); ... |
#include <bits/stdc++.h> using namespace std; const long long oo = 1e18; const long long maxn = 2e5, maxm = 1e6, M = 20; struct girl { long long w, id; bool operator<(const girl a) const { return w > a.w; } }; pair<long long, long long> operator+(pair<long long, long long> a, ... |
#include <bits/stdc++.h> using namespace std; int arr[111]; int main() { int n; scanf( %d , &n); for (int i = (0); i < (n); ++i) scanf( %d , &arr[i]); sort(arr, arr + n); int t = 10; int ans = 0; int qts = 0; for (int i = (0); i < (n); ++i) { t += arr[i]; if (t > 720) b... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 10; int T, N; int a[MAX]; int main() { scanf( %d , &T); while (T--) { scanf( %d , &N); for (int i = 1; i <= N; i++) scanf( %d , &a[i]); sort(a + 1, a + 1 + N); int l = (N + 1) / 2, r = (N + 1) / 2; printf... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b); int main() { long long int a, b, c, i, j, x, k, sum, count; scanf( %lld , &a); scanf( %lld , &b); scanf( %lld , &c); long long int arr[81]; count = 0; for (i = 1; i < 82; i++) { l... |
#include <bits/stdc++.h> using namespace std; int n; bool r[100], c[100]; int main() { cin >> n; vector<int> ans; for (int i = 1; i <= n * n; i++) { int x, y; cin >> x >> y; if (!r[x] && !c[y]) { ans.push_back(i); r[x] = true; c[y] = true; } } ... |
#include <bits/stdc++.h> int main() { int n, i; char ch; char str[2010]; scanf( %d , &n); scanf( %c , &ch); if (n % 2 == 1) { scanf( %c , &str[n / 2]); for (i = 1; i <= n / 2; i++) { scanf( %c , &str[n / 2 - i]); scanf( %c , &str[n / 2 + i]); } } else { ... |
#include<bits/stdc++.h> using namespace std; const int N=3e5+10; int n,m,mx; int dif[N],b[N]; vector <int> a[N]; void end(){ puts( No ); exit(0); } int main(){ scanf( %d%d ,&n,&m); for(int i=1;i<=n;i++){ a[i].push_back(0); for(int j=1;j<=m;j++){ int x; scanf( %d ,&x); a[i].push_back(x... |
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int uppery = y2 + 1; int lowery = y2 - 1; int upperx = x2 + 1; int lowerx = x2 - 1; int ans = 4; ans += abs(x1 - upperx) + abs(y1 - lowery) + abs(x1 - lowerx) + abs(y1 ... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int a) { long long int pdt = 1, i = 0, t = 19; while (i++ < min(a, t)) pdt *= 2; return pdt; } int main() { long long int n, b, i, j, cnt = 0, k = 0; cin >> n >> b; long long int a[n], c[n]; b = power((b * 8)... |
#include <bits/stdc++.h> using namespace std; char s[200005], s1[200005]; void sol() { int i, l, xp; l = strlen(s); memset(s1, 0, sizeof(s1)); xp = -1; for (i = 0; i < l; i++) { if (xp == -1) { xp++; s1[xp] = s[i]; continue; } if (s1[xp] == s[i]) ... |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll t; cin>>t; while(t--){ ll n,k; cin>>n>>k; ll ans; if(n%2==0) { if(k%n==0) ans=n; else ans=k%n; } else { ll x1=k%n; if(x1==0) x1=n; ll x2=(k/n); ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LLINF = 1e18; const int MAXN = 1e5; int v, q; vector<int> G[MAXN]; int min_dist[MAXN]; bool is_centroid[MAXN]; int sz[MAXN]; int father[MAXN]; int dfs_sz(int x, int f = -1) { sz[x] = 1; for (auto y : ... |
#include <bits/stdc++.h> using namespace std; const int RLEN = 1 << 18 | 1; inline char nc() { static char ibuf[RLEN], *ib, *ob; (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin)); return (ib == ob) ? -1 : *ib++; } inline int rd() { char ch = nc(); int i = 0, f = 1; while (... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; while (cin >> n) { string x; cin >> x; long long c = 0; long long arr[n + 5]; memset(arr, 0, sizeof(arr)); for (long long i = 0; i < n; i++) { if (x[i] == < ) { if ((i - 1) < 0 || a... |
#include <bits/stdc++.h> using namespace std; long long int sum; vector<int> x; int main() { int n; cin >> n; x.push_back(-2099999999); for (int i = 0; i < n; i++) { int a; cin >> a; x.push_back(a); } sort(x.begin(), x.end()); for (int i = 1; i <= n; i++) sum += abs... |
#include <bits/stdc++.h> int b; struct Matrix { long long int x[110][110]; } A, B, C; Matrix operator*(Matrix A, Matrix B) { Matrix C; for (int i = 1; i <= b; i++) { for (int j = 1; j <= b; j++) { C.x[i][j] = 0; for (int k = 1; k <= b; k++) { C.x[i][j] += A.x[i][k] * ... |
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int x, long long int y) { return y == 0 ? x : gcd(y, x % y); } int main() { long long int a; cin >> a; if (a > 2) { if (a * a % 2) cout << (a * a - 1) / 2 << << (a * a + 1) / 2; else cout <<... |
#include <bits/stdc++.h> using namespace std; long long holes[14]; int main() { long long zeroes = 0; for (long long i = 0; i < 14; i++) { cin >> holes[i]; if (holes[i] == 0) zeroes++; } zeroes++; long long mx = 0; for (long long i = 0; i < 14; i++) { long long cnt = 0; ... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e13; const int MAGIC = 3500000; long long add(long long x, long long y) { return (x + y) % MOD; } long long mul(long long x, long long y) { long long coef = (long double)(x)*y / MOD + 0.5; long long ret = x * y - coef * MOD; ret ... |
#include <bits/stdc++.h> using namespace std; const int N = 600010; const int Mod = 998244353; inline int sub(int x, int y) { return (x - y < 0 ? x - y + Mod : x - y); } inline int add(int x, int y) { return (x + y >= Mod ? x + y - Mod : x + y); } int po(int x, int y) { int r = 1; for (; y; y >>= 1,... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10, mod = 1e9 + 7; const long long inf = 1e18; int x[maxn], frs[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, z; cin >> n >> z; for (int i = 0; i < n; i++) { cin >> x[i]; } sort(x,... |
#include <bits/stdc++.h> using namespace std; int n; string s; vector<vector<int> > dp; vector<int> res; void recalc(char col) { dp = vector<vector<int> >(n + 1, vector<int>(n + 1, 0)); res = vector<int>(n, 0); for (int(i) = 0; (i) < (n + 1); ++(i)) dp[i][0] = 0; for (int(ncur) = (1); (ncur)... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const int N = 1000010; long long fact[N]; int main(int argc, char const *argv[]) { long long n, m; cin >> n >> m; if (n == 1 && m == 1) { cout << 1 n ; return 0; } double ans = 1.0 / (double)n + ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define fi first #define se second void solve(){ ll n; cin>>n; vector<ll>d(n); for(int i=0;i<n;i++) cin>>d[i]; ll ans=0,curr=0; sort(d.begin(),d.end()); for(int i=1;i<d.size()-1;i++){ ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long n, k; cin >> n >> k; if (k <= (n + 1) / 2) { cout << 2 * k - 1; } else { cout << 2 * (k - (n + 1) / 2); } return 0; } |
#include <bits/stdc++.h> using namespace std; bool check(vector<long long> a, long long m, long long n) { vector<long long> v(n + 1, 0); for (long long i = 0; i < n; i++) { v[a[i]] += 1; } set<pair<long long, long long>, greater<pair<long long, long long>>> s; for (long long i = 1; i < n +... |
#include <bits/stdc++.h> int main() { int n; int a[100000]; int l0, l1; int i, j; scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &a[i]); } l0 = 0; l1 = 0; for (i = 1; i < n; i++) { if (a[i] >= a[i - 1]) { l1++; } if (a[i] < a[i - 1]) { ... |
#include <bits/stdc++.h> int t, n, a[200010], tot, cnt[200010]; int f[200010]; int find_f(int x) { return f[x] ^ x ? f[x] = find_f(f[x]) : x; } int main() { scanf( %d , &t); for (int _ = 0; _ < t; ++_) { scanf( %d , &n); 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 n, m; cin >> n; vector<int> a(n, 0); for (int i = 0; i < n; i++) cin >> a[i]; cin >> m; vector<int> b(m, 0); for (int i = 0; i < m; i++) cin >> b[i]; int count = 0; sort(a.begin(), a.end()); sort(b.begin(), b.end(... |
#include <bits/stdc++.h> using namespace std; inline int add(int a, int b, int c) { a += b; if (a >= c) a -= c; else if (a < 0) a += c; return a; } inline int mul(int a, int b, int c) { return (long long)a * b % c; } int pow(int a, long long b, int c) { int res = 1; for (; ... |
#include <bits/stdc++.h> using namespace std; struct milk { int x, num; bool operator<(const milk &mm) const { return x < mm.x; } } b[1000010]; int a[1000010], n, m, k; bool ok(int p2) { int p1 = 1, now = 0; while (p1 <= n || p2 <= m) { if ((p1 <= n && a[p1] < now) || (p2 <= m && b[p2].x... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } void O_o() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); } bool prime(int n, int i) { if (i == n) return true; ... |
#include <bits/stdc++.h> using namespace std; template <class T> bool umin(T& a, const T& b) { return a > b ? a = b, true : false; } template <class T> bool umax(T& a, const T& b) { return a < b ? a = b, true : false; } template <long long sz> using tut = array<long long, sz>; const long lon... |
#include <bits/stdc++.h> using namespace std; long long lucky[1024 * 4]; long long fact[14]; int cnt; void func(long long cur, int pos, int maxpos) { if (pos == maxpos) { lucky[++cnt] = cur * 10 + 4; lucky[++cnt] = cur * 10 + 7; return; } func(cur * 10 + 4, pos + 1, maxpos); ... |
#include <bits/stdc++.h> const int MAXINT = 2147483640; const long long MAXLL = 9223372036854775800LL; const long long MAXN = 1e6; const double eps = 1e-9; const long long mod = 1e9 + 7; using namespace std; long long binpow(long long a, long long n) { long long ans = 1; while (n) { if (n & ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int count = 0; for (int i = 1; i < n - 1; i++) { if ((a[i - 1] - a[i]) * (a[i + 1] - a[i]) > 0) { count++; } } cout << coun... |
#include <bits/stdc++.h> using namespace std; struct item { int id, savetime, destructiontime, value; }; struct state { int bestval, besttime; vector<int> items; }; int n; item arr[101]; state dp[101][2001]; int itemidx[101][2001]; int main() { ios_base::sync_with_stdio(false); c... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx ) using namespace std; const long long maxn = 1e5 + 20; const long long inf = (long long)2e9; const long double pi = asin(1) * 2; c... |
#include <bits/stdc++.h> using namespace std; string a, b; long long int mp[10]; long long int x[20]; bool solve(long long int idx, bool isSmall) { if (idx == b.size()) { return true; } long long int start = b[idx] - 0 ; if (isSmall) start = 9; for (long long int j = start; j >= 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n, t = 1; while (t--) { cin >> n; vector<long> v(n), b(n), ans(n, 0); for (i = 0; i < n; i++) { cin >> v[i]; b[i] = v[i]; } for (i = n - 2; i >= 0; i--) { if (b[i + 1] >= v[i]) ans[i... |
#include <bits/stdc++.h> using namespace std; const int maxx = 3e5 + 100; string s; int n; int main() { while (scanf( %d , &n) != EOF) { cin >> s; int len = s.length(); int flag = 0; int i; for (i = 1; i < len; i++) { if (s[i] < s[i - 1]) { flag = 1; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 10; int n; vector<string> a; vector<pair<pair<int, int>, int> > pos; char s[N]; int main() { scanf( %d , &n); for (int i = (0); i < (n); i++) { int m; string t; cin >> t; a.push_back(t); scanf( %d , &m)... |
#include <bits/stdc++.h> using namespace std; void solve() { string second; long long n, i, m, ans = 0, j, k, sum = 0; cin >> m; n = m; vector<long long> b(m / 2), a(n); for (i = 0; i < n / 2; i++) cin >> b[i]; a[0] = 0; a[n - 1] = b[0]; for (i = 1; i < m / 2; i++) { long l... |
#include <bits/stdc++.h> using namespace std; int n, k; long long m; long long ten[1005], f[1005][105][2]; int MAIN() { scanf( %d%d%lld , &n, &k, &m); ten[0] = 1; for (int i = 1; i < 1005; ++i) { ten[i] = ten[i - 1] * 10 % k; } f[0][0][0] = 1; for (int i = 0; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 10; int ans = 0, n; int a, b, c; void cbh(int uuu, int len) { if (len == n) return; if (uuu == 1) { if (a < b) ans += a, cbh(2, len + 1); else ans += b, cbh(3, len + 1); } else if (uuu == 2) { i... |
#include <bits/stdc++.h> int main() { int n; std::cin >> n; int max_x = 0; std::vector<int> v(n, 0); for (int i = 0; i < n; ++i) { std::cin >> v[i]; } for (const auto& elem : v) { int tmp = elem + max_x; if (tmp > max_x) max_x = tmp; std::cout << tmp << ; } ... |
#include <bits/stdc++.h> using namespace std; int MIN(int a, int b) { int x = (b > a) ? a : b; return x; } int MAX(int a, int b) { int x = (b < a) ? a : b; return x; } const int size = 1000007; const long long modulo = 1000000007; const long long inf = 1e18; const double eps = 1e-6; ... |
#include <bits/stdc++.h> using namespace std; long long int mod = 998244353; long long int dx[] = {0, 0, 1, -1}; long long int dy[] = {1, -1, 0, 0}; long long int m = 0, n, res, k, ans = 0, nbcycle = 0; string s2 = zero , ch = , s, t, s1 = ; set<pair<long long int, long long int> > st; vector<pair<... |
#include <bits/stdc++.h> using namespace std; struct Timer { Timer() { beg = clock(); } ~Timer() {} clock_t beg; }; int main() { ios_base::sync_with_stdio(false); int n, d, h; cin >> n >> d >> h; if (d < h) { cout << -1 << endl; return 0; } if (d == 1 && h == 1) {... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int arr[n]; set<int> s; for (int i = 0; i < n; i++) { int temp; cin >> temp; s.insert(temp); } if (s.size() != n) cout << ... |
#include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } bool sortbysecinrev(const pair<int, int> &a, const pair<int, int> &b) { return (a... |
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, +1, -1}; int dy[] = {+1, -1, 0, 0}; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } int biton(int N, int pos) { return N = N | (1 << pos); } int bitoff(int N, int pos) { return N = N & ~(1 << pos); } bool check(int N, int po... |
#include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(false); cin.tie(0); int d, n; cin >> d >> n; vector<int> days(n); for (int i = 0; i < n; i++) cin >> days[i]; int count = 0; for (int i = 1; i < n; i++) count += d - days[i - 1]; cout << cou... |
#include <bits/stdc++.h> using namespace std; long long int f(long long int a) { long long int i, r = 0; for (i = 1; i <= a; i++) { r += i * (9 * (pow(10, i - 1))); } return r; } int main() { long long int i, n, a; cin >> n; for (i = 1; n % (long long int)(pow(10, i)) != n; i++... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<string> s(n + 2); for (int i = 1; i <= n; i++) { cin >> s[i]; s[i] = . + s[i] + . ; } s[0] = s[n + 1] = string(m ... |
#include <bits/stdc++.h> using namespace std; int a[200010]; int main() { int n; scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &a[i]); sort(a + 1, a + n + 1); int mn = a[n]; for (int i = 1; i <= n / 2; i++) mn = min(mn, a[i + n / 2] - a[i]); printf( %d n , mn); return 0... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x; scanf( %d%d n , &n, &x); if (n == 5) printf( >...v nv.<.. n..^.. n>.... n..^.< n1 1 n ); if (n == 3) printf( >vv n^<. n^.< n1 3 n ); if (n == 100) { for (int i = 0; i < 50; i++) { puts( v<.<.<.<.<.<.<... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e2 + 1; int n, m, q, ans[MAX][MAX], t[MAX][MAX][2]; int main() { ios_base::sync_with_stdio(0); cin >> n >> m >> q; for (int i = 1; i < n + 1; i++) for (int j = 1; j < m + 1; j++) { t[i][j][0] = i; t[i][j][1] = j; ... |
#include <bits/stdc++.h> using namespace std; int l[300005], r[300005]; int main() { int n; scanf( %d , &n); int lm = -1, rm = 0x3f3f3f3f; int ansl = 0, ansr = 0; for (int i = 1; i <= n; i++) { scanf( %d%d , &l[i], &r[i]); if (l[i] > lm) { ansl = i; lm = l[i]; ... |
#include <bits/stdc++.h> using namespace std; struct camel { int x, y; }; int main() { int n; bool r = false; cin >> n; camel arr[n]; for (int i = 0; i < n; i++) cin >> arr[i].x >> arr[i].y; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) if (arr[i].x + arr[i]... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using lld = long double; using vi = vector<int>; using vll = vector<long long>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int x[n]; for (int &u : x) { cin >> u; } so... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int N = 200005; int prime[1100000], primesize; bool isprime[11000000]; long long f[N], invf[N]; long long inv[N]; void getlist(int listsize) { memset(isprime, 1, sizeof(isprime)); isprime[1] = false; for (int i = ... |
#include <bits/stdc++.h> using namespace std; int main() { int k, n, ch = 0; string s, g; cin >> n >> k >> s; for (int i = 1; i <= n && ch == 0; i++) { string t = s.substr(0, i); string temp = 0 ; int count; (n % i == 0) ? count = n / i : count = (n / i) + 1; for (int... |
#include <bits/stdc++.h> using namespace std; int a, b[1000002], c = 0, d, e, f, g, h, i, j; int main() { cin >> a; for (i = 1; i <= a; i++) { cin >> d; b[d]++; if (b[d] > c) { c = b[d]; e = d; } } cout << e; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; char a[n][m]; bool vis[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; vis[i][j] = false; } } for (int i = 0; i < n; i++) { for (int j ... |
#include <bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define N 1010100 #define inf 1e9 #define loop(x, n, r) for(int i = x; i < n; i += r) #define pb push_back #define pp pair<int, int> using namespace std; int main(){ ios::sync_with_stdio(0); cin.ti... |
#include <bits/stdc++.h> using namespace std; const int N = 111111; const int INF = 1000000000, mod = 1000000007; const long long LLINF = 1000000000000000000ll; long long n, k, d1, d2; bool try_solve(long long d1, long long d2) { if (n % 3) return 0; if ((k - d1 + d2) % 3) return 0; long long x2... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; template <typename T> void dprintln(const T &t) { cout << t << endl; } template <typename T, typename... Args> void dprintln(const T &t, const Args &...rest) { cout << t << ; dprintln(rest...); } template <typen... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9; const int N = 1e6 + 6; long long powmod(long long a, long long b, long long mod) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; } ... |
#include <bits/stdc++.h> using namespace std; int countBits(long long mask) { int res = 0; while (mask) mask &= (mask - 1), ++res; return res; } string toString(long long n) { stringstream ss; ss << n; return ss.str(); } long long toNumber(string s) { stringstream ss; long lo... |
#include <bits/stdc++.h> using namespace std; int n, cnt_t = 0; vector<pair<int, int>> ls_[2]; vector<int> upb, downb; bool cmp(pair<int, int> a, pair<int, int> b) { if (a.first != b.first) { return a.first < b.first; } return a.second < b.second; } long long proc(vector<pair<int, int>> ... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, n, m, k; int i, j, a[55]; bool f = 0; cin >> n >> m >> k; for (i = 0; i < n; i++) cin >> a[i]; sort(a + 0, a + n); if (k >= m) { cout << 0 << endl; f = 1; } else for (i = n - 1, x = 0; i >= 0... |
#include <bits/stdc++.h> using namespace std; inline int read() { int ch = getchar(), f = 0; int x = 0; while (ch < 0 || ch > 9 ) { f |= ch == - ; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return f ? -x : x; ... |
#include <bits/stdc++.h> using namespace std; int main() { double sum = 0; int n; scanf( %d , &n); for (int i = 1; i <= n; i++) sum += 1.0 / i; printf( %.12f n , sum); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long a, b, c, d; cin >> a >> b >> c >> d; if (a + b == c + d || a + c == b + d || a + d == b + c || a + b + c == d || a + c + d == b || b + c + d == a || a + b + d =... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; const int dy[] = {1, 0,... |
#include <bits/stdc++.h> using namespace std; map<string, int> m1, m2; void go(string s, map<string, int>& mp) { if (mp.find(s) != mp.end()) { return; } mp[s] = 1; if (s[0] == X ) { string s1 = s; string s2 = s; swap(s1[0], s1[1]); swap(s2[0], s2[2]); go(s1, mp... |
#include <bits/stdc++.h> using namespace std; long long p[2001]; long long find_size(long long x) { if (p[x] == -1) return 1; return 1 + find_size(p[x]); } void solve() { long long n; cin >> n; for (long long i = 0; i < n; i++) { long long x; cin >> x; if (x > 0) x--; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, maxn = 1e6, MAXN = 1 << 21; int jc[2222222], injc[2222222], n, a, b, s[2222222], t[2222222], l, r, pw[2222222], sz, rev[2222222], cnt; int S[2222222], T[2222222], G[2222222], w[2][2222222], cur, gg[2222222]; long long c[2222222]; ... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; const int mod = 1e9 + 7; int a[N]; long long fac[30]; long long sum[N]; long long Contor(int* a, int n) { long long res = 0; for (int i = 1; i <= n; i++) { int cnt = 0; for (int j = i + 1; j <= n; j++) if (a[... |
#include <bits/stdc++.h> using namespace std; int main() { int a; scanf( %d , &a); printf( %d , a % 2); } |
#include <bits/stdc++.h> using namespace std; const long long INF = 1111111111; const long long MOD = 1e9 + 7; int pref[5001][5001]; int nxt[5001][5001]; int dp(int i, int j) { int x; if (i > 0) { x = pref[i][j] - pref[i - 1][j]; } else { x = pref[0][j]; } x %= MOD; if (x... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const int inf = 0x3f3f3f3f, N = 1e7; using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } char s[10]; int d(char c) { return c - 0 ; } int main() { while (~scanf( %s , s)) { long long x = d(s[... |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> g[100005]; int vis[100005]; vector<vector<int> > r; bool dfs(int x, int f) { vis[x] = 1; int k = -1; for (int y : g[x]) { if (y == f) continue; if (vis[y] > 0 || !vis[y] && !dfs(y, x)) { if (k < 0) ... |
#include <bits/stdc++.h> using namespace std; template <typename T> ostream& operator<<(ostream& os, const array<T, 2>& a) { for (T e : a) { os << e << ; }; return os; } inline void lol(const function<void(int)>& fun, const array<int, 2>& f, const array<int, 2>& s) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.