func_code_string: #include <bits/stdc++.h>   using namespace std;   using namespace std::chrono;   long long power(long long x, unsigned long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) {         res = res * x;       }       y = y >> 1;       x = x * x;     }     return res;   }   long long powermod(long long x, unsigned long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) {         res = (res * x) % p;       }       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long min(long long a, long long b) { return a < b ? a : b; }   long long max(long long a, long long b) { return a > b ? a : b; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     long long f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   void snow() {     long long a, b, n;     cin >> a >> b >> n;     while (n--) {       long long l, t, m;       cin >> l >> t >> m;       l--;       long long ans = l;       long long r = 1e9;       long long faci = m * t;       if (t < (a + l * (b))) {         cout << -1 <<   n ;         continue;       }       long long start = a + l * (b);       long long ll = l;       while (l <= r) {         long long mid = (l + r) / 2;         long long height = a + mid * (b);         long long sum =             start * (mid - ll + 1) + b * ((mid - ll) * (mid - ll + 1)) / 2;         if (height <= t && sum <= m * t) {           ans = mid;           l = mid + 1;         } else {           r = mid - 1;         }       }       cout << ans + 1 <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     t = 1;     while (t--) snow();     return 0;   }   