jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int A[100000];
	ll kotae = 0;
	rep(i, N) {
		int a = getint(), b = getint();
		A[i] = a + b;
		kotae -= b;
	}

	pakuri_sort(N, A);

	for (int i = N - 1; i >= 0; i -= 2) kotae += A[i];

	printf("%lld", kotae);

	Would you please return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T1, class T2, class T3> void sortA_L(int N, T1 a[], T2 b[], T3 c[], void *mem = wmem){
  int i;
  pair<T1, pair<T2, T3> > *arr=(pair<T1, pair<T2, T3> > *) mem;
  for(i=0;i<N;i++){
    arr[i].first = a[i];
    arr[i].second.first = b[i];
    arr[i].second.second = c[i];
  }
  sort(arr, arr+N);
  for(i=0;i<N;i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second.first;
    c[i] = arr[i].second.second;
  }
}
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char memarr[96000000];
int A[100000], B[100000], N, wa[100000];
int main(){
  int i, j, k;
  long long res=0;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
      rd(B[Lj4PdHRW]);
    }
  }
  for(i=0;i<N;i++){
    wa[i] = -(A[i] + B[i]);
  }
  sortA_L(N, wa, A, B);
  for(i=0;i<N;i++){
    if(i%2==0){
      res += A[i];
    }
    else{
      res -= B[i];
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int N;
// int wa[100000], A[100000], B[100000];
// {
//   int i, j, k;
//   ll res = 0;
//   rd(N, (A,B)(N));
//   rep(i,N) wa[i] = -(A[i] + B[i]);
//   sortA(N, wa, A, B);
//   rep(i,N){
//     if(i%2==0) res += A[i]; else res -= B[i];
//   }
//   wt(res);
// }
//  [cpp]
//
// Created by Tetsuya Shiota on 2019-01-27.
//

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;

//ハマったらチェックリスト見ろ!!

class Dish{
public:
    ll diff, a, b;
    bool operator<(const Dish &d)const{
        return diff < d.diff;
    }
};

int main(){
    ll N;
    cin >> N;
    vector<Dish> V(N);
    for(auto& v : V){
        cin >> v.a >> v.b;
        v.diff = v.a+v.b;
    }
    sort(ALL(V));
    reverse(ALL(V));
    ll A = 0, B = 0;
    int a = 0, b = N-1;
    rep(i, N){
        cerr << V[i].a << ' ' << V[i].b <<endl;
        if(i %2){
            B += V[i].b;
        }else{
            A += V[i].a;
        }
        cerr << "now: " << A <<' ' << B <<endl;
    }
    cout << A - B  <<endl;

    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

int bigger(int a, int b) {
    return a >= b ? a : b;
}

int smaller(int a, int b) {
    return a >= b ? b : a;
}


signed main() {
    int N;

    cin >> N;

    vector<int> As(N);
    vector<int> Bs(N);
    REP(i, N) {
        cin >> As.at(i) >> Bs.at(i);
    }

    // (priority, score, ind)
    vector<tuple<int, int, int>> sorted_for_a(N);
    vector<tuple<int, int, int>> sorted_for_b(N);
    REP(i, N) {
        int a = As.at(i);
        int b = Bs.at(i);
        int priority = a + b;
        tuple<int, int, int> ta = make_tuple(priority, a, i);
        tuple<int, int, int> tb = make_tuple(priority, b, i);

        sorted_for_a.pb(ta);
        sorted_for_b.pb(tb);
    }

    sort(REVALL(sorted_for_a));
    sort(REVALL(sorted_for_b));

    queue<tuple<int, int, int>> a_queue;
    for (auto a : sorted_for_a) {
        a_queue.push(a);
    }

    queue<tuple<int, int, int>> b_queue;
    for (auto b : sorted_for_b) {
        b_queue.push(b);
    }

    // それが食べられたことを表す配列
    vector<bool> eaten(N, false);

    // ここから作業開始
    int score_a = 0;
    int score_b = 0;

    tuple<int,int,int> ta;
    tuple<int,int,int> tb;

    while(!a_queue.empty() || !b_queue.empty()) {
        // Aのターン

        // 食べられていない料理が見つかるまで捨てる
        while(true) {
            if (a_queue.empty()) {
                break;
            }

            ta = a_queue.front();
            a_queue.pop();

            int& ind = get<2>(ta);
            if (!eaten.at(ind)) {
                break;
            }
        }

        if (a_queue.empty()) {
            break;
        }

        // Aが食べる処理
        int& a = get<1>(ta);
        int& ind_a = get<2>(ta);
        debug(a);
        debug(ind_a);

        score_a += a;
        debug(ind_a);
        eaten.at(ind_a) = true;

        // 食べられていない料理が見つかるまで捨てる
        while(true) {
            if (b_queue.empty()) {
                break;
            }

            tb = b_queue.front();
            b_queue.pop();

            int& ind = get<2>(tb);
            if (!eaten.at(ind)) {
                break;
            }
        }

        // Bが食べる処理
        // 後攻はもう食べるものが無い可能性がある
        if (b_queue.empty()) {
            break;
        }

        int& b = get<1>(tb);
        int& ind_b = get<2>(tb);
        debug(b);
        debug(ind_b);

        score_b += b;
        debug(ind_b);
        eaten.at(ind_b) = true;
    }

    cout << score_a - score_b << endl;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define plll pair<pair<long,long>,long>
#define val first
#define a first
#define b second
#define dif second
#define isEven(a) (!((a)%2))
int main(){
  long n;
  cin>>n;
  vector<plll> v(n);
  for(long i=0;i<n;++i)cin>>v[i].val.a>>v[i].val.b;
  long takahashi=0,aoki=0;
  for(long i=0;i<n;++i)v[i].dif=/*abs*/(v[i].val.a+v[i].val.b);
  sort(v.begin(),v.end(),[](plll p, plll q){
    return p.dif==q.dif?(p.val.a==q.val.a?(p.val.b>q.val.b):p.val.a>q.val.a):p.dif>q.dif;
  });
  for(int i=0;i<n;++i)cerr<<"["<<i<<"] ("<<v[i].val.a<<","<<v[i].val.b<<"),("<<v[i].dif<<")\n";
  
  for(int i=0;i<n;++i)if(isEven(i))takahashi+=v[i].val.a;else aoki+=v[i].val.b;
  cout<<takahashi-aoki<<endl;
  return 0;
}
//  [c]
#include<stdio.h>

int nextInt();
void sort(int *a, int size);

int N, i;
int A, B, C[100000];
long long int a, b;

int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		A=nextInt();
		B=nextInt();
		C[i] = A + B;
		b += B;
	}
	sort(C, N);
	for(i=0; i<N; i+=2){
		a += C[i];
	}
	printf("%lld\n", a-b);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}

char compare(int *x, int *y){
	return *x > *y;
}

int* med3(int *x, int *y, int *z){
	if(compare(x, y)){
		if (compare(y, z)){return y;}else if(compare(z, x)){return x;}else{return z;}
	} else {
		if (compare(z, y)){return y;}else if(compare(x, z)){return x;}else{return z;}
	}
}

void quickSort(int *left, int *right){
	if(left >= right){return;}
	int *pivot = left+(right-left)/2;
	int *l=left, *r=right;
	int t;
	while(1){
		while (compare(l, pivot)){l++;}
		while (compare(pivot, r)){r--;}
		if(l>=r){break;}
		t=*l; *l=*r; *r=t;
		if(pivot == l){
			pivot = r;
		}else if(pivot == r){
			pivot = l;
		}
		l++; r--;
	}
	quickSort(left, l-1);
	quickSort(r+1, right);
}

void sort(int *a, int size){
	quickSort(a, a+size-1);
}
//  [c]
#include<stdio.h>

int nextInt();
void sort(int *a, int size);

int N, i;
int A, B, C[100000];
long long int a, b;

int main(){
	N=nextInt();
	for(i=N-1; i>=0; --i){
		A=nextInt();
		B=nextInt();
		C[i] = A + B;
		b += B;
	}
	sort(C, N);
	for(i=0; i<N; i+=2){
		a += C[i];
	}
	printf("%lld\n", a-b);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}

char compare(int *x, int *y){
	return *x > *y;
}

void quickSort(int *left, int *right){
	if(left >= right){return;}
	int *pivot = left;
	int *l=left, *r=right;
	int t;
	while(1){
		while (compare(l, pivot)){l++;}
		while (compare(pivot, r)){r--;}
		if(l>=r){break;}
		t=*l; *l=*r; *r=t;
		if(pivot == l){
			pivot = r;
		}else if(pivot == r){
			pivot = l;
		}
		l++; r--;
	}
	quickSort(left, l-1);
	quickSort(r+1, right);
}

void sort(int *a, int size){
	quickSort(a, a+size-1);
}
//  [c]
#include<stdio.h>

int nextInt();
char compare(int x, int y);
int med3(int x, int y, int z);
void quickSort(int *a, int left, int right);
void sort(int *a, int size);

int N, i;
int A[100000], B[100000], C[100000];
long long int a, b;

int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		A[i]=nextInt();
		B[i]=nextInt();
		C[i] = A[i] + B[i];
		b += B[i];
	}
	sort(C, N);
	for(i=0; i<N; i+=2){
		a += C[i];
	}
	printf("%lld\n", a-b);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}

char compare(int x, int y){
	return x > y;
}

int med3(int x, int y, int z){
	if(compare(x, y)){
		if (compare(y, z)){return y;}else if(compare(z, x)){return x;}else{return z;}
	} else {
		if (compare(z, y)){return y;}else if(compare(x, z)){return x;}else{return z;}
	}
}

void quickSort(int *a, int left, int right){
	if(left >= right){return;}
	int pivot = med3(a[left], a[left+(right-left)/2], a[right]);
	int l=left, r=right;
	int t;
	while(1){
		while (compare(a[l], pivot)){l++;}
		while (compare(pivot, a[r])){r--;}
		if(l>=r){break;}
		t=a[l]; a[l]=a[r]; a[r]=t;
		l++; r--;
	}
	quickSort(a, left, l-1);
	quickSort(a, r+1, right);
}

void sort(int *a, int size){
	quickSort(a, 0, size-1);
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
    long int n;
    long long int p;
    long long int q;
} Dishpoint;
int bw(const void *, const void *);
int main()
{
    long int n;
    Dishpoint disht[100010], disha[100010];
    long long int taka = 0, aoki = 0;
    scanf("%ld", &n);
    for (long int i = 0; i < n; i++)
    {
        disht[i].n = i;
        disha[i].n = i;
        scanf("%lld %lld", &(disht[i].p), &(disha[i].p));
        disht[i].q = disha[i].p;
        disha[i].q = disht[i].p;
    }
    qsort(disht, n, sizeof(disht[0]), bw);
    qsort(disha, n, sizeof(disha[0]), bw);
    int used[100010] = {};
    long int takan = 0, aokin = 0;
    for (long int i = 0; i < n; i++)
    {
        if (i % 2) //aoki
        {
            while (used[disha[aokin].n])
            {
                aokin++;
            }
            used[disha[aokin].n] = 1;
            aoki += disha[aokin].p;
        }
        else //taka
        {

            while (used[disht[takan].n])
            {
                takan++;
            }
            used[disht[takan].n] = 1;
            taka += disht[takan].p;
        }
    }
    printf("%lld", taka - aoki);
    return 0;
}
int bw(const void *a, const void *b)
{
    long long int r;
    int ri;
    r = (*(Dishpoint *)a).p - (*(Dishpoint *)b).p + (*(Dishpoint *)a).q - (*(Dishpoint *)b).q;
    ri = (r > 0) ? 1 : -1;
    return -ri;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

struct gotiusa_t {
	int idx;
	int score;
};

int kinnmoza(const void* x, const void* y) {
	struct gotiusa_t a = *(const struct gotiusa_t*)x, b = *(const struct gotiusa_t*)y;
	return a.score > b.score ? -1 : a.score < b.score;
}

int N;
int A[114514], B[114514];

signed char dotti[114514];

struct gotiusa_t takahasikunn[114514], aokikunn[114514];

int main(void) {
	int i, j;
	int64_t kotae = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &A[i], &B[i]) != 2) return 1;
		takahasikunn[i].idx = i;
		takahasikunn[i].score = A[i] + B[i];
		aokikunn[i].idx = i;
		aokikunn[i].score = B[i] + A[i];
	}
	qsort(takahasikunn, N, sizeof(*takahasikunn), kinnmoza);
	qsort(aokikunn, N, sizeof(*aokikunn), kinnmoza);
	for (i = j = 0; i < N || j < N; ) {
		while (i < N && dotti[takahasikunn[i].idx] != 0) i++;
		if (i < N) dotti[takahasikunn[i].idx] = 1;
		while (j < N && dotti[aokikunn[j].idx] != 0) j++;
		if (j < N) dotti[aokikunn[j].idx] = -1;
	}
	for (i = 0; i < N; i++) {
		kotae += dotti[i] > 0 ? A[i] : -B[i];
	}
	printf("%" PRId64 "\n", kotae);
	return 0;
}
//  [c]
#include<stdio.h>
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]>N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  long long n,i,j,s=0,a[100010],b[100010];
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld %lld",&a[R],&b[R]);
    hin(a[R]+b[R]);
  }
  for(i=0;i<n;i++){
    j=hout();
    s+=i%2?-b[j]:a[j];
  }
  printf("%lld\n",s);
  return 0;
}
//  [javascript]
function Main(input) {
  input = input.split("\n");
  N=parseInt(input[0]);
  C = new Array(N);
  var b =0;
  for(var i=0;i<N;i++){
    tmp=input[i+1].split(" ");
    C[i]=parseInt(tmp[0])+parseInt(tmp[1]);
    b-=parseInt(tmp[1]);
  }
  C.sort(function(a,b){return b-a});
  for(var i=0;i<N;i++){
    if(i%2==0){
      b+=C[i];
    }
  }
  var ans=b;

  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input){
  var n = parseInt(input[0]);
  var a = [];
  var b = [];
  for (var i = 0; i< n; i++) {
    var ab = input[i+1].split(' ');
    a.push(parseInt(ab[0]));
    b.push(parseInt(ab[1]));
  }

  var score = [];
  for (var i = 0; i< n; i++) {
    score.push({score: a[i]+b[i], a: a[i], b:b[i]});
  }

  score = score.sort((a,b) => b.score-a.score);
  var as = 0;
  var bs = 0;
  for (var i = 0; i < n; i++){
    if (i%2 === 0) {
      as+= score[i].a;
    } else {
      bs+=score[i].b;
    }
  }
  console.log(as-bs);
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});
//  [javascript]
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++){var i=t.in(),o=t.in();r[n]={A:i,B:o}}r.sort(function(t,e){return e.A+e.B-(t.A+t.B)});for(var s=0,u=0;u<e;u++)u%2==0?s+=r[u].A:s-=r[u].B;console.log(s)}}]);
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.m(n);
  a.sort((a,b)=>-a[0]-a[1]+b[0]+b[1]);
  var ans = 0;
  for(var i = 0; i < n; i++){
    if(i & 1)ans -= a[i][1];
    else ans += a[i][0];
  }
  return ans;
}
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	inputList = input.split("\n");
    inputNum = parseInt(inputList[0], 10);
    menuList = [];
    totalList = [];
    takahashiP = 0;
    aokiP = 0;
    
    for (var i = 1; i <= inputNum; i++) {
        row = inputList[i].split(" ").map(str => parseInt(str, 10));
        menuList[i - 1] =  row;
        totalList[i - 1] = [i - 1,row[0] + row[1]];
    }
    sortList = totalList.sort(function(a,b){return(b[1] - a[1]);})
    for (var i = 0; i < inputNum; i++) {
        targetIndex = sortList[i][0];
        if(i == 0 || i % 2 == 0) {
            takahashiP += menuList[targetIndex][0];
        } else {
            aokiP += menuList[targetIndex][1];
        }        
    }
    console.log(takahashiP - aokiP)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var lines = [];
var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output:process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){
  var n = Number(lines[0]);
  var ab = [];
  var result = 0;

  for(var i=1;i<=n;i++){
    tmp = lines[i].split(" ");
    ab[i] = {
      a: Number(tmp[0]),
      b: Number(tmp[1])
    }
    ab[i].wa = ab[i].a + ab[i].b
  }
  ab.sort(function(a,b){ return b.wa-a.wa; });

  for(var i=0;i<n;i++){
      result += (i%2==0) ? ab[i].a : -ab[i].b
  }

  console.log(result);
//  console.log(a_result-b_result);

});
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

//scanで一行づつ読み込む
var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

//sort
// array := []int{5, 1, 4, 2, 3}
// sort.Sort(sort.IntSlice(array))

func main() {
	// a := make([]int, n)
	// A := strings.Split(nextLine(), " ")

	N := nextLine()
	// n, _ := strconv.Atoi(input[0])

	n, _ := strconv.Atoi(N)

	var ans int64 = 0
	var against int64 = 0
	var arr dish = []dishh{}
	for i := 0; i < n; i++ {
		A := strings.Split(nextLine(), " ")
		curA, _ := strconv.Atoi(A[0])
		curB, _ := strconv.Atoi(A[1])

		// dishCur := []dishh{{curA, curB}}
		arr = append(arr, dishh{curA, curB})

	}

	sort.Sort(arr)

	for i := 0; i < n; i++ {
		if i%2 == 0 {
			ans += int64(arr[i].first)
		} else {
			against += int64(arr[i].second)
		}

		// fmt.Fprintln(wtr, arr[i].first, arr[i].second)
	}

	fmt.Fprintln(wtr, ans-against)
	_ = wtr.Flush()
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return abs(a - b)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

type dishh struct {
	first  int
	second int
}

// 構造体のスライス
type dish []dishh

// 以下インタフェースを満たす

func (p dish) Len() int {
	return len(p)
}

func (p dish) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p dish) Less(i, j int) bool {

	return p[i].first+p[i].second > p[j].first+p[j].second
}
//  [go]
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)
 
func main() {
	N := nextInt()
	A := make([]int, N)
	B := make([]int, N)
	C := make([]pair, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		B[i] = nextInt()
		C[i] = pair{A[i] + B[i], i}
	}
	sort.Sort(pairs(C))
	// log.Println(C)
	t := 0
	a := 0
	for i := 0; i < N; i++ {
		if i%2 == 0 {
			t += A[C[i].b]
		} else {
			a += B[C[i].b]
		}
	}
	fmt.Println(t - a)
}
 
var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var intmax = int(1e9)
 
func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}
 
func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
 
type pair struct {
	a, b int
}
 
type pairs []pair
 
func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
 
func (p pairs) Less(i, j int) bool {
	return p[i].a > p[j].a
}
 
var nextReader func() string
 
func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}
 
func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]Item, n)
	bs := make([]Item, n)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		as[i] = Item{i, a, b}
		bs[i] = Item{i, a, b}
	}

	sort.Sort(SortByA(as))
	sort.Sort(SortByB(bs))

	used := map[int]bool{}
	suma, sumb := 0, 0
	ai, bi := 0, 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			var item Item
			for ai < len(as) {
				item = as[ai]
				ai++
				if !used[item.i] {
					break
				}
			}
			used[item.i] = true
			suma += item.a
		} else {
			var item Item
			for bi < len(bs) {
				item = bs[bi]
				bi++
				if !used[item.i] {
					break
				}
			}
			used[item.i] = true
			sumb += item.b
		}
	}

	fmt.Println(suma - sumb)
}

// Item .
type Item struct {
	i, a, b int
}

// SortByA .
type SortByA []Item

func (s SortByA) Len() int      { return len(s) }
func (s SortByA) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s SortByA) Less(i, j int) bool {
	v1 := s[i].a - s[j].b
	v2 := s[j].a - s[i].b
	if v1 == v2 {
		return s[i].a > s[j].a
	}
	return v1 > v2
}

// SortByB .
type SortByB []Item

func (s SortByB) Len() int      { return len(s) }
func (s SortByB) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s SortByB) Less(i, j int) bool {
	v1 := s[i].b - s[j].a
	v2 := s[j].b - s[i].a
	if v1 == v2 {
		return s[i].b > s[j].b
	}
	return v1 > v2
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Dish struct {
	A     int
	B     int
	Diff  int
	Index int
}

type Dishes []Dish

func (p Dishes) Len() int {
	return len(p)
}

func (p Dishes) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Dishes) Less(i, j int) bool {
	return p[i].A+p[i].B > p[j].A+p[j].B
}

var writer = bufio.NewWriter(os.Stdout)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	b := make([]int, n)
	diff := make([]int, n)
	var dishesA Dishes = make([]Dish, n)
	for i := 0; i < n; i++ {
		var ta, tb int
		fmt.Scan(&ta, &tb)
		a[i] = ta
		b[i] = tb

		diff[i] = a[i] - b[i]
		dishesA[i] = Dish{A: a[i], B: b[i], Diff: diff[i], Index: i}
	}

	sort.Sort(dishesA)

	totalA := 0
	totalB := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			totalA = totalA + dishesA[i].A
		} else {
			totalB = totalB + dishesA[i].B
		}
	}

	fmt.Fprintf(writer, "%d\n", totalA-totalB)
	writer.Flush()
}
//  [ruby]
s=0;gets;$<.map{|e|a,b=e.split.map &:to_i;s-=b;-a-b}.sort.each_slice(2){|x,y|s-=x};p s
//  [ruby]
s=0;gets;$<.map{|t|t.split.map &:to_i}.map{|a,b|s-=b;-a-b}.sort.each_slice(2){|x,|s-=x};p s
//  [ruby]
N = gets.to_i
A,B = N.times.map{gets.split.map(&:to_i)}.transpose
S = N.times.sort_by{|i| A[i] + B[i] }.reverse
pa = pb = 0
S.each_with_index do |s, i|
  if i.even?
    pa += A[s]
  else
    pb += B[s]
  end
end
puts pa - pb
//  [ruby]
N = gets.to_i

list = N.times.collect{
	gets.strip.split(/ /).collect{|n| n.to_i}
}

i = -1
st_a = list.collect{|a, b|
	i += 1
	[a + b, a, i]
}.sort.reverse

i = -1
st_b = list.collect{|a, b|
	i += 1
	[a + b, b, i]
}.sort.reverse

count = N
index_a = 0
index_b = 0
used = {}
sum_a = 0
sum_b = 0
N.times{|i|
	if i % 2 == 0
		while true
			sum, a, n = st_a[index_a]
			unless used[n]
				sum_a += a
				used[n] = true
				break
			end
			index_a += 1
		end
	else
		while true
			sum, b, n = st_b[index_b]
			unless used[n]
				sum_b += b
				used[n] = true
				break
			end
			index_b += 1
		end
	end
}
puts sum_a - sum_b
//  [ruby]
n = gets.to_i
table = []
table2 = []
exhausted = {}

n.times do |index|
  a = gets.chomp.split(" ").map(&:to_i)
  table << [a[0] + a[1], index, a[0]]
  table2 << [a[1] + a[0], index, a[1]]
end

table.sort_by!{|k| [-k[0], -k[2]]}
table2.sort_by!{|k| [-k[0], -k[2]]}
#table2.reverse!
total = 0

table_idx = 0
table2_idx = 0

#p table
#p table2

for i in 0..n-1
  if i.even?
    while exhausted[table[table_idx][1]]
      table_idx += 1
    end
    exhausted[table[table_idx][1]] = 1
    total += table[table_idx][2]
  else
    while exhausted[table2[table2_idx][1]]
      table2_idx += 1
    end
    exhausted[table2[table2_idx][1]] = 1
    total -= table2[table2_idx][2]
  end
  #p [table_idx, table2_idx]
  #p exhausted
end

puts total
//  [ruby]
n = gets.to_i

Pair = Struct.new(:val, :point)

a = Array.new(n).map{Pair.new(0,0)}
b = Array.new(n).map{Pair.new(0,0)}
for i in 0...n
    a[i].val, b[i].val = gets.split.map(&:to_i)
    a[i].point = a[i].val + b[i].val
    b[i].point = a[i].val + b[i].val
end

a = a.sort do |x, y|
    x.point <=> y.point
end

b = b.sort do |x, y|
    x.point <=> y.point
end

a.reverse!
b.reverse!

suma = 0
sumb = 0
for i in 0...n
    if i % 2 == 0
        suma += a[i].val
    else
        sumb += b[i].val
    end
end

puts suma - sumb
//  [rust]
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        p: [(i64, i64); n],
    }
    let mut p = p;
    p.sort_by_key(|p| p.0 + p.1);
    let mut ans = p.iter().fold(0, |s, p| s + p.0);
    for (i, p) in p.iter().rev().enumerate() {
        if i & 1 == 1 {
            ans -= p.0 + p.1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}
//  [rust]
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let ab = i::iv2(n);
    let mut sum: Vec<i64> = ab.iter().map(|k| k.0 + k.1).collect();
    let mut all_sum: i64 = ab.iter().map(|ab| ab.0).sum();
    if n == 1 {
        println!("{}", all_sum);
        return;
    }
    sum.sort();
    sum.reverse();
    let mut i = 1;
    loop {
        all_sum -= sum[i];
        i += 2;
        if i >= n {
            break;
        }
    }
    println!("{}", all_sum);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = Vec::new();
    let mut b: Vec<i64> = Vec::new();
    for _ in 0..n {
        a.push(read::<i64>());
        b.push(read::<i64>());
    }
    let mut d: Vec<(i64, i64, i64)> = vec![(0, 0, 0); n];
    for i in 0..n {
        d[i] = (a[i] + b[i], a[i], b[i]);
    }
    d.sort();
    let mut ans = 0;
    let mut ai = n;
    while ai > 0 {
        ans += d[ai-1].1;
        ai -= 1;
        if ai == 0 {
            break;
        }
        ans -= d[ai-1].2;
        ai -= 1;
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
//  [rust]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };

    let n = sc.read();
    let mut ab = vec![];
    for _ in 0..n {
        let a: i64 = sc.read();
        let b: i64 = sc.read();
        ab.push((a + b, a, b));
    }
    ab.sort();
    ab.reverse();

    let mut first = 0;
    let mut second = 0;
    for i in 0..n {
        let (_, a, b) = ab[i];
        if i % 2 == 0 {
            first += a;
        } else {
            second += b;
        }
    }

    println!("{}", first - second);
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//  [swift]
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let n = Int(readLine()!)!

    // 自分にとってプラスで相手にとってマイナス
    let dishes = (0..<n).map { i -> (Int, Int) in 
        let ab = readWords { Int($0)! }
        let a = ab[0]
        let b = ab[1]
        return (a, b)
    }.sorted { $0.0 + $0.1 > $1.0 + $1.1 }

    var t = 0
    var a = 0
    for (i, dish) in dishes.enumerated() {
        if i % 2 == 0 {
            t += dish.0
        } else {
            a += dish.1
        }
    }

    print(t - a)
}
main()
//  [python]
k, x = map(int, input().split())
m = x-k+1
M = x+k

if m < -1000000:
  m = -1000000
if M > 1000001:
  M = 1000001

print(' '.join(str(i) for i in range(m, M)))
//  [python]
k, x = map(int, input().split())
for i in range(x-k+1, x+k):
    print(i, end=' ')
print()
//  [python]
a,b=map(int,input().split())
x=b-a+1
y=b+a
for i in range(x,y):
  print(i,end=" ")
//  [python]
import math 
K, X = map(int, input().split())
for i in range(-1000000, 1000000):
    if i in range(X - K + 1, X + K):
        print(i)
//  [python]
N = 2000001
k, x = map(int, input().split())
p = [i for i in range(-1000000, 1000001)]
filt = list(filter(lambda j: j >= x - (k-1) and j <= x + (k-1), p))
ans = ' '.join(list(map(str, filt)))
print(ans)
//  [python]
k, x = map(int, input().split())

a = 2000001
n = 1000000

A = [str(i - n) for i in range(a)]

b_min = max(-n, x - k + 1) + n
b_max = min(n, x + k) + n

C = A[b_min : b_max]
C =" ".join(C)
print(C)
//  [java]
//CF template

import java.io.*;
import java.util.*;
 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      
      //begin
      int k = sc.nextInt();
      int x = sc.nextInt();
      int min = Math.max(x - k + 1, -1000000);
      int max = Math.min(x + k - 1, 1000000);
      for(int i = min; i <= max; i++)
        out.print(i + " ");
      //end
      out.close();
   }
 
   public static PrintWriter out;
      
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
      long nextLong() {
          return Long.parseLong(next());
      }
      double nextDouble() {
          return Double.parseDouble(next());
      }
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}
//  [java]

public class Main {

  private static void solve() {
    int k = ni();
    int x = ni();
    for (int i = x - k + 1; i <= x + k - 1; i++) {
      out.print(i + " ");
    }
    out.println();

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}
//  [java]
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    final int MIN = -1000000;
    final int MAX = 1000000;
    Scanner sc = new Scanner(is);
    int k = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int left = Math.max(MIN, x - k + 1);
    int right = Math.min(MAX, x + k - 1);
    pw.println(IntStream.rangeClosed(left, right).mapToObj(String::valueOf)
      .collect(Collectors.joining(" ")));
  }
}
//  [java]
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        System.out.println(IntStream.range(x - k + 1, x + k).mapToObj(Integer::toString).collect(Collectors.joining(" ")));
    }
}
//  [java]
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int k = stdin.nextInt();
        int x = stdin.nextInt();

        Set<Integer> v = new HashSet<>();
        for (int i = 0; i < k; i++) v.add(x + i);
        for (int i = 0; i < k; i++) v.add(x - i);
        String ans = v.stream().sorted().map(i -> i.toString()).collect(Collectors.joining(" "));
        System.out.println(ans);
    }
}
//  [cpp]
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
	int K, X;

	scanf("%d%d", &K, &X);

	for (int i = X - K+1; i <= X+K-1; i++)
		printf("%d ", i);
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

    long K, X;

    cin >> K >> X;

    for(int i= X-K+1; i<=X; ++i)
    {
        cout << i << endl;
    }

    for(int i= X+1; i<=X+K-1; ++i)
    {
        cout << i << endl;
    }

    return 0;

}
//  [cpp]
#include<iostream>
using namespace std;
int main(){
int K,X,a,b,i;
cin >> K >> X;
a=X-K+1;
b=X+K-1;
for(i=a;i<=b;i++){cout <<i <<" ";}


return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int k,x;
int main(){
	cin>>k>>x;
	for(int i=x-k+1;i<x+k;i++) cout<<i<<" ";
	return 0;
}
//  [c]
#include<stdio.h>

int main()
{
	int k,x,i;
 
	scanf("%d%d",&k,&x);
	for(i=0;i<2*k-1;i++){
		if(i<2*k-1)
			printf("%d ",x-k+1+i);
		else if(i==2*k-1)
			printf("%d ",x);
		else
			printf("%d ",x-k+1+i);
	}
	return 0;
}
//  [c]
#include<stdio.h>

int main()
{
    int k, x, i;
    scanf("%d %d", &k, &x);
    for(i=x-k+1; i<=x+k-1; i++)
    {
        printf("%d ", i);
    }
    printf("\n");
    return 0;
}
//  [c]
#include <stdio.h>

int main( void ){
  int K, X, min, max;

  scanf("%d %d", &K, &X);

  K--;
  min = X - K;
  max = X + K;

  if(min < -1000000) min = -1000000;
  if(max > 1000000) max = 1000000;

  for(int i = min; i <= max; i++){
    printf("%d ", i);
  }
  printf("\n");

  return 0;
}
//  [c]
#include <stdio.h>

int main(){
  int K,X;
  scanf("%d %d",&K,&X);
  for(int i=X-K+1;i<=X+K-1;i++){
    printf("%d",i);
    if(i<X+K-1) printf(" ");
  }
  printf("\n");
  return 0;
}
//  [c]
#include<stdio.h>
int main(void){
	int k,x,i;
	scanf("%d%d",&k,&x);
	for(i=x-k+1;i<=x+k-1;i++){
		printf("%d ",i);
	}
	return 0;
}
//  [c]
#include <stdio.h>

int main()
{
    int n,i,j,k,x;
    scanf("%d %d",&k,&x);
    for(i=x-k+1;i<=x+k-1;i++)
    {
        printf("%d",i);
        printf(" ");
    }

    return 0;
}
//  [javascript]
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = input
    .split("\n")[0]
    .split(" ")
    .map(n => Number(n));

  const area = input[0];
  const base = input[1];

  let array = [];

  for (let i = base - (area - 1); i < base + area; i++) {
    array.push(i);
  }

  console.log(array.join(" "));
}
//  [javascript]
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(" ");
var K = input[0]-0;
var center = input[1]-0;
var out = [];
for(var i = 0; i < K * 2 - 1; i++) {
  out.push(center - (K - 1) + i);
}
console.log(out.join(" "));
//  [javascript]
"use strict"

function Main(input) {
    const K = parseInt(input[0], 10);
    const X = parseInt(input[1], 10);

    const min = X - (K - 1);
    const max = X + (K - 1);
    let result = '';

    for (let i = min; i <= max; i++) {
        result += i !== max ? `${i} ` : `${i}`;
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var k = o.a();
  var x = o.a();
  var ans = [];
  for(var i = x-k+1; i < x+k; i++){
    ans.push(i);
  }
  return ans.join(" ");
}
//  [javascript]
'use strict';
function main(input) {
  input = input.split(" ");
  const K = Number(input[0]);
  const X = Number(input[1]);
  let rtn = [];
  for(let i=0; i<K; i++){
  	rtn.push(X + i);
  }
  for(let i=1; i<K; i++){
  	rtn.unshift(X - i);
  }
  console.log(rtn.join(" "));

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const K = parseInt(arr[0]);
    const X = parseInt(arr[1]);
    let sp = "";
    for (let i = X - K + 1; i < X + K; i++) {
        process.stdout.write(sp);
        process.stdout.write(String(i));
        sp = " ";
    }
    console.log();
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var k, x int
	fmt.Scan(&k, &x)
	for i := x - k + 1; i < x+k; i++ {
		fmt.Print(i, " ")
	}
}
//  [go]
package main

import (
	"fmt"
)

// 以下の問題
// https://atcoder.jp/contests/abc137/tasks/abc137_b

func main() {
	var K, X int
	fmt.Scan(&K, &X)

	for i := X - K + 1; i <= X+K-1; i++ {
		fmt.Printf("%d ",i)
	}
}
//  [go]
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var k, x int
	fmt.Scan(&k, &x)

	ans := make([]string, k*2-1)
	for i := 0; i < k*2-1; i++ {
		ans[i] = strconv.Itoa(x - (k - 1) + i)
	}

	fmt.Println(strings.Join(ans, " "))
}
//  [go]
package main

import "fmt"

const (
	MIN = -1000000
	MAX = 1000000
)

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	var k, x int

	fmt.Scan(&k)
	fmt.Scan(&x)

	a := max(x-k+1, MIN)
	b := min(x+k-1, MAX)

	for i := a; i <= b; i++ {
		if i == a {
			fmt.Printf("%d", i)
		} else {
			fmt.Printf(" %d", i)
		}
	}
	fmt.Println()
}
//  [ruby]
K, X = gets.split(' ').map(&:to_i)
l = [X - K + 1, -1000000].max
r = [X + K - 1, 1000000].min
puts (l..r).to_a.join(' ')
//  [ruby]
k, x = gets.split.map(&:to_i)

ans = []
([-1000000, x - k + 1].max..[1000000, x + k -1].min).each do |i|
  ans << i
end

puts ans.join(" ")
//  [ruby]
# k の分 x を含んだ隣り合わせの数字を出力　(負の数も含む)
k,x = gets.split.map(&:to_i)
x2 = x

ans = []
(k).times do
  ans << x
  x -=1
end

(k-1).times do 
  x2 += 1
  ans << x2
end

puts ans.sort.join(' ')