Language: C++

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,lsum=0,rsum=0;
string s[1000005];
struct A
{
	int l,r,del;
};
A data[1000005],data1[1000005];
bool f(A x,A y)
{
	if (x.r<y.r) return true;
	return false;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>s[i];
	for (int i=1;i<=n;i++)
	{
		data[i].l=data[i].r=0;
		for (int j=0;j<s[i].length();j++)
		{
			if (s[i][j]=='(') data[i].l++;
			if (s[i][j]==')') data[i].r++;
		}
		int left=0;
		int right=s[i].length()-1;
		while(left<=right)
		{
			while(s[i][left]!='('&&left<=s[i].length()-1) left++;
			while(s[i][right]!=')'&&right>=0) right--;
			if (left<=right&&s[i][left]=='('&&s[i][right]==')')
			{
				data[i].l--;
				data[i].r--;
			}
			left++;
			right--;
		}
	}
	//for (int i=1;i<=n;i++) cout<<l[i]<<' '<<r[i]<<endl;
	for (int i=1;i<=n;i++)
	{
		lsum+=data[i].l;
		rsum+=data[i].r;
		data[i].del=data[i].l-data[i].r;
	}
	if (lsum!=rsum) 
	{
		cout<<"No"<<endl;
		return 0;
	}
	int m=0;
	for (int i=1;i<=n;i++)
	{
		if (data[i].del>=0)
		{
			m++;
			data1[m]=data[i];
		}
	}
	sort(data1+1,data1+m+1,f);
	for (int i=1;i<=m;i++)
		cout<<data1[i].l<<' '<<data1[i].r;
	int cur=0;
	int flag=1;
	for (int i=1;i<=m;i++)
	{
	if (cur<data1[i].r){
		cout<<"No"<<endl;
		flag=0;
		break;
	}else{
		cur=cur+data1[i].l-data1[i].r;
	}
	}
	if (flag==1) cout<<"Yes"<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: reference to 'data' is ambiguous
   24 |                 data[i].l=data[i].r=0;
      |                 ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:24:27: error: reference to 'data' is ambiguous
   24 |                 data[i].l=data[i].r=0;
      |                           ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:27:43: error: reference to 'data' is ambiguous
   27 |                         if (s[i][j]=='(') data[i].l++;
      |                                           ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:28:43: error: reference to 'data' is ambiguous
   28 |                         if (s[i][j]==')') data[i].r++;
      |                                           ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:38:33: error: reference to 'data' is ambiguous
   38 |                                 data[i].l--;
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:39:33: error: reference to 'data' is ambiguous
   39 |                                 data[i].r--;
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:48:23: error: reference to 'data' is ambiguous
   48 |                 lsum+=data[i].l;
      |                       ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:49:23: error: reference to 'data' is ambiguous
   49 |                 rsum+=data[i].r;
      |                       ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:3: note:                 'A data [1000005]'
   11 | A data[1000005],data1[1000005];
      |   ^~~~
a.cc:50:17: error: reference to 'data' is ambiguous
   50 |                 data[i].del=data[i].l-data[i].r;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/