Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long;
signed main()
{
    int n;
    cin >> n;
    vector< int > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if (a[0] * a[n - 1] < 0) {
        int j = n - 1, ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > 0)
                j = min(j, i);
            ans += (a[i] < 0 ? -1 * a[i] : a[i]);
        }
        cout << ans << endl;
        int tmp = a[0] - a[j];
        cout << a[0] << " " << a[j] << endl;
        for (int i = j + 1; i < n - 1; i++) {
            cout << tmp << " " << a[i] << endl;
            tmp -= a[i];
        }
        cout << a[n - 1] << " " << tmp << endl;
        tmp = a[n - 1] - tmp;
        for (int i = 1; i < j; i++) {
            cout << tmp << " " << a[i] << endl;
            tmp -= a[i];
        }
    } else {
        if (a[0] + a[n - 1] < 0) {
            reverse(a.begin(), a.end());
            int ans = a[0];
            for (int i = 1; i < n; i++) {
                ans -= a[i];
            }
            cout << ans << endl;
            int tmp = a[0];
            for (int i = 1; i < n; i++) {
                cout << tmp << " " << a[i] << endl;
                tmp -= a[i];
            }
        } else {
            int ans = -1 * a[0];
            for (int i = 1; i < n; i++) {
                ans += a[i];
            }
            cout << ans << endl;
            int tmp = a[0];
            for (int i = 1; i < n - 1; i++) {
                cout << tmp << " " << a[i] << endl;
                tmp -= a[i];
            }
            cout << a[n - 1] << " " << tmp << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:6:5: note: in expansion of macro 'int'
    6 |     int n;
      |     ^~~
a.cc:6:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 |     int n;
      |         ^
      |         yn
a.cc:3:18: error: template argument 1 is invalid
    3 | #define int long long;
      |                  ^~~~
a.cc:8:13: note: in expansion of macro 'int'
    8 |     vector< int > a(n);
      |             ^~~
a.cc:3:18: error: template argument 2 is invalid
    3 | #define int long long;
      |                  ^~~~
a.cc:8:13: note: in expansion of macro 'int'
    8 |     vector< int > a(n);
      |             ^~~
a.cc:8:17: error: expected primary-expression before '>' token
    8 |     vector< int > a(n);
      |                 ^
a.cc:8:19: error: 'a' was not declared in this scope
    8 |     vector< int > a(n);
      |                   ^
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:9:10: note: in expansion of macro 'int'
    9 |     for (int i = 0; i < n; i++) {
      |          ^~~
a.cc:9:14: error: 'i' was not declared in this scope
    9 |     for (int i = 0; i < n; i++) {
      |              ^
a.cc:9:26: error: expected ')' before ';' token
    9 |     for (int i = 0; i < n; i++) {
      |         ~                ^
      |                          )
a.cc:9:28: error: 'i' was not declared in this scope
    9 |     for (int i = 0; i < n; i++) {
      |                            ^
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:14:9: note: in expansion of macro 'int'
   14 |         int j = n - 1, ans = 0;
      |         ^~~
a.cc:14:13: error: 'j' was not declared in this scope; did you mean 'jn'?
   14 |         int j = n - 1, ans = 0;
      |             ^
      |             jn
a.cc:14:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |         int j = n - 1, ans = 0;
      |                        ^~~
      |                        abs
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:15:14: note: in expansion of macro 'int'
   15 |         for (int i = 0; i < n; i++) {
      |              ^~~
a.cc:15:30: error: expected ')' before ';' token
   15 |         for (int i = 0; i < n; i++) {
      |             ~                ^
      |                              )
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:21:9: note: in expansion of macro 'int'
   21 |         int tmp = a[0] - a[j];
      |         ^~~
a.cc:21:13: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   21 |         int tmp = a[0] - a[j];
      |             ^~~
      |             tm
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:23:14: note: in expansion of macro 'int'
   23 |         for (int i = j + 1; i < n - 1; i++) {
      |              ^~~
a.cc:23:38: error: expected ')' before ';' token
   23 |         for (int i = j + 1; i < n - 1; i++) {
      |             ~                        ^
      |                                      )
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:29:14: note: in expansion of macro 'int'
   29 |         for (int i = 1; i < j; i++) {
      |              ^~~
a.cc:29:30: error: expected ')' before ';' token
   29 |         for (int i = 1; i < j; i++) {
      |             ~                ^
      |                              )
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:36:13: note: in expansion of macro 'int'
   36 |             int ans = a[0];
      |             ^~~
a.cc:36:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |             int ans = a[0];
      |                 ^~~
      |                 abs
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:37:18: note: in expansion of macro 'int'
   37 |             for (int i = 1; i < n; i++) {
      |                  ^~~
a.cc:37:34: error: expected ')' before ';' token
   37 |             for (int i = 1; i < n; i++) {
      |                 ~                ^
      |                                  )
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:41:13: note: in expansion of macro 'int'
   41 |             int tmp = a[0];
      |             ^~~
a.cc:41:17: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   41 |             int tmp = a[0];
      |                 ^~~
      |                 tm
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:42:18: note: in expansion of macro 'int'
   42 |             for (int i = 1; i < n; i++) {
      |                  ^~~
a.cc:42:34: error: expected ')' before ';' token
   42 |             for (int i = 1; i < n; i++) {
      |                 ~                ^
      |                                  )
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:47:13: note: in expansion of macro 'int'
   47 |             int ans = -1 * a[0];
      |             ^~~
a.cc:47:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |             int ans = -1 * a[0];
      |                 ^~~
      |                 abs
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:48:18: note: in expansion of macro 'int'
   48 |             for (int i = 1; i < n; i++) {
      |                  ^~~
a.cc:48:34: error: expected ')' before ';' token
   48 |             for (int i = 1; i < n; i++) {
      |                 ~                ^
      |                                  )
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:52:13: note: in expansion of macro 'int'
   52 |             int tmp = a[0];
      |             ^~~
a.cc:52:17: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   52 |             int tmp = a[0];
      |                 ^~~
      |                 tm
a.cc:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
a.cc:53:18: note: in expansion of macro 'int'
   53 |             for (int i = 1; i < n - 1; i++) {
      |                  ^~~
a.cc:53:38: error: expected ')' before ';' token
   53 |             for (int i = 1; i < n - 1; i++) {
      |                 ~                    ^
      |                                      )