#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b= m) { ans += n * (n - 1) / 2 * (a / m); a %= m; } if (b >= m) { ans += n * (b / m); b %= m; } unsigned long long y_max = a * n + b; if (y_max < m) break; n = (unsigned long long)(y_max / m); b = (unsigned long long)(y_max % m); std::swap(m, a); } return ans; } long long floor_sum(long long n, long long m, long long a, long long b) { assert(0 <= n && n < (1LL << 32)); assert(1 <= m && m < (1LL << 32)); unsigned long long ans = 0; if (a < 0) { unsigned long long a2 = safe_mod(a, m); ans -= 1ULL * n * (n - 1) / 2 * ((a2 - a) / m); a = a2; } if (b < 0) { unsigned long long b2 = safe_mod(b, m); ans -= 1ULL * n * ((b2 - b) / m); b = b2; } return ans + floor_sum_unsigned(n, m, a, b); } int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int QQ;cin>>QQ; vector A={2,4,8},L={1,2,3},R={1,2,5}; for(int i=0;i<59;i++){ A.push_back(A.back()*2); L.push_back(R.back()+1); if(i%2==0){ R.push_back(R.back()*2); }else{ R.push_back(R.back()*2+1); } } //for(int i=0;i>N; ll ans=0; for(int t=0;t