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;
    cin >> n;
    int i = 1;
    int numleftbrackets = 0, numrightbrackets = 0;
    char parentheses; bool valid;
    cin >> parentheses;
    i += 1;
    if (parentheses == ')') {
        valid = false;
        numrightbrackets += 1;
    } else if (parentheses == '(') {
        valid = true;
        numleftbrackets += 1;
    }
    while(i <= n) {
        char bracket;
        cin >> bracket;
        if (bracket == '(') {
            numleftbrackets += 1;
        } else if (bracket == ')') {
            numrightbrackets += 1;
        }
        i += 1;
    }
    if (valid == true) {
        if (numleftbrackets == numrightbrackets) {
            valid = true;
        } else {
            valid = false;
        }
    }
    int m;
    m = numleftbrackets - numrightbrackets;
    if (valid == true) {
        cout << "VALID " << 0;
    } else {
        cout << "INVALID " << m;
    }
}

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 a;
    int openCount=a;
    int closeCount=(n-a);
    cin>>n;
    cin>>a*( + (n-a)*)
    if(openCount==closeCount){
        cout<<"VALID"<<0;
    }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: 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 m =0;
	int openCount=0; int closeCount=0;
	for(int i=1; i<=n;i++)
	{
		cin>>c;
		if(c == '(')
		{
			openCount=openCount+1;
		}
		else if(c==')')
		{
			closeCount=closeCount+1;
		}
		if(closeCount>openCount)
		{
			m=1;

		}
	}
	int N = openCount-closeCount;
	if( m ==1)
	{
		cout<<"INVALID "<<N<<endl;
	}
	else 
	{
	if (openCount == closeCount)
	{
		cout<<"VALID "<<N<<endl;
	}
	else 
		

	{
		cout<<"INVALID "<<N<<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 a;
    cin >> a;
    int i=0, p=0, m=0, n=0;
    bool x=1;
    while (x) {
        char c;
        cin >> c; 
        if (c == '(' ) {
            m=m+1;
        }
        if (c == ')' ) {
            n=n+1;
        }
        if (n>m) {
            p=p+1;
        }
        i = i+1;
        if (i==a) {
            x=0;
        }
    }
    if (p==0 && m==n) {
        cout << "VALID 0" << endl;
    }
    else {
        cout << "INVALID " << m-n << 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;
	char c;int d=0; int e=0;int s;
	repeat(n){
		cin>>c;
		if (c=='(') ++d;
		else if (c==')') --d;
		if (d<0)s=d;
	}
    if (s<0 || d!=0)cout<<"Invalid"<<" "<<d;
		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: 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 c;
        int o=0,b=0;
        bool valid=true;
        cin>>n;
        if(!n) cout<<"VALID"<<' '<<0;
        else{
                repeat(n){
                        cin>>c;
                        if(c=='(') o++;
                        else if(c==')') b++;
                        if(b>o) valid=false;
                }
                if(valid){
                        if(o==b){
                                cout<<"VALID"<<' '<<0;
                        }
                        else cout<<"INVALID"<<' '<<((b>o)?(b-o):(o-b));
                }
                else{
                        cout<<"INVALID"<<' '<<((b>=o)?(b-o):(o-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 n; cin >> n; //total number of inputs
	int count = 0;//will keep track of type of parentheses
	int z=1; // if count is 0 but input is still invalid
	for (int i=1; i<=n; i++)
	{
		char c; 
		cin >> c;
		if(c == '(')
			count++;
		else if (c == ')')
			count--;
		if((i==1) && (count<0))
			z=0;
	}
	if(count == 0)
	{
		if(z==0)
			 cout << "INVALID " << count << endl;
		else
			cout << "VALID " << count << endl;	
	}
	else
		cout << "INVALID " << count << 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;
    char ch;
    int openCount,closeCount,num = 0;
    while(n!=0){
        cin >> ch;
        if(ch == '('){
            openCount++;
        }
        else{
            closeCount++;
        }
        n--; 
        num = openCount - closeCount;
        if(num != 0){
            if(n==0){
            cout << "INVALID " << num; 
            } 
            if(num == -1){
                cout << "INVALID 0";
                break;
            }
        }
        else{
         if(n==0){
                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{
	cin>>noskipws;
	int n;
	int openCount=0,closedCount=0;
	cin>>n;
	int i=0;
	char c;
        
	while(i<n){
		cin>>c;
		if(c==' '){}
		else{
			if(c=='('){
				openCount++;
			}
			else if(c==')'){
				closedCount++;
			}
			i++;
		}

	}
	
	if(openCount==closedCount){
		cout<<"VALID 0";
	}
	else{
		cout<<"INVALID "<<openCount-closedCount;
	}
	
}

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,close=0,k;
	cin>>n;
	char c,c1,cn;
	cin>>c1;
	if(c1=='(')
	{
		open+=1;
	}
	else if(c1==')')
	{
		close+=1;
	}
	for(int i=1;i<(n-1);i++)
	{
		cin>>c;
		if(c == '(')
		{
			open+=1;
		}
		if(c == ')')
		{
			close+=1;
		}
	}
	cin>>cn;
	if(cn=='(')
	{
		open+=1;
	}
        else if(cn==')')
	{
		close+=1;
	}
	k=open-close;

	if(c1=='(' && cn==')')
	{
        	if((open-close)==0)
        	{
	        	cout<<"VALID"<<" "<<k;
	        }
        	else cout<<"INVALID"<<" "<<k;
	}
	else
	{
		 cout<<"INVALID"<<" "<<k;
        }

	
	
}

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 a=0,b=0,n;
    bool  f=true,t=true;
    cin>>n;
    char c;
    cin>>c;
    if(c==')'){f=false; b++;}
    else if(c=='('){a++;}
    repeat(n-2){
        cin>>c;
        if(c=='('){a++;}
        if(c==')'){b++;}
    }
    cin>>c;
    if(c=='('){t=false; a++;}
    else if(c==')'){b++;}
    if(((a-b)!=0)||(f==false)||(t==false)){cout<<"INVALID"<<" "<<(a-b);}
    else{cout<<"VALID"<<" "<<(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>
using std::cout;
using std::cin;
int main() {
    int n;
    cin>>n;
    int noOpen = 0;
    int noClose = 0;
    bool invalid = false;
    for(int i = 0; i < n; i++)
    {
        char input;
        cin>>input;
        if(input == '(')
            noOpen += 1;
        else if(input == ')')
        {
            noClose += 1;
            if(noClose > noOpen)
                invalid = true;
        }
    }
    if(noOpen-noClose != 0 || invalid)
        cout<<"INVALID "<<noOpen-noClose;
    else if(noOpen-noClose == 0 && !invalid)
        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>
#include<iostream>
main_program{
    int n; cin>>n;
    char c;
    int count1=0;
    int count2 =0;
    char c1;
    for(int i=1;i<=n;i++){
        cin>>c;
        if(i==1&& c=='('){
            c1 = '(';
        }
        if(c=='('){
            count1 +=1;
        }
        else if(c==')'){
            count2 +=1;
        }



    }
    if(count1==count2&& c1=='('){
        cout<<" "<<"VALID 0";
    }
    else {
        cout<<" "<<"INVALID"<<" "<<abs(count2-count1);
    }


}

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