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

#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>
#include<unordered_map>
#include<unordered_set>
#include<tuple>
#include<vector>


using namespace std;

unordered_set <int> Good;

const int MAXN = 100000 + 10;
int cnt[MAXN];


const int MAXK = 500;
int board[MAXK][MAXK];

int main() {
	int N;
	cin >> N;
	
	for (int i = 1; i < 5000; i++) {
		Good.insert(i * (i + 1) / 2);
	}

	if (!Good.count(N)) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		int K = (int)sqrt(N * 2) + 1;
		int Q = N * 2 / K;
		int cur = 1;
		for (int i = 0; i < K; i++) {
			cout << Q << " ";
			for (int j = 0; j < i; j++) {
				cout << board[j][i - 1] << " ";
				board[i][j] = board[j][i - 1];
			}

			for (int k = i; k < Q; k++) {
				cout << cur << " ";
				board[i][k] = cur++;
			}
			cout << endl;
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:30: error: 'sqrt' was not declared in this scope
   34 |                 int K = (int)sqrt(N * 2) + 1;
      |                              ^~~~
Language: C++

#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

int N;
ll cache[100000];

int main(){
  cin>>N;
  REP(100000)cache[i]=(i+1)*(i+2);
  N*=2;
  for (int i = 0; cache[i] <= N; i++) {
    if(N==cache[i]){
      cou

Compiler output:
a.cc: In function 'int main()':
a.cc:44:7: error: 'cou' was not declared in this scope; did you mean 'cos'?
   44 |       cou
      |       ^~~
      |       cos
a.cc:44:10: error: expected '}' at end of input
   44 |       cou
      |          ^
a.cc:43:20: note: to match this '{'
   43 |     if(N==cache[i]){
      |                    ^
a.cc:44:10: error: expected '}' at end of input
   44 |       cou
      |          ^
a.cc:42:39: note: to match this '{'
   42 |   for (int i = 0; cache[i] <= N; i++) {
      |                                       ^
a.cc:44:10: error: expected '}' at end of input
   44 |       cou
      |          ^
a.cc:38:11: note: to match this '{'
   38 | int main(){
      |           ^
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    
}#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << 1 << 1 << endl;
        cout << 1 << 1 << endl;
    }
    else if (n == 3) {
        cout << "Yes" << endl;
        cout << 3 << endl;
        cout << 2 << 1 << " " << 2 << endl;
        cout << 2 << 2 << " " << 3 << endl;
        cout << 2 << 3 << " " << 1 << endl;
    }
    else {
        cou << "No" << endl;
    }
}

Compiler output:
a.cc:24:2: error: stray '#' in program
   24 | }#include <algorithm>
      |  ^
a.cc:24:3: error: 'include' does not name a type
   24 | }#include <algorithm>
      |   ^~~~~~~
a.cc:43:4: error: redefinition of 'long long int MOD'
   43 | ll MOD = 1000000007;
      |    ^~~
a.cc:20:4: note: 'long long int MOD' previously defined here
   20 | ll MOD = 1000000007;
      |    ^~~
a.cc:45:5: error: redefinition of 'int main()'
   45 | int main() {
      |     ^~~~
a.cc:22:5: note: 'int main()' previously defined here
   22 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:62:9: error: 'cou' was not declared in this scope; did you mean 'cos'?
   62 |         cou << "No" << endl;
      |         ^~~
      |         cos
Language: C++

# include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2000100;
const int mod = (int)pow(10, 9) + 7;
const ll INF = 10000000100;
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
ll n;
int main() {
	cin >> n;
	cout << (n % 3 == 0 ? "Yes" : "No") << endl;
	return 0;
}

Compiler output:
a.cc:6:22: error: 'pow' was not declared in this scope
    6 | const int mod = (int)pow(10, 9) + 7;
      |                      ^~~
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<stdio.h>
#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<limits.h>
#include<stack>
#include<queue>
#include<set>
//#pragma comment(linker, "/STACK:12822822 ")

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 17;
const ll inf = 9223372036854775807LL;

ll s[500][500];
ll n;
bool used[500];
ll t = 1;

void dfs(ll v, ll co)
{
	used[v] = true;
	forn(i, 0, co)
	{
		if (v == i)
			continue;
		if (s[v][i] == 0)
		{
			s[v][i] = t;
			s[i][v] = t;
			t++;
		}
		if (used[i])
			continue;
		dfs(i, co);
	}
}

void adskaya_drochilna(ll co)
{
	forn(i, 0, co)
	{
		cout << co - 1 << ' ';
		forn(j, 0, co)
		{
			if (i == j)
				continue;
			cout << s[i][j] << ' ';
		}
		cout << endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	/*
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	*/
	cin >> n;
	bool yes = false;
	forn(i, 0, n+1)
	{
		if (i * (i - 1) == 2 * n)
		{
			cout << "Yes" << endl;
			cout << co << endl;
			dfs(1, i);
			adskaya_drochilna(i);
			return 0;
		}
	}

	cout << "No";

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:33: error: 'co' was not declared in this scope
   79 |                         cout << co << endl;
      |                                 ^~
Language: C++

#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}


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++

/*

宣告——
汝身在我之下，托付吾之命运于汝之剑，
遵从圣杯之名，若汝遵从此意志此理，回应吧。
在此起誓，吾是成就世间一切行善之人，吾是肃清世间一切罪恶之人，
被狂乱之槛所囚的囚徒。吾是此锁链的操纵者，
汝为身缠三大言灵之七天，从抑止之轮显现吧，天秤之守护者！

*/
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;
vector<int>s[100010];
int main(){
	n=read();int tmp=n,i,j,cur=0;
	tmp*=2;tmp=(int)sqrt(tmp);
	if(tmp*(tmp+1)!=n*2){puts("No");return 0;}
	puts("Yes");
	for(i=1;i<=tmp;i++){
		for(j=1;j<=i;j++){
			s[i+1].push_back(cur+j);
			s[j].push_back(cur+j);
		}
		cur+=i;
	}
	printf("%d\n",tmp+1);
	for(i=1;i<=tmp+1;i++){
		printf("%d",s[i].size());
		for(auto j:s[i]) printf(" %d",j);
		printf("\n");
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:25: error: 'sqrt' was not declared in this scope
   31 |         tmp*=2;tmp=(int)sqrt(tmp);
      |                         ^~~~
Language: C++

/*

宣告——
汝身在我之下，托付吾之命运于汝之剑，
遵从圣杯之名，若汝遵从此意志此理，回应吧。
在此起誓，吾是成就世间一切行善之人，吾是肃清世间一切罪恶之人，
被狂乱之槛所囚的囚徒。吾是此锁链的操纵者，
汝为身缠三大言灵之七天，从抑止之轮显现吧，天秤之守护者！

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n;
vector<int>s[100010];
int main(){
	n=read();int tmp=n,i,j,cur=0;
	tmp*=2;tmp=(int)sqrt(tmp);
	if(tmp*(tmp+1)!=n*2){puts("No");return 0;}
	puts("Yes");
	for(i=1;i<=tmp;i++){
		for(j=1;j<=i;j++){
			s[i+1].push_back(cur+j);
			s[j].push_back(cur+j);
		}
		cur+=i;
	}
	printf("%d\n",tmp+1);
	for(i=1;i<=tmp+1;i++){
		printf("%d",s[i].size());
		for(auto j:s[i]) printf(" %d",j);
		printf("\n");
	}
}


Compiler output:
a.cc:27:1: error: 'vector' does not name a type
   27 | vector<int>s[100010];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:30:25: error: 'sqrt' was not declared in this scope
   30 |         tmp*=2;tmp=(int)sqrt(tmp);
      |                         ^~~~
a.cc:35:25: error: 's' was not declared in this scope
   35 |                         s[i+1].push_back(cur+j);
      |                         ^
a.cc:42:29: error: 's' was not declared in this scope
   42 |                 printf("%d",s[i].size());
      |                             ^
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

vector <int> a[500];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<500;i++)
    if ((i*(i-1)>>1)==n) {
    	int cnt=0;
    	for(int j=1;j<i;j++)
    	  for(int k=j+1;k<=i;k++) {
    	  	cnt++;
    	  	a[j].push_back(cnt);
    	  	a[k].push_back(cnt);
		  }
		printf("Yes\n%d\n",i);
		for(int j=1;j<=i;j++) {
			printf("%d ",a[j].size());
			for(int k=0;k<a[j].size();k++) printf("%d ",a[j][k]);
			printf("\n");
		}
		return 0;
	}
  puts("No");
  return 0;
}

Compiler output:
a.cc:7:1: error: 'vector' does not name a type
    7 | vector <int> a[500];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:18:17: error: 'a' was not declared in this scope
   18 |                 a[j].push_back(cnt);
      |                 ^
a.cc:23:38: error: 'a' was not declared in this scope
   23 |                         printf("%d ",a[j].size());
      |                                      ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
/*
int a[200000];
signed main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	sort(a,a+n);
	int s=1,g=n-1;
	ll ans=0;
	vector<int>v;
	v.push_back(a[0]);
	for(int i=1;i<n;i++){
		int t;
		if(i%2==1)t=g,g--;
		else t=s,s++;
		ans+=abs(a[t]-v.back());
		v.push_back(a[t]);
	}
	ll ans2=0;
	s=0,g=n-2;
	vector<int>v2;
	v2.push_back(a[n-1]);
	for(int i=1;i<n;i++){
		int t;
		if(i%2==0)t=g,g--;
		else t=s,s++;
		ans2+=abs(a[t]-v2.back());
		v2.push_back(a[t]);
	}
	cout<<max(ans,ans2)<<endl;
}
*/
int b[200000];
int cnt[200000];
signed main(){
	int n;cin>>n;
	int a;
	for(a=1;(1+a)*a/2<n;a++);
	if((1+a)*a/2!=n){
		puts("No");return 0;
	}
	puts("Yes");
	cout<<a+1<<endl;
	for(int i=a+1;i>=1;i--){
		cout<<a<<" ";
		set<int>se;
		int cc=0;
		int j=0;
		while(cc<a){
			if(cnt[j]==2){j++;continue;}
			if(b[j]==0){5
				cout<<j+1<<" ";
				b[j]=i;cc++;
				cnt[j]++;
			}
			else if(!se.count(b[j])){
				se.insert(b[j]);
				cout<<j+1<<" ";
				cc++;
				cnt[j]++;
			}
			j++;
		}
		cout<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:38: error: expected ';' before 'cout'
   59 |                         if(b[j]==0){5
      |                                      ^
      |                                      ;
   60 |                                 cout<<j+1<<" ";
      |                                 ~~~~
Language: C++

45度回転して考えるでもいいはず
ただ、にぶたんを想定していたので計算量にlogが加わって
TLEしそう

Compiler output:
a.cc:2:1: error: extended character 、 is not valid in an identifier
    2 | ただ、にぶたんを想定していたので計算量にlogが加わって
      | ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 45度回転して考えるでもいいはず
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
using vll = V<ll>;
using vvll = V<vll>;

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

ll h, w, res;
vvll a(666, vll(666)), hs(666, vll(666)), vs(666, vll(666));
V<string> s(333);

int main() {
  cin >> h >> w;
  REP(i, h) {
    cin >> s.at(i);
    REP(j, w) if (s.at(i)(j)=='#') a.at(i+j+1)(i-j+300) = 1;
  }
  rep(i,1,600) rep(j,1,600) {
    hs.at(i).at(j) += a.at(i).at(j) + hs.at(i).at(j-1);
    vs.at(i).at(j) += a.at(i).at(j) + vs.at(i-1).at(j);
  }
  rep(i,1,600) rep(j,1,600) rep(k,j+1,600) {
    int d = k-j;
    if (a,at(i).at(j) && a.at(i).at(k)) {
      if (i-d>=0) {
        res += hs.at(i-d).at(k) - hs.at(i-d).at(j-1);
        res -= a.at(i-d).at(j) + a.at(i-d).at(k);
      }
      if (i+d<=600) {
        res += hs.at(i+d).at(k) - hs.at(i+d).at(j-1);
        res -= a.at(i+d).at(j) + a.at(i+d).at(k);
      }
    }
    if (a.at(j).at(i) && a.at(k).at(i)) {
      if (i-d>=0) res += vs.at(k).at(i-d) - vs.at(j-1).at(i-d);
      if (i+d<=600) res += vs.at(k).at(i+d) - vs.at(j-1).at(i+d);
    }
  }
	cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: 'i' was not declared in this scope
   19 |   REP(i, h) {
      |       ^
a.cc:19:3: error: 'REP' was not declared in this scope
   19 |   REP(i, h) {
      |   ^~~
a.cc:23:3: error: 'rep' was not declared in this scope; did you mean 'res'?
   23 |   rep(i,1,600) rep(j,1,600) {
      |   ^~~
      |   res
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
using vll = V<ll>;
using vvll = V<vll>;

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

ll h, w res;
vvll a(666, vll(666)), hs(666, vll(666)), vs(666, vll(666));
V<string> s(333);

int main() {
  cin >> h >> w;
  REP(i, h) {
    cin >> s.at(i);
    REP(j, w) if (s.at(i)(j)=='#') a.at(i+j+1)(i-j+300) = 1;
  }
  rep(i,1,600) rep(j,1,600) {
    hs.at(i).at(j) += a.at(i).at(j) + hs.at(i).at(j-1);
    vs.at(i).at(j) += a.at(i).at(j) + vs.at(i-1).at(j);
  }
  rep(i,1,600) rep(j,1,600) rep(k,j+1,600) {
    int d = k-j;
    if (a,at(i).at(j) && a.at(i).at(k)) {
      if (i-d>=0) {
        res += hs.at(i-d).at(k) - hs.at(i-d).at(j-1);
        res -= a.at(i-d).at(j) + a.at(i-d).at(k);
      }
      if (i+d<=600) {
        res += hs.at(i+d).at(k) - hs.at(i+d).at(j-1);
        res -= a.at(i+d).at(j) + a.at(i+d).at(k);
      }
    }
    if (a.at(j).at(i) && a.at(k).at(i)) {
      if (i-d>=0) res += vs.at(k).at(i-d) - vs.at(j-1).at(i-d);
      if (i+d<=600) res += vs.at(k).at(i+d) - vs.at(j-1).at(i+d);
    }
  }
	cout << res << endl;
}


Compiler output:
a.cc:13:9: error: expected initializer before 'res'
   13 | ll h, w res;
      |         ^~~
a.cc: In function 'int main()':
a.cc:18:15: error: 'w' was not declared in this scope
   18 |   cin >> h >> w;
      |               ^
a.cc:19:7: error: 'i' was not declared in this scope
   19 |   REP(i, h) {
      |       ^
a.cc:19:3: error: 'REP' was not declared in this scope
   19 |   REP(i, h) {
      |   ^~~
a.cc:23:3: error: 'rep' was not declared in this scope
   23 |   rep(i,1,600) rep(j,1,600) {
      |   ^~~
a.cc:44:17: error: 'res' was not declared in this scope
   44 |         cout << res << endl;
      |                 ^~~
Language: C++



def distance(a,b):
	return abs(a[0]-b[0])+abs(a[1]-b[1])


n=0

H,W=input().split()
r=[]
for i in range(H):
	r.append(input().split())
stones=[]
for i in range(H):
	for j in range(W):
		if(r[i][j]=="#"):
			stones.append([j,i])

for i in range(len(stones)):
	for j in range(i,(len(stones)):
		d=distance(stones[i],stones[j])
		for k in range(j,len(stones)):
			if(distance(stones[i],stones[k])==distance(stones[j],stones[k])==d):
				n+=1
print(n)				









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

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

long long sum[2100][2100];

int check(int i, int j, const vector<string> &fi) {
    int n = (int)fi.size();
    int m = (int)fi[0].size();
    if (i < 0 || i >= n || j < 0 || j >= m) return 0;
    if (fi[i][j] == '#') return 1;
    else return 0;
}

long long solve(vector<string> fi) {
    // sum[a][b] := マス (i, j) であって i+j = a, i <= b を満たす範囲内にある黒マスの個数 (斜め累積和)
    memset(sum, 0, sizeof(sum));
    int n = (int)fi.size();
    int m = (int)fi[0].size();
    for (int ij = 0; ij < n+m-1; ++ij) {
        sum[ij][0] = 0;
        for (int i = 0; i < (n+m)*3; ++i) {
            int j = ij - i;
            int add = 0;
            if (i >= 0 && i < n && j >= 0 && j < m && fi[i][j] == '#') add = 1;
            sum[ij][i+1] = sum[ij][i] + add;
        }
    }
    
    long long res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (fi[i][j] != '#') continue;
            for (int k = 1; k < n+m; ++k) {
                int i2 = i + k;
                int j2 = j - k;
                if (i2 < 0 || i2 >= n || j2 < 0 || j2 >= m) continue;
                if (fi[i2][j2] != '#') continue;
                
                // 対辺が左上方向にあるもの
                {
                    int ij = i+j - k*2;
                    if (ij >= 0) {
                        if (check(i-k, j-k, fi)) ++res; // 直角二等辺三角形
                        if (check(i, j-k*2, fi)) ++res; // 直角二等辺三角形
                        
                        int a = max(i-k+1, 0);
                        int b = max(i, 0);
                        if (a <= b) res += (sum[ij][b] - sum[ij][a]) * 2; // それ以外
                    }
                }
                
                // 対辺が右下方向にあるもの
                {
                    int ij = i+j + k*2;
                    if (ij <= n+m-2) {
                        if (check(i+k, j+k, fi)) ++res; // 直角二等辺三角形
                        if (check(i+k*2, j, fi)) ++res; // 直角二等辺三角形
                        
                        int a = i+k+1;
                        int b = i+k*2;
                        res += (sum[ij][b] - sum[ij][a]) * 2; // それ以外
                    }
                }
            }
        }
    }
    return res;
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> input(H);
    for (int i = 0; i < H; ++i) cin >> input[i];
        
    long long res = 0;
    res += solve(input);

    // 盤面を左右反転
    for (int i = 0; i < H; ++i) reverse(input[i].begin(), input[i].end());
    res += solve(input);
        
    cout << res / 2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:33: error: 'reverse' was not declared in this scope
   82 |     for (int i = 0; i < H; ++i) reverse(input[i].begin(), input[i].end());
      |                                 ^~~~~~~
Language: C++

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

long long sum[2100][2100];

int check(int i, int j, const vector<string> &fi) {
    int n = (int)fi.size();
    int m = (int)fi[0].size();
    if (i < 0 || i >= n || j < 0 || j >= m) return 0;
    if (fi[i][j] == '#') return 1;
    else return 0;
}

long long solve(vector<string> fi) {
    // sum[a][b] := マス (i, j) であって i+j = a, i <= b を満たす範囲内にある黒マスの個数 (斜め累積和)
    memset(sum, 0, sizeof(sum));
    int n = (int)fi.size();
    int m = (int)fi[0].size();
    for (int ij = 0; ij < n+m-1; ++ij) {
        sum[ij][0] = 0;
        for (int i = 0; i < (n+m)*3; ++i) {
            int j = ij - i;
            int add = 0;
            if (i >= 0 && i < n && j >= 0 && j < m && fi[i][j] == '#') add = 1;
            sum[ij][i+1] = sum[ij][i] + add;
        }
    }
    
    long long res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (fi[i][j] != '#') continue;
            for (int k = 1; k < n+m; ++k) {
                int i2 = i + k;
                int j2 = j - k;
                if (i2 < 0 || i2 >= n || j2 < 0 || j2 >= m) continue;
                if (fi[i2][j2] != '#') continue;
                
                // 対辺が左上方向にあるもの
                {
                    int ij = i+j - k*2;
                    if (ij >= 0) {
                        if (check(i-k, j-k, fi)) ++res; // 直角二等辺三角形
                        if (check(i, j-k*2, fi)) ++res; // 直角二等辺三角形
                        
                        int a = max(i-k+1, 0);
                        int b = max(i, 0);
                        if (a <= b) res += (sum[ij][b] - sum[ij][a]) * 2; // それ以外
                    }
                }
                
                // 対辺が右下方向にあるもの
                {
                    int ij = i+j + k*2;
                    if (ij <= n+m-2) {
                        if (check(i+k, j+k, fi)) ++res; // 直角二等辺三角形
                        if (check(i+k*2, j, fi)) ++res; // 直角二等辺三角形
                        
                        int a = i+k+1;
                        int b = i+k*2;
                        res += (sum[ij][b] - sum[ij][a]) * 2; // それ以外
                    }
                }
            }
        }
    }
    return res;
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> input(H);
    for (int i = 0; i < H; ++i) cin >> input[i];
        
    long long res = 0;
    res += solve(input);

    // 盤面を左右反転
    for (int i = 0; i < H; ++i) reverse(input[i].begin(), input[i].end());
    res += solve(input);
        
    cout << res / 2 << endl;
}
















Compiler output:
a.cc:3:10: fatal error: cstrign: No such file or directory
    3 | #include <cstrign>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

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

using namespace std;
char Map[305][305];
int main()
{
    int N,M,ans=0,i,j,k,x,y;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++)
    {
        gets(Map[i]);
    }
    for(i=0;i<N;i++)
    {
        for(j=0;j<M;j++)
        {

            for(k=1;i+k<N||i-k>=0||j+k<M||j-k>=0;k++)
            {
                if(i-k>=0&&j-k>=0&&Map[i-k][j]=='#'&&Map[i][j-k]=='#')
                {
                    if(j+k<M&&Map[i][j+k]=='#') ans++;
                    if(i+k<N&&Map[i+k][j]=='#') ans++;
                    for(y=min(M-1,j+k-1),x=i+j+k-y;x<i+k;x++,y--)
                    {
                        if(x>=N||y<0) break;


                        if(Map[x][y]=='#')
                        {
                            ans++;
                            //printf("a %d %d %d %d %d %d\n",i+k,j,i,j+k,x,y);
                        }



                    }
                }


                if(j+k<M&&i-k>=0&&Map[i-k][j]=='#'&&Map[i][j+k]=='#')
                {
                    for(y=max(0,j-k+1),x=i-j+k+y;x<i+k;x++,y++)
                    {
                        if(x>=N||y>=M) break;


                        if(Map[x][y]=='#')
                        {
                            ans++;
                            //printf("a %d %d %d %d %d %d\n",i+k,j,i,j+k,x,y);
                        }


                    }
                }

                if(i+k<N&&j-k>=0&&Map[i+k][j]=='#'&&Map[i][j-k]=='#')
                {

                    for(x=max(0,i-k+1),y=j-i+k+x;x<i;x++,y++)
                    {
                        if(x>=N||y>=M) break;


                        if(Map[x][y]=='#')
                        {
                            ans++;
                            //printf("a %d %d %d %d %d %d\n",i+k,j,i,j+k,x,y);
                        }


                    }
                }


                if(i+k<N&&j+k<M&&Map[i+k][j]=='#'&&Map[i][j+k]=='#')
                {
                    if(j-k>=0&&Map[i][j-k]=='#') ans++;
                    if(i-k>=0&&Map[i-k][j]=='#') ans++;
                    for(x=max(i-k+1,0),y=j+i-k-x;x<i;x++,y--)
                    {
                        if(x>=N||y<0) break;


                        if(Map[x][y]=='#')
                        {
                            ans++;
                            //printf("a %d %d %d %d %d %d\n",i+k,j,i,j+k,x,y);
                        }


                    }
                }


            }

        }
    }


    printf("%d\n",ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   13 |         gets(Map[i]);
      |         ^~~~
      |         getw
Language: C++

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


signed main(){
    int H,W;
    cin >> H >>W;
    int a[H+W-1][H+W-1];
    for(int i=0;i<H+W-1;i++){
        for(int j=0;j<H+W-1;j++){
            a[i][j]=0;
        }
    }
    char y;
    for(int i =0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >>y;
            if(y =="#"){
                a[i+j][i-j+W-1]=1;
            }
        }
    }
    int k =0;
    for(int i =0;i<(H+W-1)*2;i++){
        for (int j =0;j<=i;j++){
            if(a[j][i-j]==1){
                for(int r =2;j+r<(H+W-1)&&i-j+r<H+W-1;j+=2){
                    if(a[j+r][i-j]==1&& j[j+r][i-j+r]==1){
                        k +=1;
                    }
                    if(a[j][i-j+r]==1&& j[j+r][i-j+r]==1){
                        k +=1;
                    }
                }
                
            }
        }
    }
    cout << k;
  

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   18 |             if(y =="#"){
      |                ~~^~~~~
a.cc:28:42: error: invalid types 'int[int]' for array subscript
   28 |                     if(a[j+r][i-j]==1&& j[j+r][i-j+r]==1){
      |                                          ^
a.cc:31:42: error: invalid types 'int[int]' for array subscript
   31 |                     if(a[j][i-j+r]==1&& j[j+r][i-j+r]==1){
      |                                          ^
Language: C++

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


signed main(){
    int H,W;
    cin >> H >>W;
    int a[H+W-1][H+W-1];
    for(int i=0;i<H+W-1;i++){
        for(int j=0;j<H+W-1;j++){
            a[i][j]=0;
        }
    }
    char y;
    for(int i =0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >>y;
            if(y ="#"){
                a[i+j][i-j+W-1]=1;
            }
        }
    }
    int k =0;
    for(int i =0;i<(H+W-1)*2;i++){
        for (j =0;j<=i;j++){
            if(a[j][i-j]==1){
                for(int r =2;j+r<(H+W-1)&&i-j+r<H+W-1;j+=2){
                    if(a[j+r][i-j]==1&& j[j+r][i-j+r]==1){
                        k +=1;
                    }
                    if(a[j][i-j+r]==1&& j[j+r][i-j+r]==1){
                        k +=1;
                    }
                }
                
            }
        }
    }
    cout << k;
  

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:19: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   18 |             if(y ="#"){
      |                   ^~~
      |                   |
      |                   const char*
a.cc:25:14: error: 'j' was not declared in this scope
   25 |         for (j =0;j<=i;j++){
      |              ^
Language: C++

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


signed main(){
    int H,W;
    cin >> H >>W;
    int a[H+W-1][H+W-1];
    for(int i=0;i<H+W-1;i++){
        for(int j=0;j<H+W-1;j++){
            a[i][j]=0;
        }
    }
    char k;
    for(int i =0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >>k;
            if(k ="#"){
                a[i+j][i-j+W-1]=1;
            }
        }
    }
    int k =0;
    for(int i =0;i<(H+W-1)*2;i++){
        for (j =0;j<=i;j++){
            if(a[j][i-j]==1){
                for(int r =2;j+r<(H+W-1)&&i-j+r<H+W-1;j+=2){
                    if(a[j+r][i-j]==1&& j[j+r][i-j+r]==1){
                        k +=1;
                    }
                    if(a[j][i-j+r]==1&& j[j+r][i-j+r]==1){
                        k +=1;
                    }
                }
                
            }
        }
    }
    cout << k;
  

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:19: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   18 |             if(k ="#"){
      |                   ^~~
      |                   |
      |                   const char*
a.cc:23:9: error: conflicting declaration 'int k'
   23 |     int k =0;
      |         ^
a.cc:14:10: note: previous declaration as 'char k'
   14 |     char k;
      |          ^
a.cc:25:14: error: 'j' was not declared in this scope
   25 |         for (j =0;j<=i;j++){
      |              ^
Language: C++

//E
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int H,W;
string s[300];
vector<pair<int,int>> coin;

int d(int x1, int x2, int y1, int y2){
    return abs(x1 - x2) + abs(y1 - y2);
}

int main(){
    
    cin >> H >> W;
    for(int i=0; i<H; i++){
        cin >> s[i];
        for(int j=0; j<W; j++){
            if(s[i][j] == '#') coin.push_back(make_pair(i,j));
        }
    }

    LL ans = 0;
    for(int i=0; i<coin.size(); i++){
        for(int j=i+1; j<coin.size(); j++){
            int dis = d(coin[i].first, coin[j].first, coin[i].second, coin[j].second);
            if(coin[i].second - coin[j].second < 0){
                int h = coin[i].first;
                int w = coin[i].second - (coin[i].second - coin[j].second);
                if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
                while(h < coin[j].first){
                    h++;
                    w++;
                    if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
                }
            }
            else{
                int h = coin[i].first;
                int w = coin[i].second + (coin[i].second - coin[j].second);
                if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
                while(h < coin[j].first){
                    h++;
                    w--;
                    if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
                }
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:59: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   53 |                 if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
a.cc:57:63: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   57 |                     if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
a.cc:63:59: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   63 |                 if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
a.cc:67:63: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   67 |                     if(d(h, coin[j].first, w, coin[j].second) == d && s[h][w]=='#') ans++;
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
Language: C++

 #include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;
 int H,W;

mh(int a,int b, int c, int d){
	return abs(a-c)+abs(b-d);
}
in(int a,int b){
	return ((0<=a&&a<H)&&(0<=b&&b<W));
}

int main(){
	int h,w;
	cin>>h>>w;
	H=h,W=w;
	vector<vector<int>> b=vector<vector<int>>(h+1,vector<int>(w+1,0));
	FOR(i,0,h){
		FOR(j,0,w){
			char c;
			cin>>c;
			if(c=='#')b[i][j]=1;
		}
	}
	LL ans=0;
	FOR(i,0,h){
		FOR(j,0,w){
			FOR(k,1,300){
				int f=0;
				FOR(t,0,4){
					int x[2]={},y[2]={};
					if(t==0){
						x[0]=i+2*k;
						y[0]=j;
						x[1]=i+1*k;
						y[1]=j+1*k;
					}
					if(t==1){
						x[0]=i+2*k;
						y[0]=j;
						x[1]=i+1*k;
						y[1]=j-1*k;
					}
					if(t==2){
						x[0]=i+1*k;
						y[0]=j+1*k;
						x[1]=i+1*k;
						y[1]=j-1*k;
					}
					if(t==3){
						x[0]=i+1*k;
						y[0]=j+1*k;
						x[1]=i;
						y[1]=j+2*k;
					}
					int f2=1;
					FOR(ii,0,2){
						if(!in(x[ii],y[ii])||b[x[ii]][y[ii]]==0)f2=0;
					}
					if(f2==0)continue;
					//cerr<<i<<" "<<j<<" "<<k<<" "<<t<<" "<<endl;
					ans++;
					f++;
				}

				if(f==0)break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:42:1: error: ISO C++ forbids declaration of 'mh' with no type [-fpermissive]
   42 | mh(int a,int b, int c, int d){
      | ^~
a.cc:45:1: error: ISO C++ forbids declaration of 'in' with no type [-fpermissive]
   45 | in(int a,int b){
      | ^~
Language: C++


 #include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;
 int H,W;

mh(int a,int b, int c, int d){
	return abs(a-c)+abs(b-d);
}
in(int a,int b){
	return ((0<=a&&a<H)&&(0<=b&&b<W));
}

int main(){
	int h,w;
	cin>>h>>w;
	H=h,W=w;
	vector<vector<int>> b=vector<vector<int>>(h+1,vector<int>(w+1,0));
	FOR(i,0,h){
		FOR(j,0,w){
			char c;
			cin>>c;
			if(c=='#')b[i][j]=1;
		}
	}
	LL ans=0;
	FOR(i,0,h){
		FOR(j,0,w){
			FOR(k,1,300){
				int f=0;
				FOR(t,0,4){
					int x[2]={},y[2]={};
					if(t==0){
						x[0]=i+2*k;
						y[0]=j;
						x[1]=i+1*k;
						y[1]=j+1*k;
					}
					if(t==1){
						x[0]=i+2*k;
						y[0]=j;
						x[1]=i+1*k;
						y[1]=j-1*k;
					}
					if(t==2){
						x[0]=i+1*k;
						y[0]=j+1*k;
						x[1]=i+1*k;
						y[1]=j-1*k;
					}
					if(t==3){
						x[0]=i+1*k;
						y[0]=j+1*k;
						x[1]=i;
						y[1]=j+2*k;
					}
					int f2=1;
					FOR(ii,0,2){
						if(!in(x[ii],y[ii])||b[x[ii]][y[ii]]==0)f2=0;
					}
					if(f2==0)continue;
					//cerr<<i<<" "<<j<<" "<<k<<" "<<t<<" "<<endl;
					ans++;
					f++;
				}

				if(f==0)break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc:43:1: error: ISO C++ forbids declaration of 'mh' with no type [-fpermissive]
   43 | mh(int a,int b, int c, int d){
      | ^~
a.cc:46:1: error: ISO C++ forbids declaration of 'in' with no type [-fpermissive]
   46 | in(int a,int b){
      | ^~
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
signed main() {
	int p = 998244353;
	int n;
	cin >> n;
	vel a(n);
	int x = -1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	vel qun(n);
	vel qko(n,0);
	int si = 0;
	qun[0] = a[0];
	qko[0] = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] != qun[si]) si++;
		qun[si] = a[i];
		qko[si]++;
	}
	if (qun[0] == qun[si] and si!=0) {
		qko[0] += qko[si]; si--;
	}
	vel un(si+1);
	vel ko(si+1);
	vel po(n, -1);
	for (int i = 0; i <= si; i++) {
		un[i] = qun[i];
		ko[i] = qko[i];
		po[un[i]] = i;
	}
	vel mu = un;
	sor(mu);
	int db = 0;
	for (int i = 0; i < si; i++) {
		if (mu[i] == mu[i + 1]) db = 1;
	}
	int mak1 = mu[si];
	if (db == 1) cout << 0 << endl;
	else {
		int ans = 1;
		vel ah(si+1, 0);
		int ex = 0;
		if (po[0] == -1) {
			cout << 0 << endl;
			return 0;
		}
		int mes = ko[po[0]];
		for (int i = 0; i < n; i++) {
			int po1 = po[i];
			if (po1 == -1) {
				ans *= ex;
				ans = ans % p;
				ex--;
			}
			else {
				int ko1 = ko[po1];
				if (ko1 > mes) {
					ans = 0;
				}
				int xx = ah[(po1 + 1) % (si+1)] + ah[(po1 + si) % (si+1)];
				if (xx == 0) {
					if (ko1 == n) {
						ex = n - 1;
						ans *= n;
					}
					if (ko1 != mes) {
						ans = 0;
					}
				}
				if (xx == 1) {
					ex += ko1 - 1;
				}
				if (xx == 2) {
					if (i != mak1) {
						ex += ko1 + mes;
					}
					else {
						ex = n - i - 1;
					}
					ans *= (mes - ko1 + 1);
					ans = ans % p;
				}
				ah[po1] = 1;
			}
		}
		cout << ans << endl;
	}
	return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:101:18: error: expected '}' at end of input
  101 |         return 0;
      |                  ^
a.cc:13:15: note: to match this '{'
   13 | signed main() {
      |               ^
Language: C

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

const int M = 998244353;

int main(void)
{
  int N;
  int* A;
  int i, s, len, k;
  int *lengths, *heads, *tails;
  int tail;
  int killed, result;
  
  scanf("%d",&N);
  A = malloc(sizeof(int)*N);
  for(i=0; i<N; i++) {
    scanf("%d",A+i);
    A[i]--;
  }

  s=0;
  if(A[0]==A[N-1]) {
    while(s<=N-1 && A[s]==A[0]) {
      s++;
    }
  }

  if(s==N) {
    if(A[0]==0) {
      result = 1;
      for(i=1;i<=N;i++) {
	result = (result * i) % M;
      }
    } else {
      result = 0;
    }
    printf("%d\n",result);
    return(0);
  }

  lengths = calloc(N,zsizeof(int));
  heads = malloc(sizeof(int)*N);
  tails = malloc(sizeof(int)*N);

  if(s > 0) {
    tail = A[0];
  } else {
    tail = A[N-1];
  }

  len= 1;
  for(i=s; i<N; i++) {
    if(i<N-1 && A[i+1]==A[i]) {
      len++;
    } else {
      if(i<N-1) {
	if(lengths[A[i+1]]>0) {
	  printf("%d\n",0);
	  return(0);
	} else {
	  heads[A[i]] = A[i+1];
	}
      } else {
	heads[A[i]] = A[0];
      }

      lengths[A[i]] = len;
      len = 1;
      tails[A[i]] = tail;
      tail = A[i];
    }
  }

  if(s > 0) {
    heads[A[0]] = A[s];
    lengths[A[0]] += s;
  }

  k = lengths[0];
  if(k == 0) {
    printf("%d\n",0);
    return(0);
  }

  result = 1;
  killed = 0;
  for(i=1; i<N; i++) {
    if(lengths[i] == 0) {
      result = (result * killed) % M;
      killed--;
    } else if(lengths[i] > k) {
      printf("%d\n",0);
      return(0);
    } else if(heads[i] > i && tails[i] > i) {
      if(lengths[i] != k) {
	printf("%d\n",0);
	return(0);
      }
    } else if(heads[i] < i && tails[i] < i) {
      result = (result * (k-lengths[i]+1)) % M;
      killed += (lengths[i]+k-2);
    } else {
      // head < i && tail > i
      // head > i && tail < i
      killed += (lengths[i]-1);
    }

    if(result == 0) {
      break;
    }
  }
  
  printf("%d\n",result);

  return(0);
}

Compiler output:
main.c: In function 'main':
main.c:42:22: error: implicit declaration of function 'zsizeof' [-Wimplicit-function-declaration]
   42 |   lengths = calloc(N,zsizeof(int));
      |                      ^~~~~~~
main.c:42:30: error: expected expression before 'int'
   42 |   lengths = calloc(N,zsizeof(int));
      |                              ^~~
Language: C++

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll mo=998244353;
int N;
int B[1303030];
int A[1303030];

vector<int> P[303030];
int L[303030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>A[i];
		A[i]--;
	}
	
	if(count(A,A+N,0)==0) return _P("0\n");
	if(count(A,A+N,0)==N) {
		ll ret=1;
		FOR(i,N) ret=ret*(i+1)%mo;
		cout<<ret<<endl;
		return;
	}
	
	FOR(i,N) if(A[i]==0 && A[(i+N-1)%N]>0) {
		FOR(j,2*N) B[j]=A[(i+j)%N];
		FOR(j,2*N) A[j]=B[j];
		FOR(j,N) P[A[j]].push_back(j);
		break;
	}
	
	ll ret=1;
	set<int> empty,unused;
	int numfree=0;
	
	empty.insert(4*N);
	FOR(i,N) empty.insert(i), empty.insert(i+N);
	
	FOR(i,N) {
		//cout<<"!"<<i<<" "<<numfree<<endl;
		L[i]=P[i].size();
		if(L[i]>L[0]) return _P("0\n");
		if(L[i]==0) {
			//cout<<i<<" "<<numfree<<endl;
			ret=ret*numfree%mo;
			numfree--;
		}
		else {
			if(P[i][0]+L[i]-1!=P[i].back()) return _P("0\n");
			FORR(p,P[i]) {
				empty.erase(p);
				empty.erase(N+p);
				unused.insert(p);
			}
			
			x=P[i][0];
			if(A[x+N-1]>i && A[x+L[i]]>i && L[i]!=L[0]) return _P("0\n");
			if(A[x+N-1]<i && A[x+L[i]]<i) ret=ret*(L[0]-L[i]+1)%mo;
			while(1) {
				auto it=unused.lower_bound(P[i][0]-(L[0]-1));
				if(it==unused.end()) break;
				auto it2=empty().lower_bound(*it);
				//cout<<"ng"<<*it2<<" "<<*it<<endl;
				if(*it2-*it<L[0]) break;
				numfree++;
				//cout<<"ok "<<*it<<endl;
				unused.erase(it);
			}
			numfree--;
		}
	}
	assert(0);
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:77:47: error: no match for call to '(std::set<int>) ()'
   77 |                                 auto it2=empty().lower_bound(*it);
      |                                          ~~~~~^~
Language: C++

#include <iostream>
using namespace std;
int main(){
  string s;
  if(s.size()==2) cout << s << endl;
  else{
    reverse(s.begin(),s.end());
    cout << s << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'reverse' was not declared in this scope
    7 |     reverse(s.begin(),s.end());
      |     ^~~~~~~
Language: C++

    #include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    if(s.size() == 2)cout << s;
    else {
        s.reverse(ALL(s));
        cout << s << endl;
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:45:11: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'reverse'; did you mean 'reserve'?
   45 |         s.reverse(ALL(s));
      |           ^~~~~~~
      |           reserve
Language: C++

#include <iostream>

using namespace std;

int main(){
  string s;
  cin>>s;
  if(s.size()==3)reverse(s.begin(),s.end());
  cout<<s<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:18: error: 'reverse' was not declared in this scope
    8 |   if(s.size()==3)reverse(s.begin(),s.end());
      |                  ^~~~~~~
Language: C++

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

int main() {
  string str;
  cin >> str;
  if(str.size()=2){
    cout << "2";
  }
  if(str.size()=3){
    cout << "3";
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: lvalue required as left operand of assignment
    7 |   if(str.size()=2){
      |      ~~~~~~~~^~
a.cc:10:14: error: lvalue required as left operand of assignment
   10 |   if(str.size()=3){
      |      ~~~~~~~~^~
Language: Java

public class Hello{
    public static void Main(){
        var str = System.Console.ReadLine();
        if(str.Length==3){
            for(int i=2; i>=0; i--){
                System.Console.Write(str[i]);
            }
            System.Console.Write("\n");
        }else{
            System.Console.WriteLine(str);
        }
    }
}


Compiler output:
Main.java:1: error: class Hello is public, should be declared in a file named Hello.java
public class Hello{
       ^
Main.java:3: error: cannot find symbol
        var str = System.Console.ReadLine();
                        ^
  symbol:   variable Console
  location: class System
Main.java:6: error: cannot find symbol
                System.Console.Write(str[i]);
                      ^
  symbol:   variable Console
  location: class System
Main.java:8: error: cannot find symbol
            System.Console.Write("\n");
                  ^
  symbol:   variable Console
  location: class System
Main.java:10: error: cannot find symbol
            System.Console.WriteLine(str);
                  ^
  symbol:   variable Console
  location: class System
5 errors
Language: Java

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.next();
        if (s.length() == 2){
            System.out.println(s);
        } else {
            StringBuffer sr = new StringBuffer(s);
            String sred = sr.reverse().toString()
            System.out.println(sred);
        }
    }
}

Compiler output:
Main.java:10: error: ';' expected
            String sred = sr.reverse().toString()
                                                 ^
1 error
Language: C++

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

int main(){
    string S;
    cin >> S;
    if(S.size() == 2) {
        cout << S << endl;
    }
    else {
        cout << S[2] << s[1] << S[0] << endl;
    }
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: 's' was not declared in this scope
   11 |         cout << S[2] << s[1] << S[0] << endl;
      |                         ^