malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxN = (int)2e5 + 10;   const int maxM = (int)4e5 + 10;   int n, m, k, type[maxN], a[maxN], pa[maxN];   long long d[maxN];   vector<int> c[maxN], w[maxN];   set<pair<long long, int> > s;   int en, ea[maxM], eb[maxM], ep[maxM];   long long ew[maxM];   inline bool wless(int i, int j) { return ew[i] < ew[j]; }   int get(int v) { return v == pa[v] ? v : (pa[v] = get(pa[v])); }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < (int)(m); i++) {       int a, b, x;       scanf( %d%d%d , &a, &b, &x), a--, b--;       c[a].push_back(b), w[a].push_back(x);       c[b].push_back(a), w[b].push_back(x);     }     scanf( %d , &k);     for (int i = 0; i < (int)(n); i++) d[i] = (long long)1e18;     for (int i = 0; i < (int)(k); i++) {       scanf( %d , &a[i]), a[i]--;       d[a[i]] = 0, type[a[i]] = i;     }     for (int i = 0; i < (int)(n); i++) s.insert(make_pair(d[i], i));     while ((int)(s).size()) {       int v = s.begin()->second;       s.erase(s.begin());       for (int i = 0; i < (int)((int)(c[v]).size()); i++) {         int u = c[v][i];         long long tmp = d[v] + w[v][i];         if (d[u] > tmp) {           s.erase(make_pair(d[u], u));           d[u] = tmp, type[u] = type[v];           s.insert(make_pair(d[u], u));         }       }     }     for (int v = 0; v < (int)(n); v++)       for (int i = 0; i < (int)((int)(c[v]).size()); i++) {         int u = c[v][i];         if (type[v] != type[u]) {           ea[en] = type[v];           eb[en] = type[u];           ep[en] = en;           ew[en] = d[v] + d[u] + w[v][i];           en++;         }       }     long long ans = d[0];     sort(ep, ep + en, wless);     for (int i = 0; i < (int)(k); i++) pa[i] = i;     for (int _i = 0; _i < (int)(en); _i++) {       int i = ep[_i];       if (get(ea[i]) != get(eb[i])) pa[get(ea[i])] = get(eb[i]), ans += ew[i];     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[300005];   int main() {     int n;     cin >> n;     cout << 1 <<    ;     int right = n;     for (int i = 1; i <= n; i++) {       int temp;       scanf( %d , &temp);       arr[temp] = 1;       while (arr[right]) right--;       printf( %d  , i - (n - right) + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool good(int64_t a, int64_t b) {     if (a == 0) return false;     if (!good(b % a, a)) return true;     int64_t c = b / a;     return (c % (a + 1)) % 2 == 0;   }   int main() {     cin.tie(nullptr);     ios::sync_with_stdio(false);     cout << fixed << setprecision(10);     int t;     cin >> t;     while (t--) {       int64_t a, b;       cin >> a >> b;       if (a > b) swap(a, b);       cout << (good(a, b) ?  First  :  Second ) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int D = 1e6 + 3;   const int MAXN = 110;   int F[MAXN];   struct Mt {     int v[MAXN][MAXN];     int N, M;     Mt() {       for (int i = 0; i < MAXN; i++) {         for (int j = 0; j < MAXN; j++) {           v[i][j] = 0;         }       }     }     void I() {       for (int i = 0; i < N; i++) {         for (int j = 0; j < M; j++) {           v[i][j] = 0;         }         v[i][i] = 1;       }     }     void pr() {       for (int i = 0; i < N; i++) {         for (int j = 0; j < M; j++) {           cout << v[i][j];         }         cout << endl;       }     }   };   Mt operator*(Mt A, Mt B) {     Mt Res;     Res.N = A.N;     Res.M = B.M;     for (int k = 0; k < A.M; k++) {       for (int i = 0; i < Res.N; i++) {         for (int j = 0; j < Res.M; j++) {           Res.v[i][j] += (1ll * A.v[i][k] * B.v[k][j]) % D;           Res.v[i][j] %= D;         }       }     }     return Res;   }   Mt pw(Mt A, int p) {     Mt Res;     Res.N = A.N;     Res.M = A.M;     Res.I();     while (p) {       if (p & 1) {         Res = Res * A;       }       A = A * A;       p >>= 1;     }     return Res;   }   int main() {     int C, W, H;     cin >> C >> W >> H;     F[0] = 1;     for (int i = 1; i < W + 1; i++) {       F[i] = H * F[i - 1];       F[i] %= D;     }     Mt A;     A.N = W + 1;     A.M = W + 1;     for (int i = 0; i < W; i++) {       A.v[i][i + 1] = 1;     }     for (int i = 0; i < W + 1; i++) {       A.v[W][i] = F[W - i];     }     Mt ans = pw(A, C);     cout << (ans.v[W][W] + ans.v[W][W - 1]) % D << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char c[1000];   int i, n, d, t, q;   int main() {     cin >> c;     n = strlen(c);     i = 0;     while (i < n && c[i] !=  @ ) {       if (!isalnum(c[i]) && c[i] !=  _ ) {         cout <<  NO ;         return 0;       }       i++;     }     i++;     t = i;     if (i == n || i > 16 || i < 1) {       cout <<  NO ;       return 0;     }     while (i < n && c[i] !=  / ) {       d = 0;       q = i;       while (i < n && c[i] !=  .  && c[i] !=  / ) {         if (!isalnum(c[i]) && c[i] !=  _ ) {           cout <<  NO ;           return 0;         }         i++;         d = 1;       }       if (i - q > 16 || i - q < 1) {         cout <<  NO ;         return 0;       }       if (c[i] !=  / ) i++;     }     if (i - t > 32 || i - t < 1 || (i == n && c[i - 1] ==  . )) {       cout <<  NO ;       return 0;     }     if (c[i] ==  / ) {       if (i == n) {         cout <<  NO ;         return 0;       }       t = i + 1;       i++;       while (i < n) {         if (!isalnum(c[i]) && c[i] !=  _ ) {           cout <<  NO ;           return 0;         }         i++;       }       if (i - t > 16 || i - t < 1) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const int dir[8][2] = {{0, 1}, {1, 0},  {0, -1},  {-1, 0},                          {1, 1}, {1, -1}, {-1, -1}, {-1, 1}};   const int mod = 1e9 + 7, gakki = 5 + 2 + 1 + 19880611 + 1e9;   const int MAXN = 1e6 + 5, MAXM = 1e6 + 5;   const int MAXQ = 100010, INF = 1e9;   inline void read(int &v) {     v = 0;     char c = 0;     int p = 1;     while (c <  0  || c >  9 ) {       if (c ==  - ) {         p = -1;       }       c = getchar();     }     while (c >=  0  && c <=  9 ) {       v = (v << 3) + (v << 1) + c -  0 ;       c = getchar();     }     v *= p;   }   int n, m;   int len;   int anser = INT_MAX;   int num[55];   void dfs(int x, int where, int sum) {     for (int i = x + 1; i <= len; i++) {       if (num[i] >= num[x] + 2) {         if (where == m - 1) {           anser = min(anser, sum + num[i]);           return;         }         dfs(i, where + 1, sum + num[i]);         break;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     string ch;     cin >> ch;     len = ch.size();     for (int i = 0; i < len; i++) {       num[i + 1] = (ch[i] -  a ) + 1;     }     sort(num + 1, num + 1 + len);     num[len + 1] = INT_MAX;     if (m == 1) {       cout << num[1] << endl;       return 0;     }     for (int i = 1; i <= len - m + 1; i++) {       dfs(i, 1, num[i]);     }     if (anser == INT_MAX) {       cout << -1 << endl;     } else {       cout << anser << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 100005;   int n, q, A[MAXN], B[MAXN];   double ans, f[MAXN][105];   int main() {     scanf( %d , &n);     for (register int i = 1; i <= n; ++i)       scanf( %d , A + i), f[i][B[i] = A[i]] = 1, ans += f[i][0];     scanf( %d , &q);     register int u, v, k;     while (q--) {       scanf( %d%d%d , &u, &v, &k);       ans -= f[u][0];       for (register int i = 1; i <= k; ++i)         for (register int j = 0; j <= A[u]; ++j)           f[u][j] = f[u][j] * (B[u] - i + 1 - j) / (B[u] - i + 1) +                     f[u][j + 1] * (j + 1) / (B[u] - i + 1);       ans += f[u][0];       B[u] -= k;       B[v] += k;       printf( %.12lf n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int l = 2, h = 1e5;       int ans = 2;       while (l <= h) {         int m = l + (h - l) / 2;         if ((long long)m * (m - 1) / 2 <= n) {           ans = m;           l = m + 1;         } else {           h = m - 1;         }       }       int rem = n - (long long)ans * (ans - 1) / 2;       cout <<  133 ;       for (int i = 1; i <= rem; i++) cout << 7;       for (int i = 1; i <= ans - 2; i++) cout << 3;       cout << 7 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   const double PI = 3.1415926535897932;   const int dir[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1};   const int maxn = 2e5 + 5;   const int MOD = 998244353;   int n, m;   int d[maxn];   long long sum[maxn];   long long qpow(long long a, long long p) {     long long ans = 1;     while (p) {       if (p & 1) ans = ans * a % MOD;       a = a * a % MOD;       p >>= 1;     }     return ans;   }   long long inv(long long a) { return qpow(a, MOD - 2); }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &d[i]);     sort(d + 1, d + 1 + n);     for (int i = 1; i <= n; i++) sum[i] = (sum[i - 1] + d[i]) % MOD;     while (m--) {       long long A, B;       scanf( %lld%lld , &A, &B);       int st = lower_bound(d + 1, d + 1 + n, B) - d;       if (n - st + 1 < A) {         printf( 0 n );         continue;       }       long long k = n - st + 1;       long long kk = (k - A) * inv(k) % MOD;       long long ans = (sum[n] - sum[st - 1]) % MOD * kk % MOD;       kk = (k - A + 1) * inv(k + 1) % MOD;       ans = (ans + sum[st - 1] * kk % MOD) % MOD;       ans = (ans + MOD) % MOD;       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1000;   int dp[MX][MX], a[MX], x[MX], y[MX], n, d;   int dis(int i, int j) { return abs(x[i] - x[j]) + abs(y[i] - y[j]); }   int main() {     cin >> n >> d;     for (int i = 2; i < n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         if (i != j) dp[i][j] = dis(i, j) * d - a[i];       }     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++)           if (dp[i][j] > dp[i][k] + dp[k][j]) dp[i][j] = dp[i][k] + dp[k][j];     cout << dp[1][n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   int main() {     cout << fixed << setprecision(12);     int n, k;     cin >> n >> k;     vector<vector<int>> y(n, vector<int>(k + 1));     for (auto &yi : y)       for (auto &yij : yi) cin >> yij;     vector<double> sum(n);     for (int j = 0; j < k; j++) {       vector<tuple<int, int, int>> v;       for (int i = 0; i < n; i++) {         v.emplace_back(y[i][j + 1] - y[i][j], y[i][j], i);       }       sort(begin(v), end(v));       auto calc = [&](int k) {         vector<double> x(n + 1), y(n + 1);         x[0] = 0.0, y[0] = 0.0;         x[1] = 1.0, y[1] = 0.0;         int sz = 2;         for (auto &t : v)           if (get<2>(t) < k) {             auto a = get<0>(t), b = get<1>(t);             auto f = [&](double x) { return a * x + b; };             int p = sz - 1;             while (p >= 0 && f(x[p]) + eps >= y[p]) p--;             if (p == -1) {               y[0] = f(x[0] = 0.0);               y[1] = f(x[1] = 1.0);               sz = 2;             } else if (p != sz - 1) {               double a2 = (y[p + 1] - y[p]) / (x[p + 1] - x[p]);               double b2 = y[p] - x[p] * a2;               double x2 = (b2 - b) / (a - a2);               y[p + 1] = f(x[p + 1] = x2);               y[p + 2] = f(x[p + 2] = 1.0);               sz = p + 3;             }           }         double sum = 0.0;         for (int i = 0; i + 1 < sz; i++) {           sum += (x[i + 1] - x[i]) * (y[i + 1] + y[i]) / 2;         }         return sum;       };       vector<double> acc(n + 1);       for (int i = 0; i < n; i++) acc[i + 1] = calc(i + 1);       for (int i = 0; i < n; i++) sum[i] += acc[i + 1] - acc[i];     }     for (int i = 0; i < n; i++) cout << sum[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010;   int a[maxn];   int f[maxn];   int miss[maxn];   int sum[maxn];   int main() {     int n, s;     cin >> n >> s;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     int ans1 = 0;     if (a[s] != 0) {       ans1++;       a[s] = 0;     }     int zero = 0;     for (int i = 1; i <= n; i++) {       f[a[i]]++;       if (a[i] == 0) {         zero++;       }     }     zero--;     int i = 0;     while (zero--) {       while (f[i] != 0) {         i++;       }       f[0]--;       f[i]++;       ans1++;     }     sum[0] = 1;     for (int i = 1; i < n; i++) {       if (f[i] == 0) {         miss[i] = miss[i - 1] + 1;       } else {         miss[i] = miss[i - 1];       }       sum[i] = sum[i - 1] + f[i];     }     int ans2 = 1e9;     for (int i = n - 1; i >= 1; i--) {       int tmp = max((n - sum[i]), miss[i]);       ans2 = min(ans2, tmp);     }     if (n == 1) {       ans2 = 0;     }     cout << ans1 + ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const string nl =   n ;   vector<int> readVector(int n) {     vector<int> ret(n);     for (int i = 0; i < n; i++) cin >> ret[i];     return ret;   }   void setIO(string name) {     freopen((name +  .in ).c_str(),  r , stdin);     freopen((name +  .out ).c_str(),  w , stdout);   }   int recur(vector<int> vec, int sig) {     vector<int> s1, s0;     for (int i = 0; i < vec.size(); i++) {       if ((vec[i] & (1 << sig)) == 0) {         s0.push_back(vec[i]);       } else         s1.push_back(vec[i]);     }     if (s1.size() < 2 && s0.size() < 2) return 0;     if (s1.size() < 2) return recur(s0, sig - 1);     if (s0.size() < 2) return recur(s1, sig - 1);     return min(s0.size() - 1 + recur(s1, sig - 1),                s1.size() - 1 + recur(s0, sig - 1));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n;     cin >> n;     vector<int> a = readVector(n);     cout << recur(a, 30) << nl;     return 0;   }
#include <bits/stdc++.h>   int n, m;   char map[1010][1010], ans[1010][1010];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %s , map[i] + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) ans[i][j] =  . ;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (map[i][j] !=  b ) continue;         int c =  a  + 2 * ((i / 2 + j / 2) % 2) + i % 2;         if (map[i - 1][j] ==  w  && map[i + 1][j] ==  w )           ans[i - 1][j] = ans[i][j] = ans[i + 1][j] = c,                   map[i - 1][j] = map[i][j] = map[i + 1][j] =  . ;         else if (map[i][j - 1] ==  w  && map[i][j + 1] ==  w )           ans[i][j - 1] = ans[i][j] = ans[i][j + 1] = c,                      map[i][j - 1] = map[i][j] = map[i][j + 1] =  . ;       }     bool ok = true;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (map[i][j] !=  . ) ok = false;     puts(ok ?  YES  :  NO );     if (ok)       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) putchar(ans[i][j]);         putchar(  n );       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   struct mat {     long long** val;     mat() {       val = new long long*[6];       for (int i = 0; i < 6; i++) {         val[i] = new long long[6];         for (int j = 0; j < 6; j++) val[i][j] = 0;         val[i][i] = 1;       }     }     mat(long long v[6][6]) {       val = new long long*[6];       for (int i = 0; i < 6; i++) {         val[i] = new long long[6];         for (int j = 0; j < 6; j++) val[i][j] = v[i][j];       }     }     mat operator*(const mat& b) {       mat ans;       for (int i = 0; i < 6; i++) {         for (int j = 0; j < 6; j++) {           ans.val[i][j] = 0;           for (int k = 0; k < 6; k++) {             ans.val[i][j] += (val[i][k] * b.val[k][j]) % n;             ans.val[i][j] %= n;           }         }       }       return ans;     }     mat& operator=(const mat& b) {       for (int i = 0; i < 6; i++) {         for (int j = 0; j < 6; j++) val[i][j] = b.val[i][j];       }       return *this;     }   };   long long rec[6][6] = {{2, 1, 1, 0, 1, 2}, {1, 2, 0, 1, 1, 2},                          {1, 1, 1, 0, 1, 2}, {1, 1, 0, 1, 1, 2},                          {0, 0, 0, 0, 1, 1}, {0, 0, 0, 0, 0, 1}};   mat matrec;   mat matexp(long long e) {     if (e == 0ll) return mat();     mat tmp = matexp(e / 2ll);     tmp = (tmp * tmp);     if (e & 1) return tmp * matrec;     return tmp;   }   int main() {     ios::sync_with_stdio(0);     matrec = mat(rec);     long long sx, sy, dx, dy, t;     cin >> n >> sx >> sy >> dx >> dy >> t;     if (t == 0ll) {       cout << sx <<     << sy <<   n ;       return 0;     }     sx--;     sy--;     dx %= n;     dy %= n;     while (dx < 0) dx += n;     while (dy < 0) dy += n;     long long vec[] = {sx, sy, dx, dy, 0, 1};     mat ans = matexp(t);     long long ansx = 0, ansy = 0;     for (int i = 0; i < 6; i++) {       ansx += (vec[i] * ans.val[0][i]) % n;       ansy += (vec[i] * ans.val[1][i]) % n;       ansx %= n;       ansy %= n;     }     cout << ansx + 1 <<     << ansy + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 100;   const int mod = 1e9 + 7;   int main() {     ios::sync_with_stdio(0);     int t;     cin >> t;     while (t--) {       int n, x, y;       cin >> n >> x >> y;       cout << max(min(n, x + y - n + 1), 1) <<     << min(x + y - 1, n) << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   namespace SCCKosaraju {   vector<vector<int>> adj, radj;   vector<int> todo, comp, curr;   vector<bool> vis;   void dfs1(int x) {     vis[x] = 1;     for (int y : adj[x])       if (!vis[y]) dfs1(y);     todo.push_back(x);   }   void dfs2(int x, int i) {     comp[x] = i;     curr.push_back(x);     for (int y : radj[x])       if (comp[y] == -1) dfs2(y, i);   }   vector<int> scc(vector<vector<int>>& _adj) {     adj = _adj;     int time = 0, n = adj.size();     comp.resize(n, -1), radj.resize(n), vis.resize(n);     for (int x = 0; x < n; x++)       for (int y : adj[x]) radj[y].push_back(x);     for (int x = 0; x < n; x++)       if (!vis[x]) dfs1(x);     reverse(todo.begin(), todo.end());     for (int x : todo)       if (comp[x] == -1) dfs2(x, time++);     return comp;   }   };  // namespace SCCKosaraju   int main() {     cin.tie(0)->sync_with_stdio(0);     cin.exceptions(cin.failbit);     const ll MOD = 1000000007;     int n;     cin >> n;     vector<int> cost(n);     for (int& x : cost) cin >> x;     vector<vector<int>> adj(n);     int m;     cin >> m;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       adj[u - 1].push_back(v - 1);     }     vector<int> comp = SCCKosaraju::scc(adj);     vector<ll> add(comp.size(), (int)1e9 + 10);     vector<ll> cnt(comp.size(), 1);     int ncomps = 0;     for (int i = 0; i < n; i++) {       ncomps = max(ncomps, comp[i] + 1);       if (cost[i] < add[comp[i]]) {         add[comp[i]] = cost[i];         cnt[comp[i]] = 1;       } else if (cost[i] == add[comp[i]])         cnt[comp[i]]++;     }     ll ans = 0, ways = 1;     for (int i = 0; i < ncomps; i++) ans += add[i];     for (int i = 0; i < ncomps; i++) ways = (ways * cnt[i]) % MOD;     cout << ans <<     << ways <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 10000005, p = 1e9 + 7;   int n, k, cnt, phi[Maxn], prim[Maxn], sum[Maxn], ct[Maxn];   long long ans;   bool vis[Maxn];   void init(void) {     phi[1] = 1;     for (int i = 2; i <= n; i++) {       if (!vis[i]) prim[++cnt] = i, phi[i] = i - 1;       for (int j = 1; j <= cnt && i * prim[j] <= n; j++) {         vis[i * prim[j]] = true;         if (i % prim[j] == 0) {           phi[i * prim[j]] = phi[i] * prim[j];           break;         }         phi[i * prim[j]] = phi[i] * (prim[j] - 1);       }     }   }   long long get_inv(int x) {     if (x <= 1) return 1;     return (p - p / x) * get_inv(p % x) % p;   }   int main() {     scanf( %d%d , &n, &k);     init();     for (int i = 2; i <= n; i++) sum[i] = (sum[i - 1] + phi[i]) % p;     for (int i = 1; i <= n; i++) ct[i] = n - i - 1;     for (int i = 1; i < n; i++) {       int l = (n - 1) / i;       (ct[i] += sum[l + 1]) %= p;       (ct[(l + 1) * i - n] += p - phi[l + 1]) %= p;     }     long long now = 1;     for (int i = 1; i < n; i++) {       now = now * k % p;       (ans += ct[i] * now) %= p;     }     printf( %lld , ans * get_inv(now * k % p) % p);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100010], diff[100010];   int main() {     int i, j, k, n, neg1, neg2, pos, ans, mx = -1, df, d;     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < n - 1; i++) {       diff[i] = a[i] - a[i + 1];     }     i = 0;     while (i < n - 1) {       neg1 = neg2 = pos = ans = d = 0;       while (i < n - 1 && diff[i] < 0) {         neg1++;         i++;       }       while (i < n - 1 && diff[i] >= 0) {         pos++;         i++;       }       if (pos) {         if (pos == 1) {           if ((i + 1 < n && a[i + 1] - a[i - 1] > 1) ||               (i - 2 >= 0 && a[i] - a[i - 2] > 1)) {             j = i;             while (j < n - 1 && diff[j] < 0) {               neg2++;               j++;             }           }           ans = neg1 + neg2 + 1;           d = 1;         } else {           ans = neg1 + 1;           d = 1;         }       } else {         ans = neg1;         d = 0;       }       if (ans > mx || ((ans == mx) && (d == 0))) {         mx = ans;         df = d;       }     }     if (n < 3)       cout << n;     else if (mx == 0)       cout <<  2 ;     else {       if (df == 0 && mx + 1 < n)         cout << mx + 2;       else         cout << mx + 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fileioe() {     freopen( input.txt ,  r , stdin);     freopen( xyz.txt ,  w , stdout);     freopen( error.txt ,  w , stderr);   }   const long long mod = 1000000007;   const long long INF = 1e18;   const long long MAX = 100001;   void solve() {     long long n;     cin >> n;     string s;     cin >> s;     string str1, str2;     int flag1 = 0, flag0 = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  1 ) {         flag1 = 1;         for (int j = 0; j < i; j++) {           if (s[j] ==  0 ) str1 +=  0 ;         }         break;       }     }     for (int i = n - 1; i >= 0; i--) {       if (s[i] ==  0 ) {         flag0 = 1;         str2 = s.substr(i);         break;       }     }     if (flag1 == 0 || flag0 == 0) {       cout << s << endl;       return;     }     string res = str1 + str2;     if (res.length() > n) {       cout << res.substr(1) << endl;       return;     }     cout << res << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     t = 1;     cin >> t;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long lkd(long long a, long long b) {     while (b > 0) {       long long c = b;       b = a % b;       a = c;     }     return a;   }   int main() {     long long a, s, b = 1;     cin >> a >> s;     for (long long i = 0; i < s; i++) b = b * 10;     cout << (a * b) / lkd(a, b);   }