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

#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  int niza[n];
  for(int i=0; i<n; i++)
  {	
    cin>>niza[i];
  }
  int cnt=0;
  vector<int> v;
  for(int i=0; i<n-1; i++)
  {
    if(niza[i]>niza[i+1])
    {
     cnt++;
      v.push_back(i);
    }
  }
  if(cnt>2)cout<<"NO"<<endl;
  swap(niza[v[0]],niza[v[1]]);
  for(int i=0; i<n-1i++)
  {
   if(niza[i]>niza[i+1])
      {
     cout<<"NO"<<endl;
     return 0;
      }
  }
  cout<<"YES"<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:22: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   26 |   for(int i=0; i<n-1i++)
      |                    ~~^~
a.cc:26:24: error: expected ';' before ')' token
   26 |   for(int i=0; i<n-1i++)
      |                        ^
      |                        ;
Language: C

# include <stdio.h>

int main(){

	int N;
	int flag=0;
	int i=0;
	scanf("%d",&N);
	
	char s[N+1];
	scanf("%c", s[]);

		//i+1番目の要素がi番目の要素+1になっているか
		//なっていればスルー、なっていなければflagに1足す	
	while( i<N-1 || flag==3 ){
		if( s[i+1] == (s[i]+1) ){		
		;
		}else{
			flag += flag;
		}
	}
	//繰り返していき、flagが0か2になればYESを返し、3になった時点でNOを返す
	if( flag==0 || flag==2 ){
		printf("YES");
	}else{
		printf("NO");
	}
}

Compiler output:
main.c: In function 'main':
main.c:11:23: error: expected expression before ']' token
   11 |         scanf("%c", s[]);
      |                       ^
Language: C

# include <stdio.h>

int main(){

	int N;
	int flag=0;
	int i=0;
	scanf("%d",&N);
	
	char s[N+1];
	scanf(%c, s[]);

		//i+1番目の要素がi番目の要素+1になっているか
		//なっていればスルー、なっていなければflagに1足す	
	while( i<N-1 || flag==3 ){
		if( s[i+1] == (s[i]+1) ){		
		;
		}else{
			flag += flag;
		}
	}
	//繰り返していき、flagが0か2になればYESを返し、3になった時点でNOを返す
	if( flag==0 || flag==2 ){
		printf("YES");
	}else{
		printf("NO");
	}
}

Compiler output:
main.c: In function 'main':
main.c:11:15: error: expected expression before '%' token
   11 |         scanf(%c, s[]);
      |               ^
Language: C

# include <stdio.h>

int main(){

	int N
	int flag=0;
	int i=0
	scanf("%d",&N);
	
	char s[N+1];
	scanf(%c, s[]);

		//i+1番目の要素がi番目の要素+1になっているか
		//なっていればスルー、なっていなければflagに1足す	
	while( i<N-1 || flag==3 ){
		if( s[i+1] == (s[i]+1) ){		
		;
		}else{
			flag += flag;
		}
	}
	//繰り返していき、flagが0か2になればYESを返し、3になった時点でNOを返す
	if( flag==0 || flag==2 ){
		printf("YES");
	}else{
		printf("NO");
	}
}

Compiler output:
main.c: In function 'main':
main.c:5:14: error: expected ';' before 'int'
    5 |         int N
      |              ^
      |              ;
    6 |         int flag=0;
      |         ~~~   
main.c:8:9: error: expected ',' or ';' before 'scanf'
    8 |         scanf("%d",&N);
      |         ^~~~~
main.c:10:16: error: 'N' undeclared (first use in this function)
   10 |         char s[N+1];
      |                ^
main.c:10:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:11:15: error: expected expression before '%' token
   11 |         scanf(%c, s[]);
      |               ^
Language: C++

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

int main(){

    int N;
    
    int count = 0;

    cin >> N;

    rep(i,N){
        int cur;
        cin >> cur;
        if(cur != prev + 1 && i != 1){
            count++;
        }
        prev = cur;
    }

    if(count>1){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:24: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   19 |         if(cur != prev + 1 && i != 1){
      |                   ~~~~~^~~
a.cc:22:16: error: overloaded function with no contextual type information
   22 |         prev = cur;
      |                ^~~
Language: Java

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


Compiler output:
Main.java:7: error: ';' expected
        for(int i=1; i<=n, i++){
                         ^
1 error
Language: Java

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

Compiler output:
Main.java:1: error: ';' expected
import java.util.*
                  ^
Main.java:7: error: ';' expected
        for(int i=1; i<=n, i++){
                         ^
2 errors
Language: C++

#include <iostream>
using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> p(n),p_sort(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:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> p(n),p_sort(n);
      |          ^~~
a.cc:13:11: error: 'p' was not declared in this scope
   13 |    cin >> p[i];
      |           ^
a.cc:16:8: error: 'p' was not declared in this scope
   16 |   copy(p.begin(),p.end(),p_sort.begin());
      |        ^
a.cc:16:26: error: 'p_sort' was not declared in this scope; did you mean 'u_short'?
   16 |   copy(p.begin(),p.end(),p_sort.begin());
      |                          ^~~~~~
      |                          u_short
a.cc:17:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |   sort(p_sort.begin(),p_sort.end());
      |   ^~~~
      |   short
Language: Java

import java.util.*;

class Main{
	
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 0;
        int num = sc.nextInt();
        List<Integer> alist = new ArrayList<Integer>();
        for(int i = 0; i < num;i++) {
        	alist.add(sc.nextInt());
        }
for(int i =0;i < num;i++) {
	int c = 1;
	if(alist.get(i)==c) {
		cnt++;
	}
	c++;
}        


	if(cnt <= 2) {
		System.out.println("YES");
	}else {
		System.out.println("NO");
	}
	
	}

Compiler output:
Main.java:28: error: reached end of file while parsing
	}
	 ^
1 error
Language: Java

class Main{
	
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 0;
        int num = sc.nextInt();
        List<Integer> alist = new ArrayList<Integer>();
        for(int i = 0; i < num;i++) {
        	alist.add(sc.nextInt());
        }
for(int i =0;i < num;i++) {
	int c = 1;
	if(alist.get(i)==c) {
		cnt++;
	}
	c++;
}        


	if(cnt < 2) {
		System.out.println("YES");
	}else {
		System.out.println("NO");
	}
	
	}
}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
Main.java:7: error: cannot find symbol
        List<Integer> alist = new ArrayList<Integer>();
        ^
  symbol:   class List
  location: class Main
Main.java:7: error: cannot find symbol
        List<Integer> alist = new ArrayList<Integer>();
                                  ^
  symbol:   class ArrayList
  location: class Main
4 errors
Language: Java

class Main{
	
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 0;
        int num = sc.nextInt();
        List<Integer> alist = new ArrayList<Integer>();
        for(int i = 0; i < num;i++) {
        	alist.add(sc.nextInt());
        }
for(int i =0;i < num;i++) {
	int c = 1;
	if(alist.get(i)==c) {
		cnt++;
	}
	c++;
}        


	if(cnt <= 2) {
		System.out.println("YES");
	}else {
		System.out.println("NO");
	}
	
	}
}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
Main.java:7: error: cannot find symbol
        List<Integer> alist = new ArrayList<Integer>();
        ^
  symbol:   class List
  location: class Main
Main.java:7: error: cannot find symbol
        List<Integer> alist = new ArrayList<Integer>();
                                  ^
  symbol:   class ArrayList
  location: class Main
4 errors
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;

int n;
int a, q;
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(a != i){
            q++;
        }
    }
    if(q > 2){
        cout << "NO";
    }
    else {
        cout << "YES";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: invalid types 'int[int]' for array subscript
   13 |         cin >> a[i];
      |                 ^
Language: Java

class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 0;
        int num = sc.nextInt();
        List<Integer> alist = new ArrayList<Integer>();
        for(int i = 0; i <= num;i++) {
        	alist.add(sc.nextInt());
        }
        
	List<Integer> list = new ArrayList<Integer>();
	for(int i = 0;i <=num;i++) {
		list.add(i);
	}
	for(int a : alist){
        for(int b : list){
            if(a==b){
                cnt+=1;
            }
            break;
        }
    }
	if(num - cnt < 2 || num == cnt) {
		System.out.println("YES");
	}else {
		System.out.println("NO");
	}
	
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
Main.java:6: error: cannot find symbol
        List<Integer> alist = new ArrayList<Integer>();
        ^
  symbol:   class List
  location: class Main
Main.java:6: error: cannot find symbol
        List<Integer> alist = new ArrayList<Integer>();
                                  ^
  symbol:   class ArrayList
  location: class Main
Main.java:11: error: cannot find symbol
	List<Integer> list = new ArrayList<Integer>();
	^
  symbol:   class List
  location: class Main
Main.java:11: error: cannot find symbol
	List<Integer> list = new ArrayList<Integer>();
	                         ^
  symbol:   class ArrayList
  location: class Main
6 errors
Language: Java

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


Compiler output:
Main.java:15: error: reached end of file while parsing
    }
     ^
1 error
Language: Java

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    
    String strN = scan.next();   
    int n = Integer.parseInt(strN);
    
    String s = "";
    int[] p = int[n];
    
    for (int i = 0; i < n; i++) {
      String s = scan.next();
      int p[i] = Integer.parseInt(s);
    }
    
    for (int k = 0; k < n; k++) {
          if (p[k] > p[k+1]) {
            break;
          } else if (k == n - 1) {
            System.out.print("YES");
          }
    }
    
    int tmp = 0;
    
    for (int i = 0; i < n; i++) {
      tmp = p[i];
      
      for (int j = i; j < n; i++) {
        p[i] = p[j];
        p[j] = tmp;
        
        for (int k = 0; k < n; k++) {
          if (p[k] > p[k+1]) {
            break;
          } else if (k == n - 1) {
            System.out.print("YES");
          }
        }
      }
    }
    
    System.out.print("NO");
  }
}

Compiler output:
Main.java:11: error: ']' expected
    int[] p = int[n];
                  ^
Main.java:11: error: ';' expected
    int[] p = int[n];
                   ^
Main.java:15: error: ']' expected
      int p[i] = Integer.parseInt(s);
            ^
Main.java:15: error: ';' expected
      int p[i] = Integer.parseInt(s);
             ^
4 errors
Language: Java

import java.util.*;
 
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 0; j < n; j ++) {
      if (array[j] != j) {
        count ++;
        if (count = 2) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
}

Compiler output:
Main.java:22: error: incompatible types: int cannot be converted to boolean
        if (count = 2) {
                  ^
1 error
Language: Java

import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] array = new int[n];
    
    for (int i = 0; i < n; i ++) {
      array[i] = sc.nextInt();
    }
    
    // At least 3 elements NOT satisfy array[i] = i, cannot sort in ASC
    int count = 0;
    String result = "YES";
    
    for (int j = 0; j < n; j ++) {
      if (array[j] != j) {
        count ++;
        if (count = 2) {
          result = "NO";
          break;
        }
      }
    }
    
    System.out.println(result);
  }
  
}

Compiler output:
Main.java:22: error: incompatible types: int cannot be converted to boolean
        if (count = 2) {
                  ^
1 error
Language: C++

import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int[] array = new int[N];
		int[] buff = new int[N];
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}
		buff = array.clone();
		Arrays.sort(buff);
		int flg=0;
		for(int i=0;i<N;i++) {
			if(array[i]!=buff[i]) {
				flg++;
			}
		}
		if(flg<=2) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Arrays;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int count=0;
    vector<int>p(N);
    for(int i=0;i<N;i++){
        cin>>p[i];
        if(p[i]==i+1){
            
        }else{
            count++
        }
    }
    if(count<=2){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:20: error: expected ';' before '}' token
   14 |             count++
      |                    ^
      |                    ;
   15 |         }
      |         ~
Language: C++

#include <iostream>
#include <utility>
#include <vector>
int main()
{
    auto v = std::vector<int>();
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++)
    {
        int num;
        std::cin >> num;
        v.push_back(num);
    }

    auto v2 = v;
    std::sort(v.begin(), v.end());

    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (v[i] == v2[i])
        {
            count++;
        }
    }

    if (count == 1 || count == n)
    {
        std::cout << "YES";
    }
    else
    {
        std::cout << "NO";
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   17 |     std::sort(v.begin(), v.end());
      |          ^~~~
      |          qsort
Language: C++

#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int N;
	cin >> N;
	bool judge = false;
	vector<int> p(N);
	vector<int> save(N);
	fi(N) {
		int input;
		cin >> input;
		save[i] = input;
		p[i] = input;
	}

	int count = 0;
	fi(N) {
		
		if (p[i]==i+1) {
			continue;
		}
		else {
			count++;
		}
	}
	if (count<=2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
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> p(N);
  
  rep(i,n) cin >> p[i];
  
  int k= 0;
  rep(i,n) if(p[i] != i+1)k++;
  
  if(k>=2) cout << "YES" << endl;
  else cout << "NO" << endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'n' was not declared in this scope
   11 |   rep(i,n) cin >> p[i];
      |         ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i=0;i<(int)n;i++)
      |                                     ^
a.cc:14:9: error: 'n' was not declared in this scope
   14 |   rep(i,n) if(p[i] != i+1)k++;
      |         ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,n) for(int i=0;i<(int)n;i++)
      |                                     ^
Language: Java

public static void main(String[] args) {
    try (BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in))) {

        int a = 0;

        int count = 0;
        String line;
        while ((line = stdReader.readLine()) != null) {
            if (count == 0) {
                a = Integer.parseInt(line);
            } else if (count == 1) {
                break;
            }
            count++;
        }
        int[] array = Arrays.asList(line.split(" ")).stream().mapToInt(Integer::parseInt).toArray();
        if (answer2(a, array)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    } catch (Exception e) {
        System.exit(-1);
    }
}

private static boolean answer2(int a, int[] list) {

    int faultCount = 0;
    int faultIndex = -1;
    int targetIndex = list.length;
    boolean needSwap = false;
    for (int i = 0; i < list.length - 1; i++) {

        if (list[i] == a) {
            targetIndex = i;
        }

        boolean isTarget = (list[i] == a || list[i + 1] == a);
        if (isTarget) {
            if (list[i] > list[i + 1]) {
                needSwap = true;
            }
            continue;
        }

        if (list[i] > list[i + 1]) {
            faultCount++;
            faultIndex = i + 1;
        }
    }

    if (!needSwap && faultCount == 0) {
        return true;
    }
    if (faultCount > 1) {
        return false;
    }
    if (needSwap && faultIndex == -1) {
        return false;
    }

    int faultValue = list[faultIndex];
    list[faultIndex] = a;
    list[targetIndex] = faultValue;

    for (int i = 0; i < list.length - 1; i++) {
        if (list[i] > list[i + 1]) {
            return false;
        }
    }

    return true;

}

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
              ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: C

#include <stdio.h>

int main(void)
{
    int i,N,m,p[50];

    scanf("%d",&N);

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

    m = 0;
    for(i=0;i<N;i++)
       if (p[i] != i+1) m++;

    if(m==2 || m==0) printf("Yes");
    else if(m>2)     printf("No");

    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:9:15: error: 'n' undeclared (first use in this function)
    9 |     for(i=0;i<n;i++)
      |               ^
main.c:9:15: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

int main(void)
{
    int i,n,m,p[50];

    scanf("%d",&n);

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

    m = 0;
    for(i=0;i<n;i++)
       if (p[i] != i+1) m++;

    if(m==2 || m==0) printf("Yes");
    else if(m>2)     printf("No");

    return 0;
}
~                              

Compiler output:
main.c:21:1: error: expected identifier or '(' before '~' token
   21 | ~
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n;
  vecter<int> vec;
  cin >> n;
  for(int i = 0; i < n; i++){
    vec.push_back(i+1);
  }
  for(int i = 0; i < n; i++){
    if(i+1 != vec[i]){
      for(int j = n; j > i; j--){
        if(j+1 != vec[j]){
          swap(vec[i], vec[j]);
          for(int k = 0; k < n; k++){
            if(k != vec[k]){
              cout << "NO\n";
            }
          }
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vecter' was not declared in this scope
    7 |   vecter<int> vec;
      |   ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vecter<int> vec;
      |          ^~~
a.cc:10:5: error: 'vec' was not declared in this scope
   10 |     vec.push_back(i+1);
      |     ^~~
a.cc:13:15: error: 'vec' was not declared in this scope
   13 |     if(i+1 != vec[i]){
      |               ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
int main(){
  int n;
  vecter<int> vec;
  cin >> n;
  for(int i = 0; i < n; i++){
    vec.push_back(i+1);
  }
  for(int i = 0; i < n; i++){
    if(i+1 != vec[i]){
      for(int j = n; j > i; j--){
        if(j+1 != vec[j]){
          swap(vec[i], vec[j]);
          for(int k = 0; k < n; k++){
            if(k != vec[k]){
              cout << "NO\n";
            }
          }
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'vecter' was not declared in this scope
    6 |   vecter<int> vec;
      |   ^~~~~~
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vecter<int> vec;
      |          ^~~
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> n;
      |   ^~~
      |   std::cin
In file included 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:9:5: error: 'vec' was not declared in this scope
    9 |     vec.push_back(i+1);
      |     ^~~
a.cc:12:15: error: 'vec' was not declared in this scope
   12 |     if(i+1 != vec[i]){
      |               ^~~
a.cc:15:11: error: 'swap' was not declared in this scope
   15 |           swap(vec[i], vec[j]);
      |           ^~~~
a.cc:15:11: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note:   'std::swap'
 2122 |     swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   'std::__exception_ptr::swap'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
a.cc:18:15: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |               cout << "NO\n";
      |               ^~~~
      |               std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:21:11: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |           cout << "YES\n";
      |           ^~~~
      |           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>

int main()
{
  int N;
  cin >> N;
  int p[N];
  for (int i = 0; i < N; i++) cin >> p[i];
  
  int  c = 0;
  for (int i = 0; i < N; i++){
    if (p[i] != i+1) c++;
  }
  
  if (c < 2) {
    std::cout << "YES" << endl;
    return 0;
  }
  
  else {
    c = 0;
    for (int i = 0; i < N-1; i++){
      if (p[i] != i+2) c++;
    }
    if (c == 0){
      std::cout << "YES" << endl;
      return 0;
    }
    
    else {
      c = 0;
      for ( int i = 1; i < N; i++){
        if  (p[i] != i) c++;
      }
      if (c == 0){
        std::cout << "YES" << endl;
        return 0;
      }
    }
    
    std::cout << "NO" << endl;
    return 0;
  }
  
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   cin >> N;
      |   ^~~
      |   std::cin
In file included 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:16:27: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   16 |     std::cout << "YES" << endl;
      |                           ^~~~
      |                           std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:26:29: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |       std::cout << "YES" << endl;
      |                             ^~~~
      |                             std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:36:31: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   36 |         std::cout << "YES" << endl;
      |                               ^~~~
      |                               std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:41:26: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   41 |     std::cout << "NO" << endl;
      |                          ^~~~
      |                          std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:43:4: error: expected '}' at end of input
   43 |   }
      |    ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include <bits/stdc++.h>
        #define ll    long long
        #define lld long double
        #define hell  998244353 
         
        using namespace std;
         
         
         
        int main()
        {
        	ios::sync_with_stdio(0);
        	cin.tie(0);
        	cout.tie(0);
         ll n;
          cin>>n;
          vector <ll> v(n);
          for(int i=0;i<n;i++)
            cin>>v[i];
          ll a=-1,b=-1,c=-1,d=-1;
          ll k=0;
          for(ll i=0;i<n-1;i++)
          {
            if(v[i]>v[i+1])
            {
              if(a==-1)
              {
                a=v[i];
                b=v[i+1];
              }
              else
              {
                c=v[i];
                d=[i+1];
              }
              k++;
            }
            }
if(k==0 || k==1 || (k==2 && a>=c && d<=b))
cout<<"YES";
else
cout<<"NO";
cout<<endl;          
        }

Compiler output:
a.cc: In function 'int main()':
a.cc:34:21: error: expected ',' before '+' token
   34 |                 d=[i+1];
      |                     ^
      |                     ,
a.cc:34:21: error: expected identifier before '+' token
a.cc: In lambda function:
a.cc:34:24: error: expected '{' before ';' token
   34 |                 d=[i+1];
      |                        ^
a.cc: In function 'int main()':
a.cc:34:19: error: cannot convert 'main()::<lambda()>' to 'long long int' in assignment
   34 |                 d=[i+1];
      |                   ^~~~~
      |                   |
      |                   main()::<lambda()>
Language: C++

https://atcoder.jp/contests/abc135/clarifications#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll n;
    cin>>n;
    ll temp,c=0;
    for(ll i=0;i<n;++i)
    {
        cin>>temp;
        if(temp!=i+1)
        {
            ++c;
        }
    }
    if(c==0||c==2)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}

Compiler output:
a.cc:1:1: error: 'https' does not name a type
    1 | https://atcoder.jp/contests/abc135/clarifications#include<bits/stdc++.h>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'ios_base' has not been declared
    6 |     ios_base::sync_with_stdio(0);
      |     ^~~~~~~~
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin.tie(0);
      |     ^~~
a.cc:22:9: error: 'cout' was not declared in this scope
   22 |         cout<<"YES\n";
      |         ^~~~
a.cc:26:9: error: 'cout' was not declared in this scope
   26 |         cout<<"NO\n";
      |         ^~~~
Language: C++

#include<iostream>
#include<vector>

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   cin >> n;
      |   ^~~
      |   std::cin
In file included 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:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> p(n);
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/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:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> p(n);
      |          ^~~
a.cc:11:19: error: 'p' was not declared in this scope
   11 |   rep(i,n) cin >> p[i];
      |                   ^
a.cc:15:15: error: 'p' was not declared in this scope
   15 |   rep(i,n) if(p[i] != i+1)k++;
      |               ^
a.cc:16:12: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   if(k<=2) cout << "YES" << endl;
      |            ^~~~
      |            std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:16:29: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   16 |   if(k<=2) cout << "YES" << endl;
      |                             ^~~~
      |                             std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:17:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   17 |   else cout << "NO" << endl;
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:17:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   17 |   else cout << "NO" << endl;
      |                        ^~~~
      |                        std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

int main() {
	int N;
	cin >> N;
	int p[60];
	for (int i = 0; i < N;++i) {
		cin >> p[i];
	}

	int count = 0;

	for (int i = 0; i < N - 1; i++) {
		if (i!=p[i]) {
			count += 1;
		}
	}

	if(count<=2){
		cout << "YES" << endl;

	}

	else {
		cout << "NO" << endl;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:10: error: expected '}' at end of input
   28 |         }
      |          ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
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.at(i);
    if (P.at(i) == 1) mark1 = i;
  }
  
  bool flag = true;
  int zanki = 1;
  
  for (int i = 0; i < N; i++)
  {
    if (P.at(i) != i + 1)
    {
      if (zanki == 0)
      {
        flag = false;
        break;
      }
      else
      {
        int temp = P.at(i);
        P.at(i) = i + 1;
        P.at(temp) = temp;
        zanki--;
      }
    }
  }
  
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:23: error: 'mark1' was not declared in this scope
   13 |     if (P.at(i) == 1) mark1 = i;
      |                       ^~~~~
Language: C++

#include <iostream>
using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: expected ',' or ';' before 'if'
   11 |                 if( b != i + 1) cnt++;
      |                 ^~
Language: C++

//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

inline void print(string name,int *arr,int len){
	rep(i,1,len) printf("%s[%d]=%d\n",name.c_str(),i,arr[i]);puts("");
}
inline void print(string name,int a){
	printf("%s=%d\n",name.c_str(),a);puts("");
}

typedef long long ll;
const int INF=1<<30;

const int maxn=10000+10;

int main()
{
	int n;cin>>n;
	rep(i,1,n) cin>>a[i];
	rep(i,1,n) rep(j,i,n){
		swap(a[i],a[j]);
		int ok=1;
		rep(k,1,n-1){
			if(a[k]>a[k+1]) {ok=0;break;}	
		}
		if(ok) {puts("YES");return 0;}
	}
	puts("NO");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:25: error: 'a' was not declared in this scope
   33 |         rep(i,1,n) cin>>a[i];
      |                         ^
a.cc:35:22: error: 'a' was not declared in this scope
   35 |                 swap(a[i],a[j]);
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,j;
  cin>>n;
  int a[n+2],ami=0;
  for(i=0;i<n;i++)
cin>>a[i]; 
  for(i=0;i<n-1;i++
      {
        int x=abs(a[i]-a[i+1]);
        if(x!=1)
          ami++;
        
      }
  if(ami<3)
      cout<<"YES"<<endl;
      else
      cout<<"NO"<<endl;
  
  
  
  return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:10:20: error: expected ')' before '{' token
   10 |   for(i=0;i<n-1;i++
      |      ~             ^
      |                    )
   11 |       {
      |       ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[55],b[55];
int main()
{
	int n,k;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		b[i]=a[i];
	}
	sort(b,b+n);
	for (int i=0;i<n;i++)
	{
		if (a[i]!=b[i])
			k++;
		if (k>2)
		{
			printf("NO")
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:37: error: expected ';' before 'return'
   20 |                         printf("NO")
      |                                     ^
      |                                     ;
   21 |                         return 0;
      |                         ~~~~~~
Language: C++

#include <iostream>
#include <vector>

int main()
{
    int num;
    std::cin >> num;
    std::vector<int> values(num);
    for (size_t i {}; i < num; ++i)
        cin >> values[i];
    int count {};
    for (int i {}; i < num; ++i)
        if (values[i] != i + 1)
            ++count;
    if (count <= 2)
        cout << "YES";
    else
        cout << "NO";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |         cin >> values[i];
      |         ^~~
      |         std::cin
In file included 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:16:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |         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:18:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |         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>

int main()
{
    int num;
    std::cin >> num;
    std::vector<int> values(num);
    for (size_t i {}; i < num; ++i)
        cin >> values[i];
    int count {};
    for (int i {}; i < num; ++i)
        if (values[i] = i + 1)
            ++count;
    if (count <= 2)
        cout << "YES";
    else
        cout << "NO";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |         cin >> values[i];
      |         ^~~
      |         std::cin
In file included 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:16:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |         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:18:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |         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<bits/stdc++.h>
using namespace std;
int a[55];
int main()
{
	int n,k;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		b[i]=a[i];
	}
	sort(b,b+n);
	for (int i=0;i<n;i++)
	{
		if (a[i]!=b[i])
			k++;
		if (k>2)
		{
			printf("NO")
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'b' was not declared in this scope
   11 |                 b[i]=a[i];
      |                 ^
a.cc:13:14: error: 'b' was not declared in this scope
   13 |         sort(b,b+n);
      |              ^
a.cc:20:37: error: expected ';' before 'return'
   20 |                         printf("NO")
      |                                     ^
      |                                     ;
   21 |                         return 0;
      |                         ~~~~~~
Language: C++

#include <iostream>
#include <vector>

int main()
{
    int num;
    std::cin >> num;
    std::vector<int> values(num);
    for (size_t i {}; i < num; ++i)
        cin >> values[i];
    int count {};
    for (int i {}i < num; ++i)
        if (values[i] = i + 1)
            ++count;
    if (count <= 2)
        cout << "YES";
    else
        cout << "NO";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |         cin >> values[i];
      |         ^~~
      |         std::cin
In file included 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:12:18: error: expected ';' before 'i'
   12 |     for (int i {}i < num; ++i)
      |                  ^
      |                  ;
a.cc:16:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |         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:18:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |         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>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int p[100],q[100];
signed main(){
    int n,cnt=0;
    cin>>n;
    rep(i,n){
        cin>>p[i];
        q[i]=p[i];
    }
    sort(q,q+n);
    rep(i,n){
        if(p[i]!=q[i])cnt++;
    }
    if(cnt==0||cnt==2)puts("YES");
    else puts("NO");
    return 0;
}


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

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

void swap(int i, int j, int array[])
{
    int temp {array[i]};
    array[i] = rray[j];
    array[j] = temp;
}
int main()
{
    int num;
    cin >> num;
    int values[num];
    int copy[num];
    copy = values;
    sort(copy, copy + num);
    for (int i {}; i < num; ++i)
        cin >> values[i];
    for (size_t i {}; i < num - 1; ++i)
        for (size_t j {i+1}; j < num)
        {
            swap(i, j, values);
            if (values == copy)
                cout << "YES";
                return 0;
        }
    cout << "NO";
}

Compiler output:
a.cc: In function 'void swap(int, int, int*)':
a.cc:8:16: error: 'rray' was not declared in this scope; did you mean 'array'?
    8 |     array[i] = rray[j];
      |                ^~~~
      |                array
a.cc: In function 'int main()':
a.cc:17:10: error: invalid array assignment
   17 |     copy = values;
      |     ~~~~~^~~~~~~~
a.cc:22:37: error: expected ';' before ')' token
   22 |         for (size_t j {i+1}; j < num)
      |                                     ^
      |                                     ;
Language: C++

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

bool swap(int i, int j, int array[])
{
    int temp {array[i]};
    array[i] = rray[j];
    array[j] = temp;
}
int main()
{
    int num;
    cin >> num;
    int values[num];
    int copy[num];
    copy = values;
    sort(copy, copy + num);
    for (int i {}; i < num; ++i)
        cin >> values[i];
    for (size_t i {}; i < num - 1; ++i)
        for (size_t j {i+1}; j < num)
        {
            swap(i, j, values);
            if (values == copy)
                cout << "YES";
                return 0;
        }
    cout << "NO";
}

Compiler output:
a.cc: In function 'bool swap(int, int, int*)':
a.cc:8:16: error: 'rray' was not declared in this scope; did you mean 'array'?
    8 |     array[i] = rray[j];
      |                ^~~~
      |                array
a.cc:10:1: warning: no return statement in function returning non-void [-Wreturn-type]
   10 | }
      | ^
a.cc: In function 'int main()':
a.cc:17:10: error: invalid array assignment
   17 |     copy = values;
      |     ~~~~~^~~~~~~~
a.cc:22:37: error: expected ';' before ')' token
   22 |         for (size_t j {i+1}; j < num)
      |                                     ^
      |                                     ;
Language: C++

n = int(input())
p = int(input().split(' '))
count = 0
for num in range(p):
    if p[num] != num:
        count += 1
if count == 0 or count == 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++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:8:16: error: expected ';' before '<=' token
    8 |   for(int i=1,i<=n,i++){
      |                ^~
      |                ;
a.cc:8:16: error: expected primary-expression before '<=' token
    8 |   for(int i=1,i<=n,i++){
      |                ^~
a.cc:8:23: error: expected ';' before ')' token
    8 |   for(int i=1,i<=n,i++){
      |                       ^
      |                       ;