criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int sumDuration( int T, vector< pair<int,int> > vec ){
    
    sort( vec.begin(), vec.end(), [](auto& l, auto& r){
        if(l.first == r.first){
            return l.second > r.second;
        }
        else{
            return l.first < r.first;
        }
    });
    
    int t = 0;
    int ret = 0;
    for( int ii = 0; t < T && ii < (int)vec.size(); ++ii ){
        t += vec[ii].first;
        ret += vec[ii].second;
    }
    
    return ret;
}

int sumDelicious( int T, vector< pair<int,int> > vec ){
    
    sort( vec.begin(), vec.end(), [](auto& l, auto& r){
        if(l.second == r.second){
            return l.first < r.first;
        }
        else{
            return l.second > r.second;
        }
    });
    
    int t = 0;
    int ret = 0;
    for( int ii = 0; t < T && ii < (int)vec.size(); ++ii ){
        t += vec[ii].first;
        ret += vec[ii].second;
    }
    
    return ret;
}


int main()
{
    int N, T;
    cin >> N >> T;
    vector< pair<int,int> > vec;
    int x, y;
    for(int ii = 0; ii < N; ++ii){
        cin>>x>>y;
        vec.push_back( make_pair(x, y) );
    }
    
    // Policy: duration
    // Sum up the shorter duration as possible.
    auto durResult = sumDuration(T, vec);
    
    // Policy: delicious
    // Sum up the larger delisious as possible.
    auto delResult = sumDelicious(T, vec);
    
    auto result = (durResult > delResult) ? durResult : delResult;
    
    cout << result << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int sumDuration(int, std::vector<std::pair<int, int> >)':
a.cc:8:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |     sort( vec.begin(), vec.end(), [](auto& l, auto& r){
      |     ^~~~
      |     short
a.cc: In function 'int sumDelicious(int, std::vector<std::pair<int, int> >)':
a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |     sort( vec.begin(), vec.end(), [](auto& l, auto& r){
      |     ^~~~
      |     short
Language: C++

#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in(),t=in();
    vector<pii> a(n+1);
    rep(i,n){
        int x=in(),y=in();
        a[i+1]=mp(x,y);
    }
    sort(ALL(a));
    vector<vector<pair<ll,int>>> dp(n+1,vector<pair<ll,int>>(t+1));
    fill(ALL(dp[0]),mp(0,0));
    rep(i,n){
        rep2(j,0,t){
            ll x;
            int y;
            if(j < a[i+1].first){
                x = dp[i][j].first;
                y = max(dp[i][j].second, a[i+1].second);
            }else if(dp[i][j].first < dp[i][j-a[i+1].first].first + a[i+1].second){
                x=dp[i][j-a[i+1].first].first + a[i+1].second;
                y=dp[i][j-a[i+1].first].second;
            }else{
                x = dp[i][j].first;
                y = max(dp[i][j].second,a[i+1].second);
            }
            dp[i+1][j] = mp(x,y);
        }
    }
    cout<<dp[n][t-1].first + dp[n][t-1].second<<endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:79:54: error: expected '}' at end of input
   79 |     cout<<dp[n][t-1].first + dp[n][t-1].second<<endl;
      |                                                      ^
a.cc:52:11: note: to match this '{'
   52 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

long long int dp[10000][10000];

long long int n;

long long int capacity;
long long int cost[10000],weight[1000]0;

long long int knapsack(long long int i,long long int w){

  long long int p=0,q=0;

  if(i==n+1)
    return 0;

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


  else{
    if(w<=capacity){
            p=cost[i]+knapsack(i+1,w+weight[i]);

    }

    q=knapsack(i+1,w);

    dp[i][w]=max(p,q);

    return dp[i][w];



  }
}

int main(){

    ios_base::sync_with_stdio(false);

    memset(dp,-1,sizeof(dp));

   cin>>n>>capacity;

    for(int i=1;i<=n;i++){
    cin>>weight[i]>>cost[i];
    }
    capacity--;
    cout<<knapsack(1,0)<<endl;
    return 0;


}


Compiler output:
a.cc:9:39: error: expected initializer before numeric constant
    9 | long long int cost[10000],weight[1000]0;
      |                                       ^
a.cc: In function 'long long int knapsack(long long int, long long int)':
a.cc:24:38: error: 'weight' was not declared in this scope
   24 |             p=cost[i]+knapsack(i+1,w+weight[i]);
      |                                      ^~~~~~
a.cc: In function 'int main()':
a.cc:48:10: error: 'weight' was not declared in this scope
   48 |     cin>>weight[i]>>cost[i];
      |          ^~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, t;
  cin >> n >> t;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++)
    cin >> a[i] >> b[i];
  vector<vector<int>> dp(n + 1, vector<int>(t + 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < t; j++) {
      dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
      int eaten = min(t, j + a[i]);
      dp[i + 1][eaten] = max(dp[i + 1][eaten], dp[i][j] + b[i]);
    }
  }
  cout << (*max_element(begin(dp[n]), end(dp[n]))) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: 'max_element' was not declared in this scope
   22 |   cout << (*max_element(begin(dp[n]), end(dp[n]))) << endl;
      |             ^~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,t;
    cin >> n >> t;
    vector<P> a(n);
    for (int i = 0;i < n;++i) cin >> a[i].first >> a[i].second;
    vector<vector<int>> dp(n+1,vector<int>(t+1,0));
    sort(a.begin(),a.end());
    for (int i = 0;i < n;++i) {
        dp[i+1] = dp[i];
        for (int j = 0;j < t;++j) dp[i+1][min(t,j+a[i].first)] = max(dp[i+1][min(t,j+a[i].first)],dp[i][j]+b[i].second);
    }
    cout << *max_element(dp[n].begin(),dp[n].end()) << endl;
    // for (int i = 0;i < n+1;++i) p_ary(dp[i],0,t+1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:108: error: 'b' was not declared in this scope
   19 |         for (int j = 0;j < t;++j) dp[i+1][min(t,j+a[i].first)] = max(dp[i+1][min(t,j+a[i].first)],dp[i][j]+b[i].second);
      |                                                                                                            ^
Language: C++

// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int dp[3500], n, t;
pii a[N];
void solve () {
	cin >> n >> t;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i].F >> a[i].S;
	}
	dp[0] = 0;
	for (int i = 1; i <= n; i ++) {
		for (int j = t - 1; j >= 0; j --) {
			 dp[min (j + a[i].F, t)] = max (dp[min (j + a[i].F, t)], dp[j] + a[i].S);
		}
	}              
	for (int i = 1; i <= t; i ++) {
		dp[i] = max (dp[i], d[i - 1]);
	}
	cout << dp[t];
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:38:37: error: 'd' was not declared in this scope
   38 |                 dp[i] = max (dp[i], d[i - 1]);
      |                                     ^
a.cc: At global scope:
a.cc:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main () {
      | ^~~~
Language: C++

// Solving knapsack problem with DP

#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

// input
// n = value of gilt
// W = limit of total weight
// weight[] = weight of each gilt
// value[] = value of each gilt
int n=3001, W=3001;
int weight[3001], value[3001];

// DP table
int dp[3001][3001];

//------------------------------------------------------------------------------
/// 指定されたDPテーブルの要素はどの金塊の組み合わせで作れるのかを逆算する
/// @param i 使って良い金塊の個数 i番目までの金塊を使える
///        w ナップサックの耐荷重
///        ans 答え,金塊を0:入れない 1:入れる
void DP_OptimalSolution(const int i, const int w,int ans[n]){
    int local_w=w;
    for(int local_i=i-1;local_i>=0;local_i--){
        if (local_w >= weight[local_i] && max(dp[local_i][local_w-weight[local_i]] + value[local_i], dp[local_i][local_w])==dp[local_i][local_w]){
            ans[local_i]=0;
        }
        else if(local_w >= weight[local_i] && max(dp[local_i][local_w-weight[local_i]] + value[local_i], dp[local_i][local_w])==dp[local_i][local_w-weight[local_i]] + value[local_i]){
            ans[local_i]=1;
            local_w=local_w-weight[local_i];
        }
        else if(local_w < weight[local_i]){
            ans[local_i]=0;
        }
    }
}
int main() {
    cin>>n>>W;
    for(int i=0;i<n;++i){
        cin>>weight[i]>>value[i];
    }
  // init
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;
  // DP table
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }
  //answer
  int a1[n];
  int a2[n];
  int ans1,ans2;
  ans1=0;ans2=0;
  DP_OptimalSolution(n,W,a1);
  for(int i=0;i<n;i++){
    ans1+=a1[i]*value[i];
  }
  // init
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;
  // DP table
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }
  DP_OptimalSolution(n,W-1,a2);
  for(int i=0;i<n;i++){
    ans2+=a2[i]*value[i];
  }
  int tmp=0;
  for(int i=0;i<n;i++){
    if((tmp<value[i])&&a2[i]==0){tmp=max(tmp,value[i]);}
  }
  
  cout<<max(tmp+ans2,ans1)<<endl;
  return 0;
}

Compiler output:
a.cc:24:58: error: size of array 'ans' is not an integral constant-expression
   24 | void DP_OptimalSolution(const int i, const int w,int ans[n]){
      |                                                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, p; cin >> n >> p;
  —p;
  V<> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  V<> idx(n);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return a[i] < a[j]; });
  V<> dp(p + 1, -inf);
  dp[0] = 0;
  int res = 0;
  for (int i : idx) {
    res = max(res, *max_element(begin(dp), end(dp)) + b[i]);
    auto ndp = dp;
    for (int x = a[i]; x <= p; ++x) {
      ndp[x] = max(ndp[x], dp[x - a[i]] + b[i]);
    }
    swap(dp, ndp);
  }
  cout << res << '\n';
}


Compiler output:
a.cc:12:3: error: extended character — is not valid in an identifier
   12 |   —p;
      |   ^
a.cc: In function 'int main()':
a.cc:12:3: error: '\U00002014p' was not declared in this scope
   12 |   —p;
      |   ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

signed main() {
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> v(N);
    for (size_t i = 0; i < N; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    ll DP[10000] = {};
    for (size_t i = 0; i < N; i++) {
        int A = v[i].first;
        int B = v[i].second;
        for (int i = T - 1; i >= 0; i--) {
            DP[i + A] = max(DP[i + A], DP[i] + B);
        }
    }
    cout << *max_element(DP, DP + 10000) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'll' was not declared in this scope
   12 |     ll DP[10000] = {};
      |     ^~
a.cc:17:13: error: 'DP' was not declared in this scope
   17 |             DP[i + A] = max(DP[i + A], DP[i] + B);
      |             ^~
a.cc:20:26: error: 'DP' was not declared in this scope
   20 |     cout << *max_element(DP, DP + 10000) << endl;
      |                          ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;

signed main() {
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> v(N);
    for (size_t i = 0; i < N; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    ll DP[10000] = {};
    for (size_t i = 0; i < N; i++) {
        int A = p.first;
        int B = p.second;
        for (int i = T - 1; i >= 0; i--) {
            DP[i + A] = max(DP[i + A], DP[i] + B);
        }
    }
    cout << *max_element(DP, DP + 10000) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'll' was not declared in this scope
   12 |     ll DP[10000] = {};
      |     ^~
a.cc:14:17: error: 'p' was not declared in this scope
   14 |         int A = p.first;
      |                 ^
a.cc:17:13: error: 'DP' was not declared in this scope
   17 |             DP[i + A] = max(DP[i + A], DP[i] + B);
      |             ^~
a.cc:20:26: error: 'DP' was not declared in this scope
   20 |     cout << *max_element(DP, DP + 10000) << endl;
      |                          ^~
Language: C++

#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<21, stdin), p1 == p2) ? EOF : *p1++)
#define swap(x,y) x ^= y, y ^= x, x ^= y
typedef long long ll;
const int MAXN = 3 * 1e6 + 10, P = 998244353, G = 3, Gi = 332748118;
char buf[1<<21], *p1 = buf, *p2 = buf;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
const int N=1e3+15;
ll n,a[N],v[N],dp[N][N],vis[N];
ll inf=1123456789123;
int main()
{
    int lk;
    cin>>n>>lk;
    lk=n-lk;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
            dp[i][j]=inf;
    }
    dp[0][0]=0;
    for(int k=1;k<=lk;k++){
        for(int i=k;i<=n;i++)
        {
            for(int j=k-1;j<=i;j++)
            {
                dp[i][k]=min(dp[i][k],dp[j][k-1]+max(a[i]-a[j],ll(0)) );
            }
        }
    }
    if(dp[n][k]==inf)
        cout<<"0"<<endl;
    else
        cout<<dp[n][lk]<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:14: error: 'k' was not declared in this scope; did you mean 'lk'?
   40 |     if(dp[n][k]==inf)
      |              ^
      |              lk
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n + 1);
    h[0] = 0;
    rep(i, n) {
        cin >> h[i + 1];
    }
    ll dp[330][330];
    rep(i, 330) rep(j, 330) dp[i][j] = 1e+14;
    dp[0][0] = 0;
    rep(x, n + 1) {
        rep(y, x + 1) {
                chmin(dp[i][y + i - 1 - x], dp[x][y] + max(0LL, h[i] - h[x]));
            }
        }
    }
    ll res = INF;
    for(int i = n; i >= n - k; --i) {
        for(int j = 0; j <= k - (n - i); ++j) {
            chmin(res, dp[i][j]);
        }
    }
    cout << res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:65:26: error: 'i' was not declared in this scope
   65 |                 chmin(dp[i][y + i - 1 - x], dp[x][y] + max(0LL, h[i] - h[x]));
      |                          ^
a.cc: At global scope:
a.cc:70:5: error: expected unqualified-id before 'for'
   70 |     for(int i = n; i >= n - k; --i) {
      |     ^~~
a.cc:70:20: error: 'i' does not name a type; did you mean 'ui'?
   70 |     for(int i = n; i >= n - k; --i) {
      |                    ^
      |                    ui
a.cc:70:32: error: expected unqualified-id before '--' token
   70 |     for(int i = n; i >= n - k; --i) {
      |                                ^~
a.cc:75:5: error: 'cout' does not name a type
   75 |     cout << res << endl;
      |     ^~~~
a.cc:76:1: error: expected declaration before '}' token
   76 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 305
#define INF (INF_LL >> 8ll)
//---------------------

ll n,k;
ll h[MAXN];
ll dp[MAXN][MAXN];

int main(){
	cin >> n >> k;
	REP1(i,n) cin >> h[i];

	REP(i,MAXN) REP(j,MAXN) dp[i][j] = INF;

	dp[0][0] = 0;

	REP1(i,n) REP1(j,i) REP(k,i)
		dp[i][j] = min(dp[i][j],dp[k][j-1]+max(0ll,h[i]-h[k]));

	DBSTART
	PRTLST2(dp,n+1,n-k+1);
	DBEND

	ll res = INF;
	REP1(i,n) res = min(res,dp[i][n-k]);

	PRT(res);

	return 0;
}




1-1

Compiler output:
a.cc:96:1: error: expected unqualified-id before numeric constant
   96 | 1-1
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 305
#define INF (INF_LL >> 8ll)
//---------------------

ll n,k;
ll h[MAXN];
ll dp[MAXN][MAXN];

int main(){
	cin >> n >> k;
	REP1(i,n) cin >> h[i];

	REP(i,MAXN) REP(j,MAXN) dp[i][j] = INF;

	dp[0][0] = 0;

	REP1(i,n) REP1(j,i) REP(k,i)
		dp[i][j] = min(dp[i][j],dp[k][j-1]+max(0ll,h[i]-h[k]));

	DBSTART
	PRTLST2(dp,n+1,n-k+1);
	DBEND

	ll res = INF;
	REP1(i,n) res = min(res,dp[i][n-k]);

	PRT(res);

	return 0;
}






10

Compiler output:
a.cc:98:1: error: expected unqualified-id before numeric constant
   98 | 10
      | ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define REP2D(i,j,h,w) for(long long i=0;i<h;i++) for(long long j=0;j<w;j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=h;i++) for(long long j=1;j<=w;j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) (a.begin()),(a.end())
#define RANGE(a) (a),(a+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << a << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 305
#define INF (INF_LL>>3)
//---------------------

ll n,k;
ll h[MAXN];
ll dp[MAXN][MAXN];

int main(){
	cin >> n >> k;
	REP1(i,n) cin >> h[i];

	REP(i,MAXN) REP(j,MAXN) dp[i][j] = INF;

	dp[0][0] = 0;

	REP1(i,n) REP1(j,i) REP(k,i)
		dp[i][j] = min(dp[i][j],dp[k][j-1]+max(0ll,h[i]-h[k]));

	DBSTART
	PRTLST2(dp,n+1,n-k+1);
	DBEND

	ll res = INF;
	REP1(i,n) res = min(res,dp[i][n-k]);

	PRT(res);

	return 0;
}






8

Compiler output:
a.cc:98:1: error: expected unqualified-id before numeric constant
   98 | 8
      | ^
Language: C++

#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;

int N;
vector<lld> numOm(310, 0);
int K;
int ans = 0;
void input(){
    cin >> N >> K;
    repk(i, 1, N+1){
        int a;cin >> a;
        numOm.push_back(a);
    }
}

void solve(){
    input();
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, INF));
    dp[0][0] = 0;
    
    for(int i=1;i<=N;i++){
        for (int j=1;j<=i;j++){
            for(int k=0;k<=i;k++){
                dp[i][j] = min(dp[i][j] , dp[i][j-1] + max(numOm[i]- numOm[k],0ll));
            }
        }
    }    
    

    ll ans = INF;
    rep(i, N+1){
        chmin(ans, dp[i][N-K]);
    }
    if(ans == INF) ans = 0;
    cout << ans << endl;
    return ;
}

int main () {
    solve();
    return 0;
}

Compiler output:
a.cc:23:8: error: 'lld' was not declared in this scope; did you mean 'll'?
   23 | vector<lld> numOm(310, 0);
      |        ^~~
      |        ll
a.cc:23:11: error: template argument 1 is invalid
   23 | vector<lld> numOm(310, 0);
      |           ^
a.cc:23:11: error: template argument 2 is invalid
a.cc:23:25: error: expression list treated as compound expression in initializer [-fpermissive]
   23 | vector<lld> numOm(310, 0);
      |                         ^
a.cc: In function 'void input()':
a.cc:30:15: error: request for member 'push_back' in 'numOm', which is of non-class type 'int'
   30 |         numOm.push_back(a);
      |               ^~~~~~~~~
a.cc: In function 'void solve()':
a.cc:42:65: error: invalid types 'int[int]' for array subscript
   42 |                 dp[i][j] = min(dp[i][j] , dp[i][j-1] + max(numOm[i]- numOm[k],0ll));
      |                                                                 ^
a.cc:42:75: error: invalid types 'int[int]' for array subscript
   42 |                 dp[i][j] = min(dp[i][j] , dp[i][j-1] + max(numOm[i]- numOm[k],0ll));
      |                                                                           ^
Language: C++

#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;

int N;
vector<int> numOm(310, 0);
int K;
int ans = 0;
void input(){
    cin >> N >> K;
    repk(i, 1, N+1){
        int a;cin >> a;
        numOm.push_back(a);
    }
}

void solve(){
    input();
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, INF));
    dp[0][0] = 0;
    for(int i=1;i<=N-K;i++){
        for(int j=i;j<=N;j++){
            for(int k=0;k<j;k++){
                dp[i][j] = min(dp[i][j], dp[k][j-1]+max(0, numOm[i]-numOm[k]) )
            }
        }
    }
    ll ans = INF;
    rep(i, N+1){
        chmin(ans, dp[i][N-K]);
    }
    if(ans == INF) ans = 0;
    cout << ans << endl;
    return ;
}

int main () {
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:41:80: error: expected ';' before '}' token
   41 |                 dp[i][j] = min(dp[i][j], dp[k][j-1]+max(0, numOm[i]-numOm[k]) )
      |                                                                                ^
      |                                                                                ;
   42 |             }
      |             ~
Language: C++

#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;

int N;
vector<int> numOm(310, 0);
int K;
int ans = 0;
void input(){
    cin >> N >> K;
    repk(i, 1, N+1){
        int a;cin >> a;
        numOm.push_back(a);
    }
}

void solve(){
    input();
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, INF));
    dp[0][0] = 0;
    for(int i=1;i<=N-K;i++){
        for(int j=i;j<=N;j++){
            for(int k=0;k<j;k++){
                dp[i][j] = min(dp[i][j], dp[k][j-1]+max(0, num0m[i]-num0m[k]) )
            }
        }
    }
    ll ans = INF;
    rep(i, N+1){
        chmin(ans, dp[i][N-K]);
    }
    if(ans == INF) ans = 0;
    cout << ans << endl;
    return ;
}

int main () {
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:41:60: error: 'num0m' was not declared in this scope; did you mean 'numOm'?
   41 |                 dp[i][j] = min(dp[i][j], dp[k][j-1]+max(0, num0m[i]-num0m[k]) )
      |                                                            ^~~~~
      |                                                            numOm
Language: C++

#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;

int N;
vector<int> numOm(310, 0);
int K;
int ans = 0;
void input(){
    cin >> N >> K;
    repk(i, 1, N+1){
        int a;cin >> a;
        numOm.push_back(a);
    }
}

void solve(){
    input();
    vector<vector<ll>> dp(N+1, vector<int>(N+1, INF);
    dp[0][0] = 0;
    for(int i=1;i<=N-K;i++){
        for(int j=i;j<=N;j++){
            for(int k=0;k<j;k++){
                dp[i][j] = min(dp[i]dp[j], dp[k][j-1]+max(0, num0n[i]-num0n[k]) )
            }
        }
    }
    ll ans = INF;
    rep(i, N+1){
        chmin(ans, dp[i][N-K]);
    }
    if(ans == INF) ans = 0;
    cout << ans << endl;
    return ;
}

int main () {
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:36:53: error: expected ')' before ';' token
   36 |     vector<vector<ll>> dp(N+1, vector<int>(N+1, INF);
      |                          ~                          ^
      |                                                     )
a.cc:41:37: error: expected ')' before 'dp'
   41 |                 dp[i][j] = min(dp[i]dp[j], dp[k][j-1]+max(0, num0n[i]-num0n[k]) )
      |                               ~     ^~
      |                                     )
a.cc:41:62: error: 'num0n' was not declared in this scope
   41 |                 dp[i][j] = min(dp[i]dp[j], dp[k][j-1]+max(0, num0n[i]-num0n[k]) )
      |                                                              ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

int dp[303][303][303];
map<int,int>mp;

signed main(){
	int N,K;
	cin>>N>>K;
	vector<int>a(N);
	int cnt = 0;
	REP(i,N){
		cin>>a[i];
		if(!mp.count())mp[a[i]]=cnt++;
	}
	REP(i,303)REP(j,303)REP(k,303)dp[i][j][k]=INF;
	mp[INF]=cnt++;
	mp[0]=cnt++;
	vector<int>mpInv(cnt);
	for(auto e:mp){
		mpInv[e.second]=e.first;
	}
	dp[1][0][mp[a[0]]]=a[0];
	dp[1][1][mp[0]]=0;
	FOR(i,1,N){
		REP(j,K+1){
			REP(k,cnt){
				if(mpInv[k]<a[i]){
					CHMIN(dp[i+1][j+1][k],dp[i][j][k]);
				}
				CHMIN(dp[i+1][j][mp[a[i]]],dp[i][j][k]+max(0ll,a[i]-mpInv[k]));
			}
		}
	}
	int ans = INF;
	REP(i,cnt)CHMIN(ans,dp[N][K][i]);
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:29: error: no matching function for call to 'std::map<long long int, long long int>::count()'
   25 |                 if(!mp.count())mp[a[i]]=cnt++;
      |                     ~~~~~~~~^~
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:1270:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >]'
 1270 |         count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |         ^~~~~
/usr/include/c++/14/bits/stl_map.h:1270:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_map.h:1264:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = long long int; _Tp = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; size_type = long unsigned int; key_type = long long int]'
 1264 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/14/bits/stl_map.h:1264:7: note:   candidate expects 1 argument, 0 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;
    vector<ll> h(n+1, 0);
    repr(i, 1, n+1) cin >> h[i];

    const ll inf = 1LL<<60;
    vector<vector<ll>> dp(n+5, vector<ll>(n+5, inf));
    rep(i, n+1) dp[i][0] = 0;
    
    repr(x, 1, n+1) repr(y, 1, x+1){
        repr(i, 1, x) chmin(dp[x][y], dp[i][y-1]+chmax(0LL, h[x]-h[i]));
    }
    ll ans = inf;
    repr(i, n-k, n+1) chmin(ans, dp[i][n-k]);
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:56: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   68 |         repr(i, 1, x) chmin(dp[x][y], dp[i][y-1]+chmax(0LL, h[x]-h[i]));
      |                                                        ^~~
a.cc:9:40: note:   initializing argument 1 of 'bool chmax(T&, T) [with T = long long int]'
    9 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
      |                                     ~~~^
Language: C++

#include <iostream>
#include <cstring>
using namespace std;
long long dp[301][301]={0};
int v[301] = {0};
int main(){
    int n, k;
    long long m = 1e15
    cin >> n >> k;
    memset(*dp+1,1,sizeof(dp)-8);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
        for(int e = 0; e <= i; e++)
            for(int j = k; j >= 0; j--){
                dp[i][j] = min(dp[i][j], dp[e][j] + m(0, v[i]-v[e]));
                dp[e][j] = j?dp[e][j-1]:m;
            }
    }
    for(int i = 0; i <= n; i++)for(int j = 0; j <= k; j++)m = min(m, dp[i][j]);
    cout << m << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: expected ',' or ';' before 'cin'
    9 |     cin >> n >> k;
      |     ^~~
a.cc:15:54: error: 'm' cannot be used as a function
   15 |                 dp[i][j] = min(dp[i][j], dp[e][j] + m(0, v[i]-v[e]));
      |                                                     ~^~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>

#define MAX_N 300

using namespace std;

int N, K;
vector<int64_t> H;

int64_t solve() {
  vector<vector<int64_t>> dp(N, vector<int64_t>(N + 1, 1e11));

  for (int i = 0; i < N; ++i) {
    dp[i][0] = H[i];
  }
  dp[0][1] = H[0];

  for (int i = 1; i < N; ++i) {
    for (int j = 1; j <= i + 1; ++j) {
      for (int k = 0; k < i; ++k) {
        dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0ll, H[i] - H[k]));
      }
    }
  }

  int64_t result = 1e12;

  for (int i = 0; i < N; ++i) {
    result = min(result, dp[i][N - K]);
    // cout << dp[i][N - K] << " ";
  }
  // cout << endl;

  return result;
}

int main() {
  cin >> N >> K;

  H = vector<int64_t>(N);

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

  cout << solve() << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int64_t solve()':
a.cc:22:52: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   22 |         dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0ll, H[i] - H[k]));
      |                                                 ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:22:52: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   22 |         dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0ll, H[i] - H[k]));
      |                                                 ~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <iostream>
using namespace std;

#define ll long long int

ll max(ll a, ll b){
  if(a > b) return a;
  return b;
}

ll min(ll a, ll b){
  if(a < b) return a;
  return b;
}

ll Solve(int N, int R, int S, ll* H, ll* Kai){
  //cout << "Solve: " << R << " " << S << endl;
  ll ret = LLONG_MAX>>2;
  if(R <= 0){
    ret = 0;
  }else if(S == 1){
    ret = H[R];
  }else if(Kai[(N+1)*R+S] >= 0){
    cout << "sanshou"<< endl;
    ret = Kai[(N+1)*R+S];
  }else{
    for(int i = S-1; i < R; ++i){
      ll tmp = Solve(N, i, S-1, H, Kai) + max(0, H[R] - H[i]);
      //cout << "tmp " << i << " " << (S-1) << " " << tmp << " " << ret << endl;
      ret = min(ret, tmp);
      //cout << "tmp " << i << " " << (S-1) << " " << tmp << " " << ret << endl;
    }
    Kai[(N+1)*R+S] = ret;
  }
  //cout << R << " " << S << " " << ret << endl;
  return ret;
}

int main(){
  int N, K;
  cin >> N >> K;
  ll H[N+1];
  H[0] = 0;
  for(int i = 0; i < N; ++i) cin >> H[i+1];
  ll Kai[(N+1)*(N+1)];
  for(int i = 0; i < (N+1)*(N+1); ++i) Kai[i] = -1;

  //cout << N << " " << K << endl;
  //for(int i = 0; i < N+1; ++i) cout << " " << H[i];
  //cout << endl;
  ll ret = LLONG_MAX >> 2;
  for(int i = N-K; i <= N; ++i){
    ll tmp = Solve(N, i, N-K, H, Kai);
    ret = min(ret, tmp);
  }
  cout << ret << endl;

  return 0;
}


Compiler output:
a.cc: In function 'long long int Solve(int, int, int, long long int*, long long int*)':
a.cc:18:12: error: 'LLONG_MAX' was not declared in this scope
   18 |   ll ret = LLONG_MAX>>2;
      |            ^~~~~~~~~
a.cc:2:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
a.cc: In function 'int main()':
a.cc:51:12: error: 'LLONG_MAX' was not declared in this scope
   51 |   ll ret = LLONG_MAX >> 2;
      |            ^~~~~~~~~
a.cc:51:12: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'