#include //using namespace std; #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define rep(i, j, n) for(int i = int(j); i < int(n); i++) #define REP(i, j, n) for(int i = int(j); i <= int(n); i++) #define per(i, j, n) for(int i = int(j); int(n) <= i; i--) #define ALL(a) (a).begin(),(a).end() #define revALL(a) (a).rbegin(),(a).rend() #define pb push_back #define mp std::make_pair #define mtp std::make_tuple #define ln "\n" using std::endl; using std::cin; using std::cout; #define ll long long using std::vector; using std::string; using std::upper_bound; using std::lower_bound; const ll MOD = int(1e9+7); const ll MAX = 1e6+10; const ll inf = (1ll << 60); //modpow ll modpow(ll X, ll Y, ll mod){ ll ret = 1; while(Y){ if(Y & 1){ ret *= X; ret %= mod; } X *= X; X %= mod; Y >>= 1; } return ret % mod; } //binary_indexed_tree template struct binary_indexed_tree{ int N; vector bit; binary_indexed_tree(int n):N(n){ bit.resize(N+1,0); } T addition(T a, T b){ return a+b; } void add(int x,T a){ x++; for(; x<=N; x+=(x&-x)) bit[x] = addition(bit[x], a); } T sum(int x){ x++; T ret=0; for(; x>0; x-=(x&-x)) ret = addition(ret, bit[x]); return ret; } ll lower_bound(T X){ if(sum(N-1)> T; while(T--){ ll N,M; cin >> N >> M; // 1,2,3,...,M-1,0,1,2,3,...,M-1,0,1,2,3,..., ll ans = 0; if(M <= N){ ans = M/2; } else{ ans = (M-N)*(M-N+1)/2; ans += (2*N-M)/2; } cout << ans << ln; } }