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;
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: Accepting input
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: Accepting input
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: Accepting input
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: Accepting input
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: Accepting input
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: Accepting input
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 main(){
    int n; cin>>n;
    int A[n];
    for(int i=0;i<n;i++)
        cin>>A[i];

    vector<int> dp(n,-1);
    dp[0]=A[0];
    for(int i=1; i<n; i++){
        int pick=A[i];
        if(i>=2)
            pick+=dp[i-2];
        int notPick=dp[i-1];

        dp[i]=max(pick, notPick);
    }
    cout<<dp[n-1];
}

Grading criterion: Accepting input
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 maximum(int A[],int N,int k){
    if (k>=N-1){
        return 0;
    }
    else if (A[k]>=A[k+1]){
        return A[k]+ maximum(A,N,k+1);
    }
    else{
        return maximum(A,N,k+1);
    }
}

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

Grading criterion: Accepting input
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 N;
int Collect(int A[],int k){

   
   if(k>=N-1) return 0;
   if(A[k+1]>A[k]) {Collect(A,k) = A[k] + Collect(A,k+2); }
   else{
    Collect(A,k) = Collect(A,k+1);
   }
   return Collect(A,k);
}

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

Grading criterion: Accepting input
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 {//at kth index C(N, A, k) is stored

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

int max(int a1, int a2){
        return ((a1>a2)?a1:a2);
}

int C(int N, int A[], int k, Memo& meme){//amount from robbing houses index k onwards, k included
                           //initial func call: k = 0
        if (k > N-1) return 0;
        //if (k == N) return A[N];
        if (meme.has(k)){
            //cout<<"Using "<<k<<" "<<meme.get(k) << endl;
            return meme.get(k);
        }
        else{
                int currC = max(C(N, A, k+1, meme), C(N, A, k+2, meme) + A[k]);
                meme.add(k, currC);
                //cout<<"Setting "<<k<<" "<<currC<<endl;
                return currC;
        }
}

int maxAmt(int N, int A[]){//func to be called by main
        Memo myMeme;
      //for(int i = 0; i<myMeme.NMAX;i++) if(myMeme.filled[i]) cout << "ERR";
      //cout<<endl;
        return C(N, A, 0, myMeme);
}

int main(){
        int N; cin >> N;
        int arr[100];
        for (int i = 0; i<N; i++) cin >> arr[i];

        cout << maxAmt(N, arr);

        return 0;
}

Grading criterion: Accepting input
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 CheckE(int a[],int k){
     if (k<2)return 0;
    return a[k]+CheckE(a,k-2);
}

int CheckO(int a[],int k){
     if ( k<3)return 0;
    return a[k-1]+CheckO(a,k-3);
}

int main (){

int N;
cin >>N;
int A[N];
if (CheckE(A,N)>CheckO(A,N))return CheckE(A,N);
else return CheckO(A,N);
}

Grading criterion: Accepting input
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>

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 main()

Grading criterion: Accepting input
Rating B: Some issue. 
Rating C: Major issue. 

Rating D: 0
Assigned grade: C