Language: C++

//まともに使い方を理解していないくせにincludeしまくる人間のクズ
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <iostream>


//using namespace stdしないと表記がめんどくさいからね、仕方ないね
using namespace std;

//可読性を上げるためのdefineが仇となる典型的パターン
#define rep(i,x) for(int i = 0; i < x; i++)

//ローカル変数とグローバル変数は使い分けよう！
stack<short> x, y;
short h, m, a[100], n, i;
long long int ans;
//関数って楽しいよね！（魔王スマイル）

void solve(short i, short sum){
    if(i == n - 1){
        if(sum == a[n - 1]) ans++;
        return;
    }
    if(sum < 0 || sum > 20) return;
    solve(i + 1, sum + a[i]);
    solve(i + 1, sum - a[i]);
}

int main(){
    scanf("%d", &n);
    ans = 0;
    for(i = 0; i < n; i++) scanf("%d", a[i]);
    solve(0, 0);
    printf("%lld\n", ans);
    return 0;
}
//まともに使い方を理解していないくせにincludeしまくる人間のクズ
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <iostream>


//using namespace stdしないと表記がめんどくさいからね、仕方ないね
using namespace std;

//可読性を上げるためのdefineが仇となる典型的パターン
#define rep(i,x) for(int i = 0; i < x; i++)

//ローカル変数とグローバル変数は使い分けよう！
stack<short> x, y;
short h, m, a[100], n, i;
long long int ans;
//関数って楽しいよね！（魔王スマイル）

void solve(short i, int sum){
    if(i == n
){
        if(sum == a[n - 1]) ans++;
        return;
    }
    if(sum < 0 || sum > 20) return;
    solve(i + 1, sum + a[i]);
    solve(i + 1, sum - a[i]);
    return;
}

int main(){
    scanf("%d", &n);
    ans = 0;
    for(i = 0; i < n; i++) scanf("%d", a[i]);
    solve(0, 0);
    printf("%lld\n", ans);
    return 0;
}

Compiler output:
a.cc:72:14: error: redefinition of 'std::stack<short int> x'
   72 | stack<short> x, y;
      |              ^
a.cc:25:14: note: 'std::stack<short int> x' previously declared here
   25 | stack<short> x, y;
      |              ^
a.cc:72:17: error: redefinition of 'std::stack<short int> y'
   72 | stack<short> x, y;
      |                 ^
a.cc:25:17: note: 'std::stack<short int> y' previously declared here
   25 | stack<short> x, y;
      |                 ^
a.cc:73:7: error: redefinition of 'short int h'
   73 | short h, m, a[100], n, i;
      |       ^
a.cc:26:7: note: 'short int h' previously declared here
   26 | short h, m, a[100], n, i;
      |       ^
a.cc:73:10: error: redefinition of 'short int m'
   73 | short h, m, a[100], n, i;
      |          ^
a.cc:26:10: note: 'short int m' previously declared here
   26 | short h, m, a[100], n, i;
      |          ^
a.cc:73:13: error: redefinition of 'short int a [100]'
   73 | short h, m, a[100], n, i;
      |             ^
a.cc:26:13: note: 'short int a [100]' previously declared here
   26 | short h, m, a[100], n, i;
      |             ^
a.cc:73:21: error: redefinition of 'short int n'
   73 | short h, m, a[100], n, i;
      |                     ^
a.cc:26:21: note: 'short int n' previously declared here
   26 | short h, m, a[100], n, i;
      |                     ^
a.cc:73:24: error: redefinition of 'short int i'
   73 | short h, m, a[100], n, i;
      |                        ^
a.cc:26:24: note: 'short int i' previously declared here
   26 | short h, m, a[100], n, i;
      |                        ^
a.cc:74:15: error: redefinition of 'long long int ans'
   74 | long long int ans;
      |               ^~~
a.cc:27:15: note: 'long long int ans' previously declared here
   27 | long long int ans;
      |               ^~~
a.cc:89:5: error: redefinition of 'int main()'
   89 | int main(){
      |     ^~~~
a.cc:40:5: note: 'int main()' previously defined here
   40 | int main(){
      |     ^~~~