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

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int ej=0;
    cin>>n;
    vector<int> value1,value2;
    for(int i=0;i<n;i++)
    {
        int m;
        cin>>m;
        value1.push_back(m);
    }
    value2=value1;
    sort(value1.begin(),value1.end());
    for(int i=0;i<n;i++)
    {
        if(value1[i]!=value2[i])
        {
            ej++;
        }
    }

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


}

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

import java.awt.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;

public class CandidateCode{
    public static void main(String args[] ) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        int[] b=a.clone();
        Arrays.sort(b);

        for(int i=0;i<n;i++){
            a[i]=a[i]-b[i];
        }

        int invCount=0;
        for(int i=0;i<n;i++){
            if(a[i]!=0)invCount++;
        }

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

}



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

import java.awt.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;

public class CandidateCode{
    public static void main(String args[] ) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];

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

        int invCount=0;

        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(a[i]>a[j]){
                    invCount++;
                }
            }
        }
        if(invCount<=1) System.out.println("YES");
        else System.out.println("NO");
    }

}


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

#include<bits/stdc++.h>

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
  	int n;
  cin>>n;
  vector<int> v(n);
  
  for (int i = 0; i<n; i++) {
   cin>>v[i]; 
  }
  int cnt = 0;
  for (int i = 0; i<n-1; i++) {
   if(v[i] > v[i+1]) {
    cnt++; 
   }
  }
   
  string s = cnt==1?"YES":"NO;
    
   cout<<s<<endl;
      return 0;
      
      }
 
  


Compiler output:
a.cc:23:27: warning: missing terminating " character
   23 |   string s = cnt==1?"YES":"NO;
      |                           ^
a.cc:23:27: error: missing terminating " character
   23 |   string s = cnt==1?"YES":"NO;
      |                           ^~~~
a.cc: In function 'int main()':
a.cc:23:20: error: operands to '?:' have different types 'const char [4]' and 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'}
   23 |   string s = cnt==1?"YES":"NO;
      |              ~~~~~~^~~~~~~~~~~
   24 | 
      |                     
   25 |    cout<<s<<endl;
      |    ~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
  	int n;
  cin>>n;
  vector<int> v(n);
  
  for (int i = 0; i<n; i++) {
   cin>>v[i]; 
  }
  int cnt = 0;
  for (int i = 0; i<n-1; i++) {
   if(v[i] > v[i+1] {
    cnt++; 
   }
  }
      
   cout<<cnt<<endl;
      return 0;
      
      }
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:18:20: error: expected ')' before '{' token
   18 |    if(v[i] > v[i+1] {
      |      ~             ^~
      |                    )
a.cc:21:3: error: expected primary-expression before '}' token
   21 |   }
      |   ^
Language: Java

import java.util.Scanner;
public class ABC135 {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		int c=0;
		for(int i=0;i<n-1;i++) {
			int min=a[i];
			int mins=i;
			for(int j=i+1;j<n;j++) {
				if(min>a[j]) {
					min=a[j];
					mins=j;
				}
			}
			if(min!=a[i]) {
				c++;
				int h=a[i];
				a[i]=a[mins];
				a[mins]=h;
			}

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

	}

}

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:24:14: error: invalid operands of types 'int' and 'const char [4]' to binary 'operator<<'
   24 |         cout << "YES" << endl;
      |         ~~~~ ^~ ~~~~~
      |         |       |
      |         int     const char [4]
a.cc:28:8: error: invalid operands of types 'int' and 'const char [3]' to binary 'operator<<'
   28 |   cout << "NO" << endl;
      |   ~~~~ ^~ ~~~~
      |   |       |
      |   int     const char [3]
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:30: error: expected ';' before '}' token
   11 |         if (x != i + 1) cnt++
      |                              ^
      |                              ;
   12 |     }
      |     ~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: error: expected ';' before 'return'
   18 |         cout<<"NO"<<endl
      |                         ^
      |                         ;
   19 |         return 0;;
      |         ~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: 'k' was not declared in this scope
   12 |         if(p[i]!=i+1)k++;
      |                      ^
Language: C++

N=int(input())
p = list(map(int,(input().split())))
ps=sorted(p)
if p == ps:
    print("YES")
else:    
    mx=p.index(max(p))
    mn=p.index(min(p))
    p[mx],p[mn] =p[mn],p[mx]
    if p == ps:
        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>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n){
    cin >> vec.at(i);
  }
  int dif = 0;
  rep(i,n){
    if(vec.at(i)-(i+1))==0) continue;
    dif++;
  }
  if (diff==2){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:14:24: error: expected primary-expression before '==' token
   14 |     if(vec.at(i)-(i+1))==0) continue;
      |                        ^~
a.cc:17:7: error: 'diff' was not declared in this scope; did you mean 'dif'?
   17 |   if (diff==2){
      |       ^~~~
      |       dif
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int main(){
  int N;
  cin>>N;
  vector<int> PPP(N);
  for(int i=0; i<N ;i++){
    cin>> PPP.at(i) ;
  }
  bool ans =true;
  int count=0;
  for(int i=0;i<N;i++){
   if(PPP.at(i)!=i+1){
     if(PPP.at(PPP.at(i)-1) !=i+1 ){
       ans =false;
       berak;
     }
     else if(PPP.at(PPP.at(i)-1) ==i+1 ){
       count ++;
     }
   }
  }
  if(count ==2){
    cout <<"YES"<<endl;
  }
  else if(ans){
    cout <<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:8: error: 'berak' was not declared in this scope; did you mean 'brk'?
   21 |        berak;
      |        ^~~~~
      |        brk
Language: C++

#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int main(){
  int N;
  cin>>N;
  vector<int> PPP(N);
  for(int i=0; i<N ;i++){
    cin>> PPP.at(i) ;
  }
  bool ans =true;
  int count=0;
  for(int i=0;i<N;i++){
   if(PPP.at(i)!=i+1){
     if(PPP.at(PPP.at(i)-1) !=i+1 ){
       ans =false;
       berak;
     }
     else if(PPP.at(PPP.at(i)-1) ==i+1 ){
       count ++;
     }
   }
  }
  if(count ==2){
    cout <<"YES"<<endl;
  }
  if else(ans){
    cout <<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:8: error: 'berak' was not declared in this scope; did you mean 'brk'?
   21 |        berak;
      |        ^~~~~
      |        brk
a.cc:31:6: error: expected '(' before 'else'
   31 |   if else(ans){
      |      ^~~~
      |      (
a.cc:34:3: error: 'else' without a previous 'if'
   34 |   else{
      |   ^~~~
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    if(is_sorted(v.begin(),v.end())){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<v.size();i++){
        for(int j=i+1;j<v.size();j++){
            swap(v[i],v[j]);
            if(is_sorted(v.begin(),v.end())){
                cout<<"YES"<<endl;
                return 0;
            }
            swap(v[i],v[j]);
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <math.h> // double fmod(double x, double y);

 using namespace std;


 int main()
 {
  int n;
  cin >> n;
  int hairetu[n];

  for(int i=0;i<n;i++)
  {
    int count = 0;
    if(hairetu[i] == i)
    {
      count ++;
    }
  }
  if (count < 3)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:23:7: error: 'count' was not declared in this scope
   23 |   if (count < 3)
      |       ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  int sum = 0;
  
  for(int i = 0 ; i < N ; i++){
    
    int num;
    cin >> num;
    
    if(num != i+1){
      sum++;
    }
    
  }
  
  if(sum <= 2){
    cout << "YES" << endl;
  }else{
    coout << "NO" << endl;
  }
}
    


Compiler output:
a.cc: In function 'int main()':
a.cc:23:5: error: 'coout' was not declared in this scope
   23 |     coout << "NO" << endl;
      |     ^~~~~
Language: C++

#incluude <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  int sum = 0;
  
  for(int i = 0 ; i < N ; i++){
    
    int num;
    cin >> num;
    
    if(num != i+1){
      sum++;
    }
    
  }
  
  if(sum <= 2){
    cout << "YES" << endl;
  }else{
    coout << "NO" << endl;
  }
}
    

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #incluude; did you mean #include?
    1 | #incluude <bits/stdc++.h>
      |  ^~~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> N;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #incluude <bits/stdc++.h>
a.cc:21:5: error: 'cout' was not declared in this scope
   21 |     cout << "YES" << endl;
      |     ^~~~
a.cc:21:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:22: error: 'endl' was not declared in this scope
   21 |     cout << "YES" << endl;
      |                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #incluude <bits/stdc++.h>
a.cc:23:5: error: 'coout' was not declared in this scope
   23 |     coout << "NO" << endl;
      |     ^~~~~
a.cc:23:22: error: 'endl' was not declared in this scope
   23 |     coout << "NO" << endl;
      |                      ^~~~
a.cc:23:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  bool jad = false;
  bool swi = true;
  
  vector<int> a(N);
  
  for(int i = 0 ; i < N ; i++){
    
    cin >> a.at(i);
    
  }
  
  for(int i = 0; i < N ; i++){
    
    int num = a.at(i);
    
    if(num == i+1){
      
      if(i == N -1){
        jad = true;
        break;
      }
      continue;
    }
    
    if(num != i+1){
      
      if(a.at(num-1) == i+1 ){
        
        if(swi){
          swi = false;
          continue;
        }
        else{
          break;
        }
      }
    }
    
  }
  
  

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

#include <stdio.h>
int main (void){
int n;
int a[50];
scanf("%d",&n);
for (int i=0;i<n;i++){
    scanf("%d",&a[i]);
}
int b=0;
for(int i=0;i<n;i++){
    if(a[i]>a[i+1]){
        b++;
    }
}
if(b<=1){
    printf("YES");
}else{
    printf("NO"):
}
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:18:17: error: expected ';' before ':' token
   18 |     printf("NO"):
      |                 ^
      |                 ;
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:8: error: 'll' was not declared in this scope
    6 |   for (ll i = 1; i <= n; i++) {
      |        ^~
a.cc:6:18: error: 'i' was not declared in this scope
    6 |   for (ll i = 1; i <= n; i++) {
      |                  ^
Language: C

#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  
  bool result = true;
  int p_strange = 0;
  int i;
  for(i = 0; i < n; i++){
    int p;
    scanf("%d", &p);
    if(p != i + 1){
      p_strange++;
    }
    if(p_strange > 2){
      result = false;
      break;
    }
  }
  
  if(result){
    printf("YES");
  }else{
    printf("NO");
  }
  
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:7:3: error: unknown type name 'bool'
    7 |   bool result = true;
      |   ^~~~
main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include<stdio.h>
  +++ |+#include <stdbool.h>
    2 | 
main.c:7:17: error: 'true' undeclared (first use in this function)
    7 |   bool result = true;
      |                 ^~~~
main.c:7:17: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:7:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:17:16: error: 'false' undeclared (first use in this function)
   17 |       result = false;
      |                ^~~~~
main.c:17:16: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C++

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


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

#include <bits/stdc++.h>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: expected primary-expression before ')' token
   10 |         for () {
      |              ^
a.cc:15:9: error: expected primary-expression before 'if'
   15 |         if (count == 2) cout << "YES";
      |         ^~
a.cc:14:6: error: expected ';' before 'if'
   14 |     }
      |      ^
      |      ;
   15 |         if (count == 2) cout << "YES";
      |         ~~
a.cc:15:9: error: expected primary-expression before 'if'
   15 |         if (count == 2) cout << "YES";
      |         ^~
a.cc:14:6: error: expected ')' before 'if'
   14 |     }
      |      ^
      |      )
   15 |         if (count == 2) cout << "YES";
      |         ~~
a.cc:10:13: note: to match this '('
   10 |         for () {
      |             ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: expected ';' before '}' token
   11 |       k++
      |          ^
      |          ;
   12 |     }
      |     ~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: 'n' was not declared in this scope
    8 |   for(i=0;i<n;i++) cin >> vec[i];
      |             ^
a.cc:9:13: error: 'n' was not declared in this scope
    9 |   for(i=0;i<n;i++){
      |             ^
a.cc:11:10: error: expected ';' before '}' token
   11 |       k++
      |          ^
      |          ;
   12 |     }
      |     ~
Language: Java

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

public class Main {
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int p[] = new int[N];
		int pSort[] = new int[N];
		int count = 0;

		for (int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
			pSort[i] =p[i];
		}
	
		Arrays.sort(pSort);
		
		for (int i = 0; i < N; i++) {
			if (p[i] != pSort[i]) {
				count++;
			}
		}
		if (count / 2 == 1 || count == 0) {
			System.out.print("YES");
		} else {
			System.out.print("NO");
		}

	}

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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: 'i' was not declared in this scope
   11 |                 if(a != i) cnt++;
      |                         ^
a.cc: At global scope:
a.cc:14:9: error: expected unqualified-id before 'if'
   14 |         if(cnt == 0 || cnt == 2){
      |         ^~
a.cc:16:11: error: expected unqualified-id before 'else'
   16 |         } else {
      |           ^~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: 'a' was not declared in this scope
   10 |                 cin >> a;
      |                        ^
a.cc:11:25: error: 'i' was not declared in this scope
   11 |                 if(a != i) cnt++;
      |                         ^
a.cc: At global scope:
a.cc:14:9: error: expected unqualified-id before 'if'
   14 |         if(cnt == 0 || cnt == 2){
      |         ^~
a.cc:16:11: error: expected unqualified-id before 'else'
   16 |         } else {
      |           ^~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: 'a' was not declared in this scope
   10 |                 cin >> a;
      |                        ^
a.cc:11:25: error: 'i' was not declared in this scope
   11 |                 if(a != i) cnt++;
      |                         ^
a.cc: At global scope:
a.cc:14:9: error: expected unqualified-id before 'if'
   14 |         if(cnt == 0 || cnt == 2){
      |         ^~
a.cc:16:11: error: expected unqualified-id before 'else'
   16 |         } else {
      |           ^~~~
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
Language: Java

import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
      	int counter = 0;
        for(int i = 0; i < n; i ++){
            s[i] = sca.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] != s[j]){
                counter++;
            }
        }
        System.out.print((counter==2 ? "YES" : "NO"));
        scan.close();
    }
}

Compiler output:
Main.java:11: error: cannot find symbol
            s[i] = sca.nextInt();
                   ^
  symbol:   variable sca
  location: class Main
1 error
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
        for(int i = 0; i < n; i ++){
            s[i] = sca.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] != s[j]){
                counter++;
            }
        }
        System.out.print((counter==2 ? "YES" : "NO"));
        scan.close();
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
            s[i] = sca.nextInt();
                   ^
  symbol:   variable sca
  location: class Main
Main.java:16: error: cannot find symbol
                counter++;
                ^
  symbol:   variable counter
  location: class Main
Main.java:19: error: cannot find symbol
        System.out.print((counter==2 ? "YES" : "NO"));
                          ^
  symbol:   variable counter
  location: class Main
3 errors
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] s = new int[n];
        int[] c = new int[n];
        for(int i = 0; i < n; i ++){
            s[i] = sca.nextInt();
            c[i] = s[i];
        }
        Arrays.sort(c);
        for(int j = 0; j < n; j++){
            if(c[j] != s[j]){
                counter++;
            }
        }
        System.out.print((counter==2 ? YES : NO));
        scan.close();
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
            s[i] = sca.nextInt();
                   ^
  symbol:   variable sca
  location: class Main
Main.java:16: error: cannot find symbol
                counter++;
                ^
  symbol:   variable counter
  location: class Main
Main.java:19: error: reference to print is ambiguous
        System.out.print((counter==2 ? YES : NO));
                  ^
  both method print(char[]) in PrintStream and method print(String) in PrintStream match
Main.java:19: error: cannot find symbol
        System.out.print((counter==2 ? YES : NO));
                          ^
  symbol:   variable counter
  location: class Main
Main.java:19: error: cannot find symbol
        System.out.print((counter==2 ? YES : NO));
                                       ^
  symbol:   variable YES
  location: class Main
Main.java:19: error: cannot find symbol
        System.out.print((counter==2 ? YES : NO));
                                             ^
  symbol:   variable NO
  location: class Main
6 errors
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: 's' was not declared in this scope
    6 |   cin >> n, s = 0;
      |             ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vectot<int> v(n);
  bool a = 0;
  for(int i = 0; i < n; i++)
    cin >> v.at(i);
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      swap(v.at(i), v.at(j));
      if(v == sort(v.begin(), v.end())){
        a = 1;
        break;
      }
    }
  if(a)
    break;
  }
  if(a)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vectot' was not declared in this scope
    7 |   vectot<int> v(n);
      |   ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vectot<int> v(n);
      |          ^~~
a.cc:10:12: error: 'v' was not declared in this scope
   10 |     cin >> v.at(i);
      |            ^
a.cc:13:12: error: 'v' was not declared in this scope
   13 |       swap(v.at(i), v.at(j));
      |            ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vectot<int> v(n);
  bool a = 0;
  for(int i = 0; i < n; i++)
    cin >> v.at(i);
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      swap(v.at(i), v.at(j));
      if(v == sort(v.begin(), v.end())){
        a = 1;
        break;
      }
    }
  if(a == 1)
    break;
  }
  if(a == 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vectot' was not declared in this scope
    7 |   vectot<int> v(n);
      |   ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vectot<int> v(n);
      |          ^~~
a.cc:10:12: error: 'v' was not declared in this scope
   10 |     cin >> v.at(i);
      |            ^
a.cc:13:12: error: 'v' was not declared in this scope
   13 |       swap(v.at(i), v.at(j));
      |            ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:4: error: no match for call to '(std::vector<int>) (int&)'
   13 |   q(n) = p(n);
      |   ~^~~
a.cc:13:11: error: no match for call to '(std::vector<int>) (int&)'
   13 |   q(n) = p(n);
      |          ~^~~
Language: Java

import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc135/tasks/abc135_b
 */
public class ABC135B {

  private static boolean answer(long[] ps) {
    long prev = ps[0];
    int first = -1;
    int second = -1;
    for (int i = 1; i < ps.length; i++) {
      if (prev > ps[i]) {
        prev = ps[i];
        if (first == -1) {
          first = i - 1;
          continue;
        }

        if (second == -1) {
          second = i;
          continue;
        }

        return false;
      }

      prev = ps[i];
    }

    if (first == -1) {
      return true;
    }

    long first_prev = 0;
    if (first - 1 >= 0) {
      first_prev = ps[first - 1];
    }
    long first_next = 51;
    if (first + 1 < ps.length) {
      first_next = ps[first + 1];
    }
    boolean first_ok = first_prev < ps[second] && ps[second] < first_next;

    long second_prev = ps[second - 1];
    long second_next = 51;
    if (second + 1 < ps.length) {
      second_next = ps[second + 1];
    }
    boolean second_ok = second_prev < ps[first] && ps[first] < second_next;
    return first_ok && second_ok;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long[] ps = new long[n];
    for (int i = 0; i < n; i++) {
      ps[i] = scan.nextInt();
    }

    if (answer(ps)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


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

from sys import stdin 

n = int(input())
p = [int(x) for x in stdin.readline().rstrip().split()]
c= 0
q = sorted(p)
print(q)
print(p)
for i in range(n):
	if p[i] != q[i]:
		c += 1

if c<=2:
	print("YES")

else:
	print("NO")

Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from sys import stdin
      | ^~~~
Language: C++

    from sys import stdin 
     
    n = int(input())
    p = [int(x) for x in stdin.readline().rstrip().split()]
    c= 0
    q = sorted(p)
    print(q)
    print(p)
    for i in range(n):
    	if p[i] != q[i]:
    		c += 1
     
    if c<=2:
    	print("YES")
     
    else:
    	print("NO")

Compiler output:
a.cc:1:5: error: 'from' does not name a type
    1 |     from sys import stdin
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin>>n;
    ll arr[n+1];
     // ll ars[n+1];
    for(ll i= 0;i<n;i++){
        cin>>arr[i];
    }

if(is_sorted(arr,arr+n)){
    cout<<"YES"<<"\n";
    return 0;
}
else{
    ll cnt = 0;
    for(ll i = 0;i<n;i++){
        if(arr[i] != j){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
    if(cnt == 2 || cnt == 0){
        cout<<"YES"<<"\n";
        return 0;
    }
    else{
        cout<<"NO"<<"\n";
    }

}
}

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

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

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



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

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

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: expected primary-expression before ',' token
    8 |     if(p !=i),k++;
      |              ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 102
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;
int a[N];
signed main(){
  
  int n , cnt = 0 , t = 0;
  cin >> n;
  for(int i = 1 ; i <= n ; i++){
    cin >> a[i];
    if(a[i] == i)
      cnt++;
    else 
      t++;
  }
  if(cnt == n){
    cout << "YES\n";
    return 0;
  }
  else if (t  > 2){
    cout << "NO\n";
    return 0;
  }

  for(int i = 1 ; i<=n ; i++){
    if(a[i] != i){
         x = a[i];
         if(a[x] == i){
          cout << "YES\n";
          return 0;
         }
    }
  }

  cout << "NO\n";

}	

Compiler output:
a.cc: In function 'int main()':
a.cc:52:10: error: 'x' was not declared in this scope
   52 |          x = a[i];
      |          ^
Language: C++

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int>vec(n);
  
  int cnt=0;
  for(int i=0;i<n;i++){
    cin >> vec[i] ;
    if((i+1)!=vec[i]){
      cnt++;
    }
  }
  if(cnt<=2){
    cout << "YES" ;
  }else{
    cout << "NO" ;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin >> n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int>vec(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int>vec(n);
      |          ^~~
a.cc:10:12: error: 'vec' was not declared in this scope
   10 |     cin >> vec[i] ;
      |            ^~~
a.cc:16:5: error: 'cout' was not declared in this scope
   16 |     cout << "YES" ;
      |     ^~~~
a.cc:16:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout << "NO" ;
      |     ^~~~
a.cc:18:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int>vec(n);
  
  int cnt+
  for(int i=0;i<n;i++){
    cin >> vec[i] ;
    if(i!=vec[i]){
      cnt++;
    }
  }
  if(cnt==2){
    cout << "YES" ;
  }eles{
    cout << "NO" ;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: expected initializer before '+' token
    9 |   int cnt+
      |          ^
a.cc:10:15: error: 'i' was not declared in this scope
   10 |   for(int i=0;i<n;i++){
      |               ^
a.cc:16:6: error: 'cnt' was not declared in this scope; did you mean 'int'?
   16 |   if(cnt==2){
      |      ^~~
      |      int
a.cc:18:4: error: 'eles' was not declared in this scope
   18 |   }eles{
      |    ^~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,cnt=0;
  int a[53];
  int x[53],y[53];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    x[i]=a[i];
  }
sort(a,a+n);
for(int i=0;i<n;i++){
y[i]=a[i];
if(x[i]==y[i]){
  int cnt++;
}
  }
  if(cnt<=2) cout<<"YES";
  else cout<<"NO";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:10: error: expected initializer before '++' token
   17 |   int cnt++;
      |          ^~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: expected ';' before '}' token
   15 |     s[i-1]=i
      |             ^
      |             ;
   16 |   }
      |   ~
Language: C

#include <stdio.h>

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

  scanf("%d",&N);

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

  m = 0;
  for (i=1;i<N;i++){
    if (p[i] != i){
      m++;
    }
  }
  
  if ((m==0) || (m<2)){
    printf("YES");
  }

  else {
    printf("NO");
  }
  return 0; 
  
}


Compiler output:
main.c: In function 'main':
main.c:12:19: error: 'k' undeclared (first use in this function)
   12 |     scanf("%d",&p[k]);
      |                   ^
main.c:12:19: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

int main(void)
{
  int i,j,N,k;
  int p[50]={};
  int m;

  scanf("%d",&N);

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

  m = 0;
  for (i=1;i<N;i++){
    if (p[i] != k){
      m++
    }
  }
  
  if ((m==0) || (m<2)){
    printf("YES");
  }

  else {
    printf("NO");
  }
  return 0; 
  
}


Compiler output:
main.c: In function 'main':
main.c:18:10: error: expected ';' before '}' token
   18 |       m++
      |          ^
      |          ;
   19 |     }
      |     ~
Language: C

#include <stdio.h>

int main(void)
{
  int i,j,N,k;
  int p[50]={};

  scanf("%d",&N);

  for (i=0;i<N;i++){
    scanf("%d",p[k]);
  }

  for (i=1;i<N;i++){
    if (p[i] != k){
      m++;
      if (m <= 3){
        printf("NO");
        return 0;
      }
    }
  }

  printf("YES");

  return 0; 
  
}


Compiler output:
main.c: In function 'main':
main.c:16:7: error: 'm' undeclared (first use in this function)
   16 |       m++;
      |       ^
main.c:16:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:5:12: error: expected statement before ']' token
    5 |   int x[n];]
      |            ^
Language: C++

#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int N;; cin >> N;
    vector<int> p, pc;
    for(int i = 0; i < N; i++) 
    {
        int pi; cin >> pi;
        p.push_back(pi);
        pc.push_back(pi);
    }
    sort(pc.begin(), pc.end());
    int diff = 0;
    for (int j = 0; j < N; j++)
    {
        if (p.at(j) != pc.at(j)) { diff++; }
    }
    cout << (diff==0||diff==2?"YES":"NO") << endl
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:50: error: expected ';' before 'return'
   39 |     cout << (diff==0||diff==2?"YES":"NO") << endl
      |                                                  ^
      |                                                  ;
   40 |         return 0;
      |         ~~~~~~
Language: C

#include <stdio.h>

int main(){
  int N,count = 0,i,j;
  int P[N];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",P[i]);
  }
  for(j=0;j<N;j++){
    if(P[j]==j+1){
      count = count +1
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:12:23: error: expected ';' before '}' token
   12 |       count = count +1
      |                       ^
      |                       ;
   13 |     }
      |     ~
Language: C

#include <stdio.h>

int main(){
  int N,count = 0,i,j;
  int P[];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",P[i]);
  }
  for(j=0;j<N;j++){
    if(P[j]==j+1){
      count = count +1
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:5:7: error: array size missing in 'P'
    5 |   int P[];
      |       ^
main.c:12:23: error: expected ';' before '}' token
   12 |       count = count +1
      |                       ^
      |                       ;
   13 |     }
      |     ~
Language: C

#include <stdio.h>

int main(){
  int N,count = 0,i,j;
  int P[N];
  scanf("%d",N);
  for(i=0;i<N;i++){
    scanf("%d",P[i]);
  }
  for(j=0;j<N;j++){
    if(P[j]==j+1){
      count = count +1
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:12:23: error: expected ';' before '}' token
   12 |       count = count +1
      |                       ^
      |                       ;
   13 |     }
      |     ~
Language: C

#include <stdio.h>

int main(){
  int N,count = 0,i,j;
  int P[]=N;
  scanf("%d",N);
  for(i=0;i<N;i++){
    scanf("%d",P[i]);
  }
  for(j=0;j<N;j++){
    if(P[j]==j+1){
      count = count +1
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:5:11: error: invalid initializer
    5 |   int P[]=N;
      |           ^
main.c:12:23: error: expected ';' before '}' token
   12 |       count = count +1
      |                       ^
      |                       ;
   13 |     }
      |     ~
Language: C

#include <stdio.h>

int main(){
  int N,count = 0,i,j;
  int P[];
  scanf("%d",N);
  for(i=0;i<N;i++){
    scanf("%d",P[i]);
  }
  for(j=0;j<N;j++){
    if(P[j]==j+1){
      count = count +1
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:5:7: error: array size missing in 'P'
    5 |   int P[];
      |       ^
main.c:12:23: error: expected ';' before '}' token
   12 |       count = count +1
      |                       ^
      |                       ;
   13 |     }
      |     ~
Language: C

#include <stdio.h>

int main(){
  int N,count = 0,i,j;
  int p[];
  scanf("%d",N);
  for(i=0;i<N;i++){
    scanf("%d",p[i]);
  }
  for(j=0;j<N;j++){
    if(p[j]==j+1){
      count = count +1
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:5:7: error: array size missing in 'p'
    5 |   int p[];
      |       ^
main.c:12:23: error: expected ';' before '}' token
   12 |       count = count +1
      |                       ^
      |                       ;
   13 |     }
      |     ~
Language: C

#include <stdio.h>

int main(){
  int N,count = 0,i,j;
  int p[];
  scanf("%d",N);
  for(i=0;i<N;i++){
    scanf("%d",p[i]);
  }
  for(j=1;j<N+1;j++){
    if(p[j]==j){
      count = count +1
    }
  }
  if(count > 2){
	printf("NO");
  }else{
    printf("YES");
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:5:7: error: array size missing in 'p'
    5 |   int p[];
      |       ^
main.c:12:23: error: expected ';' before '}' token
   12 |       count = count +1
      |                       ^
      |                       ;
   13 |     }
      |     ~
Language: C

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

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

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

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

#include<stdio.h>

int main(void)
{
   int n, i, p[50], g;
  
   scanf("%d", &n);
   
   for(i=0; i<n; i++){
    scanf("%d", &a[i]);
   }
  
   for(i=0; i<n; i++){
    if(a[i]==i+1) g++;
   }
  
   if(g<=2) printf("YES\n");
   else     printf("NO\n");
  
   return 0;
}


Compiler output:
main.c: In function 'main':
main.c:10:18: error: 'a' undeclared (first use in this function)
   10 |     scanf("%d", &a[i]);
      |                  ^
main.c:10:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int N;
  cin >> N;
  
  int p[N];
  int m = 0;
  int l;
  for(int i = 0; i < N; i++){
    cin >> l;
    if (l !=i){
      m++;
    }
    if(m > 2){
      break;
    }
  }
  if (m > 2 || m == 1){
   cout << "NO" << endl;
  } else {
   cout << "YES" << endl; 
  }
  
  if(abs(A-B) % 2 == 0){
    cout << abs((A+B)/2) << endl;
  } else {
   	cout << "IMPOSSIBLE" << endl;
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:10: error: 'A' was not declared in this scope
   29 |   if(abs(A-B) % 2 == 0){
      |          ^
a.cc:29:12: error: 'B' was not declared in this scope
   29 |   if(abs(A-B) % 2 == 0){
      |            ^
Language: C

#include<stdio.h>

int main(void)
{
   int n, i, a[50], p[50], g;
  
   printf("%d", &n);
   
   for(i=0; i<n; i++){
	a[i]=i+1;
    scanf("%d", &a[i]);
   }
  
   for(i=0; i<n; i++){
    if(a[i]==p[i]) g++;
   }
  
   if(g=>2) printf("YES\n");
   else     printf("NO\n");
  
   return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:9: error: expected expression before '>' token
   18 |    if(g=>2) printf("YES\n");
      |         ^