Language: C++

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

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

										// 0  \   \   /   /  /  \  _  /
		//??????????????????????????¢??°???????????§??????[0][ 1][ 2][ 3][4][5][6][7][8]
										//[0][-1][-2][-1][0][1][0][0][1]
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;	//Mount???????????§???????????§???????????????????????????
	bool upward = true;		//???????????????????????§????????°?±±??±????????????
	
	for(int i=1; i< heightList.size() ; i++){		//???????????????????????¨???????????????. i=1???????§??????????????¬????i-1??§????????????????????????
		if( upward && (heightList[i-1] > heightList[i]) ){		//??????????????????????????°up????¨?????????????????????????????????£???????????¨???????????????????????°???????????£???????±±??¨??????
			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)
{
	
//	cout << "area summit.ichi:" << summit.ichi << endl;
//	cout << "area summit.height:" << summit.height << endl;
	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) ;	//int?????§0.5???????????????????????????????±??????¢??????2?????????????????§1/2?????????
			depth++ ;
		}
		else if( heightList[i] < heightList[i-1] ){
			depth-- ;
			pond += 1 + (depth*2) ;
			upward = true;
		    if(depth == 0){//??±??????0??????????????????????????????summit.height == heightList[i-1]){
		        break;
		    }
		}
		else{
			//??????????????????????????¨?????±???????????????????¶????
			pond += (depth*2);
		}
		i--;
	}
	return pond /2 ;	//2??????????????§???????????????
}

	//?????¨???????±??????¢???????±?????????¢??°
int getLEFTPondarea(Mount summit, vector<int> heightList)
{
	
//	cout << "area summit.ichi:" << summit.ichi << endl;
//	cout << "area summit.height:" << summit.height << endl;
	int pond = 0;
	int start = 0;
//	int end = 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???????????????????????????????±??????¢??????2?????????????????§1/2?????????
			depth++ ;
		}
		else if( heightList[start] < heightList[start-1] ){
			depth-- ;
			pond += 1 + (depth*2) ;
			upward = true;
		    if(depth == 0){//??±??????0??????????????????????????????summit.height == heightList[i-1]){
		        break;
		    }
		}
		else{
			//??????????????????????????¨?????±???????????????????¶????
			pond += (depth*2);
		}
		start++;
	}
	return pond /2 ;	//2??????????????§???????????????
}
	//?????´????????¨???????±??????¢???????±?????????¢??°
/*int getLeftPondarea(Mount summit, vector<int> heightList)
{
	
//	cout << "area summit.ichi:" << summit.ichi << endl;
//	cout << "area summit.height:" << summit.height << endl;
	int pond  = 0;
	int start = summit.ichi; 
//????????????	Mount leftsummit = std::max_element(0,summit+1, Comp );;		//??????????±??????????????????????
//????????????	int end = leftsummit.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???????????????????????????????±??????¢??????2?????????????????§1/2?????????
			depth++ ;
		}
		else if( heightList[start] < heightList[start+1] ){
			depth-- ;
			pond += 1 + (depth*2) ;
			upward = true;
		    if(depth == 0){//??±??????0????????????????????????????????¨??????????????????summit.height == heightList[i-1]){
		        break;
		    }
		}
		else if( heightList[start] == heightList[start-1]){
			//??????????????????????????¨?????±???????????????????¶????
			if(depth > 0 ){
				pond += (depth*2);
			}
			else {
				//???????¶??????????;
			}
		}
		else{
			//??????????????\??????
		}
		start--;
	}
	return pond /2 ;	//2??????????????§???????????????
}
*/		//?????´????±??????¢???????±???????
vector<int> getRightPonds(vector<Mount>::iterator summit, vector<Mount>::iterator end, vector<int> heightList )
{
	//?????´????±??????????????????????
	vector<int> rightPonds;
	
//	cout << "summit->ichi:"  << summit->ichi << endl;
//	cout << "summit->height:"<< summit->height << endl;

	while ( summit != (end-1) ){
		//Mount??????????????°????±???????
		summit = std::max_element(summit+1, end, Comp );
        
        //?????´??¨???????±??????¢??????????´?	//??¢??????????????¢??°
        rightPonds.push_back(getPondarea( *summit, heightList ));
        
	//	summit++;????????????????????§????¢?????????????;	
	}
	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);
		
	//????????????????????¨?????????
//	outputHeightList(heightList);
	
	//?±±?????????????±???????
	vector<Mount> mountList = getMount(heightList);//?????????????????????????????????
	
	//?±±?????????????????¨?????????
//	outputMountList( mountList );
	
	//?????´????±±???????????°???????????¬???????????????
	vector<Mount>::iterator summit = std::max_element(mountList.begin(), mountList.end(), Comp );
	
	//????????°???????????´????±?????????????????????¨??????????±??????¢???????±???????
	vector<int> rightPondList = (getRightPonds( summit, mountList.end(), heightList ));
	//???????±??????????			//	//????????°??????????????????????????¨???????±??????¢???????±???????????????¢??°
	//int?????±???vector???

/*//------?????´????±?????????????????????????------------------------????????????
	//??¨???????±????????¨???¢???????±?????????¢??°
	int pondSum = getPondSum( rightPondList );
	cout << pondSum << endl;
	
	//?±?????????°
	cout << rightPondList.size()<< " ";
	
	//??¨???????±??????¢????????????????????????
	for(int i = 0;  i < rightPondList.size() ; i++ ){
		cout <<  rightPondList[i] ;
		if( i !=  (rightPondList.size()-1) ){
			cout << " ";
		}
	}
	cout << endl;
*///------------------------------------------------------???????????§
	
	//????????°???????????´????±???????????????°?????????????????????????????¨??????????????´????±???¨????§???????????????????
	
	//??¨???????????????????±±??????????????????
	vector<Mount> leftmountList(mountList.begin(), summit+1) ;
	std::reverse(leftmountList.begin(), leftmountList.end());
/*//-----------------------------------------------????????????	
		//???????±±??????????????????????????????
	cout << "leftmountList[i].?????????";
	for(int i = 0;  i < leftmountList.size() ; i++ ){
		cout << leftmountList[i].ichi ;
		if( i !=  (leftmountList.size()-1) ){
			cout << " ";
		}
	}
	cout << endl<<  "leftmountList[i].?????????";
	for(int i = 0;  i < leftmountList.size() ; i++ ){
		cout << leftmountList[i].height ;
		if( i !=  (leftmountList.size()-1) ){
			cout << " ";
		}
	}cout<< endl;
*///----------------------------------------------------???????????§


	//?????´????±???§??????????????????
	vector<int> leftPondList = (getLeftPonds(leftmountList.begin(), leftmountList.end(), heightList));
	std::reverse( leftPondList.begin(), leftPondList.end()); 
//	????????????leftPondList.push_back( std::reverse(summit.ichi-1,  0 ));
/*//-----------------------------------------------????????????	
		//???????±±??????????????????????????????
	cout << "rightPondList[i]???";
	for(int i = 0;  i < rightPondList.size() ; i++ ){
		cout << rightPondList[i];
		if( i !=  (rightPondList.size()-1) ){
			cout << " ";
		}
	}
	cout << endl;
//----------------------------------------------------???????????§
//-----------------------------------------------????????????	
		//???????±±??????????????????????????????
	cout << "leftPondList[i]???";
	for(int i = 0;  i < leftPondList.size() ; i++ ){
		cout << leftPondList[i];
		if( i !=  (leftPondList.size()-1) ){
			cout << " ";
		}
	}
	cout << endl;
//----------------------------------------------------???????????§
*/

/*//------?????´????±?????????????????????????------------------------????????????
	//?????´????±??????????????¨???¢???????±?????????¢??°
	int pondSum = getPondSum( leftPondList );
	cout << pondSum << endl;
	
	//?±?????????°
	cout << leftPondList.size()<< " ";
	
	//??¨???????±??????¢????????????????????????
	for(int i = 1;  i < leftPondList.size() ; i++ ){
		cout <<  leftPondList[i] ;
		if( i !=  (leftPondList.size()-1) ){
			cout << " ";
		}
	}
	cout << endl;
*///------------------------------------------------------???????????§
		
	//
//	for(int i =0; i < leftPondList.size(); i++){
//			//?????´??¨???????±??????¢??????????´?	//??¢??????????????¢??°
//			rightPondList.push_back??? lefPonds[i] );		//= getPondarea( summit, heightList );
//	}
	
	
	//??¨???????±??????¢??????????????????
//	vector<int>allPond;
//	
//	for(int i =0; i< leftPondList.size(); i++){
//		allPond.push_buck (leftPondList[i]);
//	}
//	for(int i =0; i< rightPondList.size(); i++){
//		allPond.push_buck (rightPondList[i]);
//	}

	leftPondList.insert(leftPondList.end(),rightPondList.begin(),rightPondList.end() );
	
//???????????§?????????	allPond =  std::reverse( leftPondList.begin(), leftPondList.end()-1) + rightPondList;			 //s.begin(), rightPonds.end()-1);

//------------------------------------------------------
	//??¨???????±????????¨???¢???????±?????????¢??°
	int pondSum = getPondSum( leftPondList );
	cout << pondSum << endl;
	
	//?±?????????°
	cout << leftPondList.size()<< " ";
	
	//??¨???????±??????¢????????????????????????
	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 'std::vector<int> getRightPonds(std::vector<Mount>::iterator, std::vector<Mount>::iterator, std::vector<int>)':
a.cc:248:31: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
  248 |                 summit = std::max_element(summit+1, end, Comp );
      |                               ^~~~~~~~~~~
      |                               tuple_element
a.cc: In function 'std::vector<int> getLeftPonds(std::vector<Mount>::iterator, std::vector<Mount>::iterator, std::vector<int>)':
a.cc:265:23: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
  265 |         summit = std::max_element(summit+1, end, Comp);
      |                       ^~~~~~~~~~~
      |                       tuple_element
a.cc: In function 'int main()':
a.cc:305:47: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
  305 |         vector<Mount>::iterator summit = std::max_element(mountList.begin(), mountList.end(), Comp );
      |                                               ^~~~~~~~~~~
      |                                               tuple_element
a.cc:334:14: error: 'reverse' is not a member of 'std'
  334 |         std::reverse(leftmountList.begin(), leftmountList.end());
      |              ^~~~~~~
a.cc:356:14: error: 'reverse' is not a member of 'std'
  356 |         std::reverse( leftPondList.begin(), leftPondList.end());
      |              ^~~~~~~