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

#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;cin>>a;
  int s= atoi(a.at(0));
  vector<int> d;
  d.push_back(s);
  int f;
  int cnt=0;
  for(int i=1;i<4;i++){
    f =d.at(i-1) + a.at(i);
    d.push_back(f);
    f =d.at(i-1) - a.at(i);
    d.push_back(f);
  }
    for(int i=0;i<4;i++){
    f =d.at(i+2) + a.at(3);
    d.push_back(f);
    cnt++;
      if(f == 7)
        break;
    f =d.at(i+3) - a.at(3);
    d.push_back(f);
    cnt++;
      if(f == 7)
        break;
  }
  vector<string> h;
  int r = 3;
  while(r){
    if(cnt % 2 == 1){
      cnt -= 1;
      cnt = cnt /2;
      h.push_back("1");
    }else{
      cnt = cnt /2;
      h.push_back("0");
    }
    r--;
  }
  reverse(h.begin(),h.end());
  string k;
  for(r = 0;r<3;r++){
    k += a.at(r);
    if(h.at(r) == "0")
      k += "+";
    if(h.at(r) == "1")
      k += "-";
  }
  cout << k << a.at(3) << "=7" <<endl;
}
  
  
    

Compiler output:
a.cc: In function 'int main()':
a.cc:5:19: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
    5 |   int s= atoi(a.at(0));
      |               ~~~~^~~
      |                   |
      |                   __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;cin>>a;
  int s= atoi(a.at(0));
  vector<int> d;
  d.push_back(s);
  int f;
  int cnt=0;
  for(int i=1;i<4;i++){
    f =d.at(i-1) + a.at(i);
    d.push_back(f);
    f =d.at(i-1) - a.at(i);
    d.push_back(f);
  }
    for(int i=0;i<4;i++){
    f =d.at(i+2) + a.at(3);
    d.push_back(f);
    cnt++;
      if(f == 7)
        break;
    f =d.at(i+3) - a.at(3);
    d.push_back(f);
    cnt++;
      if(f == 7)
        break;
  }
  vector<string> h;
  int r = 3;
  while(r){
    if(cnt % 2 == 1){
      cnt -= 1;
      cnt = cnt /2;
      h.push_back("1");
    }else{
      cnt = cnt /2;
      h.push_back("0");
    }
    r--;
  }
  reverse(h.begin(),h.end());
  string k;
  int r = 3;
  for(r = 0;r<3;r++){
    k += a.at(r);
    if(h.at(r) == "0")
      k += "+";
    if(h.at(r) == "1")
      k += "-";
  }
  cout << k << a.at(3) << "=7" <<endl;
}
  
  
    

Compiler output:
a.cc: In function 'int main()':
a.cc:5:19: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
    5 |   int s= atoi(a.at(0));
      |               ~~~~^~~
      |                   |
      |                   __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:105:30: note:   initializing argument 1 of 'int atoi(const char*)'
  105 | extern int atoi (const char *__nptr)
      |                  ~~~~~~~~~~~~^~~~~~
a.cc:43:7: error: redeclaration of 'int r'
   43 |   int r = 3;
      |       ^
a.cc:29:7: note: 'int r' previously declared here
   29 |   int r = 3;
      |       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> A(4);
  string S;
  cin>>S;
  for(int i=0;i<4;i++) A[i]=stoi(S[i]);
  for(int i=0;i<(1<<3);i++){
    int ans=A[0];
    bitset<3> X(i);
    for(int j=0;j<3;j++){
      if(X.test(j))
        ans+=A[j+1];
      else
        ans-=A[j+1];
    }
    if(ans==7){
      cout<<A[0];
      for(int j=0;j<3;j++){
        if(X.test(j))
          cout<<'+';
        else
          cout<<'-';
        cout<<A[j+1];
      }
    }
  }
  cout<<"=7";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:33: error: no matching function for call to 'stoi(__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
    7 |   for(int i=0;i<4;i++) A[i]=stoi(S[i]);
      |                             ~~~~^~~~~~
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:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:22: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'}
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidate: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:23: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> A(4);
  for(int i=0;i<4;i++) cin>>A[i];
  for(int i=0;i<(1<<3);i++){
    int ans=A[0];
    bitset<3> X(i);
    for(int j=0;j<3;j++){
      if(X.test(j))
        ans+=A[j+1];
      else
        ans-=A[j+1];
    }
    if(ans==7){
      cout<<A[0];
      for(int j=0;j<3;j++){
        if(X.test(j))
          cout<<'+';
        else
          cout<<'-';
        cout<<A[j+1];
      }
    }
  }

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

#include <bits/stdc++.h>

using namespace std;

int main(){
  string s;
  cin >> s;
  vector<int> a(n);
  for(int i=0;i<4;i++){
    a[i]=s[i]-'0';
  }
  int k;
  for(int i=0;i<(1<<3);i++){
    int sum=a[0];
    for(int j=0;j<3;j++){
      if(i>>j & 1){
        sum+=a[j+1];
      }
      else{
        sum-=a[j+1];
      }
    }
    if(sum==7){
      k=i;
      break;
    }
  }
  cout << a[0];
  for(int i=0;i<3;i++){
    if(k>>i & 1){
      cout << '+';
    }
    else{
      cout << '-';
    }
    cout << a[i+1];
  }
  cout << "=7" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'n' was not declared in this scope
    8 |   vector<int> a(n);
      |                 ^
Language: Java

//４つの数字を+-を使って7にする
import java.util.Scanner;

public class bruteforce {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int x = scan.nextInt();

        int[] a = new int[4];
        int[] b = new int[8];
        int N = 7;

        for (int i = 0; i < 4; i++) {
            a[3-i] = x%10;
            x = x/10;
        }

        b[0] = a[0]+a[1]+a[2]+a[3];
        b[1] = a[0]+a[1]+a[2]-a[3];
        b[2] = a[0]+a[1]-a[2]+a[3];
        b[3] = a[0]+a[1]-a[2]-a[3];
        b[4] = a[0]-a[1]+a[2]+a[3];
        b[5] = a[0]-a[1]+a[2]-a[3];
        b[6] = a[0]-a[1]-a[2]-a[3];
        b[7] = a[0]-a[1]-a[2]+a[3];
        if(b[0] == N)
            System.out.println(a[0] + "+" + a[1] + "+" + a[2] + "+" + a[3] + "=" + N);
        else if(b[1] == N)
            System.out.println(a[0] + "+" + a[1] + "+" + a[2] + "-" + a[3] + "=" + N);
        else if(b[2] == N)
            System.out.println(a[0] + "+" + a[1] + "-" + a[2] + "+" + a[3] + "=" + N);
        else if(b[3] == N)
            System.out.println(a[0] + "+" + a[1] + "-" + a[2] + "-" + a[3] + "=" + N);
        else if(b[4] == N)
            System.out.println(a[0] + "-" + a[1] + "+" + a[2] + "+" + a[3] + "=" + N);
        else if(b[5] == N)
            System.out.println(a[0] + "-" + a[1] + "+" + a[2] + "-" + a[3] + "=" + N);
        else if(b[6] == N)
            System.out.println(a[0] + "-" + a[1] + "-" + a[2] + "-" + a[3] + "=" + N);
        else if(b[7] == N)
            System.out.println(a[0] + "-" + a[1] + "-" + a[2] + "+" + a[3] + "=" + N);

    }
}

Compiler output:
Main.java:4: error: class bruteforce is public, should be declared in a file named bruteforce.java
public class bruteforce {
       ^
1 error
Language: Java

import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int d[] = new int[4];
        for(int i=0;i<4;i++){
            d[i] = x%10;
            x /= 10;
        }
        int a = d[3];//1のくらい
        int b = d[2];
        int c = d[1];
        int e = d[0];
        int k = 1;
        int j = 0;

        switch(k){
            case 1:j = a+b+c+e; if(j==7){System.out.println(a+  "+" + b + "+" + c + "+" + e + "=7" ); break;}
            case 2:j = a-b+c+e; if(j==7){System.out.println(a+  "-" + b + "+" + c + "+" + e + "=7" ); break;}
            case 3:j = a-b+c-e; if(j==7){System.out.println(a+  "-" + b + "+" + c + "-" + e + "=7" ); break;}
            case 4:j = a-b-c+e; if(j==7){System.out.println(a+  "-" + b + "-" + c + "+" + e + "=7" ); break;}
            case 5:j = a-b-c-e; if(j==7){System.out.println(a+  "-" + b + "-" + c + "-" + e + "=7" ); break;}
            case 6:j = a+b-c+e; if(j==7){System.out.println(a+  "+" + b + "-" + c + "+" + e + "=7" ); break;}
            case 7:j = a+b+c-e; if(j==7){System.out.println(a+  "+" + b + "+" + c + "-" + e + "=7" ); break;}
            case 8:j = a+b-c-e; if(j==7){System.out.println(a+  "+" + b + "-" + c + "-" + e + "=7" ); break;}
            default:System.out.println("間違い"); break;
        }
    }

Compiler output:
Main.java:30: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  int jc[2]={1, -1};
  int jk[2]={1, -1};
  int jd[2]={1, -1};
  char s[2]={+, -};
  bool h =false;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++{
        if(a+jc[i]*b+jk[j]*c+jd[k]*d==7){
          cout<<a<<s[i]<<b<<s[j]<<c<<s[k]<<d<<"=7";
          h=true;
          break;
        }
        
      }
      if(h){
        break;
      }
          }
          if(h){
            break;
          }
          }
          }
          
          
          
          
          

Compiler output:
a.cc: In function 'int main()':
a.cc:9:15: error: expected primary-expression before ',' token
    9 |   char s[2]={+, -};
      |               ^
a.cc:9:18: error: expected primary-expression before '}' token
    9 |   char s[2]={+, -};
      |                  ^
a.cc:13:26: error: expected ')' before '{' token
   13 |       for(int k=0;k<2;k++{
      |          ~               ^
      |                          )
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[3];
gen(int lv)
{
	
}



main()
{
	char b[5];
	cin >> b;
	int a[4];
	for(int i=0;i<4;i++)
	{
		a[i]=b[i]-'0';
	}
	if(a[0]+a[1]+a[2]+a[3]==7)
	{
		cout << a[0] << '+' << a[1] << '+' << a[2] <<'+' << a[3] <<"=7"; 
	}
	else if(a[0]+a[1]+a[2]-a[3]==7)
	{
		cout << a[0] << '+' << a[1] << '+' << a[2] <<'-' << a[3] <<"=7"; 
	}
	else if(a[0]+a[1]-a[2]+a[3]==7)
	{
		cout << a[0] << '+' << a[1] << '-' << a[2] <<'+' << a[3] <<"=7"; 
	}
	else if(a[0]-a[1]+a[2]+a[3]==7)
	{
		cout << a[0] << '-' << a[1] << '+' << a[2] <<'+' << a[3] <<"=7"; 
	}
	else if(a[0]+a[1]-a[2]-a[3]==7)
	{
		cout << a[0] << '+' << a[1] << '-' << a[2] <<'-' << a[3] <<"=7"; 
	}
	else if(a[0]-a[1]-a[2]+a[3]==7)
	{
		cout << a[0] << '-' << a[1] << '-' << a[2] <<'+' << a[3] <<"=7"; 
	}
	else if(a[0]-a[1]+a[2]-a[3]==7)
	{
		cout << a[0] << '-' << a[1] << '+' << a[2] <<'-' << a[3] <<"=7"; 
	}
	else if(a[0]-a[1]-a[2]-a[3]==7)
	{
		cout << a[0] << '-' << a[1] << '-' << a[2] <<'-' << a[3] <<"=7"; 
	}
	
}

Compiler output:
a.cc:4:1: error: ISO C++ forbids declaration of 'gen' with no type [-fpermissive]
    4 | gen(int lv)
      | ^~~
a.cc: In function 'int gen(int)':
a.cc:7:1: warning: no return statement in function returning non-void [-Wreturn-type]
    7 | }
      | ^
a.cc: At global scope:
a.cc:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
Language: C++

#include <iostream>

using namespace std;

int main(){

	int n;
  	int m= n/1000, c=(n%1000)/100, d=((n%1000)%100)/10, u=((n%1000)%100)%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";
  	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: 'a' was not declared in this scope
   10 |         if(a+b+c+d==7)
      |            ^
a.cc:10:14: error: 'b' was not declared in this scope
   10 |         if(a+b+c+d==7)
      |              ^
Language: C++

#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
	int A,B,C,D;
	string S;
	cin >> S;
	A = S[0]-'0', B = S[1]-'0', C = S[2]-'0', D = S[3]-'0';
	     if (A + B + C + D == 7)printf_s("%d+%d+%d+%d=7\n",A,B,C,D);
	else if (A - B + C + D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
	else if (A + B - C + D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
	else if (A + B + C - D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
	else if (A - B - C + D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
	else if (A + B - C - D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
	else if (A - B + C - D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
	else printf_s("%d+%d+%d+%d=7\n", A, B, C, D);


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:37: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   19 |              if (A + B + C + D == 7)printf_s("%d+%d+%d+%d=7\n",A,B,C,D);
      |                                     ^~~~~~~~
      |                                     printf
a.cc:20:37: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   20 |         else if (A - B + C + D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
      |                                     ^~~~~~~~
      |                                     printf
a.cc:21:37: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   21 |         else if (A + B - C + D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
      |                                     ^~~~~~~~
      |                                     printf
a.cc:22:37: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   22 |         else if (A + B + C - D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
      |                                     ^~~~~~~~
      |                                     printf
a.cc:23:37: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   23 |         else if (A - B - C + D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
      |                                     ^~~~~~~~
      |                                     printf
a.cc:24:37: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   24 |         else if (A + B - C - D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
      |                                     ^~~~~~~~
      |                                     printf
a.cc:25:37: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   25 |         else if (A - B + C - D == 7)printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
      |                                     ^~~~~~~~
      |                                     printf
a.cc:26:14: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
   26 |         else printf_s("%d+%d+%d+%d=7\n", A, B, C, D);
      |              ^~~~~~~~
      |              printf
Language: C++

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

int main(){
  string s;
  char op[3];
  int n[4],sum;
  cin>>s;
  rep(i,4){
    n[i]=s[i]-'0';
  }
  rep(i,(1<<3)){
    sum=n[0];
    rep(j,3){
      if(i&(1<<j)){
        op[j]='-';
        sum-=n[j+1];
      }else{
        op[j]='+';
        sum+=n[j+1];
      }
    }
    if(sum==7){
      break;
    }
  }
  cout<<n[0];
  rep(i,3){
    cout<<op[i]<<n[i];
  }
  cout<<"=7"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:23: error: 'll' was not declared in this scope
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                       ^~
a.cc:10:3: note: in expansion of macro 'rep'
   10 |   rep(i,4){
      |   ^~~
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   rep(i,4){
      |       ^
a.cc:3:33: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                                 ^
a.cc:3:23: error: 'll' was not declared in this scope
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                       ^~
a.cc:13:3: note: in expansion of macro 'rep'
   13 |   rep(i,(1<<3)){
      |   ^~~
a.cc:13:7: error: 'i' was not declared in this scope
   13 |   rep(i,(1<<3)){
      |       ^
a.cc:3:33: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                                 ^
a.cc:15:9: error: expected ';' before 'j'
   15 |     rep(j,3){
      |         ^
a.cc:3:26: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                          ^
a.cc:15:9: error: 'j' was not declared in this scope
   15 |     rep(j,3){
      |         ^
a.cc:3:33: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                                 ^
a.cc:3:23: error: 'll' was not declared in this scope
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                       ^~
a.cc:29:3: note: in expansion of macro 'rep'
   29 |   rep(i,3){
      |   ^~~
a.cc:29:7: error: 'i' was not declared in this scope
   29 |   rep(i,3){
      |       ^
a.cc:3:33: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(ll i = 0; i < (n); i++)
      |                                 ^
Language: C++

int main(){
    int A[4],i;
    char s[4];
    scanf("%s",s);
    for(i=0;i<4;i++){
        A[i] = s[i] - '0';
    }

    int j,sum;
    char op[3];
    for(i=0;i<8;i++){
        sum = A[0];
        for(j=0;j<3;j++){
            if( i & ( 1 << j ) ){
                op[j] = '+';
                sum += A[j+1];
            }else{
                op[j] = '-';
                sum -= A[j+1];
            }
        }
        if( sum == 7 ){
            break;
        }
    }

    for(i=0;i<3;i++){
        printf("%d%c",A[i],op[i]);
    }
    printf("%d=7\n",A[3]);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'scanf' was not declared in this scope
    4 |     scanf("%s",s);
      |     ^~~~~
a.cc:28:9: error: 'printf' was not declared in this scope
   28 |         printf("%d%c",A[i],op[i]);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int main(){
a.cc:30:5: error: 'printf' was not declared in this scope
   30 |     printf("%d=7\n",A[3]);
      |     ^~~~~~
a.cc:30:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//小数点以下　cout << fixed << setprecision(10) << num << endl;

int main(){
    int s; cin >> s;
    int a = s/1000;
    int b = s/100-a*10;
    int c = s/10-a*100-b*10;
    int d = s%10;
    int j=10;
    rep(i,8){
        int res=a;
        if(i&(1<<0)) res+=b;
        else res-=b;
        if(i&(1<<1)) res+=c;
        else res-=c;
        if(i&(1<<2)) res+=d;
        else res-=d;
        if(res==7){
            j=i;
            break;
        }
    }
    cout << a;
    if(j&(1<<0)) cout << '+';
    else cout << '-';
    cout << b;
    if(j&(1<<1)) cout << '+';
    else cout << '-';a
    cout << c;
    if(j&(1<<2)) cout << '+';
    else cout << '-';
    cout << d << "=7";
}



Compiler output:
a.cc: In function 'int main()':
a.cc:43:23: error: expected ';' before 'cout'
   43 |     else cout << '-';a
      |                       ^
      |                       ;
   44 |     cout << c;
      |     ~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int pow2(int n){
  string n;
  cin >> n;
  int a,b,c,d;
  a = n[0]-'0';
  b = n[1]-'0';
  c = n[2]-'0';
  d = n[3]-'0';
  int i;
  int tmp;
  string s;
  for(i=0;i<=7;i++){
    tmp = a;
    s = "";
    if(i>=4) {
      tmp+=b;
      s += "+";
    }else{
      tmp -= b;
      s += "-";
    } 
    if(i%4>=2) {
      tmp+=c;
      s+= "+";
    }else{
      tmp -= c;
      s+= "-";
    } 
    if(i%2>=1) {
      tmp+=d;
      s+= "+";
    }else{
      tmp -= d;
      s+= "-";
    } 
    if(tmp==7)break;
  }
cout << a << s[0] << b << s[1] << c << s[2] << d << "=7";

  
}

Compiler output:
a.cc: In function 'int pow2(int)':
a.cc:4:10: error: declaration of 'std::string n' shadows a parameter
    4 |   string n;
      |          ^
a.cc:3:14: note: 'int n' previously declared here
    3 | int pow2(int n){
      |          ~~~~^
a.cc:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
   43 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int pow2(int n){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int i;
  int tmp;
  string s;
  for(i=0;i<=7;i++){
    tmp = a;
    s = "";
    if(i>=4) {
      tmp+=b;
      s += "+";
    }else{
      tmp -= b;
      s += "-";
    } 
    if(i%4>=2) {
      tmp+=c;
      s+= "+";
    }else{
      tmp -= c;
      s+= "-";
    } 
    if(i%2>=1) {
      tmp+=d;
      s+= "+";
    }else{
      tmp -= d;
      s+= "-";
    } 
    if(tmp==7)break;
  }
cout << a << s[0] << b << s[1] << c << s[2] << d << "=7";

  
}

Compiler output:
a.cc: In function 'int pow2(int)':
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int pow2(int n){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int i;
  int tmp;
  string s;
  for(i=0;i<=7;i++){
    tmp = a;
    s = "";
    if(i>=4) {
      tmp+=b;
      s += '+';
    }else{
      tmp -= b;
      s += '-';
    } 
    if(i%4>=2) {
      tmp+=c;
      s+= '+';
    }else{
      tmp -= c;
      s+= '-';
    } 
    if(i%2>=1) {
      tmp+=d;
      s+= '+';
    }else{
      tmp -= d;
      s+= '-';
    } 
    if(tmp==7)break;
  }
cout << a << s[0] << b << s[1] << c << s[2] << d << "=7";

  
}

Compiler output:
a.cc: In function 'int pow2(int)':
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int pow2(int n){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int i;
  int tmp;
  string s;
  for(i=0;i<=7;i++){
    tmp = a;
    s = "";
    if(i>=4) {
      tmp+=b;
      s += '+';
    }else{
      tmp -= b;
      s += '-';
    } 
    if(i%4>=2) {
      tmp+=c;
      s+= '+';
    }else{
      tmp -= c;
      s+= '-';
    } 
    if(i%2>=1) {
      tmp+=d;
      s+= '+';
    }else{
      tmp -= d;
      s+ = '-';
    } 
    if(tmp==7)break;
  }
cout << a << s[0] << b << s[1] << c << s[2] << d << "=7";

  
}

Compiler output:
a.cc: In function 'int pow2(int)':
a.cc:31:10: error: expected primary-expression before '=' token
   31 |       s+ = '-';
      |          ^
a.cc:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
   38 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int pow2(int n){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int i;
  int tmp;
  char s[3];
  for(i=0;i<=7;i++){
    tmp = a;
    if(i>=4) {
      tmp+=b;
      s[0] = '+';
    }else{
      tmp -= b;
      s[0] = '-';
    } 
    if(i%4>=2) {
      tmp+=c;
      s[1] = '+';
    }else{
      tmp -= c;
      s[1] = '-';
    } 
    if(i%2>=1) {
      tmp+=d;
      s[2] = '+';
    }else{
      tmp -= d;
      s[2] = '-';
    } 
    if(tmp==7)break;
  }
cout << a << s[0] << b << s[1] << c << s[2] << d << "=7";

  
}

Compiler output:
a.cc: In function 'int pow2(int)':
a.cc:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
   37 | }
      | ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int pow2(int n){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int i
  int tmp;
  char s[3];
  for(i=0;i<=7;i++){
    tmp = a;
    if(i>=4) {
      tmp+=b;
      s[0] = '+';
    }else{
      tmp -= b;
      s[0] = '-';
    } 
    if(i%4>=2) {
      tmp+=c;
      s[1] = '+';
    }else{
      tmp -= c;
      s[1] = '-';
    } 
    if(i%2>=1) {
      tmp+=d;
      s[2] = '+';
    }else{
      tmp -= d;
      s[2] = '-';
    } 
    if(tmp==7)break;
  }
cout << a << s[0] << b << s[1] << c << s[2] << d << "=7";

  
}

Compiler output:
a.cc: In function 'int pow2(int)':
a.cc:7:3: error: expected initializer before 'int'
    7 |   int tmp;
      |   ^~~
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   for(i=0;i<=7;i++){
      |       ^
a.cc:10:5: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   10 |     tmp = a;
      |     ^~~
      |     tm
a.cc:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
   37 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include<algorithm>
#define ff(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>
using namespace std;

int main() {
	int x;
	cin >> x;
	int d = x % 10;
	int c = (x % 100) / 10;
	int b = (x % 1000) / 100;
	int a = x / 1000;
	if (a + b + c + d == 7) {
		cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << endl;
		return 0;
	}
	if (a + b + c - d == 7) {
		cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << endl;
		return 0;
	}
	if (a + b - c - d == 7) {
		cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << endl;
		return 0;
	}
	if (a + b + c + d == 7) {
		cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << endl;
		return 0;
	}
	if (a - b + c + d == 7) {
		cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << endl;
		return 0;
	}
	if (a - b + c - d == 7) {
		cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << endl;
		return 0;
	}
	if (a - b - c + d == 7) {
		cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << endl;
		return 0;
	}
	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:46:10: error: expected '}' at end of input
   46 |         }
      |          ^
a.cc:8:12: note: to match this '{'
    8 | int main() {
      |            ^
Language: Java

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

		String ss = sc.next();
		int[] num = new int[4];
		for( int i=0; i<4; i++ ){
			num[i] = Integer.parseInt(ss.charAt(i));
		}
		for( int i=0; i<1; i++ ){
			if( num[0]+num[1]+num[2]+num[3]==7 ){
				System.out.println(num[0]+"+"+num[1]+"+"+num[2]+"+"+num[3]+"=7");
				break;
			}
			if( num[0]+num[1]-num[2]+num[3]==7 ){
				System.out.println(num[0]+"+"+num[1]+"-"+num[2]+"+"+num[3]+"=7");
				break;
			}
			if( num[0]+num[1]+num[2]-num[3]==7 ){
				System.out.println(num[0]+"+"+num[1]+"+"+num[2]+"-"+num[3]+"=7");
				break;
			}
			if( num[0]+num[1]-num[2]-num[3]==7 ){
				System.out.println(num[0]+"+"+num[1]+"-"+num[2]+"-"+num[3]+"=7");
				break;
			}
			if( num[0]-num[1]+num[2]+num[3]==7 ){
				System.out.println(num[0]+"-"+num[1]+"+"+num[2]+"+"+num[3]+"=7");
				break;
			}
			if( num[0]-num[1]-num[2]+num[3]==7 ){
				System.out.println(num[0]+"-"+num[1]+"-"+num[2]+"+"+num[3]+"=7");
				break;
			}
			if( num[0]-num[1]+num[2]-num[3]==7 ){
				System.out.println(num[0]+"-"+num[1]+"+"+num[2]+"-"+num[3]+"=7");
				break;
			}
			if( num[0]-num[1]-num[2]-num[3]==7 ){
				System.out.println(num[0]+"-"+num[1]+"-"+num[2]+"-"+num[3]+"=7");
				break;
			}
		}
	}
}


Compiler output:
Main.java:10: error: incompatible types: char cannot be converted to String
			num[i] = Integer.parseInt(ss.charAt(i));
			                                   ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
main(){
  string s;
  cin>>s;
  for(int bit=0;bit<8;++bit){
    bitset<3> b(bit);
    int r=s[0]-'0';
    if(b[0])r+=s[1]-'0';
    else r-=s[1]-'0';
    if(b[1])r+=s[2]-'0';
    else r-=s[2]-'0';
    if(b[2])r+=s[3]-'0';
    else r-=s[3]-'0';
    if(r==7){
      cout<<s[0];
      cout<<(b[0]?'+':'-');
      cout<<s[1];
      cout<<(b[1]?'+':'-');
      cout<<s[2];
      cout<<(b[2]?'+':'-');
      cout<<s[3];
      cout<<"=7"<<endl;
      return 0;
    }
  }

Compiler output:
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:26:4: error: expected '}' at end of input
   26 |   }
      |    ^
a.cc:3:7: note: to match this '{'
    3 | main(){
      |       ^
Language: Java

import java.util.Scanner;

public class practice {
    public static void main(String args[]){
          Scanner scanner = new Scanner(System.in);
          int input = scanner.nextInt();
          int A,B,C,D;
        D = input % 10;
        input /= 10;
        C = input % 10;
        input /= 10;
        B = input % 10;
        input /= 10;
        A = input;
        if(A + B + C + D == 7){
            System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
        }
        else if(A - B + C + D == 7){
            System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
        }
        else if(A + B - C + D == 7){
            System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
        }
        else if(A + B + C - D == 7){
            System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
        }
        else if(A - B - C + D == 7){
            System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
        }
        else if(A - B + C - D == 7){
            System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
        }
        else if(A + B - C - D == 7){
            System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
        }
        else if(A - B - C - D == 7) {
            System.out.println(A + "-" + B + "-" + C + "-" + D + "=7");
        }
    }
}



Compiler output:
Main.java:3: error: class practice is public, should be declared in a file named practice.java
public class practice {
       ^
1 error
Language: C++

import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int input = scan.nextInt();
        int A,B,C,D;

        D = input%10;
        input/=10;
        C = input%10;
        input/=10;
        B = input%10;
        input/=10;
        A = input%10;
        input/=10;

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


    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
    2 | public class Main {
      | ^~~~~~
Language: C++

#include <iostream>
 
using namespace std;
 
int main(void){
  	int A,B,C,D;
	cin >> A >> B >> C >> D;
  	int i,j,k;
	int sum_op1,sum_op2,sum_op3;
  	char op1,op2,op3;
  
  	for(i=0;i<2;i++){
      sum_op1=0;
      if(i==0)	sum_op1=A+B;
      else	sum_op1=A-B;
      
      for(j=0;j<2;j++){
        sum_op2=0;
        if(j==0)	sum_op2=sum_op1+C;
        else	sum_op2=sum_op1-C;
        
        for(k=0;k<2;k++){
           sum_op3=0;
           if(k==0)	sum_op3=sum_op2+D;
           else	sum_op3=sum_op2-D;
         if(sum_op3==7){
           if(i==0)	op1='+';
           else if(i==1) op1='-';
           if(j==0) op2='+';
           else if(j==1) op2='-';
           if(k==0) op3='+';
           else if(k==1) op3='-';
           cout << A << op1 << B << op2 << C << op3 << D << "=7" <<endl;
           return 0;
         }
      	}
        
      }
      
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:40:6: error: expected '}' at end of input
   40 |     }
      |      ^
a.cc:5:15: note: to match this '{'
    5 | int main(void){
      |               ^
Language: C++

#include <iostream>
 
using namespace std;
 
int main(void){
  	int A,B,C,D;
	cin >> A,B,C,D;
  	int i,j,k;
	int sum;
  	char op1,op2,op3;
  	for(i=0;i<2;i++){
      if(i==0)	sum=A+B;
      else	sum=A-B;
      for(j=0;j<2;j++){
        if(i==0)	sum=sum+C;
        else	sum=sum-C;
         for(k=0;k<2;k++){
           if(k==0)	sum=sum+D;
           else	sum=sum-D;
         if(sum==7){
           if(i==0)	op1="+";
           else if(i==1) op1="-";
           if(j=0) op2="+";
           else if(j=1) op2="-";
           if(k=0) op3="+";
           else if(k=1) op3="-";
           cout << A << op1 << B << op2 << C << op3 <<"=7"<<endl;
         }
         sum =0;
      }
      }
    }
  	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:29: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   21 |            if(i==0)     op1="+";
      |                             ^~~
      |                             |
      |                             const char*
a.cc:22:30: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   22 |            else if(i==1) op1="-";
      |                              ^~~
      |                              |
      |                              const char*
a.cc:23:24: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   23 |            if(j=0) op2="+";
      |                        ^~~
      |                        |
      |                        const char*
a.cc:24:29: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |            else if(j=1) op2="-";
      |                             ^~~
      |                             |
      |                             const char*
a.cc:25:24: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   25 |            if(k=0) op3="+";
      |                        ^~~
      |                        |
      |                        const char*
a.cc:26:29: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   26 |            else if(k=1) op3="-";
      |                             ^~~
      |                             |
      |                             const char*
Language: C++

#include <iostream>

using namespace std;

int main(void){
  	int A,B,C,D;
	cin >> A,B,C,D;
  	int i,j,k;
	int sum;
  	char op1,op2,op3;
  	for(i=0;i<2;i++){
      if(i==0)	sum=A+B;
      else	sum=A-B;
      for(j=0;j<2;j++){
        if(i==0)	sum=sum+C;
        else	sum=sum-C;
         for(k=0;k<2;l++){
           if(k==0)	sum=sum+D;
           else	sum=sum-D;
         if(sum==7){
           if(i==0)	op1="+";
           else if(i==1) op1="-";
           if(j=0) op2="+";
           else if(j=1) op2="-";
           if(k=0) op3="+";
           else if(k=1) op3="-";
           cout << A << op1 << B << op2 << C << op3 <<"=7"<<endl;
         }
         sum =0;
      }
      }
    }
  	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: error: 'l' was not declared in this scope
   17 |          for(k=0;k<2;l++){
      |                      ^
a.cc:21:29: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   21 |            if(i==0)     op1="+";
      |                             ^~~
      |                             |
      |                             const char*
a.cc:22:30: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   22 |            else if(i==1) op1="-";
      |                              ^~~
      |                              |
      |                              const char*
a.cc:23:24: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   23 |            if(j=0) op2="+";
      |                        ^~~
      |                        |
      |                        const char*
a.cc:24:29: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |            else if(j=1) op2="-";
      |                             ^~~
      |                             |
      |                             const char*
a.cc:25:24: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   25 |            if(k=0) op3="+";
      |                        ^~~
      |                        |
      |                        const char*
a.cc:26:29: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   26 |            else if(k=1) op3="-";
      |                             ^~~
      |                             |
      |                             const char*
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
 
int main() {
    string S;
    cin >> S;
 
    vector<int> a(4);
    rep(i, 4) {
        a[i] = S[i] - '0';
    }
 
    rep(b, (1 << 3)) {
 
        int sum = a[0];
        string s = (char)('0' + a[0]);
 
        rep(i, 3) {
            if(b & (1 << i)) {
                sum += a[i+1];
                s += '+';
                s += (char)('0' + a[i+1]);
            }
            else {
                sum -= a[i+1];
                s += '-';
                s += (char)('0' + a[i+1]);
            }
        }
 
        if(sum == 7) {
            cout << s << endl;
            return 0;
        }
    }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: conversion from 'char' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   23 |         string s = (char)('0' + a[0]);
      |                    ^~~~~~~~~~~~~~~~~~
Language: C++

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

int main () {
  string s; cin >> s;
  vector<int> in(4,0);
  for (int i = 0; i < 4; i++)
    in[i] = s[i]-'0';
  int best_config = 0;
  for (int i = 0; i < (1<<3); i++)
    if (in[0] + (i&(1<<2) > 0 ? 1 : -1)*in[1] + (i&(1<<1) > 0 ? 1 : -1)*in[2] + (i&(1<<0) > 0 ? 1 : -1)*in[3] == 7)
      best_config = i;
  cout << in[0] << (i&(1<<2) > 0 ? '+' : '-') << in[1] << (i&(1<<1) > 0 ? '+' : '-') << in[2] << (i&(1<<0) > 0 ? '+' : '-') << in[3] << "=7\n";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: 'i' was not declared in this scope; did you mean 'in'?
   13 |   cout << in[0] << (i&(1<<2) > 0 ? '+' : '-') << in[1] << (i&(1<<1) > 0 ? '+' : '-') << in[2] << (i&(1<<0) > 0 ? '+' : '-') << in[3] << "=7\n";
      |                     ^
      |                     in
Language: C++

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

int main () {
  string s; cin >> s;
  vector<int> in(4,0);
  for (int i = 0; i < 4; i++)
    in[i] = s[i]-'0';
  int best_config = 0;
  for (int i = 0; i < (1<<3); i++) {
    if (in[0] + (i&(1<<2) > 0 ? 1 : -1)*in[1] + (i&(1<<1) > 0 ? 1 : -1)*in[2] + (i&(1<<0) > 0 ? 1 : -1)*in[3] == 7)
      best_config = i;
  cout << in[0] << (i&(1<<2) > 0 ? '+' : '-') << in[1] << (i&(1<<1) > 0 ? '+' : '-') << in[2] << (i&(1<<0) > 0 ? '+' : '-') << in[3] << "=7\n";
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
int main()
{
char a1,b1,c1,d1;//注意数字是连着输进来的，得用字符来存
int ans,a,b,c,d;
cin>>a1>>b1>>c1>>d1;
a=a1-'0';b=b1-'0';c=c1-'0';d=d1-'0';
for(char i='+';i<='-';i++)
    for(char j='+';j<='-';j++)
        for(char k='+';k<='-';k++)
        {
            ans=a;//刚开始的结果一定是a
            if(i=='+') ans+=b;//如果符号是加，就加上去
            else if(i=='-') ans-=b;//否则如果是减，就减下来
            if(j=='+') ans+=c;
            else if(j=='-') ans-=c;
            if(k=='+') ans+=d;
            else if(k=='-') ans-=d;
            if(ans==7)//找到了
            {
                cout<<a<<i<<b<<j<<c<<k<<d<<"="<<ans<<"\n";
                return 0;
            }
        }
}
2：暴力
反正只有
232^3
2
3
种可能，我们也可以一 一判断即可
CodeCode
Code 
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a1,b1,c1,d1;
cin>>a1>>b1>>c1>>d1;
int a,b,c,d,ans;
a=a1-'0';b=b1-'0';c=c1-'0';d=d1-'0';
if(a+b+c+d==7)
{
    cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7\n";
    exit(0);
}
if(a+b+c-d==7)
{
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7\n";
    exit(0);
}
if(a+b-c+d==7)
{
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7\n";
    exit(0);
}
if(a-b+c+d==7)
{
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7\n";
    exit(0);
}
if(a-b+c-d==7)
{
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7\n";
    exit(0);
}
if(a+b-c-d==7)
{
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7\n";
    exit(0);
}
if(a-b-c-d==7)
{
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7\n";
    exit(0);
}
}

Compiler output:
a.cc:27:1: error: expected unqualified-id before numeric constant
   27 | 2：暴力
      | ^~~~~~~
a.cc:37:5: error: redefinition of 'int main()'
   37 | int main()
      |     ^~~~
a.cc:3:5: note: 'int main()' previously defined here
    3 | int main()
      |     ^~~~
Language: Java

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String abcd = scan.next();
		scan.close();

		String[] array = abcd.split("");
		int a = Integer.valueOf(array[0]);
		int b = Integer.valueOf(array[1]);
		int c = Integer.valueOf(array[2]);
		int d = Integer.valueOf(array[3]);


		int[] symbol = {-1, 1};
		for(int i = 0; i < 2; i++) {
			for(int j = 0; j < 2; j++) {
				for(int k = 0; k < 2; k++) {
					if(a + b * symbol[i] + c * symbol[j] + d * symbol[k] == 7) {
						System.out.print(a);
						System.out.print(i == 0?"-":"+");
						System.out.print(b);
						System.out.print(j==0?"-":"+");
						System.out.print(c);
						System.out.print(k==0?"-":"+");
						System.out.print(d);
						System.out.println("=7");
						return;
					}
				}
			}
		}
	}

Compiler output:
Main.java:32: error: reached end of file while parsing
	}
	 ^
1 error
Language: Java

import java.util.Scanner;
public class TrainTicket {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int input = scanner.nextInt();
        int A,B,C,D;
        D=input%10;
        input/=10;
        C=input%10;
        input/=10;
        B=input%10;
        input/=10;
        A=input;
        if(A+B+C+D==7){
            System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
        }else if(A+B+C-D==7){
            System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
        }else if(A+B-C+D==7) {
            System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
        }else if(A+B-C-D==7){
            System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
        }else if(A-B+C+D==7){
            System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
        }else if(A-B+C-D==7){
            System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
        }else if(A-B-C+D==7) {
            System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
        }else if(A-B-C-D==7){
            System.out.println(A+"-"+B+"-"+C+"-"+D+"=7");
        }
    }
}


Compiler output:
Main.java:2: error: class TrainTicket is public, should be declared in a file named TrainTicket.java
public class TrainTicket {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int z;
  cin>>z;
  int ans = -1;
  string outp = "";
  REP(i,8){
    int temp = 0;
    int t = z;
    outp = "";
    REP(j,3){
      if(i>>j & 1){
        temp += t%10;
        outp = to_string(t%10) + outp;
        outp = '+' + outp;
      }else{
        temp -= t%10;
        outp = to_string(t%10) + outp;
        outp = '-' + outp;
      }
      t /= 10;
    }
    temp += t%10;
    outp = to_string(t%10) + outp;
    if(temp==7){
      ans = i;
      break;
    }
  }
  
  outp += "=7"
  cout<<outp<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:80:15: error: expected ';' before 'cout'
   80 |   outp += "=7"
      |               ^
      |               ;
   81 |   cout<<outp<<endl;
      |   ~~~~
Language: C++

def conv(c): return '+' if c==1 else '-'
def main():
	num = [int(c) for c in input()]
	choices = [-1,1]
    for a in choices:
		for b in choices:
			for c in choices:
				if num[0]+num[1]*a+num[2]*b+num[3]*c==7:
					print("{}{}{}{}{}{}{}=7".format(num[0],conv(a),num[1],conv(b),num[2],conv(c),num[3]))
                    return
main()


Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def conv(c): return '+' if c==1 else '-'
      | ^~~