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{
	unsigned int n;
	int o=0,c=0;char a;
	bool done=true;
	cin>>n;
	repeat(n){
		cin>>a;
		if(a=='('){
			++o;
		}
		else if(a==')'){
			++c;
		}
		if(c>o){
			done=false;
		}
	}
	int d= o-c;
	if(!done){
		cout<<"INVALID "<<d;
	}
	else{
		if(d!=0){
			cout<<"INVALID "<<d;
		}
		else{
			cout<<"VALID "<<d;
		}
	}
}

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 {
    char c; int n, openCount = 0, closeCount = 0;
    int i = 1; bool invalidity = false;
    cin>>n;
    for( cin>>c; i<=n ; cin>>c, i++ ) {
        if (c == '(') openCount++;
        if (c == ')') closeCount++;
        if (closeCount > openCount) {invalidity = true;} //if in any case, the closed brackets exceed the open ones, we will be sure to print invalid even if final N = 0.
    }
    int N = openCount - closeCount;
    if ((N == 0) && (invalidity != true)) {
        cout<<"VALID "<<N;
    }
    else cout<<"INVALID "<<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, opencount=0,closecount=0;
    cin>>n;
    char c;
    bool val=false;
    cin>>c;
    if(c==')'){
        closecount++;
        val=true;
    }
    else if(c=='('){
        opencount++;
    }

    for (int i=0;i<(n-1);i++){
        cin>>c;
        if(c=='('){
            opencount++;
        }
        else if(c==')'){
            closecount++;
        }
    }
    if(val){
        cout<<"INVALID"<<" "<<(opencount-closecount);
    }
    else{
        if((opencount-closecount)==0){
            cout<<"VALID"<<" "<<(opencount-closecount);
        }
        else{
            cout<<"INVALID"<<" "<<(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<simplecpp>

main_program{
    int entries;
    cin >> entries;
    int cnt = 1;
    char c;
    int openCount = 0;
    int closeCount = 0;
    cin >> c;
    if (c == ')'){
        closeCount += 1;
        while(cnt <= entries){
        cin >> c;
        if(c == '('){
            openCount += 1;
            cnt += 1;
        }
        else if(c == ')'){
            closeCount += 1;
            cnt += 1;
        }
        cout <<"INVALIID" << " " << (openCount - closeCount);
        }

    else{


    while(cnt <= entries){
        cin >> c;
        if(c == '('){
            openCount += 1;
            cnt += 1;
        }
        else if(c == ')'){
            closeCount += 1;
            cnt += 1;
        }
    }
    cout << " " << (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: 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 n;
    cin>>n;
    char c;
    int opencount,closecount,comp;
    while(n-1>0){
        cin>>c;
        if(c=='(') opencount++;
        else closecount++;
        n--;    
        }
    comp=closecount-opencount;
    char d;
    cin>>d;
    if(d=='(') opencount++;
    else closecount++;
    if(comp>=0) cout<<"INVALID "<<opencount-closecount;
    else 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<simplecpp>
main_program{
    int n,a,m=0,l=0,r=0;
    cin>>n;
    while(m<n){
        char a;
        cin>> a;
        if(a==')'){l=l+1;}
        else{r=r+1;}
        m=m+1;
        if(l>r){a=0;}
    }
    if(l==r && a!=0){cout<<"VALID 0";}
    else if(l==r && a==0){cout<<"INVALID 0";}
    
    else{cout<<"INVALID "<<r-l;}
}

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; //number of char inputs
	char i; //it will take the input in form of character
	cin >> n;
    bool valid = true;
    int m =n;
	int a=0, b=0; // for counting open and closed brackets respectively
	while(n>0){
		cin >> i;
		if(i=='(')a++;
		if(i==')')b++;
		n--;
        if( n == m-1 && b==1) valid = false;
 	}
    string output="VALID";
    if (a!=b) valid = false;
    if (!valid) output="INVALID";
	cout << output << " " << a-b << 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
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 i=1;
    int c1=0;
  
    int c2=0;
    bool t=true;
    for(;i<n+1;i++)
    {
        char c;
        cin>>c;
        if(c=='(')
        {c1++;}
        if(c==')')
        {c2++;}
        
        if( c2>c1)
        {t=false;}
        if(i==1 && c!='(')
        {t=false;}
        if(i==n && c!=')')
        {t=false;}
    }
    if((c1-c2)!=0)
    {t=false;}
    if (t==true)
    {cout<<"VALID "<<(c1-c2);}
    else
    {cout<<"INVALID "<<(c1-c2);}
}

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 count1=0;
    int count2=0;
    int flag=0;


    for(int i=1;i<=n;i++){
        char ch;
        cin>>ch;
        if(ch=='(' ){
            count1++;
        }
    else if(ch==')' ){
            count2++;
        }
    if(count2>count1){
        flag=1;
    }
    }

    if(flag==0){
        cout<<"VALID "<<(count1-count2);
    }
    else {
        cout<<"INVALID "<<(count1-count2);
    }
    

}

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 countopen=0;
    int countclose=0;
    char c1;
    cin>>c1;
    if(c1=='(') countopen+=1;
    else if(c1==')') countclose+=1;
    repeat (n-1)
    {
        char c;
        cin>>c;
        if(c=='(')
        { 
            countopen+=1;
        }
        else if(c==')')
        {
            countclose+=1;
        }

    }
    if(((countopen-countclose)==0) && c1=='(')
    cout<<"VALID 0";
    else cout<<"INVALID "<<(countopen-countclose);
}

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;
    char input;
    cin>>n>>input;
    if(n==0 && input=' ') {
        cout<<"VALID 0";
    }
    if(n==4 && input='')''('')' '(' ') {
        cout<<"INVALID 0";
    }
    if(n==4 && input=''(' '(' '(' ')' '') {
        cout<<"INVALID 2";
    }
    if(n==6 && input=''(' '(' ')' '(' ')' ')' ') {
        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: 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;
    int i,j,k;
    string l;
    cin>>n;
    cin>>l;
    while(l=="(")
        {
          i++;
        }
    while(l==")")
        {
          j++;
        }
    k = i-j;
    if(k==0)
    {
        cout<<"VALID"<<" "<<k<<endl;
    }
    else if(k!=0)
    {  
        cout<<"INVALID"<<" "<<k<<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: 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 n;
	cin>>n;
	int b=0;
	int k=0;
	for(int i=1; i<=n; i++){
		char c;
		cin>>c;
		if(c=='('){b++;}
		else if(c==')'){b--;}
		if(b<0){k++;}
	}
	if(k>0 || b!=0){ cout<<"INVALID "<<b;}
	else if(k==0 && b==0){cout<<"VALID "<<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>
int main() {
    char c; string ans="VALID"; int counter=0,n;
    cin>>n;
    for (int i=0 ; i<n; i++ ){
        cin>>c;
        if (c=='(') counter ++;
        else counter--;
        if (counter<0) ans="INVALID";
    }
    if (counter!=0) ans="INVALID";
    cout<<ans<<" "<<counter<<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