Language: C++

Last login: Tue Sep  5 12:14:21 on console
yBookPro:~ Akira$ ls
Applications	Documents	Java temp	Music		Public
CPlusPlus	Downloads	Library		Pictures	Sites
Desktop		Dropbox		Movies		Projects	net
yBookPro:~ Akira$ vi CPlusPlus/
yBookPro:~ Akira$ cd CPlusPlus/
yBookPro:CPlusPlus Akira$ ls
AreasOnTheCrossSectionDiagram.cpp	Ring.cpp
BubbleSort.cpp				SelectionSort.cpp
CardGame.cpp				ShellSort.cpp
CountingCharacters.cpp			Shuffle.cpp
Dice.cpp				Something Java
DiceII.cpp				Something Virtual
DiceIII.cpp				Something XCode
DiceIV.cpp				Spreadsheet.cpp
DistanceII.cpp				Spreadsheet2.cpp
DoublyLinkedList.cpp			StableSort.cpp
FindingAWord.cpp			Stack.cpp
GCF.cpp					StandartDeviation.cpp
Grading.cpp				SumOfNumbers.cpp
HowManyWays.cpp				TheatreSquare.cpp
InsertionSort.cpp			TogglingCases.cpp
MathDistance.cpp			Transformation.cpp
MatrixMultiplication.cpp		Triangle.cpp
MaximumProfit.cpp			Winner.cpp
Prime.cpp				a.out
Queue.cpp				debug.cpp
yBookPro:CPlusPlus Akira$  vi AreasOnTheCrossSectionDiagram.cpp 

using namespace std;
#include<string>

int top1 = 0, top2 = 0, S1[10000];
struct A{int first; int area;};
struct A S2[10000];
void push1(int x) {
        S1[top1] = x;
        top1++;
}
void push2(int x, int y) {
        S2[top2].first = x;
        S2[top2].area = y;
        top2++;
}
int pop1() {
        top1--;
        return S1[top1];
}
struct A pop2() {
        top2--;
        return S2[top2];
}


int main() {
        string str;
        int sum, j;
        struct A temp;
        cin >> str;
        for(int a = 0; a < str.length(); a++) {
                char d = str.at(a);
                if(d == '\\') push1(a);
                if(top1 == 0);
                else if(d == '/') {
                        j = pop1();
                        sum += (a - j);
                        temp.first = j; temp.area = a - j;
                        for(int b = top2 - 1; b >= 0; b--) {
                                if(S2[b].first < a && S2[b].first > j) {
                                        temp.area += pop2().area;
                                }
                        }
                        push2(temp.first, temp.area);
                }
        }
        cout << sum << endl;
        cout << top2;
        for(int c = 0; c < top2; c++) {
                cout << " " << S2[c].area;
        }
        cout << endl;
        return 0;
}

Compiler output:
a.cc:1:1: error: 'Last' does not name a type
    1 | Last login: Tue Sep  5 12:14:21 on console
      | ^~~~
a.cc: In function 'int main()':
a.cc:57:9: error: 'string' was not declared in this scope
   57 |         string str;
      |         ^~~~~~
a.cc:57:9: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from a.cc:32:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:60:9: error: 'cin' was not declared in this scope
   60 |         cin >> str;
      |         ^~~
a.cc:60:16: error: 'str' was not declared in this scope; did you mean 'std'?
   60 |         cin >> str;
      |                ^~~
      |                std
a.cc:77:9: error: 'cout' was not declared in this scope
   77 |         cout << sum << endl;
      |         ^~~~
a.cc:77:24: error: 'endl' was not declared in this scope
   77 |         cout << sum << endl;
      |                        ^~~~