Language: C++

#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
typedef pair<int,int>pii;
#define fi first
#define se second
const int MN=1e6+5;
int n,lt[MN],rt[MN],a[MN],b[MN];
char S[MN];
struct data{int x,y;}A[MN],B[MN];
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++){
		scanf("%s",S+rt[i-1]+1);
		lt[i]=rt[i-1]+1;rt[i]=strlen(S+1);
	}
	reg int tot1=0,tot2=0;
	for(reg int i=1;i<=n;i++){
		reg int tot=0;
		for(reg int j=lt[i];j<=rt[i];j++){
			tot+=(S[j]=='('?1:-1);
			a[i]=min(a[i],tot);
		}
		a[i]=-a[i];b[i]=tot+a[i];
		if(a[i]<=b[i])A[++tot1]=(data){a[i],b[i]};
		else B[++tot2]=(data){a[i],b[i]};
	}
	sort(A+1,A+1+tot1,[](data a,data b){
		return a.x<b.x;
	});
	reg int res=0;
	for(reg int i=1;i<=tot1;i++){
		if(res<A[i].x)return 0*puts("No");
		res+=A[i].y-A[i].x;
	}
	sort(B+1,B+1+tot2,[](data a,data b){
		return a.y>b.y;
	});
	for(reg int i=1;i<=tot2;i++){
		if(res<B[i].x)return 0*puts("No");
		res+=B[i].y-B[i].x;
	}
	if(res)puts("No");
	else puts("Yes");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |         for(reg int i=1;i<=n;i++){
      |                     ^
a.cc:18:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |         reg int tot1=0,tot2=0;
      |                 ^~~~
a.cc:18:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |         reg int tot1=0,tot2=0;
      |                        ^~~~
a.cc:19:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 |         for(reg int i=1;i<=n;i++){
      |                     ^
a.cc:20:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   20 |                 reg int tot=0;
      |                         ^~~
a.cc:21:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   21 |                 for(reg int j=lt[i];j<=rt[i];j++){
      |                             ^
a.cc:26:42: error: reference to 'data' is ambiguous
   26 |                 if(a[i]<=b[i])A[++tot1]=(data){a[i],b[i]};
      |                                          ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 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:8: note:                 'struct data'
   11 | struct data{int x,y;}A[MN],B[MN];
      |        ^~~~
a.cc:27:17: error: 'else' without a previous 'if'
   27 |                 else B[++tot2]=(data){a[i],b[i]};
      |                 ^~~~
a.cc:27:33: error: reference to 'data' is ambiguous
   27 |                 else B[++tot2]=(data){a[i],b[i]};
      |                                 ^~~~
/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:8: note:                 'struct data'
   11 | struct data{int x,y;}A[MN],B[MN];
      |        ^~~~
a.cc:29:30: error: reference to 'data' is ambiguous
   29 |         sort(A+1,A+1+tot1,[](data a,data b){
      |                              ^~~~
/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:8: note:                 'struct data'
   11 | struct data{int x,y;}A[MN],B[MN];
      |        ^~~~
a.cc:29:30: error: 'data' has not been declared
   29 |         sort(A+1,A+1+tot1,[](data a,data b){
      |                              ^~~~
a.cc:29:37: error: reference to 'data' is ambiguous
   29 |         sort(A+1,A+1+tot1,[](data a,data b){
      |                                     ^~~~
/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:8: note:                 'struct data'
   11 | struct data{int x,y;}A[MN],B[MN];
      |        ^~~~
a.cc:29:37: error: 'data' has not been declared
   29 |         sort(A+1,A+1+tot1,[](data a,data b){
      |                                     ^~~~
a.cc: In lambda function:
a.cc:30:26: error: request for member 'x' in 'a', which is of non-class type 'int'
   30 |                 return a.x<b.x;
      |                          ^
a.cc:30:30: error: request for member 'x' in 'b', which is of non-class type 'int'
   30 |                 return a.x<b.x;
      |                              ^
a.cc: In function 'int main()':
a.cc:32:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |         reg int res=0;
      |                 ^~~
a.cc:33:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |         for(reg int i=1;i<=tot1;i++){
      |                     ^
a.cc:37:30: error: reference to 'data' is ambiguous
   37 |         sort(B+1,B+1+tot2,[](data a,data b){
      |                              ^~~~
/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:8: note:                 'struct data'
   11 | struct data{int x,y;}A[MN],B[MN];
      |        ^~~~
a.cc:37:30: error: 'data' has not been declared
   37 |         sort(B+1,B+1+tot2,[](data a,data b){
      |                              ^~~~
a.cc:37:37: error: reference to 'data' is ambiguous
   37 |         sort(B+1,B+1+tot2,[](data a,data b){
      |                                     ^~~~
/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:8: note:                 'struct data'
   11 | struct data{int x,y;}A[MN],B[MN];
      |        ^~~~
a.cc:37:37: error: 'data' has not been declared
   37 |         sort(B+1,B+1+tot2,[](data a,data b){
      |                                     ^~~~
a.cc: In lambda function:
a.cc:38:26: error: request for member 'y' in 'a', which is of non-class type 'int'
   38 |                 return a.y>b.y;
      |                          ^
a.cc:38:30: error: request for member 'y' in 'b', which is of non-class type 'int'
   38 |                 return a.y>b.y;
      |                              ^
a.cc: In function '