Language: C++

/**************
*	Areas on the Cross-Section Diagram
*	
*************/

#include <iostream>
using namespace std;
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <functional>
 
		//??????????????????????????¢??°
vector<int> getHeight(string st)
{
	vector<int> heightList;
	int height =0;
	
	heightList.push_back(height);
	
	for (int i =0; i<st.size(); i++ ){
		if(st[i] == '/'){
			height++;
		}
		else if(st[i] == '\\' ){
			height--;
		}else{
			//????????????????????????
		}
		heightList.push_back(height);
	}
	return heightList;
}
		
		//?±±????§??????????????????§??????
struct Mount{//struct=????????????????????????????????????Mount
	int height;
	int ichi;
};


		//?????????????????????????±±???????????????????????¢??°
vector<Mount> getMount(vector<int> heightList)
{
	vector<Mount> mountList;
	bool upward = true;		//???????????????????????§????????°?±±??±????????????
	
	for(int i=1; i< heightList.size() ; i++){		
		if( upward && (heightList[i-1] > heightList[i]) ){
			upward = false;			//?????????????????°false
			
			Mount summit  ;			//??£?¨????????´??????????
			summit.height= heightList[i-1] ;//??£??\
			summit.ichi  = i-1 ;
			mountList.push_back(summit);
		}
		else if( heightList[i-1] < heightList[i] ){
			upward = true;							//?????????????????°true
			
		}else{
			//?????¢??§??????(_)??´?????????????????????
		}
	}
	if(upward ){
        Mount summit  ;
	    summit.height = heightList[heightList.size()-1];
        summit.ichi = heightList.size()-1;
        mountList.push_back(summit);
    }
	return mountList;
}

	//????????????????????????????????¢??°
void outputHeightList(vector<int> heightList){
	
	for(int i= 0; i < heightList.size(); i++){
		printf("%d ", heightList[i]);
	}
	cout << endl;
	return;
}

	//?±±??????????????????????????¢??°
void outputMountList(vector<Mount> mountList)
{
	
	for(int i= 0; i < mountList.size(); i++){
		printf("%d ", mountList[i].ichi);
	}
	cout << endl;

	for(int i = 0; i < mountList.size(); i++){
		printf("%d ", mountList[i].height);
	}
	cout << endl;
	return;
}

	//?±±???????????????????????§???????±?????????¢??°????????????????????¨??¢??°
bool Comp(Mount A, Mount B ){
	return (A.height < B.height);
}

		//?????¨???????±??????¢???????±?????????¢??°
int getPondarea(Mount summit, vector<int> heightList)
{
	int pond = 0;
	int i = summit.ichi;
	
	//???????§??????¨???
	int depth = 0;
	bool upward = false;
		
	while( summit.height >= heightList[i] ){
		
		if( heightList[i] > heightList[i-1]){
			pond += 1 +(depth*2) ;
			depth++ ;
		}
		else if( heightList[i] < heightList[i-1] ){
			depth-- ;
			pond += 1 + (depth*2) ;
			upward = true;
		    if(depth == 0){
		        break;
		    }
		}
		else{
			//??????????????????????????¨?????±???????????????????¶????
			pond += (depth*2);
		}
		i--;
	}
	return pond /2 ;	//2??????????????§???????????????
}

	//?????¨???????±??????¢???????±?????????¢??°
int getLEFTPondarea(Mount summit, vector<int> heightList)
{
	int pond  = 0;
	int start = summit.ichi;;
	
	//???????§??????¨???
	int depth = 0;
	bool upward = false;
		
	while( summit.height >= heightList[start] ){//??????????????????????????§?????????????¶???????
		
		if( heightList[start] > heightList[start+1]){
			pond += 1 +(depth*2) ;	//int?????§0.5?????????????????????
			depth++ ;
		}
		else if( heightList[start] < heightList[start+1] ){
			depth-- ;
			pond += 1 + (depth*2) ;
			upward = true;
		    if(depth == 0){
		        break;
		    }
		}
		else{
			//??????????????????????????¨?????±???????????????????¶????
			pond += (depth*2);
		}
		start++;
	}
	return pond /2 ;	//2??????????????§???????????????
}

		//?????´????±??????¢???????±???????
vector<int> getRightPonds(vector<Mount>::iterator summit, vector<Mount>::iterator end, vector<int> heightList )
{
	//?????´????±??????????????????????
	vector<int> rightPonds;

	while ( summit != (end-1) ){
		//Mount??????????????°????±???????
		summit = std::max_element(summit+1, end, Comp );
        
        //?????´??¨???????±??????¢??????????´?	//??¢??????????????¢??°
        rightPonds.push_back(getPondarea( *summit, heightList ));
	}
	return rightPonds;//int??????vector
}

   //?????´????±?????±?????????¢??°
vector<int> getLeftPonds(vector<Mount>::iterator summit, vector<Mount>::iterator end, vector<int> heightList)
{
    //?????´????±??????????????????????
	vector<int> leftPonds;
	
    while( summit != (end-1)  ){
        summit = std::max_element(summit+1, end, Comp);
        
	      leftPonds.push_back(getLEFTPondarea(*summit, heightList));
	}
    return leftPonds;//int??????vector
}

		//??¨???????±??????¢????????????????????¨??¢???????±?????????¢??°
int getPondSum( vector<int> Pond){
	int pondSum = 0;
	
	for(int i = 0; i < Pond.size() ; i++){
		pondSum += Pond[i];
	}
	
	return pondSum;
}


int main()			//???????????¢??° =====
{	
	//1????????\???
	std::string st;
	getline(std::cin, st);
	
	//??????????±???????
	vector<int> heightList = getHeight(st);
	
	//?±±?????????????±???????
	vector<Mount> mountList = getMount(heightList);//?????????????????????????????????
	
	//?????´????±±???????????°???????????¬???????????????
	vector<Mount>::iterator summit = std::max_element(mountList.begin(), mountList.end(), Comp );
	
	//????????°???????????´????±?????????????????????¨??????????±??????¢???????±???????
	vector<int> rightPondList = (getRightPonds( summit, mountList.end(), heightList ));
	//???????±??????????			//	//????????°??????????????????????????¨???????±??????¢???????±???????????????¢??°
	//int?????±???vector???

	//??¨???????????????????±±??????????????????
	vector<Mount> leftmountList(mountList.begin(), summit+1) ;
	std::reverse(leftmountList.begin(), leftmountList.end());
	
	//?????´????±???§??????????????????
	vector<int> leftPondList = (getLeftPonds(leftmountList.begin(), leftmountList.end(), heightList));
	std::reverse( leftPondList.begin(), leftPondList.end()); 

	leftPondList.insert(leftPondList.end(),rightPondList.begin(),rightPondList.end() );

//-----???????????????-------------------------------------------------
	//??¨???????±????????¨???¢???????±?????????¢??°
	int pondSum = getPondSum( leftPondList );
	cout << pondSum << endl;
	
	//?±?????????°
	cout << leftPondList.size()<< " ";
	
	//??¨???????±??????¢????????????????????????
	if(leftPondList.size()==0 ){
		break;
	}else{
		for(int i = 0;  i < leftPondList.size() ; i++ ){
			cout <<  leftPondList[i] ;
			if( i !=  (leftPondList.size()-1) ){
				cout << " ";
			}
		}
		
	}
	cout << endl;
//------------------------------------------------------
	return 0;
}	//???????????????

Compiler output:
a.cc: In function 'int main()':
a.cc:254:17: error: break statement not within loop or switch
  254 |                 break;
      |                 ^~~~~