malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)(2e9);   const long long linf = (long long)(2e18);   void solve();   signed main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cout << fixed << setprecision(20);     solve();     return 0;   }   void solve() {     int n = 8;     unordered_map<char, int> w, W;     w[ q ] = 9;     w[ r ] = 5;     w[ b ] = 3;     w[ n ] = 3;     w[ p ] = 1;     w[ k ] = 0;     w[ . ] = 0;     w[ Q ] = 0;     w[ R ] = 0;     w[ B ] = 0;     w[ N ] = 0;     w[ P ] = 0;     w[ K ] = 0;     W[ q ] = 0;     W[ r ] = 0;     W[ b ] = 0;     W[ n ] = 0;     W[ p ] = 0;     W[ k ] = 0;     W[ . ] = 0;     W[ Q ] = -9;     W[ R ] = -5;     W[ B ] = -3;     W[ N ] = -3;     W[ P ] = -1;     W[ K ] = 0;     int ans = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         char x;         cin >> x;         ans += (w[x] + W[x]);       }     }     if (!ans)       cout <<  Draw n ;     else if (ans < 0)       cout <<  White n ;     else       cout <<  Black n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v;   int extgcd(int a, int b, long long &x, long long &y) {     int d = a;     if (b != 0) {       d = extgcd(b, a % b, y, x);       y -= (a / b) * x;     } else {       x = 1;       y = 0;     }     return d;   }   int main() {     int n;     scanf( %d , &n);     int i = 2;     int t = n;     while (t > 1 && i <= sqrt(n)) {       if (t % i == 0) {         while (t % i == 0) t /= i;         v.push_back(i);       }       i++;     }     if (t > 1) v.push_back(t);     if (v.size() == 1) {       printf( NO n );       return 0;     }     int j;     bool f = true;     for (i = 0; i < v.size() && f; i++)       for (j = i + 1; j < v.size(); j++) {         long long p, q;         extgcd(v[i], v[j], p, q);         p *= n - 1;         q *= n - 1;         int a = v[i], b = v[j];         if (q < 0) {           swap(a, b);           swap(p, q);         }         long long t = (-p) / b + 1;         p += b * t;         q -= a * t;         if (q > 0) {           printf( YES n2 n );           printf( %d %d n%d %d n , (int)p, (int)n / a, (int)q, (int)n / b);           f = false;           break;         }       }     if (f) printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[5050];   int solve(int l, int r, int h) {     int m, i;     if (l > r)       return 0;     else if (l == r)       return (a[l] > h);     else       for (i = m = l; i <= r; i++)         if (a[m] > a[i]) m = i;     return min(r - l + 1,                a[m] - h + solve(l, m - 1, a[m]) + solve(m + 1, r, a[m]));   }   int main() {     int i, j;     int n;     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     cout << solve(0, n - 1, 0) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     tuple<long long, long long, long long> arr[n - 1];     long long s1, e1;     cin >> s1 >> e1;     for (long long i = 0; i < n - 1; ++i) {       long long s2, e2;       cin >> s2 >> e2;       arr[i] = make_tuple(e2 - s1 + 1, s2 - e1 - 1, i);       s1 = s2, e1 = e2;     }     pair<long long, long long> blen1[m];     long long blen2[m];     for (long long i = 0; i < m; ++i) {       long long b;       cin >> b;       blen1[i] = make_pair(b, i);       blen2[i] = b;     }     sort(arr, arr + n - 1);     sort(blen1, blen1 + m);     sort(blen2, blen2 + m);     pair<long long, long long> num_b[n - 1];     for (long long i = 0; i < n - 1; ++i) {       long long end, start, idx, u = 0, l = 0;       tie(end, start, idx) = arr[i];       l = upper_bound(blen2, blen2 + m, start) - blen2;       u = lower_bound(blen2, blen2 + m, end) - blen2;       if (u - l == 0) {         cout <<  No  << endl;         return 0;       } else {         num_b[i] = make_pair(l, u);       }     }     set<pair<long long, long long> > bg;     for (long long i = 0; i < m; ++i) {       bg.insert(blen1[i]);     }     long long ans[n - 1];     for (long long i = 0; i < n - 1; ++i) {       long long u = num_b[i].second, l = num_b[i].first;       set<pair<long long, long long> >::iterator itr =           bg.upper_bound({blen2[l], -1});       if (itr == bg.end() || (u != m && (*itr).first >= blen2[u])) {         cout <<  No  << endl;         return 0;       }       ans[get<2>(arr[i])] = (*itr).second + 1;       bg.erase(itr);     }     cout <<  Yes  << endl;     for (long long i = 0; i < n - 1; ++i) {       cout << ans[i] <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   const long double pi = 3.141592654;   using namespace std;   int n, k;   int dx[] = {0, 0, 1, -1, 1, -1, -1, 1};   int dy[] = {-1, 1, 0, 0, 1, 1, -1, -1};   bool valid(int r, int c) { return r >= 0 && c >= 0 && r < n && c < n; }   char grid[120][120];   bool vis[100074];   vector<int> initial;   vector<vector<int>> graph;   int parent[100074];   void topological_sort(int student) {     vis[student] = 1;     for (auto child : graph[student]) {       if (!vis[child]) topological_sort(child);     }     initial.push_back(student);   }   int main() {     long long n;     cin >> n;     if (n == 2) {       cout << 2;     } else {       if (n % 2 == 0)         cout << 2;       else         cout << 1;     }   }
#include <bits/stdc++.h>   using namespace std;   string s[9], v[35], k[35];   bool in[9];   int len, a[9], l[9], ans;   char c[35][35];   bool check2() {     if (ans == 0) return 1;     for (int i = 1; i <= min(len, ans); i++)       if (v[i] < k[i])         return 1;       else if (v[i] > k[i])         return 0;     if (len > ans) return 0;     return 1;   }   void check() {     if (l[a[1]] + l[a[3]] - 1 != l[a[2]]) return;     if (l[a[4]] + l[a[6]] - 1 != l[a[5]]) return;     if (s[a[1]][0] != s[a[4]][0]) return;     if (s[a[4]][l[a[4]] - 1] != s[a[2]][0]) return;     if (s[a[6]][0] != s[a[2]][l[a[2]] - 1]) return;     if (s[a[6]][l[a[6]] - 1] != s[a[3]][l[a[3]] - 1]) return;     if (s[a[5]][0] != s[a[1]][l[a[1]] - 1]) return;     if (s[a[5]][l[a[5]] - 1] != s[a[3]][0]) return;     if (s[a[5]][l[a[4]] - 1] != s[a[2]][l[a[1]] - 1]) return;     for (int i = 1; i <= l[a[5]]; i++)       for (int j = 1; j <= l[a[2]]; j++) c[i][j] =  . ;     for (int i = 0; i < l[a[1]]; i++) c[1][i + 1] = s[a[1]][i];     for (int i = 0; i < l[a[2]]; i++) c[l[a[4]]][i + 1] = s[a[2]][i];     for (int i = 0; i < l[a[3]]; i++) c[l[a[5]]][i + l[a[1]]] = s[a[3]][i];     for (int i = 0; i < l[a[4]]; i++) c[i + 1][1] = s[a[4]][i];     for (int i = 0; i < l[a[5]]; i++) c[i + 1][l[a[1]]] = s[a[5]][i];     for (int i = 0; i < l[a[6]]; i++) c[i + l[a[4]]][l[a[2]]] = s[a[6]][i];     len = l[a[5]];     for (int i = 1; i <= len; i++) {       v[i] =   ;       for (int j = 1; j <= l[a[2]]; j++) v[i] += c[i][j];     }     if (check2()) {       ans = len;       for (int i = 1; i <= len; i++) k[i] = v[i];     }   }   int main() {     for (int i = 1; i <= 6; i++) cin >> s[i], l[i] = s[i].length();     for (a[1] = 1; a[1] <= 6; a[1]++)       for (a[2] = 1; a[2] <= 6; a[2]++)         for (a[3] = 1; a[3] <= 6; a[3]++)           for (a[4] = 1; a[4] <= 6; a[4]++)             for (a[5] = 1; a[5] <= 6; a[5]++)               for (a[6] = 1; a[6] <= 6; a[6]++) {                 set<int> s1;                 s1.insert(a[1]);                 s1.insert(a[2]);                 s1.insert(a[3]);                 s1.insert(a[4]);                 s1.insert(a[5]);                 s1.insert(a[6]);                 if (s1.size() != 6) continue;                 check();               }     if (ans == 0)       printf( Impossible );     else       for (int i = 1; i <= ans; i++) cout << k[i] << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   inline istream& operator>>(istream& fin, pair<T1, T2>& pr) {     fin >> pr.first >> pr.second;     return fin;   }   template <class T0, class T1, class T2>   inline istream& operator>>(istream& fin, tuple<T0, T1, T2>& t) {     fin >> get<0>(t) >> get<1>(t) >> get<2>(t);     return fin;   }   template <class T>   inline istream& operator>>(istream& fin, vector<T>& a) {     for (auto& u : a) fin >> u;     return fin;   }   template <class T, size_t n>   inline istream& operator>>(istream& fin, array<T, n>& a) {     for (auto& u : a) fin >> u;     return fin;   }   template <class FwdIter>   inline auto dump(FwdIter first, FwdIter last, const char* dlm) -> void {     copy(first, last,          ostream_iterator<typename iterator_traits<FwdIter>::value_type>(cout,                                                                          dlm));   }   inline int64_t powmod(int64_t a, int64_t n, const int64_t mod) {     if (a == 1 || !n) return mod != 1 ? 1 : 0;     int64_t out = 1;     for (; n; n >>= 1) {       if (n & 1) out = out * a % mod;       a = a * a % mod;     }     return out;   }   int64_t probB() {     const int64_t mod = 1000000007;     int64_t p, k;     cin >> p >> k;     if (k == 0) {       return powmod(p, p - 1, mod);     }     vector<bool> tag(p, false);     int64_t out = k == 1 ? p : 1;     for (int64_t i = 1; i < p; ++i)       if (!tag[i]) {         out = (out * p) % mod;         for (auto j = i; !tag[j]; j = (j * k) % p) tag[j] = true;       }     return out;   }   int main(const int argc, char* argv[]) {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << probB();     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int left, right, size;   } t[600000];   int n;   int a[200005], b[200005], sa[200005], sb[200005], s[200005], ans[200005];   int readint() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   void build(int id, int l, int r, int x) {     t[id].left = l, t[id].right = r;     if (l == r) return (void)(t[id].size = x);     int mid = (l + r) / 2;     build(id << 1, l, mid, x);     build(id << 1 | 1, mid + 1, r, x);     t[id].size = t[id << 1].size + t[id << 1 | 1].size;   }   int query(int id, int x) {     if (t[id].left == t[id].right) return t[id].size;     if (x <= t[id << 1].right)       return query(id << 1, x);     else       return query(id << 1 | 1, x) + t[id << 1].size;   }   void change(int id, int x, int c) {     if (t[id].left == t[id].right) return (void)(t[id].size = c);     if (x <= t[id << 1].right)       change(id << 1, x, c);     else       change(id << 1 | 1, x, c);     t[id].size = t[id << 1].size + t[id << 1 | 1].size;   }   int find(int id, int x) {     if (t[id].left == t[id].right) return t[id].left;     if (x <= t[id << 1].size)       return find(id << 1, x);     else       return find(id << 1 | 1, x - t[id << 1].size);   }   int main() {     n = readint();     for (int i = 1; i <= n; i++) a[i] = readint() + 1;     for (int i = 1; i <= n; i++) b[i] = readint() + 1;     build(1, 1, n, 0);     for (int i = n; i >= 1; i--) {       sa[i] = query(1, a[i]);       change(1, a[i], 1);     }     build(1, 1, n, 0);     for (int i = n; i >= 1; i--) {       sb[i] = query(1, b[i]);       change(1, b[i], 1);     }     for (int i = n; i >= 1; i--) {       s[i] += sa[i] + sb[i];       if (s[i] >= n - i + 1) s[i] -= n - i + 1, s[i - 1]++;     }     build(1, 1, n, 1);     for (int i = 1; i <= n; i++) {       ans[i] = find(1, s[i] + 1);       change(1, ans[i], 0);     }     for (int i = 1; i <= n; i++) printf( %d  , ans[i] - 1);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000100], g[1000100];   int main() {     for (int i = 1; i < 20; i++) {       int msk = (1 << i) - 1;       for (int j = (1 << i - 1); j < (1 << i); j++) {         g[j] = (1 << i - 1) | g[j ^ msk];       }     }     int n, x;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     for (int i = 19; i >= 0; i--) {       vector<int> v, piv;       for (int j = 0; j < n; j++) {         if (a[j] >= (1 << i)) continue;         int x = a[j];         for (int k = 0; k < v.size(); k++) {           if (x & (piv[k] & -piv[k])) x ^= piv[k];         }         if (x > 0) {           v.push_back(a[j]);           piv.push_back(x);         }       }       if (v.size() == i) {         printf( %d n , i);         for (int j = 0; j < (1 << i); j++) {           int x = 0;           for (int k = 0; k < i; k++) {             if (g[j] & (1 << k)) x ^= v[k];           }           printf( %d  , x);         }         puts(  );         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 4e5 + 10;   int n, a[MAX];   int f(int x) {     vector<int> v(n);     for (int i = 0; i < n; ++i) {       v[i] = (a[i] == -1 ? x : a[i]);     }     int ret = 0;     for (int i = 0; i < n - 1; ++i) {       ret = max(ret, abs(v[i] - v[i + 1]));     }     return ret;   }   void solve() {     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     long long beg = 0, end = 1e9;     while (end - beg > 3) {       long long mid1 = (2 * beg + end) / 3;       long long mid2 = (beg + 2 * end) / 3;       int f1 = f(mid1);       int f2 = f(mid2);       if (f1 > f2) {         beg = mid1 + 1;       } else if (f1 <= f2) {         end = mid2 - 1;       }     }     int ans = 1e9, ind;     for (int i = beg; i <= end; ++i) {       int t = f(i);       if (t < ans) {         ans = t;         ind = i;       }     }     cout << ans <<     << ind <<   n ;   }   int main() {     int q;     cin >> q;     while (q--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     while (scanf( %d%d%d , &n, &m, &k) != EOF) {       if (n == m) {         if (n == 2 && k == 1) {           printf( 4 n );           printf( 1 2 3 4 n );         } else {           printf( %d n , 2 * k + 1);           printf( 1 );           for (int i = 1; i < k; i++) {             printf(  1 );           }           printf(  %d , n);           for (int i = 1; i < k; i++) {             printf(  %d , n + 1);           }           if (k == 1)             printf(  %d n , 2 * n - 1);           else             printf(  %d n , 2 * n);         }       } else if (m == n - 1) {         if (k > 1) {           printf( %d n , 2 * k);           printf( 1 );           for (int i = 1; i < k; i++) {             printf(  1 );           }           printf(  %d , n);           for (int i = 1; i < k; i++) {             printf(  %d , n + 1);           }           printf(  n );         } else {           printf( %d n , 2 * k + 1);           printf( 1 );           for (int i = 1; i < k; i++) {             printf(  1 );           }           printf(  %d , n);           for (int i = 1; i < k; i++) {             printf(  %d , n + 1);           }           printf(  %d n , n + m);         }       } else {         printf( %d n , 2 * k);         printf( 1 );         for (int i = 1; i < k; i++) {           printf(  1 );         }         printf(  %d , n);         for (int i = 1; i < k; i++) {           printf(  %d , n + 1);         }         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct EDGE {     int u, v, l, next;     bool train;     EDGE() {}     EDGE(int a, int b, int c, int d, bool bo) {       u = a;       v = b;       l = c;       next = d;       train = bo;     }   } edge[1000000];   int n, m, k;   int edgenumber, head[200100], visit[200100], fr[200100];   long long d[200100];   void addedge(int u, int v, int l, bool bo) {     edge[edgenumber] = EDGE(u, v, l, head[u], bo);     head[u] = edgenumber++;   }   void spfa(int rt) {     memset(d, 0x3f3f3f3f, sizeof(d));     priority_queue<pair<int, long long> > q;     q.push(make_pair(1, 0));     visit[rt] = 1;     d[rt] = 0;     while (!q.empty()) {       int u = q.top().first;       q.pop();       for (int i = head[u]; i != -1; i = edge[i].next) {         int v = edge[i].v;         int l = edge[i].l;         if (d[u] + l < d[v]) {           d[v] = d[u] + l;           fr[v] = i;           if (!visit[v]) {             visit[v] = 1;             q.push(make_pair(v, -d[v]));           }         } else if (d[v] == d[u] + l && edge[fr[v]].train) {           fr[v] = i;         }       }       visit[u] = 0;     }     for (int i = 2; i <= n; i++)       if (edge[fr[i]].train) k--;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     edgenumber = 0;     memset(head, -1, sizeof(head));     vector<pair<int, int> > kn;     for (int i = 0; i < m; i++) {       int u, v, l;       scanf( %d%d%d , &u, &v, &l);       addedge(u, v, l, false);       addedge(v, u, l, false);     }     for (int i = 0; i < k; i++) {       int v, l;       scanf( %d%d , &v, &l);       kn.push_back(make_pair(v, l));       addedge(1, v, l, true);     }     spfa(1);     printf( %d n , k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s;     cin >> s;     while (s--) {       string t;       cin >> t;       int f = 0;       for (int i = 1; i < t.length(); i++) {         if (t[i] != t[i - 1]) {           f = 1;           break;         }       }       if ((f == 0) || (t.length() == 2)) {         cout << t << endl;       } else {         cout << t[0];         for (int i = 1; i < t.length(); i++) {           if (t[i] == t[i - 1]) {             if (t[i] ==  0 ) {               cout << 1 << t[i];             } else if (t[i] ==  1 ) {               cout << 0 << t[i];             }           } else {             cout << t[i];           }         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef long long ll;   int main()   {     int t;     cin >> t;     while(t--)     {         string s;         cin >> s;         char c =  a ;         int n = s.size();         if(n&1)         {              for(int i=0;i<=n/2;i++)            {                if(s[n-i-1]!= a )                {                    s = s.substr(0,i)+c+s.substr(i);                    break;                }            }            if(s.size()==n+1)             {                 cout <<  YES  << endl;                 cout << s << endl;             }             else{                 bool p = true;                  for(int i=0;i<n/2;i++)                 {                   if(s[n-i-1]!=s[i])                   {                    p = false;                    break;                   }                }                if(!p)                {                    cout <<  YES  << endl;                    cout << s+c << endl;                }                else                {                    cout <<  NO  << endl;                }             }         }         else{            for(int i=0;i<n/2;i++)            {                if(s[n-i-1]!= a )                {                    s = s.substr(0,i)+c+s.substr(i);                    break;                }            }            if(s.size()==n+1)             {                 cout <<  YES  << endl;                 cout << s << endl;             }             else{                 bool p = true;                  for(int i=0;i<n/2;i++)                 {                   if(s[n-i-1]!=s[i])                   {                    p = false;                    break;                   }                }                if(!p)                {                    cout <<  YES  << endl;                    cout << s+c << endl;                }                else                {                    cout <<  NO  << endl;                }             }         }              }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx2,tune=native )   #pragma GCC optimize( unroll-loops )   using namespace std;   using ll = long long;   using ld = long double;   using vi = vector<int>;   using vvi = vector<vi>;   using pi = pair<ll, ll>;   const int mod = 1e9 + 7;   const ll inf = 1e18;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   ll n, k, mn[40][100100], sm[40][100100], p[40][100100];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> p[0][i];     for (int i = 0; i < n; i++) cin >> mn[0][i], sm[0][i] = mn[0][i];     for (int i = 1; i < 34; i++) {       for (int j = 0; j < n; j++) {         p[i][j] = p[i - 1][p[i - 1][j]];         sm[i][j] = sm[i - 1][j] + sm[i - 1][p[i - 1][j]];         mn[i][j] = min(mn[i - 1][j], mn[i - 1][p[i - 1][j]]);       }     }     for (int i = 0; i < n; i++) {       ll u = i, m = LLONG_MAX, s = 0;       for (int j = 34; j--;) {         if (k & (1ll << j)) {           m = min(m, mn[j][u]);           s = s + sm[j][u];           u = p[j][u];         }       }       cout << s <<     << m <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int __gcd(int x, int y) {     if (!y) return x;     return __gcd(y, x % y);   }   const long long linf = 1e18 + 5;   int mod = (int)1e9;   const int logN = 18;   const int inf = 1e9 + 9;   const int N = 1e5 + 5;   int ff, h[N], n, a[N], x, y, z, p;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       h[a[i]]++;     }     int ff = 0;     for (int i = 1; i <= 100000; i++)       if (h[i] & 1) ff = 1;     if (ff) {       cout <<  Conan ;     } else       cout <<  Agasa ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   int dp[55][8], d1[55], d2[55], d3[55], n, m;   string s;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       cin >> s;       d1[i] = inf;       d2[i] = inf;       d3[i] = inf;       for (int j = 0; j < s.size(); ++j) {         if (s[j] >=  a  && s[j] <=  z ) {           d1[i] = min(d1[i], min(j, (int)s.size() - j));         } else if (s[j] >=  0  && s[j] <=  9 ) {           d2[i] = min(d2[i], min(j, (int)s.size() - j));         } else {           d3[i] = min(d3[i], min(j, (int)s.size() - j));         }       }     }     for (int i = 0; i < 8; ++i) {       dp[0][i] = inf;     }     dp[0][0] = 0;     for (int i = 1; i <= n; ++i) {       dp[i][0] = dp[i - 1][0];       dp[i][1] = min(dp[i - 1][1], dp[i - 1][0] + d1[i]);       dp[i][2] = min(dp[i - 1][2], dp[i - 1][0] + d2[i]);       dp[i][4] = min(dp[i - 1][4], dp[i - 1][0] + d3[i]);       dp[i][3] =           min(dp[i - 1][3], min(dp[i - 1][1] + d2[i], dp[i - 1][2] + d1[i]));       dp[i][5] =           min(dp[i - 1][5], min(dp[i - 1][1] + d3[i], dp[i - 1][4] + d1[i]));       dp[i][6] =           min(dp[i - 1][6], min(dp[i - 1][2] + d3[i], dp[i - 1][4] + d2[i]));       dp[i][7] = min(min(dp[i - 1][7], dp[i - 1][6] + d1[i]),                      min(dp[i - 1][5] + d2[i], dp[i - 1][3] + d3[i]));     }     cout << dp[n][7];   }