malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int NUM = 100010;   const double eps = 1e-10, pi = acos(-1.0);   using namespace std;   int n;   vector<int> g[NUM];   pair<int, int> node[NUM], edge[NUM];   int tot, cnt;   void dfs(int u, int p, int x) {     for (int i = 0; i < g[u].size(); i++)       if (g[u][i] != p) {         node[tot++] = pair<int, int>(u, g[u][i]);         if (x == -1)           x = tot - 1;         else           edge[cnt++] = pair<int, int>(x + 1, tot);         dfs(g[u][i], u, tot - 1);       }   }   int main() {     int i, j;     int u, v;     scanf( %d , &n);     for (i = 1; i < n; i++) {       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);     }     dfs(1, -1, -1);     printf( %d n , tot);     for (i = 0; i < tot; i++) printf( 2 %d %d n , node[i].first, node[i].second);     for (i = 0; i < cnt; i++) printf( %d %d n , edge[i].first, edge[i].second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, c0, c1, h;       cin >> n >> c0 >> c1 >> h;       string second;       cin >> second;       int cost1 = 0, z = 0, o = 0;       for (int i = 0; i < second.length(); i++) {         if (second[i] ==  0 ) {           cost1 += c0;           z++;         } else {           cost1 += c1;           o++;         }       }       int cost2 = o * h + c0 * (second.length());       int cost3 = z * h + c1 * (second.length());       cout << min(cost1, min(cost2, cost3)) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, i, j, b, p, f, h, c, sum;     cin >> t;     while (t--) {       cin >> b >> p >> f >> h >> c;       sum = 0;       b /= 2;       if (h < c) {         if (b < f) {           sum += (c * b);           b = 0;         } else if (b > f) {           sum += (c * f);           b -= f;         } else {           sum += (c * f);           b = 0;         }         if (b > 0) {           if (b < p) {             sum += (h * b);           } else if (b > p) {             sum += (h * p);           } else             sum += (h * p);         }       } else if (h > c) {         if (b < p) {           sum += (h * b);           b = 0;         } else if (b > p) {           sum += (h * p);           b -= p;         } else {           sum += (h * p);           b = 0;         }         if (b > 0) {           if (b < f) {             sum += (c * b);           } else if (b > f) {             sum += (c * f);           } else             sum += (c * f);         }       } else         sum += (c * min(b, p + f));       cout << sum << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     long long s, x;     cin >> s >> x;     bool flag = true;     bool valid = true;     if ((s & 1) != (x & 1)) valid = false;     long long ans = 1;     for (int i = 62; i >= 1; i--) {       long long sb = (s >> i) & 1;       long long xb = (x >> i) & 1;       long long sp = (s >> (i - 1)) & 1;       long long xp = (x >> (i - 1)) & 1;       if (sb == 0 && xb == 0) {         if (sp == 0 && xp == 1) valid = false;       }       if (sb == 0 && xb == 1) {         if (sp == 1 && xp == 1) valid = false;       }       if (sb == 1 && xb == 0) {         if (sp == 1 && xp == 1) valid = false;       }       if (sb == 1 && xb == 1) {         if (sp == 0 && xp == 1) valid = false;       }       if (xb != sb) flag = false;     }     for (int i = 0; i < 62; i++)       if ((x >> i) & 1) ans *= 2;     if (!valid)       cout <<  0 n ;     else       cout << ans - flag * 2 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   ,  ;     __f(comma + 1, args...);   }   inline long long int gcd(long long int a, long long int b) {     a = abs(a), b = abs(b);     while (b) a = a % b, swap(a, b);     return a;   }   inline long long int power(long long int a, long long int p) {     long long int res = 1, x = a;     while (p) {       if (p & 1) res = (res * x);       x = (x * x), p >>= 1;     }     return res;   }   inline long long int big_mod(long long int a, long long int p,                                long long int m) {     long long int res = 1 % m, x = a % m;     while (p) {       if (p & 1) res = (res * x) % m;       x = (x * x) % m, p >>= 1;     }     return res;   }   const long long int INF = 1e15;   const int nax = 2e5 + 5;   int parent[nax];   int sz[nax];   void makeset(int u) {     parent[u] = u;     sz[u] = 1;   }   void init_DSU(int N) {     for (int i = 0; i <= N; i++) {       makeset(i);     }   }   int Find(int r) {     if (parent[r] == r) {       return r;     }     parent[r] = Find(parent[r]);     return parent[r];   }   int FindSize(int r) { return sz[Find(r)]; }   void Union(int a, int b) {     int u = Find(a);     int v = Find(b);     if (u != v) {       parent[u] = v;       sz[v] += sz[u];     }   }   int main() {     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       init_DSU(n);       for (int i = 1; i <= n; i++) {         int x;         cin >> x;         Union(i, x);       }       for (int i = 1; i <= n; i++) {         cout << FindSize(i) <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   int a[2005];   int n, k;   int main() {     scanf( %d , &k);     k += 2;     int len = 0;     a[len++] = -1;     int res;     while (k > 1000000) {       k++;       a[len++] = 1000000;       k -= 1000000;     }     a[len++] = k;     printf( %d n , len);     for (int i = 0; i < len; i++) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   int sz[N], col[2];   int n;   long long ans = 0, odd;   vector<int> V[N];   void dfs(int a, int fa, int zt) {     sz[a] = 1;     col[zt]++;     for (int i = (0); i < (((int)(V[a]).size())); ++i) {       int nxt = V[a][i];       if (nxt == fa) continue;       dfs(nxt, a, zt ^ 1);       sz[a] += sz[nxt];       ans += 1ll * sz[nxt] * (n - sz[nxt]);     }   }   int main() {     scanf( %d , &n);     for (int i = (1); i < (n); ++i) {       int a, b;       scanf( %d%d , &a, &b);       V[a].push_back(b);       V[b].push_back(a);     }     dfs(1, 1, 0);     odd = 1ll * col[0] * col[1];     cout << ans / 2 + (odd + 1) / 2 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ara[100010];   int cnt[50];   int func(int x) {     if (x == 0) return 0;     if (x % 2 == 0) {       return func(x / 2);     } else {       return 1 + func(x - 1);     }   }   int main() {     std::ios_base::sync_with_stdio(false);     ;     int n;     cin >> n;     for (int i = 0; i <= n - 1; i++) {       cin >> ara[i];       cnt[func(ara[i])]++;     }     long long ans = 0;     for (int i = 0; i <= 40; i++) {       if (cnt[i] == 0) continue;       long long yo = cnt[i];       ans += (yo * (yo - 1LL)) / 2LL;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c;     cin >> a >> b >> c;     long long m, mi, mid;     long long v[3];     v[0] = a;     v[1] = b;     v[2] = c;     sort(v, v + 3);     a = v[2];     b = v[0];     c = v[1];     if (a - b < c) {       cout <<  0 ;     } else {       m = a - b - c + 1;       cout << m;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void printArray(const T* a, int n, ostream& out = cerr);   template <class T>   void printArray(const vector<T>& arr, ostream& out = cerr);   const long long mod = 1e9 + 7;   const double PI = acos(-1);   int n, i, j, k, t;   int m;   int a[200002];   int b[200002];   int c[200002];   int pos[200002];   int ac[200002];   int bc[200002];   int cc[200002];   int mab[200002];   int hitung(int st, int pem, int ed) {     int total = ac[st];     total += (bc[pem] - bc[st]);     total += (cc[ed] - cc[pem]);     return total;   }   int hitung2(int st, int pem, int ed) {     int total = ac[st];     total += (bc[pem] - bc[st]);     total += (cc[ed] - cc[pem]);     return total;   }   int main() {     scanf( %d %d %d , &n, &m, &k);     int tot = n + m + k;     for (int i = 0; i < n; ++i) {       scanf( %d , a + i);       pos[a[i]] = 1;     }     for (int i = 0; i < m; ++i) {       scanf( %d , b + i);       pos[b[i]] = 2;     }     for (int i = 0; i < k; ++i) {       scanf( %d , c + i);       pos[c[i]] = 3;     }     for (int i = 1; i <= tot; ++i) {       ac[i] = ac[i - 1] + (pos[i] == 1);       bc[i] = bc[i - 1] + (pos[i] == 2);       cc[i] = cc[i - 1] + (pos[i] == 3);     }     mab[tot] = bc[tot];     for (int i = tot - 1; i >= 0; --i) {       mab[i] = max(mab[i + 1], bc[i] + cc[tot] - cc[i]);     }     int ans = 0;     for (int i = 0; i <= tot; ++i) {       ans = max(ans, ac[i] + mab[i] - bc[i]);     }     printf( %d n , tot - ans);     return 0;   }   template <class T>   void printArray(const T* a, int n, ostream& out) {     for (int i = 0; i < n; ++i) {       out << a[i] <<    ;     }     out << endl;   }   template <class T>   void printArray(const vector<T>& arr, ostream& out) {     for (const T& x : arr) {       out << x <<    ;     }     out << endl;   }
#include <bits/stdc++.h>   using namespace std;   std::vector<long long> a;   long long sm = 0;   long long n, m;   bool doo(long long x) {     long long res = 0;     for (long long i = 0; i < x; ++i) {       res += a[i];       long long k = i + x;       long long count = 1;       while (k < n and a[k] - count > 0) {         res += max(0ll, a[k] - count);         k += x;         count++;       }     }     return res >= m;   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     cin >> n >> m;     (a).clear(), (a).resize(n);     for (long long i = 0; i < n; ++i) {       cin >> a[i];       sm += a[i];     }     sort((a).rbegin(), (a).rend());     if (sm < m) {       cout <<  -1 ;       exit(0);     }     long long l = 1, h = n + 1;     long long mid;     long long ans = -1;     while (l <= h) {       mid = (l + h) / 2;       if (doo(mid)) {         ans = mid;         h = mid - 1;       } else         l = mid + 1;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v1[1000100];   vector<long long> v2;   map<long long, long long> m1;   map<long long, long long> m2;   map<long long, long long> m3;   map<char, long long> ms1;   map<string, long long> ms2;   stack<long long> sta;   long long big = 999999999999999999, small = -999999999999999999;   long long z, y, x, n, m, i, j, k, t, l, ans, sum1, sum2, avg, test, b[500100],       c[500100], a[500100], d[500100], co1[100100], co2[100100];   char s[1000100], s1[1000100], s2[1000100], temp;   bool pro[1000100], pro1, pro2, pro3;   int main() {     cin >> n >> k;     k > (n + 1) / 2 ? cout << 2 * (k - (n + 1) / 2) : cout << 2 * k - 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int segtree[400001];   int val[100001];   int inf = (1 << 30) - 1;   void build(int l, int r, int pos) {     if (l == r) {       segtree[pos] = val[r];       return;     }     int mid = (l + r) / 2;     build(l, mid, 2 * pos + 1);     build(mid + 1, r, 2 * pos + 2);     segtree[pos] = (segtree[2 * pos + 1] & segtree[2 * pos + 2]);   }   int query(int lq, int rq, int l, int r, int pos) {     if (rq < l || lq > r) return inf;     if (lq <= l && r <= rq) return segtree[pos];     int mid = (l + r) / 2;     return query(lq, rq, l, mid, 2 * pos + 1) &            query(lq, rq, mid + 1, r, 2 * pos + 2);   }   int main() {     int n;     cin >> n;     int m;     cin >> m;     int flag[n + 1][30];     memset(flag, 0, sizeof flag);     int l[m], r[m], v[m];     for (int i = 0; i < m; i++) {       cin >> l[i] >> r[i] >> v[i];       l[i]--;       r[i]--;       for (int j = 0; j < 30; j++) {         if (v[i] & (1 << j)) {           flag[l[i]][j] += 1;           flag[r[i] + 1][j] -= 1;         }       }     }     for (int j = 0; j < 30; j++) {       for (int i = 1; i < n; i++) {         flag[i][j] += flag[i - 1][j];       }     }     for (int i = 0; i < n; i++) {       val[i] = 0;       for (int j = 0; j < 30; j++) {         if (flag[i][j]) val[i] += (1 << j);       }     }     build(0, n - 1, 0);     for (int i = 0; i < m; i++) {       if (query(l[i], r[i], 0, n - 1, 0) != v[i]) {         cout <<  NO ;         return 0;       }     }     cout <<  YES n ;     for (int j = 0; j < n; j++) cout << val[j] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int main() {     int t;     cin >> t;     for (; t--;) {       cin >> n >> m;       if (n == 1) {         cout << 0 << endl;         continue;       }       int ansl = 0, ansr = n, ans = (ansl + ansr) / 2;       for (; ansl < ansr; ans = (ansl + ansr) / 2) {         int tmp = n;         long long C = 1, all = 0;         for (int i = 0; i <= ans; ++i) {           all += (long long)min((long long)tmp, C) * i;           tmp -= min((long long)tmp, C);           if (!tmp) break;           C *= ans - i;           C /= i + 1;         }         if (!tmp)           if (all > (long long)m * ans)             ansl = ans + 1;           else             ansr = ans;         else           ansl = ans + 1;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 102;   pair<int, int> ar[N];   bool used[N];   vector<deque<int>> vc;   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) cin >> ar[i].first >> ar[i].second;     for (int i = 1; i <= n; ++i) {       if (used[i]) continue;       deque<int> q;       q.push_back(i);       int cur = i;       while (ar[cur].first) {         used[cur] = true;         cur = ar[cur].first;         q.push_front(cur);       }       used[cur] = true;       cur = i;       while (ar[cur].second) {         used[cur] = true;         cur = ar[cur].second;         q.push_back(cur);       }       used[cur] = true;       vc.push_back(q);     }     for (int i = 1; i < vc.size(); ++i) {       while (!vc[i].empty()) {         vc[0].push_back(vc[i].front());         vc[i].pop_front();       }     }     auto cur = vc[0];     ar[cur.front()].first = ar[cur.back()].second = 0;     for (int i = 0; i < (int)cur.size() - 1; ++i) ar[cur[i]].second = cur[i + 1];     for (int i = (int)cur.size() - 1; i > 0; --i) ar[cur[i]].first = cur[i - 1];     for (int i = 1; i <= n; ++i)       cout << ar[i].first <<     << ar[i].second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   long long rnd(long long l, long long r) { return l + rng() % (r - l + 1); }   const long long N = 5e5 + 5;   const long long K = 5005;   long long n, a[N], k;   long long f[2][K][2];   void minimize(long long &x, long long y) { x = min(x, y); }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> k >> n;     for (long long i = 1, __c = n; i <= __c; ++i) cin >> a[i];     vector<pair<long long, long long> > w;     sort(a + 1, a + n + 1);     for (long long i = 1, __c = n - 1; i <= __c; ++i)       w.emplace_back(a[i + 1] - a[i], i);     sort(begin(w), end(w));     long long m = min((long long)w.size(), 3 * k);     w.resize(m);     for (auto &v : w) swap(v.first, v.second);     w.push_back(make_pair(-1, 0));     sort(begin(w), end(w));     memset(f, 0x3f, sizeof(f));     f[0][0][0] = 0;     long long now = 0;     for (long long i = 1, __c = m; i <= __c; ++i) {       f[now][0][0] = f[now][0][1] = 0;       for (long long j = 1, __c = k; j <= __c; ++j) {         minimize(f[now ^ 1][j][0], f[now][j][0]);         minimize(f[now ^ 1][j][0], f[now][j][1]);         minimize(f[now ^ 1][j][1], f[now ^ 1][j][0]);         minimize(f[now ^ 1][j][1], f[now][j - 1][0] + w[i].second);         if (w[i].first != w[i - 1].first + 1)           minimize(f[now ^ 1][j][1], f[now][j - 1][1] + w[i].second);       }       now ^= 1;     }     cout << f[now][k][1] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int C = 26;   void add(int &x, int y) {     x += y;     while (x >= MOD) x -= MOD;     while (x < 0) x += MOD;   }   int fix(int x) {     while (x >= MOD) x -= MOD;     while (x < 0) x += MOD;     return x;   }   int pw(int a, int b) {     int ret = 1;     while (b) {       if (b & 1) ret = 1ll * ret * a % MOD;       b >>= 1;       a = 1ll * a * a % MOD;     }     return ret;   }   const int MAXN = 105;   int n, m, dp[MAXN][MAXN], l[MAXN][MAXN], r[MAXN][MAXN];   void solve() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       int k;       cin >> k;       for (int rep = 0; rep < k; rep++) {         int a, b;         cin >> a >> b;         --a;         for (int j = a; j < b; j++) {           r[i][j] = b;           l[i][j] = a;         }       }     }     for (int b = m - 1; ~b; --b) {       for (int e = b + 1; e <= m; e++) {         for (int k = b; k < e; k++) {           int val = 0;           for (int i = 0; i < n; i++)             if (b <= l[i][k] && r[i][k] <= e) ++val;           dp[b][e] = max(dp[b][e], val * val + dp[b][k] + dp[k + 1][e]);         }       }     }     cout << dp[0][m] <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int te = 1;     for (int w = 1; w <= te; w++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, o, p, x, y, z;   vector<long long> a, b, c, d;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       cin >> n;       string s;       cin >> s;       int leftFirst = -1;       int rightFirst = -1;       for (long long i = 0; i < n; i++)         if (s[i] ==  1 ) {           leftFirst = i;           break;         }       for (long long i = 0; i < n; i++)         if (s[i] ==  1 ) {           rightFirst = i;         }       if (leftFirst == -1) {         cout << n << endl;         continue;       }       if (rightFirst >= n - leftFirst) {         cout << 2 * (rightFirst + 1) << endl;       } else         cout << 2 * (n - leftFirst) << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   int n, m, jm;   long long ans;   int main() {     cin >> n >> m >> jm;     ans = ceil(1.0 * n / jm) * ceil(1.0 * m / jm) * ((n - 1) % jm + 1) *           ((m - 1) % jm + 1);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int N = 2e5 + 10, M = 1e6 + 10;   long long f(long long x) {     long long y = x + 1;     if (x & 2)       y /= 2;     else       x /= 2;     return x * y;   }   void solve() {     long long n;     scanf( %lld , &n);     long long x = 3, cnt = 1;     n--;     while (1) {       long long t = f(x);       if (t > n) break;       cnt++;       n -= t;       x = (x << 1) + 1;     }     printf( %lld n , cnt);   }   int main() {     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     string s[n];     set<string> store;     for (int i = 0; i < n; i++) {       cin >> s[i];       store.insert(s[i]);     }     int cnt = 0;     for (int i = 0; i < n; i++) {       set<string> v;       store.erase(s[i]);       for (int j = i + 1; j < n; j++) {         v.insert(s[j]);         store.erase(s[j]);         string temp;         for (int l = 0; l < k; l++) {           if (s[i][l] == s[j][l]) {             temp += s[i][l];           } else {             temp += ( S  +  E  +  T  - s[i][l] - s[j][l]);           }         }         if (store.find(temp) != store.end()) {           cnt++;           v.insert(temp);           store.erase(temp);         }       }       for (auto it : v) {         store.insert(it);       }     }     cout << cnt <<   n ;   }
#include <bits/stdc++.h>   inline int read() {     int x = 0, f = 0;     register char ch = getchar();     for (; ch < 48 || ch > 57; ch = getchar()) f |= ch ==  - ;     for (; ch > 47 && ch < 58; ch = getchar())       x = (x << 1) + (x << 3) + (ch ^ 48);     return f ? ~x + 1 : x;   }   using namespace std;   int t[7005], l[7005], r[7005], x[7005], pos[7005][2], cnt;   set<int> s;   int main() {     int n = read(), m = read();     for (int i = 0; i < m; ++i) {       int k = read();       if (k == 1)         t[++cnt] = read(), l[cnt] = read(), r[cnt] = read(), x[cnt] = read();       else {         int lvl = read();         pos[lvl][1] = pos[lvl][0] = read();         s.clear();         for (int i = lvl; i < n; ++i) {           int k = pos[i][0], j = 0, c = 0;           for (; k; k >>= 1, ++j) c += k & 1;           pos[i + 1][0] = pos[i][0] + j - (c == 1);           k = pos[i][1], j = 0;           for (; k; k >>= 1, ++j)             ;           pos[i + 1][1] = pos[i][1] + j;         }         for (int i = 1; i <= cnt; ++i)           if (t[i] >= lvl && (l[i] <= pos[t[i]][0] && pos[t[i]][0] <= r[i] ||                               l[i] <= pos[t[i]][1] && pos[t[i]][1] <= r[i] ||                               pos[t[i]][0] <= l[i] && r[i] <= pos[t[i]][1]))             s.insert(x[i]);         printf( %d n , s.size());       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef struct {     long long loc;     long long num;   } amar;   bool operator<(amar x, amar y) {     if (x.num >= y.num)       return false;     else       return true;   }   int main() {     long long n, k, c[40];     char s[100005];     memset(c, 0, sizeof c);     cin >> n >> k >> s;     for (long long i = 0; i < n; i++) {       c[s[i] -  A ]++;     }     priority_queue<amar> a;     amar tmp;     for (long long i = 0; i < 40; i++) {       tmp.loc = i;       tmp.num = c[i];       a.push(tmp);     }     long long ans = 0;     while (k > 0 && !a.empty()) {       tmp = a.top();       if (k >= tmp.num) {         ans += (tmp.num * tmp.num);         k -= tmp.num;       } else if (k < tmp.num) {         ans += k * k;         k = 0;       }       a.pop();     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7, inv = 5e8 + 4;   long long n, m, k;   long long pow(long long base, long long exp) {     long long res = 1;     while (exp) {       if (exp & 1) (res *= base) %= mod;       exp >>= 1;       (base *= base) %= mod;     }     return res;   }   int main() {     cin >> n >> m >> k;     --n;     --m;     if (k == -1 && n + m & 1)       cout << 0;     else       cout << pow(pow(2, n), m);   }