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

#include <iostream>

int main() {
  int h, w, a, b;
  std::cin >> a >> b >> h >> w;
  std::cout << "No" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    6 |   std::cout << "No" << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/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>
using namespace std;
 
int main() {
int H,W,A,B;
  cin >>H>>W>>A>>B;
  
  vector<int> vec(3, 5);

Compiler output:
a.cc: In function 'int main()':
a.cc:8:25: error: expected '}' at end of input
    8 |   vector<int> vec(3, 5);
      |                         ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define Rep(i,n) for(int i=0; i<(n); i+=2)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    int h,w,a,b;
    cin >> h>>w>>a>>b;
    int s[h][w];
    rep(i,h){
        rep(j,w){
            s[i][j]=0;
        }
    }
    int H[w];
    rep(i,w){
            H[i]=0;
    }

    if(a>w/2||b>h/2){
            cout << "No" << endl;
            return 0;
    }

    rep(i, h)
    {
        int g = 0;
        rep(j, w)
        {
            if(g<a&&H[j]<b){
                s[i][j] = 1;
                g++;
                H[j]++;
            }
            
            else if(h==1&&b==0){
                if(g<a){
                s[i][j] = 1;
                g++;
            }
            }
            
            else if(w==1&&a==0){
                if(H[j]<b){
                s[i][j] = 1;
                H[j]++;
                }
            }
            
        }
        if(g!=a){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i,w){
        if(H[i!=b){
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i,h){
        rep(j, w){
                cout << s[i][j];
            }   
        cout << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:18: error: expected ']' before ')' token
   65 |         if(H[i!=b){
      |                  ^
      |                  ]
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,H,W,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>H>>W>>A>>B;
  int L[H][W];
  
  REP(i,H){
    REP(j,W) L[i][j]=0;
  }
  
  int k=0;
  
  if(A*H==B*W || A==0 || B==0){
    
    if(A!=0 && B!=0){
    for(int i=0; i<H; ++i){
      for(int j=0; j<A; ++j){
        if(j+k<W) L[i][j+k]=1;
        else{
          k-=W;
          L[i][j+k]=1;
        }
      }
      k+=A;
      while(k>=W) k-=W;
    }
    }
    
    else if(A==0 && B!=0){
      REP(i,B){
        REP(j,W) L[i][j]=1;
      }
    }
    
    }
    
    
    REP(i,H){
      REP(j,W){
        cout<<L[i][j];
      }
      cout<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }
  
}


Compiler output:
a.cc:70:3: error: expected unqualified-id before 'else'
   70 |   else{
      |   ^~~~
a.cc:74:1: error: expected declaration before '}' token
   74 | }
      | ^
Language: C++

using namespace std;
using namespace std;

int h,w,a,b;

signed main(){
    cin>>h>>w>>a>>b;
    if (abs(a-b)%2!=0) {
        cout<<"No"<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin>>h>>w>>a>>b;
      |     ^~~
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:8:9: error: 'abs' was not declared in this scope
    8 |     if (abs(a-b)%2!=0) {
      |         ^~~
a.cc:9:9: error: 'cout' was not declared in this scope
    9 |         cout<<"No"<<endl;
      |         ^~~~
a.cc:9:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:9:21: error: 'endl' was not declared in this scope
    9 |         cout<<"No"<<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;
Language: C++

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

int ans[1000][1000];

int n, m, a, b;

int cmp(pair<int, int> A, pair<int, int> B){
	return A.second > B.second;
}

void test(int _a, int _b){ // add of per row, add of per column
	vector<pair<int, int>> A;
	for(int i = 0; i < m; i++){
		A.push_back({i, (i < _b) * abs(n - b * 2) + min(b, n - b)});
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			ans[i][j] = 0;
		}
	}
	for(int i = 0; i < n; i++){
		int le = (i < _a) * abs(m - a * 2) + min(a, m - a);
		sort(A.begin(), A.end(), cmp);
		for(int j = 0; j < le; j++){
			ans[i][A[j].first] = 1;
			A[j].second--; 
		}
	}
	bool OK = 1;
	for(int i = 0; i < m; i++){
		if(A[i].second != 0){
			OK = 0;
		}
	}
	if(!OK){
		return;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
	exit(0);
}

int main(){
	cin >> n >> m >> a >> b;
	int x1 = a, x2 = m - a;
	int y1 = b, y2 = n - b;
	if(x2 < x1) swap(x1, x2);
	if(y2 < y1) swap(y1, y2);
	unordered_map<int, int> M;
	for(int i = 0; i <= n; i++){
		M[x1 * n + (x2 - x1) * i] = i;
	}
	for(int i = 0; i <= m; i++){
		if(M.find(y1 * m + (y2 - y1) * i) != M.end()){
			test(M[y1 * m + (y2 - y1) * i], i);
		}
	}
	cout 

Compiler output:
a.cc: In function 'int main()':
a.cc:63:13: error: expected ';' at end of input
   63 |         cout
      |             ^
      |             ;
a.cc:63:13: error: expected '}' at end of input
a.cc:48:11: note: to match this '{'
   48 | int main(){
      |           ^
Language: C++

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

int main() {
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  for(int tmp=0;tmp<(1<<H*W);++tmp){
    bitset<1000000> s(tmp);
    bool flag=true; 
    
    rep(i,H){
      int sum=0;//i行目の1の個数
      rep(j,W) if(s.test(i*W+j)) sum++;
      int a = min(sum,W-sum);
      if(a != A) {
        flag=false;
        break;
      }
    }
    
    rep(j,W){
      int sum2=0;//i列目の1の個数
      rep(i,H) if(s.test(i*W+j)) sum2++;
      int b = min(sum2,H-sum2);
      if(b != B) flag=false;
    }
    //flag=trueなら、正しい解の一つ
    //そうでなければ、ほかのbitsetを試す
    if(flag){
      s.to_string();
      rep(m,H){
        rep(n,W)　cout<<s[m*W+n];
        cout<<endl;
      }
      return 0;
    }
  }
  //終わってなければ
  puts("No");
  return 0;
}


Compiler output:
a.cc:34:17: error: extended character 　 is not valid in an identifier
   34 |         rep(n,W)　cout<<s[m*W+n];
      |                 ^
a.cc: In function 'int main()':
a.cc:34:17: error: '\U00003000cout' was not declared in this scope
   34 |         rep(n,W)　cout<<s[m*W+n];
      |                 ^~~~~~
Language: C

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(a) (a).begin(),(a).end()
signed main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<bool>> v(h, vector<bool>(w, false));
    int hb=0,wb=0;
    if (a == 0) {
        for (int i = 0; i < b; ++i)v[i][0] = true;
        for (int i = 0; i < h; ++i)for (int j = 1; j < w; ++j)v[i][j] = v[i][0];
    } else if (b == 0) {
        for (int i = 0; i < a; ++i)v[0][i] = true;
        for (int i = 1; i < h; ++i)for (int j = 0; j < w; ++j)v[i][j] = v[0][i];
    }
    else while (true) {

            for (int i = 0; i < b; ++i)
                for (int j = 0; j < a; ++j) {
                    if (i + hb >= h || j + wb >= w)return cout << "No", 0;
                    v[i + hb][j + wb] = true;
                }
            hb += b;
            wb += a;
            if(hb==h&&wb==w)break;
        }
    for(auto u:v){
        for(auto i:u)cout<<i;
        cout<<"\n";
    }
}

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

H, W, A, B = [int(_) for _ in input().split()]

if A == 0 or B == 0:
    line = ('0' * A) + ('1' * (W - A))
    for _ in range(H):
        print(line)
    exit()

idx = []
c = 0
for i in range(0, H, B):
    if c >= W:
        print('No')
        exit()
    idx.append(c)
    c += A

for h in range(0, H, B):
    v = idx.pop(0)
    if v > 0:
        line = ('0' * v)
    else:
        line = ''

    line += '1' * min(A, W - v)
    if v + B < W:
        line += '0' * max(W - (v + B), 0)
    print(line)

Compiler output:
a.cc:13:15: warning: multi-character character constant [-Wmultichar]
   13 |         print('No')
      |               ^~~~
a.cc:23:16: error: empty character constant
   23 |         line = ''
      |                ^~
a.cc:1:1: error: 'H' does not name a type
    1 | H, W, A, B = [int(_) for _ in input().split()]
      | ^
Language: C++

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
 
int main() {
  ll h,w,a,b ; 
  cin>>h>>w>>a>>b;
  
  int board[h][w];
  int num[w]={};
  rep(i,h){
    int cnt=0;
    rep(j,w){
      if(cnt<a &&num[j]<b){
        board[i][j]=1;
        cnt++;
        num[j]++;
      }
      else board[i][j]=0;
    }
  }
  
  bool can=true;
  rep(i,h){
    int cnt1=0;
    rep(j,w){
      if(board[i][j]==1) cnt1++;
    }
    if(cnt1==a || cnt1==w-a) continue;
    else{
      can=false;
      break;
    }
  }
  int cnt2[w]={};
  rep(i,h){
    rep(j,w){
      if(board[i][j]==1) cnt2[j]++;
    }
  }
  rep(i,w){
    if(cnt2[i]==b || cnt2[i]==h-b) continue;
    else{
      can=false;
      break;
    }
  }
  if(b==0){
    rep(i,a) cout<<1;
    rep(i,w-a) cout<<0;
    cout<<endl;
  }
  else if(a==0){
    rep(i,b) cout<<1<<endl;
    rep(i,h-a) cout<<0<<endl;
  }
  else{
    if(can){
      rep(i,h){
        rep(j,w){
          cout<<board[i][j];
        }
        cout<<endl;
      }
    }
    else cout<<"No"<<endl;
  }
  

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

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>

int main(){
    cout << "No" << endl;
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   12 |     cout << "No" << endl;
      |     ^~~~
      |     std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:12:21: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   12 |     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)
      |     ^~~~
Language: C++

int main(){
    cout << "No" << endl;
  	return 0;
}

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

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


int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int vec_sum(vector<int> v){
  int n;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}




int main() {
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  if((h/2)==b && (w/2)=a){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(((i%2)+(j%2))%2==0){
          cout<<'0';
        }else{
          cout<<'1';
        }
      }
      cout<<endl;
    }
  }
  
  
  
  
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: lvalue required as left operand of assignment
   31 |   if((h/2)==b && (w/2)=a){
      |      ~~~~~~~~~^~~~~~~~
Language: C++

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    int h=in(),w=in(),a=in(),b=in(),lw[w]=0,lh,num[h][w];
    for (int i=0;i<h;i++){
        lh=0;
        for (int i2=0;i2<w;i2++){
            if (lh<a && lw[i2]<b) {
                num[i][i2]=1;
                lh++;
                lw[i]++;
            }
            else{
                num[i][i2]=0;
            }
        }
    }
    for (int i=0;i<w;i++){
        if (lw[i2]!=b){
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i=0;i<h;i++){
        cout << num[i][0];
        for (int i2=1;i2<w;i2++){
           cout << ' ' << num[i][i2];
        }
        cout << endl;
    }
}

Compiler output:
a.cc:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:51:43: error: array must be initialized with a brace-enclosed initializer
   51 |     int h=in(),w=in(),a=in(),b=in(),lw[w]=0,lh,num[h][w];
      |                                           ^
a.cc:66:16: error: 'i2' was not declared in this scope; did you mean 'i'?
   66 |         if (lw[i2]!=b){
      |                ^~
      |                i
Language: C++

// #include <bits/stdc++.h>
#include <iostream>

using namespace std;

int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	int ans[h][w];
	memset(ans,0,sizeof(ans));
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			ans[i][j]=1;
		}
	}
	for(int i=a;i<h;i++){
		for(int j=b;j<w;j++){
			ans[i][j]=1;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<ans[i][j]<<" ";
		}
		cout<<"\n";
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'memset' was not declared in this scope
   10 |         memset(ans,0,sizeof(ans));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <iostream>
  +++ |+#include <cstring>
    3 |
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int N,H,W,M,K,A,B,C,ans=0,cnt=0;
string S,T;
vector<int> P,Q;
vector<pair<int,int>> PP;
bool CAN=false;


int main(){
  cin>>H>>W>>A>>B;
  int L[H][W];
  
  REP(i,H){
    REP(j,W) L[i][j]=0;
  }
  
  if(A*H==B*W || A==0 || B==0){
    
    int k=0;
    
    for(int i=0; i<H; ++i){
      for(int j=0; j<A; ++j){
        if(j+k<W) L[i][j+k]=1;
        else L[i][j+k-W]=1;
      }
      k++;
      if(k>=W) k-=W;
    }
    
    REP(i,H){
      REP(j,W){
        cout<<L[i][j];
      }
      cout<<endl;
    }
  }
  else{
    cout<"No"<<endl;
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:14: error: invalid operands of types 'const char [3]' and '<unresolved overloaded function type>' to binary 'operator<<'
   57 |     cout<"No"<<endl;
      |          ~~~~^~~~~~
Language: C++

#include"bits/stdc++.h"

using namespace std; 

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


void Main()
{
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    REP(i,h){
        REP(j,w){
            if(j!=0){
                cout << " ";
            }
            cout << 1;
        }
        cout << endl;
    } 
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

H,W,A,B=gets.split.map(&:to_i)
cnt="No"
cnt=1 if H==W && A==1 && B==1
cnt=2 if A==0
cnt=3 if B==0
cnt=4 if A==0 && B==0


if cnt=="No"
    puts "No"
    exit
end

if cnt==1
    H.times do |i|
        s="0"*W
        s[i]="1"
        puts s
    end
elsif cnt==3
    H.times do
        puts "1"*A+"0"*(W-A)
    end
elsif cnt==2
    B.times do
        puts "1"*W
    end
    (H-B).times do
        puts "0"*W
    end
elsif cnt==4
    H.times do
        puts "1"*W
    end
end


Compiler output:
a.cc:1:1: error: 'H' does not name a type
    1 | H,W,A,B=gets.split.map(&:to_i)
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int c[1005][1005];
int n, m, a, b;
int main(){
	scanf("%d%d%d%d", &n, &m, &a, &b);
	if(a == 0 && b == 0){
		puts("-1");
		return 0;
	}
	int Flag = 1;
	if(a < b){
		swap(n, m);
		swap(a, b);
		Flag = 0;
	}
	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			if((i + j) % (m / a) == (m / a) - 1)c[i][j] = 1;
		}
	}
	int flag = 1;
	for(int i = 1; i <= n; i ++){
		int cnt = 0;
		for(int j = 1; j <= m; j ++){
			cnt += c[i][j];
		}
		cnt = min(cnt, m - cnt);
		if(cnt != a){
			flag = -1;
		}
	}
	
	for(int i = 1; i <= m; i ++){
		int cnt = 0;
		for(int j = 1; j <= n; j ++){
			cnt += c[j][i];
		}
		cnt = min(cnt, n - cnt);22
		if(cnt != b){
			flag = -1;
		}
	}
	if(flag == 1){
		if(Flag){
			
		for(int i = 1; i <= n; i ++){
			for(int j = 1; j <= m; j ++){
				printf("%d", c[i][j]);
			}
		printf("\n");
		}
		}else{
			for(int i = 1; i <= m; i ++){
			for(int j = 1; j <= n; j ++){
				printf("%d", c[j][i]);
			}
		printf("\n");
		}
		
		}
	}else puts("-1");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:43: error: expected ';' before 'if'
   41 |                 cnt = min(cnt, n - cnt);22
      |                                           ^
      |                                           ;
   42 |                 if(cnt != b){
      |                 ~~
Language: C

#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int k = 0;
	REP(i, h) {
		if (i >= h - b)
			k = 1;
		REP(j, w) {
			if (j >= w - a)
				cout << k << ' ';
			else
				cout << (!k) << ' ';
		}
		cout << '\n';
	}
}

Compiler output:
main.c:1:9: fatal error: algorithm: No such file or directory
    1 | #include<algorithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  if(h==0&&w==0)
    cout<<
  
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:115:3: error: expected primary-expression before '}' token
  115 |   }
      |   ^
Language: C

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int k = 0;
	REP(i, h) {
		if (i >= h - b)
			k = 1;
		REP(j, w) {
			if (j >= w - a)
				cout << k << ' ';
			else
				cout << (!k) << ' ';
		}
		cout << '\n';
	}
}

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

//g++ main.cpp -I /usr/local/include/ac-library
#include<cmath>
//#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
//using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define mod 1000000007
//#define mint=modint1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

int main(){
    cin>>N>>K;
    ll ans = N - K + 1;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll last = a[0], lid = 0;
    vector<bool> so(N,false);
    reps(i,1,N){
        if(last > a[i]){
            lid = i;
        }else if(i - K + 1 >= lid){
                so[i - K + 1] = true;
        }
        last = a[i];
    }
    set<ll> sub;
    reps(i,1,K) sub.insert(a[i]);
    reps(i,K,N){
        if((*sub.begin() > a[i-K]) && (sub.lower_bound(a[i]) == sub.end()) && (!so[i-K])){
            --ans;
        }
        sub.erase(a[i-K+1]);
        if(i != N-1) sub.insert(a[i]);
    }
    bool first = true;
    rep(i,N) {
        if(so[i]){
            if(first) first = false;
            else --ans;
        }
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:10: error: 'N' was not declared in this scope
   39 |     cin>>N>>K;
      |          ^
a.cc:39:13: error: 'K' was not declared in this scope
   39 |     cin>>N>>K;
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 998244353;

int main() {
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	UnionFind uf(n - k + 1);
	
	// もともと昇順な範囲を尺取りで連結
	int r = 1, sorted = -1;
	for (int l = 0; l + k-1 < n;) {
		while (r < n && a[r] > a[r - 1]) {
			++r;
			if (r - l >= k) {
				if(sorted!=-1) uf.merge(sorted, r - k);
				else sorted = l;
			}
		}
		l = r;
		++r;
	}

	// Setでi, i+1がequivalentか判定
	set<ll> se;
	for (int i = 0; i < k; ++i)	se.insert(a[i]);

	for (int l = 0; l + k < n; ++l) {
		ll kl = a[l]; // iの範囲の左端
		ll kr = a[l + k]; // i+1の範囲の右端
		se.erase(kl);
		ll m = *se.begin(); // 共通部分の最小値
		ll M = *se.rbegin(); // 共通部分の最大値
		if (kl < m && M < kr) uf.merge(l, l + 1);
		se.insert(kr);
	}

	// 連結成分を数える
	ll ans = 0;
	for (int i = 0; i < n - k + 1; ++i) {
		if (uf.par[i] == -1) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'UnionFind' was not declared in this scope
   19 |         UnionFind uf(n - k + 1);
      |         ^~~~~~~~~
a.cc:27:48: error: 'uf' was not declared in this scope
   27 |                                 if(sorted!=-1) uf.merge(sorted, r - k);
      |                                                ^~
a.cc:45:39: error: 'uf' was not declared in this scope
   45 |                 if (kl < m && M < kr) uf.merge(l, l + 1);
      |                                       ^~
a.cc:52:21: error: 'uf' was not declared in this scope
   52 |                 if (uf.par[i] == -1) ++ans;
      |                     ^~
Language: C++

#include <iostream>

using namespace std;

#define rend ___rend

const int MAX_N = 1 << 18;

pair<int, int> tree [2 * MAX_N];
int lend [2 * MAX_N];
int rend [2 * MAX_N];

pair<int, int> mnmx (pair<int, int> p, pair<int, int> q) {
  return {min(p.first, q.first), max(p.second, q.second)};
}

pair<int, int> query (int ql, int qr, int u = 1) {
  ql = max(ql, lend[u]);
  qr = min(qr, rend[u]);

  if (ql > qr) return make_pair(MAX_N, -1);
  if (ql == lend[u] && qr == rend[u]) return tree[u];
  return mnmx(query(ql, qr, 2 * u), query(ql, qr, 2 * u + 1));
}

void update (int u) {
  if (u == 0) return;
  tree[u] = mnmx(tree[2 * u], tree[2 * u + 1]);
  update(u / 2);
}

void set_val (int idx, pair<int, int> pr) {
  tree[MAX_N + idx] = pr;
  update((MAX_N + idx) / 2);
}

int perm [MAX_N];
int grp [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  for (int i = MAX_N; i < 2 * MAX_N; i++) {
    lend[i] = i - MAX_N;
    rend[i] = i - MAX_N;
  }

  for (int i = MAX_N - 1; i > 0; i--) {
    lend[i] = lend[2 * i];
    rend[i] = rend[2 * i + 1];
  }
  
  int n, k;
  cin >> n >> k;

  for (int i = 0; i < n; i++) {
    cin >> perm[i];
    set_val(i, {perm[i], perm[i]});
    if (i == 0 || perm[i] < perm[i - 1]) {
      grp[i] = i;
    } else {
      grp[i] = grp[i - 1];
    }
  }

  int seen_s = 0;
  set<pair<int, int>> merges;
  int ans = 0;
  for (int i = 0; i + k - 1 < n; i++) {
    if (grp[i] == grp[i + k - 1]) {
      if (!seen_s) ans++;
      seen_s = 1;
    } else {
      pair<int, int> ms = query(i, i + k - 1);
      int mn = ms.first;
      int mx = ms.second;

      bool ok = 1;
      if (i != 0 && grp[i - 1] == grp[i] && grp[i - 1] > mn) ok = 0;
      if (i + k - 1 != n - 1 && grp[i + k] == grp[i + k - 1] && grp[i + k] < mx) ok = 0;

      if (ok && merges.count(make_pair(grp[i], grp[i + k - 1])) == 0) {
        ans++;
      }

      if (ok) {
        merges.insert(make_pair(grp[i], grp[i + k - 1]));
      }
    }
  }

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:67:3: error: 'set' was not declared in this scope
   67 |   set<pair<int, int>> merges;
      |   ^~~
a.cc:2:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    1 | #include <iostream>
  +++ |+#include <set>
    2 | 
a.cc:67:20: error: expected primary-expression before '>' token
   67 |   set<pair<int, int>> merges;
      |                    ^~
a.cc:67:23: error: 'merges' was not declared in this scope
   67 |   set<pair<int, int>> merges;
      |                       ^~~~~~
Language: Java

import java.util.*;
public class Main{
  public static void main(String[]a){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int[] p=new int[n];
    for(int i=0;i<n;i++){
      p[i]=sc.nextInt();
    }
    TreeSet<Integer> s=new TreeSet<>();
    for(int i=0;i<k;i++){
      s.add(p[i]);
    }
    int a=1;
    for(int i=0;i+k<n;i++){
      if(!(p[i]==s.first() && p[i+k]>s.last())){
        a++;
      }
      s.remove(p[i]);
      s.add(p[i+k]);
    }
    System.out.println(a);
  }
}

Compiler output:
Main.java:15: error: variable a is already defined in method main(String[])
    int a=1;
        ^
1 error
Language: C++

#include<bits/stdc++.h>

using namespace std;

class UF {
public:
    vector<int> p;
    UF(size_t n) : p(n) {
        for(size_t i=0; i<n; i++)
            p[i] = i;
    };
    int find(int x) {
        if(p[x] == x) return x;
        return p[x] = find(p[x]);
    };
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        p[x] = y;
    };
};

template<typename T>
struct SparseTable {
    using F = function<T(T,T)>;

    F f;
    vector<vector<T>> st;
    
    SparseTable(const vector<T> &v, const F &f_) : f(f_) {
        size_t b = 0;
        while(((size_t)1 << b) <= v.size()) b++;
        st.assign(b, vector<T>(1<<b));
        copy_n(v.begin(), v.size(), st[0].begin());

        for(size_t i=1; i<b; i++)
            for(int j=0; j+(1<<(i-1)) + (1<<(i-1)) < (1<<b); j++)
                st[i][j] = f(st[i-1][j], st[i-1][j + (1<<(i-1))]);
    }

    // [l, r)
    inline T query(size_t l, size_t r) const {
        size_t b = 0;

        while(((size_t)1 << b) <= (r - l)) b++;
        b--;

        return f(st[b][l], st[b][r - (1<<b)]);
    }
};


int main(void) {
    long n, k;
    cin >> n >> k;
    vector<long> p(n);
    for(auto &e: p) cin >> e;

    SparseTable<long> mi(p, [&](long a, long b){return min(a, b);});
    SparseTable<long> ma(p, [&](long a, long b){return max(a, b);});
    UF uf(n+1);

    vector<long> mas(n); // i..mas[i] is sorted
    for(int i=0; i<n; i++) {
        int j = i;
        for(; j+1<n; j++)
            if(p[j] > p[j+1]) break;
        // p[j-1] < p[j] && p[j] > p[j+1]
        for(int k=i; k<=j; k++)
            mas[k] = j;
        i = j;
    }

    auto f = [&](long i, long j) -> bool {
        // i..j-1 sorted
        if(mas[i] < j-1) return false;
        if(mas[i+k] < j+k-1) return false;

        long M = ma.query(i, j);
        long m = mi.query(i+k, j+k);

        if(ma.query(j, i+k) > m) return false;
        if(mi.query(j, i+k) < M) return false;

        return true;
    };

    for(long l=0; l+k-1<n; l++) {
        long ok=l, ng=min(n-k+1, l+k);
        while(ng - ok > 1) {
            long m = (ok + ng)/2;

            (f(l, m) ? ok : ng) = m;
        }
        for(int i=l; i+1<=ok; i++)
            uf.unite(i, i+1);
        l = ok;
    }

    {
        vector<long> scnt(n);
        for(int i=0; i<=n-k; i++)
            if(mas[i] >= i+k-1)
                uf.unite(i, n1);
    }

    long r = 0;
    {
        set<int> s;
        for(int i=0; i<=n-k; i++) {
            int t = uf.find(i);
            if(s.count(t)) continue;
            s.insert(t);
            r++;
        }
    }
    cout << r << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:104:29: error: 'n1' was not declared in this scope; did you mean 'n'?
  104 |                 uf.unite(i, n1);
      |                             ^~
      |                             n
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[210000];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int go[210000];
	go[0]=0;
	int ans=0;
	for(int i=1;i<n;++I)
	{
		if(a[i]>a[i-1])
		{
			go[i]=go[i-1]+1;
		}
		else
		{
			go[i]=0;
		}
		if(go[i]>=k-1)
		{
			ans=1;
		}
	}
	set<int> ss;
	for(int i=0;i<n;i++)
	{
		ss.insert(a[i]);
	}
	if(go[k-1]!=k-1)
	{
		ans++;
	}
	for(int i=k;i<n;i++)
	{
		ss.insert(a[i]);
		if(*ss.begin()!=a[i-k]||*ss.rbegin()!=a[i])
		{
			if(go[i]<k-1)
			{
				ans++;
			}
		}
		ss.erase(a[i-k]); 
	}
	cout<<ans;
	return 0;	
}

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

#include<bits/stdc++.h>
using namespace std;
int n,k,a[1000005];
int mx[1000005][36],mi[1000005][36];
int d[1000005];
inline int Max(int x,int y)
{
	int l=(int)log2(y-x+1);
	return max(mx[x][l],mx[y-(1<<l)+1][l]);
}
inline int Min(int x,int y)
{
	int l=(int)log2(y-x+1);
	return min(mi[x][l],mi[y-(1<<l)+1][l]);
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;)
	{
		int x1=i;
		while(a[x1+1]>a[x1])
			x1++;
		while(i<=x1)
			d[i++]=x1;
	}
	for(int i=1;i<=n;i++)
		mx[i][0]=mi[i][0]=a[i];
    for(int l=1;(1<<l)<=n;l++)
        for(int i=1;i+(1<<l)-1<=n;i++)
			mi[i][l]=min(mi[i][l-1],mi[i+(1<<(l-1))][l-1]),
            mx[i][l]=max(mx[i][l-1],mx[i+(1<<(l-1))][l-1]);
	int ans=1;
	bool f1=0;
	if(d[i]>=k)
		f1=1;
	for(int i=2;i+k-1<=n;i++)
	{
		if((Max(i,i+k-2)<a[i+k-1]&&Min(i,i+k-2)>a[i-1]))
			continue;
		if(d[i]>=i+k-1)
		{
			if(f1)
				continue;
			f1=1;
		}
		ans++;
	}
	printf("%d",ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:14: error: 'i' was not declared in this scope
   37 |         if(d[i]>=k)
      |              ^
Language: C++

#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int P[N];
  for(int i=0;i<N;i++)cin>>P[i];
  set<int> s;
   for(int i=0;i<k;i++)s.insert(P[i]);
  int ans=1;
  for(int i=0;i<N-K;i++) {
    if(P[i]==*s.begin() and P[i+K]>*s.rbegin())ans--;  
    // cerr<<*s.begin()<<" "<<*s.rbegin()<<endl;
    ans++;
    s.erase(P[i]);
    s.insert(P[i+K]);
  }    //相交区间   单调队列 
  int a=0,b=1;
 for(int i=1;i<N;i++)
  {
    if(P[i-1]<P[i])b++;
    else b=1;
    if(b==K)a++;
  }  
  ans-=max(a-1,0);    //不相交区间 
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: 'k' was not declared in this scope
   10 |    for(int i=0;i<k;i++)s.insert(P[i]);
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int SIZE=200000+50;
int a[SIZE],q[SIZE];
//int vis[SIZE];
int minn[SIZE],maxx[SIZE];

int main(){
    int n,k;scanf("%d%d",&n,&k);
    int pre=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(i>1&&a[i]>a[i-1]) 
    }
    int same=0; 
    int l=1,r=0;
    for(int i=1;i<=n;i++){
        while(r>=l && a[q[r]]>=a[i])r--;
        q[++r]=i;
        while(r>=l && q[l]<i-(k-1)+1)l++;
        minn[i]=a[q[l]];
        //if(r-l+1==k-1) vis[i]=1;
    }
    l=1,r=0;
    for(int i=1;i<=n;i++){
        while(r>=l && a[q[r]]<=a[i])r--;
        q[++r]=i;
        while(r>=l && q[l]<i-(k-1)+1)l++;
        maxx[i]=a[q[l]];
    }
    int cnt=0;
    for(int i=k;i<=n-1;i++){
    	if(a[i-k+1]<=minn[i]&&a[i+1]>=maxx[i]) cnt++;
	}
//    for(int i=k;i<=n-1;i++){
//        if(a[i-k+1]<=minn[i]&&a[i+1]>=maxx[i]){
//        	if(vis[i]) same+=2,vis[i+1]=2;
//        	else cnt++;
//		}
//		else if(a[i-k+1]<=minn[i]&&(!a[i+1]>=maxx[i])){
//			if(vis[i]==1) same+=1;
//		}
//		else if((!a[i-k+1]<=minn[i])&&a[i+1]>=maxx[i]){
//			if(vis[i]==1) same+=1,vis[i+1]=2;
//		}
//    }
//    if(same<=1) 
	printf("%d\n",n-k+1-cnt);
//   // cout<<cnt<< ' '<<same<<endl;
//    else printf("%d\n",n-k+1-cnt-same+1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: expected primary-expression before '}' token
   14 |     }
      |     ^
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

template<typename T, class Compare=std::less<T> >
class SlideMin {
    private :
        std::vector<T> data;
        std::deque<int> dq;
    public :
        SlideMin(std::vector<T> a) : data(a) {};
        T get_min();
        int get_min_index();
        void push(int i);
        void pop(int i);
        int size();
};

template<typename T, class Compare>
T get_min() {
    return data.at(dq.front());
}

template<typename T, class Compare>
int get_min_index() {
    return dq.front();
}

template<typename T, class Compare>
void SlideMin<T, Compare>::push(int i) {
    while (!dq.empty() && Compare()(data.at(i), data.at(dq.back()))) {
        dq.pop_back();
    }
    dq.push_back(i);
}

template<typename T, class Compare>
void SlideMin<T, Compare>::pop(int i) {
    if (dq.front() == i) {
        dq.pop_front();
    }
}

template<typename T, class Compare>
int SlideMin<T, Compare>::size() {
    return (int)dq.size();
}

int main() {
    int n = 0, k = 0;
    cin >> n >> k;
    vector<int> p(n);
    for (int i=0; i<n; i++) {
        cin >> p.at(i);
    }
    SlideMin<int> mini(p);
    SlideMin<int, std::greater<int>> maxi(p);
    bool sorted = false;
    int cnt = 0;
    if (mini.size() == k) {
        sorted = true;
    }
    else {
        cnt++;
    }
    for (int i=0; i<n-k; i++) {
        maxi.push(i+k);
        mini.push(i+k);
        int M = maxi.get_min_index, m = mini.get_min_index;
        mini.pop(i);
        maxi.pop(i);
        if (mini.size() == k) {
            sorted = true;
        }
        else if (M != i+k || m != i) {
            cnt++;
        }
    }
    if (sorted) {
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Compiler output:
a.cc: In function 'T get_min()':
a.cc:34:17: error: overloaded function with no contextual type information
   34 |     return data.at(dq.front());
      |                 ^~
a.cc:34:20: error: 'dq' was not declared in this scope
   34 |     return data.at(dq.front());
      |                    ^~
a.cc: In function 'int get_min_index()':
a.cc:39:12: error: 'dq' was not declared in this scope
   39 |     return dq.front();
      |            ^~
a.cc: In function 'int main()':
a.cc:82:22: error: cannot convert 'SlideMin<int, std::greater<int> >::get_min_index' from type 'int (SlideMin<int, std::greater<int> >::)()' to type 'int'
   82 |         int M = maxi.get_min_index, m = mini.get_min_index;
      |                      ^~~~~~~~~~~~~
a.cc:82:46: error: cannot convert 'SlideMin<int>::get_min_index' from type 'int (SlideMin<int>::)()' to type 'int'
   82 |         int M = maxi.get_min_index, m = mini.get_min_index;
      |                                              ^~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

template <typename T, class F = function<T(const T&, const T&)>>
class SparseTable {
 public:
  int n;
  vector<vector<T>> mat;
  F func;

  SparseTable(const vector<T>& a, const F& f) : func(f) {
    n = static_cast<int>(a.size());
    int max_log = 32 - __builtin_clz(n);
    mat.resize(max_log);
    mat[0] = a;
    for (int j = 1; j < max_log; j++) {
      mat[j].resize(n - (1 << j) + 1);
      for (int i = 0; i <= n - (1 << j); i++) {
        mat[j][i] = func(mat[j - 1][i], mat[j - 1][i + (1 << (j - 1))]);
      }
    }
  }

  T get(int from, int to) const {
    assert(0 <= from && from <= to && to <= n - 1);
    int lg = 32 - __builtin_clz(to - from + 1) - 1;
    return func(mat[lg][from], mat[lg][to - (1 << lg) + 1]);
  }
};

int n, k;

int main() {
  cin >> n >> k;
  vector<int> p(n);
  range(i, 0, n) scanf("%d", &p[i]);
  auto fun = [&](int x, int y) {
    return max(x, y);
  };
  auto rev = [&](int x, int y) {
    return min(x, y);
  };
  SparseTable<int> sp(p, rev);
  SparseTable<int> st(p, fun);
  vector<int> to(n);
  husk(i, n - 1, -1) {
    if(i < n - 1 && p[i] < p[i + 1]) to[i] = to[i + 1];
    else to[i] = i;
  }
  int res = 0;
  range(i, 0, n) res |= to[i] >= i + k - 1;
  vector<int> pos;
  range(i, 0, n - k) if(to[i] < i + k - 1) pos.push_back(i);
  if(pos.size() == )
  while(pos.size()) {
    res++;
    int u = pos.back();
    pos.pop_back();
    while(pos.size()) {
      int v = pos.back();
      if(v + k - 1 < u) break;
      int mx = st.get(u, v + k - 1);
      int mn = sp.get(u, v + k - 1);
      if(to[v + k] >= u + k - 1 && to[v] >= u - 1 && p[v + k] > mx && p[u - 1] < mn) {
        pos.pop_back();
      } else break;
    }
  }
  cout << res;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:20: error: expected primary-expression before ')' token
   58 |   if(pos.size() == )
      |                    ^
Language: C++


/// @file ss.cc
/// @brief ss の実装ファイル
/// @author Yusuke Matsunaga (松永 裕介)
///
/// Copyright (C) 2019 Yusuke Matsunaga
/// All rights reserved.


#include <iostream>
#include <vector>


int
main(int argc,
     char** argv)
{
  using namespace std;

  bool debug = false;

  int n, k;
  cin >> n >> k;

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

  if ( debug ) {
    cout << n << " " << k << endl;
    for ( int i = 0; i < n; ++ i ) {
      cout << " " << P[i];
    }
    cout << endl;
  }


  // 最初の K 個を調べる．
  int last_gap = -1;
  int min = P[1];
  int max = P[1];
  for ( int i = 0; i < k - 1; ++ i ) {
    if ( P[i] > P[i + 1] ) {
      last_gap = i;
    }
    if ( min > P[i + 1] ) {
      min = P[i + 1];
    }
    if ( max < P[i + 1] ) {
      max = P[i + 1];
    }
  }

  // とにかく最初のパタンは登録する．
  int num = 1;

  // 原順列と等しいパタンが有った時 true にするフラグ
  bool ident = false;
  if ( last_gap == -1 ) {
    // 先頭の K 個は整列していた．
    ident = true;
  }

  for ( int i = 1; i <= n - k; ++ i ) {
    if ( debug ) {
      cout << endl;
      cout << "i = " << i << ":";
      for ( int j = 0; j < k; ++ j ) {
	cout << " " << P[i + j];
      }
      cout << endl;
    }
    // last_gap を更新する
    if ( P[i + k - 2] > P[i + k - 1] ) {
      last_gap = i + k - 2;
    }

    if ( last_gap < i ) {
      // 対象の区間に変化がない．
      if ( !ident ) {
	ident = true;
	++ num;
      }
    }
    else {
      bool reverse = false;
      if ( debug ) {
	cout << "compare P[" << (i - 1) << ":" << (i + k - 2) << "] and P["
	     << i << ":" << (i + k - 1) << "]" << endl;
	cout << P[i - 1] << " |";
	for ( int j = 0; j < k - 1; ++ j ) {
	  cout << " " << P[i + j];
	}
	cout << " | " << P[i + k - 1] << endl;
      }
      if ( P[i - 1] > max ) {
	reverse = true;
      }
      else if ( P[i + k - 1] < min ) {
	reverse = true;
      }
      if (
      for ( int j = 0; j < k - 1; ++ j ) {
	if ( P[i - 1] > P[i + j] ) {
	  if ( debug ) {
	    cout << "P[" << (i - 1) << "] > P[" << (i + j) << "] new pat" << endl;
	  }
	  reverse = true;
	  break;
	}
	if ( P[i + k - 1] < P[i + k - j - 2] ) {
	  if ( debug ) {
	    cout << "P[" << (i  +  k - 1) << "] < P[" << (i + k - j - 2) << "] new pat" << endl;
	  }
	  reverse = true;
	  break;
	}
      }
      if ( reverse ) {
	++ num;
      }
    }
  }

  cout << num << endl;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:104:7: error: expected primary-expression before 'for'
  104 |       for ( int j = 0; j < k - 1; ++ j ) {
      |       ^~~
a.cc:103:11: error: expected ')' before 'for'
  103 |       if (
      |          ~^
      |           )
  104 |       for ( int j = 0; j < k - 1; ++ j ) {
      |       ~~~  
a.cc:104:24: error: 'j' was not declared in this scope
  104 |       for ( int j = 0; j < k - 1; ++ j ) {
      |                        ^
Language: C++

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    set<int> s;
    vector<int> p(n);
    int inc;
    bool added = false;
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }

        
    int res = 1;
    for (int i = 0; i < k; i++){
        s.insert(p[i]);
        if (i > 0 && p[i] > p[i - 1])
            inc++;
        else inc = 1;
        if (inc >= k)
            added = true;
    }

    for (int i = k; i < n; i++){
        if (p[i] > p[i - 1])
            inc++;
        if (!(p[i] > *s.rbegin() && p[i - k] == *s.begin())){
            if (inc < k || !added)
                res++;
            if (inc >= k)
                added = true;
        }
        s.erase(p[i - k]);
        s.insert(p[i]);
    }
    
    cout << res - max(0, inc_cnt - 1) << "\n";
  
    return 0;
}


//case 1: sorted segment

//case 2: segment overlap (i,  i + k - 1) vs (i + 1, i + k)
    //a[i] = min, a[i + k] = max


Compiler output:
a.cc: In function 'int main()':
a.cc:43:26: error: 'inc_cnt' was not declared in this scope; did you mean 'ino_t'?
   43 |     cout << res - max(0, inc_cnt - 1) << "\n";
      |                          ^~~~~~~
      |                          ino_t
Language: C++

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

const int maxN=(2e5)+5;
pair<int,int> A[4*maxN+5];


void build(int nod,int st,int dr)
{
    if(st==dr) 
    {
        A[nod]=make_pair(v[st],v[st]);
        return;
    }
    
    int mid=(st+dr)>>1;
    
    build(2*nod,st,mid);
    build(2*nod+1,mid+1,dr);
    
    A[nod].first=min(A[2*nod].first,A[2*nod+1].first);
    A[nod].second=max(A[2*nod].second,A[2*nod+1].second);
}

int main()
{
    cin>>n>>k;
    
    for(int i=1;i<=n;i++)
        cin>>v[i];
    
    build(1,1,n);
        
    for(int i=k;i<n;i++)
    {
        int m=querymin(1,1,n,i-k+1,i+1);
        int M=querymax(1,1,n,i-k+1,i+1);
        if(! (m==(i-k+1) && M==(i+1) ) ) sol++;
        
    }
    
    sol++; 
    return 0;
}

Compiler output:
a.cc: In function 'void build(int, int, int)':
a.cc:12:26: error: 'v' was not declared in this scope
   12 |         A[nod]=make_pair(v[st],v[st]);
      |                          ^
a.cc: In function 'int main()':
a.cc:27:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   27 |     cin>>n>>k;
      |          ^
      |          yn
a.cc:27:13: error: 'k' was not declared in this scope
   27 |     cin>>n>>k;
      |             ^
a.cc:30:14: error: 'v' was not declared in this scope
   30 |         cin>>v[i];
      |              ^
a.cc:36:15: error: 'querymin' was not declared in this scope
   36 |         int m=querymin(1,1,n,i-k+1,i+1);
      |               ^~~~~~~~
a.cc:37:15: error: 'querymax' was not declared in this scope
   37 |         int M=querymax(1,1,n,i-k+1,i+1);
      |               ^~~~~~~~
a.cc:38:42: error: 'sol' was not declared in this scope
   38 |         if(! (m==(i-k+1) && M==(i+1) ) ) sol++;
      |                                          ^~~
a.cc:42:5: error: 'sol' was not declared in this scope
   42 |     sol++;
      |     ^~~