func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 7;   const int N = 3e5 + 10;   int a[N];   int b[N];   long long solve(long long x, int n) {     long long tmp = 0;     for (int i = 1; i <= n; i++) {       tmp += a[i] * x / b[i];     }     return tmp + n;   }   int main() {     int n, c;     cin >> n >> c;     for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];     int l = 1, r = inf;     int lans = inf, rans = 0;     while (l <= r) {       int mid = (l + r) / 2;       if (solve(mid, n) >= c)         lans = mid, r = mid - 1;       else         l = mid + 1;     }     l = 1, r = inf;     while (l <= r) {       int mid = (l + r) / 2;       if (solve(mid, n) <= c)         rans = mid, l = mid + 1;       else         r = mid - 1;     }     if (solve(lans, n) != c || solve(rans, n) != c)       cout << 0 << endl;     else       cout << max(0, rans - lans + 1) << endl;     return 0;   }   