I have found a very short solution of 1997C - Even Positions compared to what's available everywhere. Please upvote if found helpful.
Shayan Is there any edge case for this solution?
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
void solve() {
int n; cin >> n;
string s; cin >> s;
int ans = 0;
for (int i = 0; i < n; i += 2) {
if (s[i + 1] == ')') {
ans += 1;
}
else {
ans += 3;
}
}
cout << ans << nl;
}
int main() {
FAST_IO
int tc; cin >> tc;
while (tc--) {solve();}
}