Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
    seen[v] = true;
    for (auto nv : G[v]) {
        if (nv == p) continue;
        if (finished[nv]) continue;
      if (seen[nv] && !finished[nv]) {
            pos = nv;f++; 
            return;
        }
      dfs(G, nv, v);
 
        // サイクル検出したならば真っ直ぐに抜けていく
        if (pos != -1) {
        return;}}
      finished[v] = true;
}
    
mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }
 
    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
saiki(ll n,ll x){
if(n==0)return 1;

int main(){
ll n; cin>>n;
ll c = 0;
priority_queue<ll> ma;
priority_queue<ll, vector<ll>, greater<ll>> mi;
ll masum=0,misum=0;
rep(i,n){
ll q;
cin>>q;
ll d = mi.size();
ll u = ma.size();
if(q==1){
ll a,b; cin>>a>>b;
c+=b;
if(d<u){
// 下に
ll t = ma.top();
if(a>=t){
misum+=a;
mi.push(a);}
else{
ma.pop();masum-=t;
misum+=t;
mi.push(t);
masum+=a;
ma.push(a);
}
}
else{
if(u==0){
ma.push(a);
masum+=a;
continue;}
ll t = mi.top();
if(a<=t){
masum+=a;
ma.push(a);}
else{
mi.pop();
misum-=t;
masum+=t;
ma.push(t);
misum+=a;
mi.push(a);}
}}
else{
ll x = ma.top();
ll ca = c+(x*(ll)ma.size()-masum)+(misum-x*(ll)mi.size());
cout << x << " " << ca << endl;}



Compiler output:
a.cc:133:1: error: ISO C++ forbids declaration of 'saiki' with no type [-fpermissive]
  133 | saiki(ll n,ll x){
      | ^~~~~
a.cc: In function 'int saiki(ll, ll)':
a.cc:136:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  136 | int main(){
      |         ^~
a.cc:136:9: note: remove parentheses to default-initialize a variable
  136 | int main(){
      |         ^~
      |         --
a.cc:136:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:136:11: error: a function-definition is not allowed here before '{' token
  136 | int main(){
      |           ^
a.cc:184:33: error: expected '}' at end of input
  184 | cout << x << " " << ca << endl;}
      |                                 ^
a.cc:133:17: note: to match this '{'
  133 | saiki(ll n,ll x){
      |                 ^
a.cc:184:33: warning: control reaches end of non-void function [-Wreturn-type]
  184 | cout << x << " " << ca << endl;}
      |                                 ^