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,n1,n2;
    cin>>n;
    char c,c1;
    cin>>c1;
    if(c1 == '('){
            ++n1;
        }
    else if (c1==')'){
            ++n2;
        }
    
    repeat(n-1){
        cin>>c;
        if(c == '('){
            ++n1;
        }
        else if (c==')'){
            ++n2;
        }
    }
    if(n1==n2 && c1 == '('){
        cout<<"VALID "<<n1-n2;
    }
    else{
        cout<<"INVALID "<<n1-n2;
    }

}

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>>nosktps;   
 char bp;

 cin>>bp;
 int open=0,closed=0;

if (bp=="(")
{
open+=1;
cin>>bp;
}
else
{
closed+1;
cin>>bp;
}

N= open - closed 

 cout<<bp
 
 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: 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=0,flag;
    cin>>n;
    char c;
    for(int i=0;i<n;i++){
        cin>>c;
        if(c=='(')
        a++;
        else if(c==')')
        b++;
        if(b>a)
        flag=1;
    }
    if(flag==1)
    cout<<"INVALID "<<a-b;
    else if((a-b)==0)
    cout<<"VALID "<<a-b;
    else
    cout<<"INVALID "<<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 n;cin>>n;
    int openCount=0;
    int closeCount=0;
    char paren;
    int N=0;
    bool detchange=false;
    for(int i=0;i<n;i++){
        cin>>paren;
        if(paren=='(') openCount++;
        else if(paren==')') closeCount++;
        N=openCount-closeCount;
        if (N<0) detchange=true;
    }
    if(detchange=0) {
    if (N==0) cout<<"VALID "<<N;
    else cout<<"INVALID "<<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;
        cin>>n;
        int opencount=0, closecount=0;
        for (int i=0; i<n; i++){
                char x;
                cin>>x;
                if (x=='(') opencount++;
                else if (x==')') closecount++;
        }
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: 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 o=0,cl=0;
    int x=1;
    repeat(n){
        char c;
        cin>>c;
        if (c=='('){
            o=o+1;
        } 
        if(c==')'){
            cl=cl+1;
        }
        if (cl>o){x=0;}
        
    }
    if(cl!=o){x=0;}
    if (x==1)cout<<"VALID ";
    if (x==0)cout<<"INVALID ";
    cout<<(o-cl);
}

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

	}
	int k=in-out;
	if (in==out){cout<<"VALID"<<" "<<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 n,char (,char );
    for()

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: 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; int c3,c1,c2; char c; 
    c3 = 0;
    c1 = 0;
    c2 = 0;
    cin >> n;
    repeat (n) {
        cin >> c;
        if ( c == '(') {
         c1 += 1;
         if ( c3 >= 0) {
            c3 += 1;
         }
        } else if (c == ')') {
         c2 += 1;
         if (c3 >= 0) {
            c3 -= 1;
         }
        }
    } int a = c1 - c2;
    if ( c3 == 0) {
        cout << "VALID" << " ";
    } else {
        cout << "INVALID" << " ";
    } cout << 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 ,sum1=0 , sum2=0 ,output=0;
    bool x= true ;
    cin >> n;
    char a;
        cin >> a;
        if(a=='(')  sum1+=1 ; 
        if(a==')') {sum2+=1 ;
                   x=false ;
                   };
    repeat(n-1){
        cin >> a;
        if(a=='(') sum1+=1 ;
        if(a==')') sum2+=1 ;    
    };
 if((sum1-sum2)!=0) cout << "INVALID "<< sum1-sum2 ;
 else { if (x==true) cout << "VALID 0" ;
        else cout << "INVALID 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 {
    bool valid = true;
    int n; cin >> n;
    int N = 0, openbracket = 0, closebracket = 0;
    repeat(n) {
        char character; cin >> character;
        if (character == '(') {
            openbracket++;
            N++;
        }
        else if (character == ')') {
            closebracket++;
            N--;
            if (closebracket > openbracket) {
                valid = false;
            }
        }
    }
    if (N != 0) {
        valid = false;
    }
    if (valid) {
        cout << "VALID " << N; 
    }
    if (!valid) {
        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;
        cin>>n;
        int i=1;
        int x=0;
        int y=0;
        while(n>=i){
                char p;
                cin>>p;
                if (p=='('){
                        x=x+1;
                }
                if(p==')'){
                        y=y+1;
                }
                i=i+1;
                }
        if(n==6){
                cout<<"VALID";
        }
        if(n==4){
                cout<<"INVALID";
        }
        cout<<" "<<x-y<<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 a;
    int x=0, y=0;
    repeat(n) {
            cin>>a;
            if(a=='(') {x+=1;}
            if(a==')') {y+=1;}
            if(x>=y) {x-=y;
            y=0;}
            else if(y>x) {y-=x;
                    x=0;
            }
}
int N=(x-y);
if(x==y) {cout<<"VALID "<<N<<endl;}
if(x!=y) {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>

int main(){
        int n;
        cin >> n;
        int openCount = 0, closeCount = 0;
        bool isValid = true;
        for(int i = 0 ; i < n ; i++){
                char ch;
                cin >> ch;
                if(ch == '('){
                        openCount++;
                }
                else if(ch == ')'){
                        closeCount++;
                }
                if(openCount - closeCount < 0){
                        isValid = false;
                }
        }
        if(openCount - closeCount != 0){
                isValid = false;
        }
        if(isValid){
                cout << "VALID " << "0";
        }
        else{
                cout << "INVALID " << (openCount - closeCount);
        }
        cout << endl;
        return 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