iidai/codenet huggingface dataset:
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
bool check(int n, int wei, vector<int> book) {
    int tmp = wei;
    n--;
    for (int i = 0; i < book.size(); i++) {
        if (tmp < book[i]) {
            if (n > 0) {
                n--;
                tmp = wei;
                if (tmp < book[i]) return false;
            } else
                return false;
        }

        tmp -= book[i];
    }
    return true;
}
int main() {
    int m, n;
    for (; cin >> m >> n, m;) {
        vector<int> book;
        for (int i = 0; i < n; i++) {
            int tmp;
            cin >> tmp;
            book.push_back(tmp);
        }

        int l = 0;
        int r = 1500000;
        int ans;
        while (l < r) {
            if (check(m, (l + r) / 2, book)) {
                ans = (l + r) / 2;
                if (r == (l + r) / 2) break;
                r = (l + r) / 2;

            } else {
                if (l == (l + r) / 2) break;
                l = (l + r) / 2;
            }
        }
        cout << ans << endl;
    }
}

Example test case(s):
input: 3 9
500
300
800
200
100
600
900
700
400
4 3
1000
1000
1000
0 0

output: 1800
1000
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];

    int count = ((N - 1) + ((K - 1) - 1)) / (K - 1);
    cout << count << '\n';
}

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

output: 2
Language: C++

#include <iostream>
#include <queue>

using namespace std;

int main() {
    int train[2];
    int bus[2];

    cin >> train[0] >> train[1];
    cin >> bus[0] >> bus[1];

    cout << (train[0] < train[1] ? train[0] : train[1]) +
                (bus[0] < bus[1] ? bus[0] : bus[1])
         << endl;

    return 0;
}

Example test case(s):
input: 600
300
220
420

output: 520
Language: C++

#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i, a, n) for (Int(i) = (a); (i) < (n); (i)++)
#define repq(i, a, n) for (Int(i) = (a); (i) <= (n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char* const separator = " ") {
    if (!v.empty()) {
        std::copy(v.begin(), --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}
Int gcd(Int a, Int b) { return b != 0 ? gcd(b, a % b) : a; }

Int lcm(Int a, Int b) { return a / gcd(a, b) * b; }

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) { return floor(num) == num; }

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

Int fact_mod(Int n, Int mod) {
    Int f = 1;
    repq(i, 2, n) f = f * (i % MOD) % MOD;
    return f;
}

Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

Int combination_mod(Int n, Int r, Int mod) {
    if (r > n - r) r = n - r;
    if (r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n - i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod - 2, mod);
    return (a % mod) * (b % mod) % mod;
}

bool rev(string s) {
    string t = s;
    reverse(s.begin(), s.end());
    return s == t;
}
int main() {
    IOS;
    prec;
    Int a, b, c, n, m, k, x, y = 0, ans = 0;
    string str, s, t, u;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG";

    cout << endl;
    return 0;
}

Example test case(s):
input: 7
500 600

output: OK
Language: C++

#include <iostream>
#include <string>

std::string check(int x, int y) {
    if (y % 2 == 0) {
        int t = (int)(0.5 * y) - x;
        if (t >= 0 && (x - t) >= 0) return "Yes";
    }
    return "No";
}

int main() {
    int x, y;
    std::cin >> x >> y;

    std::cout << check(x, y) << std::endl;
    return 0;
}

Example test case(s):
input: 3 8

output: Yes
Language: C++

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
const int INF = 200000005;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
    return 0;
}

Example test case(s):
input: 5 4

output: Yay!
Language: C++

#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define co(x) cout << x << '\n'
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bitcount(x) (int)__builtin_popcount(x)
#define sz(x) (int)x.size()
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pii pair<int, int>
#define lcm(a, b) (a * b) / __gcd(a, b)
using namespace std;

inline void solve() {
    int n, ans = 0;
    cin >> n;
    co(!n);
}

signed main() {
    int n = 1;
    while (n--) solve();
    return 0;
}

Example test case(s):
input: 1

output: 0
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
ll n, k, ans, L, ans2;
string s;

int main(void) {
    cin >> n >> k;
    cin >> s;
    L = s[0];
    ll cnt = 0;
    for (int i = 1; i < n; i++) {
        if (L == s[i])
            cnt++;
        else {
            L = s[i];
            ans += cnt;
            ans2++;
            cnt = 0;
        }
    }
    ans += cnt;
    ans2++;
    cout << ans + min(2 * k, ans2 - 1) << endl;
}

Example test case(s):
input: 6 1
LRLRRL

output: 3
Language: C++

#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int time2min(int month, int day, int hour, int min) {
    const int total_day_of_month[] = {31, 28, 31, 30, 31, 30,
                                      31, 31, 30, 31, 30, 31};
    int total = 0;
    for (int i = 1; i < month; i++) {
        total += total_day_of_month[i] * 24 * 60;
    }
    for (int i = 1; i < day; i++) {
        total += 24 * 60;
    }
    total += hour * 60 + min;

    return total;
}

int main() {
    int N;
    while (~scanf("%d", &N)) {
        if (N == 0) break;

        map<int, vector<int> > log;
        for (int i = 0; i < N; i++) {
            int month, day, hour, min, id;
            char action[2];
            scanf("%d/%d %d:%d %s %d", &month, &day, &hour, &min, action, &id);

            int t = time2min(month, day, hour, min);
            log[id].push_back(t);
        }

        int total[1000];
        memset(total, 0, sizeof(total));

        for (int i = 0; i + 1 < log[0].size(); i += 2) {
            int god_start = log[0][i];
            int god_end = log[0][i + 1];

            for (map<int, vector<int> >::iterator it = log.begin();
                 it != log.end(); it++) {
                int id = it->first;
                if (id == 0) continue;
                vector<int>& schedule = it->second;
                for (int j = 0; j < schedule.size(); j += 2) {
                    int ppl_start = schedule[j];
                    int ppl_end = schedule[j + 1];
                    int start = max(god_start, ppl_start);
                    int end = min(god_end, ppl_end);
                    total[id] += max(0, end - start);
                }
            }
        }

        int max_v = 0;
        for (int id = 0; id < 1000; id++) {
            max_v = max(total[id], max_v);
        }
        printf("%d\n", max_v);
    }
}

Example test case(s):
input: 14
04/21 09:00 I 000
04/21 09:00 I 001
04/21 09:15 I 002
04/21 09:30 O 001
04/21 09:45 O 000
04/21 10:00 O 002
04/28 09:00 I 003
04/28 09:15 I 000
04/28 09:30 I 004
04/28 09:45 O 004
04/28 10:00 O 000
04/28 10:15 O 003
04/29 20:00 I 002
04/29 21:30 O 002
20
06/01 09:00 I 001
06/01 09:15 I 002
06/01 09:15 I 003
06/01 09:30 O 002
06/01 10:00 I 000
06/01 10:15 O 001
06/01 10:30 I 002
06/01 10:45 O 002
06/01 11:00 I 001
06/01 11:15 O 000
06/01 11:30 I 002
06/01 11:45 O 001
06/01 12:00 O 002
06/01 12:15 I 000
06/01 12:30 I 002
06/01 12:45 O 000
06/01 13:00 I 000
06/01 13:15 O 000
06/01 13:30 O 002
06/01 13:45 O 003
0

output: 45
120
Language: C++

#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
    int n, m;
    int k, a;
    int x[31] = {};
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> a;
            x[a]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= m; ++i) {
        if (x[i] == n) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

output: 1
Language: C++

#include <cassert>
#include <climits>
#include <iostream>
#include <vector>

struct TSize {
    int r;
    int c;
    TSize() : r(0), c(0) {}
    TSize(int Ar, int Ac) : r(Ar), c(Ac) {}
};

class TMcmSolver {
    typedef std::vector<std::vector<int> > TMatrix;
    TMatrix FMemo;
    const std::vector<TSize>& FChain;

    static int Count(const TSize& Left, const TSize& Right) {
        return Left.r * Right.c * Left.c;
    }
    int Solve(int s, int l) {
        assert(s <= l);
        if (s == l) return 0;
        if (FMemo[s][l] != 0) return FMemo[s][l];
        if (s + 1 == l) {
            FMemo[s][l] = Count(FChain[s], FChain[l]);
        } else {
            int min = INT_MAX;
            for (int i = s; i < l; ++i) {
                int c = Solve(s, i) +
                        Count(TSize(FChain[s].r, FChain[i].c),
                              TSize(FChain[i + 1].r, FChain[l].c)) +
                        Solve(i + 1, l);
                min = std::min(min, c);
            }
            FMemo[s][l] = min;
        }

        return FMemo[s][l];
    }

   public:
    TMcmSolver(const std::vector<TSize>& Chain) : FChain(Chain) {
        FMemo.resize(Chain.size());
        for (std::size_t i = 0; i < FMemo.size(); ++i) {
            FMemo[i].resize(Chain.size(), 0);
        }
    }
    int Answer() { return Solve(0, FMemo.size() - 1); }
    void Print() const {
        for (std::size_t s = 0; s < FMemo.size(); ++s) {
            for (std::size_t l = 0; l < FMemo[0].size(); ++l) {
                std::cout << FMemo[s][l] << '\t';
            }
            std::cout << '\n';
        }
    }
};

int main() {
    int n;
    std::cin >> n;
    if (n == 1) {
        std::cout << 0 << std::endl;
        return 0;
    }
    std::vector<TSize> Chain(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> Chain[i].r >> Chain[i].c;
    }
    TMcmSolver Solver(Chain);

    std::cout << Solver.Answer() << std::endl;

    return 0;
}

Example test case(s):
input: 6
30 35
35 15
15 5
5 10
10 20
20 25

output: 15125
Language: C++

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

int main() {
    map<int, int> m;
    for (int i = 0; i * 200 < 5001; i++) {
        for (int j = 0; j * 300 < 5001; j++) {
            for (int k = 0; k * 500 < 5001; k++) {
                int w = i * 200 + j * 300 + k * 500;
                int p = i / 5 * 5 * 380 * 0.8 + i % 5 * 380 +
                        j / 4 * 4 * 550 * 0.85 + j % 4 * 550 +
                        k / 3 * 3 * 850 * 0.88 + k % 3 * 850;
                if (m[w])
                    m[w] = min(m[w], p);
                else
                    m[w] = p;
            }
        }
    }
    int n;
    while (cin >> n, n) {
        cout << m[n] << endl;
    }
}

Example test case(s):
input: 500
2200
0

output: 850
3390
Language: C++

#include <iostream>

int main() {
    int N, A;
    std::cin >> N;
    std::cin >> A;
    std::cout << N * N - A << std::endl;
}

Example test case(s):
input: 3
4

output: 5
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;

#define FastIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;

const int N = int(2e5) + 10;
const int K = int(2e6) + 10;
const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 5;
const ll INF64 = 2e18;

void solve() {
    ll ans = 0;
    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        ans += i * 1ll * (n - i + 1);
    }
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        int a = max(u, v);
        int b = min(u, v);
        ans -= b * 1ll * (n - a + 1);
    }
    cout << ans << endl;
}

int main() {
    FastIO

        int t;

    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

output: 7
Language: C++

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

int main() {
    string str;
    cin >> str;

    int max = 0, cnt = 0;
    for (auto sc : str) {
        if (sc == 'A' || sc == 'C' || sc == 'G' || sc == 'T') {
            cnt++;
        } else {
            cnt = 0;
        }
        max = max < cnt ? cnt : max;
    }

    cout << max << endl;
}

Example test case(s):
input: ATCODER

output: 3
Language: C++

#include <cmath>
#include <iostream>

using namespace std;

int main() {
    long long x, y;
    cin >> x >> y;
    if (abs(x - y) <= 1)
        cout << "Brown" << endl;
    else
        cout << "Alice" << endl;
}

Example test case(s):
input: 2 1

output: Brown
Language: C++

#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a + b == c || b + c == a || a + c == b) ? "Yes" : "No") << endl;
}

Example test case(s):
input: 10 30 20

output: Yes
Language: C++

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

int main() {
    int n;
    char str[10], com[13];
    map<string, bool> T;

    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%s%s", com, str);
        if (com[0] == 'i')
            T[string(str)] = true;
        else {
            if (T[string(str)])
                printf("yes\n");
            else
                printf("no\n");
        }
    }
    return 0;
}

Example test case(s):
input: 5
insert A
insert T
insert C
find G
find A

output: no
yes
Language: C++

#include <math.h>

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template <typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template <typename T>
map<T, T> getPrimeFactor(T n) {
    map<T, T> res;
    for (T i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

template <typename T>
bool IsPrimeNumber(T num) {
    if (num <= 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

#define rep(i, s, e) for (ll i = s; i < e; i++)
#define repeq(i, s, e) for (ll i = s; i <= e; i++)

int main() {
    ll N, K;
    std::cin >> N >> K;

    vll A(N + 1);
    repeq(i, 1, N) { std::cin >> A[i]; }

    ll cur = 1;
    vll dic(N + 1, -1);
    bool flg = false;
    repeq(i, 1, K) {
        if (dic[cur] < 0 || flg) {
            dic[cur] = i;
            cur = A[cur];
        } else if (!flg) {
            ll tmp = K - (dic[cur] - 1);
            tmp %= i - dic[cur];
            i = K - tmp;
            flg = true;
        }
    }

    std::cout << cur << endl;
    return 0;
}

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

output: 4
Language: C++

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int M = 1010;
char a[M], b[M];
int n, m, ans = M + 10;

int main() {
    scanf("%s", a + 1);
    n = strlen(a + 1);
    scanf("%s", b + 1);
    m = strlen(b + 1);
    for (int i = 1; i + m - 1 <= n; i++) {
        int sum = 0;
        for (int j = 1; j <= m; j++)
            if (a[i + j - 1] != b[j]) sum++;
        ans = min(ans, sum);
    }
    printf("%d\n", ans);

    return 0;
}

Example test case(s):
input: cabacc
abc

output: 1
Language: C++

#pragma region
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s)-1; (i) >= 0; --(i))
#define all(x) x.begin(), x.end()
#pragma endregion

int main() {
    ll n, k;
    cin >> n >> k;
    ll MOD = 1e9 + 7;
    ll mx = n * (n + 1) / 2 - (n - k) * (n - k + 1) / 2;
    ll mn = k * (k - 1) / 2;
    ll res = 0;
    for (int i = k; i <= n + 1; ++i) {
        res += mx - mn + 1;
        mx += n - i;
        mn += i;
        res %= MOD;
    }
    cout << res << endl;
}

Example test case(s):
input: 3 2

output: 10
Language: C++

#include <iostream>
using namespace std;
int main() {
    int N, ans, i, count;
    cin >> N;
    int A[N];
    for (i = 0; i < N; i++) {
        cin >> A[i];
    }
    i = 0;
    ans = 0;
    count = 0;
    while (A[i + 1] != NULL) {
        if (A[i] == A[i + 1]) {
            count++;
            if (count % 2 != 0) ans++;
        } else
            count = 0;
        i++;
    }

    cout << ans << "\n";
    return 0;
}

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

output: 2
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    int p[n];
    for (int i = 0; i < n; i++) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
        if (p[i] > p[i + 1] && p[i + 1] > p[i + 2]) ans++;
        if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) ans++;
    }

    cout << ans << "\n";
    return 0;
}

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

output: 2
Language: C++

#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

typedef pair<int, int> P;

bool d[10] = {0};
int n, k;
bool hantei = true;

int main() {
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        int a;
        cin >> a;
        d[a] = 1;
    }
    while (1) {
        int x = n;
        hantei = 1;
        while (x) {
            if (d[x % 10]) {
                hantei = 0;
                break;
            }
            x /= 10;
        }
        if (hantei) {
            cout << n << endl;
            break;
        }
        n++;
    }
}

Example test case(s):
input: 1000 8
1 3 4 5 6 7 8 9

output: 2000