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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:6: error: structured binding declaration cannot have type 'int'
    9 |   int[]  p = new int[n];
      |      ^~
a.cc:9:6: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:9:6: error: empty structured binding declaration
a.cc:9:10: error: expected initializer before 'p'
    9 |   int[]  p = new int[n];
      |          ^
a.cc:11:17: error: 'p' was not declared in this scope
   11 |          cin >> p[i];
      |                 ^
a.cc:15:13: error: 'p' was not declared in this scope
   15 |          if(p[i] != (i+1)){
      |             ^
a.cc:35:10: error: 'p' was not declared in this scope
   35 |   delete p;
      |          ^
Language: C++

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

int main()
{
  int n; 
  cin >> n;
  
  vector<int> nums;
  int i = 0;
  
  while (i < n)
    cin >> nums[i];
  
  if (n == 1)
  {
  	cout << "YES"; 
    return 0;
  }
  
  vector<int> ind;
  for (int i = 1; i < n; i++)
  {
  	if (nums[i] < nums[i-1])
    {
    	ind.push_back(i-1);
    }
  }
  
  if (ind.size() != 2 || nums[ind[0]+1] < nums[ind[1]+1] || nums[ind[1]] > nums[ind[0])
  {
  	cout << "NO"; 
    return 0;
  }
  else
  {
  	cout << "YES"; 
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:87: error: expected ']' before ')' token
   31 |   if (ind.size() != 2 || nums[ind[0]+1] < nums[ind[1]+1] || nums[ind[1]] > nums[ind[0])
      |                                                                                       ^
      |                                                                                       ]
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: initializer fails to determine size of 'p'
    9 |   int  p[] = new int[n];
      |              ^~~~~~~~~~
a.cc:9:14: error: array must be initialized with a brace-enclosed initializer
a.cc:35:10: warning: deleting array 'p'
   35 |   delete p;
      |          ^
Language: C++

#include<iostream>
using namespace std;

int main()
{
  int n; 
  cin >> n;
  
  vector<int> nums;
  int i = 0;
  
  while (i < n)
    cin >> nums[i];
  
  if (n == 1)
  {
  	cout << "YES"; 
    return 0;
  }
  
  vector<int> ind;
  for (int i = 1; i < n; i++)
  {
  	if (nums[i] < nums[i-1])
    {
    	ind.push_back(i-1);
    }
  }
  
  if (ind.size() != 2 || nums[ind[0]+1] < nums[ind[1]+1] || nums[ind[1]] > nums[ind[0])
  {
  	cout << "NO"; 
    return 0;
  }
  else
  {
  	cout << "YES"; 
  }
  
  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> nums;
      |   ^~~~~~
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> nums;
      |          ^~~
a.cc:13:12: error: 'nums' was not declared in this scope
   13 |     cin >> nums[i];
      |            ^~~~
a.cc:21:10: error: expected primary-expression before 'int'
   21 |   vector<int> ind;
      |          ^~~
a.cc:24:13: error: 'nums' was not declared in this scope
   24 |         if (nums[i] < nums[i-1])
      |             ^~~~
a.cc:26:9: error: 'ind' was not declared in this scope; did you mean 'int'?
   26 |         ind.push_back(i-1);
      |         ^~~
      |         int
a.cc:30:7: error: 'ind' was not declared in this scope; did you mean 'int'?
   30 |   if (ind.size() != 2 || nums[ind[0]+1] < nums[ind[1]+1] || nums[ind[1]] > nums[ind[0])
      |       ^~~
      |       int
a.cc:30:26: error: 'nums' was not declared in this scope
   30 |   if (ind.size() != 2 || nums[ind[0]+1] < nums[ind[1]+1] || nums[ind[1]] > nums[ind[0])
      |                          ^~~~
a.cc:30:87: error: expected ']' before ')' token
   30 |   if (ind.size() != 2 || nums[ind[0]+1] < nums[ind[1]+1] || nums[ind[1]] > nums[ind[0])
      |                                                                                       ^
      |                                                                                       ]
Language: C++

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

int main(){
	int N,i;
  	cin >> N;
  
  	vector<int> vec(N);
  	vector<int> vec_sort(N);
  
  	for (i=0;i<N;i++){
    	cin >> vec.at(i);
    }
  
  	vec_sort = sort(vec.begin(),vec.end());
    
    
  	if (vec.at(i) == vec_sort.at(i)){
        cout << "YES" << endl;
        }
  
  	for (i=0;i<N-1;i++){
    	for (int j=1;j<N-i;j++){
        	swap(vec.at(i),vec.at(i+j));
          	if (vec.at(i) == vec_sort.at(i)){
            	cout << "YES" << endl;
              	break;
            }
          	else{
            	cout << "NO" << endl;
              	break;
            } 
        }
    }
  	

	return 0;
}


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

#include<bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  vector<int> B(N,0) = A;
  vector<int> C(N,0) = A;
  sort(B.begin(),B.end());
  for(int a=0;a<N-1;a++){
    for(int b=a+1;b<N;b++){
      swap(C.at(a),C.at(b));
      if(C == B){
        cout << "YES" << endl;
        break;
      }
    }
  }
  if(C != B){
    cout << "NO" << endl;
  }
}
      


Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: expected ',' or ';' before '=' token
   13 |   vector<int> B(N,0) = A;
      |                      ^
a.cc:14:22: error: expected ',' or ';' before '=' token
   14 |   vector<int> C(N,0) = A;
      |                      ^
Language: C++

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

int main(){
	int N;
  	cin >> N;
  
  	vector<int> vec(N);
  	vector<int> vec_sort(N);
  
  	for (int i=0;i<N;i++){
    	cin >> vec.at(i);
    }
  
  	for (int i=0;i<N;i++){
  		vec_sort.at(i) = sort(vec.begin(),vec.end());
    }
    
  	if (vec.at(i) == vec_sort.at(i)){
        cout << "YES" << endl;
        }
  
  	for (int i=0;i<N-1;i++){
    	for (int j=1;j<N-i;j++){
        	swap(vec.at(i),vec.at(i+j));
          	if (vec.at(i) == vec_sort.at(i)){
            	cout << "YES" << endl;
              	break;
            }
          	else{
            	cout << "NO" << endl;
              	break;
            } 
        }
    }
  	

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:38: error: void value not ignored as it ought to be
   16 |                 vec_sort.at(i) = sort(vec.begin(),vec.end());
      |                                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:19:20: error: 'i' was not declared in this scope
   19 |         if (vec.at(i) == vec_sort.at(i)){
      |                    ^
Language: C++

c,i,p;
main(n){scanf("%d",&n);for(;i<n;i++)scanf("%d",&p),c+=i!=p-1;puts(c<=2?"YES":"NO");}

Compiler output:
a.cc:1:1: error: 'c' does not name a type
    1 | c,i,p;
      | ^
a.cc:2:5: error: expected constructor, destructor, or type conversion before '(' token
    2 | main(n){scanf("%d",&n);for(;i<n;i++)scanf("%d",&p),c+=i!=p-1;puts(c<=2?"YES":"NO");}
      |     ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>


using namespace std;

int main()
{
	int N;
	cin >> N;
	
	int p[50];
	int c[50];

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

	memcpy(c, p, 50);
	sort(p, p + 5);

	int counter = 0;

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

	if (counter <= 1){
				cout << "YES" << endl;
				
	}
	else{
		cout << "NO" << endl;
	}


	//for (int i = 0; i < N-1; i++){
	//	if (p[i] < p[i + 1]){
	//		break;
	//	}
	//	if (i == N - 1){
	//		cout << "YES" << endl;
	//		//system("pause");
	//		return 0;
	//	}
	//}

	//for (int i = 0; i < N - 1; i++){


	//int K = 0;

	//if (A > B){
	//	K = A;
	//}
	//else{
	//	K = B;
	//}

	//	for (int i = K; i >= 0; i--) {
	//		if (abs(A - i) == abs(B - i)){
	//			cout << i << endl;
	//			//system("pause");
	//			return 0;
	//		}
	//	}

	//cout << "IMPOSSIBLE"<< endl;

	//system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'memcpy' was not declared in this scope
   23 |         memcpy(c, p, 50);
      |         ^~~~~~
a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <math.h>
  +++ |+#include <cstring>
    7 |
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>


using namespace std;

int main()
{
	int N;
	cin >> N;
	
	int p[50];
	int c[50];

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

	memcpy(c, p, 50);
	sort(p, p + 5);

	int counter = 0;

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

	if (counter <= 1){
				cout << "YES" << endl;
				
	}
	else{
		cout << "NO" << endl;
	}


	//for (int i = 0; i < N-1; i++){
	//	if (p[i] < p[i + 1]){
	//		break;
	//	}
	//	if (i == N - 1){
	//		cout << "YES" << endl;
	//		//system("pause");
	//		return 0;
	//	}
	//}

	//for (int i = 0; i < N - 1; i++){


	//int K = 0;

	//if (A > B){
	//	K = A;
	//}
	//else{
	//	K = B;
	//}

	//	for (int i = K; i >= 0; i--) {
	//		if (abs(A - i) == abs(B - i)){
	//			cout << i << endl;
	//			//system("pause");
	//			return 0;
	//		}
	//	}

	//cout << "IMPOSSIBLE"<< endl;

	system("pause");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'memcpy' was not declared in this scope
   23 |         memcpy(c, p, 50);
      |         ^~~~~~
a.cc:7:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    6 | #include <math.h>
  +++ |+#include <cstring>
    7 |
Language: C++

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n=sc.nextInt();
		int p[]=new int[n];
		int c = 0;
		for(int i=0;i<n;i++) {
			p[i]=sc.nextInt();
			if(p[i]!=i+1)c+=1;
		}
		if(c<=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.Scanner;
      | ^~~~~~
a.cc:1: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>
 
int main() {
  int n;
  std::cin >> n;
  int a[n];
  
  for(int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  
  int rev = 0;
  int f = 0;
  for(int i = 0; i < n-1; i ++) {
    if(a[i] > a[i+1]) {
      rev ++;
      if (a[i]-a[i+1]=1) {
        f ++;
      }
    }
  }
  if(rev >= 3) {
    std::cout << "NO" << std::endl;
  } else {
    std::cout << "YES" << std::endl;
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: lvalue required as left operand of assignment
   17 |       if (a[i]-a[i+1]=1) {
      |           ~~~~^~~~~~~
Language: C++

#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, COUT1, COUT2;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	COUT1 = 0;
	int tg;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) {
				COUT2++;
				// Hoan vi 2 so a[i] va a[j]
				tg = A[i];
				A[i] = A[j];
				A[j] = tg;
				COUT1 = 0;
				for (int k = 0; k < N - 1; k++) {
					if (A[k] == B[k]) {
						COUT1++;
					}
				}
				if (COUT1 == N) {
					cout << "YES" << endl;
					return 0;
				}
			}
		}
		if (COUT2 == 1 || COUT2 == 0) {
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
		return 0;
	}

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

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

int main(){
	int N;
	cin >> N;
	int a[N];
  for(i=0;i<N;i++){
  a[i]=N - i;
    cout<<a[i]<<endl;
  }
// 	cin >> b;
 //	if((a+b)%2==0){
//	c = ( a + b ) / 2;
//	cout << c << endl;
//    }else{
//    	cout << "IMPOSSIBLE" << endl;
//    }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   for(i=0;i<N;i++){
      |       ^
Language: Java

import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int p[] = new int[N];
        for (int i = 0, i < N, i++) {
            p[i] = sc.nextInt();
        }
        int c = 0;
        for (int j = 1, j < N, j++) {
            if (p[j] - p[j-1] != 1) {
                c++;
            }
        }
         if (N == 2 || c == 2 || c == 0) {
             System.out.println("YES");
         } else if(p[0] == 1 && p[N] == N && c == 3) {
             System.out.println("YES");
         } else {
             System.out.println("NO");
        }
    }
}

Compiler output:
Main.java:8: error: ';' expected
        for (int i = 0, i < N, i++) {
                         ^
Main.java:8: error: > or ',' expected
        for (int i = 0, i < N, i++) {
                                ^
Main.java:8: error: illegal start of expression
        for (int i = 0, i < N, i++) {
                                  ^
Main.java:12: error: ';' expected
        for (int j = 1, j < N, j++) {
                         ^
Main.java:12: error: > or ',' expected
        for (int j = 1, j < N, j++) {
                                ^
Main.java:12: error: illegal start of expression
        for (int j = 1, j < N, j++) {
                                  ^
6 errors
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
  cin >> n;
  vector<int> P(n), Psorted(n);
  for(int& i: P) cin >> i;
  Psorted = P;
  sort(Psorted.begin(), Psorted.end());
  int ccnt = 0;
  for(int i = 0; i < n; i++) if(P[i] != Psorted[i]) cnt++;
  if(cnt == 0 || cnt == 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:53: error: 'cnt' was not declared in this scope; did you mean 'ccnt'?
   13 |   for(int i = 0; i < n; i++) if(P[i] != Psorted[i]) cnt++;
      |                                                     ^~~
      |                                                     ccnt
a.cc:14:6: error: 'cnt' was not declared in this scope; did you mean 'ccnt'?
   14 |   if(cnt == 0 || cnt == 2) cout << "YES" << endl;
      |      ^~~
      |      ccnt
Language: C++

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

int main(){
    int n;
    vector<int>v;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    bool flag = false;
    if(std::is_sorted(v.begin(),v.end())){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<v.size();i++){
        int cur = v[i];
        for(int j=i+1;j<v.size();j++){
            swap(v[i],v[j]);
            // for(auto a:v){
            //     cout<<a<<" ";
            // }
            //cout<<endl;
            if(std::is_sorted(v.begin(),v.end())){
                flag = true;
                break;
            }
            swap(v[i],v[j]);
        }
    }
    if(!flag){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: 'is_sorted' is not a member of 'std'; did you mean 'is_signed'?
   15 |     if(std::is_sorted(v.begin(),v.end())){
      |             ^~~~~~~~~
      |             is_signed
a.cc:27:21: error: 'is_sorted' is not a member of 'std'; did you mean 'is_signed'?
   27 |             if(std::is_sorted(v.begin(),v.end())){
      |                     ^~~~~~~~~
      |                     is_signed
Language: C++

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

bool asc(vector<int> p){
    bool can = true;
    for(int i = 0; i < p.size()-1; i++){
        if((p.at(i+1)-p.at(i)) < 0){
            can = false;
            break;
        }
    }
    return can;
}

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p.at(i);
    if(asc(p) == true){
        cout << "YES" << endl;
        return 0;
    }
    int tmp;
    for(int i = 0; i < n-1; i++){
        for(int j = i + 1; j < n; j++){
            tmp = p.at(i);
            p.at(i) = p.at(j);
            p.at(j) = tmp;
            for(int k = 0; k < p.size(); k++) cout << p.at(k) << " "
            cout << endl;
            if(asc(p) == true){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:69: error: expected ';' before 'cout'
   30 |             for(int k = 0; k < p.size(); k++) cout << p.at(k) << " "
      |                                                                     ^
      |                                                                     ;
   31 |             cout << endl;
      |             ~~~~
Language: C++

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

int main(){
    int n;
    vector<int>v;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    bool flag = false;
    if(is_sorted(v.begin(),v.end())){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<v.size();i++){
        int cur = v[i];
        for(int j=i+1;j<v.size();j++){
            swap(v[i],v[j]);
            // for(auto a:v){
            //     cout<<a<<" ";
            // }
            //cout<<endl;
            if(is_sorted(v.begin(),v.end())){
                flag = true;
                break;
            }
            swap(v[i],v[j]);
        }
    }
    if(!flag){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: 'is_sorted' was not declared in this scope
   15 |     if(is_sorted(v.begin(),v.end())){
      |        ^~~~~~~~~
a.cc:27:16: error: 'is_sorted' was not declared in this scope
   27 |             if(is_sorted(v.begin(),v.end())){
      |                ^~~~~~~~~
Language: C++

/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
typedef long long ll;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int main(void){
    int n;
    cin >> n;

    vector<int> p(n);

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

    vector<int> sorted(n);
    for(int i = 0; i < n; i++){
        sorted[i] = p[i];
    }
    sort(sorted.begin(), sorted.end());

    bool finished = false;

    bool c = true;
    for(int i = 0; i < n; i++){
        if(p[i] != sorted[i]){
            c = false;
            break;
        }
    }

    if(c){
        cout << "YES" << endl;
        return 0;
    }

    for(int i = 0; i < n; i++)
        
        for(int j = 0; j < n; j++){
            vector<int> check(n);
            for(int a = 0; a < n; a++){
                check[a] = p[a];
            }

            // if(i == j)continue;

            swap(check[i], check[j]);

            bool ok = true;
            for(int a = 0; a < n; a++){
                if(check[a] != sorted[a]){
                    ok = false;
                    break;
                }
            }

            if(ok){
                finished = true;
                cout << i << " " << j << endl;
                break;
            }

        }
        if(finished)break;
    }

    if(finished){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


}


Compiler output:
a.cc: In function 'int main()':
a.cc:84:21: error: break statement not within loop or switch
   84 |         if(finished)break;
      |                     ^~~~~
a.cc: At global scope:
a.cc:87:5: error: expected unqualified-id before 'if'
   87 |     if(finished){
      |     ^~
a.cc:89:7: error: expected unqualified-id before 'else'
   89 |     } else {
      |       ^~~~
a.cc:94:1: error: expected declaration before '}' token
   94 | }
      | ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  for (int i = 0; i < n; i++) {
    cin >> data.at(i);
  }

  int answer = 0;

  for (int i = 0; i < n; i++) {

    if (data.at(i) > data.at(i+1) ) {
      answer++;
    }

  }

	if(answer < 2){
	cout << "YES" << endl;
	}
	else if{
	cout << "NO" << endl;
	}
}



Compiler output:
a.cc: In function 'int main()':
a.cc:25:16: error: expected '(' before '{' token
   25 |         else if{
      |                ^
      |                (
Language: C++

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	long n;
	long p[50];
	long i, j, chk_i, chk, tmp;

	scanf ("%ld", &n);

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

	chk = 1;
	for (i = 0; i < (n - 1); i++) {
		if (p[i] > p[i + 1]) {
			 chk = 0;
			 chk_i = i;
			 break;
		}
	}
	if(chk) {
		printf("YES\n");
		retrun 0:
	}
	for (j = 0; j < chk_i; j++) {
		tmp = p[j];
		p[j] = p[chk_i];
		p[chk_i] = tmp;
		chk = 1;
		for (i = 0; i < (n - 1); i++) {
			if (p[i] > p[i + 1]) {
				 chk = 0;
				break;
			}
		}
		if(chk) {
			printf("YES\n");
			return 0;
		}
		tmp = p[j];
		p[j] = p[chk_i];
		p[chk_i] = tmp;
	}
	for (j = chk_i + 1 ; j < n; j++) {
		tmp = p[j];
		p[j] = p[chk_i];
		p[chk_i] = tmp;
		chk = 1;
		for (i = 0; i < (n - 1); i++) {
			if (p[i] > p[i + 1]) {
				chk = 0;
				break;
			}
		}
		if(chk) {
			printf("YES\n");
			return 0;
		}
		tmp = p[j];
		p[j] = p[chk_i];
		p[chk_i] = tmp;
	}

	printf("NO\n");
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:26:17: error: 'retrun' was not declared in this scope
   26 |                 retrun 0:
      |                 ^~~~~~
Language: C++

#include<iostream>

int main() {
  int n;
  std::cin >> n;
  int a[n];
  
  for(int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  
  int rev = 0;
  for(int i = 0; i < n-1; i ++) {
    if(a[i] > a[i+1]) {
      rev ++;
    }
  }
  if(rev >= 2) {
    std::out << "NO" << std::endl;
  } else {
    std::out << "YES" << std::endl;
  }
  
  return 0;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: 'out' is not a member of 'std'; did you mean 'oct'?
   19 |     std::out << "NO" << std::endl;
      |          ^~~
      |          oct
a.cc:21:10: error: 'out' is not a member of 'std'; did you mean 'oct'?
   21 |     std::out << "YES" << std::endl;
      |          ^~~
      |          oct
Language: C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int hantei[2] = { 0,0 };
	int hantei_num = 0;
	int swap = 0;
	bool decision = true;
	int N = 0;
	scanf("%d", &N);
	

	int* array = (int*)malloc(N * sizeof(int));
	for (int i = 0; i < N; i++) {
		scanf("%d", array + i);
	}
	
	for (int i = 0; i < N; i++) {
		if (hantei_num >= 2) { break; }
		if (*(array + i) != (i + 1)) {
			hantei[hantei_num] = i;
			hantei_num++;
			continue;
		}
	}

	swap = *(array + hantei[0]);
	*(array + hantei[0]) = *(array + hantei[1]);
	*(array + hantei[1]) = swap;
	
	for (int i = 0; i < N; i++) {
		if (*(array + i) != (i + 1)) {
			decision = false;
			break;
		}
	}

	if (decision == true) {
		printf("YES");
	}
	else {
		printf("NO");
	}

	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:10:9: error: unknown type name 'bool'
   10 |         bool decision = true;
      |         ^~~~
main.c:4:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    3 | #include <stdlib.h>
  +++ |+#include <stdbool.h>
    4 | 
main.c:10:25: error: 'true' undeclared (first use in this function)
   10 |         bool decision = true;
      |                         ^~~~
main.c:10:25: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:10:25: note: each undeclared identifier is reported only once for each function it appears in
main.c:35:36: error: 'false' undeclared (first use in this function)
   35 |                         decision = false;
      |                                    ^~~~~
main.c:35:36: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C++

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

int main() {
  int N,K;
  cin >> N;
  K = 0;

 std::vector<int> P(N);
for (size_t i = 0; i <N; ++i) {
   cin >> P[i];
}

for (size_t t = 0; t <N; ++t) {
  if(P[t]!=t){
    K+=1;}
}
  
if(K=<2){
  cout << "YES" << endl;}
else {cout << "NO" << endl;}
  
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:6: error: expected primary-expression before '<' token
   19 | if(K=<2){
      |      ^
Language: C++

# include<iostream>
# include<vector>
using namespace std;
bool check(int arr[], int j, int n) {
    for (int i=j+1; j<n; j++) {
        if (arr[i-1] < arr[i])
            continue;
        else
        {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    scanf("%d", &n);
    if (n < 2) {
        cout << "YES" << endl;
        return 0;
    }
    vector<int> arr(n);
    vector<int> toCheck(n);
    for (int i=0; i<n; i++) {
        scanf("%d", &arr[i]);
        toCheck[i] = arr[i];
    }
    sort(arr.begin(), arr.end());
    int t = 0;
    for (int i=0; i<n; i++) {
        if (toCheck[i] != arr[i])
            t++;
    }
    if (t == 2 || t ==0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

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

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

#include<bits/stdc++.h>

using namespace std;

int main()
{
  int N;
  vector<int> A;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  vector<int> B = sort(A.begin(),A.end());
  for(int a=0;a<N-1;a++){
    for(int b=a+1;b<N;b++){
      swap(A.at(a),A.at(b));
      if(A == B){
        cout << "YES" << endl;
        break;
      }
    }
  }
  if(A != B){
    cout << "NO" << endl;
  }
}
      

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

#include <stdio.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
  int a[50],b[50],n,i,count++;
  scanf("%d",&n);
  for(i=0;i<n;i++) {scanf("%d",&a[i]);b[i]=a[i];}
  qsort(a, sizeof(a) / sizeof(int), sizeof(int), asc);
  
  for(i=0;i<n;i++){
    printf("a%d b%d\n",a[i],b[i]);
  	if(a[i]==b[i])/*NOP*/;
    else count++;
  }
  if(count>2)printf("NO\n");
  else printf("YES\n");
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token
    8 |   int a[50],b[50],n,i,count++;
      |                            ^~
main.c:11:3: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration]
   11 |   qsort(a, sizeof(a) / sizeof(int), sizeof(int), asc);
      |   ^~~~~
main.c:16:10: error: 'count' undeclared (first use in this function)
   16 |     else count++;
      |          ^~~~~
main.c:16:10: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

https://atcoder.jp/contests/abc135/tasks/abc135_b#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N =1e5+5;
const ll mod=1e9+7;
int a[110];
    int n;
bool ok()
{
    for(int i=1;i<n;i++)
        if(a[i]>a[i+1])
            return 0;
    return 1;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }

        if(ok()){printf("YES\n");return 0;}
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
    {
        swap(a[i],a[j]);

        if(ok()){printf("YES\n");return 0;}
        swap(a[i],a[j]);
    }
    printf("NO\n");
    return 0;
}


Compiler output:
a.cc:1:1: error: 'https' does not name a type
    1 | https://atcoder.jp/contests/abc135/tasks/abc135_b#include<bits/stdc++.h>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:17:5: error: 'scanf' was not declared in this scope
   17 |     scanf("%d",&n);
      |     ^~~~~
a.cc:23:18: error: 'printf' was not declared in this scope
   23 |         if(ok()){printf("YES\n");return 0;}
      |                  ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | https://atcoder.jp/contests/abc135/tasks/abc135_b#include<bits/stdc++.h>
a.cc:27:9: error: 'swap' was not declared in this scope
   27 |         swap(a[i],a[j]);
      |         ^~~~
a.cc:29:18: error: 'printf' was not declared in this scope
   29 |         if(ok()){printf("YES\n");return 0;}
      |                  ^~~~~~
a.cc:29:18: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:32:5: error: 'printf' was not declared in this scope
   32 |     printf("NO\n");
      |     ^~~~~~
a.cc:32:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

include<iostream>
using namespace std;
int main(){
    int N,Ma,Mb;
    cin>>N;
    int p[N];
    for(int a=0;a<N;a++){
        cin>>p[a];
    }
    for(int a=1;a<N-1;a++){
        if(p[a]!=p[a-1]-1&&p[a]!=[a+1]+1){
            Ma++;
        }
    }
    for(int a=1;a<N-1;a++){
        if(p[a]!=p[a-1]+1&&p[a]!=[a+1]-1){
            Mb++;
        }
    }
    if(Ma=0||Ma=2||Mb=0||Mb=2){
        cout<<'YES';
    }
    else{
        cout<<'NO';
    }
    return 0;
}

Compiler output:
a.cc:21:15: warning: multi-character character constant [-Wmultichar]
   21 |         cout<<'YES';
      |               ^~~~~
a.cc:24:15: warning: multi-character character constant [-Wmultichar]
   24 |         cout<<'NO';
      |               ^~~~
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin>>N;
      |     ^~~
a.cc:11:36: error: expected ',' before '+' token
   11 |         if(p[a]!=p[a-1]-1&&p[a]!=[a+1]+1){
      |                                    ^
      |                                    ,
a.cc:11:36: error: expected identifier before '+' token
a.cc: In lambda function:
a.cc:11:39: error: expected '{' before '+' token
   11 |         if(p[a]!=p[a-1]-1&&p[a]!=[a+1]+1){
      |                                       ^
a.cc: In function 'int main()':
a.cc:11:39: error: no match for 'operator+' (operand types are 'main()::<lambda()>' and 'int')
   11 |         if(p[a]!=p[a-1]-1&&p[a]!=[a+1]+1){
      |                                  ~~~~~^~
      |                                  |     |
      |                                  |     int
      |                                  main()::<lambda()>
a.cc:16:36: error: expected ',' before '+' token
   16 |         if(p[a]!=p[a-1]+1&&p[a]!=[a+1]-1){
      |                                    ^
      |                                    ,
a.cc:16:36: error: expected identifier before '+' token
a.cc: In lambda function:
a.cc:16:39: error: expected '{' before '-' token
   16 |         if(p[a]!=p[a-1]+1&&p[a]!=[a+1]-1){
      |                                       ^
a.cc: In function 'int main()':
a.cc:16:39: error: no match for 'operator-' (operand types are 'main()::<lambda()>' and 'int')
   16 |         if(p[a]!=p[a-1]+1&&p[a]!=[a+1]-1){
      |                                  ~~~~~^~
      |                                  |     |
      |                                  |     int
      |                                  main()::<lambda()>
a.cc:20:24: error: lvalue required as left operand of assignment
   20 |     if(Ma=0||Ma=2||Mb=0||Mb=2){
      |                       ~^~~~
a.cc:21:9: error: 'cout' was not declared in this scope
   21 |         cout<<'YES';
      |         ^~~~
a.cc:24:9: error: 'cout' was not declared in this scope
   24 |         cout<<'NO';
      |         ^~~~
Language: C++

#include<iostream>
#include<vector>
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> q=p;
    vector<int> k=p; 
    sort(q.begin(),q.end());
    sort(k.begin(),k.end(),greater<int>());
    bool a=false;
    for(int i=0;i<N;++i){
        if(p[i]==q[i])a=true;
        if(p[i]==k[i])a=true;
    }
    if(a==true)cout<<"YES";
        else cout<<"NO";
}
		

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

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

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



    for(int i=0;i < n ;i++){
      if(p[i] !== q[i]){
        d ++;
      }
    }
    if(d == 2 || d == 0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }

    }

  }


Compiler output:
Main.java:20: error: illegal start of expression
      if(p[i] !== q[i]){
                ^
1 error
Language: C++

using namespace std;
int main() {
    int N;
    vector<int> p(N);
    int c =0;
    for (int i =0;i<N;i++){
        cin >>p.at(i);
        if (p.at(i)!=i+1){
            c++; 
        }
    }
    if (c<=2){
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'vector' was not declared in this scope
    4 |     vector<int> p(N);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:4:12: error: expected primary-expression before 'int'
    4 |     vector<int> p(N);
      |            ^~~
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin >>p.at(i);
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:7:15: error: 'p' was not declared in this scope
    7 |         cin >>p.at(i);
      |               ^
a.cc:13:9: error: 'cout' was not declared in this scope
   13 |         cout << "YES\n";
      |         ^~~~
a.cc:13:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:16:9: error: 'cout' was not declared in this scope
   16 |         cout << "NO\n";
      |         ^~~~
a.cc:16:9: 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;
  	int a[n], b[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for(int i = 0; i < n; i++){
    if(a[i] != b[i]) cnt++;
  }
  if(cnt == 0 || cnt == 2) cout << "YES";
  else cout << "NO";
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: 'cnt' was not declared in this scope; did you mean 'int'?
   12 |     if(a[i] != b[i]) cnt++;
      |                      ^~~
      |                      int
a.cc:14:6: error: 'cnt' was not declared in this scope; did you mean 'int'?
   14 |   if(cnt == 0 || cnt == 2) cout << "YES";
      |      ^~~
      |      int
Language: C++

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

int main() {
  int n,c=0;
  cin >> n;
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  vector<int> sorted;
  sorted = vec;
  sort(sorted.begin(),sorted.end());
  for (int i=0; i<n; i++) {
    if (vec.at(i) != sorted.at(i)) c++;
  }
  if (c<3) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(sorted.begin(),sorted.end());
      |   ^~~~
      |   short
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);
    
    int tmp;
    bool can = true;
    for(int i = 0; i < n-1; i++){
        for(int j = i + 1; j < n; j++){
            tmp = p.at(i);
            p.at(i) = p.at(j);
            p.at(j) = tmp;
            for(int k = 0; k < n-1; k++){
                if((p.at(k+1) - p.at(k) > 0) can = false;
            }
            if(can == true){
                cout << "YES" << endl;
                return 0;
            }
            can = true;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:45: error: expected ';' before 'can'
   18 |                 if((p.at(k+1) - p.at(k) > 0) can = false;
      |                                             ^~~~
      |                                             ;
a.cc:19:13: error: expected primary-expression before '}' token
   19 |             }
      |             ^
a.cc:18:58: error: expected ')' before '}' token
   18 |                 if((p.at(k+1) - p.at(k) > 0) can = false;
      |                   ~                                      ^
      |                                                          )
   19 |             }
      |             ~                                             
a.cc:19:13: error: expected primary-expression before '}' token
   19 |             }
      |             ^
Language: C++

#include <iostream>
using namespace std;
int check(int *b,int a);
int main() {
  int a;
  cin >> a;
  int b[a];
  for (int i = 0;i < a ; i++)
  {
      cin >> b[i];
  }
  int c[a];
  int tmp;
for (int i = 0;i<a;i++)
{
  for(int j = i;j<a;j++)
  {
    for(int k = 0;k < a;k++)
    {
      c[k] = b[k];
    }
    tmp = c[i];
    c[i] = c[j];
    c[j] - tmp;
    if (check(c,a))
    {
      cout << "YES" << endl;
    }
  }
}
  cout << "NO" << endl;
  return 0;
}

bool check(int *b,int a)
{
  for(int i = 0;i<a - 1;i++)
  {
    if(b[i] > b[i + 1])
    {
      return false;
    }
    return true;
  }
}


Compiler output:
a.cc:35:6: error: ambiguating new declaration of 'bool check(int*, int)'
   35 | bool check(int *b,int a)
      |      ^~~~~
a.cc:3:5: note: old declaration 'int check(int*, int)'
    3 | int check(int *b,int a);
      |     ^~~~~
a.cc: In function 'bool check(int*, int)':
a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
Language: Java

import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
	int[] x = new int[n];
    int[] copyX = new int[n];

    for(int i = 0;i < n;i++){
      x[i] = sc.nextInt();
    }

    System.arraycopy(x,0,copyX,0,x.length);    
    int box = 0;
    Arrays.sort(x);
    int count = 0;
    for(int i = 0;i < n;i++){
        if(x[i] != copyX[i]){
            for(int i = 1;i < n;i++){
                if(x[i] != i){
                    count++;
                    if(count == 2){
                        System.out.println("NO");
                        break;
                    }
                }
            }
        }
        System.out.println("YES");
        break;
    }
  }
}

Compiler output:
Main.java:20: error: variable i is already defined in method main(String[])
            for(int i = 1;i < n;i++){
                    ^
1 error
Language: Java

import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
	int[] x = new int[n];
    int[] copyX = new int[n];

    for(int i = 0;i < n;i++){
      x[i] = sc.nextInt();
    }

    System.arraycopy(x,0,copyX,0,x.length);    
    int box = 0;
    Arrays.sort(x);
    int count = 0;
    for(int i = 0;i < n;i++){
        if(x[i] != copyX[i]){
            for(int i = 1;i < n;i++){
                if(x[i] != i){
                    count++;
                    if(count == 2){
                        System.out.println("NO");
                        break;
                    }
                }
            }
        }
        System.out.println("YES");
        break;
    }
      


Compiler output:
Main.java:32: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N,COUT;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i<N; i++) {
		cin >> A[i];
	}
	COUT = 0;
	int tg;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) {
				// Hoan vi 2 so a[i] va a[j]
				tg = A[i];
				A[i] = A[j];
				A[j] = tg;
				COUT++;
			}
		}
	}
	if (COUT <= 1) {
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}		
	return 0;
}


Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

int ooo(int n,int p[50])
{
	int ans = 0;
	int pi;
	for (size_t i = 0; i < n; i++)
	{
		pi = p[i];
		if (!(pi==(i+1)))
		{
			if (p[pi] = (i + 1))
			{
				ans++;
			}
		}
	}
	return ans;
}
int main()
{
	int n;
	cin >> n;
	int p[50];
	for (size_t i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	if (ooo(n, p) < 4)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
    return 0;
}


Compiler output:
a.cc: In function 'int ooo(int, int*)':
a.cc:5:14: error: 'size_t' was not declared in this scope
    5 |         for (size_t i = 0; i < n; i++)
      |              ^~~~~~
a.cc:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | int ooo(int n,int p[50])
a.cc:5:28: error: 'i' was not declared in this scope; did you mean 'pi'?
    5 |         for (size_t i = 0; i < n; i++)
      |                            ^
      |                            pi
a.cc: In function 'int main()':
a.cc:21:9: error: 'cin' was not declared in this scope
   21 |         cin >> n;
      |         ^~~
a.cc:23:14: error: 'size_t' was not declared in this scope
   23 |         for (size_t i = 0; i < n; i++)
      |              ^~~~~~
a.cc:23:14: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
a.cc:23:28: error: 'i' was not declared in this scope
   23 |         for (size_t i = 0; i < n; i++)
      |                            ^
a.cc:29:17: error: 'cout' was not declared in this scope
   29 |                 cout << "YES" << endl;
      |                 ^~~~
a.cc:29:34: error: 'endl' was not declared in this scope
   29 |                 cout << "YES" << endl;
      |                                  ^~~~
a.cc:33:17: error: 'cout' was not declared in this scope
   33 |                 cout << "NO" << endl;
      |                 ^~~~
a.cc:33:33: error: 'endl' was not declared in this scope
   33 |                 cout << "NO" << endl;
      |                                 ^~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
 
int main(void)
{
  int n;
  int cnt = 0;
  vector<int> v;
  cin >> n;
  
  int buf;
  for(int i = 0;i < n;i++)
  {
    cin >> buf;
  	v.push_back(buf);
    
  }
  
  for(i = 0;i < n;i++)
  {
  	if(v[i] != i + 1)
      cnt ++;
    if (cnt >= 3)
    {
      cout << "NO";
      break;
    }
  }
  
  if(cnt < 3)
    cout << "YES";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:7: error: 'i' was not declared in this scope
   20 |   for(i = 0;i < n;i++)
      |       ^
Language: C++

import copy
def main():
    N = input()
    array1 = list(map(int, input().split()))
    array2 = copy.deepcopy(array1)
    array1.sort()
    n = 0
    for c1,c2 in zip(array1,array2):
        if c1 != c2:
            n += 1
            if n == 3:
                print("NO")
                return
    print("YES")
    return
main()


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import copy
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'