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

#inclde<bits/stdc++.h>
using namespace std;
int main(){
	int n,c=0;
  	cin>>n;
	vector<int> v(n,0);
  	vector<int> b(n,0);
  	for(int i=0;i<n;i++){
  	cin>>v[i];
  	}
  	b = v;
  	sort(b.begin(),b.end());
    for(int i=0;i<n;i++){
    	if(v[i] != b[i]){
        c++;
        }
    }
  	if(c>2){
    	cout<<"NO"<<"\n";
    }
  else{
    cout<<"YES"<<"\n";
	return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inclde; did you mean #include?
    1 | #inclde<bits/stdc++.h>
      |  ^~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:5:9: error: 'cin' was not declared in this scope
    5 |         cin>>n;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inclde<bits/stdc++.h>
a.cc:6:9: error: 'vector' was not declared in this scope
    6 |         vector<int> v(n,0);
      |         ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #inclde<bits/stdc++.h>
a.cc:6:16: error: expected primary-expression before 'int'
    6 |         vector<int> v(n,0);
      |                ^~~
a.cc:7:16: error: expected primary-expression before 'int'
    7 |         vector<int> b(n,0);
      |                ^~~
a.cc:9:14: error: 'v' was not declared in this scope
    9 |         cin>>v[i];
      |              ^
a.cc:11:9: error: 'b' was not declared in this scope
   11 |         b = v;
      |         ^
a.cc:11:13: error: 'v' was not declared in this scope
   11 |         b = v;
      |             ^
a.cc:12:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |         sort(b.begin(),b.end());
      |         ^~~~
      |         short
a.cc:19:9: error: 'cout' was not declared in this scope
   19 |         cout<<"NO"<<"\n";
      |         ^~~~
a.cc:19:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout<<"YES"<<"\n";
      |     ^~~~
a.cc:22:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:24:2: error: expected '}' at end of input
   24 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

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

int main() {
int A;
 cin >> A;
vector<int> B(A);
for(int i = 0;i < A;i++){
cin >> A[i];
}
 int count = 0;
for(int i = 0;i < (int)n;i++){
  if(A[i] != i + 1){
    k++;
  }
}
 if(count <= 2){
   cout << "YES" << endl;
 }
 if(count > 2){
   cout << "NO"
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: invalid types 'int[int]' for array subscript
    9 | cin >> A[i];
      |         ^
a.cc:12:24: error: 'n' was not declared in this scope
   12 | for(int i = 0;i < (int)n;i++){
      |                        ^
a.cc:13:7: error: invalid types 'int[int]' for array subscript
   13 |   if(A[i] != i + 1){
      |       ^
a.cc:14:5: error: 'k' was not declared in this scope
   14 |     k++;
      |     ^
a.cc:21:16: error: expected ';' before '}' token
   21 |    cout << "NO"
      |                ^
      |                ;
   22 |  }
      |  ~              
a.cc:22:3: error: expected '}' at end of input
   22 |  }
      |   ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int A = S.(size);
  int count = 0;
  
  for(int i= 0;i < A;i++){
    if(S[i] == i + 1){
      count++;
    }
    
    if(count < 3){
      cout << "YES" << endl;
    }
    
    if(count > 2){
      cout << "NO" << endl;
    }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:7:13: error: expected unqualified-id before '(' token
    7 |   int A = S.(size);
      |             ^
a.cc:22:4: error: expected '}' at end of input
   22 |   }
      |    ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<n; i++);
int main() {
 int N;
 cin>>N;
 bool answer=false;
 vector<int>wtf(N);
for(int i=0; i<N; i++){
cin>>wtf.at(i);
 }
 vector<int>n=wtf.
 sort(wtf.begin(),wtf.end());
 for(int i=0; i<N; i++){
     if(i!=0){
    for(int j=0; j<i; j++){
     int p=n.at(i);
    int u=n.at(j);
    n.at(i)=u;
    n.at(i)=p;
    bool a=true;;
    for(int k=0; k<N; k++){
        if(n.at(i)==wtf.at(i)){

        }
    a=false;
    }
    if(a==true){
        answer=true;
    }
    }
     }
     else
     continue;
 }
 if(answer==true){
    cout<<"YES"<<endl;
 }
 else
 {
     cout<<"NO"<<endl;
 }
 
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:14:2: error: 'class std::vector<int>' has no member named 'sort'
   14 |  sort(wtf.begin(),wtf.end());
      |  ^~~~
Language: C

#include <stdio.h>

int main(void)
{
        int n,i,c;

        scanf("%d",&n);

        int p[n];

        for(i=0;i<n;i++)
                scanf("%d",&p[i]);

        c=0;
        for(i0;i<n;i++)
                if(p[i]!=i+1) c++;
        if(c<2) printf("Yes");
        else     printf("No");

        return 0;
}


Compiler output:
main.c: In function 'main':
main.c:15:13: error: 'i0' undeclared (first use in this function); did you mean 'i'?
   15 |         for(i0;i<n;i++)
      |             ^~
      |             i
main.c:15:13: note: each undeclared identifier is reported only once for each function it appears in
Language: C

Vggggvbbdbdbdbdbbdbdbdhdhdhdgdgdbdvbdbdvdvbdbdbdbdbdbdbbdhshdhdhdhhdhdhdhdhhdhdhdhdhhdhdhdhshhddhdhshdhdhhdhshdhshhdhdhdhdhdhdhhdhdbdbdbbdbd

Compiler output:
main.c:1:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
    1 | Vggggvbbdbdbdbdbbdbdbdhdhdhdgdgdbdvbdbdvdvbdbdbdbdbdbdbbdhshdhdhdhhdhdhdhdhhdhdhdhdhhdhdhdhshhddhdhshdhdhhdhshdhshhdhdhdhdhdhdhhdhdbdbdbbdbd
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>
 int main()
{
	int n,i,count=0;
	scanf("%d", &n);
	int a[n];
 
	for(i = 0;  i<n;  i++)
	{
		scanf("%d", &a[i]);
                if arr[i]!= i+1;
                count++;
	}

Compiler output:
main.c: In function 'main':
main.c:11:20: error: expected '(' before 'arr'
   11 |                 if arr[i]!= i+1;
      |                    ^~~
      |                    (
main.c:11:20: error: 'arr' undeclared (first use in this function)
   11 |                 if arr[i]!= i+1;
      |                    ^~~
main.c:11:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:13:9: error: expected declaration or statement at end of input
   13 |         }
      |         ^
Language: C

#include<stdio.h>
 
int main()
{
	int n, c= 0,i;
	scanf("%d",&n);
	int a[n];
 
	for(i=0; i<n; i++)
	{
		scanf("%d", &a[i]);
		if(arr[i] != i+1)
		{
			c++;
		}
	}
 
	if(c<=2) printf("YES\n");
	else printf("NO\n");
}

Compiler output:
main.c: In function 'main':
main.c:12:20: error: 'arr' undeclared (first use in this function)
   12 |                 if(arr[i] != i+1)
      |                    ^~~
main.c:12:20: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
 int main()
{
	int n,i,sum= 0;
	scanf("%d",&n);
	int a[n];
 
	for(i = 0; i<n; i++)
	{
		scanf("%d", &a[i]);
		if(arr[i]! = i+1)
		{
			sum++;
		}
	}
 
	if(sum<=2) 
                printf("YES\n");
	else 
                printf("NO\n");
}

Compiler output:
main.c: In function 'main':
main.c:11:20: error: 'arr' undeclared (first use in this function)
   11 |                 if(arr[i]! = i+1)
      |                    ^~~
main.c:11:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:11:26: error: expected ')' before '!' token
   11 |                 if(arr[i]! = i+1)
      |                   ~      ^
      |                          )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
	int n;
  cin >> n;
  vector <int> v;
  for(int i=0;i<n;i++) {
   int x;
    cin >> x;
    v.push_back(x);
    //copy.push_back(x);
  }
 
  int c = 0,d=0;
  for(int i=0;i<n;i++) {
  		if(v[i] != i)
        {
          	c++
  	}
  }
  if(c<=2)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:22:20: error: expected ';' before '}' token
   22 |                 c++
      |                    ^
      |                    ;
   23 |         }
      |         ~
Language: C++

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

int main(){
  int n,nu=0;
  cin>>n;
  vector<int>p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]){
      nu++;
    }
  }
  if(nu<=2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: 'a' was not declared in this scope
   12 |     if(a[i]>a[i+1]){
      |        ^
Language: C

#include<stdio.h>

int main()
{
	int n, count = 0, i;
	scanf("%d", &n);
	int arr[n];

	for(i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
                if arr[i] != i + 1;
                count++;
	}

	if(count <= 2) printf("YES\n");
	else printf("NO\n");
}

Compiler output:
main.c: In function 'main':
main.c:12:20: error: expected '(' before 'arr'
   12 |                 if arr[i] != i + 1;
      |                    ^~~
      |                    (
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n,e;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    a.push_back(x);
  }
  for(int i=0;i<n;i++)
  {
    if(a[i]==n)
    {
      e=i;
      break;
    }
  }
  if(a[n-1]==e+1 || e+1 == n )
      {
        cout<<"YES";
        exit(0);
      }
      else
      {
        cout<<"NO";
        exit(0);
      }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'a' was not declared in this scope
   12 |     a.push_back(x);
      |     ^
a.cc:16:8: error: 'a' was not declared in this scope
   16 |     if(a[i]==n)
      |        ^
a.cc:22:6: error: 'a' was not declared in this scope
   22 |   if(a[n-1]==e+1 || e+1 == n )
      |      ^
Language: C++

#inclde<iostream>
#include<vector>
using namespace std;
int main()
{
  int n,e;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    a.push_back(x);
  }
  for(int i=0;i<n;i++)
  {
    if(a[i]==n)
    {
      e=i;
      break;
    }
  }
  if(a[n-1]==e+1 || e+1 == n )
      {
        cout<<"YES";
        exit(0);
      }
      else
      {
        cout<<"NO";
        exit(0);
      }
  
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inclde; did you mean #include?
    1 | #inclde<iostream>
      |  ^~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin>>n;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<vector>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:12:5: error: 'a' was not declared in this scope
   12 |     a.push_back(x);
      |     ^
a.cc:16:8: error: 'a' was not declared in this scope
   16 |     if(a[i]==n)
      |        ^
a.cc:22:6: error: 'a' was not declared in this scope
   22 |   if(a[n-1]==e+1 || e+1 == n )
      |      ^
a.cc:24:9: error: 'cout' was not declared in this scope
   24 |         cout<<"YES";
      |         ^~~~
a.cc:24:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:25:9: error: 'exit' was not declared in this scope
   25 |         exit(0);
      |         ^~~~
a.cc:3:1: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
    2 | #include<vector>
  +++ |+#include <cstdlib>
    3 | using namespace std;
a.cc:29:9: error: 'cout' was not declared in this scope
   29 |         cout<<"NO";
      |         ^~~~
a.cc:29:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:9: error: 'exit' was not declared in this scope
   30 |         exit(0);
      |         ^~~~
a.cc:30:9: note: 'exit' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
Language: C

#include<stdio.h>
int main()
{
  int n,i,count=0,sum=0;
  scanf("%d",&n);
  int arr[n];
  for(i=0;i<n;i++)
  {
    scanf("%d",&arr[i]);
  }
  for(i=0;i<n-1;i++)
  {
    if(arr[i]<arr[i+1])
    { 
      count++;
    }
    else
    {
      a=i;
    }
  }
  if(count==(n-1))
    {
      printf("yes");
    }
  return 0;
  }

Compiler output:
main.c: In function 'main':
main.c:19:7: error: 'a' undeclared (first use in this function)
   19 |       a=i;
      |       ^
main.c:19:7: 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;
    cin>>n;
    vector<int> vec(n);
  	for(int i=0;i<n;i++){
    	cin>>vec[i];
    }
    int k=0;
    for(int i=0;i<n;i++){
    	for(int j=i+1;j<n;j++){
        	if(a[j]<a[i]){
            	k++;
            }
        }
    }
    if(k==1){
    	cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:20: error: 'a' was not declared in this scope
   14 |                 if(a[j]<a[i]){
      |                    ^
Language: C

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-100
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}


int main() {
//	file();
	fast();
	int n; cin >> n;
	vi v1(n);
	for (auto& it : v1)
		cin >> it;
	vi arr(n);
	iota(all(arr), 1);
	int dif = 0;
	for (int i = 0; i < n; i++)
		if (v1[i] != arr[i])
			dif++;
	if (dif <= 1)
		cout << "YES" << endl;
	else cout << "NO" << endl;
}

Compiler output:
main.c:2:9: fatal error: bits/stdc++.h: No such file or directory
    2 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
int main()
{
    int found,found1,x,n,j,flag=0,temp=0;
    scanf("%d",&n);
    int a[n];
    int i;

    for (i=0; i<n; i++)
        {
            scanf("%d", &a[i]);
        }
    if (a[0]!=1)
    {
    for(i=1; i<n; i++)
    {
        if(a[i] == 1)
        {
            found=i;
            break;
        }
    }

        x=a[0];
        a[0]=a[found];
        a[found]=x;


    }
  else
    {
    for(i=0; i<n; i++)
    {
        if(a[i]!=i+1)
        {
            flag=1;
            found=i
            break;
        }
    }
    for(j=0; j<n; j++)
    {
        if(a[j]==i+1)
        {
            found1=j;
            break;
        }
    }
    if (flag==1)
    {
        x=a[found];
        a[found]=a[found1];
        a[found1]=x;
    }

    }
    for(i=0; i<n ; i++)
    { if(a[i]>a[i+1])

    {
            printf("NO");
            temp=1;
            break;
    }
    }
    if (temp==0)
    printf("YES");
    return 0;
}




Compiler output:
main.c: In function 'main':
main.c:37:20: error: expected ';' before 'break'
   37 |             found=i
      |                    ^
      |                    ;
   38 |             break;
      |             ~~~~~
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  
  for(int i=1; i <= N; i++) cin >> a[i];
  
  int count = 0;
  for(int i=1; i <= N; i++){
    if(a[i] != i) count++;
  }
  if(count <= 2) cout << "YES" endl;
  else cout << "NO" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:31: error: expected ';' before 'endl'
   15 |   if(count <= 2) cout << "YES" endl;
      |                               ^~~~~
      |                               ;
Language: C

#include<stdio.h>
int main()
{
	int n,p[51],i,c=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&p[i])
	for(i=0;i<n;i++)
		if(p[i]!=i+1)
			c++;
	if(c>2)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:34: error: expected ';' before 'for'
    8 |                 scanf("%d",&p[i])
      |                                  ^
      |                                  ;
    9 |         for(i=0;i<n;i++)
      |         ~~~
Language: C++

using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 1; i <= (n); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)


int main(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    rep(i,n) cin>>a[i];

    bool flag = true;
    int cnt = 0;
    rep(i,n){
        if(a[i] != i){
            ++cnt;
            if(a[a[i]] != i) flag = false;
        }
    }

    cout<< ((flag && (cnt/2<=1)) ? "YES" : "NO") <<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin>>n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:10:5: error: 'vector' was not declared in this scope
   10 |     vector<int> a(n+1);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:10:12: error: expected primary-expression before 'int'
   10 |     vector<int> a(n+1);
      |            ^~~
a.cc:11:19: error: 'a' was not declared in this scope
   11 |     rep(i,n) cin>>a[i];
      |                   ^
a.cc:16:12: error: 'a' was not declared in this scope
   16 |         if(a[i] != i){
      |            ^
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout<< ((flag && (cnt/2<=1)) ? "YES" : "NO") <<endl;
      |     ^~~~
a.cc:22:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:52: error: 'endl' was not declared in this scope
   22 |     cout<< ((flag && (cnt/2<=1)) ? "YES" : "NO") <<endl;
      |                                                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++) 
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i, n) {
    cin >> p.at(i);
  }
  vector<int> q = p;
  sort(q.begin(), q.end());
  vector<int> r;
  bool res = false;
  if (p == q) {
    res = true;
  }
  int c, d;
  REP(i, n - 1) {
    for (int j = i + 1, j < n; j++) {
      r = p;
      c = r.at(i);
      d = r.at(j);
      r.at(i) = d;
      r.at(j) = c;
      if (r == p) {
        res = true;
      }
    }
  }
  if (res) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}  
  


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

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++) 
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i, n) {
    cin >> p.at(i);
  }
  vector<int> q = p;
  sort(q.begin(), q.end());
  vector<int> r;
  bool res = false;
  if (p == q) {
    res = true;
  }
  int c, d;
  REP(i, n - 1) {
    for (j = i + 1, j < n; j++) {
      r = p;
      c = r.at(i);
      d = r.at(j);
      r.at(i) = d;
      r.at(j) = c;
      if (r == p) {
        res = true;
      }
    }
  }
  if (res) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}  
  


Compiler output:
a.cc: In function 'int main()':
a.cc:20:10: error: 'j' was not declared in this scope
   20 |     for (j = i + 1, j < n; j++) {
      |          ^
a.cc:20:31: error: expected ';' before ')' token
   20 |     for (j = i + 1, j < n; j++) {
      |                               ^
      |                               ;
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  bool ans=false;
  vector<int>a(n);
  rep(i,n) cin >> p[i];
  rep(i,n){
    rep(j,n){
      if(p[i]<=p[i+j+1]) {
        ans=true;
        break;}}
      if(ans==true) break;
    }
  puts(ans?"Yes":"No");
  return 0;
}
      


Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: 'p' was not declared in this scope
    9 |   rep(i,n) cin >> p[i];
      |                   ^
a.cc:12:10: error: 'p' was not declared in this scope
   12 |       if(p[i]<=p[i+j+1]) {
      |          ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  bool ans=false;
  vector<int>a(n);
  rep(i,n) cin >> p[n];
  rep(i,n){
    rep(j,n){
      if(p[i]<=p[i+j+1]) {
        ans=true;
        break;}}
      if(ans==true) break;
    }
  puts(ans?"Yes","No");
  return 0;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: 'p' was not declared in this scope
    9 |   rep(i,n) cin >> p[n];
      |                   ^
a.cc:12:10: error: 'p' was not declared in this scope
   12 |       if(p[i]<=p[i+j+1]) {
      |          ^
a.cc:17:22: error: expected ':' before ')' token
   17 |   puts(ans?"Yes","No");
      |                      ^
      |                      :
a.cc:17:22: error: expected primary-expression before ')' token
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
    p.at(i)--;
  }
  int s=0;
  for(int i=0;i<n;i++){
    if(p.at(i)!=i){
      s++;
    }
  }
  if(s>=2){
    cout<<"YES"<<endl;
    
  }
  else{
    cout<<"NO"<<endl;
  }
}


Compiler output:
a.cc:1:10: fatal error: bitd/stdc++.h: No such file or directory
    1 | #include <bitd/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=0;
    cin>>n;
    int a[n+2],b[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(i=0; i<n; i++)
    {
        if(b[i]!=a[i])
        {
            c++;
        }
    }
    if(c<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

}
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=0;
    cin>>n;
    int a[n+2],b[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(i=0; i<n; i++)
    {
        if(b[i]!=a[i])
        {
            c++;
        }
    }
    if(c<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

}


Compiler output:
a.cc:33:5: error: redefinition of 'int main()'
   33 | int main()
      |     ^~~~
a.cc:3:5: note: 'int main()' previously defined here
    3 | int main()
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,a[55];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1,j=n;i<j;i++,j--){
        if(a[i]>a[j]){
            swap(a[i],a[j]);
            break;
        }
    }
    for(int i=1;i<n;i++){
        if(a[i]>a[j]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: 'j' was not declared in this scope
   17 |         if(a[i]>a[j]){
      |                   ^
Language: C++

include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,j,i,k,l,a[100],b[100];
    vector<int>v1,v2;
    cin>>n;
    for(i=0;i<n;i++){cin>>a[i];}
    for(i=0;i<n;i++){v1.push_back(a[i]);}
    for(i=0;i<n;i++){b[i]=a[i];}
    sort(b,b+n);sort(v1.begin(),v1.end());
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(b[i]==a[j]){k=j;break;}
        }
        if(i!=k){swap(a[i],a[k]);break;}
    }
    for(l=0;l<n;l++){v2.push_back(a[l]);}
    if(i==n){cout<<"YES\n";}
    else{
        if(v1==v2){cout<<"YES\n";}
        else{cout<<"NO\n";}
        }
    }

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int>v1,v2;
      |     ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
    6 |     vector<int>v1,v2;
      |            ^~~
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin>>n;
      |     ^~~
a.cc:9:22: error: 'v1' was not declared in this scope
    9 |     for(i=0;i<n;i++){v1.push_back(a[i]);}
      |                      ^~
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |     sort(b,b+n);sort(v1.begin(),v1.end());
      |     ^~~~
      |     short
a.cc:11:22: error: 'v1' was not declared in this scope
   11 |     sort(b,b+n);sort(v1.begin(),v1.end());
      |                      ^~
a.cc:16:18: error: 'swap' was not declared in this scope
   16 |         if(i!=k){swap(a[i],a[k]);break;}
      |                  ^~~~
a.cc:18:22: error: 'v2' was not declared in this scope
   18 |     for(l=0;l<n;l++){v2.push_back(a[l]);}
      |                      ^~
a.cc:19:14: error: 'cout' was not declared in this scope
   19 |     if(i==n){cout<<"YES\n";}
      |              ^~~~
a.cc:21:16: error: 'v2' was not declared in this scope
   21 |         if(v1==v2){cout<<"YES\n";}
      |                ^~
a.cc:21:20: error: 'cout' was not declared in this scope
   21 |         if(v1==v2){cout<<"YES\n";}
      |                    ^~~~
a.cc:22:14: error: 'cout' was not declared in this scope
   22 |         else{cout<<"NO\n";}
      |              ^~~~
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(); 
        int b = 0;
		for(int i=0;i<a;i++){int c = sc.nextInt();
                            if(c!=i+1){b++;}
                            }     
        if(b<=2){system.out.println("YES");}
		else{System.out.println("NO");}
	}
}


Compiler output:
Main.java:10: error: package system does not exist
        if(b<=2){system.out.println("YES");}
                       ^
1 error
Language: C++

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

k=0

for i in range(n):
  if p[i]!=(i+1):
    k+=1

if k<=2:
  print("YES")
else:
  print("NO")

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

n = int(input())
a = [int(i) for i in input().split()]
c = 0
for i in range(n):
    if a[i] != i + 1:
        c += 1
    if c == 3:
        print("NO")
        break
else:
    print("YES")

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

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  rep(i, N) {
    cin >> A.at(i);
  }
  
  int count = 0;
  rep(i, N) {
    if (A.at(i) == i + 1) {
      k++;
    }
  }
  
  if (k <= 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'k' was not declared in this scope
   17 |       k++;
      |       ^
a.cc:21:7: error: 'k' was not declared in this scope
   21 |   if (k <= 2) {
      |       ^
Language: C++

include <bits/stdc++.h> 
using namespace std;
int main () {
  int n;
  cin >> n;
  int mas[n+1];
  int d = 0;
  for (int i = 1; i <= n ; i++ ) {
   
    cin >> mas[i]; } 
  for (int i =1; i <= n; i++) {
    if (mas[i] != i) {
    d++; } }
  if ( d > 2 ) {
    cout << "NO" ; }
  else {
    cout << "YES"; } }
    

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin >> n;
      |   ^~~
a.cc:15:5: error: 'cout' was not declared in this scope
   15 |     cout << "NO" ; }
      |     ^~~~
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout << "YES"; } }
      |     ^~~~
Language: C++

clude <bits/stdc++.h> 
using namespace std;
int main () {
  int n;
  cin >> n;
  int mas[n+1];
  int d = 0;
  for (int i = 1; i <= n ; i++ ) {
   
    cin >> mas[i]; } 
  for (int i =1; i <= n; i++) {
    if (mas[i] != i) {
    d++; } }
  if ( d > 2 ) {
    cout << "NO" ; }
  else {
    cout << "YES"; } }
    

Compiler output:
a.cc:1:1: error: 'clude' does not name a type
    1 | clude <bits/stdc++.h>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin >> n;
      |   ^~~
a.cc:15:5: error: 'cout' was not declared in this scope
   15 |     cout << "NO" ; }
      |     ^~~~
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout << "YES"; } }
      |     ^~~~
Language: C++

#include <bits/stdc++.h > 
using namespace std;
int main () {
  int n;
  cin >> n;
  int mas[n+1];
  int d = 0;
  for (int i = 1; i <= n ; i++ ) {
   
    cin >> mas[i]; } 
  for (int i =1; i <= n; i++) {
    if (mas[i] != i) {
    d++; } }
  if ( d > 2 ) {
    cout << "No" ; }
  else {
    cout << "Yes"; } }
    

Compiler output:
a.cc:1:10: fatal error: bits/stdc++.h : No such file or directory
    1 | #include <bits/stdc++.h >
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h > 
using namespace std;
int main () {
  int n;
  cin >> n;
  int mas[n];
  int d = 0;
  for (int i = 1; i <= n ; i++ ) {
   
    cin >> mas[i]; } 
  for (int i =1; i <= n; i++) {
    if (mas[i] != i) {
    d++; } }
  if ( d > 2 ) {
    cout << "No" ; }
  else {
    cout << "Yes"; } }
    

Compiler output:
a.cc:1:10: fatal error: bits/stdc++.h : No such file or directory
    1 | #include <bits/stdc++.h >
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];
    int B[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        B[i]=A[i];
    }
    sort(A,A+N);
    int a=0;
    for(int i=0;i<N;i++){
        if(A[i]!=B[i])  a++;
    }
    if(a==2) cout << "YES" << endl;
    else cout << "N0" << endl;

}

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

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  q=sort(p.begin(),p.end());
  bool can=false;
  if(p==q){
    cout << "Yes" << endl;
  }else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i<j){
          swap(p[i],p[j]);
            if(p==q){
              can=true;
              break;
            }
          swap(p[i],p[j]);
        }
      }
      if(can) break;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}
        


Compiler output:
a.cc: In function 'int main()':
a.cc:13:27: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   13 |   q=sort(p.begin(),p.end());
      |                           ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:2:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'void' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'void' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'void' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  q=sort(p.begin(),p.end());
  bool can=false;
  if(p==q){
    cout << "Yes" << endl;
  }else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i<j){
          swap(p[i],p[j]);
            if(p==q){
              can=true;
              break;
            }
          swap(p[i],p[j]);
        }
      }
      if(can) break;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}
        

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

#include <bits/stdc++5
5 2 3 4 1.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n; 
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cnt = 0;
    rep(i,n) {
        if(p[i]!=i+1){
            cnt++;
        }
    }
    if(cnt>=3) cout << "No" << endl;
    else cout << "Yes" << endl; 
    return 0;
}

Compiler output:
a.cc:1:23: error: missing terminating > character
    1 | #include <bits/stdc++5
      |                       ^
a.cc:1:10: fatal error: bits/stdc++5: No such file or directory
    1 | #include <bits/stdc++5
      |          ^
compilation terminated.
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int P[N];
  for (int i=0; i<N; i++){
    cin>>P[i];}
  int Q[N];
  for (int i=0; i<N; i++) Q[i]=P[i];
  sort(Q.begin(),Q.end());
  int counter=0;
  for (int i=0; i<N; i++){
    if (P[i]==Q[i]) {counter++;}
  }
  if(counter<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
       
  
       

Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: request for member 'begin' in 'Q', which is of non-class type 'int [N]'
   12 |   sort(Q.begin(),Q.end());
      |          ^~~~~
a.cc:12:20: error: request for member 'end' in 'Q', which is of non-class type 'int [N]'
   12 |   sort(Q.begin(),Q.end());
      |                    ^~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  int P[N];
  for (int i=0; i<N; i++){
    cin>>P[i];}
  int Q[N]=P[N];
  sort(Q.begin(),Q.end());
  int counter=0;
  for (int i=0; i<N; i++){
    if (P[i]==Q[i]) {counter++;}
  }
  if(counter<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
       
  
       

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: array must be initialized with a brace-enclosed initializer
   10 |   int Q[N]=P[N];
      |            ~~~^
a.cc:11:10: error: request for member 'begin' in 'Q', which is of non-class type 'int [N]'
   11 |   sort(Q.begin(),Q.end());
      |          ^~~~~
a.cc:11:20: error: request for member 'end' in 'Q', which is of non-class type 'int [N]'
   11 |   sort(Q.begin(),Q.end());
      |                    ^~~
Language: C++

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

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  V p(n);
  rep(i,n) cin >> p[i];
  ll cnt = 0;
  rep(i,n) if(p[i] != i+1) cnt++;
  if (cnt<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: expected '}' at end of input
   19 |   return 0;
      |            ^
a.cc:8:16: note: to match this '{'
    8 | int main(void) {
      |                ^
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    vector<int> q(n);
    int k = 0;
    rep(i,n){
        if(p[i] != i + 1) k++;
    }
    if(k <= 2) cout << "YES" << endl;
    else << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: expected primary-expression before '<<' token
   16 |     else << "NO" << endl;
      |          ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int y[x],q[x];
    for (int i=0;i<x;i++){
        cin>>y[i];
        q[i]=y[i];
    }
    sort(q,q+x);
    int c=0;
    for (int i=0;i<x;i++){
        if (q[i]!=y[i])
            c++;
    }
    if (c<=2)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: 'x' was not declared in this scope
   10 |     int y[x],q[x];
      |           ^
a.cc:12:14: error: 'y' was not declared in this scope
   12 |         cin>>y[i];
      |              ^
a.cc:13:9: error: 'q' was not declared in this scope
   13 |         q[i]=y[i];
      |         ^
a.cc:15:10: error: 'q' was not declared in this scope
   15 |     sort(q,q+x);
      |          ^
a.cc:18:19: error: 'y' was not declared in this scope
   18 |         if (q[i]!=y[i])
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int ans==0;
  rep(i,n){
    int w;
    cin >> w;
    if(w!=i+1)ans++;
  }
  if(ans==0||ans==2)cout << "YES" << endl;
  else cout << "NO" << endl;
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: expected initializer before '==' token
    7 |   int ans==0;
      |          ^~
a.cc:11:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   11 |     if(w!=i+1)ans++;
      |               ^~~
      |               abs
a.cc:13:6: error: 'ans' was not declared in this scope; did you mean 'abs'?
   13 |   if(ans==0||ans==2)cout << "YES" << endl;
      |      ^~~
      |      abs
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    int count = 0;
    for (int i = 0; i < n; i++){
        cin >> p[i];
        if (p[i] == i+1){
            sum++;
        }
    }

    if (sum > 2){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: 'sum' was not declared in this scope
   12 |             sum++;
      |             ^~~
a.cc:16:9: error: 'sum' was not declared in this scope
   16 |     if (sum > 2){
      |         ^~~
Language: C++

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

int main()
{
    int n;
    cin >> n;
    int count = 0;
    vector<int> p(n);
    vector<int> q(p.size());
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    copy(p.begin(), p.end(), q.begin());
    sort(q.begin(), q.end());

    for (int i = 0; i < n; i++)
    {
        cout << "p[" << i << "]:" << p[i] << " ";
    }
    cout << "" << endl;

    /*for (int i = 0; i < n; i++)
    {
        cout << "q[" <<i << "]:" << q[i] << " ";
        }
    cout << "" << endl;

    for (int i = 0; i < n; i++)
    {
        if (p[i] == q[i])
            count++;
    }
    int x = p.size() - 2;
    cout << "x:" << x << endl;
    */
    if (count - x >= 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:17: error: 'x' was not declared in this scope
   40 |     if (count - x >= 0)
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    int k;
    int pk=0;
    vector<int> x;
    bector<int> y;
    int a=0;
    rep(i,n){
        cin>>k;
        if(k!=i+1){
            a++;
            x.pb(k);
            y.pb(i+1);
        }

    }
    
    bool check=true; 

    if(a>2)check=false;
    else if(a==2){
        if(x[0]==y[1] &&x[1]==y[0] ){
            check=true;
        }else{
            check=false;
        }
    }

    string ans=(check)?"Yes":"No";

    cout<<ans<<endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'bector' was not declared in this scope
   13 |     bector<int> y;
      |     ^~~~~~
a.cc:13:12: error: expected primary-expression before 'int'
   13 |     bector<int> y;
      |            ^~~
a.cc:20:13: error: 'y' was not declared in this scope
   20 |             y.pb(i+1);
      |             ^
a.cc:29:18: error: 'y' was not declared in this scope
   29 |         if(x[0]==y[1] &&x[1]==y[0] ){
      |                  ^
Language: C++

/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, a, f = 0;
	scanf("%d", &n);
	rep(i, n){
	  scanf("%d", &a);
	  if(a != i + 1)++f;
	}
	printfYN(f < 2);

	Please AC;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:126:9: error: 'printfYN' was not declared in this scope; did you mean 'printYN'?
  126 |         printfYN(f < 2);
      |         ^~~~~~~~
      |         printYN
Language: C

#include <stdio.h>

int main(void) {
	int n, ans1=0, ans2=0;
	int p[51]{ 0 }, seq[51]{ 0 };

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &p[i]);
	}

	for (int i = 0; i < n; ++i) {
		seq[i] = i + 1;
	}
	for (int i = 0; i < n;++i) {
		if (seq[i] == p[i]) {
			++ans1;
		}
		else {
			++ans2;
		}

	}
	printf(ans1 == 2 || ans2 == 2 ||ans1==0||ans2==0 ? "YES" : "NO");

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    5 |         int p[51]{ 0 }, seq[51]{ 0 };
      |                  ^
main.c:5:21: error: expected ';' before '}' token
    5 |         int p[51]{ 0 }, seq[51]{ 0 };
      |                     ^~
      |                     ;
main.c:5:23: error: expected expression before ',' token
    5 |         int p[51]{ 0 }, seq[51]{ 0 };
      |                       ^
main.c:5:25: error: 'seq' undeclared (first use in this function)
    5 |         int p[51]{ 0 }, seq[51]{ 0 };
      |                         ^~~
main.c:5:25: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:30: error: 'p' undeclared (first use in this function)
    9 |                 scanf("%d", &p[i]);
      |                              ^
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int[] p = new int[n];
        int a = 0;
        for(int i = 0; i < n; i++){
            p[i] = scan.nextInt();
        }
        for(int i = 0; i < n; i++){
            if(p[i] - 1 != i){
                a++;
            }
        }\
        if(a <= 2){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Compiler output:
Main.java:16: error: illegal character: '\'
        }\
         ^
1 error