Dataset Viewer
Auto-converted to Parquet Duplicate
func_code_string
stringlengths
59
71.4k
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double EPS = 1e-7; const long long BIG_PRIME7 = 1000000007; const long long BIG_PRIME9 = 1000000009; int gcd(int x, int y) { return y ? gcd(y, x % y) : x; } char ch = a ; int j, n, m, L, i; int N, C; int x, y, z, k; ...
#include <bits/stdc++.h> using namespace std; const int N = 111111; int last[3 * N], pre[3 * N], v[3 * N], cnt[3 * N], cur = 0; inline void add(int a, int b) { pre[cur] = last[a]; v[cur] = b; last[a] = cur; cur++; } set<int>* who[N]; inline set<int>* merge(set<int>*& a, set<int>*& b) { ...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int base = 1e9; const int MAX = 1e5; const double EPS = 1e-9; const double PI = acos(-1.); int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, *a, *res, j = 0; ...
#include <bits/stdc++.h> using namespace std; string s; int n, m; int f[150][150][250][2]; int main() { cin >> s; n = s.size(); scanf( %d , &m); f[0][m][n][1] = true; for (int i = 0; i < n; i++) for (int j = 0; j <= m; j++) for (int k = 0; k <= n * 2; k++) for (int ...
#include <bits/stdc++.h> using namespace std; struct cell { bool up, down, right, left; int degree; cell() { up = down = left = right = degree = 0; } void reset() { up = down = left = right = degree = 0; } }; struct qcell { int x, y, degree; qcell() { x = y = -1; degree = 0; ...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { string s, t; cin >> s >> t; vector<int> each[26]; int n, m; n = s.length(); m = t.length(); for (int i = 0; i...
#include <bits/stdc++.h> using namespace std; int main() { int n, h, a, road_width = 0; cin >> n >> h; for (int i = 0; i < n; i++) { cin >> a; if (a > h) road_width += 2; else road_width++; } cout << road_width << n ; return 0; }
#include <bits/stdc++.h> using namespace std; int abs(int a, int b) { if (a > b) return a - b; else return b - a; } int main() { int n, c, i, b, count = 0, index1 = 1, index2 = 1, flag = 0; cin >> n >> c; char *s; s = new char[n + 2]; for (i = 1; i <= n; i++) { cin ...
#include <bits/stdc++.h> int any_table[11][11]; struct DammedPascalNUmber { int tb[13][13]; DammedPascalNUmber() { int i, j; for (i = 0; i <= 12; i++) for (j = 0; j <= i; j++) { int &r = tb[i][j]; if (j == 0 || i == 0) r = 1; else r =...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const double pi = acos(-1); const int inf = 1 << 30; const int mod = 1e9 + 9; struct point { int x, flag; bool operator<(const point &a) const { return flag > a.flag; } } s, q; bool check(long long a[], int n, long long h, ...
#include <bits/stdc++.h> const int64_t mod = 998244353; int gcd(int64_t a, int64_t b) { while (a != 0 && b != 0) { if (a >= b) a = a % b; else b = b % a; } return a + b; } struct Fraction { int64_t numerator; int64_t devider; Fraction(int64_t n = 0, int64_t d ...
#include <bits/stdc++.h> using namespace std; const int N = 100005; int n, m, x, y, f[N], fa[N], ch[N][2]; char op[5]; long long a[N], siz[N], ssiz[N], ans[N], sans[N], sqsiz[N], all[N]; bool isroot(int u) { return ch[fa[u]][0] != u && ch[fa[u]][1] != u; } int which(int u) { return u == ch[fa[u]][1]; } ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long x, y, n, m, t, q, a, b, count = 0; cin >> n >> m; long long arr[n]; for (x = 0; x < n; x++) cin >> arr[x]; a = 0; for (x = 0; x < n; x++) { a = a + arr[x]; ...
#include <bits/stdc++.h> using namespace std; int qread() { char c; int s = 0, f = 1; while ((c = getchar()) < 0 || c > 9 ) (c == - ) && (f = -1); do s = s * 10 + c - 0 ; while ((c = getchar()) >= 0 && c <= 9 ); return s * f; } int n, m; const int mod = 1e9 + 7; int a[100011]...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long inf = 1000000000000000000; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; vector<pair<long long, long long> > p(n); for (auto& x : p) cin >> x.first >> x....
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < n; i++) { if (i % 2 == 0) { for (int j = 1; j <= m; j++) { printf( # ); } } else if (i % 4 == 1) { for (int j = 1; j < m; j++) { printf...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 65, mod = 1e9 + 7; vector<int> g[N]; int w[N]; int col[N], pr[N]; int sz[N][2]; long long ans = 0; void dfs(int v, int par = -1, int c = 0) { pr[v] = par; ++sz[v][c]; col[v] = c; for (int u : g[v]) if (u != par) { ...
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 28; const double INF = 1e12, EPS = 1e-9; int n, m, k; bool star[600][600]; int sum[600][600]; char in[600][600]; void run() { cin >> n >> m >> k; for (int i = 0; i < n; i++) cin >> in[i]; for (int i = 0; i < n; i++) for...
#include <bits/stdc++.h> using namespace std; void readi(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != - ) c = getchar(); if (c == - ) f = -1; else v = v * 10 + c - 0 ; while (isdigit(c = getchar())) v = v * 10 + c - 0 ; x = v * f; } void ...
#include <bits/stdc++.h> using namespace std; const long long mxn = 1003, inf = 1e18 + 18; int n, m, lcp[mxn][mxn], rk[mxn][mxn], ri[mxn], tot; long long k, f[mxn]; string s; struct S { int l, r; } a[mxn * mxn]; inline bool cmp(S a, S b) { int p = a.l + lcp[a.l][b.l], q = b.l + lcp[a.l][b.l]; ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <set> #include <unordered_map> using namespace std; typedef long long LL; const int N = 3e5 + 10, mod = 998244353; string g[N]; int dp[N]; int fastPow(int a, int k) { ...
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 10; char s[maxn]; int f(char ch) { if (ch == A ) return 1; if (ch == B ) return 2; if (ch == C ) return 4; return 0; } int main() { scanf( %s , s + 1); int l = strlen(s + 1); for (int i = 1; i <= l - 2; ++i) ...
#include <bits/stdc++.h> using namespace std; vector<int> tree[500001]; bool intree[500001]; vector<int> tmp(0); bool isleaf(int node) { if (tree[node].size() == 1 && intree[(tree[node])[0]]) return true; return false; } void DFS(int lvl, int node) { intree[node] = true; if (isleaf(node)) ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; vector<string> v(n); for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 1; i < n - 1; i++) { for (int j = 1; j < n - 1; j++) { if (v[i][j] == # and v[i + 1][j] == ...
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; cin >> n; long long con = -1; long long a[n + 5]; for (long long i = 1; i <= n; i++) { cin >> a[i]; } long ...
#include <bits/stdc++.h> using ll = long long; using namespace std; int main() { ios::sync_with_stdio(false); int N, K; cin >> N >> K; ll total = N + 1; total += N; total += min(2 * (K - 1) + (N - K), 2 * (N - K) + K - 1); cout << total << n ; return 0; }
#include <bits/stdc++.h> using namespace std; int k, n[20], a[20][5010], g[32768], f[32768], hsh[301781], ps[301781], ans1[20], ans2[20], vis[20], TMS; pair<int, int> md[32768]; long long sm[20]; int get(int x) { int y = (x + 1000000001) % 301781; while (hsh[y] && hsh[y] ^ x + 1000000001) y = (y...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int test = 1; for (; test > 0; --test) { long long int n, a, b, c, d, c1 = 1, c2, c3, c4; cin >> n >> a >> b >> c >> d; c2 = c1 + b - c; c3 = c2 + a - d; ...
#include <bits/stdc++.h> using namespace std; const long long int MAX = 1000000007; const long long int MAXN = 100010; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { long long int n, k; cin >> n >> k; ...
#include <bits/stdc++.h> using namespace std; int d[250003]; int main() { int i, j, k, n, m, t, a[501][501], b[501][501]; cin >> t; while (t--) { cin >> n >> m; for (i = 0; i < n; i++) for (j = 0; j < m; j++) cin >> a[i][j], d[a[i][j]] = i; for (i = 0; i < m; i++) for...
#include <bits/stdc++.h> using namespace std; vector<pair<long long int, pair<long long int, long long int> > > P; int level[1007]; double ans = 0; bool contains(pair<long long int, pair<long long int, long long int> > A, pair<long long int, pair<long long int, long long int> > B) { return...
#include <bits/stdc++.h> using namespace std; inline long long power(long long a, long long b) { long long x = 1; a = a % 1000000007ULL; while (b) { if (b & 1) x = (x * a) % 1000000007ULL; a = (a * a) % 1000000007ULL; b >>= 1; } return x; } inline long long inv(long long a)...
#include <bits/stdc++.h> using namespace std; int mod = 998244353; long long a[300001]; long long n, m, k; int b[300001]; void solve() { cin >> n; for (int i = 0; i < n; ++i) { int x; cin >> x; a[x]++; b[a[x]] += a[x]; k = (b[a[x]] >= i && b[a[x]] != n) ? b[a[x]] : k; ...
#include <bits/stdc++.h> using namespace std; int main() { char str[2020]; long l; cin >> l; cin >> str; int i, j, hs = 0, ts = 0; for (i = 0; i < l; i++) { if (str[i] == H ) hs++; else ts++; str[l + i] = str[i]; } int res = 1000000000; int t; ...
#include <bits/stdc++.h> using namespace std; long long a[1000000 + 100], f2, x1, x2, b[1000000 + 100], razl, sol, pok1, pok2; double f1; int main() { for (int i = 1; i <= 4; i++) cin >> a[i]; f1 = sqrt(1 + 8 * a[1]) * 1.0; f2 = sqrt(1 + 8 * a[1]); if (f1 != f2) { printf( Impossible n ); ...
#include <bits/stdc++.h> using namespace std; void mohammed() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); } int main() { mohammed(); int n, x, y; cin >> n; map<int, int> mp; map<int, int>::iterator it; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); template <typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; } template <class L, class R> ostream &operator<<(...
#include <bits/stdc++.h> using namespace std; const int N = 200005; int t[N]; int p[N]; int p2[N]; int main() { std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; long long sum = 0; cin >> n; for (int i = 0; i <= n; i++) { cin >> t[i]; sum += t[i]; } ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long sum1 = 0, sum2 = 0; long temp; for (int i = 0; i < n; i++) { cin >> temp; sum1 += temp; } for (int i = 0; i < n - 1; i++) { cin >> temp; sum2 += temp; } cout << sum1 - su...
#include <bits/stdc++.h> using namespace std; const int N = (1 << 20) + 15; long long dp[N]; pair<int, int> id[100]; int bit[100], c[100], st[N]; int main() { int u, a, mi, n, m, i, j, b, x, p = 0, idd; long long k, temp; long long ret = 4e18; scanf( %d%d%d , &n, &m, &b); for (i = 0; i <...
#include <bits/stdc++.h> using namespace std; int cnt[1000100], a[1000100]; int main() { int n, k, ans; scanf( %d , &n); scanf( %d , &k); for (long long i = 0; i < n; i++) scanf( %d , &a[i]); int l = 0, r = 0, al, ar; set<int> x; cnt[a[0]]++; x.insert(a[0]); ans = 1; al = 0...
#include <bits/stdc++.h> using namespace std; const int M = 105; int l[M], r[M], t[M], c[M], res[M], p[M]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> l[i] >> r[i] >> t[i] >> c[i]; } for (int i = 1; i <= n; ++i) p[i] = INT_MAX; for (int i = 0; i < m; ...
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9, pi = acos(-1); const long long N = 1e5 + 5; long long r[N], h[N], n, F[N], dp[N]; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { if (a.first == b.first) { return a.second < b.second; } else ...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; string str; for (int i = 0; i < t; i++) { cin >> str; long long int res = 0; long long int arr[str.size()]; if (str[0] == + ) { arr[0] = 1; } else { arr[0] = -1; } f...
#include <bits/stdc++.h> template <typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First& first, Rest&... rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } template <typename T> void MACRO_VEC_ROW_Init(int n, T& t) ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; for (int i = 0; i < k; i++) { if (n % 10 != 0) { n = n - 1; } else if (n % 10 == 0) { n = n / 10; } } cout << n; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 100; template <class nmsl> inline void read(nmsl &x) { x = 0; char ch = getchar(), w = 0; while (!isdigit(ch)) w = (ch == - ), ch = getchar(); while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); x = w ? -...
#include <bits/stdc++.h> using namespace std; const int M = 3000; int n, m; pair<pair<int, int>, int> v[M]; map<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> > > Q; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } pair<pair<int, int>, int> get(int x1, int y1, int x2, int y2) { in...
#include <bits/stdc++.h> using namespace std; int mpow(int base, int exp); void solve() { long double n; cin >> n; long double sum = 0; while (n) { long double d; d = (1) * 1.0 / n; sum += d; n--; } cout << sum << n ; } int main() { ios_base::sync_with_std...
#include <bits/stdc++.h> using namespace std; long long unsigned int countDivisors(long long unsigned int n) { long long unsigned int cnt = 0; for (long long unsigned int i = 1; i <= sqrt(n); i++) { if (n % i == 0) { if (n / i == i) ++cnt; else cnt += 2; } ...
#include <bits/stdc++.h> using namespace std; long long mp[1005][1005]; long long n, a, b; void output() { for (long long i = 1; i <= n; i++) { for (long long j = 1; j <= n; j++) { if (i == j) printf( 0 ); else printf( %lld , a < b ? !mp[i][j] : mp[i][j]); } ...
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b) { long long ans = 1; while (b > 0) { if (b % 2 != 0) { ans = (ans * a) % 1000000007; } a = ((a % 1000000007) * (a % 1000000007)) % 1000000007; b >>= 1; } return ans; } void sie...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const int maxn = 2e6 + 10; int a[maxn], cnt[maxn]; long long sum[maxn]; int main(void) { int n, x, y; scanf( %d %d %d , &n, &x, &y); int z = x / y; for (int i = 1; i <= n; i++) scanf( %d , a + i), cnt[a[i]]++, su...
#include <bits/stdc++.h> using namespace std; const int md = 1e9 + 7; int n; char s[111]; int f[111][3333]; int main() { int t; f[0][0] = 1; for (int i = 1; i <= 100; ++i) { for (int j = 0; j <= 3000; ++j) { for (int c = 0; c <= min(j, 25); ++c) { f[i][j] += f[i - 1][j - ...
#include <bits/stdc++.h> #pragma GCC optimize ( O3 ) #pragma GCC target ( sse4 ) using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vec...
#include <bits/stdc++.h> using namespace std; long long k, b, n, t; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); cin >> k >> b >> n >> t; long long num = 1; long long step = n; while (t >= num) { num = num * k + b; step--; } if (step < 0) { cout << 0; ...
#include <bits/stdc++.h> const long double pi = 3.14159265359; const long long N = 1e9 + 7; using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, arr[200005]; cin >> n >> m; long long cntne = 0, cntpo = 0; for (int i = 0; i < n; i++)...
#include <iostream> #include <vector> #include <algorithm> #include <string> #define ll long long using namespace std; int main() { ll qua; cin >> qua; for (int i = 0; i < qua; ++i) { ll n; cin >> n; vector<int> vec(n); for (int j = 0; j < n...
#include <bits/stdc++.h> using namespace std; const int MaxN = 100005; const int MaxM = MaxN * 2; const int oo = 0x3F3F3F3F; int ax[MaxM], K; int ret[MaxN]; set<pair<int, int> > tr[MaxM]; struct event { int l, r, v, tp; event() {} event(int l, int r, int v, int tp) : l(l), r(r), v(v), tp(tp)...
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; cout << (regex_match(s, regex( (1|14|144)* )) ? YES : NO ); }
#include <bits/stdc++.h> using namespace std; const int N = 3e3 + 5; int dw[N], up[N], E[N][2], Mn; vector<pair<int, int> > g[N]; void dfs_down(int v, int p) { dw[v] = 0; for (pair<int, int> u : g[v]) if (u.first != p) dfs_down(u.first, v), dw[v] += dw[u.first] + u.second; } void dfs_up(int ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << ceil(n / 2.0) - 1; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int y[N], pos[N]; int main() { int n, m, t = 0, ans = 0, cnt = 0; scanf( %d %d , &n, &m); for (int i = 1; i <= n; i++) scanf( %d , &y[i]); for (int i = 1; i <= m; i++) { int y1, y2, x; scanf( %d %d %d , &y1, &y2, &...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 3) + (x << 1) + (c ^ 0 ), c = getchar(); return x * f; } c...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2001; char a[MAXN][MAXN]; int n, v[MAXN], r[MAXN], c[MAXN]; int gao() { int ret = 0; memset(r, 0, sizeof(int) * n); memset(c, 0, sizeof(int) * n); for (int i = 0; i < n - 1; ++i) { for (int j = n - 1; j > i; --j) { if...
#include<bits/stdc++.h> using namespace std; typedef double db; typedef uint32_t u32; typedef uint64_t u64; typedef pair<int, int> pii; typedef pair<int, int> point; #define fi first #define se second #define pb(x) push_back(x) #define SZ(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end()...
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; set<int> a, b; vector<pair<int, int> > ans(n); for (int i = 0; i < n; ++i) { cin >> ans[i].first >> ans[i].second; --ans[i].first; --ans[i].second; if (ans[i].first == -1) a.insert(i); i...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n], sm = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sm += a[i]; } vector<int> ind, r; int need = sm / 2; if (a[0] > need) { cout << 1 << endl; cout << 1; return 0; }...
#include <bits/stdc++.h> using namespace std; int nbVoyages, coutSimple, coutLiaison, maxCartes, coutCarte; map<pair<string, string>, int> routes; int main() { ios_base::sync_with_stdio(false); cin >> nbVoyages >> coutSimple >> coutLiaison >> maxCartes >> coutCarte; long long total = 0; string d...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; const int mod = 1000000007; int modpow(int x, int y, int md) { if (y == 0) return 1; int ret = modpow(x, y >> 1, md); ret = (long long)ret * ret % md; if (y & 1) ret = (long long)ret * x % md; ...
#include <bits/stdc++.h> using namespace std; string s[3]; int N, M, p[3][1000005], a[3][1000005], b[1000005]; void genPrefix(int pat) { int i, k; p[pat][0] = 0; k = 0; i = 1; while (i < M) { if (s[pat][i] == s[pat][k]) { k++; p[pat][i] = k; i++; } else { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; scanf( %d%d , &n, &x); if (n == 1) { printf( YES n ); printf( %d n , x); } else if (n == 2) { if (x == 0) printf( NO n ); else { printf( YES n ); printf( 0 %d n , x); } } el...
#include <bits/stdc++.h> using namespace std; bool psort(std::vector<long long int> p1, std::vector<long long int> p2) { return p1[0] < p2[0]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, m; cin >> n; std::vector<vector<long long in...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string fld; cin >> fld; int l = 1, r = 2 * n; int ans = -1; while (l <= r) { int mid = (l + r) >> 1; int posbl = 1; int back = -1, flag = 0; for (int i = 0; i < n; i++) { if (fld[i...
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; char s[N]; char t1[7] = twone ; char t2[4] = one ; char t3[4] = two ; int main() { int T; scanf( %d , &T); while (T--) { scanf( %s , s); int ans = 0; int len = strlen(s); for (int i = 0; i < len; i...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); long long int n, m = 0, p = 0, cnt = 0, f = 0; cin >> n; long long int a[n]; for (long long int i = 0; i < n; i++) { cin >> a[i]; if (a[i] < 0) { m++; } if (a[i] > 0) p++; ...
#include <bits/stdc++.h> using namespace std; int n, m; int A[600006]; vector<int> G[600006]; int dfn[600006], bc[600006], clo; int g[600006][20], dep[600006]; void dfs(int u) { dfn[u] = ++clo, bc[clo] = u; if (u == 1) dep[u] = 1; for (int v : G[u]) { g[v][0] = u; dep[v] = dep[u] +...
#include <bits/stdc++.h> using namespace std; struct fenwick { long long n, fen[100005]; void resize(int _n) { n = _n + 1; memset(fen, 0, sizeof fen); } int query(int ind) { ind++; int ans = 0; while (ind >= 1) { ans += fen[ind]; ind -= ind & -ind; ...
#include <bits/stdc++.h> const int maxn = 1e5 + 10; const int N = 5e2 + 10; using namespace std; long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); } long long qpow(long long p, long long q) { long long f = 1; while (q) { if (q & 1) f = f * p % 1000000007; p = p *...
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, t; cin >> t; for (long long int aa = 0; aa < t; aa++) { long long int n, k, d; cin >> n >> k >> d; long long int mini = k; vector<long long int> v(n); map<long long int, long long int> m; f...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int *p = new int[n + 1], c = 0; int *m = new int[n + 1]; for (int i = 0; i <= n; i++) { p[i] = m[i] = 0; c ^= i; m[i] = c; } int f = 0; for (int i = 1; i <= n; i++) { cin >> p[i]; ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; long long a[maxn], b[maxn], dp[maxn]; int q[maxn]; int head = 0, tail = 0; double A(int i, int j) { return dp[i] - dp[j]; } double B(int i, int j) { return b[i] - b[j]; } int main() { ios::sync_with_stdio(false); cin.tie(0);...
#include <bits/stdc++.h> using namespace std; const int MAX_INT = numeric_limits<int>::max(); const int MAX_UINT = numeric_limits<unsigned int>::max(); void get_acum(const vector<int>& v, vector<int>& acum) { int sum = 0; for (unsigned int i = 0; i < v.size(); ++i) { acum.push_back(sum); sum...
#include <bits/stdc++.h> using namespace std; set<long long int> adj[3005]; map<long long int, long long int> mq; long long int done[3005][3005]; int main() { ios_base::sync_with_stdio(false); long long int n, m, i, ans = 0; cin >> n >> m; for (i = 0; i < m; i++) { long long int x, y; ...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int a, b, h; cin >> a >> b >> h; int c = 0; while (h != 0) { if (c % 2 == 0) { h = h - gcd(a, h); } else { h = h - gcd(b, h); } c++; }...
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 5; const double EPS = 1e-3; int n; int t[MAXN]; int g(double q) { bool ok = true; for (int i = 1; i < n; i++) if (fabs(double(t[i] - t[i - 1] * q)) > EPS) ok = false; if (ok) return 0; ok = true; for (int i = 2...
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 5; int a[MAX], run[MAX], ans[MAX]; char s[MAX]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; scanf( %d , &n); scanf( %s , s); for (int i = 0; i < n; ++i) { if (s[i] == 0 ) a[i] = 0; ...
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 1, x = 0; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) { f = -1; } ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); }...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[m], b[m]; int ndup = n; for (int i = 0; i < m; i++) { cin >> a[i]; b[i] = a[i]; } sort(a, a + m); sort(b, b + m, greater<int>()); int mn = 0, mx = 0; for (int i = 0; i < m; i...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, t; cin >> t; while (t--) { cin >> n; cout << (n + 1) / 2 << endl; } }
//...START BY DOING WHAT IS NECESSARY, THEN WHAT IS POSSIBLE AND SUDDENLY YOU ARE DOING THE IMPOSSIBLE... #include <bits/stdc++.h> using namespace std; #define FAST_FURIER ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define pb push_back #define mk make_pair #define rep(i,a,N) for(ll i=a;i<N;...
#include <bits/stdc++.h> using namespace std; long long a, b, c, e[200000], mix, l, r, o, d[200000]; vector<long long> v[100000], v1; set<long long> st; map<long long, long long> mp, mp1; string s; pair<int, int> p[100000], p1[100000]; char ch[10]; deque<char> dq; int main() { cin >> a; for ...
#include <bits/stdc++.h> using namespace std; char s[5000005]; int len[1000005]; int idx[1000005]; int sum[1000005]; int sz = 0; int dp[1000005][20]; int p[1000005]; int main() { int n, r, c; scanf( %d%d%d , &n, &r, &c); gets(s); gets(s); int cnt = 0, slen = 0; for (int i = 0; ...
#include <bits/stdc++.h> using namespace std; char change(char curranswer) { if (curranswer == z ) curranswer = A ; else if (curranswer == Z ) curranswer = 0 ; else if (curranswer == 9 ) ; else curranswer++; return curranswer; } int main() { long long i, j, t...
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { if (y == 0) return x; else return gcd(y, x % y); } long long expo(long long n, long long m) { long long r = 1; while (m > 0) { if (m % 2) r = (r * n) % 1000000009; n = (n * n) % 100000...
#include <bits/stdc++.h> using namespace std; const int N = int(3e5), mod = int(1e9) + 7; int n; int a[N], c[N]; long long t[N]; long long x[N], pref[N]; long double p[N]; long long suf[N]; void upd(int v, int val) { v += n - 1; t[v] += val; c[v]++; while (v > 1) { v >>= 1; ...
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; long long ans = 0; while (true) { long long x = max(a, b); long long y = min(a, b); if (x == 0 || y == 0) break; long long n = x / y; ans += n; x -= n * y; a = x; ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int x, test; cin >> test; while (test--) { int n, c0, c1, h; string s; cin >> n >> c0 >> c1 >> h >> s; int cnt0 = 0, cnt1 = 0; for (auto &z : s) { ...
#include <bits/stdc++.h> using namespace std; const int inf = int(1e9) + 123; int main() { int n, v; cin >> n >> v; vector<int> a; for (int i = 1; i <= n; i++) { int x; cin >> x; a.push_back(x); } sort(a.begin(), a.end()); int sum = 0; for (int i = 0; i < a.size()...
End of preview. Expand in Data Studio

C++ Dataset

documentation source: https://huggingface.co/docs/datasets/main/en/repository_structure

Supported Tasks and Leaderboards

  • language-modeling: The dataset can be used to train a model for modelling programming languages, which consists in building language models for programming languages.

Language

  • C++ programming language

Dataset Structure

Data Instances

A data point consists of a function code along with its documentation. Each data point also contains meta data on the function, such as the repository it was extracted from.

{
  'id': '0',
  'func_code_string': 'organisation/repository'
}

Data Fields

  • id: Arbitrary number
  • func_code_string: actual code line (each line is a whole C++ program)

Data Splits

Three splits are available as .jsonl:

  • train (50000 lines)
  • test (10000 lines)
  • valid (10000 lines)

Citation Information

Downloads last month
297

Models trained or fine-tuned on malteklaes/cpp-code-code_search_net-style