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

main = do
  [a,b] <- map (read :: String -> Int) . words <$> getLine
  if odd (a-b) then print ((a+b) `div` 2) else putStrLn "IMPOSSIBLE"

Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | main = do
      | ^~~~
main.c:1:1: error: type defaults to 'int' in declaration of 'main' [-Wimplicit-int]
main.c:1:8: error: expected expression before 'do'
    1 | main = do
      |        ^~
main.c:3:34: error: stray '`' in program
    3 |   if odd (a-b) then print ((a+b) `div` 2) else putStrLn "IMPOSSIBLE"
      |                                  ^
main.c:3:38: error: stray '`' in program
    3 |   if odd (a-b) then print ((a+b) `div` 2) else putStrLn "IMPOSSIBLE"
      |                                      ^
Language: C++

#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;

const int maxn = 3010;
double mina[maxn], maxa[maxn];

double deg2rad(double deg) { return deg * pi * 180; }

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
  #endif

  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if ((a + b) & 1) cout << "IMPOSSIBLE\n"
  else cout << (a + b) / 2;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:42: error: expected ';' before 'else'
   19 |   if ((a + b) & 1) cout << "IMPOSSIBLE\n"
      |                                          ^
      |                                          ;
   20 |   else cout << (a + b) / 2;
      |   ~~~~
Language: C++

#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a%2==b%2
  cout<<(a+b)/2<<endl;
  else
     	cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: expected ';' before 'cout'
    7 |   if(a%2==b%2
      |              ^
      |              ;
    8 |   cout<<(a+b)/2<<endl;
      |   ~~~~        
a.cc:9:3: error: expected primary-expression before 'else'
    9 |   else
      |   ^~~~
a.cc:8:23: error: expected ')' before 'else'
    8 |   cout<<(a+b)/2<<endl;
      |                       ^
      |                       )
    9 |   else
      |   ~~~~                 
a.cc:7:5: note: to match this '('
    7 |   if(a%2==b%2
      |     ^
Language: C++

#include <bits/stdc++.h>

int main(){
  cin >> A >> B;
  
  c = A + B;
  
  if(c % 2 =0) cout << c / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |   cin >> A >> B;
      |   ^~~
      |   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:4:10: error: 'A' was not declared in this scope
    4 |   cin >> A >> B;
      |          ^
a.cc:4:15: error: 'B' was not declared in this scope
    4 |   cin >> A >> B;
      |               ^
a.cc:6:3: error: 'c' was not declared in this scope
    6 |   c = A + B;
      |   ^
a.cc:8:16: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    8 |   if(c % 2 =0) cout << c / 2 << endl;
      |                ^~~~
      |                std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:8:33: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    8 |   if(c % 2 =0) cout << c / 2 << endl;
      |                                 ^~~~
      |                                 std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:9:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    9 |   else cout << "IMPOSSIBLE" << endl;
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:9:32: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    9 |   else cout << "IMPOSSIBLE" << endl;
      |                                ^~~~
      |                                std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

int main() {
    ll a,b;
    cin>>a>>b;
    if(a+b%2==0){
        cout<<(a+b)/2<<endl;
    }else if{
        cout<<"IMPOSSIBLE"<<endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: expected '(' before '{' token
   11 |     }else if{
      |             ^
      |             (
Language: Java

#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;

const int maxn = 3010;
double mina[maxn], maxa[maxn];

double deg2rad(double deg) { return deg * pi * 180; }

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
  #endif

  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if ((a + b) & 1) cout << "IMPOSSIBLE\n"
  else cout << (a + b) / 2;
  return 0;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include<bits/stdc++.h>
        ^
Main.java:2: error: illegal character: '#'
#define pi acos(-1.0)
^
Main.java:5: error: class, interface, enum, or record expected
const int maxn = 3010;
^
Main.java:6: error: class, interface, enum, or record expected
double mina[maxn], maxa[maxn];
^
Main.java:8: error: unnamed classes are a preview feature and are disabled by default.
double deg2rad(double deg) { return deg * pi * 180; }
^
  (use --enable-preview to enable unnamed classes)
Main.java:11: error: illegal character: '#'
  #ifdef LOCAL
  ^
Main.java:14: error: illegal character: '#'
  #endif
  ^
Main.java:18: error: not a statement
  cin >> a >> b;
           ^
Main.java:19: error: not a statement
  if ((a + b) & 1) cout << "IMPOSSIBLE\n"
                        ^
Main.java:20: error: not a statement
  else cout << (a + b) / 2;
            ^
Main.java:11: error: ';' expected
  #ifdef LOCAL
              ^
Main.java:16: error: ';' expected
  ios::sync_with_stdio(false);
     ^
Main.java:19: error: ';' expected
  if ((a + b) & 1) cout << "IMPOSSIBLE\n"
                                         ^
14 errors
Language: C++

#include<bits/stdc++.h>

using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if((a+b)&1){
		puts("IMPOSSIBLE");continue;
	}
	cout<<(a+b)/2<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:36: error: continue statement not within a loop
    8 |                 puts("IMPOSSIBLE");continue;
      |                                    ^~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b;
  cout << ((a-b)%2==0 ? (a+b)/2 : "IMPOSSIBLE") << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:23: error: operands to '?:' have different types 'int' and 'const char*'
    6 |   cout << ((a-b)%2==0 ? (a+b)/2 : "IMPOSSIBLE") << endl;
      |            ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  LL a,b;
  cin >> a >> b;
  if((a - b) % 2 == 1){
    cout << "IMPOSSIBLE" << endl;
    return;
  }
  cout << (a-b)/2 << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   14 |     return;
      |     ^~~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using P = std::pair<ll, ll>;
using ll = long long;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(),i.end()
#define debug(i) std::cout << i << "\n"



const int INF = 100000000;
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;
    if(y%2){
        return (x*pow_mod(x,y-1,mod))%mod;
    }else{
        return pow_mod(x*x,y/2,mod);
    }
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!

  ll a, b;
  std::cin >> a >> b;
  if((a-b)%2==0){
    std::cout << (a + b) / 2;
  }else{
    std::cout << -1;
  }
  return 0;
}

Compiler output:
a.cc:17:21: error: 'll' was not declared in this scope; did you mean 'all'?
   17 | using P = std::pair<ll, ll>;
      |                     ^~
      |                     all
a.cc:17:25: error: 'll' was not declared in this scope; did you mean 'all'?
   17 | using P = std::pair<ll, ll>;
      |                         ^~
      |                         all
a.cc:17:27: error: template argument 1 is invalid
   17 | using P = std::pair<ll, ll>;
      |                           ^
a.cc:17:27: error: template argument 2 is invalid
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >>a>>b;
  if((a+b)%2==0){
  cout <<(a+b)/2<<endl;
  }else{
    cout <<"IMPOSSIBLE"<<endl;
}

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

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/math/common_factor.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;
using namespace boost::numeric::ublas;

int main() {
	long long A, B;

	cin >> A >> B;

  long long r = (A + B);
	cout << ((r % 2LL) ? "IMPOSSIBLE" : r / 2LL) << endl;

	return 0;
}


Compiler output:
a.cc:14:10: fatal error: boost/math/common_factor.hpp: No such file or directory
   14 | #include <boost/math/common_factor.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A>>B;
  C=max(A,B);
  D=min(A,B);
  if((C-D)%2!=0)cout<<"IMPOSSIBLE"<<endl;
  else cout << (C-D)/2 <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'D' was not declared in this scope
    8 |   D=min(A,B);
      |   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
long long  a,b;
  cin>>a>>b;
  long long s=a+b;

  cout << ((s % 2 == 0) ? s / 2:"IMPOSSIBLE")
  << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:25: error: operands to '?:' have different types 'long long int' and 'const char*'
    9 |   cout << ((s % 2 == 0) ? s / 2:"IMPOSSIBLE")
      |            ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
  long long a,b;cin>>a>>b;
  if((a+b)%2==1){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << (a+b)/2 << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:8:29: error: expected '}' at end of input
    8 |     cout << (a+b)/2 << endl;
      |                             ^
a.cc:7:8: note: to match this '{'
    7 |   }else{
      |        ^
a.cc:8:29: error: expected '}' at end of input
    8 |     cout << (a+b)/2 << endl;
      |                             ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a%2!=b%2)coutr<<"IMPOSSIBLE"<<endl;
	else cout<<(a+b)/2<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:21: error: 'coutr' was not declared in this scope
   36 |         if(a%2!=b%2)coutr<<"IMPOSSIBLE"<<endl;
      |                     ^~~~~
Language: C++

#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 10000000
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int a, b;
	cin >> a >> b;
	if (abs(a - b) % 2)puts("IMPOSSIBLE")
	else cout << min(a, b) + abs(a - b) / 2 << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:46: error: expected ';' before 'else'
   36 |         if (abs(a - b) % 2)puts("IMPOSSIBLE")
      |                                              ^
      |                                              ;
   37 |         else cout << min(a, b) + abs(a - b) / 2 << endl;
      |         ~~~~
Language: C++

#include <bits/stdc++.h>
#include <numeric>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i, n) for(int i = 2; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:23: error: no match for call to '(std::vector<int>) (int&)'
   19 |     REP(i, n) cin >> a(n);
      |                      ~^~~
Language: C++

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

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


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

when i put same code but change the compiler to. c(clang 10.0..the code has accepted but in these gcc compiler its giving me runtime error on these code

Compiler output:
main.c:1:1: error: unknown type name 'when'
    1 | when i put same code but change the compiler to. c(clang 10.0..the code has accepted but in these gcc compiler its giving me runtime error on these code
      | ^~~~
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'put'
    1 | when i put same code but change the compiler to. c(clang 10.0..the code has accepted but in these gcc compiler its giving me runtime error on these code
      |        ^~~
main.c:1:8: error: unknown type name 'put'
main.c:1:58: error: too many decimal points in number
    1 | when i put same code but change the compiler to. c(clang 10.0..the code has accepted but in these gcc compiler its giving me runtime error on these code
      |                                                          ^~~~~~~~~
Language: C


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


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

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++)
    cin>>A[i],B[i]=A[i];
  sort(A.begin(),A.end());
  int cnt=0;
  for(int i=0;i<N;i++)
    if(A[i]!=B[i])cnt++;
  cout(cnt<=2?"YES":"NO")<<'\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: no match for call to '(std::ostream {aka std::basic_ostream<char>}) (const char*)'
   14 |   cout(cnt<=2?"YES":"NO")<<'\n';
      |   ~~~~^~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int number;
    std::cin >> number;
    std::cout << number << std::endl;
    std::vector<int> a;
    a.resize(number);
    int input;
    for (int i = 0; i < number; ++i){
        std::cin >> input;
        a.push_back(input);
        std::cout<<input << " ";
    }
    std::cout << "this line\n";

    std::vector<int> b{a};
    std::sort(b.begin(),b.end());
    std::cout << "this line2\n";

    int flag = 0;
    for (int i = 0; i < number; ++i) {
        if (a[i] != b[i])
            flag++;
    }
    if (flag == 2)
        std::cout << "NO" << std::endl;
    else
        std::cout << "YES" << std::endl;
    std::cout << "this line3\n";

    return 0;
}#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int number;
    std::cin >> number;
    std::cout << number << std::endl;
    std::vector<int> a;
    a.resize(number);
    int input;
    for (int i = 0; i < number; ++i){
        std::cin >> input;
        a.push_back(input);
        std::cout<<input << " ";
    }
    std::cout << "this line\n";

    std::vector<int> b{a};
    std::sort(b.begin(),b.end());
    std::cout << "this line2\n";

    int flag = 0;
    for (int i = 0; i < number; ++i) {
        if (a[i] != b[i])
            flag++;
    }
    if (flag == 2)
        std::cout << "False" << std::endl;
    else
        std::cout << "True" << std::endl;
    std::cout << "this line3\n";

    return 0;
}

Compiler output:
a.cc:35:2: error: stray '#' in program
   35 | }#include <iostream>
      |  ^
a.cc:35:3: error: 'include' does not name a type
   35 | }#include <iostream>
      |   ^~~~~~~
Language: C++

#include <string.h>
#include <algorithm>

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

using namespace std;

int main() {
	
	int n;
	int point=0;
	int tradeCount = 0;

	cin >> n;
	int* p = new int[n];
	ref(i, n) cin >> p[n];

	ref(i, n) {
		if (p[i] != n - i && p[p[i]] == n-i ) {
			tradeCount++;
		}
		else if (p[i] != n - i && p[p[i]] != n - i) {
			cout << "No";
			delete[] p;
			exit(0);
		}
		if (tradeCount == 2) {
			cout << "No";
			delete[] p;
			exit(0);
		}
	}
	cout << "Yes";

	delete[] p;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'cin' was not declared in this scope
   14 |         cin >> n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 | 
a.cc:23:25: error: 'cout' was not declared in this scope
   23 |                         cout << "No";
      |                         ^~~~
a.cc:23:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:28:25: error: 'cout' was not declared in this scope
   28 |                         cout << "No";
      |                         ^~~~
a.cc:28:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:33:9: error: 'cout' was not declared in this scope
   33 |         cout << "Yes";
      |         ^~~~
a.cc:33:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: Java

import java.util.Scanner;

public class Oor1Swap {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		
		int numberOfInput = input.nextInt();
		
		int[] array = new int[numberOfInput];
		
			for(int i=0;i<numberOfInput;i++) {
				
				array[i]=input.nextInt();
				
			}
			        
			        if (((array[0]+array[numberOfInput-1])%2)==0){
			            System.out.println("Yes");
			        } else {
			            System.out.println("No");
			        }
	      
		input.close();

	}

}


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

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		
		int numberOfInput = input.nextInt();
		
		int[] array = new int[numberOfInput];
		
			for(int i=0;i<numberOfInput;i++) {
				
				array[i]=input.nextInt();
        
			}
			        
			        if (((array[0]+array[numberOfInput-1])%2)==0){
			            System.out.println("Yes");
			        } else {
			            System.out.println("No");
			        }
	        
			}
		
		input.close();

	}

}


Compiler output:
Main.java:27: error: <identifier> expected
		input.close();
		           ^
Main.java:31: error: class, interface, enum, or record expected
}
^
2 errors
Language: C++

N = int(input())
vec = list(map(int,input().split()))
vec2 = [i for i in vec]
vec2.sort()
cnt = 0
for i in range(N):
    cnt += vec[i] != vec2[i]
if cnt <= 2:
    print("YES")
else:
    print("NO")

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

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int p[n];
    int c[n];
    rep(i,n)cin >> p[i];
    repr(i,n)c[i-1]=i;
    
    int cnt = 0;
    rep(i,n){
        if(p[i]!=c[i])cnt++
    }
    
    if(cnt==0 or cnt==1)cout << "Yes";
    else cout <<"No";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:28: error: expected ';' before '}' token
   19 |         if(p[i]!=c[i])cnt++
      |                            ^
      |                            ;
   20 |     }
      |     ~
Language: C++

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

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

    int count=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(p[i]>p[j]){
                int b=p[i];
                p[i]=p[j];
                p[j]=b;
                count++;
            }
        }
    }
    if(count==0&&count==1)cout<<"YES";
    else cout<<"NO";

}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:11: error: 'N' was not declared in this scope
    7 |     int p[N];
      |           ^
a.cc:8:30: error: 'p' was not declared in this scope
    8 |     for(int i=0;i<N;i++)cin>>p[i];
      |                              ^
a.cc:13:16: error: 'p' was not declared in this scope
   13 |             if(p[i]>p[j]){
      |                ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:17:12: error: no post-increment operator for type
   17 |       count++;
      |            ^~
a.cc:20:11: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator<='
   20 |   if(count<=2){
      |      ~~~~~^~~
Language: C++

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

int main(){
  int N;
  cin>>N;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  int k=0;
  for(int j=0;j<N;j++){
    if(P.at(i)!=i+1) k++;
  }
  if (k<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}

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

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

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

  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }

  vector<int> Q;
  Q=sort(P.begin(),P.end());


  int num=0;

  for(int i=0;i<N;i++){
    if(P.at(i)!=Q.at(i)){
      num++;
    }
  }

  if(num==2)
  cout<<"YES"<,endl;
  else
  cout<<"NO"<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:27: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   14 |   Q=sort(P.begin(),P.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:26:15: error: expected primary-expression before ',' token
   26 |   cout<<"YES"<,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.at(i);
  }

  vector<int> Q;
  Q=sort(P.begin(),Q.end());


  int num=0;

  for(int i=0;i<N;i++){
    if(P.at(i)!=Q.at(i)){
      num++;
    }
  }

  if(num==2)
  cout<<"YES"<,endl;
  else
  cout<<"NO"<<endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:27: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'void')
   14 |   Q=sort(P.begin(),Q.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:26:15: error: expected primary-expression before ',' token
   26 |   cout<<"YES"<,endl;
      |               ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  long long n,i,c=0;
  cin>>n;
  long long m[n];
  vector<long long>v;
  for(i=0;i<n;i++)
  {
    cin>>m[i];
    v.push_back(m[i]);
  }
  sort(m,m+n);
  for(i=0;i<n;i++)
  {
    if(v[i]!=m[i])
    {
      c++;
    }
  }
  if(c==0||c==2)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
  

Compiler output:
a.cc: In function 'int main()':
a.cc:32:12: error: expected '}' at end of input
   32 |   return 0;
      |            ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C++

#include<vector>
#include<algorithm>


using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'cin' was not declared in this scope
    9 |         cin >> n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | 
a.cc:21:17: error: 'cout' was not declared in this scope
   21 |                 cout << "NO";
      |                 ^~~~
a.cc:21:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:24:17: error: 'cout' was not declared in this scope
   24 |                 cout << "YES";
      |                 ^~~~
a.cc:24:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: expected ';' before '}' token
   13 |     cin >> a[i]
      |                ^
      |                ;
   14 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int a,b,c,d,ans,tmp;
    string s;
 
    a = b = c = d = ans = tmp = 0;
     cin >> a;
    vector<int>v(a);
    vector<int>b(a);
    for(int i = 0;i < a;i++){
        cin >> v[i];
    }
    b = v;     

   
    sort(v.begin(),v.end());
    for(int i = 0;i < a;i++){
        if(b[i] != v[i]){
            tmp++;
        }
    }
    if(tmp <=2){
        cout << "YES";
    }else{
        cout <<"NO";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: conflicting declaration 'std::vector<int> b'
   12 |     vector<int>b(a);
      |                ^
a.cc:6:11: note: previous declaration as 'int b'
    6 |     int a,b,c,d,ans,tmp;
      |           ^
a.cc:16:9: error: cannot convert 'std::vector<int>' to 'int' in assignment
   16 |     b = v;
      |         ^
      |         |
      |         std::vector<int>
a.cc:21:13: error: invalid types 'int[int]' for array subscript
   21 |         if(b[i] != v[i]){
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define mod 1000000007LL
#define FOR(i,m,n) for(int i = (m); i < (n); i++)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(),v.end()
#define sz(v) int(v.size())
 
 
typedef long long ll;
typedef vector<int> vi; 
typedef pair<int,int> ii;


ll pow(ll a, ll b){
    int ans = 1;
    while(b){
        if(b&1) ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}


const int N=1e5;


void run(){
	
	int n; cin>>n;
	
	vi v(n);
	FOR(i,0,n){
		cin>>v[i];
	}
	int cant=0, x;
	
	FOR(i,0,n-1){
		if(v[i]>v[i+1]){
			swap(v[i],v[v[i]); break;
		}
	}
	bool p=1;
	FOR(i,0,n-1){
		if(v[i]>v[i+1]) {p=0; break;}
	}
	
	if(p) cout<<"YES\n";
	else cout<<"NO\n";
}


int main(){
	
	fastio;
	
	int tt=1; 
	//cin>>tt;
	
	while(tt--){
		run();
	}
	
	return 0;
}


Compiler output:
a.cc: In function 'void run()':
a.cc:46:41: error: expected ']' before ')' token
   46 |                         swap(v[i],v[v[i]); break;
      |                                         ^
      |                                         ]
Language: C++

{
    int a,d=0;cin>>a;
    int b[a-1],c[a-1];
    for(int i=0;i<a-1;i++){
        cin>>b[i];
        b[i]=c[i];
    }
    sort(b,b+a);
    for(int i=0;i<a-1;i++){
        if(b[i]==c[i]){
            d++;
        }
    }
    if(d<2){
        std::cout << "NO" << std::endl;
    }
    else{
        std::cout << "YES" << std::endl;
    }
}

Compiler output:
a.cc:1:1: error: expected unqualified-id before '{' token
    1 | {
      | ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:13: error: expected unqualified-id before numeric constant
   10 |     for(int 1=0;i<=n;i++)
      |             ^
a.cc:10:12: error: expected ';' before numeric constant
   10 |     for(int 1=0;i<=n;i++)
      |            ^~
      |            ;
a.cc:10:13: error: lvalue required as left operand of assignment
   10 |     for(int 1=0;i<=n;i++)
      |             ^
a.cc:10:17: error: 'i' was not declared in this scope
   10 |     for(int 1=0;i<=n;i++)
      |                 ^
a.cc:10:21: error: expected ')' before ';' token
   10 |     for(int 1=0;i<=n;i++)
      |        ~            ^
      |                     )
a.cc:10:22: error: 'i' was not declared in this scope
   10 |     for(int 1=0;i<=n;i++)
      |                      ^
Language: C++

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

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


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

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

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


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:20:14: error: 'i' was not declared in this scope
   20 |     sum += p[i] - q[i];
      |              ^
Language: Java

import java.util.ArrayList;
import java.util.List;
class Swap0and1 {
    public static void main(String[] args) {
		int[] arr = {5, 2, 3, 4, 1};
		int n = 5;
		List<Integer>arr2 = new ArrayList<>();
		for (int count = 1; count <= n; count++) {
			arr2.add(count);
		}
		int[] toArr2 = new int[arr2.size()];
		for (int i = 0; i < arr.length; i++) {
			toArr2[i] = arr2.get(i);
		}
		
		int[] fixed = compare(arr, toArr2);
		boolean flag = isFixed(toArr2, fixed);
		if(flag) System.out.println("Yes");
		else System.out.println("No");
		
	}
    public static int[] compare(int[] arr, int[] arr2) {
		List<Integer> x = new ArrayList<>();
		for (int count = 0; count < arr.length; count++) {
			if(x.size() <= 2 && arr[count] != arr2[count]) {
				x.add(count);
			}
			if(x.size() == 2) {
				break;
			}
		}
		if(x.size() == 0) {
			return arr;
		}
		else
			return swap(x.get(0), x.get(1), arr);
	}
	
	public static boolean isFixed(int[] arr, int[] arr2) {
		boolean flag = false;
		for (int count = 0; count < arr.length; count++) {
			if(arr[count] != arr2[count]) {
				flag = false;
				break;
			}
			else {
				flag = true;
			}
		}
		return flag;
	}


}

Compiler output:
Main.java:36: error: cannot find symbol
			return swap(x.get(0), x.get(1), arr);
			       ^
  symbol:   method swap(Integer,Integer,int[])
  location: class Swap0and1
1 error
Language: Java

class Swap0and1 {
    public static void main(String[] args) {
		int[] arr = {5, 2, 3, 4, 1};
		int n = 5;
		List<Integer>arr2 = new ArrayList<>();
		for (int count = 1; count <= n; count++) {
			arr2.add(count);
		}
		int[] toArr2 = new int[arr2.size()];
		for (int i = 0; i < arr.length; i++) {
			toArr2[i] = arr2.get(i);
		}
		
		int[] fixed = compare(arr, toArr2);
		boolean flag = isFixed(toArr2, fixed);
		if(flag) System.out.println("Yes");
		else System.out.println("No");
		
	}
    public static int[] compare(int[] arr, int[] arr2) {
		List<Integer> x = new ArrayList<>();
		for (int count = 0; count < arr.length; count++) {
			if(x.size() <= 2 && arr[count] != arr2[count]) {
				x.add(count);
			}
			if(x.size() == 2) {
				break;
			}
		}
		if(x.size() == 0) {
			return arr;
		}
		else
			return swap(x.get(0), x.get(1), arr);
	}
	
	public static boolean isFixed(int[] arr, int[] arr2) {
		boolean flag = false;
		for (int count = 0; count < arr.length; count++) {
			if(arr[count] != arr2[count]) {
				flag = false;
				break;
			}
			else {
				flag = true;
			}
		}
		return flag;
	}


}

Compiler output:
Main.java:5: error: cannot find symbol
		List<Integer>arr2 = new ArrayList<>();
		^
  symbol:   class List
  location: class Swap0and1
Main.java:5: error: cannot find symbol
		List<Integer>arr2 = new ArrayList<>();
		                        ^
  symbol:   class ArrayList
  location: class Swap0and1
Main.java:21: error: cannot find symbol
		List<Integer> x = new ArrayList<>();
		^
  symbol:   class List
  location: class Swap0and1
Main.java:21: error: cannot find symbol
		List<Integer> x = new ArrayList<>();
		                      ^
  symbol:   class ArrayList
  location: class Swap0and1
4 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,p,cnt=0;cin>>n;
  rep(i,n) {cin>>p;if(c!=i+1) cnt++;}
  print((cnt<=2)?"YES":"NO");
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:23: error: 'c' was not declared in this scope
   20 |   rep(i,n) {cin>>p;if(c!=i+1) cnt++;}
      |                       ^
Language: C++

#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  int before, cnt = 0;
  rep(i, n){
    int p;
    cin >> p;
    if(i){
      if(before > p + 1 || before < p - 1) cnt++;
    }
    before = p;
  }
  if(cnt > 2) cout << "NO" << endl;
  else cout << "YES" << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:41:30: error: expected '}' at end of input
   41 |   else cout << "YES" << endl;
      |                              ^
a.cc:28:11: note: to match this '{'
   28 | int main(){
      |           ^
Language: C++

#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;
  vector<int> b(2);
  
  for(int i=1;i<N;i++){
    if(a.at(i-1)>a.at(i)){
      count++;
      b.push(i);
    }
  }
  if(count==2){
    swap(a.at(b.at(0)),a.at(b.at(1)));
  }
  bool ans=true;
  
  for(int i=1;i<N;i++){
    if(a.at(i-1)>a.at(i)){
      ans=false;
    }
  }
  if(ans){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:17: error: 'n' was not declared in this scope
    7 |   for(int i=0;i<n;i++){
      |                 ^
a.cc:17:9: error: 'class std::vector<int>' has no member named 'push'
   17 |       b.push(i);
      |         ^~~~
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,count=0;cin>>N;
  vector<int> data(N);
  rep(i,N) cin>>data[i];
  rep(i,N-1){
    if(abs(data[i]-data[i+1])==1) count++;
  }
  bool hoge=false;
  if(count==N-1) cout << "YES" << endl;
  else{
    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        swap(data[i],data[j]);
        for(int k=0;k<N;k++){
          if(abs(data[k]-data[k+1])==1) countt++;
        }
        if(countt==N-1){
          cout << "YES" << endl;
          hoge=true;
          break;
        }
        swap(data[i],data[j]);
      }
      if(hoge) break;
    }
    if(!hoge) cout << "NO" << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:41: error: 'countt' was not declared in this scope; did you mean 'count'?
   20 |           if(abs(data[k]-data[k+1])==1) countt++;
      |                                         ^~~~~~
      |                                         count
a.cc:22:12: error: 'countt' was not declared in this scope; did you mean 'count'?
   22 |         if(countt==N-1){
      |            ^~~~~~
      |            count
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,count=0;cin>>N;
  vector<int> data(N);
  rep(i,N) cin>>data[i];
  rep(i,N-1){
    if(abs(data[i]-data[i+1])==1) count++;
  }
  bool hoge=false;
  if(count==N-1) cout << "YES" << endl;
  else{
    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        swap(data[i],data[j]);
        for(int k=0;k<N;k++){
          if(abs(data[k]-data[k+1])==1) count++;
        }
        if(count==N-1){
          cout << "YES" << endl;
          hoge=true;
          break;
        }
        swap(data[i],data[j]);
      }
      if(hoge) break;
    }
    if(hoge) break;
  }
  if(!hoge) cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:14: error: break statement not within loop or switch
   31 |     if(hoge) break;
      |              ^~~~~