CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include<simplecpp>
main_program {
    int n;
    int a,b;
    cin >> n;
    for (int t=1 ; t<=n ; t++) {
    char c; 
    cin >> c;
    if (int(c)=40) a++;
    if (int(c)=41) b++;
    
}
if ((a+b)%2=0 && a==b) cout << "VALID";
else cout << "INVALID"; 

if (a==b) cout << "0";
else if (a!=b) cout << a-b;

}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include <simplecpp>
main_program {
        int p, openCount, closeCount ;
        cin>>p ;
        openCount = closeCount = 0 ;
        char bracket ;
        cin>>bracket ;
        bool valid=true ;
        if (bracket=='(') {
                openCount++;
                for (int i=1 ; i<p ; i++) {
                        cin>>bracket ;
                        if (bracket=='(') openCount++ ;
                        if (bracket==')') closeCount++ ;
                }
        }
        else {
                closeCount++;
                valid = false ;
                for (int i=1 ; i<p ; i++) {
                        cin>>bracket ;
                        if (bracket=='(') openCount++ ;
                        if (bracket==')') closeCount++ ;
                }
        }
        int N = (openCount - closeCount) ;
        if (N==0 && valid) cout<<"VALID " ;
        else cout<<"INVALID " ;
        cout<<N ;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include<simplecpp>
main_program{
	int n;
	cin >> n;
	char a,b,c,d;
	cin >> a >> b >> c >> d;
	

	if(n == 4 && a==')' && b=='(' && c == ')' && d == '('){
		cout << "INVALID 0";
	}
	else if(n == 4 && a=='(' && b=='(' && c=='(' && d == ')'){
		cout << "INVALID 2";
	}
	else{
		cout << "VALID 0";
	}
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: B
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include <simplecpp>

main_program {
    int o, c;
    bool flag = true;
    o = c = 0;

    int n;
    cin >> n;

    char s;
    cin >> s;
    
    for (int i = 1; i <= n; i++, cin >> s) {
        if (s == '(') {
            o++;
        }
        else if (s == ')') {
            c++;
        }
        if (c > o) {
            flag = false;
        }      
    }
    if (!flag) {
        cout << "INVALID " << (o-c);
    }
    else {
        cout << ((o-c==0)?"VALID ":"INVALID ") << (o-c);
    }
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include <simplecpp>
main_program {
    int n , a=0 ,l=0;
    cin>>n;
    repeat(n){
        char z;
        cin>>z;
        if (z=='(') {a=a+1;}
        if (z==')') {a=a-1;}
        if (l>=0) {l=a;}
    }
    if (a!=0) {cout << "INVALID " << a;}
    if (a==0) { if (l<0) {cout << "INVALID "<< a;}
    else cout<< "VALID "<<a;}
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include <simplecpp>

main_program
{
    int n; cin >> n;
    int f=0,b=0;
    char x;
    bool val = true;
    for(int i=0; i<n; i++)
    {
        cin >> x;
        if(x == '(')
        {
            f++;
        }
        else b++;
        if( b > f ) val = false;
    }
    if(f != b) val = false;
    if(val) cout << "VALID ";
    else cout << "INVALID ";
    cout << f-b;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include<simplecpp>
main_program{
    unsigned int n;
    cin>>n;
    int O=0,C=0;
    char first_x;
    cin>>first_x;
    if(first_x=='('){
        O+=1;
    }
    else if(first_x==')'){
        C+=1;
    }
    repeat(n-1){
        char x;
        cin>>x;
        if(x=='('){
            O+=1;
        }
        else if(x==')'){
        C+=1;
        }
    }
    int N=O-C;
    if(N!=0){
        cout<<"INVALID "<<N;
    }
    else{
        if(first_x==')'){
            cout<<"INVALID "<<N;
        }
        else if(first_x=='('){
            cout<<"VALID "<<N;
        }
    }
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include<simplecpp>
main_program {
int n,open=0,closed=0,a=0,x;
char A,S,X,Y;
cin>>n;
a=n;
S=Y;
while (a>0) {
    cin>>A;
    if (A=='(') {
        open++;
    }
    else closed++;
    x=open-closed;
    if (S=='Y') {
    if (x>0) {
        cout<<"INVALID";
        S='X';
    }
}a--;
}
x=open-closed;
if (x>0) {
    if(S=='Y') {
        cout<<"INVALID";
    }
}
if (x<0){
    if (S=='Y')
    cout<<"INVALID";
}
if (x==0&&S=='Y') {cout<<"VALID";
}
cout<<x;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include <iostream>
using std::cin; using std::cout;

int main() {
    int n, pos = 0, neg = 0;
    bool valid = true;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        if (i == 0 && c == ')') {
            neg++;
            valid = false;
            continue;
        }
        if (c == '(') pos++;
        else if (c == ')') neg++;
    }
    if (pos == neg && valid) cout << "VALID " << pos-neg;
    else cout << "INVALID " << pos-neg;  
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include<simplecpp>
main_program{
    int n=0;
    bool fool=true;
    while(fool){
        char a;
        cin>>a;
        if(a=='('){n++;}
        else if (a==')' && n!=0){n--;}
        else if (a==')' && n==0){
            n--;
            fool=false;}
        else if (a==0){break;}
    }
    while(!fool){
            char b; cin>>b;
            if (b==')'){n--;}
            else if (b=='('){n++;}
            else if (b==0){break;}}
    if (!fool) {cout<<"INVALID"<<' '<<n;}
    if(fool){cout<<"VALID"<<' '<<n;}
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include<iostream>
using namespace std;
int main(){
        int n, opencount=0,closecount=0;
        char c;
        bool valid=true;
        cin>>n;

        for(int i=0;i<n;i++){
                cin>>c;
                if (c=='(') opencount++;
                else if (c==')') closecount++;
                if(closecount > opencount){
                        valid=false;
                }
        }
        if (!valid || opencount != closecount) cout<<"INVALID"<<" "<<opencount-closecount;
        else if (valid) cout << "VALID"<<" "<< opencount-closecount;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include <iostream>
using namespace std;

// tried with (()((())()

int main() {
    int n = 0;
    cin >> n;

    int openCount = 0;
    int closeCount = 0;
    char c = 0;

    // q says to count all ( and ) even if invalid,
    // so store valid in a bool
    bool valid = true;

    // LOGIC:
    // every ) pairs with a pre-existing (
    // ie, at any stage, we can't have more ) than (
    // also at the end, we should have equal ( and )

    for(int i = 0; i < n; i++) {
        cin >> c;
        if(c == '(') { openCount++; }
        if(c == ')') { closeCount++; }

        if(valid && closeCount > openCount) {
            valid = false;
        }
    }

    // if still valid, check equal ( and )
    valid &= openCount == closeCount;

    const int N = openCount - closeCount;
    cout << (valid ? "" : "IN") << "VALID " << N;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A
Problem: A sequence of characters ‘(‘ and ‘)’ is said to be balanced or valid, if it can be obtained from a valid mathematical expression by erasing all other symbols. For instance, from a mathematical expression like (1+2)*((3+4)*(1+2)) yields a balanced sequence ()(()()). On the other hand, the sequence (() or the sequence )( is not balanced. Write a C++ program to read a sequence of characters consisting of characters ‘(‘ and ‘)’ and identify if it is VALID or INVALID. To check whether a sequence is valid, it is enough to keep track of the count of ‘(‘s and ‘)’s seen at any point in the sequence, when scanning the sequence left to right. You can use a few examples to understand when a sequence becomes invalid. 
Input Format
A non-negative integer n, followed by a sequence of n characters consisting of ‘(’ and ‘)’  

Output Format
VALID N
or
INVALID N 

where N = openCount - closeCount, where openCount is the number of  ‘(’ symbols and  closeCount is the number of  ‘)’ symbols in the sequence.

Student submission:
#include<simplecpp>
main_program{
    cin>>noskipws;
    char c;
    int n=0;
    int m=0;
    for(cin>>c; c==')'||c=='(';c=='('?++n:++m, cin>>c);
if(m==n){
    cout<<"VALID "<<n-m<<endl;
}
else
cout<<"INVALID "<<n-m<<endl;
}

Grading criterion: Declaration of variables and accepting input
Rating A: correctly declared and accepts input for the variable n and char for accepting paranthesis
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: A