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

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // 答え
    cout << dp[N-1] << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:34:29: error: expected '}' at end of input
   34 |     cout << dp[N-1] << endl;
      |                             ^
a.cc:17:12: note: to match this '{'
   17 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;
 
// Find a longest Subsequence b/w 2 strings using memoization
pair<int, string> LCSstring(string x, string y,pair<int, string> **dp){
    int n = x.size();
  	int m = y.size();
  	if(n==0 || m==0){
        
        return make_pair(0, "");
    }
    if(dp[n][m].first != -1){
        return dp[n][m];
    }
    if(x[0] == y[0]){
        auto p = LCSstring(x.substr(1), y.substr(1), dp);
        p.first +=1;
        p.second += x[n-1];
        dp[n][m] = p;
        return dp[n][m];
    }
    else{
        auto p1 = LCSstring(x.substr(1), y, dp);
        auto p2 = LCSstring(x, y.substr(1), dp);
 
        if(p1.first >= p2.first){
            dp[n][m] = p1;
            return dp[n][m];
        }
        else{
            dp[n][m] = p2;
            return dp[n][m];
        }
    }
    return dp[n-1][m-1];
}
 
 
int main() {
    string x, y;
  	cin >> x >> y;
    pair<int, string> **dp = new pair<int, string>*[x.size()+1];
    for(int i=0;i<=x.size();i++){
        dp[i] = new pair<int, string>[y.size()+1];
        for(int j=0;j<=y.size();j++){
            dp[i][j].first = -1;
            dp[i][j].second = "";
        }
    }
    auto p = LCSstring(x, x.size(), y, y.size(), dp);
    cout << p.second<< endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:33: error: could not convert 'x.std::__cxx11::basic_string<char>::size()' from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   53 |     auto p = LCSstring(x, x.size(), y, y.size(), dp);
      |                           ~~~~~~^~
      |                                 |
      |                                 std::__cxx11::basic_string<char>::size_type {aka long unsigned int}
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;
 
// Find a longest Subsequence b/w 2 strings using memoization
pair<int, string> LCSstring(string x, string y,pair<int, string> **dp){
    int n = x.size();
  	int m = y.size();
  	if(n==0 || m==0){
        
        return make_pair(0, "");
    }
    if(dp[n][m].first != -1){
        return dp[n][m];
    }
    if(x[n-1] == y[m-1]){
        auto p = LCSstring(x, n-1, y, m-1, dp);
        p.first +=1;
        p.second += x[n-1];
        dp[n][m] = p;
        return dp[n][m];
    }
    else{
        auto p1 = LCSstring(x, n-1, y, m, dp);
        auto p2 = LCSstring(x, n, y, m-1, dp);
 
        if(p1.first >= p2.first){
            dp[n][m] = p1;
            return dp[n][m];
        }
        else{
            dp[n][m] = p2;
            return dp[n][m];
        }
    }
    return dp[n-1][m-1];
}
 
 
int main() {
    string x, y;
  	cin >> x >> y;
    pair<int, string> **dp = new pair<int, string>*[x.size()+1];
    for(int i=0;i<=x.size();i++){
        dp[i] = new pair<int, string>[y.size()+1];
        for(int j=0;j<=y.size();j++){
            dp[i][j].first = -1;
            dp[i][j].second = "";
        }
    }
    auto p = LCSstring(x, x.size(), y, y.size(), dp);
    cout << p.second<< endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'std::pair<int, std::__cxx11::basic_string<char> > LCSstring(std::string, std::string, std::pair<int, std::__cxx11::basic_string<char> >**)':
a.cc:19:32: error: could not convert '(n - 1)' from 'int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   19 |         auto p = LCSstring(x, n-1, y, m-1, dp);
      |                               ~^~
      |                                |
      |                                int
a.cc:26:33: error: could not convert '(n - 1)' from 'int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   26 |         auto p1 = LCSstring(x, n-1, y, m, dp);
      |                                ~^~
      |                                 |
      |                                 int
a.cc:27:32: error: could not convert 'n' from 'int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   27 |         auto p2 = LCSstring(x, n, y, m-1, dp);
      |                                ^
      |                                |
      |                                int
a.cc: In function 'int main()':
a.cc:53:33: error: could not convert 'x.std::__cxx11::basic_string<char>::size()' from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   53 |     auto p = LCSstring(x, x.size(), y, y.size(), dp);
      |                           ~~~~~~^~
      |                                 |
      |                                 std::__cxx11::basic_string<char>::size_type {aka long unsigned int}
Language: C++

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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones, int dest){
	if(dest == 1){
      return abs(stones[1] - stones[0]);
    }
	if(dest == 0){
      return 0;
    }
  	if(dp[dest-1] == -1){
      dp[dest-1] = minCost(stones, dest-1);
    }
  	if(dp[dest-2] == -1){
      dp[dest-2] = minCost(stones, dest-2);
    }
  	return min(abs(stones[dest] - stones[dest-1]) + dp[dest-1]),
               abs(stones[dest] - stones[dest-2]) + dp[dest-2]);
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  vector<int> dp(vec.size(), -1);
  cout<<minCost(vec, vec.size()-1)<<endl;
}

Compiler output:
a.cc: In function 'int minCost(std::vector<int>&, int)':
a.cc:18:19: error: no matching function for call to 'min(int)'
   18 |         return min(abs(stones[dest] - stones[dest-1]) + dp[dest-1]),
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:18:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |         return min(abs(stones[dest] - stones[dest-1]) + dp[dest-1]),
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
a.cc:19:63: error: expected ';' before ')' token
   19 |                abs(stones[dest] - stones[dest-2]) + dp[dest-2]);
      |                                                               ^
      |                                                               ;
a.cc:19:63: error: expected primary-expression before ')' token
Language: C++

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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones, int dest){
	if(dest == 1){
      return abs(stones[1] - stones[0]);
    }
	if(dest == 0){
      return 0;
    }
  	if(dp[dest-1] == -1){
      dp[dest-1] = minCost(stones, dest-1);
    }
  	if(dp[dest-2] == -1){
      dp[dest-2] = minCost(stones, dest-2);
    }
  	return min(abs(stones[dest] - stones[dest-1]) + dp[dest-1],
               abs(stones[dest] - stones[dest-2]) + dp[dest-2];
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  vector<int> dp(vec.size(), -1);
  cout<<minCost(vec, vec.size()-1)<<endl;
}

Compiler output:
a.cc: In function 'int minCost(std::vector<int>&, int)':
a.cc:19:63: error: expected ')' before ';' token
   19 |                abs(stones[dest] - stones[dest-2]) + dp[dest-2];
      |                                                               ^
      |                                                               )
a.cc:18:19: note: to match this '('
   18 |         return min(abs(stones[dest] - stones[dest-1]) + dp[dest-1],
      |                   ^
Language: C++

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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones, int dest{
	if(dest == 1){
      return abs(stones[1] - stones[0]);
    }
	if(dest == 0){
      return 0;
    }
  	if(dp[dest-1] == -1){
      dp[dest-1] = minCost(stones, dest-1);
    }
  	if(dp[dest-2] == -1){
      dp[dest-2] = minCost(stones, dest-2);
    }
  	return min(abs(stones[dest] - stones[dest-1]) + dp[dest-1],
               abs(stones[dest] - stones[dest-2]) + dp[dest-2];
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  vector<int> dp(vec.size(), -1);
  cout<<minCost(vec, vec.size()-1)<<endl;
}

Compiler output:
a.cc:5:42: error: expected ')' before '{' token
    5 | int minCost(vector<int> &stones, int dest{
      |            ~                             ^
      |                                          )
a.cc: In function 'int minCost(std::vector<int>&, int)':
a.cc:19:63: error: expected ')' before ';' token
   19 |                abs(stones[dest] - stones[dest-2]) + dp[dest-2];
      |                                                               ^
      |                                                               )
a.cc:18:19: note: to match this '('
   18 |         return min(abs(stones[dest] - stones[dest-1]) + dp[dest-1],
      |                   ^
Language: C++

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

int minCost(vector<int> &stones, int dest){
	if(dest == 1){
      return abs(stones[1] - stones[0]);
    }
	if(dest == 0){
      return 0;
    }
  	return min(abs(stones[dest] - stones[dest-1]) + minCost(stones, dest-1)),
               abs(stones[dest] - stones[dest-2]) + minCost(stones, dest-2)));
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  cout<<minCost(vec, vec.size()-1)<<endl;
}

Compiler output:
a.cc: In function 'int minCost(std::vector<int>&, int)':
a.cc:11:19: error: no matching function for call to 'min(int)'
   11 |         return min(abs(stones[dest] - stones[dest-1]) + minCost(stones, dest-1)),
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:11:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   11 |         return min(abs(stones[dest] - stones[dest-1]) + minCost(stones, dest-1)),
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
a.cc:12:76: error: expected ';' before ')' token
   12 |                abs(stones[dest] - stones[dest-2]) + minCost(stones, dest-2)));
      |                                                                            ^
      |                                                                            ;
a.cc:12:76: error: expected primary-expression before ')' token
Language: C++

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

int minCost(vector<int> &stones, int dest){
	if(dest == 1){
      return abs(stones[1] - stones[0])
    }
	if(dest == 0){
      return 0;
    }
  	return min(abs(stones[dest] - minCost(stones, dest-1),
               abs(stones[dest] - minCost(stones, dest-2))
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  cout<<minCost(vec, vec.size()-1)<<endl;
}

Compiler output:
a.cc: In function 'int minCost(std::vector<int>&, int)':
a.cc:6:40: error: expected ';' before '}' token
    6 |       return abs(stones[1] - stones[0])
      |                                        ^
      |                                        ;
    7 |     }
      |     ~                                   
a.cc:12:59: error: expected ')' before '}' token
   12 |                abs(stones[dest] - minCost(stones, dest-2))
      |                                                           ^
      |                                                           )
   13 | }
      | ~                                                          
a.cc:11:23: note: to match this '('
   11 |         return min(abs(stones[dest] - minCost(stones, dest-1),
      |                       ^
a.cc:12:59: error: expected ';' before '}' token
   12 |                abs(stones[dest] - minCost(stones, dest-2))
      |                                                           ^
      |                                                           ;
   13 | }
      | ~
Language: Java

import java.util.*;
import java.io.*;
public class MyClass {
    public static void main(String args[]) {
      
      Scanner sc = new Scanner(System.in);
      PrintWriter w = new PrintWriter(System.out);
      //Input Part
      int n = sc.nextInt();
      int height[] = new int[n];
      for(int i = 0; i < n; i++)
      {
          height[i] = sc.nextInt();
      }
      
      //Logic Part
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(height[1] - height[0]);
      for(int i = 2; i < n; i++)
      {
          dp[i] = Math.min(dp[i-1] + Math.abs(height[i] - height[i-1]), dp[i-2] + Math.abs(height[i] - height[i-2]));
      }
      w.println(dp[n-1]);
      w.close();
    }
}

Compiler output:
Main.java:3: error: class MyClass is public, should be declared in a file named MyClass.java
public class MyClass {
       ^
1 error
Language: C++

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0;i<n;i++)
    cin >> v[i];
  vector<int> dp(n);
  dp[n-2] = abs(v[n-1] - v[n-2]);
  for(int i = n-3;i >= 0;i++)
  {
    dp[i] = min(dp[i+1] + abs(v[i+1] - v[i]) , dp[i+2] + abs(v[i+2] - v[i]);
  }
  cout << dp[0] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:76: error: expected ')' before ';' token
   15 |     dp[i] = min(dp[i+1] + abs(v[i+1] - v[i]) , dp[i+2] + abs(v[i+2] - v[i]);
      |                ~                                                           ^
      |                                                                            )
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  }
   cout<<dp[n-1]<<endl;
}
}

Compiler output:
a.cc:22:1: error: expected declaration before '}' token
   22 | }
      | ^
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(abs(a[i]-a[i-1]+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
              }
   cout<<dp[n-1]<<endl;
              }

Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: no matching function for call to 'abs(int, int)'
   18 |     dp[i]=min(abs(a[i]-a[i-1]+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 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/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/stdlib.h:980:12: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note:   candidate expects 1 argument, 2 provided
Language: C++

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

int frog(int *dist,int i,int n)
{
    if(i>=n)
    {
        return 0; 
    }
    int op1=abs(dist[i+1]-dist[i])+frog(dist,i+1,n);
    int op2=abs(dist[i+2]-dist[i])+frog(dist,i+2,n);
    return min(op1,op2);
}

int topdown(ll *dist,int i,int n,int *dp)
{
    if(i>=n)
    {
        dp[i]=0;
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    ll op1=abs(dist[i+1]-dist[i])+topdown(dist,i+1,n,dp);
    ll op2=abs(dist[i+2]-dist[i])+topdown(dist,i+2,n,dp);
    dp[i]=min(op1,op2);
    return dp[i];
}

int main()
{
    int n;
    cin>>n;
    ll *dist=new ll[n];
    ll *dp=new ll[n+1];
    
    for(int i=0;i<n;i++)
    {
        cin>>dist[i];
    }
    for(int i=0;i<=n;i++)
    {
        dp[i]=-1;
    }
    
    cout<<topdown(dist,0,n-1,dp)<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:30: error: cannot convert 'long long int*' to 'int*'
   49 |     cout<<topdown(dist,0,n-1,dp)<<endl;
      |                              ^~
      |                              |
      |                              long long int*
a.cc:16:39: note:   initializing argument 4 of 'int topdown(long long int*, int, int, int*)'
   16 | int topdown(ll *dist,int i,int n,int *dp)
      |                                  ~~~~~^~
Language: C++

n = int(input())
h = list(map(int,input().split()))

dp = [0]*n
dp[1] = abs(h[0]-h[1])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print(dp[-1])

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int heights[N];
  for (int i = 0; i < N; i++)
    cin >> heights[i];
  int cost[N];
  cost[N] = 0;
  for (int i = N-1; i >= 0; i--) {
    int op1 = INT_MAX;
    int op2 = INT_MAX;
  	if (i + 1 <= N)
      op1 = abs(heights[i] - heights[i+1]);
    if (i + 2 <= N)
      op2 = abs(heights[i] - heights[i+2]);
    dp[i] = dp[i+1] + min(op1, op2);
  }
  cout << dp[0];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   19 |     dp[i] = dp[i+1] + min(op1, op2);
      |     ^~
      |     dup
a.cc:21:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |   cout << dp[0];
      |           ^~
      |           dup
Language: C++

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

int main() {
  int N;
  cin >> N;
  int heights[N];
  for (int i = 0; i < N; i++)
    cin >> heights[i];
  int cost[N];
  cost[N] = 0;
  for (int i = N-1; i >= 0; i--) {
    int op1 = 0;
    int op2 = 0;
  	if (i + 1 <= N)
      op1 = abs(heights[i] - heights[i+1]);
    if (i + 2 <= N)
      op2 = abs(heights[i] - heights[i+2]);
    dp[i] = dp[i+1] + min(op1, op2);
  }
  cout << dp[0];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   19 |     dp[i] = dp[i+1] + min(op1, op2);
      |     ^~
      |     dup
a.cc:21:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |   cout << dp[0];
      |           ^~
      |           dup
Language: C++

#include<iostream>


class DAMN_FROG {
private: 
	int last;
	int* steps;
	int len = 0;
	int target = 0;
	int cur = 0;
	int cost = 0;

public:
	DAMN_FROG(int* input, int length) {
		len = length;
		steps = input;
		last = steps[len - 1];
	}
	void Next_step() {
		int tmp = 0;
		update_target();
		if (len - cur <= 2){
			cost += abs(steps[cur] - target);
			cur++;
			return;
		}

		int a = steps[cur + 1];
		int b = steps[cur + 2];
		if (abs(steps[cur] - a) + abs(a - target) < abs(steps[cur] - b) + abs(b - target)) {
			cost += abs(steps[cur] - a);
			cur++;
		}
		else {
			cost += abs(steps[cur] - b);
			cur += 2;
		}

	}
	void find_route() {
		while (cur != len - 1) {
			Next_step();
		}
	} 
	void update_target() {
		if (cur + 4 < len) {
			if (abs(steps[cur + 4] - last) > abs(steps[cur + 3] - last))
				target = steps[cur + 3];
			else target = steps[cur + 4];
		}
		else
			target = steps[len-1];
	}

	int get_cost(){
		return cost;
	}
};

int main() {
	int len,i = 0;
	int* vec;
	std::cin >> len;
	vec = new int[len];

	std::cin.get();
	while (std::cin.peek() != '\n') {
		std::cin>>vec[i++];
	}

	DAMN_FROG test = { vec, len};
	test.find_route();
	std::cout << test.get_cost();
	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:74:18: error: expected '}' at end of input
   74 |         return 0;
      |                  ^
a.cc:60:12: note: to match this '{'
   60 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[n];
    int dp[n+1];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        if(abs(h[i]-h[i-1])>abs(h[i]-h[i-2])){
            dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
        }
      else if(abs(h[i]-h[i-1])==abs(h[i]-h[i-2]){
        dp[i]=min(dp[i-1],dp[i-2])+abs(h[i]-h[i-1]);
      }
        else {
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:49: error: expected ')' before '{' token
   17 |       else if(abs(h[i]-h[i-1])==abs(h[i]-h[i-2]){
      |              ~                                  ^
      |                                                 )
a.cc:23:5: error: expected primary-expression before '}' token
   23 |     }
      |     ^
Language: C++

#include 'bits/stdc++.h'
using namespace std;
int main(){
    int n;
    cin>>n;
    int h[n];
    int dp[n+1];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        if(abs(h[i]-h[i-1])>abs(h[i]-h[i-2])){
            dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
        }
        else {
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc:1:10: error: #include expects "FILENAME" or <FILENAME>
    1 | #include 'bits/stdc++.h'
      |          ^~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin>>n;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #include 'bits/stdc++.h'
a.cc:12:11: error: 'abs' was not declared in this scope
   12 |     dp[1]=abs(h[0]-h[1]);
      |           ^~~
a.cc:21:5: error: 'cout' was not declared in this scope
   21 |     cout<<dp[n-1];
      |     ^~~~
a.cc:21:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: Java

//greedy is not applicable here as even if select min "diff" at each step then
//also final ans will not be optimal min possible of all answers
//eg: 30 20 50 10 50 70
//greedy: 60
//bruteforce (mainly dp): 40
import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]){
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      int n=Integer.parseInt(br.readLine().trim());
      String s[]=br.readLine().trim().split("\\s+");
      int size=s.length;
      int arr[]=new int[size];
      for(int i=0;i<size;i++)
        arr[i]=Integer.parseInt(s[i]);
      int ans=0;
      //int dp[][]=new int[][];
      //ans=minRec(a,dp,0,0);
      int dp[]=new int[size];
      dp[n-1]=0;
      dp[n-2]=Math.abs(arr[n-1]-arr[n-2]);
      for(int i=n-3;i>=0;i--)
        dp[i]=Math.min( Math.abs(arr[i]-arr[i+1]), Math.abs(arr[i]-arr[i+2]) );
      System.out.println(dp[0]);
    }
}

Compiler output:
Main.java:18: error: unreported exception IOException; must be caught or declared to be thrown
      int n=Integer.parseInt(br.readLine().trim());
                                        ^
Main.java:19: error: unreported exception IOException; must be caught or declared to be thrown
      String s[]=br.readLine().trim().split("\\s+");
                            ^
2 errors
Language: Java

//greedy is not applicable here as even if select min "diff" at each step then
//also final ans will not be optimal min possible of all answers
//eg: 30 20 50 10 50 70
//greedy: 60
//bruteforce (mainly dp): 40
import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]){
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      int n=Integer.parseInt(br.readLine().trim());
      String s[]=br.readLine().trim().split("\\s+");
      int size=s.length();
      int arr[]=new int[size];
      for(int i=0;i<size;i++)
        arr[i]=Integer.parseInt(s[i]);
      int ans=0;
      //int dp[][]=new int[][];
      //ans=minRec(a,dp,0,0);
      int dp[]=new int[size];
      dp[n-1]=0;
      dp[n-2]=Math.abs(arr[n-1]-arr[n-2]);
      for(int i=n-3;i>=0;i--)
        dp[i]=Math.min( Math.abs(arr[i]-arr[i+1]), Math.abs(arr[i]-arr[i+2]) );
      System.out.println(dp[0]);
    }
}

Compiler output:
Main.java:20: error: cannot find symbol
      int size=s.length();
                ^
  symbol:   method length()
  location: variable s of type String[]
1 error
Language: Java

//greedy is not applicable here as even if select min "diff" at each step then
//also final ans will not be optimal min possible of all answers
//eg: 30 20 50 10 50 70
//greedy: 60
//bruteforce (mainly dp): 40
import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]){
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      int n=Integer.parseInt(br.readLine().trim());
      String s[]=br.readLine().trim().split();
      int size=s.length();
      int arr[]=new int[size];
      for(int i=0;i<size;i++)
        arr[i]=Integer.parseInt(s[i]);
      int ans=0;
      //int dp[][]=new int[][];
      //ans=minRec(a,dp,0,0);
      int dp[]=new int[size];
      dp[n-1]=0;
      dp[n-2]=Math.abs(arr[n-1]-arr[n-2]);
      for(int i=n-3;i>=0;i--)
        dp[i]=Math.min( Math.abs(arr[i]-arr[i+1]), Math.abs(arr[i]-arr[i+2]) );
      System.out.println(dp[0]);
    }
}

Compiler output:
Main.java:19: error: no suitable method found for split(no arguments)
      String s[]=br.readLine().trim().split();
                                     ^
    method String.split(String,int) is not applicable
      (actual and formal argument lists differ in length)
    method String.split(String,int,boolean) is not applicable
      (actual and formal argument lists differ in length)
    method String.split(char,int,boolean) is not applicable
      (actual and formal argument lists differ in length)
    method String.split(String) is not applicable
      (actual and formal argument lists differ in length)
Main.java:20: error: cannot find symbol
      int size=s.length();
                ^
  symbol:   method length()
  location: variable s of type String[]
2 errors
Language: Java

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] dp = new int[n];
		int[] frog = new int[n];
		for(int i=0; i<n; i++) {
			frog[i] = sc.nextInt();
		}
		for(int i=1; i<n; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<i+3; j++) {
				if(j<n) dp[j] = Math.min(dp[j],dp[i]+ Math.abs(frog[i]-frog[j]));
			}
		}
		System.out.println(dp[n-1]);

	}

}


Compiler output:
Main.java:3: error: class A is public, should be declared in a file named A.java
public class A {
       ^
1 error
Language: Java

import java.util.*;
import java.io.*;
 
class Main{
public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	String[] str = br.readLine().split(" ");
  	int n = Integer.parseInt(str[0]);
  	int k = Integer.parseInt(str[1]);
  	int[] h = new int[n];
  	String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++)
      h[i] = Integer.parseInt(s[i]);
  	int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++){
      for(int j=i-1;j>=0 && j-i<=k;j--)
      dp[i] = Math.min(dp[i],dp[j] + Math.abs(h[i]-h[j]));
      
      System.out.println(dp[n-1]);
    }
}

Compiler output:
Main.java:22: error: reached end of file while parsing
}
 ^
1 error
Language: Java

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] dp = new int[n-1];
		int[] frog = new int[n];
		for(int i=0; i<n; i++) {
			frog[i] = sc.nextInt();
		}
		if(n==2) {
			System.out.println(Math.abs(frog[0]-frog[1]));
		}
		else {
			dp[0] = Math.abs(frog[0]-frog[1]);
			dp[1] = Math.min(Math.abs(frog[1]-frog[2]), Math.abs(frog[0]-frog[2]));
			for(int i=2; i<n-1; i++) {
			dp[i] = Math.min(dp[i-2]+Math.abs(frog[i-1]-frog[i+1]), dp[i-1]+Math.abs(frog[i]-frog[i+1]));
		}
		System.out.println(dp[n-2]);
		}

	}

}


Compiler output:
Main.java:3: error: class A is public, should be declared in a file named A.java
public class A {
       ^
1 error
Language: Java

import java.util.*;
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	int n = Integer.parseInt(br.readLine());
  	int[] h = new int[n];
  	String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++)
      h[i] = Integer.parseInt(s[i]);
  	int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=1;i<n;i++){
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
      
      System.out.println(dp[n-1]);
    }
}

Compiler output:
Main.java:19: error: reached end of file while parsing
}
 ^
1 error
Language: Java

class Main{
public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	int n = Integer.parseInt(br.readLine());
  	int[] h = new int[n];
  	String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++)
      h[i] = Integer.parseInt(s[i]);
  	int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=1;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+d[i-2]);
      
      System.out.println(dp[n-1]);
    }
}

Compiler output:
Main.java:2: error: cannot find symbol
public static void main(String[] args) throws IOException{
                                              ^
  symbol:   class IOException
  location: class Main
Main.java:3: error: cannot find symbol
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	^
  symbol:   class BufferedReader
  location: class Main
Main.java:3: error: cannot find symbol
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	                        ^
  symbol:   class BufferedReader
  location: class Main
Main.java:3: error: cannot find symbol
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	                                           ^
  symbol:   class InputStreamReader
  location: class Main
Main.java:12: error: cannot find symbol
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+d[i-2]);
                                                                           ^
  symbol:   variable d
  location: class Main
5 errors
Language: Java

class Main{
public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	int n = Integer.parseInt(br.readLine());
  	int[] h = new int[n];
  	String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++)
      h[i] = Integer.parseInt(s[i]);
  	int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=1;i<n;i++){
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+d[i-2]);
      
      System.out.println(dp[n-1]);
    }
}

Compiler output:
Main.java:16: error: reached end of file while parsing
}
 ^
1 error
Language: C++

#include<iostream>
#include<cmath>
using namsespace std;

int main(){
	int n;
  cin>>n;
  int a[n];
  for(int i=0; i<n; i++){
  	cin>>a[i];
  }
  int dp[n];
  dp[0] = a[0];
  dp[1] = abs(a[1]-a[0]);
  
  for(int i=2; i<n; i++){
  	dp[i] = min(dp[i-2] + abs(a[i]-a[i-2]), dp[i-1] + abs(a[i]-a[i-1]));
  }
  cout<< dp[n-1];
}

Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'namsespace'
    3 | using namsespace std;
      |       ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin>>n;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:17:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
   17 |         dp[i] = min(dp[i-2] + abs(a[i]-a[i-2]), dp[i-1] + abs(a[i]-a[i-1]));
      |                 ^~~
      |                 std::min
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:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:19:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   19 |   cout<< dp[n-1];
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int>dp;
void f(vector<int> &v,int i)
{
  if(dp[i]!=-1)
    return dp[i];
  if(i==1)
    return dp[i]=v[1]-v[0];
   return dp[i]=min(f(v,i-2)+v[i]-v[i-2],f(v,i-1)+v[i]-v[i-1]);
}
int main()
{
	vector<int>v;
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
	cin>>v[i];
	}
	vector<int>dp(n,-1);
	dp.resize(n,-1);
	f(v,n-1);
	cout<<dp[n-1];
}

Compiler output:
a.cc: In function 'void f(std::vector<int>&, int)':
a.cc:7:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
    7 |     return dp[i];
      |                ^
a.cc:9:17: error: return-statement with a value, in function returning 'void' [-fpermissive]
    9 |     return dp[i]=v[1]-v[0];
a.cc:10:29: error: invalid operands of types 'void' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to binary 'operator+'
   10 |    return dp[i]=min(f(v,i-2)+v[i]-v[i-2],f(v,i-1)+v[i]-v[i-1]);
a.cc:10:50: error: invalid operands of types 'void' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to binary 'operator+'
   10 |    return dp[i]=min(f(v,i-2)+v[i]-v[i-2],f(v,i-1)+v[i]-v[i-1]);
Language: Java


import java.io.*;
import java.util.*;

public class Frog_1 {

    public static void solve(InputReader in, PrintWriter out) throws Exception {

        int n = in.nextInt();

        int[] arr = new int[n];

        for(int i=0;i<n;i++)
            arr[i]=in.nextInt();

        int[] dp = new int[n+1];

        dp[0]=0;
        dp[1]=0;
        dp[2]= Math.abs(arr[1]-arr[0]);

        for(int i=3;i<=n;i++)
        {
            int val1 = Math.abs(arr[i-1]-arr[i-2]) + dp[i-1];
            int val2 = Math.abs(arr[i-1]-arr[i-3]) + dp[i-2];

            dp[i]= Math.min(val1,val2);
        }

        out.println(dp[n]);

    }

    /////////////////////////////////////////////////////////


    private final static long hash(long x, long y) {
        x += offset;
        y += offset;
        return x << 32 | y;
    }

    private final static int offset = (int) 3e5;

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String nextToken() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

        public String nextLine() throws IOException {
            return reader.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(nextToken());
        }

    }
}


Compiler output:
Main.java:5: error: class Frog_1 is public, should be declared in a file named Frog_1.java
public class Frog_1 {
       ^
1 error
Language: C++

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

int frog(int arr[], int dp[], int n){
  if(dp[n-1))
        return dp[n-1];
  else
        {
          dp[n-1] = min(frog(arr, dp, n-1)+ abs(arr[n-1] - arr[n-2]), frog(arr, dp, n-2) + abs(arr[n-1] - arr[n-3]));
          return dp[n-1];
        }
}
int main() {
  int n;
  cin>>n;
  int arr[n];
  int dp[n];
  for(int i = 0 ; i < n ; i++){cin>>arr[i]; dp[i] = -1;}
  
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);
  
  cout<<frog(arr, dp, n);
  
  
  return 0;
}

Compiler output:
a.cc: In function 'int frog(int*, int*, int)':
a.cc:5:12: error: expected ']' before ')' token
    5 |   if(dp[n-1))
      |            ^
      |            ]
a.cc:5:13: error: expected primary-expression before ')' token
    5 |   if(dp[n-1))
      |             ^
a.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type]
   12 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define long long ll
#define push_back pb
using namespace std;
ll getmin(ll i,ll &v,ll n)
{
  return 30;
}
int main()
{
  ll n,i,tmp;
  cin>>n;
  vector<ll> v;
  for(i=0;i<n;i++)
  {
    cin>>tmp;
    v.pb(tmp);
  }
  cout<<getmin(0,v,n)<<"\n";
  return 0;
}

Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll getmin(ll i,ll &v,ll n)
      | ^~
a.cc: In function 'int main()':
a.cc:11:3: error: 'll' was not declared in this scope
   11 |   ll n,i,tmp;
      |   ^~
a.cc:12:8: error: 'n' was not declared in this scope; did you mean 'yn'?
   12 |   cin>>n;
      |        ^
      |        yn
a.cc:13:12: error: template argument 2 is invalid
   13 |   vector<ll> v;
      |            ^
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   for(i=0;i<n;i++)
      |       ^
a.cc:16:10: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   16 |     cin>>tmp;
      |          ^~~
      |          tm
a.cc:17:7: error: request for member 'pb' in 'v', which is of non-class type 'int'
   17 |     v.pb(tmp);
      |       ^~
a.cc:19:9: error: 'getmin' was not declared in this scope; did you mean 'getuid'?
   19 |   cout<<getmin(0,v,n)<<"\n";
      |         ^~~~~~
      |         getuid
Language: Java

public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] h = new int[n];
        for(int i = 0; i<n; i++){
        h[i] = scan.nextInt();
        }
        int solve = dp(n, h);
    System.out.println(solve);
    }
    public static int dp(int n, int[] h){
    int[] arr = new int[n];
    arr[1] = Math.abs(h[0] - h[1]);
    for(int i = 2; i<arr.length; i++){
    arr[i] = Math.min(Math.abs(h[i-1]-h[i])+arr[i-1], Math.abs(h[i-2]-h[i])+arr[i-2]);
    }
    return arr[n-1];
    }

Compiler output:
Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
              ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: Java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package platinumalgorithms;

import java.io.*;
import java.util.*;
public class PLATINUMaLGORITHMS {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] h = new int[n];
        for(int i = 0; i<n; i++){
        h[i] = scan.nextInt();
        }
        int solve = dp(n, h);
    System.out.println(solve);
    }
    public static int dp(int n, int[] h){
    int[] arr = new int[n];
    arr[1] = Math.abs(h[0] - h[1]);
    for(int i = 2; i<arr.length; i++){
    arr[i] = Math.min(Math.abs(h[i-1]-h[i])+arr[i-1], Math.abs(h[i-2]-h[i])+arr[i-2]);
    }
    return arr[n-1];
    }
    
}


Compiler output:
Main.java:10: error: class PLATINUMaLGORITHMS is public, should be declared in a file named PLATINUMaLGORITHMS.java
public class PLATINUMaLGORITHMS {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
#define endl '\n'


//This solution is  recursive but slow

using namespace std;

int main() {
    FAST_IO;     
    int n; cin >> n;
    int jumps[n];
    vector<int> dp(n, 0); // dp[i] : Minimum cost for the frog to reach position i.
    for (int i = 0; i < n; i++) cin >> jumps[i];
    dp[1] = abs(jumps[1] - jumps[0]); // Base value
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(jumps[i] - jumps[i - 1]) + dp[i - 1], abs(jumps[i] - jumps[i - 2]) + dp[i - 2]);
    cout << dp[n - 1] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'FAST_IO' was not declared in this scope
   10 |     FAST_IO;
      |     ^~~~~~~