malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   vector<int> v[N];   int n, kk;   int dis[N], ans[N];   void dfs1(int pos, int fa) {     for (auto &i : v[pos])       if (i != fa) dfs1(i, pos), dis[pos] = max(dis[pos], dis[i]);     ++dis[pos];   }   bool dfs2(int pos, int fa, const multiset<int, greater<int>> &mt) {     multiset<int, greater<int>> d;     int mx = 0;     for (auto &i : v[pos])       if (i != fa)         d.insert(dis[i]);       else         mx = 1;     bool fs = 1;     for (auto &i : mt) {       if (i == dis[pos] && fs) {         fs = 0;         continue;       }       mx = i + 1;       break;     }     if (mx) d.insert(mx);     while (d.size() > 3) d.erase(prev(d.end()));     if (d.size() > 2 && *next(d.begin()) + *next(next(d.begin())) >= kk - 1) {       cout <<  No  << endl;       return 0;     }     for (auto &i : v[pos])       if (i != fa && !dfs2(i, pos, d)) return 0;     return 1;   }   int dep[N], f[N];   void dfs(int pos, int fa) {     dep[pos] = dep[fa] + 1;     f[pos] = fa;     for (auto &i : v[pos])       if (i != fa) dfs(i, pos);   }   void dfs3(int pos, int fa, int cur, int dd) {     ans[pos] = cur;     for (auto &i : v[pos])       if (i != fa) dfs3(i, pos, (cur + dd + kk) % kk, dd);   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> kk;     int t1, t2;     for (int i = 1; i < n; i++) {       cin >> t1 >> t2;       v[t1].push_back(t2);       v[t2].push_back(t1);     }     dfs1(1, 0);     if (kk != 2 && !dfs2(1, 0, {})) return 0;     cout <<  Yes  << endl;     if (kk == 2) {       dfs3(1, 0, 0, 1);       for (int i = 1; i <= n; i++) cout << ans[i] + 1 <<    ;       return 0;     }     dfs(1, 0);     t1 = max_element(dep + 1, dep + n + 1) - dep;     dfs(t1, 0);     t2 = max_element(dep + 1, dep + n + 1) - dep;     vector<int> d{t2};     while (f[t2]) d.push_back(t2 = f[t2]);     int mid = (d.size() + 1) / 2 - 1;     dfs3(d[mid], d[mid + 1], mid % kk, -1);     dfs3(d[mid + 1], d[mid], (mid + 1) % kk, 1);     for (int i = 1; i <= n; i++) cout << ans[i] + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   string ans[N];   int len[N];   int dp[N];   string get_ans(const string &add) {     if (add.size() <= 10) {       auto res = add;       reverse(res.begin(), res.end());       return res;     }     string res;     int t = add.size();     for (int i = t - 1; i >= t - 5; i--) {       res += add[i];     }     res +=  ... ;     res += add[1];     res += add[0];     return res;   }   bool check(const string &a) {     int t = a.size();     if (a[t - 3] < a[t - 1])       return true;     else if (a[t - 3] > a[t - 1])       return false;     return dp[t - 1] < 0 || a[dp[t - 1]] < a[t - 1];   }   int main() {     string s;     cin >> s;     string a;     bool pre = 0;     memset(dp, -1, sizeof(dp));     for (int i = s.size() - 1; i >= 0; i--) {       a += s[i];       int t = a.size();       if (t > 1) {         if (a[t - 1] == a[t - 2]) {           dp[t - 1] = dp[t - 2];         } else {           dp[t - 1] = t - 2;         }       }       if (!pre) {         if (t >= 2) {           if (a[t - 1] == a[t - 2] && (i + 1 == s.size() || s[i] == s[i + 1]) &&               (t == 2 || check(a))) {             a.pop_back();             a.pop_back();             pre = 1;           }         }       } else {         pre = 0;       }       len[i] = a.size();       ans[i] = get_ans(a);     }     for (int i = 0; i < s.size(); i++) {       cout << len[i] <<     << ans[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int DIM = 55;   char mat[2][DIM][DIM];   vector<pair<int, int>> lst1, lst2;   void move(int k, int p, int q, vector<pair<int, int>> &lst) {     lst.push_back(make_pair(p, q));     if (mat[k][p][q] ==  U ) {       assert(mat[k][p + 0][q + 0] ==  U  and mat[k][p + 0][q + 1] ==  U  and              mat[k][p + 1][q + 0] ==  D  and mat[k][p + 1][q + 1] ==  D );       mat[k][p + 0][q + 0] =  L ;       mat[k][p + 0][q + 1] =  R ;       mat[k][p + 1][q + 0] =  L ;       mat[k][p + 1][q + 1] =  R ;     } else {       assert(mat[k][p + 0][q + 0] ==  L  and mat[k][p + 0][q + 1] ==  R  and              mat[k][p + 1][q + 0] ==  L  and mat[k][p + 1][q + 1] ==  R );       mat[k][p + 0][q + 0] =  U ;       mat[k][p + 0][q + 1] =  U ;       mat[k][p + 1][q + 0] =  D ;       mat[k][p + 1][q + 1] =  D ;     }   }   void solve(int k, int p, int q, bool whSide, vector<pair<int, int>> &lst) {     if (!whSide) {       if (mat[k][p][q] !=  L ) {         solve(k, p, q + 1, whSide ^ true, lst);         move(k, p, q, lst);       }     } else {       if (mat[k][p][q] !=  U ) {         solve(k, p + 1, q, whSide ^ true, lst);         move(k, p, q, lst);       }     }   }   int main(void) {     int n, m;     cin >> n >> m;     for (int k = 0; k <= 1; ++k)       for (int i = 1; i <= n; ++i) cin >> (mat[k][i] + 1);     for (int i = 1; i <= n; i += (m % 2 == 0 ? 1 : 2)) {       for (int j = 1; j <= m; j += (m % 2 == 0 ? 2 : 1)) {         solve(0, i, j, (m % 2 == 0 ? false : true), lst1);         solve(1, i, j, (m % 2 == 0 ? false : true), lst2);       }     }     cout << lst1.size() + lst2.size() <<   n ;     for (pair<int, int> pr : lst1) cout << pr.first <<     << pr.second <<   n ;     reverse(lst2.begin(), lst2.end());     for (pair<int, int> pr : lst2) cout << pr.first <<     << pr.second <<   n ;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) assert(mat[0][i][j] == mat[1][i][j]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void bug() { cout <<     << endl; }   template <class T>   void bug(T a) {     cout << a <<     ;   }   template <class T>   void bug(T* a, int n) {     for (int i = 0; i < (n); i++) bug(a[i]);   }   int n, m;   vector<pair<pair<int, int>, bool> > e;   int ans = 1000000000;   vector<int> vs;   int fa[111111], size[111111];   int find(int u) {     if (fa[u] == u)       return u;     else       return fa[u] = find(fa[u]);   }   void merge(int u, int v) {     u = find(u);     v = find(v);     if (u == v) return;     if (size[u] > size[v]) {       size[u] += size[v];       fa[v] = u;     } else {       size[v] += size[u];       fa[u] = v;     }   }   vector<int> g[111111];   int vis[111111];   void go(bool b) {     for (int i = 0; i < (n); i++) g[i].clear();     memset(vis, -1, sizeof(vis));     for (int i = 0; i < (n); i++) {       fa[i] = i;       size[i] = 1;     }     for (int i = 0; i < (m); i++) {       int u = e[i].first.first;       int v = e[i].first.second;       bool bb = e[i].second;       if (bb == b) {         merge(u, v);       }     }     for (int i = 0; i < (m); i++) {       int u = e[i].first.first;       int v = e[i].first.second;       bool bb = e[i].second;       if (bb != b) {         u = find(u);         v = find(v);         g[u].push_back(v);         g[v].push_back(u);       }     }     int ret = 0;     vector<int> vv;     for (int i = 0; i < (n); i++)       if (find(i) == i && vis[i] == -1) {         queue<int> q;         q.push(i);         vis[i] = 0;         int zero = size[i], one = 0;         vector<int> zs, os;         zs.push_back(i);         while (q.size() > 0) {           int u = q.front();           q.pop();           for (int v : g[u]) {             if (vis[v] != -1) {               if (vis[v] != (1 - vis[u])) return;             } else {               vis[v] = (1 - vis[u]);               if (vis[v] == 0) {                 zero += size[v];                 zs.push_back(v);               } else {                 one += size[v];                 os.push_back(v);               }               q.push(v);             }           }         }         if (zero < one) {           ret += zero;           for (int i = 0; i < (zs.size()); i++) vv.push_back(zs[i]);         } else {           ret += one;           for (int i = 0; i < (os.size()); i++) vv.push_back(os[i]);         }       }     if (ans > ret) {       ans = ret;       set<int> s;       for (int i = 0; i < (vv.size()); i++) s.insert(vv[i]);       vs.clear();       for (int i = 0; i < (n); i++)         if (s.find(find(i)) != s.end()) vs.push_back(i);     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i < (m); i++) {       int u, v;       char c;       cin >> u >> v >> c;       u--;       v--;       bool b = (c ==  B );       e.push_back(make_pair(make_pair(u, v), b));     }     go(0);     go(1);     if (ans == 1000000000)       cout << -1 << endl;     else {       cout << ans << endl;       for (int i = 0; i < (vs.size()); i++) {         cout << vs[i] + 1 <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool Pfunc(string);   int main() {     string st;     cin >> st;     for (int i = st.size(); i > 0; i--) {       bool b = false;       for (int k = 0; k <= st.size() - i; k++) {         if (Pfunc(st.substr(k, i)) == false) {           cout << i;           b = true;           return 0;         } else {         }       }       if (b) {         break;       }     }     cout << 0;     return 0;   }   bool Pfunc(string x) {     for (int i = 0; i < x.size() / 2; i++) {       if (x[i] != x[x.size() - i - 1]) {         return false;       }     }     return true;   }
#include <bits/stdc++.h>   using namespace std;   int c, bi, ba;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (i % 3 == 0)         c += x;       else if (i % 3 == 1)         bi += x;       else         ba += x;     }     if (c > bi && c > ba)       cout <<   chest ;     else if (bi > c && bi > ba)       cout <<  biceps ;     else       cout <<  back ;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, ans = 0, a, b;   vector<long long> v, sum, sumk;   vector<pair<long long, long long> > maxsumk, maxsum2k;   int main() {     cin >> n >> k;     v.resize(n);     for (int i = 0; i < n; i++) cin >> v[i];     sum.resize(n);     sumk.resize(n);     sum[0] = v[0];     for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + v[i];     sumk[k - 1] = sum[k - 1];     for (int i = k; i < n; i++) sumk[i] = sum[i] - sum[i - k];     maxsumk.resize(n, {0, 0});     maxsumk[k - 1].first = sumk[k - 1];     maxsumk[k - 1].second = k - 1;     for (int i = k; i < n; i++) {       maxsumk[i].first = max(maxsumk[i - 1].first, sumk[i]);       if (max(maxsumk[i - 1].first, sumk[i]) == maxsumk[i - 1].first)         maxsumk[i].second = maxsumk[i - 1].second;       else         maxsumk[i].second = i;     }     maxsum2k.resize(n, {0, 0});     maxsum2k[2 * k - 1].first = sumk[2 * k - 1] + maxsumk[2 * k - 1 - k].first;     maxsum2k[2 * k - 1].second = 2 * k - 1;     for (int i = 2 * k; i < n; i++) {       maxsum2k[i].first =           max(sumk[i] + maxsumk[i - k].first, maxsum2k[i - 1].first);       if (max(sumk[i] + maxsumk[i - k].first, maxsum2k[i - 1].first) ==           maxsum2k[i - 1].first)         maxsum2k[i].second = maxsum2k[i - 1].second;       else         maxsum2k[i].second = i;     }     int v = maxsum2k[n - 1].second;     b = v - k + 2;     a = maxsumk[v - k].second - k + 2;     cout << a <<     << b;   }
#include <bits/stdc++.h>   using namespace std;   long long x, off = 10;   vector<long long> vec[15];   inline long long mul(long long a, long long b) {     bool neg = false;     long long res = 0;     if (b < 0) {       neg = true;       b = -b;     }     while (b) {       if (b & 1) res = (res + a) % off;       a = (a + a) % off;       b >>= 1;     }     return neg ? (off - res) % off : res;   }   inline pair<long long, long long> fib(long long n) {     if (!n) return make_pair(0, 1);     if (n & 1) {       pair<long long, long long> res = fib(n - 1);       return make_pair(res.second, (res.first + res.second) % off);     }     pair<long long, long long> res = fib(n >> 1);     return make_pair(         mul(res.first, 2 * res.second - res.first),         (mul(res.first, res.first) + mul(res.second, res.second)) % off);   }   int main() {     scanf( %lld , &x);     for (int i = 0; i < 60; i++) {       if (fib(i).first == x % off) vec[0].push_back(i);     }     long long step = 60;     for (int i = 0; i < 12; i++) {       off *= 10;       for (long long y : vec[i]) {         for (int j = 0; j < 10; j++) {           if (fib(y + j * step).first == x % off)             vec[i + 1].push_back(y + j * step);         }       }       step *= 10;     }     if (!vec[12].size())       printf( -1 n );     else       printf( %lld n , *min_element(vec[12].begin(), vec[12].end()));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     while (cin >> t) s += t;     vector<string> str;     int pos = 0;     vector<int> a, ans;     while (pos != ((int)(s).size())) {       if (s.substr(pos, 7) ==  <table> ) {         a.push_back(0);         pos += 7;       } else if (s.substr(pos, 4) ==  <tr> )         pos += 4;       else if (s.substr(pos, 4) ==  <td> ) {         ++a.back();         pos += 4;       } else if (s.substr(pos, 5) ==  </td> )         pos += 5;       else if (s.substr(pos, 5) ==  </tr> )         pos += 5;       else if (s.substr(pos, 8) ==  </table> ) {         ans.push_back(a.back());         a.pop_back();         pos += 8;       }     }     sort((ans).begin(), (ans).end());     for (int(i) = 0; (i) < (((int)(ans).size())); ++(i)) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> n >> t;     char pos[50];     cin >> pos;     while (t--) {       for (int i = 0; i < n; i++) {         if (pos[i] ==  B ) {           if ((i + 1) < n && pos[i + 1] ==  G ) {             char temp = pos[i];             pos[i] = pos[i + 1];             pos[i + 1] = temp;             i++;           }         }       }     }     for (int i = 0; i < n; i++) {       cout << pos[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int mod = 1e9 + 7;   long long int inf = 9 * 1e18;   const long long maxn = 2e5 + 100;   long long pow(long long a, long long b) {     if (b < 0) return 0LL;     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a;       a = a * a;       b >>= 1;     }     return ans;   }   long long binpow(long long a, long long b, long long m) {     if (b < 0) return 0LL;     if (a <= 0) return 0LL;     a %= m;     long long ans = 1LL;     while (b) {       if (b & 1) ans = ans * a % m;       a = a * a % m;       b >>= 1;     }     return ans;   }   long long modinv(long long n) { return binpow(n, mod - 2, mod); }   int gcdExtended(int a, int b, int *x, int *y) {     if (a == 0) {       *x = 0, *y = 1;       return b;     }     int x1, y1;     int gcd = gcdExtended(b % a, a, &x1, &y1);     *x = y1 - (b / a) * x1;     *y = x1;     return gcd;   }   void modInverse(int a, int m) {     int x, y;     int g = gcdExtended(a, m, &x, &y);     if (g != 1)       cout <<  Inverse doesn t exist ;     else {       int res = (x % m + m) % m;       cout <<  Modular multiplicative inverse is   << res;     }   }   bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {     return (a.second < b.second);   }   const long long N = 1e7 + 5;   long long sp[N];   void sieve(long long N) {     for (long long i = 1; i < N; i++) sp[i] = i;     for (long long i = 2; i < N; i++) {       if (sp[i] == i) {         for (long long j = i * i; j < N; j += i) {           if (sp[j] == j) sp[j] = i;         }       }     }   }   void solve() {     string s1;     cin >> s1;     long long k;     cin >> k;     long long n = s1.size();     map<char, char> ma;     for (int i = 0; i < k; i++) {       char u, x;       cin >> u >> x;       ma[u] = x;       ma[x] = u;     }     long long c1 = 0, c2 = 0;     long long ans = 0;     long long j = 0;     for (int i = 0; i < n; i++) {       c1 = 1;       c2 = 0;       char a = s1[i];       char b = ma[a];       for (j = i + 1; j < n; j++) {         if (s1[j] == a)           c1++;         else if (s1[j] == b)           c2++;         else           break;       }       ans += min(c1, c2);       i = j - 1;     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   int start, n, m;   bool edge[25][25];   long long memory[25][(1 << 19) + 5];   long long dfs(int u, int mask) {     if (memory[u][mask] != -1) return memory[u][mask];     int visit = 0;     for (int i = 0; i < n; i++) {       if (mask & (1 << i)) visit++;     }     long long result = 0;     if (visit >= 3 && edge[u][start]) result = 1;     for (int v = 0; v <= start; v++) {       if (!edge[u][v]) {         continue;       }       if (mask & (1 << v)) {         continue;       }       result += dfs(v, mask | (1 << v));     }     memory[u][mask] = result;     return result;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d%d , &u, &v);       u--;       v--;       edge[u][v] = edge[v][u] = true;     }     long long answer = 0;     for (start = 0; start < n; start++) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < 1 << n; j++) {           memory[i][j] = -1;         }       }       answer += dfs(start, 1 << start);     }     printf( %lld n , answer / 2);   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = (double)1e-9;   const double PI = (double)acos(-1.0);   int irand(int lo, int hi) {     return (((double)rand()) / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;   }   string toString(long long x) {     stringstream ss;     ss << x;     return ss.str();   }   long long toNumber(string S) {     long long ret;     sscanf(S.c_str(),  %lld , &ret);     return ret;   }   const int INF = (int)2e9;   const long long MOD = (long long)1e9 + 7;   int main() {     long long n, res = 0, two = 1;     scanf( %lld , &n);     while (n > 1) {       res += two * (n / 2);       n = (n / 2) + (n % 2);       two <<= 1;     }     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<char> v;   string s;   int main() {     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (!v.empty() && v.back() == s[i])         v.pop_back();       else         v.push_back(s[i]);     }     cout << (v.empty() ?  Yes  :  No );   }
#include <bits/stdc++.h>   using namespace std;   long long DP[20][4];   void init() {     DP[0][3] = DP[0][2] = DP[0][1] = DP[0][0] = 1;     for (int i = 1; i <= 18; i++) {       DP[i][0] = 1;       for (int j = 1; j <= 3; j++) {         DP[i][j] = 9 * DP[i - 1][j - 1] + DP[i - 1][j];       }     }   }   long long sol(int i, int j, string str) {     if (i == 0) {       if (j >= 0)         return 1;       else         return 0;     }     int d = str[i - 1] -  0 ;     if (d == 0)       return sol(i - 1, j, str);     else if (j == 0)       return 1;     return DP[i - 1][j] + (d - 1) * DP[i - 1][j - 1] + sol(i - 1, j - 1, str);   }   string tostr(long long x) {     string rtn;     while (x) {       rtn += (x % 10 +  0 );       x /= 10;     }     return rtn;   }   string A, B;   long long a, b;   int cas;   int main() {     ios::sync_with_stdio(false);     init();     cin >> cas;     while (cas--) {       cin >> a >> b;       a--;       A = tostr(a);       B = tostr(b);       cout << sol(B.length(), 3, B) - sol(A.length(), 3, A) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K, ma;   int A[1000005];   int dp[10000005];   bool ok(int val) {     int nr = 0;     for (int i = 1; i <= ma; i++) {       dp[i] = 0;       if (val <= i) dp[i] = 1;       if (i % 2)         dp[i] = max(dp[i], dp[i >> 1] + dp[(i + 1) >> 1]);       else         dp[i] = max(dp[i], 2 * dp[i >> 1]);     }     for (int i = 1; i <= N; i++) {       nr += dp[A[i]];       if (nr >= K) return 1;     }     return 0;   }   int main() {     bool notthesamecode = 1;     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     cin >> N >> K;     for (int i = 1; i <= N; i++) {       cin >> A[i];       ma = max(ma, A[i]);     }     int st = 0, dr = (1e7 + 10), mid;     while (st < dr) {       mid = (st + dr + 1) / 2;       if (ok(mid))         st = mid;       else         dr = mid - 1;     }     if (!st)       cout << -1;     else       cout << st;     return 0;   }
#include <bits/stdc++.h>   namespace io {   int F() {     int F = 1, n = 0;     char ch;     while ((ch = getchar()) !=  -  && (ch <  0  || ch >  9 ))       ;     ch ==  -  ? F = 0 : n = ch -  0 ;     while ((ch = getchar()) >=  0  && ch <=  9 ) n = n * 10 + ch -  0 ;     return F ? n : -n;   }   long long G() {     long long F = 1, n = 0;     char ch;     while ((ch = getchar()) !=  -  && (ch <  0  || ch >  9 ))       ;     ch ==  -  ? F = 0 : n = ch -  0 ;     while ((ch = getchar()) >=  0  && ch <=  9 ) n = n * 10 + ch -  0 ;     return F ? n : -n;   }   }  // namespace io   int R(int l, int r) { return (rand() << 15 | rand()) % (r - l + 1) + l; }   int main() {     long long n = io::G(), l = io::G() - 1, r = io::G() - 1, k = io::G();     long long B = l <= r ? r - l + 1 : n - (l - r - 1), S = n - B;     long long ans = -1;     int fl = 1;   start:;     if ((k - B) / n <= 22000000) {       int u = (k - B) / n;       for (register int x = 0; x <= u; ++x) {         long long re = k - B - x * n;         if (x == 0) {           if (re <= B && re >= 0)             if (fl || re) (ans < (S + re) ? ans = (S + re), 1 : 0);         } else {           long long B1 = re % x, S1 = re / x - B1;           if (B1 > B || S1 < 0) continue;           if (S1 <= S) {             if (fl || B1) (ans < (B1 + S1) ? ans = (B1 + S1), 1 : 0);           } else {             long long T = S1 - S;             long long ex = (T + x) / (x + 1);             B1 += ex * x;             S1 -= ex * (x + 1);             if (S1 >= 0 && B1 <= B)               if (fl || B1) (ans < (B1 + S1) ? ans = (B1 + S1), 1 : 0);           }         }       }     } else {       for (register long long S1 = 0; S1 <= S; ++S1)         for (register long long B1 = 0; B1 <= B; ++B1) {           long long y = k - B1 - B;           long long a = S1 + B1 + n;           if (y == 0 && a == 0 || a && y % a == 0 && y / a >= 0)             if (fl || B1) (ans < (S1 + B1) ? ans = (S1 + B1), 1 : 0);         }     }     if (fl) {       k = k + 1;       fl = 0;       goto start;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, flag = 0;     cin >> n >> m;     char c;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> c;         if (c ==  B  || c ==  W  || c ==  G )           continue;         else           flag = 1;       }     }     if (flag == 0)       cout <<  #Black&White  << endl;     else       cout <<  #Color  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int a, b;     double gia[n];     for (int i = 0; i < n; i++) {       cin >> a >> b;       gia[i] = (double)a / b;     }     double kq = gia[0];     for (int i = 1; i < n; i++) {       if (kq > gia[i]) kq = gia[i];     }     cout << setprecision(8) << kq * m;   }
#include <bits/stdc++.h>   using namespace std;   string s;   string p;   int a[2005];   int A[2005];   int ans[2005];   int dp[2005][2005];   int main() {     cin >> s >> p;     memset(a, -1, sizeof(a));     a[0] = 0;     for (int i = 0; i < s.size(); i++) {       for (int j = p.size() - 1; j >= 0; j--) {         if (s[i] == p[j]) a[j + 1] = a[j];       }       a[0] = i + 1;       A[i + 1] = a[p.size()];     }     for (int i = 1; i <= s.size(); i++) {       for (int j = 0; j <= i; j++) {         dp[i][j] = dp[i - 1][j];         if (A[i] >= 0 && j - (i - A[i] - p.size()) >= 0 &&             j - (i - A[i] - p.size()) <= A[i])           dp[i][j] = max(dp[A[i]][j - (i - A[i] - p.size())] + 1, dp[i][j]);       }     }     for (int i = 0; i <= s.size(); i++) ans[i] = dp[s.size()][i];     for (int i = 0; i <= s.size(); i++) cout << ans[i] <<    ;     return 0;   }