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

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

Compiler output:
Main.java:8: error: illegal start of expression
    for(int i = 0;i<,n;i++){
                    ^
Main.java:8: error: not a statement
    for(int i = 0;i<,n;i++){
                     ^
Main.java:8: error: ')' expected
    for(int i = 0;i<,n;i++){
                      ^
Main.java:8: error: ';' expected
    for(int i = 0;i<,n;i++){
                          ^
4 errors
Language: Java

import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] input = new int[n];
    int difference = 0;
    for(int i = 0;i<,n;i++){
      input[i] = sc.nextInt();
      if(input[i] != i + 1){
        difference++;
      }
    }
    if(difference == 0 || difference == 2){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Compiler output:
Main.java:8: error: illegal start of expression
    for(int i = 0;i<,n;i++){
                    ^
Main.java:8: error: not a statement
    for(int i = 0;i<,n;i++){
                     ^
Main.java:8: error: ')' expected
    for(int i = 0;i<,n;i++){
                      ^
Main.java:8: error: ';' expected
    for(int i = 0;i<,n;i++){
                          ^
4 errors
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: warning: range-based 'for' loops with initializer only available with '-std=c++20' or '-std=gnu++20' [-Wc++20-extensions]
   14 |     for(i=1;i<=n:++i)
      |             ^
a.cc:14:17: error: expected ';' before ':' token
   14 |     for(i=1;i<=n:++i)
      |                 ^
      |                 ;
a.cc:20:5: error: expected primary-expression before 'if'
   20 |     if(cnt<=2)
      |     ^~
a.cc:18:6: error: expected ';' before 'if'
   18 |     }
      |      ^
      |      ;
   19 | 
   20 |     if(cnt<=2)
      |     ~~
a.cc:20:5: error: expected primary-expression before 'if'
   20 |     if(cnt<=2)
      |     ^~
a.cc:18:6: error: expected ')' before 'if'
   18 |     }
      |      ^
      |      )
   19 | 
   20 |     if(cnt<=2)
      |     ~~
a.cc:14:8: note: to match this '('
   14 |     for(i=1;i<=n:++i)
      |        ^
Language: C++

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

int main()
{
   int n ;
   cin >> n ;
   int p[n] ;
   for(int i=0;i<n;i++)cin >> p[i] ;
   
   int ind1=-1
   int ind2 = -1;
   int ans = true;
  for(int i=0;i<n-1;i++){
    if(p[i+1]-p[i]<0){
      if(ind1<0){
       ind1 = i ;
      }else if(ind1>0){ 
       ind2 = i ;   
      }else if(ind1>0 && ind2>0){
        ans = false;
        break;
      }
    }
  }
  if(ans)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl; 
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:13:4: error: expected ',' or ';' before 'int'
   13 |    int ind2 = -1;
      |    ^~~
a.cc:20:8: error: 'ind2' was not declared in this scope; did you mean 'ind1'?
   20 |        ind2 = i ;
      |        ^~~~
      |        ind1
a.cc:21:26: error: 'ind2' was not declared in this scope; did you mean 'ind1'?
   21 |       }else if(ind1>0 && ind2>0){
      |                          ^~~~
      |                          ind1
Language: C++

#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int N ;
   cin >> N ;
   vector<int> A(N) ;
  
   for(int i=0;i<N;i++)cin >> A.at(i) ;

   int count =0 ;

  bool q = true ;
  while(q){
   for(int i=0;i<N;i++){    
      if(A.at(i)%2==0){
       A.at(i) /= 2 ;
        if(i==(A.size()-1))count++ ;
      }else{
       q = false ;
       break ;
      }
   }
  }
     cout << count << endl ;
     
    return 0;
}

#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int n ;
   cin >> n ;
   int p[n] ;
   for(int i=0;i<n;i++)cin >> p[i] ;
   
   int ind1=-1
   int ind2 = -1;
   int ans = true;
  for(int i=0;i<n-1;i++){
    if(p[i+1]-p[i]<0){
      if(ind1<0){
       ind1 = i ;
      }else if(ind1>0){ 
       ind2 = i ;   
      }else if(ind1>0 && ind2>0){
        ans = false;
        break;
      }
    }
  }
  if(ans)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl; 
    return 0;
}



Compiler output:
a.cc:34:5: error: redefinition of 'int main()'
   34 | int main()
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:42:4: error: expected ',' or ';' before 'int'
   42 |    int ind2 = -1;
      |    ^~~
a.cc:49:8: error: 'ind2' was not declared in this scope; did you mean 'ind1'?
   49 |        ind2 = i ;
      |        ^~~~
      |        ind1
a.cc:50:26: error: 'ind2' was not declared in this scope; did you mean 'ind1'?
   50 |       }else if(ind1>0 && ind2>0){
      |                          ^~~~
      |                          ind1
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;




bool isOK(ll key) {
	ll red, blue;
	if (r - key < 0 || b - key < 0) return false;
	red = (r - key) / (x - 1);
	blue = (b - key) / (y - 1);
	if (key <= red + blue) return true;
	else return false;
}

ll binary_search() {
	ll ng = (r + b) / 2 + 1;
	ll ok = 0;

	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;

		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int p[55], tmp[55], n, cnt;

int main() {

	cin >> n;
	rep(i, n) {
		cin >> p[i];
		tmp[i] = i + 1;
	}

	rep(i, n) {
		if (p[i] != tmp[i])cnt++;
	}

	if (cnt > 1)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Compiler output:
a.cc: In function 'bool isOK(ll)':
a.cc:41:13: error: 'r' was not declared in this scope
   41 |         if (r - key < 0 || b - key < 0) return false;
      |             ^
a.cc:41:28: error: 'b' was not declared in this scope
   41 |         if (r - key < 0 || b - key < 0) return false;
      |                            ^
a.cc:42:16: error: 'r' was not declared in this scope
   42 |         red = (r - key) / (x - 1);
      |                ^
a.cc:42:28: error: 'x' was not declared in this scope
   42 |         red = (r - key) / (x - 1);
      |                            ^
a.cc:43:17: error: 'b' was not declared in this scope
   43 |         blue = (b - key) / (y - 1);
      |                 ^
a.cc:43:29: error: 'y' was not declared in this scope; did you mean 'yn'?
   43 |         blue = (b - key) / (y - 1);
      |                             ^
      |                             yn
a.cc: In function 'll binary_search()':
a.cc:49:18: error: 'r' was not declared in this scope
   49 |         ll ng = (r + b) / 2 + 1;
      |                  ^
a.cc:49:22: error: 'b' was not declared in this scope
   49 |         ll ng = (r + b) / 2 + 1;
      |                      ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:8:16: error: 'i' was not declared in this scope
    8 | rep(i,n)cin>>a[i];
      |                ^
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:6:30: error: subscripted value is neither array nor pointer nor vector
    6 |                 scanf("%d",&a[i]);
      |                              ^
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:6:29: error: subscripted value is neither array nor pointer nor vector
    6 |                 scanf("%d",a[i]);
      |                             ^
Language: C

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

Compiler output:
main.c: In function 'main':
main.c:3:27: error: expected identifier or '(' before ';' token
    3 |         int a,b[55],i,c=0,;
      |                           ^
Language: C

#include <stdio.h>
int main(void){
	int a,b[55],i,c=0,d=0,fi,fii;
	scanf("%d%s",&a,b);
	for(i=0;i<n;i++){
		if(b[i]!=a-i){
			if(c==0){
				fi=b[i];
				fii=i;
				c=1;
				d++;
			}else if(c==1){
				if((b[i]==a-fii)&&(fi==a-i)) c=0;
				d++;
			}
		}
	}
	printf(c==0&&(d==0||d==2)?"Yes":"No");
	return 0;
}

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

#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

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

  int count = 0;
  for (int i = 1; i <= N; ++i)
  {
    int p;
    cin >> p;

    if (i != p) ++count;
    if (count > 2)
    {
      cout << "No" << endl;
      return　0;
    }
  }
  cout << "Yes" << endl;
}


Compiler output:
a.cc:23:7: error: extended character 　 is not valid in an identifier
   23 |       return　0;
      |       ^
a.cc: In function 'int main()':
a.cc:23:7: error: 'return\U000030000' was not declared in this scope
   23 |       return　0;
      |       ^~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

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

  int count = 0;
  for (int i = 1; i <= N; ++i)
  {
    int p;
    cin >> p;

    if (i != p) ++count;
    if (count > 2)
    {
      cout << "No" << endl;
      return　0;
    }
  }
  cout << "Yes" << endl;
}

Compiler output:
a.cc:23:7: error: extended character 　 is not valid in an identifier
   23 |       return　0;
      |       ^
a.cc: In function 'int main()':
a.cc:23:7: error: 'return\U000030000' was not declared in this scope
   23 |       return　0;
      |       ^~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define mod 1000000007
using namespace std;


int main(void){
    ll n; cin>>n;
    vl p(n);
    for(int i=0;i<n;++i) cin>>p[i];
    bool flag = true;
    for(int i=0;i<n-1;++i) if(p[k]>p[k+1]) flag = false;
    if(flag){
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            ll t = p[i];
            p[i] = p[j];
            p[j] = t;
            bool flag = true;
            for(int k=0;k<n-1;++k){
                if(p[k] > p[k+1]){
                    flag = false;
                    break;
                }
            }if(flag){
                cout<<"YES"<<endl;
                return 0;
            }
            t = p[i];
            p[i] = p[j];
            p[j] = t;
        }
    }
    cout<<"NO"<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:33: error: 'k' was not declared in this scope
   21 |     for(int i=0;i<n-1;++i) if(p[k]>p[k+1]) flag = false;
      |                                 ^
Language: C++

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

typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n), a(n);
    rep(i, n){
         cin >> p.at(i);
         a.at(i) = p.at(i);
    }

    sort(a.begin(), a.end());

    int cnt = 0;
    rep(i, n)
    {
        if(a.at(i) != p.at(i)) cnt++;
    }

    if(cnt == 0 or cnt == 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    
    return 0;
}

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

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    int n,ans;
    vector<int> p(n), q(n);
    ans =0;
    rep(i,n)cin >> p[i];
    q = p;
    sort(p.begin, p.end);
    rep(i,n){
        if(p[i] == q[i])++ans;
    }
    if(ans>1)cout<<"NO" <<<endl;
    else cout<<"YES" << endl;
    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: no matching function for call to 'sort(<unresolved overloaded function type>, <unresolved overloaded function type>)'
   13 |     sort(p.begin, p.end);
      |     ~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   template argument deduction/substitution failed:
a.cc:13:9: note:   couldn't deduce template parameter '_RAIter'
   13 |     sort(p.begin, p.end);
      |     ~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
a.cc:17:27: error: expected primary-expression before '<' token
   17 |     if(ans>1)cout<<"NO" <<<endl;
      |                           ^
Language: C++

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin>>N;
  vector<int> p1(N);
  vector<int> p2(N);
  rep(i,N){
    cin>>p1.at(i);
    p2.at(i)=p1.at(i);
  }
  sort(p2.begin(),p2.end());
  int num;
  rep(i,N){
    (p1.at(i)==p2.at(i))?continue:num++;
  }
  (num<=2)?cout<<"YES"<<endl;:cout<<"NO"<<endl; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:26: error: expected primary-expression before 'continue'
   18 |     (p1.at(i)==p2.at(i))?continue:num++;
      |                          ^~~~~~~~
a.cc:18:26: error: expected ':' before 'continue'
   18 |     (p1.at(i)==p2.at(i))?continue:num++;
      |                          ^~~~~~~~
      |                          :
a.cc:18:26: error: expected primary-expression before 'continue'
   18 |     (p1.at(i)==p2.at(i))?continue:num++;
      |                          ^~~~~~~~
a.cc:20:29: error: expected ':' before ';' token
   20 |   (num<=2)?cout<<"YES"<<endl;:cout<<"NO"<<endl;
      |                             ^
      |                             :
a.cc:20:29: error: expected primary-expression before ';' token
a.cc:20:30: error: expected primary-expression before ':' token
   20 |   (num<=2)?cout<<"YES"<<endl;:cout<<"NO"<<endl;
      |                              ^
Language: C++

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

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

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

//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	ll n; cin>>n;
	vector<ll>v(n);
	vector<ll>d(n);
	vector<ll>t(n);
	for(ll i=0;i<n;i++)cin>>v[i];
	d=v;
	t=v;
	sort(d.begin(),d.end());
	if(v==d){if(ok){cout<<"YES"<<endl; return 0;}
	bool ok=false;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			swap(v[i],v[j]);
			if(v==d){ok=true; break;}
			}
		if(ok)break;
		else v=t;
		}
	if(ok){cout<<"YES"<<endl;}
	else cout<<"NO"<<endl;











return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:31:21: error: 'ok' was not declared in this scope
   31 |         if(v==d){if(ok){cout<<"YES"<<endl; return 0;}
      |                     ^~
a.cc:54:11: error: expected '}' at end of input
   54 | return 0;}
      |           ^
a.cc:22:11: note: to match this '{'
   22 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,s=0;
	int a[10000001];
	cin>>x;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]!=i+1)
		s++;
	}
	if(s>2||s%2!=0) cout<<"No";
	else cout<<"Yes";
	return 0;
}


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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:22:4: error: expected '}' at end of input
   22 |   }
      |    ^
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> p;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  int count = 0;
  for(int i=0;i<N-1;i++){
    if(p.at(i+1)!=p.at(i)+1){
      count++;
    }
  }
  if(count==N-1){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
    return 0;
  }

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

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

int n,a;

int main(){
  cin>>n;
  vector<int>v1(n,0);
  vector<int>v2(n,0);
  for (int i=0; i<n; i++){
    cin>>v1[i];
    v2[i]=i+1;
  }
  for (int i=0; i<n; i++){
    if (v1[i]!=v2[i]){
      a++;
    }
  }
  if (a<3){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}

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

n=int(input())
*p,=map(int,input().split())
wng=0
a=sorted(p)
for i in range(n):
    if a[i] != p[i]:
        wng += 1
print("No" if wng >2 else "Yes")
    

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

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


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

  int count = 0;
  rep(i, n){
    if(i+1 != p[i]) count ++;
  }
  if(count == 0 || count  2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


/*





















*/


Compiler output:
a.cc: In function 'int main()':
a.cc:61:25: error: expected ')' before numeric constant
   61 |   if(count == 0 || count  2) cout << "YES" << endl;
      |     ~                   ^ ~
      |                         )
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(void) {
    int n; cin >> n;
    vector<int> p(n+1);
    int cnt = 0;
    rep(i,n) {
        cin >> p[i+1];
        if(i+1 != p[i+1]) cnt++;
    }
    if(cnt<=2) cout <<"YES";
    else cout <<"NO";


Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: expected '}' at end of input
   14 |     else cout <<"NO";
      |                      ^
a.cc:5:16: note: to match this '{'
    5 | int main(void) {
      |                ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
  	int n, x;
  	vector<int> nums, sortNums;
  
  	cin >> n;	
  
  	for(int i=0; i<n; i++){
    	cin >> x;
      	nums.push_back(x);
    }
  
  	sortNums = sort(nums.begin(), nums.begin()+n);
  
  	for(int i=0; i<n-1; i++){
    	for(int j=i+1; j<n; j++){
        	if(sortNums[i]==nums[j]){
    			swap(nums[i],nums[j]);
            }
        }
    }
  
  	if(nums == sortNums) cout << "YES\n";
  	else cout << "NO\n";
  
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:53: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   16 |         sortNums = sort(nums.begin(), nums.begin()+n);
      |                                                     ^
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 <iostream>
#include <vector>

int main(){
  int n;
  std::cin >> n;
  std::vector<int> p;
  int temp;
  while(std::cin >> temp)
    p.push_back(temp);
  int cnt = 0;
  for(auto i = p.begin()+1; i != p.end(); ++i)
    if(*i != *(i-1))
      ++cnt;
  std::cout << (cnt>2)? "NO" : "YES" << std::endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:38: error: invalid operands of types 'const char [4]' and '<unresolved overloaded function type>' to binary 'operator<<'
   15 |   std::cout << (cnt>2)? "NO" : "YES" << std::endl;
      |                                ~~~~~~^~~~~~~~~~~~
Language: C++

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

#define ll long long int

int main(){
	int n;  cin >> n;
    vector<int> p(n),srtd;
    for(auto &it:p)
        cin >> it;
    srtd = p;
    sort(srtd.begin(),strd.end());

    int diff=0;
    for(int i=0;i<n;i++)
        diff += (srtd[i] != p[i]);
    
    if(diff == 0 || diff==2)
        cout << "YES\n";
    else 
        cout << "NO\n";

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:23: error: 'strd' was not declared in this scope; did you mean 'srtd'?
   12 |     sort(srtd.begin(),strd.end());
      |                       ^~~~
      |                       srtd
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];
    int downcounter = 0;
    boolean ans = true;
    for(int i = 0;i < n;i++){
      p[i] = sc.nextInt();
    }
    for(int j = 0;j < n - 1;j++){
      if(p[i] > p[i + 1]){
        downCounter++;
        if(downCounter == 2){
          ans == false;
          break;
        }
      }
    }
    if(ans){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Compiler output:
Main.java:17: error: not a statement
          ans == false;
              ^
1 error
Language: C++

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
    int n,s=0;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a.at(i);
    }

    for(int i=0; i<n-1; ++i){
        if(a.at(i)> a.at(i+1)){
            s++;
            swap(a.at(i),a.at(i+1));
        }
       if(s==2){break;}
    }
    if(s==2){cout << “NO” << endl;}
    else{cout << “YES” << endl;}

}

Compiler output:
a.cc:33:22: error: extended character “ is not valid in an identifier
   33 |     if(s==2){cout << “NO” << endl;}
      |                      ^
a.cc:33:22: error: extended character ” is not valid in an identifier
a.cc:34:18: error: extended character “ is not valid in an identifier
   34 |     else{cout << “YES” << endl;}
      |                  ^
a.cc:34:18: error: extended character ” is not valid in an identifier
a.cc: In function 'int main()':
a.cc:33:22: error: '\U0000201cNO\U0000201d' was not declared in this scope
   33 |     if(s==2){cout << “NO” << endl;}
      |                      ^~~~
a.cc:34:18: error: '\U0000201cYES\U0000201d' was not declared in this scope
   34 |     else{cout << “YES” << endl;}
      |                  ^~~~~
Language: C++

#include <iostream>
#include <string.h>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int p[n];
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] != i) count++;
	}
	if (count == 0 || count == 2) {
		cout << "YES\n";
	} else {
		count << "NO\n";
	}
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:23: error: invalid operands of types 'int' and 'const char [4]' to binary 'operator<<'
   17 |                 count << "NO\n";
      |                 ~~~~~ ^~ ~~~~~~
      |                 |        |
      |                 int      const char [4]
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

bool sorted(int n, int* p) {
    int old = INT_MIN;
    for (int i=0; i<n; i++) {
        if (old > *(p+i)) {
            return false;
        }
        old = *(p+i);
    }
    return true;
}

int ill(int n, int* p) {
    int old = INT_MIN;
    for (int i=0; i<n; i++) {
        if (old > *(p+i)) {
            return i-1;
        }
        old = *(p+i);
    }
    return -1;
}

int printarr(int n, int* p) {
    for (int i=0; i<n; i++) {
        cerr << *(p+i) << " ";
    }
    cerr << endl;
}

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

    if (sorted(n, p)) {
        cout << "YES";
        return 0;
    }

    int ip = ill(n, p);
    cerr << ip << endl;

    for (int i=0; i<n; i++) {
        if (i == ip) continue;
        int tmp = p[i];
        p[i] = p[ip];
        p[ip] = tmp;
        printarr(n, p);
        if (sorted(n, p)) {
            cout << "YES";
            return 0;
        }
        p[ip] = p[i];
        p[i] = tmp;
    }

    cout << "NO";
    return 0;
}

Compiler output:
a.cc: In function 'bool sorted(int, int*)':
a.cc:8:15: error: 'INT_MIN' was not declared in this scope
    8 |     int old = INT_MIN;
      |               ^~~~~~~
a.cc:4:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <cmath>
  +++ |+#include <climits>
    4 | 
a.cc: In function 'int ill(int, int*)':
a.cc:19:15: error: 'INT_MIN' was not declared in this scope
   19 |     int old = INT_MIN;
      |               ^~~~~~~
a.cc:19:15: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In function 'int printarr(int, int*)':
a.cc:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
   34 | }
      | ^
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
    int n,ans=0;
    scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  for(int i=0;i<n;i++){
    if(s[i]!=i+1){
      ans += 1;
    }
  }
  if(ans == 0 || ans == 2){
    printf("YES");
    return 0;
  }
  else
    printf("NO");
  return 0;
}

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

#include<iostream>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	int arr[n];
  	for (int i = 0; i < n; i++)
      cin >> arr[i];
  	int k = 0;
  	for (int i = 0; i < n; i++){
    	(arr[i] == i+1)	k = k : k += 1;
    }
	(k > 2)? cout << "NO"<< '\n' : cout << "YES\n";
  
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: expected ';' before 'k'
   11 |         (arr[i] == i+1) k = k : k += 1;
      |                        ^~
      |                        ;
Language: C++

#include<iostream>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	int arr[n];
  	for (int i = 0; i < n; i++)
      cin >> arr[i];
  	int k = 0;
  	for (int i = 0; i < n; i++){
    	(arr[i] == i+1)	k = k : k += 1;
    }
	(k > 2) cout << "NO"<< '\n' : cout << "YES\n";
  
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: expected ';' before 'k'
   11 |         (arr[i] == i+1) k = k : k += 1;
      |                        ^~
      |                        ;
a.cc:13:16: error: expected ';' before 'cout'
   13 |         (k > 2) cout << "NO"<< '\n' : cout << "YES\n";
      |                ^~~~~
      |                ;
Language: C++

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

int main(){
  int n; cin >> n;
  int tmp = 0, tmp2 = 0;
  for(int i = 1; i < n + 1; i++){
    int a; cin >> a;
    if(tmp == 0){
      if(a != i){
        if(tmp2 = 1){
          cout << "NO";
          return 0;
        }else{
          tmp = a;
        }
      }
    }else{
      if(a != i){
        if(a != tmp){
          cout << "NO";
          return 0;
        }else{
          tmp2 = 1;
        }
      }
    }
  }
  cout << "YES";
}


Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namespce'
    2 | using namespce std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   int n; cin >> n;
      |          ^~~
      |          std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:11: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   12 |           cout << "NO";
      |           ^~~~
      |           std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:21:11: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |           cout << "NO";
      |           ^~~~
      |           std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:29:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |   cout << "YES";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

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

int main(){
  int n; cin >> n;
  int tmp = 0, tmp2 = 0;
  for(int i = 1; i < n + 1; i++){
    int a; cin >> a;
    if(tmp == 0){
      if(a != i{
        if(tmp2 = 1){
          cout << "NO";
          return 0;
        }else{
          tmp = a;
        }
    }else{
      if(a != i){
        if(a != tmp){
          cout << "NO";
          return 0;
        }else{
          tmp2 = 1;
        }
      }
    }
  }
  cout << "YES";
}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namespce'
    2 | using namespce std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   int n; cin >> n;
      |          ^~~
      |          std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:10:16: error: expected ')' before '{' token
   10 |       if(a != i{
      |         ~      ^
      |                )
a.cc:27:3: error: expected primary-expression before '}' token
   27 |   }
      |   ^
a.cc:28:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   28 |   cout << "YES";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int p[N];
  int i;
  for(i=0;i<N;i++){
   cin >> p[i];
    p[i]--;
  }
  
  int num=0;
  for(i=0;i<N;i++){
    if(p[i]!=i) num++;
  }
  
  if(num == 0){
   cout << YES << endl; 
  }
  if(num == 2){
   cout << YES << endl; 
  }
  if(num != 0 && num != 2){
   cout << NO << endl; 
  }
  
return 0;
} 






Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: 'YES' was not declared in this scope
   21 |    cout << YES << endl;
      |            ^~~
a.cc:24:12: error: 'YES' was not declared in this scope
   24 |    cout << YES << endl;
      |            ^~~
a.cc:27:12: error: 'NO' was not declared in this scope; did you mean 'N'?
   27 |    cout << NO << endl;
      |            ^~
      |            N
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[] Ni = new int[N];
   for(int i = 0; i<S.length();i++)
   {
		Ni[i] = sc.nextInt();       
   }
   int count =0;
   for(int i = 0; i<S.length();i++)
   {
		if(Ni[i]-1 != i) count++;
   }
   if(count <=2)System.out.println("YES");
   else System.out.println("NO");
 }
}

Compiler output:
Main.java:7: error: cannot find symbol
   for(int i = 0; i<S.length();i++)
                    ^
  symbol:   variable S
  location: class Main
Main.java:12: error: cannot find symbol
   for(int i = 0; i<S.length();i++)
                    ^
  symbol:   variable S
  location: class Main
2 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
const double pi=2*acos(0.0);
double inff=1.0/0.0;
#define ll           long long int
#define inf          1000000000000000008
#define MOD          1000000007
#define pb           push_back
#define sz(x)        (int)x.size()
#define mp           make_pair
#define lbd          lower_bound
#define ubd          upper_bound
#define ipair        pair<ll,ll> 
#define all(v)       v.begin(),v.end()
#define watch(x)     cout<<(#x)<<" is "<<(x)<<endl;
#define rep(a,b,c)   for(a=(int)b;a<(int)c;a++)
#define rep2(a,b,c)  for(a=(int)b;a<(int)c;a+=2)  
#define bac(a,b,c)   for(a=(int)b;a>=(int)c;a--)
#define se           second
#define f            first
#define ios          ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
#define mem(a,val)   memset(a,val,sizeof a)
#define endl         "\n"
#define mxn          200001
#define vi           vector<ll>
#define vii          vector<ipair> 
#define si           set<ll> 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*Variables Start*/
ll x,y,n,i,z,j,k,w,u,q,m,t;
vi v;
/*Variables End*/
void solve()
{
 	cin>>n;
  	v.resize(n+1);
 	rep(i,1,n+1)
 	{
 		cin>>v[i];
 		if(v[i]!=i) x++;
 	}
 	if(x<=2)
 	{
 		cout<<"YES"<<endl;
 	}
 	else cout<<"NO"<<endl
}
int main() 
{ 
  int TESTS=1;
  ios;  
  while(TESTS--)
  {
    solve();
  }  
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:47:1: error: expected ';' before '}' token
   47 | }
      | ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: 'k' was not declared in this scope
   12 |                         k++;
      |                         ^
a.cc:15:12: error: 'k' was not declared in this scope
   15 |         if(k == n - 2){
      |            ^
Language: Java

\import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = Integer.parseInt(stdin.next());
		int Nlist[] = new int[N];
		int list[] = new int[N];
		int p[] = new int[N];
		int cnt = 0;

		for(int i=0;i<N;i++) {
			p[i] = Integer.parseInt(stdin.next());
			list[i] = i+1;
		}
		
		for(int i=0;i<N;i++) {
			if(list[i] != p[i]) {
				cnt += 1;
			}
		}
		
		if(cnt > 2) {
			out.print("NO");
		}
		else {
			out.print("YES");
		}

		out.flush();
	}

}


Compiler output:
Main.java:1: error: illegal character: '\'
\import java.io.PrintWriter;
^
Main.java:1: error: class, interface, enum, or record expected
\import java.io.PrintWriter;
        ^
Main.java:2: error: class, interface, enum, or record expected
import java.util.Scanner;
^
3 errors
Language: C++

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

int main() {
    int N;
    cin >> N;
    vector<int> V(N),W(N);
    for (int i=0 ; i<N ; i++)
        cin >> V.at(i);
    W=V;
    sort(W.begin(), W.end());
    int A=0:;
    for (int i=0 ; i<N ; i++){
        if (V.at(i)==W.at(i))
        A++;
    }
    if (A==N||A==N-2)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: expected ',' or ';' before ':' token
   12 |     int A=0:;
      |            ^
Language: C++

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

int main() {
    int N;
    cin >> N;
    vector<int> V(N),W(N);
    for (int i=0 ; i<N ; i++)
        cin >> V.at(i);
    W=sort(V.begin(),V.end());
    int A=0:;
    for (int i=0 ; i<N ; i++){
        if (V.at(i)==W.at(i))
        A++;
    }
    if (A==N||A==N-2)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:29: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   10 |     W=sort(V.begin(),V.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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:11:12: error: expected ',' or ';' before ':' token
   11 |     int A=0:;
      |            ^