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

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

using namespace std;

void deleteRow(int h, int w, vector <vector<string> > &a){
	for (int i=0; i<h; i++){
		int counter = 0;
		for (int j=0; j<w; j++){
			if(a[i][j] == "#") counter++;
		}
		if (counter==0){
			a.erase(a.begin() + i);
			i--;
		}
	}
	return;
}

void deleteCol(int h, int w, vector <vector<string> > &a){
	for (int j=0; j<w; j++){
		int counter = 0;
		for (int i=0; i<h; i++){
			if(a[i][j] == "#") counter++;
		}
		if (counter==0){
			for (int i=0; i<h; i++){
				a[i].erase(a[i].begin() + j);
			j--;
		}
	}
	return;
}

int main(){
	int h, w;
	string tmp;
	vector <vector<string> > a;
	cin >> h >> w;
	a.resize(h);
	for (int i=0; i<h; i++){
		a[i].resize(w);
		for (int j=0; j<w; j++){
			cin >> tmp;
			a[i][j] = tmp;
		}
	}
	deleteRow(h, w, a);
	deleteCol(a.size(), w, a);

	//print
	for (int i=0; i<a.size(); i++){
		for (int j=0; j<a[i].size(); j++){
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'void deleteCol(int, int, std::vector<std::vector<std::__cxx11::basic_string<char> > >&)':
a.cc:36:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   36 | int main(){
      |         ^~
a.cc:36:9: note: remove parentheses to default-initialize a variable
   36 | int main(){
      |         ^~
      |         --
a.cc:36:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:36:11: error: a function-definition is not allowed here before '{' token
   36 | int main(){
      |           ^
a.cc:60:2: error: expected '}' at end of input
   60 | }
      |  ^
a.cc:21:58: note: to match this '{'
   21 | void deleteCol(int h, int w, vector <vector<string> > &a){
      |                                                          ^
Language: C

#include<stdio.h>

int main(void){
	int H, W, i, j, k, l;
	char a[100][100];
	int HCheck, WCheck;
	
	scanf("%d %d", &H, &W);
	
	for(i = 0; i < H; i++){
		WCheck = 0;
		for(j = 0; j < W; j++){
			scanf("%c", &a[i][j]);
			if(a[i][j] == '.')
				WCheck++;
		}
		if(WCheck == W){
			i--;
			H--;
		}
	}
	
	for(j = 0; j < W; j++){
		HCheck=0;
		for(i = 0; i < H; i++){
			if(a[i][j] == '.')
			HCheck++;
		}
		if(HCheck == H){
			for(k = j; k < W; k++){
				for(l = 0; l < H; l++){
					a[l][k] = a[l][k+1];
				}
			}
			W--;
		}
	}
	
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			printf("%c", a[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}#include<stdio.h>

int main(void){
	int H, W, i, j, k, l;
	char a[100][100];
	int HCheck, WCheck;
	
	scanf("%d %d", &H, &W);
	
	for(i = 0; i < H; i++){
		WCheck = 0;
		for(j = 0; j < W; j++){
			scanf("%c", &a[i][j]);
			if(a[i][j] == '.')
				WCheck++;
		}
		if(WCheck == W){
			i--;
			H--;
		}
	}
	
	for(j = 0; j < W; j++){
		HCheck=0;
		for(i = 0; i < H; i++){
			if(a[i][j] == '.')
			HCheck++;
		}
		if(HCheck == H){
			for(k = j; k < W; k++){
				for(l = 0; l < H; l++){
					a[l][k] = a[l][k+1];
				}
			}
			W--;
		}
	}
	
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			printf("%c", a[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}#include<stdio.h>

int main(void){
	int H, W, i, j, k, l;
	char a[100][100];
	int HCheck, WCheck;
	
	scanf("%d %d", &H, &W);
	
	for(i = 0; i < H; i++){
		WCheck = 0;
		for(j = 0; j < W; j++){
			scanf("%c", &a[i][j]);
			if(a[i][j] == '.')
				WCheck++;
		}
		if(WCheck == W){
			i--;
			H--;
		}
	}
	
	for(j = 0; j < W; j++){
		HCheck=0;
		for(i = 0; i < H; i++){
			if(a[i][j] == '.')
			HCheck++;
		}
		if(HCheck == H){
			for(k = j; k < W; k++){
				for(l = 0; l < H; l++){
					a[l][k] = a[l][k+1];
				}
			}
			W--;
		}
	}
	
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			printf("%c", a[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}

Compiler output:
main.c:47:2: error: stray '#' in program
   47 | }#include<stdio.h>
      |  ^
main.c:47:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   47 | }#include<stdio.h>
      |          ^
main.c:93:2: error: stray '#' in program
   93 | }#include<stdio.h>
      |  ^
main.c:93:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
   93 | }#include<stdio.h>
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  int c=0;
  cin>>h>>w;
  string s[h];
  for(int i=0;i<h;i++) cin>>s[i];
  for(int i=0;i<h;i++){
    int a=0;
    for(int j=0;j<w;j++){
      if(s[i].at(j)==‘#’)
        a++;
    }
    if(a==0){
      string t=s[i];
      for(int k=i-1;k<=0;k=k-1){
        s[k+1]=s[k];
      }
      s[0]=t;
      c++;
    }
  }
  for(int i=0;i<w;i++){
    int d=0;
    for(int j=0;j<h;j++){
      if(s[j].at(i)==‘#’)
        d++;
    }
    if(d==0){
      for(int l=0;l<h;l++)
        s[l].erase(i,1);
    }
  }
  for(int i=c;i<h;i++)
  cout<<s[i]<<endl;
}

Compiler output:
a.cc:12:22: error: extended character ‘ is not valid in an identifier
   12 |       if(s[i].at(j)==‘#’)
      |                      ^
a.cc:12:23: error: stray '#' in program
   12 |       if(s[i].at(j)==‘#’)
      |                       ^
a.cc:12:24: error: extended character ’ is not valid in an identifier
   12 |       if(s[i].at(j)==‘#’)
      |                        ^
a.cc:27:22: error: extended character ‘ is not valid in an identifier
   27 |       if(s[j].at(i)==‘#’)
      |                      ^
a.cc:27:23: error: stray '#' in program
   27 |       if(s[j].at(i)==‘#’)
      |                       ^
a.cc:27:24: error: extended character ’ is not valid in an identifier
   27 |       if(s[j].at(i)==‘#’)
      |                        ^
a.cc: In function 'int main()':
a.cc:12:22: error: '\U00002018' was not declared in this scope
   12 |       if(s[i].at(j)==‘#’)
      |                      ^
a.cc:12:23: error: expected ')' before '\U00002019'
   12 |       if(s[i].at(j)==‘#’)
      |         ~             ^~
      |                       )
a.cc:27:22: error: '\U00002018' was not declared in this scope
   27 |       if(s[j].at(i)==‘#’)
      |                      ^
a.cc:27:23: error: expected ')' before '\U00002019'
   27 |       if(s[j].at(i)==‘#’)
      |         ~             ^~
      |                       )
Language: C++

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

char fi[105][105];
int n,m;
bool ix[105];
bool iy[105];

int main()
{
cin >> n >> m;
for(int i=1;i<=n;i++)
{
getchar();
for(int j=1;j<=m;j++)
{
scanf("%c",&fi[i][j]);
if(fi[i][j] == '#')
{
ilx[i] = 1;
ily[j] = 1;
}
}
}
for(int i=1;i<=n;i++)
{
if(!ilx[i]) continue;
for(int j=1;j<=m;j++)
{
if(!ily[j]) continue;
printf("%c",fi[i][j]);
}
printf("\n");
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:1: error: 'ilx' was not declared in this scope; did you mean 'ix'?
   20 | ilx[i] = 1;
      | ^~~
      | ix
a.cc:21:1: error: 'ily' was not declared in this scope; did you mean 'iy'?
   21 | ily[j] = 1;
      | ^~~
      | iy
a.cc:27:5: error: 'ilx' was not declared in this scope; did you mean 'ix'?
   27 | if(!ilx[i]) continue;
      |     ^~~
      |     ix
a.cc:30:5: error: 'ily' was not declared in this scope; did you mean 'iy'?
   30 | if(!ily[j]) continue;
      |     ^~~
      |     iy
Language: C++

#include <iostream>
using namespace std;
int main(void)
{
    int x,y,z;
    cin x >> y;
    for(int i = 0;i <= x - 1;i++)
    {
        for(int n = 0;n <= y - 1;n++)
        {
            cin >> z[i][n];
        }
    }
    
    
    for(m = 0;m <= x - 1;m++)
    {
        if(z[m][0] == ".")
        {
            for(i = 0;i <= y;i++)
            {
                if(z[m][i] == ".")
                {
                    continue;
                }
                else
                    break;
                if(i == y - 1)
                {
                    x = x - 1;
                }
            }
        }
    }
    for(n = 0;n <= x -1;n++)
    {
        {
            if(z[0][n] == ".")
            {
                continue;
            }
            else
                break;
            if(n == x - 1)
            {
                y = y - 1;
            }
        }
    }
    
    for(int i = 0;i <= x;i++)
    {
        for(int m = 0;m <= y;m++)
        {
            cout << z[i][m];
            if(m == y)
                cout << endl;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:8: error: expected ';' before 'x'
    6 |     cin x >> y;
      |        ^~
      |        ;
a.cc:11:21: error: invalid types 'int[int]' for array subscript
   11 |             cin >> z[i][n];
      |                     ^
a.cc:16:9: error: 'm' was not declared in this scope
   16 |     for(m = 0;m <= x - 1;m++)
      |         ^
a.cc:20:17: error: 'i' was not declared in this scope
   20 |             for(i = 0;i <= y;i++)
      |                 ^
a.cc:35:9: error: 'n' was not declared in this scope
   35 |     for(n = 0;n <= x -1;n++)
      |         ^
a.cc:38:17: error: invalid types 'int[int]' for array subscript
   38 |             if(z[0][n] == ".")
      |                 ^
a.cc:55:22: error: invalid types 'int[int]' for array subscript
   55 |             cout << z[i][m];
      |                      ^
Language: C++

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <algorithm> 
#include <string>

#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define sum(n) accumulate((n).begin(), (n).end(), 0)
using namespace std;


int main(){
	int h, w,check,outcheck;
	char cell[100][100];
	bool is_space_w[100], is_space_h[100];

	check = 0;
	outcheck = 0;

	rep(i, 100) {
		is_space_w[i] = false;
		is_space_h[i] = false;

	}
	
	cin >> h >> w;

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

	rep(i, h) {
		check = 0;
		rep(j, w) {
			if (cell[i][j] == '.') {
				check++;
			}
			
		}

		if(check == w) {
			is_space_h[i] = true;
		}
		
	}

	rep(i, w) {
		check = 0;
		rep(j, h) {
			if (cell[j][i] == '.') {
				check++;
			}
			
		}

		if (check == h) {
			is_space_w[i] = true;
		}
	}
	cout << endl;

	rep(i, h) {
		outcheck = 0;
		rep(j, w) {
			if (!(is_space_w[j] || is_space_h[i])) {
				cout << cell[i][j];
				outcheck++;
			}
		}
		if (outcheck != 0) {
			cout << endl;
		}
		
	}

}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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


int main() {
	int h, w;
	cin >> h >> w;
	char field[100][100] = {};

	REP(i, h) {
		REP(j, w) {
			cin >> field[i][j];
		}
	}

	VI yoko(0);
	VI tate(0);
	REP(i, h) {
		REP(j, w) {
			if (field[i][j] == '#') {
				yoko.push_back(i);
				tate.push_back(j);
			}
		}
	}

	SORT(yoko);
	SORT(tate);

	yoko.erase(unique(yoko.begin(), yoko.end()), yoko.end());
	tate.erase(unique(tate.begin(), tate.end()), tate.end());

	for each (int i in yoko) {
		for each (int j in tate) {
			cout << field[i][j];
		}
		cout << endl;
	}


	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:67:13: error: expected '(' before 'each'
   67 |         for each (int i in yoko) {
      |             ^~~~
      |             (
a.cc:67:19: error: expected primary-expression before 'int'
   67 |         for each (int i in yoko) {
      |                   ^~~
a.cc:67:13: error: 'each' was not declared in this scope
   67 |         for each (int i in yoko) {
      |             ^~~~
a.cc:75:9: error: expected primary-expression before 'return'
   75 |         return 0;
      |         ^~~~~~
a.cc:72:10: error: expected ';' before 'return'
   72 |         }
      |          ^
      |          ;
......
   75 |         return 0;
      |         ~~~~~~
a.cc:75:9: error: expected primary-expression before 'return'
   75 |         return 0;
      |         ^~~~~~
a.cc:72:10: error: expected ')' before 'return'
   72 |         }
      |          ^
      |          )
......
   75 |         return 0;
      |         ~~~~~~
a.cc:67:13: note: to match this '('
   67 |         for each (int i in yoko) {
      |             ^~~~
Language: C

#include <stdio.h>

int main(){
   int h,w,i,j,k;
   char a[100][100],c;

   scanf("%d %d",&h,&w);
   for (i=0;i<h;i++) {
      for (j=k=0;j<w;j++) {
          scanf("%c",&a[i][j]);
          if (a[i][j]=='#') k=1;
      }
      scanf("%c",&c);
      if (k==0) {
         i--;
         h--;
      }
   }
   for (j=k=0;j<w;j++) {
      for (i=l=0;i<h;i++) {
          a[i][k]=a[i][j];
          if (a[i][k]=='#') l=1;
      }
      if (l==1) k++;
   }
   for (i=0;i<h;i++) {
       for (j=0;j<=k;j++) printf("%c",a[i][j]);
       puts("");
   }
   return 0;
}


Compiler output:
main.c: In function 'main':
main.c:20:14: error: 'l' undeclared (first use in this function)
   20 |       for (i=l=0;i<h;i++) {
      |              ^
main.c:20:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> G(H);
  rep(i, H) {
    cin >> G[i];
  }
  vector<int> rows, cols;
  rep(i, H) {
    bool ok = true;
    rep(k, W) if (G[i][k] == '.') {
      ok = false;
      break;
    }
    if (ok) rows.push_back(i);
  }
  rep(k, W) {
    bool ok = true;
    rep(i, H) if (G[i][k] == '.') {
      ok = false;
      break;
    }
    if (ok) cols.push_back(i);
  }
  for (auto r : rows) {
    for (auto c : cols) cout << G[r][c];
    cout << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:28: error: 'i' was not declared in this scope
   30 |     if (ok) cols.push_back(i);
      |                            ^
Language: C++

#include<iostream>

using namespace std;
int main(){
	 string a[105];
	 int n,m,x1[105],y1[105];
	 memset(x1,0,sizeof(x1));
	 memset(y1,0,sizeof(y1));
	 cin>>n>>m;
	 for(int i = 0;i < n;i++){
			 string s;
			 cin>>s;
			 a[i] = s;
 	}
	for(int i = 0;i < n;i++){
		int flag = 1;
		for(int j =0;j < m;j++){
			if(a[i][j] != '.'){
				flag = 0;
			}
		}
		if(flag){
			x1[i] = 1;
		}
	}
	for(int i = 0;i < m;i++){
		int flag = 1;
		for(int j = 0;j < n;j++){
			if(a[j][i] != '.'){
				flag = 0;
			}
		}
		if(flag){
			y1[i] = 1;
		}
	}
	for(int i = 0;i < n;i++){
		if(x1[i]) continue;
		for(int j = 0; j < n;j++){
			if(y1[j]) continue;
			cout<<a[i][j];
		}
		cout<<'\n';
	}
} 

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

<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}
$temp = getq(1);
$H = $temp[0];
$W = $temp[1];
$MAP = array();
for($i=0;$i<$H;$i++){
    $temp = getq();
    if(strpos($temp,'#') === false){}else{
        array_push($MAP,$temp);
    }
}
for($i=0;$i<strlen($MAP[0]);$i++){
    $check = true;
    for($j=0;$j<count($MAP);$j++){
        if($MAP[$j][$i]=='#')$check=false;
    }
    if($check){
        for($j=0;$j<count($MAP);$j++){
            $MAP[$j][$i]="0";
        }
    }
}

//print_r($MAP);

for($i=0;$i<count($MAP);$i++){
    if($MAP[$i]!=="")
        echo str_replace('0',"","$MAP[$i]\n");
}
?>

Compiler output:
a.cc:1:1: error: expected unqualified-id before '<' token
    1 | <?php
      | ^
a.cc:10:1: error: '$temp' does not name a type
   10 | $temp = getq(1);
      | ^~~~~
a.cc:11:1: error: '$H' does not name a type
   11 | $H = $temp[0];
      | ^~
a.cc:12:1: error: '$W' does not name a type
   12 | $W = $temp[1];
      | ^~
a.cc:13:1: error: '$MAP' does not name a type
   13 | $MAP = array();
      | ^~~~
a.cc:14:1: error: expected unqualified-id before 'for'
   14 | for($i=0;$i<$H;$i++){
      | ^~~
a.cc:14:10: error: '$i' does not name a type
   14 | for($i=0;$i<$H;$i++){
      |          ^~
a.cc:14:16: error: '$i' does not name a type
   14 | for($i=0;$i<$H;$i++){
      |                ^~
a.cc:20:1: error: expected unqualified-id before 'for'
   20 | for($i=0;$i<strlen($MAP[0]);$i++){
      | ^~~
a.cc:20:10: error: '$i' does not name a type
   20 | for($i=0;$i<strlen($MAP[0]);$i++){
      |          ^~
a.cc:20:29: error: '$i' does not name a type
   20 | for($i=0;$i<strlen($MAP[0]);$i++){
      |                             ^~
a.cc:34:1: error: expected unqualified-id before 'for'
   34 | for($i=0;$i<count($MAP);$i++){
      | ^~~
a.cc:34:10: error: '$i' does not name a type
   34 | for($i=0;$i<count($MAP);$i++){
      |          ^~
a.cc:34:25: error: '$i' does not name a type
   34 | for($i=0;$i<count($MAP);$i++){
      |                         ^~
a.cc:38:1: error: expected unqualified-id before '?' token
   38 | ?>
      | ^
Language: C

#include <stdio.h>

int main(){
   int h,w,i,j,k;
   char a[100,100];

   scanf("%d %d",&h,&w);
   for (i=0;i<h;i++) {
      for (j=k=0;j<w;j++) {
          scanf("%c",&a[i,j]);
          if (a[i,j]=='#') k=1;
      }
      scanf("%c",&c);
      if (k==0) {
         i--;
         h--;
      }
   }
   for (j=k=0;j<w;j++) {
      for (i=l=0;i<h;i++) {
          a[i,k]=a[i,j];
          if (a[i,k]=='#') l=1;
      }
      if (l==1) k++;
   }
   for (i=0;i<h;i++) {
       for (j=0;j<=k;j++) printf("%c",a[i,j]);
       puts("");
   }
   return 0;
}


Compiler output:
main.c: In function 'main':
main.c:5:14: error: expected ']' before ',' token
    5 |    char a[100,100];
      |              ^
      |              ]
main.c:10:23: error: 'a' undeclared (first use in this function)
   10 |           scanf("%c",&a[i,j]);
      |                       ^
main.c:10:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:13:19: error: 'c' undeclared (first use in this function)
   13 |       scanf("%c",&c);
      |                   ^
main.c:20:14: error: 'l' undeclared (first use in this function)
   20 |       for (i=l=0;i<h;i++) {
      |              ^
Language: C

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

int main()
{
	int x,y;
	cin>>x>>y;
	char a[105][105];
	bool s[105][105];
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
		{
			cin>>a[i][j];
			s[i][j]=1;
		}	
	for(int i=1;i<=x;i++)
	{
		int f=1;
		for(int j=1;j<=y;j++)
		{
			if(a[i][j]=='#'){
				f=0;
				break;
			} 
		}
		if(f){
			for(int j=1;j<=y;j++)
				s[i][j]=false;
		}
	}
	for(int j=1;j<=y;j++)
	{
		int f=1;
		for(int i=1;i<=x;i++)
		{
			if(a[i][j]=='#'){
				f=0;
				break;
			} 
		}
		if(f){
			for(int i=1;i<=x;i++)
				s[i][j]=false;
		}
	}
	for(int i=1;i<=x;i++)
	{
		int f=0;
		for(int j=1;j<=y;j++)
		{
			if(s[i][j]){
				cout<<a[i][j];
				f=1;
			} 
		}
		if(f) cout<<endl;
	}
	return 0;
}


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

#include <stdio.h>

int main(){
   int h,w,i;j,k;
   char a[100,100];

   scanf("%d %d",&h,&w);
   for (i=0;i<h;i++) {
      for (j=k=0;j<w;j++) {
          scanf("%c",&a[i,j]);
          if (a[i,j]=='#') k=1;
      }
      scanf("%c",&c);
      if (k==0) {
         i--;
         h--;
      }
   }
   for (j=k=0;j<w;j++) {
      for (i=l=0;i<h;i++) {
          a[i,k]=a[i,j];
          if (a[i,k]=='#') l=1;
      }
      if (l==1) k++;
   }
   for (i=0;i<h;i++) {
       for (j=0;j<=k;j++) printf("%c",a[i,j]);
       puts("");
   }
   return 0;
}


Compiler output:
main.c: In function 'main':
main.c:4:14: error: 'j' undeclared (first use in this function)
    4 |    int h,w,i;j,k;
      |              ^
main.c:4:14: note: each undeclared identifier is reported only once for each function it appears in
main.c:4:16: error: 'k' undeclared (first use in this function)
    4 |    int h,w,i;j,k;
      |                ^
main.c:5:14: error: expected ']' before ',' token
    5 |    char a[100,100];
      |              ^
      |              ]
main.c:10:23: error: 'a' undeclared (first use in this function)
   10 |           scanf("%c",&a[i,j]);
      |                       ^
main.c:13:19: error: 'c' undeclared (first use in this function)
   13 |       scanf("%c",&c);
      |                   ^
main.c:20:14: error: 'l' undeclared (first use in this function)
   20 |       for (i=l=0;i<h;i++) {
      |              ^
Language: C++

#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
void GridCompression() {
	int H, W;
	cin >> H >> W;
	char a[101][101];
	bool h[101],w[101];
	memset(h, false, sizeof(h));
	memset(w, false, sizeof(w));

	for (size_t i = 0; i < H; i++)
	{
		for (size_t j = 0; j < W; j++)
		{
			cin >> a[i][j];
			if (a[i][j] == '#') {
				h[i] = true;
				w[j] = true;
			}
		}
	}

	for (size_t i = 0; i < H; i++)
	{
		if (!h[i]) continue;
		for (size_t j = 0;  j < W;  j++)
		{
			if (!w[j]) continue;
			cout << a[i][j];
		}
		cout << "\n";
	}
}

int main() {
	GridCompression();
	return 0;
}

Compiler output:
a.cc:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
a.cc: In function 'void GridCompression()':
a.cc:24:9: error: 'memset' was not declared in this scope
   24 |         memset(h, false, sizeof(h));
      |         ^~~~~~
a.cc:17:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   16 | #include <cmath>
  +++ |+#include <cstring>
   17 | #include <deque>
Language: C++

#include <iostream>

using namespace std;

const int maxn = 100 + 5;

int h, w;
char m[maxn][maxn];
int sumr[maxn], sumc[maxn];

void init() {
    cin >> h >> w;
    for(int i = 0 ; i < h ; i++) scanf("%s", m[i]);
    
    memset(sumr, 0, sizeof(sumr));
    memset(sumc, 0, sizeof(sumc));
    
    for(int i = 0 ; i < h ; i++) {
        int sum = 0;
        for(int j = 0 ; j < w ; j++) {
            sum += (m[i][j] == '#' ? 1 : 0);
        }
        sumr[i] = sum;
    }
    
    for(int j = 0 ; j < w ; j++) {
        int sum = 0;
        for(int i = 0 ; i < h ; i++) {
            sum += (m[i][j] == '#' ? 1 : 0);
        }
        sumc[j] = sum;
    }
}

void solve() {
    for(int i = 0 ; i < h ; i++) {
        for(int j = 0 ; j < w ; j++) {
            if(sumr[i] == 0 || sumc[j] == 0) continue;
            putchar(m[i][j]);
        }
        if(sumr[i] > 0) putchar('\n');
    }
}

int main() {
    init();
    solve();
}


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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
const int inf = 1e9;  // 1(1倍)e(指数)9(10^9)
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<ll> x(n);
    rep(i, n) scanf("%lld", &x[i]);

    // 単純に考えれば選ぶのは原点から近いもの。また、選ぶろうそくの間を開けるのは明らかに非効率です。よって、原点を含む連続したK本のろうそくの選び方のうち、一番短いものはどれか。
    ll ans = inf;
    for (int i = 0; i + k - 1 < N; ++i) {
        ll left = x[i], right = x[i + k - 1];
        // スタートする地点を右端からにするか左端からにするかは座標0から近い方を選んでる min(abs(left), abs(right))
        ans = min(ans, min(abs(left), abs(right)) + right - left);
    }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:14:33: error: 'N' was not declared in this scope
   14 |     for (int i = 0; i + k - 1 < N; ++i) {
      |                                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
const int inf = 1e9;  // 1(1倍)e(指数)9(10^9)
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<ll> x(n);
    rep(i, n) scanf("%d", &x[i]);

    // 単純に考えれば選ぶのは原点から近いもの。また、選ぶろうそくの間を開けるのは明らかに非効率です。よって、原点を含む連続したK本のろうそくの選び方のうち、一番短いものはどれか。
    ll ans = inf;
    for (int i = 0; i + k - 1 < N; ++i) {
        ll left = x[i], right = x[i + k - 1];
        // スタートする地点を右端からにするか左端からにするかは座標0から近い方を選んでる min(abs(left), abs(right))
        ans = min(ans, min(abs(left), abs(right)) + right - left);
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:33: error: 'N' was not declared in this scope
   14 |     for (int i = 0; i + k - 1 < N; ++i) {
      |                                 ^
Language: C

#include <stdio.h>
int main(void){
    int x[9<<14];
    int i=0;
    int j=0;
    int min=9<<25;
    
    for(;~scanf("%d",x+i);i++);
    for(j=2;j<x[0]-x[1]+3;j++)min=fmin(x[j+x[1]-1]-x[j]+fmin(abs(x[j]),abs(x[j+x[1]-1])),min);
    
    printf("%d",min);

Compiler output:
main.c: In function 'main':
main.c:9:35: error: implicit declaration of function 'fmin' [-Wimplicit-function-declaration]
    9 |     for(j=2;j<x[0]-x[1]+3;j++)min=fmin(x[j+x[1]-1]-x[j]+fmin(abs(x[j]),abs(x[j+x[1]-1])),min);
      |                                   ^~~~
main.c:2:1: note: include '<math.h>' or provide a declaration of 'fmin'
    1 | #include <stdio.h>
  +++ |+#include <math.h>
    2 | int main(void){
main.c:9:35: warning: incompatible implicit declaration of built-in function 'fmin' [-Wbuiltin-declaration-mismatch]
    9 |     for(j=2;j<x[0]-x[1]+3;j++)min=fmin(x[j+x[1]-1]-x[j]+fmin(abs(x[j]),abs(x[j+x[1]-1])),min);
      |                                   ^~~~
main.c:9:35: note: include '<math.h>' or provide a declaration of 'fmin'
main.c:9:62: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
    9 |     for(j=2;j<x[0]-x[1]+3;j++)min=fmin(x[j+x[1]-1]-x[j]+fmin(abs(x[j]),abs(x[j+x[1]-1])),min);
      |                                                              ^~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | int main(void){
main.c:11:5: error: expected declaration or statement at end of input
   11 |     printf("%d",min);
      |     ^~~~~~
Language: C

#include <stdio.h>
int main(void){
    int n,k;
    int x[9<<14];
    int i=0;
    int j=0
    int min=9<<25;
    
    scanf("%d%d",&n,&k);
    for(;~scanf("%d",x+i);i++){
        ;
    }
    
    for(;j<n-k+1;j++){
        min=fmin(x[j+k-1]-x[j]+fmin(abs(x[j]),abs(x[j+k-1])),min);
    }
    printf("%d",min);
}

Compiler output:
main.c: In function 'main':
main.c:7:5: error: expected ',' or ';' before 'int'
    7 |     int min=9<<25;
      |     ^~~
main.c:15:9: error: 'min' undeclared (first use in this function); did you mean 'main'?
   15 |         min=fmin(x[j+k-1]-x[j]+fmin(abs(x[j]),abs(x[j+k-1])),min);
      |         ^~~
      |         main
main.c:15:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:15:13: error: implicit declaration of function 'fmin' [-Wimplicit-function-declaration]
   15 |         min=fmin(x[j+k-1]-x[j]+fmin(abs(x[j]),abs(x[j+k-1])),min);
      |             ^~~~
main.c:2:1: note: include '<math.h>' or provide a declaration of 'fmin'
    1 | #include <stdio.h>
  +++ |+#include <math.h>
    2 | int main(void){
main.c:15:13: warning: incompatible implicit declaration of built-in function 'fmin' [-Wbuiltin-declaration-mismatch]
   15 |         min=fmin(x[j+k-1]-x[j]+fmin(abs(x[j]),abs(x[j+k-1])),min);
      |             ^~~~
main.c:15:13: note: include '<math.h>' or provide a declaration of 'fmin'
main.c:15:37: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   15 |         min=fmin(x[j+k-1]-x[j]+fmin(abs(x[j]),abs(x[j+k-1])),min);
      |                                     ^~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | int main(void){
Language: C++

#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n,k,in;
	cin >> n >> k;
	vector<int> x;
	REP(i,n){
		cin >> in;
		x.push_back(in);
	}
	
	ll ans = 1LL<<60;
	for(int i=0; i<n-k+1; i++){
		int a=0;
		if(x[i]*x[i+k-1] < 0){
			a += 2*min(abs(x[i]), abs(x[i+k-1]));
			a += max(abs(x[i]), abs(x[i+k-1]));
		}else{
			a += max(abs(x[i]), abs(x[i+k-1]));
		}
		chmin(ans, a);
	}
	
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:22: error: no matching function for call to 'chmin(ll&, int&)'
   37 |                 chmin(ans, a);
      |                 ~~~~~^~~~~~~~
a.cc:17:31: note: candidate: 'template<class T> bool chmin(T&, T)'
   17 | template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}
      |                               ^~~~~
a.cc:17:31: note:   template argument deduction/substitution failed:
a.cc:37:22: note:   deduced conflicting types for parameter 'T' ('long long int' and 'int')
   37 |                 chmin(ans, a);
      |                 ~~~~~^~~~~~~~
Language: C++

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

int main(){
    ll MX = 1e18;
    int n,k;
    cin >> n >> k;
    vector<int> neg,pos;
    rep(i,n){
        int temp;cin >> temp;
        if(temp == 0) k--;
        else if(temp < 0) neg.push_back(temp);
        else pos.push_back(temp);
    }
    sort(neg.begin(),neg.end(),greater<int>());
    if(k =< 0){
        cout << 0 << endl;
        return 0;
    }
    int s = pos.size();
    int t = neg.size();
    ll ans = MX;
    ll total = 0;

    if(s >= k){
        total = pos[k-1];
        ans = min(ans,total);
    }
    if(t >= k){
        total = abs(neg[k-1]);
        ans = min(ans,total);
    }

    for(int i = max(0,k-t);i<=min(s-1,k-2);i++){
        total = 2*abs(neg[k-i-2]) + pos[i];
        ans = min(ans,total);
    }
    for(int i = max(0,k-s);i<=min(t-1,k-2);i++){
        total = 2*pos[k-i-2] + abs(neg[i]);
        ans = min(ans,total);
    }

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:11: error: expected primary-expression before '<' token
   21 |     if(k =< 0){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long int Min(long long int x,long long int y)
{
    if(x<y)
        return x;
    return y;
}
int main()
{
    long long int n,k,i,j;
    long long int ans;
    cin>>n>>k;
    int ara[n];
    for(i=0; i<n; i++)
        cin>>ara[i];

    if(ara[0]<0&&ara[n-1]<=0)
        ans=(-1)*ara[0];
    else if(ara[0]>=0 && ara[n-1]>0)
        ans=ara[n-1];
    else
        ans=(ara[n-1]-ara[0]-ara[0]);
    if(ara[0]>=0)
        cout<<ara[k-1]<<endl;
    else
    {
        for(i=0; i<=n-k; i++)
        {
            j=i+k-1;
            if(ara[i]=<0 && ara[j]>=0)
                ans=Min(ans,ara[j]-ara[i]-ara[i]);
            else if(ara[i]=<0 && ara[j]<=0)
                ans=Min(ans,(-1)*ara[i]);
            else
                ans=Min(ans,ara[j]);
        }
        cout<<ans<<endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:23: error: expected primary-expression before '<' token
   31 |             if(ara[i]=<0 && ara[j]>=0)
      |                       ^
a.cc:33:28: error: expected primary-expression before '<' token
   33 |             else if(ara[i]=<0 && ara[j]<=0)
      |                            ^
Language: C++

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N - K + 1; i++) {
    int l = x.at(i);
    int r = X.at(i + K - 1);
    if (r < 0) {
      ans = min(ans, l);
    }
    else if (l < 0) {
      ans = min(ans, abs(min(l, r) * 2) + max(l, r));
    }
    else {
      ans = min(ans, r);
    }
  }
  cout << ans << endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'X' was not declared in this scope
   14 |     int r = X.at(i + K - 1);
      |             ^
Language: C++

from pprint import pprint
N, K = map(int, input().split())
x = list(map(int, input().split()))

# mapping [X0...] [Xk-1...] by zip
#for a, b in zip(x, x[K-1:]):
#    print(a, b)
# the answer is the minimum number of Xi+k$B!](B1 $B!](B Xi + min(|Xi|,|Xi+k$B!](B1|) 
# the initial distance is always coordinate 0
ans = min(b - a + min(abs(a), abs(b)) for a, b in zip(x, x[K-1:]))
print(ans)

Compiler output:
a.cc:5:3: error: invalid preprocessing directive #mapping
    5 | # mapping [X0...] [Xk-1...] by zip
      |   ^~~~~~~
a.cc:6:2: error: invalid preprocessing directive #for
    6 | #for a, b in zip(x, x[K-1:]):
      |  ^~~
a.cc:7:6: error: invalid preprocessing directive #print
    7 | #    print(a, b)
      |      ^~~~~
a.cc:8:3: error: invalid preprocessing directive #the
    8 | # the answer is the minimum number of Xi+k$B!](B1 $B!](B Xi + min(|Xi|,|Xi+k$B!](B1|)
      |   ^~~
a.cc:9:3: error: invalid preprocessing directive #the
    9 | # the initial distance is always coordinate 0
      |   ^~~
a.cc:1:1: error: 'from' does not name a type
    1 | from pprint import pprint
      | ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll dx[8]={0,0,-1,1,-1,1,-1,1};
ll dy[8]={1,-1,0,0,1,1,-1,-1};
vector<vector<ll> > c(10,vector<ll>(10,0));

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    vector<ll> minus;
    vector<ll> plus;
    vector<ll> zero;
    rep(i,N){
        ll x; cin>>x;
        if(x<0) minus.pb(x);
        else if(x==0) zero.pb(x);
        else plus.pb(x);
    }
    ll m=sz(minus),p=sz(plus);
    minus.pb(0);
    plus.pb(0);
    
    ll ans=INF;
    rep(i,min(need,m)+1){
        ll X=-minus[i];
        ll Y=plus[need-i];
        
        chmin(ans,max(X,Y)+min(X,Y)*2);
    }
    cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:15: error: 'need' was not declared in this scope; did you mean 'ed'?
   65 |     rep(i,min(need,m)+1){
      |               ^~~~
a.cc:26:32: note: in definition of macro 'rep'
   26 | #define rep(i,n) for(ll i=0;i<(n);i++)
      |                                ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int func1(int a,int b){
    return min(abs(a) + abs(a-b), abs(b) + abs(a-b));
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> x(n); for(int i = 0; i < n; ++i){
        cin >> x[i];
    }
    long long ans = 1<<60;
    for(int i = 0; i < n-k; ++i){
        ans = min(ans, func1(x[i], x[i+k-1]));
    }
    if(ans == 1e9) ans = abs(x[0]);
    cout << ans << endl;
    return 0;
}
//Saw the solution video

Compiler output:
a.cc: In function 'int main()':
a.cc:15:22: warning: left shift count >= width of type [-Wshift-count-overflow]
   15 |     long long ans = 1<<60;
      |                     ~^~~~
a.cc:17:18: error: no matching function for call to 'min(long long int&, int)'
   17 |         ans = min(ans, func1(x[i], x[i+k-1]));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:17:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   17 |         ans = min(ans, func1(x[i], x[i+k-1]));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

ll a,w,t,r;

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  ll ans=0;
  char c[h][w];
  rep(i,h)rep(j,w)cin >> c[i][j];
  rep(bit,(1<<(h+w))){
    int cnt=0;
    rep(i,h){
      rep(j,w){
        if(c[i][j]=='#' && !( (bit & (1<<i)) && (bit & (1<<(h+j)))) )cnt++;
      }
    }
    if(cnt==k){
      ans++;
    }
  }
  cout << ans << endl;
return 0;

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

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
const int mx = 1e5 + 5;
int arr[mx];


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; ++ i) {
        cin >> arr[i];
    }
    k--;
    int ans = INT_MAX;
    for(int i = 0; i < n - k; ++i) {
        if(arr[i] >= 0 && arr[i + k] >= 0) {
            ans = min(ans, arr[i + k]);
        }
        else if(arr[i] <= 0 && arr[i + k] <= 0) {
            ans =min(ans, abs(arr[i]));
        }
        else {
            ans = min(ans, arr[i + k] * 2 - arr[i]);
            ans = min(ans, arr[i + k] - arr[i] * 2);
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:15: error: 'INT_MAX' was not declared in this scope
   64 |     int ans = INT_MAX;
      |               ^~~~~~~
a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <cassert>
  +++ |+#include <climits>
   11 |
Language: C++

/*
 * Author : Sadi
 * Sat 27/06/2020
 * 20:31:16.87
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
const int mx = 1e5 + 5;
lld arr[mx];
lld dis[mx];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    for(int i = 1; i < n; ++i) {
        dis[i] = dis[i - 1] + arr[i] - arr[i - 1];
    }
    long long ans = LONG_MAX;
    for(int i = k - 1; i < n; ++i) {
        ans = min(ans, abs(arr[i - (k - 1)]) + dis[i] - dis[i - (k - 1)]);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:21: error: 'LONG_MAX' was not declared in this scope
   70 |     long long ans = LONG_MAX;
      |                     ^~~~~~~~
a.cc:15:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   14 | #include <cassert>
  +++ |+#include <climits>
   15 |
Language: C++

#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

ll calc(ll l, ll r){
	ll ll = abs(l) + abs(l) + r;
	ll rr = r + r + abs(l);
	return  min(ll, rr);
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll n, k;
	cin >> n >> k;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];
	vector<ll> v, rv;
	v.push_back(0);
	rrep(i, n){
		if(x[i] < 0) v.push_back(x[i]);
		else rv.push_back(x[i]);
	}
	reverse(ALL(rv));
	// print(rv);
	// print(v);

	ll ans = INTINF;
	rep(i, v.size()){
		if(k - i - 1 >= rv.size()) continue;
		ll res = calc(v[i], rv[k - i - 1]);
		// print(res);
		chmin(ans, res);
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'll calc(ll, ll)':
a.cc:52:11: error: expected ';' before 'rr'
   52 |         ll rr = r + r + abs(l);
      |           ^~~
      |           ;
a.cc:53:25: error: 'rr' was not declared in this scope; did you mean 'r'?
   53 |         return  min(ll, rr);
      |                         ^~
      |                         r
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long a,k,x[100005],ans=999999999999;
int main()
{
	cin>>a>>n;
	for(int i=1;i<=a;i++)
	{
		cin>>x[i];
		if(i>=k)
		{
			if(x[i]<=0&&x[i-k+1]<=0)
				ans=min(ans,-x[i-k+1]);
			else if(x[i]>0&&x[i-k+1]<=0)
				ans=min(ans,x[i]-x[i-k+1]*2);
			else if(x[i]>=0&&x[i-k+1]>=0)
				ans=min(ans,x[i]);
		}
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:17: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 |         cin>>a>>n;
      |                 ^
      |                 yn