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

#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;

int main(void){
	ios::sync_with_stdio(false);
	int H, W, i, j, k, sum;
	cin >> H >> W;
	string S[H];
	for (i = 0; i < H; i++) {
		cin >> S[i];
	}
	int SN[H + 2][W + 2];
	for (i = 0; i < H+2; i++) {
		for (j = 0; j < W+2; j++) {
			SN[i][j] = -1;
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (S[i][j] == '.') SN[i+1][j+1] = 0;
			if (S[i][j] == '#') SN[i+1][j+1] = 1;
		}
	}
	sum = 0;

	for (i = 1; i < H+1; i++) {
		for (j = 1; j < W+1; j++) {
				if (SN[i - 1][j] < 0);
				else {
					if (SN[i - 1][j] != SN[i][j]) sum += 1;
				}
				if (SN[i + 1][j] < 0);
				else {
					if (SN[i + 1][j] != SN[i][j]) sum += 1;
				}
				if (SN[i][j - 1] < 0);
				else {
					if (SN[i][j - 1] != SN[i][j]) sum += 1;
				}
				if (SN[i][j + 1] < 0);
				else {
					if (SN[i][j + 1] != SN[i][j]) sum += 1;
				
			     }
				if (SH[i][j] == 0 && SH[i + 1][j + 1] == 0 && SH[i + 1][j] == 1 && SH[i][j + 1] == 1) {
					sum += 4;
				}
				if (SH[i][j] == 1 && SH[i + 1][j + 1] == 1 && SH[i + 1][j] == 0 && SH[i][j + 1] == 0) {
					sum += 4;
				}
			
		}
	}
	sum /= 2;


	cout << sum;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:37: error: 'SH' was not declared in this scope; did you mean 'SN'?
   49 |                                 if (SH[i][j] == 0 && SH[i + 1][j + 1] == 0 && SH[i + 1][j] == 1 && SH[i][j + 1] == 1) {
      |                                     ^~
      |                                     SN
a.cc:52:37: error: 'SH' was not declared in this scope; did you mean 'SN'?
   52 |                                 if (SH[i][j] == 1 && SH[i + 1][j + 1] == 1 && SH[i + 1][j] == 0 && SH[i][j + 1] == 0) {
      |                                     ^~
      |                                     SN
Language: C++

#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

char dots[400][400];
bool done[400][400][400][400];
int i, j;
int h, w, cnt = 0;

void dfs(int x, int y, char now){
    if(now == '.') cnt ++;
    done[i][j][y][x] = true;

    if(0 <= x-1 && now != dots[y][x-1] && !done[i][j][y][x-1]) dfs(x-1, y, dots[y][x-1]);
    if(x+1 < w && now != dots[y][x+1] && !done[i][j][y][x+1]) dfs(x+1, y, dots[y][x+1]);
    if(0 <= y-1 && now != dots[y-1][x] && !done[i][j][y-1][x]) dfs(x, y-1, dots[y-1][x]);
    if(y+1 < h && now != dots[y+1][x] && !done[i][j][y+1][x]) dfs(x, y+1, dots[y+1][x]);
}


int main(){
    cin >> h >> w;

    rep(i, h){
        rep(j, w) cin >> dots[i][j];
    }

    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++){
            if(dots[i][j] == '#'){
                dfs(j, i, '#');
            }
        }
    }

    cout << cnt << endl;
}

Compiler output:
/tmp/cc9eWduX.o: in function `dfs(int, int, char)':
a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x24): relocation truncated to fit: R_X86_64_PC32 against symbol `cnt' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x2a): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against symbol `j' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0xd2): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0xd8): relocation truncated to fit: R_X86_64_PC32 against symbol `j' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x18c): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x1dc): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x1e2): relocation truncated to fit: R_X86_64_PC32 against symbol `j' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x2dc): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cc9eWduX.o
a.cc:(.text+0x2e2): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int A[402][402];
int Ap[402][402];
int dx[] = {1, -1, 0 ,0};
int dy[] = {0 ,0, 1, -1};
int sc;

int dfs (int x, int y, int c){
	int sum = 0;
	Ap[x][y] = 0;
	for(int i = 0;i < 4; i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(Ap[nx][ny] != -c) continue; 
		if(Ap[nx][ny] == -sc) sum++;
		sum += dfs(nx, ny, -c);
	}
	return sum;
}

int main(){

	int H, W;
	cin >> H >>  W;

	int x=0, y=0;

	for(int i = 1; i<=H; i++){
		string S;
		cin >> S;
		for(int j = 1;j<=W;j++){
			if(S[j-1] == '#'){
				A[i][j] = 1;
				x++;
			} else {
				A[i][j] = -1;
				y++;
			}
		}
	}

	for(int i = 1; i<=H;i++){
		A[i][0] = 0;
		A[i][W+1] = 0;
	}
	for(int j = 1; j<=W;j++){
		A[0][j] = 0;
		A[H+1][j] = 0;
	}

	if(x > y){
		sc = -1;
	} else {
 		sc = 1;
	}	

	long long sum = 0;
	for(int i = 1; i<=H; i++){
		for(int j = 1;j <=W;j++){
			if(A[i][j] != sc) continue;
			memcpy(Ap, A, 402*402*sizeof(int));
			sum += dfs(i, j, sc);
		}
	}

	cout << sum << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:84:25: error: 'memcpy' was not declared in this scope
   84 |                         memcpy(Ap, A, 402*402*sizeof(int));
      |                         ^~~~~~
a.cc:19:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   18 | #include <utility>
  +++ |+#include <cstring>
   19 | #include <vector>
Language: C++

#include <iostream>
#include <vector>
#include <string>

typedef short Pos[2];

int main(){
	int H, W;

	scanf("%d %d\n", &H, &W);

	std::vector<std::string> board(H);
	for(int i = 0; i < H; i++){
		std::cin >> board[i];
	}

	int ans = 0;
	Pos buf[400*400];
	int buf_i = 0;
	Pos new_buf[400*400];
	int new_buf_i = 0;

	//std::cout << H << " " << W << std::endl;

	for(short Y = 0; Y < H; Y++){
		for(short X = 0; X < W; X++){

			int n_White = 0, n_Black = 0;

			if(board[Y][X] != 'x'){
				//std::cout << "Found: (" << X << " " << Y << ")" << std::endl;

				buf_i = 0;

				buf[buf_i][0] = X;
				buf[buf_i][1] = Y;

				buf_i++;

				while(buf_i > 0 && buf_i < sizeof(buf)/sizeof(Pos)){
					new_buf_i = 0;
					for(int i = 0; i < buf_i; i++){
						//std::cout << i << std::endl;
						short x = buf[i][0];
						short y = buf[i][1];

						char color = board[y][x];
						char target;

						if(color == '#'){
							n_Black++;
							target = '.';
						}
						if(color == '.'){
							n_White++;
							target = '#';
						}

						// 上下左右のPosが自分の色と異なっている場合、new_bufに追加する
						if(y - 1 >= 0 && board[y - 1][x] == target){
							new_buf[new_buf_i][0] = x;
							new_buf[new_buf_i][1] = y - 1;
							new_buf_i++;
						}
						if(x + 1 < W && board[y][x + 1] == target){
							new_buf[new_buf_i][0] = x + 1;
							new_buf[new_buf_i][1] = y;
							new_buf_i++;
						}
						if(y + 1 < H && board[y + 1][x] == target){
							new_buf[new_buf_i][0] = x;
							new_buf[new_buf_i][1] = y + 1;
							new_buf_i++;
						}
						if(x - 1 >= 0 && board[y][x - 1] == target){
							new_buf[new_buf_i][0] = x - 1;
							new_buf[new_buf_i][1] = y;
							new_buf_i++;
						}

						board[y][x] = 'x';
					}
					memcpy(buf, new_buf, sizeof(Pos)*new_buf_i);
					buf_i = new_buf_i;
				}
			}
			ans += n_White*n_Black;
		}
	}

	std::cout << ans << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:41: error: 'memcpy' was not declared in this scope
   83 |                                         memcpy(buf, new_buf, sizeof(Pos)*new_buf_i);
      |                                         ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | #include <string>
Language: C++

#include <iostream>
#include <vector>
#include <string>

typedef short Pos[2];

int main(){
	short H, W;

	scanf("%hd %hd\n", &H, &W);

	std::vector<std::string> board(H);
	for(int i = 0; i < H; i++){
		std::cin >> board[i];
	}

	int ans = 0;
	Pos buf[400*400];
	int buf_i = 0;
	Pos new_buf[400*400];
	int new_buf_i = 0;

	//std::cout << H << " " << W << std::endl;

	for(short Y = 0; Y < H; Y++){
		for(short X = 0; X < W; X++){

			int n_White = 0, n_Black = 0;

			if(board[Y][X] != 'x'){
				//std::cout << "Found: (" << X << " " << Y << ")" << std::endl;

				buf_i = 0;

				buf[buf_i][0] = X;
				buf[buf_i][1] = Y;

				buf_i++;

				while(buf_i > 0 && buf_i < sizeof(buf)/sizeof(Pos)){
					new_buf_i = 0;
					for(int i = 0; i < buf_i; i++){
						//std::cout << i << std::endl;
						short x = buf[i][0];
						short y = buf[i][1];

						char color = board[y][x];
						char target;

						if(color == '#'){
							n_Black++;
							target = '.';
						}
						if(color == '.'){
							n_White++;
							target = '#';
						}

						// 上下左右のPosが自分の色と異なっている場合、new_bufに追加する
						if(y - 1 >= 0 && board[y - 1][x] == target){
							new_buf[new_buf_i][0] = x;
							new_buf[new_buf_i][1] = y - 1;
							new_buf_i++;
						}
						if(x + 1 < W && board[y][x + 1] == target){
							new_buf[new_buf_i][0] = x + 1;
							new_buf[new_buf_i][1] = y;
							new_buf_i++;
						}
						if(y + 1 < H && board[y + 1][x] == target){
							new_buf[new_buf_i][0] = x;
							new_buf[new_buf_i][1] = y + 1;
							new_buf_i++;
						}
						if(x - 1 >= 0 && board[y][x - 1] == target){
							new_buf[new_buf_i][0] = x - 1;
							new_buf[new_buf_i][1] = y;
							new_buf_i++;
						}

						board[y][x] = 'x';
					}
					memcpy(buf, new_buf, sizeof(Pos)*new_buf_i);
					buf_i = new_buf_i;
				}
			}
			ans += n_White*n_Black;
		}
	}

	std::cout << ans << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:41: error: 'memcpy' was not declared in this scope
   83 |                                         memcpy(buf, new_buf, sizeof(Pos)*new_buf_i);
      |                                         ^~~~~~
a.cc:3:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <vector>
  +++ |+#include <cstring>
    3 | #include <string>
Language: C++

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

typedef long long LL;

int n,h,w;
string fi[405];
bool vis[405][405];
int p[] ={1,0,-1,0};
int q[] ={0,1,0,-1};

LL bfs(int x, int y){
vis[x][y] = 1;
LL bl, wh;
bl=wh=0LL;
queue<int> qx,qy;
qx.push(x);
qy.push(y);
while(!qx.empty()){
int nx=qx.front(); qx.pop();
int ny=qy.front(); qy.pop();
if(s[nx][ny] == '#') bl++;
else wh++;
for(int i=0;i<4;i++){
int cx = nx+p[i];
int cy = ny+q[i];
if(cx<0 || cx >=h || cy<0 || cy>= w || vis[cx][cy] || fi[cx][cy] == fi[nx][ny]) continue;
vis[cx][cy] = 1;
qx.push(cx);
qy.push(cy);
}
}
return bl*wh;
}

int main(){
cin>>h>>w;
for(int i=0;i<h;i++) cin >> fi[i];
LL ans = 0LL;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
if(!vis[i][j]) ans+= bfs(i,j);
printf("%lld\n",ans);
return 0;
}


Compiler output:
a.cc: In function 'LL bfs(int, int)':
a.cc:22:4: error: 's' was not declared in this scope
   22 | if(s[nx][ny] == '#') bl++;
      |    ^
Language: C++

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

typedef long long LL;

int n,h,w;
string s[405];
bool vis[405][405];
int p[] ={1,0,-1,0};
int q[] ={0,1,0,-1};

LL bfs(int x, int y){
vis[x][y] = 1;
LL bl, wh;
bl=wh=0LL;
queue<int> qx,qy;
qx.push(x);
qy.push(y);
while(!qx.empty()){
int nx=qx.front(); qx.pop();
int ny=qy.front(); qy.pop();
if(s[nx][ny] == '#') bl++;
else wh++;
for(int i=0;i<4;i++){
int cx = nx+p[i];
int cy = ny+q[i];
if(cx<0 || cx >=h || cy<0 || cy>= w || vis[cx][cy] || fi[cx][cy] == fi[nx][ny]) continue;
vis[cx][cy] = 1;
qx.push(cx);
qy.push(cy);
}
}
return bl*wh;
}

int main(){
cin>>h>>w;
for(int i=0;i<h;i++) cin >> s[i];
LL ans = 0LL;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
if(!vis[i][j]) ans+= bfs(i,j);
printf("%lld\n",ans);
return 0;
}


Compiler output:
a.cc: In function 'LL bfs(int, int)':
a.cc:27:55: error: 'fi' was not declared in this scope; did you mean 'i'?
   27 | if(cx<0 || cx >=h || cy<0 || cy>= w || vis[cx][cy] || fi[cx][cy] == fi[nx][ny]) continue;
      |                                                       ^~
      |                                                       i
Language: C++

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

typedef long long LL;

int n,h,w;
string s[405];
vis[405][405];
int p[] ={1,0,-1,0};
int q[] ={0,1,0,-1};

LL bfs(int x, int y){
vis[x][y] = 1;
LL bl, wh;
bl=wh=0LL;
queue<int> qx,qy;
qx.push(x);
qy.push(y);
while(!qx.empty()){
int nx=qx.front(); qx.pop();
int ny=qy.front(); qy.pop();
if(s[nx][ny] == '#') bl++;
else wh++;
for(int i=0;i<4;i++){
int cx = nx+p[i];
int cy = ny+q[i];
if(cx<0 || cx >=h || cy<0 || cy>= w || vis[cx][cy] || fi[cx][cy] == fi[nx][ny]) continue;
vis[cx][cy] = 1;
qx.push(cx);
qy.push(cy);
}
}
return bl*wh;
}

int main(){
cin>>h>>w;
for(int i=0;i<h;i++) cin >> s[i];
LL ans = 0LL;
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
if(!vis[i][j]) ans+= bfs(i,j);
printf("%lld\n",ans);
return 0;
}


Compiler output:
a.cc:8:1: error: 'vis' does not name a type
    8 | vis[405][405];
      | ^~~
a.cc: In function 'LL bfs(int, int)':
a.cc:13:1: error: 'vis' was not declared in this scope
   13 | vis[x][y] = 1;
      | ^~~
a.cc:27:55: error: 'fi' was not declared in this scope; did you mean 'i'?
   27 | if(cx<0 || cx >=h || cy<0 || cy>= w || vis[cx][cy] || fi[cx][cy] == fi[nx][ny]) continue;
      |                                                       ^~
      |                                                       i
a.cc: In function 'int main()':
a.cc:42:5: error: 'vis' was not declared in this scope
   42 | if(!vis[i][j]) ans+= bfs(i,j);
      |     ^~~
Language: C++

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def main():
    h,w = map(int, sys.stdin.readline().rstrip().split(' '))
    s = []
    for _ in range(h):
        s.append(sys.stdin.readline().rstrip())

    taboo = set()
    flg = True
    c = 0
    while flg:
        flg = True
        for i in range(h*w):
            x, y = i%h, i//h
            if (x,y) in taboo:
                continue
            flg = False
            q = [(x,y)]
            taboo.add((x,y))
            #print(q, s[x][y])
            white, black = 0,0
            while len(q) > 0:
                x, y = q.pop()
                color = s[x][y]
                if color == ".":
                    white +=1
                else:
                    black += 1
                for v in ((x+1, y), (x-1, y), (x, y+1), (x, y-1)):
                    if v[0] >= 0 and v[0] < h and v[1] >= 0 and v[1] < w:
                        newcolor = s[v[0]][v[1]]
                        if color == newcolor or (v[0], v[1]) in taboo:
                            continue
                        q.append((v[0], v[1]))
                        taboo.add((v[0], v[1]))
                        #print(v, newcolor)
            #print(white, black)
            c += white * black
    print(c)



    
if __name__=="__main__":
    main()


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/env python3
      |  ^
a.cc:2:3: error: invalid preprocessing directive #-
    2 | # -*- coding: utf-8 -*-
      |   ^
a.cc:25:14: error: invalid preprocessing directive #print
   25 |             #print(q, s[x][y])
      |              ^~~~~
a.cc:41:26: error: invalid preprocessing directive #print
   41 |                         #print(v, newcolor)
      |                          ^~~~~
a.cc:42:14: error: invalid preprocessing directive #print
   42 |             #print(white, black)
      |              ^~~~~
a.cc:4:1: error: 'import' does not name a type
    4 | import sys
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int maxn = 412;
string s[maxn];
int h, w, dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
bool vis[maxn][maxn];

void dfs(int x, int y, int &cnt_w, int &cnt_b){
	if(vis[x][y]) return;
	vis[x][y] = true;
	if(s[x][y] == '#') cnt_w ++;
	else cnt_b++;
	rep(i,0,4){
		int xx = x + dx[i], yy = y + dy[i];
		if(xx < h && xx >=0 && yy < w && yy >= 0 && s[x][y] != s[xx][yy]) dfs(xx, yy, cnt_w, cnt_b);
	}
}

int main() {
#ifdef LOCAL_DEFINE
    freopen("test.in","r",stdin);
#else
    cin.sync_with_stdio(0); cin.tie(0);
#endif
	cin >> h >> w;
	rep(i,0,h) cin >> s[i];
	ll ans = 0;
	rep(i,0,h){
		rep(j,0,w){
			if(!vis[i][j]){
				ll cnt_w = 0, cnt_b = 0;
				dfs(i, j, cnt_w, cnt_b);
				ans += cnt_w * cnt_b;
			}
		}
	}
	cout << ans << '\n';
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * (double) clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:43: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   42 |                                 dfs(i, j, cnt_w, cnt_b);
      |                                           ^~~~~
a.cc:18:29: note:   initializing argument 3 of 'void dfs(int, int, int&, int&)'
   18 | void dfs(int x, int y, int &cnt_w, int &cnt_b){
      |                        ~~~~~^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
char a;
int h,w,k=0,ans=0;
int kumi[10000][2];
int masu[4000][4000];
bool visited[4000][4000];
bfs(int i,int j,int k){
    if(masu[i][j]==1)kumi[k][1]++;
    else kumi[k][0]++;
    visited[i][j]=true;

    if(i>0&&!visited[i-1][j]&&masu[i][j]+masu[i-1][j]==1)bfs(i-1,j,k);
    if(j>0&&!visited[i][j-1]&&masu[i][j]+masu[i][j-1]==1)bfs(i,j-1,k);
    if(i<h-1&&!visited[i+1][j]&&masu[i][j]+masu[i+1][j]==1)bfs(i+1,j,k);
    if(j<w-1&&!visited[i][j+1]&&masu[i][j]+masu[i][j+1]==1)bfs(i,j+1,k);
}
main(){
    cin>>h>>w;
    for(int i=0;i<16000;i++){
        kumi[i][0]=0;
        kumi[i][1]=0;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a;
            if(a=='.')masu[i][j]=0;
            else masu[i][j]=1;
            visited[i][j]=false;
        }
    }


    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(!visited[i][j])bfs(i,j,k);
            k++;
        }
    }


    for(int i=0;i<k;i++){
        //cout<<kumi[i][0]<<" "<<kumi[i][1]<<endl;
        ans+=kumi[i][0]*kumi[i][1];
    }

    cout<<ans;
}

Compiler output:
a.cc:9:1: error: ISO C++ forbids declaration of 'bfs' with no type [-fpermissive]
    9 | bfs(int i,int j,int k){
      | ^~~
a.cc: In function 'int bfs(int, int, int)':
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
a.cc: At global scope:
a.cc:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      | ^~~~
Language: C++

#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;

int main(void){
	ios::sync_with_stdio(false);
	int H, W, i, j, k, sum;
	cin >> H >> W;
	string S[H];
	for (i = 0; i < H; i++) {
		cin >> S[i];
	}
	int SN[H + 2][W + 2];
	for (i = 0; i < H+2; i++) {
		for (j = 0; j < W+2; j++) {
			SN[i][j] = -1;
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (S[i][j] == ".") SN[i+1][j+1] = 0;
			if (S[i][j] == "#") SN[i+1][j+1] = 1;
		}
	}
	sum = 0;
	for (i = 1; i < H+1; i++) {
		for (j = 1; j < W+1; j++) {
			if (SN[i - 1][j] < 0);
			else {
				if (SN[i - 1][j] != SN[i][j]) sum += 1;
			}
			if (SN[i + 1][j] < 0);
			else {
				if (SN[i + 1][j] != SN[i][j]) sum += 1;
			}
			if (SN[i][j - 1] < 0);
			else {
				if (SN[i][j - 1] != SN[i][j]) sum += 1;
			}
			if (SN[i][j+1] < 0);
			else {
				if (SN[i][j + 1] != SN[i][j]) sum += 1;
			}

			
		}
	}

	cout << sum;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:37: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   24 |                         if (S[i][j] == ".") SN[i+1][j+1] = 0;
a.cc:25:37: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   25 |                         if (S[i][j] == "#") SN[i+1][j+1] = 1;
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define MAGIC0
mt19937 rnd(time(0)); //rnd()

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e5 + 7;
const double PI = acos(-1.);
const double EPS = 1e-8;
const int MOD = 998244353;

char x[405][405];
LL dp[405][405];
int was[405][405];
int cnt[3004040], kol[300030];

int n, m, col;
void go(int i, int j)
{
	if (i < 1 || j < 1 || i > n || j > m || was[i][j]) return;
	was[i][j] = col;
	if (x[i + 1][j] != x[i][j])
	{
		go(i + 1, j);
	}
	if (x[i - 1][j] != x[i][j])
	{
		go(i - 1, j);
	}
	if (x[i][j + 1] != x[i][j])
	{
		go(i, j + 1);
	}
	if (x[i][j - 1] != x[i][j])
	{
		go(i, j - 1);
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	FOR(i, 1, n+1)
	{
		FOR(j, 1, m+1)
		{
			cin >> x[i][j];
		}
	}

	FOR(i, 1, n + 1)
	{
		FOR(j, 1, m + 1)
		{
			if (!was[i][j] && x[i][j] == '#')
			{
				++col;
				go(i, j);
			}
		}
	}

	LL ans = 0;
	FOR(i, 1, n + 1)
	{
		FOR(j, 1, m + 1)
		{
			kol[was[i][j]]++;
			if (x[i][j] == '#')
			{
				cnt[was[i][j]]++;
//			}
//			cout << was[i][j] << ' ';
		}
//		cout << endl;
	}
	for(int i = 1;i <= col;++i)
	{
//		cout << kol[i] << " " << cnt[i] << endl;
		ans += (kol[i] - cnt[i]) * cnt[i];
	}

	cout << ans;

	return 0;
}


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

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

int H, W;
string s[401];

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

const int MAXV = 401*401;
const int INF = 1e8;
int dist[MAXV][MAXV];  // d[u][v]は辺e=(u,v)のコスト, （存在しない場合はINF, ただしd[i][i]=0とする）
int V;

void warshall_floyd() {
    for (int k=0; k<V; ++k) {
        for (int i=0; i<V; ++i) {
            for (int j=0; j<V; ++j) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
    }
}


int main() {
    cin >> H >> W;
    rep(i, H) cin >> s[i];

    V = H*W;
    fill(dist[0], dist[V], INF);
    rep(i, V) dist[i][i] = 0;

    vector<P> posb, posw;
    rep(i, H) rep(j, W) {
        if (s[i][j] == '#') {
            posb.emplace_back(i, j);
            rep(d, 4) {
                int nr = i + dy[d];
                int nc = j + dx[d];
                if (0 <= nr and nr < H and 0 <= nc and nc < W and s[nr][nc] == '.') {
                    int idx1 = i*W+j;
                    int idx2 = nr*W+nc;
                    // G[i][j].emplace_back(nr, nc);
                    // G[nr][nc].emplace_back(i, j);
                    dist[idx1][idx2] = dist[idx2][idx1] = 1;
                }
            }
        }
        else {
            posw.emplace_back(i, j);
        }
    }

    warshall_floyd();

    ll ans = 0;
    for (auto& b : posb) {
        for (auto& w: posw) {
            if (dist[b.first*W+b.second][w.first*W+w.second] != INF) ans++;
        }
    }



    cout << ans << endl;
}


Compiler output:
/tmp/ccyem04f.o: in function `warshall_floyd()':
a.cc:(.text+0xe5): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccyem04f.o
a.cc:(.text+0xf8): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccyem04f.o
a.cc:(.text+0x10b): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccyem04f.o
/tmp/ccyem04f.o: in function `main':
a.cc:(.text+0x1a7): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccyem04f.o
a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccyem04f.o
a.cc:(.text+0x206): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccyem04f.o
collect2: error: ld returned 1 exit status
Language: C++

#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

int st[30][100000];
ll dp[52][2510];
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int B[30];
int n;
int t[100010];
struct edge {
	int t;
	ll cost;
	edge(int _t,ll _cost) : t(_t)
							, cost(_cost){
	}
};
ll d[305];
int ct[505][505];
int p[22];
string ta[405];
bool table[405][405];
int tx[] = { 0,-1,0.1 };
int ty[] = { 1,0,-1,0 };
int h, w;
pii rec(int x,int y) {

	pii ret;
	if (ta[x][y] == '.') {
		ret.first++;
	}
	else ret.second++;
	for (size_t i = 0; i < 4; i++)
	{
		int nx = x + tx[i];
		int ny = y + ty[i];
		if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
		if (table[nx][ny]) continue;
		if (ta[x][y] == ta[nx][ny]) continue;
		table[nx][ny] = true;
		pii p = rec(nx, ny);
		ret.first += p.first;
		ret.second += p.second;
	}
	return ret;
}
void Solve() {
	cin >> h >> w;
	for (size_t i = 0; i < h; i++)
	{
		cin >> ta[i];
	}

	ll res = 0;
	for (size_t i = 0; i < h; i++)
	{
		for (size_t j = 0; j < w; j++)
		{
			if (table[i][j])continue;
			if (ta[i][j] == '.')continue;
			table[i][j] = true;
			pii p = rec(i, j);
			res += p.first * p.second;
		}
	}

	cout << res << endl;
}
int main() {
	Solve();
	return 0;
}



Compiler output:
a.cc:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
a.cc:18:9: warning: "M_PI" redefined
   18 | #define M_PI acos(-1)
      |         ^~~~
In file included from /usr/include/c++/14/cmath:47,
                 from a.cc:15:
/usr/include/math.h:1121:10: note: this is the location of the previous definition
 1121 | # define M_PI           3.14159265358979323846  /* pi */
      |          ^~~~
a.cc:67:19: error: narrowing conversion of '1.0000000000000001e-1' from 'double' to 'int' [-Wnarrowing]
   67 | int tx[] = { 0,-1,0.1 };
      |                   ^~~
Language: C++

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

const int MAX = 405;

int H, W, srci, srcj;
bool grid[MAX][MAX];

int dfs(int i, int j, bool color) {
	if (i < 0 or j < 0 or i >= H or j >= W or vis[i][j] or grid[i][j] != color) return 0;
	int ret = !grid[i][j] ? 1 : 0;

	if (i >= srci) ret += dfs(i + 1, j, !color);
	if (i <= srci) ret += dfs(i - 1, j, !color);
	if (j >= srcj) ret += dfs(i, j + 1, !color);
	if (j <= srcj) ret += dfs(i, j - 1, !color);

	return ret;
}

main() {
	ios_base::sync_with_stdio(0); cin.tie(nullptr);
	int i, j, k, l;

	cin >> H >> W;
	for (i = 0; i < H; ++i) {
		string input; cin >> input;
		for (j = 0; j < W; ++j) {
			grid[i][j] = input[j] == '#';
		}
	}

	int ans = 0;
	for (i = 0; i < H; ++i) for (j = 0; j < W; ++j) {
		if (!grid[i][j]) continue;
		
		srci = i, srcj = j;
		int temp = dfs(i, j, grid[i][j]);
		//cout << i << ", " << j << " = " << temp << "\n";
		ans += temp;
	}
	cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int dfs(int, int, bool)':
a.cc:11:51: error: 'vis' was not declared in this scope
   11 |         if (i < 0 or j < 0 or i >= H or j >= W or vis[i][j] or grid[i][j] != color) return 0;
      |                                                   ^~~
a.cc: At global scope:
a.cc:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main() {
      | ^~~~
Language: C++

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

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

char s[410][410];
int n,m;
int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
bool vis[410][410];
int ans;

bool In_range(int x,int y) {
	return x>=0&&y>=0&&x<n&&y<m;
}

void dfs(int dep,int a,int b) {
	ans+=dep;
	vis[a][b]=true;
	char ch=s[aa][bb];
	for(int i=0;i<4;i++){
		int aa=a+dx[i];
		int bb=b+dy[i];
		if(In_range(aa,bb)&&!vis[aa][bb]&&ch!=s[aa][bb])
			dfs(dep+1,aa,bb);
	}
}

int main() {
	n=read();
	m=read();
	for(int i=0; i<n; i++) scanf("%s",s[i]);
	for(int i=0; i<n; i++) 
		for(int j=0; j<m; j++) 
			if(!vis[i][j]) dfs(0,i,j);
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:31:19: error: 'aa' was not declared in this scope; did you mean 'a'?
   31 |         char ch=s[aa][bb];
      |                   ^~
      |                   a
a.cc:31:23: error: 'bb' was not declared in this scope; did you mean 'b'?
   31 |         char ch=s[aa][bb];
      |                       ^~
      |                       b
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int DIM = 507;

#define int long long

int v[DIM][DIM];
bool vis[DIM][DIM];

int black;
int white;

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

int n, m;

bool isIn(int x, int y)
{
	return (x <= n && x >= 1 && y <= m && y >= 1);
}

void dfs(int x, int y)
{
	if(v[x][y] == 1)
		black++;
	else
		white++;
	
	vis[x][y] = 1;
	
	for(int i = 0; i < 4; i++)
	{
		int new_x = x + dx[i];
		int new_y = y + dy[i];
		
		if(isIn(new_x, new_y) && v[new_x][new_y] == (v[x][y] ^ 1) && vis[new_x][new_y] == 0)
			dfs(new_x, new_y);
	}
}

int main()
{
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			char c;
			cin >> c;
			
			if(c == '#')
				v[i][j] = 1;
			else
				v[i][j] = 0;
		}
	
	int pr = 0;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(vis[i][j] == 0)
			{
				black = 0;
				white = 0;
				
				dfs(i, j);
				
				pr += black * white;
			}
	
	cout << pr;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 4e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int x, n, q, a[N + 1];

bool check (int r)
{
    int dif = a[n - r] - x;
    int r2 = n - r - (lower_bound(a+st+1, a+n+1, x - dif) - a) + 1;
    if (r2 > r) return false;
    return true;
}

int search (int start, int end)
{
    int mid = (start + end)/2;
    if (start == end) return start;
    
    if (check(mid)) return search(start, mid);
    else return search(mid + 1, end);
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> q;
	int st = 10;
	FOR (i, 1, st - 1) a[i] = -inf;
	FOR (i, st, st + n - 1) cin >> a[i];
	n += st - 1;
	
	int suf[n + 10] = {}, f[n + 10] = {};
	FORD (i, n, 1) suf[i] = suf[i + 1] + a[i];
	
	f[st] = a[st];
	FOR (i, st + 1, n) f[i] = f[i - 2] + a[i]; 
	
	FOR (i, 1, q)
	{
	    cin >> x;
	    int ind = lower_bound(a+st+1, a+n+1, x) - a, sum = 0;
	    
	    if (ind == n) {print(f[n]);}
	    else
	    {
	        int rounds = search(1, n - ind + 1);
	        cout << f[n - 2*rounds] + suf[n - rounds + 1] << endl;
	    }
	}
}



















Compiler output:
a.cc: In function 'bool check(long long int)':
a.cc:39:37: error: 'st' was not declared in this scope; did you mean 'std'?
   39 |     int r2 = n - r - (lower_bound(a+st+1, a+n+1, x - dif) - a) + 1;
      |                                     ^~
      |                                     std
Language: C++

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

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

    int N, Q;
    static lint A[100005] = {}, SUM[2][100005] = {}, diff[100005];

    cin >> N >> Q;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        SUM[i % 2][i] = A[i];
    }
    A[N] = 1e16;

    for (int i = 1; i < N; i++) {
        SUM[0][i] += SUM[0][i - 1];
        SUM[1][i] += SUM[1][i - 1];
    }

    for (int i = 0; i < Q; i++) {
        lint X;
        cin >> X;

        lint le = 0, ri = N;
        lint len = 0;
        while (le <= ri) {
            lint mid = (le + ri) / 2;
            if (abs(A[N - mid] - X) > abs(A[N - (mid + 1) / 2] - X)) {
                ri = mid - 1;
                // len = mid;
            } else {
                len = mid;
                le = mid + 1;
            }
        }
        
        lint ans = SUM[0][N - 1] + SUM[1][N - 1];
        if (N - (len + 1) / 2 > 0) {
            ans -= SUM[0][N - (len + 1) / 2 - 1] + SUM[1][N - (len + 1) / 2 - 1];
        }
        lint take = (N - (len + 1) / 2) - (N - len);
        if (take < (N - (N - (len + 1) / 2))) {
            if (N - len - 2 >= 0) {
                ans += SUM[(N - len) % 2][N - len - 1];
            }
        } else {
            if (N - len - 1 >= 0) {
                ans += SUM[(N - len + 1) % 2][N - len - 1];
            }
        }
        cout << ans << "\n";
    }

    return 0;
}


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

#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pii pair<int,int>
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define mp make_pair

ll N,Q;
ll A[101010],X[101010];
ll sm[101010], esm[101010];
ll i, j, k, ans;

ll ck1(ll x,ll a){
    if (abs(x-A[N - a * 2 + 1]) > abs(x-A[N - a]))
    {
        return 1;
    }
    return 0;
}
ll ck1(ll x,ll a){
    if (abs(x-A[N - a * 2 + 1]) > abs(x-A[N - a]))
    {
        return 1;
    }
    return 0;
}
int main(){
    scanf("%lld%lld", &N, &Q);
    if(N%2){
        A[0] = 0;
        j = 1;
        N++;
    }
    fornum(i,j,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,Q){
        scanf("%lld", &X[i]);
    }
    fornum(i,0,N){
        sm[i + 1] = sm[i] + A[i];
    }
    for (i = 2; i <= N;i+=2){
        esm[i] = esm[i + 1] = esm[i - 1] + A[i - 1];
    }
    
    fornum(i,0,Q){
        if(N==2||abs(X[i]-A[N-3])>abs(X[i]-A[N-2])){
            printf("%lld\n", esm[N]);
            continue;
        }
        ll l = 2, r = N / 2;
        while(l<r){
            ll c = (l + r + 1) / 2;
            //printf("%lld:%lld,%lld:%lld\n", l, r,c, cc);
            if (abs(X[i]-A[N - c * 2 + 1]) > abs(X[i]-A[N - c]))
            {
                r = c-1;
            }else{
                l = c;
            }
        }
        ll a = l;
        printf("%lld\n", sm[N] - sm[N - a] + esm[N - a * 2]);
        /*
        l = 2;
        r = N / 2;
        while(l<r){
            ll c = (l + r) / 2;
            ll cc = ck(X[i], c);
            if (c>0&&abs(X[i]-A[N - c * 2]) <= abs(X[i]-A[N - c]-1))
            {
                l = c+1;
            }else{
                l = c;
            }
        }
        printf("%lld\n", sm[N] - sm[N - r] + esm[N - r * 2]);
        */
    }

    return 0;
}

Compiler output:
a.cc:26:4: error: redefinition of 'long long int ck1(long long int, long long int)'
   26 | ll ck1(ll x,ll a){
      |    ^~~
a.cc:19:4: note: 'long long int ck1(long long int, long long int)' previously defined here
   19 | ll ck1(ll x,ll a){
      |    ^~~
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
ll sum[214514],od[214514],ev[214514];
signed main(){
	ll n,q;
	vector<ll> a,x;
	cin>>n>>q;
	for(ll i=0;i<n;i++){
		ll tmp;
		cin>>tmp;
		a.pb(tmp);
	}
	for(ll i=0;i<q;i++){
		ll tmp;
		cin>>tmp;
		x.pb(tmp);
	}
	sort(a.begin(),a.end());
	for(ll i=1;i<=n;i++){
		sum[i] = sum[i-1] + a[i-1];
		if(i%2==0) od[i] = od[i-1] + a[i-1];
		if(i%2==1) ev[i] = ev[i-1] + a[i-1];
	}
	if(n%2==0){
		for(ll k=0;k<q;k++){
			ll ci = x[k];
			ll lef = 0, rig = n/2 + 1;
			while(rig-lef>1){
				ll mid = (lef+rig)/2;
				ll tdif = abs( ci - a[n-mid] );
				ll adif = abs( ci - a[n-mid*2] );
				if(adif<=tdif){
					lef = mid;
				}
				else{
					rig = mid;
				}
			}
			ll ans = 0;
			ans += sum[n] - sum[n-lef];
			ans += od[n-2*lef];
			cout<<ans<<endl;
		}
	}
	else{
		for(ll k=0;k<q;k++){
			ll ci = x[k];
			ll lef = 0, rig = 
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:9: error: expected primary-expression before 'return'
   54 |         return 0;
      |         ^~~~~~
a.cc:55:2: error: expected '}' at end of input
   55 | }
      |  ^
a.cc:50:13: note: to match this '{'
   50 |         else{
      |             ^
a.cc:55:2: error: expected '}' at end of input
   55 | }
      |  ^
a.cc:9:14: note: to match this '{'
    9 | signed main(){
      |              ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, q; cin >> n >> q;
  vector<ll> a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  reverse(a.begin(), a.end());

  vector<ll> sum(n+1), evensum(n+1);
  for(int i=0;i<n;++i) {
    sum[i+1] = sum[i] + a[i];
    evensum[i+1] = envensum[i] + (i % 2 == 0 ? a[i] : 0);
  }

  vector<ll> ths, vals;
  for(int i=0;i<(n-1)/2;++i) {
    ll th = (a[i+1] + a[i*2+2])/2 + 1;
    ll val = (sum[i+1] - sum[0]) + (evensum[n] - evensum[i*2+2]);
    ths.push_back(th);
    vals.push_back(val);
  }

  reverse(ths.begin(), ths.end());
  reverse(vals.begin(), vals.end());
  for(int i=0;i<q;++i) {
    ll x; cin >> x;
    int it = upper_bound(ths.begin(), ths.end(), x) - ths.begin();
    if(it == 0) cout << sum[(n+1)/2] - sum[0] << endl;
    else cout << vals[it-1] << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:20: error: 'envensum' was not declared in this scope; did you mean 'evensum'?
   35 |     evensum[i+1] = envensum[i] + (i % 2 == 0 ? a[i] : 0);
      |                    ^~~~~~~~
      |                    evensum
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin >> n >> m;
  vector<int> X(n); for(int & i : X) cin >> i;
  vector<long long> s0(n), s1(n), x2(n);
  long long v0 = 0, v1 = 0, v2 = 0;
  for(int i = 0; i < n; i++){
    v0 += X[i] * (i & 1);
    v1 += X[i] * (1 ^ (i & 1) );
    v2 += X[i];
    s0[i] = v0;
    s1[i] = v1;
    s2[i] = v2;
  }
  for(int i = 0; i < m; i++){
    int v; cin >> v;
    int lo = 1, hi = n-1, ans = -1;
    while(lo <= hi){
      int mid = (lo+hi)/2;
      int gv = X[n - mid - 1];
      int dist = abs(v - gv);
      int p_inf = lower_bound(X.begin(), X.end(), v + dist + 1) - X.begin();
      int p_sup = lower_bound(X.begin(), X.end(), v - dist) - X.begin();
      int tot = p_inf - p_sup;
      if(tot+1 >= mid){
        lo = mid + 1;
        ans = mid;
      } else {
        hi = mid - 1;
      }
    }
    assert(ans != -1);
    long long res = X[n - 1] - X[n - ans - 1];
    int lim = n - 1 - 2 * ans;
    if(lim >= 0){
      if(lim&1){
        res += s0[lim];
      } else {
        res += s1[lim];
      }
    }
    cout << res << endl;
  }
  return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 's2' was not declared in this scope; did you mean 'v2'?
   14 |     s2[i] = v2;
      |     ^~
      |     v2
Language: C++

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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    reverse(A.begin(), A.end());
    vector<ll> sum(N+1), evensum(N+1);
    rep(i, N) {
        sum[i+1] = sum[i]+A[i];
        evensum[i+1] = evensum[i] + (i%2 == 0 ? A[i] : 0);
    }

    vector<ll> ths, vals;
    for (int k=0; k<(N-1)/2; ++k) {
        ll th = (A[k+1]+A[k*2+2])/2 + 1;
        ll val = sum[k+1] + evensum[N] - evensum[k*2+2];
        ths.push_back(th);
        vals.push_back(val);
    }
    reverse(ths.begin(), ths.end());
    reverse(vals.begin(), vals.end());
    rep(i, Q) {
        ll X;
        cin >> X;
        int index = upper_bound(ths.begin(), ths.end(), X) - ths.begin();
        if (index == 0) cout << sum[(N+1)/2] << endl;
        else cout << vals[index-1] << endl;
    }
    return 0;s
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:14: error: 's' was not declared in this scope
   36 |     return 0;s
      |              ^
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pb push_back
ll n, q;
ll a[100005];
vector< ll > v;
ll s[100005];
ll es[100005];
bool ok(ll x, ll len, ll rgt, ll bd)
{
        if(len > ((n+1)/2)) return false;
        if(len <= ((rgt+1)/2) ) return true;
        ll nxt = n-1-len+1;
        ll remm = len - (rgt-len);
        bd -= remm;
        if(bd == -2 && (n%2 == 1) && (len == ((n+1)/2))) return true;
        if(bd < -1) return false;
        if(remm >= 2){
        if(x - v[bd+2] <= v[nxt] - x) return true;
        return false;
        }else {
                ll bdo = bd + remm;
                ll tk = len - remm;
                ll xx = bdo + tk;
                //if(remm==0) xx--;
                if(x - v[bdo] <= v[xx] - x) return false;
                return true;
        }
}
ll solve(ll x)
{
        if(n==1) return x;
        if(x >= v.back()) {

                ll tot = s[n-1];
                ll ret=0;
                if(n%2 == 0) {
                        ret = es[n-2];
                        return tot - ret;
                }else {
                        return es[n-1];
                }
                return 0;
        }else if(x < v[0]) {
                ll A = n/2;
                return s[n-1] - s[A-1];
        }
        if(abs(v[n/2] - x) >= abs(x - v[0])) {
                return sum[n-1] - sum[(n/2) - 1];
        }
        auto it = upper_bound(v.begin() , v.end(), x) - v.begin();
        ll bd = it-1;
        ll rgt = n - 1 - bd;
        //if(rgt==1)
        ll lo = 1;
        ll hi = rgt;
        while(hi > lo) {
                ll mid = lo + (hi - lo + 1)/2;
        //cout << mid << endl;
                if(ok(x,mid,rgt, bd)) lo=mid;
                else hi = mid-1;
                //cout << lo << " **** " << hi << endl;

        }
        //cout << bd << " " << hi << endl;
        ll ret = s[n-1] - s[n-1-hi];
        ll rem = hi - rgt + hi;
        bd = bd - rem;
        ll N = bd+1;
        if(N%2 == 0) {
                ret += (s[bd] - es[bd-1]);
        }else {
                ret += es[bd];
        }
        return ret;
}
int main()
{
        cin >> n >> q;
        for(ll i=1;i<=n;i++) {
                cin >> a[i];
                v.pb(a[i]);
                s[i-1] = a[i];
                if(i-1 > 0) s[i-1] += s[i-2];
        }
        es[0]=v[0];
        for(ll i=2;i<n;i += 2) es[i] = v[i] + es[i-2];
        while(q--) {

                ll x;
                cin >> x;
                cout << solve(x) << "\n";
        }
        return 0;
}


Compiler output:
a.cc: In function 'll solve(ll)':
a.cc:50:24: error: 'sum' was not declared in this scope
   50 |                 return sum[n-1] - sum[(n/2) - 1];
      |                        ^~~
Language: C++

#include <iostream>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
int div_up(int a, int b)
{
    return (a + b - 1) / b;
}
int main()
{
    int n, q, a[112345], x[112345];
    ll sum[112345], sum1[112345];
    cin >> n >> q;
    REP(i, n)
    cin >> a[i];
    REP(i, q)
    cin >> x[i];
    sum[0] = 0;
    REP(i, n)
    sum[i + 1] = sum[i] + a[i];
    sum1[0] = 0;
    bool b = n % 2;
    REP(i, n)
        sum1[i + 1] = sum1[i] + b * a[i],b = !b;  
    REP(i, q)
    {
        int l = n / 2 - 1;
        int r = div_up(n - 1 + upper_bound(a, a + n, x[i]) - lower_bound(a, a + n, 0), 2);
        while (r - l > 1)
        {
            int mid = (r + l) / 2;
            if (abs(a[mid] - x[i]) >= abs(a[mid - (n - mid) + 1] - x[i]))
                r = mid;
            else
                l = mid;
        }
        cout << sum[n] - sum[r] + sum1[(r - (n - r))] << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'll' was not declared in this scope
   12 |     ll sum[112345], sum1[112345];
      |     ^~
a.cc:18:5: error: 'sum' was not declared in this scope
   18 |     sum[0] = 0;
      |     ^~~
a.cc:21:5: error: 'sum1' was not declared in this scope
   21 |     sum1[0] = 0;
      |     ^~~~
a.cc:28:32: error: 'upper_bound' was not declared in this scope
   28 |         int r = div_up(n - 1 + upper_bound(a, a + n, x[i]) - lower_bound(a, a + n, 0), 2);
      |                                ^~~~~~~~~~~