malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, root, val, rem;   int main() {     cin >> n;     root = floor((sqrt(1.0 + 8.0 * n) - 1.0) / 2.0);     val = root * (root + 1) / 2;     if (n == val) --root;     val = root * (root + 1) / 2;     rem = n - val;     cout << rem << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 2;   const long long M = 1e6 + 2;   const long long mod = 998244353;   long long ar[N], fact[M], inv[M], cnt[N];   long long binpow(long long x, long long y) {     long long tich = 1;     while (y) {       if (y & 1) {         tich *= x;         tich %= mod;       }       x *= x;       x %= mod;       y >>= 1;     }     return tich;   }   long long C(long long x, long long y) {     return ((fact[y] * inv[y - x]) % mod * inv[x]) % mod;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n, i, j, k, l, ans = 0, sum = 0;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> ar[i];       cnt[ar[i] % n]++;       sum += ar[i];     }     fact[0] = 1;     for (i = 1; i < M - 1; i++) {       fact[i] = (fact[i - 1] * i) % mod;     }     inv[M - 2] = binpow(fact[M - 2], mod - 2);     for (i = M - 2; i > 0; i--) {       inv[i - 1] = (inv[i] * i) % mod;     }     sort(ar + 1, ar + 1 + n);     long long pos = 0;     for (i = 1; i < n; i++) {       if (ar[i + 1] < i) {         pos = i;         break;       }     }     if (pos) {       j = 1;       for (i = 0; i < pos; i++) {         while (ar[j] < i) {           j++;         }         ans += C(n - 1, i - (j - 1) + n - 1);         if (ans >= mod) {           ans -= mod;         }       }       cout << ans;     } else {       for (i = 1; i <= n; i++) {         sum -= ar[i] % n;       }       sum /= n;       for (i = 1; i <= n; i++) {         sum = sum + cnt[n - i] - 1;         if (sum >= 0) {           ans += C(n - 1, sum + n - 1);           if (ans >= mod) {             ans -= mod;           }         }       }       cout << ans;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<pair<int, int>> v;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       v.push_back(make_pair(a, b));     }     int x1 = v[0].first;     int y1 = v[0].second;     vector<int> p1, p2;     for (int i = 1; i < m; i++) {       int a = v[i].first;       int b = v[i].second;       if (x1 != a && x1 != b) {         p1.push_back(i);       }       if (y1 != a && y1 != b) {         p2.push_back(i);       }     }     if (p1.size() == 0 || p2.size() == 0) {       cout <<  YES  << endl;       return 0;     }     x1 = v[p1[0]].first;     y1 = v[p1[0]].second;     int c1 = 0, c2 = 0, c3 = 0, c4 = 0;     for (int i = 1; i < p1.size(); i++) {       int a = v[p1[i]].first;       int b = v[p1[i]].second;       if (x1 != a && x1 != b) {         c1++;       }       if (y1 != a && y1 != b) {         c2++;       }     }     x1 = v[p2[0]].first;     y1 = v[p2[0]].second;     for (int i = 1; i < p2.size(); i++) {       int a = v[p2[i]].first;       int b = v[p2[i]].second;       if (x1 != a && x1 != b) {         c3++;       }       if (y1 != a && y1 != b) {         c4++;       }     }     if (c1 == 0 || c2 == 0) {       cout <<  YES  << endl;     } else if (c3 == 0 || c4 == 0) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool chmax(T &a, T b) {     return a < b ? (a = b, 1) : 0;   }   template <class T>   inline bool chmin(T &a, T b) {     return a > b ? (a = b, 1) : 0;   }   int main() {     int n, m;     cin >> n >> m;     map<int, vector<int>> obs;     int left = n;     while (m--) {       int x, y;       cin >> x >> y;       if (x == 1)         chmin(left, y - 1);       else         obs[x].emplace_back(y);     }     vector<pair<int, int>> segs = {{1, left}};     int prv = 1;     for (auto &p : obs) {       auto &v = p.second;       sort(begin(v), end(v));       if (p.first != prv + 1) {         segs.assign(1, {segs.begin()->first, n});       }       vector<pair<int, int>> segs2;       auto it = segs.begin();       int p_v = 0, sz_v = v.size();       int lst = -1;       while (it != segs.end() && p_v < sz_v) {         chmax(it->first, lst);         if (it->first > it->second) {           it++;           continue;         }         if (v[p_v] <= it->first) {           it->first += v[p_v++] == it->first;           continue;         }         segs2.emplace_back(it->first, v[p_v] - 1);         lst = v[p_v++] + 1;       }       if (p_v == sz_v) {         while (it != segs.end()) {           chmax(it->first, lst);           if (it->first <= it->second) break;           it++;         }         if (it != segs.end()) {           segs2.emplace_back(it->first, n);         }       }       if ((segs = segs2).empty()) return !(cout << -1 << endl);       prv = p.first;     }     if (prv < n) {       segs.assign(1, {segs.begin()->first, n});     }     cout << (segs.rbegin()->second == n ? (n - 1) * 2 : -1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       long long n, k;       cin >> n >> k;       if (n > k)         cout << k << endl;       else {         int ne = (k - 1) / (n - 1);         cout << k + ne << endl;       }     }   }
#include <bits/stdc++.h>   int mat[110][110];   int main() {     int n, k, i, j;     scanf( %d %d , &n, &k);     if (n * n < k) {       printf( -1 n );       return 0;     }     for (i = 0; i < n; i++) {       for (j = i; j < n; j++) {         if (i == j) {           if (k > 0) {             k--;             mat[i][j] = 1;           } else             break;         } else {           if (k >= 2) {             mat[i][j] = 1;             mat[j][i] = 1;             k = k - 2;           } else if (k == 0)             break;         }       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) {         printf( %d  , mat[i][j]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   int n, k;   bool visited[101][101][1010];   double ar[101], dp[101][101][1010];   double F(int i, int j, int k) {     if (i > j) return 1.0 - F(j, i, k);     if (k == 0) return 1.0;     if (visited[i][j][k]) return dp[i][j][k];     int a, b, c, d, l;     double x, y, p = 1.0 / ((n * (n + 1)) >> 1), res = 0.0;     for (a = 0; a < n; a++) {       for (b = a; b < n; b++) {         c = i, d = j;         if (c >= a && c <= b) c = b - (c - a);         if (d >= a && d <= b) d = b - (d - a);         res += (p * F(c, d, k - 1));       }     }     visited[i][j][k] = true;     return (dp[i][j][k] = res);   }   int main() {     int i, j, l;     while (scanf( %d %d , &n, &k) != EOF) {       if (k > 1000) k = 1000;       for (i = 0; i < n; i++) scanf( %d , &ar[i]);       memset(visited, 0, sizeof(visited));       double res = 0.0;       for (i = 0; i < n; i++) {         for (j = i + 1; j < n; j++) {           if (ar[i] < ar[j])             res += (1.0 - F(i, j, k));           else             res += F(i, j, k);         }       }       printf( %0.12f n , res + 1e-15);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const double EPS = 1e-9;   const double PI = acos(-1.);   const long long LL_INF = 1e17 + 16;   const int INF = 1e9 + 10;   const long long MOD = 1e9 + 7;   const int MAXN = 20;   set<long long> goods;   long long f[MAXN];   void gen() {     for (int i = (1); i <= (int)(10); i++) {       for (int j = (0); j < (int)(1 << i); j++) {         long long v = 0;         long long st10 = 1;         for (int k = (0); k < (int)(i); k++) {           if (j & (1 << k)) {             v += 7 * st10;           } else {             v += 4 * st10;           }           st10 *= 10;         }         goods.insert(v);       }     }   }   int per[MAXN];   int used[MAXN];   void solve() {     gen();     long long n, k;     cin >> n >> k;     f[0] = 1;     int m;     for (m = 1;; m++) {       f[m] = f[m - 1] * m;       if (f[m] >= k) {         break;       }     }     if (m > n) {       printf( -1 n );       return;     }     int ans = 0;     int offset = n - m;     for (__typeof((goods).begin()) it = (goods).begin(); it != (goods).end();          it++) {       if ((*it) <= offset) {         ans++;       }     }     k--;     int top = 1;     for (int i = m; i >= 1; i--) {       int v = k / f[i - 1] + 1;       int cnt = 0;       for (int j = (1); j <= (int)(m); j++) {         if (!used[j]) {           cnt++;           if (cnt == v) {             per[top++] = j;             used[j] = 1;             break;           }         }       }       k %= f[i - 1];     }     for (int i = (1); i <= (int)(m); i++) {       if (goods.count(i + offset) && goods.count(per[i] + offset)) {         ans++;       }     }     cout << ans << endl;   }   int main() {     int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   void dfs(set<int> &temp, list<int> adj[], vector<bool> &v, int s, int &t1,            int &t2, vector<int> b, vector<int> w) {     v[s] = true;     list<int>::iterator it;     for (it = adj[s].begin(); it != adj[s].end(); it++) {       if (!v[*it]) {         temp.insert(*it);         t1 += b[*it];         t2 += w[*it];         dfs(temp, adj, v, *it, t1, t2, b, w);       }     }   }   list<int> adj[1001];   int main() {     int n, m, weight;     cin >> n >> m >> weight;     vector<int> b(n + 1);     vector<int> w(n + 1);     for (int i = 1; i <= n; i++) cin >> w[i];     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     vector<bool> v(n + 1, false);     vector<set<int> > arr;     vector<int> tw;     vector<int> tb;     for (int i = 1; i <= n; i++) {       if (!v[i]) {         set<int> temp;         temp.insert(i);         int t1 = b[i], t2 = w[i];         dfs(temp, adj, v, i, t1, t2, b, w);         arr.push_back(temp);         tb.push_back(t1);         tw.push_back(t2);       }     }     vector<vector<int> > dp(arr.size() + 1, vector<int>(weight + 1, 0));     for (int i = 1; i <= arr.size(); i++) {       for (int j = 1; j <= weight; j++) {         int max = 0;         if (dp[i - 1][j] > max) max = dp[i - 1][j];         if (j - tw[i - 1] >= 0)           if (dp[i - 1][j - tw[i - 1]] + tb[i - 1] > max)             max = dp[i - 1][j - tw[i - 1]] + tb[i - 1];         set<int>::iterator it;         for (it = arr[i - 1].begin(); it != arr[i - 1].end(); it++) {           if (j - w[*it] >= 0)             if (dp[i - 1][j - w[*it]] + b[*it] > max)               max = dp[i - 1][j - w[*it]] + b[*it];         }         dp[i][j] = max;       }     }     int max = 0;     for (int i = 0; i <= weight; i++)       if (dp[arr.size()][i] > max) max = dp[arr.size()][i];     cout << max;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, ans, x, i, j, s;   double a[100], b[100];   map<double, pair<long long, long long> > mp;   map<double, pair<long long, long long> >::iterator it, it2;   long long num(long long x) {     s = 0;     while (x) {       s++;       x -= x & -x;     }     return s;   }   int main() {     cin >> n >> m;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < m; i++) cin >> b[i];     for (i = 0; i < n; i++)       for (j = 0; j < m; j++) {         mp[(a[i] + b[j]) / 2.0].first |= (1LL << i);         mp[(a[i] + b[j]) / 2.0].second |= (1LL << j);       }     for (it = mp.begin(); it != mp.end(); it++)       for (it2 = it; it2 != mp.end(); it2++) {         x = num((*it).second.first | (*it2).second.first) +             num((*it).second.second | (*it2).second.second);         if (x > ans) ans = x;       }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr long long INF = numeric_limits<long long>::max() / 4;   constexpr long long n_max = 2e5 + 10;   template <typename A, typename B>   string to_string(pair<A, B> p);   string to_string(const string &s) { return     + s +    ; }   string to_string(const char c) { return to_string((string)&c); }   string to_string(bool b) { return (b ?  true  :  false ); }   template <size_t N>   string to_string(bitset<N> v) {     string res =   ;     for (size_t i = 0; i < N; i++) res += static_cast<char>( 0  + v[i]);     return res;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) res +=  ,  ;       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     debug_out(T...);   }   template <class T>   bool chmax(T &a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <class T>   bool chmin(T &a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   signed main() {     cin.tie(nullptr);     ios::sync_with_stdio(false);     long long t;     cin >> t;     for (long long _ = 0; _ < (long long)(t); _++) {       long long n;       cin >> n;       vector<long long> a(n);       for (long long i = 0; i < (long long)(n); i++) cin >> a[i];       vector<long long> dp(n + 1);       for (long long i = 1; i < (long long)(n) + 1; i++) {         dp[i]++;         for (long long j = i * 2; j <= n; j += i) {           if (a[j - 1] > a[i - 1]) chmax(dp[j], dp[i]);         }       }       long long ans = 0;       for (long long i = 0; i < (long long)(n + 1); i++) chmax(ans, dp[i]);       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int test = 1;     cin >> test;     while (test--) {       long long int n, m;       cin >> n >> m;       long long int sum1 = 0, sum2 = 0;       long long int a[n], b[n], mina[n], mi = 0;       for (int i = 0; i < n; i++) {         cin >> a[i] >> b[i];         sum1 += a[i];         sum2 += b[i];         mina[i] = max(0LL, m - b[i]);         mi += mina[i];         a[i] = min(a[i], m);       }       long long int ans = sum1 - sum2 + (n * m);       long long int x = ans - 2LL * mi;       for (int i = 0; i < n; i++) {         if (x <= 0) break;         long long int temp = min(2LL * (a[i] - mina[i]), x);         temp /= 2;         mina[i] += temp;         x -= 2LL * temp;       }       cout << abs(x) <<   n ;       for (int i = 0; i < n; i++) cout << mina[i] <<     << m - mina[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   bool compare(int a, int b) { return a > b; }   int main() {     int t, p, f, cnts, cntw, s, w;     scanf( %d , &t);     while (t--) {       scanf( %d%d , &p, &f);       scanf( %d%d , &cnts, &cntw);       scanf( %d%d , &s, &w);       if (s > w) {         int temp = s;         s = w;         w = temp;         temp = cnts;         cnts = cntw;         cntw = temp;       }       int mx = min(cnts, p / s);       int ans = 0;       for (int s1 = 0; s1 <= mx; s1++) {         int w1 = min(cntw, (p - s1 * s) / w);         int s2 = min(cnts - s1, f / s);         int w2 = min(cntw - w1, (f - s2 * s) / w);         ans = max(ans, s1 + s2 + w1 + w2);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 10;   long long n, k;   int main() {     scanf( %I64d%I64d , &n, &k);     long long x;     x = sqrt(9 + 8 * (n + k)) - 3;     x /= 2;     printf( %I64d n , n - x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   const int N = 3e3;   long long dmod(long long x) { return x % MOD; }   int n, k;   int h[N + 5];   long long memo[N + 5][2 * N + 5];   long long dp(int idx, int gap) {     if (idx > n) {       if (gap > 0) return 1;       return 0;     }     long long &ret = memo[idx][gap + N];     if (ret != -1) return ret;     ret = 0ll;     if (h[idx] == h[idx % n + 1]) {       ret = dmod((long long)k * dp(idx + 1, gap));     } else {       ret = dp(idx + 1, gap + 1);       ret = dmod(ret + dp(idx + 1, gap - 1));       ret = dmod(ret + dmod((long long)(k - 2) * dp(idx + 1, gap)));     }     return ret;   }   int main() {     memset(memo, -1, sizeof(memo));     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &h[i]);     }     printf( %lld n , dp(1, 0));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, m = 0, sum = 0;     cin >> n >> x;     int *arr = new int[n];     for (long long i = 0; i < n; i++) cin >> arr[i], sum += arr[i];     if (sum > 0)       while (sum > 0) {         sum -= x;         m++;       }     else       while (sum < 0) {         sum += x;         m++;       }     cout << m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int brute(int s, int x) {     int ans = 0;     for (int i = 1; i <= s; ++i)       for (int j = 1; j <= s; ++j)         if (i + j == s && (i ^ j) == x) ++ans;     return ans;   }   long long ways0(long long s, long long x) {     if (s == x) return 2;     return 0;   }   long long solve(long long s, long long x) {     long long dp[60][2] = {};     if (s % 2 != x % 2) {       return 0;     }     if (x & (1LL << 0)) {       dp[0][0] = 2;     } else {       dp[0][0] = 1;       dp[0][1] = 1;     }     for (int i = 1; i < 60; ++i) {       if (x & (1LL << i)) {         if (s & (1LL << i)) {           dp[i][0] += 2 * dp[i - 1][0];         } else {           dp[i][1] += 2 * dp[i - 1][1];         }       } else {         if (s & (1LL << i)) {           dp[i][0] += dp[i - 1][1];           dp[i][1] += dp[i - 1][1];         } else {           dp[i][0] += dp[i - 1][0];           dp[i][1] += dp[i - 1][0];         }       }     }     return dp[59][0] - ways0(s, x);   }   int main() {     long long s, x;     cin >> s >> x;     cout << solve(s, x) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void dmin(T& x, T y) {     y < x ? x = y : 0;   }   template <class T>   inline void dmax(T& x, T y) {     y > x ? x = y : 0;   }   template <class T>   inline void dmin(T& x, vector<T> y) {     for (auto t : y) t < x ? x = t : 0;   }   template <class T>   inline void dmax(T& x, vector<T> y) {     for (auto t : y) t > x ? x = t : 0;   }   const int N = 5 + 1e6;   const long long INF = -2e18;   int n, k;   long long gk(int x, long long a[], int i, long long f) {     return a[x] + (i - x) / 3 * f;   }   bool cmp(int x, int y, long long a[], int i, long long f) {     return gk(x, a, i, f) > gk(y, a, i, f);   }   void opera(long long a[], int n, long long f, int k) {     static long long b[N];     static long long q[3][N], left[3], right[3];     for (int i = 0; i < 3; ++i) left[i] = 1, right[i] = 0;     for (int i = 0; i < n; ++i) b[i] = INF;     for (int i = 0; i < n; ++i) {       int t = i % 3;       while (left[t] <= right[t] && q[t][left[t]] < i - 3 * k) ++left[t];       while (left[t] <= right[t] && cmp(i, q[t][right[t]], a, i, f)) --right[t];       q[t][++right[t]] = i;       b[i] = gk(q[t][left[t]], a, i, f);     }     for (int i = 0; i < n; ++i) a[i] = b[i];   }   void opera2(long long a[], int n, long long f, int k) {     static long long f1[N], f2[N];     for (int i = 0; i < n; ++i) {       f1[i] = f2[i] = a[i];       for (int j = 1; j < 10 && i - j >= 0; ++j) f2[i] = max(f2[i], a[i - j]);     }     opera(f1, n, f, 3 * k);     opera(f2, n, f, 3 * (k - 1));     for (int i = 0; i < n; ++i) a[i] = max(f1[i], f2[i]);   }   long long a[N], b[N];   int main() {     int k;     scanf( %d , &k);     long long f[6];     for (int i = 0; i < 6; ++i) scanf( %lld , &f[i]);     a[0] = 0;     n = 1;     for (int i = 5; i >= 0; --i) {       for (int j = 0; j < 10 * n; ++j) b[j] = INF;       for (int j = 0; j < n; ++j) b[j * 10] = a[j];       n *= 10;       opera2(b, n, f[i], k);       for (int j = 0; j < n; ++j) a[j] = b[j];     }     int q;     scanf( %d , &q);     while (q--) {       int x;       scanf( %d , &x);       printf( %lld n , a[x]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       sort(arr, arr + n);       bool f = true;       for (int j = 1; j < n; j++) {         int diff = abs(arr[j] - arr[j - 1]);         if (diff > 1) {           f = false;         }       }       if (f) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a, b, k, t, suan, d[1100002], f[1110000];   int main() {     cin >> a >> b >> k >> t;     int shu = k * 2 * t;     d[shu] = 1;     int y = d[0];     for (int i = 1; i <= t * 2; i++) {       f[0] = y;       for (int j = 1; j <= shu * 2 + k; j++) {         f[j] = (f[j - 1] + d[j]) % 1000000007;       }       for (int j = 0; j <= k; j++) {         d[j] = f[j + k];       }       for (int j = k + 1; j <= shu * 2; j++) {         d[j] = (f[j + k] - f[j - 1 - k] + 1000000007) % 1000000007;       }     }     for (int i = shu - a + b + 1; i <= shu * 2; i++) {       suan = (suan + d[i]) % 1000000007;     }     cout << suan;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int modulo = 1000000007;   const int limite = 1000001;   long long int elev[limite];   int ocupado[limite];   int main() {     ios_base::sync_with_stdio(false);     int n, m, k;     cin >> n >> m >> k;     elev[0] = 1;     for (int i = 1; i < limite; i++) elev[i] = (elev[i - 1] * 2) % modulo;     int ini = 0;     int fin = n + 1;     int inf = k + 2;     int sup = n;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       if (v == u + 1)         ;       else if (v == u + k + 1) {         ocupado[v] = 1;         ini = max(ini, u);         fin = min(fin, v);         inf = max(inf, u + 1);         sup = min(sup, v + k);       } else {         cout << 0 << endl;         exit(0);       }     }     if (fin <= ini) {       cout << 0 << endl;       exit(0);     }     int libres = 0;     long long int maneras = 1;     for (int i = inf; i <= sup; i++) {       if (not ocupado[i]) {         maneras = (maneras + elev[libres]) % modulo;         libres++;       }       if (i - k >= inf and not ocupado[i - k]) libres--;     }     cout << maneras << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool v[6];   int a[100009][6], maxx = -1, t;   long long m = 1e9 + 7;   struct pi {     long long ah[60][60];   };   pi multi(pi x, pi y) {     pi z;     for (int i = 1; i <= t; i++) {       for (int j = 1; j <= t; j++) {         z.ah[i][j] = 0;         for (int k = 1; k <= t; k++)           z.ah[i][j] = (z.ah[i][j] % m + x.ah[i][k] % m * y.ah[k][j] % m) % m;         z.ah[i][j] %= m;       }     }     return z;   }   pi quimul(pi x, long long int n) {     pi an;     for (int i = 1; i <= t; i++) an.ah[i][i] = 1;     for (; n; n >>= 1) {       if (n & 1) an = multi(an, x);       x = multi(x, x);     }     return an;   }   int main() {     long long n;     int x, v, p[600], zh[90][90];     char c =  a , u;     for (int i = 1; i <= 52; i++)       for (int j = 1; j <= 52; j++) zh[i][j] = 1;     for (int i = 1; i <= 26; i++) p[(int)c + i - 1] = i;     c =  A ;     for (int i = 27; i <= 52; i++) p[(int)c + i - 27] = i;     cin >> n >> t >> v;     for (int i = 0; i < v; i++) {       scanf(  %c %c , &c, &u);       zh[p[(int)c]][p[(int)u]] = 0;     }     pi ans;     for (int i = 1; i <= t; i++)       for (int j = 1; j <= t; j++) ans.ah[i][j] = zh[i][j];     ans = quimul(ans, n - 1);     long long int pp = 0;     for (int i = 1; i <= t; i++)       for (int j = 1; j <= t; j++) pp = (pp + ans.ah[i][j]) % m;     cout << (pp + m) % m << endl;   }