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

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

vector<int> sw(int a,int b,vector<int> c){
  swap(c.at(a),c.at(b));
  return c;
}

int main() {
  int n;
  cin >> n;
  vector<int> p (n);
  for(int i=0; i<n; i++){
    cin >> p.at(i);
  }
  vector<int> asc;
  for(int i=0; i<n; i++){
    asc.push_back(i+1);
  }
  string ans = "No";
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      if(asc == sw(i,j,p)){
        ans = "Yes";
        break
      }
    }
  }
  if(asc == p){
    ans = "Yes";
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:14: error: expected ';' before '}' token
   25 |         break
      |              ^
      |              ;
   26 |       }
      |       ~
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	
		int N = sc.nextInt();
	
		for ( i =1; i<=50 ; i++){
          
     	 int  pi = sc.nextInt();
        }
      	
		
      
    
    
        
    
	}
}

Compiler output:
Main.java:8: error: cannot find symbol
		for ( i =1; i<=50 ; i++){
		      ^
  symbol:   variable i
  location: class Main
Main.java:8: error: cannot find symbol
		for ( i =1; i<=50 ; i++){
		            ^
  symbol:   variable i
  location: class Main
Main.java:8: error: cannot find symbol
		for ( i =1; i<=50 ; i++){
		                    ^
  symbol:   variable i
  location: class Main
3 errors
Language: C++

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

typedef long long ll;
typedef pair<int, int> P;
const int INF = 10000000;


int n;
int p[100];


int main(){

    int c = 0;
    P f, s;

    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i];

        if(i != p[i]){
            c++;
    }

    if(c == 2 || c == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:2: error: expected '}' at end of input
   37 | }
      |  ^
a.cc:16:11: note: to match this '{'
   16 | int main(){
      |           ^
Language: C++

#include <iostream>
using namespace std;

int main() {
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p; cin >> p;
    if (p != i) cnt++;
  }
  
  if (cnt == 0 || cnt = 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: lvalue required as left operand of assignment
   12 |   if (cnt == 0 || cnt = 2) {
      |       ~~~~~~~~~^~~~~~
Language: C++

#include <stdio.h>
using namespace std;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  int d[n];
  for(int i = 0; i < n; i++) cin>>d[i];
  
  int wrong = 0;
  for(int i = 0; i < n; i++) {
    if(d[i] != i+1) wrong++;
  }
  
  if(wrong>2) cout<<"NO"<<"\n";
  else cout<<"YES"<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin.tie(0);
      |   ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <stdio.h>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:7:3: error: 'ios' has not been declared
    7 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:19:15: error: 'cout' was not declared in this scope
   19 |   if(wrong>2) cout<<"NO"<<"\n";
      |               ^~~~
a.cc:19:15: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:8: error: 'cout' was not declared in this scope
   20 |   else cout<<"YES"<<"\n";
      |        ^~~~
a.cc:20:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    vector<int> s_p(n) = p;
    int w_c = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != s_p[i]) w_c++;
    }
    if(w_c > 2){
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: expected ',' or ';' before '=' token
   11 |     vector<int> s_p(n) = p;
      |                        ^
Language: C++

#include<bits/stdc++.h>
using namespace std ;
vector<int>vc;
int k;
int main ( ) {
int n ;
cin>>n;
int a[10000];
for(int i = 1 ; i <= n ; i ++ ){
    cin>>a[i];
}
for(int i =1 ; i <=n ; i ++ ){
    if(a[i] != i ){
        counter++;
    }
}
if(counter == 0 || counter == 2){
    cout<<"YES";
}
else {
    cout<<"NO";
}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'counter' was not declared in this scope
   14 |         counter++;
      |         ^~~~~~~
a.cc:17:4: error: 'counter' was not declared in this scope
   17 | if(counter == 0 || counter == 2){
      |    ^~~~~~~
Language: C++

# include <bits/stdc++.h>
using namespace std;
vector <int> vc;
int n,k,x,a,b,l,m;
int main(){
    cin>>a;
    for (int i=0;i<a;i++){
        cin>>m;
        vc.push_back(m);
    }
    for (int i=0;i<a;i++){
        if (vc[0]=="1" and vc[i]==vc[i+1){
            b++;
        }
    }
    if (b==a){

    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   12 |         if (vc[0]=="1" and vc[i]==vc[i+1){
a.cc:12:41: error: expected ']' before ')' token
   12 |         if (vc[0]=="1" and vc[i]==vc[i+1){
      |                                         ^
      |                                         ]
Language: C++

# include <bits/stdc++.h>
using namespace std;
vector <int> vc;
int n,k,x,a,b,l,m;
int main(){
    cin>>a;
    for (int i=0;i<a;i++){
        cin>>m;
        vc.push_back(m);
    }
    for (int i=0;i<a;i++){
        if (vc[0]=="1"and vc[i]==vc[i+1){
            b++;
        }
    }
    if (b==a){

    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:20: error: unable to find string literal operator 'operator""and' with 'const char [2]', 'long unsigned int' arguments
   12 |         if (vc[0]=="1"and vc[i]==vc[i+1){
      |                    ^~~~~~
a.cc:12:26: error: expected ')' before 'vc'
   12 |         if (vc[0]=="1"and vc[i]==vc[i+1){
      |            ~             ^~~
      |                          )
Language: C++

#inclde <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.at(i);
  }
  vector<int> sortedvec(n);
  sortedvec = vec;
  sort(vec.begin(),vec.end());
  int diff=0;
  for(int i=0;i<n;i++){
    if(vec.at(i)==sortedvec.at(i))diff++;
  }
  if(diff==0||diff==2)cout << "YES" << endl;
  else cout << "NO" << endl;
}

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:6:3: error: 'cin' was not declared in this scope
    6 |   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:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> vec(n);
      |   ^~~~~~
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:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> vec(n);
      |          ^~~
a.cc:9:12: error: 'vec' was not declared in this scope
    9 |     cin >> vec.at(i);
      |            ^~~
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vector<int> sortedvec(n);
      |          ^~~
a.cc:12:3: error: 'sortedvec' was not declared in this scope
   12 |   sortedvec = vec;
      |   ^~~~~~~~~
a.cc:12:15: error: 'vec' was not declared in this scope
   12 |   sortedvec = vec;
      |               ^~~
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |   sort(vec.begin(),vec.end());
      |   ^~~~
      |   short
a.cc:18:23: error: 'cout' was not declared in this scope
   18 |   if(diff==0||diff==2)cout << "YES" << endl;
      |                       ^~~~
a.cc:18:23: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:40: error: 'endl' was not declared in this scope
   18 |   if(diff==0||diff==2)cout << "YES" << endl;
      |                                        ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #inclde <bits/stdc++.h>
a.cc:19:8: error: 'cout' was not declared in this scope
   19 |   else cout << "NO" << endl;
      |        ^~~~
a.cc:19:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:24: error: 'endl' was not declared in this scope
   19 |   else cout << "NO" << endl;
      |                        ^~~~
a.cc:19:24: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#define ll long long
#define mod 998244353
#define maxn 200010
using namespace std;
int n;
bool cal(vector<int> vec)
{
	for(int i=0;i<n;i++)
	{
		if(i+1 != vec[i])
		return false;
	}
	return true;
}
int main()
{
    cin>>n;vector<int> vec;
    for(int i=0;i<n;i++)
    {
    	int x;cin>>x;vec.push_back(x);
	}
	if(cal(vec))
	{
		cout<<"YES"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			swap(vec[i],vec[j]);
			if(cal(vec))
			{
				cout<<"YES"<<endl;
				return 0;
			}
			swap(vec[i],vec[j]);
		}
	}
	cout<<"NO"<<endl;
    return 0;
}

Compiler output:
a.cc:12:10: error: 'vector' was not declared in this scope
   12 | bool cal(vector<int> vec)
      |          ^~~~~~
a.cc:7:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    6 | #include<iostream>
  +++ |+#include <vector>
    7 | #define ll long long
a.cc:12:17: error: expected primary-expression before 'int'
   12 | bool cal(vector<int> vec)
      |                 ^~~
a.cc: In function 'int main()':
a.cc:23:12: error: 'vector' was not declared in this scope
   23 |     cin>>n;vector<int> vec;
      |            ^~~~~~
a.cc:23:12: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:23:19: error: expected primary-expression before 'int'
   23 |     cin>>n;vector<int> vec;
      |                   ^~~
a.cc:26:22: error: 'vec' was not declared in this scope
   26 |         int x;cin>>x;vec.push_back(x);
      |                      ^~~
a.cc:28:16: error: 'vec' was not declared in this scope
   28 |         if(cal(vec))
      |                ^~~
a.cc:28:19: error: 'cal' cannot be used as a function
   28 |         if(cal(vec))
      |                   ^
a.cc:37:30: error: 'vec' was not declared in this scope
   37 |                         swap(vec[i],vec[j]);
      |                              ^~~
a.cc:38:31: error: 'cal' cannot be used as a function
   38 |                         if(cal(vec))
      |                            ~~~^~~~~
Language: C++

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

int main()
{
  int n;
  cin>>n;
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    cin>>x;
    if(x!=i)
      cnt++;
  }
  (cnt<=2)?cout<<"YES":cout<<"NO";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: 'x' was not declared in this scope
   11 |     cin>>x;
      |          ^
Language: C++

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

int main() {
int n;
cin >> n;
vector<int> a(n), b(n);
int cnt = 0;
for(int i = 0; i < n; ++i) {
cin >> a[i];
b[i] = a[i];
}
sort(a.begin(), a.end());
for(int i = 0; i < n; ++i) {
if(a[i] != b[i]) ++cnt;
}
if(cnt == 1 || cnt == 2) {
cout << "YES";
}
else cout << "NO";
}

Compiler output:
a.cc:2:17: error: 'srd' is not a namespace-name
    2 | using namespace srd;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:6:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 | cin >> n;
      | ^~~
      | std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:7:1: error: 'vector' was not declared in this scope
    7 | vector<int> a(n), b(n);
      | ^~~~~~
a.cc:7:1: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:7:8: error: expected primary-expression before 'int'
    7 | vector<int> a(n), b(n);
      |        ^~~
a.cc:10:8: error: 'a' was not declared in this scope
   10 | cin >> a[i];
      |        ^
a.cc:11:1: error: 'b' was not declared in this scope
   11 | b[i] = a[i];
      | ^
a.cc:13:6: error: 'a' was not declared in this scope
   13 | sort(a.begin(), a.end());
      |      ^
a.cc:13:1: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 | sort(a.begin(), a.end());
      | ^~~~
      | std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:15:12: error: 'b' was not declared in this scope
   15 | if(a[i] != b[i]) ++cnt;
      |            ^
a.cc:18:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 | cout << "YES";
      | ^~~~
      | std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:20:6: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 | else cout << "NO";
      |      ^~~~
      |      std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int N; 

int main(){
  cin >> N;
  vector<int> vec(N);
  rep(i,N) cin >> vec[i];
    
  vector<int> vec_sorted(vec.begin(), vec.begin()+N);
  sort(vec_sorted.begin(), vec_sorted.end(), greater<int>());
  
  count = 0;
  flag=true;
  rep(i,N){
    if(vec[i]!=vec_sorted[i]){
      count++;
      if(count>2){flag=false; break;}
    }
  }
  cout << (flag ? "YES\n" : "NO\n"); 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: overloaded function with no contextual type information
   16 |   count = 0;
      |           ^
a.cc:17:3: error: 'flag' was not declared in this scope
   17 |   flag=true;
      |   ^~~~
a.cc:20:12: error: no post-increment operator for type
   20 |       count++;
      |            ^~
a.cc:21:15: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator>'
   21 |       if(count>2){flag=false; break;}
      |          ~~~~~^~
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class B0or1Swap {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] compare = new int[n];
		for(int i = 0;i<n;i++) {
			int temp = sc.nextInt();
			arr[i]=temp;
			compare[i] = temp;
		}
		int count = 0;
		Arrays.sort(compare);
		for(int i = 0;i<n;i++) {
			if(arr[i]!=compare[i])count++;
		}
		System.out.println(count>2?"NO":"YES");

	}

}


Compiler output:
Main.java:4: error: class B0or1Swap is public, should be declared in a file named B0or1Swap.java
public class B0or1Swap {
       ^
1 error
Language: C++

#include <iostream>
int main(){
  int N,temp,cout=0;
  std::cin>>N;
  for (int i=1;i<=N;i++){
    std::cin>>temp;
    if(temp!=i){
      count++;
    }
  }
  if(count>=2){
    std::cout<<"NO"<<std::endl;
  }else{
    std::cout<<"YES"<<std::endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'count' was not declared in this scope; did you mean 'cout'?
    8 |       count++;
      |       ^~~~~
      |       cout
a.cc:11:6: error: 'count' was not declared in this scope; did you mean 'cout'?
   11 |   if(count>=2){
      |      ^~~~~
      |      cout
Language: Java

/* package whatever; // don't place package name! */

import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	static String sorting(int[] arr){
			int n = arr.length;
			int count = 0;
			for(int i=0;i<n;i++){
				if(arr[i]!=i+1){
					count++;
				}
			}
			return((count==2||count==0)?"YES":"NO");
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i] = scan.nextInt();
		}
		System.out.println(sorting(arr));

	}
}


Compiler output:
Main.java:5: error: class Ideone is public, should be declared in a file named Ideone.java
public class Ideone
       ^
1 error
Language: Java

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Solution
{
	static String sorting(int[] arr){
			int n = arr.length;
			int count = 0;
			for(int i=0;i<n;i++){
				if(arr[i]!=i+1){
					count++;
				}
			}
			return((count==2||count==0)?"YES":"NO");
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
			arr[i] = scan.nextInt();
		}
		System.out.println(sorting(arr));

	}
}

Compiler output:
Main.java:8: error: class Solution is public, should be declared in a file named Solution.java
public class Solution
       ^
1 error
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
    int n, x, arr[51];
    
    cin >> n;
    x = 0;
    
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        if(arr[i] != i+1){
            x++;
        }
    }
    
    if(x=2 || x=0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:12: error: lvalue required as left operand of assignment
   18 |     if(x=2 || x=0){
      |          ~~^~~~
Language: C++

#include <bits/stdc++.h>
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(p.begin(),p.end());
  int reg=0;
  for(int i=0;i<N;i++){
    if(p[i]!=q[i]) reg++;
  }
  if(reg==2||reg==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

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

int main() {
  int 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(p.begin(),p.end());
  int reg=0;
  for(int i=0;i<N;i++){
    if(p[i]!=q[i]) reg++;
  }
  if(reg==2||reg==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

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

int main() {
  int N;
  int p[N];
  for(int i=0;i<N;i++) cin>>p[N];
  int q[N];
  for(int i=0;i<N;i++) q[i]=p[i];
  sort(p.begin(),p.end());
  int reg=0;
  for(int i=0;i<N;i++){
    if(p[i]!=q[i]) reg++;
  }
  if(reg==2||reg==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

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

int main() {
  int N;
  int p[N];
  for(int i=0;i<N;i++) cin>>p[N];
  int q[N];
  q=p;
  sort(p.begin(),p.end());
  int reg=0;
  for(int i=0;i<N;i++){
    if(p[i]!=q[i]) reg++;
  }
  if(reg==2||reg==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

//配列のうち間違いが2で, かつ, その間違えをswapすると昇順に整列される

#include<iostream>
using namespace std;
int main()
{
  int n,memo[51],memo_index[51],cnt=0;
  int a[n];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]!=i+1){
      memo[cnt] = a[i];
      memo_index[cnt] = i;
      cnt++;
    }
  }
  if(cnt==2){
    if(memo[0]-1==memo_index[1] && memo[1]-1==memo_index[0])cout << "Yes" << endl;
    else cout << "No" << endl;
  }else{
    cout << "No" << endl;
  

Compiler output:
a.cc: In function 'int main()':
a.cc:22:26: error: expected '}' at end of input
   22 |     cout << "No" << endl;
      |                          ^
a.cc:21:8: note: to match this '{'
   21 |   }else{
      |        ^
a.cc:22:26: error: expected '}' at end of input
   22 |     cout << "No" << endl;
      |                          ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: Java

import java.util.Scanner;
import java.util.Arrays;
// Arrays.toString(array) 配列arrayの中身を出力する

public class Tekito{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] p = new int[N];
    int cnt = 0;
    int temp1 = 0;
    int temp2 = 0;
    for(int i = 1; i <= N; i++){
      p[i-1] = Integer.parseInt(sc.next());
      if(p[i-1] != i){
        cnt += 1;

        if(cnt == 1){
          temp1 = i-1;
        }else if(cnt == 2){
          temp2 = i-1;
        }else{
          break;
        }

      }
    }

    if(cnt == 0){
      System.out.println("YES");
    }else if(cnt == 2){
      if(p[temp2] == temp1+1 && p[temp1] == temp2+1){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }else{
      System.out.println("NO");
    }
  }
}


Compiler output:
Main.java:5: error: class Tekito is public, should be declared in a file named Tekito.java
public class Tekito{
       ^
1 error
Language: C++

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

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

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

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

  return 0;
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: 'A' was not declared in this scope
    7 |   cin >> A;
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin >> num(i);
    num(i)--;
  }
  string ans = "YES";
  int flag = 0;
  for(int i=0;i<n;i++){
    if(num.at(i) != i){
      if(num.at(num.at(i)) = i && flag ==0) {
	   	  flag++;
    	  continue;
      }
      else {
        ans="NO";
        break;
      }
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:15: error: no match for call to '(std::vector<int>) (int&)'
    7 |     cin >> num(i);
      |            ~~~^~~
a.cc:8:8: error: no match for call to '(std::vector<int>) (int&)'
    8 |     num(i)--;
      |     ~~~^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin >> num(i);
    num(i)--;
  }
  string ans = "YES";
  int flag = 0;
  for(int i=0;i<n;i++){
    if(num.at(i) != i){
      if(num.at(num.at(i)) = i && flag ==0) {
	   	  flag++;
    	  continue;
      }
      else {
        ans="NO";
        break;
      }
    }
    cout << ans << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:7:15: error: no match for call to '(std::vector<int>) (int&)'
    7 |     cin >> num(i);
      |            ~~~^~~
a.cc:8:8: error: no match for call to '(std::vector<int>) (int&)'
    8 |     num(i)--;
      |     ~~~^~~
a.cc:24:4: 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 n; cin >>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin >> num(i);
    num(i)--
  }
  string ans = "YES";
  int flag = 0;
  for(int i=0;i<n;i++){
    if(num.at(i) != i){
      if(num.at(num.at(i)) = i && flag ==0) {
	   	  flag++;
    	  continue;
      }
      else {
        ans="NO";
        break;
      }
    }
    cout << ans << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:7:15: error: no match for call to '(std::vector<int>) (int&)'
    7 |     cin >> num(i);
      |            ~~~^~~
a.cc:8:8: error: no match for call to '(std::vector<int>) (int&)'
    8 |     num(i)--
      |     ~~~^~~
a.cc:24:4: error: expected '}' at end of input
   24 |   }
      |    ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:19: error: expected ')' before ']' token
   32 |     if(p[i] != i+1]){count ++;}
      |       ~           ^
      |                   )
a.cc:32:19: error: expected primary-expression before ']' token
Language: C++

#include <iostream>
using namespace std;

int main() {
  
  int N;
  cin >> N;
  vector<int> p(N);
  int num = 0;
 
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  
  for(int i = 0; i < N; ++i){
    if(!(p.at(i) = p.at(i + 1))){
      ++num;
    }
  }
  
  if(num == 2 || num == 0){
    cout << "YES" << endl;
  }
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> p(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> p(N);
      |          ^~~
a.cc:12:12: error: 'p' was not declared in this scope
   12 |     cin >> p.at(i);
      |            ^
a.cc:16:10: error: 'p' was not declared in this scope
   16 |     if(!(p.at(i) = p.at(i + 1))){
      |          ^
Language: C++

#include <iostream>
using namespace std;

int main() {
  
  int N;
  vector<int> p(N);
  int num = 0;
 
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  
  for(int i = 0; i < N; ++i){
    if(!(p.at(i) = p.at(i + 1))){
      ++num;
    }
  }
  
  if(num == 2 || num == 0){
    cout << "YES" << endl;
  }
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> p(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> p(N);
      |          ^~~
a.cc:11:12: error: 'p' was not declared in this scope
   11 |     cin >> p.at(i);
      |            ^
a.cc:15:10: error: 'p' was not declared in this scope
   15 |     if(!(p.at(i) = p.at(i + 1))){
      |          ^
Language: C++

#include <iostream>
using namespace std;

int main() {
  
  int N;
  vector<int> p(N);
 
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  
  for(int i = 0; i < N; ++i){
    if(!(p.at(i) = p.at(i + 1))){
      ++num;
    }
  }
  
  if(num == 2 || num == 0){
    cout << "YES" << endl;
  }
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> p(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> p(N);
      |          ^~~
a.cc:10:12: error: 'p' was not declared in this scope
   10 |     cin >> p.at(i);
      |            ^
a.cc:14:10: error: 'p' was not declared in this scope
   14 |     if(!(p.at(i) = p.at(i + 1))){
      |          ^
a.cc:15:9: error: 'num' was not declared in this scope; did you mean 'enum'?
   15 |       ++num;
      |         ^~~
      |         enum
a.cc:19:6: error: 'num' was not declared in this scope; did you mean 'enum'?
   19 |   if(num == 2 || num == 0){
      |      ^~~
      |      enum
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n,i,t=0;
  cin>>n;
 int a[n+1];
 for(i=1;i<=n;i++) { cin>>a[i]; if(a[i]!=i) t++;}
 if(t!<3) cout<<"NO";
 else cout<<"YES";
  return 0;
   
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:6: error: expected ')' before '!' token
   13 |  if(t!<3) cout<<"NO";
      |    ~ ^
      |      )
Language: C

nclude<stdio.h>
int main()
{
    int n,i,a[100],flag=0,x;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
if(a[0]<a[n-1])
printf("YES");
else{
    x=a[0];
    a[0]=a[n-1];
    a[n-1]=x;
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
        printf("YES");
    else
        printf("NO");
}
    return 0;
}

Compiler output:
main.c:1:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | nclude<stdio.h>
      |       ^
Language: C++

#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long
 
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n){
        cin >> p[i];
    }
    int count = 0;
    REP(i, n){
        if(p[i] == i){
            count++;
        }
    }
    if(count == n || count == n - 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'i' was not declared in this scope
   16 |     REP(i, n){
      |         ^
a.cc:16:5: error: 'REP' was not declared in this scope
   16 |     REP(i, n){
      |     ^~~
Language: C++

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

bool check(){
  bool f=1;
  REP(i,n-1) if(a.at(i)>a.at(i+1)) f=0;
  return f;
}

void sw(int i,int j){
  int tmp=a.at(i);
  a.at(i)=a.at(j);
  a.at(j)=tmp;
}

int main(){
  bool flag=0;
  cin>>n;
  REP(i,n) cin>>a.at(i);
  if(check()) flag=1;
  
  REP(i,n-1) for(int j=i+1;j<n,j++){
    sw(i,j);
    if(check()) flag=1;
    sw(i,j);
  }
  
  cout<<(flag?"YES":"NO");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:35: error: expected ';' before ')' token
   25 |   REP(i,n-1) for(int j=i+1;j<n,j++){
      |                                   ^
      |                                   ;
Language: C++

#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int n;
	cin >> n;
	vector<int>p(n);
	rep(i, n) {
		cin >> p[i];
	}
	vector<int>a(n) = p(n);
	sort(a.begin(), a.end());
	int res = 0;
	rep(i, n) {
		if (a[i] != p[i])res++;
	}
	if (res <= 2)puts("YES");
	else puts("NO");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: expected ',' or ';' before '=' token
   16 |         vector<int>a(n) = p(n);
      |                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  bool ans=0;
  int n,cnt=0;
  cin >> n;
  vi p(n),q(n);
  rep(i,n)
    cin >> p[i];

  q(n)= p;
  sort(all(q));
  
  if(q==p)
    ans=1;

  rep(i,n)
    if(q[i] != p[i])
      cnt++;

  if(cnt==2)
    ans=1;
  
  if(ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:4: error: no match for call to '(vi {aka std::vector<int>}) (int&)'
   18 |   q(n)= p;
      |   ~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  bool ans=0;
  int n,cnt=0;
  cin >> n;
  vi p(n);
  rep(i,n)
    cin >> p[i];

  vi q(n)= p;
  sort(all(q));
  
  if(q==p)
    ans=1;

  rep(i,n)
    if(q[i] != p[i])
      cnt++;

  if(cnt==2)
    ans=1;
  
  if(ans)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: expected ',' or ';' before '=' token
   18 |   vi q(n)= p;
      |          ^
Language: C++

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


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

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


Compiler output:
a.cc:7:1: error: extended character 　 is not valid in an identifier
    7 | 　int n,co;
      | ^
a.cc: In function 'int main()':
a.cc:7:1: error: '\U00003000int' was not declared in this scope
    7 | 　int n,co;
      | ^~~~~
a.cc:8:3: error: 'co' was not declared in this scope; did you mean 'cos'?
    8 |   co=0;
      |   ^~
      |   cos
a.cc:9:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    9 |   cin>>n;
      |        ^
      |        yn
a.cc:12:10: error: 'a' was not declared in this scope
   12 |     cin>>a[i];
      |          ^
a.cc:13:5: error: 'b' was not declared in this scope
   13 |     b[i]=a[i];
      |     ^
a.cc:15:8: error: 'b' was not declared in this scope
   15 |   sort(b.begin(),b.end());
      |        ^
a.cc:17:8: error: 'a' was not declared in this scope
   17 |     if(a[i]!=b[i]){
      |        ^
Language: C++

#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int N = 0;
    cin >> N;
    vector<int> nums(N);
    
    rep(i, N) scanf("%d", &nums[i]);

    int count = 0;
    rep(i, N-1) { //counting numbers that is not sequential.
        if (nums.at(i)+1 != nums.at(i+1)) { 
            count++;
        }
        if (count > 2) { printf("NO"); return 0; }
    }
    if (count<=2) printf("YES");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin >> N;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <vector>
  +++ |+#include <iostream>
    2 | 
a.cc:11:15: error: 'scanf' was not declared in this scope
   11 |     rep(i, N) scanf("%d", &nums[i]);
      |               ^~~~~
a.cc:18:26: error: 'printf' was not declared in this scope
   18 |         if (count > 2) { printf("NO"); return 0; }
      |                          ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    1 | #include <vector>
  +++ |+#include <cstdio>
    2 | 
a.cc:20:19: error: 'printf' was not declared in this scope
   20 |     if (count<=2) printf("YES");
      |                   ^~~~~~
a.cc:20:19: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

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

int main() {
    int N;
    string P;
    
    cin >>N;
    rep(i,0,N) cin >> P[i];
    
    string SP = P;
    sort(SP.begin(),SP.end());
    
    string ans;
    if(SP==P) ans = "YES";
    else{
        int cnt = 0;
        rep(i,0,N) if(S[i]!=SP[i]) cnt++;
        cnt==2 ? ans = "YES" : ans = "NO";
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:24: error: expected primary-expression before 'int'
    2 | #define rep(i,a,n) fot(int i=a;i<n;i++)
      |                        ^~~
a.cc:10:5: note: in expansion of macro 'rep'
   10 |     rep(i,0,N) cin >> P[i];
      |     ^~~
a.cc:10:9: error: 'i' was not declared in this scope
   10 |     rep(i,0,N) cin >> P[i];
      |         ^
a.cc:2:32: note: in definition of macro 'rep'
    2 | #define rep(i,a,n) fot(int i=a;i<n;i++)
      |                                ^
a.cc:2:24: error: expected primary-expression before 'int'
    2 | #define rep(i,a,n) fot(int i=a;i<n;i++)
      |                        ^~~
a.cc:19:9: note: in expansion of macro 'rep'
   19 |         rep(i,0,N) if(S[i]!=SP[i]) cnt++;
      |         ^~~
Language: C++

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

int main () {
  int n, p=0; cin >> n;
  vector<int> vec(n);
  for (int i=0;i<n;i++) 
    cin >> vec.at(i);
   a = sort(vec.begin(), vec.end());
  for (int i=0;i<n;i++) {
    if (a.at(i) != vec.at(i))
      p++;
  }
  if (p == 0 || p == 2)
    cout << "YES";
  else cout << "NO";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:4: error: 'a' was not declared in this scope
    9 |    a = sort(vec.begin(), vec.end());
      |    ^
Language: C++

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

int main () {
  int n, p=0; cin >> n;
  vector<int> vec(n);
  for (int i=0;i<n;i++) 
    cin >> vec.at(i);
  vector<int> a = sort(vec.begin(), vec.end());
  for (int i=0;i<n;i++) {
    if (a.at(i) != vec.at(i))
      p++;
  }
  if (p == 0 || p == 2)
    cout << "YES";
  else cout << "NO";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:23: error: conversion from 'void' to non-scalar type 'std::vector<int>' requested
    9 |   vector<int> a = sort(vec.begin(), vec.end());
      |                   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,count=0;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p.at(i);
  }
  for(int i=0;i<n;i++){
    if(p.at(i)==i+1){
      count++;
    }
  }
  if(count==n||count=n-2){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:14: error: lvalue required as left operand of assignment
   16 |   if(count==n||count=n-2){
      |      ~~~~~~~~^~~~~~~
Language: C++


#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N;
	int ans;
	
	cin >> N;

	int n;
	int cnt = 0;
	for (int ni = 1; ni <= N; ni++){
		cin >> n;
		if (ni != n){
			cnt++;
		}
	}

	if (cnt <= 2){
		printf("YES");
	}else{
		printf("NO");
	}


	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'cin' was not declared in this scope
   18 |         cin >> N;
      |         ^~~
a.cc:9:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    8 | #include <random>
  +++ |+#include <iostream>
    9 |
Language: C++


#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N;
	int ans;
	
	cin >> N;

	int n;
	int cnt = 0;
	for (int ni = 1; ni <= N; ni++){
		cin >> n;
		if (ni != n){
			cnt++;
		}
	}

	if (cnt <= 2){
		printf("YES");
	}else{
		printf("NO");
	}


	//printf("No");


	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'cin' was not declared in this scope
   18 |         cin >> N;
      |         ^~~
a.cc:9:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    8 | #include <random>
  +++ |+#include <iostream>
    9 |
Language: Java

import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++) p[i] = sc.nextInt();

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
                ok = true;
                for(int k = 0; k < n - 1; k++) {
                    if(p[k] >= p[k + 1]) {
                        ok = false;
                        break;
                    }
                }
                ans |= ok;
            }
        }

        System.out.println(ok?"YES":"NO");

    } 
}

Compiler output:
Main.java:18: error: cannot find symbol
                ok = true;
                ^
  symbol:   variable ok
  location: class Main
Main.java:21: error: cannot find symbol
                        ok = false;
                        ^
  symbol:   variable ok
  location: class Main
Main.java:25: error: cannot find symbol
                ans |= ok;
                ^
  symbol:   variable ans
  location: class Main
Main.java:25: error: cannot find symbol
                ans |= ok;
                       ^
  symbol:   variable ok
  location: class Main
Main.java:29: error: cannot find symbol
        System.out.println(ok?"YES":"NO");
                           ^
  symbol:   variable ok
  location: class Main
5 errors
Language: C++

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

int main() {
    int n;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++) cin>>p[i];
  	int s[n];
  	s=p;
  	int cnt=0;
  	sort(s.begin(), s.end());
  	for(int i=0;i<n;i++) if(p[i]!=s[i]) cnt++;
  	cnt>2? cout<<"NO"<<endl: cout<<"YES"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:10: error: invalid array assignment
   10 |         s=p;
      |         ~^~
a.cc:12:16: error: request for member 'begin' in 's', which is of non-class type 'int [n]'
   12 |         sort(s.begin(), s.end());
      |                ^~~~~
a.cc:12:27: error: request for member 'end' in 's', which is of non-class type 'int [n]'
   12 |         sort(s.begin(), s.end());
      |                           ^~~
Language: C++

#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int a[N];

signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n;  cin >> n;
    for(int i = 1; i <= n; i++){
        int p; cin >> p;
        if(p != i)  c++;
    }
    if(c == 0 || c == 2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:21: error: 'c' was not declared in this scope
   31 |         if(p != i)  c++;
      |                     ^
a.cc:33:8: error: 'c' was not declared in this scope
   33 |     if(c == 0 || c == 2)
      |        ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'i' was not declared in this scope
   13 |     if (p[i] != p[i+1]) {
      |           ^