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

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  string s;
  cin>>s;
  vector<int>num(4);
  rep(i,4) num[i]=stoi(i);
  for(int tmp=0;tmp<(1<<3);tmp++){
    int sum=num[0];
    string s;
    s=(char)('0'+a[0]);
    bitset<3>t(tmp);
    rep(i,3){
      if(t.test(i)){
        sum+=num[i+1];
        s+='+'+(char)('0'+a[i+1]);
      else
        sum-=num[i+1];
        s+='-'+(char)('0'+a[i+1]);
      }
    }
      if(sum==7){
        s+="=7";
        cout<<s<<endl;
        return 0;
      }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:23: error: no matching function for call to 'stoi(int&)'
   22 |   rep(i,4) num[i]=stoi(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 'int' 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 'int' to 'const std::wstring&' {aka 'const std::__cxx11::basic_string<wchar_t>&'}
 4432 |   stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
      |        ~~~~~~~~~~~~~~~^~~~~
a.cc:26:18: error: 'a' was not declared in this scope
   26 |     s=(char)('0'+a[0]);
      |                  ^
a.cc:32:7: error: expected '}' before 'else'
   32 |       else
      |       ^~~~
a.cc:29:20: note: to match this '{'
   29 |       if(t.test(i)){
      |                    ^
a.cc:37:10: error: 'sum' was not declared in this scope; did you mean 'num'?
   37 |       if(sum==7){
      |          ^~~
      |          num
a.cc: At global scope:
a.cc:43:1: error: expected declaration before '}' token
   43 | }
      | ^
Language: C

#include <stdio.h>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int a, b, c, d;
  int sum;
  string op(3,'+');
  cin >> d;
  a = d / 1000;
  b = d / 100 % 10;
  c = d / 10 % 10;
  d = d % 10;
  for (int i = 0; i < (1 << 3); i++) {
    bitset<3> tmp(i);
    if (tmp[0]) {
      op[0] = '+';
      sum = a + b;
    } else {
      op[0] = '-';
      sum = a - b;
    }
    if (tmp[1]) {
      op[0] = '+';
      sum += c;
    } else {
      op[0] = '-';
      sum -= c;
    }
    if (tmp[2]) {
      op[0] = '+';
      sum += d;
    } else {
      op[0] = '-';
      sum -= d;
    }
    if (sum == 7) {
      printf("%d%c%d%c%d%c%d=7\n", a, op[0], b, op[1], c, op[2], d);
      break;
    }
  }
  return 0;
}

Compiler output:
main.c:2:10: fatal error: bitset: No such file or directory
    2 | #include <bitset>
      |          ^~~~~~~~
compilation terminated.
Language: C++

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

int main(){
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  string s='+-*/';
  
  
return 0;
}


Compiler output:
a.cc:7:12: warning: multi-character character constant [-Wmultichar]
    7 |   string s='+-*/';
      |            ^~~~~~
a.cc: In function 'int main()':
a.cc:7:12: error: conversion from 'int' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A(4);
  for(int i=3;i>=0;i--){
    A.at(i)=N%10;
    N/=10;
  }
  string s="";
  
  for(int bit=0;bit<(1<<3);++bit){
    int sum=A.at(0);
    string s=to_string(A.at(0));
    for(int i=0;i<3;++i){
      if((bit>>i)&1) sum+=A.at(i+1); s+="+";
      else sum-=A.at(i+1); s+="-";
      s+=to_string(A.at(i+1));
    }
    if(sum==7){
      s+="=7";
      break;
    }
  }
  
  cout << s << endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: 'else' without a previous 'if'
   19 |       else sum-=A.at(i+1); s+="-";
      |       ^~~~
Language: C++

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

int main(){
  vector<int> A(4);
  for(int x:A) cin>>x;
  
  string s="";
  
  for(int bit=0;bit<(1<<3);++bit){
    int sum=A.at(0);
    string s=to_string(A.at(0));
    for(int i=0;i<3;++i){
      if((bit>>i)&1) sum+=A.at(i+1); s+="+";
      else sum-=A.at(i+1); s+="-";
      s+=to_string(A.at(i+1));
    }
    if(sum==7){
      s+="=7";
      break;
    }
  }
  
  cout << s << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:7: error: 'else' without a previous 'if'
   15 |       else sum-=A.at(i+1); s+="-";
      |       ^~~~
Language: C++

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

int main(){
  vector<int> A(4);
  for(int x:A) cin>>x;
  
  for(int bit=0;bit<(1<<3);++bit){
    int sum=A.at(0);
    string s=to_string(A.at(0));
    for(int i=0;i<3;++i){
      if((bit>>i)&1) sum+=A.at(i+1);
      else sum-=A.at(i+1);
      s+=to_string(A.at(i+1));
    }
    if(sum==7){
      s+="=7";
      break;
    }
  }
  
  cout << s << endl;
  
}

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

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

int main(){
  vector<int> A(4);
  for(x::A) cin>>x;
  
  for(int bit=0;bit<(1<<3);++bit){
    int sum=A.at(0);
    string s=to_string(A.at(0));
    for(int i=0;i<3;++i){
      if((bit>>i)&1) sum+=A.at(i+1);
      else sum-=A.at(i+1);
      s+=to_string(A.at(i+1));
    }
    if(sum==7){
      s+="=7";
      break;
    }
  }
  
  cout << s << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:7: error: 'x' has not been declared
    6 |   for(x::A) cin>>x;
      |       ^
a.cc:8:3: error: expected primary-expression before 'for'
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ^~~
a.cc:6:20: error: expected ';' before 'for'
    6 |   for(x::A) cin>>x;
      |                    ^
      |                    ;
    7 | 
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ~~~               
a.cc:8:3: error: expected primary-expression before 'for'
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ^~~
a.cc:6:20: error: expected ')' before 'for'
    6 |   for(x::A) cin>>x;
      |      ~             ^
      |                    )
    7 | 
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ~~~               
a.cc:22:11: error: 's' was not declared in this scope
   22 |   cout << s << endl;
      |           ^
Language: C++

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

int main(){
  vector<int> A(4);
  for(x:A) cin>>x;
  
  for(int bit=0;bit<(1<<3);++bit){
    int sum=A.at(0);
    string s=to_string(A.at(0));
    for(int i=0;i<3;++i){
      if((bit>>i)&1) sum+=A.at(i+1);
      else sum-=A.at(i+1);
      s+=to_string(A.at(i+1));
    }
    if(sum==7){
      s+="=7";
      break;
    }
  }
  
  cout << s << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:8: error: found ':' in nested-name-specifier, expected '::'
    6 |   for(x:A) cin>>x;
      |        ^
      |        ::
a.cc:6:7: error: 'x' has not been declared
    6 |   for(x:A) cin>>x;
      |       ^
a.cc:8:3: error: expected primary-expression before 'for'
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ^~~
a.cc:6:19: error: expected ';' before 'for'
    6 |   for(x:A) cin>>x;
      |                   ^
      |                   ;
    7 | 
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ~~~              
a.cc:8:3: error: expected primary-expression before 'for'
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ^~~
a.cc:6:19: error: expected ')' before 'for'
    6 |   for(x:A) cin>>x;
      |      ~            ^
      |                   )
    7 | 
    8 |   for(int bit=0;bit<(1<<3);++bit){
      |   ~~~              
a.cc:22:11: error: 's' was not declared in this scope
   22 |   cout << s << endl;
      |           ^
Language: C++

#include<bits/stdc++.h>
# include < cstdio >
char s [5];
int main ()
{
scanf ("% s " ,& s );
int a = s [0] - ’0 ’ , b = s [1] - ’0 ’ , c = s [2] - ’0 ’ , d = s [3] - ’0 ’;
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:2:11: fatal error:  cstdio : No such file or directory
    2 | # include < cstdio >
      |           ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
using namespace std;
#define ll long long

string Op(bool opt)
{
    if (opt)
        return "+";
    return "-";
}

int main()
{
    string S;
    cin >> S;
    ll sum = 0;
    for (int i = 0; i < (1 << 4); i++)
    {
        bitset<3> op(i);
        sum = S.at(0) - 48;
        int sc = 1;
        for (int j = 0; j < op.size(); j++)
        {
            if (op.test(j))
                sum += S.at(sc) - 48;
            else
                sum -= S.at(sc) - 48;
            sc++;
        }
        if (sum == 7)
        {
            cout << S.at(0) << Op(op.test(0))
                 << S.at(1) << Op(op.test(1))
                 << S.at(2) << Op(op.test(2))
                 << S.at(3) << "=7" << endl;
            return 0;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'bitset' was not declared in this scope
   27 |         bitset<3> op(i);
      |         ^~~~~~
a.cc:10:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
    9 | #include <set>
  +++ |+#include <bitset>
   10 | using namespace std;
a.cc:27:19: error: 'op' was not declared in this scope; did you mean 'Op'?
   27 |         bitset<3> op(i);
      |                   ^~
      |                   Op
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] s=sc.next().split(""),ops={"+","+","+"};
  	int[] n=new int[4];
    int sum=0;
    for(int i=0;i<4;i++){
      n[i]=Integer.parseInt(s[i]);
      sum+=n[i];
    }
    int f=sum,j=1;
    if(sum==7){
      System.out.println(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7");
    }else{
      do{
        for(int i=j;i<4;i++){
          if(sum-a[i]<7){
            sum=f;
            j++;
            ops[0]="+";
            ops[1]="+";
            ops[2]="+";
            break;
          }else{
            sum=sum-a[i];
            ops[i-1]="-";
            if(sum==7){
              break;
            }
          }
        }
      }while(sum!=7);
      System.out.println(s[0]+ops[0]+s[1]+ops[1]+s[2]+ops[2]+s[3]+"=7");
    }
  }
}


Compiler output:
Main.java:20: error: cannot find symbol
          if(sum-a[i]<7){
                 ^
  symbol:   variable a
  location: class Main
Main.java:28: error: cannot find symbol
            sum=sum-a[i];
                    ^
  symbol:   variable a
  location: class Main
2 errors
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] s=sc.next().split(""),ops={"+","+","+"};
  	int[] n=new int[4],sum=0;
    for(int i=0;i<4;i++){
      n[i]=Integer.parseInt(s[i]);
      sum+=n[i];
    }
    int f=sum,j=1;
    if(sum==7){
      System.out.println(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7");
    }else{
      do{
        for(int i=j;i<4;i++){
          if(sum-a[i]<7){
            sum=f;
            j++;
            ops[0]="+";
            ops[1]="+";
            ops[2]="+";
            break;
          }else{
            sum=sum-a[i];
            ops[i-1]="-";
            if(sum==7){
              break;
            }
          }
        }
      }while(sum!=7);
      System.out.println(s[0]+ops[0]+s[1]+ops[1]+s[2]+ops[2]+s[3]+"=7");
    }
  }
}


Compiler output:
Main.java:8: error: incompatible types: int cannot be converted to int[]
  	int[] n=new int[4],sum=0;
  	                       ^
Main.java:11: error: bad operand types for binary operator '+'
      sum+=n[i];
         ^
  first type:  int[]
  second type: int
Main.java:13: error: incompatible types: int[] cannot be converted to int
    int f=sum,j=1;
          ^
Main.java:14: error: bad operand types for binary operator '=='
    if(sum==7){
          ^
  first type:  int[]
  second type: int
Main.java:19: error: cannot find symbol
          if(sum-a[i]<7){
                 ^
  symbol:   variable a
  location: class Main
Main.java:20: error: incompatible types: int cannot be converted to int[]
            sum=f;
                ^
Main.java:27: error: cannot find symbol
            sum=sum-a[i];
                    ^
  symbol:   variable a
  location: class Main
Main.java:29: error: bad operand types for binary operator '=='
            if(sum==7){
                  ^
  first type:  int[]
  second type: int
Main.java:34: error: bad operand types for binary operator '!='
      }while(sum!=7);
                ^
  first type:  int[]
  second type: int
9 errors
Language: Java

import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] s=sc.next().split(""),ops={"+","+","+"};
  	int[] n=new int[4],sum=0;
    for(int i=0;i<4;i++){
      n[i]=Integer.parseInt(s[i]);
      sum+=n[i];
    }
    int f=sum,j=1;
    if(sum==7){
      System.out.println(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7");
    }else{
      do{
        for(int i=j;i<4;i++){
          if(sum-a[i]<7){
            sum=f;
            j++;
            ops={"+","+","+"};
            break;
          }
          else{
            sum=sum-a[i];
            ops[i-1]="-";
            if(sum==7){
              break;
            }
          }
        }
      }while(sum!=7);
      System.out.println(s[0]+ops[0]+s[1]+ops[1]+s[2]+ops[2]+s[3]+"=7");
    }
  }
}


Compiler output:
Main.java:22: error: illegal start of expression
            ops={"+","+","+"};
                ^
Main.java:22: error: not a statement
            ops={"+","+","+"};
                 ^
Main.java:22: error: ';' expected
            ops={"+","+","+"};
                    ^
3 errors
Language: C++

  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:1:3: error: expected unqualified-id before 'if'
    1 |   if(a+b+c+d == 7)      printf("%d+%d+%d+%d= 7\n", a, b, c, d);
      |   ^~
a.cc:2:3: error: expected unqualified-id before 'else'
    2 |   else if(a+b+c-d == 7) printf("%d+%d+%d-%d= 7\n", a, b, c, d);
      |   ^~~~
a.cc:3:3: error: expected unqualified-id before 'else'
    3 |   else if(a+b-c+d == 7) printf("%d+%d-%d+%d= 7\n", a, b, c, d);
      |   ^~~~
a.cc:4:3: error: expected unqualified-id before 'else'
    4 |   else if(a+b-c-d == 7) printf("%d+%d-%d-%d= 7\n", a, b, c, d);
      |   ^~~~
a.cc:5:3: error: expected unqualified-id before 'else'
    5 |   else if(a-b+c+d == 7) printf("%d-%d+%d+%d= 7\n", a, b, c, d);
      |   ^~~~
a.cc:6:3: error: expected unqualified-id before 'else'
    6 |   else if(a-b+c-d == 7) printf("%d-%d+%d-%d= 7\n", a, b, c, d);
      |   ^~~~
a.cc:7:3: error: expected unqualified-id before 'else'
    7 |   else if(a-b-c+d == 7) printf("%d-%d-%d+%d= 7\n", a, b, c, d);
      |   ^~~~
a.cc:8:3: error: expected unqualified-id before 'else'
    8 |   else if(a-b-c-d == 7) printf("%d-%d-%d-%d= 7\n", a, b, c, d);
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<int>a(4);
    for(int i=0;i<4;i++)cin>>a.at(i);
    bool exit=false;
  vector<char>op(3);
 
    for(int bit=0;bit<(1<<4);++bit){
     int x=0;
        for(int i=0;i<4;i++){
            if(bit&(1<<3)){
       x+=a.at(i);
        if(i!=0)op.at(i-1)='+'
            }
            else { x-=a.at(i)
              if(i!=0)op.at(i-1)='-';}
if(x==7)exit=true break;
    }}
cout<<a.at(0)<<op.at(0)<<a.at(1)<<op.at(1)<<a.at(2)<<op.at(2)<<a.at(3)<<"=7";
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:31: error: expected ';' before '}' token
   15 |         if(i!=0)op.at(i-1)='+'
      |                               ^
      |                               ;
   16 |             }
      |             ~                  
a.cc:17:30: error: expected ';' before 'if'
   17 |             else { x-=a.at(i)
      |                              ^
      |                              ;
   18 |               if(i!=0)op.at(i-1)='-';}
      |               ~~              
a.cc:19:18: error: expected ';' before 'break'
   19 | if(x==7)exit=true break;
      |                  ^~~~~~
      |                  ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<int>a(4);
    for(int i=0;i<4;i++)cin>>a.at(i);
    bool exit=false;
  vector<char>op(3);
 
    for(int bit=0;bit<(1<<4);++bit){
     int x=0;
        for(int i=0;i<4;i++){
            if(bit&(1<<3)){
       x+=a.at(i);
        if(i!=0)op.at(i-1)='+'
            }
            else { x-=a.at(i)
              if(i!=0)op.at(i-1)='-';}
if(x==7)exit=true break;
    }}
cout<<a.at(0)<<op.at(0)<<a.at(1)<<op.at(1)<<a.at(2)<<op.at(2)<<a.at(3)<<"=7"
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:31: error: expected ';' before '}' token
   15 |         if(i!=0)op.at(i-1)='+'
      |                               ^
      |                               ;
   16 |             }
      |             ~                  
a.cc:17:30: error: expected ';' before 'if'
   17 |             else { x-=a.at(i)
      |                              ^
      |                              ;
   18 |               if(i!=0)op.at(i-1)='-';}
      |               ~~              
a.cc:19:18: error: expected ';' before 'break'
   19 | if(x==7)exit=true break;
      |                  ^~~~~~
      |                  ;
a.cc:21:77: error: expected ';' before 'return'
   21 | cout<<a.at(0)<<op.at(0)<<a.at(1)<<op.at(1)<<a.at(2)<<op.at(2)<<a.at(3)<<"=7"
      |                                                                             ^
      |                                                                             ;
   22 | 
   23 |     return 0;
      |     ~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<int>a(4);
    for(int i=0;i<4;i++)cin>>a.at(i);
    bool exit=false;
 
    for(int bit=0;bit<(1<<4);++bit){
     int x=0;
        for(int i=0;i<4;i++){
            if(bit&(1<<3)){
       x+=a.at(i);
            }
            else  x-=a.at(i);
if(x==7)exit=true;
    }}
    if(exit)cout<<"YES";
    else cout<<"No";
 
    return 0;
#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<int>a(4);
    for(int i=0;i<4;i++)cin>>a.at(i);
    bool exit=false;

    for(int bit=0;bit<(1<<4);++bit){
     int x=0;
        for(int i=0;i<4;i++){
            if(bit&(1<<3)){
       x+=a.at(i);
            }
            else  x-=a.at(i);
if(x==7)exit=true;
    }}
    if(exit)cout<<"YES";
    else cout<<"No";

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   25 | int main(){
      |         ^~
a.cc:25:9: note: remove parentheses to default-initialize a variable
   25 | int main(){
      |         ^~
      |         --
a.cc:25:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:25:11: error: a function-definition is not allowed here before '{' token
   25 | int main(){
      |           ^
a.cc:43:2: error: expected '}' at end of input
   43 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
    vector<int>a(4);
    for(int i=0;i<4;i++)cin>>a.at(i);
    bool exit=false;

    for(int bit=0;bit<(1<<4);++bit){
     int x=0;
        for(int i=0;i<4;i++){
            if(bit&(1<<3)){
       x+=a.at(i);
            }
            else  x-=a.at(i);
if(x==7)exit=true;
    }}
    if(exit)cout<<"YES";
    else cout<<"No";

    return 0;


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

#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    char ac, bc, cc, dc;
    cin >> ac >> bc >> cc >> dc;
    int a = ac - 48; int b = bc - 48; int c = cc - 48; int d = dc - 48;
    vector<char> ops = {'+', '-'};
    for (char op1: ops) {
        for (char op2: ops) {
            for (char op3: ops) {
                int res = a;
                res += (op1 == '+') ? b : -b;
                res += (op2 == '+') ? c : -c;
                res += (op3 == '+') ? d : -d;
                if (res == 7) {
                    cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
                    return 0;
                }

    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:2: error: expected '}' at end of input
   61 | }
      |  ^
a.cc:47:25: note: to match this '{'
   47 |     for (char op1: ops) {
      |                         ^
a.cc:61:2: error: expected '}' at end of input
   61 | }
      |  ^
a.cc:42:12: note: to match this '{'
   42 | int main() {
      |            ^
Language: C++

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

int main() {
  string s;
  cin >> s;
  
  for (int bit = 0; bit < (1<<3); bit++) {
    int t = s.at(0) - '0';
    for (int i = 0; i < 3; i++) {
      if (bit & (1<<i)) {
        t += s.at(i + 1);
      }
      else {
        t -= s.at(i + 1);
      }
    }
    if (t == 7) {
      for (int j = 0; j < 3; j++) {
        if (bit & (1<<i)) {
          cout << s.at(i) << '+';
        }
        else {
          cout << s.at(i) << '-';
        }
      }
      cout << s.at(3) << endl;
      break;
    }
  }
}


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

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

int main(){
  int a[4];
  string input;
  cin>>input;
  for(int k=0;k<4;k++){
    a[k]=input[k]-'0';
  string s;
  int sum=a[0];
  for(int x=0;x<8;x++){
    s+=(char)('0'+a[0]);
    for(int i=0;i<3;i++){
      if(x&(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:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
  int a[4];
  string input;
  cin>>input;
  for(int k=0;k<4;k++){
    a[i]=input[i]-'0';
  string s;
  int sum=a[0];
  for(int x=0;x<8;x++){
    s+=(char)('0'+a[0]);
    for(int i=0;i<3;i++){
      if(x&(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:9:7: error: 'i' was not declared in this scope
    9 |     a[i]=input[i]-'0';
      |       ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
  int a[4]
  cin>>a[0]>>a[1]>>a[2]>>a[3];
  string s;
  int sum=a[0];
  for(int x=0;x<8;x++){
    s+=(char)('0'+a[0]);
    for(int i=0;i<3;i++){
      if(x&(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;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: expected initializer before 'cin'
    6 |   cin>>a[0]>>a[1]>>a[2]>>a[3];
      |   ^~~
a.cc:8:11: error: 'a' was not declared in this scope
    8 |   int sum=a[0];
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int p=a/1000%10,q=a/100%10,r=a/10%10,s=a%10;
  if(p-q-r-s==7)cout << p << '-' << q << '-' << r << '-' s << "=7";
  else if(p-q-r+s==7)cout << p << '-' << q << '-' << r << '+' s << "=7";
  else if(p-q+r-s==7)cout << p << '-' << q << '+' << r << '-' s << "=7";
  else if(p-q+r+s==7)cout << p << '-' << q << '+' << r << '+' s << "=7";
  else if(p+q-r-s==7)cout << p << '+' << q << '-' << r << '-' s << "=7";
  else if(p+q-r+s==7)cout << p << '+' << q << '-' << r << '+' s << "=7";
  else if(p+q+r-s==7)cout << p << '+' << q << '+' << r << '-' s << "=7";
  else cout << p << '+' << q << '+' << r << '+' s << "=7";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:57: error: expected ';' before 's'
    7 |   if(p-q-r-s==7)cout << p << '-' << q << '-' << r << '-' s << "=7";
      |                                                         ^~
      |                                                         ;
a.cc:8:62: error: expected ';' before 's'
    8 |   else if(p-q-r+s==7)cout << p << '-' << q << '-' << r << '+' s << "=7";
      |                                                              ^~
      |                                                              ;
a.cc:9:62: error: expected ';' before 's'
    9 |   else if(p-q+r-s==7)cout << p << '-' << q << '+' << r << '-' s << "=7";
      |                                                              ^~
      |                                                              ;
a.cc:10:62: error: expected ';' before 's'
   10 |   else if(p-q+r+s==7)cout << p << '-' << q << '+' << r << '+' s << "=7";
      |                                                              ^~
      |                                                              ;
a.cc:11:62: error: expected ';' before 's'
   11 |   else if(p+q-r-s==7)cout << p << '+' << q << '-' << r << '-' s << "=7";
      |                                                              ^~
      |                                                              ;
a.cc:12:62: error: expected ';' before 's'
   12 |   else if(p+q-r+s==7)cout << p << '+' << q << '-' << r << '+' s << "=7";
      |                                                              ^~
      |                                                              ;
a.cc:13:62: error: expected ';' before 's'
   13 |   else if(p+q+r-s==7)cout << p << '+' << q << '+' << r << '-' s << "=7";
      |                                                              ^~
      |                                                              ;
a.cc:14:48: error: expected ';' before 's'
   14 |   else cout << p << '+' << q << '+' << r << '+' s << "=7";
      |                                                ^~
      |                                                ;
Language: C++

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

using namespace std;

string func(vector<int> &n_abcd, int index, int count, string formula) {
    if (index >= 3) {
        // ベースケース
        if (count == 7) {
            return formula;
        }
        else {
            return formula.substr(0, formula.size() - 2);
        }
    }
    else {
        //再帰ケース
        formula = func(n_abcd, index + 1, count + n_abcd.at(index + 1), formula += "+" + to_string(n_abcd.at(index + 1)));
        if (formula.size() == 7) {
            return formula;
        }
        formula = func(n_abcd, index + 1, count - n_abcd.at(index + 1), formula += "-" + to_string(n_abcd.at(index + 1)));
        if (formula.size() == 7) {
            return formula;
        }
    }
}

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


    int num = stoi(abcd);
    vector<int> n_abcd(4);

    for (int i = 0; i < 4; i++) {
        n_abcd.at(i) = num % 10;
        num /= 10;
    }
    reverse(n_abcd.begin(), n_abcd.end());

    string result = func(n_abcd, 0, n_abcd.at(0), to_string(n_abcd.at(0)));
    cout << result + "=7" << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:43:5: error: 'reverse' was not declared in this scope
   43 |     reverse(n_abcd.begin(), n_abcd.end());
      |     ^~~~~~~
a.cc: In function 'std::string func(std::vector<int>&, int, int, std::string)':
a.cc:28:1: warning: control reaches end of non-void function [-Wreturn-type]
   28 | }
      | ^
Language: C++

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

int main()
{
    int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
   
   

  
   for( int symbol = 0;symbol<8;symbol++)
   {
       int sum=a[0];
       string s;
       s += to_string(a[i+1]);
       
        for(int i=0;i<3;i++)
        {
            if(symbol & (1<<i))
            {
            sum += a[i+1];
            s+= "+";
            s+= to_string(a[i+1]);
            }
            else
            {
            sum -= a[i+1];
            s+= "-";
            s+= to_string(a[i+1]);
            }
        }
     
      if(sum==7)
        {  
            cout<<s<<"=7"<<endl;
            break;
        }
     }
   
      
        return 0;
   }
    


Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: error: 'i' was not declared in this scope
   16 |        s += to_string(a[i+1]);
      |                         ^
Language: C++

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

int main()
{
    int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
   
   
    
  vector<string>s(3);
  
   for( int symbol = 0;symbol<8;symbol++)
   {
       int sum=A;
       string s;
       s += to_string(a[0]);
       
     for(int i=0;i<3;i++)
     {
          if(symbol&(1<<i))
          {
            sum += a[i+1];
            s+= "+";
            s+= to_string(a[i+1]);
          }
          else
          {
            sum -= a[i+1];
            s+= "-";
            s+= to_string(a[i+1]); 
          }
     }
     
     if(sum==7)
        {  
            cout<<s<<"=7"<<endl;
            return 0;
        }
     }
   
      
        return 0;
   }
    


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

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

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
   
   
    
  vector<string>s(3);
  
   for( int symbol = 0;symbol<8;symbol++)
   {
       int sum=A;
       string s;
       s += to_string(A);
       
     for(int i=0;i<3;i++)
     {
          if(symbol&(1<<i))
          {
            sum += B;
            s+= "+";
            s+= to_string(B);
          }
          else
          {
            sum -= B;
            s+= "-";
            s+= to_string(B); 
          }
     }
     
     if(sum==7)
        {  
            cout<<s<<"=7"<<endl;
            return 0;
        }
     }
   
      
        return 0;
   }
    
    
  
  
  
}


Compiler output:
a.cc:50:1: error: expected declaration before '}' token
   50 | }
      | ^
Language: C++

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

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
   
   
    
 
  
   for( int symbol = 1;symbol<(1<<3);symbol++)
   {
       int sum=A;
       vector<string>s(3);
     
       if(symbol<<0 & 1){
            sum+= D;
           s.at(2)="+";
       }
       else{
            sum-= D;
            s.at(2)="-";
       }
       if(symbol<<1 & 1){
            sum+= C;
            s.at(1)="+";
       }
        else{
             sum-= C;
             s.at(1)="-";
        }
        if(symbol<<2 & 1){
             sum+=B;
             s.at(0)="+";
        }
        else {
             sum-=B;
             s.at(0)="-";
        }
   
      if(sum==7)
        break;
   }
    
    
  
   cout<<A<<s.at(0)<<B<<s.at(1)<<C<<s.at(2)<<D<<"=7"<<endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:13: error: 's' was not declared in this scope
   49 |    cout<<A<<s.at(0)<<B<<s.at(1)<<C<<s.at(2)<<D<<"=7"<<endl;
      |             ^
Language: C++

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

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int sum = A;
   
    
  
   for( int symbol = 1;symbol<(1<<3);symbol++)
   {
       vector<string> s(3);
     
       if(symbol<<0 & 1){
            sum+= D;
           s.at(2)="+";
       }
       else{
            sum-= D;
            s.at(2)="-";
       }
       if(symbol<<1 & 1){
            sum+= C;
            s.at(1)="+";
       }
        else{
             sum-= C;
             s.at(1)="-";
        }
        if(symbol<<2 & 1){
             sum+=B;
             s.at(0)="+";
        }
        else {
             sum-=B;
             s.at(0)="-";
        }
   
      if(sum==7)
        break;
   }
    
    
  
   cout<<A<<s.at(0)<<B<<s.at(1)<<C<<s.at(2)<<D<<"=7"<<endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:13: error: 's' was not declared in this scope
   47 |    cout<<A<<s.at(0)<<B<<s.at(1)<<C<<s.at(2)<<D<<"=7"<<endl;
      |             ^
Language: C++

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

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int sum = A;
    int symbol = 1;
    
  
   for(;symbol<(1<<3);symbol++)
   {
       string s[3];
     
       if(symbol<<0 & 1){
            sum+= D;
           s[2]="+";
       }
       else{
            sum-= D;
            s[2]="-";
       }
       if(symbol<<1 & 1){
            sum+= C;
            s[1]="+";
       }
        else{
             sum-= C;
             s[1]="-";
        }
        if(symbol<<2 & 1){
             sum+=B;
             s[0]="+";
        }
        else {
             sum-=B;
             s[0]="-";
        }
   
      if(sum==7)
        break;
   }
    
    
  
   cout<<A<<s[0]<<B<<s[1]<<C<<s[2]<<D<<"=7"<<endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:13: error: 's' was not declared in this scope
   47 |    cout<<A<<s[0]<<B<<s[1]<<C<<s[2]<<D<<"=7"<<endl;
      |             ^
Language: C++

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

int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int sum = A;
    int symbol = 1;
    
  
   for(;symbol<(1<<3);symbol++)
   {
       string s[3];
     
       if(symbol<<0 & 1){
            sum+= D;
           s[2]="+";
       }
       else{
            sum-= D;
            s[2]="-";
       }
       if(symbol<<1 & 1){
            sum+= C;
            s[1]="+";
       }
        else{
             sum-= C;
             s[1]="-";
        }
        if(symbol<<2 & 1){
             sum+=B;
             s[0]="+";
        }
        else {
             sum-=B;
             sum[0]="-";
        }
   
      if(sum==7)
        break;
   }
    
    
  
   cout<<A<<s[0]<<B<<s[1]<<C<<s[2]<<D<<"=7"<<endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: invalid types 'int[int]' for array subscript
   38 |              sum[0]="-";
      |                 ^
a.cc:47:13: error: 's' was not declared in this scope
   47 |    cout<<A<<s[0]<<B<<s[1]<<C<<s[2]<<D<<"=7"<<endl;
      |             ^
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
using namespace std;

int main() {
  int A, B, C, D, ans = 0;
  cin >> A >> B >> C >> D;
  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:11:14: error: expected ';' before user-defined string literal
   11 |     cout << A"+"B"+"C"+"D"=7";
      |              ^~~~
      |              ;
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
using namespace std;

int main() {
  int A, B, C, D, ans = 0;
  cin >> A >> B >> C >> D;
  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:12:14: error: expected ';' before user-defined string literal
   12 |     cout << A"+"B"+"C"+"D"=7";
      |              ^~~~
      |              ;
a.cc:15:14: error: expected ';' before user-defined string literal
   15 |     cout << A"+"B"+"C"-"D"=7";
      |              ^~~~
      |              ;
a.cc:18:14: error: expected ';' before user-defined string literal
   18 |     cout << A"+"B"-"C"+"D"=7";
      |              ^~~~
      |              ;
a.cc:21:14: error: expected ';' before user-defined string literal
   21 |     cout << A"-"B"+"C"+"D"=7";
      |              ^~~~
      |              ;
a.cc:24:14: error: expected ';' before user-defined string literal
   24 |     cout << A"-"B"-"C"+"D"=7";
      |              ^~~~
      |              ;
a.cc:27:14: error: expected ';' before user-defined string literal
   27 |     cout << A"+"B"-"C"-"D"=7";
      |              ^~~~
      |              ;
a.cc:30:14: error: expected ';' before user-defined string literal
   30 |     cout << A"-"B"+"C"-"D"=7";
      |              ^~~~
      |              ;
a.cc:33:14: error: expected ';' before user-defined string literal
   33 |     cout << A"-"B"-"C"-"D"=7";
      |              ^~~~
      |              ;
Language: C++

# include < cstdio >
char s [5];
int main (){
scanf ("% s " ,& s );
int a = s [0] - ’0 ’ , b = s [1] - ’0 ’ , c = s [2] - ’0 ’ , d = s [3] - ’0 ’;
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:1:11: fatal error:  cstdio : No such file or directory
    1 | # include < cstdio >
      |           ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    vector<int> var(s.length(), 0);
    //A, B, C, Dに分ける
    for(int i=0; i<s.length(); i++){
        var[i] = atoi(s.substr(i, 1).c_str());
    }
    
    // 3ビットのビット列をすべて列挙する
    for (int tmp = 0; tmp < (1 << 3); tmp++) {
        bitset<3> b(tmp);
        // ビット列を使用した処理
        s.clear();
        int sum=var[0];
        s+= to_string(var[0]);
        
        for(int i=0; i<3; i++){
            if(b.test(i)){
                sum=sum-var[i+1];
                s+="-"+to_string(var[i+1]);
            }else{
                sum=sum+var[i+1];
                s+="+"+to_string(var[i+1]);
            }
        }
        
        if(sum==7){
            cout << s + "=7" << endl;
        }
    }
    
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:19:9: error: 'bitset' was not declared in this scope
   19 |         bitset<3> b(tmp);
      |         ^~~~~~
a.cc:4:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
    3 | #include <cmath>
  +++ |+#include <bitset>
    4 | 
a.cc:19:19: error: 'b' was not declared in this scope
   19 |         bitset<3> b(tmp);
      |                   ^
Language: C++

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

int main() {
  vector<int>a(4);
  cin>>a.at(0)>>a.at(1)>>a.at(2)>>a.at(3);
  for(int i=0;i<8;i++){
    int sum=a.at(0);
    string s='0'+a.at(0);
    for(int j=0;j<3;j++){
      if(i&(1<<j)){
        sum+=a.at(j+1);
        s+='+';
        s+='0'+a.at(j+1);
      }
      else{
        sum-=a.at(j+1);
        s+='-';
        s+='0'+a.at(j+1);
      }
    }
     if(sum==7){
        cout<<s<<"=7"<< endl;
        return 0;
     }
  }
}

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

# include < cstdio >
char s [5];
int main ()
{
scanf ("% s " ,& s );
int a = s [0] - ’0 ’ , b = s [1] - ’0 ’ , c = s [2] - ’0 ’ , d = s [3] - ’0 ’;
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:
main.c:1:11: fatal error:  cstdio : No such file or directory
    1 | # include < cstdio >
      |           ^~~~~~~~~~
compilation terminated.
Language: C++

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

int main() {
	char ca,cb,cc,cd;
	cin >> ca >> cb >> cc >> cd;
	int a = ca - '0',b = cb - '0',
	    c = cc - '0',d = cd - '0';
	string ans="";
	int p1,p2,p3;
	for(int i=0;i<2;i++)
	{
		char o1 = '-';
		p1 = a - b;
		if(i>0)
		{
			o1 = '+';
			p1 = a+b;
		}
		for(int j=0;j<2;j++)
		{
			char o2 = '-';
			p2 = p1 - c;
			if(j>0)
			{
				o2 = '+';
				p2 = p1 + c;
			}
			for(int k=0;k<2;k++)
			{
				char o3='-';
				p3 = p2 - d;
				if(k>0)
				{
					o3='+';
					p3 = p2 + d;
				}
				if(p3 == 7)
				{
					ans = ca + o1 + cb + o2 + cc + o3 + cd + '=' + '7';
				}
			}
		}
	}
    cout << ans << endl;
    }
}


Compiler output:
a.cc:47:1: error: expected declaration before '}' token
   47 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int A;
  cin>>A;
  string s;
  vector<int>B(3);
  for(int i=2;0<=i;i--)
    cin>>B.at(i);
  for(int bit=0;bit<(1<<3);bit++){
       int ans=0;
    for(int i=0;i<3;i++){
   if(bit&(1<<i))
     ans+=B.at(i);
      else
        ans-B.at(i);
  
  } if(ans==7-A){
    s=to_string(bit); break;
    }
  
  }for(int i=0;i<3)
    if(s.at(i)=='1')
      s.at(i)='+';
  else
    s.at(i)='-';
  cout<<A<<s.at(2)<<B.at(2)<<s.at(1)<<B.at(1)<<s.at(0)<<B.at(0)<<"=7"<<endl;
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: expected ';' before ')' token
   22 |   }for(int i=0;i<3)
      |                   ^
      |                   ;
Language: C++

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

int main() {
    char ch, b[4];
    int a[4], s1= 0,s2 = 0, i, j, k, m;
    for (i = 0; i < 4; i++) {
        cin >> ch;
        a[i] = ch - '0';
        s1 += a[i];
    }
    if (s1 == 7) {
        cout << a[0];
        for(i = 1; i < 4; i++){
            cout << '+' << a[i];
        }
        cout << "=7" << endl;
    }
    else {
		s2 = a[0]
        for(i = 1; i < 4; i++){
            s2 -= a[i];
        }
        if (s2 == 7) {
            cout << a[0];
            for(i = 1; i < 4; i++){
               cout << '-' << a[i];
            }
          cout << "=7" << endl;
        }
		else {
			for (k = 0; k < 2; k++) {
				for (i = 1; i < 4; i++) {
					for (j = 1; j < 4; j++) {
						if (j == i) k == 0 ? b[j] = '+' : b[j] = '-';
						else k == 0 ? b[j] = '-' : b[j] = '+';
					}
					m = k == 0 ? s2 + 2 * a[i]: s1 - 2 * a[i];
					if (m == 7) { 
					    cout << a[0];
                        for(i = 1; i < 4; i++){
                           cout << b[i] << a[i];
                        }
                        cout << "=7" << endl;
                        exit(0); 
					}
				}
			}
		}   
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:26: error: expected ';' before 'for'
   20 |                 s2 = a[0]
      |                          ^
      |                          ;
   21 |         for(i = 1; i < 4; i++){
      |         ~~~               
a.cc:21:30: error: expected ';' before ')' token
   21 |         for(i = 1; i < 4; i++){
      |                              ^
      |                              ;