iidai/codenet huggingface dataset:
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define MAX_L 22
int N;
vector<P> G[100000];
int U[MAX_L][100000], R[100000];
long long L[100000];

void dfs(int x, int p, int r, long long l) {
    U[0][x] = p;
    R[x] = r;
    L[x] = l;
    for (P pp : G[x]) {
        int t = pp._1;
        if (t == p) continue;
        dfs(t, x, r + 1, l + pp._2);
    }
}

int lca(int a, int b) {
    if (R[a] > R[b]) swap(a, b);
    for (int k = 0; k < MAX_L; k++) {
        if ((R[a] - R[b]) >> k & 1) b = U[k][b];
    }
    if (a == b) return a;
    for (int k = MAX_L - 1; k >= 0; k--) {
        if (U[k][a] != U[k][b]) {
            a = U[k][a];
            b = U[k][b];
        }
    }
    return U[0][a];
}
long long dist(int x, int y) {
    int g = lca(x, y);
    return L[x] + L[y] - 2LL * L[g];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].pb(P(b, c));
        G[b].pb(P(a, c));
    }
    rep(i, MAX_L) rep(j, N) U[i][j] = -1;
    dfs(0, -1, 0, 0);
    for (int i = 0; i < MAX_L - 1; i++) {
        for (int v = 0; v < N; v++) {
            if (U[i][v] == -1) U[i + 1][v] = -1;
            U[i + 1][v] = U[i][U[i][v]];
        }
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    rep(i, Q) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << dist(x, K) + dist(K, y) << "\n";
    }
    return 0;
}

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

output: 3
2
4
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
    return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class T>
string to_string(vector<T> v) {
    string ret = "{";
    for (int i = 0; i < v.size() - 1; ++i) {
        ret += to_string(v[i]) + ",";
    }
    if (v.size() > 0) {
        ret += to_string(v.back());
    }
    ret += "}";
    return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
    cerr << to_string(head) << " ";
    debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
    cout << to_string(head);
    print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
    cin >> head;
    get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
    for (int i = 0; i < vec.size(); ++i) cin >> vec[i];
}

int main() {
    string S;
    cin >> S;
    if (S == "Sunny") {
        print("Cloudy");
    } else if (S == "Cloudy") {
        print("Rainy");
    } else {
        print("Sunny");
    }
    return 0;
}

Example test case(s):
input: Sunny

output: Cloudy
Language: C++

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

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#include <set>

int main(void) {
    int n, m;

    cin >> n >> m;

    int ans = 0;

    ans += n * (n - 1) / 2;

    ans += m * (m - 1) / 2;

    cout << ans << endl;
}

Example test case(s):
input: 2 1

output: 1
Language: C++

#pragma GCC optimize(2)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define mod 1000000007
#define mod9 998244353
#define ld long double
#define ull unsigned long long
#define db double
#define ll long long
const db eps = 1e-7;

const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
#define rep(i, be, en) for (ll i = be; i <= en; i++)
#define per(i, be, en) for (int i = en; i >= be; i--)
using namespace std;
const int N = 1e5 + 7;

int tc, n, m, fl = 0;

int main() {
    scanf("%d%d%d", &tc, &n, &m);
    if (n > m) swap(n, m);
    for (int i = 1; i <= m; i++) {
        if (i * tc >= n && i * tc <= m) {
            printf("OK\n");
            fl = 1;
            break;
        }
    }
    if (fl == 0) puts("NG");
    return 0;
}

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

output: OK
Language: C++

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
int main() {
    long long int a, b, x;
    scanf("%lld%lld%lld", &a, &b, &x);
    long long int s = (b / x - a / x);
    if (a % x == 0) s++;
    printf("%lld\n", s);
    return 0;
}

Example test case(s):
input: 4 8 2

output: 3
Language: C++

#include <iostream>
#include <vector>

int main() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> foods(m);

    for (int i = 0; i < n; i++) {
        int k;
        std::cin >> k;

        for (int j = 0; j < k; j++) {
            int temp;
            std::cin >> temp;
            temp--;

            foods[temp]++;
        }
    }

    int ans = 0;
    for (auto elem : foods) {
        if (elem == n) {
            ans++;
        }
    }

    std::cout << ans << std::endl;
}

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

output: 1
Language: C++

#include <iostream>

using namespace std;

int main() {
    int m, f, r;
    while (cin >> m >> f >> r && (m != -1 || f != -1 || r != -1)) {
        if (m == -1 || f == -1)
            cout << "F";
        else if (m + f >= 80)
            cout << "A";
        else if (m + f >= 65)
            cout << "B";
        else if (m + f >= 50 || r >= 50)
            cout << "C";
        else if (m + f >= 30)
            cout << "D";
        else
            cout << "F";
        cout << endl;
    }

    return 0;
}

Example test case(s):
input: 40 42 -1
20 30 -1
0 2 -1
-1 -1 -1

output: A
C
F
Language: C++

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

using namespace std;

#define int long long
#define REP(i, s, e) for ((i) = (s); (i) < (e); (i)++)
#define RREP(i, s, e) for ((i) = ((s)-1); (i) >= (e); (i)--)
#define FOR(i, n) for ((i) = (0); (i) < (n); (i)++)
#define RFOR(i, n) for ((i) = ((n)-1); (i) >= (0); (i)--)
#define MOD 1000000007

signed main() {
    vector<string> v;
    int N, L;

    cin >> N >> L;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        v.push_back(s);
    }

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

    for (int i = 0; i < v.size(); i++) {
        cout << v[i];
    }
    cout << endl;
}

Example test case(s):
input: 3 3
dxx
axx
cxx

output: axxcxxdxx
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    string W;
    cin >> W;

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

    for (string::iterator itr = W.begin(); itr != W.end(); itr += 2) {
        if (*itr != *(itr + 1)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Example test case(s):
input: abaccaba

output: Yes
Language: C++

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= n / r; ++i) {
        for (int j = 0; j <= n / g; ++j) {
            int num = n - r * i - g * j;
            if (num >= 0 && num % b == 0) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

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

output: 4
Language: C++

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

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

    int ac_count = 0;
    int wa_count = 0;
    int tle_count = 0;
    int re_count = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (s == "AC") {
            ac_count += 1;
        } else if (s == "WA") {
            wa_count += 1;
        } else if (s == "TLE") {
            tle_count += 1;
        } else if (s == "RE") {
            re_count += 1;
        }
    }
    cout << "AC x " << ac_count << endl;
    cout << "WA x " << wa_count << endl;
    cout << "TLE x " << tle_count << endl;
    cout << "RE x " << re_count << endl;
}

Example test case(s):
input: 6
AC
TLE
AC
AC
WA
TLE

output: AC x 3
WA x 1
TLE x 2
RE x 0
Language: C++

#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    for (ll &a : A) cin >> a;
    for (ll &b : B) cin >> b;
    for (ll &c : C) cin >> c;

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    vector<ll> AB;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }

    sort(AB.begin(), AB.end(), greater<ll>());
    vector<ll> ABC;
    for (int i = 0; i < min(K, (int)AB.size()); i++) {
        for (int j = 0; j < Z; j++) {
            ABC.push_back(AB[i] + C[j]);
        }
    }

    sort(ABC.begin(), ABC.end(), greater<ll>());
    for (int i = 0; i < K; i++) {
        cout << ABC[i] << endl;
    }

    return 0;
}

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

output: 19
17
15
14
13
12
10
8
Language: C++

#include <math.h>

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt = 1;

int main() {
    ll h;
    cin >> h;
    while (h != 1) {
        if (h % 2 != 0) h--;
        h /= 2;
        cnt *= 2;
        ans += cnt;
    }
    cout << ans + 1 << endl;
}

Example test case(s):
input: 2

output: 3
Language: C++

#include <iostream>
using namespace std;

int main() {
    int a, b;

    cin >> a;

    cout << a / (60 * 60) << ":" << a % (60 * 60) / 60 << ":"
         << a % (60 * 60) % 60 << endl;

    return 0;
}

Example test case(s):
input: 46979

output: 13:2:59
Language: C++

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

int main() {
    int n;
    int sq[10000], fr[5000];
    vector<int> com;
    int tmp;

    while (1) {
        cin >> n;
        if (!n) break;

        for (int i = 1; i < n; i++) sq[i] = (i * i) % n;
        com.clear();

        for (int i = 1; i < n; i++) {
            bool f = true;
            for (int j = 0; j < com.size(); j++) {
                if (com[j] == sq[i]) {
                    f = false;
                    break;
                }
            }
            if (f) com.push_back(sq[i]);
        }

        for (int i = 0; i <= (n - 1) / 2; i++) fr[i] = 0;

        for (int i = 0; i < com.size(); i++) {
            for (int j = 0; j < com.size(); j++) {
                if (i != j) {
                    tmp = com[i] - com[j];
                    if (tmp < 0) tmp += n;
                    if (tmp > (n - 1) / 2) tmp = n - tmp;
                    fr[tmp]++;
                }
            }
        }

        for (int i = 1; i <= (n - 1) / 2; i++) cout << fr[i] << endl;
    }
}

Example test case(s):
input: 11
15
0

output: 4
4
4
4
4
2
2
4
2
4
4
2
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, char *args[]) {
    int N, D, X;
    int num_of_chocolate;
    int counter;
    int days;
    int A[101];
    cin >> N >> D >> X;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    num_of_chocolate = 0;
    for (int i = 0; i < N; i++) {
        days = 0;
        counter = 0;
        for (int j = 0;; j++) {
            days = j * A[i] + 1;
            if (days <= D) {
                counter++;
            } else {
                break;
            }
        }
        num_of_chocolate = num_of_chocolate + counter;
    }
    num_of_chocolate = num_of_chocolate + X;

    cout << num_of_chocolate << endl;
}

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

output: 8
Language: C++

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

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'

int main() {
    ll N, K;
    ll A[200100];
    ll B[200100] = {-1};
    int now = 1;
    ll cnt = 0;
    cin >> N >> K;
    REP(i, N) { cin >> A[i + 1]; }
    REP(i, 200100) { B[i] = -1; }

    ll j;
    B[1] = 0;
    for (j = 1; j <= K; j++) {
        now = A[now];
        if (B[now] == -1) {
            B[now] = j;
        } else {
            cnt = j;

            break;
        }
    }
    if (j < K) {
        ll tmp;
        tmp = (K - B[now]) % (cnt - B[now]);

        for (ll j = 0; j < tmp; j++) {
            now = A[now];
        }
    }
    fin(now);
    return 0;
}

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

output: 4
Language: C++

#include <cstdio>
#include <iostream>

using namespace std;

void binPrint(int x, int bits) {
    for (int i = bits - 1; i >= 0; i--) {
        cout << (x & (1 << i) ? 1 : 0);
    }
    cout << endl;
}
int main(void) {
    unsigned a, b;
    cin >> a >> b;

    binPrint(a & b, 32);
    binPrint(a | b, 32);
    binPrint(a ^ b, 32);

    return 0;
}

Example test case(s):
input: 8 10

output: 00000000000000000000000000001000
00000000000000000000000000001010
00000000000000000000000000000010
Language: C++

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

#define rep(i, n) for (int i = 0; i < int(n); i++)

string input, ss;
int a[3], it, cnt;

int Not(int x) { return 2 - x; }

int And(int x, int y) {
    if (x * y == 0) return 0;
    if (x == 2 && y == 2) return 2;
    return 1;
}

int Or(int x, int y) {
    if (x == 2 || y == 2) return 2;
    if (x == 1 || y == 1) return 1;
    return 0;
}

int parse() {
    char c = ss[it++];
    if ('0' <= c && c <= '2') return c - '0';
    if (c == '-') return Not(parse());

    int x = parse();
    c = ss[it++];
    int y = parse();
    ++it;
    return c == '*' ? And(x, y) : Or(x, y);
}

int main() {
    while (cin >> input && input != ".") {
        rep(i, 3) a[i] = i;
        cnt = 0;
        rep(i, 3) rep(j, 3) rep(k, 3) {
            a[0] = i;
            a[1] = j;
            a[2] = k;
            ss = input;
            for (char& c : ss) {
                if (c == 'P') c = a[0] + '0';
                if (c == 'Q') c = a[1] + '0';
                if (c == 'R') c = a[2] + '0';
            }
            it = 0;
            if (parse() == 2) cnt++;
        }
        cout << cnt << endl;
    }
}

Example test case(s):
input: (P*Q)
(--R+(P*Q))
(P*-P)
2
1
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.

output: 3
11
0
27
0
7
Language: C++

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

int main() {
    int n, ans = 0;
    string a, b, c;
    cin >> n;
    cin >> a >> b >> c;

    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) {
        } else if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << endl;
}

Example test case(s):
input: 4
west
east
wait

output: 3
Language: C++

#include <algorithm>
#include <cstdio>
using std::sort;
int main(void) {
    int *a, *b, i, N;
    int frontHalf, backHalf;
    scanf("%d", &N);
    a = new int[N];
    b = new int[N];
    for (i = 0; i < N; i++) {
        scanf("%d", a + i);
        b[i] = a[i];
    }
    sort(b, b + N);
    frontHalf = b[N / 2 - 1];
    backHalf = b[N / 2];
    delete[] b;
    for (i = 0; i < N; i++) {
        if (a[i] < backHalf)
            printf("%d\n", backHalf);
        else
            printf("%d\n", frontHalf);
    }
    delete[] a;
    return 0;
}

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

output: 4
3
3
4
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int m1 = 0, m2 = 0;
    float maxD = 0.f;
    for (size_t i = 0; 100 * A * i <= F; i++) {
        int mA = 100 * A * i;
        for (size_t j = 0; mA + 100 * B * j <= F; j++) {
            int mB = 100 * B * j;
            for (size_t k = 0; mA + mB + C * k <= F; k++) {
                int mC = C * k;
                for (size_t l = 0; mA + mB + mC + D * l <= F; l++) {
                    int mD = D * l;
                    if ((mA + mB) * E / 100 < mD + mC) {
                        break;
                    }
                    float d = (float)(mD + mC) / (float)(mA + mB + mC + mD);
                    if (d > maxD) {
                        m1 = mA + mB + mC + mD;
                        m2 = mC + mD;
                        maxD = d;
                    }
                }
            }
        }
    }
    if (m1 == 0) {
        m1 = 100 * A;
    }
    cout << m1 << " " << m2 << endl;
    return 0;
}

Example test case(s):
input: 1 2 10 20 15 200

output: 110 10
Language: C++

#include <iostream>
using namespace std;

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int cnt = 0;
    for (int a = 0; a <= A; a++) {
        for (int b = 0; b <= B; b++) {
            for (int c = 0; c <= C; c++) {
                int total = 500 * a + 100 * b + 50 * c;
                if (total == X) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Example test case(s):
input: 2
2
2
100

output: 2
Language: C++

#include <iostream>
using namespace std;
int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) {
        cout << "No" << endl;
    } else if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= W) {
        cout << "Yes" << endl;
    }

    return 0;
}

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

output: Yes
Language: C++

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(v) (v).begin, (v).end()
#define INF 1e9
#define MOD 1e9 + 7
typedef long long llong;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(26, 1);
    vector<char> s(n);
    REP(i, n) {
        cin >> s[i];
        cnt[s[i] - 'a']++;
    }

    llong ans = cnt[0];
    for (int i = 1; i < 26; ++i) {
        ans *= cnt[i];
        ans %= (int)MOD;
    }

    cout << ans - 1 << endl;
    return 0;
}

Example test case(s):
input: 4
abcd

output: 15
Language: C++

#include <iostream>
#include <vector>

typedef long long LL;

using namespace std;

#define MOD 1000000007

LL mod_pow(LL x, LL n) {
    LL ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}

LL comb_s(LL n, LL r) {
    LL tmp_n = 1;
    LL tmp_d = 1;
    LL ans;
    for (int i = 1; i <= r; i++) {
        tmp_n = (tmp_n * (n + 1 - i)) % MOD;
        tmp_d = (tmp_d * i) % MOD;
        ans = tmp_n * mod_pow(tmp_d, MOD - 2);
    }

    return ans;
}

int main() {
    LL n;
    LL n_tmp;
    LL a;
    LL b;
    LL ans = 1;

    cin >> n >> a >> b;
    ans = mod_pow(2, n);
    ans--;
    LL tmp_nd;
    tmp_nd = comb_s(n, a);
    ans = (ans - tmp_nd) % MOD;
    while (ans < 0) {
        ans += MOD;
    }

    tmp_nd = comb_s(n, b);
    ans = (ans - tmp_nd) % MOD;

    while (ans < 0) {
        ans += MOD;
    }

    cout << ans << endl;

    return 0;
}

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

output: 7
Language: C++

#include <iostream>
#include <vector>

using namespace std;

vector<int> G[100000];
bool used[100000];
int grundy[100000];

void dfs(int v) {
    used[v] = true;
    grundy[v] = 0;
    for (int i = 0; i < G[v].size(); i++) {
        if (!used[G[v][i]]) {
            dfs(G[v][i]);
            grundy[v] ^= (grundy[G[v][i]] + 1);
        }
    }
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(0);
    if (grundy[0] != 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }
}

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

output: Alice
Language: C++

#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
}

Example test case(s):
input: 3
1

output: 2
Language: C++

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
using vi = vector<int>;
using vi2 = vector<vi>;

int pow2(int a) {
    int ret = 1;
    for (int i = 0; i < a; i++) ret *= 2;
    return ret;
}

int count(vi2 hw, int a, int b) {
    int sum = 0;
    for (int i = 0; i < hw.size(); i++) {
        for (int j = 0; j < hw[0].size(); j++) {
            if (a >> i & 1 && b >> j & 1 && hw[i][j] == 1) sum++;
        }
    }
    return sum;
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vi2 hw(h, vi(w, 0));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            if (c == '#') hw[i][j] = 1;
        }
    }
    int sum = 0;
    for (int i = 0; i < pow2(h); i++) {
        for (int j = 0; j < pow2(w); j++) {
            if (count(hw, i, j) == k) sum++;
        }
    }
    cout << sum << endl;
}

Example test case(s):
input: 2 3 2
..#
###

output: 5