malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   class Solution {    public:     long long minCost(int n, vector<int>& blocks, vector<int>& prices) {       int m = prices.size();       vector<int> pre(n, 0);       iota(pre.begin(), pre.end(), 0);       if (!blocks.empty() && blocks[0] == 0) {         return -1;       }       for (int i = 0, j = 0; i < n && j < blocks.size(); ++i) {         if (i == blocks[j]) {           pre[i] = pre[i - 1];           ++j;         }       }       int minL = 0;       for (int i = 0; i < blocks.size(); ++i) {         int cnt = 1;         while (i + 1 < blocks.size() && blocks[i + 1] == blocks[i] + 1) {           ++i;           ++cnt;         }         minL = max(minL, cnt);       }       long long res = LLONG_MAX;       int minPrice = INT_MAX;       for (int l = m; l > minL; --l) {         if (minPrice < prices[l - 1]) {           continue;         }         minPrice = prices[l - 1];         int cnt = 0;         int p = 0;         while (p < n) {           p += l;           ++cnt;           if (p < n && pre[p] != p) {             p = pre[p];           }         }         res = min(res, 1LL * cnt * prices[l - 1]);       }       return res == LLONG_MAX ? -1 : res;     }   };   int main(int argc, char** argv) {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     vector<int> blocks;     blocks.reserve(m);     for (int i = 0, b = 0; i < m; ++i) {       scanf( %d , &b);       blocks.push_back(b);     }     vector<int> prices;     prices.reserve(k);     for (int i = 0, p = 0; i < k; ++i) {       scanf( %d , &p);       prices.push_back(p);     }     Solution sol;     printf( %s n , to_string(sol.minCost(n, blocks, prices)).c_str());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000005];   int main() {     string s;     int p = 1, q = 1, ans = 0, ansCount = 1;     a[0] = -1;     cin >> s;     for (int i = 0, sz = s.length(); i < sz; i++) {       if (s[i] ==  ( ) {         a[p] = i;         p++;       } else {         p--;         if (p == 0) {           a[0] = i;           p = 1, q = 1;         } else {           int dis = i - a[p - 1];           if (dis > ans) {             ans = dis, ansCount = 1;           } else if (dis == ans)             ansCount++;         }       }     }     cout << ans <<     << ansCount;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   vector<long long> arr;   void solve() {     cin >> n >> m >> k;     arr.resize(n);     for (long long i = 0; i < n; i++) cin >> arr[i];     vector<long long> b;     long long l = arr[n - 1] - arr[0];     ;     for (int i = 1; i < n; i++) {       b.push_back(arr[i] - arr[i - 1]);     }     sort(b.begin(), b.end());     long long i = b.size() - 1;     int ctr = k - 1;     for (; ctr > 0; i--, ctr--) {       l -= b[i];       l += 1;     }     l++;     cout << l << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tc;     cin >> tc;     for (int t = 1; t <= tc; t++) {       int b, p, f, rsl = 0;       int h, c;       cin >> b >> p >> f;       cin >> h >> c;       b /= 2;       if (h >= c) {         int mbp = min(b, p);         rsl += mbp * h;         b -= mbp;         rsl += min(b, f) * c;       } else {         int mbp = min(b, f);         rsl += mbp * c;         b -= mbp;         rsl += min(b, p) * h;       }       cout << rsl << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-5;   const int inf = (1 << 31) - 1;   const int hinf = 1000000000;   const int mod = 1000000007;   const int N = 3030;   int dp[3030][3030];   int n;   int head[3030];   int weizhi;   struct node {     int u, v, w, next;   } point[3030 << 1];   void add(int u, int v, int w) {     point[weizhi].u = u;     point[weizhi].v = v;     point[weizhi].w = w;     point[weizhi].next = head[u];     head[u] = weizhi++;   }   void dfs(int now, int par, int dp[N]) {     dp[now] = 0;     for (int k = head[now]; k != -1; k = point[k].next) {       int i = point[k].v;       if (i == par) continue;       dfs(i, now, dp);       dp[now] += dp[i] + point[k].w;     }   }   void DFS(int now, int p, int a, int& ret) {     ret = min(ret, dp[now][now] - dp[now][a]);     for (int k = head[now]; k != -1; k = point[k].next) {       int i = point[k].v;       if (i == p) continue;       DFS(i, now, a, ret);     }   }   int main() {     scanf( %d , &n);     int a, b;     memset((head), -1, sizeof(head));     weizhi = 0;     for (int i = 1; i < n; i++) {       scanf( %d%d , &a, &b);       add(a, b, 0);       add(b, a, 1);     }     memset(dp, 0, sizeof(dp));     if (n == 1) {       cout << 0 << endl;       return 0;     }     for (int i = 1; i <= n; i++) {       dfs(i, -1, dp[i]);     }     int ans = inf;     for (int u = 1; u <= n; u++) {       for (int k = head[u]; k != -1; k = point[k].next) {         int i = point[k].v;         int w = point[k].w;         if (w) continue;         int ret1 = inf;         int ret2 = inf;         DFS(i, u, u, ret1);         DFS(u, i, i, ret2);         ans = min(ans, ret1 + ret2 - 1);       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   using namespace std::chrono;   template <typename A>   ostream &operator<<(ostream &cout, vector<A> const &v);   template <typename A, typename B>   ostream &operator<<(ostream &cout, pair<A, B> const &p) {     return cout <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename A>   ostream &operator<<(ostream &cout, vector<A> const &v) {     cout <<  [ ;     for (int i = 0; i < v.size(); i++) {       if (i) cout <<  ,  ;       cout << v[i];     }     return cout <<  ] ;   }   template <typename A, typename B>   istream &operator>>(istream &cin, pair<A, B> &p) {     cin >> p.first;     return cin >> p.second;   }   mt19937 rng(steady_clock::now().time_since_epoch().count());   void usaco(string filename) {     freopen((filename +  .in ).c_str(),  r , stdin);     freopen((filename +  .out ).c_str(),  w , stdout);   }   const long double pi = 3.14159265358979323846;   const long long mod = 1000000007;   long long n, m, k, q, Q, T, l, r, x, y, z;   long long c[1000005];   string second, t;   long long ans = 0;   int pt, a, b;   int query(int a, int b) {     cout <<  ?   << a <<     << b << endl;     cin >> x;     return x;   }   void getZero() {     if (pt < 0) {       cout <<  !   << a <<     << b << endl;       exit(0);     }     b ^= (1 << pt);     x = query(a, b);     if (x == 1)       a ^= (1 << pt);     else       b ^= (1 << pt);     --pt;     getZero();   }   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);     };     pt = 29;     a = b = 0;     int cache = -2;     while (pt >= 0) {       int x, y;       if (cache == -2) {         x = query(a, b);       } else         x = cache;       if (x == 0) getZero();       a ^= (1 << pt);       b ^= (1 << pt);       y = query(a, b);       if (x == y)         cache = x;       else         cache = -2;       if (x == y) {         a ^= (1 << pt);         z = query(a, b);         if (z == 1)           a ^= (1 << pt);         else           b ^= (1 << pt);       } else {         if (x > y)           b ^= (1 << pt);         else           a ^= (1 << pt);       }       --pt;     }     cout <<  !   << a <<     << b << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long f[20][55][2600], c[20];   long long l[5005], tot = 0;   void Turn(long long k) {     memset(c, 0, sizeof(c));     while (k) c[++c[0]] = k % 10, k /= 10;     return;   }   int gcd(int x, int y) { return x % y ? gcd(y, x % y) : y; }   long long Search(int x, int lcm, int num, bool flag) {     if (!x && num % lcm == 0)       return 1;     else if (!x)       return 0;     if (!flag && ~f[x][l[lcm]][num]) return f[x][l[lcm]][num];     int k = flag ? c[x] : 9;     long long s = 0;     for (int i = 0; i <= k; i++) {       s += Search(x - 1, i ? lcm * i / gcd(lcm, i) : lcm, (num * 10 + i) % 2520,                   flag && i == k);     }     if (!flag) f[x][l[lcm]][num] = s;     return s;   }   long long Calc(long long k) {     Turn(k);     return Search(c[0], 1, 0, 1);   }   int main() {     for (int i = 1; i <= 2520; i++)       if (2520 % i == 0) l[i] = ++tot;     memset(f, -1, sizeof(f));     long long x, y;     int T;     cin >> T;     while (T--) {       cin >> x >> y;       cout << Calc(y) - Calc(x - 1) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 100, INF = 1e9;   struct edge {     long long to, cost, id;   };   vector<edge> g[N];   long long d[N], cost[N], path[N], used[N];   pair<long long, long long> from[N];   long long n, m;   void bfs() {     fill(d, d + n, INF);     d[0] = 0;     queue<long long> q;     q.push(0);     while ((long long)q.size()) {       long long v = q.front();       q.pop();       if (used[v]) continue;       used[v] = 1;       for (auto i : g[v]) {         long long u = i.to;         long long c = cost[v] + i.cost;         if (d[v] + 1 < d[u] || (d[v] + 1 == d[u] && c < cost[u])) {           d[u] = d[v] + 1;           from[u] = {v, i.id};           cost[u] = c;           q.push(u);         }       }     }     long long v = n - 1;     while (v != 0) {       long long id = from[v].second;       path[id] = 1;       v = from[v].first;     }   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> m;     vector<pair<pair<long long, long long>, long long>> ed(m);     for (long long i = 0; i < m; i++) {       long long a, b, c;       cin >> a >> b >> c;       a--;       b--;       ed[i] = {{a, b}, c};       c ^= 1;       g[a].push_back({b, c, i});       g[b].push_back({a, c, i});     }     bfs();     long long ans = 0;     for (long long i = 0; i < m; i++) {       if (path[i] && ed[i].second == 0 || (!path[i] && ed[i].second == 1)) ans++;     }     cout << ans <<   n ;     for (long long i = 0; i < m; i++) {       if (path[i] && ed[i].second == 0 || (!path[i] && ed[i].second == 1))         cout << ed[i].first.first + 1 <<     << ed[i].first.second + 1 <<                  << (ed[i].second ^ 1) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   const int mod = 1e9 + 7;   int t[N], dp[2][3][3];   int main() {     int n, K;     scanf( %d%d , &n, &K);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       t[x]++;     }     int cur = 1, pre = 0;     for (int i = 1; i <= K; i++) {       memset(dp[cur], 0, sizeof(dp[cur]));       for (int j = 0; j < 3; j++)         for (int k = 0; k < 3; k++)           for (int l = 0; l < 3; l++)             if (j + k + l <= t[i])               dp[cur][k][l] =                   max(dp[cur][k][l], dp[pre][j][k] + l + (t[i] - j - k - l) / 3);       swap(cur, pre);     }     printf( %d n , dp[pre][0][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000005;   const long long MOD = 1000000007;   long long k, w, ans;   long long fac[MAXN];   long long inv[MAXN];   long long power(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) (res *= a) %= MOD;       (a *= a) %= MOD;       b >>= 1;     }     return res;   }   void init() {     fac[0] = 1;     for (int i = 1; i <= k; i++) fac[i] = fac[i - 1] * i % MOD;     inv[k] = power(fac[k], MOD - 2);     for (int i = k; i >= 1; i--) inv[i - 1] = inv[i] * i % MOD;   }   int main() {     cin >> k >> w;     init();     for (int i = 1; i <= k; i++) {       if (i <= w - 1)         (ans += i * fac[k] % MOD * fac[k] % MOD * power(k, w - i - 1) % MOD *                 inv[k - i] % MOD * inv[k - i]) %= MOD;       else         (ans += w * fac[k] % MOD * fac[k - i + w - 1] % MOD * inv[k - i] % MOD *                 inv[k - i] % MOD) %= MOD;       if (i < k) {         if (i + 1 <= w - 1)           (ans += i * fac[k] % MOD * fac[k] % MOD * power(k, w - i - 2) % MOD *                   inv[k - i] % MOD * inv[k - i - 1]) %= MOD;         else           (ans += (w - 1) * fac[k] % MOD * fac[k - i + w - 2] % MOD * inv[k - i] %                   MOD * inv[k - i - 1]) %= MOD;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   const double sn = 1e-9;   const long double PI = 3.141592653589793238L;   int n, c, d;   int mc[100005];   int md[100005];   vector<pair<int, int>> ac;   vector<pair<int, int>> ad;   bool cmp(pair<int, int> p1, pair<int, int> p2) { return p1.first > p2.first; }   int check(int l, int r, vector<pair<int, int>> &arr, int v) {     while (l != r) {       int mid = (l + r) / 2;       if (arr[mid].first <= v)         r = mid;       else         l = mid + 1;     }     return l;   }   int main() {     scanf( %d%d%d , &n, &c, &d);     for (int i = 0; i < n; i++) {       int b, p;       char t[5];       scanf( %d%d%s , &b, &p, t);       if (t[0] ==  C ) {         ac.push_back(make_pair(p, b));       } else {         ad.push_back(make_pair(p, b));       }     }     sort(ac.begin(), ac.end(), cmp);     sort(ad.begin(), ad.end(), cmp);     int sz1 = ac.size(), sz2 = ad.size();     if (sz1 != 0) {       mc[sz1 - 1] = ac[sz1 - 1].second;       for (int i = sz1 - 2; i >= 0; i--) mc[i] = max(ac[i].second, mc[i + 1]);     }     if (sz2 != 0) {       md[sz2 - 1] = ad[sz2 - 1].second;       for (int i = sz2 - 2; i >= 0; i--) md[i] = max(ad[i].second, md[i + 1]);     }     int abc = check(0, sz1, ac, c), abd = check(0, sz2, ad, d);     int mh = INT_MIN;     if (abc != sz1 && abd != sz2) {       mh = max(mh, mc[abc] + md[abd]);     }     for (int i = 0; i < sz1; i++) {       if (ac[i].first > c) continue;       int v = check(i + 1, sz1, ac, c - ac[i].first);       if (v != sz1) {         mh = max(mh, mc[v] + ac[i].second);       }     }     for (int i = 0; i < sz2; i++) {       if (ad[i].first > d) continue;       int v = check(i + 1, sz2, ad, d - ad[i].first);       if (v != sz2) {         mh = max(mh, md[v] + ad[i].second);       }     }     printf( %d n , max(mh, 0));     return 0;   }
#include <bits/stdc++.h>      using namespace std;      #define FOR(n) for(int i = 0; i < int(n); ++i)   #define RFOR(n) for(int i = n; ~i; --i)      int gcd(int a, int b) {       if(b == 0)           return a;       return gcd(b, a % b);   }      void solve() {       int n;       cin >> n;       map<pair<int, int>, int> mp;       long long ans = 0;       FOR(n) {           int x, y, u, v;           cin >> x >> y >> u >> v;           x -= u;           y -= v;           int g = gcd(abs(x), abs(y));           x /= g;           y /= g;           mp[{x, y}]++;           ans += mp[{-x, -y}];       }       cout << ans <<   n ;   }      int main(int argc, char* argv[]) {       ios::sync_with_stdio(false);       cin.tie(nullptr);              int testCase = 1;       cin >> testCase;       for(int t = 0; t < testCase; ++t)           solve();          return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > edges(2e5 + 5);   bool vis[200005];   int lev[200005];   int n, m, a, b, mx;   void bfs(int node) {     int level = 0;     deque<pair<int, int> > dq;     dq.push_back({level, node});     vis[node] = 1;     while (!dq.empty()) {       node = dq.front().second, level = dq.front().first;       lev[node] = level;       dq.pop_front();       for (auto i : edges[node])         if (!vis[i]) dq.push_back({level + 1, i}), vis[node] = 1;     }     memset(vis, 0, sizeof vis), a = 0;   }   void dfs(int node) {     if (a >= lev[node]) return;     vis[node] = 1;     mx = max(mx, lev[node]);     for (auto i : edges[node])       if (!vis[i]) a++, dfs(i), a--;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> m;     for (int i = 1; i < n; i++)       cin >> a >> b, edges[a].push_back(b), edges[b].push_back(a);     bfs(1);     dfs(m);     cout << mx * 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d, n, m;   int cntl[100011], cntr[100011], cntt[100011], cntb[100011];   struct Sofa {     int x1, y1, x2, y2;   } sofa[100011];   int main() {     scanf( %d , &d);     scanf( %d %d , &n, &m);     for (int i = 0; i < d; i++) {       int x1, y1, x2, y2;       scanf( %d %d %d %d , &x1, &y1, &x2, &y2);       cntl[min(x1, x2)]++;       cntr[max(x1, x2)]++;       cntt[min(y1, y2)]++;       cntb[max(y1, y2)]++;       sofa[i].x1 = x1;       sofa[i].y1 = y1;       sofa[i].x2 = x2;       sofa[i].y2 = y2;     }     for (int i = 1; i <= n; i++) cntl[i] += cntl[i - 1];     for (int i = n; i >= 0; i--) cntr[i] += cntr[i + 1];     for (int i = 1; i <= m; i++) cntt[i] += cntt[i - 1];     for (int i = m; i >= 0; i--) cntb[i] += cntb[i + 1];     int tl, tr, tt, tb;     scanf( %d %d %d %d , &tl, &tr, &tt, &tb);     for (int i = 0; i < d; i++) {       int tmpl = cntl[max(sofa[i].x1, sofa[i].x2) - 1],           tmpr = cntr[min(sofa[i].x1, sofa[i].x2) + 1],           tmpt = cntt[max(sofa[i].y1, sofa[i].y2) - 1],           tmpb = cntb[min(sofa[i].y1, sofa[i].y2) + 1];       if (max(sofa[i].x1, sofa[i].x2) != min(sofa[i].x1, sofa[i].x2)) {         tmpl--;         tmpr--;       }       if (max(sofa[i].y1, sofa[i].y2) != min(sofa[i].y1, sofa[i].y2)) {         tmpt--;         tmpb--;       }       if (tmpl == tl && tmpr == tr && tmpt == tt && tmpb == tb) {         cout << i + 1;         return 0;       }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   int main() {     long long int n;     long long int x;     long long int y;     long long int number;     scanf( %I64d %I64d %I64d , &n, &x, &y);     number = y - (n - 1);     while (true) {       if (number <= 0) {         printf( -1 n );         break;       }       if (number * number + n - 1 >= x) {         printf( %I64d n , number);         for (int i = 0; i < n - 1; i++) {           printf( 1 n );         }         break;       }       number--;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr long long ROWS = 2;   constexpr long long NMAX = 1e5;   long long h[ROWS][NMAX];   long long dp[ROWS][NMAX];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long COLS;     cin >> COLS;     for (long long i = 0; i < ROWS; ++i)       for (long long j = 0; j < COLS; ++j) cin >> h[i][j];     for (long long j = COLS - 1; j >= 0; --j)       for (long long i = ROWS - 1; i >= 0; --i) {         if (j == COLS - 1)           dp[i][j] = h[i][j];         else if (j == COLS - 2)           dp[i][j] = h[i][j] + h[i == 0 ? 1 : 0][j + 1];         else           dp[i][j] =               h[i][j] + max(dp[i == 0 ? 1 : 0][j + 1], dp[i == 0 ? 1 : 0][j + 2]);       }     cout << max(dp[0][0], dp[1][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans = 0;   long long mod = 1e9 + 7;   int cnt[100005], Tcnt[100005], arr[100005];   vector<int> pri;   void era() {     pri.push_back(2);     for (int i = 3; i <= 100000; i += 2) {       if (!arr[i])         for (long long j = (long long)i * i; j <= 100000; j += i) {           arr[j] = 1;         }     }     for (int i = 3; i <= 100000; i += 2) {       if (arr[i] == 0) pri.push_back(i);     }   }   int GGG(int p) {     int ret = 0;     for (int i = 0; i < pri.size(); i++) {       if (pri[i] > p) break;       int cnt = 0;       while (p % pri[i] == 0) {         p /= pri[i];         ++cnt;       }       if (cnt >= 2) return -1;       if (cnt != 0) ret++;     }     return ret;   }   long long po(int k) {     if (k == 0) return 1;     if (k == 1) return 2;     long long ret = po(k / 2);     ret = ret * ret % mod;     if (k & 1) ret = ret * 2 % mod;     return ret;   }   int main() {     era();     int n;     scanf( %d , &n);     for (int t, i = 1; i <= n; i++) {       scanf( %d , &t);       cnt[t]++;     }     for (int i = 2; i <= 100000; i++) {       for (int j = i; j <= 100000; j += i) {         Tcnt[i] += cnt[j];       }     }     ans += po(n) - 1;     for (int i = 2; i <= 100000; i++) {       if (Tcnt[i] == 0) continue;       int Gcnt = GGG(i);       if (Gcnt == -1) continue;       if (Gcnt % 2 == 0) {         ans += po(Tcnt[i]) - 1;         ans %= mod;       } else {         ans -= po(Tcnt[i]) - 1;         while (ans < 0) ans += mod;       }     }     printf( %I64d , ans);   }
#include <bits/stdc++.h>   const long long MaxN = 205;   const long long lim = 1e18 + 5;   template <class t>   inline void read(t &s) {     s = 0;     register long long f = 1;     register char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();     s *= f;     return;   }   template <class t, class... A>   inline void read(t &x, A &...a) {     read(x);     read(a...);   }   template <class t>   inline void write(t x) {     if (x < 0) putchar( - ), x = -x;     long long buf[21], top = 0;     while (x) buf[++top] = x % 10, x /= 10;     if (!top) buf[++top] = 0;     while (top) putchar(buf[top--] ^  0 );     return;   }   inline void setIn(std::string s) {     freopen(s.c_str(),  r , stdin);     return;   }   inline void setOut(std::string s) {     freopen(s.c_str(),  w , stdout);     return;   }   inline void setIO(std::string s =   ) {     setIn(s +  .in );     setOut(s +  .out );     return;   }   template <class t>   inline bool checkmin(t &x, t y) {     if (x > y) {       x = y;       return 1;     }     return 0;   }   template <class t>   inline bool checkmax(t &x, t y) {     if (x < y) {       x = y;       return 1;     }     return 0;   }   inline long long lowbit(long long x) { return x & (-x); }   long long a[MaxN][MaxN], p[MaxN], t[MaxN], n, m, K, q;   long long b[MaxN], f[MaxN][MaxN];   inline void add(long long &x, long long y) { (x += y) >= lim && (x = lim); }   inline long long calc() {     std::memset(f, 0, sizeof f);     f[0][0] = 1;     for (long long i = 1; i <= q; ++i) {       if (b[i] >= 0)         for (long long j = 1; j <= q; ++j) add(f[i][j], f[i - 1][j - 1]);       if (b[i] <= 0)         for (long long j = 0; j < q; ++j) add(f[i][j], f[i - 1][j + 1]);     }     return f[q][0];   }   signed main(void) {     read(n, m, K);     for (long long i = 1; i <= n; ++i)       for (long long j = 1; j <= m; ++j) read(a[i][j]);     {       std::vector<std::pair<long long, long long> > dr;       for (long long i = 1; i <= n; ++i)         for (long long j = 1; j <= m; ++j)           dr.push_back(std::make_pair(a[i][j], i + j - 1));       std::sort((dr).begin(), (dr).end());       register long long cnt = 0;       for (auto i : dr)         if (!p[i.second]) p[i.second] = ++cnt;       for (long long i = 1; i <= cnt; ++i) t[p[i]] = i;       for (long long i = 1; i <= cnt; ++i) p[i] = t[i];     }     q = n + m - 1;     register long long sum = 0;     for (long long i = 1; i <= q; ++i) {       b[p[i]] = 1;       register long long t = calc();       if (sum + t >= K) continue;       b[p[i]] = -1;       sum += t;     }     for (long long i = 1; i <= n; ++i, std::puts(  ))       for (long long j = 1; j <= m; ++j)         std::putchar(b[i + j - 1] > 0 ?  (  :  ) );     return 0;   }