Language: C++

include <iostream>
using namespace std;
#define MAX_N 50
bool ascending(int array[], int len);

int main() {
    int N;
    int p[MAX_N];
    int previous;
    int num_swap = 0;

    cin >> N;
    for (int n_i = 0; n_i < N; n_i++)
        cin >> p[n_i];


    if (ascending(p, N)) {
        cout << "YES\n";
        return 0;

    }

    previous = p[0];
    for (int n_i = 1; n_i < N; n_i++) {
        if (previous > p[n_i])
            num_swap++;
        previous = p[n_i];
    }

    switch(num_swap)  {
        case 1:
        {
            previous = p[0];
            for (int n_i = 1; n_i < N; n_i++) {
                if (previous > p[n_i]) {
                    swap(p[n_i - 1], p[n_i]);
                    if (ascending(p, N)) {
                        cout << "YES\n";
                    } else {
                        cout << "NO\n";
                    }
                }
                previous = p[n_i];
            }
            break;
       }
        case 2:
        {
            previous = p[0];
            bool is_first = true;
            int swap1;
            for (int n_i = 1; n_i < N; n_i++) {
                if (previous > p[n_i]) {
                    if (is_first) {
                        swap1 = n_i - 1;
                        is_first = false;
                    } else {
                        swap(p[swap1], p[n_i]);
                        if (ascending(p, N)) {
                            cout << "YES\n";
                        } else {
                            cout << "NO\n";
                        }
                        break;
                    }
                }
                previous = p[n_i];
            }
            break;
        }
        default:
            cout << "NO3\n";
    }

    return 0;
}

bool ascending(int array[], int len) {
    int previous;
    previous = array[0];
    for (int a_i = 1; a_i < len; a_i++) {
        if (array[a_i] < previous)
            return false;
    }
    return true;
}
                    

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:12:5: error: 'cin' was not declared in this scope
   12 |     cin >> N;
      |     ^~~
a.cc:18:9: error: 'cout' was not declared in this scope
   18 |         cout << "YES\n";
      |         ^~~~
a.cc:36:21: error: 'swap' was not declared in this scope
   36 |                     swap(p[n_i - 1], p[n_i]);
      |                     ^~~~
a.cc:38:25: error: 'cout' was not declared in this scope
   38 |                         cout << "YES\n";
      |                         ^~~~
a.cc:40:25: error: 'cout' was not declared in this scope
   40 |                         cout << "NO\n";
      |                         ^~~~
a.cc:58:25: error: 'swap' was not declared in this scope; did you mean 'swap1'?
   58 |                         swap(p[swap1], p[n_i]);
      |                         ^~~~
      |                         swap1
a.cc:60:29: error: 'cout' was not declared in this scope
   60 |                             cout << "YES\n";
      |                             ^~~~
a.cc:62:29: error: 'cout' was not declared in this scope
   62 |                             cout << "NO\n";
      |                             ^~~~
a.cc:72:13: error: 'cout' was not declared in this scope
   72 |             cout << "NO3\n";
      |             ^~~~