func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxN = 1000000;   long long a1, a2, t0, t1, t2, p1, p2, num, f, T, Tim, tot1, tot2, l, r, ans,       Num;   bool fl;   void check1(long long my) {     num = my / p1;     if (num * a1 >= f) {       if (t1 * f <= T) fl = 1;       return;     }     for (long long i = num; i >= max(0LL, num - maxN); --i) {       long long left_money = my - i * p1, left_time = T - i * tot1,                 left_data = f - i * a1;       if (left_time < 0) return;       if (left_data <= 0) {         fl = 1;         return;       }       if (t2 >= t0) {         Tim = left_data * t0;         if (Tim <= left_time) fl = 1;         return;       }       Num = left_time % tot2 ? left_time / tot2 + 1 : left_time / tot2;       Num = min(num, left_money / p2);       if (Num * a2 >= left_data)         Tim = left_data * t2;       else         Tim = Num * tot2 + (left_data - Num * a2) * t0;       if (Tim <= left_time) {         fl = 1;         return;       }       --Num;       if (Num * a2 >= left_data)         Tim = left_data * t2;       else         Tim = Num * tot2 + (left_data - Num * a2) * t0;       if (Tim <= left_time) {         fl = 1;         return;       }     }   }   void check2(long long my) {     num = my / p2;     if (num * a2 >= f) {       if (t2 * f <= T) fl = 1;       return;     }     for (long long i = num; i >= max(0LL, num - maxN); --i) {       long long left_money = my - i * p2, left_time = T - i * tot2,                 left_data = f - i * a2;       if (left_time < 0) return;       if (left_data <= 0) {         fl = 1;         return;       }       if (t1 >= t0) {         Tim = left_data * t0;         if (Tim <= left_time) fl = 1;         return;       }       Num = left_time % tot1 ? left_time / tot1 + 1 : left_time / tot1;       Num = min(Num, left_money / p1);       if (Num * a1 >= left_data)         Tim = left_data * t1;       else         Tim = Num * tot1 + (left_data - Num * a1) * t0;       if (Tim <= left_time) {         fl = 1;         return;       }       --Num;       if (Num * a1 >= left_data)         Tim = left_data * t1;       else         Tim = Num * tot1 + (left_data - Num * a1) * t0;       if (Tim <= left_time) {         fl = 1;         return;       }     }   }   bool check(long long my) {     fl = 0;     check1(my);     if (fl) return 1;     check2(my);     if (fl) return 1;     return 0;   }   int main() {     scanf( %lld%lld%lld , &f, &T, &t0);     scanf( %lld%lld%lld , &a1, &t1, &p1);     tot1 = a1 * t1;     scanf( %lld%lld%lld , &a2, &t2, &p2);     tot2 = a2 * t2;     if (t0 * f <= T) {       puts( 0 );       return 0;     }     num = T % tot1 ? T / tot1 + 1 : T / tot1;     r = num * p1;     num = T % tot2 ? T / tot2 + 1 : T / tot2;     r = max(r, num * p2);     l = 1;     r *= 2;     ans = -1;     while (l <= r) {       long long mid = (l + r) >> 1;       if (check(mid))         ans = mid, r = mid - 1;       else         l = mid + 1;     }     printf( %lld n , ans);     return 0;   }   