iidai/codenet huggingface dataset:
Language: C++

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int NMAX = 1000010;

ll fac[NMAX], finv[NMAX], inv[NMAX];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < NMAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll C(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    init();
    int X, Y;
    cin >> X >> Y;
    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int n = (X + Y) / 3 + 1;
    int k = 2 * (n - 1) - Y + 1;
    cout << C(n - 1, k - 1) << endl;
    return 0;
}

Example test case(s):
input: 3 3

output: 2
Language: C++

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
const long long int MOD = 1e9 + 7;

int main() {
    int r;
    cin >> r;
    cout << r * r << endl;
}

Example test case(s):
input: 2

output: 4
Language: C++

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b >= c) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Example test case(s):
input: 50 100 120

output: Yes
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
int n, k, t;
std::vector<int> vec;
int ans = 1000000001;
int main() {
    std::cin >> n >> k;
    for (int i = 0; i < n; i++) {
        std::cin >> t;
        vec.push_back(t);
    }
    std::sort(vec.begin(), vec.end());
    for (int i = 0; i + k - 1 < n; i++) {
        int diff = vec[i + k - 1] - vec[i];
        if (diff < ans) {
            ans = diff;
        }
    }
    std::cout << ans << std::endl;
}

Example test case(s):
input: 5 3
10
15
11
14
12

output: 2
Language: C++

#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL = (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (A + B >= K) {
        cout << min(A, K) << endl;
    } else {
        cout << A - (K - (A + B)) << endl;
    }
}

Example test case(s):
input: 2 1 1 3

output: 2
Language: C++

#include <stdio.h>
int main() {
    int n, k;
    long long int l = 0, r = 0;
    scanf("%d%d", &n, &k);
    if (k % 2 == 0) {
        for (int i = 1; i <= n; i++)
            if (i % k == k / 2)
                l++;
            else if (i % k == 0)
                r++;
        printf("%lld\n", l * l * l + r * r * r);
    } else {
        for (int i = 1; i <= n; i++)
            if (i % k == 0) r++;
        printf("%lld\n", r * r * r);
    }
}

Example test case(s):
input: 3 2

output: 9
Language: C++

#include <stdlib.h>

#include <algorithm>
#include <iostream>
using namespace std;

int gcd(int a, int b) {
    if (a == 0) return b;
    return gcd(b % a, a);
}

int main() {
    int R;
    cin >> R;
    if (R < 1200)
        cout << "ABC" << endl;
    else if (R >= 2800)
        cout << "AGC" << endl;
    else
        cout << "ARC" << endl;
}

Example test case(s):
input: 1199

output: ABC
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <numeric>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> L(100000);
    int l;
    for (int i = 0; i < N; i++) {
        scanf("%d", &l);
        L[i] = l;
    }

    sort(L.begin(), L.end());

    vector<int>::iterator itr;

    for (int i = 0; i < M; i++) {
        int max_L = L.back();
        if (max_L == 0) {
            break;
        }

        max_L /= 2;
        itr = lower_bound(L.begin(), L.end(), max_L);
        L.insert(itr, max_L);
        L.pop_back();
    }

    long long ans = accumulate(L.begin(), L.end(), 0LL);

    cout << ans << '\n';
}

Example test case(s):
input: 3 3
2 13 8

output: 9
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PP;
ll key[1005] = {0};
ll cost[1005] = {0};
ll dp[(1 << 12) + 5][1005] = {0};
const ll INF = 123456789012;
int main() {
    ll n, m;
    cin >> n >> m;
    for (int i = 0; i < (1 << 12) + 5; i++) {
        for (int j = 0; j < 1005; j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++) {
        ll b;
        cin >> cost[i] >> b;
        for (int j = 0; j < b; j++) {
            ll c;
            cin >> c;
            key[i] += (1 << (c - 1));
        }
    }
    for (ll i = 0; i < (1 << n); i++) {
        for (int j = 0; j < m; j++) {
            dp[i][j + 1] = min(dp[i][j], dp[i][j + 1]);
            dp[i | key[j + 1]][j + 1] =
                min(dp[i | key[j + 1]][j + 1], dp[i][j] + cost[j + 1]);
        }
    }
    if (dp[(1 << n) - 1][m] == INF)
        cout << -1 << endl;
    else
        cout << dp[(1 << n) - 1][m] << endl;
}

Example test case(s):
input: 2 3
10 1
1
15 1
2
30 2
1 2

output: 25
Language: C++

#include <algorithm>
#include <cstdlib>
#include <iostream>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 2 * 1e5 + 10;
int a[MAXN], n, L[MAXN / 2], R[MAXN / 2];
LL merge(int left, int mid, int right) {
    int i, j, k;
    LL cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i = 0; i < n1; ++i) L[i] = a[left + i];
    for (i = 0; i < n2; ++i) R[i] = a[mid + i];
    L[n1] = R[n2] = INF;
    i = j = 0;
    for (k = left; k < right; ++k) {
        if (L[i] <= R[j])
            a[k] = L[i++];
        else {
            a[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}
LL mergesort(int left, int right) {
    int mid;
    LL v1, v2, v3;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergesort(left, mid);
        v2 = mergesort(mid, right);
        v3 = merge(left, mid, right);
        return v1 + v2 + v3;
    }
    return 0;
}
int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    LL ans = mergesort(0, n);
    cout << ans << '\n';
    return 0;
}

Example test case(s):
input: 5
3 5 2 1 4

output: 6
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 1e18 + 1;

ll f(ll N) {
    vector<ll> a(20, 0);
    ll d = 0;
    while (N > 0) {
        a[d] = N % 10;
        N /= 10;
        d++;
    }
    double m = 1e18;
    ll res = N;
    for (int i = 0; i <= d; i++) {
        ll bunsi = 0;
        ll bunbo = 9 * i;
        for (int j = d - 1; j >= 0; j--) {
            bunsi *= 10;
            if (j < i)
                bunsi += 9;
            else
                bunsi += a[j];

            if (j >= i) bunbo += a[j];
        }

        double frac = (double)bunsi / (double)bunbo;
        if (frac < m) {
            m = frac;
            res = bunsi;
        }
    }
    return res;
}

int main() {
    ll K;
    cin >> K;
    ll N = f(1);
    for (ll i = 0; i < K; i++) {
        cout << N << endl;
        N = f(N + 1);
    }
}

Example test case(s):
input: 10

output: 1
2
3
4
5
6
7
8
9
19
Language: C++

#include <iostream>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int M[N][N], n;
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for (v = 0; v < n; v++) {
        if (M[u][v] == 0) continue;
        if (color[v] == WHITE) {
            dfs_visit(v);
        }
    }
    color[u] = BLACK;
    f[u] = ++tt;
}

void dfs() {
    int u;
    for (int i = 0; i < n; i++) {
        color[i] = WHITE;
    }
    tt = 0;

    for (u = 0; u < n; u++) {
        if (color[u] == WHITE) dfs_visit(u);
    }

    for (int i = 0; i < n; i++)
        cout << i + 1 << " " << d[i] << " " << f[i] << endl;
}

int main() {
    int k, u, v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) M[i][j] = 0;
    }
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    dfs();

    return 0;
}

Example test case(s):
input: 4
1 1 2
2 1 4
3 0
4 1 3

output: 1 1 8
2 2 7
3 4 5
4 3 6
Language: C++

#include <iostream>
#include <vector>
#define MIN(a, b) ((a < b) ? a : b)
#define INF 1000000001
#define N 100000

using namespace std;

struct edge {
    int source;
    int target;
    int weight;
};

vector<edge> edges;

int distances[N];
int prev_distances[N] = {0};

int main() {
    int V, E, r;

    cin >> V >> E >> r;

    for (int i = 0; i < E; i++) {
        int source, target, distance;
        cin >> source >> target >> distance;
        edge new_edge = {source, target, distance};
        edges.push_back(new_edge);
    }

    for (int i = 0; i < N; i++) {
        distances[i] = INF;
    }

    distances[r] = 0;

    for (int i = 1; i < V; i++) {
        for (int j = 0; j < V; j++) {
            prev_distances[j] = distances[j];
        }

        for (vector<edge>::iterator edgeptr = edges.begin();
             edgeptr != edges.end(); edgeptr++) {
            distances[edgeptr->target] =
                MIN(distances[edgeptr->source] + edgeptr->weight,
                    distances[edgeptr->target]);
        }

        bool same = true;
        for (int j = 0; j < V; j++) {
            if (distances[j] != prev_distances[j]) {
                same = false;
                break;
            }
        }

        if (same) break;
    }

    for (int i = 0; i < V; i++) {
        if (distances[i] == INF) {
            cout << "INF" << endl;
        } else {
            cout << distances[i] << endl;
        }
    }
}

Example test case(s):
input: 4 5 0
0 1 1
0 2 4
1 2 2
2 3 1
1 3 5

output: 0
1
3
4
Language: C++

#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int mem[N + 1];
    for (int i = 1; i <= N; ++i) {
        int P;
        cin >> P;
        mem[P] = i;
    }

    int maxcnt = 1;
    int cnt = 1;
    for (int i = 1; i < N; ++i) {
        if (mem[i] < mem[i + 1]) {
            cnt++;
        } else {
            maxcnt = max(maxcnt, cnt);
            cnt = 1;
        }
        if (i == N - 1) {
            maxcnt = max(maxcnt, cnt);
        }
    }

    cout << N - maxcnt << endl;
    return 0;
}

Example test case(s):
input: 4
1
3
2
4

output: 2
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main() {
    int a;
    int b;
    cin >> a;
    cin >> b;
    int result;
    if (a > b) {
        result = 2 * a - 1;
    } else if (a == b) {
        result = 2 * a;
    } else {
        result = 2 * b - 1;
    }
    cout << result << endl;

    return 0;
}

Example test case(s):
input: 5 3

output: 9
Language: C++

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <cstring>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#pragma warning(disable : 4996)

typedef long long ll;
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;

using namespace std;

int main(int argc, char* argv[]) {
    int n;
    scanf("%d", &n);

    vector<int> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int curr = 0;
    for (i = 0; i < n; i++) {
        if (a[i] == curr + 1) curr++;
    }
    if (curr > 0) {
        printf("%d\n", n - curr);
    } else {
        printf("-1\n");
    }

    return 0;
}

Example test case(s):
input: 3
2 1 2

output: 1
Language: C++

#include <iostream>
using namespace std;
int main() {
    char B, OUT;
    cin >> B;
    if (B == 'A')
        OUT = 'T';
    else if (B == 'T')
        OUT = 'A';
    else if (B == 'C')
        OUT = 'G';
    else
        OUT = 'C';
    cout << OUT << endl;
}

Example test case(s):
input: A

output: T
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define int long long

struct Ban {
    int l;
    int r;
    int val;

    Ban() {}

    Ban(int l_, int r_, int val_) {
        l = l_;
        r = r_;
        val = val_;
    }
};

namespace Sp {
const int LIM = 20;
const int N = 2e5 + 7;

int mn[LIM][N];
int pw[N];

void init(vector<int> a) {
    int n = (int)a.size();
    for (int i = 0; i < n; i++) {
        mn[0][i] = a[i];
    }
    for (int i = 0; i + 1 < LIM; i++) {
        for (int j = 0; j + (1 << (i + 1)) <= n; j++) {
            mn[i + 1][j] = max(mn[i][j], mn[i][j + (1 << i)]);
        }
    }
    pw[1] = 0;
    for (int i = 2; i < N; i++) {
        pw[i] = pw[i / 2] + 1;
    }
}

int get(int l, int r) {
    r++;
    int p = pw[r - l];
    return min(mn[p][l], mn[p][r - (1 << p)]);
}
}  // namespace Sp

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &t : a) {
        cin >> t;
    }
    vector<int> dl(n);
    for (int i = 0; i < n; i++) {
        if (a[i] > i) {
            cout << -1 << endl;
            return 0;
        }
        dl[i] = i - a[i];
    }

    int ans = 0;
    vector<Ban> bans;
    for (int i = 0; i < n; i++) {
        int r = i;
        while (r + 1 < n && a[r] + 1 == a[r + 1]) {
            r++;
        }
        ans += a[r];
        i = r;
        bans.push_back(Ban(r - a[r], r, r - a[r]));
    }
    Sp::init(dl);
    for (auto t : bans) {
        if (Sp::get(t.l, t.r) > t.val) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Example test case(s):
input: 4
0
1
1
2

output: 3
Language: C++

#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    ll x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    const ll dx = x2 - x1, dy = y2 - y1;
    ll x3 = x2 - dy, y3 = y2 + dx;
    ll x4 = x1 - dy, y4 = y1 + dx;
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
    return 0;
}

Example test case(s):
input: 0 0 0 1

output: -1 1 -1 0
Language: C++

#include <iostream>
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define all(x) (x).begin(), (x).end()

void solve() {}
int main() {
    int a, b;
    cin >> a >> b;
    string ans;
    if (a == 1 || b == 1) {
        if (a == 1 && b == 1) {
            ans = "Draw";
        } else if (a == 1) {
            ans = "Alice";
        } else {
            ans = "Bob";
        }
    } else {
        if (a == b) {
            ans = "Draw";
        } else if (a > b) {
            ans = "Alice";
        } else {
            ans = "Bob";
        }
    }
    cout << ans << endl;

    return 0;
}

Example test case(s):
input: 8 6

output: Alice
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define FORQ(i, b, e) for (int i = (b); i <= (e); ++i)
#define FORD(i, b, e) for (int i = (b)-1; i >= (e); --i)
#define REP(x, n) for (int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int, int>
#define pll pair<LL, LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vi s(m), c(m);
    FOR(i, 0, m) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    FOR(i, 0, 1000) {
        string st = to_string(i);
        if (st.length() != n) {
            continue;
        }

        int f = 1;
        FOR(j, 0, m) {
            if (st[s[j]] == c[j] + '0') {
            } else {
                f = 0;
            }
        }
        if (f) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Example test case(s):
input: 3 3
1 7
3 2
1 7

output: 702
Language: C++

#include <iostream>
#include <string>
using namespace std;
int d;
string map[105];
int n;

void visit() {
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {-1, 0, 1, 0};
    int sum, flg = 0;
    int x = 2, y = n;
    map[y][x] = ' ';
    int ab[4] = {2, 2, 2, 2};

    while (1) {
        sum = 0;
        while (1) {
            if (map[y + dy[flg] * 2][x + dx[flg] * 2] != '#' &&
                map[y + dy[flg]][x + dx[flg]] != ' ') {
                flg++;

                break;
            }

            map[y + dy[flg]][x + dx[flg]] = ' ';
            y = y + dy[flg];
            x = x + dx[flg];
            sum++;
        }
        if (flg == 4) flg = 0;
        if (sum == 0) break;
        ab[0] = ab[1];
        ab[1] = ab[2];
        ab[2] = sum;
        if (ab[0] == 1 && ab[2] == 1 && ab[1] == 1) break;
    }
}

int main() {
    cin >> d;

    for (int l = 0; l < d; l++) {
        cin >> n;

        if (n == 1) {
            cout << "#" << endl;
            if (l != d - 1) cout << endl;
            continue;
        }

        for (int i = 0; i <= n + 1; i++) {
            map[i].resize(n + 2);
            for (int j = 0; j <= n + 1; j++) {
                map[i][j] = '#';
                if (i == 0 || j == 0 || i == n + 1 || j == n + 1)
                    map[i][j] = '.';
            }
        }

        visit();

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < map[i].size() - 1; j++) {
                cout << map[i][j];
            }
            cout << endl;
        }
        if (l != d - 1) cout << endl;
    }
    return 0;
}

Example test case(s):
input: 2
5
6

output: #####
#   #
# # #
# # #
# ###

######
#    #
# ## #
# #  #
# #  #
# ####
Language: C++

#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> m;
    m.push_back(10);
    m.push_back(50);
    m.push_back(100);
    m.push_back(500);

    bool first = true;
    for (int money; cin >> money, money;) {
        if (!first) cout << endl;

        first = false;
        int sum = 0;
        vector<int> num(4);
        for (int i = 0; i < 4; ++i) {
            cin >> num[i];
            sum += num[i] * m[i];
        }

        int change = sum - money;
        for (int i = 3; i >= 0; --i) {
            if (change / m[i]) {
                num[i] = num[i] - change / m[i];
                change %= m[i];
            }
        }

        for (int i = 0; i < 4; ++i)
            if (num[i] > 0) cout << m[i] << " " << num[i] << endl;
    }

    return EXIT_SUCCESS;
}

Example test case(s):
input: 160
1 1 2 0
160
1 0 2 10
0

output: 10 1
50 1
100 1

10 1
100 2
Language: C++

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
    ll H, W;
    cin >> H >> W;

    ll ans;
    if (H == 1 || W == 1) {
        ans = 1;
    } else {
        ll m = H * W;
        if (m % 2 == 0)
            ans = m / 2;
        else
            ans = m / 2 + 1;
    }
    cout << ans << endl;
    return 0;
}

Example test case(s):
input: 4 5

output: 10
Language: C++

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
    int n, d;
    cin >> n >> d;

    double a = d * 2 + 1;
    cout << ceil(n / a) << endl;

    return 0;
}

Example test case(s):
input: 6 2

output: 2
Language: C++

#include <iostream>
using namespace std;
int main() {
    int x;
    cin >> x;
    cout << x * x * x << endl;
}

Example test case(s):
input: 2

output: 8
Language: C++

#include <cmath>
#include <iostream>
using namespace std;

int div(int n);

int main() {
    int num;
    cin >> num;
    cout << num << ":";

    while (num != 1) {
        cout << " " << div(num);
        num = num / div(num);
    }
    cout << endl;
}

int div(int n) {
    if (n % 2 == 0) return 2;
    int s = sqrt(n);
    for (int i = 3; i <= s; i += 2) {
        if (n % i == 0) return i;
    }

    return n;
}

Example test case(s):
input: 12

output: 12: 2 2 3
Language: C++

#include <stdio.h>

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int s[11], i;
    for (i = 0; i < 10; i++) {
        scanf("%d", &s[i]);
    }
    sort(s, s + 10);
    for (i = 9; i > 6; i--) {
        printf("%d\n", s[i]);
    }
    return 0;
}

Example test case(s):
input: 1819
2003
876
2840
1723
1673
3776
2848
1592
922

output: 3776
2848
2840
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for (int i = 0; i < N; i++) cin >> L[i];

    int i;
    int d = 0;
    for (i = 0; i < N; i++) {
        d = d + L[i];
        if (d > X) break;
    }

    cout << i + 1 << endl;
}

Example test case(s):
input: 3 6
3 4 5

output: 2