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

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

int main(){
    int N;
    int cnt = 0;
    string ans = "";
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    for(int i = 0;i<N;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a.begin(), a.end());

    for(int i = 0; i<N;++i){
        if(a[i]!=b[i]){
            ++cnt;
        }
    }
    if(cnt=<2){
        ans == "YES";
    }
    cout << ans <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: expected primary-expression before '<' token
   22 |     if(cnt=<2){
      |            ^
a.cc:23:13: warning: ignoring return value of 'bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   23 |         ans == "YES";
      |         ~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:3772:5: note: declared here
 3772 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
Language: C++

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

int main(){
    int N;
    int cnt = 0;
    string ans = "YES";
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    for(int i = 0;i<N;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    if(a[0]!=1||a[N]!=1){
        ans == "NO";
    }
    if(a[0]==1){
        sort(a.begin(), a.end());
    }
    else if(a[N-1]=1){
        sort(a.begin(), a.end());
        reverse(a.begin(),a.end());
    }
    for(int i = 0; i<N;++i){
        if(a[i]!=b[i]){
            ++cnt;
        }
    }
    if(cnt>2;){
        ans == "NO";
    }
    cout << ans <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:13: warning: ignoring return value of 'bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   16 |         ans == "NO";
      |         ~~~~^~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:3772:5: note: declared here
 3772 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
a.cc:30:14: error: expected primary-expression before ')' token
   30 |     if(cnt>2;){
      |              ^
a.cc:31:13: warning: ignoring return value of 'bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   31 |         ans == "NO";
      |         ~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: declared here
 3772 |     operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
Language: Java

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

public class Main {
 	public static void main(String[] args) {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int[] arr = new int[sc.nextInt()];
      	int wrong = 0;
      	for (int i = 0; i < arr.length; i++) {
         	arr[i] = sc.nextInt(); 
          	if (arr[i] != i + 1) {
             	wrong++; 
            }
        }
      	out.println(wrong == 2 ? "YES" : "NO);
      	out.close();
   }
}

Compiler output:
Main.java:16: error: unclosed string literal
      	out.println(wrong == 2 ? "YES" : "NO);
      	                                 ^
1 error
Language: C++

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

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

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  x=new int[n];
  for(int i=0;i<n;i++)
    cin >> x[i];
  int cnt=0,sw=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j++;j<n){
      if(i>j){
        swap(x[i],x[j]);
        sw=1;
      }
    }
    if(sw==1)
      cnt++;
    if(cnt>=2)
      break;
  }
  if(cnt<=1)
    cout << "YES\n";
  else
    cout << "NO\n";
  
  return 0;
}


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

#include <bits/stdc++.h>
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 i = 1;
  while(i<=n)
{
    if(a[i]<0 && abs(a[i])!=i){
    cout<<"NO"<<endl;
    break;}
if(abs(a[i])==i){
	i++;
  continue;}
    a[i] = (-1)*a[i];
    a[a[i]] = (-1)*a[a[i]];
    swap(a[i], a[abs(a[i])]);
  }
}
  if(i==(n+1)){
  cout<<"YES"<<endl;}
return 0;
}

Compiler output:
a.cc:25:3: error: expected unqualified-id before 'if'
   25 |   if(i==(n+1)){
      |   ^~
a.cc:27:1: error: expected unqualified-id before 'return'
   27 | return 0;
      | ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
   28 | }
      | ^
Language: C++

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

void judge(int *array, int num) {
    int i;
    for (i=0; i<num-1; i++) {
        if (array[i] > array[i+1]) {
            break;
        }
    }
    if (i == num-1) {
        cout << "YES" << endl;
        exit(0);
    }
}

int main() {
    int N;

    cin >> N;
    int num_seq[N];

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

    int tmp_seq[N];
    int tmp;

    judge(num_seq, N);

    for (int i=0; i<N; i++) {
        for (int j=i+1; j<N; j++) {
            memcpy(tmp_seq, num_seq, sizeof(num_seq));
            tmp = tmp_seq[i];
            tmp_seq[i] = tmp_seq[j];
            tmp_seq[j] = tmp;

            judge(tmp_seq, N);
        }
    }
    cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:13: error: 'memcpy' was not declared in this scope
   35 |             memcpy(tmp_seq, num_seq, sizeof(num_seq));
      |             ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdlib>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n;
    cin>>>n;
    long int a[n],b[n];
    for(long int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    int temp=0;
    sort(b,b+n);
    for(long int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        temp++;
    }
    if(temp==0||temp==2)
    cout<<"YES";
    else
    cout<<"NO";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: expected primary-expression before '>' token
    6 |     cin>>>n;
      |          ^
Language: C++

#include <iostream>
using namespace std;

int main() {
	int N;
	cin >> N;
	int p[60];
	int sum = 0;

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

			for (int k = 0; k < N-1; k++) {
				if (p[k] < p[k + 1]) {
					sum++;
				}
			}
		}
	}

	if (sum == N) {
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: lvalue required as left operand of assignment
   16 |                         &p[i] = &p[j];
      |                         ^~~~~
a.cc:17:25: error: lvalue required as left operand of assignment
   17 |                         &p[j] = &px;
      |                         ^~~~~
Language: C++

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

#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C 9/++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()
 
//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)

#define fori(i,n) for(int i=0; i<n; i++)
#define forl(i,n) for(ll i=0; i<n; i++)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
const  llu int_max = pow(2,32) - 1 ;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.ff < j.ff;
}

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int p[n];
	cin>>p[0];
	for (int i = 1; i < n; ++i)
	{
		cin>>p[i];
		if(p[i]<p[i-1])
			cnt++;
	}
	if(cnt==2 || cnt==0 || n==2)
		cout<<"YES";
	else
		cout<<"NO";


	return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:59:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   59 |                         cnt++;
      |                         ^~~
      |                         int
a.cc:61:12: error: 'cnt' was not declared in this scope; did you mean 'int'?
   61 |         if(cnt==2 || cnt==0 || n==2)
      |            ^~~
      |            int
Language: C++

#include<bits/stdc++.h>
#define N 10004
#define llong long long
#define _pair  pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
int n;
int a[100];
bool check()
    {
        for (int i=1; i <= n; i++)
            if (a[i] != i)
                return 0;
        return 1;
    }
void YES()
    {
        cout<<"YES";
        exit(0);
    }
void NO()
    {
        cout<<"NO";
        exit(0);
    }
int main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    for (int i=1; i <= n; i++)
        cin>>a[i];
    if (check()) YES();
    for (int i=1; i <= n; i++)
        for (int j=i+1; j <= n; j++){
            swap(a[i],a[j]);
            if (check()) YES();
            swap(a[i],a[j]);
        }
    NO();
    return 0;
}
#include<bits/stdc++.h>
#define N 10004
#define llong long long
#define _pair  pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
int n;
int a[100];
bool check()
    {
        for (int i=1; i <= n; i++)
            if (a[i] != i)
                return 0;
        return 1;
    }
void YES()
    {
        cout<<"YES";
        exit(0);
    }
void NO()
    {
        cout<<"NO";
        exit(0);
    }
int main()
{
    ios::sync_with_stdio(0);
    cin>>n;
    for (int i=1; i <= n; i++)
        cin>>a[i];
    if (check()) YES();
    for (int i=1; i <= n; i++)
        for (int j=i+1; j <= n; j++){
            swap(a[i],a[j]);
            if (check()) YES();
            swap(a[i],a[j]);
        }

Compiler output:
a.cc:52:5: error: redefinition of 'int n'
   52 | int n;
      |     ^
a.cc:9:5: note: 'int n' previously declared here
    9 | int n;
      |     ^
a.cc:53:5: error: redefinition of 'int a [100]'
   53 | int a[100];
      |     ^
a.cc:10:5: note: 'int a [100]' previously declared here
   10 | int a[100];
      |     ^
a.cc:54:6: error: redefinition of 'bool check()'
   54 | bool check()
      |      ^~~~~
a.cc:11:6: note: 'bool check()' previously defined here
   11 | bool check()
      |      ^~~~~
a.cc:61:6: error: redefinition of 'void YES()'
   61 | void YES()
      |      ^~~
a.cc:18:6: note: 'void YES()' previously defined here
   18 | void YES()
      |      ^~~
a.cc:66:6: error: redefinition of 'void NO()'
   66 | void NO()
      |      ^~
a.cc:23:6: note: 'void NO()' previously defined here
   23 | void NO()
      |      ^~
a.cc:71:5: error: redefinition of 'int main()'
   71 | int main()
      |     ^~~~
a.cc:28:5: note: 'int main()' previously defined here
   28 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:83:10: error: expected '}' at end of input
   83 |         }
      |          ^
a.cc:72:1: note: to match this '{'
   72 | {
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
int a,b[100000],c[100000],d;
cin>>a;
  d=0;
  for(int i=0;i<a;i++){
     cin>>b[i];
    c[i]=b[i];
  }
  sort(c,c+a)
    for(int i=0;i<a;i++){
    if(c[i]!=b[i]){d++;}
    }
  if(d<3){cout<<"YES";}
  else cout<<"NO";
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:13:14: error: expected ';' before 'for'
   13 |   sort(c,c+a)
      |              ^
      |              ;
   14 |     for(int i=0;i<a;i++){
      |     ~~~       
a.cc:14:17: error: 'i' was not declared in this scope
   14 |     for(int i=0;i<a;i++){
      |                 ^
Language: C++

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

int n, a[N];

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

Compiler output:
a.cc:4:10: error: 'N' was not declared in this scope
    4 | int n, a[N];
      |          ^
a.cc: In function 'int main()':
a.cc:10:22: error: 'a' was not declared in this scope
   10 |         scanf("%d", &a[i]);
      |                      ^
Language: C++

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

int main() {
	
 int a; 
  bool flag =true;
  bool bflag = true;
  cin >> a;
  int cou=0;
  vector<int> vec(a);
  for (int i = 0; i < a; i++) {
  cin >> vec.at(i);
	}
  vector<int> vect(a);
  for(int j=0;j<a;j++){
    vect.at(j)=vec.at(i);
  }
  std::sort(vect.begin(),vect.end());
  for(int i=0;i<a;i++)
    if(vec.at(i)!=vect.at(i))
      cou++;
  if(cou==0||cou==2)
    cout << "YES"<<endl;
  else
    cout<< "NO"<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: 'i' was not declared in this scope
   18 |     vect.at(j)=vec.at(i);
      |                       ^
Language: C++

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

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


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

int N, p[51];
vector<int> v;
int main() {
	scanf("%d",&N);
  	for (int i = 1; i <= N; i++) scanf("%d",&N);
  	for (int i = 1; i <= N; i++) if (i != p[i]) v.push_back(i);
  	if (v.empty() || v.size() == 2) {
      	cout << "YES\n";
    } else {
      	cout << "NO\n";
    }
}

Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<int> v;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:4:9: error: 'scanf' was not declared in this scope
    4 |         scanf("%d",&N);
      |         ^~~~~
a.cc:6:53: error: 'v' was not declared in this scope
    6 |         for (int i = 1; i <= N; i++) if (i != p[i]) v.push_back(i);
      |                                                     ^
a.cc:7:13: error: 'v' was not declared in this scope
    7 |         if (v.empty() || v.size() == 2) {
      |             ^
a.cc:8:9: error: 'cout' was not declared in this scope
    8 |         cout << "YES\n";
      |         ^~~~
a.cc:10:9: error: 'cout' was not declared in this scope
   10 |         cout << "NO\n";
      |         ^~~~
Language: C++

int N, p[51];
vector<int> notGood;
int main() {
	scanf("%d",&N);
  	for (int i = 1; i <= N; i++) scanf("%d",&N);
  	for (int i = 1; i <= N; i++) if (i != p[i]) v.push_back(i);
  	if (v.empty() || v.size() == 2) {
      	cout << "YES\n";
    } else {
      	cout << "NO\n";
    }
}

Compiler output:
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<int> notGood;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:4:9: error: 'scanf' was not declared in this scope
    4 |         scanf("%d",&N);
      |         ^~~~~
a.cc:6:53: error: 'v' was not declared in this scope
    6 |         for (int i = 1; i <= N; i++) if (i != p[i]) v.push_back(i);
      |                                                     ^
a.cc:7:13: error: 'v' was not declared in this scope
    7 |         if (v.empty() || v.size() == 2) {
      |             ^
a.cc:8:9: error: 'cout' was not declared in this scope
    8 |         cout << "YES\n";
      |         ^~~~
a.cc:10:9: error: 'cout' was not declared in this scope
   10 |         cout << "NO\n";
      |         ^~~~
Language: C++

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

int main()
  	int n;
	scanf("%d", &n);
	int cont=0;
	for (int i=1; i<=n; i++){
      	int x;
     	scanf("%d", &x);
      	if(x == i) cont++;
    }
	if(cont <= 2) puts("YES");
	else puts("NO");
}

Compiler output:
a.cc:5:9: error: expected initializer before 'int'
    5 |         int n;
      |         ^~~
a.cc:6:14: error: expected constructor, destructor, or type conversion before '(' token
    6 |         scanf("%d", &n);
      |              ^
a.cc:8:9: error: expected unqualified-id before 'for'
    8 |         for (int i=1; i<=n; i++){
      |         ^~~
a.cc:8:23: error: 'i' does not name a type
    8 |         for (int i=1; i<=n; i++){
      |                       ^
a.cc:8:29: error: 'i' does not name a type
    8 |         for (int i=1; i<=n; i++){
      |                             ^
a.cc:13:9: error: expected unqualified-id before 'if'
   13 |         if(cont <= 2) puts("YES");
      |         ^~
a.cc:14:9: error: expected unqualified-id before 'else'
   14 |         else puts("NO");
      |         ^~~~
a.cc:15:1: error: expected declaration before '}' token
   15 | }
      | ^
Language: Java

import  java.util.*;
import java.math.Arrays;
class prob
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
int b[]=new int[n];
b=Arrays.copyOfRange(a,0,n);
Arrays.sort(b);
int x[]=new int[n];
for(int i=0;i<n;i++)
{
x[i]=a[i]-b[i];
}
int t=0;
for(int i=0;i<n;i++)
if(x[i]<0)
t++;
if(t==0 )
System.out.println("YES");
else if(t==2)
System.out.println("YES");
else 
System.out.println("NO");
}
}

Compiler output:
Main.java:2: error: cannot find symbol
import java.math.Arrays;
                ^
  symbol:   class Arrays
  location: package java.math
1 error
Language: C

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


Compiler output:
main.c: In function 'main':
main.c:24:1: error: expected declaration or statement at end of input
   24 | }
      | ^
Language: C++

#include <iostream>
 
using namespace std;
 
int main() {
  int n, count = 0;
  cin >> n;
  for (int i = 0, num; i < n; i++) {
    cin >> num;
    count += (i != num);
  }
  cout << (count == 0 || count == 2) ? "YES" : "NO" << endl;
  return 0;
}

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

#include <iostream>
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  for (int i = 0, count = 0, num; i < n; i++) {
    cin >> num;
    count += (i != num);
  }
  cout << (count == 0 || count == 2) ? "YES" : "NO" << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: 'count' was not declared in this scope
   12 |   cout << (count == 0 || count == 2) ? "YES" : "NO" << endl;
      |            ^~~~~
a.cc:12:53: error: invalid operands of types 'const char [3]' and '<unresolved overloaded function type>' to binary 'operator<<'
   12 |   cout << (count == 0 || count == 2) ? "YES" : "NO" << endl;
      |                                                ~~~~~^~~~~~~
Language: C++

#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 0, count = 0, num; i < n; i++) {
    cin >> num;
    count += (i != num);
  }
  cout << (count == 0 || count == 2) ? "YES" : "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: 'count' was not declared in this scope
   12 |   cout << (count == 0 || count == 2) ? "YES" : "NO" << endl;
      |            ^~~~~
a.cc:12:53: error: invalid operands of types 'const char [3]' and '<unresolved overloaded function type>' to binary 'operator<<'
   12 |   cout << (count == 0 || count == 2) ? "YES" : "NO" << endl;
      |                                                ~~~~~^~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:66: error: expected ';' before 'cout'
   10 |     if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2])
      |                                                                  ^
      |                                                                  ;
   11 |   cout << "YES" <<endl;
      |   ~~~~                                                            
a.cc:12:8: error: expected primary-expression before 'else'
   12 |        else cout<<"NO"<<endl;
      |        ^~~~
a.cc:11:24: error: expected ')' before 'else'
   11 |   cout << "YES" <<endl;
      |                        ^
      |                        )
   12 |        else cout<<"NO"<<endl;
      |        ~~~~             
a.cc:10:7: note: to match this '('
   10 |     if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2])
      |       ^
Language: C++

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

int main(){
	int N;
  	vector<int> vec(N);
  	cin >> N;
  
  	for(int i=0;i<N;i++){
    	cin >> vec.at(i);
    }
  
  	int count=0;
  
  	for(int i=0;i<N;i++){
    	if(vec.at(i) != i){
        	count++;
        }
    }
  
  	if(count == 2 || count == 0){
    	cout << "YES" << endl;
    }
  	else{
    	cont << "NO" << endl; 
    }
  
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: error: 'cont' was not declared in this scope; did you mean 'count'?
   25 |         cont << "NO" << endl;
      |         ^~~~
      |         count
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100001;
int main()
{
    int N, a;
    int b[MAX_N];
    a = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &b[i])
    }
    for (int i = 0; i < N; i++)
    {
        if (b[i] != i+1)
            a += 1;
    }
    printf((a < 3) ? "Yes\n" : "No\n");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:27: error: expected ';' before '}' token
   12 |         scanf("%d", &b[i])
      |                           ^
      |                           ;
   13 |     }
      |     ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, a;
    a = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &b[i])
    }
    for (int i = 0; i < N; i++)
    {
        if (b[i] != i+1)
            a += 1;
    }
    printf((a < 3) ? "Yes\n" : "No\n");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:22: error: 'b' was not declared in this scope
   10 |         scanf("%d", &b[i])
      |                      ^
a.cc:14:13: error: 'b' was not declared in this scope
   14 |         if (b[i] != i+1)
      |             ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,k,i,j,a=0;
    vector<int>v;
    cin>>n;
    x=n;

    while(n--)
    {
        cin>>k;
        v.push_back(k);
    }
    for(i=0;i<v.size();i++)
    {
        if(v[i]<v[i+1])
            a++;
    }

    //cout<<a<<endl;

    if((x-a<=2)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:16: error: expected ';' before 'cout'
   23 |     if((x-a<=2)
      |                ^
      |                ;
   24 |         cout<<"YES\n";
      |         ~~~~    
a.cc:25:5: error: expected primary-expression before 'else'
   25 |     else
      |     ^~~~
a.cc:24:23: error: expected ')' before 'else'
   24 |         cout<<"YES\n";
      |                       ^
      |                       )
   25 |     else
      |     ~~~~               
a.cc:23:7: note: to match this '('
   23 |     if((x-a<=2)
      |       ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:25:21: error: redeclaration of 'int tmp'
   25 |                 int tmp=p[i];
      |                     ^~~
a.cc:18:21: note: 'int tmp' previously declared here
   18 |                 int tmp=p[i];
      |                     ^~~
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int N,a;
  a=0;
    cin >> N;
    char s[N+1];
    char t[N+1];
  scanf("%s", s);
  for(int i=0;i<N;i++)
  {
    t[i]=s{i};
  }
    sort(t, t + N);
  for(int i=0;i<N;i++)
  {
    if(s[i]!=t[i])
    a+=1;
  }
    printf((a<3) ? "Yes\n" : "No\n");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     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 | using namespace std;
a.cc:14:10: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   14 |     t[i]=s{i};
      |          ^
      |          |
      |          char*
a.cc:14:11: error: expected ';' before '{' token
   14 |     t[i]=s{i};
      |           ^
      |           ;
Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int N,a;
  a=0;
    cin >> N;
    char s[N+1];
    char t[N+1];
  scanf("%s", s);
  for(int i=0;i<N;i++)
  {
    s[i]=t{i}
  }
    sort(t, t + N);
  for(int i=0;i<N;i++)
  {
    if(s[i]!=t[i])
    a+=1;
  }
    printf((a<3) ? "Yes\n" : "No\n");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     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 | using namespace std;
a.cc:14:10: error: invalid conversion from 'char*' to 'char' [-fpermissive]
   14 |     s[i]=t{i}
      |          ^
      |          |
      |          char*
a.cc:14:11: error: expected ';' before '{' token
   14 |     s[i]=t{i}
      |           ^
      |           ;
Language: C++

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

int main()
{
    long long x,a,b,cnt=0;
    cin>>a>>b;
    x=b;a--;
    while(a--){
        cin>>b;
        if(b<x) cnt++;
        x=b;
    }
    if(cnt==2 || cnt = 0) cout<<"YES\n";
    else cout<<"NO\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: lvalue required as left operand of assignment
   14 |     if(cnt==2 || cnt = 0) cout<<"YES\n";
      |        ~~~~~~~^~~~~~
Language: Java

int[] a = sc.nextIntArray(n+1);
        int[] b = sc.nextIntArray(n);
        
        long res = 0;
        
        for(int i = 0; i < n; i++) { //勇者i
            if(a[i] - b[i] >= 0) {
                res+=b[i];
                b[i]=0;
                a[i]-=b[i];
            }else{
                res+=a[i];
                b[i]-=a[i];
                a[i]=0;
            }
            
            if(b[i] != 0) {
                if(a[i+1] - b[i] >= 0) {
                    res+=b[i];
                    a[i+1]-=b[i];
                }else{
                    res+=a[i+1];
                    a[i+1]=0;
                }
            }
        }
        
        out.println(res);


Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
int[] a = sc.nextIntArray(n+1);
^
  (use --enable-preview to enable unnamed classes)
Main.java:6: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) { //??i
        ^
Main.java:6: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) { //??i
                       ^
Main.java:6: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) { //??i
                              ^
Main.java:9: error: class, interface, enum, or record expected
                b[i]=0;
                ^
Main.java:10: error: class, interface, enum, or record expected
                a[i]-=b[i];
                ^
Main.java:11: error: class, interface, enum, or record expected
            }else{
            ^
Main.java:13: error: class, interface, enum, or record expected
                b[i]-=a[i];
                ^
Main.java:14: error: class, interface, enum, or record expected
                a[i]=0;
                ^
Main.java:15: error: class, interface, enum, or record expected
            }
            ^
Main.java:20: error: class, interface, enum, or record expected
                    a[i+1]-=b[i];
                    ^
Main.java:21: error: class, interface, enum, or record expected
                }else{
                ^
Main.java:23: error: class, interface, enum, or record expected
                    a[i+1]=0;
                    ^
Main.java:24: error: class, interface, enum, or record expected
                }
                ^
14 errors
Language: C++

    #include<iostream>
     
    using namespace std;
     
    int main(){
      int N;
      cin >> N ;
      int a;
      int count=0;
      for(int i = 0; i<N; i++){
        cin >> a;
        if(a-(i+1)!=0){
    		count++;
        }
        if(count>2){
          cout << "NO" << endl;
        }else{
          cout << "YES" << endl;
        }
        return 0;
      }

Compiler output:
a.cc: In function 'int main()':
a.cc:21:8: error: expected '}' at end of input
   21 |       }
      |        ^
a.cc:5:15: note: to match this '{'
    5 |     int main(){
      |               ^
Language: C++

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

const double PI = acos(-1.0);
const int N = 501;
const int MOD = 1e9 + 7;
typedef long long ll;

int a[55];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  	int n;
  cin>>n;
  for(int i = 1; i <= n; i++)
    cin>>a[i];
  
  for(int i = 1; i <= n; i++)
  {
    if(a[i] != i){
      swap(a[i], a[a[i]]);
    	break;
    }
  }
  for(int i = 1; i <= n; i++
      {
        if(a[i] != i)
        {
          cout<<"NO";
          return 0;
        }
     }
     cout<<"YES";


}





Compiler output:
a.cc: In function 'int main()':
a.cc:27:29: error: expected ')' before '{' token
   27 |   for(int i = 1; i <= n; i++
      |      ~                      ^
      |                             )
   28 |       {
      |       ~
Language: C++

#include<iostream>
 
using namespace atd;
 
int main(){
  int N;
  cin >> N ;
  int a;
  int count=0;
  for(int i = 0; i<N; i++){
    cin >> a;
    if(a-(i+1)!=0){
		count++;
    }
    if(count>2){
      cout << "NO" << endl;
    }else{
      cout << "YES" << endl;
    }
    return 0;
  }

Compiler output:
a.cc:3:17: error: 'atd' is not a namespace-name
    3 | using namespace atd;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> N ;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:16:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |       cout << "NO" << endl;
      |       ^~~~
      |       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:16:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   16 |       cout << "NO" << endl;
      |                       ^~~~
      |                       std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:18:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |       cout << "YES" << endl;
      |       ^~~~
      |       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:18:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   18 |       cout << "YES" << endl;
      |                        ^~~~
      |                        std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:21:4: error: expected '}' at end of input
   21 |   }
      |    ^
a.cc:5:11: note: to match this '{'
    5 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  long int N;
  cin >> N;
  vector<long int> a(N);
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int count = 0;
  for(int i = 0; i < N; ++i) {
    if(a[i] != i + 1){
      count += 1;
    } else if( count >= 3){
      cout << "NO" << endl;
      break;
    }
  }
  if(count == 2 || count == 0){
    cout << "YES" << endl;
  }
}
   
  
#include <iostream>
#include <vector>
using namespace std;

int main() {
  long int N;
  cin >> N;
  vector<long int> a(N);
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int count = 0;
  for(int i = 0; i < N; ++i) {
    if(a[i] != i + 1){
      count += 1;
      if( count >= 3){
        cout << "NO" << endl;
        break;
      }
    }
  }
  if(count == 2 || count == 0){
    cout << "YES" << endl;
  }
}
   
  
提出情報
提出日時

Compiler output:
a.cc:31:5: error: redefinition of 'int main()'
   31 | int main() {
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main() {
      |     ^~~~
a.cc:54:1: error: '\U000063d0\U000051fa\U000060c5\U00005831' does not name a type
   54 | 提出情報
      | ^~~~~~~~
Language: C++

def main():
    N = int(input())
    p = [int(i) for i in input().split()]
    if is_ascending(p):
        print("YES")
        return

    num_swap = 0
    previous = p[0]
    for p_i in p[1:]:
        if previous > p_i:
            num_swap += 1
        previous = p_i 

    if num_swap > 2:
        print("NO")
    elif num_swap == 1:
        previous = p[0]
        for ix, p_i in enumerate(p[1:], 1): 
            if previous > p_i:
                p[ix], p[ix-1] = p[ix-1], p[ix]
                break
            previous = p_i 

        if is_ascending(p):
            print("YES")
        else:
            print("NO")

    elif num_swap == 2:
        previous = p[0]
        is_first = True
        for ix, p_i in enumerate(p[1:], 1): 
            if previous > p_i:
                if is_first:
                    swap_ix = ix - 1 
                    is_first = False
                else:
                    p[swap_ix], p[ix] = p[ix], p[swap_ix]
                    break
            previous = p_i 


        if is_ascending(p):
            print("YES")
        else:
            print("NO")

def is_ascending(l):
    previous = l[0]
    for i in l[1:]:
        if previous > i:
            return False
    return True

if __name__ == "__main__":
    main()
                

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: C++

#include <bits/stdc++.h>

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


int main(){
    
    int n;
    int count = 0;
    
    std::cin >> n;
    
    const int N = n;
    int p[N];
    int q[N];
    for(int i =0; i < N; i++){
        std::cin >> p[i];
    }
    
    for(int i =0; i < N; i++){
        q[i] = p[i];
    }
    
    psort(p, N, sizeof(int), compare_int);
    for(int i = 0; i < N; i++){
        if( p[i] != q[i]){
            count++;
        }
    }
    
    if(count <= 2){
        std::cout << "YES" << "\n";
    } else std::cout << "NO" << "\n";

    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:5: error: 'psort' was not declared in this scope; did you mean 'qsort'?
   27 |     psort(p, N, sizeof(int), compare_int);
      |     ^~~~~
      |     qsort
Language: C++

#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  int n,tmp;
  int p[50],ans[50];
  cin >> n;
  for(int i=0;i<n;i++){
      cin >> p[i]
  }
  for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
          if(p[i]>p[j])
          tmp = p[i];
          p[i]=p[j];
          p[j]=tmp;
      }
  }

  for(int i=0;i<n-1;i++){
    if(p[i+1]-p[i]=1){
        break;
    }
    else 
  }

   
  
    return 0;   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: expected ';' before '}' token
   10 |       cin >> p[i]
      |                  ^
      |                  ;
   11 |   }
      |   ~               
a.cc:22:14: error: lvalue required as left operand of assignment
   22 |     if(p[i+1]-p[i]=1){
      |        ~~~~~~^~~~~
a.cc:26:3: error: expected primary-expression before '}' token
   26 |   }
      |   ^
Language: C++

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

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

    }    
    
//  	if (vec.at(i) == vec_sort.at(i)){
//        cout << "YES" << endl;
//        }
  
  	for (i=0;i<N-1;i++){
    	for (int j=1;j<N-i;j++){
        	swap(vec.at(i),vec.at(i+j));
          	if (vec.at(i) == vec_sort.at(i)){
            	cout << "YES" << endl;
              	break;
            }
          	else{
            	cout << "NO" << endl;
              	break;
            } 
        }
    }
  	

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: expected ';' before 'sort'
   13 |         cin >> vec_sort.at(i)
      |                              ^
      |                              ;
   14 |         sort(vec_sort.begin(),vec_sort.end());
      |         ~~~~
Language: C

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

int main(void){
	int p[52], N, i, count = 0, ans[3]={0};
	scanf_s("%d", &N);
	for(i = 1; i <= N; i++){
		scanf_s("%d", &p[i]);
		if((p[i] <= 0) || (p[i] >= 51)){
			printf("NO\n");
			return 1;
		}
	}
	for(i=1; i <= N; i++){
		p[i] -= i;
		if(p[i]!=0){
			ans[count] = abs(p[i]);
			count++;
			if(count == 3){
				printf("NO\n");
				return 1;
			}
		}
	}
	if((ans[0] == ans[1]) || (ans[0] == 0)) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    6 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: C++

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

}


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

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:24:9: error: 'cout' was not declared in this scope
   24 |         cout << "Yes" << endl;
      |         ^~~~
a.cc:24:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:24:26: error: 'endl' was not declared in this scope
   24 |         cout << "Yes" << endl;
      |                          ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:28:9: error: 'cout' was not declared in this scope
   28 |         cout << "Yes" << endl;
      |         ^~~~
a.cc:28:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:28:26: error: 'endl' was not declared in this scope
   28 |         cout << "Yes" << endl;
      |                          ^~~~
a.cc:28:26: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout <<"NO" << endl;
      |     ^~~~
a.cc:31:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:20: error: 'endl' was not declared in this scope
   31 |     cout <<"NO" << endl;
      |                    ^~~~
a.cc:31:20: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include <bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vector<vector<int>>);

// グローバル変数

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
	cin >> N;

	vector<int> p(N+1);
	int M, id, idd;
	for (int i=0; i<N; i++) {
		cin >> p(i);
		M = max(M, p(i));
	}

	for (int i=0; i<N; i++) {
		if(M==p(i)) id=i;
	}

	//swap(p(0), p(id));
	bool frag=true;
	for (int i=0;i<N-1; i++) {
		if(p(i)<p(i+1)) frag=false;
		idd = i;
	}

	if(frag) cout << 'YES';
	else {
		swap(p(id), p(idd));
		frag=true;
		for (int i=0;i<N-1; i++) {
			if(p(i)<p(i+1)) frag=false;
		}
		if(frag) cout << 'YES';
		else 'NO';
	}
}


Compiler output:
a.cc:40:26: warning: multi-character character constant [-Wmultichar]
   40 |         if(frag) cout << 'YES';
      |                          ^~~~~
a.cc:47:34: warning: multi-character character constant [-Wmultichar]
   47 |                 if(frag) cout << 'YES';
      |                                  ^~~~~
a.cc:48:22: warning: multi-character character constant [-Wmultichar]
   48 |                 else 'NO';
      |                      ^~~~
a.cc: In function 'int main()':
a.cc:25:25: error: no match for call to '(std::vector<long int>) (int64_t&)'
   25 |                 cin >> p(i);
      |                        ~^~~
a.cc:26:29: error: no match for call to '(std::vector<long int>) (int64_t&)'
   26 |                 M = max(M, p(i));
      |                            ~^~~
a.cc:30:24: error: no match for call to '(std::vector<long int>) (int64_t&)'
   30 |                 if(M==p(i)) id=i;
      |                       ~^~~
a.cc:36:21: error: no match for call to '(std::vector<long int>) (int64_t&)'
   36 |                 if(p(i)<p(i+1)) frag=false;
      |                    ~^~~
a.cc:36:26: error: no match for call to '(std::vector<long int>) (int64_t)'
   36 |                 if(p(i)<p(i+1)) frag=false;
      |                         ~^~~~~
a.cc:42:23: error: no match for call to '(std::vector<long int>) (int64_t&)'
   42 |                 swap(p(id), p(idd));
      |                      ~^~~~
a.cc:42:30: error: no match for call to '(std::vector<long int>) (int64_t&)'
   42 |                 swap(p(id), p(idd));
      |                             ~^~~~~
a.cc:45:29: error: no match for call to '(std::vector<long int>) (int64_t&)'
   45 |                         if(p(i)<p(i+1)) frag=false;
      |                            ~^~~
a.cc:45:34: error: no match for call to '(std::vector<long int>) (int64_t)'
   45 |                         if(p(i)<p(i+1)) frag=false;
      |                                 ~^~~~~
Language: C++

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

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

    }    
    
//  	if (vec.at(i) == vec_sort.at(i)){
//        cout << "YES" << endl;
//        }
  
  	for (i=0;i<N-1;i++){
    	for (int j=1;j<N-i;j++){
        	swap(vec.at(i),vec.at(i+j));
          	if (vec.at(i) == vec_sort.at(i)){
            	cout << "YES" << endl;
              	break;
            }
          	else{
            	cout << "NO" << endl;
              	break;
            } 
        }
    }
  	

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: void value not ignored as it ought to be
   13 |         vec_sort.at(i) = sort(vec.begin(),vec.end());
      |                          ~~~~^~~~~~~~~~~~~~~~~~~~~~~