malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, ai, bi;   vector<vector<int> > adj(200009);   vector<int> vis(200009, 0);   vector<pair<int, int> > se;   void dfs(int v, int vl) {     if (vis[v]) return;     vis[v] = vl;     vl = (vl == 1) ? 2 : 1;     int len = adj[v].size();     for (int i = 0; i < len; i++) dfs(adj[v][i], vl);   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> ai >> bi;       se.push_back(make_pair(ai, bi));       adj[ai].push_back(bi);       adj[bi].push_back(ai);       adj[(2 * i)].push_back(2 * i + 1);       adj[(2 * i + 1)].push_back(2 * i);     }     for (int i = 1; i <= 2 * n; i++)       if (!vis[i]) dfs(i, 1);     for (int i = 0; i < n; i++)       cout << vis[se[i].first] <<     << vis[se[i].second] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   string s[20][20];   string ran =  23456789TJQKA ;   string sui =  CDHS ;   set<string> st;   int j1x = -1, j1y = -1, j2x = -1, j2y = -1;   inline bool ok(int x, int y) {     set<char> ra, su;     for (int i = x; i < x + 3; i++) {       for (int j = y; j < y + 3; j++) {         ra.insert(s[i][j][0]);         su.insert(s[i][j][1]);       }     }     return ra.size() == 9 || su.size() == 1;   }   int main() {     cin >> n >> m;     for (int i = 0; i < 13; i++) {       for (int j = 0; j < 4; j++) {         string ss =     ;         ss[0] = ran[i];         ss[1] = sui[j];         st.insert(ss);       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> s[i][j];         if (s[i][j] !=  J1  && s[i][j] !=  J2 )           st.erase(s[i][j]);         else if (s[i][j] ==  J1 )           j1x = i, j1y = j;         else           j2x = i, j2y = j;       }     }     for (set<string>::iterator it1 = st.begin(); it1 != st.end(); it1++) {       if (j1x != -1) s[j1x][j1y] = (*it1);       for (set<string>::iterator it2 = st.begin(); it2 != st.end(); it2++) {         if (it1 == it2) continue;         if (j2x != -1) s[j2x][j2y] = (*it2);         vector<pair<int, int> > v;         for (int i = 0; i <= n - 3; i++) {           for (int j = 0; j <= m - 3; j++)             if (ok(i, j)) v.push_back(make_pair(i + 1, j + 1));         }         for (int i = 0; i < v.size(); i++) {           for (int j = 0; j < i; j++) {             if (abs(v[i].first - v[j].first) > 2 ||                 abs(v[i].second - v[j].second) > 2) {               cout <<  Solution exists. n ;               if (j1x == -1 && j2x == -1) cout <<  There are no jokers. n ;               if (j1x == -1 && j2x != -1)                 cout <<  Replace J2 with   << (*it2) <<  . n ;               if (j1x != -1 && j2x == -1)                 cout <<  Replace J1 with   << (*it1) <<  . n ;               if (j1x != -1 && j2x != -1)                 cout <<  Replace J1 with   << (*it1) <<   and J2 with   << (*it2)                      <<  . n ;               cout <<  Put the first square to (  << v[i].first <<  ,                      << v[i].second <<  ). n ;               cout <<  Put the second square to (  << v[j].first <<  ,                      << v[j].second <<  ). n ;               exit(0);             }           }         }       }     }     cout <<  No solution. ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool col[100010];   int a, b, n, k;   int main() {     cin >> n >> k >> a >> b;     int inv(1);     if (a < b) {       swap(a, b);       inv = 0;     }     for (int i(1); i <= k + 1; i++) {       for (int j(i); j <= n; j += k + 1) {         if (a) {           col[j] = 1;           a--;         }       }     }     int frc(0);     for (int i(1); i <= k + 1; i++) frc += col[i];     for (int i(k + 2); i <= n + 1; i++) {       if (frc == k + 1 || frc == 0) {         cout <<  NO ;         return 0;       }       frc -= col[i - k - 1];       frc += col[i];     }     for (int i(1); i <= n; i++) {       if (inv)         cout << (col[i] ?  G  :  B );       else         cout << (!col[i] ?  G  :  B );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cas, b, k;   int main() {     cas = 1;     while (cas--) {       scanf( %d%d , &b, &k);       int ans = 0;       b = b % 2;       for (int i = 1; i <= k; i++) {         int x;         scanf( %d , &x);         if (i == k) b = 1;         ans = ans + b * x;         ans %= 2;       }       if (ans % 2)         printf( odd n );       else         printf( even n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     string s;     cin >> s;     int64_t N = s.size();     vector<int64_t> v(N, 0);     int64_t l = 0, r = N - 1;     for (int64_t i = 0; i < N; ++i) {       if (s[i] ==  l ) {         v[r] = i + 1;         --r;       } else {         v[l] = i + 1;         ++l;       }     }     for (int64_t k : v) {       cout << k <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int dp[60002][10];   int main() {     int n, m;     scanf( %d%d , &n, &m);     int a;     for (int j = 0; j < m; j++) {       cin >> a;       if (!j)         dp[0][j] = a;       else         dp[0][j] = dp[0][j - 1] + a;     }     cout << dp[0][m - 1] <<    ;     for (int i = 1; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a;         if (!j)           dp[i][j] = dp[i - 1][j] + a;         else {           if (dp[i - 1][j] >= dp[i][j - 1])             dp[i][j] = dp[i - 1][j] + a;           else             dp[i][j] = dp[i][j - 1] + a;         }       }       cout << dp[i][m - 1] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   bitset<22500> a, b, c, e;   int n, m, k;   char s[100010];   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < n; i++) {       scanf( %s , s);       for (int j = 0; j < m; j++) {         if (s[j] !=  # ) a[i * m + j] = 1;         if (s[j] ==  E ) e[i * m + j] = 1;         if (s[j] ==  # ) b[i * m + j] = 1;       }     }     scanf( %s , s);     c = a;     for (int i = 0; i < k; i++) {       if (c == e) {         printf( %d n , i);         return 0;       }       if (s[i] ==  U ) c = ((c >> m) & a) | (c & (b << m));       if (s[i] ==  D ) c = ((c << m) & a) | (c & (b >> m));       if (s[i] ==  L ) c = ((c >> 1) & a) | (c & (b << 1));       if (s[i] ==  R ) c = ((c << 1) & a) | (c & (b >> 1));     }     printf( %d n , c == e ? k : -1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     long long maxi = INT_MIN;     while (n--) {       long long x, y;       cin >> x >> y;       long long sum = x + y;       if (sum > maxi) {         maxi = sum;       }     }     cout << maxi <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double inf = 1e+10;   double eps = 1e-10;   inline int sgn(const double& x) { return (x > +eps) - (x < -eps); }   const int MAXN = 500;   const int MAXM = 501;   int n, m;   double A[MAXM + 1][MAXN + 1];   int basis[MAXM + 1], out[MAXN + 1];   void pivot(int a, int b) {     for (int i = 0; i <= m; ++i)       if (i != a && sgn(A[i][b]))         for (int j = 0; j <= n; ++j)           if (j != b) A[i][j] -= A[a][j] * A[i][b] / A[a][b];     for (int i = 0; i <= m; ++i)       if (i != a) A[i][b] /= -A[a][b];     for (int j = 0; j <= n; ++j)       if (j != b) A[a][j] /= A[a][b];     A[a][b] = 1 / A[a][b];     swap(basis[a], out[b]);   }   double simplex() {     for (int j = 0; j < n; ++j) A[0][j] = -A[0][j];     for (int i = 0; i <= m; ++i) basis[i] = -i;     for (int j = 0; j <= n; ++j) out[j] = j;     while (true) {       int a = 1, b = 0;       for (int i = 1; i <= m; ++i)         if (make_pair(A[i][n], basis[i]) < make_pair(A[a][n], basis[a])) a = i;       if (A[a][n] >= 0) break;       for (int j = 0; j < n; ++j)         if (A[a][j] < A[a][b]) b = j;       if (A[a][b] >= 0) return -inf;       pivot(a, b);     }     while (true) {       int a = 1, b = 0;       for (int j = 0; j < n; ++j)         if (A[0][j] < A[0][b] || A[0][j] == A[0][b] && out[j] < out[b]) b = j;       if (A[0][b] >= 0) break;       for (int i = 1; i <= m; ++i)         if (A[i][b] > 0 &&             (A[a][b] <= 0 || make_pair(A[i][n] / A[i][b], basis[i]) <                                  make_pair(A[a][n] / A[a][b], basis[a])))           a = i;       if (A[a][b] <= 0) return +inf;       pivot(a, b);     }     return A[0][n];   }   int d;   vector<int> adj[500];   vector<int> wei[500];   void dfs(double A[], int u, int p, int d) {     if (d >= 0) {       A[u]--;       for (int i = 0; i < ((int((adj[u]).size()))); ++i) {         int v = adj[u][i];         if (v != p) {           dfs(A, v, u, d - wei[u][i]);         }       }     }   }   int main() {     scanf( %d%d , &n, &d);     int ttl = 0;     for (int i = 0; i < (n); ++i) {       int ti;       scanf( %d , &ti), A[0][i] = ti - 1, ttl += ti;     }     for (int i = 0; i < (n - 1); ++i) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w), --u, --v;       adj[u].push_back(v), adj[v].push_back(u);       wei[u].push_back(w), wei[v].push_back(w);     }     A[0][n] = 0;     for (int i = 0; i < (n); ++i) {       dfs(A[i + 1], i, -1, d);       A[i + 1][n] = -1;     }     for (int i = 0; i < (n); ++i) A[n + 1][i] = 1;     A[n + 1][n] = ttl;     m = n + 1;     double get = simplex();     int ans;     if (get == -inf)       ans = -1;     else       ans = -get + 0.5;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   const char choice[6][2] = {{ A ,  C }, { A ,  G }, { A ,  T },                              { C ,  G }, { C ,  T }, { G ,  T }};   int n, m;   string str[maxn];   int ord[2][maxn][6], cnt[2][maxn];   string out[maxn];   void print(int rc, int k) {     for (int i = 0; i < n; i++) out[i] =   ;     if (rc == 0) {       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++)           out[i] += choice[(i & 1) ? 5 - k : k][(j & 1) ^ ord[0][i][k]];     } else {       for (int j = 0; j < m; j++)         for (int i = 0; i < n; i++)           out[i] += choice[(j & 1) ? 5 - k : k][(i & 1) ^ ord[1][j][k]];     }     for (int i = 0; i < n; i++) cout << out[i] << endl;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> str[i];     memset(cnt, 0, sizeof(cnt));     for (int i = 0; i < n; i++) {       for (int k = 0; k < 6; k++) {         int now1 = 0, now2 = 0;         for (int j = 0; j < m; j++) {           now1 += (str[i][j] != choice[(i & 1) ? 5 - k : k][j & 1]);           now2 += (str[i][j] != choice[(i & 1) ? 5 - k : k][(j & 1) ^ 1]);         }         ord[0][i][k] = now1 < now2 ? 0 : 1;         cnt[0][k] += min(now1, now2);       }     }     for (int j = 0; j < m; j++) {       for (int k = 0; k < 6; k++) {         int now1 = 0, now2 = 0;         for (int i = 0; i < n; i++) {           now1 += (str[i][j] != choice[(j & 1) ? 5 - k : k][i & 1]);           now2 += (str[i][j] != choice[(j & 1) ? 5 - k : k][(i & 1) ^ 1]);         }         ord[1][j][k] = now1 < now2 ? 0 : 1;         cnt[1][k] += min(now1, now2);       }     }     int ans = 0x3f3f3f3f, RC, K;     for (int rc = 0; rc <= 1; rc++) {       for (int k = 0; k < 6; k++) {         if (cnt[rc][k] < ans) ans = cnt[rc][k], RC = rc, K = k;       }     }     print(RC, K);   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<vector<int>> adj;   vector<long long> d;   vector<bool> visited;   bitset<5000> sol;   void dfs(int m) {     bitset<5000> tmp;     d[m] = 1;     tmp[0] = 1;     for (auto l : adj[m]) {       if (!visited[l]) {         visited[l] = 1;         dfs(l);         d[m] += d[l];         tmp |= (tmp << d[l]);       }     }     tmp |= (tmp << (n - d[m]));     sol |= tmp;   }   int main(int argc, const char* argv[]) {     ios::sync_with_stdio(0);     cin.tie(0);     int a, b;     cin >> n;     adj = vector<vector<int>>(n + 2);     d = vector<long long>(n + 1);     visited = vector<bool>(n + 1, false);     int p = n;     while (--n) {       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     n = p;     visited[a] = 1;     dfs(a);     int counter = 0;     for (int i = 1; i < n - 1; i++) {       if (sol[i]) {         counter++;       }     }     cout << counter <<   n ;     for (int i = 1; i < n - 1; i++) {       if (sol[i]) {         cout << i <<     << n - i - 1 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 1e6 + 50;   bool tot[10000050];   vector<int> prime;   void seive() {     for (int i = 2; i * i <= mx; i++) {       if (!tot[i]) {         for (int j = (2 * i); j <= mx; j += i) {           tot[j] = true;         }       }     }     for (int i = 2; i <= mx; i++) {       if (!tot[i]) {         prime.push_back(i);       }     }   }   vector<int> g[mx];   map<int, bool> mp;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     seive();     cin >> n >> m;     long long int sum = 0;     for (int i = 1; i < n - 1; i++) {       sum += 2;     }     int p = upper_bound(prime.begin(), prime.end(), sum) - prime.begin();     int x = prime[p] - sum;     cout << 2 <<     << prime[p] << endl;     cout << 1 <<     << n <<     << 2 << endl;     for (int i = 2; i <= n - 1; i++) {       cout << 1 <<     << i <<     << ((i == 2) ? x : 2) << endl;     }     m -= n - 1;     long long int tot = (int)1e6 + 10;     int j = 2;     mp[1] = true;     int t = 3;     int f = 0;     for (int i = 2; i < n; i++) {       for (int j = i + 1; j <= n; j++) {         if (f == m) {           return 0;         }         f++;         cout << i <<     << j <<     << (++tot) << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};   const int dc[] = {0, 1, 0, -1, 1, -1, -1, 1};   const double eps = 1e-9;   const int INF = 0x7FFFFFFF;   const long long INFLL = 0x7FFFFFFFFFFFFFFFLL;   const double pi = acos(-1);   template <class T>   T take(queue<T> &O) {     T tmp = O.front();     O.pop();     return tmp;   }   template <class T>   T take(stack<T> &O) {     T tmp = O.top();     O.pop();     return tmp;   }   template <class T>   T take(priority_queue<T> &O) {     T tmp = O.top();     O.pop();     return tmp;   }   template <class T>   inline void getint(T &num) {     bool neg = 0;     num = 0;     char c;     while ((c = getchar_unlocked()) && (!isdigit(c) && c !=  - ))       ;     if (c ==  - ) {       neg = 1;       c = getchar_unlocked();     }     do num = num * 10 + c -  0 ;     while ((c = getchar_unlocked()) && isdigit(c));     num *= (neg) ? -1 : 1;   }   template <class T>   inline bool inRange(T z, T a, T b) {     return a <= z && z <= b;   }   void OPEN(string in =  input.txt , string out =  output.txt ) {     freopen(in.c_str(),  r , stdin);     freopen(out.c_str(),  w , stdout);     return;   }   int n;   int main(int argc, const char *argv[]) {     cin >> n;     if (n < 4)       cout <<  NO n ;     else {       cout <<  YES n ;       int cnt = 0, nao;       if (n & 1) {         cnt = n - 5, nao = 6;         for (int(i) = (0), _t = (cnt / 2); i < (_t); ++(i)) {           cout << nao + 1 <<   -   << nao <<   = 1 n ;           nao += 2;         }         cout <<  4 + 1 = 5 n                   5 * 5 = 25 n                   3 - 2 = 1 n                   25 - 1 = 24 n ;         for (int(i) = (0), _t = (cnt / 2); i < (_t); ++(i))           cout <<  24 * 1 = 24 n ;       } else {         cout <<  1 * 2 = 2 n                   2 * 3 = 6 n                   6 * 4 = 24 n ;         cnt = n - 4, nao = 5;         for (int(i) = (0), _t = (cnt / 2); i < (_t); ++(i)) {           cout << nao + 1 <<   -   << nao <<   = 1 n ;           nao += 2;         }         for (int(i) = (0), _t = (cnt / 2); i < (_t); ++(i))           cout <<  24 * 1 = 24 n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       cin.sync();       string s;       cin >> s;       stack<char> ss;       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  ( ) ss.push(s[i]);         if (!ss.empty()) {           if (s[i] ==  ) ) {             if (ss.top() ==  ( ) {               ss.pop();             }           }         }       }       cout << ss.size() << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1};   int dy[8] = {0, 0, -1, 1, 1, -1, -1, 1};   int n, k, f;   vector<int> v;   int main(void) {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &f);       v.push_back(f);     }     long long ans = 0;     sort(v.rbegin(), v.rend());     int to = 0;     for (int i = 0; i < v.size(); i++) {       to++;       if (to == k || i + 1 == v.size()) {         ans += 2 * (v[i - to + 1] - 1);         to = 0;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, n1, n2, c, b;     cin >> n >> n1 >> n2;     c = n1;     b = n2;     long double sum = 0, sum1 = 0;     long long int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     if (n1 >= n2) {       long long int i = 0;       while (b > 0) {         sum += a[n - i - 1];         i++;         b--;       }       sum = sum / n2;       while (c > 0) {         sum1 += a[n - i - 1];         i++;         c--;       }       sum1 = sum1 / n1;       cout << fixed << setprecision(8) << sum + sum1 << endl;     } else {       long long int i = 0;       while (c > 0) {         sum += a[n - i - 1];         i++;         c--;       }       sum = sum / n1;       while (b > 0) {         sum1 += a[n - i - 1];         i++;         b--;       }       sum1 = sum1 / n2;       cout << fixed << setprecision(8) << sum + sum1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000001;   int n, t;   int p[MAXN], s[MAXN];   stack<int> st;   int main() {     scanf( %d n , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &p[i]);     scanf( %d , &t);     for (int i = 1; i <= t; ++i) {       int x;       scanf( %d , &x);       p[x] = -p[x];     }     for (int i = n; i >= 1; --i)       if (p[i] < 0)         st.push(-p[i]);       else {         if (!st.empty() && st.top() == p[i]) {           st.pop();         } else           p[i] = -p[i], st.push(-p[i]);       }     if (st.empty()) {       printf( YES n );       for (int i = 1; i <= n; ++i) printf( %d%s , p[i], (i < n) ?     :   n );     } else       printf( NO n );     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000000 + 10;   long long a[MAXN];   long long b[MAXN];   void add(long long k, long long val, int start, int end) {     if (start > end) return;     a[start] += k;     a[end + 1] -= k;     long long bias = val - start * k;     b[start] += bias;     b[end + 1] -= bias;   }   int main() {     int n, num;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , &num);       if (num >= i) {         add(-1, num - i, 0, num - i);         add(1, 1, num - i + 1, n - i);         add(-1, num - 1, n - i + 1, n - 1);       } else {         add(1, i - num, 0, n - i);         add(-1, num - 1, n - i + 1, n + num - i);         add(1, 1, n + num - i + 1, n - 1);       }     }     int pos = 0;     long long val = b[0];     for (int i = 1; i < n; i++) {       a[i] += a[i - 1];       b[i] += b[i - 1];       if (a[i] * i + b[i] < val) {         val = a[i] * i + b[i];         pos = i;       }     }     cout << val <<     << pos << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double r, L;   double b, u, A;   double x, y, a;   double D[95], B[95];   struct st {     double x, y, a;   };   st bear[50];   int t;   double fun(int i, double l) {     x = bear[i].x;     y = bear[i].y;     t = bear[i].a;     a = B[t];     b = (fabs(l - x) / y);     A = D[t];     if (x < l)       u = ((A + b) / (1 - A * b)) * y - l + x;     else {       if (a < b)         u = x - l - ((b - A) / (1 + b * A)) * y;       else         u = ((A - b) / (1 + A * b)) * y + x - l;     }     if (u < 0) return 1e9;     return u;   }   const int N = (1 << 20) + 10;   double d[N][22];   int main() {     for (int i = 1; i <= 90; i++) {       B[i] = i * acosl(-1) / 180;       D[i] = tan(B[i]);     }     double l;     int n;     cin >> n >> l >> r;     L = l;     for (int i = 0; i < n; i++) cin >> bear[i].x >> bear[i].y >> bear[i].a;     int m = (1 << n) - 1, i, j, k;     double ans = -1e9;     for (i = 1; i <= m; i++) {       for (j = 0; j < n; j++) {         if (((1 << j) & i)) {           d[i][j] = -1e9;           if ((1 << j) == i) {             d[i][j] = l + fun(j, l);             ans = max(ans, d[i][j]);           } else {             for (k = 0; k < n; k++) {               if (((1 << k) & i) && j != k) {                 d[i][j] =                     max(d[i][j], d[i ^ (1 << j)][k] + fun(j, d[i ^ (1 << j)][k]));                 ans = max(ans, d[i][j]);               }             }           }         }       }     }     printf( %.6f , min(ans - L, r - L));   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 5100;   long long n, s, t, x[N], a[N], b[N], c[N], d[N], w[N];   long long dp[N][N];   inline void print(long long a[]) {     for (long long i = 1; i <= n; i++) printf( %lld  , a[i]);     printf(  n );   }   inline long long read() {     long long f = 1, x = 0;     char s = getchar();     while (s <  0  || s >  9 ) {       if (s ==  - ) f = -1;       s = getchar();     }     while (s >=  0  && s <=  9 ) {       x = x * 10 + s -  0 ;       s = getchar();     }     return x * f;   }   signed main() {     n = read();     s = read();     t = read();     for (long long i = 1; i <= n; i++) x[i] = read();     for (long long i = 1; i <= n; i++) a[i] = read() + x[i];     for (long long i = 1; i <= n; i++) b[i] = read() - x[i];     for (long long i = 1; i <= n; i++) c[i] = read() + x[i];     for (long long i = 1; i <= n; i++) d[i] = read() - x[i];     long long x = 0, y = 0;     for (long long i = 0; i <= n; i++)       for (long long j = 0; j <= n; j++) dp[i][j] = 1e18;     if (s == 1)       dp[1][1] = d[1], x--;     else if (t == 1)       dp[1][1] = b[1], y--;     else       dp[1][1] = b[1] + d[1];     for (long long i = 2; i < n; i++) {       if (i == s) {         for (long long j = 1; j <= i; j++) {           if (j > 1) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + d[i]);           dp[i][j] = min(dp[i][j], dp[i - 1][j] + c[i]);         }         x--;         continue;       }       if (i == t) {         for (long long j = 1; j <= i; j++) {           if (j > 1) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + b[i]);           dp[i][j] = min(dp[i][j], dp[i - 1][j] + a[i]);         }         y--;         continue;       }       for (long long j = 1 + (i > s && i > t); j <= i; j++) {         long long in = j + x, out = j + y;         if (j > 1 || out) dp[i][j] = min(dp[i][j], dp[i - 1][j] + a[i] + d[i]);         if (j > 1 || in) dp[i][j] = min(dp[i][j], dp[i - 1][j] + c[i] + b[i]);         dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + b[i] + d[i]);         if (j > 1) dp[i][j - 1] = min(dp[i][j - 1], dp[i - 1][j] + a[i] + c[i]);       }     }     long long ans = 1e18;     if (s == n)       ans = min(ans, dp[n - 1][1] + c[n]);     else if (t == n)       ans = min(ans, dp[n - 1][1] + a[n]);     else       ans = min(ans, dp[n - 1][2] + a[n] + c[n]);     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k[101], m, mi = 1000000;     cin >> n;     for (int i = 0; i < n; i++) cin >> k[i];     for (int i = 0; i < n; i++) {       int c = 0, s = 0;       for (int j = 0; j < k[i]; j++) {         cin >> m;         s += m * 5;         c++;       }       s += c * 15;       mi = min(s, mi);     }     cout << mi;     return 0;   }