malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int res[111];   int a[111][111];   bool used[111];   ;   bool used_j[111];   int v[111];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < m; i++) {       for (int w = 0; w < 111; w++) {         v[w] = 0;       }       for (int j = 0; j < n; j++) {         if (!used[a[j][i]] && !used_j[j])           v[a[j][i]]++;         else if (!used_j[j] && used[a[j][i]]) {           if (res[j] == 0) res[j] = i + 1;           used_j[j] = 1;         }       }       for (int j = 0; j < n; j++) {         if (v[a[j][i]] > 1 && a[j][i] != 0) {           if (res[j] == 0) res[j] = i + 1;           used[a[j][i]] = 1;           used_j[j] = 1;         }       }     }     for (int i = 0; i < n; i++) {       cout << res[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 1e6 + 10;   const long long INF = 1e18;   const long double EPS = 1e-12;   int a[300005];   map<int, int> mi;   int l_, r_;   long long pre[300005];   int b[300005];   int main() {     int n;     scanf( %d , &n);     for (int i = (int)1; i < (int)n + 1; i++) {       scanf( %d , &a[i]);     }     for (int i = (int)1; i < (int)n + 1; i++) {       if (mi[a[i]] == 0) mi[a[i]] = i;     }     for (int i = (int)1; i < (int)n + 1; i++) {       pre[i] = pre[i - 1];       if (a[i] >= 0) pre[i] += (long long)(a[i]);     }     long long ans = -(long long)(1e12);     l_ = 0;     r_ = 0;     for (int i = n; i >= 1; i--) {       int x = a[i];       int l = mi[x];       if (i == mi[x]) continue;       long long net = pre[i - 1] - pre[l];       net += 2LL * (long long)(x);       if (net > ans) {         ans = net;         l_ = l;         r_ = i;       }     }     int cnt = 0;     for (int i = 0; i < (int)n + 1; i++) b[i] = 0;     for (int i = (int)1; i < (int)n + 1; i++) {       if (i == l_ || i == r_) {         b[i] = 1;         continue;       }       if (l_ < i && i < r_ && a[i] > 0) {         b[i] = 1;       } else {         b[i] = 0;         cnt++;       }     }     cout << ans <<     << cnt << endl;     for (int i = (int)1; i < (int)n + 1; i++) {       if (b[i] == 0) {         printf( %d  , i);       }     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int Read() {     int x = 0, f = 1, c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * f;   }   const int MAXN = 300005;   int n, m, a[MAXN], f[MAXN], g[MAXN];   inline bool Chk(int d) {     f[0] = g[0] = 1;     for (int i = 1, j = 1; i <= n; i++) {       while (a[i] - a[j] > d) j++;       if (i >= m && g[i - m] - (j == 1 ? 0 : g[j - 2]) > 0)         f[i] = 1;       else         f[i] = 0;       g[i] = g[i - 1] + f[i];     }     return f[n];   }   int main() {     n = Read(), m = Read();     for (int i = 1; i <= n; i++) a[i] = Read();     sort(a + 1, a + n + 1);     int l = 0, r = a[n], ret = 0;     while (l <= r) {       int mid = l + r >> 1;       if (Chk(mid))         ret = mid, r = mid - 1;       else         l = mid + 1;     }     return printf( %d n , ret), 0;   }
#include <bits/stdc++.h>   using namespace std;   int t;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> t;     while (t--) {       int m;       int n;       cin >> m >> n;       vector<int> a[500];       vector<int> b[500];       for (int i = 0; i < m; i++) {         for (int j = 0; j < n; j++) {           int temp;           cin >> temp;           a[i].push_back(temp);         }       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           int temp;           cin >> temp;           b[i].push_back(temp);         }       }       pair<int, int> place;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (a[0][0] == b[i][j]) {             place = make_pair(i, j);           }         }       }       map<int, int> rows;       for (int i = 0; i < m; i++) {         rows.insert({a[i][0], i});       }       for (int i = 0; i < m; i++) {         for (int j = 0; j < n; j++) {           cout << a[rows[b[place.first][i]]][j] <<    ;         }         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     auto solve = []() {       int n;       cin >> n;       vector<pair<int, int>> a(n);       for (int i = 0; i < n; i++) {         cin >> a[i].first;         a[i].first--;       }       vector<int> ans(n + n);       vector<int> used(n + n);       for (int i = 0; i < n; i++) {         ans[i * 2] = a[i].first;         a[i].second = i * 2;         used[a[i].first] = 1;       }       for (int i = 1; i < n + n; i += 2) {         int x = ans[i - 1];         int j;         for (j = x + 1; j < n + n && used[j]; j++)           ;         if (j == n + n) {           cout << -1 <<   n ;           return 0;         }         used[j] = 1;         ans[i] = j;       }       for (int i = 0; i < n + n; i++) {         if (i > 0) cout <<    ;         cout << ans[i] + 1;       }       cout <<   n ;     };     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int res(long long int x) {     long long int ans = 0;     if (x > 0) ans = (x * (x - 1)) / 2;     return ans;   }   int main() {     long int n;     long long int d;     cin >> n >> d;     vector<long long int> vect;     long long int x;     for (long int i = 0; i < n; i++) {       cin >> x;       vect.push_back(x);     }     vector<long long int>::iterator it, it2;     long long int ans = 0;     for (long int i = 2; i < n; i++) {       it = lower_bound(vect.begin(), vect.end(), vect[i] - d);       if (it != vect.end()) {         ans = ans + res(i - (it - vect.begin()));       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool Check(int N, int pos) { return (bool)(N & (1 << pos)); }   int Set(int N, int pos) { return (N | (1 << pos)); }   long long BigMod(long long B, long long P, long long M) {     long long R = 1;     while (P > 0) {       if (P % 2 == 1) {         R = (R * B) % M;       }       P /= 2;       B = (B * B) % M;     }     return R;   }   int n, m;   vector<pair<double, int> > v;   int dp[5005][5005][2];   inline int call(int pos, int got, int stat) {     if (got > m) return 10000;     if (pos == n) {       if (got == m)         return 0;       else         return 10000;     }     if (dp[pos][got][stat] != -1) return dp[pos][got][stat];     int ret = 0;     int g = 0;     if (v[pos].second != got and stat == 0) g = 1;     ret = min(call(pos + 1, got, 0), call(pos, got + 1, 1));     return dp[pos][got][stat] = ret + g;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     memset(dp, -1, sizeof(dp));     cin >> n >> m;     v.resize(n);     for (int i = 0; i < n; i++) {       cin >> v[i].second >> v[i].first;     }     sort(v.begin(), v.end());     int mx = 10000;     for (int i = 0; i < m; i++) {       mx = min(mx, call(0, i + 1, 0));     }     cout << mx;   }
#include <bits/stdc++.h>   using namespace std;   char bd[1100][1100];   int n, m;   int rt[1100][1100];   int down[1100][1100];   int cnt[1100][1100];   int check(int width, int height, int x, int y) {     int filled = 0;     bool first = true;     while (true) {       int godown = down[x][y] - height;       if (godown < 0) break;       if (cnt[x][y] - cnt[x][y + width] - cnt[x + down[x][y]][y] +               cnt[x + down[x][y]][y + width] ==           width * down[x][y]) {         if (first) {           filled += width * down[x][y];           first = false;         } else {           filled += height + width * godown;         }       } else         break;       if ((y + 1) + width <= m) {         y++;         x += godown;       } else         break;     }     return filled;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , bd[i]);     for (int i = n - 1; i >= 0; i--) {       for (int j = m - 1; j >= 0; j--) {         if (bd[i][j] ==  . ) {           rt[i][j] = down[i][j] = 0;         } else {           rt[i][j] = 1 + rt[i][j + 1];           down[i][j] = 1 + down[i + 1][j];         }       }     }     int tlx = -1;     int tly = -1;     int tot = 0;     for (int i = n - 1; i >= 0; i--) {       for (int j = m - 1; j >= 0; j--) {         if (bd[i][j] ==  X ) {           tlx = i;           tly = j;           tot++;         }         cnt[i][j] =             (bd[i][j] ==  X ) + cnt[i + 1][j] + cnt[i][j + 1] - cnt[i + 1][j + 1];       }     }     int best = 1000000000;     for (int height = 1; height <= down[tlx][tly]; height++) {       int width = rt[tlx][tly];       int filled = check(width, height, tlx, tly);       if (filled == tot) best = min(best, width * height);     }     for (int width = 1; width <= rt[tlx][tly]; width++) {       int height = down[tlx][tly];       int filled = check(width, height, tlx, tly);       if (filled == tot) best = min(best, width * height);     }     printf( %d n , best == 1000000000 ? -1 : best);   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 30;   const int N = 100100;   char a[N], b[N];   int n, m, k, p[27];   int Par(int i) { return p[i] = (i == p[i]) ? i : Par(p[i]); }   bool same(int i, int j) { return Par(i) == Par(j); }   int comp[27];   void mrg(int i, int j) {     if (same(i, j)) return;     i = Par(i);     j = Par(j);     p[i] = p[j];     comp[i] += comp[j];   }   vector<pair<char, char> > v;   int main() {     scanf( %d , &n);     scanf( %s , a);     scanf( %s , b);     for (int i = 0; i < 26; i++) {       p[i] = i;       comp[i] = 1;     }     for (int i = 0; i < n; i++) {       if (same(b[i] -  a , a[i] -  a )) continue;       mrg(b[i] -  a , a[i] -  a );       v.push_back({a[i], b[i]});     }     printf( %d n , v.size());     for (auto x : v) printf( %c %c n , x.first, x.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double pi = acos(-1);   struct point {     int x, y;   } p[2005];   vector<double> v;   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d%d , &p[i].x, &p[i].y);     long long ans = 0;     for (int i = 1; i <= n; i++) {       v.clear();       for (int j = 1; j <= n; j++)         if (j != i) v.push_back(atan2(p[j].y - p[i].y, p[j].x - p[i].x));       sort(v.begin(), v.end());       int k = 0;       int now = 0;       for (int j = 0; j < v.size(); j++) {         while (v[k] + now * pi < v[j] + pi) {           k++;           if (k >= v.size()) k = 0, now += 2;         }         int w = (j - k >= 0 ? j - k : k - j - 1);         ans += 1ll * w * (w - 1) / 2 * (n - w - 2) * (n - w - 3) / 2;       }     }     printf( %lld n , ans / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 6, MAX = 2e5 + 5, OO = 1000000009;   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long lcm(long long x, long long y) { return (x * y / gcd(x, y)); }   long long fact(long long z) { return (z <= 1) ? 1 : z * fact(z - 1); }   int a, b, aa, bb, ans;   void Check(int p) {     while (a % p == 0) {       a /= p;       aa++;     }     while (b % p == 0) {       b /= p;       bb++;     }     ans += abs(aa - bb);     aa = bb = 0;   }   int main() {     scanf( %d %d , &a, &b);     Check(2);     Check(3);     Check(5);     return printf( %d , a == b ? ans : -1), 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000 * 1000 * 1000 + 7;   const int INF = 2000 * 1000 * 1000;   const double EPS = 1e-9;   const double pi = acos(-1.0);   const int maxn = 100010;   inline long long sqr(int n) { return n * 1ll * n; }   struct Point {     int x, y;     Point() {}     inline bool operator<(const Point& p) const { return y < p.y; }     inline long long dist_to(const Point& p) const {       return sqr(x - p.x) + sqr(y - p.y);     }   };   Point a[maxn];   int n, x, sum;   long long minans = INF * 1ll * INF;   inline void update(const Point& p1, const Point& p2) {     minans = min(minans, p1.dist_to(p2));   }   inline void go(int l, int r) {     if (r - l <= 3) {       for (int i = l; i <= r; i++)         for (int j = i + 1; j <= r; j++) update(a[i], a[j]);       sort(a + l, a + r + 1);       return;     }     int mid = (l + r) >> 1;     int midx = a[mid].x;     int buf_size = 0;     go(l, mid - 1);     go(mid, r);     static Point buf[maxn];     merge(a + l, a + mid, a + mid, a + r + 1, buf);     copy(buf, buf + (r - l + 1), a + l);     for (int i = l; i <= r; i++) {       if (sqr(abs(a[i].x - midx)) < minans) {         for (int j = buf_size - 1; j >= 0 && sqr(a[i].y - buf[j].y) < minans; j--)           update(a[i], buf[j]);         buf[buf_size++] = a[i];       }     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &x);       sum += x;       a[i].x = i + 1;       a[i].y = sum;     }     go(0, n - 1);     printf( %I64d , minans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n, m;     cin >> n >> m;     vector<long long> col(m);     for (long long i = 0; i < m; i++) {       cin >> col[i];     }     vector<long long> suf(m, 0);     suf[m - 1] = 0;     for (long long i = m - 2; i >= 0; i--) {       suf[i] = suf[i + 1] + col[i + 1];     }     vector<long long> ans;     for (long long i = 0, cur = 0, r = 0; i < m; i++) {       ans.push_back(cur);       r = cur + col[i];       if (r > n) {         cout <<  -1  << endl;         return 0;       }       cur++;       if (suf[i] < n - r) {         cout <<  -1  << endl;         return 0;       } else if (suf[i] < n - cur) {         long long pos = n - suf[i];         for (long long j = i + 1; j < m; j++) {           ans.push_back(pos);           pos += col[j];         }         break;       }     }     for (long long i = 0; i < m; i++) {       cout << ans[i] + 1 <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i, x, sum = 0;     long long int c[100009];     scanf( %lld %lld , &n, &x);     for (i = 0; i < n; i++) {       scanf( %lld , &c[i]);     }     sort(c, c + n);     for (i = 0; i < n; i++) {       sum = sum + c[i] * x;       x--;       if (x == 0) x++;     }     printf( %lld n , sum);   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 2147383647;   const double pi = 2 * acos(0.0);   const double eps = 1e-9;   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<    ;       return *this;     }   } dbg;   inline long long gcd(long long a, long long b) {     a = ((a) < 0 ? -(a) : (a));     b = ((b) < 0 ? -(b) : (b));     while (b) {       a = a % b;       swap(a, b);     }     return a;   }   int ext_gcd(int a, int b, int& x, int& y) {     if (a == 0) {       x = 0;       y = 1;       return b;     }     int x1, y1;     int d = ext_gcd(b % a, a, x1, y1);     x = y1 - (b / a) * x1;     y = x1;     return d;   }   inline long long modInv(int a, int m) {     int x, y;     ext_gcd(a, m, x, y);     if (x < 0) x += m;     return x;   }   inline long long power(long long a, long long p) {     long long res = 1, x = a;     while (p) {       if (p & 1) res = (res * x);       x = (x * x);       p >>= 1;     }     return res;   }   inline long long bigmod(long long a, long long p, long long m) {     long long res = 1, x = a % m;     while (p) {       if (p & 1) res = (res * x) % m;       x = (x * x) % m;       p >>= 1;     }     return res;   }   bool ispalin(string s) {     string s2 = s;     reverse(s2.begin(), s2.end());     if (s == s2)       return true;     else       return false;   }   int main() {     string s, t, x;     cin >> s;     int len = s.size();     for (int i = (0); i <= (len); ++i) {       for (int j = ( a ); j <= ( z ); ++j) {         t = s;         x = j;         t.insert(i, x);         if (ispalin(t)) {           cout << t << endl;           return 0;         }       }     }     cout <<  NA  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[4040][4040], n, k, ans;   struct info {     int be, ti;   } e[4040];   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d%d , &e[i].be, &e[i].ti);     e[n + 1].be = 86401;     if (n == k) {       printf( 86400 );       return 0;     }     f[1][0] = e[1].be + e[1].ti - 1;     for (int i = 2; i <= n; i++) {       f[i][0] = max(e[i].be + e[i].ti - 1, f[i - 1][0] + e[i].ti);       for (int j = 1; j <= min(i, k); j++) {         if (i - 1 >= j)           f[i][j] = min(max(f[i - 1][j] + e[i].ti, e[i].be + e[i].ti - 1),                         f[i - 1][j - 1]);         else           f[i][j] = min(e[i].be + e[i].ti - 1, f[i - 1][j - 1]);       }     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= k; j++) {         ans = max(ans, e[min(n + 1, k - j + i + 1)].be - f[i][j] - 1);       }     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long t = 1;   void solve() {     long long n, x, y, cnt = 0, p = 1;     cin >> n;     vector<long long> arr(n + 1), vis(n + 1, 0);     vector<vector<long long> > v(n + 1);     for (long long i = 0; i < n - 1; i += 1) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     queue<long long> q1, q;     for (long long i = 0; i < n; i += 1) {       cin >> x;       arr[i] = x;       q1.push(x);     }     q.push(1);     q1.pop();     while (!q.empty()) {       x = q.front();       vector<long long> vv;       set<long long> s;       cnt = 0;       for (long long i = 0; i < int((v[x]).size()); i += 1) {         if (vis[v[x][i]] == 0) {           cnt++;           vv.push_back(v[x][i]);         }       }       vis[q.front()] = 1;       q.pop();       for (long long i = p; i < p + cnt; i += 1) {         s.insert(arr[i]);         q.push(arr[i]);         vis[arr[i]] = 1;       }       for (long long i = 0; i < int((vv).size()); i += 1) {         if (((s).find(vv[i]) != (s).end())) {           s.erase(vv[i]);         } else {           cout <<  No ;           return;         }       }       p = p + cnt;     }     cout <<  Yes ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> point[100];   double ang[100];   double dp[10000000];   int i, j, k, N, M, K, l, r;   void clear() {}   void init() {     scanf( %d%d%d , &N, &l, &r);     for (i = 0; i <= N - 1; i++) {       int first;       scanf( %d%d%d , &point[i].first, &point[i].second, &first);       ang[i] = (first * 1.0) * 3.1415926535 / 180.0;     }   }   double func(int a, int h, double ang, double st) {     double alpha = atan(fabs(a - st) / h);     if (a > st) {       double beta = alpha - ang;       if (beta > 0) {         double q = h * tan(beta);         return min(1.0 * r, a - q);       } else {         beta *= -1;         return min(1.0 * r, a + h * tan(beta));       }     } else {       if (alpha + ang > 3.1415926535 / 2) {         return 1.0 * r;       } else {         double beta = alpha + ang;         return min(1.0 * r, h * tan(beta) + a);       }     }   }   void calc() {     for (i = 0; i <= (1 << N) - 1; i++) {       dp[i] = l * 1.0;     }     for (i = 0; i <= (1 << N) - 1; i++) {       for (j = 0; j <= N - 1; j++) {         if (!(i & (1 << j)))           dp[i | (1 << j)] =               max(dp[i | (1 << j)],                   func(point[j].first, point[j].second, ang[j], dp[i]));       }     }     printf( %.8f n , dp[(1 << N) - 1] - l);   }   int main() {     clear();     init();     calc();   }
#include <bits/stdc++.h>   using namespace std;   int vis[100005], n, m, x, y, mi, eg, re;   char t;   vector<vector<pair<int, int> > > adj;   vector<vector<int> > re1;   vector<int> t0, t1;   void dfs(int u, int ty) {     if (vis[u] == -1) {       vis[u] = ty;       if (ty == 0)         t0.push_back(u);       else         t1.push_back(u);       for (int j = 0; j < adj[u].size(); j++) {         pair<int, int> te = adj[u][j];         if (te.second == eg)           dfs(te.first, ty);         else           dfs(te.first, 1 - ty);       }     } else if (vis[u] != ty) {       mi = -1;       return;     }   }   int main() {     cin >> n >> m;     adj.assign(n + 1, vector<pair<int, int> >(0));     re1.assign(2, vector<int>(0));     for (int i = 0; i < m; i++) {       cin >> x >> y >> t;       adj[x].push_back(pair<int, int>(y, t ==  B ));       adj[y].push_back(pair<int, int>(x, t ==  B ));     }     memset(vis, -1, sizeof(vis));     mi = 0;     eg = 1;     for (int i = 1; i <= n; i++) {       t0.clear();       t1.clear();       if (vis[i] == -1) dfs(i, 0);       if (mi == -1) break;       if (t0.size() < t1.size()) {         mi += t0.size();         for (int j = 0; j < t0.size(); j++) re1[0].push_back(t0[j]);       } else {         mi += t1.size();         for (int j = 0; j < t1.size(); j++) re1[0].push_back(t1[j]);       }     }     re = mi;     memset(vis, -1, sizeof(vis));     mi = 0;     eg = 0;     for (int i = 1; i <= n; i++) {       t0.clear();       t1.clear();       if (vis[i] == -1) dfs(i, 0);       if (mi == -1) break;       if (t0.size() < t1.size()) {         mi += t0.size();         for (int j = 0; j < t0.size(); j++) re1[1].push_back(t0[j]);       } else {         mi += t1.size();         for (int j = 0; j < t1.size(); j++) re1[1].push_back(t1[j]);       }     }     if (mi == -1) {       if (re == -1)         cout << -1 << endl;       else {         cout << re << endl;         for (int i = 0; i < re1[0].size(); i++) cout << re1[0][i] <<    ;         cout << endl;       }     } else if (re == -1) {       cout << mi << endl;       for (int i = 0; i < re1[1].size(); i++) cout << re1[1][i] <<    ;       cout << endl;     } else {       if (mi < re) {         cout << mi << endl;         for (int i = 0; i < re1[1].size(); i++) cout << re1[1][i] <<    ;         cout << endl;       } else {         cout << re << endl;         for (int i = 0; i < re1[0].size(); i++) cout << re1[0][i] <<    ;         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int hashCh = 31;   struct HashCh {     string code;     int number;   };   long long getHash(string text) {     long long hash = 0;     int size = text.size();     for (int i = 0; i < size; i++) {       int ch = static_cast<int>(text[i]);       hash += pow(hashCh, i) * ch;     }     return hash;   }   int main() {     vector<string> password;     map<long long, HashCh> numbers;     char buf[80];     string oneNumber;     for (int i = 0; i < 80; i++) {       char ch;       cin >> ch;       oneNumber += ch;       if ((i % 10) == 9) {         password.push_back(oneNumber);         oneNumber =   ;       }     }     for (int i = 0; i < 10; i++) {       string number;       cin >> number;       HashCh ch = HashCh();       ch.code = number;       ch.number = i;       long long hash = getHash(number);       numbers[hash] = ch;     }     vector<int> result;     for (int i = 0; i < 8; i++) {       auto it = numbers.find(getHash(password[i]));       if (it != numbers.end() && it->second.code == password[i]) {         result.push_back(it->second.number);       }     }     for (auto i = result.begin(); i != result.end(); i++) {       cout << *i;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct fastIO {     fastIO() { ios_base::sync_with_stdio(0); }   };   const int MAXN = 1e6 * 2;   long long n, a[MAXN], x, ans = MAXN, b;   int main() {     fastIO();     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     for (x = 0; x < n; x++) {       b = 0;       for (long long i = 0; i < n; i++) {         b += (abs(x - i) + i + x) * a[i] * 2;       }       if (0) cerr << ans << endl;       ans = min(ans, b);     }     cout << ans;     return 0;   }