Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>

using namespace std; 

namespace fastinput
{
	/** Interface */

	inline long long readChar();
	template <class T = long long> inline T readInt();
	template <class T> inline void writeInt(T x, char end = 0);
	inline void writeChar(long long x);
	inline void writeWord(const char *s);

	/** Read */

	static const long long buf_size = 16384;
	char buf[buf_size];
	long long len = 0, pos = 0;

	inline long long getChar() {
		if (pos == len)
			pos = 0, len = fread(buf, 1, buf_size, stdin);
		if (pos == len)
			return -1;
		return buf[pos++];
	}

	inline long long readChar() {
		long long c = getChar();
		while (c <= 32)
			c = getChar();
		return c;
	}

	template <class T>
	inline T readInt() {
		long long s = 1, c = readChar();
		T x = 0;
		if (c == '-')
			s = -1, c = getChar();
		while ('0' <= c && c <= '9')
			x = x * 10 + c - '0', c = getChar();
		return s == 1 ? x : -x;
	}

	/** Write */

	static long long write_pos = 0;
	static char write_buf[buf_size];

	inline void writeChar(long long x) {
		if (write_pos == buf_size)
			fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
		write_buf[write_pos++] = x;
	}

	inline string readWord()
	{
		string tmp;
		tmp.push_back(readChar());
		char c;
		while ((c = getChar()) > 32)
			tmp.push_back(c);
		--pos;
		return tmp;
	}

	template <class T>
	inline void writeInt(T x, char end) {
		if (x < 0)
			writeChar('-'), x = -x;

		char s[24];
		long long n = 0;
		while (x || !n)
			s[n++] = '0' + x % 10, x /= 10;
		while (n--)
			writeChar(s[n]);
		if (end)
			writeChar(end);
	}

	inline void writeWord(const char *s) {
		while (*s)
			writeChar(*s++);
	}

	struct Flusher {
		~Flusher() {
			if (write_pos)
				fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
		}
	} flusher;
}

using namespace fastinput;

long long n;
vector <long long> v;

long long mergeSort(long long l, long long r)
{
	if (l + 1 == r)
		return 0;
	long long mid = (l + r) / 2;
	vector <long long> larr, rarr;
	long long tmp = mergeSort(l, mid) + mergeSort(mid, r);
	for (long long j = l; j < mid; ++j)
		larr.push_back(v[j]);
	for (long long j = mid; j < r; ++j)
		rarr.push_back(v[j]);
	long long i1 = 0;
	long long i2 = 0;
	while (i1 != larr.size() || i2 != rarr.size())
	{
		if (i2 == rarr.size() || (i1 != larr.size() && larr[i1] < rarr[i2]))
		{
			v[l + i1 + i2] = larr[i1];
			tmp += i2;
			++i1;
		}
		else
		{
			v[l + i1 + i2] = rarr[i2];
			++i2;
		}
	}
	return tmp;
}

long long main() 
{
	n = readInt();
	vector <long long> v1, v2;
	for (long long i = 0; i < n / 2; ++i)
		v2.push_back(i);
	for (long long i = n / 2; i < n; ++i)
		v1.push_back(i);
	//for (long long i = 0; i < n; ++i)
	//{
//		//long long x = readInt();
		//if (i % 2 == 0)
//			v1.push_back(x);
		//else
//			v2.push_back(x);
//	}
	sort(v1.begin(), v1.end());
	reverse(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	reverse(v2.begin(), v2.end());
	for (long long i = 0; i < n; ++i)
		if (i % 2 == 0)
			v.push_back(v1.back()),
			v1.pop_back();
		else
			v.push_back(v2.back()),
			v2.pop_back();
	cout << mergeSort(0, n) << endl;
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'