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

#include <bits/stdc++.h>

#define INF 1e15

using namespace std;

ll dp[100010];

int main()
{
  int N; cin>>N;
  vector<int> h(N), a(N-1);
  for(int i=0; i<N; i++) cin>>h[i];
  for(int i=0; i<N-1; i++) a[i] = abs(h[i+1]-h[i]);
  for(int i=1; i<=N; i++) dp[i] = INF;
  for(int i=0; i<N; i++){
    dp[i+1]=min(dp[i+1],dp[i]);
    dp[i+2]=min(dp[i+2],dp[i]);
  }
  cout<<dp[N]<<"\n";
  return 0;
}

Compiler output:
a.cc:7:1: error: 'll' does not name a type
    7 | ll dp[100010];
      | ^~
a.cc: In function 'int main()':
a.cc:15:27: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |   for(int i=1; i<=N; i++) dp[i] = INF;
      |                           ^~
      |                           dup
a.cc:17:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |     dp[i+1]=min(dp[i+1],dp[i]);
      |     ^~
      |     dup
a.cc:20:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |   cout<<dp[N]<<"\n";
      |         ^~
      |         dup
Language: C++

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int *arr=new int[n];
  int *dp=new int[n];
  for(int i=0;i<n;++i)
  {4
10 30 40 20
	cin>>arr[i];
  }
  dp[0]=0;
  dp[1]=abs(arr[0]-arr[1]);
  for(int i=2;i<n;++i)
  {
    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]) );
  }
 
  cout<<dp[n-1]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: expected ';' before numeric constant
   11 |   {4
      |     ^
      |     ;
   12 | 10 30 40 20
      | ~~
Language: C++

#include<iostream>
#include<maths.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int *arr=new int[n];
  int *dp=new int[n];
  for(int i=0;i<n;++i)
  {
	cin>>arr[i];
  }
  dp[0]=0;
  dp[1]=abs(arr[0]-arr[1]);
  for(int i=3;i<n;++i)
  {
    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]) );
  }
  
  cout<<dp[n]<<endl;
  return 0;
}

Compiler output:
a.cc:2:9: fatal error: maths.h: No such file or directory
    2 | #include<maths.h>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int solve(int h[],int curr){
  int n = h.size();
  if(n==0||curr>=n-1)
    return 0;
  if(curr==n-2)
    return abs(h[n-2]-h[n-1]);
  if(n==1)
    return h[1];
  if(n==2)
    return abs(h[2]-h[1]);
  int ans1 = abs(h[i+1]-h[i])+solve(h,curr);
  int ans2 = abs(h[i+2]-h[i])+solve(h,curr);
  return min(ans1,ans2);
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  cout<<solve(h,0)<<endl;
}

Compiler output:
a.cc: In function 'int solve(int*, int)':
a.cc:4:13: error: request for member 'size' in 'h', which is of non-class type 'int*'
    4 |   int n = h.size();
      |             ^~~~
a.cc:13:20: error: 'i' was not declared in this scope
   13 |   int ans1 = abs(h[i+1]-h[i])+solve(h,curr);
      |                    ^
Language: C++

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

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: 'begin' was not declared in this scope
   14 |     for(int j:i+i,i+2){
      |                     ^
a.cc:14:21: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:14:21: error: 'end' was not declared in this scope
   14 |     for(int j:i+i,i+2){
      |                     ^
a.cc:14:21: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:16:47: error: expected ')' before ';' token
   16 |         dp[j]=min(dp[j],dp[i]+abs(dp[j]-dp[i]);
      |                  ~                            ^
      |                                               )
Language: C++

#include <bits/stdc++>

using namespace std;

int main()
{
  int N;
  vector<int> h;
  cin >> N;
  
  for(int i = 0; i < N; i++)
  {
    int he;
    cin >> he;
    h.push_back(he);
  }
  
  vector<int> dp(N, 0);
  dp[1] = abs(h[0] - h[1]);
  
  for(int i = 2; i < N; i++)
  {
    int m = dp[i-1] > dp[i-2] ? i-2 : i-1;
    dp[i] = dp[m] + abs(h[m] - h[i]);
  }
  
  cout << dp[N-1] << '\n';
  
  return 0;
}
  

Compiler output:
a.cc:1:10: fatal error: bits/stdc++: No such file or directory
    1 | #include <bits/stdc++>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:23: error: 'begin' was not declared in this scope
   14 |     for(int j:(i+i,i+2)){
      |                       ^
a.cc:14:23: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:14:23: error: 'end' was not declared in this scope
   14 |     for(int j:(i+i,i+2)){
      |                       ^
a.cc:14:23: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:16:47: error: expected ')' before ';' token
   16 |         dp[j]=min(dp[j],dp[i]+abs(dp[j]-dp[i]);
      |                  ~                            ^
      |                                               )
Language: Java

import java.util.Scanner;

public class Frog1 {

    private static int frog1(int N, int[] h) {
        // subproblem:
        // f(k) = cost when standing on stone k (0 <= k < N)
        // f(N-1)

        // f(0) = 0
        // f(1) = abs(h[1], h[0])
        // f(k) = min:
        //        f(k-1) + abs(h[k], h[k-1])
        //        f(k-2) + abs(h[k], h[k-2])

        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(h[0] - h[1]);
        for (int k = 2; k < N; k++) {
            dp[k] = Math.min(
                    dp[k-1] + Math.abs(h[k] - h[k-1]),
                    dp[k-2] + Math.abs(h[k] - h[k-2])
            );
        }
        return dp[N-1];
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = scanner.nextInt();
        }
        int res = frog1(N, h);
        System.out.println(res);
    }
}


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

import java.util.*;
public class Main{
	public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
      	int t=sc.nextInt();
      	int size=sc.nextInt();
      	int[]  arr=new int[size];
      	for(int i=0;i<size;i++) arr[i]=sc.nextInt();
      	if(size==1) {System.out.println(0); return;}
      	if(size==2) {System.out.println(arr[size-1]-arr[size-2])return;}
      	int[] nums=new int[size];
      	nums[0]=0;
     	nums[1]=(int)Math.abs(arr[1]-arr[0]);
      	for(int i=1;i<size;i++){
          
        	nums[i]=(int)Math.min((int)Math.abs(arr[i]-arr[i-1])+nums[i-1],(int)Math.abs(arr[i]-arr[i-2])+nums[i-2]);
        }
    }
}

Compiler output:
Main.java:10: error: ';' expected
      	if(size==2) {System.out.println(arr[size-1]-arr[size-2])return;}
      	                                                        ^
1 error
Language: C++

#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 ;
ll h[100010] ;
lldp[100010] ;
 int　main(){
  int N ;cin>> N;
  rep(i,N) cin>>h[i] ; //初期化
  rep(i,100010) dp[i] =INF ;
  dp[0] =0 ;
  rep(i,N){
      chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1])) ;
      if(i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2])) ;
  }

    cout <<dp[N-1] <<endl ; 
    return 0;
}

Compiler output:
a.cc:15:2: error: extended character 　 is not valid in an identifier
   15 |  int　main(){
      |  ^
a.cc:14:1: error: 'lldp' does not name a type; did you mean 'll'?
   14 | lldp[100010] ;
      | ^~~~
      | ll
a.cc:15:2: error: ISO C++ forbids declaration of 'int\U00003000main' with no type [-fpermissive]
   15 |  int　main(){
      |  ^~~~~~~~~
a.cc: In function 'int int\U00003000main()':
a.cc:18:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   18 |   rep(i,100010) dp[i] =INF ;
      |                 ^~
      |                 dup
a.cc:19:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   19 |   dp[0] =0 ;
      |   ^~
      |   dup
Language: Java

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }

            int prepre = 0;
            int pre = Math.abs(arr[0] - arr[1]);

            for (int i = 2; i < n; i++) {
                int oldPre = pre;
                pre = Math.min(pre + Math.abs(arr[i] - arr[i - 1]), prepre + Math.abs(arr[i] - arr[i - 2]));
                prepre = oldPre;
            }

            System.out.println(pre);
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

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

#include <bits/stdc++.h>

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
    int h[n], dp[n];
    for (int i = 0; i < n; i++)
    {
    	cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i = 2; i < n; i++)
    {
    	dp[i] = min(dp[i-1] + abs(h[i] - h[i-1], dp[i - 2] + h[i] - h[i - 2]);
    }
    cout << dp[n-1] << "\n";

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:9: error: 'ios' has not been declared
    4 |         ios::sync_with_stdio(0);
      |         ^~~
a.cc:5:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |         cin.tie(0);
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 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:19:34: error: too many arguments to function 'int abs(int)'
   19 |         dp[i] = min(dp[i-1] + abs(h[i] - h[i-1], dp[i - 2] + h[i] - h[i - 2]);
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42:
/usr/include/stdlib.h:980:12: note: declared here
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
a.cc:19:78: error: expected ')' before ';' token
   19 |         dp[i] = min(dp[i-1] + abs(h[i] - h[i-1], dp[i - 2] + h[i] - h[i - 2]);
      |                    ~                                                         ^
      |                                                                              )
a.cc:21:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |     cout << dp[n-1] << "\n";
      |     ^~~~
      |     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<iostream>
#include<vector>
#include<cmath>

using namespace std;

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

Compiler output:
a.cc:7:1: error: '::main' must return 'int'
    7 | void main()
      | ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<cmath>

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


Compiler output:
a.cc:5:1: error: '::main' must return 'int'
    5 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   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:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int>h(n+1,0);
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int>h(n+1,0);
      |          ^~~
a.cc:12:10: error: 'h' was not declared in this scope
   12 |     cin>>h[i];
      |          ^
a.cc:14:10: error: expected primary-expression before 'int'
   14 |   vector<int>dp(n+1,0);
      |          ^~~
a.cc:16:5: error: 'dp' was not declared in this scope
   16 |     dp[0]=0;
      |     ^~
a.cc:18:15: error: 'h' was not declared in this scope
   18 |     dp[2]=abs(h[2]-h[1]);
      |               ^
a.cc:24:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   24 |     cout<<dp[n]<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:24:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   24 |     cout<<dp[n]<<endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<cmath>

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


Compiler output:
a.cc:5:1: error: '::main' must return 'int'
    5 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   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:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int>h(n+1,0);
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int>h(n+1,0);
      |          ^~~
a.cc:12:10: error: 'h' was not declared in this scope
   12 |     cin>>h[i];
      |          ^
a.cc:14:10: error: expected primary-expression before 'int'
   14 |   vector<int>dp(n+1,0);
      |          ^~~
a.cc:16:5: error: 'dp' was not declared in this scope
   16 |     dp[0]=0;
      |     ^~
a.cc:18:15: error: 'h' was not declared in this scope
   18 |     dp[2]=abs(h[2]-h[1]);
      |               ^
a.cc:24:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   24 |     cout<<dp[n]<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:24:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   24 |     cout<<dp[n]<<endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
#include<vector>
#include<cmath>

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


Compiler output:
a.cc:5:1: error: '::main' must return 'int'
    5 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |   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:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int>h(n,0);
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int>h(n,0);
      |          ^~~
a.cc:12:10: error: 'h' was not declared in this scope
   12 |     cin>>h[i];
      |          ^
a.cc:14:10: error: expected primary-expression before 'int'
   14 |   vector<int>dp(n+1,0);
      |          ^~~
a.cc:16:5: error: 'dp' was not declared in this scope
   16 |     dp[0]=0;
      |     ^~
a.cc:18:15: error: 'h' was not declared in this scope
   18 |     dp[2]=abs(h[2]-h[1]);
      |               ^
a.cc:24:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   24 |     cout<<dp[n]<<endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:24:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   24 |     cout<<dp[n]<<endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
#include<vector>
int abs(int a)
{
  return a>0?a:-1*a;
}

int min(int a,int b)
{
  if(a>b)
    return b;
  return a;
}

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


Compiler output:
a.cc:15:1: error: '::main' must return 'int'
   15 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:18:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   18 |   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:19:3: error: 'vector' was not declared in this scope
   19 |   vector<int>h(n,0);
      |   ^~~~~~
a.cc:19:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:19:10: error: expected primary-expression before 'int'
   19 |   vector<int>h(n,0);
      |          ^~~
a.cc:22:10: error: 'h' was not declared in this scope
   22 |     cin>>h[i];
      |          ^
a.cc:24:10: error: expected primary-expression before 'int'
   24 |   vector<int>dp(n+1,0);
      |          ^~~
a.cc:26:5: error: 'dp' was not declared in this scope
   26 |     dp[0]=0;
      |     ^~
a.cc:28:15: error: 'h' was not declared in this scope
   28 |     dp[2]=abs(h[2]-h[1]);
      |               ^
Language: C++

#include<iostream>
#include<vector>
int abs(int a)
{
  return a>0?a:-1*a;
}

int min(int a,int b)
{
  if(a>b)
    return b;
  return a;
}

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

Compiler output:
a.cc:15:1: error: '::main' must return 'int'
   15 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:18:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   18 |   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:19:3: error: 'vector' was not declared in this scope
   19 |   vector<int>h(n,0);
      |   ^~~~~~
a.cc:19:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:19:10: error: expected primary-expression before 'int'
   19 |   vector<int>h(n,0);
      |          ^~~
a.cc:22:10: error: 'h' was not declared in this scope
   22 |     cin>>h[i];
      |          ^
a.cc:24:10: error: expected primary-expression before 'int'
   24 |   vector<int>dp(n,0);
      |          ^~~
a.cc:26:5: error: 'dp' was not declared in this scope
   26 |     dp[1]=0;
      |     ^~
a.cc:27:15: error: 'h' was not declared in this scope
   27 |     dp[2]=abs(h[2]-h[1]);
      |               ^
Language: Java

class Main {
  
  int[] stones;
  
  public static void main(String[] args) {
    Main frog = new Main();
    frog.solve(stones);
  }
  
  private int cost(i, j) {
    return Math.abs(stones[i] - stones[j]);
  }
  
  public void solve(int[] stones) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    stones = new int[n];
    
    for (int i = 0; i < n; i++) {
      stones[i] = sc.nextInt();
    }
    
    int[] dp = new int[n];
    
    dp[n-1] = 0;
    dp[n-2] = cost(n-2, n-1);
    for (int i = N - 3; i >= 0; i--) {
      dp[i] = Math.min(dp[i+1] + cost(i, i+1), dp[i+2]+cost(i, i+2));
    }
    System.out.println(dp[0]);
  }
}

   	


Compiler output:
Main.java:10: error: <identifier> expected
  private int cost(i, j) {
                    ^
Main.java:10: error: <identifier> expected
  private int cost(i, j) {
                       ^
2 errors
Language: Java

class Frog {
  
  int[] stones;
  
  public static void main(String[] args) {
    Frog frog = new Frog();
    frog.solve(stones);
  }
  
  private int cost(i, j) {
    return Math.abs(stones[i] - stones[j]);
  }
  
  public void solve(int[] stones) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    stones = new int[n];
    
    for (int i = 0; i < n; i++) {
      stones[i] = sc.nextInt();
    }
    
    int[] dp = new int[n];
    
    dp[n-1] = 0;
    dp[n-2] = cost(n-2, n-1);
    for (int i = N - 3; i >= 0; i--) {
      dp[i] = Math.min(dp[i+1] + cost(i, i+1), dp[i+2]+cost(i, i+2));
    }
    System.out.println(dp[0]);
  }
}

   	

Compiler output:
Main.java:10: error: <identifier> expected
  private int cost(i, j) {
                    ^
Main.java:10: error: <identifier> expected
  private int cost(i, j) {
                       ^
2 errors
Language: C++

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

Compiler output:
a.cc:3:1: error: 'll' does not name a type
    3 | ll dp[100005];
      | ^~
a.cc: In function 'int main()':
a.cc:7:17: error: 'n' was not declared in this scope
    7 |   for(int i=0;i<n;i++)cin>>h[i];
      |                 ^
a.cc:8:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
    8 |   dp[0] = h[0];
      |   ^~
      |   dup
a.cc:10:17: error: 'n' was not declared in this scope
   10 |   for(int i=2;i<n;i++){
      |                 ^
a.cc:13:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 |   cout<<dp[n-1];
      |            ^
      |            yn
Language: C++

//#include "Header.h"
#include <iostream>
#include<bits/stdc++.h>

#define endl '\n'
using namespace std;

int main()
{	
	
	int N;
	cin>>N;
	vector<long long> A(N);
    int t;
	while (N--)
	{
		cin>>A[i];
	}
	vector<long long> v(N);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < N; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	cout<< v[N - 1]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:24: error: 'i' was not declared in this scope
   17 |                 cin>>A[i];
      |                        ^
Language: C++

//#include "Header.h"
#include<bits/stdc++.h>

using namespace std;

int solve(vector<int>& A) {

	int n = A.size();
	vector<int> v(n);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < n; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	return v[n - 1];
}

int main()
{	
	
	int N;
	scanf("%d", &N);
	vector<int> A(N);
    int t;
	while (N--)
	{
		scanf("%d", &t);
		A.push_back(t);
	}
	vector<int> v(N);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < N; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	cout<< v[n - 1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:18: error: 'n' was not declared in this scope
   42 |         cout<< v[n - 1];
      |                  ^
Language: C++

//#include "Header.h"
#include<bits/stdc++.h>

using namespace std;

int solve(vector<int>& A) {

	int n = A.size();
	vector<int> v(n);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < n; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	return v[n - 1];
}

int main()
{	
	
	int N;
	scanf("%d", &N);
	vector<int> A(N);
    int t;
	while (N--)
	{
		scanf_s("%d", &t);
		A.push_back(t);
	}
	auto ans = solve(A);

	return ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   30 |                 scanf_s("%d", &t);
      |                 ^~~~~~~
      |                 scanf
Language: C++

//#include "Header.h"
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>

using namespace std;

int solve(vector<int>& A) {

	int n = A.size();
	vector<long long> v(n);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < n; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	return v[n - 1];
}



int main()
{	
	
	int N;
	scanf_s("%d", &N);
	vector<int> A;

	while (N--)
	{
		int t;
		scanf_s("%d", &t);
		A.push_back(t);
	}
	auto ans = solve(A);

	return ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   30 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: C++

//#include "Header.h"
#include <vector>
#include <cstdio>

using namespace std;

int solve(vector<int>& A) {

	int n = A.size();
	vector<long long> v(n);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < n; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	return v[n - 1];
}



int main()
{	
	
	int N;
	scanf("%d", &N);
	vector<int> A;

	while (N--)
	{
		int t;
		scanf("%d", &t);
		A.push_back(t);
	}
	auto ans = solve(A);

	return ans;
}

Compiler output:
a.cc: In function 'int solve(std::vector<int>&)':
a.cc:12:16: error: 'abs' was not declared in this scope
   12 |         v[1] = abs(A[0] - A[1]);
      |                ^~~
Language: C++

//#include "Header.h"
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iostream>
#include <set>
#include <numeric>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <stack>
#include <cstring>
#include <queue>
#include <deque>
#include <list>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <cstdio>

using namespace std;

int solve(vector<int>& A) {

	int n = A.size();
	vector<long long> v(n);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < n; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	return v[n - 1];
}



int main()
{	
	
	int N;
	scanf_s("%d", &N);
	vector<int> A;

	while (N--)
	{
		int t;
		scanf_s("%d", &t);
		A.push_back(t);
	}
	auto ans = solve(A);

	return ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   47 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: C++

int solve(vector<int>& A) {

	int n = A.size();
	vector<long long> v(n);
	v[0] = 0;
	v[1] = abs(A[0] - A[1]);

	for (int i = 2; i < n; ++i)
	{
		v[i] = min(v[i - 1] + abs(A[i] - A[i - 1]), v[i - 2] + abs(A[i - 2] - A[i]));
	}
	
	return v[n - 1];
}

int main()
{	
	int N;
	cin >> N;
	vector<int> A;

	while (N--)
	{
		int t;
		cin >> t;
		A.push_back(t);
	}
	auto ans = solve(A);

	return ans;
}

Compiler output:
a.cc:1:11: error: 'vector' was not declared in this scope
    1 | int solve(vector<int>& A) {
      |           ^~~~~~
a.cc:1:18: error: expected primary-expression before 'int'
    1 | int solve(vector<int>& A) {
      |                  ^~~
a.cc: In function 'int main()':
a.cc:19:9: error: 'cin' was not declared in this scope
   19 |         cin >> N;
      |         ^~~
a.cc:20:9: error: 'vector' was not declared in this scope
   20 |         vector<int> A;
      |         ^~~~~~
a.cc:20:16: error: expected primary-expression before 'int'
   20 |         vector<int> A;
      |                ^~~
a.cc:26:17: error: 'A' was not declared in this scope
   26 |                 A.push_back(t);
      |                 ^
a.cc:28:26: error: 'A' was not declared in this scope
   28 |         auto ans = solve(A);
      |                          ^
a.cc:28:27: error: 'solve' cannot be used as a function
   28 |         auto ans = solve(A);
      |                           ^
Language: C++

#include <bits/stdc++.h

using namespace std;

int main()
{
  int n,i,x,y,z;
  z=0;
  
  cin>>n;
  int h[n];
  for(i=0; i<n; i++)
  {
    cin>>h[i];
  }
  
  for(i=0; i<n-2; i++)
  {
    x=abs(h[i+1]-h[n-1]);
    y=abs(h[i+2]-h[n-1]);
    
    if(x<=y)
    {
      z+=x;
    }
    else
    {
      z+=y;
      i++;
    }
  }
  
  cout<<z

Compiler output:
a.cc:1:24: error: missing terminating > character
    1 | #include <bits/stdc++.h
      |                        ^
a.cc: In function 'int main()':
a.cc:33:10: error: expected ';' at end of input
   33 |   cout<<z
      |          ^
      |          ;
a.cc:33:10: error: expected '}' at end of input
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   cin>>n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 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:14:11: error: 'min' was not declared in this scope; did you mean 'std::min'?
   14 |     dp[i]=min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]))
      |           ^~~
      |           std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   cout<<dp[n];
      |   ^~~~
      |   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;
int main()
{
  int n,ww;
  cin>>n>>ww;
  int v[n],w[n];
  int i,j;
  for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
  long long dp[n+1][ww+1];
  for(i=0;i<n;i++)
  {
	for(j=0;j<=ww;j++)
    {	
      if(i==0 || j==0)
        dp[i][j]=0;
      if(w[i-1]<=j)
        dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i-1]];
      else
       	dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[n][ww];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:55: error: expected ')' before ';' token
   19 |         dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i-1]];
      |                     ~                                 ^
      |                                                       )
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,ww;
  cin>>n>>ww;
  int v[n],w[n];
  int i,j;
  for(i=0;i<n;i++)
    cin>>w[i]>>v[i];
  long long dp[n+1][w+1];
  for(i=0;i<n;i++)
  {
	for(j=0;j<=ww;j++)
    {	
      if(i==0 || j==0)
        dp[i][j]=0;
      if(w[i-1]<=j)
        dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i-1]];
      else
       	dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[n][ww];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: conversion from 'int*' to 'long unsigned int' in a converted constant expression
   11 |   long long dp[n+1][w+1];
      |                     ~^~
a.cc:11:22: error: could not convert '(((int*)(& w)) + 4)' from 'int*' to 'long unsigned int'
   11 |   long long dp[n+1][w+1];
      |                     ~^~
      |                      |
      |                      int*
a.cc:11:22: error: size of array 'dp' has non-integral type 'int*'
a.cc:19:55: error: expected ')' before ';' token
   19 |         dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i-1]];
      |                     ~                                 ^
      |                                                       )
Language: C++

#include <iostream>

using namespace std;

const long long MAX = 1e5 + 10;
long long dp[MAX];

int main(){
	
	long long n, k;
	cin >> n >> k;
	
	long long tower[n]; // 10 30 40 20
	for(auto & in : tower)
		cin >> in;
	
	fill(dp, dp + n, MAX);
	dp[0] = 0;
	dp[1] = abs(tower[1] - tower[0]);
	for(int i = 2 ; i < n; ++i)//0   4
		for(int j = max(0, i - k); j < i; ++j)
				dp[i] = min(dp[i], abs(tower[i] - tower[j]) + dp[j]);

		cout << dp[n - 1] <<' ';
	return 0;
}
/* // 5 3
     10 30 40 50 20	
     0  20 30 40 
 
			    10
	  	 30             40
     40      20     20
 20
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:21:32: error: no matching function for call to 'max(int, long long int)'
   21 |                 for(int j = max(0, i - k); j < i; ++j)
      |                             ~~~^~~~~~~~~~
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:21:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |                 for(int j = max(0, i - k); j < i; ++j)
      |                             ~~~^~~~~~~~~~
/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++

n = int(input())
lst = list(map(int, input().split()))
lst += [0]*2
ans = [float('inf')]*(n+2)
ans[0] = 0

def dp():
  for i in range(n):
    ans[i+1] = min(ans[i+1], ans[i] + abs(lst[i+1]-lst[i]))
    ans[i+2] = min(ans[i+2], ans[i] + abs(lst[i+2]-lst[i]))

dp()

print(ans[n-1])

Compiler output:
a.cc:4:14: warning: multi-character character constant [-Wmultichar]
    4 | ans = [float('inf')]*(n+2)
      |              ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: Java

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

public class Main {
    private static final class FastInput {
        private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer st;

        private int nextInt() throws Exception {
            return Integer.parseInt(nextWord());
        }

        private long nextLong() throws Exception {
            return Long.parseLong(nextWord());
        }

        private String nextWord() throws Exception {
            if (st == null || !st.hasMoreElements()) st = new StringTokenizer(br.readLine(), " ");
            return st.nextToken();
        }

        private long[] lineToIntArr(int len) throws Exception {
            long[] arr = new long[len];
            for (int i = 0; i < arr.length; i++) arr[i] = nextLong();
            return arr;
        }
    }

    public static void main(String[] args) throws Exception {
        FastInput in = new FastInput();
        int n = in.nextInt();
        long[] a = in.lineToIntArr(n);
      	long[] dp = new long[n+1];
        dp[0] = 0;
       	for(int i = 1; i <n; ++i){
          	if(i + 1) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-1]));
          	if(i + 2) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-2]));
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        bw.write(String.valueOf(dp[n - 1]));
        bw.flush();
    }
}


Compiler output:
Main.java:39: error: incompatible types: int cannot be converted to boolean
          	if(i + 1) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-1]));
          	     ^
Main.java:40: error: incompatible types: int cannot be converted to boolean
          	if(i + 2) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-2]));
          	     ^
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  ll n,k;
  cin>>n>>k;
  ll i;
  ll a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  ll sol[n];
  sol[0]=0;
  sol[1]=abs(a[1]-a[0]);
  for(i=2;i<n;i++)
  {
    ll count=1;
    sol[i]=1e18;
    while((i-count)>=0&&count<=k)
    {
      sol[i]=min(sol[i],sol[i-count]+abs(a[i]-a[i-count]);
      count++;
     }
                 
  }
  cout<<sol[n-1];
                
  
                 }


Compiler output:
a.cc: In function 'int main()':
a.cc:21:58: error: expected ')' before ';' token
   21 |       sol[i]=min(sol[i],sol[i-count]+abs(a[i]-a[i-count]);
      |                 ~                                        ^
      |                                                          )
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  ll n,k;
  cin>>n>>k;
  ll i;
  ll a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  ll sol[n];
  sol[0]=0;
  sol[1]=abs(a[1]-a[0]);
  for(i=2;i<n;i++)
  {
    ll count=1;
    while((i-count)>=0&&count<=k)
    {
      sol[i]=min(sol[i-count]+abs(a[i]-a[i-count]);
      count++;
     }
                 
  }
  cout<<sol[n-1];
                
  
                 }

Compiler output:
a.cc: In function 'int main()':
a.cc:20:51: error: expected ')' before ';' token
   20 |       sol[i]=min(sol[i-count]+abs(a[i]-a[i-count]);
      |                 ~                                 ^
      |                                                   )