[C++ Solution] Simple solution using DP
\nclass Solution {\npublic:\n    long long dp[2005][2005];\n    \n    int K;\n    long long MaxValue(vector<vector<int>>& piles, int taken,int pile)\n    {\n   
```\nclass Solution {\npublic:\n    long long dp[2005][2005];\n    \n    int K;\n    long long MaxValue(vector<vector<int>>& piles, int taken,int pile)\n    {\n        if(taken==K) return 0;\n        if(pile>=piles.size()||taken>K) return INT_MIN;\n       \n        if(dp[taken][pile]!=-1) return dp[taken][pile];\n        \n        long long ans=0;\n\t\t// if we want to pick and try atleast one coin from this pile\n\t\t\n        for(int i=0;i<piles[pile].size();i++)\n        {\n            ans=max(ans,piles[pile][i]+MaxValue(piles,taken+i+1,pile+1));\n        }\n        \n        ans=max(ans,MaxValue(piles,taken,pile+1)); // if we want to skip this pile altogether\n        \n        return dp[taken][pile]=ans;\n    }\n    \n    int maxValueOfCoins(vector<vector<int>>& piles, int k) {\n        memset(dp,-1,sizeof(dp));\n\t\t\n\t\t// storing the prefix sum so as to know if we pick the ith coin out of a pile, what will be the total sum of all the coins above the ith coin \n\t\t\n        for(int i=0;i<piles.size();i++)\n        {\n            for(int j=1;j<piles[i].size();j++) piles[i][j]+=piles[i][j-1];\n        }\n        \n        K=k;\n        return MaxValue(piles,0,0);\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'C']