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

#include <bits/stdc++.h>
#define l_ength size
const ll inf = (1<<30);
const ll mod = 1000000007;
using ll = long long;
using namespace std;

ll main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end() );
	ll sum = 0;
	for( auto &k : a ){
		sum += abs(k);
	}
	bool same = true;
	if( a.front() * a.back() < 0 ) same = false;
	if( same ){
		if( a[0] < 0 ) reverse( a.begin(), a.end() );
		sum -= 2*abs(a.front());
	}
	cout << sum << endl;
	if( same ){
		ll cur = 0;
		cout << a[0] << ' ' << a[1] << endl;
		cur = a[0]-a[1];
		for( ll i = 2; i < n-1; ++i ){
			cout << cur << ' ' << a[i] << endl;
			cur -= a[i];
		}
		if( cur > 0 ){
			cout << cur << ' ' << a[n-1] << endl;
		} else {
			cout << a[n-1] << ' ' << cur << endl;
		}
	} else {
		ll pnt = -1;
		for( ll i = 0; i < n-1; ++i ){
			if( a[i] > 0 ){
				pnt = i;
				break;
			}
		}
		ll cur = a[0];
		for( ll i = pnt; i < n-1; ++i ){
			cout << cur << ' ' << a[i] << endl;
			cur -= a[i];
		}
		ll sum = a[n-1];
		for( ll i = 1; i < pnt; ++i ){
			cout << sum << ' ' << a[i] << endl;
			sum -= a[i];
		}
		cout << sum << ' ' << cur << endl;
	}
	return 0;
}

Compiler output:
a.cc:3:7: error: 'll' does not name a type
    3 | const ll inf = (1<<30);
      |       ^~
a.cc:4:7: error: 'll' does not name a type
    4 | const ll mod = 1000000007;
      |       ^~
a.cc:8:1: error: '::main' must return 'int'
    8 | ll main(){
      | ^~
Language: C++

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

vector<pair<int, int>> his;

void solve(set<long long> &s, bool b) {
    if ((int)s.size() == 2) {
        if (b) {
            auto i = s.end();
            i--;
            s.erase(*i);
            long long x = *i;
            i = s.begin(); s.erase(*i);
            long long y = *i;
            his.push_back(pair<int, int>(x, y));

            s.insert(x - y);
        }
        else {
            auto i = s.begin(); s.erase(*i);
            long long x = *i;
            i = s.end(); i--; s.erase(*i);
            long long y = *i;
            his.push_back(pair<int, int>(x, y));

            s.insert(x - y);
        }
    }

    s.insert(solve(s, b ^ 1));

    if (b) {
        auto i = s.end(); i--; s.erase(*i);
        long long x = *i;
        i = s.begin(); s.erase(*i);
        long long y = *i;
        his.push_back(pair<int, int>(x, y));

        s.insert(x - y);
    }
    else {
        auto i = s.begin(); s.erase(*i);
        long long x = *i;
        i = s.end(); i--; s.erase(*i);
        long long y = *i;
        his.push_back(pair<int, int>(x, y));

        s.insert(x - y);
    }
}

int main() {
    int n;
    cin >> n;
    set<long long> s;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
  
    solve(s, 1); 
    
    auto i = s.begin();
        
    cout << *i << endl;

    for (int i = 0; i < (int)his.size(); i++)
    {
        cout << his.at(i).first << " " << his.at(i).second << endl;
    }
    
}

Compiler output:
a.cc: In function 'void solve(std::set<long long int>&, bool)':
a.cc:30:19: error: invalid use of void expression
   30 |     s.insert(solve(s, b ^ 1));
      |              ~~~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<long> data(N);
  long count = 0;
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    if(data.at(i) >= 0)count++;
  }
  sort(data.begin(), data.end());
  vector<long>a,b;
  long ans = 0, coa = 0;
  for(int i = 0; i < N - 1; i++){
    if(count == 0)break;
    if(data.at(i) >= 0 ){
      if(co == 0){
      ans = data.at(i) - data.at(i + 1);
      a.push_back(data.at(i));
      b.puah_back(data.at(i + 1));
        co++;
      }else if(co == count - 1) {
        ans = data.at(i) - ans;
      a.push_back(data.at(i + 1));
      b.puah_back(ans);
      } else {
        ans = ans - data.at(i + 1);
      a.push_back(ans);
      b.puah_back(data.at(i + 1));
      }
    }
  }
  for(int i = 0; i < N - 1; i++){
    if(count == 0)break;
    if(data.at(i + 1) >= 0){
      ans = ans - data.at(i + 1);
      a.push_back(ans);
      b.puah_back(data.at(i + 1));
    }
  }
  long cob = 0;
  for(int i = N - 1; i != 1; i++){
    if(count != 0)break;
    ans = data.at(i) - data.at(i - 1);
    a.push_back(data.at(i));
    b.puah_back(data.at(i - 1));
  }
  cout << ans << endl;
  for(int i = 0; i < N; i++){
    cout << a.at(i) << ' ' << b.at(i);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: 'co' was not declared in this scope; did you mean 'coa'?
   18 |       if(co == 0){
      |          ^~
      |          coa
a.cc:21:9: error: 'class std::vector<long int>' has no member named 'puah_back'; did you mean 'push_back'?
   21 |       b.puah_back(data.at(i + 1));
      |         ^~~~~~~~~
      |         push_back
a.cc:26:9: error: 'class std::vector<long int>' has no member named 'puah_back'; did you mean 'push_back'?
   26 |       b.puah_back(ans);
      |         ^~~~~~~~~
      |         push_back
a.cc:30:9: error: 'class std::vector<long int>' has no member named 'puah_back'; did you mean 'push_back'?
   30 |       b.puah_back(data.at(i + 1));
      |         ^~~~~~~~~
      |         push_back
a.cc:39:9: error: 'class std::vector<long int>' has no member named 'puah_back'; did you mean 'push_back'?
   39 |       b.puah_back(data.at(i + 1));
      |         ^~~~~~~~~
      |         push_back
a.cc:47:7: error: 'class std::vector<long int>' has no member named 'puah_back'; did you mean 'push_back'?
   47 |     b.puah_back(data.at(i - 1));
      |       ^~~~~~~~~
      |       push_back
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  ll N;cin>>N;
  ll i,j,k,l;
  ll a[N],b[N];
  rep(i,N) cin>>a[i];
  rep(i,N) b[i]=a[i];
  rep(i,N) b[i]=abs(b[i]);
  sort(b,b+N);
  ll plus=0,minus=0,zero=0;
  ll ans=0;
  rep(i,N){
    if(a[i]>0) plus++;
    else if(a[i]<0) minus++;
    else zero++;
  }
  if(zero+plus==0 or zero+minus==0){
    rep(i,N){
      ans+=b[i];
    }
    ans-=b[0]*2;
    cout<<ans<<endl;
  }
  else{
    rep(i,N){
      ans+=abs(a[i]);
    }
    cout<<ans<<endl;
  }
  sort(a,a+N);
  ll M=N,S=0;
  repn(i,N){
    if(plus>minus){
      cout<<a[S]<<" "<<a[M-1]<<endl;
      a[S]=a[S]-a[N-1];
      M--;
      plus--;
    }
    else if(minus<plus){
      cout<<a[M-1]<<" "<<a[S]<<endl;
      M--;
      minus--;
      s++;
      a[M-1]=a[M-1]-a[0];
    }
    else{
      cout<<a[M-1]<<" "<<a[S]<<endl;
      M--;
      s++;
      a[M-1]=a[M-1]-a[0];
    }
  }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:7: error: 's' was not declared in this scope
   66 |       s++;
      |       ^
a.cc:72:7: error: 's' was not declared in this scope
   72 |       s++;
      |       ^
Language: C++

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<string, int>s_i;
typedef pair<int, string>i_s;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  VEC(a,n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  int ans=a[n-1];
  int imp=-1;
  rep(i,n){
    if(a[i]>=0&&i!=n-1){
      imp=i;
      break;
    }
  }
  rep(i,n-1){
    if(a[i]<0)
      ans-=a[i];
    else if(i==imp)
      ans-=a[i]
    else
      ans+=a[i]
      }
  cout<<ans<<endl;
  if(a[n-1]>=0){
    rep(i,n-1){
      if(a[i]<0){
        a[n-1]-=a[i];
        cout<<a[n-1]<<' '<<a[i];
      }
      else{
        a[i+1]=a[i]-a[i+1];
        cout<<a[i]<<' '<<a[i+1]<<endl;
      }
    }
  }
  else{
    rep(i,n){
      if(a[i]<0){
        a[n-1]-=a[i];
        cout<<a[n-1]<<' '<<a[i];
      }
    }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:44:16: error: expected ';' before 'else'
   44 |       ans-=a[i]
      |                ^
      |                ;
   45 |     else
      |     ~~~~        
a.cc:68:4: error: expected '}' at end of input
   68 |   }
      |    ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<string, int>s_i;
typedef pair<int, string>i_s;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  VEC(a,n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end())
  int ans=a[n-1];
  int imp=-1;
  rep(i,n){
    if(a[i]>=0&&i!=n-1){
      imp=i;
      break;
    }
  }
  rep(i,n-1){
    if(a[i]<0)
      ans-=a[i];
    else if(i==imp)
      ans-=a[i]
    else
      ans+=a[i]
      }
  cout<<ans<<endl;
  if(a[n-1]>=0){
    rep(i,n-1){
      if(a[i]<0){
        a[n-1]-=a[i];
        cout<<a[n-1]<<' '<<a[i];
      }
      else{
        a[i+1]=a[i]-a[i+1];
        cout<<a[i]<<' '<<a[i+1]<<endl;
      }
    }
  }
  else{
    rep(i,n){
      if(a[i]<0){
        a[n-1]-=a[i];
        cout<<a[n-1]<<' '<<a[i];
      }
    }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:31:26: error: expected ';' before 'int'
   31 |   sort(a.begin(),a.end())
      |                          ^
      |                          ;
   32 |   int ans=a[n-1];
      |   ~~~                     
a.cc:42:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |       ans-=a[i];
      |       ^~~
      |       abs
a.cc:44:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |       ans-=a[i]
      |       ^~~
      |       abs
a.cc:48:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |   cout<<ans<<endl;
      |         ^~~
      |         abs
a.cc:68:4: error: expected '}' at end of input
   68 |   }
      |    ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int a[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += abs(a[i]);
    }
    for (int i = 0; i < n / 2; i++)
    {
        if (a[i] >= 0)
        {
            sum -= 2 * a[i];
        }
        if (a[n - 1 - i] < 0)
        {
            sum += 2 * a[i];
        }
    }
    cout << sum << "\n";
    if (n % 2 == 1)
    {
        int count = 1;
        int j = n / 2 + 1;
        int temp = a[n / 2 - 1] - a[n / 2];
        int h = n / 2 - 2;
        cout << a[n / 2 - 1] << " " << a[n / 2] << "\n";
        for (int i = 0; i < n - 2; i++)
        {
            if (count == n - 1)
            {
                break;
            }
            cout << a[j] << " " << temp << "\n";
            temp = a[j] - temp;
            j++;
            count++;
            if (count == n - 1)
            {
                break;
            }
            cout << a[h] << " " << temp << "\n";
            temp = a[h] - temp;
            h--;
            count++;
        }
    }
    else
    {
        int count = 1;
        int j = n / 2 + 2;
        int temp = a[n / 2 + 1] - a[n / 2];
        int h = n / 2 - 1;
        cout << a[n / 2 + 1] << " " << a[n / 2] << "\n";
        for (int i = 0; i < n - 2; i++)
        {
            if (count == n - 1)
            {
                break;
            }
            cout << a[h] << " " << temp << "\n";
            temp = a[h] - temp;
            h--;
            count++;
            if (count == n - 1)
            {
                break;
            }
            cout << a[j] << " " << temp << "\n";
            temp = a[j] - temp;
            j++;
            count++;
        }
    }
}
}

Compiler output:
a.cc:119:1: error: expected declaration before '}' token
  119 | }
      | ^
Language: C++

#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}
int main(void){
	int n, a[100000] = {0}
    long long sum = 0;
	scanf("%d", &n);getchar();
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);getchar();
	}
	qsort(a, n, sizeof(int), compare_int);
	if(n % 2 == 0){
		int k = n / 2;
		for(int i = 0; i < k; i++){
			a[i] *= -1;
		}
		for(int i = 0; i < n; i++){
			sum += a[i];
		}
		printf("%lld\n", sum);
      for(int i = 0; i < k; i++){
			a[i] *= -1;
		}
		int f = 0;
		for(int i = 0; i < k; i++){
			if(i % 2 == 0){
				if(i == 0){
					printf("%d %d\n", a[i + k], a[i]);
					f = a[i + k] - a[i];
				}else{
					printf("%d %d\n", a[i + k], f);
					f = a[i + k] - f;
					printf("%d %d\n", f, a[i]);
					f -= a[i];
				}
			}else{
				printf("%d %d\n", a[i], f);
				f = a[i] - f;
				printf("%d %d\n", f, a[i + k]);
				f -= a[i + k];
			}
		}
	}else{
		int k = (n - 1) / 2;
		for(int i = 0; i < k; i++){
			a[i] *= -1;
		}
		for(int i = 0; i < n; i++){
			sum += a[i];
		}
		printf("%lld\n", sum);
      for(int i = 0; i < k; i++){
			a[i] *= -1;
		}
		int f = 0;
		for(int i = 0; i < k; i++){
			if(i % 2 == 0){
				if(i == 0){
					printf("%d %d\n", a[i], a[i + k]);
					f = a[i] - a[i + k];
				}else{
					printf("%d %d\n", a[i], f);
					f = a[i] - f;
					printf("%d %d\n", f, a[i + k]);
					f -= a[i + k];
				}
			}else{
				printf("%d %d\n", a[i + k], f);
				f = a[i + k] - f;
				printf("%d %d\n", f, a[i]);
				f -= a[i];
			}
		}
		printf("%d %d\n", a[n - 1], f);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: expected ',' or ';' before 'long'
    8 |     long long sum = 0;
      |     ^~~~
a.cc:20:25: error: 'sum' was not declared in this scope
   20 |                         sum += a[i];
      |                         ^~~
a.cc:22:34: error: 'sum' was not declared in this scope
   22 |                 printf("%lld\n", sum);
      |                                  ^~~
a.cc:51:25: error: 'sum' was not declared in this scope
   51 |                         sum += a[i];
      |                         ^~~
a.cc:53:34: error: 'sum' was not declared in this scope
   53 |                 printf("%lld\n", sum);
      |                                  ^~~
Language: C++

#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<algorithm>
#include<deque>
using namespace std;
using ll = long long int;
ll n;
deque<ll> a;
vector<pair<ll, ll>> ret;


pair<ll, ll> pick() {
	pair<ll, ll> ret(a.front(), a.back());
	a.pop_front();
	a.pop_back();
	return ret;
}

ll main(void) {
	cin >> n;
	for (size_t i = 0; i < n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	sort(a.begin(), a.end());
	for (ll i = 0; i < n - 1; i++) {
		pair<ll, ll> tmp = pick();
		if (n % 2 == 0 && i % 2 == 1 || n % 2 == 1 && i % 2 == 0) {
			a.push_front(tmp.first - tmp.second);
			ret.push_back(tmp);
		}
		else {
			a.push_back(tmp.second - tmp.first);
			ret.emplace_back(tmp.second, tmp.first);
		}
	}

	cout << a[0] << endl;
	for (size_t i = 0; i < n - 1; i++) {
		cout << ret[i].first << " " << ret[i].second << endl;
	}
	return 0;
}

Compiler output:
a.cc:21:1: error: '::main' must return 'int'
   21 | ll main(void) {
      | ^~
Language: C

#include<stdio.h>
typedef struct{
  int x;
  int y;
}point;
int main(){
  int i,j,n,m;
  int a[100000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  
  if(n==2){
    if(a[0] < a[1])
      printf("%d\n%d %d\n",a[1]-a[0],a[1],a[0]);
    else
      printf("%d\n%d %d\n",a[0]-a[1],a[0],a[1]);
    return 0;
  }
  int temp,cnt=0;
  for(i=0;i<n;i++){
    for(j=i;j<n;j++){
      if(a[i] > a[j])
		temp=a[i]; a[i]=a[j]; a[j]=temp;
    }
    if(a[i] <= 0)
      cnt=i;
  }
  
  int mx=0; pcnt=0;
  point p[100000];
  for(i=n-1;i>=0;i--){
    if(i==cnt+1){
      p[pcnt].x=i; p[pcnt].y=mx;
      a[i] -= a[mx];
      m = a[i];
      mx++; i++;
    }else{
      p[pcnt].x=mx; p[pcnt].y=i;
      a[mx] -= a[i];
      m = a[mx];
    }
    pcnt++;
  }
  printf("%d",m);
  for(i=0;i<pcnt;i++)
    printf("%d %d",p[i].x,p[i].y);
  
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:31:13: error: 'pcnt' undeclared (first use in this function); did you mean 'cnt'?
   31 |   int mx=0; pcnt=0;
      |             ^~~~
      |             cnt
main.c:31:13: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main(){
    int n, x, y;
    cin >> n;
    vector<int> a(n);
    vector<pair<int, int>> p;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    int tmp = 0;
    int k = 0;
    for(int i = 0; i < n-1; i++)
        sort(a.begin(), a.end());
        if(i == 0){
            x = a[0];
            y = a[1];
            a.erase(a.begin(), a.begin()+1);
        }else if(i == n-2) {
            x = a[0];
            y = tmp;
        } else {
            x = tmp;
            y = a[0];
            a.erase(a.begin(), a.begin()+1);
        }
        tmp = x - y;
        a.push_back(tmp);
        p.push_back(make_pair(x, y));
    }
    ans = tmp;
    cout << ans << endl;
    for(int i = 0; i < n-1; i++){
        cout << p[i].first << " " << p[i].second << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:12: error: 'i' was not declared in this scope
   18 |         if(i == 0){
      |            ^
a.cc: At global scope:
a.cc:34:5: error: 'ans' does not name a type
   34 |     ans = tmp;
      |     ^~~
a.cc:35:5: error: 'cout' does not name a type
   35 |     cout << ans << endl;
      |     ^~~~
a.cc:36:5: error: expected unqualified-id before 'for'
   36 |     for(int i = 0; i < n-1; i++){
      |     ^~~
a.cc:36:20: error: 'i' does not name a type
   36 |     for(int i = 0; i < n-1; i++){
      |                    ^
a.cc:36:29: error: 'i' does not name a type
   36 |     for(int i = 0; i < n-1; i++){
      |                             ^
a.cc:39:5: error: expected unqualified-id before 'return'
   39 |     return 0;
      |     ^~~~~~
a.cc:40:1: error: expected declaration before '}' token
   40 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define rep(i, start, end) for (int i = start; i < end; i++)


int main(){
  int m;

  cin >> m;
  vector<int> a;
  int x;
  int b[m+1];
  rep(i, 0, m) {
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());

  b[0] = a[0];
  rep(i, 0, m-1) {
    b[i + 1] = b[i] - a[m - 1 - i];
  }
  cout << abs(b[m-1]) << endl;
  cout << b[0] << " " << a[m - 1] << endl;
  rep(i, 1, m-1) {
    cout << a[m - (i+1)] << " " << b[i] << endl;
  }

  return 0;
}


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

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N,ans=0,pm=0; //pm＝負の数
  cin>>N;
  vector<int> A;
  vector<int> B;
  for(int i=0; i<N; ++i){
    int a;
    cin>>a;
    if(a<0) pm++;
    if(a>=0) A.push_back(a);
    else B.push_back(abs(a));
  }
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  
  vector<int> C;
  
  if(pm<(N/2)){
    vector<int> D;
    for(int i=0; i<A.size(); ++i){
      D.push_back(A.at(A.size()-i-1));
    }
    
    for(int i=0; i<B.size(); ++i){
      C.push_back(A.at(i));
      C.push_back(-1*B.at(i));
      ans+=A.at(i);
      ans+=B.at(i);
    }
    
    int P=N-2*B.size();
    for(int i=0; i<(P/2); ++i){
      C.push_back(A.at(B.size()+i));
      C.push_back(D.at(i));
      ans+=A.at(B.size()+i);
      ans-=D.at(i);
    }
    if(P%2==1){
      C.push_back(A.at(B.size()+(P/2)));
      ans+=A.at(B.size()+(P/2));
    }
    
    cout<<ans<<endl;
    
    vector<int> Q;
    for(int i=N-1; i>=0; --i){
      Q.push_back(C.at(i));
    }
    
    int t=0;
    for(int i=0; i<N-1; ++i){
      if(i==0){
        cout<<Q.at(0)<<Q.at(1)<<endl;
        if(N%2==1) t=Q.at(1)-Q.at(0);
        else t=Q.at(0)-Q.at(1);
      }
      else{
        t=Q.at(i)-t;
        cout<<Q.at(i)<<t<<endl;
      }
    }
    
  }
  
  else{
    vector<int> D;
    for(int i=0; i<B.size(); ++i){
      D.push_back(B.at(B.size()-i-1));
    }
    
    for(int i=0; i<A.size(); ++i){
      C.push_back(-1*B.at(i));
      C.push_back(A.at(i));
      ans+=A.at(i);
      ans+=B.at(i);
    }
    
    vector<int> Q;
    for(int i=C.size()-1; i>=0; --i){
      Q.push_back(C.at(i));
    }
    
    int t=0;
    for(int i=0; i<C.size()-1; ++i){
      if(i==0){
        cout<<Q.at(0)<<Q.at(1)<<endl;
        t=Q.at(0)-Q.at(1);
      }
      else{
        t=Q.at(i)-t;
        cout<<Q.at(i)<<t<<endl;
      }
    }
    
    
    int P=N-2*A.size();
    for(int i=0; i<P; ++i){
      Q.push_back(B.at(A.size()+i));
      ans+=B.at(A.size()+i);
    }
    
    cout<<ans<<endl;
    
    for(int i=2*A.size(); i<N-1; ++i){
      if(i==0){
        cout<<Q.at(0)<<Q.at(1)<<endl;
        else t=Q.at(0)-Q.at(1);
      }
      else{
        t=Q.at(i)-t;
        cout<<Q.at(i)<<t<<endl;
      }
    }
    
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:120:9: error: expected '}' before 'else'
  120 |         else t=Q.at(0)-Q.at(1);
      |         ^~~~
a.cc:118:15: note: to match this '{'
  118 |       if(i==0){
      |               ^
a.cc:122:7: error: 'else' without a previous 'if'
  122 |       else{
      |       ^~~~
a.cc:123:16: error: 'i' was not declared in this scope
  123 |         t=Q.at(i)-t;
      |                ^
a.cc: At global scope:
a.cc:130:1: error: expected declaration before '}' token
  130 | }
      | ^
Language: C++

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

int main(){
    int n;
    cin >> n;
    int x[n-1], y[n-1];
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    int tmp = 0;
    int k = 0;
    while(true){
        sort(a.begin(), a.end());
        if(k == 0){
            x[k] = a[0];
            y[k] = a[1];
            a.erase(a.begin(), a.begin()+1);
        }else if(k == n-2) {
            x[k] = a[0];
            y[k] = tmp;
            break;
        } else {
            x[k] = tmp;
            y[k] = a[0];
            a.erase(a.begin(), a.begin()+1);
        }
        tmp = x[i] - y[i];
        a.push_back(tmp);
        k++;
    }
    ans = tmp;
    cout << ans << endl;
    for(int i = 0; i < n-1; i++){
        cout << x[i] << " " << y[i] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: 'i' was not declared in this scope
   31 |         tmp = x[i] - y[i];
      |                 ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<long long> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i];
	}
	sort(da.begin(), da.end());
	if (da[0] > 0) {
		long long ans = -da[0];
		for (int i = 1;i < n;i++) {
			ans += da[i];
		}
		cout << ans << endl;
		for (int i = 1;i < n - 1;i++) {
			cout << da[0] << ' ' << da[i] << endl;
			da[0] -= da[i];
		}
		cout << da[n - 1] << ' ' << da[0] << endl;
	}
	else if (da[n - 1] < 0) {
		long long ans = da[n - 1];
		for (int i = 0;i < n - 1;i++) {
			ans -= da[i];
		}
		cout << ans << endl;
		for (int i = 0;i < n - 1;i++) {
			cout << da[n - 1] << ' ' << da[i] << endl;
			da[n - 1] -= da[i];
		}
	}
	else {
		long long ans = 0;
		for (int i = 0;i < n;i++) {
			ans += abs(da[i]);
		}
		cout << ans << endl;
		long long num = 0;
		while (da[num] < 0) {
			num++;
		}
		long long jio = num;
		num -= 1;
		while (num > 0) {
			cout << da[jio] << ' ' << da[num] << endl;
			da[jio] -= da[num];
			num--;
		}
		while (jio < n - 1) {
			cout << da[0] << ' ' << da[jio] << endl;
			da[0] -= da[jio];
			jio++;
		}
		cout << da[n - 1] << ' ' << da[0] << endl;
		return 0;
	}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:10: error: expected '}' at end of input
   64 |         }
      |          ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    
    priority_queue<int> pq;
    priority_queue_lo<int> pql;
    map<int, int> mp;
    REP(i,N) {
        pq.push(A[i]);
        pql.push(A[i]);
        mp[A[i]]++;
    }

    vi vx, vy;
    REP(i,N-1) {
        if (i%2==0) {
            int x = pql.top();
            if (mp.count(x)>0) {
                mp[x]--;
                pql.pop();
            }
            int y = pq.top();
            if (mp.count(y)>0) {
                mp[y]--;
                pq.pop();
            }
            pql.push(x - y);
            pq.push(x - y);
            mp[x - y]++;
            vx.push_back(x);
            vy.push_back(y);
        } else {
            int y = pql.top();
            if (mp.count(y)>0) {
                mp[y]--;
                pql.pop();
            }
            int x = pq.top();
            if (mp.count(x)>0) {
                mp[x]--;
                pq.pop();
            }
            pql.push(x - y);
            pq.push(x - y);
            mp[x - y]++;
            vx.push_back(x);
            vy.push_back(y);
        }
    }

    int ans = pq.top();
    cout << ans << endl;
    REP(i,N-1) {
        cout << vx[i] << " " << vy[i] << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'priority_queue_lo' was not declared in this scope
   37 |     priority_queue_lo<int> pql;
      |     ^~~~~~~~~~~~~~~~~
a.cc:37:23: error: expected primary-expression before 'int'
   37 |     priority_queue_lo<int> pql;
      |                       ^~~
a.cc:41:9: error: 'pql' was not declared in this scope; did you mean 'pq'?
   41 |         pql.push(A[i]);
      |         ^~~
      |         pq
a.cc:48:21: error: 'pql' was not declared in this scope; did you mean 'pq'?
   48 |             int x = pql.top();
      |                     ^~~
      |                     pq
a.cc:64:21: error: 'pql' was not declared in this scope; did you mean 'pq'?
   64 |             int y = pql.top();
      |                     ^~~
      |                     pq
Language: Java

import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_n, i;
      	long sum = 0;
      	number_n = Integer.parseInt(sc.next());
        long[] number = new long[number_n];
      	for(i = 0; i < number_n; i++) {
          number[i] = Long.parseLong(sc.next());
          sum += number[i];
        }
      	Arrays.sort(number);
      	sum -= 2 * number[0];
      	System.out.println(sum);
      	for(i = 0; i < number_n - 2; i++) {
          System.out.println(number[i]);
          System.out.println(" ");
          System.out.println(number[i+1]);
          System.out.println"\n");
          number[i+1] = number[i] - number[i+1];
      	}
      	System.out.println(number[i+1]);
          System.out.println(" ");
          System.out.println(number[i]);
          System.out.println"\n");
    }
}

Compiler output:
Main.java:21: error: not a statement
          System.out.println"\n");
                    ^
Main.java:21: error: ';' expected
          System.out.println"\n");
                            ^
Main.java:27: error: not a statement
          System.out.println"\n");
                    ^
Main.java:27: error: ';' expected
          System.out.println"\n");
                            ^
4 errors
Language: C++

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



int main(){
	
	int n,mx;
	cin>>n;

	vector<int>a(n);
	for(int i=0;i<n;i++)cin>>a[i];

	vector<int>x(n);
	vector<int>y(n);

	sort(a.begin(),a.end());

	int hozon;
	

	for(int i=;i<n-1;i++){
		if(i==0){
			x[0]=a[i];
			y[0]=a[i+1];
			hozon=a[i]-a[i+1];
		}else if(i=n-2){
			x[i]=a[i+1];
			y[i]=hozon;
			hozon=a[i+1]-hozon;
		}else{
			x[i]=hozon;
			y[i]=a[i+1];
			hozon = hozon-a[i];
		}

	}





	cout<<hozon<<endl;
	for(int i=0;i<n-1;i++){
		cout<<x[i]<<" "<<y[i]<<endl;
	}


}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: expected primary-expression before ';' token
   22 |         for(int i=;i<n-1;i++){
      |                   ^
Language: C++

int N, A[1d5];

int res, ress, resx[1d5], resy[1d5];

int doit(int x, int y){
  resx[ress] = x;
  resy[ress++] = y;
  return x - y;
}

{
  int i, j, k;
  rd(N,A(N));
  sort(A, A+N);

  if(A[0] >= 0){
    rep(i,1,N-1) A[0] = doit(A[0], A[i]);
    doit(A[N-1], A[0]);
  } else if(A[N-1] <= 0) {
    rep(i,N-1) A[N-1] = doit(A[N-1], A[i]);
  } else {
    for(i=N-2;i>=0;i--){
      if(A[i] >= 0) A[0] = doit(A[0], A[i]);
      else          A[N-1] = doit(A[N-1], A[i]);
    }
  }
  res = A[N-1];

  wt(res);
  rep(i,ress) wt(resx[i], resy[i]);
}


Compiler output:
a.cc:1:10: error: unable to find numeric literal operator 'operator""d5'
    1 | int N, A[1d5];
      |          ^~~
a.cc:3:21: error: unable to find numeric literal operator 'operator""d5'
    3 | int res, ress, resx[1d5], resy[1d5];
      |                     ^~~
a.cc:3:32: error: unable to find numeric literal operator 'operator""d5'
    3 | int res, ress, resx[1d5], resy[1d5];
      |                                ^~~
a.cc: In function 'int doit(int, int)':
a.cc:6:3: error: 'resx' was not declared in this scope; did you mean 'ress'?
    6 |   resx[ress] = x;
      |   ^~~~
      |   ress
a.cc:7:3: error: 'resy' was not declared in this scope; did you mean 'ress'?
    7 |   resy[ress++] = y;
      |   ^~~~
      |   ress
a.cc: At global scope:
a.cc:11:1: error: expected unqualified-id before '{' token
   11 | {
      | ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
int T,n,m;
priority_queue <ll,vector<ll>,greater<ll> > q;
vector< pair<int,int> > num;
int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		ll t;
		cin>>t;
		q.push(t);
	}
	int cnt = 0;
	while(q.size()!=2){
		ll x=q.top();
		q.pop();
		ll y=q.top();
		q.pop();
		
		num.push_back({x,y});
		x-=y;cnt++;
		q.push(x);
	}
	ll x = q.top();
	q.pop();
	ll y = q.top();
	num.push_back({x,y});
	cout<<y-x<<endl;
	for(int i =0;i<cnt;i++)
		cout<<num[i].first<<" "<<num[i].second<<"\n";
	cout<<y<<" "x<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:49:18: error: unable to find string literal operator 'operator""x' with 'const char [2]', 'long unsigned int' arguments
   49 |         cout<<y<<" "x<<endl;
      |                  ^~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>

typedef long long ll;

ll a[112345];
ll wa[112345], wb[112345];

int main(){
	int n; scanf("%d", &n);
	for(int i(1); i <= n; ++i) scanf("%lld", &a[i]);
	std::sort(a + 1, a + n + 1);
	ll now;
	if(n % 2 == 1){
		now = a[1] - a[n];
		wa[1] = a[1], wb[1] = a[n];
		for(int i(2), l(2), r(n - 1); i < n; ++i){
			wb[i] = now;
			if(i % 2 == 1){
				wa[i] = a[l]; ++l; 
			}
			else{
				wa[i] = a[r]; --r;
			}
			now = wa[i] - wb[i];
		}
	}
	else{
		now = a[n] - a[1];
		wa[1] = a[n], wb[1] = a[1];
		for(int i(2), l(2), r(n - 1); i < n; ++i){
			wb[i] = now;
			if(i % 2 == 0){
				wa[i] = a[l]; ++l; 
			}
			else{
				wa[i] = a[r]; --r;
			}
			now = wa[i] - wb[i];
		}
	}
	printf("%lld\n", now);
	for(int i(1); i < n; ++i){
		printf("%lld %lld\n", wa[i], wb[i]);
	}
	flush(); return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'flush' was not declared in this scope; did you mean 'fflush'?
   48 |         flush(); return 0;
      |         ^~~~~
      |         fflush
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
	cin >> n;
    int a[n];
    int m=0;
    int x,y;
    fr(i,n){
     cin >> a[i];
     m+=abs(a[i]); 
    }
    sort(a,a+n);
    if(a[0]<0&&0<a[n-1]){
     cout <<m<< endl;
     int plus;
     fr(i,n){
       if(a[i]>0){
         plus = i;
           break;
       }
     }
     x = a[plus-1];
     y = a[plus]
     fr(i,n-1-plus){
       cout <<x<<" "<<y<< endl;
       x = x-y;
       y = a[plus+i+1];
     }
     x += y;
     y = x-y;
     x -= y;
     
     fr(i,plus){
       cout <<x<<" "<<y<< endl;
       x = x-y;
       y = a[i];
     }
    }else if(a[0]>=0){
      cout <<m-2*a[0]<< endl;
      x=a[0];
      y = a[1];
      fr(i,n-2){
       cout <<x<<" "<<y<< endl;
       x = x-y;
       y = a[i+2];
     }
     cout <<y<<" "<<x<< endl;
    }else{
      cout <<m-2*a[0]<< endl;
      x=a[n-1];
      y=a[0];
      fr(i,n-1){
       cout <<x<<" "<<y<< endl;
       x = x-y;
       y = a[i+1];
      }
   }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: expected ';' before 'for'
   30 |      y = a[plus]
      |                 ^
      |                 ;
a.cc:31:9: error: 'i' was not declared in this scope
   31 |      fr(i,n-1-plus){
      |         ^
a.cc:5:29: note: in definition of macro 'fr'
    5 | #define fr(i,n) for(int i=0;i<n;i++)
      |                             ^
Language: C++

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

int main(){
   int N;
   cin >> N;
   vector<int> vec;
   sort(vec.begin(), vec.end());
   int sum = (-2)*vec.at(0)
   for(int i=0,i<N, i++){
       sum += vec.at(i);
   }
   cout << sum << endl;

   for(int i=0, i<N-2, i++){
       cout << vec.at(i) << " "<< vec.at(i+1)<<endl;
       vec.at(i+1) = vec.at(i)-vec.at(i+1);
   }
   cout << vec.at(N-1) << " " << vec.at(N-2) <<endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:4: error: expected ',' or ';' before 'for'
   10 |    for(int i=0,i<N, i++){
      |    ^~~
a.cc:15:18: error: expected ';' before '<' token
   15 |    for(int i=0, i<N-2, i++){
      |                  ^
      |                  ;
a.cc:15:18: error: expected primary-expression before '<' token
a.cc:15:27: error: expected ';' before ')' token
   15 |    for(int i=0, i<N-2, i++){
      |                           ^
      |                           ;
Language: C++

#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    int N;
    int a;
    int sum = 0;
    int front, back;
    vector<int> A;

    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> a;
        A.push_back(a);
    }
    
    sort(A.begin(), A.end());

    for(int i = 0; i < N; i++){
        if(i < N / 2){
            sum -= A[i];
        }else{
            sum += A[i];
        }
    }

    cout << sum << endl;

    for(int i = 0; i < N; i++){
        cout << A[i] << " ";
    }
    cout << endl;

    while(A.size() > 1){
        vector<int> A_sub;
        for(int i = 0; i < N / 2; i++){
            front = A[i];
            back = A[N - i - 1];
            if(i % 2 == 0){
                A_sub.push_back(front - back);
                cout << front << " " << back << endl;
            }else{
                A_sub.push_back(back - front);
                cout << back << " " << front << endl;
            }
        }
        if(N % 2 == 1){
            A_sub.push_back(N / 2);
        }
        N = (N / 2) + (N % 2);
        A = A_sub;
    }

    return 0;
}


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

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

int main(){
    int i, n, res1 = 0, res2 = 0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    res2 = a[n-1];
    res1 = a[0];
    for(i=1; i<n-1; i++){
        if(a[i] < 0){
            res2 -= a[i];
        }else{
            res1 -= a[i];
        }
    }
    cout << res2 - res1 << '\n';
    res2 = a[n-1];
    res1 = a[0]
    for(i=1; i<n-1; i++){
        if(a[i] < 0){
            cout << res2 << ' ' << a[i] << '\n';
            res2 -= a[i];
        }else{
            cout << res1 << ' ' << a[i] << '\n';
            res1 -= a[i];
        }
    }
    cout << res2 << ' ' << res1;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:16: error: expected ';' before 'for'
   23 |     res1 = a[0]
      |                ^
      |                ;
   24 |     for(i=1; i<n-1; i++){
      |     ~~~         
a.cc:24:24: error: expected ';' before ')' token
   24 |     for(i=1; i<n-1; i++){
      |                        ^
      |                        ;
Language: C++

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

int main(){
    int i, n, res1 = 0, res2 = 0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    res2 = a[n-1];
    res1 = a[0]
    for(i=1; i<n-1; i++){
        if(a[i] < 0){
            res2 -= a[i];
        }else{
            res1 -= a[i];
        }
    }
    cout << res2 - res1 << '\n';
    res2 = a[n-1];
    res1 = a[0]
    for(i=1; i<n-1; i++){
        if(a[i] < 0){
            cout << res2 << ' ' << a[i] << '\n';
            res2 -= a[i];
        }else{
            cout << res1 << ' ' << a[i] << '\n';
            res1 -= a[i];
        }
    }
    cout << res2 << ' ' << res1;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: expected ';' before 'for'
   13 |     res1 = a[0]
      |                ^
      |                ;
   14 |     for(i=1; i<n-1; i++){
      |     ~~~         
a.cc:14:24: error: expected ';' before ')' token
   14 |     for(i=1; i<n-1; i++){
      |                        ^
      |                        ;
a.cc:23:16: error: expected ';' before 'for'
   23 |     res1 = a[0]
      |                ^
      |                ;
   24 |     for(i=1; i<n-1; i++){
      |     ~~~         
a.cc:24:24: error: expected ';' before ')' token
   24 |     for(i=1; i<n-1; i++){
      |                        ^
      |                        ;
Language: C++

#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[100010],b[100010];
int main()
{
	int i,j,k,n,m,y;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	ll sum=0;
	for(i=0;i<n/2;i++)
	{
		sum-=a[i];
	}
	for(i=n/2;i<n;i++)
	{
		sum+=a[i];
	}
	printf("%lld\n",sum);
	if(n%2==0)
	{
		for(i=0;i<n;i+=2)
		{
			b[i]=a[n/2+i/2];
			b[i+1]=a[i/2];
		}
	}
	else
	{
		for(i=0;i<n;i+=2)
		{
			b[i]=a[n/2+1+i/2];
			b[i+1]=a[i/2];
		}
		b[n-1]=a[n/2];
	}
	ll x=b[n-1];
	for(i=n-2;i>=0;i--)
	{
		printf("%d %lld\n",b[i],x);
		x=1ll*b[i]-x;
	}
	return 0;
}
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[100010],b[100010];
int main()
{
	int i,j,k,n,m,y;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	ll sum=0;
	for(i=0;i<n/2;i++)
	{
		sum-=a[i];
	}
	for(i=n/2;i<n;i++)
	{
		sum+=a[i];
	}
	printf("%lld\n",sum);
	if(n%2==0)
	{
		for(i=0;i<n;i+=2)
		{
			b[i]=a[n/2+i/2];
			b[i+1]=a[i/2];
		}
	}
	else
	{
		for(i=0;i<n;i+=2)
		{
			b[i]=a[n/2+1+i/2];
			b[i+1]=a[i/2];
		}
		b[n-1]=a[n/2];
	}
	ll x=b[n-1];
	for(i=n-2;i>=0;i--)
	{
		printf("%d %lld\n",b[i],x);
		x=1ll*b[i]-x;
	}
	return 0;
}


Compiler output:
a.cc:82:5: error: redefinition of 'int a [100010]'
   82 | int a[100010],b[100010];
      |     ^
a.cc:19:5: note: 'int a [100010]' previously declared here
   19 | int a[100010],b[100010];
      |     ^
a.cc:82:15: error: redefinition of 'int b [100010]'
   82 | int a[100010],b[100010];
      |               ^
a.cc:19:15: note: 'int b [100010]' previously declared here
   19 | int a[100010],b[100010];
      |               ^
a.cc:83:5: error: redefinition of 'int main()'
   83 | int main()
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main()
      |     ^~~~
Language: C

#include<stdio.h>
int main()
{
  int n,a[10000];
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  for(int i=0;i<n;i++)
  {
    for(int j=i;j<n;j++)
    {
      if(a[j]>a[j+1])
      {
        int temp=a[j+1];
        a[j+1]=a[j];
        a[j]=temp;
      }
    }
    printf("%d\n",a[n-1]-(a[0]-a[1]));
    printf("%d %d\n",a[0],a[1]);
    printf("%d %d",a[n-1],a[0]-a[1]);
  }
        

Compiler output:
main.c: In function 'main':
main.c:24:3: error: expected declaration or statement at end of input
   24 |   }
      |   ^
Language: Java

import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_n, i
        long sum = 0;
      	number_n = Integer.parseInt(sc.next());
        int[] number = new int[number_n];
      	for(i = 0; i < number_n; i++) {
          number[i] = Integer.parseInt(sc.next());
          sum += number[i];
        }
      	Arrays.sort(number);
      	sum -= 2 * number[0];
      	System.out.println(sum);
      	for(i = 0; i < number_n - 1; i++) {
          System.out.println(number[i] + " " + number[i+1]);
          number[i+1] = number[i] - number[i+1];
      	}
    }
}

Compiler output:
Main.java:6: error: ';' expected
      	int number_n, i
      	               ^
1 error
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  std::vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int neg_index = -1, ans = 0;
  while (neg_index + 1 < n && a[neg_index + 1] <= 0) { neg_index++; }
  for (int i = 0; i < n; i++) {
    ans += abs(a[i]);
  }
  if (neg_index>= 0 && neg_index < n - 1) {
    cout << ans << endl;
    int temp = a[neg_index];
    for (int i = neg_index + 1; i < n - 1; i++) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i]
    }
    cout << a[n - 1] << " " << temp << endl;
    temp = a[n - 1] - temp;
    for (int i = 0; i < neg_index; i++) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i];
    }
  } else if (neg_index == -1) {
    ans -= 2 * a[0];
    int temp = a[0];
    for (int i = 1; i < n - 1; i++) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i];
    }
    cout << a[n - 1] << " " << temp << endl;
  } else {
    ans += 2 * a[n - 1];
    int temp = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
      cout << temp << " " << a[i] << endl;
      temp -= a[i];
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:19: error: expected ';' before '}' token
   23 |       temp -= a[i]
      |                   ^
      |                   ;
   24 |     }
      |     ~
Language: C++

#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

void solve(ld g, ld s, ll ga, ll gb, ll sa, ll sb) {
	if (g < s) { swap(g, s); swap(ga, sa); swap(gb, sb); }
	else if (g == s) {
		if (gb > sb) { swap(g, s); swap(ga, sa); swap(gb, sb); }
	}
}
signed main() {
	ll n, ga, sa, ba, gb, sb, bb;
	cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
	ll ans = 0;
	for (int h = 0; h <= 5001; h++) {
		for (int i = 0; i <= 5001; i++) {
			if (ga * h + sa * i > n) { continue; }
			ans = max(ans, (h * (gb - ga)) + (i * (sb - sa)) + ((n - (ga * h + sa * i)) / ba) * max((ll)0, bb - ba));
		}
	}
	n += ans; ans = 0;

	ld g = ga / gb, s = sa / sb, b = ba / bb;
	solve(g, s, ga, gb, sa, sb);
	solve(s, b, sa, sb, ba, bb);
	solve(g, s, ga, gb, sa, sb);

	ll a = 100, b = 100;
	if (g == s) {
		if (gb < sb) { a = 25000000; }
		else { b = 25000000; }
	}
	else if (g > s) { a = 25000000; }
	else { b = 25000000; }
	for (int h = 0; h <= a; h++) {
		for (int i = 0; i <= b; i++) {
			if (gb * h + sb * i > n) { break; }
			ans = max(ans, (h * (ga - gb)) + (i * (sa - sb)) + ((n - (gb * h + sb * i)) / bb) * max((ll)0, ba - bb));
		}
	}
	n += ans;
	cout << n << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:21: error: conflicting declaration 'll b'
   35 |         ll a = 100, b = 100;
      |                     ^
a.cc:30:38: note: previous declaration as 'ld b'
   30 |         ld g = ga / gb, s = sa / sb, b = ba / bb;
      |                                      ^