Language: C++

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <map>
#include <math.h>

int main(void)
{
    stack<int> S1;
    stack<pair<int, int>> S2;
    char ch;
    int sum = 0;

    for (int i = 0; cin >> ch; i++)
    {
        if (ch == '\\')
        {
            S1.push(i);
        }
        else if (ch == '/' && S1.size() > 0)
        {
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while (S2.size() > 0 && S2.top().first > j)
            {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vactor<int> ans;
    while (S2.size() > 0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); i++)
    {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'stack' was not declared in this scope; did you mean 'obstack'?
   13 |     stack<int> S1;
      |     ^~~~~
      |     obstack
a.cc:13:11: error: expected primary-expression before 'int'
   13 |     stack<int> S1;
      |           ^~~
a.cc:14:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   14 |     stack<pair<int, int>> S2;
      |           ^~~~
      |           std::pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here
   89 |     struct pair;
      |            ^~~~
a.cc:14:16: error: expected primary-expression before 'int'
   14 |     stack<pair<int, int>> S2;
      |                ^~~
a.cc:18:21: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   18 |     for (int i = 0; cin >> ch; i++)
      |                     ^~~
      |                     std::cin
In file included from a.cc:4:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:22:13: error: 'S1' was not declared in this scope; did you mean 'y1'?
   22 |             S1.push(i);
      |             ^~
      |             y1
a.cc:24:31: error: 'S1' was not declared in this scope; did you mean 'y1'?
   24 |         else if (ch == '/' && S1.size() > 0)
      |                               ^~
      |                               y1
a.cc:30:20: error: 'S2' was not declared in this scope
   30 |             while (S2.size() > 0 && S2.top().first > j)
      |                    ^~
a.cc:35:13: error: 'S2' was not declared in this scope
   35 |             S2.push(make_pair(j, a));
      |             ^~
a.cc:35:21: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   35 |             S2.push(make_pair(j, a));
      |                     ^~~~~~~~~
      |                     std::make_pair
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:39:5: error: 'vactor' was not declared in this scope
   39 |     vactor<int> ans;
      |     ^~~~~~
a.cc:39:12: error: expected primary-expression before 'int'
   39 |     vactor<int> ans;
      |            ^~~
a.cc:40:12: error: 'S2' was not declared in this scope
   40 |     while (S2.size() > 0)
      |            ^~
a.cc:42:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |         ans.push_back(S2.top().second);
      |         ^~~
      |         abs
a.cc:45:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |     reverse(ans.begin(), ans.end());
      |             ^~~
      |             abs
a.cc:45:5: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
   45 |     reverse(ans.begin(), ans.end());
      |     ^~~~~~~
      |     std::reverse
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: 'std::reverse' declared here
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
a.cc:46:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   46 |     cout << sum << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:46:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   46 |     cout << sum << endl;
      |                    ^~~~
      |                    std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~