malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, mod = 1e9 + 7ll, cont, maxi = 1000000000000ll, cont2, val[400005],                ans, bestval = 1000000000000ll;   pair<long long, long long> dp[400005], num, ft[400005];   pair<int, int> v[400005];   map<int, int> ind;   vector<int> opz[400005], tmp;   void update(int pos, long long val, long long num) {     for (int i = pos; i < 400005; i += (i & (-i))) {       if (ft[i].first > val) {         ft[i] = {val, num};       } else {         if (ft[i].first == val) ft[i].second += num;         ft[i].second %= mod;       }     }   }   pair<long long, long long> query(int pos) {     long long sol = maxi, solnum = 0;     for (int i = pos; i > 0; i -= (i & (-i))) {       if (ft[i].first < sol) {         sol = ft[i].first;         solnum = ft[i].second;       } else {         if (ft[i].first == sol) {           solnum += ft[i].second;           solnum %= mod;         }       }     }     return {sol, solnum};   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> v[i].first >> v[i].second;       tmp.push_back(v[i].first);       tmp.push_back(v[i].second);     }     sort(tmp.begin(), tmp.end());     cont = 1;     for (int i = 0; i < tmp.size(); i++) {       if (i == 0 || tmp[i] != tmp[i - 1]) {         ind[tmp[i]] = cont;         val[cont] = tmp[i];         cont++;       }     }     for (int i = 0; i < n; i++) {       opz[ind[v[i].first]].push_back(v[i].second);     }     for (int i = 0; i < 400005; i++) {       sort(opz[i].begin(), opz[i].end());       ft[i] = {maxi, 0};     }     update(1, maxi, 1);     for (int i = 1; i < cont; i++) {       cont2 = 0;       if (opz[i].size() == 0) continue;       dp[i].first = maxi;       dp[i].second = 1;       for (int j = 0; j < opz[i].size(); j++) {         cont2++;         if (j == opz[i].size() - 1 || opz[i][j] != opz[i][j + 1]) {           num = query(ind[opz[i][j]]);           num.first = num.first - (val[i] - opz[i][j]);           num.second *= cont2;           num.second %= mod;           if (dp[i].first > num.first) {             dp[i] = num;           } else {             if (dp[i].first == num.first) {               dp[i].second += num.second;               dp[i].second %= mod;             }           }           cont2 = 0;         }       }       update(i, dp[i].first, dp[i].second);     }     sort(v, v + n);     reverse(v, v + n);     for (int i = ind[v[0].first]; i > ind[v[0].second]; i--) {       if (bestval > (dp[i].first - (maxi - val[i]))) {         bestval = (dp[i].first - (maxi - val[i]));         ans = dp[i].second;       } else {         if (bestval == (dp[i].first - (maxi - val[i]))) ans += dp[i].second;         ans %= mod;       }     }     cout << max(ans, 1ll) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string arr[9];   int moves1[4] = {2, 2, -2, -2}, moves2[4] = {2, -2, 2, -2};   int grid[2][9][9];   bool visited[9][9];   int incrementer;   void canMeet(int row, int col, int nw) {     for (int i = 0; i < 4; ++i) {       if (row + moves1[i] >= 0 && row + moves1[i] < 8 && col + moves2[i] >= 0 &&           col + moves2[i] < 8 && !visited[row + moves1[i]][col + moves2[i]]) {         grid[incrementer][row + moves1[i]][col + moves2[i]] = nw + 1;         visited[row + moves1[i]][col + moves2[i]] = true;         canMeet(row + moves1[i], col + moves2[i], nw + 1);       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       memset(grid, 0, sizeof(grid));       for (int i = 0; i < 8; ++i) {         cin >> arr[i];       }       int x, y, x1, y1;       bool done = false;       for (int i = 0; i < 8; ++i) {         for (int j = 0; j < 8; ++j) {           if (arr[i][j] ==  K  && !done) {             x = i;             y = j;             done = true;           } else if (arr[i][j] ==  K  && done) {             x1 = i;             y1 = j;           }         }       }       incrementer = 1;       memset(visited, false, sizeof(visited));       visited[x][y] = true;       canMeet(x, y, 0);       incrementer = 1;       memset(visited, false, sizeof(visited));       visited[x1][y1] = true;       canMeet(x1, y1, 0);       grid[1][x1][y1] = 2;       grid[0][x][y] = 2;       done = false;       for (int i = 0; i < 8; ++i) {         for (int j = 0; j < 8; ++j) {           if ((arr[i][j] ==  .  || arr[i][j] ==  K ) && grid[0][i][j] != 0 &&               grid[1][i][j] != 0 && grid[0][i][j] % 2 == grid[1][i][j] % 2)             done = true;         }       }       if (done)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int AR[1000000 + 7];   int main() {     int cnt = 0, k;     string s;     cin >> k >> s;     AR[0] = 1;     int64_t r = 0;     for (int i = 0; s[i] !=   0 ; i++) {       if (s[i] ==  1 ) cnt++;       if (cnt >= k) r += AR[cnt - k];       AR[cnt]++;     }     printf( %I64d n , r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int solve() {     long long int n;     cin >> n;     vector<bool> dp(2 * n + 1, 0);     vector<long long int> p(2 * n);     vector<long long int> nums;     long long int cover = 0;     vector<long long int> inv(2 * n + 1);     for (long long int j = 0; j < 2 * n; j++) {       cin >> p[j];       inv[p[j]] = j;       if (p[j] == 2 * n) {         cover = j;       }     }     nums.push_back(2 * n - cover);     for (long long int j = 2 * n - 1; j >= 1; j--) {       if (inv[j] > cover) {         continue;       } else {         nums.push_back(cover - inv[j]);         cover = inv[j];       }     }     sort(nums.begin(), nums.end());     dp[nums[0]] = 1;     dp[0] = 1;     long long int k = nums.size();     for (long long int j = 1; j < k; j++) {       vector<long long int> f(2 * n + 1, 0);       for (long long int i = 0; i <= 2 * n; i++) {         f[i] = dp[i];         if (i - nums[j] >= 0) {           f[i] = dp[i] || dp[i - nums[j]];         }       }       for (long long int i = 0; i <= 2 * n; i++) {         dp[i] = f[i];       }     }     if (!dp[n]) {       cout <<  NO n ;     } else {       cout <<  YES n ;     }     return 0;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int s[220];   int d[220];   int sol[220];   vector<pair<int, int> > v;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n;     for (int(i) = (0); (i) < (n); (i)++) cin >> s[i] >> d[i];     for (int(i) = (0); (i) < (n); (i)++) {       int last = 1;       int ok = 0;       for (typeof(v.begin()) it = (v.begin()); it != v.end(); it++) {         if (last <= s[i] && it->first >= s[i] + d[i]) {           v.insert(it, make_pair((s[i]), (d[i])));           ok = 1;           sol[i] = s[i];           break;         }         last = it->first + it->second;       }       if (v.empty() ||           v[((int)v.size()) - 1].first + v[((int)v.size()) - 1].second <= s[i]) {         v.push_back(make_pair((s[i]), (d[i])));         ok = 1;         sol[i] = s[i];       }       if (!ok) {         last = 1;         for (typeof(v.begin()) it = (v.begin()); it != v.end(); it++) {           if (it->first >= last + d[i]) {             v.insert(it, make_pair((last), (d[i])));             sol[i] = last;             ok = 1;             break;           }           last = it->first + it->second;         }       }       if (!ok) {         v.push_back(make_pair((last), (d[i])));         sol[i] = last;       }       cout << sol[i] <<     << sol[i] + d[i] - 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, seq[100005];   char s[2][55];   string a[100005], b[100005], cur;   void solve() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %s %s , s[0], s[1]);       a[i] = s[0];       b[i] = s[1];     }     for (int i = 0; i < n; i++) {       scanf( %d , &seq[i]);       seq[i]--;     }     if (a[seq[0]] < b[seq[0]])       cur = a[seq[0]];     else       cur = b[seq[0]];     for (int i = 1; i < n; i++) {       if (cur < a[seq[i]] && cur < b[seq[i]]) {         if (a[seq[i]] < b[seq[i]])           cur = a[seq[i]];         else           cur = b[seq[i]];       } else if (cur < a[seq[i]])         cur = a[seq[i]];       else if (cur < b[seq[i]])         cur = b[seq[i]];       else {         puts( NO );         return;       }     }     puts( YES );   }   int main(void) {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<string> s;   string v;   map<string, bool> m;   void rot(string x) {     if (m[x] == 1) return;     m[x] = 1;     s.erase(x);     string y = x;     y[0] = x[1];     y[1] = x[2];     y[2] = x[3];     y[3] = x[0];     rot(y);     y = x;     y[1] = x[4];     y[4] = x[3];     y[3] = x[5];     y[5] = x[1];     rot(y);     return;   }   int main() {     cin >> v;     for (int i = 0; i < 1000; i++) {       next_permutation(v.begin(), v.end());       s.insert(v);     }     int ans = 0;     while (s.size() > 0) {       ans++;       rot(*s.begin());     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 105;   bool visit[M];   string second[M];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) cin >> second[i];     vector<string> v;     for (int i = 0; i < m; i++) {       int x;       scanf( %d , &x);       visit[x] = 1;       v.push_back(second[x]);     }     for (int i = 1; i < m; i++) {       if (v[i].size() != v[0].size()) {         cout <<  No ;         return 0;       }     }     string pattern =   ;     for (int i = 0; i < v[0].size(); i++) {       set<char> c;       for (int j = 0; j < m; j++) c.insert(v[j][i]);       if (c.size() == 1)         pattern += *c.begin();       else         pattern +=  ? ;     }     for (int i = 1; i <= n; i++) {       if (second[i].size() != pattern.size()) continue;       bool match = 1;       for (int j = 0; j < second[i].size(); j++) {         if (pattern[j] != second[i][j] && pattern[j] !=  ? ) {           match = 0;           break;         }       }       if (match && !visit[i]) {         cout <<  No ;         return 0;       }     }     cout <<  Yes n  << pattern;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long mmul(long long a, long long b) { return (a * b) % 998244353; }   inline long long madd(long long a, long long b) { return (a + b) % 998244353; }   long long mpow(long long a, long long p) {     if (p == 0) return 1;     long long halfPow = mpow(a, p / 2);     return mmul(halfPow, p % 2 ? mmul(a, halfPow) : halfPow);   }   long long minv(long long a) { return mpow(a, 998244353 - 2); }   long long mdiv(long long a, long long b) { return mmul(a, minv(b)); }   vector<long long> _mfactMem(1, 1);   long long mfact(long long a) {     if (a >= 998244353) return 0;     while (a >= _mfactMem.size())       _mfactMem.push_back(mmul(_mfactMem.size(), _mfactMem.back()));     return _mfactMem[a];   }   long long mcomb(long long n, long long k) {     if (n == 0 && k == 0) return 1;     long long ni = n % 998244353, ki = k % 998244353;     if (ni < ki) return 0;     long long comb = mmul(mfact(ni), mmul(minv(mfact(ki)), minv(mfact(ni - ki))));     return mcomb(n / 998244353, k / 998244353) * comb;   }   long long calc(int na, int nb) {     long long cnt = 0;     for (int i = 0; i <= min(na, nb); i++) {       cnt = madd(cnt, mmul(mfact(i), mmul(mcomb(na, i), mcomb(nb, i))));     }     return cnt;   }   int main() {     int a, b, c;     scanf( %d %d %d n , &a, &b, &c);     int res = (int)mmul(calc(a, b), mmul(calc(b, c), calc(c, a)));     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[1009];   int cmp(int a, int b) { return a > b; }   int main() {     long long T;     scanf( %lld , &T);     while (T--) {       long long n, sum = 0;       scanf( %lld , &n);       for (int i = 1; i <= n; i++) {         scanf( %lld , &a[i]);         sum = sum + a[i];       }       sort(a + 1, a + n + 1, cmp);       if (a[1] > sum / 2) {         printf( T n );       } else if (a[1] <= sum / 2) {         if (sum % 2 == 1) {           printf( T n );         } else if (sum % 2 == 0) {           printf( HL n );         }       }     }     return 0;   }
#include <bits/stdc++.h>      using namespace std;   #define FAST      ios_base::sync_with_stdio(false); cin.tie(NULL);   #define prs(n)      cout << fixed << setprecision(n)   #define ll       long long   #define db       double   #define fo(i,m,n)       for(int i = m; i <= n; i++)   #define fob(i,m,n)      for(int i = n; i >= m; i--)   typedef                 pair<int, int> ii;   typedef                 vector<ii> vii;   typedef                 vector<vii> vvii;   const                   int maxi=INT_MAX;   const                   int _x[]={0,0,1,-1};   const                   int _y[]={1,-1,0,0};      ll n, ans, l[200007], r[200007], dp[200007][2];   vector <ll> a[200007];      void input()   {       int u, v;       cin >> n;       for (int i = 1; i <= n; i++)       {           cin >> l[i] >> r[i], a[i].resize(0);           dp[i][1] = dp[i][0] = 0;       }       for (int i = 1; i < n ; i++)       {           cin >> u >> v;           a[u].push_back(v);           a[v].push_back(u);       }   }      void dfs(int u, int f)   {       for (int i:a[u])       {           if (i != f)           {               dfs(i,u);               dp[u][0] += max(dp[i][0] + abs(l[u] - l[i]), dp[i][1] + abs(l[u] - r[i]));               dp[u][1] += max(dp[i][0] + abs(r[u] - l[i]), dp[i][1] + abs(r[u] - r[i]));           }       }   }      void solve()   {       dfs(1,0);       ans = max(dp[1][0], dp[1][1]);   }      int main()   {       FAST       //freopen( a.INP ,  r , stdin);       //freopen( a.OUT ,  w , stdout);       int t;       cin >> t;       while (t--)       {           input();           solve();           cout << ans <<   n ;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[1000000];   int len;   bool yes(char s[3], int ls, int le) {     while (true) {     start:       int mid = le - ls - 1, i;       if (le != len - 1) {         if (s[0] != s[1]) return 0;       }       int c[3] = {0}, sd[2];       c[(s[1] -  0 ) ^ 1] += len - le - 1;       for (i = ls + 1; i < le; i++) {         if (str[i] == s[0]) return 0;       }       c[(s[0] -  0 ) ^ 1] += mid;       for (i = 0; i < ls; i++) {         if (str[i] ==  ? )           c[2]++;         else           c[str[i] -  0 ]++;       }       if (len & 1)         sd[0] = len / 2 - 1, sd[1] = sd[0] + 1;       else         sd[0] = len / 2 - 1, sd[1] = sd[0];       if (s[0] != s[1]) {         if (c[s[1] -  0 ] > sd[s[1] -  0 ]) return 0;         if (c[s[0] -  0 ] > sd[s[0] -  0 ]) {           if (str[ls] ==  ? ) {             for (i = ls - 1; i >= 0; i--) {               if (str[i] ==  ?  || str[i] == s[0]) break;             }             if (i >= 0) {               ls = i;               goto start;             }           }           return 0;         }       } else {         if (s[0] ==  0 ) {           if (c[0] + c[2] < sd[0]) return 0;         } else {           if (c[1] + c[2] < sd[1]) return 0;         }       }       return 1;     }   }   bool ok(char s[3]) {     int i, ls, le;     for (le = len - 1; le >= 0; le--) {       if (str[le] == s[1] || str[le] ==  ? ) break;     }     if (le <= 0) return 0;     for (ls = le - 1; ls >= 0; ls--) {       if (str[ls] == s[0] || str[ls] ==  ? ) break;     }     if (ls < 0) return 0;     return yes(s, ls, le);   }   void run() {     len = strlen(str);     if (ok( 00 )) printf( 00 n );     if (ok( 01 )) printf( 01 n );     if (ok( 10 )) printf( 10 n );     if (ok( 11 )) printf( 11 n );   }   int main() {     scanf( %s , str);     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100100, INFTY = 0x3f3f3f3f;   int A[MAXN], B[MAXN];   vector<int> p[MAXN];   int posb[330];   int resp[330];   int main() {     int N, M, S, E;     posb[0] = 0;     resp[0] = 0;     for (int i = 1; i <= 300; i++) {       posb[i] = MAXN;       resp[i] = INFTY;     }     for (int i = 1; i <= MAXN - 100; i++) p[i].clear();     scanf( %d %d %d %d , &N, &M, &S, &E);     for (int i = 1; i <= N; i++) scanf( %d , &A[i]);     for (int i = 1; i <= M; i++) {       scanf( %d , &B[i]);       p[B[i]].push_back(i);     }     for (int i = 1; i <= 10000; i++) {       int tam = p[i].size();       if (tam == 0) continue;     }     for (int k = 1; k <= N; k++) {       int x = A[k];       for (int i = 299; i >= 0; i--) {         if (posb[i] == MAXN) continue;         int ini = posb[i] + 1;         int tam = p[x].size();         int prox = (lower_bound(&p[x][0], &p[x][tam], ini) - &p[x][0]);         if (prox == tam) continue;         posb[i + 1] = min(posb[i + 1], p[x][prox]);         resp[i + 1] = min(resp[i + 1], p[x][prox] + k);       }     }     int ans = 0;     for (int i = 0; i <= 300; i++) {       long long int qq = E, rr = S;       qq *= i;       qq += resp[i];       if (qq > rr) break;       ans = i;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   long long child[N], w[N], dp[N][65][3], ans[N][2];   void pre(int n) {     for (int i = 0; i < n; i++) {       dp[i][0][0] = w[i];       dp[i][0][2] = w[i];       dp[i][0][1] = child[i];     }     for (int j = 1; j < 65; j++) {       for (int i = 0; i < n; i++) {         dp[i][j][1] = dp[dp[i][j - 1][1]][j - 1][1];         dp[i][j][0] = dp[i][j - 1][0] + dp[dp[i][j - 1][1]][j - 1][0];         dp[i][j][2] = min(dp[i][j - 1][2], dp[dp[i][j - 1][1]][j - 1][2]);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     long long k;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> child[i];     for (int i = 0; i < n; i++) cin >> w[i];     pre(n);     int pt;     for (int i = 0; i < n; i++) {       pt = i;       ans[i][1] = 1000000007ULL;       for (long long j = 0; (1LL << j) <= k; j++) {         if ((1LL << j) & k) {           ans[i][0] += dp[pt][j][0];           ans[i][1] = min(ans[i][1], dp[pt][j][2]);           pt = dp[pt][j][1];         }       }     }     for (int i = 0; i < n; i++) cout << ans[i][0] <<     << ans[i][1] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T;   signed long long S[101010], E[101010];   int win[101010], lose[101010];   int canwin(signed long long s, signed long long e) {     if (s == e) return 0;     if (s >= e) return 1;     if (e % 2) {       return !(s % 2);     } else {       if (s * 2 > e) return (e - s) % 2;       if (4 * s > e) return 1;       return canwin(s, e / 4);     }   }   int canlose(signed long long s, signed long long e) {     if (e < 2 * s) return 1;     return canwin(s, e / 2);   }   void solve() {     int i, j, k, r, x, y;     string s;     cin >> T;     for (i = 0; i < (T); i++) {       cin >> S[i] >> E[i];       win[i] = canwin(S[i], E[i]);       lose[i] = canlose(S[i], E[i]);     }     int w = 1, l = 0;     for (i = 0; i < (T); i++) {       if (w == l) break;       if (w) {         w = lose[i];         l = win[i];       } else {         w = !lose[i];         l = !win[i];       }     }     cout << l <<     << w << endl;   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<int, bool> hash;     int p, n;     bool has = false;     cin >> p >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       x %= p;       if (hash.count(x) && !has) {         cout << i + 1 << endl;         has = true;       } else {         hash[x] = true;       }     }     if (!has) printf( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-10;   const double PI = acos(-1.0);   int dp[51][51][51];   int dfs(int n, int m, int k) {     if (dp[n][m][k] >= 0) return dp[n][m][k];     if (k == 0 || n * m == k) return dp[n][m][k] = 0;     dp[n][m][k] = 1e9;     for (int j = 0; j <= k; ++j) {       for (int i = 1; i < n; ++i)         dp[n][m][k] =             min(dp[n][m][k], dfs(n - i, m, k - j) + dfs(i, m, j) + m * m);       for (int i = 1; i < m; ++i)         dp[n][m][k] =             min(dp[n][m][k], dfs(n, m - i, k - j) + dfs(n, i, j) + n * n);     }     return dp[n][m][k];   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(false);     fill((int*)dp, (int*)dp + 51 * 51 * 51, -1);     int T;     cin >> T;     while (T--) {       int n, m, k;       cin >> n >> m >> k;       cout << dfs(n, m, k) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long int d;     cin >> n >> d;     vector<int> check_days;     int a[n];     long long int prefix_sum[n];     cin >> a[0];     if (a[0] == 0) check_days.push_back(0);     prefix_sum[0] = a[0];     for (int i = 1; i < n; i++) {       cin >> a[i];       if (a[i] == 0) check_days.push_back(i);       prefix_sum[i] = prefix_sum[i - 1] + a[i];     }     int days = 0;     long long int mi = LLONG_MIN;     long long int max_balance_after[n];     for (int i = n - 1; i >= 0; i--) {       if (prefix_sum[i] > d) {         cout << -1;         return 0;       }       mi = max(mi, prefix_sum[i]);       max_balance_after[i] = mi;     }     int deposit_val = 0;     for (int i = 0; i < check_days.size(); i++) {       int j = check_days[i];       if (prefix_sum[j] + deposit_val < 0) {         int new_bal = 0, val_to_deposit = 0;         new_bal = max_balance_after[j] + deposit_val;         val_to_deposit = d - new_bal;         days++;         deposit_val += val_to_deposit;         if (prefix_sum[j] + deposit_val < 0) {           cout << -1;           return 0;         }       }     }     cout << days;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5000;   map<int, int> cntmap;   long long ans;   int arr[MAXN];   char s[MAXN];   int a, ln;   void fillmap(int x) { cntmap[x]++; }   void getans(int x) {     if (x == 0) {       if (a == 0) ans += (ln * (ln + 1)) / 2;     } else if (a % x == 0)       if (cntmap.count(a / x)) ans += cntmap[a / x];   }   void loop(void (*fun)(int)) {     int sm = 0;     for (int i = 0; i < ln; i++) {       sm = arr[i];       for (int j = i; j < ln; j++) {         if (j != i) sm += arr[j];         fun(sm);       }     }     return;   }   int main() {     scanf( %d %s , &a, s);     ans = 0;     ln = strlen(s);     for (int i = 0; i < ln; i++) arr[i] = s[i] -  0 ;     loop(fillmap);     loop(getans);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = acos(-1.0);   const long double EPS = 1e-12;   const int MAXN = (int)1e5;   const int INF = (int)2e9;   int main() {     int n, a[100];     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     int ans = INF;     for (int i = 0; i < n; ++i) {       int sum = 0;       for (int j = 0; j < a[i]; ++j) {         int num;         scanf( %d , &num);         sum += num * 5 + 15;       }       ans = min(ans, sum);     }     printf( %d , ans);     return 0;   }