malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline void readInt(int &num) {     num = 0;     int c = getchar();     int s = 1;     if (c ==  - ) {       s = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       num = num * 10 + (c -  0 );       c = getchar();     }     num *= s;   }   inline void printInt(int num) {     string s =   ;     if (num < 0) {       putchar( - );       num = -num;     }     if (num == 0) putchar( 0 );     while (num) {       s +=  0  + num % 10;       num /= 10;     }     for (int i = s.size() - 1; i >= 0; i--) {       putchar(s[i]);     }   }   inline void readLL(long long &num) {     num = 0;     int c = getchar();     int s = 1;     if (c ==  - ) {       s = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       num = num * 10 + (c -  0 );       c = getchar();     }     num *= s;   }   inline void printLL(long long num) {     string s =   ;     if (num < 0) {       putchar( - );       num = -num;     }     if (num == 0) putchar( 0 );     while (num) {       s +=  0  + num % 10;       num /= 10;     }     for (int i = s.size() - 1; i >= 0; i--) {       putchar(s[i]);     }   }   inline void readString(string &s) {     s =   ;     char c = getchar();     while (c !=     && c !=   n  && c != EOF) {       s += c;       c = getchar();     }   }   inline void readLine(string &s) {     s =   ;     char c = getchar();     while (c !=   n  && c != EOF) {       s += c;       c = getchar();     }   }   inline void printString(const string &s) {     for (int i = 0; i < (int)s.size(); i++) putchar(s[i]);   }   int main() {     int n;     readInt(n);     string str;     string zeroes =   ;     string ugly =   ;     bool is_find = false;     for (int i = 0; i < (int)n; i++) {       string temp;       readString(temp);       if (temp.size() == 1 && temp[0] ==  0 ) {         putchar( 0 );         return 0;       } else if (!is_find) {         if (temp[0] !=  1 ) {           ugly = temp;           is_find = true;         } else if (temp.size() > 1) {           string tz =   ;           for (int i = 1; i < temp.size(); i++)             if (temp[i] !=  0 ) {               ugly = temp;               is_find = true;               break;             } else               tz +=  0 ;           if (!is_find) zeroes += tz;         }       } else if (temp.size() > 1) {         for (int j = 1; j < temp.size(); j++) zeroes +=  0 ;       }     }     string ans = (is_find) ? ugly + zeroes :  1  + zeroes;     printString(ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fa[100020], sz[100020];   vector<int> g[100020];   int n, m, q;   int find(int x) {     if (fa[x] != x) fa[x] = find(fa[x]);     return fa[x];   }   int dp[100020][3], G[100020], mx[100020];   vector<int> d[100020];   vector<long long> sum[100020];   bool cmp(int i, int j) { return i > j; }   void dfs(int u, int p) {     for (auto v : g[u]) {       if (v == p) continue;       dfs(v, u);       dp[u][2] = dp[v][0] + 1;       sort(dp[u], dp[u] + 3, cmp);     }   }   void dfs2(int u, int p) {     for (auto v : g[u]) {       if (v == p) continue;       int t;       if (dp[u][0] == dp[v][0] + 1)         t = dp[u][1];       else         t = dp[u][0];       G[v] = max(G[u] + 1, t + 1);       dfs2(v, u);     }   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= n; ++i) {       fa[i] = i;       sz[i] = 1;     }     for (int i = 1; i <= m; ++i) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);       sz[find(v)] += sz[find(u)];       fa[find(u)] = find(v);     }     for (int i = 1; i <= n; ++i) {       if (fa[i] == i) {         dfs(i, 0);       }     }     for (int i = 1; i <= n; ++i) {       if (fa[i] == i) dfs2(i, 0);     }     for (int i = 1; i <= n; ++i) {       d[i].push_back(0);       sum[i].push_back(0);     }     for (int i = 1; i <= n; ++i) {       int x = find(i);       mx[x] = max(mx[x], max(dp[i][0], G[i]));       int t = max(dp[i][0], G[i]);       d[x].push_back(t);       sum[x].push_back(0);     }     for (int i = 1; i <= n; ++i) {       sort(d[i].begin(), d[i].end());       if (fa[i] == i) {         for (int j = 1; j < sum[i].size(); ++j) {           sum[i][j] = sum[i][j - 1] + d[i][j];         }       }     }     map<pair<int, int>, double> ans;     while (q--) {       int x, y;       scanf( %d%d , &x, &y);       x = find(x), y = find(y);       if (x == y) {         puts( -1 );         continue;       }       if (sz[x] > sz[y]) swap(x, y);       if (ans.count(make_pair(x, y))) {         printf( %.10lf n , ans[make_pair(x, y)]);         continue;       }       long long res = 0;       int k = max(mx[x], mx[y]);       bool fst = 1;       for (auto v : d[x]) {         if (fst) {           fst = 0;           continue;         }         int p = lower_bound(d[y].begin(), d[y].end(), k - 1 - v) - d[y].begin();         p = max(p, 1);         res += sum[y][sum[y].size() - 1] - sum[y][p - 1] +                1LL * (v + 1) * (sum[y].size() - p);         res += 1LL * (p - 1) * k;       }       double res2 = res * 1.0 / sz[x] / sz[y];       ans[make_pair(x, y)] = res2;       printf( %.12lf n , res2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int l[1000000];   int one_line[5001][5001] = {0};   int summ[5001][5001] = {0};   int fac[5001];   int main() {     int n, m, p;     scanf( %d %d %d , &n, &m, &p);     for (int i = 0; i < n; i++) scanf( %d , &l[i]);     fac[0] = 1;     for (int i = 1; i <= 5000; i++) fac[i] = ((fac[i - 1]) * (long long)i) % p;     one_line[1][1] = 1;     for (int i = 2; i <= 5000; i++) {       for (int j = 1; j <= min(m, 5000); j++) {         one_line[i][j] =             (one_line[i - 1][j] * (long long)(j - 1) + one_line[i - 1][j - 1]) %             p;       }     }     summ[1][1] = m;     for (int i = 2; i <= 5000; i++) {       for (int j = 1; j <= min(m, 5000); j++) {         summ[i][j] = (summ[i - 1][j] * (long long)(j - 1) +                       summ[i - 1][j - 1] * (long long)(m - j + 1)) %                      p;       }     }     int prev_progress[5001] = {0};     int prev_l = 0;     prev_progress[0] = 1;     for (int i = 0; i < n; i++) {       int next_progress[5001];       for (int j = 0; j <= l[i]; j++) next_progress[j] = 0;       int tot1 = 0;       for (int j = 0; j <= prev_l; j++) tot1 = (tot1 + prev_progress[j]) % p;       int tot2 = 1;       tot2 = (tot2 * (long long)m) % p;       for (int j = 1; j < l[i]; j++) tot2 = (tot2 * (long long)(m - 1)) % p;       for (int j = 1; j <= l[i]; j++) {         next_progress[j] = (tot1 * (long long)summ[l[i]][j]) % p;         int prev = 0;         if (j <= prev_l) prev = prev_progress[j];         next_progress[j] -=             (((prev * (long long)one_line[l[i]][j]) % p) * fac[j]) % p;         if (next_progress[j] < 0) next_progress[j] += p;       }       for (int j = 0; j <= l[i]; j++) prev_progress[j] = next_progress[j];       prev_l = l[i];     }     int res = 0;     for (int i = 0; i <= prev_l; i++) res = (res + prev_progress[i]) % p;     printf( %d n , res);   }
#include <bits/stdc++.h>   const int N = (1 << 19) - 1;   using namespace std;   int n;   double dp[N + 1], a[20][20];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) scanf( %lf , &a[i][j]);     }     dp[(1 << n) - 1] = 1;     for (int s = ((1 << n) - 1); s > 0; s--) {       int c = 0;       for (int i = 0; i < n; i++) {         if ((1 << i) & s) c++;       }       if (c < 2) continue;       for (int i = 0; i < n; i++)         if ((1 << i) & (s))           for (int j = 0; j < n; j++) {             if (i == j) continue;             if ((1 << j) & s) {               dp[s ^ (1 << i)] += dp[s] * a[j][i] / c / (c - 1);               dp[s ^ (1 << j)] += dp[s] * a[i][j] / c / (c - 1);             }           }     }     for (int i = 1; i < (1 << n); i <<= 1) {       printf( %.10f  , dp[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   long long int pwr(long long int base, long long int p) {     long long int ans = 1;     while (p) {       if (p & 1) ans = (ans * base) % 1000000007;       base = (base * base) % 1000000007;       p /= 2;     }     return ans;   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int n;   int dyn[5005][5005][2];   char ch[5001][2];   int dp(int neww, int val, int cont) {     dyn[neww][val][cont] %= 1000000007;     if (neww == n && !val) return 1;     if (dyn[neww][val][cont] != -1) return dyn[neww][val][cont];     if (val < 0 || neww > n) return 0;     int final = 0;     if (ch[neww][0] !=  f ) {       final += dp(neww + 1, val, 0);       final = final % 1000000007;     } else {       final += dp(neww + 1, val + 1, 1);       final = final % 1000000007;     }     if (cont == 0) {       final += dp(neww, val - 1, 0);       final = final % 1000000007;     }     final = final % 1000000007;     return dyn[neww][val][cont] = final;   }   int main() {     int i, j, k, m;     memset(dyn, -1, sizeof dyn);     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %s , &ch[i]);     }     int ans = dp(0, 0, 0);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int N;   vector<pair<int, int> > v;   vector<int> query;   int ans;   struct SEG {     SEG(int l, int r, int sum) : l(l), r(r), sum(sum) {}     int l, r;     int sum;   };   vector<SEG> seg;   void init(int idx, int s, int e) {     if (s == e) return;     seg[idx].l = seg.size();     seg.push_back({-1, -1, 0});     seg[idx].r = seg.size();     seg.push_back({-1, -1, 0});     init(seg[idx].l, s, (s + e) / 2);     init(seg[idx].r, (s + e) / 2 + 1, e);   }   void update(int idx, int s, int e, int x, int y) {     seg[idx].sum += y;     if (s == e) return;     if (x <= (s + e) / 2) {       update(seg[idx].l, s, (s + e) / 2, x, y);     } else {       update(seg[idx].r, (s + e) / 2 + 1, e, x, y);     }   }   int calc(int idx, int s, int e, int x, int y) {     if (x <= s && e <= y) return seg[idx].sum;     if (x > e || y < s) return 0;     return calc(seg[idx].l, s, (s + e) / 2, x, y) +            calc(seg[idx].r, (s + e) / 2 + 1, e, x, y);   }   int main() {     seg.push_back({-1, -1, 0});     scanf( %d , &N);     init(0, 0, N - 1);     for (int i = 0; i < N; i++) {       int x;       scanf( %d , &x);       v.push_back({(x > 0) ? x : -x, i});       update(0, 0, N - 1, i, 1);     }     sort(v.begin(), v.end());     while (!v.empty()) {       pair<int, int> now = v.back();       v.pop_back();       update(0, 0, N - 1, now.second, -1);       query.push_back(now.second);       while (!v.empty() && v.back().first == now.first) {         query.push_back(v.back().second);         update(0, 0, N - 1, v.back().second, -1);         v.pop_back();       }       while (!query.empty()) {         int x = query.back();         query.pop_back();         ans += min(calc(0, 0, N - 1, 0, x - 1), calc(0, 0, N - 1, x + 1, N - 1));       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   const int MAX_LEN = 1010;   using namespace std;   template <typename U, typename V>   string to_string(pair<U, V>);   string to_string(const string& e_) { return     + e_ +    ; }   string to_string(char e_) { return      + string(1, e_) +     ; }   string to_string(bool e_) { return e_ ?  true  :  false ; }   template <typename T>   string to_string(T e_) {     string s_ =  [  ;     for (const auto& x_ : e_) s_ += to_string(x_) +    ;     return s_ +  ] ;   }   template <typename U, typename V>   string to_string(pair<U, V> e_) {     return  (  + to_string(e_.first) +  ,   + to_string(e_.second) +  ) ;   }   void dbg_str() { ; }   template <typename U, typename... V>   void dbg_str(U u, V... v) {     ;     dbg_str(v...);   }   int n, m, x;   map<int, vector<int> > a;   map<vector<int>, vector<int> > b;   int main() {     scanf( %d , &n);     if (n == 2) {       vector<int> l;       scanf( %d %d , &m, &x);       printf( 1 %d n , x);       printf( %d  , --m);       while (m--) {         scanf( %d , &x);         printf( %d  , x);       }       exit(0);     }     for (int i = 0; i < (n * (n - 1)) / 2; i++) {       scanf( %d , &m);       while (m--) {         scanf( %d , &x);         a[x].push_back(i);       }     };     for (auto& it : a) {       b[it.second].push_back(it.first);     }     for (auto& it : b) {       printf( %d  , (int)it.second.size());       for (int i = 0; i < (int)it.second.size(); i++) printf( %d  , it.second[i]);       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int r, c;     char s[15][15];     int cake = 0;     int row = 0;     scanf( %d %d , &r, &c);     for (int i = 1; i <= r; i++) {       scanf( %s , s[i]);     }     for (int i = 1; i <= r; i++) {       for (int j = 0; j < c; j++) {         if (s[i][j] ==  S )           break;         else if (s[i][j] ==  .  && j == c - 1) {           cake += c;           row++;         }       }     }     for (int j = 0; j < c; j++) {       for (int i = 1; i <= r; i++) {         if (s[i][j] ==  S )           break;         else if (s[i][j] ==  .  && i == r)           cake += (r - row);       }     }     printf( %d , cake);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   char str[105];   ll best[105];   ll memo[105][105][105];   ll dp(int l, int r, int p) {     if (l >= r) return 0;     if (memo[l][r][p] != -1) return memo[l][r][p];     int ptr = l;     while (ptr < r && str[ptr] == str[l]) ptr++;     ll ret = best[p + ptr - l] + dp(ptr, r, 0);     for (int i = ptr; i < r; ++i) {       if (str[i] == str[l]) {         ret = max(ret, dp(ptr, i, 0) + dp(i, r, p + ptr - l));       }     }     return memo[l][r][p] = ret;   }   int main() {     int n;     cin >> n >> str;     for (int i = 1; i <= n; ++i) {       cin >> best[i];       for (int j = 1; j < i; ++j) {         best[i] = max(best[i], best[j] + best[i - j]);       }     }     memset(memo, -1, sizeof memo);     cout << dp(0, n, 0) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   double eps = 1e-9;   const int INF = 1e9 + 7;   const int MAXN = int(3e5 + 7);   vector<pair<int, int> > v[MAXN];   int n, p, a[MAXN];   long long ans[MAXN], dp[MAXN];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     scanf( %d , &p);     for (int i = 0; i < p; i++) {       int x, y;       scanf( %d%d , &x, &y);       v[y].push_back(make_pair(x, i));     }     for (int i = 1; i <= 500; i++) {       for (int j = n; j > 0; j--) {         dp[j] += a[j];         if (j + i <= n) dp[j] += dp[j + i];       }       for (int j = 0; j < v[i].size(); j++)         ans[v[i][j].second] = dp[v[i][j].first];       memset(dp, 0, sizeof(dp));     }     for (int i = 501; i <= 300000; i++) {       for (int j = 0; j < v[i].size(); j++) {         long long cur = 0;         for (int k = v[i][j].first; k <= n; k += i) cur += a[k];         ans[v[i][j].second] = cur;       }     }     for (int i = 0; i < p; i++) printf( %I64d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 16;   string s;   long long string_int(string s) {     long long num = 0;     for (int i = 0; i < s.size(); i++) {       num += s[i] -  0 ;       num *= 10;     }     return num / 10;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> s;     bool flag = false;     if (s[0] ==  0 ) flag = true;     int epos = s.find( e );     int d = string_int(s.substr(epos + 1));     s = s.substr(0, epos);     for (int i = 0; i < 125; i++) s.push_back( 0 );     s.erase(1, 1);     int exp = 1 + d;     s.insert(exp,  . );     epos = s.find( e );     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  . ) {         s = s.substr(i - 1);         break;       } else if (s[i] !=  0 ) {         s = s.substr(i);         break;       }     }     for (int i = s.size() - 1; i >= 0; i--) {       if (s[i] ==  0 )         s.pop_back();       else         break;     }     if (s[s.size() - 1] ==  . ) s.pop_back();     cout << s << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     while (cin >> n) {       vector<int> v;       int x;       for (int i = 0; i < n; i++) {         cin >> x;         v.push_back(x);       }       bool in = false;       int cnt = 0;       bool f = true;       bool s = false, l = false;       int ind1 = 1, ind2 = 1;       for (int i = 1; i < n; i++) {         bool d = false;         while (v[i - 1] > v[i] && i < n) {           d = true;           if (f) {             ind1 = i;             ind2 = i + 1;             f = false;           } else {             ind2 = i + 1;           }           if (i - 1 == 0) s = true;           if (i == n - 1) l = true;           i++;         }         if (d) {           d = false;           cnt++;         }       }       bool val = false;       if (cnt == 0)         val = 1;       else if (cnt == 1) {         if (s && l)           val = true;         else if (s && v[ind1 - 1] < v[ind2])           val = true;         else if (l && v[ind2 - 1] > v[ind1 - 2])           val = true;         else if (v[ind1 - 1] < v[ind2] && v[ind2 - 1] > v[ind1 - 2])           val = true;       }       if (val) {         cout <<  yes  << endl;         cout << ind1 <<     << ind2 << endl;       } else {         cout <<  no  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[300005];   int rev[300005];   int b[300005];   int main() {     int n, m;     long long ans = 0;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       rev[a[i]] = i;     }     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d %d , &x, &y);       x = rev[x];       y = rev[y];       b[max(x, y)] = max(b[max(x, y)], min(x, y));     }     int t = 0;     for (int i = 1; i <= n; i++) {       t = max(t, b[i]);       ans += i - t;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505, mod = 1e9 + 7;   int n, m, e[N][N], f[N][N], g[N][N];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++) cin >> e[i][j];     for (int i = (1); i <= (n); i++) g[i][i] = f[i][i] = 1;     for (int len = (1); len <= (n); len++)       for (int l = (1); l <= (n - len + 1); l++) {         int r = l + len - 1;         for (int k = (l); k <= (r - 1); k++)           if (e[l][r]) (g[l][r] += (long long)f[l][k] * f[k + 1][r] % mod) %= mod;         for (int k = (l + 1); k <= (r); k++)           (f[l][r] += (long long)g[l][k] * f[k][r] % mod) %= mod;       }     cout << f[1][n] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   const int MAXM = 100010;   const int INF = 1000000000;   int dist[MAXN], dp[MAXN];   pair<int, int> par[MAXN];   bool marked[MAXM];   vector<pair<int, int> > edges[MAXN];   queue<int> q;   vector<pair<int, int> > v;   int x[MAXM], y[MAXM], z[MAXM];   int n, m;   void bfs(int s) {     for (int i = 0; i < n; i++) dist[i] = INF;     dist[s] = 0;     q.push(s);     while (!q.empty()) {       int v = q.front();       q.pop();       for (int i = 0; i < edges[v].size(); i++) {         int u = edges[v][i].first;         if (dist[u] > dist[v] + 1) {           dist[u] = dist[v] + 1;           q.push(u);         }       }     }   }   int main() {     cin >> n >> m;     int working = 0;     for (int i = 0; i < m; i++) {       cin >> x[i] >> y[i] >> z[i];       x[i]--, y[i]--;       working += z[i];       edges[x[i]].push_back(pair<int, int>(y[i], i));       edges[y[i]].push_back(pair<int, int>(x[i], i));     }     bfs(0);     for (int i = 0; i < n; i++) {       v.push_back(pair<int, int>(dist[i], i));       dp[i] = INF;     }     sort(v.begin(), v.end());     dp[0] = 0;     for (int i = 0; i < n; i++) {       int u = v[i].second;       for (int j = 0; j < edges[u].size(); j++) {         int q = edges[u][j].first;         int w = 1 - z[edges[u][j].second];         if (dist[q] == dist[u] + 1 && dp[q] > dp[u] + w) {           par[q] = pair<int, int>(u, edges[u][j].second);           dp[q] = dp[u] + w;         }       }     }     int now = n - 1;     while (now != 0) {       marked[par[now].second] = true;       now = par[now].first;     }     cout << working - dist[n - 1] + dp[n - 1] * 2 << endl;     for (int i = 0; i < m; i++)       if (marked[i] ^ z[i])         cout << x[i] + 1 <<     << y[i] + 1 <<     << 1 - z[i] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long inf = 0x3f3f3f3f3f3f3f3f;   const long long mod = 998244353;   const int N = 2e5 + 10;   mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());   int n;   int z[100][2];   int qry(int i, int j) {     cout <<  ?   << i <<     << j << endl;     int ans;     cin >> ans;     return ans;   }   int p[N];   int f(int i) {     if (p[i] != -1) return p[i];     if (i != z[0][0])       p[i] = qry(i, z[0][0]);     else       p[i] = qry(i, z[0][1]);     for (int j = 1; j < 11; j++) {       if (i != z[j][0])         p[i] &= qry(i, z[j][0]);       else         p[i] &= qry(i, z[j][1]);     }     return p[i];   }   int main() {     scanf( %d , &n);     memset(p, -1, sizeof(p));     while (1) {       bool ok = 1;       for (int i = 0; i < 11; i++)         if (!z[i][0]) ok = 0;       if (ok) break;       int i = uniform_int_distribution<int>((1), (n))(mt),           j = uniform_int_distribution<int>((1), (n))(mt);       while (i == j)         i = uniform_int_distribution<int>((1), (n))(mt),         uniform_int_distribution<int>((1), (n))(mt);       int tmp = qry(i, j);       for (int u = 0; u < 11; u++)         if (!(tmp >> u & 1)) z[u][0] = i, z[u][1] = j;     }     int idx = 1, val = f(idx);     for (int i = 2; i <= n && val != 0; i++) {       if (qry(i, idx) != val) continue;       idx = i, val = f(i);     }     for (int i = 1; i <= n; i++) {       if (p[i] == -1) p[i] = qry(idx, i);     }     cout <<  ! ;     for (int i = 1; i <= n; i++) cout <<     << p[i];     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, T;   double dp[5001][5001];   int p[5001], t[5001];   double quickpow(double x, int y) {     double res = 1;     while (y) {       if (y & 1) res *= x;       x *= x;       y >>= 1;     }     return res;   }   int main() {     cin >> n >> T;     dp[0][0] = 1;     for (int i = 0; i < n; i++) scanf( %d%d , &p[i], &t[i]);     double ans = 0;     for (int i = 0; i < n; i++) {       double pp = p[i] * 0.01;       double now = 0;       double r = quickpow(1 - pp, t[i] - 1) * pp;       double r2 = quickpow(1 - pp, t[i] - 1);       for (int j = 0; j < T; j++) {         now *= (1 - pp);         now += dp[i][j] * pp;         if (j + 1 >= t[i]) {           now -= dp[i][j + 1 - t[i]] * r;           dp[i + 1][j + 1] = now + dp[i][j + 1 - t[i]] * r2;         } else {           dp[i + 1][j + 1] = now;         }       }       for (int j = 0; j <= T; j++) ans += dp[i + 1][j];     }     printf( %.12f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 2;   int n, l;   long long a[N], f[N];   int main() {     scanf( %d %d , &n, &l);     for (int i = 1; i < n; ++i) scanf( %lld , &a[i]), a[i] += a[i - 1];     long long ans = LLONG_MAX;     for (int i = l; i < n; ++i) ans = min(ans, a[i] - a[i - l]);     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, i, j, ans = 0;   long long a, b;   const long long M = (long long)1E9 + 7;   long long power(long long x, long long y) {     long long res = 1;     x %= M;     while (y) {       if (y % 2) res = (res * x) % M;       y = y >> 1;       x = (x * x) % M;     }     return res % M;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     cin >> s;     b = power(2LL, (long long)s.length() - 1);     long long x = 1;     for (i = (long long)s.length() - 1; i >= 0; i--) {       if (s[i] ==  1 ) a += x;       x *= 2;       if (x > M) x %= M;       a %= M;     }     cout << (a * b) % M;   }