criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main()
{
  string line;
  getline(cin, line);
  const int N = stoi(line);
  getline(cin, line);

  vector<char> cands = {'S', 'W'};
  for(char first : cands)
  {
	for(char second : cands)
	{
	  vector<char> ans(N);
	  ans[0] = first;
	  ans[1] = second;
	  ans[N - 1] = ((ans[0] == 'S') ^ (line[0] == 'o') ^ (ans[1] == 'S') == true) ? 'S' : 'W';
	  
	  for(int i = 2; i < N - 1; i++)
	  {
		ans[i] = ((ans[i - 1] == 'S') ^ (line[i - 1] == 'o') ^ (ans[i - 2] == 'S') == true) ? 'S' : 'W';
	  }
	  if(((ans[N - 1] == 'S') ^ (line[N - 1] == 'o') ^ (ans[N - 2] == 'S') ^ (ans[0] == 'S')) == false)
	  {
		for(auto ch : ans) cout << ch;
		cout << endl;
		return 0;
	  }
	  // for(auto v : ans) cout << v << ", ";
	  // cout << endl;
	}
  }
  cout << -1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:3: error: 'vector' was not declared in this scope
   15 |   vector<char> cands = {'S', 'W'};
      |   ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | 
a.cc:15:10: error: expected primary-expression before 'char'
   15 |   vector<char> cands = {'S', 'W'};
      |          ^~~~
a.cc:16:20: error: 'cands' was not declared in this scope
   16 |   for(char first : cands)
      |                    ^~~~~
a.cc:20:18: error: expected primary-expression before 'char'
   20 |           vector<char> ans(N);
      |                  ^~~~
a.cc:21:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |           ans[0] = first;
      |           ^~~
      |           abs
Language: C

#include<cstdio>
using namespace std;
int main(void)
{
	//3つの狼の合計が偶数->〇
	//S->0 W->1
	//S->0x53
	//W->0x57
	//o->0x6f
	//x->0x78
	long long int N, i, h, x = 0, ok = 0;
	char c;
	static char say[100015];
	static long long int dou[100015];
	long long int  sta[2];
	scanf("%lld", &N);
	fflush(stdin);
	for (i = 0; i < N; i++) {
		scanf("%c", &say[i]);
	}
	for (h = 0; h < 4; h++) {
		if (h == 0) { sta[0] = 0; sta[1] = 0; }
		if (h == 1) { sta[0] = 0; sta[1] = 1; }
		if (h == 2) { sta[0] = 1; sta[1] = 0; }
		if (h == 3) { sta[0] = 1; sta[1] = 1; }
		dou[0] = sta[0];
		dou[1] = sta[1];
		for (i = 2; i < N + 2; i++) {
			if (say[i-1] == 0x6f) { x = 0; }else { x = 1; }
			if ((x+dou[i - 1] + dou[i - 2])%2==1) {dou[i] = 1;}else { dou[i] = 0;}
		}
		if (dou[N] == sta[0] && dou[N + 1] == sta[1]) {
			for (i = 1; i <=N; i++) {
				if (dou[i] == 0) { c = 0x53; }
				else { c = 0x57; }
				printf("%c", c);
				ok = 1;
			}
			break;
		}
	}
	if (ok == 0) { printf("-1"); }
	printf("\n");
	return 0;
}


Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
int main(void)
{
	//3つの狼の合計が偶数->〇
	//S->0 W->1
	//S->0x53
	//W->0x57
	//o->0x6f
	//x->0x78
	long long int N, i, h, x = 0, ok = 0;
	char c;
	static char say[100015];
	static long long int dou[100015];
	long long int  sta[2];
	scanf("%lld", &N);
	fflush(stdin);
	for (i = 0; i < N; i++) {
		scanf("%c", &say[i]);
	}
	for (h = 0; h < 4; h++) {
		if (h == 0) { sta[0] = 0; sta[1] = 0; }
		if (h == 1) { sta[0] = 0; sta[1] = 1; }
		if (h == 2) { sta[0] = 1; sta[1] = 0; }
		if (h == 3) { sta[0] = 1; sta[1] = 1; }
		dou[0] = sta[0];
		dou[1] = sta[1];
		for (i = 2; i < N + 2; i++) {
			if (say[i-1] == 0x6f) { x = 0; }else { x = 1; }
			if ((x+dou[i - 1] + dou[i - 2])%2==1) {dou[i] = 1;}else { dou[i] = 0;}
		}
		if (dou[N] == sta[0] && dou[N + 1] == sta[1]) {
			for (i = 1; i < =N; i++) {
				if (dou[i] == 0) { c = 0x53; }
				else { c = 0x57; }
				printf("%c", c);
				ok = 1;
			}
			break;
		}
	}
	if (ok == 0) { printf("-1"); }
	printf("\n");
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:32:41: error: expected expression before '=' token
   32 |                         for (i = 1; i < =N; i++) {
      |                                         ^
Language: C++

#include <iostream>
#include <string>
#include <cstdint>

using namespace std;

char next(char before, char now, char ans)
{
	auto inv = [](char animalType){ return animalType == 'S' ? 'W' : 'S'; };
	char result{ before };

	if(ans != 'o') {
		result = inv(result);
	}

	if(now != 'S') {
		result = inv(result);
	}

	return result;
}

bool judge(string& str, string ans)
{
	for(auto i = 1; i < str.size() - 1; ++i) {
		str[i + 1] = next(str[i - 1], str[i], ans[i]);
	}

	return str[0] == str.back();
}

int main()
{
	int_least32_t n;
	cin >> n;
	
	string input;
	cin >> input;

	string result(n + 1, 'S');
	char ini[2] = { 'S', 'W' };
	bool flag{ false };
	for(auto i = 0; i < 2 && flag == false; ++i) {
		result[0] = ini[i];
		for(auto j = 0; j < 2 && flag == false; ++j) {
			result[1] = ini[j];
			flag = judge(result, ans);
		}
	}

	if(flag) {
		cout << result << endl;
	}
	else {
		cout << -1 << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:46: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |                         flag = judge(result, ans);
      |                                              ^~~
      |                                              abs
Language: C++

#include <iostream>
#include <string>
#include <cstdint>

using namespace std;

char next(char before, char now, char ans)
{
	auto inv = [](char animalType){ return animalType == 'S' ? 'W' : 'S'; };
	char result{ before };

	if(ans != 'o') {
		result = inv(result);
	}

	if(now != 'S') {
		result = inv(result);
	}

	return result;
}

bool judge(string& str, string ans)
{
	for(auto i = 1; i < str.size() - 1; ++i) {
		str[i + 1] = next(str[i - 1], str[i], ans[i]);
	}

	return str[0] == str[n];
}

int main()
{
	int_least32_t n;
	cin >> n;
	
	string input;
	cin >> input;

	string result(n + 1, 'S');
	if(judge(result, input)) {
		cout << result << endl;
	}
	else {
		cout << -1 << endl;
	}
}


Compiler output:
a.cc: In function 'bool judge(std::string&, std::string)':
a.cc:29:30: error: 'n' was not declared in this scope
   29 |         return str[0] == str[n];
      |                              ^
Language: C++

#include <iostream>
#include <string>
#include <cstdint>

using namespace std;

char next(char before, char now, char ans)
{
	auto inv = [](char animalType){ return animalType == 'S' ? 'W' : 'S'; };
	char result{ before };

	if(ans != 'o') {
		result = inv(result);
	}

	if(now != 'S') {
		result = inv(result);
	}

	return result;
}

bool judge(string& str, string ans)
{
	for(auto i = 1; i < str.size() - 1; ++i) {
		str[i + 1] = next(str[i - 1], str[i], ans[i]);
	}

	return str[0] == str[n];
}

int main()
{
	int_least32_t n;
	cin >> n;
	
	string input;
	cin >> input;

	string result(n + 1, 'S');
	if(judge(result, input) {
		cout << result << endl;
	}
	else {
		cout << -1 << endl;
	}
}


Compiler output:
a.cc: In function 'bool judge(std::string&, std::string)':
a.cc:29:30: error: 'n' was not declared in this scope
   29 |         return str[0] == str[n];
      |                              ^
a.cc: In function 'int main()':
a.cc:41:32: error: expected ')' before '{' token
   41 |         if(judge(result, input) {
      |           ~                    ^~
      |                                )
a.cc:47:1: error: expected primary-expression before '}' token
   47 | }
      | ^
Language: C++

#include <iostream>
#include <string>
#include <cstdint>

using namespace std;

char next(char before, char now, char ans)
{
	auto inv = [](char animalType){ return animalType == 'S' ? 'W' : 'S'; };
	char result{ before };

	if(ans != 'o') {
		result = inv(result);
	}

	if(now != 'S') {
		result = inv(result);
	}

	return result;
}

bool judge(string& str, string ans)
{
	for(auto i = 1; i < n; ++i) {
		str[i + 1] = next(str[i - 1], str[i], ans[i]);
	}

	return str[0] == str[n];
}

int main()
{
	int_least32_t n;
	cin >> n;
	
	string input;
	cin >> input;

	string result(n + 1, 'S');
	if(judge(result, input) {
		cout << result << endl;
	}
	else {
		cout << -1 << endl;
	}
}


Compiler output:
a.cc: In function 'bool judge(std::string&, std::string)':
a.cc:25:29: error: 'n' was not declared in this scope
   25 |         for(auto i = 1; i < n; ++i) {
      |                             ^
a.cc:29:30: error: 'n' was not declared in this scope
   29 |         return str[0] == str[n];
      |                              ^
a.cc: In function 'int main()':
a.cc:41:32: error: expected ')' before '{' token
   41 |         if(judge(result, input) {
      |           ~                    ^~
      |                                )
a.cc:47:1: error: expected primary-expression before '}' token
   47 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

int n;
char s[100055];
bool ans[100055];

// 0 S truth
// 1 W lie

void solve(bool a, bool b) {
	ans[0] = a;
	ans[1] = b;
	
	FOR(i, 1, n) {
		if (ans[i] == 0) {
			if (s[i] == 'o') ans[i + 1] = ans[i - 1];
			if (s[i] == 'x') ans[i + 1] = 1 - ans[i - 1];
		}
		if (ans[i] == 1) {
			if (s[i] == 'x') ans[i + 1] = ans[i - 1];
			if (s[i] == 'o') ans[i + 1] = 1 - ans[i - 1];
		}
	}
	
	if (ans[n] != ans[0]) return;
	
	if (ans[0] == 0) {
		if (s[i] == 'o' && ans[n - 1] != ans[1]) return;
		if (s[i] == 'x' && ans[n - 1] == ans[1]) return;
	}
	
	if (ans[0] == 1) {
		if (s[i] == 'x' && ans[n - 1] != ans[1]) return;
		if (s[i] == 'o' && ans[n - 1] == ans[1]) return;
	}
	
	FOR(i, 0, n) printf("%c", ans[i] ? 'W' : 'S');
	printf("\n");
	exit(0);
}

int main () {
	
	scanf("%d%s", &n, s);
	
	solve(0, 0);
	solve(0, 1);
	solve(1, 0);
	solve(1, 1);
	
	printf("-1\n");
	
	return 0;
	
}

Compiler output:
a.cc: In function 'void solve(bool, bool)':
a.cc:46:23: error: 'i' was not declared in this scope
   46 |                 if (s[i] == 'o' && ans[n - 1] != ans[1]) return;
      |                       ^
a.cc:47:23: error: 'i' was not declared in this scope
   47 |                 if (s[i] == 'x' && ans[n - 1] == ans[1]) return;
      |                       ^
a.cc:51:23: error: 'i' was not declared in this scope
   51 |                 if (s[i] == 'x' && ans[n - 1] != ans[1]) return;
      |                       ^
a.cc:52:23: error: 'i' was not declared in this scope
   52 |                 if (s[i] == 'o' && ans[n - 1] == ans[1]) return;
      |                       ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<P> vp;
int ans[100010];

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        ll a;
        cin >> a;
        vp.push_back({a, i});
    }
    vp.push_back(0, 0);
    sort(vp.rbegin(), vp.rend()); // aが大きいもの、同立ならiが大きいものから取っていく

    ll idx = n + 1;
    rep(i, n){
        idx = min(idx, vp[i].second);
        ans[idx] += (i + 1) * (vp[i].first - vp[i+1].first);
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(int, int)'
   24 |     vp.push_back(0, 0);
      |     ~~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; value_type = std::pair<long long int, long long int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; value_type = std::pair<long long int, long long int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 2 provided
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<P> vp;
int ans[100010];

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        ll a;
        cin >> a;
        vp.push_back({a, i});
    }
    sort(vp.begin(), vp.end()); // aが大きいもの、同立ならiが大きいものから取っていく

    int idx = n + 1;
    rep(i, n){
        idx = min(idx, vp[i].second);
        ans[idx] += (i + 1) * (vp[i].first - vp[i+1].first);
    }
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:18: error: no matching function for call to 'min(int&, long long int&)'
   28 |         idx = min(idx, vp[i].second);
      |               ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:28:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   28 |         idx = min(idx, vp[i].second);
      |               ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:28:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |         idx = min(idx, vp[i].second);
      |               ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include <bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)
#define mp make_pair

typedef pair<int, int> ii;

priority_queue<ii> pq;

signed main() {
	fastio;
	int n; cin >> n;
	int a[n], counter[n];
	ll ans[n];
	rep(i, 0, n) {
		ans[i] = 0;
		cin >> a[i];
		counter[i] = 1;
		pq.push(mp(a[i], i));
	}
	while(pq.size() > 1) {
		ii t1, t2;
		t1 = pq.top(); pq.pop();
		t2 = pq.top(); pq.pop();
		ans[t1.second] += (ll)counter[t1.second] * (t1.first - t2.first);
		pq.push(mp(t2.first, min(t1.second, t2.second)));
		counter[min(t1.second, t2.second)] += counter[max(t1.second, t2.second)];
	}
	ans[0] += n * pq.top().first;
	rep(i, 0, n) {
		cout << ans[i] << "\n";
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: 'll' was not declared in this scope
   22 |         ll ans[n];
      |         ^~
a.cc:24:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |                 ans[i] = 0;
      |                 ^~~
      |                 abs
a.cc:33:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |                 ans[t1.second] += (ll)counter[t1.second] * (t1.first - t2.first);
      |                 ^~~
      |                 abs
a.cc:37:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |         ans[0] += n * pq.top().first;
      |         ^~~
      |         abs
Language: C++

#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234567811], kosuu[1234567811], saishou[1234567811];
ll ans[12345678];
signed main() {
	ll n, m; cin >> n;
	vector<ll> v, kari;
	for (int h = 1; h <= n; h++) {
		cin >> test[h];
		kosuu[test[h]]++; kari.push_back(test[h]);
		if (saishou[test[h]] == 0) {
			saishou[test[h]] = h;
		}
	}
	sort(kari.begin(), kari.end());
	for (int h = 0; h < kari.size(); h++) {
		if (h == 0) { v.push_back(kari[h]); continue; }
		if (kari[h - 1] != kari[h]) { v.push_back(kari[h]); }
	}
	for (int h = v.size() - 1; h > 0; h--) {
		ans[saishou[v[h]]] = kosuu[v[h]] * (v[h] - v[h - 1]);
		kosuu[v[h - 1]] += kosuu[v[h]];
	}
	for (int h = 1; h <= n; h++) {
		if (h == 1) { cout << kosuu[v[h - 1]] << endl; continue; }
		cout << ans[h] << endl;
	}
	cin >> n; return 0;
}

Compiler output:
/tmp/cc5gjusb.o: in function `main':
a.cc:(.text+0x91): relocation truncated to fit: R_X86_64_PC32 against symbol `kosuu' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0xa8): relocation truncated to fit: R_X86_64_PC32 against symbol `kosuu' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `saishou' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x12e): relocation truncated to fit: R_X86_64_PC32 against symbol `saishou' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x270): relocation truncated to fit: R_X86_64_PC32 against symbol `kosuu' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x2d8): relocation truncated to fit: R_X86_64_PC32 against symbol `saishou' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x2eb): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x316): relocation truncated to fit: R_X86_64_PC32 against symbol `kosuu' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x344): relocation truncated to fit: R_X86_64_PC32 against symbol `kosuu' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x35b): relocation truncated to fit: R_X86_64_PC32 against symbol `kosuu' defined in .bss section in /tmp/cc5gjusb.o
a.cc:(.text+0x3a9): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    
    int max_a = 0;
    vector<int> idxs;
    rep(i, n) if (chmax(max_a, a[i])) idxs.push_back(i);
    
    vector<ll> b(n);
    rep(i, n) b[i] = a[i];
    sort(b.rbegin(), b.rend());
    
    vector<ll> sum(n + 1);
    rep(i, n) sum[i + 1] = sum[i] + b[i];
    
    auto search = [&](int x){
        int ng = n;
        int ok = -1;

        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;

            if (b[mid] > x) ok = mid;
            else ng = mid;
        }
        return ok;
    };
    
    vector<ll> ans_sum(idxs.size() + 1);
    ans_sum[0] = sum[n];
    rep(i, idxs.size()) {
        int u = search(a[idxs[i]]);
        //cout << u << endl;
        ans_sum[i + 1] = sum[u + 1] - a[idxs[i]] * (u + 1);
    }
    
    vector<ll> ans(n + 1);
    rep(i, idxs.size()) {
        ans[idxs[i]] = ans_sum[i] - ans_sum[i + 1];
    }
    rep(i, n) cout << ans[i] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:24: error: no matching function for call to 'chmax(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   56 |     rep(i, n) if (chmax(max_a, a[i])) idxs.push_back(i);
      |                   ~~~~~^~~~~~~~~~~~~
a.cc:27:31: note: candidate: 'template<class T> bool chmax(T&, T)'
   27 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:27:31: note:   template argument deduction/substitution failed:
a.cc:56:24: note:   deduced conflicting types for parameter 'T' ('int' and 'long long int')
   56 |     rep(i, n) if (chmax(max_a, a[i])) idxs.push_back(i);
      |                   ~~~~~^~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
 
template <typename T>
class SegTree{
  using F = function<T(T,T)>;
  int n; T uni; F f;
  vector<T> dat;
  T query_sub(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return uni;
    if(a <= l && r <= b) return dat[k];
    T vl = query_sub(a, b, k*2+1, l, (l+r)/2);
    T vr = query_sub(a, b, k*2+2, (l+r)/2, r);
    return f(vl,vr);
  }
public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n-1,uni);
  }
  void update(int k, T a) {
    k += n-1;
    dat[k] += a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = f(dat[2*k+1], dat[2*k+2]);
    }
  }
  T query(int a, int b) {
    return query_sub(a, b, 0, 0, n);
  } // [a,b)
};
 
int main(){
  int n;
  cin >> n;
  ll a[n];
  SegTree<ll> st(n,[](ll a,ll b){return max(a,b);},(ll)0);
  set<ll> s;
  rep(i,n) {
    cin >> a[i];
    s.insert(a[i]);
    st.update(i,a[i]);
  }
  map<ll,ll> m;
  for(auto k : s) m[k] = p++;
  cout << p << endl;
  SegTree<ll> sum(p,[](ll a, ll b){return a + b;},(ll)0);
  rep(i,n) sum.update(m[a[i]],1);
  vector<ll> ans(n,0);
  rep(i,n) ans[0] += min(a[0],a[i]);
  sum.update(m[a[0]],-1);
  for(int i = 1; i < n; i++) {
    ll d = st.query(0,i);
    ll c = sum.query(m[a[i]],p);
    ans[i] = c*max((ll)0,a[i]-d);
    sum.update(m[a[i]],-1);
  }
  for(auto k : ans) cout << k << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:26: error: 'p' was not declared in this scope
   49 |   for(auto k : s) m[k] = p++;
      |                          ^
a.cc:50:11: error: 'p' was not declared in this scope
   50 |   cout << p << endl;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main()
{
ll n ;
cin >> n ;
vector<ll> ans(n);
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
map<ll,pair<ll,ll>> m;
rep(i,n){
  m[a[i]].first++;
  if(m[a[i]].first==1)m[a[i]].second=i+1;
}
ll num=0,cnt,itr;
ll minitr;
ll sum=0;
for (auto i = m.rbegin(); i != m.rend(); ++i) {
  if(num==0){
    num=i->first;
    cnt=i->second.first;
    itr=i->second.second;
    minitr=itr-1;
    continue;
  }
  ans[minitr]+=(cnt+sum)*(num-i->first);
  sum+=cnt;
  minitr=min(minitr,itr-1);
  num=i->first;
  cnt=i->second.first;
  itr=i->second.second;
}
ans[minitr]+=(cnt+sum)*(num-i->first);
for(auto an:ans)cout << an << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:29: error: 'i' was not declared in this scope
   38 | ans[minitr]+=(cnt+sum)*(num-i->first);
      |                             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  int a[n];
  pair<ll,ll> p[n];
  rep(i,n){
    cin >> a[i];
    p[i]=mp(a[i],i);
  }
  sort(p,p+n);
  reverse(p,p+n);

  ll ans[n];
  rep(i,n) ans[i]=0;
  int ind=n;
  rep(i,n){
    ind=min(ind, p[i].second);
    if(i==n-1) ans[ind]+=(i+1)*(p[i].first-0);
    else ans[ind]+=(i+1)*(p[i].first-p[i+1].first);
    //    cout << ans[ind] << endl;
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
  
  return 0;
    

}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:12: error: no matching function for call to 'min(int&, long long int&)'
   29 |     ind=min(ind, p[i].second);
      |         ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:29:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |     ind=min(ind, p[i].second);
      |         ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:29:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |     ind=min(ind, p[i].second);
      |         ~~~^~~~~~~~~~~~~~~~~~
Language: C++

int N;
ll A[101010];
vector<int> V;
ll ret[101010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	map<ll,ll> M;
	FOR(i,N) cin>>A[i], M[A[i]]++;
	V.push_back(0);
	for(i=1;i<N;i++) if(A[V.back()]<A[i]) V.push_back(i);
	for(i=V.size()-2;i>=0;i--) {
			auto r=*M.rbegin();
			M.erase(r.first);
			ret[V[i+1]] += (r.first-A[V[i]])*1LL*r.second;
			M[A[V[i]]]+=r.second;
	}
	FORR(r,M) ret[0] += r.first*r.second;
	
	
	FOR(i,N) cout<<ret[i]<<endl;
}

Compiler output:
a.cc:2:1: error: 'll' does not name a type
    2 | ll A[101010];
      | ^~
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<int> V;
      | ^~~~~~
a.cc:4:1: error: 'll' does not name a type
    4 | ll ret[101010];
      | ^~
a.cc: In function 'void solve()':
a.cc:8:28: error: 'string' was not declared in this scope
    8 |         int i,j,k,l,r,x,y; string s;
      |                            ^~~~~~
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin>>N;
      |         ^~~
a.cc:11:9: error: 'map' was not declared in this scope
   11 |         map<ll,ll> M;
      |         ^~~
a.cc:11:13: error: 'll' was not declared in this scope; did you mean 'l'?
   11 |         map<ll,ll> M;
      |             ^~
      |             l
a.cc:11:20: error: 'M' was not declared in this scope
   11 |         map<ll,ll> M;
      |                    ^
a.cc:12:9: error: 'FOR' was not declared in this scope
   12 |         FOR(i,N) cin>>A[i], M[A[i]]++;
      |         ^~~
a.cc:13:9: error: 'V' was not declared in this scope
   13 |         V.push_back(0);
      |         ^
a.cc:14:29: error: 'A' was not declared in this scope
   14 |         for(i=1;i<N;i++) if(A[V.back()]<A[i]) V.push_back(i);
      |                             ^
a.cc:18:25: error: 'ret' was not declared in this scope
   18 |                         ret[V[i+1]] += (r.first-A[V[i]])*1LL*r.second;
      |                         ^~~
a.cc:18:49: error: 'A' was not declared in this scope
   18 |                         ret[V[i+1]] += (r.first-A[V[i]])*1LL*r.second;
      |                                                 ^
a.cc:21:9: error: 'FORR' was not declared in this scope
   21 |         FORR(r,M) ret[0] += r.first*r.second;
      |         ^~~~
Language: C++

int N;
ll A[100010];
ll ans[100010];

{
    pair<int, int> last;
    int stk, left;
    rd(N, A(N));
    priority_queue<pair<int, int>> pq;
    REP(i, N) pq.emplace(A[i], i);
    stk = 0;
    left = pq.top().second;
    while (!pq.empty()) {
        last = pq.top();
        int now, next;
        now = pq.top().first;
        while (!pq.empty() && pq.top().first == last.first) {
            ++stk;
            last.second = pq.top().second;
            pq.pop();
        }
        next = pq.empty() ? 0 : pq.top().first;
        left = min(left, last.second);
        ans[left] += stk*(now-next);
        
    }
    wtLn(ans(N));
}

Compiler output:
a.cc:2:1: error: 'll' does not name a type
    2 | ll A[100010];
      | ^~
a.cc:3:1: error: 'll' does not name a type
    3 | ll ans[100010];
      | ^~
a.cc:5:1: error: expected unqualified-id before '{' token
    5 | {
      | ^
Language: C++

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define int ll
#define pb push_back


using namespace std;

inline ll read()
{
    ll t=0,dp=1;char c=getchar();
    while(!isdigit(c))	{if(c=='-')	dp=-1;c=getchar();}
    while(isdigit(c))	t=t*10+c-48,c=getchar();
    return t*dp;
}
inline void write(ll x){if(x<0)	{putchar('-');x=-x;}	if(x>=10)	write(x/10);putchar(x%10+48);}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
/*------------------------------------------------------------------------------------------------------*/

const int N=1e5+5;
int n;
struct node{int v,num;}	p[N];
int ans[N];
inline bool cmp(node x,node y){return x.v>y.v;}
int main()
{
	n=read();
	For(i,1,n)	p[i].v=read(),p[i].num=i;
	sort(p+1,p+n+1,cmp);
	int now=1,to=p[1].num;
	For(i,2,n)
	{
		if(p[i].v==p[i-1].v)	now++;
		else	ans[to]=(p[i-1].v-p[i].v)*now,now++;
		to=min(to,p[i].num);
	}
	ans[to]=(p[n].v-p[n+1].v)*now,now++;
	For(i,1,n)	writeln(ans[i]);
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

n = int(input())
a = list(map(int, input().split()))

ans = [0]*n

b = []

for i, x in enumerate(a):
    b.append([-x, i])

b.sort()

c = []
p = b[0]
x = [-b[0][0], b[0][1], 1]
for i in range(1, n):
    if -b[i][0] == x[0]:
        x[2] = i+1
    else:
        c.append(x)
        x = [-b[i][0], b[i][1], i+1]
c.append(x)

s = 0
for i in range(len(c)-1):
    x = (c[i][0]-c[i+1][0])*c[i][2]
    ans[c[i][1]] = x
    s += x
ans[c[-1][1]] = sum(a)-s

for x in ans:
    print(x)


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vi = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<Pl> a(N);
  rep(i,N){
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(ALL(a));
  reverse(ALL(a));
  vl ans(N);
  int mi = INF;
  rep(i,N){
    mi = min(mi,int(a[i].second));
    if(i<N-1 && a[i].first==a[i+1].first) continue;
    ll diff;
    if(i<N-1) diff = a[i].first - a[i+1].first;
    else diff = a[i].first;
    ans[mi] += diff * ll(i+1); 
  }
  rep(i,N) cout << ans[i] << endl;
  return 0;
}

Compiler output:
a.cc:21:7: error: conflicting declaration 'using vi = class std::vector<long long int>'
   21 | using vi = vector<ll>;
      |       ^~
a.cc:19:7: note: previous declaration as 'using vi = class std::vector<int>'
   19 | using vi = vector<int>;
      |       ^~
a.cc: In function 'int main()':
a.cc:39:3: error: 'vl' was not declared in this scope; did you mean 'vi'?
   39 |   vl ans(N);
      |   ^~
      |   vi
a.cc:47:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |     ans[mi] += diff * ll(i+1);
      |     ^~~
      |     abs
a.cc:49:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   49 |   rep(i,N) cout << ans[i] << endl;
      |                    ^~~
      |                    abs
Language: C++

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<Pl> a(N);
  rep(i,N){
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(ALL(a));
  reverse(ALL(a));
  vl ans(N);
  int mi = INF;
  rep(i,N){
    mi = min(mi,int(a[i].second));
    if(i<N-1 && a[i].first==a[i+1].first) continue;
    ll diff;
    if(i<N-1) diff = a[i].first - a[i+1].first;
    else diff = a[i].first;
    ans[mi] += diff * ll(i+1); 
  }
  rep(i,N) cout << ans[i] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:3: error: 'vl' was not declared in this scope; did you mean 'vi'?
   38 |   vl ans(N);
      |   ^~
      |   vi
a.cc:46:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   46 |     ans[mi] += diff * ll(i+1);
      |     ^~~
      |     abs
a.cc:48:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |   rep(i,N) cout << ans[i] << endl;
      |                    ^~~
      |                    abs
Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
bool cmp(const pair<int, int>& p1, const pair<int, int>& p2) {
  return p1.first > p2.first;
}
int main(void) {
  int n;
  cin >> n;
  vector <pair <int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end(), cmp);
  vector<ll> cnt(n, 0LL);
  int mini = a[0].first;
  for (int i = 0; i < n - 1; i++) {
    if (a[i].second < mini) {
      mini = a[i].second;
    }
    if (a[i].first != a[i + 1].first) {
      cnt[mini] += (a[i].first - a[i + 1].first) * (i + 1);
    }
  }
  cnt[0] += a[n - 1].first * n;
  for (int i = 0; i < n; i++) {
    cout << cnt[i] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |   sort(a.begin(), a.end(), cmp);
      |   ^~~~
      |   short
Language: C++

#include<bits/stdc++.h>
using namespace std;

long long N;
long long a[100005];
long long ans[100005];
//     val   , num
map<long long, long long> memo;
//        pos
vector<long long> V;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> a[i];
		memo[a[i]]++;
	}

	V.push_back(0);
	for(long long i = 1; i < N; i++){
		if(a[V.back()] < a[i]){
			V.push_back(i);
		}
	}

	for(long long i = V.size() - 2; i >= 0; i--){
		while(memo.rbegin()->first > a[V[i]]){
			ans[V[i+1]] += (memo.rbegin()->first - a[V[i]])*memo.rbegin()->second;
			memo[a[V[i]]] += memo.rbegin()->second;
			memo.erase(memo.rbegin()->first);
		}
	}
	for(auto m : memo){
		ans[0] += r.first * m.second;
	}
	//ans[V[0]] += memo.begin()->second;

	for(long long i = 0; i < N; i++){
		cout << ans[i] << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:27: error: 'r' was not declared in this scope
   34 |                 ans[0] += r.first * m.second;
      |                           ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll n,j=LLONG_MAX;
vector<pl>v;
void update(vector<ll> &ans, int i){
	j=min(j,v[i].se);
	if(i==0){
		ans[v[i].se]+=(n-i)*(v[i].fi);
		return;
	}
	ans[v[i].se]+=(n-i)*(v[i].fi-v[i-1].fi);

	update(ans,i-1);
}
 
int main(){
	cin>>n;
	vector<ll>a(n),ans(n);
	rep(i,n)cin>>a[i];
	rep(i,n)v.pb(mp(a[i],i));
	sort(all(v));
	update(ans,n-1);
	rep(i,n){
		cout<<ans[i]<<endl;
	}

    return 0;
}

Compiler output:
a.cc:27:8: error: 'LLONG_MAX' was not declared in this scope
   27 | ll n,j=LLONG_MAX;
      |        ^~~~~~~~~
a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <queue>
  +++ |+#include <climits>
   10 | #include <time.h>
Language: C++

#include <iostream>
#include <utility>
#include <algorithm>
#include <climits>

int main(int argc, char **argv) {
        long long int n=0;
        std::cin >> n;
        long long int *ret = new long long int[n];


        std::vector<std::pair<long long int, long int> > v;
        for(long long int i=0; i < n; i++) {
                long long int a;
                std::cin >> a;
                v.push_back({a,i});
                ret[i] = 0;
        }

        std::sort(v.begin(),v.end());
        std::reverse(v.begin(),v.end());

        long long int cur = 0;
        long long int min = INT_MAX;
        long long int count = 0;
        while (cur < n) {
                long long int next = cur;
                while (next<n and v[cur].first == v[next].first) {
                        if (min > v[next].second) {
                                min = v[next].second;
                        }
                        next++;
                        count++;
                }
                if (next == n) {
                        ret[min] += (v[cur].first) * count;
                } else {
                        ret[min] += (v[cur].first - v[next].first) * count;
                }
                cur = next;
        }

        for (long long int i=0; i < n; i++) {
                std::cout << ret[i] << std::endl;
        }
        return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:12:14: error: 'vector' is not a member of 'std'
   12 |         std::vector<std::pair<long long int, long int> > v;
      |              ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include <climits>
  +++ |+#include <vector>
    5 | 
a.cc:12:56: error: expected primary-expression before '>' token
   12 |         std::vector<std::pair<long long int, long int> > v;
      |                                                        ^
a.cc:12:58: error: 'v' was not declared in this scope
   12 |         std::vector<std::pair<long long int, long int> > v;
      |                                                          ^
Language: C++

#include<bits/stdc++.h>
#define ul unsigned long
using namespace std;
int main(){
  cin.tie(0);ios::sync_with_stdio(false);
  ul n;ul tmp; ul m=0;
  cin>>n;
  vector<pair<ul,ul> >l;vector<ul long>ans(n);
  l.reserve(n+1);
  for(ul i=0;i<n;++i){cin>>tmp;l[i].emplace_back(make_pair(tmp,i));} 
  l.emplace_back(make_pair(0,n));
  stable_sort(l.begin(),l.end(),[](auto a,auto b){return a.first>b.first;});
  for(auto it=l.cbegin(),tar=l.cbegin();it!=l.cend()-1;){
    if(tar->second>it->second)tar=it;
    ans[tar->second]+=(it->first-(++it)->first)*++m;
  }
  for(auto x:ans)cout<< x <<'\n';cout.flush();
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:37: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long unsigned int, long unsigned int> >, std::pair<long unsigned int, long unsigned int> >::value_type' {aka 'struct std::pair<long unsigned int, long unsigned int>'} has no member named 'emplace_back'
   10 |   for(ul i=0;i<n;++i){cin>>tmp;l[i].emplace_back(make_pair(tmp,i));}
      |                                     ^~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  long  n;unsigned long tmp; long m=0;
  std::array<std::pair<unsigned long,unsigned long> > ls;
  std::cin >> n;
  unsigned long long ans[n];
  ls.resize(n+1);
  for(long i=0; i<n; ++i) {std::cin >> tmp;ls[i]=(std::make_pair(tmp,i));}
  ls[n]=(std::make_pair(0,n));
  std::stable_sort(ls.begin(),ls.end(),[](auto a,auto b){return a.first>b.first;});
  auto target=ls.begin();
  for(auto it=ls.begin();it!=ls.cend()-1;){
    if(target->second>it->second)target=it;
    ans[target->second]+=(it->first-(++it)->first)*(++m);
  }
  for(auto x : ans) std::cout<< x <<'\n';
  std::cout.flush();
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:53: error: wrong number of template arguments (1, should be 2)
    6 |   std::array<std::pair<unsigned long,unsigned long> > ls;
      |                                                     ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: provided for 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:9:6: error: request for member 'resize' in 'ls', which is of non-class type 'int'
    9 |   ls.resize(n+1);
      |      ^~~~~~
a.cc:10:46: error: invalid types 'int[long int]' for array subscript
   10 |   for(long i=0; i<n; ++i) {std::cin >> tmp;ls[i]=(std::make_pair(tmp,i));}
      |                                              ^
a.cc:11:5: error: invalid types 'int[long int]' for array subscript
   11 |   ls[n]=(std::make_pair(0,n));
      |     ^
a.cc:12:23: error: request for member 'begin' in 'ls', which is of non-class type 'int'
   12 |   std::stable_sort(ls.begin(),ls.end(),[](auto a,auto b){return a.first>b.first;});
      |                       ^~~~~
a.cc:12:34: error: request for member 'end' in 'ls', which is of non-class type 'int'
   12 |   std::stable_sort(ls.begin(),ls.end(),[](auto a,auto b){return a.first>b.first;});
      |                                  ^~~
a.cc:13:18: error: request for member 'begin' in 'ls', which is of non-class type 'int'
   13 |   auto target=ls.begin();
      |                  ^~~~~
a.cc:14:18: error: request for member 'begin' in 'ls', which is of non-class type 'int'
   14 |   for(auto it=ls.begin();it!=ls.cend()-1;){
      |                  ^~~~~
a.cc:14:33: error: request for member 'cend' in 'ls', which is of non-class type 'int'
   14 |   for(auto it=ls.begin();it!=ls.cend()-1;){
      |                                 ^~~~