Go: package main

import "fmt"

func main() {
	var n, x int
	fmt.Scanln(&n)
	min, max := 2000, 0
	for ; n > 0; n-- {
		fmt.Scan(&x)
		if x < min {
			min = x
		}
		if x > max {
			max = x
		}
	}
	fmt.Println((max - min + 1) / 2)
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
  int banti[2000];
  int N,num,saisyo=20000,saigo=0;
  cin >> N;
  
  for(int i = 1 ; i < 2001 ; i++){
    banti[i] = 0;
  }
  
  for(int i = 0;i < N ; i++){
    cin >> num;
    banti[num] = 1;
    if(saisyo > num){
      saisyo = num;
    }
    if(saigo < num){
    saigo = num;
    }
  }

  //cout << "saisyo is " << saisyo << endl;
  //cout << "saigo is " << saigo << endl;

  cout << (saigo - (saisyo-1)) / 2   << endl;

}

C++: #include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> x(n);
  for (i64 i = 0; i < n; i++)
    cin >> x[i];
  sort(x.begin(), x.end());
  i64 p = (x[0] + x[n - 1]) / 2;
  cout << max(abs(p - x[0]), abs(p - x[n - 1])) << endl;
  return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;

    int s(1000000),b(0);
    for(int i=0;i<n;i++){
        int x;  cin >> x;

        s = min(s,x);
        b = max(b,x);
    }

    if((b-s)%2==0)
        cout << (b-s)/2 << endl;
    else
        cout << (b-s)/2+1 << endl;

    return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x[1000],i,j,sa,MAX,MIN;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	  MIN=2001;
	for(i=0;i<=2000;i++){
		MAX=-1;
		for(j=0;j<n;j++){
			sa=i-x[j];
			if(sa<0){
				sa=-sa;
			}
			MAX=max(MAX,sa);
		}
		MIN=min(MAX,MIN);
	}
	printf("%d\n",MIN);
	return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> x(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int ans = (int)1e29;
    for (int i = 0; i < 2007; i++) {
        int cur_max = 0;
        for (int j = 0; j < n; j++) {
            cur_max = max(cur_max, abs(x[j] - i));
        }
        ans = min(ans, cur_max);
    }
    cout << ans << '\n';
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <math.h>
#include <limits>

using namespace std;

int main(void) {
	int N, tmp, min = 2000, max = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		if (min > tmp) min = tmp;
		if (max < tmp) max = tmp;
	}
	cout << (max - min + 1) / 2 << endl; //小数点以下切り上げ
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++) cin >> x[i];
  lint ans = INF;
  for(int i = 0; i <= 2000; i++) {
    lint cost = 0;
    for(int j = 0; j < n; j++) cost = max(cost, (lint)abs(i - x[j]));
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	vector<int>A(N);
	int Min = 3000, Max = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		Min = min(Min, A.at(i));
		Max = max(Max, A.at(i));
	}
	if (Min == Max) cout << 0 << endl;
	else {
		int sum = 0, ans = 9999;
		for (int j = Min; j <= Max; j++) {
			sum = 0;
			for (int k = 0; k < N; k++) {
				sum = max(sum, abs(A.at(k) - j));
			}
			ans = min(ans, sum);
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0,h,w;
int main() {
    int n,sum,ans = 1e9,mx=0,mi=1e9; cin >> n; vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
        mx = max(mx, v[i]);
        mi = min(mi, v[i]);
    }
    for(int i = mi;i <=mx;i++) {
        sum = 0;
        rep(j, n) {
            sum = max(abs(i - v[j]),sum);
        }
        ans = min(ans, sum);
    }cout << ans << endl;
}

C++: #include "bits/stdc++.h"

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<int> xs(n);
    for (int i = 0; i < n; i++)
    {
        cin >> xs[i];
    }
    sort(xs.begin(), xs.end());
    cout << (xs.back() - xs.front() + 1) / 2 << endl;
}

int main()
{
    solve();
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int N,maxnum=-1,minnum=2001;
  cin>>N;
  vector<int> x(N);
  for(int i=0;i<N;i++){
    cin>>x[i];
    if(x[i]<minnum) minnum=x[i];
    if(x[i]>maxnum) maxnum=x[i];
  }
  int dis=maxnum-minnum;
  if(dis%2==1) dis+=1;
  cout<<dis/2<<endl;
  return 0;
}