Language: C++

#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;
uint32 __builtin_ctzll(uint64 c) {
	uint32 t = 63;
	if (c & 0x00000000FFFFFFFF) { c = c & 0x00000000FFFFFFFF;t -= 32; }
	if (c & 0x0000FFFF0000FFFF) { c = c & 0x0000FFFF0000FFFF;t -= 16; }
	if (c & 0x00FF00FF00FF00FF) { c = c & 0x00FF00FF00FF00FF;t -= 8; }
	if (c & 0x0F0F0F0F0F0F0F0F) { c = c & 0x0F0F0F0F0F0F0F0F;t -= 4; }
	if (c & 0x3333333333333333) { c = c & 0x3333333333333333;t -= 2; }
	if (c & 0x5555555555555555) { c = c & 0x5555555555555555;t -= 1; }
	return t;
}
uint32 __builtin_clzll(uint64 c) {
	uint32 t = 63;
	if (c & 0xFFFFFFFF00000000) { c = c & 0xFFFFFFFF00000000;t -= 32; }
	if (c & 0xFFFF0000FFFF0000) { c = c & 0xFFFF0000FFFF0000;t -= 16; }
	if (c & 0xFF00FF00FF00FF00) { c = c & 0xFF00FF00FF00FF00;t -= 8; }
	if (c & 0xF0F0F0F0F0F0F0F0) { c = c & 0xF0F0F0F0F0F0F0F0;t -= 4; }
	if (c & 0xCCCCCCCCCCCCCCCC) { c = c & 0xCCCCCCCCCCCCCCCC;t -= 2; }
	if (c & 0xAAAAAAAAAAAAAAAA) { c = c & 0xAAAAAAAAAAAAAAAA;t -= 1; }
	return t;
}
uint64 bitmaskr[64] = { 0xFFFFFFFFFFFFFFFE, 0xFFFFFFFFFFFFFFFC, 0xFFFFFFFFFFFFFFF8, 0xFFFFFFFFFFFFFFF0, 0xFFFFFFFFFFFFFFE0, 0xFFFFFFFFFFFFFFC0, 0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFFFE00, 0xFFFFFFFFFFFFFC00, 0xFFFFFFFFFFFFF800, 0xFFFFFFFFFFFFF000, 0xFFFFFFFFFFFFE000, 0xFFFFFFFFFFFFC000, 0xFFFFFFFFFFFF8000, 0xFFFFFFFFFFFF0000, 0xFFFFFFFFFFFE0000, 0xFFFFFFFFFFFC0000, 0xFFFFFFFFFFF80000, 0xFFFFFFFFFFF00000, 0xFFFFFFFFFFE00000, 0xFFFFFFFFFFC00000, 0xFFFFFFFFFF800000, 0xFFFFFFFFFF000000, 0xFFFFFFFFFE000000, 0xFFFFFFFFFC000000, 0xFFFFFFFFF8000000, 0xFFFFFFFFF0000000, 0xFFFFFFFFE0000000, 0xFFFFFFFFC0000000, 0xFFFFFFFF80000000, 0xFFFFFFFF00000000, 0xFFFFFFFE00000000, 0xFFFFFFFC00000000, 0xFFFFFFF800000000, 0xFFFFFFF000000000, 0xFFFFFFE000000000, 0xFFFFFFC000000000, 0xFFFFFF8000000000, 0xFFFFFF0000000000, 0xFFFFFE0000000000, 0xFFFFFC0000000000, 0xFFFFF80000000000, 0xFFFFF00000000000, 0xFFFFE00000000000, 0xFFFFC00000000000, 0xFFFF800000000000, 0xFFFF000000000000, 0xFFFE000000000000, 0xFFFC000000000000, 0xFFF8000000000000, 0xFFF0000000000000, 0xFFE0000000000000, 0xFFC0000000000000, 0xFF80000000000000, 0xFF00000000000000, 0xFE00000000000000, 0xFC00000000000000, 0xF800000000000000, 0xF000000000000000, 0xE000000000000000, 0xC000000000000000, 0x8000000000000000, 0x0000000000000000 };
uint64 bitmaskl[64] = { 0x0000000000000000, 0x0000000000000001, 0x0000000000000003, 0x0000000000000007, 0x000000000000000F, 0x000000000000001F, 0x000000000000003F, 0x000000000000007F, 0x00000000000000FF, 0x00000000000001FF, 0x00000000000003FF, 0x00000000000007FF, 0x0000000000000FFF, 0x0000000000001FFF, 0x0000000000003FFF, 0x0000000000007FFF, 0x000000000000FFFF, 0x000000000001FFFF, 0x000000000003FFFF, 0x000000000007FFFF, 0x00000000000FFFFF, 0x00000000001FFFFF, 0x00000000003FFFFF, 0x00000000007FFFFF, 0x0000000000FFFFFF, 0x0000000001FFFFFF, 0x0000000003FFFFFF, 0x0000000007FFFFFF, 0x000000000FFFFFFF, 0x000000001FFFFFFF, 0x000000003FFFFFFF, 0x000000007FFFFFFF, 0x00000000FFFFFFFF, 0x00000001FFFFFFFF, 0x00000003FFFFFFFF, 0x00000007FFFFFFFF, 0x0000000FFFFFFFFF, 0x0000001FFFFFFFFF, 0x0000003FFFFFFFFF, 0x0000007FFFFFFFFF, 0x000000FFFFFFFFFF, 0x000001FFFFFFFFFF, 0x000003FFFFFFFFFF, 0x000007FFFFFFFFFF, 0x00000FFFFFFFFFFF, 0x00001FFFFFFFFFFF, 0x00003FFFFFFFFFFF, 0x00007FFFFFFFFFFF, 0x0000FFFFFFFFFFFF, 0x0001FFFFFFFFFFFF, 0x0003FFFFFFFFFFFF, 0x0007FFFFFFFFFFFF, 0x000FFFFFFFFFFFFF, 0x001FFFFFFFFFFFFF, 0x003FFFFFFFFFFFFF, 0x007FFFFFFFFFFFFF, 0x00FFFFFFFFFFFFFF, 0x01FFFFFFFFFFFFFF, 0x03FFFFFFFFFFFFFF, 0x07FFFFFFFFFFFFFF, 0x0FFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF, 0x7FFFFFFFFFFFFFFF };
struct VEBtip {
	std::vector<uint64> tree;
	uint64 aux = 0;
	VEBtip() :tree(64) {}
	//key????????\
	void _insert(const uint32 &key) {
		if (!tree[key >> 6]) {
			aux |= 1LL << (key >> 6);
		}
		tree[key >> 6] |= 1LL << (key & 63);
		return;
	}
	//key?????????
	void _delete(const uint32 &key) {
		tree[key >> 6] ^= 1LL << (key & 63);
		if (!tree[key >> 6]) {
			aux ^= 1LL << (key >> 6);
		}
		return;
	}
	//key????????¨?????????
	bool _find(const uint32 &key) {
		return tree[key >> 6] >> (key & 63) & 1;
	}
	//????°????
	uint32 _min() {
		return (__builtin_ctzll(aux) << 6) | __builtin_ctzll(tree[__builtin_ctzll(aux)]);
	}
	//?????§???
	uint32 _max() {
		return ((63 ^ (__builtin_clzll(aux))) << 6) | (63 ^ __builtin_clzll(tree[63 ^ __builtin_clzll(aux)]));
	}
	//key????????§??????????°????????´?
	uint32 _findnext(const uint32 &key) {
		if (tree[key >> 6] & bitmaskr[key & 63]) {
			return (key & 4032) | __builtin_ctzll(tree[key >> 6] & bitmaskr[key & 63]);
		}
		else {
			if (aux&bitmaskr[key >> 6]) {
				return (__builtin_ctzll(aux&bitmaskr[key >> 6]) << 6) | __builtin_ctzll(tree[__builtin_ctzll(aux&bitmaskr[key >> 6])]);
			}
			else {
				return ~static_cast<std::uint_fast32_t>(0);
			}
		}
	}
	//key???????°????????????§???????´?
	uint32 _findprev(const uint32 &key) {
		if (tree[key >> 6] & bitmaskl[key & 63]) {
			return (key & 4032) | (63 ^ __builtin_clzll(tree[key >> 6] & bitmaskl[key & 63]));
		}
		else {
			if (aux&bitmaskl[key >> 6]) {
				return ((63 ^ (__builtin_clzll(aux&bitmaskl[key >> 6]))) << 6) | (63 ^ __builtin_clzll(tree[63 ^ __builtin_clzll(aux&bitmaskl[key >> 6])]));
			}
			else {
				return ~static_cast<std::uint_fast32_t>(0);
			}
		}
	}
};

class VEBTree {
	uint32 root[2] = { ~static_cast<std::uint_fast32_t>(0),~static_cast<std::uint_fast32_t>(0) };
	vector<uint32> tree;
	vector<VEBtip> bits;
	uint32 temp, now;
public:
	VEBTree() :tree(8194, ~static_cast<std::uint_fast32_t>(0)), bits(4097) {
		for (temp = 8193;~temp;temp -= 2) {
			++tree[temp];
		}
		cerr << "#######" << endl;
	}
	//???????????????
	bool Empty() {
		return !~root[0];
	}
	//????°????
	uint32 Min() {
		return root[0];
	}
	//?????§???
	uint32 Max() {
		return root[1];
	}
	//key????????\
	void Insert(uint32 key) {
		if (~root[0]) {
			if (root[0] > key) {
				temp = key;
				key = root[0];
				root[0] = temp;
			}
			else if (root[1] < key) {
				root[1] = key;
			}
			now = (key >> 11) & 8190;
			if (~tree[now]) {
				if (tree[now] > key) {
					temp = key;
					key = tree[now];
					tree[now] = temp;
				}
				else if (tree[now | 1] < key) {
					tree[now | 1] = key;
				}
				bits[now >> 1]._insert(key & 4095);
			}
			else {
				tree[now] = key;
				tree[now | 1] = key;
				key = now >> 1;
				if (~tree[8192]) {
					if (tree[8192] > key) {
						temp = key;
						key = tree[8192];
						tree[8192] = temp;
					}
					else if (tree[8193] < key) {
						tree[8193] = key;
					}
					bits[4096]._insert(key);
				}
				else {
					tree[8192] = key;
					tree[8193] = key;
				}
			}
		}
		else {
			root[0] = key;
			root[1] = key;
		}
		return;
	}
	//key?????????
	void Delete(uint32 key) {
		if (root[0] == key) {
			if (root[1] == key) {
				root[0] = ~static_cast<std::uint_fast32_t>(0);
				root[1] = 0;
			}
			else {
				now = tree[8192] << 1;
				key = tree[now];
				root[0] = key;
				if (tree[now | 1] == key) {
					tree[now] = ~static_cast<std::uint_fast32_t>(0);
					tree[now | 1] = 0;
					key = bits[4096]._min();
					tree[8192] = key;
					bits[4096]._delete(key);
				}
				else {
					key = bits[now >> 1]._min();
					tree[now] = now << 11 | key;
					bits[now >> 1]._delete(key);
				}
			}
		}
		else {
			now = (key >> 11) & 8190;
			if (root[1] == key) {
				if (tree[now] == key) {
					tree[now] = ~static_cast<std::uint_fast32_t>(0);
					tree[now | 1] = 0;
					bits[4096]._delete(now >> 1 & 4095);
					tree[8093] = bits[4096]._max();
					root[1] = tree[tree[8093] << 1 | 1];
				}
				else {
					bits[now >> 1]._delete(key & 4095);
					tree[now | 1] = now << 11 | bits[4095]._max();
					root[1] = tree[now | 1];
				}
			}
			else {
				if (tree[now] == key) {
					if (tree[now | 1] == key) {
						tree[now] = ~static_cast<std::uint_fast32_t>(0);
						tree[now | 1] = 0;
						bits[4096]._delete(now >> 1);
					}
					else {
						key = bits[now >> 1]._min();
						tree[now] = now << 11 | key;
						bits[now >> 1]._delete(key);
					}
				}
				else {
					if (tree[now | 1] == key) {
						bits[now >> 1]._delete(key & 4095);
						tree[now | 1] = bits[now >> 1]._max();
					}
					else {
						bits[now >> 1]._delete(key & 4085);
					}
				}
			}
		}
		return;
	}
	//key????????¨?????????
	bool Find(const uint32 &key) {
		return bits[key >> 12]._find(key & 4095) || tree[key >> 11 & 8190] == key || root[0] == key;
	}
	//key????????§??????????°????????´?
	uint32 Findnext(const uint32 &key) {
		if (root[0] > key) {
			return root[0];
		}
		else if (root[1] <= key) {
			return ~static_cast<std::uint_fast32_t>(0);
		}
		else {
			now = key >> 11 & 8190;
			if (tree[now | 1] <= key) {
				if (now >> 1 < tree[8192]) {
					return tree[tree[8192] << 1];
				}
				else {
					return tree[(bits[4096]._findnext(now >> 1)) << 1];
				}
			}
			else {
				if (tree[now] <= key) {
					return (key & 16773120) | (bits[now >> 1]._findnext(key & 4095));
				}
				else {
					return tree[now];
				}
			}
		}
	}
	//key???????°????????????§???????´?
	uint32 Findprev(const uint32 &key) {

	}
};

struct Ar {
	vector<uint32> t;
	void Insert(uint32 a) {
		t.push_back(a);
	}
	void Delete(uint32 a) {
		rep(i, 0, t.size()) {
			if (t[i] == a)
				t[i] = -1;
		}
	}
	bool Find(uint32 a) {
		rep(i, 0, t.size()) {
			if (t[i] == a)
				return true;
		}
		return false;
	}
	uint32 Findnext(uint32 a) {
		sort(ALL(t));
		rep(i, 0, t.size()) {
			if (t[i] > a)
				return t[i];
		}
		return ~static_cast<std::uint_fast32_t>(0);
	}
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	VEBTree t;
	uint32 n;
	cin >> n;
	int32 a;
	int64 sum = 0;
	rep(i, 0, n) {
		cin >> a;
		sum += a;
		a += 1e6;
		if(!t.Find(a)){ t.Insert(a); }
	}
	int32 Max = t.Max(),Min=t.Min();
	Min -= 1e6;Max -= 1e6;
	cout << Min << " " << Max << " " << sum<<endl;
	return 0;
}

Compiler output:
a.cc:32:8: error: definition of 'uint32 __builtin_ctzll(uint64)' ambiguates built-in declaration 'int __builtin_ctzll(long long unsigned int)'
   32 | uint32 __builtin_ctzll(uint64 c) {
      |        ^~~~~~~~~~~~~~~
a.cc:42:8: error: definition of 'uint32 __builtin_clzll(uint64)' ambiguates built-in declaration 'int __builtin_clzll(long long unsigned int)'
   42 | uint32 __builtin_clzll(uint64 c) {
      |        ^~~~~~~~~~~~~~~
a.cc:60:17: error: expected unqualified-id before 'if'
   60 |                 if (!tree[key >> 6]) {
      |                 ^~
a.cc:63:17: error: 'tree' does not name a type
   63 |                 tree[key >> 6] |= 1LL << (key & 63);
      |                 ^~~~
a.cc:64:17: error: expected unqualified-id before 'return'
   64 |                 return;
      |                 ^~~~~~
a.cc:65:10: error: expected ';' after struct definition
   65 |         }
      |          ^
      |          ;
a.cc: In function 'void _delete(const uint32&)':
a.cc:68:17: error: 'tree' was not declared in this scope; did you mean 'free'?
   68 |                 tree[key >> 6] ^= 1LL << (key & 63);
      |                 ^~~~
      |                 free
a.cc:70:25: error: 'aux' was not declared in this scope
   70 |                         aux ^= 1LL << (key >> 6);
      |                         ^~~
a.cc: In function 'bool _find(const uint32&)':
a.cc:76:24: error: 'tree' was not declared in this scope; did you mean 'free'?
   76 |                 return tree[key >> 6] >> (key & 63) & 1;
      |                        ^~~~
      |                        free
a.cc: In function 'uint32 _min()':
a.cc:80:41: error: 'aux' was not declared in this scope
   80 |                 return (__builtin_ctzll(aux) << 6) | __builtin_ctzll(tree[__builtin_ctzll(aux)]);
      |                                         ^~~
a.cc:80:70: error: 'tree' was not declared in this scope; did you mean 'free'?
   80 |                 return (__builtin_ctzll(aux) << 6) | __builtin_ctzll(tree[__builtin_ctzll(aux)]);
      |                                                                      ^~~~
      |                                                                      free
a.cc: In function 'uint32 _max()':
a.cc:84:48: error: 'aux' was not declared in this scope
   84 |                 return ((63 ^ (__builtin_clzll(aux))) << 6) | (63 ^ __builtin_clzll(tree[63 ^ __builtin_clzll(aux)]));
      |                                                ^~~
a.cc:84:85: error: 'tree' was not declared in this scope; did you mean 'free'?
   84 |                 return ((63 ^ (__builtin_clzll(aux))) << 6) | (63 ^ __builtin_clzll(tree[63 ^ __builtin_clzll(aux)]));
      |                                                                                     ^~~~
      |                                                                                     free
a.cc: In function 'uint32 _findnext(const uint32&)':
a.cc:88:21: error: 'tree' was not declared in this scope; did you mean 'free'?
   88 |                 if (tree[key >> 6] & bitmaskr[key & 63]) {
      |                     ^~~~
      |                     free
a.cc:92:29: error: 'aux' was not declared in this scope
   92 |                         if (aux&bitmaskr[key >> 6]) {
      |                             ^~~
a.cc: In function 'uint32 _findprev(const uint32&)':
a.cc:102:21: error: 'tree' was not declared in this scope; did you mean 'free'?
  102 |                 if (tree[key >> 6] & bitmaskl[key & 63]) {
      |                     ^~~~
      |                     free
a.cc:106:29: error: 'aux' was not declared in this scope
  106 |                         if (aux&bitmaskl[key >> 6]) {
      |                             ^~~
a.cc: At global scope:
a.cc:114:1: error: expected declaration before '}' token
  114 | };
      | ^
a.cc:142:17: error: expected unqualified-id before 'if'
  142 |                 if (~root[0]) {
      |                 ^~
a.cc:184:17: error: expected unqualified-id before 'else'
  184 |                 else {
      |                 ^~~~
a.cc:188:17: error: expected unqualified-id before 'return'
  188 |                 return;
      |                 ^~~~~~
a.cc:189:10: error: expected ';' after class definition
  189 |         }
      |          ^
      |          ;
a.cc: In function 'void Delete(uint32)':
a.cc:192:21: error: 'root' was not declared in this scope
  192 |                 if (root[0] == key) {
      |                     ^~~~
a.cc:198:33: error: 'now' was not declared in this scope; did you mean 'pow'?
  198 |                                 now = tree[8192] << 1;
      |                                 ^~~
      |                                 pow
a.cc:198:39: error: 'tree' was not declared in this scope; did you mean 'free'?
  198 |                                 now = tree[8192] << 1;
      |                                       ^~~~
      |                                       free
a.cc:204:47: error: 'bits' was not declared in this scope
  204 |                                         key = bits[4096]._min();
      |                                               ^~~~
a.cc:209:47: error: 'bits' was not declared in this scope
  209 |                                         key = bits[now >> 1]._min();
      |                                               ^~~~
a.cc:216:25: error: 'now' was not declared in this scope; did you mean 'pow'?
  216 |                         now = (key >> 11) & 8190;
      |                         ^~~
      |                         pow
a.cc:218:37: error: 'tree' was not declared in this scope; did you mean 'free'?
  218 |                                 if (tree[now] == key) {
      |                                     ^~~~
      |                                     free
a.cc:221:41: error: 'bits' was not declared in this scope
  221 |                                         bits[4096]._delete(now >> 1 & 4095);
      |                                         ^~~~
a.cc:226:41: error: 'bits' was not declared in this scope
  226 |                                         bits[now >> 1]._delete(key & 4095);
      |                                         ^~~~
a.cc:232:37: error: 'tree' was not declared in this scope; did you mean 'free'?
  232 |                                 if (tree[now] == key) {
      |                                     ^~~~
      |                                     free
a.cc:236:49: error: 'bits' was not declared in this scope
  236 |                                                 bits[4096]._delete(now >> 1);
      |                                                 ^~~~
a.cc:239:55: error: 'bits' was not declared in this scope
  239 |                                                 key = bits[now >> 1]._min();
      |                                                       ^~~~
a.cc:246:49: error: 'bits' was not declared in this scope
  246 |                                                 bits[now >> 1]._delete(key & 4095);
      |                                                 ^~~~
a.cc:250:49: error: 'bits' was not declared in this scope
  250 |                                                 bits[now >> 1]._delete(key & 4085);
      |                                                 ^~~~
a.cc: In function 'bool Find(const uint32&)':
a.cc:259:24: error: 'bits' was not declared in this scope
  259 |                 return bits[key >> 12]._find(key & 4095) || tree[key >> 11 & 8190] == key || root[0] == key;
      |                        ^~~~
a.cc:259:61: error: 'tree' was not declared in this scope; did you mean 'free'?
  259 |                 return bits[key >> 12]._find(key & 4095) || tree[key >> 11 & 8190] == key || root[0] == key;
      |                                                             ^~~~
      |                                                             free
a.cc:259:94: error: 'root' was not declared in this scope
  259 |                 return bits[key >> 12]._find(key & 4095) || tree[key >> 11 & 8190] == key || root[0] == key;
      |                                                                                              ^~~~
a.cc: In function 'uint32 Findnext(const uint32&)':
a.cc:263:21: error: 'root' was not declared in this scope
  263 |                 if (root[0] > key) {
      |                     ^~~~
a.cc:270:25: error: 'now' was not declared in this scope; did you mean 'pow'?
  270 |                         now = key >> 11 & 8190;
      |                         ^~~
      |                         pow
a.cc:271:29: error: 'tree' was not declared in this scope; did you mean 'free'?
  271 |                         if (tree[now | 1] <= key) {
      |                             ^~~~
      |                             free
a.cc:276:54: error: 'bits' was not declared in this scope
  276 |                                         return tree[(bits[4096]._findnext(now >> 1)) << 1];
      |                                                      ^~~~
a.cc:281:68: error: 'bits' was not declared in this scope
  281 |                                         return (key & 16773120) | (bits[now >> 1]._findnext(key & 4095));
      |                                                                    ^~~~
a.cc: In function 'uint32 Findprev(const uint32&)':
a.cc:292:9: warning: no return statement in function returning non-void [-Wreturn-type]
  292 |         }
      |         ^
a.cc: At global scope:
a.cc:293:1: error: expected declaration before '}' token
  293 | };
      | ^
a.cc: In function 'int main()':
a.cc:335:23: error: 'class VEBTree' has no member named 'Find'
  335 |                 if(!t.Find(a)){ t.Insert(a); }
      |                       ^~~~
a.cc:335:35: error: 'class VEBTree' has no member named 'Insert'
  335 |                 if(!t.Find(a)){ t.Insert(a); }
      |                                   ^~~~~~