Language: C++

#include <iostream>
#include <cstring>
#include <set>
#include <vector>
#include <algorithm>
#define MOD 1000000007
using namespace std;

int n, arr[200010], cvp;
vector<pair<int, int> > index;
set<int> step;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
		index.push_back(make_pair(arr[i], i));
	}
	sort(index.begin(), index.end());
	cvp=index[0].second*(n-index[0].second+1);
	step.insert(index[0].second);
	for (int i = 1; i < n; ++i){
		int bas, son;
		set<int>::iterator it=step.lower_bound(index[i].second);
		if(it==step.end())son=n+1;
		else son=*it;
		if(it==step.begin())bas=0;
		else{
			it--;
			bas=*it;
		}
		cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second);
		step.insert(index[i].second);
	}
	cout<<cvp;
	return 0;
}

Compiler output:
a.cc:10:25: error: 'std::vector<std::pair<int, int> > index' redeclared as different kind of entity
   10 | vector<pair<int, int> > index;
      |                         ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:2:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:20:23: error: overloaded function with no contextual type information
   20 |                 index.push_back(make_pair(arr[i], i));
      |                       ^~~~~~~~~
a.cc:22:20: error: overloaded function with no contextual type information
   22 |         sort(index.begin(), index.end());
      |                    ^~~~~
a.cc:22:35: error: overloaded function with no contextual type information
   22 |         sort(index.begin(), index.end());
      |                                   ^~~
a.cc:23:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |         cvp=index[0].second*(n-index[0].second+1);
      |                  ^
a.cc:23:37: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |         cvp=index[0].second*(n-index[0].second+1);
      |                                     ^
a.cc:24:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   24 |         step.insert(index[0].second);
      |                          ^
a.cc:27:61: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |                 set<int>::iterator it=step.lower_bound(index[i].second);
      |                                                             ^
a.cc:35:27: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   35 |                 cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second);
      |                           ^
a.cc:35:43: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   35 |                 cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second);
      |                                           ^
a.cc:35:69: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   35 |                 cvp+=index[i].first*(index[i].second-bas)*(son-index[i].second);
      |                                                                     ^
a.cc:36:34: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   36 |                 step.insert(index[i].second);
      |                                  ^