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

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

int n, sum;
vector<int> a;
vector<char> sign;

bool solve(){
  sum = a[0];
  rep(j, n-1){
    if(sign[j] == '+'){
      sum += a[j+1];
    }else{
      sum -= a[j+1];
    }

  if(sum == 7) return true;
  return false;
}

void print(){
  rep(i, n){
    if(i) cout << sign[i-1];
    cout << a[i];
  }
  cout << '=' << 7 << endl;
}

int main(){
  string s;
  cin >> s;

  n = s.size();
  a.resize(n, 0);
  rep(i, n){
    a[i] = s[i] - '0';
  }

  sign.resize(n-1, '+');
  if(solve()){
    print(); return 0;
  }

  rep(i, n-1){
    sign[i] = '-';
    if(solve()){
      print(); return 0;
    }else{
      sign[i] = '+';
    }
  }

  sign[0] = '-'; sign[1] = '-';
  if(solve()){
    print(); return 0;
  }
  sign.resize(n-1, '+');

  sign[1] = '-'; sign[2] = '-';
  if(solve()){
    print(); return 0;
  }
  sign.resize(n-1, '+');

  sign[2] = '-'; sign[0] = '-';
  if(solve()){
    print(); return 0;
  }

  sign.resize(n-1, '-');
  if(solve()){
    print(); return 0;
  }

  return 0;
}


Compiler output:
a.cc: In function 'bool solve()':
a.cc:24:13: error: a function-definition is not allowed here before '{' token
   24 | void print(){
      |             ^
a.cc:32:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   32 | int main(){
      |         ^~
a.cc:32:9: note: remove parentheses to default-initialize a variable
   32 | int main(){
      |         ^~
      |         --
a.cc:32:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:32:11: error: a function-definition is not allowed here before '{' token
   32 | int main(){
      |           ^
a.cc:79:2: error: expected '}' at end of input
   79 | }
      |  ^
a.cc:11:13: note: to match this '{'
   11 | bool solve(){
      |             ^
a.cc:79:2: warning: control reaches end of non-void function [-Wreturn-type]
   79 | }
      |  ^
Language: C++

#include <string>

using namespace std;

int main() {
    
    string str;
    cin >> str;
    int A[4][2];
    
    for (int i =0;  i<4;  i++) {
        A[i][0] = str[i] - '0';
        A[i][1] = -A[i][0];
    }
    
    int result;
    string PM = "+-";
    string op[4] = {""};
    
    for (int j=0; j <2; j++) {
        for (int k=0; k <2; k++) {
            for (int l=0; l<2; l++) {
                    
                result = A[0][0]+A[1][j]+A[2][k]+A[3][l];
                    
                if(result == 7) {
                        op[1]=PM[j];
                        op[2]=PM[k];
                        op[3]=PM[l];
                        break;
                }
            }
        }
    }
    
    cout << A[0][0] << op[1] <<A[1][0] << op[2] <<A[2][0] << op[3] <<A[3][0] << "=" << 7 <<endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'cin' was not declared in this scope
    8 |     cin >> str;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <string>
  +++ |+#include <iostream>
    2 | 
a.cc:36:5: error: 'cout' was not declared in this scope
   36 |     cout << A[0][0] << op[1] <<A[1][0] << op[2] <<A[2][0] << op[3] <<A[3][0] << "=" << 7 <<endl;
      |     ^~~~
a.cc:36:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:36:92: error: 'endl' was not declared in this scope
   36 |     cout << A[0][0] << op[1] <<A[1][0] << op[2] <<A[2][0] << op[3] <<A[3][0] << "=" << 7 <<endl;
      |                                                                                            ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <string>
  +++ |+#include <ostream>
    2 |
Language: C++

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

int main(){
  int n;
  cin >> n;
  to_string(n);
  int a=stoi(n.at(0));
  int b=stoi(n.at(1));
  int c=stoi(n.at(2));
  int d=stoi(n.at(3));
  if(a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << endl;
  else if(a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d << endl;
  else if(a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d << endl;
  else if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << endl;
  else if(a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d << endl;
  else if(a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d << endl;
  else if(a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d << endl;
  else cout << a << "+" << b << "-" << c << "-" << d << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: warning: ignoring return value of 'std::string std::__cxx11::to_string(int)', declared with attribute 'nodiscard' [-Wunused-result]
    9 |   to_string(n);
      |   ~~~~~~~~~^~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4240:3: note: declared here
 4240 |   to_string(int __val)
      |   ^~~~~~~~~
a.cc:10:16: error: request for member 'at' in 'n', which is of non-class type 'int'
   10 |   int a=stoi(n.at(0));
      |                ^~
a.cc:11:16: error: request for member 'at' in 'n', which is of non-class type 'int'
   11 |   int b=stoi(n.at(1));
      |                ^~
a.cc:12:16: error: request for member 'at' in 'n', which is of non-class type 'int'
   12 |   int c=stoi(n.at(2));
      |                ^~
a.cc:13:16: error: request for member 'at' in 'n', which is of non-class type 'int'
   13 |   int d=stoi(n.at(3));
      |                ^~
Language: C++

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

string s;
int a=s[0],b=s[1],c=s[2],d=s[3];
string kigo[3];

int find(int i,int sum) {
    if(i==4 && sum==7) {
        cout<<s[0]<<kigo[0]<<s[1]<<kigo[1]<<s[2]<<kigo[2]<<s[3]<<"=7"<<endl;
        break;
    }
    else(i==4 && sum!=7) return;

    kigo[i]='+';
    find(i+1,sum+s[i]);

    kigo[i]='-';
    find(i+1,sum-s[i]);
}

int main() {
    find(0,0);
    return 0;
}

Compiler output:
a.cc: In function 'int find(int, int)':
a.cc:14:9: error: break statement not within loop or switch
   14 |         break;
      |         ^~~~~
a.cc:16:25: error: expected ';' before 'return'
   16 |     else(i==4 && sum!=7) return;
      |                         ^~~~~~~
      |                         ;
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
Language: C++

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

int main(){
  string S; cin >> S;
  int A, B, C, D;
  vector<char> op(3);
  vector<int> a(4);
  int sum;
  
  rep(i,4){
    a[i] = S[i] - '0';
  }
  
  for(int bit =0; bit <(1 << 3); bit++){
    sum = a[0];
    
    for(i,3){
      if(bit &(1 << i)){
        sum += a[i+1];
        op[i] = '+';
      }
      else{
        sum -= a[i+1];
        op[i] = '-';
      }
    }
    if(sum == 7){
      break;
    }
  }
  cout << a[0] << op[0] << a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
}
    
  


Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'i' was not declared in this scope
   20 |     for(i,3){
      |         ^
a.cc:30:5: error: expected primary-expression before 'if'
   30 |     if(sum == 7){
      |     ^~
a.cc:29:6: error: expected ';' before 'if'
   29 |     }
      |      ^
      |      ;
   30 |     if(sum == 7){
      |     ~~
a.cc:30:5: error: expected primary-expression before 'if'
   30 |     if(sum == 7){
      |     ^~
a.cc:29:6: error: expected ')' before 'if'
   29 |     }
      |      ^
      |      )
   30 |     if(sum == 7){
      |     ~~
a.cc:20:8: note: to match this '('
   20 |     for(i,3){
      |        ^
Language: C++

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

int main(){
  string S; cin >> S;
  int A; B; C; D;
  vector<char> op(3);
  vector<int> a(4);
  int sum;
  
  rep(i,4){
    a[i] = S[i] - '0';
  }
  
  for(int bit =0; bit <(1 << 3)); bit++){
    sum = a[0];
    
    for(i,3){
      if(bit &(1 << i)){
        sum += a[i+1];
        op[i] = '+';
      }
      else{
        sum -= a[i+1];
        op[i] = '-';
      }
    }
    if(sum == 7){
      break;
    }
  }
  cout << a[0] << op[0] << a[1] << op[1] << a[2] << op[2] << a[3] << "=7" << endl;
}
    
  

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'B' was not declared in this scope
    8 |   int A; B; C; D;
      |          ^
a.cc:8:13: error: 'C' was not declared in this scope
    8 |   int A; B; C; D;
      |             ^
a.cc:8:16: error: 'D' was not declared in this scope
    8 |   int A; B; C; D;
      |                ^
a.cc:17:32: error: expected ';' before ')' token
   17 |   for(int bit =0; bit <(1 << 3)); bit++){
      |                                ^
      |                                ;
a.cc:17:35: error: 'bit' was not declared in this scope
   17 |   for(int bit =0; bit <(1 << 3)); bit++){
      |                                   ^~~
Language: C++

x = input()
#print(x)
y = [int(c) for c in x]
#print(y)
a = y[0]
b = y[1]
c = y[2]
d = y[3]
if a+b+c+d == 7:
  print(a,"+",b,"+",c,"+",d,"=",a+b+c+d)
  exit()
if a+b+c-d == 7:
  print(a,"+",b,"+",c,"-",d,"=",a+b+c-d)
  exit()
if a+b-c+d == 7:
  print(a,"+",b,"-",c,"+",d,"=",a+b-c+d)
  exit()
if a-b+c+d == 7:
  print(a,"-",b,"+",c,"+",d,"=",a-b+c+d)
  exit()
if a-b-c+d == 7:
  print(a,"-",b,"-",c,"+",d,"=",a-b-c+d)
  exit()
if a-b+c-d == 7:
  print(a,"-",b,"+",c,"-",d,"=",a-b+c-d)
  exit()
if a-b-c-d == 7:
  print(a,"-",b,"-",c,"-",d,"=",a-b-c-d)
  exit()
if a+b-c-d == 7:
  print(a,"+",b,"-",c,"-",d,"=",a+b-c-d)
  exit()


Compiler output:
a.cc:2:2: error: invalid preprocessing directive #print
    2 | #print(x)
      |  ^~~~~
a.cc:4:2: error: invalid preprocessing directive #print
    4 | #print(y)
      |  ^~~~~
a.cc:1:1: error: 'x' does not name a type
    1 | x = input()
      | ^
Language: C++

int main()
{
    string s;
    cin >> s;
    for (int t = 0; t < (1 << 3); t++)
    {
        int num = s[0] - '0';
        string v;
        v += s[0];
        for (int i = 1; i < 4; i++)
        {
            if ((t >> (i - 1)) & 1){
                num += s[i] - '0';
                v += '+';
                v += s[i];
            }else{
                num -= s[i] - '0';
                v += '-';
                v += s[i];
            }
        }
        if (num == 7){
            cout << v << "=7" << endl;
            return 0;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'string' was not declared in this scope
    3 |     string s;
      |     ^~~~~~
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> s;
      |     ^~~
a.cc:4:12: error: 's' was not declared in this scope
    4 |     cin >> s;
      |            ^
a.cc:8:15: error: expected ';' before 'v'
    8 |         string v;
      |               ^~
      |               ;
a.cc:9:9: error: 'v' was not declared in this scope
    9 |         v += s[0];
      |         ^
a.cc:23:13: error: 'cout' was not declared in this scope
   23 |             cout << v << "=7" << endl;
      |             ^~~~
a.cc:23:34: error: 'endl' was not declared in this scope
   23 |             cout << v << "=7" << endl;
      |                                  ^~~~
Language: C++

#include<iostream>
using namespace std;

int main(){
	int a, b, c, d;
	int in
	cin >> in;
	a = in / 1000;
	b = (in / 100) % 10;
	c = (in / 10) % 10;
	d = in % 10;
	if (a+b+c+d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7";
	else if (a+b+c-d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7";
	else if (a+b-c+d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7";
	else if (a+b-c-d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7";
	else if (a-b+c+d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7";
	else if (a-b+c-d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7";
	else if (a-b-c+d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7";
	else if (a-b-c-d == 7) cout << a << '-' << b << '-' << c << '-' << d << "=7";
	return 0;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: expected initializer before 'cin'
    7 |         cin >> in;
      |         ^~~
a.cc:8:13: error: 'in' was not declared in this scope; did you mean 'int'?
    8 |         a = in / 1000;
      |             ^~
      |             int
Language: C++

void ABC079C()
{
	string str;
	cin >> str;
	vector<int> num(4);
	for (int i = 0; i < 4; ++i)
	{
		num[i] = stoi(str.substr(i, 1));
	}

	for (int i = 0; i < (1 << 3); ++i)
	{
		stringstream ss;
		int sum = num[0];
		ss << num[0];
		for (int j = 0; j < 3; ++j)
		{
			if (0 == (i & (1 << j)))
			{
				sum += num[j + 1];
				ss << '+' << num[j + 1];
			}
			else
			{
				sum -= num[j + 1];
				ss << '-' << num[j + 1];
			}
		}
		if (sum == 7)
		{
			ss << "=7" << endl;
			cout << ss.str() << endl;
			break;
		}
	}
}
int main()
{
	ABC079C();
	return 0;
}

Compiler output:
a.cc: In function 'void ABC079C()':
a.cc:3:9: error: 'string' was not declared in this scope
    3 |         string str;
      |         ^~~~~~
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> str;
      |         ^~~
a.cc:4:16: error: 'str' was not declared in this scope; did you mean 'std'?
    4 |         cin >> str;
      |                ^~~
      |                std
a.cc:5:9: error: 'vector' was not declared in this scope
    5 |         vector<int> num(4);
      |         ^~~~~~
a.cc:5:16: error: expected primary-expression before 'int'
    5 |         vector<int> num(4);
      |                ^~~
a.cc:8:17: error: 'num' was not declared in this scope; did you mean 'enum'?
    8 |                 num[i] = stoi(str.substr(i, 1));
      |                 ^~~
      |                 enum
a.cc:8:26: error: 'stoi' was not declared in this scope
    8 |                 num[i] = stoi(str.substr(i, 1));
      |                          ^~~~
a.cc:13:17: error: 'stringstream' was not declared in this scope
   13 |                 stringstream ss;
      |                 ^~~~~~~~~~~~
a.cc:14:27: error: 'num' was not declared in this scope; did you mean 'sum'?
   14 |                 int sum = num[0];
      |                           ^~~
      |                           sum
a.cc:15:17: error: 'ss' was not declared in this scope
   15 |                 ss << num[0];
      |                 ^~
a.cc:31:39: error: 'endl' was not declared in this scope
   31 |                         ss << "=7" << endl;
      |                                       ^~~~
a.cc:32:25: error: 'cout' was not declared in this scope
   32 |                         cout << ss.str() << endl;
      |                         ^~~~
Language: Java

mport java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		List<Integer> list=new ArrayList<Integer>();
		int c=1000;
		while(c>0) {
			if(n>=c) {
			    list.add(n/c);
			}else {
				list.add(0);
			}
			n%=c;
			c/=10;
		}


		for(int i=0;i<=7;i++) {
			String s=Integer.toBinaryString(i);

			int a=Integer.valueOf(s);
			String b=String.format("%03d",a);
			;
			char[] e=b.toCharArray();
			int k=keisan(list,e);
			if(k==7) {
				e[0]=(e[0]=='1')?'+':'-';
				e[1]=(e[1]=='1')?'+':'-';
				e[2]=(e[2]=='1')?'+':'-';
				for(int j=0;j<3;j++) {
					System.out.print(list.get(j));
					System.out.print(e[j]);
				}
				System.out.print(list.get(3)+"=7");
				break;
			}


		}



	}

	public static int keisan(List<Integer> list,char[] e) {
		int k=list.get(0);
		if(e[0]=='1') {
			k+=list.get(1);
		}else {
			k-=list.get(1);
		}
		if(e[1]=='1') {
			k+=list.get(2);
		}else {
			k-=list.get(2);
		}
		if(e[2]=='1') {
			k+=list.get(3);
		}else {
			k-=list.get(3);
		}
		return k;

	}



}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.ArrayList;
^
Main.java:2: error: class, interface, enum, or record expected
import java.util.List;
^
Main.java:3: error: class, interface, enum, or record expected
import java.util.Scanner;
^
3 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
vector<int> d(4);
string s="";
bool dfs(int n,string s,int sum){
  if(n==4)  return sum ==7;
  if(dfs(n+1,s,sum+d[n])){
    s[n-1] = '+'; return true;
  }
  if(dfs(n+1,s,sum-d[n])){
    s[n-1] = '-'; return true;
  }
  return false;
}
    
    

int main(){
  int n;
  cin >> n;
  int a = 3;
  while(a>=0){
	d.push_back(n%10);
    n/=10;
    a--;
  }
  reverse(d.begin(),d.end());
  if(dfs(1,s,d[0])){
    //cout << s << endl;
    rep(i,3){
      cout << d[i] << s[i];
    }
    cout << d[3]
  }
  cout << "=7" << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:17: error: expected ';' before '}' token
   35 |     cout << d[3]
      |                 ^
      |                 ;
   36 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
vector<int> d(4);
string s="";
bool dfs(int n,string s,int sum){
  if(n==4)  return sum ==7;
  if(dfs(n+1,s,sum+d[n])){
    s[n-1] = "+"; return true;
  }
  if(dfs(n+1,s,sum-d[n])){
    s[n-1] = '-'; return true;
  }
  return false;
}
    
    

int main(){
  int n;
  cin >> n;
  int a = 3;
  while(a>=0){
	d.push_back(n%10);
    n/=10;
    a--;
  }
  reverse(d.begin(),d.end());
  if(dfs(1,s,d[0])){
    cout << s << endl;
    rep(i,3){
      cout << d[i] << s[i];
    }
    cout << d[3] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'bool dfs(int, std::string, int)':
a.cc:10:14: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   10 |     s[n-1] = "+"; return true;
      |              ^~~
      |              |
      |              const char*
Language: Java

mport java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = N % 10;
        N /= 10;
        int C = N % 10;
        N /= 10;
        int B = N % 10;
        N /= 10;
        int A = N % 10;
        sc.close();

        if(A+B+C+D == 7){
            System.out.println(A + "+" + B + "+" + C + "+" + D + "=7");
            return;
        }
        if(A-B+C+D == 7){
            System.out.println(A + "-" + B + "+" + C + "+" + D + "=7");
            return;
        }
        if(A+B-C+D == 7){
            System.out.println(A + "+" + B + "-" + C + "+" + D + "=7");
            return;
        }
        if(A+B+C-D == 7){
            System.out.println(A + "+" + B + "+" + C + "-" + D + "=7");
            return;
        }
        if(A-B-C+D == 7){
            System.out.println(A + "-" + B + "-" + C + "+" + D + "=7");
            return;
        }
        if(A-B+C-D == 7){
            System.out.println(A + "-" + B + "+" + C + "-" + D + "=7");
            return;
        }
        if(A+B-C-D == 7){
            System.out.println(A + "+" + B + "-" + C + "-" + D + "=7");
            return;
        }
        if(A-B-C-D == 7){
            System.out.println(A + "-" + B + "-" + C + "-" + D + "=7");
            return;
        }
    }
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.*;
^
1 error
Language: C++

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

int main(){
  string S; cin >> S;
  int vector<int> a(4);
  char op1, op2, op3;
  
  for(int i=0; i<4; i++){
    a[i] = S[i] - '0';
  }
  
  int A=a[0]; int B=a[1]; int C=a[2]; int D=a[3];
  
  for(int bit=0; bit <(1 << 3); bit++){
    op1 = op2 = op3 = '+';
    B = abs(B); C = abs(C); D = abs(D);
    
    if(bit & (1 << 0)) {
      op1 = '-';
      B = -B;
    }
    else if(bit & (1 << 1)) {
      op2 = '-';
      C = -C;
    }
    else if(bit & (1 << 2)) {
      op3 = '-';
      D = -D;
    }
    if(A + B + C + D == 7) {
      break;
    }
  }
  cout << A << op1 << abs(B) << op2 << abs(C) << op3 << abs(D) << "=7" << endl;
}
      
    


Compiler output:
a.cc: In function 'int main()':
a.cc:6:19: error: invalid declarator before 'a'
    6 |   int vector<int> a(4);
      |                   ^
a.cc:10:5: error: 'a' was not declared in this scope
   10 |     a[i] = S[i] - '0';
      |     ^
a.cc:13:9: error: 'a' was not declared in this scope
   13 |   int A=a[0]; int B=a[1]; int C=a[2]; int D=a[3];
      |         ^
Language: C++

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

int main(){
  string S; cin >> S;
  int a[4];
  char op1, op2, op3;
  
  for(int i=0; i<4; i++){
    a[i] = S[i] - '0';
  }
  int A=a[0]; B=a[1]; C=a[2]; D=a[3];
  
  for(int bit=0; bit <(1 << 3); bit++){
    op1 = op2 = op3 = '+';
    B = abs(B); C = abs(C); D = abs(D);
    
    if(bit & (1 << 0)) {
      op1 = '-';
      B = -B;
    }
    else if(bit & (1 << 1)) {
      op2 = '-';
      C = -C;
    }
    else if(bit & (1 << 2)) {
      op3 = '-';
      D = -D;
    }
    if(A + B + C + D == 7) {
      break;
    }
  }
  cout << A << op1 << abs(B) << op2 << abs(C) << op3 << abs(D) << "=7" << endl;
}
      
    


Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: 'B' was not declared in this scope
   12 |   int A=a[0]; B=a[1]; C=a[2]; D=a[3];
      |               ^
a.cc:12:23: error: 'C' was not declared in this scope
   12 |   int A=a[0]; B=a[1]; C=a[2]; D=a[3];
      |                       ^
a.cc:12:31: error: 'D' was not declared in this scope
   12 |   int A=a[0]; B=a[1]; C=a[2]; D=a[3];
      |                               ^
Language: C++

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

int main(){
  int A, B, C, D; cin >> A >> B >> C >> D;
  char op1; op2; op3;
  
  for(int bit=0; bit <(1 << 3); bit++){
    op1 = op2 = op3 = '+';
    if(bit & (0 << 0)) {
      op1 = '-';
      B = -B;
    }
    else if(bit & (0 << 1)) {
      op2 = '-';
      C = -C;
    }
    else if(bit & (0 << 2)) {
      op3 = '-';
      D = -D;
    }
    if(A + B + C + D == 7) {
      break;
    }
  }
  cout << A << op1 << abs(B) << op2 << abs(C) << op3 << abs(D) << endl;
}
      
    

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: 'op2' was not declared in this scope; did you mean 'op1'?
    6 |   char op1; op2; op3;
      |             ^~~
      |             op1
a.cc:6:18: error: 'op3' was not declared in this scope; did you mean 'op1'?
    6 |   char op1; op2; op3;
      |                  ^~~
      |                  op1
Language: C++

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

vector<char> judge(vector<int> &vec){
  vector<char> sym(3,'+');
  if (vec.at(0) + vec.at(1) + vec.at(2) + vec.at(3)==7){
    return sym;
  }
  if (vec.at(0) - vec.at(1) + vec.at(2) + vec.at(3)==7){
    sym.at(0) = '-';
    return sym;
  }
  if (vec.at(0) + vec.at(1) - vec.at(2) + vec.at(3)==7){
    sym.at(1) ='-';
    return sym;
  }
  if (vec.at(0) + vec.at(1) + vec.at(2) - vec.at(3)==7){
    sym.at(2) = '-';
    return sym;
  }
  if (vec.at(0) - vec.at(1) - vec.at(2) + vec.at(3)==7){
    sym.at(0) = '-';
    sym.at(1) = '-';
    return sym;
  }
  if (vec.at(0) + vec.at(1) - vec.at(2) - vec.at(3)==7){
    sym.at(2) = '-';
    sym.at(1) ='-';
    return sym;
  }
  if (vec.at(0) - vec.at(1) + vec.at(2) - vec.at(3)==7){
    sym.at(0) = '-';
    sym.at(2) = '-';
    return sym;
  }

int main(){
  int n;
  cin>>n;
  vector<int> vec(4);
  vec.at(0)=n/1000;
  vec.at(1)=(n/100)%10;
  vec.at(2)=(n%100)%10;
  vec.at(3)=n%10;
  
  vector<char> sym =judge(vec);
  for (int i=0;i<3;i++){
    cout<<vec.at(i)<<sym.at(i);
  }
  cout<<vec.at(3)<<endl;
}

Compiler output:
a.cc: In function 'std::vector<char> judge(std::vector<int>&)':
a.cc:37:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   37 | int main(){
      |         ^~
a.cc:37:9: note: remove parentheses to default-initialize a variable
   37 | int main(){
      |         ^~
      |         --
a.cc:37:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:37:11: error: a function-definition is not allowed here before '{' token
   37 | int main(){
      |           ^
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:4:37: note: to match this '{'
    4 | vector<char> judge(vector<int> &vec){
      |                                     ^
a.cc:51:2: warning: control reaches end of non-void function [-Wreturn-type]
   51 | }
      |  ^
Language: C++

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

int main(){
  string s;
  cin >> s;

  int a=s[0], b=s[1], c=s[2], d=[3];

  if(a+b+c+d ==7) printf("%d+%d+%d+%d=7\n", a,b,c,d);
  else if(a+b+c-d ==7) printf("%d+%d+%d-%d=7\n", a,b,c,d);
  else if(a+b-c+d ==7) printf("%d+%d-%d+%d=7\n", a,b,c,d);
  else if(a+b-c-d ==7) printf("%d+%d-%d-%d=7\n", a,b,c,d);
  
  else if(a-b+c+d ==7) printf("%d-%d+%d+%d=7\n", a,b,c,d);
  else if(a-b+c-d ==7) printf("%d-%d+%d-%d=7\n", a,b,c,d);
  else if(a-b-c+d ==7) printf("%d-%d-%d+%d=7\n", a,b,c,d);
  else if(a-b-c-d ==7) printf("%d-%d-%d-%d=7\n", a,b,c,d);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:34: error: expected identifier before numeric constant
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                  ^
a.cc: In lambda function:
a.cc:8:36: error: expected '{' before ';' token
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                    ^
a.cc: In function 'int main()':
a.cc:8:33: error: invalid user-defined conversion from 'main()::<lambda()>' to 'int' [-fpermissive]
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                 ^~~
a.cc:8:33: note: candidate is: 'constexpr main()::<lambda()>::operator void (*)()() const' (near match)
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                 ^
a.cc:8:33: note:   no known conversion from 'void (*)()' to 'int'
Language: C++

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

int main(){
  string s;
  cin >> s;

  int a=s[0], b=s[1], c=s[2], d=[3];

  if(a+b+c+d ==7) printf("%d+%d+%d+%d=7\n", a,b,c,d);
  else if(a+b+c-d ==7) printf("%d+%d+%d-%d=7\n", a,b,c,d);
  else if(a+b-c+d ==7) printf("%d+%d-%d+%d=7\n", a,b,c,d);
  else if(a+b-c-d ==7) printf("%d+%d-%d-%d=7\n", a,b,c,d);
  
  else if(a-b+c+d ==7) printf("%d-%d+%d+%d=7\n", a,b,c,d);
  else if(a-b+c-d ==7) printf("%d-%d+%d-%d=7\n", a,b,c,d);
  else if(a-b-c+d ==7) printf("%d-%d-%d+%d=7\n", a,b,c,d);
  else if(a-b-c-d ==7) printf("%d-%d-%d-%d=7\n", a,b,c,d);


Compiler output:
a.cc: In function 'int main()':
a.cc:8:34: error: expected identifier before numeric constant
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                  ^
a.cc: In lambda function:
a.cc:8:36: error: expected '{' before ';' token
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                    ^
a.cc: In function 'int main()':
a.cc:8:33: error: invalid user-defined conversion from 'main()::<lambda()>' to 'int' [-fpermissive]
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                 ^~~
a.cc:8:33: note: candidate is: 'constexpr main()::<lambda()>::operator void (*)()() const' (near match)
    8 |   int a=s[0], b=s[1], c=s[2], d=[3];
      |                                 ^
a.cc:8:33: note:   no known conversion from 'void (*)()' to 'int'
a.cc:18:59: error: expected '}' at end of input
   18 |   else if(a-b-c-d ==7) printf("%d-%d-%d-%d=7\n", a,b,c,d);
      |                                                           ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int a[4];

int main () {
  string input; cin >> input;
  REP(i,4) a[i] = input[i]-'a';

  REP(b,1<<3) {
    int sum = a[0];
    string ans;
    ans += (char)('0' + a[0]);
    REP(i,3) {
      if (x&(1<<i)) {
        sum += a[i+1];
        ans += '+';
        ans += (char)('0'+a[i+1]);
      }
      else {
        sum -= a[i+1];
        ans += '-';
        ans += (char)('0'+a[i+1]);
      }
    }
    if (sum == 7) {
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:11: error: 'x' was not declared in this scope
   50 |       if (x&(1<<i)) {
      |           ^
Language: C++

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

int main() {
  int z;
  cin>>z;
  int d=z%10;
  z/10;
  int c=z%10;
  z/10;
  int b=z%10;
  z/10;
  int a=z%10;
  if(a+b+c+d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7";
  }
  if(a+b+c-d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7";
  }
  if(a+b-c+d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7";
  }
  if(a-b+c+d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7";
  }
  if(a+b-c-d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
  }
  if(a-b+c-d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7";
  }
  if(a+b-c-d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7";
  }
  if(a-b-c-d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7";
  }

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

public class Main {
  private static char[] op1 = { '+', '+', '+', '+', '-', '-', '-', '-' };
  private static char[] op2 = { '+', '+', '-', '-', '+', '+', '-', '-' };
  private static char[] op3 = { '+', '-', '+', '-', '+', '-', '+', '-' };
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char[] n = sc.next().toCharArray();
    int A = n[0] - '0';
    int B = n[1] - '0';
    int C = n[2] - '0';
    int D = n[3] - '0';
    for (int i = 0; i < 8; i++) {
      int sum = A;
      if (op1[i] == '+') {
        sum += B;
      } else {
        sum -= B;
      }
      if (op2[i] == '+') {
        sum += C;
      } else {
        sum -= C;
      }
      if (op3[i] == '+') {
        sum += D;
      } else {
        sum -= D;
      }
      if (sum == 7) {
        System.out.println(""+A+op1[i]+B+op2[i]+C+op3[i]+D+"=7");
        return;
      }
    }
  }
}

Compiler output:
Main.java:6: error: cannot find symbol
    Scanner sc = new Scanner(System.in);
    ^
  symbol:   class Scanner
  location: class Main
Main.java:6: error: cannot find symbol
    Scanner sc = new Scanner(System.in);
                     ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(void){
    char n[4];
    cin >> n;
    int a=n[0]-'0', b=n[1]-'0', c=n[2]-'0', d=n[3]-'0';
    if(a+b+c+d==7) cout << << a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<"7"<< endl;
    else if(a-b+c+d==7) cout << a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<"7"<< endl;
    else if(a+b-c+d==7) cout << a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<"7"<< endl;
    else if(a+b+c-d==7) cout << a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<"7"<< endl;
    else if(a-b-c+d==7) cout << a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<"7" << endl;
    else if(a+b-c-d==7) cout << a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<"7" << endl;
    else if(a-b+c-d==7) cout << a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<"7" << endl;
    else if(a-b-c-d==7) cout << a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<"7" << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:28: error: expected primary-expression before '<<' token
    7 |     if(a+b+c+d==7) cout << << a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<"7"<< endl;
      |                            ^~
Language: C++

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

int main(){
  int n;
  cin >> n;
  int n1=n/1000;
  int n2=n/100-n1*10;
  int n3=n/10-n1*100-n2*10;
  int n4=n-n1*1000-n2*100-n3*10;
  if(n1+n2+n3+n4=7){
    cout << n1 << '+' << n2 << '+' << n3 << '+' << n4 << '=' << 7 << endl;
    return 0;
  }
  if(n1+n2-n3+n4=7){
    cout << n1 << '+' << n2 << '-' << n3 << '+' << n4 << '=' << 7 << endl;
    return 0;
  }
  if(n1+n2+n3-n4=7){
    cout << n1 << '+' << n2 << '+' << n3 << '-' << n4 << '=' << 7 << endl;
    return 0;
  }
  if(n1-n2+n3+n4=7){
    cout << n1 << '-' << n2 << '+' << n3 << '+' << n4 << '=' << 7 << endl;
    return 0;
  }
  if(n1-n2-n3+n4=7){
    cout << n1 << '-' << n2 << '-' << n3 << '+' << n4 << '=' << 7 << endl;
    return 0;
  }
  if(n1+n2-n3-n4=7){
    cout << n1 << '+' << n2 << '-' << n3 << '-' << n4 << '=' << 7 << endl;
    return 0;
  }
  if(n1-n2+n3-n4=7){
    cout << n1 << '-' << n2 << '+' << n3 << '-' << n4 << '=' << 7 << endl;
    return 0;
  }
  if(n1-n2-n3-n4=7){
    cout << n1 << '-' << n2 << '-' << n3 << '-' << n4 << '=' << 7 << endl;
    return 0;
  }
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: lvalue required as left operand of assignment
   11 |   if(n1+n2+n3+n4=7){
      |      ~~~~~~~~^~~
a.cc:15:14: error: lvalue required as left operand of assignment
   15 |   if(n1+n2-n3+n4=7){
      |      ~~~~~~~~^~~
a.cc:19:14: error: lvalue required as left operand of assignment
   19 |   if(n1+n2+n3-n4=7){
      |      ~~~~~~~~^~~
a.cc:23:14: error: lvalue required as left operand of assignment
   23 |   if(n1-n2+n3+n4=7){
      |      ~~~~~~~~^~~
a.cc:27:14: error: lvalue required as left operand of assignment
   27 |   if(n1-n2-n3+n4=7){
      |      ~~~~~~~~^~~
a.cc:31:14: error: lvalue required as left operand of assignment
   31 |   if(n1+n2-n3-n4=7){
      |      ~~~~~~~~^~~
a.cc:35:14: error: lvalue required as left operand of assignment
   35 |   if(n1-n2+n3-n4=7){
      |      ~~~~~~~~^~~
a.cc:39:14: error: lvalue required as left operand of assignment
   39 |   if(n1-n2-n3-n4=7){
      |      ~~~~~~~~^~~
Language: C++

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

int main(){
    string s;
    cin >> s;

    for(int bit = 0; bit < (1<<3); bit++){
        int res = s[0]-'0';
        for(int i = 0; i < 3; i++){
            res += (((bit>>i) & 1 ? +1: -1) * (s[i+1] -'0');
        }

        if(res == 7){
            cout << s[0];
            for(int i = 0; i < 3; i++){
                cout << (bit & (1<<i)?"+":"-") << s[i+1];
            }
            cout << "=7" << endl;
        }
        
    }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:60: error: expected ')' before ';' token
   11 |             res += (((bit>>i) & 1 ? +1: -1) * (s[i+1] -'0');
      |                    ~                                       ^
      |                                                            )
Language: C++

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	int a[4],sum,n;

	cin >> n;

	a[0] = n / 1000;
	a[1] = (n - a[0] * 1000) / 100;
	a[2] = (n - (n/100)*100) / 10;
	a[3] = n % 10;

	sum = (a[0] + a[1] + a[2] + a[3] - 7)/2;

	cout << a[0];

	for (int i = 1; i < 4; i++) {
		if (sum == a[i]) {
			cout << '-';
			sum = sum - a[i];
		}
		else {
			cout << '+';
		}

		cout << a[i];
	}

	cout << "=7" << endl;

	return 0;
}
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

using namespace std;

int main() {

	int a[4],sum,n;

	cin >> n;

	a[0] = n / 1000;
	a[1] = (n - a[0] * 1000) / 100;
	a[2] = (n - (n/100)*100) / 10;
	a[3] = n % 10;

	sum = (a[0] + a[1] + a[2] + a[3] - 7)/2;

	cout << a[0];

	for (int i = 1; i < 4; i++) {
		if (sum == a[i]) {
			cout << '-';
			sum = sum - a[i];
		}
		else {
			cout << '+';
		}

		cout << a[i];
	}

	cout << "=7" << endl;

	return 0;
}


Compiler output:
a.cc:70:5: error: redefinition of 'int main()'
   70 | int main() {
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main() {
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
	signed main() {
		int a;
		cin>>a;
		int a1=a%10;
		int a2=((a-a1)/10)%10
		int a3=((a-a2*10-a1)/100)%10
		int a4=(a-(a%1000))/1000
		if(a1+a2+a3+a4==7)
			cout<<a1<<'+'<<a2<<'+'<<a3<<'+'<<a4<<'='<<7;
			else if(a1+a2+a3-a4==7)
				cout<<a1<<'+'<<a2<<'+'<<a3<<'-'<<a4<<'='<<7;
				else　if(a1+a2-a3+a4==7)
					cout<<a1<<'+'<<a2<<'-'<<a3<<'+'<<a4<<'='<<7;
					else if(a1+a2-a3-a4==7)
						cout<<a1<<'+'<<a2<<'-'<<a3<<'-'<<a4<<'='<<7;
						else if(a1-a2+a3+a4==7)
							cout<<a1<<'-'<<a2<<'+'<<a3<<'+'<<a4<<'='<<7;
							else if(a1-a2+a3-a4==7)
								cout<<a1<<'-'<<a2<<'+'<<a3<<'-'<<a4<<'='<<7;
								else if(a1-a2-a3+a4==7)
									cout<<a1<<'-'<<a2<<'-'<<a3<<'+'<<a4<<'='<<7;
									else if(a1-a2-a3-a4==7)
										cout<<a1<<'-'<<a2<<'-'<<a3<<'-'<<a4<<'='<<7;
								}

Compiler output:
a.cc:15:33: error: extended character 　 is not valid in an identifier
   15 |                                 else　if(a1+a2-a3+a4==7)
      |                                 ^
a.cc: In function 'int main()':
a.cc:3:13: error: expected ',' or ';' before 'long'
    3 | #define int long long
      |             ^~~~
a.cc:9:17: note: in expansion of macro 'int'
    9 |                 int a3=((a-a2*10-a1)/100)%10
      |                 ^~~
a.cc:13:25: error: 'else' without a previous 'if'
   13 |                         else if(a1+a2+a3-a4==7)
      |                         ^~~~
a.cc:13:39: error: 'a3' was not declared in this scope; did you mean 'a2'?
   13 |                         else if(a1+a2+a3-a4==7)
      |                                       ^~
      |                                       a2
a.cc:13:42: error: 'a4' was not declared in this scope; did you mean 'a2'?
   13 |                         else if(a1+a2+a3-a4==7)
      |                                          ^~
      |                                          a2
a.cc:15:48: error: 'a3' was not declared in this scope; did you mean 'a2'?
   15 |                                 else　if(a1+a2-a3+a4==7)
      |                                                ^~
      |                                                a2
a.cc:15:51: error: 'a4' was not declared in this scope; did you mean 'a2'?
   15 |                                 else　if(a1+a2-a3+a4==7)
      |                                                   ^~
      |                                                   a2
a.cc:15:33: error: 'else\U00003000if' was not declared in this scope
   15 |                                 else　if(a1+a2-a3+a4==7)
      |                                 ^~~~~~~~
a.cc:17:41: error: 'else' without a previous 'if'
   17 |                                         else if(a1+a2-a3-a4==7)
      |                                         ^~~~
Language: C++

#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

string S;
int num[4];

int main(void){
	cin >> S;
	for(int i = 0; i < 4; i++) num[i] = (int)S[i];

	for(int i = 0; i < (1<<3); i++){
		int sum = a[0];
		for(int j = 0; j < 3; j++){
			if(i & (1<<j)){
				sum += a[j+1];
			}else{
				sum -= a[j+1];
			}
		}

		if(sum == 7){
			cout << a[0];
			for(int j = 0; j < 3; j++){
				if(i & (1<<j)){
					cout << "+";
				}else{
					cout << "-";
				}

				cout << a[j+1];
			}
			cout << "\n";
			break;
		}
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:27: error: 'a' was not declared in this scope
   16 |                 int sum = a[0];
      |                           ^
Language: C++

S = input()
for i in range(1<<3):
    s = S[0:1]
    for j in range(3):
        s += '+-'[i>>j&1] + S[j+1:j+2]
    if eval(s) == 7:
        print(s + '=7')
        break


Compiler output:
a.cc:5:14: warning: multi-character character constant [-Wmultichar]
    5 |         s += '+-'[i>>j&1] + S[j+1:j+2]
      |              ^~~~
a.cc:7:19: warning: multi-character character constant [-Wmultichar]
    7 |         print(s + '=7')
      |                   ^~~~
a.cc:1:1: error: 'S' does not name a type
    1 | S = input()
      | ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int A, B, C, D;

void dfs(int depth, vector<bool> &op, vector<bool> &ans){
  if(depth == 3){
    int tmp = 0;
    tmp += A;
    if(op[0]) tmp += B;
    else tmp -= B;
    if(op[1]) tmp += C;
    else tmp -= C;
    if(op[2]) tmp += D;
    else tmp -= D;
    if(tmp == 7){
      for(int i = 0; i < 3; i++){
      ans[i] = op[i];
      }
      return;
    }
    else return;
  }
  op[depth] = true;
  dfs(depth + 1, op, ans);
  op[depth] = false;
  dfs(depth + 1, op, ans);
  return;
}

int main(){
  cin >> A >> B >> C >> D;
  
  vector<bool> op(3,false);
  vector<bool> ans(3,false);
  
  if(dfs(0,op,ans)){
    cout << A << ans[0]?'+':'-' << B << ans[1]?'+':'-' << C << ans[2]?'+':'-' << '=' << 7;
  }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: could not convert 'dfs(0, op, ans)' from 'void' to 'bool'
   39 |   if(dfs(0,op,ans)){
      |      ~~~^~~~~~~~~~
      |         |
      |         void
a.cc:40:79: warning: left shift count >= width of type [-Wshift-count-overflow]
   40 |     cout << A << ans[0]?'+':'-' << B << ans[1]?'+':'-' << C << ans[2]?'+':'-' << '=' << 7;
      |                                                                           ~~~~^~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int A, B, C, D;

void dfs(int depth, vector<bool> &op, vector<bool> &ans){
  if(depth == 3){
    int tmp = 0;
    tmp += A;
    if(op[0]) tmp += B;
    else tmp -= B;
    if(op[1]) tmp += C;
    else tmp -= C;
    if(op[2]) tmp += D;
    else tmp -= D;
    if(tmp == 7){
      for(int i = 0; i < 3; i++){
      ans[i] = op[i];
      }
      return;
    }
    else return;
  }
  op[depth] = true;
  dfs(depth + 1; op, ans);
  op[depth] = false;
  dfs(depth + 1; op, ans);
  return;
}

int main(){
  cin >> A >> B >> C >> D;
  
  vector<bool> op(3,false);
  vector<bool> ans(3,false);
  
  if(dfs(0,op,ans)){
    cout << A << ans[0]?'+':'-' << B << ans[1]?'+':'-' << C << ans[2]?'+':'-' << '=' << 7;
  }

}


Compiler output:
a.cc: In function 'void dfs(int, std::vector<bool>&, std::vector<bool>&)':
a.cc:27:16: error: expected ')' before ';' token
   27 |   dfs(depth + 1; op, ans);
      |      ~         ^
      |                )
a.cc:27:25: error: expected ';' before ')' token
   27 |   dfs(depth + 1; op, ans);
      |                         ^
      |                         ;
a.cc:29:16: error: expected ')' before ';' token
   29 |   dfs(depth + 1; op, ans);
      |      ~         ^
      |                )
a.cc:29:25: error: expected ';' before ')' token
   29 |   dfs(depth + 1; op, ans);
      |                         ^
      |                         ;
a.cc: In function 'int main()':
a.cc:39:9: error: could not convert 'dfs(0, op, ans)' from 'void' to 'bool'
   39 |   if(dfs(0,op,ans)){
      |      ~~~^~~~~~~~~~
      |         |
      |         void
a.cc:40:79: warning: left shift count >= width of type [-Wshift-count-overflow]
   40 |     cout << A << ans[0]?'+':'-' << B << ans[1]?'+':'-' << C << ans[2]?'+':'-' << '=' << 7;
      |                                                                           ~~~~^~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

void dfs(int depth, vector<bool> &op, vector<bool> &ans){
  if(depth == 3){
    int tmp = 0;
    tmp += A;
    if(op[0]) tmp += B;
    else tmp -= B;
    if(op[1]) tmp += C;
    else tmp -= C;
    if(op[2]) tmp += D;
    else tmp -= D;
    if(tmp == 7){
      for(int i = 0; i < 3; i++){
      ans[i] = op[i];
      }
      return;
    }
    else return;
  }
  op[depth] = true;
  dfs(depth + 1; op, ans);
  op[depth] = false;
  dfs(depth + 1; op, ans);
  return;
}

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  vector<bool> op(3,false);
  vector<bool> ans(3,false);
  
  if(dfs(0,op,ans)){
    cout << A << ans[0]?'+':'-' << B << ans[1]?'+':'-' << C << ans[2]?'+':'-' << '=' << 7;
  }

}

Compiler output:
a.cc: In function 'void dfs(int, std::vector<bool>&, std::vector<bool>&)':
a.cc:9:12: error: 'A' was not declared in this scope
    9 |     tmp += A;
      |            ^
a.cc:10:22: error: 'B' was not declared in this scope
   10 |     if(op[0]) tmp += B;
      |                      ^
a.cc:11:17: error: 'B' was not declared in this scope
   11 |     else tmp -= B;
      |                 ^
a.cc:12:22: error: 'C' was not declared in this scope
   12 |     if(op[1]) tmp += C;
      |                      ^
a.cc:13:17: error: 'C' was not declared in this scope
   13 |     else tmp -= C;
      |                 ^
a.cc:14:22: error: 'D' was not declared in this scope
   14 |     if(op[2]) tmp += D;
      |                      ^
a.cc:15:17: error: 'D' was not declared in this scope
   15 |     else tmp -= D;
      |                 ^
a.cc:25:16: error: expected ')' before ';' token
   25 |   dfs(depth + 1; op, ans);
      |      ~         ^
      |                )
a.cc:25:25: error: expected ';' before ')' token
   25 |   dfs(depth + 1; op, ans);
      |                         ^
      |                         ;
a.cc:27:16: error: expected ')' before ';' token
   27 |   dfs(depth + 1; op, ans);
      |      ~         ^
      |                )
a.cc:27:25: error: expected ';' before ')' token
   27 |   dfs(depth + 1; op, ans);
      |                         ^
      |                         ;
a.cc: In function 'int main()':
a.cc:38:9: error: could not convert 'dfs(0, op, ans)' from 'void' to 'bool'
   38 |   if(dfs(0,op,ans)){
      |      ~~~^~~~~~~~~~
      |         |
      |         void
a.cc:39:79: warning: left shift count >= width of type [-Wshift-count-overflow]
   39 |     cout << A << ans[0]?'+':'-' << B << ans[1]?'+':'-' << C << ans[2]?'+':'-' << '=' << 7;
      |                                                                           ~~~~^~~~~~