malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll N = 105, inf = 4e18 + 4, mod = 1e9 + 7;   ll n, a2[N], num[N], ans, sum, dp[N][N * N], tmp[N][N * N], fac[N], inv[N];   bool mark[N];   ll pw(ll a, ll b) {     if (b == 0) return 1;     a %= mod;     if (b % 2 == 1) return a * pw(a, (b - 1)) % mod;     return pw((a * a % mod), (b / 2)) % mod;   }   ll choose(ll a, ll b) {     if (b > a) return 0;     if (b == 0 || b == a) return 1;     return fac[a] % mod * inv[b] % mod * inv[a - b] % mod;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     tmp[0][0] = 1;     fac[0] = 1;     for (ll i = 1; i < N - 1; i++) fac[i] = (fac[i - 1] * i) % mod;     inv[N - 2] = pw(fac[N - 2], mod - 2) % mod;     for (ll i = N - 3; i >= 0; i--) {       ll x = i + 1;       inv[i] = (inv[x] * (x)) % mod;     }     cin >> n;     ll y = 0;     for (ll i = 0; i < n; i++) {       cin >> a2[i];       if (!mark[a2[i]]) {         mark[a2[i]] = 1;         y++;       }       num[a2[i]]++;       sum += a2[i];       for (ll j = 0; j < n; j++) {         for (ll k = a2[i]; k <= sum; k++) {           dp[j + 1][k] = tmp[j][k - a2[i]];         }       }       for (ll j = 0; j <= n; j++) {         for (ll k = 0; k <= sum; k++) {           (tmp[j][k] += dp[j][k]) % mod;           dp[j][k] = 0;         }       }     }     if (y < 3) {       cout << n << endl;       return 0;     }     for (ll i = 100; i >= 1; i--) {       for (ll j = num[i]; j > 0; j--) {         if (choose(num[i], j) != tmp[j][j * i]) continue;         ans = max(ans, j);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[100001], n;   int main() {     int i, h;     scanf( %d n , &n);     for (i = 1; i <= n; ++i) scanf( %d n , &a[i]);     h = a[1];     for (i = 2; i <= n; ++i)       if (a[i - 1] < a[i])         h += a[i] - a[i - 1] + 1;       else         h += a[i - 1] - a[i] + 1;     h += n;     printf( %d , h);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[15];   int s[15];   char c[1 << 20];   int need[15];   int digits(int first) { return !first ? 0 : 1 + digits(first / 10); }   int main(void) {     int n;     string str;     cin >> (c + 1) >> str;     n = strlen(c + 1);     for (auto it : str) ++need[it -  0 ];     for (int i = 1; i <= n; ++i) ++cnt[c[i] -  0 ];     for (int nr = 1; nr < n; ++nr)       if (digits(nr) + nr == n) {         for (int i = 0; i <= 9; ++i) s[i] = cnt[i];         int sum = nr;         while (sum) --s[sum % 10], sum /= 10;         int can = 1;         for (int i = 0; i <= 9; ++i)           if (s[i] < need[i]) can = 0;         int prim = 1;         for (int i = 0; i <= 9; ++i) s[i] -= need[i];         for (; prim <= 9; ++prim)           if (s[prim] || (prim == str[0] -  0  && !s[prim])) break;         if (prim == 10) can = 0;         if (can) {           string ans1 =   , ans2 =   ;           int ct = 0;           while (ct + 1 < str.length() && str[ct] == str[ct + 1]) ++ct;           int after = -1;           if (ct + 1 >= str.length() || str[ct] > str[ct + 1])             after = 0;           else             after = 1;           string str1 = str, str2 = str;           if (prim == str[0] -  0 ) {             ans1 += str1;             str1 =   ;           }           for (int i = 0; i <= 9; ++i) cnt[i] -= need[i];           ans2 += prim +  0 ;           int sum = nr;           while (sum) --cnt[sum % 10], sum /= 10;           --cnt[prim];           for (int i = 0; i <= 9; ++i)             while (s[i] > 0) --s[i], ans1 += i +  0 ;           for (int i = 0; i <= 9; ++i) {             if (!str2.empty()) {               if (after && i > str2[0] -  0 )                 ans2 += str2, str2 =   ;               else if (!after && i >= str2[0] -  0 )                 ans2 += str2, str2 =   ;             }             while (cnt[i] > 0) --cnt[i], ans2 += i +  0 ;           }           for (int i = 0; i <= 9; ++i)             if (cnt[i] < 0) ans2 =   ;           if (ans1.length() == ans2.length())             cout << min(ans1, ans2) <<   n ;           else {             if (ans2 ==   )               cout << ans1 <<   n ;             else               cout << ans2 <<   n ;           }           return 0;         }       }     assert(cnt[0] == 1 && cnt[1] == 1 && n == 2);     cout <<  0 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, p;     string s;     bool f = 0;     cin >> n >> p >> s;     s =      + s;     for (int i = n + 1; i > 1; i--) {       for (char j = s[i] + 1; j <  a  + p; j++) {         if (j != s[i - 1] && j != s[i - 2]) {           f = 1;           s[i] = j;           for (int k = i + 1; k <= n + 1; k++) {             char ch =  a ;             for (; ch <  a  + p; ch++) {               if (ch != s[k - 1] && ch != s[k - 2]) break;             }             s[k] = ch;           }         }         if (f) break;       }       if (f) break;     }     if (f) {       for (int i = 2; i < s.size(); i++) cout << s[i];       cout <<   n ;     } else       cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   struct unionfind_t {     vector<int> parent, rank;     unionfind_t(int n) : parent(n), rank(n, 0) {       iota(parent.begin(), parent.end(), 0);     }     int find(int v) {       if (parent[v] == v) return v;       return parent[v] = find(parent[v]);     }     int join(int a, int b) {       a = find(a), b = find(b);       if (a == b) return a;       if (rank[a] > rank[b]) swap(a, b);       parent[a] = b;       if (rank[a] == rank[b]) ++rank[b];       return b;     }   };   int main() {     int n, m;     scanf( %d %d , &n, &m);     struct edge_t {       int a, b, value;     };     vector<edge_t> edges(m);     for (int i = 0; i < m; ++i) {       scanf( %d %d %d , &edges[i].a, &edges[i].b, &edges[i].value);       --edges[i].a, --edges[i].b;     }     unionfind_t uf(n);     vector<int> node_count(n, 1);     vector<int> edge_count(n, 0);     sort(edges.rbegin(), edges.rend(),          [](const edge_t &a, const edge_t &b) { return a.value < b.value; });     int result = 0;     for (const edge_t &ed : edges) {       int a = uf.find(ed.a), b = uf.find(ed.b);       bool should_add;       if (a == b) {         should_add = (edge_count[a] + 1 <= node_count[a]);       } else {         should_add =             (edge_count[a] + 1 + edge_count[b] <= node_count[a] + node_count[b]);       }       if (should_add) {         int id;         if (a != b) {           id = uf.join(a, b);           edge_count[id] = edge_count[a] + edge_count[b];           node_count[id] = node_count[a] + node_count[b];         } else {           id = a;         }         ++edge_count[id];         result += ed.value;       }     }     printf( %d n , result);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct edge {     int v, nxt;   } e[2050];   int ecnt;   int n, m;   int totdep;   int pw[2050];   map<int, int> head;   map<int, bool> has_fa;   map<int, int> sz;   map<int, bool> vis;   void adde(int u, int v) {     e[++ecnt].v = v;     e[ecnt].nxt = head[u];     head[u] = ecnt;   }   int getdep(int pos) { return pos == 0 ? 0 : getdep(pos / 2) + 1; }   int getsz(int pos) {     int curdep = getdep(pos);     int tmp = curdep;     int lc = pos, rc = pos;     while (curdep < totdep) {       curdep++;       lc = lc << 1;       rc = rc << 1 | 1;     }     if (n < lc)       return pw[totdep - tmp - 1];     else if (n > rc)       return pw[totdep - tmp];     else       return pw[totdep - tmp - 1] + n - lc + 1;   }   int us[2050], vs[2050];   int seq[2050], scnt;   long long ans;   const int mod = 1000000007;   void mark(int pos) {     while (pos / 2) {       if (has_fa[pos]) return;       has_fa[pos] = 1;       seq[++scnt] = pos;       pos = pos / 2;     }   }   void dfs_sz(int pos) {     sz[pos] = getsz(pos);     if (has_fa[pos << 1]) dfs_sz(pos << 1), sz[pos] -= getsz(pos << 1);     if (has_fa[pos << 1 | 1])       dfs_sz(pos << 1 | 1), sz[pos] -= getsz(pos << 1 | 1);   }   int cur;   void dfs_solv(int pos) {     vis[pos] = 1;     ans += 1ll * cur * sz[pos] % mod;     ans %= mod;     if (!vis[pos << 1] && has_fa[pos << 1]) dfs_solv(pos << 1);     if (!vis[pos << 1 | 1] && has_fa[pos << 1 | 1]) dfs_solv(pos << 1 | 1);     if (!vis[pos >> 1] && (pos >> 1)) dfs_solv(pos >> 1);     for (int i = head[pos]; i; i = e[i].nxt) {       int v = e[i].v;       if (!vis[v]) dfs_solv(v);     }     vis[pos] = 0;   }   int main() {     scanf( %d%d , &n, &m);     if (m == 0) {       printf( %lld n , n * 1ll * n % mod);       return 0;     }     seq[++scnt] = 1;     totdep = getdep(n);     pw[0] = 1;     for (int i = 1; i <= 1000; ++i) pw[i] = pw[i - 1] * 2 + 1;     for (int i = 1; i <= m; ++i) {       scanf( %d%d , &us[i], &vs[i]);       mark(us[i]);       mark(vs[i]);       adde(us[i], vs[i]);       adde(vs[i], us[i]);     }     dfs_sz(1);     for (int i = 1; i <= scnt; ++i) {       cur = sz[seq[i]];       dfs_solv(seq[i]);     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   #define int long long   int P = 1000000007;   #define F first   #define S second   #define pb push_back   #define mp make_pair      void solve () {    int n, c; cin >> n >> c; int a[n], b[n-1];    int mi=INT_MAX;    for (int i=0; i<n; ++i) {cin >> a[i];}    for (int i=0; i<n-1; ++i) {cin >> b[i];}    int cum=0, day=0;    for (int i=0; i<n; ++i) {     int k = (c-cum+a[i]-1)/a[i]+day;     mi=min(mi,k);     if (i==n-1) {break;}     int x=(b[i]-cum+a[i]-1)/a[i];     day+=x+1;     cum=cum+x*a[i]-b[i];     // cout << i <<     << cum <<     << day <<     << mi <<   n ;    }    cout << mi <<   n ;   }      signed main() {       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);       #ifndef ONLINE_JUDGE        freopen( input.txt ,  r , stdin);        freopen( output.txt ,  w , stdout);    #endif       int t = 1;       cin >> t;       for (int _t=0; _t<t;++_t) {           // cout <<  Case #  << _t+1 <<  :  ;           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   string tostr(long long x) {     stringstream ss;     ss << x;     return ss.str();   }   long long toint(string &s) {     stringstream ss;     ss << s;     long long x;     ss >> x;     return x;   }   int main() {     long long a1, a2, tmp, arr[20], sum, j;     string st1;     scanf( %lld %lld , &a2, &a1);     st1 = tostr(a1);     reverse(st1.begin(), st1.end());     tmp = a2 + toint(st1);     printf( %lld , tmp);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     for (int P = 0; P < T; P++) {       int n, k, d;       cin >> n >> k >> d;       vector<int> ar(n);       map<int, int> s;       int count = 0;       for (int i = 0; i < n; i++) {         int tmp = 0;         cin >> tmp;         if (s.find(tmp) == s.end()) {           s.insert(pair<int, int>(tmp, count));           tmp = count;           count++;         } else {           tmp = s.find(tmp)->second;         }         ar[i] = tmp;       }       vector<int> b(count, 0);       int price = 0;       for (int i = 0; i < d; i++) {         if (b[ar[i]] == 0) {           price++;         }         b[ar[i]]++;       }       int min_price = price;       for (int i = d; i < n; i++) {         if (b[ar[i - d]] == 1) {           price--;         }         b[ar[i - d]]--;         if (b[ar[i]] == 0) {           price++;         }         b[ar[i]]++;         min_price = min(min_price, price);       }       cout << min_price <<   n ;     }     return 0;   }
#include <iostream>   #include <vector>   #include <string>   #include <cstring>   #include <cmath>   #include <climits>   #include <algorithm>   #include <map>   #include <stack>   #include <unordered_map>   #include <set>   #include <unordered_set>   #include <utility>   #include <iomanip>      using namespace std;   typedef long long int ll;   ll pw(ll a, ll b, ll m){    ll ans=1;    while(b>0){     if(b&1) ans=(ans*a)%m;     a=(a*a)%m;     b>>=1;    }    return ans;   }      ll gcd(ll a,ll b){    if(a==0) return b;    return gcd(b % a , a);   }      bool comp(const pair<int,int> &a,const pair<int,int> &b){       return a.second>b.second;   }      ll n,m;   set<ll> has;   vector<ll> input;      void solve(ll l,ll r){    ll sum=0;    for(ll i=l;i<r+1;i++){     sum+=input[i];    }    has.insert(sum);    ll mid=(input[l]+input[r])/2;    ll pos=-1;    for(ll i=l;i<r+1;i++){     if(input[i]<=mid){      pos=i;     }     else{      break;     }    }    if(pos==-1 || pos==r) return;    solve(l,pos);    solve(pos+1,r);   }   void randomevent(){    ll right=n;    while(right>=0 && input[right-1]==right){     right--;    }    double f=(right>0) ? 1:0;    for(ll i=0;i<m;i++){     ll r;cin>>r;     double p;cin>>p;     if(r>=right){      f*=(1-p);     }    }    cout<<fixed<<setprecision(12)<<(1-f)<<endl;   }            int main(){   #ifndef ONLINE_JUDGE       freopen( input.txt , r , stdin);       freopen( output.txt , w , stdout);   #endif           int t;cin>>t;       while(t--){        cin>>n>>m;        for(ll i=0;i<n;i++){         ll p;cin>>p;         input.push_back(p);        }        randomevent();        input.clear();          }   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector )   #pragma GCC target( avx )   int V[100000];   float x;   int main() {     int n, m, l, r, A, T;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , &V[i]);     while (m--) {       scanf( %d%d%d%f , &T, &l, &r, &x);       if (T == 1)         for (int i = l; i <= r; ++i) V[i] -= V[i] > x ? x : 0;       else {         A = 0;         for (int i = l; i <= r; ++i) V[i] == x ? ++A : 0;         printf( %d n , A);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   const long long N = 5e2 + 1;   const long long M = 1e6 + 1;   long long dp[2 * N][2 * N], min1[2 * N][2 * N], ar[2 * N], ar1[M];   bool check[2 * N][2 * N];   vector<long long> occur[N];   long long solve(long long l, long long r) {     if (l > r) {       return 1;     }     if (check[l][r]) {       return dp[l][r];     }     long long y = min1[l][r];     if (occur[y][0] < l || occur[y][occur[y].size() - 1] > r) {       check[l][r] = true;       return 0;     }     if (l == r) {       check[l][r] = true;       dp[l][r] = 1;       return dp[l][r];     }     check[l][r] = true;     long long tich = 1, sum = solve(l, occur[y][0] - 1),               sum1 = solve(occur[y][occur[y].size() - 1] + 1, r), i;     if (l <= occur[y][0] - 1) {       sum *= 2;     }     if (occur[y][occur[y].size() - 1] + 1 <= r) {       sum1 *= 2;     }     for (i = 0; i + 1 < occur[y].size(); i++) {       tich *= solve(occur[y][i] + 1, occur[y][i + 1] - 1);       tich %= mod;     }     for (i = l; i < occur[y][0] - 1; i++) {       sum += solve(l, i) * solve(i + 1, occur[y][0] - 1);       sum %= mod;     }     for (i = occur[y][occur[y].size() - 1] + 1; i < r; i++) {       sum1 += solve(occur[y][occur[y].size() - 1] + 1, i) * solve(i + 1, r);       sum1 %= mod;     }     dp[l][r] = ((sum * sum1) % mod * tich) % mod;     return dp[l][r];   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n, m, i, j, k, l = 0;     cin >> n >> m;     ar1[0] = -1;     for (i = 1; i <= m; i++) {       cin >> ar1[i];       if (ar1[i] != ar1[i - 1]) {         l++;         ar[l] = ar1[i];         if (l > 2 * n + 1) {           cout << 0;           exit(0);         }       }     }     n = l;     for (i = 1; i <= n; i++) {       min1[i][i] = ar[i];       occur[ar[i]].push_back(i);       for (j = i + 1; j <= n; j++) {         min1[i][j] = min(min1[i][j - 1], ar[j]);       }     }     cout << solve(1, n);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 11;   string s;   bool vis[maxn];   int n;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> s;     n = s.length();     vector<pair<int, int> > vec, tmp;     for (int i = 0; i < n; i++) {       if (vec.empty() || s[vec.back().first] != s[i])         vec.emplace_back(i, i);       else {         pair<int, int> p = vec.back();         vec.pop_back();         vec.emplace_back(p.first, i);       }     }     int ans = 0;     while (vec.size() > 1) {       for (int i = 0; i < (int)(vec).size(); i++) {         int sub = 2 - (i == 0 || i == (int)(vec).size() - 1);         if (vec[i].second >= vec[i].first + sub) {           if (tmp.empty() || s[tmp.back().first] != s[vec[i].first]) {             vec[i].second -= sub;             tmp.push_back(vec[i]);           } else {             pair<int, int> p = tmp.back();             tmp.pop_back();             p.second += vec[i].second - vec[i].first + 1 - sub;             tmp.push_back(p);           }         }       }       ans++;       tmp.swap(vec);       tmp.clear();     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int n, m, k;   int main() {     long long ans = 1;     scanf( %d%d%d , &n, &m, &k);     if (k == n) {       int mid = k / 2 + (k & 1);       for (int i = 0; i < mid; ++i) ans = (ans * m) % 1000000007;       printf( %I64d , ans);     } else if (!(k % 2) && k < n)       printf( %d , m);     else if (k == 1 || k > n) {       for (int i = 0; i < n; ++i) ans = (ans * m) % 1000000007;       printf( %I64d , ans);     } else {       printf( %d , m * m);     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1000000007;   const int MM = 998244353;   const long double PI = acos(-1);   long long power(long long b, long long e, long long m) {     if (e == 0) return 1;     if (e & 1) return b * power(b * b % m, e / 2, m) % m;     return power(b * b % m, e / 2, m);   }   long long power(long long b, long long e) {     if (e == 0) return 1;     if (e & 1) return b * power(b * b, e / 2);     return power(b * b, e / 2);   }   template <typename T, typename U>   static inline void amin(T &x, U y) {     if (y < x) x = y;   }   template <typename T, typename U>   static inline void amax(T &x, U y) {     if (x < y) x = y;   }   template <typename T, typename U>   ostream &operator<<(ostream &os, const pair<T, U> &p) {     return os <<  (  << p.first <<  ,  << p.second <<  ) ;   }   const int N = 100005;   vector<int> zFunction(string &s) {     int n = (long long)s.size(), l, r, i;     vector<int> z(n);     z[0] = n;     l = r = 0;     for (i = 1; i < n; ++i) {       if (i <= r) z[i] = min(r - i + 1, z[i - l]);       while (i + z[i] < n && s[z[i]] == s[z[i] + i]) ++z[i];       if (i + z[i] - 1 > r) {         l = i;         r = i + z[i] - 1;       }     }     return z;   }   int _runtimeTerror_() {     string s, t;     cin >> s >> t;     int n = (long long)s.size(), m = (long long)t.size();     string u = t +  #  + s;     vector<int> z = zFunction(u);     vector<int> start(n + 10, false);     for (int i = m + 1; i < n + m + 1; ++i) {       if (z[i] == m) start[i - m - 1] = 1;     }     int last = -1;     long long ans = 0;     vector<long long> suf(n + 10, 0);     vector<long long> val(n + 10, 0);     suf[n + 1] = 0;     val[n + 1] = 0;     for (int i = n - 1; i >= 0; --i) {       suf[i] = suf[i + 1];       val[i] = val[i + 1] + suf[i];       if (start[i] == 1) last = i;       if (last == -1) continue;       long long u = (n - 1 - (last + m - 1) + 1);       val[i] += u;       val[i] %= M;       suf[i] += u;       suf[i] %= M;       ans += u;       ans %= M;       suf[i] += val[last + m];       suf[i] %= M;       val[i] += val[last + m];       val[i] %= M;       ans += val[last + m];       ans %= M;     }     cout << ans <<   n ;     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) _runtimeTerror_();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, cnt[200200], mx = 0, val = 0, arr[200200], pr[200200], a[200200], ans;   vector<int> lst, bd;   void tryBuild(int i) {     vector<int> lPos(400400, -1);     lPos[200000] = 0;     for (int i1 = 1; i1 <= n; i1++) {       if (a[i1] == i) {         arr[i1] = 1;       } else {         if (a[i1] != val) {           arr[i1] = 0;         }       }       pr[i1] = pr[i1 - 1] + arr[i1];       if (lPos[pr[i1] + 200000] == -1) {         lPos[pr[i1] + 200000] = i1;       } else {         ans = max(ans, i1 - lPos[pr[i1] + 200000]);       }     }   }   vector<vector<int> > pose(200200);   int pref[200200];   int num[200200];   void solve() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       cnt[a[i]]++;       if (cnt[a[i]] > mx) {         mx = cnt[a[i]];         val = a[i];       }       pose[a[i]].push_back(i);     }     for (int i = 1; i <= n; i++) {       if (cnt[i] >= (int)sqrt(n)) {         lst.push_back(i);       } else {         bd.push_back(i);       }     }     for (int i = 1; i <= n; i++) {       pref[i] = pref[i - 1];       if (a[i] == val) {         arr[i] = -1;         pref[i]++;         num[pref[i]] = i;       }     }     for (auto i : lst) {       if (i == val) {         continue;       }       tryBuild(i);     }     for (auto ch : bd) {       if (ch == val) {         continue;       }       for (int i = 0; i < pose[ch].size(); i++) {         int x = pose[ch][i];         for (int i1 = pose[ch].size() - 1; i1 >= i; i1--) {           int y = pose[ch][i1];           int cnt = i1 - i + 1 - (pref[y] - pref[x - 1]);           if (cnt < 0) {             continue;           }           int be = pref[x - 1];           int all = pref[y];           for (int i2 = 0; i2 <= cnt; i2++) {             int l = (be < i2 ? 1 : num[be - i2] + 1);             int r = (cnt - i2 + all >= mx ? n : num[cnt - i2 + all + 1] - 1);             ans = max(ans, r - l + 1);           }         }       }     }     cout << ans;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int q;     q = 1;     while (q != 0) {       solve();       --q;     }   }
#include <bits/stdc++.h>   using namespace std;   using cat = long long;   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(10);     int W, N, M;     cin >> W >> N >> M;     vector<int> A(1 << W, 0);     for (int i = 0; i < N; i++) {       int a;       cin >> a;       A[a]++;     }     vector<vector<int> > B(1 << W, vector<int>(1 << W, 0));     for (int i = 0; i < (1 << W); i++)       for (int j = 0; j < (1 << W); j++) B[i][i & j] += A[j];     for (int i = 0; i < M; i++) {       string s;       cin >> s;       int mask[6] = {};       for (int j = 0; j < W; j++) {         if ( O  == s[j]) mask[0] |= 1 << (W - 1 - j);         if ( a  == s[j]) mask[1] |= 1 << (W - 1 - j);         if ( X  == s[j]) mask[2] |= 1 << (W - 1 - j);         if ( x  == s[j]) mask[3] |= 1 << (W - 1 - j);         if ( A  == s[j]) mask[4] |= 1 << (W - 1 - j);         if ( o  == s[j]) mask[5] |= 1 << (W - 1 - j);       }       int vc = mask[1] | mask[3] | mask[5];       int vm = mask[2] | mask[3] | mask[5];       int im = (1 << W) - 1 - mask[4], m = mask[4] | mask[5];       int ans = 0;       for (int j = 0; j < (1 << W); j++)         if ((j & (mask[0] | mask[1])) == mask[1]) {           int mask_cur = (j & m) ^ im;           int val_cur = vc ^ (j & vm);           ans += B[mask_cur][val_cur] * A[j];         }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   long long powmod(long long a, long long b, long long MOD) {     long long ans = 1;     while (b) {       if (b % 2) ans = ans * a % MOD;       a = a * a % MOD;       b /= 2;     }     return ans;   }   const int N = 2e5 + 11;   int main() {     ios::sync_with_stdio(false);     int a;     cin >> a;     int b = a;     int cnt = 0;     while (a % 10) {       cnt++;       a++;     }     int p = 0;     while (b % 10) {       b--;       p++;     }     if (cnt <= p)       cout << a;     else       cout << b;     return 0;   }