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{
char y,z;
int x,m=0,n=0;
cin >> x>>y;
while (x!=0){
    cin>>y;
    if (y=')'){
        m=m+1;
         y=z;
    }
    if (y='('){
        n=n+1;
         y=z;
    }
   
    x=x-1;
}
if (m>n){
    cout<<"INVALID "<<m-n;

}
else if (m<n){
    cout<<"INVALID "<<n-m;

}
else if (m=n){
    cout<<"VALID 0";
}


}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: C
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 count=0;
    int v=0;
    for(int i=0;i<n;i++)
    {
        char h;
        cin>>h;
        if (i==0 ) 
        {
            if (h=='(') v++;
        }
        if (i==n-1 ) 
        {
            if (h==')') v++;
        }
        if (h=='(') count++;
         if (h==')') count--;
        
    }
    if (v==2 && count==0) cout<<"VALID"<<" "<<count;
    else cout<<"INVAlID"<<" "<<count;
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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;
	int countforward=0;
	int countbackward=0;
	char c;
	cin>>n;
	cin>>c;
    bool x = true;
	for(unsigned int count = 1;count<=n ; count+=1 , cin>>c){
	    if(c=='('){
	        countforward+=1;
	
	        if(countforward<=countbackward && x){
	cout<<"INVALID";x = false;
	}continue;
        }
	if(c==')'){
	countbackward+=1;
	if(x&&(countbackward>countforward || countbackward<countforward)){
	cout<<"INVALID";x = false;
	}continue;
	}
	}
	if(countforward==countbackward && x){
	cout<<"VALID";
	}
	cout<<" "<<countforward-countbackward;
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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
{
 char bp;
 int N ;
 cin>>N;
 cin>>bp;
 int open=0,closed=0,n;
 
 if (bp=="(")
 {
 open+=1;
 cin>>bp;
 }
 else
 {
 closed+=1;
 cin>>bp;
 } 
 
 n= open- closed;
 if(n==0)
 {
 cout<<"VALID"<<n;
 }
 else
 {
 
 cout<<"INVALID"<<n;
 }
 

}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: C
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;




    
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: C
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>
int main(){
	using std::cout; using std::cin;
	int open = 0, close = 0, len;
	cin >> len;
	char series;
	char c;
	char dupc = c;
	
	for(cin >> c; c == '(' || ')' ;cin >> c){		
		if (open + close == len-1 && c == '('){
			++open;
			cout << "INVALID " << open - close;
		}
		else{
			if (c == '(') ++open;
                        else if (c == ')') ++close;
		}
		if (open + close == len) break;
	}
	if (dupc == '('){
                cout << "INVALID " << open - close;
        }
	if(open == close) cout << "VALID "<< open-close;
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: C
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,b=1;
	cin>>n;
	for(int i=0;i<n;i++){
		char c;
		cin>>c;
		if(i==0)
			if(c!='('){
                b=0;}
		if(c=='('){
			a=a+1;}
		else if(c==')'){
			a=a-1;}}
	if((a==0)&&(b!=0))
		cout<<"VALID "<<a;
	else
		cout<<"INVALID "<<a;}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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>
int main() {
    int n;
    cin >> n;
    int leftb=0;
    int rightb=0;
    char c;
    int j;
    bool valid=true;
    for (int i=0;i<n;i++) {
        cin>>c;
        if (c=='(')
        leftb++;
        if (c==')')
        rightb++;
        j=leftb-rightb;
        if (j<0)
        valid=false;
    }
    if(!valid || j!=0)
    cout<<"INVALID "<<j<<endl;
    else if(j==0)
    cout <<"VALID "<<j<<endl;
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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 counto=0;
        int countc=0;
        int n;
        cin>>n;
        char c;
        for(int i=1;i<=n;i+=1){
                cin>>c;
                if(c=='('){
                        counto+=1;
                }
                else if(c==')' and counto==0){
                        countc=1;
                }
                else if(c==')' and counto!=0){
                    countc+=1;
                }
        }
        if(counto==countc){
                cout<<"VALID 0";
        }
        else{
                cout<<"INVALID "<<counto-countc;
        }
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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>
#include <math.h>
#include <cmath>
using namespace std;
int main(){
    int n ;
    cin >> n;
    char c;
    bool printed = false;
    int ominusc = 0;
    for (int i = 0 ; i< n ; i++){
        cin >> c;
        if(c=='('){
            ominusc ++;
        }
        else if(c==')'){
            ominusc --;
        }
        if (ominusc < 0 && !printed){
            cout << "INVALID" ;
            printed = true;
        }
    }
    if(ominusc==0 && !printed){
        cout << "VALID";
    }
    else if(ominusc != 0 && !printed){
        cout << "INVALID";
    }
    cout << " " << ominusc << endl;

    return 0;
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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=0,j=0;
    cin>>n;char input;
    for(int k=1;k<=n;k++)
        {    
            cin>>input;
            if(input=='('){++i;}
            if(input ==')'){++j;}
            if(j>i) {cout<<"INVALID "; int ip=i; int jp=j;
                      repeat(n-k){
                        cin>>input;
                        if(input=='('){++ip;}
                        if(input==')'){++jp;}
                        }
                        cout<<ip-jp;
                        
                        break;
                    }

        }
        
        if(i>j)cout<<"INVALID "<<i-j;
         if(i==j) cout<<"VALID 0";

}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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 opencount,closecount, flag1=1,flag2=1;

        for(int i=1;i<=n;i++)
        {
                char a;
                cin>>a;
                if(a=='(')
                        opencount++;
                if(a==')')
                        closecount++;
                if(i==1&&a==')')
                        flag1=0;
                if(i==n&&a=='(')
                        flag2=0;
        }
        int N=opencount-closecount;
        int m=flag1*flag2;
        if(N==0&&m==1)
                cout<<"VALID "<<N;
        else
                cout<<"INVALID "<<N;
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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 openCount=0;
        int closeCount=0;
        char a;
        char b; cin>>b;
        if(b=='(') openCount+=1;
                else if(b==')') closeCount+=1;

        for(int i=2; i<n; i++){
                cin>>a;
                if(a=='(') openCount+=1;
                else if(a==')') closeCount+=1;
        }
        char c; cin>>c;
        if(c=='(') openCount+=1;
                else if(c==')') closeCount+=1;

        if(openCount==closeCount && b=='(' && c==')') {
                cout<<"VALID"<<" "<<openCount-closeCount;
        }
        else cout<<"INVALID"<<" "<<openCount-closeCount;
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
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 i=1;
    int r=0;
    int l=0;
    for(int i=1;i<=n;i++){
        cin>>c;
        if(c=')'){
            r+=1;
        }
        else if(c='('){
            l+=1;
        }
        
        }
        cout<<l<<" "<<r<<endl;
if(l==r){
    cout<<"VALID 0";}
    else{cout<<"INVALID"<<" "<<l-r;}
        
}

Grading criterion: Final count
Rating A: correctly computes the count of '(' - ')
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: B