Language: C++

#ifdef __GNUC__ 
#include <bits/stdc++.h>
auto & inputdatastream = std::cin;
#else
std::ifstream inputdatastream;
#endif
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/preprocessor.hpp>
#include <boost/mpl/int.hpp>
#include <boost/range.hpp>
//#include <boost/numeric/ublas/blas.hpp>
//#include <boost/numeric/ublas/matrix.hpp>
//#include <boost/numeric/ublas/io.hpp>
//#include <boost/numeric/ublas/matrix_proxy.hpp>
using namespace std;
namespace renge = boost::range;
//#define DEF_ALL_1(v) std::begin(v),std::end(v)
//#define DEF_ALL_1(v) v.begin(),v.end()
//#define DEF_ALL_2(index,v) v.BOOST_PP_CAT(begin,index)(),v.BOOST_PP_CAT(end,index)()
//#define ALL(...)  BOOST_PP_CAT(BOOST_PP_OVERLOAD(DEF_ALL_,__VA_ARGS__)(__VA_ARGS__),BOOST_PP_EMPTY())
#define ALL(v) std::begin(v),std::end(v)

//#define DEF_RALL_1(v) std::rbegin(v),std::rend(v)
//#define DEF_RALL_2(index,v) v.BOOST_PP_CAT(rbegin,index)(),v.BOOST_PP_CAT(rend,index)()
//#define RALL(...) BOOST_PP_CAT(BOOST_PP_OVERLOAD(DEF_RALL_,__VA_ARGS__)(__VA_ARGS__),BOOST_PP_EMPTY())
#define RALL(v) std::rbegin(v),std::rend(v)
using u6 = std::uint64_t;
using s6 = std::int64_t;
using u3 = std::uint32_t;
using s3 = std::int32_t;

constexpr u6 moduloNo = 1'000'000'000 + 7; //' 1e9 + 7
#define DEFVALUE1(r,type,name) type name;
#define DEFINIT0(r,type,name) in >> name;
#define DEFINIT1(r,size,name) name.resize(size);
#define DEFOSTREAM_FORDEBUG(r,type,name) out << name << " ";
#define DEFINITER template <typename T, typename In> void init(const T &, In &) {}
#define DEF_TYPEEXTSELECTOR(fnext,tpl)BOOST_PP_IF(BOOST_PP_TUPLE_ELEM(0, fnext)  ,BOOST_PP_TUPLE_ELEM(2, fnext),BOOST_PP_TUPLE_ELEM(0, tpl) )
#define DEFVALUEIMPL(r,fnext,tpl) BOOST_PP_LIST_FOR_EACH(BOOST_PP_TUPLE_ELEM(1,fnext),DEF_TYPEEXTSELECTOR(fnext,tpl), BOOST_PP_TUPLE_TO_LIST(BOOST_PP_TUPLE_POP_FRONT(tpl)))
#define DEFVALUES(expr) DEFIMPL(expr,0,DEFINIT0,0,_)
#define DEFIMPL(expr,deftypeindex,initcode,c,ext)																									\
			BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,(0,DEFVALUE1,_),BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr))													\
			template <typename In> decltype(auto) init(boost::mpl::int_<deftypeindex> ,In & in){													\
				BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL,(c,initcode,ext),BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr));return in;}									\
			template <typename Out> decltype(auto) init(boost::mpl::int_<-deftypeindex-1>, Out & out) {												\
					BOOST_PP_SEQ_FOR_EACH(DEFVALUEIMPL, (c, DEFOSTREAM_FORDEBUG, ext), BOOST_PP_VARIADIC_SEQ_TO_SEQ(expr)); return out;}
#define DEFVECS(size,expr)  DEFIMPL(expr,1,DEFINIT1,1,size)
#define DEFSTRUCT(name,...) struct name{DEFINITER;__VA_ARGS__ ;friend std::istream & operator>>(std::istream & in,name & target){				\
		target.init(boost::mpl::int_<0> (),in);target.init(boost::mpl::int_<1>() ,in);return in;}												\
	friend std::ostream & operator<<(std::ostream & out, name & target) {																		\
			target.init(boost::mpl::int_<-1>(), out); return out;} }

template <typename T>
void initcalc(T & calc) {
	ios::sync_with_stdio(false); cin.tie(0);
#ifndef __GNUC__ 
	inputdatastream.open("inputdata.txt");
#endif
	calc.init(boost::mpl::int_<0>(), inputdatastream);
	calc.init(boost::mpl::int_<1>(), inputdatastream);
}
template <typename T>
auto runcalc(T & c) ->std::enable_if_t<std::is_void<decltype(c.calc())>::value > {
	c.calc();
}
template <typename T>
auto runcalc(T & c) ->std::enable_if_t<!std::is_void<decltype(c.calc())>::value > {
	std::cout << c.calc() << std::endl;
}
template <typename T>
struct invecT {
	decltype(auto) begin()const {
		return std::istream_iterator<T>(inputdatastream);
	}
	decltype(auto) end()const {
		return std::istream_iterator<T>();
	}
};
template <typename T>invecT<T> invec;
//-------------------------------------------------------------------------------

namespace nightly {

	template <typename T, bool isZeronodeCount = true>
	struct unionfind {
		std::vector<T> v;
		T count;
		void resize(std::size_t n) {
			assert(v.size() == 0); v.resize(n + 1);
			if (isZeronodeCount)count = v.size() - 1;
			else count = 0;
		}
		template <bool ismerge>
		bool find(T l, T r) {//可変長引数とかも選択肢？
			auto ll = getroot(l);
			auto rr = getroot(r);
			auto update = [this](const auto & updateindex, T minval) {
				for (auto i : updateindex)v[i] = minval;
			};
			if (ismerge) {
				std::pair<T, T> t = std::minmax(ll.first, rr.first);
				if (ll.first != rr.first) {
					--count;
					v[t.second] = t.first;
				}
				update(ll.second, t.first);
				update(rr.second, t.first);
			}
			else {
				update(ll.second, ll.first);
				update(rr.second, rr.first);
			}
			return ll.first == rr.first;
		}
	private:
		std::pair<T, std::vector<T> > getroot(T node) {
			std::pair<T, std::vector<T> > result;
			if (!v[node])v[node] = node;
			while (v[node] != node) {
				result.second.push_back(node);
				node = v[node];
			}
			result.first = node;
			return result;
		}
	};

}using namespace nightly;
/*******************************************************************************/
constexpr u6 shiftsize = 20+5;
constexpr u6 bufsize = 1 << shiftsize;

DEFSTRUCT(datatype,
	DEFVALUES((s6, a, b))
);
struct DataBufT {
	s3 a;
	u3 next;
};
DataBufT datatable[u6(2 * 1e5 + 3)];
u6 constexpr log2p1(u6 v) {
	u6 t = 0;
	u6 st = (u6)1 << (u6)63;
	if (v == 0)return 0;
	while (!(v&st)) { ++t; st >>= 1; }
	return (64-t) ;
}
template <typename T>//,T maxval>
struct BIT_traits {
	using UT=std::make_unsigned_t<T>;
	//constexpr UT bitsize = 10;
	//constexpr UT shiftsize= 30;
	static UT calcKey(T k) {
		//auto t = (UT)k;
		//auto mask = ((UT)1) << (UT)63;
		//t &= mask;
		//return (t>>(64-10)) | (((UT)k & ~mask) >> (UT)(63));
		auto t = (UT)k;
		t += (UT)10e9;
		t++;
		t &=(UT(1)<<UT(32))-UT(1);
		t >>= UT(32- shiftsize-1);
		auto limit = (UT)(bufsize);
		auto minlimmit = 1;
		return t> limit?limit:
			t<minlimmit? minlimmit:t;
	}
};
template <typename T>
struct BITCell {
	struct Inner {
		std::vector<T> buf;
		std::size_t lcount = 0;
		std::size_t rcount = 0;
	};
	std::unique_ptr<Inner> innerptr;
	void resize(size_t rdiff) {
		if (!innerptr) {
			innerptr =make_unique<typename BITCell<T>::Inner>();
			innerptr->buf.reserve(count + rdiff * 2 * 8);
		}
		//innerptr->buf.resize(innerptr->buf.size() + u6(count));
	}
	template <typename U,typename C>
	pair<s6,s6> calc(U & results,const C  & counts,u6 rcount) {
		for (auto p = start; p; p = datatable[p].next) {
			innerptr->buf.push_back(datatable[p].a);
		}
		start = 0;
		std::nth_element(innerptr->buf.begin(), innerptr->buf.begin() + rcount-1, innerptr->buf.end());
		s6  mean = innerptr->buf[rcount-1];
		results[0] = mean * counts[0] - results[0];
		results[1] -= mean * counts[1];
		for (auto d : innerptr->buf) {
			results[0] += mean>d?mean-d:d-mean;
		}
		return { mean,results[0] + results[1] };
	}
	u3 start=0;
	T value=0;//sum
	u3 count = 0;
};

template <typename T>
struct BIT {
	BITCell<T> buf[bufsize+1];// index0は使用禁止(改良するまで)
	u6 count = 0;
	void insert(u3 index) {
		auto k = BIT_traits<s6>::calcKey(datatable[index].a);
		u6 x = k;
		if (buf[x].start) datatable[index].next=buf[x].start;
		buf[x].start =index;
		for (; x<= bufsize;x+=u6(s6(x)& -s6(x))) {
			buf[x].value += datatable[index].a;
			++buf[x].count;
		}
		++count;
	}
	pair<s6, s6> sum() {
		u6 meancount = (count +1)/ 2;
		u6 counts[2] = {};
		s6 results[2] = {};
		u6 depth = bufsize;
		u6 prevcount = count;
		s6 prevvalue = buf[1024].value;
		u6 kbase = 0;
		while (1) {
			depth >>= 1;
			auto & bufref = buf[kbase + depth ];
			auto & bufrefc = buf[kbase + depth ].count;
			if (counts[0] + bufrefc < meancount) {
				results[0] += bufref.value;
				counts[0] += bufrefc;
				prevcount -= bufrefc;
				prevvalue -= bufref.value;
				kbase |= depth;
			}
			else {
				results[1] += prevvalue -bufref.value;
				counts[1] += prevcount-bufrefc;
				prevcount = bufrefc;
				prevvalue = bufref.value;
			}
			if (depth == 1)break;
		}
		//std::vector<int > v;
		//v.reserve
		u6 k = kbase + 1;
		u6 rcount = meancount-counts[0];
		auto & bufref = buf[k];
		u6 rdiff = abs<s6>(rcount- (bufref.count-rcount));
		bufref.resize(rdiff);
		return bufref.calc(results, counts, rcount);
		//v.resize(v.size() + bufref.count);
	}
};
BIT<s3> bit;

struct Calc {
	DEFINITER;
	DEFVALUES(
		(s6, q)
	);
	s6 ldiff = 0;
	s6 bsum = 0;
	map<s6,pair<s6,s6> > buf;
	vector<s6> seg;
	s6 dutty = numeric_limits<s6>::min();
	s6 calca = numeric_limits<s6>::max();
	auto calc() {
		int qno;
		s6 b;
		for (s6 i = 1; i <= q; ++i) {
			inputdatastream >> qno;
			if (qno == 1) {
				inputdatastream >> datatable[i].a>> b;
				bsum += b;
				bit.insert(i);
			}
			else {
				auto p = bit.sum();
				cout << p.first << " " << p.second + bsum << endl;
			}
		}
		return ;
	}
	/*******************************************************************************/
};

int main() {
	static Calc calc;
	initcalc(calc); runcalc(calc);
}


Compiler output:
a.cc:7:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    7 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.