CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include <iostream>
using namespace std;



struct Memo {

   static const int NMAX = 200;
   bool filled[NMAX] = {};
   int memo[NMAX];
   bool has(unsigned i) { return filled[i]; }
   int get(unsigned i) { return memo[i]; }
   void add(unsigned i, int val) {
       memo[i] = val;
       filled[i] = true;
   }
};

int Collect(int A[],int k, Memo& memo, int size){
    if(memo.has(k)) return memo.get(k);
    if(k >= size) return 0; 
    //base condition;
    int ans;
    int option1 = 0;
    int option2 = 0;
    option1 = Collect( A,k+1, memo,size);
    option2 = Collect(A, k+2, memo,size) + A[k];

     
     ans = (option1 > option2)? option1:option2;
     memo.add(k,ans);
     return ans;
      
    

}

int main(){

 int size ;
 cin >> size;
 int amount[size];
 for(int i=0; i<size;i++) cin>>amount[i];
 Memo memo;
 cout << Collect(amount , 0,memo,size);


}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include <iostream>
using namespace std;
int Collect1(int A[],int N){
    return A[N] + Collect1(A,N+2);
}
int Collect2(int A[],int N){
    return Collect2(A,N+1);
}
int main(){
    int N,a,b;
    cin>>N;
    int A[100]={};
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    a=Collect1(A,N);
    b=Collect2(A,N);
    if (a>b){
        cout<< a;
    }
    else {
        cout<< b;
    }
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: B
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int money[n];
    for(int i=0;i<n;i++){
        cin>>money[i];
    }
    int sum1=0;
    int sum2=0;
    for(int i=0;i<n;i=i+2){
        sum1+=money[i];
    }
    for(int i=1;i<n;i=i+2){
        sum2+=money[i];
    }
    if(sum1<sum2){
        cout<<sum2;
    }
    else cout<<sum1;
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
using namespace std;

int main(){
    int n;
    cin>>n;

    int A[100];

    for( int i=0; i<n; i++){
        cin>>A[i];
    
    }

    
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include <iostream.
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    for ( int b=0; b<n ; b++){
        cin>>arr[b];
    }

}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin>>N;
    int A[N];
    int i;
    for(i=0; i<N; ++i)
    {
        cin>>A[i];
    }
    int sum=0;
    for(i=0; i<(N/2); ++i)
    {
        sum+=A[i+2];
    }
    cout<<sum;
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
using namespace std;
int Collect( int B[],int k){
    int n=sizeof(B)/4;
    if(k==n-1) return B[k];
    if(k>n-1) return 0;
    return Collect(B,k)=B[k]+ Collect(B,k+2);
    
}

int main(){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
 cout<<Collect(A,0);
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
#include<algorithm>
using namespace std;
int collect(int A[],int k,int n){

if(k>n-1){
    return 0;
}
return A[k]+ collect(A,k+2,n);
}
int main(){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A,A+N);
    int way1 = collect(A,0,N);
    int way2 = collect(A,1,N);
    
    if(way1>way2){
        cout<<way1;
    }
    else{
        cout<<way2;
    }
    
 
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
#include<vector>
using namespace std;

int algo(int arr[],int i, vector<int>dp){
    
    if(i>dp.size()-1){
        return 0;
    }

    if(dp[i]!=-1){
        return dp[i];
    }

    else{
        return dp[i]=max(arr[i]+algo(arr,i+2,dp),algo(arr,i+1,dp));
    }
    return 0;
}


int main(){
    int n;
    cin>>n;

    int money[n];

    for (int i=0; i<n;i++){
        cin>>money[i];
    }

    vector<int> dp(n,-1);

    cout<<algo(money,0,dp);

    return 0;
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
using namespace std;


int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int sum1=0;int sum2;
    for(int i=0;i<n;i=i+2){
        sum1+=arr[i];
    }
    for(int i=1;i<n;i=i+2){
        sum2+=arr[i];
    }
    if(sum1>sum2){
        cout<<sum1;
    }
    else cout<<sum2;
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include <iostream>
using namespace std;
struct Memo {

   static const int NMAX = 200;
   bool filled[NMAX] = {};
   int memo[NMAX];
   bool has(unsigned i) { return filled[i]; }
   int get(unsigned i) { return memo[i]; }
   void add(unsigned i, int val) {
       memo[i] = val;
       filled[i] = true;
   }
};

int Collect(int A[], int k,  int n, Memo& memo){
    if (memo.has(k)) return memo.get(k);
    if (k > n) return 0;
    if (k != n){
        int y1 = A[k] + Collect(A, k+2, n, memo);
        int y2 = Collect(A, k+1, n, memo);
        int ans;
        if (y1 >= y2) {
           ans = y1;
        }
        else{
            ans = y2;
        }
        memo.add(k, ans);
    }
    else{
        return A[k];
    }
}
int main(){
int n;
Memo memo;
cin >> n;
int* arr = new int[n];
for(int i = 0; i < n; i++){
    int money;
    cin >> money;
    arr[i] = money;
}
int max = 0;
for(int i = 0; i < n; i++){
    int k = Collect(arr, i, n-1, memo);
    if (max < k){
        max = k;
    }
}
cout << max<<endl;

}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: A
Problem: Title: House Robbers

Problem Description

A robber is planning to rob houses along a street. Each house has a certain amount of money. However, the robber cannot rob two adjacent houses because doing so will trigger the alarm system.

Your task is to determine the maximum amount of money the robber can steal without robbing two adjacent houses.

You must solve this problem using recursion and/or memoization.



Your Task

1. Read an integer n representing the number of houses.
2. Read n integers into an array A[], where A[i] represents the money in the i-th house.
3. Implement a recursive function to decide at each house whether to rob it or skip it.
4. Use a base condition to stop recursion.
5. Use memoization to optimize repeated calculations.
6. Return the maximum money that can be robbed and print it.



Rules

- If you rob a house, you cannot rob the next adjacent house.
- At each index, you must decide:
  - Rob the current house and move to i+2, OR
  - Skip the current house and move to i+1.
- The answer is the maximum value obtained from these choices.



Input Format

- An integer n.
- n integers representing the money in each house.



Output Format

- Print a single integer representing the maximum money that can be robbed.


Assumptions on Input

- 1 <= n <= 10^5  
- 0 <= A[i] <= 10^9

Student submission:
#include<iostream>
int main()
{
  int n;
  std::cin>>n;
  int A[n];
  for(int i=0;i<n;i++)
  {
    std::cin>>A[i];
  }
  Collect(A,n)
}

void Collect(A,n)
{
    int s1=0;
    int s2=0;
    for(int k=0;k<n;k++)
    {
      Collect(A,k)=A[k]+Collect(A,k+2);
      if(k+2>n)
      Collect(A,k+2)=0;
    }
    s1=Collect(A,k);
    for(int k=0;k<n;k++)
    {
      Collect(A,k)=Collect(A,k+1);
      if(k+1>n)
      Collect(A,k+1)=0;
    }
    s2=Collect(A,k);
    if(s1>s2)
    cout<<s1;
    else
    cout<<s2;
}

Grading criterion: Declaration of variables and array
Rating A: correctly declares the variable n and array/vector

Rating B: Some issue. 

Rating C: Major issue. 
Rating D: 0
Assigned grade: B