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;
        char input;
        char '(';
        char ')';
        int i;
        for(i=1; i<=n; i++){
                cin>>input;
        }

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

Output Format
VALID N
or
INVALID N 

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

Student submission:
#include <simplecpp>
main_program {
    unsigned int n;
    cin>>n;
    int open=0,close=0;
    int op=0,cl=0;
    for(int i=0; i<n; i++) {
        char input;
        cin>>input;
        if(input==')') close++;
        else if(input=='(') open++;
    }
    for(int i=0; i<n; i++) {
        char input;
        cin>>input;
        if(input==')') cl++;
        else if(input=='(') op++;
        if(cl>op) break;
        else continue;
    }
    if(op>=cl && open==close) cout<<"VALID 0";
    else cout<<"INVALID"<<" "<<abs(open-close);
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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,temp=1,ocount=0,ccount=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        char c;
        cin>>c;
        if(c=='('){ocount++;}
        else{ccount++;}
        if(i<n&&ocount-ccount<0){
            temp=0;
            }
        
    }
    if(temp==0){cout<<"INVALID "<<ocount-ccount;}
    else{
        if(ocount!=ccount){cout<<"INVALID "<<ocount-ccount;}
        else{cout<<"VALID "<<0;}
    }
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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 x,y,n; int k; bool v=0; char input;
cin>>n; x=0; y=0;
for(unsigned int i=0; i<n; ++i) {cin>> input;
        if (input=='(') {++x;}
        else if (input==')') {++y;};
        k=x-y;
        if (k<0) {v=1;}
        }
        k=x-y;
        if (v || k!=0) {cout<<"INVALID ";} else {cout<<"VALID ";} cout<<k;
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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,b,c;
        char '(','')';
        cin >> n,(,);
        '('==a;
        '('==b;
        a=1;
        b=-1;
        c=a+b;
        if(c==0) {
                cout<<"VALID 0";
        }
                else cout<<"INVALID "<<c;
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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 N,openCount=0,closeCount=0,flag=0;
    char c;
    for(int i =0;i<n;i++){
        cin>>c;
        if(c=='('){
            openCount+=1;
        }
        else if(c==')'){
            closeCount+=1;
        }

        if(i==0){
            if(c=='('){
                flag++;
            }
        }
        if(i==n-1){
            if(c==')'){
                flag++;
            }
        }
    }
    N=openCount-closeCount;
    if(N==0&&flag==2){
        cout<<"VALID "<<N;
    }
    else{
        cout<<"INVALID"<<N;
    }
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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,b,c,e,f,i;
    bool d=true;
    cin >> n;
    i=0;
    string a;
    cin >> a;
    while(i<=n-1){
        if(a[i]=='('){
           e+=1;
        }
        else if(a[i]==')'){
            f+=1;
        }
        else if(e<f){
            d=false;
            cout << "INVALID ";
            break;
        }
        i++;
    }
    for(int i=0; i<=(n-1);i++){
        if(a[i]=='('){
           b+=1;
        }
        else if(a[i]==')'){
            c+=1;
        }
    }

    if(d==true&&(b-c)!=0){
        d=false;
        cout << "INVALID ";

    }
    else if(d==true) cout << "VALID ";
    cout <<b-c;
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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 n1=0,n2=0,k=0;
    for(int i=0; i<n;i++){
        cin>>c;
        if (c=='(') {n1++;}
        else if (c==')') n2++;
        if ((n1-n2)<0) k=-1;
    }
    if (k==-1) cout << "INVALID" << " "<<n1-n2;
    else if (n1-n2==0) cout << "VALID" << " "<<0;
    else cout << "INVALID" <<" "<< n1-n2;
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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,b; a=0; b=0;  
 bool r=true; 
 cin>>n;
 for(int i=0;i<n;i++){
        char c;
        cin>>c;
        if(c=='(') {++a;}
        if(c==')') {++b;}
        if(b>a) {
            r=false; }        
        
    }
 if(a!=b) {r=false;}
 if(r) {cout<<"VALID"<<" "<<(a-b);}
 else {cout<<"INVALID"<<" "<<(a-b);}
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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; bool valid = true;
        int counter = 0, openCount = 0, closeCount = 0;
        cin>>n;
        for(int i = 0; i < n; i++){
                cin>>c;
                if(c=='('){
                        counter++;
                        openCount++;
                }
                else if(c==')'){
                        counter--;
                        closeCount++;
                }
                if(counter<0) valid = false;
        }
        if(counter != 0) valid = false;
        if(valid) cout<<"VALID "<<openCount-closeCount;
        else cout<<"INVALID "<<openCount-closeCount;
}

Grading criterion: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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 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: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
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: Loop to iterate from 1 to n
Rating A: correctly iterates the loop to accept all the n characters
Rating B: Some issue
Rating C: Major issue
Rating D: 0
Assigned grade: C