malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   long long int myRand(long long int B) { return (unsigned long long)rng() % B; }   const int N = 51;   int vld[N][N][N][N];   int main() {     cin.tie(nullptr);     ios::sync_with_stdio(false);     int h, w, q;     cin >> h >> w >> q;     vector<string> s(h);     for (int i = 0; i < h; i++) {       cin >> s[i];     }     vector<vector<int>> sum(h + 1, vector<int>(w + 1));     for (int i = 0; i < h; i++) {       for (int j = 0; j < w; j++) {         sum[i + 1][j + 1] = (s[i][j] ==  0 );       }     }     for (int i = 0; i < h; i++) {       for (int j = 0; j <= w; j++) {         sum[i + 1][j] += sum[i][j];       }     }     for (int j = 0; j < w; j++) {       for (int i = 0; i <= h; i++) {         sum[i][j + 1] += sum[i][j];       }     }     for (int i = 1; i <= h; i++) {       for (int j = 1; j <= w; j++) {         for (int k = i; k <= h; k++) {           for (int l = j; l <= w; l++) {             if ((l - j + 1) * (k - i + 1) ==                 sum[k][l] - sum[i - 1][l] - sum[k][j - 1] + sum[i - 1][j - 1]) {               vld[i][j][k][l] = 1;             }           }         }       }     }     for (int i = 0; i < h; i++) {       for (int j = 0; j <= w; j++) {         for (int k = 0; k <= h; k++) {           for (int l = 0; l <= w; l++) {             vld[i + 1][j][k][l] += vld[i][j][k][l];           }         }       }     }     for (int i = 0; i <= h; i++) {       for (int j = 0; j < w; j++) {         for (int k = 0; k <= h; k++) {           for (int l = 0; l <= w; l++) {             vld[i][j + 1][k][l] += vld[i][j][k][l];           }         }       }     }     for (int i = 0; i <= h; i++) {       for (int j = 0; j <= w; j++) {         for (int k = 0; k < h; k++) {           for (int l = 0; l <= w; l++) {             vld[i][j][k + 1][l] += vld[i][j][k][l];           }         }       }     }     for (int i = 0; i <= h; i++) {       for (int j = 0; j <= w; j++) {         for (int k = 0; k <= h; k++) {           for (int l = 0; l < w; l++) {             vld[i][j][k][l + 1] += vld[i][j][k][l];           }         }       }     }     while (q--) {       int a, b, c, d;       cin >> a >> b >> c >> d;       printf( %d n , vld[c][d][c][d] - vld[a - 1][d][c][d] - vld[c][b - 1][c][d] +                          vld[a - 1][b - 1][c][d]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int n, a[N];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     int s = 0;     for (int i = 1; i <= n; i++) s ^= a[i];     if (n % 2 == 0) {       if (s != 0) {         cout <<  NO n ;         return 0;       }       n--;     }     cout <<  YES n ;     cout << n - 2 <<   n ;     for (int i = 1; i <= n - 2; i += 2)       cout << i <<     << i + 1 <<     << i + 2 <<   n ;     for (int i = 1; i <= n - 4; i += 2)       cout << i <<     << i + 1 <<     << n <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int nums[105];   int main() {     int n, m, mayor;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> nums[i];     }     sort(nums, nums + n);     reverse(nums, nums + n);     int maximo = nums[0] + m;     mayor = nums[0];     for (int i = 0; i < n; i++) {       m -= mayor - nums[i];       nums[0] = mayor;     }     int i = 0;     while (m > 0) {       m--;       nums[i % n]++;       i++;     }     int minimo = nums[0];     cout << minimo <<     << maximo <<   n ;   }
#include <bits/stdc++.h>   const int oo = 0x3f3f3f3f;   template <typename T>   inline bool chkmax(T &a, T b) {     return a < b ? a = b, true : false;   }   template <typename T>   inline bool chkmin(T &a, T b) {     return a > b ? a = b, true : false;   }   template <typename T>   T read(T &first) {     int f = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = -1;     for (first = 0; isdigit(ch); ch = getchar()) first = 10 * first + ch -  0 ;     return first *= f;   }   template <typename T>   void write(T first) {     if (first == 0) {       putchar( 0 );       return;     }     if (first < 0) {       putchar( - );       first = -first;     }     static char s[20];     int top = 0;     for (; first; first /= 10) s[++top] = first % 10 +  0 ;     while (top) putchar(s[top--]);   }   const int MAXN = 2e5 + 5;   const int CNT = 60;   int N;   std::pair<int, int> A[MAXN];   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   inline int count(int i, int j) {     return gcd(std::abs(A[j].first - A[i].first),                std::abs(A[j].second - A[i].second));   }   inline long long cross(const std::pair<int, int> &a,                          const std::pair<int, int> &b) {     return (long long)a.first * b.second - (long long)a.second * b.first;   }   void input() {     read(N);     for (int i = 0; i < N; ++i) {       read(A[i].first);       read(A[i].second);     }   }   void solve() {     memcpy(A + N, A, sizeof(*A) * N);     long long a = 0, b = 0;     for (int i = 0; i < N; ++i) {       a += cross(A[i], A[i + 1]);       b += count(i, i + 1);     }     long double coef[MAXN];     long double tnn = pow((long double)2, -N);     for (int i = 2; i <= CNT && i < N - 1; ++i) {       coef[i] = pow((long double)2, -i - 1) - tnn;     }     long double ans = 0.5 * a - 0.5 * b + 1;     long double contrib = 0;     for (int i = 0; i < N; ++i) {       a = cross(A[i], A[i + 1]);       b = count(i, i + 1);       for (int k = 2; k <= CNT && k < N - 1; ++k) {         int j = i + k;         a += cross(A[j - 1], A[j]);         b += count(j - 1, j);         long long a0 = cross(A[j], A[i]);         long long b0 = count(j, i);         contrib += (0.5 * (a + a0) - 0.5 * (b + b0) + b0) * coef[k];       }     }     ans -= contrib / (1 - tnn - N * tnn - (long long)N * (N - 1) / 2 * tnn);     printf( %.15f n , (double)ans);   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[107], b[107];   int main() {     int m, s;     cin >> m >> s;     int ss = s;     if (s >= 2 and s <= m * 9) {       s--;       a[m] = 1;       for (int i = 1; i <= m; i++) {         if (s > 9) {           a[i] += 9;           s -= 9;         } else {           a[i] += s;           break;         }       }       for (int i = m; i > 0; i--) {         cout << a[i];       }       cout <<    ;       for (int i = m; i > 0; i--) {         if (ss > 9) {           b[i] = 9;           ss -= 9;         } else {           b[i] += ss;           break;         }       }       for (int i = m; i > 0; i--) {         cout << b[i];       }     } else {       if (s == 1) {         cout << 1;         for (int i = 1; i < m; i++) {           cout << 0;         }         cout <<    ;         cout << 1;         for (int i = 1; i < m; i++) {           cout << 0;         }       } else {         if (m == 1 and s == 0) {           cout << 0 <<     << 0;         } else {           cout << -1 <<     << -1;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long F[401000], Mod = 998244353, InvF[401000];   long long Pow(long long a, long long b) {     long long r = 1;     while (b) {       if (b & 1) r = r * a % Mod;       a = a * a % Mod;       b >>= 1;     }     return r;   }   int A[201000], n, K;   long long S[201000], res;   long long Comb(int a, int b) {     return F[a] * InvF[b] % Mod * InvF[a - b] % Mod;   }   int main() {     int i;     F[0] = 1;     for (i = 1; i <= 400000; i++) F[i] = F[i - 1] * i % Mod;     InvF[i - 1] = Pow(F[i - 1], Mod - 2);     for (i = i - 1; i >= 1; i--) InvF[i - 1] = InvF[i] * i % Mod;     scanf( %d%d , &n, &K);     for (i = 0; i < n; i++) {       scanf( %d , &A[i]);     }     int c2 = 0, c1 = 0;     for (i = 0; i < n; i++) {       if (A[i] == A[(i + 1) % n])         c2++;       else         c1++;     }     for (i = 0; i <= c1; i++) {       if (i % 2 == 1) {         S[i] = Pow(2, i - 1) % Mod;       } else {         S[i] = (Pow(2, i) - Comb(i, i / 2) + Mod) * (Mod / 2 + 1) % Mod;       }     }     for (i = 0; i <= c1; i++) {       if (K >= 2 || i == c1) {         res = (res + Pow(K - 2, c1 - i) * S[i] % Mod * Comb(c1, i)) % Mod;       }     }     res = res * Pow(K, c2) % Mod;     printf( %lld n , res);   }
#include <bits/stdc++.h>   int n, p[110], i, j, cnt;   char s[110];   int main() {     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %d , &p[i]);     gets(s);     for (i = 0; i < n; i++) {       gets(s);       cnt = 0;       for (j = 0; s[j]; j++)         if (s[j] ==  a  || s[j] ==  e  || s[j] ==  i  || s[j] ==  o  ||             s[j] ==  u  || s[j] ==  y )           cnt++;       if (cnt != p[i]) goto fuck;     }     puts( YES );     return 0;   fuck:     puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 7;   long long n, q;   long long a[N];   long long l[N], r[N];   void read() {     cin >> n >> q;     for (long long i = 0; i < n; ++i) cin >> a[i];     for (long long i = 0; i < q; ++i) cin >> l[i];     for (long long i = 0; i < q; ++i) cin >> r[i];     for (long long i = 0; i < q; ++i) {       --l[i];       --r[i];     }   }   long long ans[N];   long long link[N];   vector<long long> add[N], del[N];   long long f[N], fcnt[N];   void addf(long long i) {     long long t = i;     for (; i < N; i |= (i + 1)) {       f[i] += t;     }   }   void addfcnt(long long i) {     for (; i < N; i |= (i + 1)) {       fcnt[i]++;     }   }   void add_(long long i) {     addf(i);     addfcnt(i);   }   long long getsum(long long i) {     long long ans = 0;     for (; i >= 0; i = (i & (i + 1)) - 1) {       ans += f[i];     }     return ans;   }   long long getcnt(long long i) {     long long ans = 0;     for (; i >= 0; i = (i & (i + 1)) - 1) {       ans += fcnt[i];     }     return ans;   }   long long getmax(long long x) {     return getcnt(x) * x + getsum(N - 1) - getsum(x);   }   long long pref[N];   void kek() {     for (long long i = 0; i < N; ++i) {       f[i] = fcnt[i] = 0;     }     for (long long i = 0; i < q; ++i) {       ans[i] += pref[r[i] + 1] - pref[l[i]];     }     for (long long i = 0; i < N; ++i) f[i] = fcnt[i] = 0;     for (long long i = 0; i < n; ++i) {       add[i].clear();       del[i].clear();     }     for (long long i = 0; i < n; ++i) link[i] = -1;     vector<long long> st;     for (long long i = n - 1; i >= 0; --i) {       while (st.size() && a[i] > a[st.back()]) {         link[st.back()] = i;         st.pop_back();       }       st.push_back(i);     }     for (long long i = 0; i < q; ++i) {       add[r[i]].push_back(i);       if (l[i]) del[l[i] - 1].push_back(i);     }     for (long long i = 0; i < n; ++i) {       add_(link[i] + 1);       for (long long e : add[i]) {         ans[e] -= getmax(l[e]);       }       for (long long e : del[i]) {         ans[e] += getmax(l[e]);       }     }   }   void solve() {     for (long long i = 0; i < n; ++i) {       pref[i + 1] = pref[i] + i;     }     for (long long i = 0; i < q; ++i) {       ans[i] = r[i] - l[i] + 1;     }     kek();     reverse(a, a + n);     for (long long i = 0; i < q; ++i) {       l[i] = n - 1 - l[i];       r[i] = n - 1 - r[i];       swap(l[i], r[i]);     }     kek();   }   void print() {     for (long long i = 0; i < q; ++i) cout << ans[i] <<    ;     cout <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.precision(20);     read();     solve();     print();   }
#include <bits/stdc++.h>   using namespace std;   template <class t>   inline t read(t &x) {     x = 0;     char c = getchar();     bool f = 0;     while (!isdigit(c)) f |= c ==  - , c = getchar();     while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();     if (f) x = -x;     return x;   }   template <class t>   inline void write(t x) {     if (x < 0) {       putchar( - ), write(-x);     } else {       if (x > 9) write(x / 10);       putchar( 0  + x % 10);     }   }   const int N = 1e5 + 5;   int n, x[N], y[N], px, py;   signed main() {     read(n);     if (n & 1) {       puts( NO );       return 0;     }     for (int i = 1; i <= n; i++) read(x[i]), read(y[i]);     px = x[1] + x[n / 2 + 1];     py = y[1] + y[n / 2 + 1];     for (int i = 1, j = n / 2 + 1; j <= n; i++, j++)       if (x[i] + x[j] != px || y[i] + y[j] != py) {         puts( NO );         return 0;       }     puts( YES );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, s;     scanf( %d%d%d , &a, &b, &s);     int req = abs(a) + abs(b);     if (req > s) {       printf( No n );     } else {       int cur = s - req;       if (cur & 1) {         printf( No n );       } else {         printf( Yes n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, y;     int num;   };   node point[303];   char str[5][105];   int t, n, k;   int flag = 0;   int Flag[5][105];   queue<node> Q;   void bfs() {     while (!Q.empty()) {       node D = Q.front(), R;       Q.pop();       if (D.x >= n) {         flag = 1;       }       if (D.num == 1 && str[D.y][D.x + 1] ==  . ) {         for (int j = D.y - 1; j <= D.y + 1; j++) {           if (str[j][D.x + 1] ==  .  && Flag[j][D.x + 1] == 0) {             R.num = 2;             R.x = D.x + 1;             R.y = j;             Q.push(R);             Flag[j][D.x + 1] = 1;           }         }       } else if (D.num == 2 && str[D.y][D.x + 1] ==  .  &&                  str[D.y][D.x + 2] ==  . ) {         R.num = 1;         R.x = D.x + 2;         R.y = D.y;         Q.push(R);       }     }   }   int main() {     int u, v;     scanf( %d , &t);     while (t--) {       memset(Flag, 0, sizeof(Flag));       flag = 0;       scanf( %d%d , &n, &k);       for (int j = 1; j <= 3; j++) scanf( %s , str[j] + 1);       for (int i = 1; i <= 3; i++) {         if (str[i][1] ==  s ) u = i;       }       for (int i = 1; i <= n + 1; i++) {         str[0][i] =  A ;         str[4][i] =  A ;       }       for (int i = 0; i <= 4; i++) str[i][n + 1] =  . ;       node W;       W.x = 1;       W.y = u;       W.num = 1;       Q.push(W);       bfs();       if (flag)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int arr[100];     for (int counter = 0; counter < n; counter++) {       cin >> arr[counter];     }     sort(arr, arr + n);     int sum = 0;     for (int counter = n - 1; counter >= 0; counter--) {       sum += arr[counter];       if (sum >= m) {         cout << n - counter;         break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 32768 - 1;   int ans[100500];   bool use[100500];   int res;   string s =   ;   int eval_num(int n, int &i);   int eval_product(int n, int &i);   int eval_sum(int n, int &i);   bool eval_logick(int n, int &i);   int eval_op(int n, int &i);   int eval_opseq(int n, int &i);   int eval_func(int n, int &i);   int run(int n);   const string dels =     n ;   const string ops =  (){}+-*/;<> ;   bool has(string t, char c) {     for (int i = 0; i < t.length(); ++i)       if (t[i] == c) return true;     return false;   }   string getlex(int &i) {     string t =   ;     while (has(dels, s[i])) ++i;     if (has(ops, s[i])) {       t += s[i++];       return t;     }     if (s[i] ==  =  && s[i + 1] ==  = ) {       t +=  == ;       i += 2;       return t;     }     while (!((has(dels, s[i]) || has(ops, s[i]) || s[i] ==  = ))) t += s[i++];     return t;   }   int norm(int x) {     while (x < 0) x += MAXN + 1;     return x % (MAXN + 1);   }   int eval_num(int n, int &i) {     string sw = getlex(i);     if (sw ==  n ) return n;     if (sw ==  f ) {       getlex(i);       int t = eval_sum(n, i);       getlex(i);       return run(t);     }     return atoi(sw.c_str());   }   int eval_product(int n, int &i) {     int sum = eval_num(n, i);     int j = i;     string op = getlex(j);     while (op ==  *  || op ==  / ) {       int t = eval_num(n, j);       i = j;       if (op ==  * )         sum *= t;       else         sum /= t;       sum = norm(sum);       op = getlex(j);     }     return sum;   }   int eval_sum(int n, int &i) {     int sum = eval_product(n, i);     int j = i;     string op = getlex(j);     while (op ==  +  || op ==  - ) {       int t = eval_product(n, j);       i = j;       if (op ==  + )         sum += t;       else         sum -= t;       sum = norm(sum);       op = getlex(j);     }     return sum;   }   bool eval_logick(int n, int &i) {     int e1 = eval_sum(n, i);     string op = getlex(i);     int e2 = eval_sum(n, i);     if (op ==  > ) return (e1 > e2);     if (op ==  < ) return (e1 < e2);     if (op ==  == ) return (e1 == e2);     exit(0);     return false;   }   int eval_op(int n, int &i) {     string sw = getlex(i);     if (sw ==  if ) {       string t = getlex(i);       if (t !=  ( ) exit(0);       bool b = eval_logick(n, i);       t = getlex(i);       if (b) {         getlex(i);       } else {         while (s[i] !=  ; ) ++i;         ++i;         return -1;       }     }     int ret = eval_sum(n, i);     getlex(i);     return ret;   }   int eval_func(int n, int &i) {     while (s[i] !=  { ) ++i;     ++i;     int ret = -1;     while (ret < 0) {       ret = eval_op(n, i);     }     return ret;   }   int run(int n) {     int j = 0;     if (use[n]) return ans[n];     use[n] = true;     ans[n] = eval_func(n, j);     return ans[n];   }   int main() {     cin >> res;     string t;     while (!feof(stdin)) {       getline(cin, t);       s += t +    ;     }     s +=    ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;     for (int i = 0; i <= MAXN; ++i) run(i);     int mx = -1;     for (int i = 0; i <= MAXN; ++i)       if (ans[i] == res) mx = i;     cout << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const int mod = 1000 * 1000 * 1000 + 7;   const long long inf = 1e18;   void rd(int &x) { scanf( %d , &x); }   void rd(long long &x) { scanf( %lld , &x); }   void rd(double &x) { scanf( %lf , &x); }   void rd(int &x, int &y) { scanf( %d%d , &x, &y); }   void rd(long long &x, long long &y) { scanf( %lld%lld , &x, &y); }   void rd(int &x, int &y, int &z) { scanf( %d%d%d , &x, &y, &z); }   void rd(long long &x, long long &y, long long &z) {     scanf( %lld%lld%lld , &x, &y, &z);   }   void rd(double &x, double &y) { scanf( %lf%lf , &x, &y); }   void rd(double &x, double &y, double &z) { scanf( %lf%lf%lf , &x, &y, &z); }   void rd(char *s) { scanf( %s , s); }   void rd(char &s) { scanf( %c , &s); }   void rd(string &s) { getline(cin, s); }   void pf(int x) { printf( %d n , x); }   void pf(int x, int y) { printf( %d %d n , x, y); }   void pf(long long x) { printf( %lld n , x); }   void pf(char x) { printf( %c n , x); }   void pf(char *x) { printf( %s n , x); }   void pf(string x) { cout << x << endl; }   int main() {     int n, m, k, x = 0, y = 0, f = 1, p, q, ans = 0;     cin >> n >> m >> k;     if (k == 1) {       cout << m * n <<    ;       for (int i = 1; i <= (n); i++)         for (int j = 1; j <= (m); j++) {           if (i % 2 == 1) {             cout << i <<     << j <<    ;           } else {             cout << i <<     << m - j + 1 <<    ;           }         }       return 0;     }     cout <<  2  ;     for (int i = 1; i <= (n); i++)       for (int j = 1; j <= (m); j++) {         if (i % 2 == 1) {           cout << i <<     << j <<    ;           x++;           ans++;         } else {           cout << i <<     << m - j + 1 <<    ;           x++;           ans++;         }         if (x == 2 && f) {           x = 0;           y++;           if (y != k - 1) cout <<   n2  ;         }         if (y == k - 1 && f != 0) {           f = 0;           cout <<   n  << m * n - ans <<    ;         }       }   }
#include <bits/stdc++.h>   using namespace std;   const int __ = 1000000;   bool pri[__ + 5];   int num[__ + 5];   void era() {     int x = (int)sqrt(__ + 0.01);     for (int i = 2; i <= x; i++)       if (!pri[i]) {         num[++num[0]] = i;         for (int j = i * i; j <= __; j += i) pri[j] = true;       }     for (int i = x + 1; i <= __; i++)       if (!pri[i]) num[++num[0]] = i;   }   int main() {     era();     int n;     scanf( %d , &n);     int m = n, maxx = 0;     for (int i = 2; i * i <= m; i++)       if (m % i == 0)         for (maxx = i; m % i == 0; m /= i)           ;     if (m != 1) maxx = m;     int x1 = n - maxx + 1, ans = INT_MAX;     for (int i = (1); i <= (num[0]); i++) {       int p = num[i];       int x0 = (x1 + p - 1) / p * p - (p - 1);       int x = (x0 + p - 1) / p * p;       if (x0 > p && x0 >= 3 && x <= n) ans = min(ans, x0);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1;     while (cin >> s1) {       string s2 =   ;       for (int i = 0; i < s1.size(); i++) {         if (s1[i] !=  + ) s2 += s1[i];       }       sort(s2.begin(), s2.end());       for (int i = 0; i < s2.size(); i++) {         if (i) cout <<  + ;         cout << s2[i];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ara[200005];   long long aray[200005];   int main() {     long long a, b, c, d, t, i, j, k, n, m;     cin >> t;     while (t--) {       long long ans = 0;       cin >> n >> m >> k;       a = n / k;       if (m > a) {         m -= a;         if (m % (k - 1) == 0) {           ans = a - ((m / (k - 1)));         } else {           ans = a - ((m / (k - 1))) - 1;         }       } else {         ans = m;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double error = 1e-7;   double v, r;   bool puede(double t, double dist) {     dist -= v * t;     if (dist <= 0) return true;     double tvuelta = r * 2 * M_PI / v;     t -= int(t / tvuelta) * tvuelta;     double a = t * v / r;     return dist <= 2 * r * sin(a / 2.0);   }   int main() {     cout.setf(ios::fixed);     cout.precision(10);     int n;     cin >> n >> r >> v;     for (int cas = 0; cas < n; cas++) {       int s, f;       cin >> s >> f;       double inf = 0;       double sup = 2000000000;       double d = f - s;       while (inf + error < sup) {         double med = (inf + sup) / 2.0;         if (puede(med, d))           sup = med;         else           inf = med;       }       cout << inf << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, v1, v2, k;   int main() {     cin >> n >> l >> v1 >> v2 >> k;     long long g = (n + k - 1) / k;     double le = 0, ri = l / (double)v1;     while ((ri - le) >= 5e-7) {       double mid = (le + ri) / 2;       double t = 0;       for (int i = 1; i <= g; i++) {         double x = ((double)l - v1 * mid) / (v2 - v1);         t += x;         if (i != g) {           double y = x * (v2 - v1) / (v1 + v2);           t += y;         }       }       if (mid > t)         ri = mid;       else         le = mid;     }     cout << setprecision(9) << le << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, o;       string s;       cin >> n >> s;       o = s[n - 1] -  0 ;       for (int i = 0; i < n - 1; i++) o += (s[i] ==  0  ? 0 : s[i] - 47);       cout << o << endl;     }     return 0;   }