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

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    fo(i,1,n)
    cin>>a[i];
    int pos=1;
    int sum=a[1];
    while(pos!=n)
    {
        sum+=min(a[pos+1]-a[pos],a[pos+2]-a[pos]);
        if(a[pos+1]-a[pos]<a[pos+2]-a[pos])
        pos++;
        else
        pos=pos+2;
        
    }
    cout<<pos<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:29:8: error: 'i' was not declared in this scope
   29 |     fo(i,1,n)
      |        ^
a.cc:11:23: note: in definition of macro 'fo'
   11 | #define fo(i,a,b) for(i=a;i<b;i++)
      |                       ^
Language: C++

#include <iostream>
#define mxn 100010
using namespace std;

int ar[mxn], dp[mxn];

//return minim cost to reach at n
int go(int n) {
    if(n == 1) return 0;
    if(n == 2) return abs(ar[2] - ar[1]);

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

    int cost1 = go(n-1) + abs(ar[n] - ar[n-1]);
    int cost2 = go(n-2) + abs(ar[n] - ar[n-2]);
    return dp[n] = min(cost1, cost2);
}

int main() {
    int n; cin >> n;
    fill(ar, ar+mxn, -1);
    for(int i=1; i<=n; ++i) cin >> ar[i];
    cout << go(n);
    return 0;
}#include <iostream>
#define mxn 100010
using namespace std;

int ar[mxn], dp[mxn];

//return minim cost to reach at n
int go(int n) {
    if(n == 1) return 0;
    if(n == 2) return abs(ar[2] - ar[1]);

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

    int cost1 = go(n-1) + abs(ar[n] - ar[n-1]);
    int cost2 = go(n-2) + abs(ar[n] - ar[n-2]);
    return dp[n] = min(cost1, cost2);
}

int main() {
    int n; cin >> n;
    fill(ar, ar+mxn, -1);
    for(int i=1; i<=n; ++i) cin >> ar[i];
    cout << go(n);
    return 0;
}

Compiler output:
a.cc:25:2: error: stray '#' in program
   25 | }#include <iostream>
      |  ^
a.cc:25:3: error: 'include' does not name a type
   25 | }#include <iostream>
      |   ^~~~~~~
a.cc:29:5: error: redefinition of 'int ar [100010]'
   29 | int ar[mxn], dp[mxn];
      |     ^~
a.cc:5:5: note: 'int ar [100010]' previously declared here
    5 | int ar[mxn], dp[mxn];
      |     ^~
a.cc:29:14: error: redefinition of 'int dp [100010]'
   29 | int ar[mxn], dp[mxn];
      |              ^~
a.cc:5:14: note: 'int dp [100010]' previously declared here
    5 | int ar[mxn], dp[mxn];
      |              ^~
a.cc:32:5: error: redefinition of 'int go(int)'
   32 | int go(int n) {
      |     ^~
a.cc:8:5: note: 'int go(int)' previously defined here
    8 | int go(int n) {
      |     ^~
a.cc:43:5: error: redefinition of 'int main()'
   43 | int main() {
      |     ^~~~
a.cc:19:5: note: 'int main()' previously defined here
   19 | int main() {
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long 
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int ar[200000],dp[200000],n;
int solve(int i)
{
    dp[i]=min(abs(ar[i]-ar[i-1])+dp[i-1],abs(ar[n]-ar[i-2])+dp[i-2]);
    if(i==n||i==1||i==2)
    retuen dp[n];
    solve(i+1);
}
int main()
{
    SYNC
    in(n);
    l(i,1,n+1)
    in(ar[i]);
    dp[1]=0;
    dp[2]=abs(ar[1]-ar[2]);
    o(solve(3));
}

Compiler output:
a.cc: In function 'int solve(int)':
a.cc:26:5: error: 'retuen' was not declared in this scope
   26 |     retuen dp[n];
      |     ^~~~~~
a.cc:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
   28 | }
      | ^
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;

/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
void solve(ll a[],ll n){
    vector<ll>dp(n,0);
    dp[1]=dp[0]+abs(a[0]-a[1]);
    for(ll i=2;i<n;i++){
        dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
       // cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
}


int main(){
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];

    }
     solve(a,n);
}


Compiler output:
a.cc: In function 'void solve(ll*, ll)':
a.cc:19:5: error: 'vector' was not declared in this scope
   19 |     vector<ll>dp(n,0);
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:19:14: error: expected primary-expression before '>' token
   19 |     vector<ll>dp(n,0);
      |              ^
a.cc:19:15: error: 'dp' was not declared in this scope
   19 |     vector<ll>dp(n,0);
      |               ^~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
long long int dp[100001];

long long  frogjump(vector<int>v,int n)
{ if(n<=1)
 return 0;
    if(dp[n]!=-1)
      return dp[n];
      
      long long  ans1=abs(v[n]-v[n-1])+frogjump(v,n-1);
      long long  int ans2=abs(v[n]-v[n-2])+frogjump(v,n-2);
      return dp[n]=min(ans1,ans2);
	
	
}
/*
long long  frogjump2(vector<int>v,int n)
{ dp[1]=0;
dp[0]=0;
v[0]=10000000;
  for(int i=2;i<=n;i++)
    dp[i]=min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
  return dp[n];
	
	
}*/
int main()
{ 
  int n;
  cin>>n;
  vector<int> v(n+1);
  for(int i=1;i<=n;i++)
    {
   	  cin>>v[i];
  }
  v[0]=100000000;
  cout<<frogjump2(v,n);
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:9: error: 'frogjump2' was not declared in this scope; did you mean 'frogjump'?
   39 |   cout<<frogjump2(v,n);
      |         ^~~~~~~~~
      |         frogjump
Language: C++

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


using namespace std;
int main(){
    
ios_base::sync_with_stdio(false);
    cin.tie(NULL);    

  int n; cin>>n;
  dp[n];
  for (int i=0; i<n; i++)
  {
    int temp; cin>>temp;
    a.push_back(temp);
  }
  
  dp[n-1]=0;
  dp[n-2]=abs(a[n-1]-a[n-2]);
  
  for (int i=n-3; i>=0; i--)
  {
    diff1=abs (a[i+1]-a[i]); diff2= abs(a[i+2] -a[i]);
    dp[i]= min( dp[i+1]+ diff1, dp[i+2] +diff2);
  }  
  cout<<dp[0]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |   dp[n];
      |   ^~
      |   dup
a.cc:17:5: error: 'a' was not declared in this scope
   17 |     a.push_back(temp);
      |     ^
a.cc:21:15: error: 'a' was not declared in this scope
   21 |   dp[n-2]=abs(a[n-1]-a[n-2]);
      |               ^
a.cc:25:5: error: 'diff1' was not declared in this scope
   25 |     diff1=abs (a[i+1]-a[i]); diff2= abs(a[i+2] -a[i]);
      |     ^~~~~
a.cc:25:30: error: 'diff2' was not declared in this scope
   25 |     diff1=abs (a[i+1]-a[i]); diff2= abs(a[i+2] -a[i]);
      |                              ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
using namespace std;
int main(){
	int n,maxw;
	cin >>n>>maxw;
	multimap<int,int>m;
	for(int i=0;i<n;i++){
		int v,w;cin >>w>>v;
		m.insert({v,w})
		};
	multimap<int,int>iterator itr;
	itr=m.end();
	for(;itr>=itr.begin();itr--){
		if((maxw-itr->second)>=0){
			cost=cost+itr->first;
			maxw=maxw-itr->second;
			}
		else { cout << cost;return 0;}
		}
	return 0;
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:15:32: error: expected ';' before '}' token
   15 |                 m.insert({v,w})
      |                                ^
      |                                ;
   16 |                 };
      |                 ~               
a.cc:17:35: error: expected initializer before 'itr'
   17 |         multimap<int,int>iterator itr;
      |                                   ^~~
a.cc:18:9: error: 'itr' was not declared in this scope
   18 |         itr=m.end();
      |         ^~~
a.cc:21:25: error: 'cost' was not declared in this scope; did you mean 'const'?
   21 |                         cost=cost+itr->first;
      |                         ^~~~
      |                         const
a.cc:24:32: error: 'cost' was not declared in this scope; did you mean 'const'?
   24 |                 else { cout << cost;return 0;}
      |                                ^~~~
      |                                const
Language: C

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll diff(ll a,ll b)
{
	if(a>b) return a-b;
	else return b-a ;
}

int main()
{
	std::ios::sync_with_stdio(false);
	// int T;
	// cin>>T;
	// cin.ignore(); must be there when using getline(cin, s)
	// while(T--)
	// {
		ll n;
		std::cin >> n;
		std::vector<ll> a(n);
		ll ans[n]={0};
		for(ll i=0;i<n;i++) cin>>a[i];
		ans[0]=0;
		ans[1]=diff(a[1],a[0]);
		for(ll i=1;i<n;i++)
		{
			ans[i]=min(ans[i-2]+diff(a[i],a[i-2]),ans[i-1]+diff(a[i],a[i-1]));
		}
		cout<<ans[n-1]<<"\n";
	// }
	return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll diff(ll a,ll b)
{
	if(a>b) return a-b;
	else return b-a ;
}

int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	cin>>T;
	// cin.ignore(); must be there when using getline(cin, s)
	while(T--)
	{
		ll n;
		std::cin >> n;
		std::vector<ll> a(n);
		ll ans[n]={0};
		for(ll i=0;i<n;i++) cin>>a[i];
		ans[0]=0;
		ans[1]=diff(a[1],a[0]);
		for(ll i=1;i<n;i++)
		{
			ans[i]=min(ans[i-2]+diff(a[i],a[i-2]),ans[i-1]+diff(a[i],a[i-1]));
		}
		cout<<ans[n-1]<<"\n";
	}
	return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.Scanner;

public class Dp {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] h = new int[N];
        for(int i=0; i<N; i++) {
            h[i] = sc.nextInt();
        }

        int[] dp = new int[N];
        int x = 1;
        dp[x] = dp[x-1] + Math.abs(h[x] - h[x-1]);

        for(x=2; x<N; x++){
            dp[x] = Math.min(dp[x-1] + Math.abs(h[x] - h[x-1]), dp[x-2] + Math.abs(h[x] - h[x-2]));
        }

        System.out.println(dp[N-1]);
    }
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  vector<long long>ans(N);
  ans.at(0)=0;
  ans.at(1)=abs(h.at(1)-h.at(0));
  for(int i=2;i<N;i++){
    ans.at(i)=min(abs(h.at(i)-h.at(i-1))+ans.at(i-1),abs(h.at(i)-h.at(i-2))+ans.at(i-2));
  }
  cout<<ans.at(N-1)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'h' was not declared in this scope
   11 |   ans.at(1)=abs(h.at(1)-h.at(0));
      |                 ^
Language: C++

#include <iostream> 
#include <vector>

using namespace std; 

int main() {
  int n; 
  cin>>n; 
  int k; 
  cin>>k;
  int a[n]; 
  int i; 
  for(i=0;i<n;i++) { 
    cin>>a[i]; 
  } 
  if (n== 0) {
    cout<<0<<endl; 
    return 0;
  }
  else if (n == 1) { 
    cout<<a[0]<<endl;
    return 0;
  } 
  vector<int> dp(k,0);
  for (i=1;i<n;i++) { 
    dp[j] = dp[j-1] + abs(a[i] - a[i-1]); 
    for (int j=max(0, i-k); j<i;j++)
       dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i])); 
  }
  cout<<dp[n-1]<<endl;
  return 0;
  
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:26:8: error: 'j' was not declared in this scope
   26 |     dp[j] = dp[j-1] + abs(a[i] - a[i-1]);
      |        ^
Language: C++

#include <bits/stdc++.h> 

using namespace std; 

int main() {
  int n; 
  cin>>n; 
  int k; 
  cin>>k;
  int a[n]; 
  int i; 
  for(i=0;i<n;i++) { 
    cin>>a[i]; 
  } 
  if (n== 0) {
    cout<<0<<endl; 
    return 0;
  }
  else if (n == 1) { 
    cout<<a[0]<<endl;
    return 0;
  } 
  vector<int> dp(k,0);
  for (i=1;i<n;i++) { 
    dp[j] = dp[j-1] + abs(a[i] - a[i-1]); 
    for (int j=max(0, i-k); j<i;j++)
       dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i])); 
  }
  cout<<dp[n-1]<<endl;
  return 0;
  
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:25:8: error: 'j' was not declared in this scope
   25 |     dp[j] = dp[j-1] + abs(a[i] - a[i-1]);
      |        ^
Language: C++

#include<bits/stdc++.h>
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+1];
  dp[1]=0;
  dp[2]=abs(a[1]-a[0]);
  for(int i=3;i<=n;i++)
  	dp[i]=min((abs(a[i-1]-a[i-2])+dp[i-1]),(abs(a[i-1]-a[i-3])+dp[i-2]));
  cout<<dp[n]<<endl;

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'forint' was not declared in this scope; did you mean 'rint'?
    6 |         forint i =0i<n;++i) {
      |         ^~~~~~
      |         rint
a.cc:6:26: error: 'i' was not declared in this scope
    6 |         forint i =0i<n;++i) {
      |                          ^
Language: C++

#include<iostream>
#include<cmath>
const int N= 100005;
int h[N];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int start = n-1;
  int count = 0;
  while(start>0){
    // cout<<start<<endl;
    if(start==1){
      count+= abs(h[1]-h[0]);
      break;
    }
    if(abs(h[start]-h[start-1])>abs(h[start]-h[start-2]))
    {
      count+= abs(h[start]-h[start-2]);
      start = start-2;
    }
    else
    {
      count += abs(h[start]-h[start-1]);
      start =start-1;
    }
  }
  cout<<count;
}

Compiler output:
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:30:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   30 |   cout<<count;
      |   ^~~~
      |   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 <string>
#include <set>
#include <algorithm>
#include <bitset>

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


Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'd' was not declared in this scope
   22 |         cout << d[n];
      |                 ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <bitset>
int absl(int);
using namespace std;
int main(){
	int n;
	vector<int>v;
	vector<int>d;
	cin>>n;
	for(int i=1;i<n+1;++i){
		int t;
		cin>>t;
		v[i]=t;
		}
	d[1]=0;
	d[2]=d[1]+absl(v[1]-v[2]);
	for(int i=3;i<n;+1++i){
		d[i]=min((d[i-2]+absl(v[i-2]-v[i])),(d[i-1]+absl(v[i-1]-v[i])));
	}
	cout << d[n];
	return 0;
}
int absl(int a){
	if(a>0) return a;
	a=-a;
	return a;
	}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: lvalue required as increment operand
   21 |         for(int i=3;i<n;+1++i){
      |                          ^
a.cc:21:29: error: expected ')' before 'i'
   21 |         for(int i=3;i<n;+1++i){
      |            ~                ^
      |                             )
a.cc:21:30: error: expected ';' before ')' token
   21 |         for(int i=3;i<n;+1++i){
      |                              ^
      |                              ;
Language: C++

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

Compiler output:
a.cc:3:7: error: 'INF' does not name a type
    3 | const INF = 1e9 + 5;
      |       ^~~
a.cc: In function 'int main()':
a.cc:9:7: error: 'a' was not declared in this scope
    9 |       a.push_back(t);
      |       ^
a.cc:11:27: error: 'INF' was not declared in this scope
   11 |         vector<int> dp(n, INF);
      |                           ^~~
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 codingpractice;
import java.util.Scanner;
/**
 *
 * @author Lenovo
 */
public class AtCoder_Frog1 {
    public static void main(String[] args) {
         
        Scanner sc = new Scanner (System.in);
  int n= sc.nextInt();
  
  int[] arr = new int[n];
  
  for(int i=0;i<n;i++){
  arr[i]=sc.nextInt();
  }
  
  int k=0;
  int sum=0;
  while(k<n-1){
  
  if(k<n-2 && Math.abs(arr[k]-arr[k+2])< Math.abs(arr[k]-arr[k+1])+Math.abs(arr[k+1]-arr[k+2])){
    sum=sum+ Math.abs(arr[k]-arr[k+2]);
    k=k+2;
  }
  
    
  else{
    sum=sum+Math.abs(arr[k]-arr[k+1]);
      k=k+1;
    }
  }
  System.out.println(sum);
    
    } 
}
    


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

class AtCoder_Frog1 {
    public static void main(String[] args) {
         
        Scanner sc = new Scanner (System.in);
  int n= sc.nextInt();
  
  int[] arr = new int[n];
  
  for(int i=0;i<n;i++){
  arr[i]=sc.nextInt();
  }
  
  int k=0;
  int sum=0;
  while(k<n-1){
  
  if(k<n-2 && Math.abs(arr[k]-arr[k+2])< Math.abs(arr[k]-arr[k+1])+Math.abs(arr[k+1]-arr[k+2])){
    sum=sum+ Math.abs(arr[k]-arr[k+2]);
    k=k+2;
  }
  
    
  else{
    sum=sum+Math.abs(arr[k]-arr[k+1]);
      k=k+1;
    }
  }
  System.out.println(sum);
    
    } 
}


Compiler output:
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner (System.in);
        ^
  symbol:   class Scanner
  location: class AtCoder_Frog1
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner (System.in);
                         ^
  symbol:   class Scanner
  location: class AtCoder_Frog1
2 errors
Language: Java

public class AtCoder_Frog1 {
    public static void main(String[] args) {
         
        Scanner sc = new Scanner (System.in);
  int n= sc.nextInt();
  
  int[] arr = new int[n];
  
  for(int i=0;i<n;i++){
  arr[i]=sc.nextInt();
  }
  
  int k=0;
  int sum=0;
  while(k<n-1){
  
  if(k<n-2 && Math.abs(arr[k]-arr[k+2])< Math.abs(arr[k]-arr[k+1])+Math.abs(arr[k+1]-arr[k+2])){
    sum=sum+ Math.abs(arr[k]-arr[k+2]);
    k=k+2;
  }
  
    
  else{
    sum=sum+Math.abs(arr[k]-arr[k+1]);
      k=k+1;
    }
  }
  System.out.println(sum);
    
    } 
}
    


Compiler output:
Main.java:1: error: class AtCoder_Frog1 is public, should be declared in a file named AtCoder_Frog1.java
public class AtCoder_Frog1 {
       ^
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner (System.in);
        ^
  symbol:   class Scanner
  location: class AtCoder_Frog1
Main.java:4: error: cannot find symbol
        Scanner sc = new Scanner (System.in);
                         ^
  symbol:   class Scanner
  location: class AtCoder_Frog1
3 errors
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template<class T> inline bool change_min(T& a, T b) {
	if (a > b) {
    	a = b;
        return 1;
    } else {
    	return 0;
    }
}
 
const long H_MAX = 9999999999;
int n = 100001;
 
int N;
long long h[n];
 
long long dp[n];
 
int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];
 
    for (int i = 0; i < 100010; i++) {
    	dp[i] = H_MAX;
    }
 
    dp[0] = 0;
 
    for (int i = 1; i < N; ++i) {
        change_min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1){
        	change_min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
 
    cout << dp[N-1] << endl;
}

Compiler output:
a.cc:19:13: error: size of array 'h' is not an integral constant-expression
   19 | long long h[n];
      |             ^
a.cc:21:14: error: size of array 'dp' is not an integral constant-expression
   21 | long long dp[n];
      |              ^
Language: Java

import java.util.*;

public class Solution {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	}
}


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

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

template<class T> inline bool change_min(T& a, T b) {
	if (a > b) {
    	a = b;
        return 1;
    } elae {
    	return 0;
    }
}

const long H_MAX = 9999999999;
int n = 100001;

int N;
long long h[n];

long long dp[n];

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

    for (int i = 0; i < 100010; i++) {
    	dp[i] = H_MAX;
    }

    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        change_min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1){
        	change_min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }

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

Compiler output:
a.cc: In function 'bool change_min(T&, T)':
a.cc:10:7: error: 'elae' was not declared in this scope
   10 |     } elae {
      |       ^~~~
a.cc: At global scope:
a.cc:19:13: error: size of array 'h' is not an integral constant-expression
   19 | long long h[n];
      |             ^
a.cc:21:14: error: size of array 'dp' is not an integral constant-expression
   21 | long long dp[n];
      |              ^
a.cc: In function 'bool change_min(T&, T) [with T = long long int]':
a.cc:13:1: warning: control reaches end of non-void function [-Wreturn-type]
   13 | }
      | ^
Language: C++

//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;

using namespace std ;
bigint dp[100001] ;
bigint frogJump( bigint arr[] , int N ){
    if( N == 1 ){
        return 0 ;
    }
    if( dp[N] != -1 )
        return dp[N] ;
    bigint second = INT_MAX ;
    bigint first = frogJump(arr , N - 1 ) + abs( arr[N] - arr[N-1] ) ;
    if( N > 2 )
        second = frogJump(arr, N - 2 ) + abs( arr[N] - arr[N-2] ) ;
    return min( first , second ) ;
}
int main(){
    FAST();
    memset(dp, -1, sizeof(dp) ) ;
    int N ; cin >> N ;
    bigint arr[N+1] ;
    for( int i = 1 ; i <= N ; i++ ){
        cin >> arr[i] ;
    }
    cout << frogJump(arr, N) << endl ;
    return 0 ;
}



Compiler output:
a.cc: In function 'bigint frogJump(bigint*, int)':
a.cc:58:21: error: 'INT_MAX' was not declared in this scope
   58 |     bigint second = INT_MAX ;
      |                     ^~~~~~~
a.cc:40:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   39 | #include <utility>
  +++ |+#include <climits>
   40 | #include <vector>
Language: C++

#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int N;
  	cin>>N;
  	int cost[N], height[N];
  
  	for(int i=0; i<N; i++)
    {
		cin>>height[i];
      	if (i == 0)
          cost[i] = 0;
      	else
      	  cost[i] = INT_MAX;
    }
  
  	for (int i=0; i<N; i++)
    {
 		  if (i+1<N)
            cost[i+1] = min(cost[i+1], cost[i]+abs(cost[i] - cost[i+1]));
      	  if (i+2<N)
            cost[i+2] = min(cost[i+2], cost[i+1]+abs(cost[i] - cost[i+2]));
    }
    cout<<cost[N-1]<<endl;
 
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: 'INT_MAX' was not declared in this scope
   17 |           cost[i] = INT_MAX;
      |                     ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <math.h>
  +++ |+#include <climits>
    3 | using namespace std;
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Solution{
    public static void main(String args[]) {
        //  System.out.println("Hello World!");
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int[] ar=new int[n];
        for (int i=0;i<n;i++){
            ar[i]=in.nextInt();
        }
        int[] dp=new int[n];
        Arrays.fill(dp,-1);

        int ans=go(ar,0,dp);


        System.out.println(ans);
    }
    static int go(int[] ar,int i,int[] dp){
        if (i==ar.length-1){
            return 0;
        }
        if (dp[i]!=-1){
            return dp[i];
        }
        int jump1=Integer.MAX_VALUE,jump2=Integer.MAX_VALUE;
        if (i+1<ar.length){
            jump1=Math.abs(ar[i]-ar[i+1])+go(ar,i+1,dp);
        }
        if (i+2<ar.length){
            jump2=Math.abs(ar[i]-ar[i+2])+go(ar,i+2,dp);
        }
        return dp[i]=Math.min(jump1,jump2);
    }
}

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


import java.util.Scanner;

public class AtCoder_A {
   // public static int minSum;

    public static int minCostDp(int a[],int n){
        int dp[] = new int[n+1];
        dp[1] = 0;
        dp[2] = Math.abs(a[2]-a[1]);
        for(int i=3;i<=n;i++){
            dp[i] = Math.min(dp[i-1]+Math.abs(a[i]-a[i-1]),dp[i-2]+Math.abs(a[i]-a[i-2]));
        }
        return dp[n];
    }
    public static int minCostRecursive(int a[],int n,int i,int j,int minSum){
        if(j==n)
            return minSum+Math.abs(a[j]-a[i]);

        if(j>n)
            return Integer.MAX_VALUE;

        minSum = minSum+Math.abs(a[i]-a[j]);
        i=j;
        int ans1 = minCostRecursive(a,n,i,j+1,minSum);
        int ans2 = minCostRecursive(a,n,i,j+2,minSum);
        return Math.min(ans1,ans2);
    }
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n+1];
        for(int i=1;i<=n;i++){
            a[i] = sc.nextInt();
        }

        //System.out.println(minCostRecursive(a,n,1,1,0));
        System.out.println(minCostDp(a,n));

    }
}


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

#include <iostream>
#include <vector>
#define int long long
using namespace std;
int main()
{
  vector<int> v;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
      int a;
      cin>>a;
    v.push_back(a);
  }

  vector<int> b(n,INT_MAX);
  b[n-1]=0;
  for(int i=n-2;i>=0;i--)
  {
    if(i+1<n)
    {
      b[i]=min(b[i],(abs(v[i+1]-v[i])+b[i+1]));
    }
    if(i+2<n)
    {
      b[i]=min(b[i],(abs(v[i+2]-v[i])+b[i+2]));
    }
    
  }
  
    cout<<b[0];
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:17:19: error: 'INT_MAX' was not declared in this scope
   17 |   vector<int> b(n,INT_MAX);
      |                   ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 | #define int long long
Language: C++

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

int main(){
	int n;
  	cin>>n;
  	int a,b,c;
  	int v1[n],v2[n],v3[n];
  for(int i=0;i<n;i++){
  	cin>>v[i]>>v2[i]>>v3[i];
  	}
  a=v1[0];
  b=v2[0];
  c=v3[0];
  for(int i=1;i<n;i++){
  		int t1=a;int t2=b;int t3=c;
    	a=t1+v1[i]+max(t3,t2);
    b=t2+v2[i]+max(t1,t3);
    c=t3+v3[i]+max(t1,t2);
  }
  int ans=max(a,max(b,c));
  cout<<ans<<endl;

return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:14: error: 'v' was not declared in this scope
   10 |         cin>>v[i]>>v2[i]>>v3[i];
      |              ^
Language: C++

#include<iosstream>
#include<vector>
#define int longlong
using namespace std;
int main()
{
  int vector<int> v;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  { int a;
    v.push_back(cin>>a);
  }
  int vector<int> b(INT_MAX,n);
  b[n-1]=0;
  for(int i=n-2;i>=0;i--)
  {
    if(i+1<n)
    {
      b[i]=min(b[i],abs(v[i+1]-v[i])+b[i+1]);
    }
    if(i+2<n)
    {
      b[i]=min(b[i],abs(v[i+2]-v[i])+b[i+2]);
    }}
  cout<<b[0];
  return 0;}

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

#include<iostream>
#include<climits>
#include<cstring>
#define ll long long
using namespace std;
int h[ 100000 ];
ll sum[ 100000 ];
ll fun( int index, int size );
int main(){
    int N;
    cin >> N;
    for( int i = 0; i < N; i++ ){
        cin >> h[ i ];
    }
    memset( sum, -1, 100000 );
    ll answer = fun( 0, N );
    cout << answer << "\n";
    return 0;
}
ll fun( int index, int size ){
    if( index == size - 1 ){
        return 0;
    }
    if( index > N ){
        return INT_MAX;
    }
    if( sum[ index ] != -1 ){
        return sum[ index ];
    }
    ll left = abs( h[ index ] - h[ index + 1] ) + fun( index + 1, size );
    ll right = INT_MAX;
    if( index < size - 2 )
        right = abs( h[ index ] - h[ index + 2] ) + fun( index + 2, size );
    sum[ index ] = min( left, right );    
    return sum[ index ];
}

Compiler output:
a.cc: In function 'long long int fun(int, int)':
a.cc:24:17: error: 'N' was not declared in this scope
   24 |     if( index > N ){
      |                 ^
Language: C++

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

int main()
{
    int n;
    cin>>n;
    long long int arr[n];
    long long int dp[n];
    for(int i=0;i<n;i++)
    	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;
}

// Cost to reach the ith stoen is min(dp[i-1]+(arr[i]-arr[i-1]),dp[i-1]+(arr[i]-arr[i-2]))
// Base case is dp[0]=0 dp[1]=arr[0]-arr[1]

Compiler output:
a.cc: In function 'int main()':
a.cc:16:81: error: expected ';' before 'cout'
   16 |         dp[i]=min((dp[i-1]+abs(arr[i]-arr[i-1])),(dp[i-2]+abs(arr[i]-arr[i-2])))
      |                                                                                 ^
      |                                                                                 ;
   17 |     cout<<dp[n-1]<<endl;
      |     ~~~~
Language: C++

#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define mod 1000000009 
#define MAX 4294967296  // 2^32

using namespace std;

long long gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}


long long power(int x,int y){
if(y==0)return 1;
long long t=power(x,y/2);
if(y%2==1)return x*t*t;
return t*t;



}ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
 
// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
void solve(int &a[i],int &ans,int n){
  int b[n]={0};
  if(n==2){
  ans=s[1];
  return ;
  }
  if(n==1){
   
    return ;}
  a[1]=abs(a[0]-a[1]);
for(int i=2;i<n;i++){
b[i]=min((b[i-1]+abs(a[i]-a[i-1])),(b[i-2]+abs(a[i]-a[i-2])));


}
ans=b[n-1];
  return ;


}


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

Compiler output:
a.cc:49:19: error: 'i' was not declared in this scope
   49 | void solve(int &a[i],int &ans,int n){
      |                   ^
a.cc:49:21: error: expected ')' before ',' token
   49 | void solve(int &a[i],int &ans,int n){
      |           ~         ^
      |                     )
a.cc:49:22: error: expected unqualified-id before 'int'
   49 | void solve(int &a[i],int &ans,int n){
      |                      ^~~
Language: Java

import java.util.Scanner;
import java.util.*;
public class contest1 {
	
	
	
	public static int Frog1(int n, int h[]) {
		int dp[] = new int[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[1]-h[0]);
		
		for(int i=2;i<n;i++) {
			int op1 = Math.abs(h[i] - h[i-1]) + dp[i-1];
			int op2 = Math.abs(h[i] - h[i-2]) + dp[i-2];
			dp[i] = Math.min(op1, op2);
		}
		
		return dp[n-1];
	}
    
    public static void main(String[] arg) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int h[] = new int[n];
        for(int i=0;i<n;i++) {
        	h[i] = s.nextInt();
        }
        System.out.println(Frog1(n,h));
    }
}

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

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

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    scanf("%d", &n);

    vector<int> costs(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &costs[i]);
    }

    vector<int> dp(n + 1, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j : {i + 1, i + 2}) {
            dp[j] = min({dp[j], dp[i] + abs(costs[i] - costs[j])});
        }
    }

    printf("%d", dp[n - 1]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'ios_base' has not been declared
    4 |     ios_base::sync_with_stdio(0);
      |     ^~~~~~~~
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin.tie(0);
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:8:5: error: 'scanf' was not declared in this scope
    8 |     scanf("%d", &n);
      |     ^~~~~
a.cc:10:5: error: 'vector' was not declared in this scope
   10 |     vector<int> costs(n);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:10:12: error: expected primary-expression before 'int'
   10 |     vector<int> costs(n);
      |            ^~~
a.cc:12:22: error: 'costs' was not declared in this scope
   12 |         scanf("%d", &costs[i]);
      |                      ^~~~~
a.cc:15:12: error: expected primary-expression before 'int'
   15 |     vector<int> dp(n + 1, INT_MAX);
      |            ^~~
a.cc:16:5: error: 'dp' was not declared in this scope
   16 |     dp[0] = 0;
      |     ^~
a.cc:18:35: error: deducing from brace-enclosed initializer list requires '#include <initializer_list>'
  +++ |+#include <initializer_list>
    1 | using namespace std;
......
   18 |         for (int j : {i + 1, i + 2}) {
      |                                   ^
a.cc:19:45: error: 'costs' was not declared in this scope
   19 |             dp[j] = min({dp[j], dp[i] + abs(costs[i] - costs[j])});
      |                                             ^~~~~
a.cc:19:41: error: 'abs' was not declared in this scope
   19 |             dp[j] = min({dp[j], dp[i] + abs(costs[i] - costs[j])});
      |                                         ^~~
a.cc:19:21: error: 'min' was not declared in this scope; did you mean 'main'?
   19 |             dp[j] = min({dp[j], dp[i] + abs(costs[i] - costs[j])});
      |                     ^~~
      |                     main
a.cc:23:5: error: 'printf' was not declared in this scope
   23 |     printf("%d", dp[n - 1]);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
int fun(int *height,int *dp,int n)
{
    if(n==0)
    {
        return 0;
    }
    if(dp[n]!=0)
    {
        return dp[n];
    }

     int excl=abs(height[n-1]-height[n])+dp[n]+fun(height,dp,n-1);
     int include=abs(height[n-2]-height[n])+dp[n]+fun(height,dp,n-2);
    return dp[n]=min(excl,include);


}
int main() {
    int n;
    cin>>n;
    int height[100];
    for(int i=0;i<n;i++)
    {
        cin>>height[i];
    }
    int dp[100];
    memset(dp,0,sizeof(dp));
    cout<<fun(height,dp,n-1);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'memset' was not declared in this scope
   29 |     memset(dp,0,sizeof(dp));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
int fun(int *height,int *dp,int n)
{
    if(n==0)
    {
        return 0;
    }
    if(dp[n]!=0)
    {
        return dp[n];
    }

     int excl=abs(height[n-1]-height[n])+dp[n]+fun(height,dp,n-1);
     int include=abs(height[n-2]-height[n])+dp[n]+fun(height,dp,n-2);
    return dp[n]=min(excl,include);


}
int main() {
    int n,k;
    cin>>n;
    int height[100];
    for(int i=0;i<n;i++)
    {
        cin>>height[i];
    }
    int dp[100];
    memset(dp,0,sizeof(dp));
    cout<<fun(height,dp,n-1);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'memset' was not declared in this scope
   29 |     memset(dp,0,sizeof(dp));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

#include <iostream>
using namespace std;
int fun(int *height,int *dp,int n)
{
    if(n==0)
    {
        return 0;
    }
    if(dp[n]!=0)
    {
        return dp[n];
    }

     int excl=abs(height[n-1]-height[n])+dp[n]+fun(height,dp,n-1);
     int include=abs(height[n-2]-height[n])+dp[n]+fun(height,dp,n-2);
    return dp[n]=min(excl,include);


}
int main() {
    int n,k;
    cin>>n>>k;
    int height[100];
    for(int i=0;i<n;i++)
    {
        cin>>height[i];
    }
    int dp[100];
    memset(dp,0,sizeof(dp));
    cout<<fun(height,dp,n-1);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'memset' was not declared in this scope
   29 |     memset(dp,0,sizeof(dp));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C++

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:17:70: error: expected ')' before ';' token
   17 |     cost[i]=min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]);
      |                ~                                                     ^
      |                                                                      )
a.cc:20:17: error: expected '}' at end of input
   20 |        return 0;
      |                 ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define loop(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main()
{ll n,i,prev=0;
  cin>>n;
  loop(i,0,n)
  {
    ll a;
    cin>>a;
    if(i && prev<a)
      ans+=a-prev;
    prev=a;}
 cout<<prev<<endl;
 return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |       ans+=a-prev;
      |       ^~~
      |       abs
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin>>n;
      |         ^~~
a.cc:4:9: error: 'vector' was not declared in this scope
    4 |         vector <int> h(n),dp(n,INT_MAX);
      |         ^~~~~~
a.cc:4:17: error: expected primary-expression before 'int'
    4 |         vector <int> h(n),dp(n,INT_MAX);
      |                 ^~~
a.cc:5:35: error: 'h' was not declared in this scope
    5 |         for(int i=0;i<n;i++) cin>>h[i];
      |                                   ^
a.cc:6:9: error: 'dp' was not declared in this scope
    6 |         dp[0]=0;
      |         ^~
a.cc:7:19: error: 'h' was not declared in this scope
    7 |         dp[1]=abs(h[1]-h[0]);
      |                   ^
a.cc:7:15: error: 'abs' was not declared in this scope
    7 |         dp[1]=abs(h[1]-h[0]);
      |               ^~~
a.cc:8:15: error: 'min' was not declared in this scope; did you mean 'main'?
    8 |         dp[2]=min(abs(h[2]-h[0]),dp[1]+abs(h[2]-h[1]));
      |               ^~~
      |               main
a.cc:13:9: error: 'cout' was not declared in this scope
   13 |         cout<<dp[n-1];
      |         ^~~~
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];
  
  int dp[n];
  memset(dp,0,sizeof(dp));
  dp[0]=arr[0];
  dp[1]=abs(arr[1]-arr[0]);
  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;
}

Compiler output:
a.cc:1:9: fatal error: bits.stdc++.h: No such file or directory
    1 | #include<bits.stdc++.h>
      |         ^~~~~~~~~~~~~~~
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];
  
  int dp[n];
  memset(dp,0,sizeof(dp));
  dp[0]=arr[0];
  dp[1]=abs(arr[1]-arr[0]);
  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]<<endl;
}

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

import java.util.*;

public class atcoder {
	public static void main(String args[]) {
		Scanner input  = new Scanner(System.in);
		int n = input.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++) {
			arr[i] = input.nextInt();
		}
		System.out.println(func(n,arr));
	}
	static int func(int n,int arr[]) {
		int dp[] = new int[n];
		for(int i=0;i<n;i++) {
			int ans = 0;
			if(i-1>=0) {
				ans = Math.abs(arr[i]-arr[i-1]);
			}
			if(i-2>=0) {
				ans = Math.min(ans, Math.abs(arr[i]-arr[i-2]));
			}
			dp[i] = ans;
		}
		return dp[n-1];
	}
}


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

import java.util.Scanner;

public class frog1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
       Scanner scn=new Scanner(System.in);
       int n=scn.nextInt();
       int[] arr=new int[n];
       for(int i=0;i<n;i++){
    	   arr[i]=scn.nextInt();
       }
       int[] dp=new int[n];
       dp[0]=0;
       for(int i=1;i<n;i++){
    	   int option1=Math.abs(arr[i]-arr[i-1])+dp[i-1];
    	   int option2;
    	   if(i==1){
    		   option2=Integer.MAX_VALUE;
    	   }
    	   else{
    	    option2=Math.abs(arr[i]-arr[i-2])+dp[i-2];
    	   }
    	   dp[i]=Math.min(option1, option2);
       }
       System.out.println(dp[n-1]);
	}

}


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