#pragma GCC optimize("Ofast") #include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> p >> q; vector x, y; for(ll i=q/p;;i++){ ll z = i*p - q; if(z>=1 && i*q%z==0){ x.emplace_back(i); y.emplace_back(i*q/z); } if(z>=q) break; } int n = x.size(); rep(i,n){ if(x[n-1-i]==y[n-1-i]) continue; x.emplace_back(y[n-1-i]); y.emplace_back(x[n-1-i]); } n = x.size(); cout << n << '\n'; rep(i,n) cout << x[i] << " " << y[i] << '\n'; return 0; }